1d5c65159SKalle Valo // SPDX-License-Identifier: BSD-3-Clause-Clear 2d5c65159SKalle Valo /* 3d5c65159SKalle Valo * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved. 4d5c65159SKalle Valo */ 5d5c65159SKalle Valo #include <linux/skbuff.h> 6d5c65159SKalle Valo #include <linux/ctype.h> 7d5c65159SKalle Valo #include <net/mac80211.h> 8d5c65159SKalle Valo #include <net/cfg80211.h> 9d5c65159SKalle Valo #include <linux/completion.h> 10d5c65159SKalle Valo #include <linux/if_ether.h> 11d5c65159SKalle Valo #include <linux/types.h> 12d5c65159SKalle Valo #include <linux/pci.h> 13d5c65159SKalle Valo #include <linux/uuid.h> 14d5c65159SKalle Valo #include <linux/time.h> 15d5c65159SKalle Valo #include <linux/of.h> 16d5c65159SKalle Valo #include "core.h" 17d5c65159SKalle Valo #include "debug.h" 18d5c65159SKalle Valo #include "mac.h" 19d5c65159SKalle Valo #include "hw.h" 20d5c65159SKalle Valo #include "peer.h" 21d5c65159SKalle Valo 22d5c65159SKalle Valo struct wmi_tlv_policy { 23d5c65159SKalle Valo size_t min_len; 24d5c65159SKalle Valo }; 25d5c65159SKalle Valo 26d5c65159SKalle Valo struct wmi_tlv_svc_ready_parse { 27d5c65159SKalle Valo bool wmi_svc_bitmap_done; 28d5c65159SKalle Valo }; 29d5c65159SKalle Valo 30bd647855SKarthikeyan Periyasamy struct wmi_tlv_dma_ring_caps_parse { 31bd647855SKarthikeyan Periyasamy struct wmi_dma_ring_capabilities *dma_ring_caps; 32bd647855SKarthikeyan Periyasamy u32 n_dma_ring_caps; 33bd647855SKarthikeyan Periyasamy }; 34bd647855SKarthikeyan Periyasamy 35d5c65159SKalle Valo struct wmi_tlv_svc_rdy_ext_parse { 36d5c65159SKalle Valo struct ath11k_service_ext_param param; 37d5c65159SKalle Valo struct wmi_soc_mac_phy_hw_mode_caps *hw_caps; 38d5c65159SKalle Valo struct wmi_hw_mode_capabilities *hw_mode_caps; 39d5c65159SKalle Valo u32 n_hw_mode_caps; 40d5c65159SKalle Valo u32 tot_phy_id; 41d5c65159SKalle Valo struct wmi_hw_mode_capabilities pref_hw_mode_caps; 42d5c65159SKalle Valo struct wmi_mac_phy_capabilities *mac_phy_caps; 43d5c65159SKalle Valo u32 n_mac_phy_caps; 44d5c65159SKalle Valo struct wmi_soc_hal_reg_capabilities *soc_hal_reg_caps; 45d5c65159SKalle Valo struct wmi_hal_reg_capabilities_ext *ext_hal_reg_caps; 46d5c65159SKalle Valo u32 n_ext_hal_reg_caps; 47bd647855SKarthikeyan Periyasamy struct wmi_tlv_dma_ring_caps_parse dma_caps_parse; 48d5c65159SKalle Valo bool hw_mode_done; 49d5c65159SKalle Valo bool mac_phy_done; 50d5c65159SKalle Valo bool ext_hal_reg_done; 51bd647855SKarthikeyan Periyasamy bool mac_phy_chainmask_combo_done; 52bd647855SKarthikeyan Periyasamy bool mac_phy_chainmask_cap_done; 53bd647855SKarthikeyan Periyasamy bool oem_dma_ring_cap_done; 54bd647855SKarthikeyan Periyasamy bool dma_ring_cap_done; 55bd647855SKarthikeyan Periyasamy }; 56bd647855SKarthikeyan Periyasamy 57bd647855SKarthikeyan Periyasamy struct wmi_tlv_svc_rdy_ext2_parse { 58bd647855SKarthikeyan Periyasamy struct wmi_tlv_dma_ring_caps_parse dma_caps_parse; 59bd647855SKarthikeyan Periyasamy bool dma_ring_cap_done; 60d5c65159SKalle Valo }; 61d5c65159SKalle Valo 62d5c65159SKalle Valo struct wmi_tlv_rdy_parse { 63d5c65159SKalle Valo u32 num_extra_mac_addr; 64d5c65159SKalle Valo }; 65d5c65159SKalle Valo 669d11b7bfSKarthikeyan Periyasamy struct wmi_tlv_dma_buf_release_parse { 679d11b7bfSKarthikeyan Periyasamy struct ath11k_wmi_dma_buf_release_fixed_param fixed; 689d11b7bfSKarthikeyan Periyasamy struct wmi_dma_buf_release_entry *buf_entry; 699d11b7bfSKarthikeyan Periyasamy struct wmi_dma_buf_release_meta_data *meta_data; 709d11b7bfSKarthikeyan Periyasamy u32 num_buf_entry; 719d11b7bfSKarthikeyan Periyasamy u32 num_meta; 729d11b7bfSKarthikeyan Periyasamy bool buf_entry_done; 739d11b7bfSKarthikeyan Periyasamy bool meta_data_done; 749d11b7bfSKarthikeyan Periyasamy }; 759d11b7bfSKarthikeyan Periyasamy 76d5c65159SKalle Valo static const struct wmi_tlv_policy wmi_tlv_policies[] = { 77d5c65159SKalle Valo [WMI_TAG_ARRAY_BYTE] 78d5c65159SKalle Valo = { .min_len = 0 }, 79d5c65159SKalle Valo [WMI_TAG_ARRAY_UINT32] 80d5c65159SKalle Valo = { .min_len = 0 }, 81d5c65159SKalle Valo [WMI_TAG_SERVICE_READY_EVENT] 82d5c65159SKalle Valo = { .min_len = sizeof(struct wmi_service_ready_event) }, 83d5c65159SKalle Valo [WMI_TAG_SERVICE_READY_EXT_EVENT] 84d5c65159SKalle Valo = { .min_len = sizeof(struct wmi_service_ready_ext_event) }, 85d5c65159SKalle Valo [WMI_TAG_SOC_MAC_PHY_HW_MODE_CAPS] 86d5c65159SKalle Valo = { .min_len = sizeof(struct wmi_soc_mac_phy_hw_mode_caps) }, 87d5c65159SKalle Valo [WMI_TAG_SOC_HAL_REG_CAPABILITIES] 88d5c65159SKalle Valo = { .min_len = sizeof(struct wmi_soc_hal_reg_capabilities) }, 89d5c65159SKalle Valo [WMI_TAG_VDEV_START_RESPONSE_EVENT] 90d5c65159SKalle Valo = { .min_len = sizeof(struct wmi_vdev_start_resp_event) }, 91d5c65159SKalle Valo [WMI_TAG_PEER_DELETE_RESP_EVENT] 92d5c65159SKalle Valo = { .min_len = sizeof(struct wmi_peer_delete_resp_event) }, 93d5c65159SKalle Valo [WMI_TAG_OFFLOAD_BCN_TX_STATUS_EVENT] 94d5c65159SKalle Valo = { .min_len = sizeof(struct wmi_bcn_tx_status_event) }, 95d5c65159SKalle Valo [WMI_TAG_VDEV_STOPPED_EVENT] 96d5c65159SKalle Valo = { .min_len = sizeof(struct wmi_vdev_stopped_event) }, 97d5c65159SKalle Valo [WMI_TAG_REG_CHAN_LIST_CC_EVENT] 98d5c65159SKalle Valo = { .min_len = sizeof(struct wmi_reg_chan_list_cc_event) }, 99d5c65159SKalle Valo [WMI_TAG_MGMT_RX_HDR] 100d5c65159SKalle Valo = { .min_len = sizeof(struct wmi_mgmt_rx_hdr) }, 101d5c65159SKalle Valo [WMI_TAG_MGMT_TX_COMPL_EVENT] 102d5c65159SKalle Valo = { .min_len = sizeof(struct wmi_mgmt_tx_compl_event) }, 103d5c65159SKalle Valo [WMI_TAG_SCAN_EVENT] 104d5c65159SKalle Valo = { .min_len = sizeof(struct wmi_scan_event) }, 105d5c65159SKalle Valo [WMI_TAG_PEER_STA_KICKOUT_EVENT] 106d5c65159SKalle Valo = { .min_len = sizeof(struct wmi_peer_sta_kickout_event) }, 107d5c65159SKalle Valo [WMI_TAG_ROAM_EVENT] 108d5c65159SKalle Valo = { .min_len = sizeof(struct wmi_roam_event) }, 109d5c65159SKalle Valo [WMI_TAG_CHAN_INFO_EVENT] 110d5c65159SKalle Valo = { .min_len = sizeof(struct wmi_chan_info_event) }, 111d5c65159SKalle Valo [WMI_TAG_PDEV_BSS_CHAN_INFO_EVENT] 112d5c65159SKalle Valo = { .min_len = sizeof(struct wmi_pdev_bss_chan_info_event) }, 113d5c65159SKalle Valo [WMI_TAG_VDEV_INSTALL_KEY_COMPLETE_EVENT] 114d5c65159SKalle Valo = { .min_len = sizeof(struct wmi_vdev_install_key_compl_event) }, 11521c1b063SMaharaja Kennadyrajan [WMI_TAG_READY_EVENT] = { 11621c1b063SMaharaja Kennadyrajan .min_len = sizeof(struct wmi_ready_event_min) }, 117d5c65159SKalle Valo [WMI_TAG_SERVICE_AVAILABLE_EVENT] 118d5c65159SKalle Valo = {.min_len = sizeof(struct wmi_service_available_event) }, 119d5c65159SKalle Valo [WMI_TAG_PEER_ASSOC_CONF_EVENT] 120d5c65159SKalle Valo = { .min_len = sizeof(struct wmi_peer_assoc_conf_event) }, 121d5c65159SKalle Valo [WMI_TAG_STATS_EVENT] 122d5c65159SKalle Valo = { .min_len = sizeof(struct wmi_stats_event) }, 123d5c65159SKalle Valo [WMI_TAG_PDEV_CTL_FAILSAFE_CHECK_EVENT] 124d5c65159SKalle Valo = { .min_len = sizeof(struct wmi_pdev_ctl_failsafe_chk_event) }, 125047679e3SAloka Dixit [WMI_TAG_HOST_SWFDA_EVENT] = { 126047679e3SAloka Dixit .min_len = sizeof(struct wmi_fils_discovery_event) }, 127047679e3SAloka Dixit [WMI_TAG_OFFLOAD_PRB_RSP_TX_STATUS_EVENT] = { 128047679e3SAloka Dixit .min_len = sizeof(struct wmi_probe_resp_tx_status_event) }, 1293cbbdfbeSRitesh Singh [WMI_TAG_VDEV_DELETE_RESP_EVENT] = { 1303cbbdfbeSRitesh Singh .min_len = sizeof(struct wmi_vdev_delete_resp_event) }, 131886433a9SJohn Crispin [WMI_TAG_OBSS_COLOR_COLLISION_EVT] = { 132886433a9SJohn Crispin .min_len = sizeof(struct wmi_obss_color_collision_event) }, 133d5c65159SKalle Valo }; 134d5c65159SKalle Valo 135d5c65159SKalle Valo #define PRIMAP(_hw_mode_) \ 136d5c65159SKalle Valo [_hw_mode_] = _hw_mode_##_PRI 137d5c65159SKalle Valo 138d5c65159SKalle Valo static const int ath11k_hw_mode_pri_map[] = { 139d5c65159SKalle Valo PRIMAP(WMI_HOST_HW_MODE_SINGLE), 140d5c65159SKalle Valo PRIMAP(WMI_HOST_HW_MODE_DBS), 141d5c65159SKalle Valo PRIMAP(WMI_HOST_HW_MODE_SBS_PASSIVE), 142d5c65159SKalle Valo PRIMAP(WMI_HOST_HW_MODE_SBS), 143d5c65159SKalle Valo PRIMAP(WMI_HOST_HW_MODE_DBS_SBS), 144d5c65159SKalle Valo PRIMAP(WMI_HOST_HW_MODE_DBS_OR_SBS), 145d5c65159SKalle Valo /* keep last */ 146d5c65159SKalle Valo PRIMAP(WMI_HOST_HW_MODE_MAX), 147d5c65159SKalle Valo }; 148d5c65159SKalle Valo 149d5c65159SKalle Valo static int 150d5c65159SKalle Valo ath11k_wmi_tlv_iter(struct ath11k_base *ab, const void *ptr, size_t len, 151d5c65159SKalle Valo int (*iter)(struct ath11k_base *ab, u16 tag, u16 len, 152d5c65159SKalle Valo const void *ptr, void *data), 153d5c65159SKalle Valo void *data) 154d5c65159SKalle Valo { 155d5c65159SKalle Valo const void *begin = ptr; 156d5c65159SKalle Valo const struct wmi_tlv *tlv; 157d5c65159SKalle Valo u16 tlv_tag, tlv_len; 158d5c65159SKalle Valo int ret; 159d5c65159SKalle Valo 160d5c65159SKalle Valo while (len > 0) { 161d5c65159SKalle Valo if (len < sizeof(*tlv)) { 162d5c65159SKalle Valo ath11k_err(ab, "wmi tlv parse failure at byte %zd (%zu bytes left, %zu expected)\n", 163d5c65159SKalle Valo ptr - begin, len, sizeof(*tlv)); 164d5c65159SKalle Valo return -EINVAL; 165d5c65159SKalle Valo } 166d5c65159SKalle Valo 167d5c65159SKalle Valo tlv = ptr; 168d5c65159SKalle Valo tlv_tag = FIELD_GET(WMI_TLV_TAG, tlv->header); 169d5c65159SKalle Valo tlv_len = FIELD_GET(WMI_TLV_LEN, tlv->header); 170d5c65159SKalle Valo ptr += sizeof(*tlv); 171d5c65159SKalle Valo len -= sizeof(*tlv); 172d5c65159SKalle Valo 173d5c65159SKalle Valo if (tlv_len > len) { 174bb2d2dfdSTom Rix ath11k_err(ab, "wmi tlv parse failure of tag %u at byte %zd (%zu bytes left, %u expected)\n", 175d5c65159SKalle Valo tlv_tag, ptr - begin, len, tlv_len); 176d5c65159SKalle Valo return -EINVAL; 177d5c65159SKalle Valo } 178d5c65159SKalle Valo 179d5c65159SKalle Valo if (tlv_tag < ARRAY_SIZE(wmi_tlv_policies) && 180d5c65159SKalle Valo wmi_tlv_policies[tlv_tag].min_len && 181d5c65159SKalle Valo wmi_tlv_policies[tlv_tag].min_len > tlv_len) { 182bb2d2dfdSTom Rix ath11k_err(ab, "wmi tlv parse failure of tag %u at byte %zd (%u bytes is less than min length %zu)\n", 183d5c65159SKalle Valo tlv_tag, ptr - begin, tlv_len, 184d5c65159SKalle Valo wmi_tlv_policies[tlv_tag].min_len); 185d5c65159SKalle Valo return -EINVAL; 186d5c65159SKalle Valo } 187d5c65159SKalle Valo 188d5c65159SKalle Valo ret = iter(ab, tlv_tag, tlv_len, ptr, data); 189d5c65159SKalle Valo if (ret) 190d5c65159SKalle Valo return ret; 191d5c65159SKalle Valo 192d5c65159SKalle Valo ptr += tlv_len; 193d5c65159SKalle Valo len -= tlv_len; 194d5c65159SKalle Valo } 195d5c65159SKalle Valo 196d5c65159SKalle Valo return 0; 197d5c65159SKalle Valo } 198d5c65159SKalle Valo 199d5c65159SKalle Valo static int ath11k_wmi_tlv_iter_parse(struct ath11k_base *ab, u16 tag, u16 len, 200d5c65159SKalle Valo const void *ptr, void *data) 201d5c65159SKalle Valo { 202d5c65159SKalle Valo const void **tb = data; 203d5c65159SKalle Valo 204d5c65159SKalle Valo if (tag < WMI_TAG_MAX) 205d5c65159SKalle Valo tb[tag] = ptr; 206d5c65159SKalle Valo 207d5c65159SKalle Valo return 0; 208d5c65159SKalle Valo } 209d5c65159SKalle Valo 210d5c65159SKalle Valo static int ath11k_wmi_tlv_parse(struct ath11k_base *ar, const void **tb, 211d5c65159SKalle Valo const void *ptr, size_t len) 212d5c65159SKalle Valo { 213d5c65159SKalle Valo return ath11k_wmi_tlv_iter(ar, ptr, len, ath11k_wmi_tlv_iter_parse, 214d5c65159SKalle Valo (void *)tb); 215d5c65159SKalle Valo } 216d5c65159SKalle Valo 217d5c65159SKalle Valo static const void ** 218d5c65159SKalle Valo ath11k_wmi_tlv_parse_alloc(struct ath11k_base *ab, const void *ptr, 219d5c65159SKalle Valo size_t len, gfp_t gfp) 220d5c65159SKalle Valo { 221d5c65159SKalle Valo const void **tb; 222d5c65159SKalle Valo int ret; 223d5c65159SKalle Valo 224d5c65159SKalle Valo tb = kcalloc(WMI_TAG_MAX, sizeof(*tb), gfp); 225d5c65159SKalle Valo if (!tb) 226d5c65159SKalle Valo return ERR_PTR(-ENOMEM); 227d5c65159SKalle Valo 228d5c65159SKalle Valo ret = ath11k_wmi_tlv_parse(ab, tb, ptr, len); 229d5c65159SKalle Valo if (ret) { 230d5c65159SKalle Valo kfree(tb); 231d5c65159SKalle Valo return ERR_PTR(ret); 232d5c65159SKalle Valo } 233d5c65159SKalle Valo 234d5c65159SKalle Valo return tb; 235d5c65159SKalle Valo } 236d5c65159SKalle Valo 237d5c65159SKalle Valo static int ath11k_wmi_cmd_send_nowait(struct ath11k_pdev_wmi *wmi, struct sk_buff *skb, 238d5c65159SKalle Valo u32 cmd_id) 239d5c65159SKalle Valo { 240d5c65159SKalle Valo struct ath11k_skb_cb *skb_cb = ATH11K_SKB_CB(skb); 2416bc9d6f7SJohn Crispin struct ath11k_base *ab = wmi->wmi_ab->ab; 242d5c65159SKalle Valo struct wmi_cmd_hdr *cmd_hdr; 243d5c65159SKalle Valo int ret; 244d5c65159SKalle Valo u32 cmd = 0; 245d5c65159SKalle Valo 246d5c65159SKalle Valo if (skb_push(skb, sizeof(struct wmi_cmd_hdr)) == NULL) 247d5c65159SKalle Valo return -ENOMEM; 248d5c65159SKalle Valo 249d5c65159SKalle Valo cmd |= FIELD_PREP(WMI_CMD_HDR_CMD_ID, cmd_id); 250d5c65159SKalle Valo 251d5c65159SKalle Valo cmd_hdr = (struct wmi_cmd_hdr *)skb->data; 252d5c65159SKalle Valo cmd_hdr->cmd_id = cmd; 253d5c65159SKalle Valo 254fb12305aSVenkateswara Naralasetty trace_ath11k_wmi_cmd(ab, cmd_id, skb->data, skb->len); 255fb12305aSVenkateswara Naralasetty 256d5c65159SKalle Valo memset(skb_cb, 0, sizeof(*skb_cb)); 257d5c65159SKalle Valo ret = ath11k_htc_send(&ab->htc, wmi->eid, skb); 258d5c65159SKalle Valo 259d5c65159SKalle Valo if (ret) 260d5c65159SKalle Valo goto err_pull; 261d5c65159SKalle Valo 262d5c65159SKalle Valo return 0; 263d5c65159SKalle Valo 264d5c65159SKalle Valo err_pull: 265d5c65159SKalle Valo skb_pull(skb, sizeof(struct wmi_cmd_hdr)); 266d5c65159SKalle Valo return ret; 267d5c65159SKalle Valo } 268d5c65159SKalle Valo 269d5c65159SKalle Valo int ath11k_wmi_cmd_send(struct ath11k_pdev_wmi *wmi, struct sk_buff *skb, 270d5c65159SKalle Valo u32 cmd_id) 271d5c65159SKalle Valo { 2726bc9d6f7SJohn Crispin struct ath11k_wmi_base *wmi_sc = wmi->wmi_ab; 273d5c65159SKalle Valo int ret = -EOPNOTSUPP; 274f951380aSP Praneesh struct ath11k_base *ab = wmi_sc->ab; 275d5c65159SKalle Valo 276d5c65159SKalle Valo might_sleep(); 277d5c65159SKalle Valo 278f951380aSP Praneesh if (ab->hw_params.credit_flow) { 279d5c65159SKalle Valo wait_event_timeout(wmi_sc->tx_credits_wq, ({ 280d5c65159SKalle Valo ret = ath11k_wmi_cmd_send_nowait(wmi, skb, cmd_id); 281d5c65159SKalle Valo 282f951380aSP Praneesh if (ret && test_bit(ATH11K_FLAG_CRASH_FLUSH, 283f951380aSP Praneesh &wmi_sc->ab->dev_flags)) 284d5c65159SKalle Valo ret = -ESHUTDOWN; 285d5c65159SKalle Valo 286d5c65159SKalle Valo (ret != -EAGAIN); 287d5c65159SKalle Valo }), WMI_SEND_TIMEOUT_HZ); 288f951380aSP Praneesh } else { 289f951380aSP Praneesh wait_event_timeout(wmi->tx_ce_desc_wq, ({ 290f951380aSP Praneesh ret = ath11k_wmi_cmd_send_nowait(wmi, skb, cmd_id); 291f951380aSP Praneesh 292f951380aSP Praneesh if (ret && test_bit(ATH11K_FLAG_CRASH_FLUSH, 293f951380aSP Praneesh &wmi_sc->ab->dev_flags)) 294f951380aSP Praneesh ret = -ESHUTDOWN; 295f951380aSP Praneesh 296f951380aSP Praneesh (ret != -ENOBUFS); 297f951380aSP Praneesh }), WMI_SEND_TIMEOUT_HZ); 298f951380aSP Praneesh } 299d5c65159SKalle Valo 300d5c65159SKalle Valo if (ret == -EAGAIN) 301d5c65159SKalle Valo ath11k_warn(wmi_sc->ab, "wmi command %d timeout\n", cmd_id); 302d5c65159SKalle Valo 303f951380aSP Praneesh if (ret == -ENOBUFS) 304f951380aSP Praneesh ath11k_warn(wmi_sc->ab, "ce desc not available for wmi command %d\n", 305f951380aSP Praneesh cmd_id); 306f951380aSP Praneesh 307d5c65159SKalle Valo return ret; 308d5c65159SKalle Valo } 309d5c65159SKalle Valo 310d5c65159SKalle Valo static int ath11k_pull_svc_ready_ext(struct ath11k_pdev_wmi *wmi_handle, 311d5c65159SKalle Valo const void *ptr, 312d5c65159SKalle Valo struct ath11k_service_ext_param *param) 313d5c65159SKalle Valo { 314d5c65159SKalle Valo const struct wmi_service_ready_ext_event *ev = ptr; 315d5c65159SKalle Valo 316d5c65159SKalle Valo if (!ev) 317d5c65159SKalle Valo return -EINVAL; 318d5c65159SKalle Valo 319d5c65159SKalle Valo /* Move this to host based bitmap */ 320d5c65159SKalle Valo param->default_conc_scan_config_bits = ev->default_conc_scan_config_bits; 321d5c65159SKalle Valo param->default_fw_config_bits = ev->default_fw_config_bits; 322d5c65159SKalle Valo param->he_cap_info = ev->he_cap_info; 323d5c65159SKalle Valo param->mpdu_density = ev->mpdu_density; 324d5c65159SKalle Valo param->max_bssid_rx_filters = ev->max_bssid_rx_filters; 325d5c65159SKalle Valo memcpy(¶m->ppet, &ev->ppet, sizeof(param->ppet)); 326d5c65159SKalle Valo 327d5c65159SKalle Valo return 0; 328d5c65159SKalle Valo } 329d5c65159SKalle Valo 330d5c65159SKalle Valo static int 331d5c65159SKalle Valo ath11k_pull_mac_phy_cap_svc_ready_ext(struct ath11k_pdev_wmi *wmi_handle, 332d5c65159SKalle Valo struct wmi_soc_mac_phy_hw_mode_caps *hw_caps, 333d5c65159SKalle Valo struct wmi_hw_mode_capabilities *wmi_hw_mode_caps, 334d5c65159SKalle Valo struct wmi_soc_hal_reg_capabilities *hal_reg_caps, 335d5c65159SKalle Valo struct wmi_mac_phy_capabilities *wmi_mac_phy_caps, 336d5c65159SKalle Valo u8 hw_mode_id, u8 phy_id, 337d5c65159SKalle Valo struct ath11k_pdev *pdev) 338d5c65159SKalle Valo { 339d5c65159SKalle Valo struct wmi_mac_phy_capabilities *mac_phy_caps; 340d5c65159SKalle Valo struct ath11k_band_cap *cap_band; 341d5c65159SKalle Valo struct ath11k_pdev_cap *pdev_cap = &pdev->cap; 342d5c65159SKalle Valo u32 phy_map; 343d5c65159SKalle Valo u32 hw_idx, phy_idx = 0; 344d5c65159SKalle Valo 345d5c65159SKalle Valo if (!hw_caps || !wmi_hw_mode_caps || !hal_reg_caps) 346d5c65159SKalle Valo return -EINVAL; 347d5c65159SKalle Valo 348d5c65159SKalle Valo for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) { 349d5c65159SKalle Valo if (hw_mode_id == wmi_hw_mode_caps[hw_idx].hw_mode_id) 350d5c65159SKalle Valo break; 351d5c65159SKalle Valo 352d5c65159SKalle Valo phy_map = wmi_hw_mode_caps[hw_idx].phy_id_map; 353d5c65159SKalle Valo while (phy_map) { 354d5c65159SKalle Valo phy_map >>= 1; 355d5c65159SKalle Valo phy_idx++; 356d5c65159SKalle Valo } 357d5c65159SKalle Valo } 358d5c65159SKalle Valo 359d5c65159SKalle Valo if (hw_idx == hw_caps->num_hw_modes) 360d5c65159SKalle Valo return -EINVAL; 361d5c65159SKalle Valo 362d5c65159SKalle Valo phy_idx += phy_id; 363d5c65159SKalle Valo if (phy_id >= hal_reg_caps->num_phy) 364d5c65159SKalle Valo return -EINVAL; 365d5c65159SKalle Valo 3665b90fc76SAnilkumar Kolli mac_phy_caps = wmi_mac_phy_caps + phy_idx; 367d5c65159SKalle Valo 368d5c65159SKalle Valo pdev->pdev_id = mac_phy_caps->pdev_id; 3695f859bc0SCarl Huang pdev_cap->supported_bands |= mac_phy_caps->supported_bands; 370d5c65159SKalle Valo pdev_cap->ampdu_density = mac_phy_caps->ampdu_density; 371d5c65159SKalle Valo 372d5c65159SKalle Valo /* Take non-zero tx/rx chainmask. If tx/rx chainmask differs from 373d5c65159SKalle Valo * band to band for a single radio, need to see how this should be 374d5c65159SKalle Valo * handled. 375d5c65159SKalle Valo */ 376d5c65159SKalle Valo if (mac_phy_caps->supported_bands & WMI_HOST_WLAN_2G_CAP) { 377d5c65159SKalle Valo pdev_cap->tx_chain_mask = mac_phy_caps->tx_chain_mask_2g; 378d5c65159SKalle Valo pdev_cap->rx_chain_mask = mac_phy_caps->rx_chain_mask_2g; 379d5c65159SKalle Valo } else if (mac_phy_caps->supported_bands & WMI_HOST_WLAN_5G_CAP) { 380d5c65159SKalle Valo pdev_cap->vht_cap = mac_phy_caps->vht_cap_info_5g; 381d5c65159SKalle Valo pdev_cap->vht_mcs = mac_phy_caps->vht_supp_mcs_5g; 382d5c65159SKalle Valo pdev_cap->he_mcs = mac_phy_caps->he_supp_mcs_5g; 383d5c65159SKalle Valo pdev_cap->tx_chain_mask = mac_phy_caps->tx_chain_mask_5g; 384d5c65159SKalle Valo pdev_cap->rx_chain_mask = mac_phy_caps->rx_chain_mask_5g; 385f552d6fdSP Praneesh pdev_cap->nss_ratio_enabled = 386f552d6fdSP Praneesh WMI_NSS_RATIO_ENABLE_DISABLE_GET(mac_phy_caps->nss_ratio); 387f552d6fdSP Praneesh pdev_cap->nss_ratio_info = 388f552d6fdSP Praneesh WMI_NSS_RATIO_INFO_GET(mac_phy_caps->nss_ratio); 389d5c65159SKalle Valo } else { 390d5c65159SKalle Valo return -EINVAL; 391d5c65159SKalle Valo } 392d5c65159SKalle Valo 393d5c65159SKalle Valo /* tx/rx chainmask reported from fw depends on the actual hw chains used, 394d5c65159SKalle Valo * For example, for 4x4 capable macphys, first 4 chains can be used for first 395d5c65159SKalle Valo * mac and the remaing 4 chains can be used for the second mac or vice-versa. 396d5c65159SKalle Valo * In this case, tx/rx chainmask 0xf will be advertised for first mac and 0xf0 39716f283f0SKalle Valo * will be advertised for second mac or vice-versa. Compute the shift value 398d5c65159SKalle Valo * for tx/rx chainmask which will be used to advertise supported ht/vht rates to 399d5c65159SKalle Valo * mac80211. 400d5c65159SKalle Valo */ 401d5c65159SKalle Valo pdev_cap->tx_chain_mask_shift = 402d5c65159SKalle Valo find_first_bit((unsigned long *)&pdev_cap->tx_chain_mask, 32); 403d5c65159SKalle Valo pdev_cap->rx_chain_mask_shift = 404d5c65159SKalle Valo find_first_bit((unsigned long *)&pdev_cap->rx_chain_mask, 32); 405d5c65159SKalle Valo 4065f859bc0SCarl Huang if (mac_phy_caps->supported_bands & WMI_HOST_WLAN_2G_CAP) { 407d5c65159SKalle Valo cap_band = &pdev_cap->band[NL80211_BAND_2GHZ]; 4085f859bc0SCarl Huang cap_band->phy_id = mac_phy_caps->phy_id; 409d5c65159SKalle Valo cap_band->max_bw_supported = mac_phy_caps->max_bw_supported_2g; 410d5c65159SKalle Valo cap_band->ht_cap_info = mac_phy_caps->ht_cap_info_2g; 411d5c65159SKalle Valo cap_band->he_cap_info[0] = mac_phy_caps->he_cap_info_2g; 412d5c65159SKalle Valo cap_band->he_cap_info[1] = mac_phy_caps->he_cap_info_2g_ext; 413d5c65159SKalle Valo cap_band->he_mcs = mac_phy_caps->he_supp_mcs_2g; 414d5c65159SKalle Valo memcpy(cap_band->he_cap_phy_info, &mac_phy_caps->he_cap_phy_info_2g, 415d5c65159SKalle Valo sizeof(u32) * PSOC_HOST_MAX_PHY_SIZE); 416d5c65159SKalle Valo memcpy(&cap_band->he_ppet, &mac_phy_caps->he_ppet2g, 417d5c65159SKalle Valo sizeof(struct ath11k_ppe_threshold)); 4185f859bc0SCarl Huang } 419d5c65159SKalle Valo 4205f859bc0SCarl Huang if (mac_phy_caps->supported_bands & WMI_HOST_WLAN_5G_CAP) { 421d5c65159SKalle Valo cap_band = &pdev_cap->band[NL80211_BAND_5GHZ]; 4225f859bc0SCarl Huang cap_band->phy_id = mac_phy_caps->phy_id; 423d5c65159SKalle Valo cap_band->max_bw_supported = mac_phy_caps->max_bw_supported_5g; 424d5c65159SKalle Valo cap_band->ht_cap_info = mac_phy_caps->ht_cap_info_5g; 425d5c65159SKalle Valo cap_band->he_cap_info[0] = mac_phy_caps->he_cap_info_5g; 426d5c65159SKalle Valo cap_band->he_cap_info[1] = mac_phy_caps->he_cap_info_5g_ext; 427d5c65159SKalle Valo cap_band->he_mcs = mac_phy_caps->he_supp_mcs_5g; 428d5c65159SKalle Valo memcpy(cap_band->he_cap_phy_info, &mac_phy_caps->he_cap_phy_info_5g, 429d5c65159SKalle Valo sizeof(u32) * PSOC_HOST_MAX_PHY_SIZE); 430d5c65159SKalle Valo memcpy(&cap_band->he_ppet, &mac_phy_caps->he_ppet5g, 431d5c65159SKalle Valo sizeof(struct ath11k_ppe_threshold)); 432d5c65159SKalle Valo 43322eeadcdSPradeep Kumar Chitrapu cap_band = &pdev_cap->band[NL80211_BAND_6GHZ]; 43422eeadcdSPradeep Kumar Chitrapu cap_band->max_bw_supported = mac_phy_caps->max_bw_supported_5g; 43522eeadcdSPradeep Kumar Chitrapu cap_band->ht_cap_info = mac_phy_caps->ht_cap_info_5g; 43622eeadcdSPradeep Kumar Chitrapu cap_band->he_cap_info[0] = mac_phy_caps->he_cap_info_5g; 43722eeadcdSPradeep Kumar Chitrapu cap_band->he_cap_info[1] = mac_phy_caps->he_cap_info_5g_ext; 43822eeadcdSPradeep Kumar Chitrapu cap_band->he_mcs = mac_phy_caps->he_supp_mcs_5g; 43922eeadcdSPradeep Kumar Chitrapu memcpy(cap_band->he_cap_phy_info, &mac_phy_caps->he_cap_phy_info_5g, 44022eeadcdSPradeep Kumar Chitrapu sizeof(u32) * PSOC_HOST_MAX_PHY_SIZE); 44122eeadcdSPradeep Kumar Chitrapu memcpy(&cap_band->he_ppet, &mac_phy_caps->he_ppet5g, 44222eeadcdSPradeep Kumar Chitrapu sizeof(struct ath11k_ppe_threshold)); 4430f17ae43SWen Gong } 44422eeadcdSPradeep Kumar Chitrapu 445d5c65159SKalle Valo return 0; 446d5c65159SKalle Valo } 447d5c65159SKalle Valo 448d5c65159SKalle Valo static int 449d5c65159SKalle Valo ath11k_pull_reg_cap_svc_rdy_ext(struct ath11k_pdev_wmi *wmi_handle, 450d5c65159SKalle Valo struct wmi_soc_hal_reg_capabilities *reg_caps, 451d5c65159SKalle Valo struct wmi_hal_reg_capabilities_ext *wmi_ext_reg_cap, 452d5c65159SKalle Valo u8 phy_idx, 453d5c65159SKalle Valo struct ath11k_hal_reg_capabilities_ext *param) 454d5c65159SKalle Valo { 455d5c65159SKalle Valo struct wmi_hal_reg_capabilities_ext *ext_reg_cap; 456d5c65159SKalle Valo 457d5c65159SKalle Valo if (!reg_caps || !wmi_ext_reg_cap) 458d5c65159SKalle Valo return -EINVAL; 459d5c65159SKalle Valo 460d5c65159SKalle Valo if (phy_idx >= reg_caps->num_phy) 461d5c65159SKalle Valo return -EINVAL; 462d5c65159SKalle Valo 463d5c65159SKalle Valo ext_reg_cap = &wmi_ext_reg_cap[phy_idx]; 464d5c65159SKalle Valo 465d5c65159SKalle Valo param->phy_id = ext_reg_cap->phy_id; 466d5c65159SKalle Valo param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain; 467d5c65159SKalle Valo param->eeprom_reg_domain_ext = 468d5c65159SKalle Valo ext_reg_cap->eeprom_reg_domain_ext; 469d5c65159SKalle Valo param->regcap1 = ext_reg_cap->regcap1; 470d5c65159SKalle Valo param->regcap2 = ext_reg_cap->regcap2; 471d5c65159SKalle Valo /* check if param->wireless_mode is needed */ 472d5c65159SKalle Valo param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan; 473d5c65159SKalle Valo param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan; 474d5c65159SKalle Valo param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan; 475d5c65159SKalle Valo param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan; 476d5c65159SKalle Valo 477d5c65159SKalle Valo return 0; 478d5c65159SKalle Valo } 479d5c65159SKalle Valo 480d5c65159SKalle Valo static int ath11k_pull_service_ready_tlv(struct ath11k_base *ab, 481d5c65159SKalle Valo const void *evt_buf, 482d5c65159SKalle Valo struct ath11k_targ_cap *cap) 483d5c65159SKalle Valo { 484d5c65159SKalle Valo const struct wmi_service_ready_event *ev = evt_buf; 485d5c65159SKalle Valo 486d5c65159SKalle Valo if (!ev) { 487d5c65159SKalle Valo ath11k_err(ab, "%s: failed by NULL param\n", 488d5c65159SKalle Valo __func__); 489d5c65159SKalle Valo return -EINVAL; 490d5c65159SKalle Valo } 491d5c65159SKalle Valo 492d5c65159SKalle Valo cap->phy_capability = ev->phy_capability; 493d5c65159SKalle Valo cap->max_frag_entry = ev->max_frag_entry; 494d5c65159SKalle Valo cap->num_rf_chains = ev->num_rf_chains; 495d5c65159SKalle Valo cap->ht_cap_info = ev->ht_cap_info; 496d5c65159SKalle Valo cap->vht_cap_info = ev->vht_cap_info; 497d5c65159SKalle Valo cap->vht_supp_mcs = ev->vht_supp_mcs; 498d5c65159SKalle Valo cap->hw_min_tx_power = ev->hw_min_tx_power; 499d5c65159SKalle Valo cap->hw_max_tx_power = ev->hw_max_tx_power; 500d5c65159SKalle Valo cap->sys_cap_info = ev->sys_cap_info; 501d5c65159SKalle Valo cap->min_pkt_size_enable = ev->min_pkt_size_enable; 502d5c65159SKalle Valo cap->max_bcn_ie_size = ev->max_bcn_ie_size; 503d5c65159SKalle Valo cap->max_num_scan_channels = ev->max_num_scan_channels; 504d5c65159SKalle Valo cap->max_supported_macs = ev->max_supported_macs; 505d5c65159SKalle Valo cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps; 506d5c65159SKalle Valo cap->txrx_chainmask = ev->txrx_chainmask; 507d5c65159SKalle Valo cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index; 508d5c65159SKalle Valo cap->num_msdu_desc = ev->num_msdu_desc; 509d5c65159SKalle Valo 510d5c65159SKalle Valo return 0; 511d5c65159SKalle Valo } 512d5c65159SKalle Valo 513d5c65159SKalle Valo /* Save the wmi_service_bitmap into a linear bitmap. The wmi_services in 514d5c65159SKalle Valo * wmi_service ready event are advertised in b0-b3 (LSB 4-bits) of each 515d5c65159SKalle Valo * 4-byte word. 516d5c65159SKalle Valo */ 517d5c65159SKalle Valo static void ath11k_wmi_service_bitmap_copy(struct ath11k_pdev_wmi *wmi, 518d5c65159SKalle Valo const u32 *wmi_svc_bm) 519d5c65159SKalle Valo { 520d5c65159SKalle Valo int i, j; 521d5c65159SKalle Valo 522d5c65159SKalle Valo for (i = 0, j = 0; i < WMI_SERVICE_BM_SIZE && j < WMI_MAX_SERVICE; i++) { 523d5c65159SKalle Valo do { 524d5c65159SKalle Valo if (wmi_svc_bm[i] & BIT(j % WMI_SERVICE_BITS_IN_SIZE32)) 5256bc9d6f7SJohn Crispin set_bit(j, wmi->wmi_ab->svc_map); 526d5c65159SKalle Valo } while (++j % WMI_SERVICE_BITS_IN_SIZE32); 527d5c65159SKalle Valo } 528d5c65159SKalle Valo } 529d5c65159SKalle Valo 530d5c65159SKalle Valo static int ath11k_wmi_tlv_svc_rdy_parse(struct ath11k_base *ab, u16 tag, u16 len, 531d5c65159SKalle Valo const void *ptr, void *data) 532d5c65159SKalle Valo { 533d5c65159SKalle Valo struct wmi_tlv_svc_ready_parse *svc_ready = data; 5346bc9d6f7SJohn Crispin struct ath11k_pdev_wmi *wmi_handle = &ab->wmi_ab.wmi[0]; 535d5c65159SKalle Valo u16 expect_len; 536d5c65159SKalle Valo 537d5c65159SKalle Valo switch (tag) { 538d5c65159SKalle Valo case WMI_TAG_SERVICE_READY_EVENT: 539d5c65159SKalle Valo if (ath11k_pull_service_ready_tlv(ab, ptr, &ab->target_caps)) 540d5c65159SKalle Valo return -EINVAL; 541d5c65159SKalle Valo break; 542d5c65159SKalle Valo 543d5c65159SKalle Valo case WMI_TAG_ARRAY_UINT32: 544d5c65159SKalle Valo if (!svc_ready->wmi_svc_bitmap_done) { 545d5c65159SKalle Valo expect_len = WMI_SERVICE_BM_SIZE * sizeof(u32); 546d5c65159SKalle Valo if (len < expect_len) { 547d5c65159SKalle Valo ath11k_warn(ab, "invalid len %d for the tag 0x%x\n", 548d5c65159SKalle Valo len, tag); 549d5c65159SKalle Valo return -EINVAL; 550d5c65159SKalle Valo } 551d5c65159SKalle Valo 552d5c65159SKalle Valo ath11k_wmi_service_bitmap_copy(wmi_handle, ptr); 553d5c65159SKalle Valo 554d5c65159SKalle Valo svc_ready->wmi_svc_bitmap_done = true; 555d5c65159SKalle Valo } 556d5c65159SKalle Valo break; 557d5c65159SKalle Valo default: 558d5c65159SKalle Valo break; 559d5c65159SKalle Valo } 560d5c65159SKalle Valo 561d5c65159SKalle Valo return 0; 562d5c65159SKalle Valo } 563d5c65159SKalle Valo 564d5c65159SKalle Valo static int ath11k_service_ready_event(struct ath11k_base *ab, struct sk_buff *skb) 565d5c65159SKalle Valo { 566d5c65159SKalle Valo struct wmi_tlv_svc_ready_parse svc_ready = { }; 567d5c65159SKalle Valo int ret; 568d5c65159SKalle Valo 569d5c65159SKalle Valo ret = ath11k_wmi_tlv_iter(ab, skb->data, skb->len, 570d5c65159SKalle Valo ath11k_wmi_tlv_svc_rdy_parse, 571d5c65159SKalle Valo &svc_ready); 572d5c65159SKalle Valo if (ret) { 573d5c65159SKalle Valo ath11k_warn(ab, "failed to parse tlv %d\n", ret); 574d5c65159SKalle Valo return ret; 575d5c65159SKalle Valo } 576d5c65159SKalle Valo 577d5c65159SKalle Valo return 0; 578d5c65159SKalle Valo } 579d5c65159SKalle Valo 580d5c65159SKalle Valo struct sk_buff *ath11k_wmi_alloc_skb(struct ath11k_wmi_base *wmi_sc, u32 len) 581d5c65159SKalle Valo { 582d5c65159SKalle Valo struct sk_buff *skb; 583d5c65159SKalle Valo struct ath11k_base *ab = wmi_sc->ab; 584d5c65159SKalle Valo u32 round_len = roundup(len, 4); 585d5c65159SKalle Valo 586d5c65159SKalle Valo skb = ath11k_htc_alloc_skb(ab, WMI_SKB_HEADROOM + round_len); 587d5c65159SKalle Valo if (!skb) 588d5c65159SKalle Valo return NULL; 589d5c65159SKalle Valo 590d5c65159SKalle Valo skb_reserve(skb, WMI_SKB_HEADROOM); 591d5c65159SKalle Valo if (!IS_ALIGNED((unsigned long)skb->data, 4)) 592d5c65159SKalle Valo ath11k_warn(ab, "unaligned WMI skb data\n"); 593d5c65159SKalle Valo 594d5c65159SKalle Valo skb_put(skb, round_len); 595d5c65159SKalle Valo memset(skb->data, 0, round_len); 596d5c65159SKalle Valo 597d5c65159SKalle Valo return skb; 598d5c65159SKalle Valo } 599d5c65159SKalle Valo 600d5c65159SKalle Valo int ath11k_wmi_mgmt_send(struct ath11k *ar, u32 vdev_id, u32 buf_id, 601d5c65159SKalle Valo struct sk_buff *frame) 602d5c65159SKalle Valo { 603d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 604d5c65159SKalle Valo struct wmi_mgmt_send_cmd *cmd; 605d5c65159SKalle Valo struct wmi_tlv *frame_tlv; 606d5c65159SKalle Valo struct sk_buff *skb; 607d5c65159SKalle Valo u32 buf_len; 608d5c65159SKalle Valo int ret, len; 609d5c65159SKalle Valo 610d5c65159SKalle Valo buf_len = frame->len < WMI_MGMT_SEND_DOWNLD_LEN ? 611d5c65159SKalle Valo frame->len : WMI_MGMT_SEND_DOWNLD_LEN; 612d5c65159SKalle Valo 613d5c65159SKalle Valo len = sizeof(*cmd) + sizeof(*frame_tlv) + roundup(buf_len, 4); 614d5c65159SKalle Valo 6156bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len); 616d5c65159SKalle Valo if (!skb) 617d5c65159SKalle Valo return -ENOMEM; 618d5c65159SKalle Valo 619d5c65159SKalle Valo cmd = (struct wmi_mgmt_send_cmd *)skb->data; 620d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_MGMT_TX_SEND_CMD) | 621d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 622d5c65159SKalle Valo cmd->vdev_id = vdev_id; 623d5c65159SKalle Valo cmd->desc_id = buf_id; 624d5c65159SKalle Valo cmd->chanfreq = 0; 625d5c65159SKalle Valo cmd->paddr_lo = lower_32_bits(ATH11K_SKB_CB(frame)->paddr); 626d5c65159SKalle Valo cmd->paddr_hi = upper_32_bits(ATH11K_SKB_CB(frame)->paddr); 627d5c65159SKalle Valo cmd->frame_len = frame->len; 628d5c65159SKalle Valo cmd->buf_len = buf_len; 629d5c65159SKalle Valo cmd->tx_params_valid = 0; 630d5c65159SKalle Valo 631d5c65159SKalle Valo frame_tlv = (struct wmi_tlv *)(skb->data + sizeof(*cmd)); 632d5c65159SKalle Valo frame_tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_BYTE) | 633d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, buf_len); 634d5c65159SKalle Valo 635d5c65159SKalle Valo memcpy(frame_tlv->value, frame->data, buf_len); 636d5c65159SKalle Valo 637d5c65159SKalle Valo ath11k_ce_byte_swap(frame_tlv->value, buf_len); 638d5c65159SKalle Valo 639d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, WMI_MGMT_TX_SEND_CMDID); 640d5c65159SKalle Valo if (ret) { 641d5c65159SKalle Valo ath11k_warn(ar->ab, 642d5c65159SKalle Valo "failed to submit WMI_MGMT_TX_SEND_CMDID cmd\n"); 643d5c65159SKalle Valo dev_kfree_skb(skb); 644d5c65159SKalle Valo } 645d5c65159SKalle Valo 646d5c65159SKalle Valo return ret; 647d5c65159SKalle Valo } 648d5c65159SKalle Valo 649d5c65159SKalle Valo int ath11k_wmi_vdev_create(struct ath11k *ar, u8 *macaddr, 650d5c65159SKalle Valo struct vdev_create_params *param) 651d5c65159SKalle Valo { 652d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 653d5c65159SKalle Valo struct wmi_vdev_create_cmd *cmd; 654d5c65159SKalle Valo struct sk_buff *skb; 655d5c65159SKalle Valo struct wmi_vdev_txrx_streams *txrx_streams; 656d5c65159SKalle Valo struct wmi_tlv *tlv; 657d5c65159SKalle Valo int ret, len; 658d5c65159SKalle Valo void *ptr; 659d5c65159SKalle Valo 660d5c65159SKalle Valo /* It can be optimized my sending tx/rx chain configuration 661d5c65159SKalle Valo * only for supported bands instead of always sending it for 662d5c65159SKalle Valo * both the bands. 663d5c65159SKalle Valo */ 664d5c65159SKalle Valo len = sizeof(*cmd) + TLV_HDR_SIZE + 665d5c65159SKalle Valo (WMI_NUM_SUPPORTED_BAND_MAX * sizeof(*txrx_streams)); 666d5c65159SKalle Valo 6676bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len); 668d5c65159SKalle Valo if (!skb) 669d5c65159SKalle Valo return -ENOMEM; 670d5c65159SKalle Valo 671d5c65159SKalle Valo cmd = (struct wmi_vdev_create_cmd *)skb->data; 672d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_VDEV_CREATE_CMD) | 673d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 674d5c65159SKalle Valo 675d5c65159SKalle Valo cmd->vdev_id = param->if_id; 676d5c65159SKalle Valo cmd->vdev_type = param->type; 677d5c65159SKalle Valo cmd->vdev_subtype = param->subtype; 678d5c65159SKalle Valo cmd->num_cfg_txrx_streams = WMI_NUM_SUPPORTED_BAND_MAX; 679d5c65159SKalle Valo cmd->pdev_id = param->pdev_id; 680d5c65159SKalle Valo ether_addr_copy(cmd->vdev_macaddr.addr, macaddr); 681d5c65159SKalle Valo 682d5c65159SKalle Valo ptr = skb->data + sizeof(*cmd); 683d5c65159SKalle Valo len = WMI_NUM_SUPPORTED_BAND_MAX * sizeof(*txrx_streams); 684d5c65159SKalle Valo 685d5c65159SKalle Valo tlv = ptr; 686d5c65159SKalle Valo tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_STRUCT) | 687d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, len); 688d5c65159SKalle Valo 689d5c65159SKalle Valo ptr += TLV_HDR_SIZE; 690d5c65159SKalle Valo txrx_streams = ptr; 691d5c65159SKalle Valo len = sizeof(*txrx_streams); 692d5c65159SKalle Valo txrx_streams->tlv_header = 693d5c65159SKalle Valo FIELD_PREP(WMI_TLV_TAG, WMI_TAG_VDEV_TXRX_STREAMS) | 694d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, len - TLV_HDR_SIZE); 695d5c65159SKalle Valo txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_2G; 696d5c65159SKalle Valo txrx_streams->supported_tx_streams = 697d5c65159SKalle Valo param->chains[NL80211_BAND_2GHZ].tx; 698d5c65159SKalle Valo txrx_streams->supported_rx_streams = 699d5c65159SKalle Valo param->chains[NL80211_BAND_2GHZ].rx; 700d5c65159SKalle Valo 701d5c65159SKalle Valo txrx_streams++; 702d5c65159SKalle Valo txrx_streams->tlv_header = 703d5c65159SKalle Valo FIELD_PREP(WMI_TLV_TAG, WMI_TAG_VDEV_TXRX_STREAMS) | 704d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, len - TLV_HDR_SIZE); 705d5c65159SKalle Valo txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_5G; 706d5c65159SKalle Valo txrx_streams->supported_tx_streams = 707d5c65159SKalle Valo param->chains[NL80211_BAND_5GHZ].tx; 708d5c65159SKalle Valo txrx_streams->supported_rx_streams = 709d5c65159SKalle Valo param->chains[NL80211_BAND_5GHZ].rx; 710d5c65159SKalle Valo 711d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, WMI_VDEV_CREATE_CMDID); 712d5c65159SKalle Valo if (ret) { 713d5c65159SKalle Valo ath11k_warn(ar->ab, 714d5c65159SKalle Valo "failed to submit WMI_VDEV_CREATE_CMDID\n"); 715d5c65159SKalle Valo dev_kfree_skb(skb); 716d5c65159SKalle Valo } 717d5c65159SKalle Valo 718d5c65159SKalle Valo ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 719d5c65159SKalle Valo "WMI vdev create: id %d type %d subtype %d macaddr %pM pdevid %d\n", 720d5c65159SKalle Valo param->if_id, param->type, param->subtype, 721d5c65159SKalle Valo macaddr, param->pdev_id); 722d5c65159SKalle Valo 723d5c65159SKalle Valo return ret; 724d5c65159SKalle Valo } 725d5c65159SKalle Valo 726d5c65159SKalle Valo int ath11k_wmi_vdev_delete(struct ath11k *ar, u8 vdev_id) 727d5c65159SKalle Valo { 728d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 729d5c65159SKalle Valo struct wmi_vdev_delete_cmd *cmd; 730d5c65159SKalle Valo struct sk_buff *skb; 731d5c65159SKalle Valo int ret; 732d5c65159SKalle Valo 7336bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd)); 734d5c65159SKalle Valo if (!skb) 735d5c65159SKalle Valo return -ENOMEM; 736d5c65159SKalle Valo 737d5c65159SKalle Valo cmd = (struct wmi_vdev_delete_cmd *)skb->data; 738d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_VDEV_DELETE_CMD) | 739d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 740d5c65159SKalle Valo cmd->vdev_id = vdev_id; 741d5c65159SKalle Valo 742d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, WMI_VDEV_DELETE_CMDID); 743d5c65159SKalle Valo if (ret) { 744d5c65159SKalle Valo ath11k_warn(ar->ab, "failed to submit WMI_VDEV_DELETE_CMDID\n"); 745d5c65159SKalle Valo dev_kfree_skb(skb); 746d5c65159SKalle Valo } 747d5c65159SKalle Valo 748d5c65159SKalle Valo ath11k_dbg(ar->ab, ATH11K_DBG_WMI, "WMI vdev delete id %d\n", vdev_id); 749d5c65159SKalle Valo 750d5c65159SKalle Valo return ret; 751d5c65159SKalle Valo } 752d5c65159SKalle Valo 753d5c65159SKalle Valo int ath11k_wmi_vdev_stop(struct ath11k *ar, u8 vdev_id) 754d5c65159SKalle Valo { 755d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 756d5c65159SKalle Valo struct wmi_vdev_stop_cmd *cmd; 757d5c65159SKalle Valo struct sk_buff *skb; 758d5c65159SKalle Valo int ret; 759d5c65159SKalle Valo 7606bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd)); 761d5c65159SKalle Valo if (!skb) 762d5c65159SKalle Valo return -ENOMEM; 763d5c65159SKalle Valo 764d5c65159SKalle Valo cmd = (struct wmi_vdev_stop_cmd *)skb->data; 765d5c65159SKalle Valo 766d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_VDEV_STOP_CMD) | 767d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 768d5c65159SKalle Valo cmd->vdev_id = vdev_id; 769d5c65159SKalle Valo 770d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, WMI_VDEV_STOP_CMDID); 771d5c65159SKalle Valo if (ret) { 772d5c65159SKalle Valo ath11k_warn(ar->ab, "failed to submit WMI_VDEV_STOP cmd\n"); 773d5c65159SKalle Valo dev_kfree_skb(skb); 774d5c65159SKalle Valo } 775d5c65159SKalle Valo 776d5c65159SKalle Valo ath11k_dbg(ar->ab, ATH11K_DBG_WMI, "WMI vdev stop id 0x%x\n", vdev_id); 777d5c65159SKalle Valo 778d5c65159SKalle Valo return ret; 779d5c65159SKalle Valo } 780d5c65159SKalle Valo 781d5c65159SKalle Valo int ath11k_wmi_vdev_down(struct ath11k *ar, u8 vdev_id) 782d5c65159SKalle Valo { 783d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 784d5c65159SKalle Valo struct wmi_vdev_down_cmd *cmd; 785d5c65159SKalle Valo struct sk_buff *skb; 786d5c65159SKalle Valo int ret; 787d5c65159SKalle Valo 7886bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd)); 789d5c65159SKalle Valo if (!skb) 790d5c65159SKalle Valo return -ENOMEM; 791d5c65159SKalle Valo 792d5c65159SKalle Valo cmd = (struct wmi_vdev_down_cmd *)skb->data; 793d5c65159SKalle Valo 794d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_VDEV_DOWN_CMD) | 795d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 796d5c65159SKalle Valo cmd->vdev_id = vdev_id; 797d5c65159SKalle Valo 798d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, WMI_VDEV_DOWN_CMDID); 799d5c65159SKalle Valo if (ret) { 800d5c65159SKalle Valo ath11k_warn(ar->ab, "failed to submit WMI_VDEV_DOWN cmd\n"); 801d5c65159SKalle Valo dev_kfree_skb(skb); 802d5c65159SKalle Valo } 803d5c65159SKalle Valo 804d5c65159SKalle Valo ath11k_dbg(ar->ab, ATH11K_DBG_WMI, "WMI vdev down id 0x%x\n", vdev_id); 805d5c65159SKalle Valo 806d5c65159SKalle Valo return ret; 807d5c65159SKalle Valo } 808d5c65159SKalle Valo 809d5c65159SKalle Valo static void ath11k_wmi_put_wmi_channel(struct wmi_channel *chan, 810d5c65159SKalle Valo struct wmi_vdev_start_req_arg *arg) 811d5c65159SKalle Valo { 812f552d6fdSP Praneesh u32 center_freq1 = arg->channel.band_center_freq1; 813f552d6fdSP Praneesh 814d5c65159SKalle Valo memset(chan, 0, sizeof(*chan)); 815d5c65159SKalle Valo 816d5c65159SKalle Valo chan->mhz = arg->channel.freq; 817d5c65159SKalle Valo chan->band_center_freq1 = arg->channel.band_center_freq1; 818f552d6fdSP Praneesh 819f552d6fdSP Praneesh if (arg->channel.mode == MODE_11AX_HE160) { 820f552d6fdSP Praneesh if (arg->channel.freq > arg->channel.band_center_freq1) 821f552d6fdSP Praneesh chan->band_center_freq1 = center_freq1 + 40; 822d5c65159SKalle Valo else 823f552d6fdSP Praneesh chan->band_center_freq1 = center_freq1 - 40; 824f552d6fdSP Praneesh 825f552d6fdSP Praneesh chan->band_center_freq2 = arg->channel.band_center_freq1; 826f552d6fdSP Praneesh 827f552d6fdSP Praneesh } else if (arg->channel.mode == MODE_11AC_VHT80_80) { 828f552d6fdSP Praneesh chan->band_center_freq2 = arg->channel.band_center_freq2; 829f552d6fdSP Praneesh } else { 830d5c65159SKalle Valo chan->band_center_freq2 = 0; 831f552d6fdSP Praneesh } 832d5c65159SKalle Valo 833d5c65159SKalle Valo chan->info |= FIELD_PREP(WMI_CHAN_INFO_MODE, arg->channel.mode); 834d5c65159SKalle Valo if (arg->channel.passive) 835d5c65159SKalle Valo chan->info |= WMI_CHAN_INFO_PASSIVE; 836d5c65159SKalle Valo if (arg->channel.allow_ibss) 837d5c65159SKalle Valo chan->info |= WMI_CHAN_INFO_ADHOC_ALLOWED; 838d5c65159SKalle Valo if (arg->channel.allow_ht) 839d5c65159SKalle Valo chan->info |= WMI_CHAN_INFO_ALLOW_HT; 840d5c65159SKalle Valo if (arg->channel.allow_vht) 841d5c65159SKalle Valo chan->info |= WMI_CHAN_INFO_ALLOW_VHT; 8429f056ed8SJohn Crispin if (arg->channel.allow_he) 8439f056ed8SJohn Crispin chan->info |= WMI_CHAN_INFO_ALLOW_HE; 844d5c65159SKalle Valo if (arg->channel.ht40plus) 845d5c65159SKalle Valo chan->info |= WMI_CHAN_INFO_HT40_PLUS; 846d5c65159SKalle Valo if (arg->channel.chan_radar) 847d5c65159SKalle Valo chan->info |= WMI_CHAN_INFO_DFS; 848d5c65159SKalle Valo if (arg->channel.freq2_radar) 849d5c65159SKalle Valo chan->info |= WMI_CHAN_INFO_DFS_FREQ2; 850d5c65159SKalle Valo 851d5c65159SKalle Valo chan->reg_info_1 = FIELD_PREP(WMI_CHAN_REG_INFO1_MAX_PWR, 852d5c65159SKalle Valo arg->channel.max_power) | 853d5c65159SKalle Valo FIELD_PREP(WMI_CHAN_REG_INFO1_MAX_REG_PWR, 854d5c65159SKalle Valo arg->channel.max_reg_power); 855d5c65159SKalle Valo 856d5c65159SKalle Valo chan->reg_info_2 = FIELD_PREP(WMI_CHAN_REG_INFO2_ANT_MAX, 857d5c65159SKalle Valo arg->channel.max_antenna_gain) | 858d5c65159SKalle Valo FIELD_PREP(WMI_CHAN_REG_INFO2_MAX_TX_PWR, 859d5c65159SKalle Valo arg->channel.max_power); 860d5c65159SKalle Valo } 861d5c65159SKalle Valo 862d5c65159SKalle Valo int ath11k_wmi_vdev_start(struct ath11k *ar, struct wmi_vdev_start_req_arg *arg, 863d5c65159SKalle Valo bool restart) 864d5c65159SKalle Valo { 865d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 866d5c65159SKalle Valo struct wmi_vdev_start_request_cmd *cmd; 867d5c65159SKalle Valo struct sk_buff *skb; 868d5c65159SKalle Valo struct wmi_channel *chan; 869d5c65159SKalle Valo struct wmi_tlv *tlv; 870d5c65159SKalle Valo void *ptr; 871d5c65159SKalle Valo int ret, len; 872d5c65159SKalle Valo 873d5c65159SKalle Valo if (WARN_ON(arg->ssid_len > sizeof(cmd->ssid.ssid))) 874d5c65159SKalle Valo return -EINVAL; 875d5c65159SKalle Valo 876d5c65159SKalle Valo len = sizeof(*cmd) + sizeof(*chan) + TLV_HDR_SIZE; 877d5c65159SKalle Valo 8786bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len); 879d5c65159SKalle Valo if (!skb) 880d5c65159SKalle Valo return -ENOMEM; 881d5c65159SKalle Valo 882d5c65159SKalle Valo cmd = (struct wmi_vdev_start_request_cmd *)skb->data; 883d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, 884d5c65159SKalle Valo WMI_TAG_VDEV_START_REQUEST_CMD) | 885d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 886d5c65159SKalle Valo cmd->vdev_id = arg->vdev_id; 887d5c65159SKalle Valo cmd->beacon_interval = arg->bcn_intval; 888d5c65159SKalle Valo cmd->bcn_tx_rate = arg->bcn_tx_rate; 889d5c65159SKalle Valo cmd->dtim_period = arg->dtim_period; 890d5c65159SKalle Valo cmd->num_noa_descriptors = arg->num_noa_descriptors; 891d5c65159SKalle Valo cmd->preferred_rx_streams = arg->pref_rx_streams; 892d5c65159SKalle Valo cmd->preferred_tx_streams = arg->pref_tx_streams; 893d5c65159SKalle Valo cmd->cac_duration_ms = arg->cac_duration_ms; 894d5c65159SKalle Valo cmd->regdomain = arg->regdomain; 895d5c65159SKalle Valo cmd->he_ops = arg->he_ops; 896d5c65159SKalle Valo 897d5c65159SKalle Valo if (!restart) { 898d5c65159SKalle Valo if (arg->ssid) { 899d5c65159SKalle Valo cmd->ssid.ssid_len = arg->ssid_len; 900d5c65159SKalle Valo memcpy(cmd->ssid.ssid, arg->ssid, arg->ssid_len); 901d5c65159SKalle Valo } 902d5c65159SKalle Valo if (arg->hidden_ssid) 903d5c65159SKalle Valo cmd->flags |= WMI_VDEV_START_HIDDEN_SSID; 904d5c65159SKalle Valo if (arg->pmf_enabled) 905d5c65159SKalle Valo cmd->flags |= WMI_VDEV_START_PMF_ENABLED; 906d5c65159SKalle Valo } 907d5c65159SKalle Valo 908d5c65159SKalle Valo cmd->flags |= WMI_VDEV_START_LDPC_RX_ENABLED; 9098717db7eSSeevalamuthu Mariappan if (test_bit(ATH11K_FLAG_HW_CRYPTO_DISABLED, &ar->ab->dev_flags)) 9108717db7eSSeevalamuthu Mariappan cmd->flags |= WMI_VDEV_START_HW_ENCRYPTION_DISABLED; 911d5c65159SKalle Valo 912d5c65159SKalle Valo ptr = skb->data + sizeof(*cmd); 913d5c65159SKalle Valo chan = ptr; 914d5c65159SKalle Valo 915d5c65159SKalle Valo ath11k_wmi_put_wmi_channel(chan, arg); 916d5c65159SKalle Valo 917d5c65159SKalle Valo chan->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_CHANNEL) | 918d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, 919d5c65159SKalle Valo sizeof(*chan) - TLV_HDR_SIZE); 920d5c65159SKalle Valo ptr += sizeof(*chan); 921d5c65159SKalle Valo 922d5c65159SKalle Valo tlv = ptr; 923d5c65159SKalle Valo tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_STRUCT) | 924d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, 0); 925d5c65159SKalle Valo 926d5c65159SKalle Valo /* Note: This is a nested TLV containing: 927d5c65159SKalle Valo * [wmi_tlv][wmi_p2p_noa_descriptor][wmi_tlv].. 928d5c65159SKalle Valo */ 929d5c65159SKalle Valo 930d5c65159SKalle Valo ptr += sizeof(*tlv); 931d5c65159SKalle Valo 932d5c65159SKalle Valo if (restart) 933d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, 934d5c65159SKalle Valo WMI_VDEV_RESTART_REQUEST_CMDID); 935d5c65159SKalle Valo else 936d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, 937d5c65159SKalle Valo WMI_VDEV_START_REQUEST_CMDID); 938d5c65159SKalle Valo if (ret) { 939d5c65159SKalle Valo ath11k_warn(ar->ab, "failed to submit vdev_%s cmd\n", 940d5c65159SKalle Valo restart ? "restart" : "start"); 941d5c65159SKalle Valo dev_kfree_skb(skb); 942d5c65159SKalle Valo } 943d5c65159SKalle Valo 944d5c65159SKalle Valo ath11k_dbg(ar->ab, ATH11K_DBG_WMI, "vdev %s id 0x%x freq 0x%x mode 0x%x\n", 945d5c65159SKalle Valo restart ? "restart" : "start", arg->vdev_id, 946d5c65159SKalle Valo arg->channel.freq, arg->channel.mode); 947d5c65159SKalle Valo 948d5c65159SKalle Valo return ret; 949d5c65159SKalle Valo } 950d5c65159SKalle Valo 951d5c65159SKalle Valo int ath11k_wmi_vdev_up(struct ath11k *ar, u32 vdev_id, u32 aid, const u8 *bssid) 952d5c65159SKalle Valo { 953d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 954d5c65159SKalle Valo struct wmi_vdev_up_cmd *cmd; 955d5c65159SKalle Valo struct sk_buff *skb; 956d5c65159SKalle Valo int ret; 957d5c65159SKalle Valo 9586bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd)); 959d5c65159SKalle Valo if (!skb) 960d5c65159SKalle Valo return -ENOMEM; 961d5c65159SKalle Valo 962d5c65159SKalle Valo cmd = (struct wmi_vdev_up_cmd *)skb->data; 963d5c65159SKalle Valo 964d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_VDEV_UP_CMD) | 965d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 966d5c65159SKalle Valo cmd->vdev_id = vdev_id; 967d5c65159SKalle Valo cmd->vdev_assoc_id = aid; 968d5c65159SKalle Valo 969d5c65159SKalle Valo ether_addr_copy(cmd->vdev_bssid.addr, bssid); 970d5c65159SKalle Valo 971d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, WMI_VDEV_UP_CMDID); 972d5c65159SKalle Valo if (ret) { 973d5c65159SKalle Valo ath11k_warn(ar->ab, "failed to submit WMI_VDEV_UP cmd\n"); 974d5c65159SKalle Valo dev_kfree_skb(skb); 975d5c65159SKalle Valo } 976d5c65159SKalle Valo 977d5c65159SKalle Valo ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 978d5c65159SKalle Valo "WMI mgmt vdev up id 0x%x assoc id %d bssid %pM\n", 979d5c65159SKalle Valo vdev_id, aid, bssid); 980d5c65159SKalle Valo 981d5c65159SKalle Valo return ret; 982d5c65159SKalle Valo } 983d5c65159SKalle Valo 984d5c65159SKalle Valo int ath11k_wmi_send_peer_create_cmd(struct ath11k *ar, 985d5c65159SKalle Valo struct peer_create_params *param) 986d5c65159SKalle Valo { 987d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 988d5c65159SKalle Valo struct wmi_peer_create_cmd *cmd; 989d5c65159SKalle Valo struct sk_buff *skb; 990d5c65159SKalle Valo int ret; 991d5c65159SKalle Valo 9926bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd)); 993d5c65159SKalle Valo if (!skb) 994d5c65159SKalle Valo return -ENOMEM; 995d5c65159SKalle Valo 996d5c65159SKalle Valo cmd = (struct wmi_peer_create_cmd *)skb->data; 997d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_PEER_CREATE_CMD) | 998d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 999d5c65159SKalle Valo 1000d5c65159SKalle Valo ether_addr_copy(cmd->peer_macaddr.addr, param->peer_addr); 1001d5c65159SKalle Valo cmd->peer_type = param->peer_type; 1002d5c65159SKalle Valo cmd->vdev_id = param->vdev_id; 1003d5c65159SKalle Valo 1004d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, WMI_PEER_CREATE_CMDID); 1005d5c65159SKalle Valo if (ret) { 1006d5c65159SKalle Valo ath11k_warn(ar->ab, "failed to submit WMI_PEER_CREATE cmd\n"); 1007d5c65159SKalle Valo dev_kfree_skb(skb); 1008d5c65159SKalle Valo } 1009d5c65159SKalle Valo 1010d5c65159SKalle Valo ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 1011d5c65159SKalle Valo "WMI peer create vdev_id %d peer_addr %pM\n", 1012d5c65159SKalle Valo param->vdev_id, param->peer_addr); 1013d5c65159SKalle Valo 1014d5c65159SKalle Valo return ret; 1015d5c65159SKalle Valo } 1016d5c65159SKalle Valo 1017d5c65159SKalle Valo int ath11k_wmi_send_peer_delete_cmd(struct ath11k *ar, 1018d5c65159SKalle Valo const u8 *peer_addr, u8 vdev_id) 1019d5c65159SKalle Valo { 1020d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 1021d5c65159SKalle Valo struct wmi_peer_delete_cmd *cmd; 1022d5c65159SKalle Valo struct sk_buff *skb; 1023d5c65159SKalle Valo int ret; 1024d5c65159SKalle Valo 10256bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd)); 1026d5c65159SKalle Valo if (!skb) 1027d5c65159SKalle Valo return -ENOMEM; 1028d5c65159SKalle Valo 1029d5c65159SKalle Valo cmd = (struct wmi_peer_delete_cmd *)skb->data; 1030d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_PEER_DELETE_CMD) | 1031d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 1032d5c65159SKalle Valo 1033d5c65159SKalle Valo ether_addr_copy(cmd->peer_macaddr.addr, peer_addr); 1034d5c65159SKalle Valo cmd->vdev_id = vdev_id; 1035d5c65159SKalle Valo 1036d5c65159SKalle Valo ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 1037d5c65159SKalle Valo "WMI peer delete vdev_id %d peer_addr %pM\n", 1038d5c65159SKalle Valo vdev_id, peer_addr); 1039d5c65159SKalle Valo 1040d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, WMI_PEER_DELETE_CMDID); 1041d5c65159SKalle Valo if (ret) { 1042d5c65159SKalle Valo ath11k_warn(ar->ab, "failed to send WMI_PEER_DELETE cmd\n"); 1043d5c65159SKalle Valo dev_kfree_skb(skb); 1044d5c65159SKalle Valo } 1045d5c65159SKalle Valo 1046d5c65159SKalle Valo return ret; 1047d5c65159SKalle Valo } 1048d5c65159SKalle Valo 1049d5c65159SKalle Valo int ath11k_wmi_send_pdev_set_regdomain(struct ath11k *ar, 1050d5c65159SKalle Valo struct pdev_set_regdomain_params *param) 1051d5c65159SKalle Valo { 1052d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 1053d5c65159SKalle Valo struct wmi_pdev_set_regdomain_cmd *cmd; 1054d5c65159SKalle Valo struct sk_buff *skb; 1055d5c65159SKalle Valo int ret; 1056d5c65159SKalle Valo 10576bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd)); 1058d5c65159SKalle Valo if (!skb) 1059d5c65159SKalle Valo return -ENOMEM; 1060d5c65159SKalle Valo 1061d5c65159SKalle Valo cmd = (struct wmi_pdev_set_regdomain_cmd *)skb->data; 1062d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, 1063d5c65159SKalle Valo WMI_TAG_PDEV_SET_REGDOMAIN_CMD) | 1064d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 1065d5c65159SKalle Valo 1066d5c65159SKalle Valo cmd->reg_domain = param->current_rd_in_use; 1067d5c65159SKalle Valo cmd->reg_domain_2g = param->current_rd_2g; 1068d5c65159SKalle Valo cmd->reg_domain_5g = param->current_rd_5g; 1069d5c65159SKalle Valo cmd->conformance_test_limit_2g = param->ctl_2g; 1070d5c65159SKalle Valo cmd->conformance_test_limit_5g = param->ctl_5g; 1071d5c65159SKalle Valo cmd->dfs_domain = param->dfs_domain; 1072d5c65159SKalle Valo cmd->pdev_id = param->pdev_id; 1073d5c65159SKalle Valo 1074d5c65159SKalle Valo ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 1075d5c65159SKalle Valo "WMI pdev regd rd %d rd2g %d rd5g %d domain %d pdev id %d\n", 1076d5c65159SKalle Valo param->current_rd_in_use, param->current_rd_2g, 1077d5c65159SKalle Valo param->current_rd_5g, param->dfs_domain, param->pdev_id); 1078d5c65159SKalle Valo 1079d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, WMI_PDEV_SET_REGDOMAIN_CMDID); 1080d5c65159SKalle Valo if (ret) { 1081d5c65159SKalle Valo ath11k_warn(ar->ab, 1082d5c65159SKalle Valo "failed to send WMI_PDEV_SET_REGDOMAIN cmd\n"); 1083d5c65159SKalle Valo dev_kfree_skb(skb); 1084d5c65159SKalle Valo } 1085d5c65159SKalle Valo 1086d5c65159SKalle Valo return ret; 1087d5c65159SKalle Valo } 1088d5c65159SKalle Valo 1089d5c65159SKalle Valo int ath11k_wmi_set_peer_param(struct ath11k *ar, const u8 *peer_addr, 1090d5c65159SKalle Valo u32 vdev_id, u32 param_id, u32 param_val) 1091d5c65159SKalle Valo { 1092d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 1093d5c65159SKalle Valo struct wmi_peer_set_param_cmd *cmd; 1094d5c65159SKalle Valo struct sk_buff *skb; 1095d5c65159SKalle Valo int ret; 1096d5c65159SKalle Valo 10976bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd)); 1098d5c65159SKalle Valo if (!skb) 1099d5c65159SKalle Valo return -ENOMEM; 1100d5c65159SKalle Valo 1101d5c65159SKalle Valo cmd = (struct wmi_peer_set_param_cmd *)skb->data; 1102d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_PEER_SET_PARAM_CMD) | 1103d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 1104d5c65159SKalle Valo ether_addr_copy(cmd->peer_macaddr.addr, peer_addr); 1105d5c65159SKalle Valo cmd->vdev_id = vdev_id; 1106d5c65159SKalle Valo cmd->param_id = param_id; 1107d5c65159SKalle Valo cmd->param_value = param_val; 1108d5c65159SKalle Valo 1109d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, WMI_PEER_SET_PARAM_CMDID); 1110d5c65159SKalle Valo if (ret) { 1111d5c65159SKalle Valo ath11k_warn(ar->ab, "failed to send WMI_PEER_SET_PARAM cmd\n"); 1112d5c65159SKalle Valo dev_kfree_skb(skb); 1113d5c65159SKalle Valo } 1114d5c65159SKalle Valo 1115d5c65159SKalle Valo ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 1116d5c65159SKalle Valo "WMI vdev %d peer 0x%pM set param %d value %d\n", 1117d5c65159SKalle Valo vdev_id, peer_addr, param_id, param_val); 1118d5c65159SKalle Valo 1119d5c65159SKalle Valo return ret; 1120d5c65159SKalle Valo } 1121d5c65159SKalle Valo 1122d5c65159SKalle Valo int ath11k_wmi_send_peer_flush_tids_cmd(struct ath11k *ar, 1123d5c65159SKalle Valo u8 peer_addr[ETH_ALEN], 1124d5c65159SKalle Valo struct peer_flush_params *param) 1125d5c65159SKalle Valo { 1126d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 1127d5c65159SKalle Valo struct wmi_peer_flush_tids_cmd *cmd; 1128d5c65159SKalle Valo struct sk_buff *skb; 1129d5c65159SKalle Valo int ret; 1130d5c65159SKalle Valo 11316bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd)); 1132d5c65159SKalle Valo if (!skb) 1133d5c65159SKalle Valo return -ENOMEM; 1134d5c65159SKalle Valo 1135d5c65159SKalle Valo cmd = (struct wmi_peer_flush_tids_cmd *)skb->data; 1136d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_PEER_FLUSH_TIDS_CMD) | 1137d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 1138d5c65159SKalle Valo 1139d5c65159SKalle Valo ether_addr_copy(cmd->peer_macaddr.addr, peer_addr); 1140d5c65159SKalle Valo cmd->peer_tid_bitmap = param->peer_tid_bitmap; 1141d5c65159SKalle Valo cmd->vdev_id = param->vdev_id; 1142d5c65159SKalle Valo 1143d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, WMI_PEER_FLUSH_TIDS_CMDID); 1144d5c65159SKalle Valo if (ret) { 1145d5c65159SKalle Valo ath11k_warn(ar->ab, 1146d5c65159SKalle Valo "failed to send WMI_PEER_FLUSH_TIDS cmd\n"); 1147d5c65159SKalle Valo dev_kfree_skb(skb); 1148d5c65159SKalle Valo } 1149d5c65159SKalle Valo 1150d5c65159SKalle Valo ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 1151d5c65159SKalle Valo "WMI peer flush vdev_id %d peer_addr %pM tids %08x\n", 1152d5c65159SKalle Valo param->vdev_id, peer_addr, param->peer_tid_bitmap); 1153d5c65159SKalle Valo 1154d5c65159SKalle Valo return ret; 1155d5c65159SKalle Valo } 1156d5c65159SKalle Valo 1157d5c65159SKalle Valo int ath11k_wmi_peer_rx_reorder_queue_setup(struct ath11k *ar, 1158d5c65159SKalle Valo int vdev_id, const u8 *addr, 1159d5c65159SKalle Valo dma_addr_t paddr, u8 tid, 1160d5c65159SKalle Valo u8 ba_window_size_valid, 1161d5c65159SKalle Valo u32 ba_window_size) 1162d5c65159SKalle Valo { 1163d5c65159SKalle Valo struct wmi_peer_reorder_queue_setup_cmd *cmd; 1164d5c65159SKalle Valo struct sk_buff *skb; 1165d5c65159SKalle Valo int ret; 1166d5c65159SKalle Valo 11676bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(ar->wmi->wmi_ab, sizeof(*cmd)); 1168d5c65159SKalle Valo if (!skb) 1169d5c65159SKalle Valo return -ENOMEM; 1170d5c65159SKalle Valo 1171d5c65159SKalle Valo cmd = (struct wmi_peer_reorder_queue_setup_cmd *)skb->data; 1172d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, 1173d5c65159SKalle Valo WMI_TAG_REORDER_QUEUE_SETUP_CMD) | 1174d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 1175d5c65159SKalle Valo 1176d5c65159SKalle Valo ether_addr_copy(cmd->peer_macaddr.addr, addr); 1177d5c65159SKalle Valo cmd->vdev_id = vdev_id; 1178d5c65159SKalle Valo cmd->tid = tid; 1179d5c65159SKalle Valo cmd->queue_ptr_lo = lower_32_bits(paddr); 1180d5c65159SKalle Valo cmd->queue_ptr_hi = upper_32_bits(paddr); 1181d5c65159SKalle Valo cmd->queue_no = tid; 1182d5c65159SKalle Valo cmd->ba_window_size_valid = ba_window_size_valid; 1183d5c65159SKalle Valo cmd->ba_window_size = ba_window_size; 1184d5c65159SKalle Valo 1185d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(ar->wmi, skb, 1186d5c65159SKalle Valo WMI_PEER_REORDER_QUEUE_SETUP_CMDID); 1187d5c65159SKalle Valo if (ret) { 1188d5c65159SKalle Valo ath11k_warn(ar->ab, 1189d5c65159SKalle Valo "failed to send WMI_PEER_REORDER_QUEUE_SETUP\n"); 1190d5c65159SKalle Valo dev_kfree_skb(skb); 1191d5c65159SKalle Valo } 1192d5c65159SKalle Valo 1193d5c65159SKalle Valo ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 1194d5c65159SKalle Valo "wmi rx reorder queue setup addr %pM vdev_id %d tid %d\n", 1195d5c65159SKalle Valo addr, vdev_id, tid); 1196d5c65159SKalle Valo 1197d5c65159SKalle Valo return ret; 1198d5c65159SKalle Valo } 1199d5c65159SKalle Valo 1200d5c65159SKalle Valo int 1201d5c65159SKalle Valo ath11k_wmi_rx_reord_queue_remove(struct ath11k *ar, 1202d5c65159SKalle Valo struct rx_reorder_queue_remove_params *param) 1203d5c65159SKalle Valo { 1204d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 1205d5c65159SKalle Valo struct wmi_peer_reorder_queue_remove_cmd *cmd; 1206d5c65159SKalle Valo struct sk_buff *skb; 1207d5c65159SKalle Valo int ret; 1208d5c65159SKalle Valo 12096bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd)); 1210d5c65159SKalle Valo if (!skb) 1211d5c65159SKalle Valo return -ENOMEM; 1212d5c65159SKalle Valo 1213d5c65159SKalle Valo cmd = (struct wmi_peer_reorder_queue_remove_cmd *)skb->data; 1214d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, 1215d5c65159SKalle Valo WMI_TAG_REORDER_QUEUE_REMOVE_CMD) | 1216d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 1217d5c65159SKalle Valo 1218d5c65159SKalle Valo ether_addr_copy(cmd->peer_macaddr.addr, param->peer_macaddr); 1219d5c65159SKalle Valo cmd->vdev_id = param->vdev_id; 1220d5c65159SKalle Valo cmd->tid_mask = param->peer_tid_bitmap; 1221d5c65159SKalle Valo 1222d5c65159SKalle Valo ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 1223d5c65159SKalle Valo "%s: peer_macaddr %pM vdev_id %d, tid_map %d", __func__, 1224d5c65159SKalle Valo param->peer_macaddr, param->vdev_id, param->peer_tid_bitmap); 1225d5c65159SKalle Valo 1226d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, 1227d5c65159SKalle Valo WMI_PEER_REORDER_QUEUE_REMOVE_CMDID); 1228d5c65159SKalle Valo if (ret) { 1229d5c65159SKalle Valo ath11k_warn(ar->ab, 1230d5c65159SKalle Valo "failed to send WMI_PEER_REORDER_QUEUE_REMOVE_CMDID"); 1231d5c65159SKalle Valo dev_kfree_skb(skb); 1232d5c65159SKalle Valo } 1233d5c65159SKalle Valo 1234d5c65159SKalle Valo return ret; 1235d5c65159SKalle Valo } 1236d5c65159SKalle Valo 1237d5c65159SKalle Valo int ath11k_wmi_pdev_set_param(struct ath11k *ar, u32 param_id, 1238d5c65159SKalle Valo u32 param_value, u8 pdev_id) 1239d5c65159SKalle Valo { 1240d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 1241d5c65159SKalle Valo struct wmi_pdev_set_param_cmd *cmd; 1242d5c65159SKalle Valo struct sk_buff *skb; 1243d5c65159SKalle Valo int ret; 1244d5c65159SKalle Valo 12456bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd)); 1246d5c65159SKalle Valo if (!skb) 1247d5c65159SKalle Valo return -ENOMEM; 1248d5c65159SKalle Valo 1249d5c65159SKalle Valo cmd = (struct wmi_pdev_set_param_cmd *)skb->data; 1250d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_PDEV_SET_PARAM_CMD) | 1251d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 1252d5c65159SKalle Valo cmd->pdev_id = pdev_id; 1253d5c65159SKalle Valo cmd->param_id = param_id; 1254d5c65159SKalle Valo cmd->param_value = param_value; 1255d5c65159SKalle Valo 1256d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, WMI_PDEV_SET_PARAM_CMDID); 1257d5c65159SKalle Valo if (ret) { 1258d5c65159SKalle Valo ath11k_warn(ar->ab, "failed to send WMI_PDEV_SET_PARAM cmd\n"); 1259d5c65159SKalle Valo dev_kfree_skb(skb); 1260d5c65159SKalle Valo } 1261d5c65159SKalle Valo 1262d5c65159SKalle Valo ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 1263d5c65159SKalle Valo "WMI pdev set param %d pdev id %d value %d\n", 1264d5c65159SKalle Valo param_id, pdev_id, param_value); 1265d5c65159SKalle Valo 1266d5c65159SKalle Valo return ret; 1267d5c65159SKalle Valo } 1268d5c65159SKalle Valo 1269af3d8964SKalle Valo int ath11k_wmi_pdev_set_ps_mode(struct ath11k *ar, int vdev_id, 1270af3d8964SKalle Valo enum wmi_sta_ps_mode psmode) 127197c63746SJohn Crispin { 127297c63746SJohn Crispin struct ath11k_pdev_wmi *wmi = ar->wmi; 127397c63746SJohn Crispin struct wmi_pdev_set_ps_mode_cmd *cmd; 127497c63746SJohn Crispin struct sk_buff *skb; 127597c63746SJohn Crispin int ret; 127697c63746SJohn Crispin 12776bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd)); 127897c63746SJohn Crispin if (!skb) 127997c63746SJohn Crispin return -ENOMEM; 128097c63746SJohn Crispin 128197c63746SJohn Crispin cmd = (struct wmi_pdev_set_ps_mode_cmd *)skb->data; 128297c63746SJohn Crispin cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_STA_POWERSAVE_MODE_CMD) | 128397c63746SJohn Crispin FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 128497c63746SJohn Crispin cmd->vdev_id = vdev_id; 1285af3d8964SKalle Valo cmd->sta_ps_mode = psmode; 128697c63746SJohn Crispin 128797c63746SJohn Crispin ret = ath11k_wmi_cmd_send(wmi, skb, WMI_STA_POWERSAVE_MODE_CMDID); 128897c63746SJohn Crispin if (ret) { 128997c63746SJohn Crispin ath11k_warn(ar->ab, "failed to send WMI_PDEV_SET_PARAM cmd\n"); 129097c63746SJohn Crispin dev_kfree_skb(skb); 129197c63746SJohn Crispin } 129297c63746SJohn Crispin 129397c63746SJohn Crispin ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 129497c63746SJohn Crispin "WMI vdev set psmode %d vdev id %d\n", 1295af3d8964SKalle Valo psmode, vdev_id); 129697c63746SJohn Crispin 129797c63746SJohn Crispin return ret; 129897c63746SJohn Crispin } 129997c63746SJohn Crispin 1300d5c65159SKalle Valo int ath11k_wmi_pdev_suspend(struct ath11k *ar, u32 suspend_opt, 1301d5c65159SKalle Valo u32 pdev_id) 1302d5c65159SKalle Valo { 1303d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 1304d5c65159SKalle Valo struct wmi_pdev_suspend_cmd *cmd; 1305d5c65159SKalle Valo struct sk_buff *skb; 1306d5c65159SKalle Valo int ret; 1307d5c65159SKalle Valo 13086bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd)); 1309d5c65159SKalle Valo if (!skb) 1310d5c65159SKalle Valo return -ENOMEM; 1311d5c65159SKalle Valo 1312d5c65159SKalle Valo cmd = (struct wmi_pdev_suspend_cmd *)skb->data; 1313d5c65159SKalle Valo 1314d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_PDEV_SUSPEND_CMD) | 1315d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 1316d5c65159SKalle Valo 1317d5c65159SKalle Valo cmd->suspend_opt = suspend_opt; 1318d5c65159SKalle Valo cmd->pdev_id = pdev_id; 1319d5c65159SKalle Valo 1320d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, WMI_PDEV_SUSPEND_CMDID); 1321d5c65159SKalle Valo if (ret) { 1322d5c65159SKalle Valo ath11k_warn(ar->ab, "failed to send WMI_PDEV_SUSPEND cmd\n"); 1323d5c65159SKalle Valo dev_kfree_skb(skb); 1324d5c65159SKalle Valo } 1325d5c65159SKalle Valo 1326d5c65159SKalle Valo ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 1327d5c65159SKalle Valo "WMI pdev suspend pdev_id %d\n", pdev_id); 1328d5c65159SKalle Valo 1329d5c65159SKalle Valo return ret; 1330d5c65159SKalle Valo } 1331d5c65159SKalle Valo 1332d5c65159SKalle Valo int ath11k_wmi_pdev_resume(struct ath11k *ar, u32 pdev_id) 1333d5c65159SKalle Valo { 1334d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 1335d5c65159SKalle Valo struct wmi_pdev_resume_cmd *cmd; 1336d5c65159SKalle Valo struct sk_buff *skb; 1337d5c65159SKalle Valo int ret; 1338d5c65159SKalle Valo 13396bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd)); 1340d5c65159SKalle Valo if (!skb) 1341d5c65159SKalle Valo return -ENOMEM; 1342d5c65159SKalle Valo 1343d5c65159SKalle Valo cmd = (struct wmi_pdev_resume_cmd *)skb->data; 1344d5c65159SKalle Valo 1345d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_PDEV_RESUME_CMD) | 1346d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 1347d5c65159SKalle Valo cmd->pdev_id = pdev_id; 1348d5c65159SKalle Valo 1349d5c65159SKalle Valo ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 1350d5c65159SKalle Valo "WMI pdev resume pdev id %d\n", pdev_id); 1351d5c65159SKalle Valo 1352d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, WMI_PDEV_RESUME_CMDID); 1353d5c65159SKalle Valo if (ret) { 1354d5c65159SKalle Valo ath11k_warn(ar->ab, "failed to send WMI_PDEV_RESUME cmd\n"); 1355d5c65159SKalle Valo dev_kfree_skb(skb); 1356d5c65159SKalle Valo } 1357d5c65159SKalle Valo 1358d5c65159SKalle Valo return ret; 1359d5c65159SKalle Valo } 1360d5c65159SKalle Valo 1361d5c65159SKalle Valo /* TODO FW Support for the cmd is not available yet. 1362d5c65159SKalle Valo * Can be tested once the command and corresponding 1363d5c65159SKalle Valo * event is implemented in FW 1364d5c65159SKalle Valo */ 1365d5c65159SKalle Valo int ath11k_wmi_pdev_bss_chan_info_request(struct ath11k *ar, 1366d5c65159SKalle Valo enum wmi_bss_chan_info_req_type type) 1367d5c65159SKalle Valo { 1368d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 1369d5c65159SKalle Valo struct wmi_pdev_bss_chan_info_req_cmd *cmd; 1370d5c65159SKalle Valo struct sk_buff *skb; 1371d5c65159SKalle Valo int ret; 1372d5c65159SKalle Valo 13736bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd)); 1374d5c65159SKalle Valo if (!skb) 1375d5c65159SKalle Valo return -ENOMEM; 1376d5c65159SKalle Valo 1377d5c65159SKalle Valo cmd = (struct wmi_pdev_bss_chan_info_req_cmd *)skb->data; 1378d5c65159SKalle Valo 1379d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, 1380d5c65159SKalle Valo WMI_TAG_PDEV_BSS_CHAN_INFO_REQUEST) | 1381d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 1382d5c65159SKalle Valo cmd->req_type = type; 1383feab5bb8SSeevalamuthu Mariappan cmd->pdev_id = ar->pdev->pdev_id; 1384d5c65159SKalle Valo 1385d5c65159SKalle Valo ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 1386d5c65159SKalle Valo "WMI bss chan info req type %d\n", type); 1387d5c65159SKalle Valo 1388d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, 1389d5c65159SKalle Valo WMI_PDEV_BSS_CHAN_INFO_REQUEST_CMDID); 1390d5c65159SKalle Valo if (ret) { 1391d5c65159SKalle Valo ath11k_warn(ar->ab, 1392d5c65159SKalle Valo "failed to send WMI_PDEV_BSS_CHAN_INFO_REQUEST cmd\n"); 1393d5c65159SKalle Valo dev_kfree_skb(skb); 1394d5c65159SKalle Valo } 1395d5c65159SKalle Valo 1396d5c65159SKalle Valo return ret; 1397d5c65159SKalle Valo } 1398d5c65159SKalle Valo 1399d5c65159SKalle Valo int ath11k_wmi_send_set_ap_ps_param_cmd(struct ath11k *ar, u8 *peer_addr, 1400d5c65159SKalle Valo struct ap_ps_params *param) 1401d5c65159SKalle Valo { 1402d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 1403d5c65159SKalle Valo struct wmi_ap_ps_peer_cmd *cmd; 1404d5c65159SKalle Valo struct sk_buff *skb; 1405d5c65159SKalle Valo int ret; 1406d5c65159SKalle Valo 14076bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd)); 1408d5c65159SKalle Valo if (!skb) 1409d5c65159SKalle Valo return -ENOMEM; 1410d5c65159SKalle Valo 1411d5c65159SKalle Valo cmd = (struct wmi_ap_ps_peer_cmd *)skb->data; 1412d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_AP_PS_PEER_CMD) | 1413d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 1414d5c65159SKalle Valo 1415d5c65159SKalle Valo cmd->vdev_id = param->vdev_id; 1416d5c65159SKalle Valo ether_addr_copy(cmd->peer_macaddr.addr, peer_addr); 1417d5c65159SKalle Valo cmd->param = param->param; 1418d5c65159SKalle Valo cmd->value = param->value; 1419d5c65159SKalle Valo 1420d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, WMI_AP_PS_PEER_PARAM_CMDID); 1421d5c65159SKalle Valo if (ret) { 1422d5c65159SKalle Valo ath11k_warn(ar->ab, 1423d5c65159SKalle Valo "failed to send WMI_AP_PS_PEER_PARAM_CMDID\n"); 1424d5c65159SKalle Valo dev_kfree_skb(skb); 1425d5c65159SKalle Valo } 1426d5c65159SKalle Valo 1427d5c65159SKalle Valo ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 1428d5c65159SKalle Valo "WMI set ap ps vdev id %d peer %pM param %d value %d\n", 1429d5c65159SKalle Valo param->vdev_id, peer_addr, param->param, param->value); 1430d5c65159SKalle Valo 1431d5c65159SKalle Valo return ret; 1432d5c65159SKalle Valo } 1433d5c65159SKalle Valo 1434d5c65159SKalle Valo int ath11k_wmi_set_sta_ps_param(struct ath11k *ar, u32 vdev_id, 1435d5c65159SKalle Valo u32 param, u32 param_value) 1436d5c65159SKalle Valo { 1437d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 1438d5c65159SKalle Valo struct wmi_sta_powersave_param_cmd *cmd; 1439d5c65159SKalle Valo struct sk_buff *skb; 1440d5c65159SKalle Valo int ret; 1441d5c65159SKalle Valo 14426bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd)); 1443d5c65159SKalle Valo if (!skb) 1444d5c65159SKalle Valo return -ENOMEM; 1445d5c65159SKalle Valo 1446d5c65159SKalle Valo cmd = (struct wmi_sta_powersave_param_cmd *)skb->data; 1447d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, 1448d5c65159SKalle Valo WMI_TAG_STA_POWERSAVE_PARAM_CMD) | 1449d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 1450d5c65159SKalle Valo 1451d5c65159SKalle Valo cmd->vdev_id = vdev_id; 1452d5c65159SKalle Valo cmd->param = param; 1453d5c65159SKalle Valo cmd->value = param_value; 1454d5c65159SKalle Valo 1455d5c65159SKalle Valo ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 1456d5c65159SKalle Valo "WMI set sta ps vdev_id %d param %d value %d\n", 1457d5c65159SKalle Valo vdev_id, param, param_value); 1458d5c65159SKalle Valo 1459d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, WMI_STA_POWERSAVE_PARAM_CMDID); 1460d5c65159SKalle Valo if (ret) { 1461d5c65159SKalle Valo ath11k_warn(ar->ab, "failed to send WMI_STA_POWERSAVE_PARAM_CMDID"); 1462d5c65159SKalle Valo dev_kfree_skb(skb); 1463d5c65159SKalle Valo } 1464d5c65159SKalle Valo 1465d5c65159SKalle Valo return ret; 1466d5c65159SKalle Valo } 1467d5c65159SKalle Valo 1468d5c65159SKalle Valo int ath11k_wmi_force_fw_hang_cmd(struct ath11k *ar, u32 type, u32 delay_time_ms) 1469d5c65159SKalle Valo { 1470d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 1471d5c65159SKalle Valo struct wmi_force_fw_hang_cmd *cmd; 1472d5c65159SKalle Valo struct sk_buff *skb; 1473d5c65159SKalle Valo int ret, len; 1474d5c65159SKalle Valo 1475d5c65159SKalle Valo len = sizeof(*cmd); 1476d5c65159SKalle Valo 14776bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len); 1478d5c65159SKalle Valo if (!skb) 1479d5c65159SKalle Valo return -ENOMEM; 1480d5c65159SKalle Valo 1481d5c65159SKalle Valo cmd = (struct wmi_force_fw_hang_cmd *)skb->data; 1482d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_FORCE_FW_HANG_CMD) | 1483d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, len - TLV_HDR_SIZE); 1484d5c65159SKalle Valo 1485d5c65159SKalle Valo cmd->type = type; 1486d5c65159SKalle Valo cmd->delay_time_ms = delay_time_ms; 1487d5c65159SKalle Valo 1488d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, WMI_FORCE_FW_HANG_CMDID); 1489d5c65159SKalle Valo 1490d5c65159SKalle Valo if (ret) { 1491d5c65159SKalle Valo ath11k_warn(ar->ab, "Failed to send WMI_FORCE_FW_HANG_CMDID"); 1492d5c65159SKalle Valo dev_kfree_skb(skb); 1493d5c65159SKalle Valo } 1494d5c65159SKalle Valo return ret; 1495d5c65159SKalle Valo } 1496d5c65159SKalle Valo 1497d5c65159SKalle Valo int ath11k_wmi_vdev_set_param_cmd(struct ath11k *ar, u32 vdev_id, 1498d5c65159SKalle Valo u32 param_id, u32 param_value) 1499d5c65159SKalle Valo { 1500d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 1501d5c65159SKalle Valo struct wmi_vdev_set_param_cmd *cmd; 1502d5c65159SKalle Valo struct sk_buff *skb; 1503d5c65159SKalle Valo int ret; 1504d5c65159SKalle Valo 15056bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd)); 1506d5c65159SKalle Valo if (!skb) 1507d5c65159SKalle Valo return -ENOMEM; 1508d5c65159SKalle Valo 1509d5c65159SKalle Valo cmd = (struct wmi_vdev_set_param_cmd *)skb->data; 1510d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_VDEV_SET_PARAM_CMD) | 1511d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 1512d5c65159SKalle Valo 1513d5c65159SKalle Valo cmd->vdev_id = vdev_id; 1514d5c65159SKalle Valo cmd->param_id = param_id; 1515d5c65159SKalle Valo cmd->param_value = param_value; 1516d5c65159SKalle Valo 1517d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, WMI_VDEV_SET_PARAM_CMDID); 1518d5c65159SKalle Valo if (ret) { 1519d5c65159SKalle Valo ath11k_warn(ar->ab, 1520d5c65159SKalle Valo "failed to send WMI_VDEV_SET_PARAM_CMDID\n"); 1521d5c65159SKalle Valo dev_kfree_skb(skb); 1522d5c65159SKalle Valo } 1523d5c65159SKalle Valo 1524d5c65159SKalle Valo ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 1525d5c65159SKalle Valo "WMI vdev id 0x%x set param %d value %d\n", 1526d5c65159SKalle Valo vdev_id, param_id, param_value); 1527d5c65159SKalle Valo 1528d5c65159SKalle Valo return ret; 1529d5c65159SKalle Valo } 1530d5c65159SKalle Valo 1531d5c65159SKalle Valo int ath11k_wmi_send_stats_request_cmd(struct ath11k *ar, 1532d5c65159SKalle Valo struct stats_request_params *param) 1533d5c65159SKalle Valo { 1534d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 1535d5c65159SKalle Valo struct wmi_request_stats_cmd *cmd; 1536d5c65159SKalle Valo struct sk_buff *skb; 1537d5c65159SKalle Valo int ret; 1538d5c65159SKalle Valo 15396bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd)); 1540d5c65159SKalle Valo if (!skb) 1541d5c65159SKalle Valo return -ENOMEM; 1542d5c65159SKalle Valo 1543d5c65159SKalle Valo cmd = (struct wmi_request_stats_cmd *)skb->data; 1544d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_REQUEST_STATS_CMD) | 1545d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 1546d5c65159SKalle Valo 1547d5c65159SKalle Valo cmd->stats_id = param->stats_id; 1548d5c65159SKalle Valo cmd->vdev_id = param->vdev_id; 1549d5c65159SKalle Valo cmd->pdev_id = param->pdev_id; 1550d5c65159SKalle Valo 1551d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, WMI_REQUEST_STATS_CMDID); 1552d5c65159SKalle Valo if (ret) { 1553d5c65159SKalle Valo ath11k_warn(ar->ab, "failed to send WMI_REQUEST_STATS cmd\n"); 1554d5c65159SKalle Valo dev_kfree_skb(skb); 1555d5c65159SKalle Valo } 1556d5c65159SKalle Valo 1557d5c65159SKalle Valo ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 1558d5c65159SKalle Valo "WMI request stats 0x%x vdev id %d pdev id %d\n", 1559d5c65159SKalle Valo param->stats_id, param->vdev_id, param->pdev_id); 1560d5c65159SKalle Valo 1561d5c65159SKalle Valo return ret; 1562d5c65159SKalle Valo } 1563d5c65159SKalle Valo 1564a41d1034SPradeep Kumar Chitrapu int ath11k_wmi_send_pdev_temperature_cmd(struct ath11k *ar) 1565a41d1034SPradeep Kumar Chitrapu { 1566a41d1034SPradeep Kumar Chitrapu struct ath11k_pdev_wmi *wmi = ar->wmi; 1567a41d1034SPradeep Kumar Chitrapu struct wmi_get_pdev_temperature_cmd *cmd; 1568a41d1034SPradeep Kumar Chitrapu struct sk_buff *skb; 1569a41d1034SPradeep Kumar Chitrapu int ret; 1570a41d1034SPradeep Kumar Chitrapu 1571a41d1034SPradeep Kumar Chitrapu skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd)); 1572a41d1034SPradeep Kumar Chitrapu if (!skb) 1573a41d1034SPradeep Kumar Chitrapu return -ENOMEM; 1574a41d1034SPradeep Kumar Chitrapu 1575a41d1034SPradeep Kumar Chitrapu cmd = (struct wmi_get_pdev_temperature_cmd *)skb->data; 1576a41d1034SPradeep Kumar Chitrapu cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_PDEV_GET_TEMPERATURE_CMD) | 1577a41d1034SPradeep Kumar Chitrapu FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 1578a41d1034SPradeep Kumar Chitrapu cmd->pdev_id = ar->pdev->pdev_id; 1579a41d1034SPradeep Kumar Chitrapu 1580a41d1034SPradeep Kumar Chitrapu ret = ath11k_wmi_cmd_send(wmi, skb, WMI_PDEV_GET_TEMPERATURE_CMDID); 1581a41d1034SPradeep Kumar Chitrapu if (ret) { 1582a41d1034SPradeep Kumar Chitrapu ath11k_warn(ar->ab, "failed to send WMI_PDEV_GET_TEMPERATURE cmd\n"); 1583a41d1034SPradeep Kumar Chitrapu dev_kfree_skb(skb); 1584a41d1034SPradeep Kumar Chitrapu } 1585a41d1034SPradeep Kumar Chitrapu 1586a41d1034SPradeep Kumar Chitrapu ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 1587a41d1034SPradeep Kumar Chitrapu "WMI pdev get temperature for pdev_id %d\n", ar->pdev->pdev_id); 1588a41d1034SPradeep Kumar Chitrapu 1589a41d1034SPradeep Kumar Chitrapu return ret; 1590a41d1034SPradeep Kumar Chitrapu } 1591a41d1034SPradeep Kumar Chitrapu 1592d5c65159SKalle Valo int ath11k_wmi_send_bcn_offload_control_cmd(struct ath11k *ar, 1593d5c65159SKalle Valo u32 vdev_id, u32 bcn_ctrl_op) 1594d5c65159SKalle Valo { 1595d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 1596d5c65159SKalle Valo struct wmi_bcn_offload_ctrl_cmd *cmd; 1597d5c65159SKalle Valo struct sk_buff *skb; 1598d5c65159SKalle Valo int ret; 1599d5c65159SKalle Valo 16006bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd)); 1601d5c65159SKalle Valo if (!skb) 1602d5c65159SKalle Valo return -ENOMEM; 1603d5c65159SKalle Valo 1604d5c65159SKalle Valo cmd = (struct wmi_bcn_offload_ctrl_cmd *)skb->data; 1605d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, 1606d5c65159SKalle Valo WMI_TAG_BCN_OFFLOAD_CTRL_CMD) | 1607d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 1608d5c65159SKalle Valo 1609d5c65159SKalle Valo cmd->vdev_id = vdev_id; 1610d5c65159SKalle Valo cmd->bcn_ctrl_op = bcn_ctrl_op; 1611d5c65159SKalle Valo 1612d5c65159SKalle Valo ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 1613d5c65159SKalle Valo "WMI bcn ctrl offload vdev id %d ctrl_op %d\n", 1614d5c65159SKalle Valo vdev_id, bcn_ctrl_op); 1615d5c65159SKalle Valo 1616d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, WMI_BCN_OFFLOAD_CTRL_CMDID); 1617d5c65159SKalle Valo if (ret) { 1618d5c65159SKalle Valo ath11k_warn(ar->ab, 1619d5c65159SKalle Valo "failed to send WMI_BCN_OFFLOAD_CTRL_CMDID\n"); 1620d5c65159SKalle Valo dev_kfree_skb(skb); 1621d5c65159SKalle Valo } 1622d5c65159SKalle Valo 1623d5c65159SKalle Valo return ret; 1624d5c65159SKalle Valo } 1625d5c65159SKalle Valo 1626d5c65159SKalle Valo int ath11k_wmi_bcn_tmpl(struct ath11k *ar, u32 vdev_id, 1627d5c65159SKalle Valo struct ieee80211_mutable_offsets *offs, 1628d5c65159SKalle Valo struct sk_buff *bcn) 1629d5c65159SKalle Valo { 1630d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 1631d5c65159SKalle Valo struct wmi_bcn_tmpl_cmd *cmd; 1632d5c65159SKalle Valo struct wmi_bcn_prb_info *bcn_prb_info; 1633d5c65159SKalle Valo struct wmi_tlv *tlv; 1634d5c65159SKalle Valo struct sk_buff *skb; 1635d5c65159SKalle Valo void *ptr; 1636d5c65159SKalle Valo int ret, len; 1637d5c65159SKalle Valo size_t aligned_len = roundup(bcn->len, 4); 1638886433a9SJohn Crispin struct ieee80211_vif *vif; 1639886433a9SJohn Crispin struct ath11k_vif *arvif = ath11k_mac_get_arvif(ar, vdev_id); 1640886433a9SJohn Crispin 1641886433a9SJohn Crispin if (!arvif) { 1642886433a9SJohn Crispin ath11k_warn(ar->ab, "failed to find arvif with vdev id %d\n", vdev_id); 1643886433a9SJohn Crispin return -EINVAL; 1644886433a9SJohn Crispin } 1645886433a9SJohn Crispin 1646886433a9SJohn Crispin vif = arvif->vif; 1647d5c65159SKalle Valo 1648d5c65159SKalle Valo len = sizeof(*cmd) + sizeof(*bcn_prb_info) + TLV_HDR_SIZE + aligned_len; 1649d5c65159SKalle Valo 16506bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len); 1651d5c65159SKalle Valo if (!skb) 1652d5c65159SKalle Valo return -ENOMEM; 1653d5c65159SKalle Valo 1654d5c65159SKalle Valo cmd = (struct wmi_bcn_tmpl_cmd *)skb->data; 1655d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_BCN_TMPL_CMD) | 1656d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 1657d5c65159SKalle Valo cmd->vdev_id = vdev_id; 1658d5c65159SKalle Valo cmd->tim_ie_offset = offs->tim_offset; 1659886433a9SJohn Crispin 1660886433a9SJohn Crispin if (vif->csa_active) { 16618552a434SJohn Crispin cmd->csa_switch_count_offset = offs->cntdwn_counter_offs[0]; 16628552a434SJohn Crispin cmd->ext_csa_switch_count_offset = offs->cntdwn_counter_offs[1]; 1663886433a9SJohn Crispin } 1664886433a9SJohn Crispin 1665d5c65159SKalle Valo cmd->buf_len = bcn->len; 1666d5c65159SKalle Valo 1667d5c65159SKalle Valo ptr = skb->data + sizeof(*cmd); 1668d5c65159SKalle Valo 1669d5c65159SKalle Valo bcn_prb_info = ptr; 1670d5c65159SKalle Valo len = sizeof(*bcn_prb_info); 1671d5c65159SKalle Valo bcn_prb_info->tlv_header = FIELD_PREP(WMI_TLV_TAG, 1672d5c65159SKalle Valo WMI_TAG_BCN_PRB_INFO) | 1673d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, len - TLV_HDR_SIZE); 1674d5c65159SKalle Valo bcn_prb_info->caps = 0; 1675d5c65159SKalle Valo bcn_prb_info->erp = 0; 1676d5c65159SKalle Valo 1677d5c65159SKalle Valo ptr += sizeof(*bcn_prb_info); 1678d5c65159SKalle Valo 1679d5c65159SKalle Valo tlv = ptr; 1680d5c65159SKalle Valo tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_BYTE) | 1681d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, aligned_len); 1682d5c65159SKalle Valo memcpy(tlv->value, bcn->data, bcn->len); 1683d5c65159SKalle Valo 1684d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, WMI_BCN_TMPL_CMDID); 1685d5c65159SKalle Valo if (ret) { 1686d5c65159SKalle Valo ath11k_warn(ar->ab, "failed to send WMI_BCN_TMPL_CMDID\n"); 1687d5c65159SKalle Valo dev_kfree_skb(skb); 1688d5c65159SKalle Valo } 1689d5c65159SKalle Valo 1690d5c65159SKalle Valo return ret; 1691d5c65159SKalle Valo } 1692d5c65159SKalle Valo 1693d5c65159SKalle Valo int ath11k_wmi_vdev_install_key(struct ath11k *ar, 1694d5c65159SKalle Valo struct wmi_vdev_install_key_arg *arg) 1695d5c65159SKalle Valo { 1696d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 1697d5c65159SKalle Valo struct wmi_vdev_install_key_cmd *cmd; 1698d5c65159SKalle Valo struct wmi_tlv *tlv; 1699d5c65159SKalle Valo struct sk_buff *skb; 1700d5c65159SKalle Valo int ret, len; 1701d5c65159SKalle Valo int key_len_aligned = roundup(arg->key_len, sizeof(uint32_t)); 1702d5c65159SKalle Valo 1703d5c65159SKalle Valo len = sizeof(*cmd) + TLV_HDR_SIZE + key_len_aligned; 1704d5c65159SKalle Valo 17056bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len); 1706d5c65159SKalle Valo if (!skb) 1707d5c65159SKalle Valo return -ENOMEM; 1708d5c65159SKalle Valo 1709d5c65159SKalle Valo cmd = (struct wmi_vdev_install_key_cmd *)skb->data; 1710d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_VDEV_INSTALL_KEY_CMD) | 1711d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 1712d5c65159SKalle Valo cmd->vdev_id = arg->vdev_id; 1713d5c65159SKalle Valo ether_addr_copy(cmd->peer_macaddr.addr, arg->macaddr); 1714d5c65159SKalle Valo cmd->key_idx = arg->key_idx; 1715d5c65159SKalle Valo cmd->key_flags = arg->key_flags; 1716d5c65159SKalle Valo cmd->key_cipher = arg->key_cipher; 1717d5c65159SKalle Valo cmd->key_len = arg->key_len; 1718d5c65159SKalle Valo cmd->key_txmic_len = arg->key_txmic_len; 1719d5c65159SKalle Valo cmd->key_rxmic_len = arg->key_rxmic_len; 1720d5c65159SKalle Valo 1721d5c65159SKalle Valo if (arg->key_rsc_counter) 1722d5c65159SKalle Valo memcpy(&cmd->key_rsc_counter, &arg->key_rsc_counter, 1723d5c65159SKalle Valo sizeof(struct wmi_key_seq_counter)); 1724d5c65159SKalle Valo 1725d5c65159SKalle Valo tlv = (struct wmi_tlv *)(skb->data + sizeof(*cmd)); 1726d5c65159SKalle Valo tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_BYTE) | 1727d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, key_len_aligned); 1728*436a4e88SKarthikeyan Kathirvel if (arg->key_data) 1729d5c65159SKalle Valo memcpy(tlv->value, (u8 *)arg->key_data, key_len_aligned); 1730d5c65159SKalle Valo 1731d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, WMI_VDEV_INSTALL_KEY_CMDID); 1732d5c65159SKalle Valo if (ret) { 1733d5c65159SKalle Valo ath11k_warn(ar->ab, 1734d5c65159SKalle Valo "failed to send WMI_VDEV_INSTALL_KEY cmd\n"); 1735d5c65159SKalle Valo dev_kfree_skb(skb); 1736d5c65159SKalle Valo } 1737d5c65159SKalle Valo 1738d5c65159SKalle Valo ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 1739d5c65159SKalle Valo "WMI vdev install key idx %d cipher %d len %d\n", 1740d5c65159SKalle Valo arg->key_idx, arg->key_cipher, arg->key_len); 1741d5c65159SKalle Valo 1742d5c65159SKalle Valo return ret; 1743d5c65159SKalle Valo } 1744d5c65159SKalle Valo 1745d5c65159SKalle Valo static inline void 1746d5c65159SKalle Valo ath11k_wmi_copy_peer_flags(struct wmi_peer_assoc_complete_cmd *cmd, 17471daf58b2SSeevalamuthu Mariappan struct peer_assoc_params *param, 17481daf58b2SSeevalamuthu Mariappan bool hw_crypto_disabled) 1749d5c65159SKalle Valo { 1750d5c65159SKalle Valo cmd->peer_flags = 0; 1751d5c65159SKalle Valo 1752d5c65159SKalle Valo if (param->is_wme_set) { 1753d5c65159SKalle Valo if (param->qos_flag) 1754d5c65159SKalle Valo cmd->peer_flags |= WMI_PEER_QOS; 1755d5c65159SKalle Valo if (param->apsd_flag) 1756d5c65159SKalle Valo cmd->peer_flags |= WMI_PEER_APSD; 1757d5c65159SKalle Valo if (param->ht_flag) 1758d5c65159SKalle Valo cmd->peer_flags |= WMI_PEER_HT; 1759d5c65159SKalle Valo if (param->bw_40) 1760d5c65159SKalle Valo cmd->peer_flags |= WMI_PEER_40MHZ; 1761d5c65159SKalle Valo if (param->bw_80) 1762d5c65159SKalle Valo cmd->peer_flags |= WMI_PEER_80MHZ; 1763d5c65159SKalle Valo if (param->bw_160) 1764d5c65159SKalle Valo cmd->peer_flags |= WMI_PEER_160MHZ; 1765d5c65159SKalle Valo 1766d5c65159SKalle Valo /* Typically if STBC is enabled for VHT it should be enabled 1767d5c65159SKalle Valo * for HT as well 1768d5c65159SKalle Valo **/ 1769d5c65159SKalle Valo if (param->stbc_flag) 1770d5c65159SKalle Valo cmd->peer_flags |= WMI_PEER_STBC; 1771d5c65159SKalle Valo 1772d5c65159SKalle Valo /* Typically if LDPC is enabled for VHT it should be enabled 1773d5c65159SKalle Valo * for HT as well 1774d5c65159SKalle Valo **/ 1775d5c65159SKalle Valo if (param->ldpc_flag) 1776d5c65159SKalle Valo cmd->peer_flags |= WMI_PEER_LDPC; 1777d5c65159SKalle Valo 1778d5c65159SKalle Valo if (param->static_mimops_flag) 1779d5c65159SKalle Valo cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS; 1780d5c65159SKalle Valo if (param->dynamic_mimops_flag) 1781d5c65159SKalle Valo cmd->peer_flags |= WMI_PEER_DYN_MIMOPS; 1782d5c65159SKalle Valo if (param->spatial_mux_flag) 1783d5c65159SKalle Valo cmd->peer_flags |= WMI_PEER_SPATIAL_MUX; 1784d5c65159SKalle Valo if (param->vht_flag) 1785d5c65159SKalle Valo cmd->peer_flags |= WMI_PEER_VHT; 1786d5c65159SKalle Valo if (param->he_flag) 1787d5c65159SKalle Valo cmd->peer_flags |= WMI_PEER_HE; 17886d293d44SJohn Crispin if (param->twt_requester) 17896d293d44SJohn Crispin cmd->peer_flags |= WMI_PEER_TWT_REQ; 17906d293d44SJohn Crispin if (param->twt_responder) 17916d293d44SJohn Crispin cmd->peer_flags |= WMI_PEER_TWT_RESP; 1792d5c65159SKalle Valo } 1793d5c65159SKalle Valo 1794d5c65159SKalle Valo /* Suppress authorization for all AUTH modes that need 4-way handshake 1795d5c65159SKalle Valo * (during re-association). 1796d5c65159SKalle Valo * Authorization will be done for these modes on key installation. 1797d5c65159SKalle Valo */ 1798d5c65159SKalle Valo if (param->auth_flag) 1799d5c65159SKalle Valo cmd->peer_flags |= WMI_PEER_AUTH; 180001e34233SVenkateswara Naralasetty if (param->need_ptk_4_way) { 1801d5c65159SKalle Valo cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY; 1802c802b6d7SRameshkumar Sundaram if (!hw_crypto_disabled && param->is_assoc) 180301e34233SVenkateswara Naralasetty cmd->peer_flags &= ~WMI_PEER_AUTH; 180401e34233SVenkateswara Naralasetty } 1805d5c65159SKalle Valo if (param->need_gtk_2_way) 1806d5c65159SKalle Valo cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY; 1807d5c65159SKalle Valo /* safe mode bypass the 4-way handshake */ 1808d5c65159SKalle Valo if (param->safe_mode_enabled) 1809d5c65159SKalle Valo cmd->peer_flags &= ~(WMI_PEER_NEED_PTK_4_WAY | 1810d5c65159SKalle Valo WMI_PEER_NEED_GTK_2_WAY); 1811d5c65159SKalle Valo 1812d5c65159SKalle Valo if (param->is_pmf_enabled) 1813d5c65159SKalle Valo cmd->peer_flags |= WMI_PEER_PMF; 1814d5c65159SKalle Valo 1815d5c65159SKalle Valo /* Disable AMSDU for station transmit, if user configures it */ 1816d5c65159SKalle Valo /* Disable AMSDU for AP transmit to 11n Stations, if user configures 1817d5c65159SKalle Valo * it 1818d5c65159SKalle Valo * if (param->amsdu_disable) Add after FW support 1819d5c65159SKalle Valo **/ 1820d5c65159SKalle Valo 1821d5c65159SKalle Valo /* Target asserts if node is marked HT and all MCS is set to 0. 1822d5c65159SKalle Valo * Mark the node as non-HT if all the mcs rates are disabled through 1823d5c65159SKalle Valo * iwpriv 1824d5c65159SKalle Valo **/ 1825d5c65159SKalle Valo if (param->peer_ht_rates.num_rates == 0) 1826d5c65159SKalle Valo cmd->peer_flags &= ~WMI_PEER_HT; 1827d5c65159SKalle Valo } 1828d5c65159SKalle Valo 1829d5c65159SKalle Valo int ath11k_wmi_send_peer_assoc_cmd(struct ath11k *ar, 1830d5c65159SKalle Valo struct peer_assoc_params *param) 1831d5c65159SKalle Valo { 1832d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 1833d5c65159SKalle Valo struct wmi_peer_assoc_complete_cmd *cmd; 1834d5c65159SKalle Valo struct wmi_vht_rate_set *mcs; 1835d5c65159SKalle Valo struct wmi_he_rate_set *he_mcs; 1836d5c65159SKalle Valo struct sk_buff *skb; 1837d5c65159SKalle Valo struct wmi_tlv *tlv; 1838d5c65159SKalle Valo void *ptr; 1839d5c65159SKalle Valo u32 peer_legacy_rates_align; 1840d5c65159SKalle Valo u32 peer_ht_rates_align; 1841d5c65159SKalle Valo int i, ret, len; 1842d5c65159SKalle Valo 1843d5c65159SKalle Valo peer_legacy_rates_align = roundup(param->peer_legacy_rates.num_rates, 1844d5c65159SKalle Valo sizeof(u32)); 1845d5c65159SKalle Valo peer_ht_rates_align = roundup(param->peer_ht_rates.num_rates, 1846d5c65159SKalle Valo sizeof(u32)); 1847d5c65159SKalle Valo 1848d5c65159SKalle Valo len = sizeof(*cmd) + 1849d5c65159SKalle Valo TLV_HDR_SIZE + (peer_legacy_rates_align * sizeof(u8)) + 1850d5c65159SKalle Valo TLV_HDR_SIZE + (peer_ht_rates_align * sizeof(u8)) + 1851d5c65159SKalle Valo sizeof(*mcs) + TLV_HDR_SIZE + 1852d5c65159SKalle Valo (sizeof(*he_mcs) * param->peer_he_mcs_count); 1853d5c65159SKalle Valo 18546bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len); 1855d5c65159SKalle Valo if (!skb) 1856d5c65159SKalle Valo return -ENOMEM; 1857d5c65159SKalle Valo 1858d5c65159SKalle Valo ptr = skb->data; 1859d5c65159SKalle Valo 1860d5c65159SKalle Valo cmd = ptr; 1861d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, 1862d5c65159SKalle Valo WMI_TAG_PEER_ASSOC_COMPLETE_CMD) | 1863d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 1864d5c65159SKalle Valo 1865d5c65159SKalle Valo cmd->vdev_id = param->vdev_id; 1866d5c65159SKalle Valo 1867d5c65159SKalle Valo cmd->peer_new_assoc = param->peer_new_assoc; 1868d5c65159SKalle Valo cmd->peer_associd = param->peer_associd; 1869d5c65159SKalle Valo 18701daf58b2SSeevalamuthu Mariappan ath11k_wmi_copy_peer_flags(cmd, param, 18711daf58b2SSeevalamuthu Mariappan test_bit(ATH11K_FLAG_HW_CRYPTO_DISABLED, 18721daf58b2SSeevalamuthu Mariappan &ar->ab->dev_flags)); 1873d5c65159SKalle Valo 1874d5c65159SKalle Valo ether_addr_copy(cmd->peer_macaddr.addr, param->peer_mac); 1875d5c65159SKalle Valo 1876d5c65159SKalle Valo cmd->peer_rate_caps = param->peer_rate_caps; 1877d5c65159SKalle Valo cmd->peer_caps = param->peer_caps; 1878d5c65159SKalle Valo cmd->peer_listen_intval = param->peer_listen_intval; 1879d5c65159SKalle Valo cmd->peer_ht_caps = param->peer_ht_caps; 1880d5c65159SKalle Valo cmd->peer_max_mpdu = param->peer_max_mpdu; 1881d5c65159SKalle Valo cmd->peer_mpdu_density = param->peer_mpdu_density; 1882d5c65159SKalle Valo cmd->peer_vht_caps = param->peer_vht_caps; 1883d5c65159SKalle Valo cmd->peer_phymode = param->peer_phymode; 1884d5c65159SKalle Valo 1885d5c65159SKalle Valo /* Update 11ax capabilities */ 1886d5c65159SKalle Valo cmd->peer_he_cap_info = param->peer_he_cap_macinfo[0]; 1887d5c65159SKalle Valo cmd->peer_he_cap_info_ext = param->peer_he_cap_macinfo[1]; 1888d5c65159SKalle Valo cmd->peer_he_cap_info_internal = param->peer_he_cap_macinfo_internal; 188991270d70SPradeep Kumar Chitrapu cmd->peer_he_caps_6ghz = param->peer_he_caps_6ghz; 1890d5c65159SKalle Valo cmd->peer_he_ops = param->peer_he_ops; 1891d5c65159SKalle Valo memcpy(&cmd->peer_he_cap_phy, ¶m->peer_he_cap_phyinfo, 1892d5c65159SKalle Valo sizeof(param->peer_he_cap_phyinfo)); 1893d5c65159SKalle Valo memcpy(&cmd->peer_ppet, ¶m->peer_ppet, 1894d5c65159SKalle Valo sizeof(param->peer_ppet)); 1895d5c65159SKalle Valo 1896d5c65159SKalle Valo /* Update peer legacy rate information */ 1897d5c65159SKalle Valo ptr += sizeof(*cmd); 1898d5c65159SKalle Valo 1899d5c65159SKalle Valo tlv = ptr; 1900d5c65159SKalle Valo tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_BYTE) | 1901d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, peer_legacy_rates_align); 1902d5c65159SKalle Valo 1903d5c65159SKalle Valo ptr += TLV_HDR_SIZE; 1904d5c65159SKalle Valo 1905d5c65159SKalle Valo cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates; 1906d5c65159SKalle Valo memcpy(ptr, param->peer_legacy_rates.rates, 1907d5c65159SKalle Valo param->peer_legacy_rates.num_rates); 1908d5c65159SKalle Valo 1909d5c65159SKalle Valo /* Update peer HT rate information */ 1910d5c65159SKalle Valo ptr += peer_legacy_rates_align; 1911d5c65159SKalle Valo 1912d5c65159SKalle Valo tlv = ptr; 1913d5c65159SKalle Valo tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_BYTE) | 1914d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, peer_ht_rates_align); 1915d5c65159SKalle Valo ptr += TLV_HDR_SIZE; 1916d5c65159SKalle Valo cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates; 1917d5c65159SKalle Valo memcpy(ptr, param->peer_ht_rates.rates, 1918d5c65159SKalle Valo param->peer_ht_rates.num_rates); 1919d5c65159SKalle Valo 1920d5c65159SKalle Valo /* VHT Rates */ 1921d5c65159SKalle Valo ptr += peer_ht_rates_align; 1922d5c65159SKalle Valo 1923d5c65159SKalle Valo mcs = ptr; 1924d5c65159SKalle Valo 1925d5c65159SKalle Valo mcs->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_VHT_RATE_SET) | 1926d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*mcs) - TLV_HDR_SIZE); 1927d5c65159SKalle Valo 1928d5c65159SKalle Valo cmd->peer_nss = param->peer_nss; 1929d5c65159SKalle Valo 1930d5c65159SKalle Valo /* Update bandwidth-NSS mapping */ 1931d5c65159SKalle Valo cmd->peer_bw_rxnss_override = 0; 1932d5c65159SKalle Valo cmd->peer_bw_rxnss_override |= param->peer_bw_rxnss_override; 1933d5c65159SKalle Valo 1934d5c65159SKalle Valo if (param->vht_capable) { 1935d5c65159SKalle Valo mcs->rx_max_rate = param->rx_max_rate; 1936d5c65159SKalle Valo mcs->rx_mcs_set = param->rx_mcs_set; 1937d5c65159SKalle Valo mcs->tx_max_rate = param->tx_max_rate; 1938d5c65159SKalle Valo mcs->tx_mcs_set = param->tx_mcs_set; 1939d5c65159SKalle Valo } 1940d5c65159SKalle Valo 1941d5c65159SKalle Valo /* HE Rates */ 1942d5c65159SKalle Valo cmd->peer_he_mcs = param->peer_he_mcs_count; 194391270d70SPradeep Kumar Chitrapu cmd->min_data_rate = param->min_data_rate; 1944d5c65159SKalle Valo 1945d5c65159SKalle Valo ptr += sizeof(*mcs); 1946d5c65159SKalle Valo 1947d5c65159SKalle Valo len = param->peer_he_mcs_count * sizeof(*he_mcs); 1948d5c65159SKalle Valo 1949d5c65159SKalle Valo tlv = ptr; 1950d5c65159SKalle Valo tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_STRUCT) | 1951d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, len); 1952d5c65159SKalle Valo ptr += TLV_HDR_SIZE; 1953d5c65159SKalle Valo 1954d5c65159SKalle Valo /* Loop through the HE rate set */ 1955d5c65159SKalle Valo for (i = 0; i < param->peer_he_mcs_count; i++) { 1956d5c65159SKalle Valo he_mcs = ptr; 1957d5c65159SKalle Valo he_mcs->tlv_header = FIELD_PREP(WMI_TLV_TAG, 1958d5c65159SKalle Valo WMI_TAG_HE_RATE_SET) | 1959d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, 1960d5c65159SKalle Valo sizeof(*he_mcs) - TLV_HDR_SIZE); 1961d5c65159SKalle Valo 196261fe43e7SMiles Hu he_mcs->rx_mcs_set = param->peer_he_tx_mcs_set[i]; 196361fe43e7SMiles Hu he_mcs->tx_mcs_set = param->peer_he_rx_mcs_set[i]; 1964d5c65159SKalle Valo ptr += sizeof(*he_mcs); 1965d5c65159SKalle Valo } 1966d5c65159SKalle Valo 1967d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, WMI_PEER_ASSOC_CMDID); 1968d5c65159SKalle Valo if (ret) { 1969d5c65159SKalle Valo ath11k_warn(ar->ab, 1970d5c65159SKalle Valo "failed to send WMI_PEER_ASSOC_CMDID\n"); 1971d5c65159SKalle Valo dev_kfree_skb(skb); 1972d5c65159SKalle Valo } 1973d5c65159SKalle Valo 1974d5c65159SKalle Valo ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 19751cb616a3SSriram R "wmi peer assoc vdev id %d assoc id %d peer mac %pM peer_flags %x rate_caps %x peer_caps %x listen_intval %d ht_caps %x max_mpdu %d nss %d phymode %d peer_mpdu_density %d vht_caps %x he cap_info %x he ops %x he cap_info_ext %x he phy %x %x %x peer_bw_rxnss_override %x\n", 19761cb616a3SSriram R cmd->vdev_id, cmd->peer_associd, param->peer_mac, 19771cb616a3SSriram R cmd->peer_flags, cmd->peer_rate_caps, cmd->peer_caps, 19781cb616a3SSriram R cmd->peer_listen_intval, cmd->peer_ht_caps, 19791cb616a3SSriram R cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode, 19801cb616a3SSriram R cmd->peer_mpdu_density, 19811cb616a3SSriram R cmd->peer_vht_caps, cmd->peer_he_cap_info, 19821cb616a3SSriram R cmd->peer_he_ops, cmd->peer_he_cap_info_ext, 19831cb616a3SSriram R cmd->peer_he_cap_phy[0], cmd->peer_he_cap_phy[1], 19841cb616a3SSriram R cmd->peer_he_cap_phy[2], 19851cb616a3SSriram R cmd->peer_bw_rxnss_override); 1986d5c65159SKalle Valo 1987d5c65159SKalle Valo return ret; 1988d5c65159SKalle Valo } 1989d5c65159SKalle Valo 1990d5c65159SKalle Valo void ath11k_wmi_start_scan_init(struct ath11k *ar, 1991d5c65159SKalle Valo struct scan_req_params *arg) 1992d5c65159SKalle Valo { 1993d5c65159SKalle Valo /* setup commonly used values */ 1994d5c65159SKalle Valo arg->scan_req_id = 1; 1995d5c65159SKalle Valo arg->scan_priority = WMI_SCAN_PRIORITY_LOW; 1996d5c65159SKalle Valo arg->dwell_time_active = 50; 1997d5c65159SKalle Valo arg->dwell_time_active_2g = 0; 1998d5c65159SKalle Valo arg->dwell_time_passive = 150; 1999194b8ea1SPradeep Kumar Chitrapu arg->dwell_time_active_6g = 40; 2000194b8ea1SPradeep Kumar Chitrapu arg->dwell_time_passive_6g = 30; 2001d5c65159SKalle Valo arg->min_rest_time = 50; 2002d5c65159SKalle Valo arg->max_rest_time = 500; 2003d5c65159SKalle Valo arg->repeat_probe_time = 0; 2004d5c65159SKalle Valo arg->probe_spacing_time = 0; 2005d5c65159SKalle Valo arg->idle_time = 0; 2006d5c65159SKalle Valo arg->max_scan_time = 20000; 2007d5c65159SKalle Valo arg->probe_delay = 5; 2008d5c65159SKalle Valo arg->notify_scan_events = WMI_SCAN_EVENT_STARTED | 2009d5c65159SKalle Valo WMI_SCAN_EVENT_COMPLETED | 2010d5c65159SKalle Valo WMI_SCAN_EVENT_BSS_CHANNEL | 2011d5c65159SKalle Valo WMI_SCAN_EVENT_FOREIGN_CHAN | 2012d5c65159SKalle Valo WMI_SCAN_EVENT_DEQUEUED; 2013d5c65159SKalle Valo arg->scan_flags |= WMI_SCAN_CHAN_STAT_EVENT; 2014d5c65159SKalle Valo arg->num_bssid = 1; 2015fa7572c2SCarl Huang 2016fa7572c2SCarl Huang /* fill bssid_list[0] with 0xff, otherwise bssid and RA will be 2017fa7572c2SCarl Huang * ZEROs in probe request 2018fa7572c2SCarl Huang */ 2019fa7572c2SCarl Huang eth_broadcast_addr(arg->bssid_list[0].addr); 2020d5c65159SKalle Valo } 2021d5c65159SKalle Valo 2022d5c65159SKalle Valo static inline void 2023d5c65159SKalle Valo ath11k_wmi_copy_scan_event_cntrl_flags(struct wmi_start_scan_cmd *cmd, 2024d5c65159SKalle Valo struct scan_req_params *param) 2025d5c65159SKalle Valo { 2026d5c65159SKalle Valo /* Scan events subscription */ 2027d5c65159SKalle Valo if (param->scan_ev_started) 2028d5c65159SKalle Valo cmd->notify_scan_events |= WMI_SCAN_EVENT_STARTED; 2029d5c65159SKalle Valo if (param->scan_ev_completed) 2030d5c65159SKalle Valo cmd->notify_scan_events |= WMI_SCAN_EVENT_COMPLETED; 2031d5c65159SKalle Valo if (param->scan_ev_bss_chan) 2032d5c65159SKalle Valo cmd->notify_scan_events |= WMI_SCAN_EVENT_BSS_CHANNEL; 2033d5c65159SKalle Valo if (param->scan_ev_foreign_chan) 2034d5c65159SKalle Valo cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHAN; 2035d5c65159SKalle Valo if (param->scan_ev_dequeued) 2036d5c65159SKalle Valo cmd->notify_scan_events |= WMI_SCAN_EVENT_DEQUEUED; 2037d5c65159SKalle Valo if (param->scan_ev_preempted) 2038d5c65159SKalle Valo cmd->notify_scan_events |= WMI_SCAN_EVENT_PREEMPTED; 2039d5c65159SKalle Valo if (param->scan_ev_start_failed) 2040d5c65159SKalle Valo cmd->notify_scan_events |= WMI_SCAN_EVENT_START_FAILED; 2041d5c65159SKalle Valo if (param->scan_ev_restarted) 2042d5c65159SKalle Valo cmd->notify_scan_events |= WMI_SCAN_EVENT_RESTARTED; 2043d5c65159SKalle Valo if (param->scan_ev_foreign_chn_exit) 2044d5c65159SKalle Valo cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHAN_EXIT; 2045d5c65159SKalle Valo if (param->scan_ev_suspended) 2046d5c65159SKalle Valo cmd->notify_scan_events |= WMI_SCAN_EVENT_SUSPENDED; 2047d5c65159SKalle Valo if (param->scan_ev_resumed) 2048d5c65159SKalle Valo cmd->notify_scan_events |= WMI_SCAN_EVENT_RESUMED; 2049d5c65159SKalle Valo 2050d5c65159SKalle Valo /** Set scan control flags */ 2051d5c65159SKalle Valo cmd->scan_ctrl_flags = 0; 2052d5c65159SKalle Valo if (param->scan_f_passive) 2053d5c65159SKalle Valo cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_PASSIVE; 2054d5c65159SKalle Valo if (param->scan_f_strict_passive_pch) 2055d5c65159SKalle Valo cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_STRICT_PASSIVE_ON_PCHN; 2056d5c65159SKalle Valo if (param->scan_f_promisc_mode) 2057d5c65159SKalle Valo cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROMISCUOS; 2058d5c65159SKalle Valo if (param->scan_f_capture_phy_err) 2059d5c65159SKalle Valo cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR; 2060d5c65159SKalle Valo if (param->scan_f_half_rate) 2061d5c65159SKalle Valo cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_HALF_RATE_SUPPORT; 2062d5c65159SKalle Valo if (param->scan_f_quarter_rate) 2063d5c65159SKalle Valo cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_QUARTER_RATE_SUPPORT; 2064d5c65159SKalle Valo if (param->scan_f_cck_rates) 2065d5c65159SKalle Valo cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES; 2066d5c65159SKalle Valo if (param->scan_f_ofdm_rates) 2067d5c65159SKalle Valo cmd->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES; 2068d5c65159SKalle Valo if (param->scan_f_chan_stat_evnt) 2069d5c65159SKalle Valo cmd->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT; 2070d5c65159SKalle Valo if (param->scan_f_filter_prb_req) 2071d5c65159SKalle Valo cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROBE_REQ; 2072d5c65159SKalle Valo if (param->scan_f_bcast_probe) 2073d5c65159SKalle Valo cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ; 2074d5c65159SKalle Valo if (param->scan_f_offchan_mgmt_tx) 2075d5c65159SKalle Valo cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_MGMT_TX; 2076d5c65159SKalle Valo if (param->scan_f_offchan_data_tx) 2077d5c65159SKalle Valo cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_DATA_TX; 2078d5c65159SKalle Valo if (param->scan_f_force_active_dfs_chn) 2079d5c65159SKalle Valo cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_FORCE_ACTIVE_ON_DFS; 2080d5c65159SKalle Valo if (param->scan_f_add_tpc_ie_in_probe) 2081d5c65159SKalle Valo cmd->scan_ctrl_flags |= WMI_SCAN_ADD_TPC_IE_IN_PROBE_REQ; 2082d5c65159SKalle Valo if (param->scan_f_add_ds_ie_in_probe) 2083d5c65159SKalle Valo cmd->scan_ctrl_flags |= WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ; 2084d5c65159SKalle Valo if (param->scan_f_add_spoofed_mac_in_probe) 2085d5c65159SKalle Valo cmd->scan_ctrl_flags |= WMI_SCAN_ADD_SPOOF_MAC_IN_PROBE_REQ; 2086d5c65159SKalle Valo if (param->scan_f_add_rand_seq_in_probe) 2087d5c65159SKalle Valo cmd->scan_ctrl_flags |= WMI_SCAN_RANDOM_SEQ_NO_IN_PROBE_REQ; 2088d5c65159SKalle Valo if (param->scan_f_en_ie_whitelist_in_probe) 2089d5c65159SKalle Valo cmd->scan_ctrl_flags |= 2090d5c65159SKalle Valo WMI_SCAN_ENABLE_IE_WHTELIST_IN_PROBE_REQ; 2091d5c65159SKalle Valo 2092d5c65159SKalle Valo /* for adaptive scan mode using 3 bits (21 - 23 bits) */ 2093d5c65159SKalle Valo WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags, 2094d5c65159SKalle Valo param->adaptive_dwell_time_mode); 2095d5c65159SKalle Valo } 2096d5c65159SKalle Valo 2097d5c65159SKalle Valo int ath11k_wmi_send_scan_start_cmd(struct ath11k *ar, 2098d5c65159SKalle Valo struct scan_req_params *params) 2099d5c65159SKalle Valo { 2100d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 2101d5c65159SKalle Valo struct wmi_start_scan_cmd *cmd; 2102d5c65159SKalle Valo struct wmi_ssid *ssid = NULL; 2103d5c65159SKalle Valo struct wmi_mac_addr *bssid; 2104d5c65159SKalle Valo struct sk_buff *skb; 2105d5c65159SKalle Valo struct wmi_tlv *tlv; 2106d5c65159SKalle Valo void *ptr; 2107d5c65159SKalle Valo int i, ret, len; 2108d5c65159SKalle Valo u32 *tmp_ptr; 2109d5c65159SKalle Valo u8 extraie_len_with_pad = 0; 211074601ecfSPradeep Kumar Chitrapu struct hint_short_ssid *s_ssid = NULL; 211174601ecfSPradeep Kumar Chitrapu struct hint_bssid *hint_bssid = NULL; 2112d5c65159SKalle Valo 2113d5c65159SKalle Valo len = sizeof(*cmd); 2114d5c65159SKalle Valo 2115d5c65159SKalle Valo len += TLV_HDR_SIZE; 2116d5c65159SKalle Valo if (params->num_chan) 2117d5c65159SKalle Valo len += params->num_chan * sizeof(u32); 2118d5c65159SKalle Valo 2119d5c65159SKalle Valo len += TLV_HDR_SIZE; 2120d5c65159SKalle Valo if (params->num_ssids) 2121d5c65159SKalle Valo len += params->num_ssids * sizeof(*ssid); 2122d5c65159SKalle Valo 2123d5c65159SKalle Valo len += TLV_HDR_SIZE; 2124d5c65159SKalle Valo if (params->num_bssid) 2125d5c65159SKalle Valo len += sizeof(*bssid) * params->num_bssid; 2126d5c65159SKalle Valo 2127d5c65159SKalle Valo len += TLV_HDR_SIZE; 2128d5c65159SKalle Valo if (params->extraie.len) 2129d5c65159SKalle Valo extraie_len_with_pad = 2130d5c65159SKalle Valo roundup(params->extraie.len, sizeof(u32)); 2131d5c65159SKalle Valo len += extraie_len_with_pad; 2132d5c65159SKalle Valo 213374601ecfSPradeep Kumar Chitrapu if (params->num_hint_bssid) 213474601ecfSPradeep Kumar Chitrapu len += TLV_HDR_SIZE + 213574601ecfSPradeep Kumar Chitrapu params->num_hint_bssid * sizeof(struct hint_bssid); 213674601ecfSPradeep Kumar Chitrapu 213774601ecfSPradeep Kumar Chitrapu if (params->num_hint_s_ssid) 213874601ecfSPradeep Kumar Chitrapu len += TLV_HDR_SIZE + 213974601ecfSPradeep Kumar Chitrapu params->num_hint_s_ssid * sizeof(struct hint_short_ssid); 214074601ecfSPradeep Kumar Chitrapu 21416bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len); 2142d5c65159SKalle Valo if (!skb) 2143d5c65159SKalle Valo return -ENOMEM; 2144d5c65159SKalle Valo 2145d5c65159SKalle Valo ptr = skb->data; 2146d5c65159SKalle Valo 2147d5c65159SKalle Valo cmd = ptr; 2148d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_START_SCAN_CMD) | 2149d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 2150d5c65159SKalle Valo 2151d5c65159SKalle Valo cmd->scan_id = params->scan_id; 2152d5c65159SKalle Valo cmd->scan_req_id = params->scan_req_id; 2153d5c65159SKalle Valo cmd->vdev_id = params->vdev_id; 2154d5c65159SKalle Valo cmd->scan_priority = params->scan_priority; 2155d5c65159SKalle Valo cmd->notify_scan_events = params->notify_scan_events; 2156d5c65159SKalle Valo 2157d5c65159SKalle Valo ath11k_wmi_copy_scan_event_cntrl_flags(cmd, params); 2158d5c65159SKalle Valo 2159d5c65159SKalle Valo cmd->dwell_time_active = params->dwell_time_active; 2160d5c65159SKalle Valo cmd->dwell_time_active_2g = params->dwell_time_active_2g; 2161d5c65159SKalle Valo cmd->dwell_time_passive = params->dwell_time_passive; 2162194b8ea1SPradeep Kumar Chitrapu cmd->dwell_time_active_6g = params->dwell_time_active_6g; 2163194b8ea1SPradeep Kumar Chitrapu cmd->dwell_time_passive_6g = params->dwell_time_passive_6g; 2164d5c65159SKalle Valo cmd->min_rest_time = params->min_rest_time; 2165d5c65159SKalle Valo cmd->max_rest_time = params->max_rest_time; 2166d5c65159SKalle Valo cmd->repeat_probe_time = params->repeat_probe_time; 2167d5c65159SKalle Valo cmd->probe_spacing_time = params->probe_spacing_time; 2168d5c65159SKalle Valo cmd->idle_time = params->idle_time; 2169d5c65159SKalle Valo cmd->max_scan_time = params->max_scan_time; 2170d5c65159SKalle Valo cmd->probe_delay = params->probe_delay; 2171d5c65159SKalle Valo cmd->burst_duration = params->burst_duration; 2172d5c65159SKalle Valo cmd->num_chan = params->num_chan; 2173d5c65159SKalle Valo cmd->num_bssid = params->num_bssid; 2174d5c65159SKalle Valo cmd->num_ssids = params->num_ssids; 2175d5c65159SKalle Valo cmd->ie_len = params->extraie.len; 2176d5c65159SKalle Valo cmd->n_probes = params->n_probes; 2177d5c65159SKalle Valo 2178d5c65159SKalle Valo ptr += sizeof(*cmd); 2179d5c65159SKalle Valo 2180d5c65159SKalle Valo len = params->num_chan * sizeof(u32); 2181d5c65159SKalle Valo 2182d5c65159SKalle Valo tlv = ptr; 2183d5c65159SKalle Valo tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_UINT32) | 2184d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, len); 2185d5c65159SKalle Valo ptr += TLV_HDR_SIZE; 2186d5c65159SKalle Valo tmp_ptr = (u32 *)ptr; 2187d5c65159SKalle Valo 2188d5c65159SKalle Valo for (i = 0; i < params->num_chan; ++i) 2189d5c65159SKalle Valo tmp_ptr[i] = params->chan_list[i]; 2190d5c65159SKalle Valo 2191d5c65159SKalle Valo ptr += len; 2192d5c65159SKalle Valo 2193d5c65159SKalle Valo len = params->num_ssids * sizeof(*ssid); 2194d5c65159SKalle Valo tlv = ptr; 2195d5c65159SKalle Valo tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_FIXED_STRUCT) | 2196d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, len); 2197d5c65159SKalle Valo 2198d5c65159SKalle Valo ptr += TLV_HDR_SIZE; 2199d5c65159SKalle Valo 2200d5c65159SKalle Valo if (params->num_ssids) { 2201d5c65159SKalle Valo ssid = ptr; 2202d5c65159SKalle Valo for (i = 0; i < params->num_ssids; ++i) { 2203d5c65159SKalle Valo ssid->ssid_len = params->ssid[i].length; 2204d5c65159SKalle Valo memcpy(ssid->ssid, params->ssid[i].ssid, 2205d5c65159SKalle Valo params->ssid[i].length); 2206d5c65159SKalle Valo ssid++; 2207d5c65159SKalle Valo } 2208d5c65159SKalle Valo } 2209d5c65159SKalle Valo 2210d5c65159SKalle Valo ptr += (params->num_ssids * sizeof(*ssid)); 2211d5c65159SKalle Valo len = params->num_bssid * sizeof(*bssid); 2212d5c65159SKalle Valo tlv = ptr; 2213d5c65159SKalle Valo tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_FIXED_STRUCT) | 2214d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, len); 2215d5c65159SKalle Valo 2216d5c65159SKalle Valo ptr += TLV_HDR_SIZE; 2217d5c65159SKalle Valo bssid = ptr; 2218d5c65159SKalle Valo 2219d5c65159SKalle Valo if (params->num_bssid) { 2220d5c65159SKalle Valo for (i = 0; i < params->num_bssid; ++i) { 2221d5c65159SKalle Valo ether_addr_copy(bssid->addr, 2222d5c65159SKalle Valo params->bssid_list[i].addr); 2223d5c65159SKalle Valo bssid++; 2224d5c65159SKalle Valo } 2225d5c65159SKalle Valo } 2226d5c65159SKalle Valo 2227d5c65159SKalle Valo ptr += params->num_bssid * sizeof(*bssid); 2228d5c65159SKalle Valo 2229d5c65159SKalle Valo len = extraie_len_with_pad; 2230d5c65159SKalle Valo tlv = ptr; 2231d5c65159SKalle Valo tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_BYTE) | 2232d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, len); 2233d5c65159SKalle Valo ptr += TLV_HDR_SIZE; 2234d5c65159SKalle Valo 2235d5c65159SKalle Valo if (params->extraie.len) 2236d5c65159SKalle Valo memcpy(ptr, params->extraie.ptr, 2237d5c65159SKalle Valo params->extraie.len); 2238d5c65159SKalle Valo 2239d5c65159SKalle Valo ptr += extraie_len_with_pad; 2240d5c65159SKalle Valo 224174601ecfSPradeep Kumar Chitrapu if (params->num_hint_s_ssid) { 224274601ecfSPradeep Kumar Chitrapu len = params->num_hint_s_ssid * sizeof(struct hint_short_ssid); 224374601ecfSPradeep Kumar Chitrapu tlv = ptr; 224474601ecfSPradeep Kumar Chitrapu tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_FIXED_STRUCT) | 224574601ecfSPradeep Kumar Chitrapu FIELD_PREP(WMI_TLV_LEN, len); 224674601ecfSPradeep Kumar Chitrapu ptr += TLV_HDR_SIZE; 224774601ecfSPradeep Kumar Chitrapu s_ssid = ptr; 224874601ecfSPradeep Kumar Chitrapu for (i = 0; i < params->num_hint_s_ssid; ++i) { 224974601ecfSPradeep Kumar Chitrapu s_ssid->freq_flags = params->hint_s_ssid[i].freq_flags; 225074601ecfSPradeep Kumar Chitrapu s_ssid->short_ssid = params->hint_s_ssid[i].short_ssid; 225174601ecfSPradeep Kumar Chitrapu s_ssid++; 225274601ecfSPradeep Kumar Chitrapu } 225374601ecfSPradeep Kumar Chitrapu ptr += len; 225474601ecfSPradeep Kumar Chitrapu } 225574601ecfSPradeep Kumar Chitrapu 225674601ecfSPradeep Kumar Chitrapu if (params->num_hint_bssid) { 225774601ecfSPradeep Kumar Chitrapu len = params->num_hint_bssid * sizeof(struct hint_bssid); 225874601ecfSPradeep Kumar Chitrapu tlv = ptr; 225974601ecfSPradeep Kumar Chitrapu tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_FIXED_STRUCT) | 226074601ecfSPradeep Kumar Chitrapu FIELD_PREP(WMI_TLV_LEN, len); 226174601ecfSPradeep Kumar Chitrapu ptr += TLV_HDR_SIZE; 226274601ecfSPradeep Kumar Chitrapu hint_bssid = ptr; 226374601ecfSPradeep Kumar Chitrapu for (i = 0; i < params->num_hint_bssid; ++i) { 226474601ecfSPradeep Kumar Chitrapu hint_bssid->freq_flags = 226574601ecfSPradeep Kumar Chitrapu params->hint_bssid[i].freq_flags; 226674601ecfSPradeep Kumar Chitrapu ether_addr_copy(¶ms->hint_bssid[i].bssid.addr[0], 226774601ecfSPradeep Kumar Chitrapu &hint_bssid->bssid.addr[0]); 226874601ecfSPradeep Kumar Chitrapu hint_bssid++; 226974601ecfSPradeep Kumar Chitrapu } 227074601ecfSPradeep Kumar Chitrapu } 227174601ecfSPradeep Kumar Chitrapu 2272d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, 2273d5c65159SKalle Valo WMI_START_SCAN_CMDID); 2274d5c65159SKalle Valo if (ret) { 2275d5c65159SKalle Valo ath11k_warn(ar->ab, "failed to send WMI_START_SCAN_CMDID\n"); 2276d5c65159SKalle Valo dev_kfree_skb(skb); 2277d5c65159SKalle Valo } 2278d5c65159SKalle Valo 2279d5c65159SKalle Valo return ret; 2280d5c65159SKalle Valo } 2281d5c65159SKalle Valo 2282d5c65159SKalle Valo int ath11k_wmi_send_scan_stop_cmd(struct ath11k *ar, 2283d5c65159SKalle Valo struct scan_cancel_param *param) 2284d5c65159SKalle Valo { 2285d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 2286d5c65159SKalle Valo struct wmi_stop_scan_cmd *cmd; 2287d5c65159SKalle Valo struct sk_buff *skb; 2288d5c65159SKalle Valo int ret; 2289d5c65159SKalle Valo 22906bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd)); 2291d5c65159SKalle Valo if (!skb) 2292d5c65159SKalle Valo return -ENOMEM; 2293d5c65159SKalle Valo 2294d5c65159SKalle Valo cmd = (struct wmi_stop_scan_cmd *)skb->data; 2295d5c65159SKalle Valo 2296d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_STOP_SCAN_CMD) | 2297d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 2298d5c65159SKalle Valo 2299d5c65159SKalle Valo cmd->vdev_id = param->vdev_id; 2300d5c65159SKalle Valo cmd->requestor = param->requester; 2301d5c65159SKalle Valo cmd->scan_id = param->scan_id; 2302d5c65159SKalle Valo cmd->pdev_id = param->pdev_id; 2303d5c65159SKalle Valo /* stop the scan with the corresponding scan_id */ 2304d5c65159SKalle Valo if (param->req_type == WLAN_SCAN_CANCEL_PDEV_ALL) { 2305d5c65159SKalle Valo /* Cancelling all scans */ 2306d5c65159SKalle Valo cmd->req_type = WMI_SCAN_STOP_ALL; 2307d5c65159SKalle Valo } else if (param->req_type == WLAN_SCAN_CANCEL_VDEV_ALL) { 2308d5c65159SKalle Valo /* Cancelling VAP scans */ 2309d5c65159SKalle Valo cmd->req_type = WMI_SCN_STOP_VAP_ALL; 2310d5c65159SKalle Valo } else if (param->req_type == WLAN_SCAN_CANCEL_SINGLE) { 2311d5c65159SKalle Valo /* Cancelling specific scan */ 2312d5c65159SKalle Valo cmd->req_type = WMI_SCAN_STOP_ONE; 2313d5c65159SKalle Valo } else { 2314d5c65159SKalle Valo ath11k_warn(ar->ab, "invalid scan cancel param %d", 2315d5c65159SKalle Valo param->req_type); 2316d5c65159SKalle Valo dev_kfree_skb(skb); 2317d5c65159SKalle Valo return -EINVAL; 2318d5c65159SKalle Valo } 2319d5c65159SKalle Valo 2320d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, 2321d5c65159SKalle Valo WMI_STOP_SCAN_CMDID); 2322d5c65159SKalle Valo if (ret) { 2323d5c65159SKalle Valo ath11k_warn(ar->ab, "failed to send WMI_STOP_SCAN_CMDID\n"); 2324d5c65159SKalle Valo dev_kfree_skb(skb); 2325d5c65159SKalle Valo } 2326d5c65159SKalle Valo 2327d5c65159SKalle Valo return ret; 2328d5c65159SKalle Valo } 2329d5c65159SKalle Valo 2330d5c65159SKalle Valo int ath11k_wmi_send_scan_chan_list_cmd(struct ath11k *ar, 2331d5c65159SKalle Valo struct scan_chan_list_params *chan_list) 2332d5c65159SKalle Valo { 2333d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 2334d5c65159SKalle Valo struct wmi_scan_chan_list_cmd *cmd; 2335d5c65159SKalle Valo struct sk_buff *skb; 2336d5c65159SKalle Valo struct wmi_channel *chan_info; 2337d5c65159SKalle Valo struct channel_param *tchan_info; 2338d5c65159SKalle Valo struct wmi_tlv *tlv; 2339d5c65159SKalle Valo void *ptr; 2340d5c65159SKalle Valo int i, ret, len; 2341bff621fdSPradeep Kumar Chitrapu u16 num_send_chans, num_sends = 0, max_chan_limit = 0; 2342d5c65159SKalle Valo u32 *reg1, *reg2; 2343d5c65159SKalle Valo 2344b2549465SGustavo A. R. Silva tchan_info = chan_list->ch_param; 2345bff621fdSPradeep Kumar Chitrapu while (chan_list->nallchans) { 2346bff621fdSPradeep Kumar Chitrapu len = sizeof(*cmd) + TLV_HDR_SIZE; 2347bff621fdSPradeep Kumar Chitrapu max_chan_limit = (wmi->wmi_ab->max_msg_len[ar->pdev_idx] - len) / 2348bff621fdSPradeep Kumar Chitrapu sizeof(*chan_info); 2349bff621fdSPradeep Kumar Chitrapu 2350bff621fdSPradeep Kumar Chitrapu if (chan_list->nallchans > max_chan_limit) 2351bff621fdSPradeep Kumar Chitrapu num_send_chans = max_chan_limit; 2352bff621fdSPradeep Kumar Chitrapu else 2353bff621fdSPradeep Kumar Chitrapu num_send_chans = chan_list->nallchans; 2354bff621fdSPradeep Kumar Chitrapu 2355bff621fdSPradeep Kumar Chitrapu chan_list->nallchans -= num_send_chans; 2356bff621fdSPradeep Kumar Chitrapu len += sizeof(*chan_info) * num_send_chans; 2357d5c65159SKalle Valo 23586bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len); 2359d5c65159SKalle Valo if (!skb) 2360d5c65159SKalle Valo return -ENOMEM; 2361d5c65159SKalle Valo 2362d5c65159SKalle Valo cmd = (struct wmi_scan_chan_list_cmd *)skb->data; 2363d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_SCAN_CHAN_LIST_CMD) | 2364d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 2365bff621fdSPradeep Kumar Chitrapu cmd->pdev_id = chan_list->pdev_id; 2366bff621fdSPradeep Kumar Chitrapu cmd->num_scan_chans = num_send_chans; 2367bff621fdSPradeep Kumar Chitrapu if (num_sends) 2368bff621fdSPradeep Kumar Chitrapu cmd->flags |= WMI_APPEND_TO_EXISTING_CHAN_LIST_FLAG; 2369d5c65159SKalle Valo 2370d5c65159SKalle Valo ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 2371bff621fdSPradeep Kumar Chitrapu "WMI no.of chan = %d len = %d pdev_id = %d num_sends = %d\n", 2372bff621fdSPradeep Kumar Chitrapu num_send_chans, len, cmd->pdev_id, num_sends); 2373d5c65159SKalle Valo 2374d5c65159SKalle Valo ptr = skb->data + sizeof(*cmd); 2375d5c65159SKalle Valo 2376bff621fdSPradeep Kumar Chitrapu len = sizeof(*chan_info) * num_send_chans; 2377d5c65159SKalle Valo tlv = ptr; 2378d5c65159SKalle Valo tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_STRUCT) | 2379d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, len - TLV_HDR_SIZE); 2380d5c65159SKalle Valo ptr += TLV_HDR_SIZE; 2381d5c65159SKalle Valo 2382bff621fdSPradeep Kumar Chitrapu for (i = 0; i < num_send_chans; ++i) { 2383d5c65159SKalle Valo chan_info = ptr; 2384d5c65159SKalle Valo memset(chan_info, 0, sizeof(*chan_info)); 2385d5c65159SKalle Valo len = sizeof(*chan_info); 2386d5c65159SKalle Valo chan_info->tlv_header = FIELD_PREP(WMI_TLV_TAG, 2387d5c65159SKalle Valo WMI_TAG_CHANNEL) | 2388d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, 2389d5c65159SKalle Valo len - TLV_HDR_SIZE); 2390d5c65159SKalle Valo 2391d5c65159SKalle Valo reg1 = &chan_info->reg_info_1; 2392d5c65159SKalle Valo reg2 = &chan_info->reg_info_2; 2393d5c65159SKalle Valo chan_info->mhz = tchan_info->mhz; 2394d5c65159SKalle Valo chan_info->band_center_freq1 = tchan_info->cfreq1; 2395d5c65159SKalle Valo chan_info->band_center_freq2 = tchan_info->cfreq2; 2396d5c65159SKalle Valo 2397d5c65159SKalle Valo if (tchan_info->is_chan_passive) 2398d5c65159SKalle Valo chan_info->info |= WMI_CHAN_INFO_PASSIVE; 23999f056ed8SJohn Crispin if (tchan_info->allow_he) 24009f056ed8SJohn Crispin chan_info->info |= WMI_CHAN_INFO_ALLOW_HE; 24019f056ed8SJohn Crispin else if (tchan_info->allow_vht) 2402d5c65159SKalle Valo chan_info->info |= WMI_CHAN_INFO_ALLOW_VHT; 2403d5c65159SKalle Valo else if (tchan_info->allow_ht) 2404d5c65159SKalle Valo chan_info->info |= WMI_CHAN_INFO_ALLOW_HT; 2405d5c65159SKalle Valo if (tchan_info->half_rate) 2406d5c65159SKalle Valo chan_info->info |= WMI_CHAN_INFO_HALF_RATE; 2407d5c65159SKalle Valo if (tchan_info->quarter_rate) 2408d5c65159SKalle Valo chan_info->info |= WMI_CHAN_INFO_QUARTER_RATE; 2409bff621fdSPradeep Kumar Chitrapu if (tchan_info->psc_channel) 2410bff621fdSPradeep Kumar Chitrapu chan_info->info |= WMI_CHAN_INFO_PSC; 24118cd5c084SBaochen Qiang if (tchan_info->dfs_set) 24128cd5c084SBaochen Qiang chan_info->info |= WMI_CHAN_INFO_DFS; 2413d5c65159SKalle Valo 2414d5c65159SKalle Valo chan_info->info |= FIELD_PREP(WMI_CHAN_INFO_MODE, 2415d5c65159SKalle Valo tchan_info->phy_mode); 2416d5c65159SKalle Valo *reg1 |= FIELD_PREP(WMI_CHAN_REG_INFO1_MIN_PWR, 2417d5c65159SKalle Valo tchan_info->minpower); 2418d5c65159SKalle Valo *reg1 |= FIELD_PREP(WMI_CHAN_REG_INFO1_MAX_PWR, 2419d5c65159SKalle Valo tchan_info->maxpower); 2420d5c65159SKalle Valo *reg1 |= FIELD_PREP(WMI_CHAN_REG_INFO1_MAX_REG_PWR, 2421d5c65159SKalle Valo tchan_info->maxregpower); 2422d5c65159SKalle Valo *reg1 |= FIELD_PREP(WMI_CHAN_REG_INFO1_REG_CLS, 2423d5c65159SKalle Valo tchan_info->reg_class_id); 2424d5c65159SKalle Valo *reg2 |= FIELD_PREP(WMI_CHAN_REG_INFO2_ANT_MAX, 2425d5c65159SKalle Valo tchan_info->antennamax); 24269212c1b9SP Praneesh *reg2 |= FIELD_PREP(WMI_CHAN_REG_INFO2_MAX_TX_PWR, 24279212c1b9SP Praneesh tchan_info->maxregpower); 2428d5c65159SKalle Valo 2429d5c65159SKalle Valo ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 2430bff621fdSPradeep Kumar Chitrapu "WMI chan scan list chan[%d] = %u, chan_info->info %8x\n", 2431bff621fdSPradeep Kumar Chitrapu i, chan_info->mhz, chan_info->info); 2432d5c65159SKalle Valo 2433d5c65159SKalle Valo ptr += sizeof(*chan_info); 2434d5c65159SKalle Valo 2435d5c65159SKalle Valo tchan_info++; 2436d5c65159SKalle Valo } 2437d5c65159SKalle Valo 2438d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, WMI_SCAN_CHAN_LIST_CMDID); 2439d5c65159SKalle Valo if (ret) { 2440d5c65159SKalle Valo ath11k_warn(ar->ab, "failed to send WMI_SCAN_CHAN_LIST cmd\n"); 2441d5c65159SKalle Valo dev_kfree_skb(skb); 2442bff621fdSPradeep Kumar Chitrapu return ret; 2443d5c65159SKalle Valo } 2444d5c65159SKalle Valo 2445bff621fdSPradeep Kumar Chitrapu num_sends++; 2446bff621fdSPradeep Kumar Chitrapu } 2447bff621fdSPradeep Kumar Chitrapu 2448bff621fdSPradeep Kumar Chitrapu return 0; 2449d5c65159SKalle Valo } 2450d5c65159SKalle Valo 2451d5c65159SKalle Valo int ath11k_wmi_send_wmm_update_cmd_tlv(struct ath11k *ar, u32 vdev_id, 2452d5c65159SKalle Valo struct wmi_wmm_params_all_arg *param) 2453d5c65159SKalle Valo { 2454d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 2455d5c65159SKalle Valo struct wmi_vdev_set_wmm_params_cmd *cmd; 2456d5c65159SKalle Valo struct wmi_wmm_params *wmm_param; 2457d5c65159SKalle Valo struct wmi_wmm_params_arg *wmi_wmm_arg; 2458d5c65159SKalle Valo struct sk_buff *skb; 2459d5c65159SKalle Valo int ret, ac; 2460d5c65159SKalle Valo 24616bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd)); 2462d5c65159SKalle Valo if (!skb) 2463d5c65159SKalle Valo return -ENOMEM; 2464d5c65159SKalle Valo 2465d5c65159SKalle Valo cmd = (struct wmi_vdev_set_wmm_params_cmd *)skb->data; 2466d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, 2467d5c65159SKalle Valo WMI_TAG_VDEV_SET_WMM_PARAMS_CMD) | 2468d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 2469d5c65159SKalle Valo 2470d5c65159SKalle Valo cmd->vdev_id = vdev_id; 2471d5c65159SKalle Valo cmd->wmm_param_type = 0; 2472d5c65159SKalle Valo 2473d5c65159SKalle Valo for (ac = 0; ac < WME_NUM_AC; ac++) { 2474d5c65159SKalle Valo switch (ac) { 2475d5c65159SKalle Valo case WME_AC_BE: 2476d5c65159SKalle Valo wmi_wmm_arg = ¶m->ac_be; 2477d5c65159SKalle Valo break; 2478d5c65159SKalle Valo case WME_AC_BK: 2479d5c65159SKalle Valo wmi_wmm_arg = ¶m->ac_bk; 2480d5c65159SKalle Valo break; 2481d5c65159SKalle Valo case WME_AC_VI: 2482d5c65159SKalle Valo wmi_wmm_arg = ¶m->ac_vi; 2483d5c65159SKalle Valo break; 2484d5c65159SKalle Valo case WME_AC_VO: 2485d5c65159SKalle Valo wmi_wmm_arg = ¶m->ac_vo; 2486d5c65159SKalle Valo break; 2487d5c65159SKalle Valo } 2488d5c65159SKalle Valo 2489d5c65159SKalle Valo wmm_param = (struct wmi_wmm_params *)&cmd->wmm_params[ac]; 2490d5c65159SKalle Valo wmm_param->tlv_header = 2491d5c65159SKalle Valo FIELD_PREP(WMI_TLV_TAG, 2492d5c65159SKalle Valo WMI_TAG_VDEV_SET_WMM_PARAMS_CMD) | 2493d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, 2494d5c65159SKalle Valo sizeof(*wmm_param) - TLV_HDR_SIZE); 2495d5c65159SKalle Valo 2496d5c65159SKalle Valo wmm_param->aifs = wmi_wmm_arg->aifs; 2497d5c65159SKalle Valo wmm_param->cwmin = wmi_wmm_arg->cwmin; 2498d5c65159SKalle Valo wmm_param->cwmax = wmi_wmm_arg->cwmax; 2499d5c65159SKalle Valo wmm_param->txoplimit = wmi_wmm_arg->txop; 2500d5c65159SKalle Valo wmm_param->acm = wmi_wmm_arg->acm; 2501d5c65159SKalle Valo wmm_param->no_ack = wmi_wmm_arg->no_ack; 2502d5c65159SKalle Valo 2503d5c65159SKalle Valo ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 2504d5c65159SKalle Valo "wmi wmm set ac %d aifs %d cwmin %d cwmax %d txop %d acm %d no_ack %d\n", 2505d5c65159SKalle Valo ac, wmm_param->aifs, wmm_param->cwmin, 2506d5c65159SKalle Valo wmm_param->cwmax, wmm_param->txoplimit, 2507d5c65159SKalle Valo wmm_param->acm, wmm_param->no_ack); 2508d5c65159SKalle Valo } 2509d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, 2510d5c65159SKalle Valo WMI_VDEV_SET_WMM_PARAMS_CMDID); 2511d5c65159SKalle Valo if (ret) { 2512d5c65159SKalle Valo ath11k_warn(ar->ab, 2513d5c65159SKalle Valo "failed to send WMI_VDEV_SET_WMM_PARAMS_CMDID"); 2514d5c65159SKalle Valo dev_kfree_skb(skb); 2515d5c65159SKalle Valo } 2516d5c65159SKalle Valo 2517d5c65159SKalle Valo return ret; 2518d5c65159SKalle Valo } 2519d5c65159SKalle Valo 2520d5c65159SKalle Valo int ath11k_wmi_send_dfs_phyerr_offload_enable_cmd(struct ath11k *ar, 2521d5c65159SKalle Valo u32 pdev_id) 2522d5c65159SKalle Valo { 2523d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 2524d5c65159SKalle Valo struct wmi_dfs_phyerr_offload_cmd *cmd; 2525d5c65159SKalle Valo struct sk_buff *skb; 2526d5c65159SKalle Valo int ret; 2527d5c65159SKalle Valo 25286bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd)); 2529d5c65159SKalle Valo if (!skb) 2530d5c65159SKalle Valo return -ENOMEM; 2531d5c65159SKalle Valo 2532d5c65159SKalle Valo cmd = (struct wmi_dfs_phyerr_offload_cmd *)skb->data; 2533d5c65159SKalle Valo cmd->tlv_header = 2534d5c65159SKalle Valo FIELD_PREP(WMI_TLV_TAG, 2535d5c65159SKalle Valo WMI_TAG_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMD) | 2536d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 2537d5c65159SKalle Valo 2538d5c65159SKalle Valo cmd->pdev_id = pdev_id; 2539d5c65159SKalle Valo 2540d5c65159SKalle Valo ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 2541d5c65159SKalle Valo "WMI dfs phy err offload enable pdev id %d\n", pdev_id); 2542d5c65159SKalle Valo 2543d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, 2544d5c65159SKalle Valo WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID); 2545d5c65159SKalle Valo if (ret) { 2546d5c65159SKalle Valo ath11k_warn(ar->ab, 2547d5c65159SKalle Valo "failed to send WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE cmd\n"); 2548d5c65159SKalle Valo dev_kfree_skb(skb); 2549d5c65159SKalle Valo } 2550d5c65159SKalle Valo 2551d5c65159SKalle Valo return ret; 2552d5c65159SKalle Valo } 2553d5c65159SKalle Valo 25549556dfa2SMaharaja Kennadyrajan int ath11k_wmi_delba_send(struct ath11k *ar, u32 vdev_id, const u8 *mac, 25559556dfa2SMaharaja Kennadyrajan u32 tid, u32 initiator, u32 reason) 25569556dfa2SMaharaja Kennadyrajan { 25579556dfa2SMaharaja Kennadyrajan struct ath11k_pdev_wmi *wmi = ar->wmi; 25589556dfa2SMaharaja Kennadyrajan struct wmi_delba_send_cmd *cmd; 25599556dfa2SMaharaja Kennadyrajan struct sk_buff *skb; 25609556dfa2SMaharaja Kennadyrajan int ret; 25619556dfa2SMaharaja Kennadyrajan 25629556dfa2SMaharaja Kennadyrajan skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd)); 25639556dfa2SMaharaja Kennadyrajan if (!skb) 25649556dfa2SMaharaja Kennadyrajan return -ENOMEM; 25659556dfa2SMaharaja Kennadyrajan 25669556dfa2SMaharaja Kennadyrajan cmd = (struct wmi_delba_send_cmd *)skb->data; 25679556dfa2SMaharaja Kennadyrajan cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_DELBA_SEND_CMD) | 25689556dfa2SMaharaja Kennadyrajan FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 25699556dfa2SMaharaja Kennadyrajan cmd->vdev_id = vdev_id; 25709556dfa2SMaharaja Kennadyrajan ether_addr_copy(cmd->peer_macaddr.addr, mac); 25719556dfa2SMaharaja Kennadyrajan cmd->tid = tid; 25729556dfa2SMaharaja Kennadyrajan cmd->initiator = initiator; 25739556dfa2SMaharaja Kennadyrajan cmd->reasoncode = reason; 25749556dfa2SMaharaja Kennadyrajan 25759556dfa2SMaharaja Kennadyrajan ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 25769556dfa2SMaharaja Kennadyrajan "wmi delba send vdev_id 0x%X mac_addr %pM tid %u initiator %u reason %u\n", 25779556dfa2SMaharaja Kennadyrajan vdev_id, mac, tid, initiator, reason); 25789556dfa2SMaharaja Kennadyrajan 25799556dfa2SMaharaja Kennadyrajan ret = ath11k_wmi_cmd_send(wmi, skb, WMI_DELBA_SEND_CMDID); 25809556dfa2SMaharaja Kennadyrajan 25819556dfa2SMaharaja Kennadyrajan if (ret) { 25829556dfa2SMaharaja Kennadyrajan ath11k_warn(ar->ab, 25839556dfa2SMaharaja Kennadyrajan "failed to send WMI_DELBA_SEND_CMDID cmd\n"); 25849556dfa2SMaharaja Kennadyrajan dev_kfree_skb(skb); 25859556dfa2SMaharaja Kennadyrajan } 25869556dfa2SMaharaja Kennadyrajan 25879556dfa2SMaharaja Kennadyrajan return ret; 25889556dfa2SMaharaja Kennadyrajan } 25899556dfa2SMaharaja Kennadyrajan 25909556dfa2SMaharaja Kennadyrajan int ath11k_wmi_addba_set_resp(struct ath11k *ar, u32 vdev_id, const u8 *mac, 25919556dfa2SMaharaja Kennadyrajan u32 tid, u32 status) 25929556dfa2SMaharaja Kennadyrajan { 25939556dfa2SMaharaja Kennadyrajan struct ath11k_pdev_wmi *wmi = ar->wmi; 25949556dfa2SMaharaja Kennadyrajan struct wmi_addba_setresponse_cmd *cmd; 25959556dfa2SMaharaja Kennadyrajan struct sk_buff *skb; 25969556dfa2SMaharaja Kennadyrajan int ret; 25979556dfa2SMaharaja Kennadyrajan 25989556dfa2SMaharaja Kennadyrajan skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd)); 25999556dfa2SMaharaja Kennadyrajan if (!skb) 26009556dfa2SMaharaja Kennadyrajan return -ENOMEM; 26019556dfa2SMaharaja Kennadyrajan 26029556dfa2SMaharaja Kennadyrajan cmd = (struct wmi_addba_setresponse_cmd *)skb->data; 26039556dfa2SMaharaja Kennadyrajan cmd->tlv_header = 26049556dfa2SMaharaja Kennadyrajan FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ADDBA_SETRESPONSE_CMD) | 26059556dfa2SMaharaja Kennadyrajan FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 26069556dfa2SMaharaja Kennadyrajan cmd->vdev_id = vdev_id; 26079556dfa2SMaharaja Kennadyrajan ether_addr_copy(cmd->peer_macaddr.addr, mac); 26089556dfa2SMaharaja Kennadyrajan cmd->tid = tid; 26099556dfa2SMaharaja Kennadyrajan cmd->statuscode = status; 26109556dfa2SMaharaja Kennadyrajan 26119556dfa2SMaharaja Kennadyrajan ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 26129556dfa2SMaharaja Kennadyrajan "wmi addba set resp vdev_id 0x%X mac_addr %pM tid %u status %u\n", 26139556dfa2SMaharaja Kennadyrajan vdev_id, mac, tid, status); 26149556dfa2SMaharaja Kennadyrajan 26159556dfa2SMaharaja Kennadyrajan ret = ath11k_wmi_cmd_send(wmi, skb, WMI_ADDBA_SET_RESP_CMDID); 26169556dfa2SMaharaja Kennadyrajan 26179556dfa2SMaharaja Kennadyrajan if (ret) { 26189556dfa2SMaharaja Kennadyrajan ath11k_warn(ar->ab, 26199556dfa2SMaharaja Kennadyrajan "failed to send WMI_ADDBA_SET_RESP_CMDID cmd\n"); 26209556dfa2SMaharaja Kennadyrajan dev_kfree_skb(skb); 26219556dfa2SMaharaja Kennadyrajan } 26229556dfa2SMaharaja Kennadyrajan 26239556dfa2SMaharaja Kennadyrajan return ret; 26249556dfa2SMaharaja Kennadyrajan } 26259556dfa2SMaharaja Kennadyrajan 26269556dfa2SMaharaja Kennadyrajan int ath11k_wmi_addba_send(struct ath11k *ar, u32 vdev_id, const u8 *mac, 26279556dfa2SMaharaja Kennadyrajan u32 tid, u32 buf_size) 26289556dfa2SMaharaja Kennadyrajan { 26299556dfa2SMaharaja Kennadyrajan struct ath11k_pdev_wmi *wmi = ar->wmi; 26309556dfa2SMaharaja Kennadyrajan struct wmi_addba_send_cmd *cmd; 26319556dfa2SMaharaja Kennadyrajan struct sk_buff *skb; 26329556dfa2SMaharaja Kennadyrajan int ret; 26339556dfa2SMaharaja Kennadyrajan 26349556dfa2SMaharaja Kennadyrajan skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd)); 26359556dfa2SMaharaja Kennadyrajan if (!skb) 26369556dfa2SMaharaja Kennadyrajan return -ENOMEM; 26379556dfa2SMaharaja Kennadyrajan 26389556dfa2SMaharaja Kennadyrajan cmd = (struct wmi_addba_send_cmd *)skb->data; 26399556dfa2SMaharaja Kennadyrajan cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ADDBA_SEND_CMD) | 26409556dfa2SMaharaja Kennadyrajan FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 26419556dfa2SMaharaja Kennadyrajan cmd->vdev_id = vdev_id; 26429556dfa2SMaharaja Kennadyrajan ether_addr_copy(cmd->peer_macaddr.addr, mac); 26439556dfa2SMaharaja Kennadyrajan cmd->tid = tid; 26449556dfa2SMaharaja Kennadyrajan cmd->buffersize = buf_size; 26459556dfa2SMaharaja Kennadyrajan 26469556dfa2SMaharaja Kennadyrajan ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 26479556dfa2SMaharaja Kennadyrajan "wmi addba send vdev_id 0x%X mac_addr %pM tid %u bufsize %u\n", 26489556dfa2SMaharaja Kennadyrajan vdev_id, mac, tid, buf_size); 26499556dfa2SMaharaja Kennadyrajan 26509556dfa2SMaharaja Kennadyrajan ret = ath11k_wmi_cmd_send(wmi, skb, WMI_ADDBA_SEND_CMDID); 26519556dfa2SMaharaja Kennadyrajan 26529556dfa2SMaharaja Kennadyrajan if (ret) { 26539556dfa2SMaharaja Kennadyrajan ath11k_warn(ar->ab, 26549556dfa2SMaharaja Kennadyrajan "failed to send WMI_ADDBA_SEND_CMDID cmd\n"); 26559556dfa2SMaharaja Kennadyrajan dev_kfree_skb(skb); 26569556dfa2SMaharaja Kennadyrajan } 26579556dfa2SMaharaja Kennadyrajan 26589556dfa2SMaharaja Kennadyrajan return ret; 26599556dfa2SMaharaja Kennadyrajan } 26609556dfa2SMaharaja Kennadyrajan 26619556dfa2SMaharaja Kennadyrajan int ath11k_wmi_addba_clear_resp(struct ath11k *ar, u32 vdev_id, const u8 *mac) 26629556dfa2SMaharaja Kennadyrajan { 26639556dfa2SMaharaja Kennadyrajan struct ath11k_pdev_wmi *wmi = ar->wmi; 26649556dfa2SMaharaja Kennadyrajan struct wmi_addba_clear_resp_cmd *cmd; 26659556dfa2SMaharaja Kennadyrajan struct sk_buff *skb; 26669556dfa2SMaharaja Kennadyrajan int ret; 26679556dfa2SMaharaja Kennadyrajan 26689556dfa2SMaharaja Kennadyrajan skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd)); 26699556dfa2SMaharaja Kennadyrajan if (!skb) 26709556dfa2SMaharaja Kennadyrajan return -ENOMEM; 26719556dfa2SMaharaja Kennadyrajan 26729556dfa2SMaharaja Kennadyrajan cmd = (struct wmi_addba_clear_resp_cmd *)skb->data; 26739556dfa2SMaharaja Kennadyrajan cmd->tlv_header = 26749556dfa2SMaharaja Kennadyrajan FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ADDBA_CLEAR_RESP_CMD) | 26759556dfa2SMaharaja Kennadyrajan FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 26769556dfa2SMaharaja Kennadyrajan cmd->vdev_id = vdev_id; 26779556dfa2SMaharaja Kennadyrajan ether_addr_copy(cmd->peer_macaddr.addr, mac); 26789556dfa2SMaharaja Kennadyrajan 26799556dfa2SMaharaja Kennadyrajan ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 26809556dfa2SMaharaja Kennadyrajan "wmi addba clear resp vdev_id 0x%X mac_addr %pM\n", 26819556dfa2SMaharaja Kennadyrajan vdev_id, mac); 26829556dfa2SMaharaja Kennadyrajan 26839556dfa2SMaharaja Kennadyrajan ret = ath11k_wmi_cmd_send(wmi, skb, WMI_ADDBA_CLEAR_RESP_CMDID); 26849556dfa2SMaharaja Kennadyrajan 26859556dfa2SMaharaja Kennadyrajan if (ret) { 26869556dfa2SMaharaja Kennadyrajan ath11k_warn(ar->ab, 26879556dfa2SMaharaja Kennadyrajan "failed to send WMI_ADDBA_CLEAR_RESP_CMDID cmd\n"); 26889556dfa2SMaharaja Kennadyrajan dev_kfree_skb(skb); 26899556dfa2SMaharaja Kennadyrajan } 26909556dfa2SMaharaja Kennadyrajan 26919556dfa2SMaharaja Kennadyrajan return ret; 26929556dfa2SMaharaja Kennadyrajan } 26939556dfa2SMaharaja Kennadyrajan 2694d5c65159SKalle Valo int ath11k_wmi_pdev_peer_pktlog_filter(struct ath11k *ar, u8 *addr, u8 enable) 2695d5c65159SKalle Valo { 2696d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 2697d5c65159SKalle Valo struct wmi_pdev_pktlog_filter_cmd *cmd; 2698d5c65159SKalle Valo struct wmi_pdev_pktlog_filter_info *info; 2699d5c65159SKalle Valo struct sk_buff *skb; 2700d5c65159SKalle Valo struct wmi_tlv *tlv; 2701d5c65159SKalle Valo void *ptr; 2702d5c65159SKalle Valo int ret, len; 2703d5c65159SKalle Valo 2704d5c65159SKalle Valo len = sizeof(*cmd) + sizeof(*info) + TLV_HDR_SIZE; 27056bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len); 2706d5c65159SKalle Valo if (!skb) 2707d5c65159SKalle Valo return -ENOMEM; 2708d5c65159SKalle Valo 2709d5c65159SKalle Valo cmd = (struct wmi_pdev_pktlog_filter_cmd *)skb->data; 2710d5c65159SKalle Valo 2711d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_PDEV_PEER_PKTLOG_FILTER_CMD) | 2712d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 2713d5c65159SKalle Valo 2714d0f390eaSAnilkumar Kolli cmd->pdev_id = DP_HW2SW_MACID(ar->pdev->pdev_id); 2715d5c65159SKalle Valo cmd->num_mac = 1; 2716d5c65159SKalle Valo cmd->enable = enable; 2717d5c65159SKalle Valo 2718d5c65159SKalle Valo ptr = skb->data + sizeof(*cmd); 2719d5c65159SKalle Valo 2720d5c65159SKalle Valo tlv = ptr; 2721d5c65159SKalle Valo tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_STRUCT) | 272279c647a3SVikas Patel FIELD_PREP(WMI_TLV_LEN, sizeof(*info)); 2723d5c65159SKalle Valo 2724d5c65159SKalle Valo ptr += TLV_HDR_SIZE; 2725d5c65159SKalle Valo info = ptr; 2726d5c65159SKalle Valo 2727d5c65159SKalle Valo ether_addr_copy(info->peer_macaddr.addr, addr); 2728d5c65159SKalle Valo info->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_PDEV_PEER_PKTLOG_FILTER_INFO) | 2729d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, 2730d5c65159SKalle Valo sizeof(*info) - TLV_HDR_SIZE); 2731d5c65159SKalle Valo 2732d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, 2733d5c65159SKalle Valo WMI_PDEV_PKTLOG_FILTER_CMDID); 2734d5c65159SKalle Valo if (ret) { 2735d5c65159SKalle Valo ath11k_warn(ar->ab, "failed to send WMI_PDEV_PKTLOG_ENABLE_CMDID\n"); 2736d5c65159SKalle Valo dev_kfree_skb(skb); 2737d5c65159SKalle Valo } 2738d5c65159SKalle Valo 2739d5c65159SKalle Valo return ret; 2740d5c65159SKalle Valo } 2741d5c65159SKalle Valo 2742d5c65159SKalle Valo int 2743d5c65159SKalle Valo ath11k_wmi_send_init_country_cmd(struct ath11k *ar, 2744d5c65159SKalle Valo struct wmi_init_country_params init_cc_params) 2745d5c65159SKalle Valo { 2746d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 2747d5c65159SKalle Valo struct wmi_init_country_cmd *cmd; 2748d5c65159SKalle Valo struct sk_buff *skb; 2749d5c65159SKalle Valo int ret; 2750d5c65159SKalle Valo 27516bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd)); 2752d5c65159SKalle Valo if (!skb) 2753d5c65159SKalle Valo return -ENOMEM; 2754d5c65159SKalle Valo 2755d5c65159SKalle Valo cmd = (struct wmi_init_country_cmd *)skb->data; 2756d5c65159SKalle Valo cmd->tlv_header = 2757d5c65159SKalle Valo FIELD_PREP(WMI_TLV_TAG, 2758d5c65159SKalle Valo WMI_TAG_SET_INIT_COUNTRY_CMD) | 2759d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 2760d5c65159SKalle Valo 2761d5c65159SKalle Valo cmd->pdev_id = ar->pdev->pdev_id; 2762d5c65159SKalle Valo 2763d5c65159SKalle Valo switch (init_cc_params.flags) { 2764d5c65159SKalle Valo case ALPHA_IS_SET: 2765d5c65159SKalle Valo cmd->init_cc_type = WMI_COUNTRY_INFO_TYPE_ALPHA; 2766d5c65159SKalle Valo memcpy((u8 *)&cmd->cc_info.alpha2, 2767d5c65159SKalle Valo init_cc_params.cc_info.alpha2, 3); 2768d5c65159SKalle Valo break; 2769d5c65159SKalle Valo case CC_IS_SET: 2770d5c65159SKalle Valo cmd->init_cc_type = WMI_COUNTRY_INFO_TYPE_COUNTRY_CODE; 2771d5c65159SKalle Valo cmd->cc_info.country_code = init_cc_params.cc_info.country_code; 2772d5c65159SKalle Valo break; 2773d5c65159SKalle Valo case REGDMN_IS_SET: 2774d5c65159SKalle Valo cmd->init_cc_type = WMI_COUNTRY_INFO_TYPE_REGDOMAIN; 2775d5c65159SKalle Valo cmd->cc_info.regdom_id = init_cc_params.cc_info.regdom_id; 2776d5c65159SKalle Valo break; 2777d5c65159SKalle Valo default: 2778d5c65159SKalle Valo ret = -EINVAL; 2779d5c65159SKalle Valo goto out; 2780d5c65159SKalle Valo } 2781d5c65159SKalle Valo 2782d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, 2783d5c65159SKalle Valo WMI_SET_INIT_COUNTRY_CMDID); 2784d5c65159SKalle Valo 2785d5c65159SKalle Valo out: 2786d5c65159SKalle Valo if (ret) { 2787d5c65159SKalle Valo ath11k_warn(ar->ab, 2788d5c65159SKalle Valo "failed to send WMI_SET_INIT_COUNTRY CMD :%d\n", 2789d5c65159SKalle Valo ret); 2790d5c65159SKalle Valo dev_kfree_skb(skb); 2791d5c65159SKalle Valo } 2792d5c65159SKalle Valo 2793d5c65159SKalle Valo return ret; 2794d5c65159SKalle Valo } 2795d5c65159SKalle Valo 27962a63bbcaSPradeep Kumar Chitrapu int 27972a63bbcaSPradeep Kumar Chitrapu ath11k_wmi_send_thermal_mitigation_param_cmd(struct ath11k *ar, 27982a63bbcaSPradeep Kumar Chitrapu struct thermal_mitigation_params *param) 27992a63bbcaSPradeep Kumar Chitrapu { 28002a63bbcaSPradeep Kumar Chitrapu struct ath11k_pdev_wmi *wmi = ar->wmi; 28012a63bbcaSPradeep Kumar Chitrapu struct wmi_therm_throt_config_request_cmd *cmd; 28022a63bbcaSPradeep Kumar Chitrapu struct wmi_therm_throt_level_config_info *lvl_conf; 28032a63bbcaSPradeep Kumar Chitrapu struct wmi_tlv *tlv; 28042a63bbcaSPradeep Kumar Chitrapu struct sk_buff *skb; 28052a63bbcaSPradeep Kumar Chitrapu int i, ret, len; 28062a63bbcaSPradeep Kumar Chitrapu 28072a63bbcaSPradeep Kumar Chitrapu len = sizeof(*cmd) + TLV_HDR_SIZE + 28082a63bbcaSPradeep Kumar Chitrapu THERMAL_LEVELS * sizeof(struct wmi_therm_throt_level_config_info); 28092a63bbcaSPradeep Kumar Chitrapu 28102a63bbcaSPradeep Kumar Chitrapu skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len); 28112a63bbcaSPradeep Kumar Chitrapu if (!skb) 28122a63bbcaSPradeep Kumar Chitrapu return -ENOMEM; 28132a63bbcaSPradeep Kumar Chitrapu 28142a63bbcaSPradeep Kumar Chitrapu cmd = (struct wmi_therm_throt_config_request_cmd *)skb->data; 28152a63bbcaSPradeep Kumar Chitrapu 28162a63bbcaSPradeep Kumar Chitrapu cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_THERM_THROT_CONFIG_REQUEST) | 28172a63bbcaSPradeep Kumar Chitrapu FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 28182a63bbcaSPradeep Kumar Chitrapu 28192a63bbcaSPradeep Kumar Chitrapu cmd->pdev_id = ar->pdev->pdev_id; 28202a63bbcaSPradeep Kumar Chitrapu cmd->enable = param->enable; 28212a63bbcaSPradeep Kumar Chitrapu cmd->dc = param->dc; 28222a63bbcaSPradeep Kumar Chitrapu cmd->dc_per_event = param->dc_per_event; 28232a63bbcaSPradeep Kumar Chitrapu cmd->therm_throt_levels = THERMAL_LEVELS; 28242a63bbcaSPradeep Kumar Chitrapu 28252a63bbcaSPradeep Kumar Chitrapu tlv = (struct wmi_tlv *)(skb->data + sizeof(*cmd)); 28262a63bbcaSPradeep Kumar Chitrapu tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_STRUCT) | 28272a63bbcaSPradeep Kumar Chitrapu FIELD_PREP(WMI_TLV_LEN, 28282a63bbcaSPradeep Kumar Chitrapu (THERMAL_LEVELS * 28292a63bbcaSPradeep Kumar Chitrapu sizeof(struct wmi_therm_throt_level_config_info))); 28302a63bbcaSPradeep Kumar Chitrapu 28312a63bbcaSPradeep Kumar Chitrapu lvl_conf = (struct wmi_therm_throt_level_config_info *)(skb->data + 28322a63bbcaSPradeep Kumar Chitrapu sizeof(*cmd) + 28332a63bbcaSPradeep Kumar Chitrapu TLV_HDR_SIZE); 28342a63bbcaSPradeep Kumar Chitrapu for (i = 0; i < THERMAL_LEVELS; i++) { 28352a63bbcaSPradeep Kumar Chitrapu lvl_conf->tlv_header = 28362a63bbcaSPradeep Kumar Chitrapu FIELD_PREP(WMI_TLV_TAG, WMI_TAG_THERM_THROT_LEVEL_CONFIG_INFO) | 28372a63bbcaSPradeep Kumar Chitrapu FIELD_PREP(WMI_TLV_LEN, sizeof(*lvl_conf) - TLV_HDR_SIZE); 28382a63bbcaSPradeep Kumar Chitrapu 28392a63bbcaSPradeep Kumar Chitrapu lvl_conf->temp_lwm = param->levelconf[i].tmplwm; 28402a63bbcaSPradeep Kumar Chitrapu lvl_conf->temp_hwm = param->levelconf[i].tmphwm; 28412a63bbcaSPradeep Kumar Chitrapu lvl_conf->dc_off_percent = param->levelconf[i].dcoffpercent; 28422a63bbcaSPradeep Kumar Chitrapu lvl_conf->prio = param->levelconf[i].priority; 28432a63bbcaSPradeep Kumar Chitrapu lvl_conf++; 28442a63bbcaSPradeep Kumar Chitrapu } 28452a63bbcaSPradeep Kumar Chitrapu 28462a63bbcaSPradeep Kumar Chitrapu ret = ath11k_wmi_cmd_send(wmi, skb, WMI_THERM_THROT_SET_CONF_CMDID); 28472a63bbcaSPradeep Kumar Chitrapu if (ret) { 28482a63bbcaSPradeep Kumar Chitrapu ath11k_warn(ar->ab, "failed to send THERM_THROT_SET_CONF cmd\n"); 28492a63bbcaSPradeep Kumar Chitrapu dev_kfree_skb(skb); 28502a63bbcaSPradeep Kumar Chitrapu } 28512a63bbcaSPradeep Kumar Chitrapu 28522a63bbcaSPradeep Kumar Chitrapu ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 28532a63bbcaSPradeep Kumar Chitrapu "WMI vdev set thermal throt pdev_id %d enable %d dc %d dc_per_event %x levels %d\n", 28542a63bbcaSPradeep Kumar Chitrapu ar->pdev->pdev_id, param->enable, param->dc, 28552a63bbcaSPradeep Kumar Chitrapu param->dc_per_event, THERMAL_LEVELS); 28562a63bbcaSPradeep Kumar Chitrapu 28572a63bbcaSPradeep Kumar Chitrapu return ret; 28582a63bbcaSPradeep Kumar Chitrapu } 28592a63bbcaSPradeep Kumar Chitrapu 2860d5c65159SKalle Valo int ath11k_wmi_pdev_pktlog_enable(struct ath11k *ar, u32 pktlog_filter) 2861d5c65159SKalle Valo { 2862d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 2863d5c65159SKalle Valo struct wmi_pktlog_enable_cmd *cmd; 2864d5c65159SKalle Valo struct sk_buff *skb; 2865d5c65159SKalle Valo int ret; 2866d5c65159SKalle Valo 28676bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd)); 2868d5c65159SKalle Valo if (!skb) 2869d5c65159SKalle Valo return -ENOMEM; 2870d5c65159SKalle Valo 2871d5c65159SKalle Valo cmd = (struct wmi_pktlog_enable_cmd *)skb->data; 2872d5c65159SKalle Valo 2873d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_PDEV_PKTLOG_ENABLE_CMD) | 2874d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 2875d5c65159SKalle Valo 2876d0f390eaSAnilkumar Kolli cmd->pdev_id = DP_HW2SW_MACID(ar->pdev->pdev_id); 2877d5c65159SKalle Valo cmd->evlist = pktlog_filter; 2878d5c65159SKalle Valo cmd->enable = ATH11K_WMI_PKTLOG_ENABLE_FORCE; 2879d5c65159SKalle Valo 2880d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, 2881d5c65159SKalle Valo WMI_PDEV_PKTLOG_ENABLE_CMDID); 2882d5c65159SKalle Valo if (ret) { 2883d5c65159SKalle Valo ath11k_warn(ar->ab, "failed to send WMI_PDEV_PKTLOG_ENABLE_CMDID\n"); 2884d5c65159SKalle Valo dev_kfree_skb(skb); 2885d5c65159SKalle Valo } 2886d5c65159SKalle Valo 2887d5c65159SKalle Valo return ret; 2888d5c65159SKalle Valo } 2889d5c65159SKalle Valo 2890d5c65159SKalle Valo int ath11k_wmi_pdev_pktlog_disable(struct ath11k *ar) 2891d5c65159SKalle Valo { 2892d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 2893d5c65159SKalle Valo struct wmi_pktlog_disable_cmd *cmd; 2894d5c65159SKalle Valo struct sk_buff *skb; 2895d5c65159SKalle Valo int ret; 2896d5c65159SKalle Valo 28976bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd)); 2898d5c65159SKalle Valo if (!skb) 2899d5c65159SKalle Valo return -ENOMEM; 2900d5c65159SKalle Valo 2901d5c65159SKalle Valo cmd = (struct wmi_pktlog_disable_cmd *)skb->data; 2902d5c65159SKalle Valo 2903d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_PDEV_PKTLOG_DISABLE_CMD) | 2904d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 2905d5c65159SKalle Valo 2906d0f390eaSAnilkumar Kolli cmd->pdev_id = DP_HW2SW_MACID(ar->pdev->pdev_id); 2907d5c65159SKalle Valo 2908d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, 2909d5c65159SKalle Valo WMI_PDEV_PKTLOG_DISABLE_CMDID); 2910d5c65159SKalle Valo if (ret) { 2911d5c65159SKalle Valo ath11k_warn(ar->ab, "failed to send WMI_PDEV_PKTLOG_ENABLE_CMDID\n"); 2912d5c65159SKalle Valo dev_kfree_skb(skb); 2913d5c65159SKalle Valo } 2914d5c65159SKalle Valo 2915d5c65159SKalle Valo return ret; 2916d5c65159SKalle Valo } 2917d5c65159SKalle Valo 29186d293d44SJohn Crispin int 29196d293d44SJohn Crispin ath11k_wmi_send_twt_enable_cmd(struct ath11k *ar, u32 pdev_id) 29206d293d44SJohn Crispin { 29216d293d44SJohn Crispin struct ath11k_pdev_wmi *wmi = ar->wmi; 29226bc9d6f7SJohn Crispin struct ath11k_base *ab = wmi->wmi_ab->ab; 29236d293d44SJohn Crispin struct wmi_twt_enable_params_cmd *cmd; 29246d293d44SJohn Crispin struct sk_buff *skb; 29256d293d44SJohn Crispin int ret, len; 29266d293d44SJohn Crispin 29276d293d44SJohn Crispin len = sizeof(*cmd); 29286d293d44SJohn Crispin 29296bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len); 29306d293d44SJohn Crispin if (!skb) 29316d293d44SJohn Crispin return -ENOMEM; 29326d293d44SJohn Crispin 293377ea8b45SJohn Crispin cmd = (struct wmi_twt_enable_params_cmd *)skb->data; 29346d293d44SJohn Crispin cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_TWT_ENABLE_CMD) | 29356d293d44SJohn Crispin FIELD_PREP(WMI_TLV_LEN, len - TLV_HDR_SIZE); 29366d293d44SJohn Crispin cmd->pdev_id = pdev_id; 29376d293d44SJohn Crispin cmd->sta_cong_timer_ms = ATH11K_TWT_DEF_STA_CONG_TIMER_MS; 29386d293d44SJohn Crispin cmd->default_slot_size = ATH11K_TWT_DEF_DEFAULT_SLOT_SIZE; 29396d293d44SJohn Crispin cmd->congestion_thresh_setup = ATH11K_TWT_DEF_CONGESTION_THRESH_SETUP; 29406d293d44SJohn Crispin cmd->congestion_thresh_teardown = 29416d293d44SJohn Crispin ATH11K_TWT_DEF_CONGESTION_THRESH_TEARDOWN; 29426d293d44SJohn Crispin cmd->congestion_thresh_critical = 29436d293d44SJohn Crispin ATH11K_TWT_DEF_CONGESTION_THRESH_CRITICAL; 29446d293d44SJohn Crispin cmd->interference_thresh_teardown = 29456d293d44SJohn Crispin ATH11K_TWT_DEF_INTERFERENCE_THRESH_TEARDOWN; 29466d293d44SJohn Crispin cmd->interference_thresh_setup = 29476d293d44SJohn Crispin ATH11K_TWT_DEF_INTERFERENCE_THRESH_SETUP; 29486d293d44SJohn Crispin cmd->min_no_sta_setup = ATH11K_TWT_DEF_MIN_NO_STA_SETUP; 29496d293d44SJohn Crispin cmd->min_no_sta_teardown = ATH11K_TWT_DEF_MIN_NO_STA_TEARDOWN; 29506d293d44SJohn Crispin cmd->no_of_bcast_mcast_slots = ATH11K_TWT_DEF_NO_OF_BCAST_MCAST_SLOTS; 29516d293d44SJohn Crispin cmd->min_no_twt_slots = ATH11K_TWT_DEF_MIN_NO_TWT_SLOTS; 29526d293d44SJohn Crispin cmd->max_no_sta_twt = ATH11K_TWT_DEF_MAX_NO_STA_TWT; 29536d293d44SJohn Crispin cmd->mode_check_interval = ATH11K_TWT_DEF_MODE_CHECK_INTERVAL; 29546d293d44SJohn Crispin cmd->add_sta_slot_interval = ATH11K_TWT_DEF_ADD_STA_SLOT_INTERVAL; 29556d293d44SJohn Crispin cmd->remove_sta_slot_interval = 29566d293d44SJohn Crispin ATH11K_TWT_DEF_REMOVE_STA_SLOT_INTERVAL; 29576d293d44SJohn Crispin /* TODO add MBSSID support */ 29586d293d44SJohn Crispin cmd->mbss_support = 0; 29596d293d44SJohn Crispin 29606d293d44SJohn Crispin ret = ath11k_wmi_cmd_send(wmi, skb, 29616d293d44SJohn Crispin WMI_TWT_ENABLE_CMDID); 29626d293d44SJohn Crispin if (ret) { 29636d293d44SJohn Crispin ath11k_warn(ab, "Failed to send WMI_TWT_ENABLE_CMDID"); 29646d293d44SJohn Crispin dev_kfree_skb(skb); 29656d293d44SJohn Crispin } 29666d293d44SJohn Crispin return ret; 29676d293d44SJohn Crispin } 29686d293d44SJohn Crispin 29696d293d44SJohn Crispin int 29706d293d44SJohn Crispin ath11k_wmi_send_twt_disable_cmd(struct ath11k *ar, u32 pdev_id) 29716d293d44SJohn Crispin { 29726d293d44SJohn Crispin struct ath11k_pdev_wmi *wmi = ar->wmi; 29736bc9d6f7SJohn Crispin struct ath11k_base *ab = wmi->wmi_ab->ab; 29746d293d44SJohn Crispin struct wmi_twt_disable_params_cmd *cmd; 29756d293d44SJohn Crispin struct sk_buff *skb; 29766d293d44SJohn Crispin int ret, len; 29776d293d44SJohn Crispin 29786d293d44SJohn Crispin len = sizeof(*cmd); 29796d293d44SJohn Crispin 29806bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len); 29816d293d44SJohn Crispin if (!skb) 29826d293d44SJohn Crispin return -ENOMEM; 29836d293d44SJohn Crispin 298477ea8b45SJohn Crispin cmd = (struct wmi_twt_disable_params_cmd *)skb->data; 29856d293d44SJohn Crispin cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_TWT_DISABLE_CMD) | 29866d293d44SJohn Crispin FIELD_PREP(WMI_TLV_LEN, len - TLV_HDR_SIZE); 29876d293d44SJohn Crispin cmd->pdev_id = pdev_id; 29886d293d44SJohn Crispin 29896d293d44SJohn Crispin ret = ath11k_wmi_cmd_send(wmi, skb, 29906d293d44SJohn Crispin WMI_TWT_DISABLE_CMDID); 29916d293d44SJohn Crispin if (ret) { 2992345a4f22SColin Ian King ath11k_warn(ab, "Failed to send WMI_TWT_DISABLE_CMDID"); 29936d293d44SJohn Crispin dev_kfree_skb(skb); 29946d293d44SJohn Crispin } 29956d293d44SJohn Crispin return ret; 29966d293d44SJohn Crispin } 29976d293d44SJohn Crispin 29983f8be640SJohn Crispin int 29993f8be640SJohn Crispin ath11k_wmi_send_obss_spr_cmd(struct ath11k *ar, u32 vdev_id, 30003f8be640SJohn Crispin struct ieee80211_he_obss_pd *he_obss_pd) 30013f8be640SJohn Crispin { 30023f8be640SJohn Crispin struct ath11k_pdev_wmi *wmi = ar->wmi; 30036bc9d6f7SJohn Crispin struct ath11k_base *ab = wmi->wmi_ab->ab; 30043f8be640SJohn Crispin struct wmi_obss_spatial_reuse_params_cmd *cmd; 30053f8be640SJohn Crispin struct sk_buff *skb; 30063f8be640SJohn Crispin int ret, len; 30073f8be640SJohn Crispin 30083f8be640SJohn Crispin len = sizeof(*cmd); 30093f8be640SJohn Crispin 30106bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len); 30113f8be640SJohn Crispin if (!skb) 30123f8be640SJohn Crispin return -ENOMEM; 30133f8be640SJohn Crispin 301477ea8b45SJohn Crispin cmd = (struct wmi_obss_spatial_reuse_params_cmd *)skb->data; 30153f8be640SJohn Crispin cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, 30163f8be640SJohn Crispin WMI_TAG_OBSS_SPATIAL_REUSE_SET_CMD) | 30173f8be640SJohn Crispin FIELD_PREP(WMI_TLV_LEN, len - TLV_HDR_SIZE); 30183f8be640SJohn Crispin cmd->vdev_id = vdev_id; 30193f8be640SJohn Crispin cmd->enable = he_obss_pd->enable; 30203f8be640SJohn Crispin cmd->obss_min = he_obss_pd->min_offset; 30213f8be640SJohn Crispin cmd->obss_max = he_obss_pd->max_offset; 30223f8be640SJohn Crispin 30233f8be640SJohn Crispin ret = ath11k_wmi_cmd_send(wmi, skb, 30243f8be640SJohn Crispin WMI_PDEV_OBSS_PD_SPATIAL_REUSE_CMDID); 30253f8be640SJohn Crispin if (ret) { 30263f8be640SJohn Crispin ath11k_warn(ab, 30273f8be640SJohn Crispin "Failed to send WMI_PDEV_OBSS_PD_SPATIAL_REUSE_CMDID"); 30283f8be640SJohn Crispin dev_kfree_skb(skb); 30293f8be640SJohn Crispin } 30303f8be640SJohn Crispin return ret; 30313f8be640SJohn Crispin } 30323f8be640SJohn Crispin 30335a032c8dSJohn Crispin int 3034b56b08aeSRajkumar Manoharan ath11k_wmi_pdev_set_srg_bss_color_bitmap(struct ath11k *ar, u32 *bitmap) 3035b56b08aeSRajkumar Manoharan { 3036b56b08aeSRajkumar Manoharan struct ath11k_pdev_wmi *wmi = ar->wmi; 3037b56b08aeSRajkumar Manoharan struct ath11k_base *ab = wmi->wmi_ab->ab; 3038b56b08aeSRajkumar Manoharan struct wmi_pdev_obss_pd_bitmap_cmd *cmd; 3039b56b08aeSRajkumar Manoharan struct sk_buff *skb; 3040b56b08aeSRajkumar Manoharan int ret, len; 3041b56b08aeSRajkumar Manoharan 3042b56b08aeSRajkumar Manoharan len = sizeof(*cmd); 3043b56b08aeSRajkumar Manoharan 3044b56b08aeSRajkumar Manoharan skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len); 3045b56b08aeSRajkumar Manoharan if (!skb) 3046b56b08aeSRajkumar Manoharan return -ENOMEM; 3047b56b08aeSRajkumar Manoharan 3048b56b08aeSRajkumar Manoharan cmd = (struct wmi_pdev_obss_pd_bitmap_cmd *)skb->data; 3049b56b08aeSRajkumar Manoharan cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, 3050b56b08aeSRajkumar Manoharan WMI_TAG_PDEV_SRG_BSS_COLOR_BITMAP_CMD) | 3051b56b08aeSRajkumar Manoharan FIELD_PREP(WMI_TLV_LEN, len - TLV_HDR_SIZE); 3052b56b08aeSRajkumar Manoharan cmd->pdev_id = ar->pdev->pdev_id; 3053b56b08aeSRajkumar Manoharan memcpy(cmd->bitmap, bitmap, sizeof(cmd->bitmap)); 3054b56b08aeSRajkumar Manoharan 3055b56b08aeSRajkumar Manoharan ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 3056b56b08aeSRajkumar Manoharan "obss pd pdev_id %d bss color bitmap %08x %08x\n", 3057b56b08aeSRajkumar Manoharan cmd->pdev_id, cmd->bitmap[0], cmd->bitmap[1]); 3058b56b08aeSRajkumar Manoharan 3059b56b08aeSRajkumar Manoharan ret = ath11k_wmi_cmd_send(wmi, skb, 3060b56b08aeSRajkumar Manoharan WMI_PDEV_SET_SRG_BSS_COLOR_BITMAP_CMDID); 3061b56b08aeSRajkumar Manoharan if (ret) { 3062b56b08aeSRajkumar Manoharan ath11k_warn(ab, 3063b56b08aeSRajkumar Manoharan "failed to send WMI_PDEV_SET_SRG_BSS_COLOR_BITMAP_CMDID"); 3064b56b08aeSRajkumar Manoharan dev_kfree_skb(skb); 3065b56b08aeSRajkumar Manoharan } 3066b56b08aeSRajkumar Manoharan 3067b56b08aeSRajkumar Manoharan return ret; 3068b56b08aeSRajkumar Manoharan } 3069b56b08aeSRajkumar Manoharan 3070b56b08aeSRajkumar Manoharan int 3071b56b08aeSRajkumar Manoharan ath11k_wmi_pdev_set_srg_patial_bssid_bitmap(struct ath11k *ar, u32 *bitmap) 3072b56b08aeSRajkumar Manoharan { 3073b56b08aeSRajkumar Manoharan struct ath11k_pdev_wmi *wmi = ar->wmi; 3074b56b08aeSRajkumar Manoharan struct ath11k_base *ab = wmi->wmi_ab->ab; 3075b56b08aeSRajkumar Manoharan struct wmi_pdev_obss_pd_bitmap_cmd *cmd; 3076b56b08aeSRajkumar Manoharan struct sk_buff *skb; 3077b56b08aeSRajkumar Manoharan int ret, len; 3078b56b08aeSRajkumar Manoharan 3079b56b08aeSRajkumar Manoharan len = sizeof(*cmd); 3080b56b08aeSRajkumar Manoharan 3081b56b08aeSRajkumar Manoharan skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len); 3082b56b08aeSRajkumar Manoharan if (!skb) 3083b56b08aeSRajkumar Manoharan return -ENOMEM; 3084b56b08aeSRajkumar Manoharan 3085b56b08aeSRajkumar Manoharan cmd = (struct wmi_pdev_obss_pd_bitmap_cmd *)skb->data; 3086b56b08aeSRajkumar Manoharan cmd->tlv_header = 3087b56b08aeSRajkumar Manoharan FIELD_PREP(WMI_TLV_TAG, 3088b56b08aeSRajkumar Manoharan WMI_TAG_PDEV_SRG_PARTIAL_BSSID_BITMAP_CMD) | 3089b56b08aeSRajkumar Manoharan FIELD_PREP(WMI_TLV_LEN, len - TLV_HDR_SIZE); 3090b56b08aeSRajkumar Manoharan cmd->pdev_id = ar->pdev->pdev_id; 3091b56b08aeSRajkumar Manoharan memcpy(cmd->bitmap, bitmap, sizeof(cmd->bitmap)); 3092b56b08aeSRajkumar Manoharan 3093b56b08aeSRajkumar Manoharan ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 3094b56b08aeSRajkumar Manoharan "obss pd pdev_id %d partial bssid bitmap %08x %08x\n", 3095b56b08aeSRajkumar Manoharan cmd->pdev_id, cmd->bitmap[0], cmd->bitmap[1]); 3096b56b08aeSRajkumar Manoharan 3097b56b08aeSRajkumar Manoharan ret = ath11k_wmi_cmd_send(wmi, skb, 3098b56b08aeSRajkumar Manoharan WMI_PDEV_SET_SRG_PARTIAL_BSSID_BITMAP_CMDID); 3099b56b08aeSRajkumar Manoharan if (ret) { 3100b56b08aeSRajkumar Manoharan ath11k_warn(ab, 3101b56b08aeSRajkumar Manoharan "failed to send WMI_PDEV_SET_SRG_PARTIAL_BSSID_BITMAP_CMDID"); 3102b56b08aeSRajkumar Manoharan dev_kfree_skb(skb); 3103b56b08aeSRajkumar Manoharan } 3104b56b08aeSRajkumar Manoharan 3105b56b08aeSRajkumar Manoharan return ret; 3106b56b08aeSRajkumar Manoharan } 3107b56b08aeSRajkumar Manoharan 3108b56b08aeSRajkumar Manoharan int 3109b56b08aeSRajkumar Manoharan ath11k_wmi_pdev_srg_obss_color_enable_bitmap(struct ath11k *ar, u32 *bitmap) 3110b56b08aeSRajkumar Manoharan { 3111b56b08aeSRajkumar Manoharan struct ath11k_pdev_wmi *wmi = ar->wmi; 3112b56b08aeSRajkumar Manoharan struct ath11k_base *ab = wmi->wmi_ab->ab; 3113b56b08aeSRajkumar Manoharan struct wmi_pdev_obss_pd_bitmap_cmd *cmd; 3114b56b08aeSRajkumar Manoharan struct sk_buff *skb; 3115b56b08aeSRajkumar Manoharan int ret, len; 3116b56b08aeSRajkumar Manoharan 3117b56b08aeSRajkumar Manoharan len = sizeof(*cmd); 3118b56b08aeSRajkumar Manoharan 3119b56b08aeSRajkumar Manoharan skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len); 3120b56b08aeSRajkumar Manoharan if (!skb) 3121b56b08aeSRajkumar Manoharan return -ENOMEM; 3122b56b08aeSRajkumar Manoharan 3123b56b08aeSRajkumar Manoharan cmd = (struct wmi_pdev_obss_pd_bitmap_cmd *)skb->data; 3124b56b08aeSRajkumar Manoharan cmd->tlv_header = 3125b56b08aeSRajkumar Manoharan FIELD_PREP(WMI_TLV_TAG, 3126b56b08aeSRajkumar Manoharan WMI_TAG_PDEV_SRG_OBSS_COLOR_ENABLE_BITMAP_CMD) | 3127b56b08aeSRajkumar Manoharan FIELD_PREP(WMI_TLV_LEN, len - TLV_HDR_SIZE); 3128b56b08aeSRajkumar Manoharan cmd->pdev_id = ar->pdev->pdev_id; 3129b56b08aeSRajkumar Manoharan memcpy(cmd->bitmap, bitmap, sizeof(cmd->bitmap)); 3130b56b08aeSRajkumar Manoharan 3131b56b08aeSRajkumar Manoharan ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 3132b56b08aeSRajkumar Manoharan "obss pd srg pdev_id %d bss color enable bitmap %08x %08x\n", 3133b56b08aeSRajkumar Manoharan cmd->pdev_id, cmd->bitmap[0], cmd->bitmap[1]); 3134b56b08aeSRajkumar Manoharan 3135b56b08aeSRajkumar Manoharan ret = ath11k_wmi_cmd_send(wmi, skb, 3136b56b08aeSRajkumar Manoharan WMI_PDEV_SET_SRG_OBSS_COLOR_ENABLE_BITMAP_CMDID); 3137b56b08aeSRajkumar Manoharan if (ret) { 3138b56b08aeSRajkumar Manoharan ath11k_warn(ab, 3139b56b08aeSRajkumar Manoharan "failed to send WMI_PDEV_SET_SRG_OBSS_COLOR_ENABLE_BITMAP_CMDID"); 3140b56b08aeSRajkumar Manoharan dev_kfree_skb(skb); 3141b56b08aeSRajkumar Manoharan } 3142b56b08aeSRajkumar Manoharan 3143b56b08aeSRajkumar Manoharan return ret; 3144b56b08aeSRajkumar Manoharan } 3145b56b08aeSRajkumar Manoharan 3146b56b08aeSRajkumar Manoharan int 3147b56b08aeSRajkumar Manoharan ath11k_wmi_pdev_srg_obss_bssid_enable_bitmap(struct ath11k *ar, u32 *bitmap) 3148b56b08aeSRajkumar Manoharan { 3149b56b08aeSRajkumar Manoharan struct ath11k_pdev_wmi *wmi = ar->wmi; 3150b56b08aeSRajkumar Manoharan struct ath11k_base *ab = wmi->wmi_ab->ab; 3151b56b08aeSRajkumar Manoharan struct wmi_pdev_obss_pd_bitmap_cmd *cmd; 3152b56b08aeSRajkumar Manoharan struct sk_buff *skb; 3153b56b08aeSRajkumar Manoharan int ret, len; 3154b56b08aeSRajkumar Manoharan 3155b56b08aeSRajkumar Manoharan len = sizeof(*cmd); 3156b56b08aeSRajkumar Manoharan 3157b56b08aeSRajkumar Manoharan skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len); 3158b56b08aeSRajkumar Manoharan if (!skb) 3159b56b08aeSRajkumar Manoharan return -ENOMEM; 3160b56b08aeSRajkumar Manoharan 3161b56b08aeSRajkumar Manoharan cmd = (struct wmi_pdev_obss_pd_bitmap_cmd *)skb->data; 3162b56b08aeSRajkumar Manoharan cmd->tlv_header = 3163b56b08aeSRajkumar Manoharan FIELD_PREP(WMI_TLV_TAG, 3164b56b08aeSRajkumar Manoharan WMI_TAG_PDEV_SRG_OBSS_BSSID_ENABLE_BITMAP_CMD) | 3165b56b08aeSRajkumar Manoharan FIELD_PREP(WMI_TLV_LEN, len - TLV_HDR_SIZE); 3166b56b08aeSRajkumar Manoharan cmd->pdev_id = ar->pdev->pdev_id; 3167b56b08aeSRajkumar Manoharan memcpy(cmd->bitmap, bitmap, sizeof(cmd->bitmap)); 3168b56b08aeSRajkumar Manoharan 3169b56b08aeSRajkumar Manoharan ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 3170b56b08aeSRajkumar Manoharan "obss pd srg pdev_id %d bssid enable bitmap %08x %08x\n", 3171b56b08aeSRajkumar Manoharan cmd->pdev_id, cmd->bitmap[0], cmd->bitmap[1]); 3172b56b08aeSRajkumar Manoharan 3173b56b08aeSRajkumar Manoharan ret = ath11k_wmi_cmd_send(wmi, skb, 3174b56b08aeSRajkumar Manoharan WMI_PDEV_SET_SRG_OBSS_BSSID_ENABLE_BITMAP_CMDID); 3175b56b08aeSRajkumar Manoharan if (ret) { 3176b56b08aeSRajkumar Manoharan ath11k_warn(ab, 3177b56b08aeSRajkumar Manoharan "failed to send WMI_PDEV_SET_SRG_OBSS_BSSID_ENABLE_BITMAP_CMDID"); 3178b56b08aeSRajkumar Manoharan dev_kfree_skb(skb); 3179b56b08aeSRajkumar Manoharan } 3180b56b08aeSRajkumar Manoharan 3181b56b08aeSRajkumar Manoharan return ret; 3182b56b08aeSRajkumar Manoharan } 3183b56b08aeSRajkumar Manoharan 3184b56b08aeSRajkumar Manoharan int 3185b56b08aeSRajkumar Manoharan ath11k_wmi_pdev_non_srg_obss_color_enable_bitmap(struct ath11k *ar, u32 *bitmap) 3186b56b08aeSRajkumar Manoharan { 3187b56b08aeSRajkumar Manoharan struct ath11k_pdev_wmi *wmi = ar->wmi; 3188b56b08aeSRajkumar Manoharan struct ath11k_base *ab = wmi->wmi_ab->ab; 3189b56b08aeSRajkumar Manoharan struct wmi_pdev_obss_pd_bitmap_cmd *cmd; 3190b56b08aeSRajkumar Manoharan struct sk_buff *skb; 3191b56b08aeSRajkumar Manoharan int ret, len; 3192b56b08aeSRajkumar Manoharan 3193b56b08aeSRajkumar Manoharan len = sizeof(*cmd); 3194b56b08aeSRajkumar Manoharan 3195b56b08aeSRajkumar Manoharan skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len); 3196b56b08aeSRajkumar Manoharan if (!skb) 3197b56b08aeSRajkumar Manoharan return -ENOMEM; 3198b56b08aeSRajkumar Manoharan 3199b56b08aeSRajkumar Manoharan cmd = (struct wmi_pdev_obss_pd_bitmap_cmd *)skb->data; 3200b56b08aeSRajkumar Manoharan cmd->tlv_header = 3201b56b08aeSRajkumar Manoharan FIELD_PREP(WMI_TLV_TAG, 3202b56b08aeSRajkumar Manoharan WMI_TAG_PDEV_NON_SRG_OBSS_COLOR_ENABLE_BITMAP_CMD) | 3203b56b08aeSRajkumar Manoharan FIELD_PREP(WMI_TLV_LEN, len - TLV_HDR_SIZE); 3204b56b08aeSRajkumar Manoharan cmd->pdev_id = ar->pdev->pdev_id; 3205b56b08aeSRajkumar Manoharan memcpy(cmd->bitmap, bitmap, sizeof(cmd->bitmap)); 3206b56b08aeSRajkumar Manoharan 3207b56b08aeSRajkumar Manoharan ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 3208b56b08aeSRajkumar Manoharan "obss pd non_srg pdev_id %d bss color enable bitmap %08x %08x\n", 3209b56b08aeSRajkumar Manoharan cmd->pdev_id, cmd->bitmap[0], cmd->bitmap[1]); 3210b56b08aeSRajkumar Manoharan 3211b56b08aeSRajkumar Manoharan ret = ath11k_wmi_cmd_send(wmi, skb, 3212b56b08aeSRajkumar Manoharan WMI_PDEV_SET_NON_SRG_OBSS_COLOR_ENABLE_BITMAP_CMDID); 3213b56b08aeSRajkumar Manoharan if (ret) { 3214b56b08aeSRajkumar Manoharan ath11k_warn(ab, 3215b56b08aeSRajkumar Manoharan "failed to send WMI_PDEV_SET_NON_SRG_OBSS_COLOR_ENABLE_BITMAP_CMDID"); 3216b56b08aeSRajkumar Manoharan dev_kfree_skb(skb); 3217b56b08aeSRajkumar Manoharan } 3218b56b08aeSRajkumar Manoharan 3219b56b08aeSRajkumar Manoharan return ret; 3220b56b08aeSRajkumar Manoharan } 3221b56b08aeSRajkumar Manoharan 3222b56b08aeSRajkumar Manoharan int 3223b56b08aeSRajkumar Manoharan ath11k_wmi_pdev_non_srg_obss_bssid_enable_bitmap(struct ath11k *ar, u32 *bitmap) 3224b56b08aeSRajkumar Manoharan { 3225b56b08aeSRajkumar Manoharan struct ath11k_pdev_wmi *wmi = ar->wmi; 3226b56b08aeSRajkumar Manoharan struct ath11k_base *ab = wmi->wmi_ab->ab; 3227b56b08aeSRajkumar Manoharan struct wmi_pdev_obss_pd_bitmap_cmd *cmd; 3228b56b08aeSRajkumar Manoharan struct sk_buff *skb; 3229b56b08aeSRajkumar Manoharan int ret, len; 3230b56b08aeSRajkumar Manoharan 3231b56b08aeSRajkumar Manoharan len = sizeof(*cmd); 3232b56b08aeSRajkumar Manoharan 3233b56b08aeSRajkumar Manoharan skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len); 3234b56b08aeSRajkumar Manoharan if (!skb) 3235b56b08aeSRajkumar Manoharan return -ENOMEM; 3236b56b08aeSRajkumar Manoharan 3237b56b08aeSRajkumar Manoharan cmd = (struct wmi_pdev_obss_pd_bitmap_cmd *)skb->data; 3238b56b08aeSRajkumar Manoharan cmd->tlv_header = 3239b56b08aeSRajkumar Manoharan FIELD_PREP(WMI_TLV_TAG, 3240b56b08aeSRajkumar Manoharan WMI_TAG_PDEV_NON_SRG_OBSS_BSSID_ENABLE_BITMAP_CMD) | 3241b56b08aeSRajkumar Manoharan FIELD_PREP(WMI_TLV_LEN, len - TLV_HDR_SIZE); 3242b56b08aeSRajkumar Manoharan cmd->pdev_id = ar->pdev->pdev_id; 3243b56b08aeSRajkumar Manoharan memcpy(cmd->bitmap, bitmap, sizeof(cmd->bitmap)); 3244b56b08aeSRajkumar Manoharan 3245b56b08aeSRajkumar Manoharan ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 3246b56b08aeSRajkumar Manoharan "obss pd non_srg pdev_id %d bssid enable bitmap %08x %08x\n", 3247b56b08aeSRajkumar Manoharan cmd->pdev_id, cmd->bitmap[0], cmd->bitmap[1]); 3248b56b08aeSRajkumar Manoharan 3249b56b08aeSRajkumar Manoharan ret = ath11k_wmi_cmd_send(wmi, skb, 3250b56b08aeSRajkumar Manoharan WMI_PDEV_SET_NON_SRG_OBSS_BSSID_ENABLE_BITMAP_CMDID); 3251b56b08aeSRajkumar Manoharan if (ret) { 3252b56b08aeSRajkumar Manoharan ath11k_warn(ab, 3253b56b08aeSRajkumar Manoharan "failed to send WMI_PDEV_SET_NON_SRG_OBSS_BSSID_ENABLE_BITMAP_CMDID"); 3254b56b08aeSRajkumar Manoharan dev_kfree_skb(skb); 3255b56b08aeSRajkumar Manoharan } 3256b56b08aeSRajkumar Manoharan 3257b56b08aeSRajkumar Manoharan return ret; 3258b56b08aeSRajkumar Manoharan } 3259b56b08aeSRajkumar Manoharan 3260b56b08aeSRajkumar Manoharan int 32615a032c8dSJohn Crispin ath11k_wmi_send_obss_color_collision_cfg_cmd(struct ath11k *ar, u32 vdev_id, 32625a032c8dSJohn Crispin u8 bss_color, u32 period, 32635a032c8dSJohn Crispin bool enable) 32645a032c8dSJohn Crispin { 32655a032c8dSJohn Crispin struct ath11k_pdev_wmi *wmi = ar->wmi; 32665a032c8dSJohn Crispin struct ath11k_base *ab = wmi->wmi_ab->ab; 32675a032c8dSJohn Crispin struct wmi_obss_color_collision_cfg_params_cmd *cmd; 32685a032c8dSJohn Crispin struct sk_buff *skb; 32695a032c8dSJohn Crispin int ret, len; 32705a032c8dSJohn Crispin 32715a032c8dSJohn Crispin len = sizeof(*cmd); 32725a032c8dSJohn Crispin 32735a032c8dSJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len); 32745a032c8dSJohn Crispin if (!skb) 32755a032c8dSJohn Crispin return -ENOMEM; 32765a032c8dSJohn Crispin 32775a032c8dSJohn Crispin cmd = (struct wmi_obss_color_collision_cfg_params_cmd *)skb->data; 32785a032c8dSJohn Crispin cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, 32795a032c8dSJohn Crispin WMI_TAG_OBSS_COLOR_COLLISION_DET_CONFIG) | 32805a032c8dSJohn Crispin FIELD_PREP(WMI_TLV_LEN, len - TLV_HDR_SIZE); 32815a032c8dSJohn Crispin cmd->vdev_id = vdev_id; 32825a032c8dSJohn Crispin cmd->evt_type = enable ? ATH11K_OBSS_COLOR_COLLISION_DETECTION : 32835a032c8dSJohn Crispin ATH11K_OBSS_COLOR_COLLISION_DETECTION_DISABLE; 32845a032c8dSJohn Crispin cmd->current_bss_color = bss_color; 32855a032c8dSJohn Crispin cmd->detection_period_ms = period; 32865a032c8dSJohn Crispin cmd->scan_period_ms = ATH11K_BSS_COLOR_COLLISION_SCAN_PERIOD_MS; 32875a032c8dSJohn Crispin cmd->free_slot_expiry_time_ms = 0; 32885a032c8dSJohn Crispin cmd->flags = 0; 32895a032c8dSJohn Crispin 32905a032c8dSJohn Crispin ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 32915a032c8dSJohn Crispin "wmi_send_obss_color_collision_cfg id %d type %d bss_color %d detect_period %d scan_period %d\n", 32925a032c8dSJohn Crispin cmd->vdev_id, cmd->evt_type, cmd->current_bss_color, 32935a032c8dSJohn Crispin cmd->detection_period_ms, cmd->scan_period_ms); 32945a032c8dSJohn Crispin 32955a032c8dSJohn Crispin ret = ath11k_wmi_cmd_send(wmi, skb, 32965a032c8dSJohn Crispin WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID); 32975a032c8dSJohn Crispin if (ret) { 32985a032c8dSJohn Crispin ath11k_warn(ab, "Failed to send WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID"); 32995a032c8dSJohn Crispin dev_kfree_skb(skb); 33005a032c8dSJohn Crispin } 33015a032c8dSJohn Crispin return ret; 33025a032c8dSJohn Crispin } 33035a032c8dSJohn Crispin 33045a032c8dSJohn Crispin int ath11k_wmi_send_bss_color_change_enable_cmd(struct ath11k *ar, u32 vdev_id, 33055a032c8dSJohn Crispin bool enable) 33065a032c8dSJohn Crispin { 33075a032c8dSJohn Crispin struct ath11k_pdev_wmi *wmi = ar->wmi; 33085a032c8dSJohn Crispin struct ath11k_base *ab = wmi->wmi_ab->ab; 33095a032c8dSJohn Crispin struct wmi_bss_color_change_enable_params_cmd *cmd; 33105a032c8dSJohn Crispin struct sk_buff *skb; 33115a032c8dSJohn Crispin int ret, len; 33125a032c8dSJohn Crispin 33135a032c8dSJohn Crispin len = sizeof(*cmd); 33145a032c8dSJohn Crispin 33155a032c8dSJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len); 33165a032c8dSJohn Crispin if (!skb) 33175a032c8dSJohn Crispin return -ENOMEM; 33185a032c8dSJohn Crispin 33195a032c8dSJohn Crispin cmd = (struct wmi_bss_color_change_enable_params_cmd *)skb->data; 33205a032c8dSJohn Crispin cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_BSS_COLOR_CHANGE_ENABLE) | 33215a032c8dSJohn Crispin FIELD_PREP(WMI_TLV_LEN, len - TLV_HDR_SIZE); 33225a032c8dSJohn Crispin cmd->vdev_id = vdev_id; 33235a032c8dSJohn Crispin cmd->enable = enable ? 1 : 0; 33245a032c8dSJohn Crispin 33255a032c8dSJohn Crispin ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 33265a032c8dSJohn Crispin "wmi_send_bss_color_change_enable id %d enable %d\n", 33275a032c8dSJohn Crispin cmd->vdev_id, cmd->enable); 33285a032c8dSJohn Crispin 33295a032c8dSJohn Crispin ret = ath11k_wmi_cmd_send(wmi, skb, 33305a032c8dSJohn Crispin WMI_BSS_COLOR_CHANGE_ENABLE_CMDID); 33315a032c8dSJohn Crispin if (ret) { 33329a8074e3SColin Ian King ath11k_warn(ab, "Failed to send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID"); 33335a032c8dSJohn Crispin dev_kfree_skb(skb); 33345a032c8dSJohn Crispin } 33355a032c8dSJohn Crispin return ret; 33365a032c8dSJohn Crispin } 33375a032c8dSJohn Crispin 3338047679e3SAloka Dixit int ath11k_wmi_fils_discovery_tmpl(struct ath11k *ar, u32 vdev_id, 3339047679e3SAloka Dixit struct sk_buff *tmpl) 3340047679e3SAloka Dixit { 3341047679e3SAloka Dixit struct wmi_tlv *tlv; 3342047679e3SAloka Dixit struct sk_buff *skb; 3343047679e3SAloka Dixit void *ptr; 3344047679e3SAloka Dixit int ret, len; 3345047679e3SAloka Dixit size_t aligned_len; 3346047679e3SAloka Dixit struct wmi_fils_discovery_tmpl_cmd *cmd; 3347047679e3SAloka Dixit 3348047679e3SAloka Dixit aligned_len = roundup(tmpl->len, 4); 3349047679e3SAloka Dixit len = sizeof(*cmd) + TLV_HDR_SIZE + aligned_len; 3350047679e3SAloka Dixit 3351047679e3SAloka Dixit ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 3352047679e3SAloka Dixit "WMI vdev %i set FILS discovery template\n", vdev_id); 3353047679e3SAloka Dixit 3354047679e3SAloka Dixit skb = ath11k_wmi_alloc_skb(ar->wmi->wmi_ab, len); 3355047679e3SAloka Dixit if (!skb) 3356047679e3SAloka Dixit return -ENOMEM; 3357047679e3SAloka Dixit 3358047679e3SAloka Dixit cmd = (struct wmi_fils_discovery_tmpl_cmd *)skb->data; 3359047679e3SAloka Dixit cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, 3360047679e3SAloka Dixit WMI_TAG_FILS_DISCOVERY_TMPL_CMD) | 3361047679e3SAloka Dixit FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 3362047679e3SAloka Dixit cmd->vdev_id = vdev_id; 3363047679e3SAloka Dixit cmd->buf_len = tmpl->len; 3364047679e3SAloka Dixit ptr = skb->data + sizeof(*cmd); 3365047679e3SAloka Dixit 3366047679e3SAloka Dixit tlv = ptr; 3367047679e3SAloka Dixit tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_BYTE) | 3368047679e3SAloka Dixit FIELD_PREP(WMI_TLV_LEN, aligned_len); 3369047679e3SAloka Dixit memcpy(tlv->value, tmpl->data, tmpl->len); 3370047679e3SAloka Dixit 3371047679e3SAloka Dixit ret = ath11k_wmi_cmd_send(ar->wmi, skb, WMI_FILS_DISCOVERY_TMPL_CMDID); 3372047679e3SAloka Dixit if (ret) { 3373047679e3SAloka Dixit ath11k_warn(ar->ab, 3374047679e3SAloka Dixit "WMI vdev %i failed to send FILS discovery template command\n", 3375047679e3SAloka Dixit vdev_id); 3376047679e3SAloka Dixit dev_kfree_skb(skb); 3377047679e3SAloka Dixit } 3378047679e3SAloka Dixit return ret; 3379047679e3SAloka Dixit } 3380047679e3SAloka Dixit 3381047679e3SAloka Dixit int ath11k_wmi_probe_resp_tmpl(struct ath11k *ar, u32 vdev_id, 3382047679e3SAloka Dixit struct sk_buff *tmpl) 3383047679e3SAloka Dixit { 3384047679e3SAloka Dixit struct wmi_probe_tmpl_cmd *cmd; 3385047679e3SAloka Dixit struct wmi_bcn_prb_info *probe_info; 3386047679e3SAloka Dixit struct wmi_tlv *tlv; 3387047679e3SAloka Dixit struct sk_buff *skb; 3388047679e3SAloka Dixit void *ptr; 3389047679e3SAloka Dixit int ret, len; 3390047679e3SAloka Dixit size_t aligned_len = roundup(tmpl->len, 4); 3391047679e3SAloka Dixit 3392047679e3SAloka Dixit ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 3393047679e3SAloka Dixit "WMI vdev %i set probe response template\n", vdev_id); 3394047679e3SAloka Dixit 3395047679e3SAloka Dixit len = sizeof(*cmd) + sizeof(*probe_info) + TLV_HDR_SIZE + aligned_len; 3396047679e3SAloka Dixit 3397047679e3SAloka Dixit skb = ath11k_wmi_alloc_skb(ar->wmi->wmi_ab, len); 3398047679e3SAloka Dixit if (!skb) 3399047679e3SAloka Dixit return -ENOMEM; 3400047679e3SAloka Dixit 3401047679e3SAloka Dixit cmd = (struct wmi_probe_tmpl_cmd *)skb->data; 3402047679e3SAloka Dixit cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_PRB_TMPL_CMD) | 3403047679e3SAloka Dixit FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 3404047679e3SAloka Dixit cmd->vdev_id = vdev_id; 3405047679e3SAloka Dixit cmd->buf_len = tmpl->len; 3406047679e3SAloka Dixit 3407047679e3SAloka Dixit ptr = skb->data + sizeof(*cmd); 3408047679e3SAloka Dixit 3409047679e3SAloka Dixit probe_info = ptr; 3410047679e3SAloka Dixit len = sizeof(*probe_info); 3411047679e3SAloka Dixit probe_info->tlv_header = FIELD_PREP(WMI_TLV_TAG, 3412047679e3SAloka Dixit WMI_TAG_BCN_PRB_INFO) | 3413047679e3SAloka Dixit FIELD_PREP(WMI_TLV_LEN, len - TLV_HDR_SIZE); 3414047679e3SAloka Dixit probe_info->caps = 0; 3415047679e3SAloka Dixit probe_info->erp = 0; 3416047679e3SAloka Dixit 3417047679e3SAloka Dixit ptr += sizeof(*probe_info); 3418047679e3SAloka Dixit 3419047679e3SAloka Dixit tlv = ptr; 3420047679e3SAloka Dixit tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_BYTE) | 3421047679e3SAloka Dixit FIELD_PREP(WMI_TLV_LEN, aligned_len); 3422047679e3SAloka Dixit memcpy(tlv->value, tmpl->data, tmpl->len); 3423047679e3SAloka Dixit 3424047679e3SAloka Dixit ret = ath11k_wmi_cmd_send(ar->wmi, skb, WMI_PRB_TMPL_CMDID); 3425047679e3SAloka Dixit if (ret) { 3426047679e3SAloka Dixit ath11k_warn(ar->ab, 3427047679e3SAloka Dixit "WMI vdev %i failed to send probe response template command\n", 3428047679e3SAloka Dixit vdev_id); 3429047679e3SAloka Dixit dev_kfree_skb(skb); 3430047679e3SAloka Dixit } 3431047679e3SAloka Dixit return ret; 3432047679e3SAloka Dixit } 3433047679e3SAloka Dixit 3434047679e3SAloka Dixit int ath11k_wmi_fils_discovery(struct ath11k *ar, u32 vdev_id, u32 interval, 3435047679e3SAloka Dixit bool unsol_bcast_probe_resp_enabled) 3436047679e3SAloka Dixit { 3437047679e3SAloka Dixit struct sk_buff *skb; 3438047679e3SAloka Dixit int ret, len; 3439047679e3SAloka Dixit struct wmi_fils_discovery_cmd *cmd; 3440047679e3SAloka Dixit 3441047679e3SAloka Dixit ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 3442047679e3SAloka Dixit "WMI vdev %i set %s interval to %u TU\n", 3443047679e3SAloka Dixit vdev_id, unsol_bcast_probe_resp_enabled ? 3444047679e3SAloka Dixit "unsolicited broadcast probe response" : "FILS discovery", 3445047679e3SAloka Dixit interval); 3446047679e3SAloka Dixit 3447047679e3SAloka Dixit len = sizeof(*cmd); 3448047679e3SAloka Dixit skb = ath11k_wmi_alloc_skb(ar->wmi->wmi_ab, len); 3449047679e3SAloka Dixit if (!skb) 3450047679e3SAloka Dixit return -ENOMEM; 3451047679e3SAloka Dixit 3452047679e3SAloka Dixit cmd = (struct wmi_fils_discovery_cmd *)skb->data; 3453047679e3SAloka Dixit cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ENABLE_FILS_CMD) | 3454047679e3SAloka Dixit FIELD_PREP(WMI_TLV_LEN, len - TLV_HDR_SIZE); 3455047679e3SAloka Dixit cmd->vdev_id = vdev_id; 3456047679e3SAloka Dixit cmd->interval = interval; 3457047679e3SAloka Dixit cmd->config = unsol_bcast_probe_resp_enabled; 3458047679e3SAloka Dixit 3459047679e3SAloka Dixit ret = ath11k_wmi_cmd_send(ar->wmi, skb, WMI_ENABLE_FILS_CMDID); 3460047679e3SAloka Dixit if (ret) { 3461047679e3SAloka Dixit ath11k_warn(ar->ab, 3462047679e3SAloka Dixit "WMI vdev %i failed to send FILS discovery enable/disable command\n", 3463047679e3SAloka Dixit vdev_id); 3464047679e3SAloka Dixit dev_kfree_skb(skb); 3465047679e3SAloka Dixit } 3466047679e3SAloka Dixit return ret; 3467047679e3SAloka Dixit } 3468047679e3SAloka Dixit 3469d5c65159SKalle Valo static void 3470886433a9SJohn Crispin ath11k_wmi_obss_color_collision_event(struct ath11k_base *ab, struct sk_buff *skb) 3471886433a9SJohn Crispin { 3472886433a9SJohn Crispin const void **tb; 3473886433a9SJohn Crispin const struct wmi_obss_color_collision_event *ev; 3474886433a9SJohn Crispin struct ath11k_vif *arvif; 3475886433a9SJohn Crispin int ret; 3476886433a9SJohn Crispin 3477886433a9SJohn Crispin tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC); 3478886433a9SJohn Crispin if (IS_ERR(tb)) { 3479886433a9SJohn Crispin ret = PTR_ERR(tb); 3480886433a9SJohn Crispin ath11k_warn(ab, "failed to parse tlv: %d\n", ret); 3481886433a9SJohn Crispin return; 3482886433a9SJohn Crispin } 3483886433a9SJohn Crispin 3484886433a9SJohn Crispin ev = tb[WMI_TAG_OBSS_COLOR_COLLISION_EVT]; 3485886433a9SJohn Crispin if (!ev) { 3486886433a9SJohn Crispin ath11k_warn(ab, "failed to fetch obss color collision ev"); 3487886433a9SJohn Crispin goto exit; 3488886433a9SJohn Crispin } 3489886433a9SJohn Crispin 3490886433a9SJohn Crispin arvif = ath11k_mac_get_arvif_by_vdev_id(ab, ev->vdev_id); 3491886433a9SJohn Crispin if (!arvif) { 3492886433a9SJohn Crispin ath11k_warn(ab, "failed to find arvif with vedv id %d in obss_color_collision_event\n", 3493886433a9SJohn Crispin ev->vdev_id); 3494886433a9SJohn Crispin goto exit; 3495886433a9SJohn Crispin } 3496886433a9SJohn Crispin 3497886433a9SJohn Crispin switch (ev->evt_type) { 3498886433a9SJohn Crispin case WMI_BSS_COLOR_COLLISION_DETECTION: 3499886433a9SJohn Crispin ieeee80211_obss_color_collision_notify(arvif->vif, ev->obss_color_bitmap); 3500886433a9SJohn Crispin ath11k_dbg(ab, ATH11K_DBG_WMI, 3501886433a9SJohn Crispin "OBSS color collision detected vdev:%d, event:%d, bitmap:%08llx\n", 3502886433a9SJohn Crispin ev->vdev_id, ev->evt_type, ev->obss_color_bitmap); 3503886433a9SJohn Crispin break; 3504886433a9SJohn Crispin case WMI_BSS_COLOR_COLLISION_DISABLE: 3505886433a9SJohn Crispin case WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY: 3506886433a9SJohn Crispin case WMI_BSS_COLOR_FREE_SLOT_AVAILABLE: 3507886433a9SJohn Crispin break; 3508886433a9SJohn Crispin default: 3509886433a9SJohn Crispin ath11k_warn(ab, "received unknown obss color collision detetction event\n"); 3510886433a9SJohn Crispin } 3511886433a9SJohn Crispin 3512886433a9SJohn Crispin exit: 3513886433a9SJohn Crispin kfree(tb); 3514886433a9SJohn Crispin } 3515886433a9SJohn Crispin 3516886433a9SJohn Crispin static void 3517d5c65159SKalle Valo ath11k_fill_band_to_mac_param(struct ath11k_base *soc, 3518d5c65159SKalle Valo struct wmi_host_pdev_band_to_mac *band_to_mac) 3519d5c65159SKalle Valo { 3520d5c65159SKalle Valo u8 i; 3521d5c65159SKalle Valo struct ath11k_hal_reg_capabilities_ext *hal_reg_cap; 3522d5c65159SKalle Valo struct ath11k_pdev *pdev; 3523d5c65159SKalle Valo 3524d5c65159SKalle Valo for (i = 0; i < soc->num_radios; i++) { 3525d5c65159SKalle Valo pdev = &soc->pdevs[i]; 3526d5c65159SKalle Valo hal_reg_cap = &soc->hal_reg_cap[i]; 3527d5c65159SKalle Valo band_to_mac[i].pdev_id = pdev->pdev_id; 3528d5c65159SKalle Valo 3529d5c65159SKalle Valo switch (pdev->cap.supported_bands) { 3530d5c65159SKalle Valo case WMI_HOST_WLAN_2G_5G_CAP: 3531d5c65159SKalle Valo band_to_mac[i].start_freq = hal_reg_cap->low_2ghz_chan; 3532d5c65159SKalle Valo band_to_mac[i].end_freq = hal_reg_cap->high_5ghz_chan; 3533d5c65159SKalle Valo break; 3534d5c65159SKalle Valo case WMI_HOST_WLAN_2G_CAP: 3535d5c65159SKalle Valo band_to_mac[i].start_freq = hal_reg_cap->low_2ghz_chan; 3536d5c65159SKalle Valo band_to_mac[i].end_freq = hal_reg_cap->high_2ghz_chan; 3537d5c65159SKalle Valo break; 3538d5c65159SKalle Valo case WMI_HOST_WLAN_5G_CAP: 3539d5c65159SKalle Valo band_to_mac[i].start_freq = hal_reg_cap->low_5ghz_chan; 3540d5c65159SKalle Valo band_to_mac[i].end_freq = hal_reg_cap->high_5ghz_chan; 3541d5c65159SKalle Valo break; 3542d5c65159SKalle Valo default: 3543d5c65159SKalle Valo break; 3544d5c65159SKalle Valo } 3545d5c65159SKalle Valo } 3546d5c65159SKalle Valo } 3547d5c65159SKalle Valo 3548d5c65159SKalle Valo static void 3549d5c65159SKalle Valo ath11k_wmi_copy_resource_config(struct wmi_resource_config *wmi_cfg, 3550d5c65159SKalle Valo struct target_resource_config *tg_cfg) 3551d5c65159SKalle Valo { 3552d5c65159SKalle Valo wmi_cfg->num_vdevs = tg_cfg->num_vdevs; 3553d5c65159SKalle Valo wmi_cfg->num_peers = tg_cfg->num_peers; 3554d5c65159SKalle Valo wmi_cfg->num_offload_peers = tg_cfg->num_offload_peers; 3555d5c65159SKalle Valo wmi_cfg->num_offload_reorder_buffs = tg_cfg->num_offload_reorder_buffs; 3556d5c65159SKalle Valo wmi_cfg->num_peer_keys = tg_cfg->num_peer_keys; 3557d5c65159SKalle Valo wmi_cfg->num_tids = tg_cfg->num_tids; 3558d5c65159SKalle Valo wmi_cfg->ast_skid_limit = tg_cfg->ast_skid_limit; 3559d5c65159SKalle Valo wmi_cfg->tx_chain_mask = tg_cfg->tx_chain_mask; 3560d5c65159SKalle Valo wmi_cfg->rx_chain_mask = tg_cfg->rx_chain_mask; 3561d5c65159SKalle Valo wmi_cfg->rx_timeout_pri[0] = tg_cfg->rx_timeout_pri[0]; 3562d5c65159SKalle Valo wmi_cfg->rx_timeout_pri[1] = tg_cfg->rx_timeout_pri[1]; 3563d5c65159SKalle Valo wmi_cfg->rx_timeout_pri[2] = tg_cfg->rx_timeout_pri[2]; 3564d5c65159SKalle Valo wmi_cfg->rx_timeout_pri[3] = tg_cfg->rx_timeout_pri[3]; 3565d5c65159SKalle Valo wmi_cfg->rx_decap_mode = tg_cfg->rx_decap_mode; 3566d5c65159SKalle Valo wmi_cfg->scan_max_pending_req = tg_cfg->scan_max_pending_req; 3567d5c65159SKalle Valo wmi_cfg->bmiss_offload_max_vdev = tg_cfg->bmiss_offload_max_vdev; 3568d5c65159SKalle Valo wmi_cfg->roam_offload_max_vdev = tg_cfg->roam_offload_max_vdev; 3569d5c65159SKalle Valo wmi_cfg->roam_offload_max_ap_profiles = 3570d5c65159SKalle Valo tg_cfg->roam_offload_max_ap_profiles; 3571d5c65159SKalle Valo wmi_cfg->num_mcast_groups = tg_cfg->num_mcast_groups; 3572d5c65159SKalle Valo wmi_cfg->num_mcast_table_elems = tg_cfg->num_mcast_table_elems; 3573d5c65159SKalle Valo wmi_cfg->mcast2ucast_mode = tg_cfg->mcast2ucast_mode; 3574d5c65159SKalle Valo wmi_cfg->tx_dbg_log_size = tg_cfg->tx_dbg_log_size; 3575d5c65159SKalle Valo wmi_cfg->num_wds_entries = tg_cfg->num_wds_entries; 3576d5c65159SKalle Valo wmi_cfg->dma_burst_size = tg_cfg->dma_burst_size; 3577d5c65159SKalle Valo wmi_cfg->mac_aggr_delim = tg_cfg->mac_aggr_delim; 3578d5c65159SKalle Valo wmi_cfg->rx_skip_defrag_timeout_dup_detection_check = 3579d5c65159SKalle Valo tg_cfg->rx_skip_defrag_timeout_dup_detection_check; 3580d5c65159SKalle Valo wmi_cfg->vow_config = tg_cfg->vow_config; 3581d5c65159SKalle Valo wmi_cfg->gtk_offload_max_vdev = tg_cfg->gtk_offload_max_vdev; 3582d5c65159SKalle Valo wmi_cfg->num_msdu_desc = tg_cfg->num_msdu_desc; 3583d5c65159SKalle Valo wmi_cfg->max_frag_entries = tg_cfg->max_frag_entries; 3584d5c65159SKalle Valo wmi_cfg->num_tdls_vdevs = tg_cfg->num_tdls_vdevs; 3585d5c65159SKalle Valo wmi_cfg->num_tdls_conn_table_entries = 3586d5c65159SKalle Valo tg_cfg->num_tdls_conn_table_entries; 3587d5c65159SKalle Valo wmi_cfg->beacon_tx_offload_max_vdev = 3588d5c65159SKalle Valo tg_cfg->beacon_tx_offload_max_vdev; 3589d5c65159SKalle Valo wmi_cfg->num_multicast_filter_entries = 3590d5c65159SKalle Valo tg_cfg->num_multicast_filter_entries; 3591d5c65159SKalle Valo wmi_cfg->num_wow_filters = tg_cfg->num_wow_filters; 3592d5c65159SKalle Valo wmi_cfg->num_keep_alive_pattern = tg_cfg->num_keep_alive_pattern; 3593d5c65159SKalle Valo wmi_cfg->keep_alive_pattern_size = tg_cfg->keep_alive_pattern_size; 3594d5c65159SKalle Valo wmi_cfg->max_tdls_concurrent_sleep_sta = 3595d5c65159SKalle Valo tg_cfg->max_tdls_concurrent_sleep_sta; 3596d5c65159SKalle Valo wmi_cfg->max_tdls_concurrent_buffer_sta = 3597d5c65159SKalle Valo tg_cfg->max_tdls_concurrent_buffer_sta; 3598d5c65159SKalle Valo wmi_cfg->wmi_send_separate = tg_cfg->wmi_send_separate; 3599d5c65159SKalle Valo wmi_cfg->num_ocb_vdevs = tg_cfg->num_ocb_vdevs; 3600d5c65159SKalle Valo wmi_cfg->num_ocb_channels = tg_cfg->num_ocb_channels; 3601d5c65159SKalle Valo wmi_cfg->num_ocb_schedules = tg_cfg->num_ocb_schedules; 3602d5c65159SKalle Valo wmi_cfg->bpf_instruction_size = tg_cfg->bpf_instruction_size; 3603d5c65159SKalle Valo wmi_cfg->max_bssid_rx_filters = tg_cfg->max_bssid_rx_filters; 3604d5c65159SKalle Valo wmi_cfg->use_pdev_id = tg_cfg->use_pdev_id; 36057e9fb241SSeevalamuthu Mariappan wmi_cfg->flag1 = tg_cfg->flag1; 3606d5c65159SKalle Valo wmi_cfg->peer_map_unmap_v2_support = tg_cfg->peer_map_unmap_v2_support; 36076d293d44SJohn Crispin wmi_cfg->sched_params = tg_cfg->sched_params; 36086d293d44SJohn Crispin wmi_cfg->twt_ap_pdev_count = tg_cfg->twt_ap_pdev_count; 36096d293d44SJohn Crispin wmi_cfg->twt_ap_sta_count = tg_cfg->twt_ap_sta_count; 3610d5c65159SKalle Valo } 3611d5c65159SKalle Valo 3612d5c65159SKalle Valo static int ath11k_init_cmd_send(struct ath11k_pdev_wmi *wmi, 3613d5c65159SKalle Valo struct wmi_init_cmd_param *param) 3614d5c65159SKalle Valo { 36156bc9d6f7SJohn Crispin struct ath11k_base *ab = wmi->wmi_ab->ab; 3616d5c65159SKalle Valo struct sk_buff *skb; 3617d5c65159SKalle Valo struct wmi_init_cmd *cmd; 3618d5c65159SKalle Valo struct wmi_resource_config *cfg; 3619d5c65159SKalle Valo struct wmi_pdev_set_hw_mode_cmd_param *hw_mode; 3620d5c65159SKalle Valo struct wmi_pdev_band_to_mac *band_to_mac; 3621d5c65159SKalle Valo struct wlan_host_mem_chunk *host_mem_chunks; 3622d5c65159SKalle Valo struct wmi_tlv *tlv; 3623d5c65159SKalle Valo size_t ret, len; 3624d5c65159SKalle Valo void *ptr; 3625d5c65159SKalle Valo u32 hw_mode_len = 0; 3626d5c65159SKalle Valo u16 idx; 3627d5c65159SKalle Valo 3628d5c65159SKalle Valo if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) 3629d5c65159SKalle Valo hw_mode_len = sizeof(*hw_mode) + TLV_HDR_SIZE + 3630d5c65159SKalle Valo (param->num_band_to_mac * sizeof(*band_to_mac)); 3631d5c65159SKalle Valo 3632d5c65159SKalle Valo len = sizeof(*cmd) + TLV_HDR_SIZE + sizeof(*cfg) + hw_mode_len + 36332d4bcbedSCarl Huang (param->num_mem_chunks ? (sizeof(*host_mem_chunks) * WMI_MAX_MEM_REQS) : 0); 3634d5c65159SKalle Valo 36356bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len); 3636d5c65159SKalle Valo if (!skb) 3637d5c65159SKalle Valo return -ENOMEM; 3638d5c65159SKalle Valo 3639d5c65159SKalle Valo cmd = (struct wmi_init_cmd *)skb->data; 3640d5c65159SKalle Valo 3641d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_INIT_CMD) | 3642d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 3643d5c65159SKalle Valo 3644d5c65159SKalle Valo ptr = skb->data + sizeof(*cmd); 3645d5c65159SKalle Valo cfg = ptr; 3646d5c65159SKalle Valo 3647d5c65159SKalle Valo ath11k_wmi_copy_resource_config(cfg, param->res_cfg); 3648d5c65159SKalle Valo 3649d5c65159SKalle Valo cfg->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_RESOURCE_CONFIG) | 3650d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(*cfg) - TLV_HDR_SIZE); 3651d5c65159SKalle Valo 3652d5c65159SKalle Valo ptr += sizeof(*cfg); 3653d5c65159SKalle Valo host_mem_chunks = ptr + TLV_HDR_SIZE; 3654d5c65159SKalle Valo len = sizeof(struct wlan_host_mem_chunk); 3655d5c65159SKalle Valo 3656d5c65159SKalle Valo for (idx = 0; idx < param->num_mem_chunks; ++idx) { 3657d5c65159SKalle Valo host_mem_chunks[idx].tlv_header = 3658d5c65159SKalle Valo FIELD_PREP(WMI_TLV_TAG, 3659d5c65159SKalle Valo WMI_TAG_WLAN_HOST_MEMORY_CHUNK) | 3660d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, len); 3661d5c65159SKalle Valo 3662d5c65159SKalle Valo host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr; 3663d5c65159SKalle Valo host_mem_chunks[idx].size = param->mem_chunks[idx].len; 3664d5c65159SKalle Valo host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id; 3665d5c65159SKalle Valo 3666d5c65159SKalle Valo ath11k_dbg(ab, ATH11K_DBG_WMI, 3667d5c65159SKalle Valo "WMI host mem chunk req_id %d paddr 0x%llx len %d\n", 3668d5c65159SKalle Valo param->mem_chunks[idx].req_id, 3669d5c65159SKalle Valo (u64)param->mem_chunks[idx].paddr, 3670d5c65159SKalle Valo param->mem_chunks[idx].len); 3671d5c65159SKalle Valo } 3672d5c65159SKalle Valo cmd->num_host_mem_chunks = param->num_mem_chunks; 3673d5c65159SKalle Valo len = sizeof(struct wlan_host_mem_chunk) * param->num_mem_chunks; 3674d5c65159SKalle Valo 3675d5c65159SKalle Valo /* num_mem_chunks is zero */ 3676d5c65159SKalle Valo tlv = ptr; 3677d5c65159SKalle Valo tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_STRUCT) | 3678d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, len); 3679d5c65159SKalle Valo ptr += TLV_HDR_SIZE + len; 3680d5c65159SKalle Valo 3681d5c65159SKalle Valo if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) { 3682d5c65159SKalle Valo hw_mode = (struct wmi_pdev_set_hw_mode_cmd_param *)ptr; 3683d5c65159SKalle Valo hw_mode->tlv_header = FIELD_PREP(WMI_TLV_TAG, 3684d5c65159SKalle Valo WMI_TAG_PDEV_SET_HW_MODE_CMD) | 3685d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, 3686d5c65159SKalle Valo sizeof(*hw_mode) - TLV_HDR_SIZE); 3687d5c65159SKalle Valo 3688d5c65159SKalle Valo hw_mode->hw_mode_index = param->hw_mode_id; 3689d5c65159SKalle Valo hw_mode->num_band_to_mac = param->num_band_to_mac; 3690d5c65159SKalle Valo 3691d5c65159SKalle Valo ptr += sizeof(*hw_mode); 3692d5c65159SKalle Valo 3693d5c65159SKalle Valo len = param->num_band_to_mac * sizeof(*band_to_mac); 3694d5c65159SKalle Valo tlv = ptr; 3695d5c65159SKalle Valo tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_STRUCT) | 3696d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, len); 3697d5c65159SKalle Valo 3698d5c65159SKalle Valo ptr += TLV_HDR_SIZE; 3699d5c65159SKalle Valo len = sizeof(*band_to_mac); 3700d5c65159SKalle Valo 3701d5c65159SKalle Valo for (idx = 0; idx < param->num_band_to_mac; idx++) { 3702d5c65159SKalle Valo band_to_mac = (void *)ptr; 3703d5c65159SKalle Valo 3704d5c65159SKalle Valo band_to_mac->tlv_header = FIELD_PREP(WMI_TLV_TAG, 3705d5c65159SKalle Valo WMI_TAG_PDEV_BAND_TO_MAC) | 3706d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, 3707d5c65159SKalle Valo len - TLV_HDR_SIZE); 3708d5c65159SKalle Valo band_to_mac->pdev_id = param->band_to_mac[idx].pdev_id; 3709d5c65159SKalle Valo band_to_mac->start_freq = 3710d5c65159SKalle Valo param->band_to_mac[idx].start_freq; 3711d5c65159SKalle Valo band_to_mac->end_freq = 3712d5c65159SKalle Valo param->band_to_mac[idx].end_freq; 3713d5c65159SKalle Valo ptr += sizeof(*band_to_mac); 3714d5c65159SKalle Valo } 3715d5c65159SKalle Valo } 3716d5c65159SKalle Valo 3717d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, WMI_INIT_CMDID); 3718d5c65159SKalle Valo if (ret) { 3719d5c65159SKalle Valo ath11k_warn(ab, "failed to send WMI_INIT_CMDID\n"); 3720d5c65159SKalle Valo dev_kfree_skb(skb); 3721d5c65159SKalle Valo } 3722d5c65159SKalle Valo 3723d5c65159SKalle Valo return ret; 3724d5c65159SKalle Valo } 3725d5c65159SKalle Valo 372626c79927SSriram R int ath11k_wmi_pdev_lro_cfg(struct ath11k *ar, 372726c79927SSriram R int pdev_id) 372826c79927SSriram R { 372926c79927SSriram R struct ath11k_wmi_pdev_lro_config_cmd *cmd; 373026c79927SSriram R struct sk_buff *skb; 373126c79927SSriram R int ret; 373226c79927SSriram R 373326c79927SSriram R skb = ath11k_wmi_alloc_skb(ar->wmi->wmi_ab, sizeof(*cmd)); 373426c79927SSriram R if (!skb) 373526c79927SSriram R return -ENOMEM; 373626c79927SSriram R 373726c79927SSriram R cmd = (struct ath11k_wmi_pdev_lro_config_cmd *)skb->data; 373826c79927SSriram R cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_LRO_INFO_CMD) | 373926c79927SSriram R FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 374026c79927SSriram R 374126c79927SSriram R get_random_bytes(cmd->th_4, sizeof(uint32_t) * ATH11K_IPV4_TH_SEED_SIZE); 374226c79927SSriram R get_random_bytes(cmd->th_6, sizeof(uint32_t) * ATH11K_IPV6_TH_SEED_SIZE); 374326c79927SSriram R 374426c79927SSriram R cmd->pdev_id = pdev_id; 374526c79927SSriram R 374626c79927SSriram R ret = ath11k_wmi_cmd_send(ar->wmi, skb, WMI_LRO_CONFIG_CMDID); 374726c79927SSriram R if (ret) { 374826c79927SSriram R ath11k_warn(ar->ab, 374926c79927SSriram R "failed to send lro cfg req wmi cmd\n"); 375026c79927SSriram R goto err; 375126c79927SSriram R } 375226c79927SSriram R 375326c79927SSriram R ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 375426c79927SSriram R "WMI lro cfg cmd pdev_id 0x%x\n", pdev_id); 375526c79927SSriram R return 0; 375626c79927SSriram R err: 375726c79927SSriram R dev_kfree_skb(skb); 375826c79927SSriram R return ret; 375926c79927SSriram R } 376026c79927SSriram R 3761d5c65159SKalle Valo int ath11k_wmi_wait_for_service_ready(struct ath11k_base *ab) 3762d5c65159SKalle Valo { 3763d5c65159SKalle Valo unsigned long time_left; 3764d5c65159SKalle Valo 37656bc9d6f7SJohn Crispin time_left = wait_for_completion_timeout(&ab->wmi_ab.service_ready, 3766d5c65159SKalle Valo WMI_SERVICE_READY_TIMEOUT_HZ); 3767d5c65159SKalle Valo if (!time_left) 3768d5c65159SKalle Valo return -ETIMEDOUT; 3769d5c65159SKalle Valo 3770d5c65159SKalle Valo return 0; 3771d5c65159SKalle Valo } 3772d5c65159SKalle Valo 3773d5c65159SKalle Valo int ath11k_wmi_wait_for_unified_ready(struct ath11k_base *ab) 3774d5c65159SKalle Valo { 3775d5c65159SKalle Valo unsigned long time_left; 3776d5c65159SKalle Valo 37776bc9d6f7SJohn Crispin time_left = wait_for_completion_timeout(&ab->wmi_ab.unified_ready, 3778d5c65159SKalle Valo WMI_SERVICE_READY_TIMEOUT_HZ); 3779d5c65159SKalle Valo if (!time_left) 3780d5c65159SKalle Valo return -ETIMEDOUT; 3781d5c65159SKalle Valo 3782d5c65159SKalle Valo return 0; 3783d5c65159SKalle Valo } 3784d5c65159SKalle Valo 378543ed15e1SCarl Huang int ath11k_wmi_set_hw_mode(struct ath11k_base *ab, 378643ed15e1SCarl Huang enum wmi_host_hw_mode_config_type mode) 378743ed15e1SCarl Huang { 378843ed15e1SCarl Huang struct wmi_pdev_set_hw_mode_cmd_param *cmd; 378943ed15e1SCarl Huang struct sk_buff *skb; 379043ed15e1SCarl Huang struct ath11k_wmi_base *wmi_ab = &ab->wmi_ab; 379143ed15e1SCarl Huang int len; 379243ed15e1SCarl Huang int ret; 379343ed15e1SCarl Huang 379443ed15e1SCarl Huang len = sizeof(*cmd); 379543ed15e1SCarl Huang 379643ed15e1SCarl Huang skb = ath11k_wmi_alloc_skb(wmi_ab, len); 3797292bff94SColin Ian King if (!skb) 3798292bff94SColin Ian King return -ENOMEM; 3799292bff94SColin Ian King 380043ed15e1SCarl Huang cmd = (struct wmi_pdev_set_hw_mode_cmd_param *)skb->data; 380143ed15e1SCarl Huang 380243ed15e1SCarl Huang cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_PDEV_SET_HW_MODE_CMD) | 380343ed15e1SCarl Huang FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 380443ed15e1SCarl Huang 380543ed15e1SCarl Huang cmd->pdev_id = WMI_PDEV_ID_SOC; 380643ed15e1SCarl Huang cmd->hw_mode_index = mode; 380743ed15e1SCarl Huang 380843ed15e1SCarl Huang ret = ath11k_wmi_cmd_send(&wmi_ab->wmi[0], skb, WMI_PDEV_SET_HW_MODE_CMDID); 380943ed15e1SCarl Huang if (ret) { 381043ed15e1SCarl Huang ath11k_warn(ab, "failed to send WMI_PDEV_SET_HW_MODE_CMDID\n"); 381143ed15e1SCarl Huang dev_kfree_skb(skb); 381243ed15e1SCarl Huang } 381343ed15e1SCarl Huang 381443ed15e1SCarl Huang return ret; 381543ed15e1SCarl Huang } 381643ed15e1SCarl Huang 3817d5c65159SKalle Valo int ath11k_wmi_cmd_init(struct ath11k_base *ab) 3818d5c65159SKalle Valo { 38196bc9d6f7SJohn Crispin struct ath11k_wmi_base *wmi_sc = &ab->wmi_ab; 3820d5c65159SKalle Valo struct wmi_init_cmd_param init_param; 3821d5c65159SKalle Valo struct target_resource_config config; 3822d5c65159SKalle Valo 3823d5c65159SKalle Valo memset(&init_param, 0, sizeof(init_param)); 3824d5c65159SKalle Valo memset(&config, 0, sizeof(config)); 3825d5c65159SKalle Valo 38262d4bcbedSCarl Huang ab->hw_params.hw_ops->wmi_init_config(ab, &config); 38272d4bcbedSCarl Huang 3828d5c65159SKalle Valo memcpy(&wmi_sc->wlan_resource_config, &config, sizeof(config)); 3829d5c65159SKalle Valo 3830d5c65159SKalle Valo init_param.res_cfg = &wmi_sc->wlan_resource_config; 3831d5c65159SKalle Valo init_param.num_mem_chunks = wmi_sc->num_mem_chunks; 3832d5c65159SKalle Valo init_param.hw_mode_id = wmi_sc->preferred_hw_mode; 3833d5c65159SKalle Valo init_param.mem_chunks = wmi_sc->mem_chunks; 3834d5c65159SKalle Valo 383543ed15e1SCarl Huang if (ab->hw_params.single_pdev_only) 383643ed15e1SCarl Huang init_param.hw_mode_id = WMI_HOST_HW_MODE_MAX; 383743ed15e1SCarl Huang 3838d5c65159SKalle Valo init_param.num_band_to_mac = ab->num_radios; 3839d5c65159SKalle Valo ath11k_fill_band_to_mac_param(ab, init_param.band_to_mac); 3840d5c65159SKalle Valo 3841d5c65159SKalle Valo return ath11k_init_cmd_send(&wmi_sc->wmi[0], &init_param); 3842d5c65159SKalle Valo } 3843d5c65159SKalle Valo 38449d11b7bfSKarthikeyan Periyasamy int ath11k_wmi_vdev_spectral_conf(struct ath11k *ar, 38459d11b7bfSKarthikeyan Periyasamy struct ath11k_wmi_vdev_spectral_conf_param *param) 38469d11b7bfSKarthikeyan Periyasamy { 38479d11b7bfSKarthikeyan Periyasamy struct ath11k_wmi_vdev_spectral_conf_cmd *cmd; 38489d11b7bfSKarthikeyan Periyasamy struct sk_buff *skb; 38499d11b7bfSKarthikeyan Periyasamy int ret; 38509d11b7bfSKarthikeyan Periyasamy 38519d11b7bfSKarthikeyan Periyasamy skb = ath11k_wmi_alloc_skb(ar->wmi->wmi_ab, sizeof(*cmd)); 38529d11b7bfSKarthikeyan Periyasamy if (!skb) 38539d11b7bfSKarthikeyan Periyasamy return -ENOMEM; 38549d11b7bfSKarthikeyan Periyasamy 38559d11b7bfSKarthikeyan Periyasamy cmd = (struct ath11k_wmi_vdev_spectral_conf_cmd *)skb->data; 38569d11b7bfSKarthikeyan Periyasamy cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, 38579d11b7bfSKarthikeyan Periyasamy WMI_TAG_VDEV_SPECTRAL_CONFIGURE_CMD) | 38589d11b7bfSKarthikeyan Periyasamy FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 38599d11b7bfSKarthikeyan Periyasamy 38609d11b7bfSKarthikeyan Periyasamy memcpy(&cmd->param, param, sizeof(*param)); 38619d11b7bfSKarthikeyan Periyasamy 38629d11b7bfSKarthikeyan Periyasamy ret = ath11k_wmi_cmd_send(ar->wmi, skb, 38639d11b7bfSKarthikeyan Periyasamy WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID); 38649d11b7bfSKarthikeyan Periyasamy if (ret) { 38659d11b7bfSKarthikeyan Periyasamy ath11k_warn(ar->ab, 38669d11b7bfSKarthikeyan Periyasamy "failed to send spectral scan config wmi cmd\n"); 38679d11b7bfSKarthikeyan Periyasamy goto err; 38689d11b7bfSKarthikeyan Periyasamy } 38699d11b7bfSKarthikeyan Periyasamy 38709d11b7bfSKarthikeyan Periyasamy ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 38719d11b7bfSKarthikeyan Periyasamy "WMI spectral scan config cmd vdev_id 0x%x\n", 38729d11b7bfSKarthikeyan Periyasamy param->vdev_id); 38739d11b7bfSKarthikeyan Periyasamy 38749d11b7bfSKarthikeyan Periyasamy return 0; 38759d11b7bfSKarthikeyan Periyasamy err: 38769d11b7bfSKarthikeyan Periyasamy dev_kfree_skb(skb); 38779d11b7bfSKarthikeyan Periyasamy return ret; 38789d11b7bfSKarthikeyan Periyasamy } 38799d11b7bfSKarthikeyan Periyasamy 38809d11b7bfSKarthikeyan Periyasamy int ath11k_wmi_vdev_spectral_enable(struct ath11k *ar, u32 vdev_id, 38819d11b7bfSKarthikeyan Periyasamy u32 trigger, u32 enable) 38829d11b7bfSKarthikeyan Periyasamy { 38839d11b7bfSKarthikeyan Periyasamy struct ath11k_wmi_vdev_spectral_enable_cmd *cmd; 38849d11b7bfSKarthikeyan Periyasamy struct sk_buff *skb; 38859d11b7bfSKarthikeyan Periyasamy int ret; 38869d11b7bfSKarthikeyan Periyasamy 38879d11b7bfSKarthikeyan Periyasamy skb = ath11k_wmi_alloc_skb(ar->wmi->wmi_ab, sizeof(*cmd)); 38889d11b7bfSKarthikeyan Periyasamy if (!skb) 38899d11b7bfSKarthikeyan Periyasamy return -ENOMEM; 38909d11b7bfSKarthikeyan Periyasamy 38919d11b7bfSKarthikeyan Periyasamy cmd = (struct ath11k_wmi_vdev_spectral_enable_cmd *)skb->data; 38929d11b7bfSKarthikeyan Periyasamy cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, 38939d11b7bfSKarthikeyan Periyasamy WMI_TAG_VDEV_SPECTRAL_ENABLE_CMD) | 38949d11b7bfSKarthikeyan Periyasamy FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 38959d11b7bfSKarthikeyan Periyasamy 38969d11b7bfSKarthikeyan Periyasamy cmd->vdev_id = vdev_id; 38979d11b7bfSKarthikeyan Periyasamy cmd->trigger_cmd = trigger; 38989d11b7bfSKarthikeyan Periyasamy cmd->enable_cmd = enable; 38999d11b7bfSKarthikeyan Periyasamy 39009d11b7bfSKarthikeyan Periyasamy ret = ath11k_wmi_cmd_send(ar->wmi, skb, 39019d11b7bfSKarthikeyan Periyasamy WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID); 39029d11b7bfSKarthikeyan Periyasamy if (ret) { 39039d11b7bfSKarthikeyan Periyasamy ath11k_warn(ar->ab, 39049d11b7bfSKarthikeyan Periyasamy "failed to send spectral enable wmi cmd\n"); 39059d11b7bfSKarthikeyan Periyasamy goto err; 39069d11b7bfSKarthikeyan Periyasamy } 39079d11b7bfSKarthikeyan Periyasamy 39089d11b7bfSKarthikeyan Periyasamy ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 39099d11b7bfSKarthikeyan Periyasamy "WMI spectral enable cmd vdev id 0x%x\n", 39109d11b7bfSKarthikeyan Periyasamy vdev_id); 39119d11b7bfSKarthikeyan Periyasamy 39129d11b7bfSKarthikeyan Periyasamy return 0; 39139d11b7bfSKarthikeyan Periyasamy err: 39149d11b7bfSKarthikeyan Periyasamy dev_kfree_skb(skb); 39159d11b7bfSKarthikeyan Periyasamy return ret; 39169d11b7bfSKarthikeyan Periyasamy } 39179d11b7bfSKarthikeyan Periyasamy 3918bd647855SKarthikeyan Periyasamy int ath11k_wmi_pdev_dma_ring_cfg(struct ath11k *ar, 3919bd647855SKarthikeyan Periyasamy struct ath11k_wmi_pdev_dma_ring_cfg_req_cmd *param) 3920bd647855SKarthikeyan Periyasamy { 3921bd647855SKarthikeyan Periyasamy struct ath11k_wmi_pdev_dma_ring_cfg_req_cmd *cmd; 3922bd647855SKarthikeyan Periyasamy struct sk_buff *skb; 3923bd647855SKarthikeyan Periyasamy int ret; 3924bd647855SKarthikeyan Periyasamy 3925bd647855SKarthikeyan Periyasamy skb = ath11k_wmi_alloc_skb(ar->wmi->wmi_ab, sizeof(*cmd)); 3926bd647855SKarthikeyan Periyasamy if (!skb) 3927bd647855SKarthikeyan Periyasamy return -ENOMEM; 3928bd647855SKarthikeyan Periyasamy 3929bd647855SKarthikeyan Periyasamy cmd = (struct ath11k_wmi_pdev_dma_ring_cfg_req_cmd *)skb->data; 3930bd647855SKarthikeyan Periyasamy cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_DMA_RING_CFG_REQ) | 3931bd647855SKarthikeyan Periyasamy FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 3932bd647855SKarthikeyan Periyasamy 3933bd647855SKarthikeyan Periyasamy cmd->pdev_id = param->pdev_id; 3934bd647855SKarthikeyan Periyasamy cmd->module_id = param->module_id; 3935bd647855SKarthikeyan Periyasamy cmd->base_paddr_lo = param->base_paddr_lo; 3936bd647855SKarthikeyan Periyasamy cmd->base_paddr_hi = param->base_paddr_hi; 3937bd647855SKarthikeyan Periyasamy cmd->head_idx_paddr_lo = param->head_idx_paddr_lo; 3938bd647855SKarthikeyan Periyasamy cmd->head_idx_paddr_hi = param->head_idx_paddr_hi; 3939bd647855SKarthikeyan Periyasamy cmd->tail_idx_paddr_lo = param->tail_idx_paddr_lo; 3940bd647855SKarthikeyan Periyasamy cmd->tail_idx_paddr_hi = param->tail_idx_paddr_hi; 3941bd647855SKarthikeyan Periyasamy cmd->num_elems = param->num_elems; 3942bd647855SKarthikeyan Periyasamy cmd->buf_size = param->buf_size; 3943bd647855SKarthikeyan Periyasamy cmd->num_resp_per_event = param->num_resp_per_event; 3944bd647855SKarthikeyan Periyasamy cmd->event_timeout_ms = param->event_timeout_ms; 3945bd647855SKarthikeyan Periyasamy 3946bd647855SKarthikeyan Periyasamy ret = ath11k_wmi_cmd_send(ar->wmi, skb, 3947bd647855SKarthikeyan Periyasamy WMI_PDEV_DMA_RING_CFG_REQ_CMDID); 3948bd647855SKarthikeyan Periyasamy if (ret) { 3949bd647855SKarthikeyan Periyasamy ath11k_warn(ar->ab, 3950bd647855SKarthikeyan Periyasamy "failed to send dma ring cfg req wmi cmd\n"); 3951bd647855SKarthikeyan Periyasamy goto err; 3952bd647855SKarthikeyan Periyasamy } 3953bd647855SKarthikeyan Periyasamy 3954bd647855SKarthikeyan Periyasamy ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 3955bd647855SKarthikeyan Periyasamy "WMI DMA ring cfg req cmd pdev_id 0x%x\n", 3956bd647855SKarthikeyan Periyasamy param->pdev_id); 3957bd647855SKarthikeyan Periyasamy 3958bd647855SKarthikeyan Periyasamy return 0; 3959bd647855SKarthikeyan Periyasamy err: 3960bd647855SKarthikeyan Periyasamy dev_kfree_skb(skb); 3961bd647855SKarthikeyan Periyasamy return ret; 3962bd647855SKarthikeyan Periyasamy } 3963bd647855SKarthikeyan Periyasamy 39649d11b7bfSKarthikeyan Periyasamy static int ath11k_wmi_tlv_dma_buf_entry_parse(struct ath11k_base *soc, 39659d11b7bfSKarthikeyan Periyasamy u16 tag, u16 len, 39669d11b7bfSKarthikeyan Periyasamy const void *ptr, void *data) 39679d11b7bfSKarthikeyan Periyasamy { 39689d11b7bfSKarthikeyan Periyasamy struct wmi_tlv_dma_buf_release_parse *parse = data; 39699d11b7bfSKarthikeyan Periyasamy 39709d11b7bfSKarthikeyan Periyasamy if (tag != WMI_TAG_DMA_BUF_RELEASE_ENTRY) 39719d11b7bfSKarthikeyan Periyasamy return -EPROTO; 39729d11b7bfSKarthikeyan Periyasamy 39739d11b7bfSKarthikeyan Periyasamy if (parse->num_buf_entry >= parse->fixed.num_buf_release_entry) 39749d11b7bfSKarthikeyan Periyasamy return -ENOBUFS; 39759d11b7bfSKarthikeyan Periyasamy 39769d11b7bfSKarthikeyan Periyasamy parse->num_buf_entry++; 39779d11b7bfSKarthikeyan Periyasamy return 0; 39789d11b7bfSKarthikeyan Periyasamy } 39799d11b7bfSKarthikeyan Periyasamy 39809d11b7bfSKarthikeyan Periyasamy static int ath11k_wmi_tlv_dma_buf_meta_parse(struct ath11k_base *soc, 39819d11b7bfSKarthikeyan Periyasamy u16 tag, u16 len, 39829d11b7bfSKarthikeyan Periyasamy const void *ptr, void *data) 39839d11b7bfSKarthikeyan Periyasamy { 39849d11b7bfSKarthikeyan Periyasamy struct wmi_tlv_dma_buf_release_parse *parse = data; 39859d11b7bfSKarthikeyan Periyasamy 39869d11b7bfSKarthikeyan Periyasamy if (tag != WMI_TAG_DMA_BUF_RELEASE_SPECTRAL_META_DATA) 39879d11b7bfSKarthikeyan Periyasamy return -EPROTO; 39889d11b7bfSKarthikeyan Periyasamy 39899d11b7bfSKarthikeyan Periyasamy if (parse->num_meta >= parse->fixed.num_meta_data_entry) 39909d11b7bfSKarthikeyan Periyasamy return -ENOBUFS; 39919d11b7bfSKarthikeyan Periyasamy 39929d11b7bfSKarthikeyan Periyasamy parse->num_meta++; 39939d11b7bfSKarthikeyan Periyasamy return 0; 39949d11b7bfSKarthikeyan Periyasamy } 39959d11b7bfSKarthikeyan Periyasamy 39969d11b7bfSKarthikeyan Periyasamy static int ath11k_wmi_tlv_dma_buf_parse(struct ath11k_base *ab, 39979d11b7bfSKarthikeyan Periyasamy u16 tag, u16 len, 39989d11b7bfSKarthikeyan Periyasamy const void *ptr, void *data) 39999d11b7bfSKarthikeyan Periyasamy { 40009d11b7bfSKarthikeyan Periyasamy struct wmi_tlv_dma_buf_release_parse *parse = data; 40019d11b7bfSKarthikeyan Periyasamy int ret; 40029d11b7bfSKarthikeyan Periyasamy 40039d11b7bfSKarthikeyan Periyasamy switch (tag) { 40049d11b7bfSKarthikeyan Periyasamy case WMI_TAG_DMA_BUF_RELEASE: 40059d11b7bfSKarthikeyan Periyasamy memcpy(&parse->fixed, ptr, 40069d11b7bfSKarthikeyan Periyasamy sizeof(struct ath11k_wmi_dma_buf_release_fixed_param)); 40079d11b7bfSKarthikeyan Periyasamy parse->fixed.pdev_id = DP_HW2SW_MACID(parse->fixed.pdev_id); 40089d11b7bfSKarthikeyan Periyasamy break; 40099d11b7bfSKarthikeyan Periyasamy case WMI_TAG_ARRAY_STRUCT: 40109d11b7bfSKarthikeyan Periyasamy if (!parse->buf_entry_done) { 40119d11b7bfSKarthikeyan Periyasamy parse->num_buf_entry = 0; 40129d11b7bfSKarthikeyan Periyasamy parse->buf_entry = (struct wmi_dma_buf_release_entry *)ptr; 40139d11b7bfSKarthikeyan Periyasamy 40149d11b7bfSKarthikeyan Periyasamy ret = ath11k_wmi_tlv_iter(ab, ptr, len, 40159d11b7bfSKarthikeyan Periyasamy ath11k_wmi_tlv_dma_buf_entry_parse, 40169d11b7bfSKarthikeyan Periyasamy parse); 40179d11b7bfSKarthikeyan Periyasamy if (ret) { 40189d11b7bfSKarthikeyan Periyasamy ath11k_warn(ab, "failed to parse dma buf entry tlv %d\n", 40199d11b7bfSKarthikeyan Periyasamy ret); 40209d11b7bfSKarthikeyan Periyasamy return ret; 40219d11b7bfSKarthikeyan Periyasamy } 40229d11b7bfSKarthikeyan Periyasamy 40239d11b7bfSKarthikeyan Periyasamy parse->buf_entry_done = true; 40249d11b7bfSKarthikeyan Periyasamy } else if (!parse->meta_data_done) { 40259d11b7bfSKarthikeyan Periyasamy parse->num_meta = 0; 40269d11b7bfSKarthikeyan Periyasamy parse->meta_data = (struct wmi_dma_buf_release_meta_data *)ptr; 40279d11b7bfSKarthikeyan Periyasamy 40289d11b7bfSKarthikeyan Periyasamy ret = ath11k_wmi_tlv_iter(ab, ptr, len, 40299d11b7bfSKarthikeyan Periyasamy ath11k_wmi_tlv_dma_buf_meta_parse, 40309d11b7bfSKarthikeyan Periyasamy parse); 40319d11b7bfSKarthikeyan Periyasamy if (ret) { 40329d11b7bfSKarthikeyan Periyasamy ath11k_warn(ab, "failed to parse dma buf meta tlv %d\n", 40339d11b7bfSKarthikeyan Periyasamy ret); 40349d11b7bfSKarthikeyan Periyasamy return ret; 40359d11b7bfSKarthikeyan Periyasamy } 40369d11b7bfSKarthikeyan Periyasamy 40379d11b7bfSKarthikeyan Periyasamy parse->meta_data_done = true; 40389d11b7bfSKarthikeyan Periyasamy } 40399d11b7bfSKarthikeyan Periyasamy break; 40409d11b7bfSKarthikeyan Periyasamy default: 40419d11b7bfSKarthikeyan Periyasamy break; 40429d11b7bfSKarthikeyan Periyasamy } 40439d11b7bfSKarthikeyan Periyasamy return 0; 40449d11b7bfSKarthikeyan Periyasamy } 40459d11b7bfSKarthikeyan Periyasamy 40469d11b7bfSKarthikeyan Periyasamy static void ath11k_wmi_pdev_dma_ring_buf_release_event(struct ath11k_base *ab, 40479d11b7bfSKarthikeyan Periyasamy struct sk_buff *skb) 40489d11b7bfSKarthikeyan Periyasamy { 40499d11b7bfSKarthikeyan Periyasamy struct wmi_tlv_dma_buf_release_parse parse = { }; 40509d11b7bfSKarthikeyan Periyasamy struct ath11k_dbring_buf_release_event param; 40519d11b7bfSKarthikeyan Periyasamy int ret; 40529d11b7bfSKarthikeyan Periyasamy 40539d11b7bfSKarthikeyan Periyasamy ret = ath11k_wmi_tlv_iter(ab, skb->data, skb->len, 40549d11b7bfSKarthikeyan Periyasamy ath11k_wmi_tlv_dma_buf_parse, 40559d11b7bfSKarthikeyan Periyasamy &parse); 40569d11b7bfSKarthikeyan Periyasamy if (ret) { 40579d11b7bfSKarthikeyan Periyasamy ath11k_warn(ab, "failed to parse dma buf release tlv %d\n", ret); 40589d11b7bfSKarthikeyan Periyasamy return; 40599d11b7bfSKarthikeyan Periyasamy } 40609d11b7bfSKarthikeyan Periyasamy 40619d11b7bfSKarthikeyan Periyasamy param.fixed = parse.fixed; 40629d11b7bfSKarthikeyan Periyasamy param.buf_entry = parse.buf_entry; 40639d11b7bfSKarthikeyan Periyasamy param.num_buf_entry = parse.num_buf_entry; 40649d11b7bfSKarthikeyan Periyasamy param.meta_data = parse.meta_data; 40659d11b7bfSKarthikeyan Periyasamy param.num_meta = parse.num_meta; 40669d11b7bfSKarthikeyan Periyasamy 40679d11b7bfSKarthikeyan Periyasamy ret = ath11k_dbring_buffer_release_event(ab, ¶m); 40689d11b7bfSKarthikeyan Periyasamy if (ret) { 40699d11b7bfSKarthikeyan Periyasamy ath11k_warn(ab, "failed to handle dma buf release event %d\n", ret); 40709d11b7bfSKarthikeyan Periyasamy return; 40719d11b7bfSKarthikeyan Periyasamy } 40729d11b7bfSKarthikeyan Periyasamy } 40739d11b7bfSKarthikeyan Periyasamy 4074d5c65159SKalle Valo static int ath11k_wmi_tlv_hw_mode_caps_parse(struct ath11k_base *soc, 4075d5c65159SKalle Valo u16 tag, u16 len, 4076d5c65159SKalle Valo const void *ptr, void *data) 4077d5c65159SKalle Valo { 4078d5c65159SKalle Valo struct wmi_tlv_svc_rdy_ext_parse *svc_rdy_ext = data; 4079d5c65159SKalle Valo struct wmi_hw_mode_capabilities *hw_mode_cap; 4080d5c65159SKalle Valo u32 phy_map = 0; 4081d5c65159SKalle Valo 4082d5c65159SKalle Valo if (tag != WMI_TAG_HW_MODE_CAPABILITIES) 4083d5c65159SKalle Valo return -EPROTO; 4084d5c65159SKalle Valo 4085d5c65159SKalle Valo if (svc_rdy_ext->n_hw_mode_caps >= svc_rdy_ext->param.num_hw_modes) 4086d5c65159SKalle Valo return -ENOBUFS; 4087d5c65159SKalle Valo 4088d5c65159SKalle Valo hw_mode_cap = container_of(ptr, struct wmi_hw_mode_capabilities, 4089d5c65159SKalle Valo hw_mode_id); 4090d5c65159SKalle Valo svc_rdy_ext->n_hw_mode_caps++; 4091d5c65159SKalle Valo 4092d5c65159SKalle Valo phy_map = hw_mode_cap->phy_id_map; 4093d5c65159SKalle Valo while (phy_map) { 4094d5c65159SKalle Valo svc_rdy_ext->tot_phy_id++; 4095d5c65159SKalle Valo phy_map = phy_map >> 1; 4096d5c65159SKalle Valo } 4097d5c65159SKalle Valo 4098d5c65159SKalle Valo return 0; 4099d5c65159SKalle Valo } 4100d5c65159SKalle Valo 4101d5c65159SKalle Valo static int ath11k_wmi_tlv_hw_mode_caps(struct ath11k_base *soc, 4102d5c65159SKalle Valo u16 len, const void *ptr, void *data) 4103d5c65159SKalle Valo { 4104d5c65159SKalle Valo struct wmi_tlv_svc_rdy_ext_parse *svc_rdy_ext = data; 4105d5c65159SKalle Valo struct wmi_hw_mode_capabilities *hw_mode_caps; 4106d5c65159SKalle Valo enum wmi_host_hw_mode_config_type mode, pref; 4107d5c65159SKalle Valo u32 i; 4108d5c65159SKalle Valo int ret; 4109d5c65159SKalle Valo 4110d5c65159SKalle Valo svc_rdy_ext->n_hw_mode_caps = 0; 4111d5c65159SKalle Valo svc_rdy_ext->hw_mode_caps = (struct wmi_hw_mode_capabilities *)ptr; 4112d5c65159SKalle Valo 4113d5c65159SKalle Valo ret = ath11k_wmi_tlv_iter(soc, ptr, len, 4114d5c65159SKalle Valo ath11k_wmi_tlv_hw_mode_caps_parse, 4115d5c65159SKalle Valo svc_rdy_ext); 4116d5c65159SKalle Valo if (ret) { 4117d5c65159SKalle Valo ath11k_warn(soc, "failed to parse tlv %d\n", ret); 4118d5c65159SKalle Valo return ret; 4119d5c65159SKalle Valo } 4120d5c65159SKalle Valo 4121d5c65159SKalle Valo i = 0; 4122d5c65159SKalle Valo while (i < svc_rdy_ext->n_hw_mode_caps) { 4123d5c65159SKalle Valo hw_mode_caps = &svc_rdy_ext->hw_mode_caps[i]; 4124d5c65159SKalle Valo mode = hw_mode_caps->hw_mode_id; 41256bc9d6f7SJohn Crispin pref = soc->wmi_ab.preferred_hw_mode; 4126d5c65159SKalle Valo 4127d5c65159SKalle Valo if (ath11k_hw_mode_pri_map[mode] < ath11k_hw_mode_pri_map[pref]) { 4128d5c65159SKalle Valo svc_rdy_ext->pref_hw_mode_caps = *hw_mode_caps; 41296bc9d6f7SJohn Crispin soc->wmi_ab.preferred_hw_mode = mode; 4130d5c65159SKalle Valo } 4131d5c65159SKalle Valo i++; 4132d5c65159SKalle Valo } 4133d5c65159SKalle Valo 41345f859bc0SCarl Huang ath11k_dbg(soc, ATH11K_DBG_WMI, "preferred_hw_mode:%d\n", 41355f859bc0SCarl Huang soc->wmi_ab.preferred_hw_mode); 41366bc9d6f7SJohn Crispin if (soc->wmi_ab.preferred_hw_mode == WMI_HOST_HW_MODE_MAX) 4137d5c65159SKalle Valo return -EINVAL; 4138d5c65159SKalle Valo 4139d5c65159SKalle Valo return 0; 4140d5c65159SKalle Valo } 4141d5c65159SKalle Valo 4142d5c65159SKalle Valo static int ath11k_wmi_tlv_mac_phy_caps_parse(struct ath11k_base *soc, 4143d5c65159SKalle Valo u16 tag, u16 len, 4144d5c65159SKalle Valo const void *ptr, void *data) 4145d5c65159SKalle Valo { 4146d5c65159SKalle Valo struct wmi_tlv_svc_rdy_ext_parse *svc_rdy_ext = data; 4147d5c65159SKalle Valo 4148d5c65159SKalle Valo if (tag != WMI_TAG_MAC_PHY_CAPABILITIES) 4149d5c65159SKalle Valo return -EPROTO; 4150d5c65159SKalle Valo 4151d5c65159SKalle Valo if (svc_rdy_ext->n_mac_phy_caps >= svc_rdy_ext->tot_phy_id) 4152d5c65159SKalle Valo return -ENOBUFS; 4153d5c65159SKalle Valo 41545b90fc76SAnilkumar Kolli len = min_t(u16, len, sizeof(struct wmi_mac_phy_capabilities)); 41555b90fc76SAnilkumar Kolli if (!svc_rdy_ext->n_mac_phy_caps) { 4156ec436338SGustavo A. R. Silva svc_rdy_ext->mac_phy_caps = kcalloc(svc_rdy_ext->tot_phy_id, 4157ec436338SGustavo A. R. Silva len, GFP_ATOMIC); 41585b90fc76SAnilkumar Kolli if (!svc_rdy_ext->mac_phy_caps) 41595b90fc76SAnilkumar Kolli return -ENOMEM; 41605b90fc76SAnilkumar Kolli } 41615b90fc76SAnilkumar Kolli 41625b90fc76SAnilkumar Kolli memcpy(svc_rdy_ext->mac_phy_caps + svc_rdy_ext->n_mac_phy_caps, ptr, len); 4163d5c65159SKalle Valo svc_rdy_ext->n_mac_phy_caps++; 4164d5c65159SKalle Valo return 0; 4165d5c65159SKalle Valo } 4166d5c65159SKalle Valo 4167d5c65159SKalle Valo static int ath11k_wmi_tlv_ext_hal_reg_caps_parse(struct ath11k_base *soc, 4168d5c65159SKalle Valo u16 tag, u16 len, 4169d5c65159SKalle Valo const void *ptr, void *data) 4170d5c65159SKalle Valo { 4171d5c65159SKalle Valo struct wmi_tlv_svc_rdy_ext_parse *svc_rdy_ext = data; 4172d5c65159SKalle Valo 4173d5c65159SKalle Valo if (tag != WMI_TAG_HAL_REG_CAPABILITIES_EXT) 4174d5c65159SKalle Valo return -EPROTO; 4175d5c65159SKalle Valo 4176d5c65159SKalle Valo if (svc_rdy_ext->n_ext_hal_reg_caps >= svc_rdy_ext->param.num_phy) 4177d5c65159SKalle Valo return -ENOBUFS; 4178d5c65159SKalle Valo 4179d5c65159SKalle Valo svc_rdy_ext->n_ext_hal_reg_caps++; 4180d5c65159SKalle Valo return 0; 4181d5c65159SKalle Valo } 4182d5c65159SKalle Valo 4183d5c65159SKalle Valo static int ath11k_wmi_tlv_ext_hal_reg_caps(struct ath11k_base *soc, 4184d5c65159SKalle Valo u16 len, const void *ptr, void *data) 4185d5c65159SKalle Valo { 41866bc9d6f7SJohn Crispin struct ath11k_pdev_wmi *wmi_handle = &soc->wmi_ab.wmi[0]; 4187d5c65159SKalle Valo struct wmi_tlv_svc_rdy_ext_parse *svc_rdy_ext = data; 4188d5c65159SKalle Valo struct ath11k_hal_reg_capabilities_ext reg_cap; 4189d5c65159SKalle Valo int ret; 4190d5c65159SKalle Valo u32 i; 4191d5c65159SKalle Valo 4192d5c65159SKalle Valo svc_rdy_ext->n_ext_hal_reg_caps = 0; 4193d5c65159SKalle Valo svc_rdy_ext->ext_hal_reg_caps = (struct wmi_hal_reg_capabilities_ext *)ptr; 4194d5c65159SKalle Valo ret = ath11k_wmi_tlv_iter(soc, ptr, len, 4195d5c65159SKalle Valo ath11k_wmi_tlv_ext_hal_reg_caps_parse, 4196d5c65159SKalle Valo svc_rdy_ext); 4197d5c65159SKalle Valo if (ret) { 4198d5c65159SKalle Valo ath11k_warn(soc, "failed to parse tlv %d\n", ret); 4199d5c65159SKalle Valo return ret; 4200d5c65159SKalle Valo } 4201d5c65159SKalle Valo 4202d5c65159SKalle Valo for (i = 0; i < svc_rdy_ext->param.num_phy; i++) { 4203d5c65159SKalle Valo ret = ath11k_pull_reg_cap_svc_rdy_ext(wmi_handle, 4204d5c65159SKalle Valo svc_rdy_ext->soc_hal_reg_caps, 4205d5c65159SKalle Valo svc_rdy_ext->ext_hal_reg_caps, i, 4206d5c65159SKalle Valo ®_cap); 4207d5c65159SKalle Valo if (ret) { 4208d5c65159SKalle Valo ath11k_warn(soc, "failed to extract reg cap %d\n", i); 4209d5c65159SKalle Valo return ret; 4210d5c65159SKalle Valo } 4211d5c65159SKalle Valo 4212d5c65159SKalle Valo memcpy(&soc->hal_reg_cap[reg_cap.phy_id], 4213d5c65159SKalle Valo ®_cap, sizeof(reg_cap)); 4214d5c65159SKalle Valo } 4215d5c65159SKalle Valo return 0; 4216d5c65159SKalle Valo } 4217d5c65159SKalle Valo 4218d5c65159SKalle Valo static int ath11k_wmi_tlv_ext_soc_hal_reg_caps_parse(struct ath11k_base *soc, 4219d5c65159SKalle Valo u16 len, const void *ptr, 4220d5c65159SKalle Valo void *data) 4221d5c65159SKalle Valo { 42226bc9d6f7SJohn Crispin struct ath11k_pdev_wmi *wmi_handle = &soc->wmi_ab.wmi[0]; 4223d5c65159SKalle Valo struct wmi_tlv_svc_rdy_ext_parse *svc_rdy_ext = data; 4224d5c65159SKalle Valo u8 hw_mode_id = svc_rdy_ext->pref_hw_mode_caps.hw_mode_id; 4225d5c65159SKalle Valo u32 phy_id_map; 42265f859bc0SCarl Huang int pdev_index = 0; 4227d5c65159SKalle Valo int ret; 4228d5c65159SKalle Valo 4229d5c65159SKalle Valo svc_rdy_ext->soc_hal_reg_caps = (struct wmi_soc_hal_reg_capabilities *)ptr; 4230d5c65159SKalle Valo svc_rdy_ext->param.num_phy = svc_rdy_ext->soc_hal_reg_caps->num_phy; 4231d5c65159SKalle Valo 4232d5c65159SKalle Valo soc->num_radios = 0; 4233d5c65159SKalle Valo phy_id_map = svc_rdy_ext->pref_hw_mode_caps.phy_id_map; 4234d5c65159SKalle Valo 4235d5c65159SKalle Valo while (phy_id_map && soc->num_radios < MAX_RADIOS) { 4236d5c65159SKalle Valo ret = ath11k_pull_mac_phy_cap_svc_ready_ext(wmi_handle, 4237d5c65159SKalle Valo svc_rdy_ext->hw_caps, 4238d5c65159SKalle Valo svc_rdy_ext->hw_mode_caps, 4239d5c65159SKalle Valo svc_rdy_ext->soc_hal_reg_caps, 4240d5c65159SKalle Valo svc_rdy_ext->mac_phy_caps, 4241d5c65159SKalle Valo hw_mode_id, soc->num_radios, 42425f859bc0SCarl Huang &soc->pdevs[pdev_index]); 4243d5c65159SKalle Valo if (ret) { 4244d5c65159SKalle Valo ath11k_warn(soc, "failed to extract mac caps, idx :%d\n", 4245d5c65159SKalle Valo soc->num_radios); 4246d5c65159SKalle Valo return ret; 4247d5c65159SKalle Valo } 4248d5c65159SKalle Valo 4249d5c65159SKalle Valo soc->num_radios++; 4250d5c65159SKalle Valo 42515f859bc0SCarl Huang /* For QCA6390, save mac_phy capability in the same pdev */ 42525f859bc0SCarl Huang if (soc->hw_params.single_pdev_only) 42535f859bc0SCarl Huang pdev_index = 0; 42545f859bc0SCarl Huang else 42555f859bc0SCarl Huang pdev_index = soc->num_radios; 42565f859bc0SCarl Huang 4257d5c65159SKalle Valo /* TODO: mac_phy_cap prints */ 4258d5c65159SKalle Valo phy_id_map >>= 1; 4259d5c65159SKalle Valo } 42605f859bc0SCarl Huang 42615f859bc0SCarl Huang /* For QCA6390, set num_radios to 1 because host manages 42625f859bc0SCarl Huang * both 2G and 5G radio in one pdev. 42635f859bc0SCarl Huang * Set pdev_id = 0 and 0 means soc level. 42645f859bc0SCarl Huang */ 42655f859bc0SCarl Huang if (soc->hw_params.single_pdev_only) { 42665f859bc0SCarl Huang soc->num_radios = 1; 42675f859bc0SCarl Huang soc->pdevs[0].pdev_id = 0; 42685f859bc0SCarl Huang } 42695f859bc0SCarl Huang 4270d5c65159SKalle Valo return 0; 4271d5c65159SKalle Valo } 4272d5c65159SKalle Valo 4273bd647855SKarthikeyan Periyasamy static int ath11k_wmi_tlv_dma_ring_caps_parse(struct ath11k_base *soc, 4274bd647855SKarthikeyan Periyasamy u16 tag, u16 len, 4275bd647855SKarthikeyan Periyasamy const void *ptr, void *data) 4276bd647855SKarthikeyan Periyasamy { 4277bd647855SKarthikeyan Periyasamy struct wmi_tlv_dma_ring_caps_parse *parse = data; 4278bd647855SKarthikeyan Periyasamy 4279bd647855SKarthikeyan Periyasamy if (tag != WMI_TAG_DMA_RING_CAPABILITIES) 4280bd647855SKarthikeyan Periyasamy return -EPROTO; 4281bd647855SKarthikeyan Periyasamy 4282bd647855SKarthikeyan Periyasamy parse->n_dma_ring_caps++; 4283bd647855SKarthikeyan Periyasamy return 0; 4284bd647855SKarthikeyan Periyasamy } 4285bd647855SKarthikeyan Periyasamy 4286bd647855SKarthikeyan Periyasamy static int ath11k_wmi_alloc_dbring_caps(struct ath11k_base *ab, 4287bd647855SKarthikeyan Periyasamy u32 num_cap) 4288bd647855SKarthikeyan Periyasamy { 4289bd647855SKarthikeyan Periyasamy size_t sz; 4290bd647855SKarthikeyan Periyasamy void *ptr; 4291bd647855SKarthikeyan Periyasamy 4292bd647855SKarthikeyan Periyasamy sz = num_cap * sizeof(struct ath11k_dbring_cap); 4293bd647855SKarthikeyan Periyasamy ptr = kzalloc(sz, GFP_ATOMIC); 4294bd647855SKarthikeyan Periyasamy if (!ptr) 4295bd647855SKarthikeyan Periyasamy return -ENOMEM; 4296bd647855SKarthikeyan Periyasamy 4297bd647855SKarthikeyan Periyasamy ab->db_caps = ptr; 4298bd647855SKarthikeyan Periyasamy ab->num_db_cap = num_cap; 4299bd647855SKarthikeyan Periyasamy 4300bd647855SKarthikeyan Periyasamy return 0; 4301bd647855SKarthikeyan Periyasamy } 4302bd647855SKarthikeyan Periyasamy 4303bd647855SKarthikeyan Periyasamy static void ath11k_wmi_free_dbring_caps(struct ath11k_base *ab) 4304bd647855SKarthikeyan Periyasamy { 4305bd647855SKarthikeyan Periyasamy kfree(ab->db_caps); 4306bd647855SKarthikeyan Periyasamy ab->db_caps = NULL; 4307bd647855SKarthikeyan Periyasamy } 4308bd647855SKarthikeyan Periyasamy 4309bd647855SKarthikeyan Periyasamy static int ath11k_wmi_tlv_dma_ring_caps(struct ath11k_base *ab, 4310bd647855SKarthikeyan Periyasamy u16 len, const void *ptr, void *data) 4311bd647855SKarthikeyan Periyasamy { 4312bd647855SKarthikeyan Periyasamy struct wmi_tlv_dma_ring_caps_parse *dma_caps_parse = data; 4313bd647855SKarthikeyan Periyasamy struct wmi_dma_ring_capabilities *dma_caps; 4314bd647855SKarthikeyan Periyasamy struct ath11k_dbring_cap *dir_buff_caps; 4315bd647855SKarthikeyan Periyasamy int ret; 4316bd647855SKarthikeyan Periyasamy u32 i; 4317bd647855SKarthikeyan Periyasamy 4318bd647855SKarthikeyan Periyasamy dma_caps_parse->n_dma_ring_caps = 0; 4319bd647855SKarthikeyan Periyasamy dma_caps = (struct wmi_dma_ring_capabilities *)ptr; 4320bd647855SKarthikeyan Periyasamy ret = ath11k_wmi_tlv_iter(ab, ptr, len, 4321bd647855SKarthikeyan Periyasamy ath11k_wmi_tlv_dma_ring_caps_parse, 4322bd647855SKarthikeyan Periyasamy dma_caps_parse); 4323bd647855SKarthikeyan Periyasamy if (ret) { 4324bd647855SKarthikeyan Periyasamy ath11k_warn(ab, "failed to parse dma ring caps tlv %d\n", ret); 4325bd647855SKarthikeyan Periyasamy return ret; 4326bd647855SKarthikeyan Periyasamy } 4327bd647855SKarthikeyan Periyasamy 4328bd647855SKarthikeyan Periyasamy if (!dma_caps_parse->n_dma_ring_caps) 4329bd647855SKarthikeyan Periyasamy return 0; 4330bd647855SKarthikeyan Periyasamy 4331bd647855SKarthikeyan Periyasamy if (ab->num_db_cap) { 4332bd647855SKarthikeyan Periyasamy ath11k_warn(ab, "Already processed, so ignoring dma ring caps\n"); 4333bd647855SKarthikeyan Periyasamy return 0; 4334bd647855SKarthikeyan Periyasamy } 4335bd647855SKarthikeyan Periyasamy 4336bd647855SKarthikeyan Periyasamy ret = ath11k_wmi_alloc_dbring_caps(ab, dma_caps_parse->n_dma_ring_caps); 4337bd647855SKarthikeyan Periyasamy if (ret) 4338bd647855SKarthikeyan Periyasamy return ret; 4339bd647855SKarthikeyan Periyasamy 4340bd647855SKarthikeyan Periyasamy dir_buff_caps = ab->db_caps; 4341bd647855SKarthikeyan Periyasamy for (i = 0; i < dma_caps_parse->n_dma_ring_caps; i++) { 4342bd647855SKarthikeyan Periyasamy if (dma_caps[i].module_id >= WMI_DIRECT_BUF_MAX) { 4343bd647855SKarthikeyan Periyasamy ath11k_warn(ab, "Invalid module id %d\n", dma_caps[i].module_id); 4344bd647855SKarthikeyan Periyasamy ret = -EINVAL; 4345bd647855SKarthikeyan Periyasamy goto free_dir_buff; 4346bd647855SKarthikeyan Periyasamy } 4347bd647855SKarthikeyan Periyasamy 4348bd647855SKarthikeyan Periyasamy dir_buff_caps[i].id = dma_caps[i].module_id; 4349bd647855SKarthikeyan Periyasamy dir_buff_caps[i].pdev_id = DP_HW2SW_MACID(dma_caps[i].pdev_id); 4350bd647855SKarthikeyan Periyasamy dir_buff_caps[i].min_elem = dma_caps[i].min_elem; 4351bd647855SKarthikeyan Periyasamy dir_buff_caps[i].min_buf_sz = dma_caps[i].min_buf_sz; 4352bd647855SKarthikeyan Periyasamy dir_buff_caps[i].min_buf_align = dma_caps[i].min_buf_align; 4353bd647855SKarthikeyan Periyasamy } 4354bd647855SKarthikeyan Periyasamy 4355bd647855SKarthikeyan Periyasamy return 0; 4356bd647855SKarthikeyan Periyasamy 4357bd647855SKarthikeyan Periyasamy free_dir_buff: 4358bd647855SKarthikeyan Periyasamy ath11k_wmi_free_dbring_caps(ab); 4359bd647855SKarthikeyan Periyasamy return ret; 4360bd647855SKarthikeyan Periyasamy } 4361bd647855SKarthikeyan Periyasamy 4362d5c65159SKalle Valo static int ath11k_wmi_tlv_svc_rdy_ext_parse(struct ath11k_base *ab, 4363d5c65159SKalle Valo u16 tag, u16 len, 4364d5c65159SKalle Valo const void *ptr, void *data) 4365d5c65159SKalle Valo { 43666bc9d6f7SJohn Crispin struct ath11k_pdev_wmi *wmi_handle = &ab->wmi_ab.wmi[0]; 4367d5c65159SKalle Valo struct wmi_tlv_svc_rdy_ext_parse *svc_rdy_ext = data; 4368d5c65159SKalle Valo int ret; 4369d5c65159SKalle Valo 4370d5c65159SKalle Valo switch (tag) { 4371d5c65159SKalle Valo case WMI_TAG_SERVICE_READY_EXT_EVENT: 4372d5c65159SKalle Valo ret = ath11k_pull_svc_ready_ext(wmi_handle, ptr, 4373d5c65159SKalle Valo &svc_rdy_ext->param); 4374d5c65159SKalle Valo if (ret) { 4375d5c65159SKalle Valo ath11k_warn(ab, "unable to extract ext params\n"); 4376d5c65159SKalle Valo return ret; 4377d5c65159SKalle Valo } 4378d5c65159SKalle Valo break; 4379d5c65159SKalle Valo 4380d5c65159SKalle Valo case WMI_TAG_SOC_MAC_PHY_HW_MODE_CAPS: 4381d5c65159SKalle Valo svc_rdy_ext->hw_caps = (struct wmi_soc_mac_phy_hw_mode_caps *)ptr; 4382d5c65159SKalle Valo svc_rdy_ext->param.num_hw_modes = svc_rdy_ext->hw_caps->num_hw_modes; 4383d5c65159SKalle Valo break; 4384d5c65159SKalle Valo 4385d5c65159SKalle Valo case WMI_TAG_SOC_HAL_REG_CAPABILITIES: 4386d5c65159SKalle Valo ret = ath11k_wmi_tlv_ext_soc_hal_reg_caps_parse(ab, len, ptr, 4387d5c65159SKalle Valo svc_rdy_ext); 4388d5c65159SKalle Valo if (ret) 4389d5c65159SKalle Valo return ret; 4390d5c65159SKalle Valo break; 4391d5c65159SKalle Valo 4392d5c65159SKalle Valo case WMI_TAG_ARRAY_STRUCT: 4393d5c65159SKalle Valo if (!svc_rdy_ext->hw_mode_done) { 4394d5c65159SKalle Valo ret = ath11k_wmi_tlv_hw_mode_caps(ab, len, ptr, 4395d5c65159SKalle Valo svc_rdy_ext); 4396d5c65159SKalle Valo if (ret) 4397d5c65159SKalle Valo return ret; 4398d5c65159SKalle Valo 4399d5c65159SKalle Valo svc_rdy_ext->hw_mode_done = true; 4400d5c65159SKalle Valo } else if (!svc_rdy_ext->mac_phy_done) { 4401d5c65159SKalle Valo svc_rdy_ext->n_mac_phy_caps = 0; 4402d5c65159SKalle Valo ret = ath11k_wmi_tlv_iter(ab, ptr, len, 4403d5c65159SKalle Valo ath11k_wmi_tlv_mac_phy_caps_parse, 4404d5c65159SKalle Valo svc_rdy_ext); 4405d5c65159SKalle Valo if (ret) { 4406d5c65159SKalle Valo ath11k_warn(ab, "failed to parse tlv %d\n", ret); 4407d5c65159SKalle Valo return ret; 4408d5c65159SKalle Valo } 4409d5c65159SKalle Valo 4410d5c65159SKalle Valo svc_rdy_ext->mac_phy_done = true; 4411d5c65159SKalle Valo } else if (!svc_rdy_ext->ext_hal_reg_done) { 4412d5c65159SKalle Valo ret = ath11k_wmi_tlv_ext_hal_reg_caps(ab, len, ptr, 4413d5c65159SKalle Valo svc_rdy_ext); 4414d5c65159SKalle Valo if (ret) 4415d5c65159SKalle Valo return ret; 4416d5c65159SKalle Valo 4417d5c65159SKalle Valo svc_rdy_ext->ext_hal_reg_done = true; 4418bd647855SKarthikeyan Periyasamy } else if (!svc_rdy_ext->mac_phy_chainmask_combo_done) { 4419bd647855SKarthikeyan Periyasamy svc_rdy_ext->mac_phy_chainmask_combo_done = true; 4420bd647855SKarthikeyan Periyasamy } else if (!svc_rdy_ext->mac_phy_chainmask_cap_done) { 4421bd647855SKarthikeyan Periyasamy svc_rdy_ext->mac_phy_chainmask_cap_done = true; 4422bd647855SKarthikeyan Periyasamy } else if (!svc_rdy_ext->oem_dma_ring_cap_done) { 4423bd647855SKarthikeyan Periyasamy svc_rdy_ext->oem_dma_ring_cap_done = true; 4424bd647855SKarthikeyan Periyasamy } else if (!svc_rdy_ext->dma_ring_cap_done) { 4425bd647855SKarthikeyan Periyasamy ret = ath11k_wmi_tlv_dma_ring_caps(ab, len, ptr, 4426bd647855SKarthikeyan Periyasamy &svc_rdy_ext->dma_caps_parse); 4427bd647855SKarthikeyan Periyasamy if (ret) 4428bd647855SKarthikeyan Periyasamy return ret; 4429bd647855SKarthikeyan Periyasamy 4430bd647855SKarthikeyan Periyasamy svc_rdy_ext->dma_ring_cap_done = true; 4431d5c65159SKalle Valo } 4432d5c65159SKalle Valo break; 4433d5c65159SKalle Valo 4434d5c65159SKalle Valo default: 4435d5c65159SKalle Valo break; 4436d5c65159SKalle Valo } 4437d5c65159SKalle Valo return 0; 4438d5c65159SKalle Valo } 4439d5c65159SKalle Valo 4440d5c65159SKalle Valo static int ath11k_service_ready_ext_event(struct ath11k_base *ab, 4441d5c65159SKalle Valo struct sk_buff *skb) 4442d5c65159SKalle Valo { 4443d5c65159SKalle Valo struct wmi_tlv_svc_rdy_ext_parse svc_rdy_ext = { }; 4444d5c65159SKalle Valo int ret; 4445d5c65159SKalle Valo 4446d5c65159SKalle Valo ret = ath11k_wmi_tlv_iter(ab, skb->data, skb->len, 4447d5c65159SKalle Valo ath11k_wmi_tlv_svc_rdy_ext_parse, 4448d5c65159SKalle Valo &svc_rdy_ext); 4449d5c65159SKalle Valo if (ret) { 4450d5c65159SKalle Valo ath11k_warn(ab, "failed to parse tlv %d\n", ret); 4451bd647855SKarthikeyan Periyasamy goto err; 4452d5c65159SKalle Valo } 4453d5c65159SKalle Valo 4454bd647855SKarthikeyan Periyasamy if (!test_bit(WMI_TLV_SERVICE_EXT2_MSG, ab->wmi_ab.svc_map)) 4455bd647855SKarthikeyan Periyasamy complete(&ab->wmi_ab.service_ready); 4456bd647855SKarthikeyan Periyasamy 44575b90fc76SAnilkumar Kolli kfree(svc_rdy_ext.mac_phy_caps); 4458d5c65159SKalle Valo return 0; 4459bd647855SKarthikeyan Periyasamy 4460bd647855SKarthikeyan Periyasamy err: 4461bd647855SKarthikeyan Periyasamy ath11k_wmi_free_dbring_caps(ab); 4462bd647855SKarthikeyan Periyasamy return ret; 4463bd647855SKarthikeyan Periyasamy } 4464bd647855SKarthikeyan Periyasamy 4465bd647855SKarthikeyan Periyasamy static int ath11k_wmi_tlv_svc_rdy_ext2_parse(struct ath11k_base *ab, 4466bd647855SKarthikeyan Periyasamy u16 tag, u16 len, 4467bd647855SKarthikeyan Periyasamy const void *ptr, void *data) 4468bd647855SKarthikeyan Periyasamy { 4469bd647855SKarthikeyan Periyasamy struct wmi_tlv_svc_rdy_ext2_parse *parse = data; 4470bd647855SKarthikeyan Periyasamy int ret; 4471bd647855SKarthikeyan Periyasamy 4472bd647855SKarthikeyan Periyasamy switch (tag) { 4473bd647855SKarthikeyan Periyasamy case WMI_TAG_ARRAY_STRUCT: 4474bd647855SKarthikeyan Periyasamy if (!parse->dma_ring_cap_done) { 4475bd647855SKarthikeyan Periyasamy ret = ath11k_wmi_tlv_dma_ring_caps(ab, len, ptr, 4476bd647855SKarthikeyan Periyasamy &parse->dma_caps_parse); 4477bd647855SKarthikeyan Periyasamy if (ret) 4478bd647855SKarthikeyan Periyasamy return ret; 4479bd647855SKarthikeyan Periyasamy 4480bd647855SKarthikeyan Periyasamy parse->dma_ring_cap_done = true; 4481bd647855SKarthikeyan Periyasamy } 4482bd647855SKarthikeyan Periyasamy break; 4483bd647855SKarthikeyan Periyasamy default: 4484bd647855SKarthikeyan Periyasamy break; 4485bd647855SKarthikeyan Periyasamy } 4486bd647855SKarthikeyan Periyasamy 4487bd647855SKarthikeyan Periyasamy return 0; 4488bd647855SKarthikeyan Periyasamy } 4489bd647855SKarthikeyan Periyasamy 4490bd647855SKarthikeyan Periyasamy static int ath11k_service_ready_ext2_event(struct ath11k_base *ab, 4491bd647855SKarthikeyan Periyasamy struct sk_buff *skb) 4492bd647855SKarthikeyan Periyasamy { 4493bd647855SKarthikeyan Periyasamy struct wmi_tlv_svc_rdy_ext2_parse svc_rdy_ext2 = { }; 4494bd647855SKarthikeyan Periyasamy int ret; 4495bd647855SKarthikeyan Periyasamy 4496bd647855SKarthikeyan Periyasamy ret = ath11k_wmi_tlv_iter(ab, skb->data, skb->len, 4497bd647855SKarthikeyan Periyasamy ath11k_wmi_tlv_svc_rdy_ext2_parse, 4498bd647855SKarthikeyan Periyasamy &svc_rdy_ext2); 4499bd647855SKarthikeyan Periyasamy if (ret) { 4500bd647855SKarthikeyan Periyasamy ath11k_warn(ab, "failed to parse ext2 event tlv %d\n", ret); 4501bd647855SKarthikeyan Periyasamy goto err; 4502bd647855SKarthikeyan Periyasamy } 4503bd647855SKarthikeyan Periyasamy 4504bd647855SKarthikeyan Periyasamy complete(&ab->wmi_ab.service_ready); 4505bd647855SKarthikeyan Periyasamy 4506bd647855SKarthikeyan Periyasamy return 0; 4507bd647855SKarthikeyan Periyasamy 4508bd647855SKarthikeyan Periyasamy err: 4509bd647855SKarthikeyan Periyasamy ath11k_wmi_free_dbring_caps(ab); 4510bd647855SKarthikeyan Periyasamy return ret; 4511d5c65159SKalle Valo } 4512d5c65159SKalle Valo 4513d5c65159SKalle Valo static int ath11k_pull_vdev_start_resp_tlv(struct ath11k_base *ab, struct sk_buff *skb, 4514d5c65159SKalle Valo struct wmi_vdev_start_resp_event *vdev_rsp) 4515d5c65159SKalle Valo { 4516d5c65159SKalle Valo const void **tb; 4517d5c65159SKalle Valo const struct wmi_vdev_start_resp_event *ev; 4518d5c65159SKalle Valo int ret; 4519d5c65159SKalle Valo 4520d5c65159SKalle Valo tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC); 4521d5c65159SKalle Valo if (IS_ERR(tb)) { 4522d5c65159SKalle Valo ret = PTR_ERR(tb); 4523d5c65159SKalle Valo ath11k_warn(ab, "failed to parse tlv: %d\n", ret); 4524d5c65159SKalle Valo return ret; 4525d5c65159SKalle Valo } 4526d5c65159SKalle Valo 4527d5c65159SKalle Valo ev = tb[WMI_TAG_VDEV_START_RESPONSE_EVENT]; 4528d5c65159SKalle Valo if (!ev) { 4529d5c65159SKalle Valo ath11k_warn(ab, "failed to fetch vdev start resp ev"); 4530d5c65159SKalle Valo kfree(tb); 4531d5c65159SKalle Valo return -EPROTO; 4532d5c65159SKalle Valo } 4533d5c65159SKalle Valo 4534d5c65159SKalle Valo memset(vdev_rsp, 0, sizeof(*vdev_rsp)); 4535d5c65159SKalle Valo 4536d5c65159SKalle Valo vdev_rsp->vdev_id = ev->vdev_id; 4537d5c65159SKalle Valo vdev_rsp->requestor_id = ev->requestor_id; 4538d5c65159SKalle Valo vdev_rsp->resp_type = ev->resp_type; 4539d5c65159SKalle Valo vdev_rsp->status = ev->status; 4540d5c65159SKalle Valo vdev_rsp->chain_mask = ev->chain_mask; 4541d5c65159SKalle Valo vdev_rsp->smps_mode = ev->smps_mode; 4542d5c65159SKalle Valo vdev_rsp->mac_id = ev->mac_id; 4543d5c65159SKalle Valo vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams; 4544d5c65159SKalle Valo vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams; 4545d5c65159SKalle Valo 4546d5c65159SKalle Valo kfree(tb); 4547d5c65159SKalle Valo return 0; 4548d5c65159SKalle Valo } 4549d5c65159SKalle Valo 4550d5c65159SKalle Valo static struct cur_reg_rule 4551d5c65159SKalle Valo *create_reg_rules_from_wmi(u32 num_reg_rules, 4552d5c65159SKalle Valo struct wmi_regulatory_rule_struct *wmi_reg_rule) 4553d5c65159SKalle Valo { 4554d5c65159SKalle Valo struct cur_reg_rule *reg_rule_ptr; 4555d5c65159SKalle Valo u32 count; 4556d5c65159SKalle Valo 4557ec436338SGustavo A. R. Silva reg_rule_ptr = kcalloc(num_reg_rules, sizeof(*reg_rule_ptr), 4558d5c65159SKalle Valo GFP_ATOMIC); 4559d5c65159SKalle Valo 4560d5c65159SKalle Valo if (!reg_rule_ptr) 4561d5c65159SKalle Valo return NULL; 4562d5c65159SKalle Valo 4563d5c65159SKalle Valo for (count = 0; count < num_reg_rules; count++) { 4564d5c65159SKalle Valo reg_rule_ptr[count].start_freq = 4565d5c65159SKalle Valo FIELD_GET(REG_RULE_START_FREQ, 4566d5c65159SKalle Valo wmi_reg_rule[count].freq_info); 4567d5c65159SKalle Valo reg_rule_ptr[count].end_freq = 4568d5c65159SKalle Valo FIELD_GET(REG_RULE_END_FREQ, 4569d5c65159SKalle Valo wmi_reg_rule[count].freq_info); 4570d5c65159SKalle Valo reg_rule_ptr[count].max_bw = 4571d5c65159SKalle Valo FIELD_GET(REG_RULE_MAX_BW, 4572d5c65159SKalle Valo wmi_reg_rule[count].bw_pwr_info); 4573d5c65159SKalle Valo reg_rule_ptr[count].reg_power = 4574d5c65159SKalle Valo FIELD_GET(REG_RULE_REG_PWR, 4575d5c65159SKalle Valo wmi_reg_rule[count].bw_pwr_info); 4576d5c65159SKalle Valo reg_rule_ptr[count].ant_gain = 4577d5c65159SKalle Valo FIELD_GET(REG_RULE_ANT_GAIN, 4578d5c65159SKalle Valo wmi_reg_rule[count].bw_pwr_info); 4579d5c65159SKalle Valo reg_rule_ptr[count].flags = 4580d5c65159SKalle Valo FIELD_GET(REG_RULE_FLAGS, 4581d5c65159SKalle Valo wmi_reg_rule[count].flag_info); 4582d5c65159SKalle Valo } 4583d5c65159SKalle Valo 4584d5c65159SKalle Valo return reg_rule_ptr; 4585d5c65159SKalle Valo } 4586d5c65159SKalle Valo 4587d5c65159SKalle Valo static int ath11k_pull_reg_chan_list_update_ev(struct ath11k_base *ab, 4588d5c65159SKalle Valo struct sk_buff *skb, 4589d5c65159SKalle Valo struct cur_regulatory_info *reg_info) 4590d5c65159SKalle Valo { 4591d5c65159SKalle Valo const void **tb; 4592d5c65159SKalle Valo const struct wmi_reg_chan_list_cc_event *chan_list_event_hdr; 4593d5c65159SKalle Valo struct wmi_regulatory_rule_struct *wmi_reg_rule; 4594d5c65159SKalle Valo u32 num_2g_reg_rules, num_5g_reg_rules; 4595d5c65159SKalle Valo int ret; 4596d5c65159SKalle Valo 4597d5c65159SKalle Valo ath11k_dbg(ab, ATH11K_DBG_WMI, "processing regulatory channel list\n"); 4598d5c65159SKalle Valo 4599d5c65159SKalle Valo tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC); 4600d5c65159SKalle Valo if (IS_ERR(tb)) { 4601d5c65159SKalle Valo ret = PTR_ERR(tb); 4602d5c65159SKalle Valo ath11k_warn(ab, "failed to parse tlv: %d\n", ret); 4603d5c65159SKalle Valo return ret; 4604d5c65159SKalle Valo } 4605d5c65159SKalle Valo 4606d5c65159SKalle Valo chan_list_event_hdr = tb[WMI_TAG_REG_CHAN_LIST_CC_EVENT]; 4607d5c65159SKalle Valo if (!chan_list_event_hdr) { 4608d5c65159SKalle Valo ath11k_warn(ab, "failed to fetch reg chan list update ev\n"); 4609d5c65159SKalle Valo kfree(tb); 4610d5c65159SKalle Valo return -EPROTO; 4611d5c65159SKalle Valo } 4612d5c65159SKalle Valo 4613d5c65159SKalle Valo reg_info->num_2g_reg_rules = chan_list_event_hdr->num_2g_reg_rules; 4614d5c65159SKalle Valo reg_info->num_5g_reg_rules = chan_list_event_hdr->num_5g_reg_rules; 4615d5c65159SKalle Valo 4616d5c65159SKalle Valo if (!(reg_info->num_2g_reg_rules + reg_info->num_5g_reg_rules)) { 4617d5c65159SKalle Valo ath11k_warn(ab, "No regulatory rules available in the event info\n"); 4618d5c65159SKalle Valo kfree(tb); 4619d5c65159SKalle Valo return -EINVAL; 4620d5c65159SKalle Valo } 4621d5c65159SKalle Valo 4622d5c65159SKalle Valo memcpy(reg_info->alpha2, &chan_list_event_hdr->alpha2, 4623d5c65159SKalle Valo REG_ALPHA2_LEN); 4624d5c65159SKalle Valo reg_info->dfs_region = chan_list_event_hdr->dfs_region; 4625d5c65159SKalle Valo reg_info->phybitmap = chan_list_event_hdr->phybitmap; 4626d5c65159SKalle Valo reg_info->num_phy = chan_list_event_hdr->num_phy; 4627d5c65159SKalle Valo reg_info->phy_id = chan_list_event_hdr->phy_id; 4628d5c65159SKalle Valo reg_info->ctry_code = chan_list_event_hdr->country_id; 4629d5c65159SKalle Valo reg_info->reg_dmn_pair = chan_list_event_hdr->domain_code; 4630d5c65159SKalle Valo if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_PASS) 4631d5c65159SKalle Valo reg_info->status_code = REG_SET_CC_STATUS_PASS; 4632d5c65159SKalle Valo else if (chan_list_event_hdr->status_code == WMI_REG_CURRENT_ALPHA2_NOT_FOUND) 4633d5c65159SKalle Valo reg_info->status_code = REG_CURRENT_ALPHA2_NOT_FOUND; 4634d5c65159SKalle Valo else if (chan_list_event_hdr->status_code == WMI_REG_INIT_ALPHA2_NOT_FOUND) 4635d5c65159SKalle Valo reg_info->status_code = REG_INIT_ALPHA2_NOT_FOUND; 4636d5c65159SKalle Valo else if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_CHANGE_NOT_ALLOWED) 4637d5c65159SKalle Valo reg_info->status_code = REG_SET_CC_CHANGE_NOT_ALLOWED; 4638d5c65159SKalle Valo else if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_NO_MEMORY) 4639d5c65159SKalle Valo reg_info->status_code = REG_SET_CC_STATUS_NO_MEMORY; 4640d5c65159SKalle Valo else if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_FAIL) 4641d5c65159SKalle Valo reg_info->status_code = REG_SET_CC_STATUS_FAIL; 4642d5c65159SKalle Valo 4643d5c65159SKalle Valo reg_info->min_bw_2g = chan_list_event_hdr->min_bw_2g; 4644d5c65159SKalle Valo reg_info->max_bw_2g = chan_list_event_hdr->max_bw_2g; 4645d5c65159SKalle Valo reg_info->min_bw_5g = chan_list_event_hdr->min_bw_5g; 4646d5c65159SKalle Valo reg_info->max_bw_5g = chan_list_event_hdr->max_bw_5g; 4647d5c65159SKalle Valo 4648d5c65159SKalle Valo num_2g_reg_rules = reg_info->num_2g_reg_rules; 4649d5c65159SKalle Valo num_5g_reg_rules = reg_info->num_5g_reg_rules; 4650d5c65159SKalle Valo 4651d5c65159SKalle Valo ath11k_dbg(ab, ATH11K_DBG_WMI, 4652d5c65159SKalle Valo "%s:cc %s dsf %d BW: min_2g %d max_2g %d min_5g %d max_5g %d", 4653d5c65159SKalle Valo __func__, reg_info->alpha2, reg_info->dfs_region, 4654d5c65159SKalle Valo reg_info->min_bw_2g, reg_info->max_bw_2g, 4655d5c65159SKalle Valo reg_info->min_bw_5g, reg_info->max_bw_5g); 4656d5c65159SKalle Valo 4657d5c65159SKalle Valo ath11k_dbg(ab, ATH11K_DBG_WMI, 4658d5c65159SKalle Valo "%s: num_2g_reg_rules %d num_5g_reg_rules %d", __func__, 4659d5c65159SKalle Valo num_2g_reg_rules, num_5g_reg_rules); 4660d5c65159SKalle Valo 4661d5c65159SKalle Valo wmi_reg_rule = 4662d5c65159SKalle Valo (struct wmi_regulatory_rule_struct *)((u8 *)chan_list_event_hdr 4663d5c65159SKalle Valo + sizeof(*chan_list_event_hdr) 4664d5c65159SKalle Valo + sizeof(struct wmi_tlv)); 4665d5c65159SKalle Valo 4666d5c65159SKalle Valo if (num_2g_reg_rules) { 4667d5c65159SKalle Valo reg_info->reg_rules_2g_ptr = create_reg_rules_from_wmi(num_2g_reg_rules, 4668d5c65159SKalle Valo wmi_reg_rule); 4669d5c65159SKalle Valo if (!reg_info->reg_rules_2g_ptr) { 4670d5c65159SKalle Valo kfree(tb); 4671d5c65159SKalle Valo ath11k_warn(ab, "Unable to Allocate memory for 2g rules\n"); 4672d5c65159SKalle Valo return -ENOMEM; 4673d5c65159SKalle Valo } 4674d5c65159SKalle Valo } 4675d5c65159SKalle Valo 4676d5c65159SKalle Valo if (num_5g_reg_rules) { 4677d5c65159SKalle Valo wmi_reg_rule += num_2g_reg_rules; 4678d5c65159SKalle Valo reg_info->reg_rules_5g_ptr = create_reg_rules_from_wmi(num_5g_reg_rules, 4679d5c65159SKalle Valo wmi_reg_rule); 4680d5c65159SKalle Valo if (!reg_info->reg_rules_5g_ptr) { 4681d5c65159SKalle Valo kfree(tb); 4682d5c65159SKalle Valo ath11k_warn(ab, "Unable to Allocate memory for 5g rules\n"); 4683d5c65159SKalle Valo return -ENOMEM; 4684d5c65159SKalle Valo } 4685d5c65159SKalle Valo } 4686d5c65159SKalle Valo 4687d5c65159SKalle Valo ath11k_dbg(ab, ATH11K_DBG_WMI, "processed regulatory channel list\n"); 4688d5c65159SKalle Valo 4689d5c65159SKalle Valo kfree(tb); 4690d5c65159SKalle Valo return 0; 4691d5c65159SKalle Valo } 4692d5c65159SKalle Valo 4693d5c65159SKalle Valo static int ath11k_pull_peer_del_resp_ev(struct ath11k_base *ab, struct sk_buff *skb, 4694d5c65159SKalle Valo struct wmi_peer_delete_resp_event *peer_del_resp) 4695d5c65159SKalle Valo { 4696d5c65159SKalle Valo const void **tb; 4697d5c65159SKalle Valo const struct wmi_peer_delete_resp_event *ev; 4698d5c65159SKalle Valo int ret; 4699d5c65159SKalle Valo 4700d5c65159SKalle Valo tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC); 4701d5c65159SKalle Valo if (IS_ERR(tb)) { 4702d5c65159SKalle Valo ret = PTR_ERR(tb); 4703d5c65159SKalle Valo ath11k_warn(ab, "failed to parse tlv: %d\n", ret); 4704d5c65159SKalle Valo return ret; 4705d5c65159SKalle Valo } 4706d5c65159SKalle Valo 4707d5c65159SKalle Valo ev = tb[WMI_TAG_PEER_DELETE_RESP_EVENT]; 4708d5c65159SKalle Valo if (!ev) { 4709d5c65159SKalle Valo ath11k_warn(ab, "failed to fetch peer delete resp ev"); 4710d5c65159SKalle Valo kfree(tb); 4711d5c65159SKalle Valo return -EPROTO; 4712d5c65159SKalle Valo } 4713d5c65159SKalle Valo 4714d5c65159SKalle Valo memset(peer_del_resp, 0, sizeof(*peer_del_resp)); 4715d5c65159SKalle Valo 4716d5c65159SKalle Valo peer_del_resp->vdev_id = ev->vdev_id; 4717d5c65159SKalle Valo ether_addr_copy(peer_del_resp->peer_macaddr.addr, 4718d5c65159SKalle Valo ev->peer_macaddr.addr); 4719d5c65159SKalle Valo 4720d5c65159SKalle Valo kfree(tb); 4721d5c65159SKalle Valo return 0; 4722d5c65159SKalle Valo } 4723d5c65159SKalle Valo 47243cbbdfbeSRitesh Singh static int ath11k_pull_vdev_del_resp_ev(struct ath11k_base *ab, 47253cbbdfbeSRitesh Singh struct sk_buff *skb, 47263cbbdfbeSRitesh Singh u32 *vdev_id) 47273cbbdfbeSRitesh Singh { 47283cbbdfbeSRitesh Singh const void **tb; 47293cbbdfbeSRitesh Singh const struct wmi_vdev_delete_resp_event *ev; 47303cbbdfbeSRitesh Singh int ret; 47313cbbdfbeSRitesh Singh 47323cbbdfbeSRitesh Singh tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC); 47333cbbdfbeSRitesh Singh if (IS_ERR(tb)) { 47343cbbdfbeSRitesh Singh ret = PTR_ERR(tb); 47353cbbdfbeSRitesh Singh ath11k_warn(ab, "failed to parse tlv: %d\n", ret); 47363cbbdfbeSRitesh Singh return ret; 47373cbbdfbeSRitesh Singh } 47383cbbdfbeSRitesh Singh 47393cbbdfbeSRitesh Singh ev = tb[WMI_TAG_VDEV_DELETE_RESP_EVENT]; 47403cbbdfbeSRitesh Singh if (!ev) { 47413cbbdfbeSRitesh Singh ath11k_warn(ab, "failed to fetch vdev delete resp ev"); 47423cbbdfbeSRitesh Singh kfree(tb); 47433cbbdfbeSRitesh Singh return -EPROTO; 47443cbbdfbeSRitesh Singh } 47453cbbdfbeSRitesh Singh 47463cbbdfbeSRitesh Singh *vdev_id = ev->vdev_id; 47473cbbdfbeSRitesh Singh 47483cbbdfbeSRitesh Singh kfree(tb); 47493cbbdfbeSRitesh Singh return 0; 47503cbbdfbeSRitesh Singh } 47513cbbdfbeSRitesh Singh 4752d5c65159SKalle Valo static int ath11k_pull_bcn_tx_status_ev(struct ath11k_base *ab, void *evt_buf, 4753d5c65159SKalle Valo u32 len, u32 *vdev_id, 4754d5c65159SKalle Valo u32 *tx_status) 4755d5c65159SKalle Valo { 4756d5c65159SKalle Valo const void **tb; 4757d5c65159SKalle Valo const struct wmi_bcn_tx_status_event *ev; 4758d5c65159SKalle Valo int ret; 4759d5c65159SKalle Valo 4760d5c65159SKalle Valo tb = ath11k_wmi_tlv_parse_alloc(ab, evt_buf, len, GFP_ATOMIC); 4761d5c65159SKalle Valo if (IS_ERR(tb)) { 4762d5c65159SKalle Valo ret = PTR_ERR(tb); 4763d5c65159SKalle Valo ath11k_warn(ab, "failed to parse tlv: %d\n", ret); 4764d5c65159SKalle Valo return ret; 4765d5c65159SKalle Valo } 4766d5c65159SKalle Valo 4767d5c65159SKalle Valo ev = tb[WMI_TAG_OFFLOAD_BCN_TX_STATUS_EVENT]; 4768d5c65159SKalle Valo if (!ev) { 4769d5c65159SKalle Valo ath11k_warn(ab, "failed to fetch bcn tx status ev"); 4770d5c65159SKalle Valo kfree(tb); 4771d5c65159SKalle Valo return -EPROTO; 4772d5c65159SKalle Valo } 4773d5c65159SKalle Valo 4774d5c65159SKalle Valo *vdev_id = ev->vdev_id; 4775d5c65159SKalle Valo *tx_status = ev->tx_status; 4776d5c65159SKalle Valo 4777d5c65159SKalle Valo kfree(tb); 4778d5c65159SKalle Valo return 0; 4779d5c65159SKalle Valo } 4780d5c65159SKalle Valo 4781d5c65159SKalle Valo static int ath11k_pull_vdev_stopped_param_tlv(struct ath11k_base *ab, struct sk_buff *skb, 4782d5c65159SKalle Valo u32 *vdev_id) 4783d5c65159SKalle Valo { 4784d5c65159SKalle Valo const void **tb; 4785d5c65159SKalle Valo const struct wmi_vdev_stopped_event *ev; 4786d5c65159SKalle Valo int ret; 4787d5c65159SKalle Valo 4788d5c65159SKalle Valo tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC); 4789d5c65159SKalle Valo if (IS_ERR(tb)) { 4790d5c65159SKalle Valo ret = PTR_ERR(tb); 4791d5c65159SKalle Valo ath11k_warn(ab, "failed to parse tlv: %d\n", ret); 4792d5c65159SKalle Valo return ret; 4793d5c65159SKalle Valo } 4794d5c65159SKalle Valo 4795d5c65159SKalle Valo ev = tb[WMI_TAG_VDEV_STOPPED_EVENT]; 4796d5c65159SKalle Valo if (!ev) { 4797d5c65159SKalle Valo ath11k_warn(ab, "failed to fetch vdev stop ev"); 4798d5c65159SKalle Valo kfree(tb); 4799d5c65159SKalle Valo return -EPROTO; 4800d5c65159SKalle Valo } 4801d5c65159SKalle Valo 4802d5c65159SKalle Valo *vdev_id = ev->vdev_id; 4803d5c65159SKalle Valo 4804d5c65159SKalle Valo kfree(tb); 4805d5c65159SKalle Valo return 0; 4806d5c65159SKalle Valo } 4807d5c65159SKalle Valo 4808d5c65159SKalle Valo static int ath11k_pull_mgmt_rx_params_tlv(struct ath11k_base *ab, 4809d5c65159SKalle Valo struct sk_buff *skb, 4810d5c65159SKalle Valo struct mgmt_rx_event_params *hdr) 4811d5c65159SKalle Valo { 4812d5c65159SKalle Valo const void **tb; 4813d5c65159SKalle Valo const struct wmi_mgmt_rx_hdr *ev; 4814d5c65159SKalle Valo const u8 *frame; 4815d5c65159SKalle Valo int ret; 4816d5c65159SKalle Valo 4817d5c65159SKalle Valo tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC); 4818d5c65159SKalle Valo if (IS_ERR(tb)) { 4819d5c65159SKalle Valo ret = PTR_ERR(tb); 4820d5c65159SKalle Valo ath11k_warn(ab, "failed to parse tlv: %d\n", ret); 4821d5c65159SKalle Valo return ret; 4822d5c65159SKalle Valo } 4823d5c65159SKalle Valo 4824d5c65159SKalle Valo ev = tb[WMI_TAG_MGMT_RX_HDR]; 4825d5c65159SKalle Valo frame = tb[WMI_TAG_ARRAY_BYTE]; 4826d5c65159SKalle Valo 4827d5c65159SKalle Valo if (!ev || !frame) { 4828d5c65159SKalle Valo ath11k_warn(ab, "failed to fetch mgmt rx hdr"); 4829d5c65159SKalle Valo kfree(tb); 4830d5c65159SKalle Valo return -EPROTO; 4831d5c65159SKalle Valo } 4832d5c65159SKalle Valo 4833d5c65159SKalle Valo hdr->pdev_id = ev->pdev_id; 48345dcf42f8SPradeep Kumar Chitrapu hdr->chan_freq = ev->chan_freq; 4835d5c65159SKalle Valo hdr->channel = ev->channel; 4836d5c65159SKalle Valo hdr->snr = ev->snr; 4837d5c65159SKalle Valo hdr->rate = ev->rate; 4838d5c65159SKalle Valo hdr->phy_mode = ev->phy_mode; 4839d5c65159SKalle Valo hdr->buf_len = ev->buf_len; 4840d5c65159SKalle Valo hdr->status = ev->status; 4841d5c65159SKalle Valo hdr->flags = ev->flags; 4842d5c65159SKalle Valo hdr->rssi = ev->rssi; 4843d5c65159SKalle Valo hdr->tsf_delta = ev->tsf_delta; 4844d5c65159SKalle Valo memcpy(hdr->rssi_ctl, ev->rssi_ctl, sizeof(hdr->rssi_ctl)); 4845d5c65159SKalle Valo 4846d5c65159SKalle Valo if (skb->len < (frame - skb->data) + hdr->buf_len) { 4847d5c65159SKalle Valo ath11k_warn(ab, "invalid length in mgmt rx hdr ev"); 4848d5c65159SKalle Valo kfree(tb); 4849d5c65159SKalle Valo return -EPROTO; 4850d5c65159SKalle Valo } 4851d5c65159SKalle Valo 4852d5c65159SKalle Valo /* shift the sk_buff to point to `frame` */ 4853d5c65159SKalle Valo skb_trim(skb, 0); 4854d5c65159SKalle Valo skb_put(skb, frame - skb->data); 4855d5c65159SKalle Valo skb_pull(skb, frame - skb->data); 4856d5c65159SKalle Valo skb_put(skb, hdr->buf_len); 4857d5c65159SKalle Valo 4858d5c65159SKalle Valo ath11k_ce_byte_swap(skb->data, hdr->buf_len); 4859d5c65159SKalle Valo 4860d5c65159SKalle Valo kfree(tb); 4861d5c65159SKalle Valo return 0; 4862d5c65159SKalle Valo } 4863d5c65159SKalle Valo 4864d5c65159SKalle Valo static int wmi_process_mgmt_tx_comp(struct ath11k *ar, u32 desc_id, 4865d5c65159SKalle Valo u32 status) 4866d5c65159SKalle Valo { 4867d5c65159SKalle Valo struct sk_buff *msdu; 4868d5c65159SKalle Valo struct ieee80211_tx_info *info; 4869d5c65159SKalle Valo struct ath11k_skb_cb *skb_cb; 4870d5c65159SKalle Valo 4871d5c65159SKalle Valo spin_lock_bh(&ar->txmgmt_idr_lock); 4872d5c65159SKalle Valo msdu = idr_find(&ar->txmgmt_idr, desc_id); 4873d5c65159SKalle Valo 4874d5c65159SKalle Valo if (!msdu) { 4875d5c65159SKalle Valo ath11k_warn(ar->ab, "received mgmt tx compl for invalid msdu_id: %d\n", 4876d5c65159SKalle Valo desc_id); 4877d5c65159SKalle Valo spin_unlock_bh(&ar->txmgmt_idr_lock); 4878d5c65159SKalle Valo return -ENOENT; 4879d5c65159SKalle Valo } 4880d5c65159SKalle Valo 4881d5c65159SKalle Valo idr_remove(&ar->txmgmt_idr, desc_id); 4882d5c65159SKalle Valo spin_unlock_bh(&ar->txmgmt_idr_lock); 4883d5c65159SKalle Valo 4884d5c65159SKalle Valo skb_cb = ATH11K_SKB_CB(msdu); 4885d5c65159SKalle Valo dma_unmap_single(ar->ab->dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE); 4886d5c65159SKalle Valo 4887d5c65159SKalle Valo info = IEEE80211_SKB_CB(msdu); 4888d5c65159SKalle Valo if ((!(info->flags & IEEE80211_TX_CTL_NO_ACK)) && !status) 4889d5c65159SKalle Valo info->flags |= IEEE80211_TX_STAT_ACK; 4890d5c65159SKalle Valo 4891d5c65159SKalle Valo ieee80211_tx_status_irqsafe(ar->hw, msdu); 4892d5c65159SKalle Valo 4893800113ffSSriram R /* WARN when we received this event without doing any mgmt tx */ 4894800113ffSSriram R if (atomic_dec_if_positive(&ar->num_pending_mgmt_tx) < 0) 4895800113ffSSriram R WARN_ON_ONCE(1); 4896d5c65159SKalle Valo 4897d5c65159SKalle Valo return 0; 4898d5c65159SKalle Valo } 4899d5c65159SKalle Valo 4900d5c65159SKalle Valo static int ath11k_pull_mgmt_tx_compl_param_tlv(struct ath11k_base *ab, 4901d5c65159SKalle Valo struct sk_buff *skb, 4902d5c65159SKalle Valo struct wmi_mgmt_tx_compl_event *param) 4903d5c65159SKalle Valo { 4904d5c65159SKalle Valo const void **tb; 4905d5c65159SKalle Valo const struct wmi_mgmt_tx_compl_event *ev; 4906d5c65159SKalle Valo int ret; 4907d5c65159SKalle Valo 4908d5c65159SKalle Valo tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC); 4909d5c65159SKalle Valo if (IS_ERR(tb)) { 4910d5c65159SKalle Valo ret = PTR_ERR(tb); 4911d5c65159SKalle Valo ath11k_warn(ab, "failed to parse tlv: %d\n", ret); 4912d5c65159SKalle Valo return ret; 4913d5c65159SKalle Valo } 4914d5c65159SKalle Valo 4915d5c65159SKalle Valo ev = tb[WMI_TAG_MGMT_TX_COMPL_EVENT]; 4916d5c65159SKalle Valo if (!ev) { 4917d5c65159SKalle Valo ath11k_warn(ab, "failed to fetch mgmt tx compl ev"); 4918d5c65159SKalle Valo kfree(tb); 4919d5c65159SKalle Valo return -EPROTO; 4920d5c65159SKalle Valo } 4921d5c65159SKalle Valo 4922d5c65159SKalle Valo param->pdev_id = ev->pdev_id; 4923d5c65159SKalle Valo param->desc_id = ev->desc_id; 4924d5c65159SKalle Valo param->status = ev->status; 4925d5c65159SKalle Valo 4926d5c65159SKalle Valo kfree(tb); 4927d5c65159SKalle Valo return 0; 4928d5c65159SKalle Valo } 4929d5c65159SKalle Valo 4930d5c65159SKalle Valo static void ath11k_wmi_event_scan_started(struct ath11k *ar) 4931d5c65159SKalle Valo { 4932d5c65159SKalle Valo lockdep_assert_held(&ar->data_lock); 4933d5c65159SKalle Valo 4934d5c65159SKalle Valo switch (ar->scan.state) { 4935d5c65159SKalle Valo case ATH11K_SCAN_IDLE: 4936d5c65159SKalle Valo case ATH11K_SCAN_RUNNING: 4937d5c65159SKalle Valo case ATH11K_SCAN_ABORTING: 4938d5c65159SKalle Valo ath11k_warn(ar->ab, "received scan started event in an invalid scan state: %s (%d)\n", 4939d5c65159SKalle Valo ath11k_scan_state_str(ar->scan.state), 4940d5c65159SKalle Valo ar->scan.state); 4941d5c65159SKalle Valo break; 4942d5c65159SKalle Valo case ATH11K_SCAN_STARTING: 4943d5c65159SKalle Valo ar->scan.state = ATH11K_SCAN_RUNNING; 4944d5c65159SKalle Valo complete(&ar->scan.started); 4945d5c65159SKalle Valo break; 4946d5c65159SKalle Valo } 4947d5c65159SKalle Valo } 4948d5c65159SKalle Valo 4949d5c65159SKalle Valo static void ath11k_wmi_event_scan_start_failed(struct ath11k *ar) 4950d5c65159SKalle Valo { 4951d5c65159SKalle Valo lockdep_assert_held(&ar->data_lock); 4952d5c65159SKalle Valo 4953d5c65159SKalle Valo switch (ar->scan.state) { 4954d5c65159SKalle Valo case ATH11K_SCAN_IDLE: 4955d5c65159SKalle Valo case ATH11K_SCAN_RUNNING: 4956d5c65159SKalle Valo case ATH11K_SCAN_ABORTING: 4957d5c65159SKalle Valo ath11k_warn(ar->ab, "received scan start failed event in an invalid scan state: %s (%d)\n", 4958d5c65159SKalle Valo ath11k_scan_state_str(ar->scan.state), 4959d5c65159SKalle Valo ar->scan.state); 4960d5c65159SKalle Valo break; 4961d5c65159SKalle Valo case ATH11K_SCAN_STARTING: 4962d5c65159SKalle Valo complete(&ar->scan.started); 4963d5c65159SKalle Valo __ath11k_mac_scan_finish(ar); 4964d5c65159SKalle Valo break; 4965d5c65159SKalle Valo } 4966d5c65159SKalle Valo } 4967d5c65159SKalle Valo 4968d5c65159SKalle Valo static void ath11k_wmi_event_scan_completed(struct ath11k *ar) 4969d5c65159SKalle Valo { 4970d5c65159SKalle Valo lockdep_assert_held(&ar->data_lock); 4971d5c65159SKalle Valo 4972d5c65159SKalle Valo switch (ar->scan.state) { 4973d5c65159SKalle Valo case ATH11K_SCAN_IDLE: 4974d5c65159SKalle Valo case ATH11K_SCAN_STARTING: 4975d5c65159SKalle Valo /* One suspected reason scan can be completed while starting is 4976d5c65159SKalle Valo * if firmware fails to deliver all scan events to the host, 4977d5c65159SKalle Valo * e.g. when transport pipe is full. This has been observed 4978d5c65159SKalle Valo * with spectral scan phyerr events starving wmi transport 4979d5c65159SKalle Valo * pipe. In such case the "scan completed" event should be (and 4980d5c65159SKalle Valo * is) ignored by the host as it may be just firmware's scan 4981d5c65159SKalle Valo * state machine recovering. 4982d5c65159SKalle Valo */ 4983d5c65159SKalle Valo ath11k_warn(ar->ab, "received scan completed event in an invalid scan state: %s (%d)\n", 4984d5c65159SKalle Valo ath11k_scan_state_str(ar->scan.state), 4985d5c65159SKalle Valo ar->scan.state); 4986d5c65159SKalle Valo break; 4987d5c65159SKalle Valo case ATH11K_SCAN_RUNNING: 4988d5c65159SKalle Valo case ATH11K_SCAN_ABORTING: 4989d5c65159SKalle Valo __ath11k_mac_scan_finish(ar); 4990d5c65159SKalle Valo break; 4991d5c65159SKalle Valo } 4992d5c65159SKalle Valo } 4993d5c65159SKalle Valo 4994d5c65159SKalle Valo static void ath11k_wmi_event_scan_bss_chan(struct ath11k *ar) 4995d5c65159SKalle Valo { 4996d5c65159SKalle Valo lockdep_assert_held(&ar->data_lock); 4997d5c65159SKalle Valo 4998d5c65159SKalle Valo switch (ar->scan.state) { 4999d5c65159SKalle Valo case ATH11K_SCAN_IDLE: 5000d5c65159SKalle Valo case ATH11K_SCAN_STARTING: 5001d5c65159SKalle Valo ath11k_warn(ar->ab, "received scan bss chan event in an invalid scan state: %s (%d)\n", 5002d5c65159SKalle Valo ath11k_scan_state_str(ar->scan.state), 5003d5c65159SKalle Valo ar->scan.state); 5004d5c65159SKalle Valo break; 5005d5c65159SKalle Valo case ATH11K_SCAN_RUNNING: 5006d5c65159SKalle Valo case ATH11K_SCAN_ABORTING: 5007d5c65159SKalle Valo ar->scan_channel = NULL; 5008d5c65159SKalle Valo break; 5009d5c65159SKalle Valo } 5010d5c65159SKalle Valo } 5011d5c65159SKalle Valo 5012d5c65159SKalle Valo static void ath11k_wmi_event_scan_foreign_chan(struct ath11k *ar, u32 freq) 5013d5c65159SKalle Valo { 5014d5c65159SKalle Valo lockdep_assert_held(&ar->data_lock); 5015d5c65159SKalle Valo 5016d5c65159SKalle Valo switch (ar->scan.state) { 5017d5c65159SKalle Valo case ATH11K_SCAN_IDLE: 5018d5c65159SKalle Valo case ATH11K_SCAN_STARTING: 5019d5c65159SKalle Valo ath11k_warn(ar->ab, "received scan foreign chan event in an invalid scan state: %s (%d)\n", 5020d5c65159SKalle Valo ath11k_scan_state_str(ar->scan.state), 5021d5c65159SKalle Valo ar->scan.state); 5022d5c65159SKalle Valo break; 5023d5c65159SKalle Valo case ATH11K_SCAN_RUNNING: 5024d5c65159SKalle Valo case ATH11K_SCAN_ABORTING: 5025d5c65159SKalle Valo ar->scan_channel = ieee80211_get_channel(ar->hw->wiphy, freq); 5026d5c65159SKalle Valo break; 5027d5c65159SKalle Valo } 5028d5c65159SKalle Valo } 5029d5c65159SKalle Valo 5030d5c65159SKalle Valo static const char * 5031d5c65159SKalle Valo ath11k_wmi_event_scan_type_str(enum wmi_scan_event_type type, 5032d5c65159SKalle Valo enum wmi_scan_completion_reason reason) 5033d5c65159SKalle Valo { 5034d5c65159SKalle Valo switch (type) { 5035d5c65159SKalle Valo case WMI_SCAN_EVENT_STARTED: 5036d5c65159SKalle Valo return "started"; 5037d5c65159SKalle Valo case WMI_SCAN_EVENT_COMPLETED: 5038d5c65159SKalle Valo switch (reason) { 5039d5c65159SKalle Valo case WMI_SCAN_REASON_COMPLETED: 5040d5c65159SKalle Valo return "completed"; 5041d5c65159SKalle Valo case WMI_SCAN_REASON_CANCELLED: 5042d5c65159SKalle Valo return "completed [cancelled]"; 5043d5c65159SKalle Valo case WMI_SCAN_REASON_PREEMPTED: 5044d5c65159SKalle Valo return "completed [preempted]"; 5045d5c65159SKalle Valo case WMI_SCAN_REASON_TIMEDOUT: 5046d5c65159SKalle Valo return "completed [timedout]"; 5047d5c65159SKalle Valo case WMI_SCAN_REASON_INTERNAL_FAILURE: 5048d5c65159SKalle Valo return "completed [internal err]"; 5049d5c65159SKalle Valo case WMI_SCAN_REASON_MAX: 5050d5c65159SKalle Valo break; 5051d5c65159SKalle Valo } 5052d5c65159SKalle Valo return "completed [unknown]"; 5053d5c65159SKalle Valo case WMI_SCAN_EVENT_BSS_CHANNEL: 5054d5c65159SKalle Valo return "bss channel"; 5055d5c65159SKalle Valo case WMI_SCAN_EVENT_FOREIGN_CHAN: 5056d5c65159SKalle Valo return "foreign channel"; 5057d5c65159SKalle Valo case WMI_SCAN_EVENT_DEQUEUED: 5058d5c65159SKalle Valo return "dequeued"; 5059d5c65159SKalle Valo case WMI_SCAN_EVENT_PREEMPTED: 5060d5c65159SKalle Valo return "preempted"; 5061d5c65159SKalle Valo case WMI_SCAN_EVENT_START_FAILED: 5062d5c65159SKalle Valo return "start failed"; 5063d5c65159SKalle Valo case WMI_SCAN_EVENT_RESTARTED: 5064d5c65159SKalle Valo return "restarted"; 5065d5c65159SKalle Valo case WMI_SCAN_EVENT_FOREIGN_CHAN_EXIT: 5066d5c65159SKalle Valo return "foreign channel exit"; 5067d5c65159SKalle Valo default: 5068d5c65159SKalle Valo return "unknown"; 5069d5c65159SKalle Valo } 5070d5c65159SKalle Valo } 5071d5c65159SKalle Valo 5072d5c65159SKalle Valo static int ath11k_pull_scan_ev(struct ath11k_base *ab, struct sk_buff *skb, 5073d5c65159SKalle Valo struct wmi_scan_event *scan_evt_param) 5074d5c65159SKalle Valo { 5075d5c65159SKalle Valo const void **tb; 5076d5c65159SKalle Valo const struct wmi_scan_event *ev; 5077d5c65159SKalle Valo int ret; 5078d5c65159SKalle Valo 5079d5c65159SKalle Valo tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC); 5080d5c65159SKalle Valo if (IS_ERR(tb)) { 5081d5c65159SKalle Valo ret = PTR_ERR(tb); 5082d5c65159SKalle Valo ath11k_warn(ab, "failed to parse tlv: %d\n", ret); 5083d5c65159SKalle Valo return ret; 5084d5c65159SKalle Valo } 5085d5c65159SKalle Valo 5086d5c65159SKalle Valo ev = tb[WMI_TAG_SCAN_EVENT]; 5087d5c65159SKalle Valo if (!ev) { 5088d5c65159SKalle Valo ath11k_warn(ab, "failed to fetch scan ev"); 5089d5c65159SKalle Valo kfree(tb); 5090d5c65159SKalle Valo return -EPROTO; 5091d5c65159SKalle Valo } 5092d5c65159SKalle Valo 5093d5c65159SKalle Valo scan_evt_param->event_type = ev->event_type; 5094d5c65159SKalle Valo scan_evt_param->reason = ev->reason; 5095d5c65159SKalle Valo scan_evt_param->channel_freq = ev->channel_freq; 5096d5c65159SKalle Valo scan_evt_param->scan_req_id = ev->scan_req_id; 5097d5c65159SKalle Valo scan_evt_param->scan_id = ev->scan_id; 5098d5c65159SKalle Valo scan_evt_param->vdev_id = ev->vdev_id; 5099d5c65159SKalle Valo scan_evt_param->tsf_timestamp = ev->tsf_timestamp; 5100d5c65159SKalle Valo 5101d5c65159SKalle Valo kfree(tb); 5102d5c65159SKalle Valo return 0; 5103d5c65159SKalle Valo } 5104d5c65159SKalle Valo 5105d5c65159SKalle Valo static int ath11k_pull_peer_sta_kickout_ev(struct ath11k_base *ab, struct sk_buff *skb, 5106d5c65159SKalle Valo struct wmi_peer_sta_kickout_arg *arg) 5107d5c65159SKalle Valo { 5108d5c65159SKalle Valo const void **tb; 5109d5c65159SKalle Valo const struct wmi_peer_sta_kickout_event *ev; 5110d5c65159SKalle Valo int ret; 5111d5c65159SKalle Valo 5112d5c65159SKalle Valo tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC); 5113d5c65159SKalle Valo if (IS_ERR(tb)) { 5114d5c65159SKalle Valo ret = PTR_ERR(tb); 5115d5c65159SKalle Valo ath11k_warn(ab, "failed to parse tlv: %d\n", ret); 5116d5c65159SKalle Valo return ret; 5117d5c65159SKalle Valo } 5118d5c65159SKalle Valo 5119d5c65159SKalle Valo ev = tb[WMI_TAG_PEER_STA_KICKOUT_EVENT]; 5120d5c65159SKalle Valo if (!ev) { 5121d5c65159SKalle Valo ath11k_warn(ab, "failed to fetch peer sta kickout ev"); 5122d5c65159SKalle Valo kfree(tb); 5123d5c65159SKalle Valo return -EPROTO; 5124d5c65159SKalle Valo } 5125d5c65159SKalle Valo 5126d5c65159SKalle Valo arg->mac_addr = ev->peer_macaddr.addr; 5127d5c65159SKalle Valo 5128d5c65159SKalle Valo kfree(tb); 5129d5c65159SKalle Valo return 0; 5130d5c65159SKalle Valo } 5131d5c65159SKalle Valo 5132d5c65159SKalle Valo static int ath11k_pull_roam_ev(struct ath11k_base *ab, struct sk_buff *skb, 5133d5c65159SKalle Valo struct wmi_roam_event *roam_ev) 5134d5c65159SKalle Valo { 5135d5c65159SKalle Valo const void **tb; 5136d5c65159SKalle Valo const struct wmi_roam_event *ev; 5137d5c65159SKalle Valo int ret; 5138d5c65159SKalle Valo 5139d5c65159SKalle Valo tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC); 5140d5c65159SKalle Valo if (IS_ERR(tb)) { 5141d5c65159SKalle Valo ret = PTR_ERR(tb); 5142d5c65159SKalle Valo ath11k_warn(ab, "failed to parse tlv: %d\n", ret); 5143d5c65159SKalle Valo return ret; 5144d5c65159SKalle Valo } 5145d5c65159SKalle Valo 5146d5c65159SKalle Valo ev = tb[WMI_TAG_ROAM_EVENT]; 5147d5c65159SKalle Valo if (!ev) { 5148d5c65159SKalle Valo ath11k_warn(ab, "failed to fetch roam ev"); 5149d5c65159SKalle Valo kfree(tb); 5150d5c65159SKalle Valo return -EPROTO; 5151d5c65159SKalle Valo } 5152d5c65159SKalle Valo 5153d5c65159SKalle Valo roam_ev->vdev_id = ev->vdev_id; 5154d5c65159SKalle Valo roam_ev->reason = ev->reason; 5155d5c65159SKalle Valo roam_ev->rssi = ev->rssi; 5156d5c65159SKalle Valo 5157d5c65159SKalle Valo kfree(tb); 5158d5c65159SKalle Valo return 0; 5159d5c65159SKalle Valo } 5160d5c65159SKalle Valo 5161d5c65159SKalle Valo static int freq_to_idx(struct ath11k *ar, int freq) 5162d5c65159SKalle Valo { 5163d5c65159SKalle Valo struct ieee80211_supported_band *sband; 5164d5c65159SKalle Valo int band, ch, idx = 0; 5165d5c65159SKalle Valo 5166d5c65159SKalle Valo for (band = NL80211_BAND_2GHZ; band < NUM_NL80211_BANDS; band++) { 5167d5c65159SKalle Valo sband = ar->hw->wiphy->bands[band]; 5168d5c65159SKalle Valo if (!sband) 5169d5c65159SKalle Valo continue; 5170d5c65159SKalle Valo 5171d5c65159SKalle Valo for (ch = 0; ch < sband->n_channels; ch++, idx++) 5172d5c65159SKalle Valo if (sband->channels[ch].center_freq == freq) 5173d5c65159SKalle Valo goto exit; 5174d5c65159SKalle Valo } 5175d5c65159SKalle Valo 5176d5c65159SKalle Valo exit: 5177d5c65159SKalle Valo return idx; 5178d5c65159SKalle Valo } 5179d5c65159SKalle Valo 5180d5c65159SKalle Valo static int ath11k_pull_chan_info_ev(struct ath11k_base *ab, u8 *evt_buf, 5181d5c65159SKalle Valo u32 len, struct wmi_chan_info_event *ch_info_ev) 5182d5c65159SKalle Valo { 5183d5c65159SKalle Valo const void **tb; 5184d5c65159SKalle Valo const struct wmi_chan_info_event *ev; 5185d5c65159SKalle Valo int ret; 5186d5c65159SKalle Valo 5187d5c65159SKalle Valo tb = ath11k_wmi_tlv_parse_alloc(ab, evt_buf, len, GFP_ATOMIC); 5188d5c65159SKalle Valo if (IS_ERR(tb)) { 5189d5c65159SKalle Valo ret = PTR_ERR(tb); 5190d5c65159SKalle Valo ath11k_warn(ab, "failed to parse tlv: %d\n", ret); 5191d5c65159SKalle Valo return ret; 5192d5c65159SKalle Valo } 5193d5c65159SKalle Valo 5194d5c65159SKalle Valo ev = tb[WMI_TAG_CHAN_INFO_EVENT]; 5195d5c65159SKalle Valo if (!ev) { 5196d5c65159SKalle Valo ath11k_warn(ab, "failed to fetch chan info ev"); 5197d5c65159SKalle Valo kfree(tb); 5198d5c65159SKalle Valo return -EPROTO; 5199d5c65159SKalle Valo } 5200d5c65159SKalle Valo 5201d5c65159SKalle Valo ch_info_ev->err_code = ev->err_code; 5202d5c65159SKalle Valo ch_info_ev->freq = ev->freq; 5203d5c65159SKalle Valo ch_info_ev->cmd_flags = ev->cmd_flags; 5204d5c65159SKalle Valo ch_info_ev->noise_floor = ev->noise_floor; 5205d5c65159SKalle Valo ch_info_ev->rx_clear_count = ev->rx_clear_count; 5206d5c65159SKalle Valo ch_info_ev->cycle_count = ev->cycle_count; 5207d5c65159SKalle Valo ch_info_ev->chan_tx_pwr_range = ev->chan_tx_pwr_range; 5208d5c65159SKalle Valo ch_info_ev->chan_tx_pwr_tp = ev->chan_tx_pwr_tp; 5209d5c65159SKalle Valo ch_info_ev->rx_frame_count = ev->rx_frame_count; 5210d5c65159SKalle Valo ch_info_ev->tx_frame_cnt = ev->tx_frame_cnt; 5211d5c65159SKalle Valo ch_info_ev->mac_clk_mhz = ev->mac_clk_mhz; 5212d5c65159SKalle Valo ch_info_ev->vdev_id = ev->vdev_id; 5213d5c65159SKalle Valo 5214d5c65159SKalle Valo kfree(tb); 5215d5c65159SKalle Valo return 0; 5216d5c65159SKalle Valo } 5217d5c65159SKalle Valo 5218d5c65159SKalle Valo static int 5219d5c65159SKalle Valo ath11k_pull_pdev_bss_chan_info_ev(struct ath11k_base *ab, struct sk_buff *skb, 5220d5c65159SKalle Valo struct wmi_pdev_bss_chan_info_event *bss_ch_info_ev) 5221d5c65159SKalle Valo { 5222d5c65159SKalle Valo const void **tb; 5223d5c65159SKalle Valo const struct wmi_pdev_bss_chan_info_event *ev; 5224d5c65159SKalle Valo int ret; 5225d5c65159SKalle Valo 5226d5c65159SKalle Valo tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC); 5227d5c65159SKalle Valo if (IS_ERR(tb)) { 5228d5c65159SKalle Valo ret = PTR_ERR(tb); 5229d5c65159SKalle Valo ath11k_warn(ab, "failed to parse tlv: %d\n", ret); 5230d5c65159SKalle Valo return ret; 5231d5c65159SKalle Valo } 5232d5c65159SKalle Valo 5233d5c65159SKalle Valo ev = tb[WMI_TAG_PDEV_BSS_CHAN_INFO_EVENT]; 5234d5c65159SKalle Valo if (!ev) { 5235d5c65159SKalle Valo ath11k_warn(ab, "failed to fetch pdev bss chan info ev"); 5236d5c65159SKalle Valo kfree(tb); 5237d5c65159SKalle Valo return -EPROTO; 5238d5c65159SKalle Valo } 5239d5c65159SKalle Valo 5240d5c65159SKalle Valo bss_ch_info_ev->pdev_id = ev->pdev_id; 5241d5c65159SKalle Valo bss_ch_info_ev->freq = ev->freq; 5242d5c65159SKalle Valo bss_ch_info_ev->noise_floor = ev->noise_floor; 5243d5c65159SKalle Valo bss_ch_info_ev->rx_clear_count_low = ev->rx_clear_count_low; 5244d5c65159SKalle Valo bss_ch_info_ev->rx_clear_count_high = ev->rx_clear_count_high; 5245d5c65159SKalle Valo bss_ch_info_ev->cycle_count_low = ev->cycle_count_low; 5246d5c65159SKalle Valo bss_ch_info_ev->cycle_count_high = ev->cycle_count_high; 5247d5c65159SKalle Valo bss_ch_info_ev->tx_cycle_count_low = ev->tx_cycle_count_low; 5248d5c65159SKalle Valo bss_ch_info_ev->tx_cycle_count_high = ev->tx_cycle_count_high; 5249d5c65159SKalle Valo bss_ch_info_ev->rx_cycle_count_low = ev->rx_cycle_count_low; 5250d5c65159SKalle Valo bss_ch_info_ev->rx_cycle_count_high = ev->rx_cycle_count_high; 5251d5c65159SKalle Valo bss_ch_info_ev->rx_bss_cycle_count_low = ev->rx_bss_cycle_count_low; 5252d5c65159SKalle Valo bss_ch_info_ev->rx_bss_cycle_count_high = ev->rx_bss_cycle_count_high; 5253d5c65159SKalle Valo 5254d5c65159SKalle Valo kfree(tb); 5255d5c65159SKalle Valo return 0; 5256d5c65159SKalle Valo } 5257d5c65159SKalle Valo 5258d5c65159SKalle Valo static int 5259d5c65159SKalle Valo ath11k_pull_vdev_install_key_compl_ev(struct ath11k_base *ab, struct sk_buff *skb, 5260d5c65159SKalle Valo struct wmi_vdev_install_key_complete_arg *arg) 5261d5c65159SKalle Valo { 5262d5c65159SKalle Valo const void **tb; 5263d5c65159SKalle Valo const struct wmi_vdev_install_key_compl_event *ev; 5264d5c65159SKalle Valo int ret; 5265d5c65159SKalle Valo 5266d5c65159SKalle Valo tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC); 5267d5c65159SKalle Valo if (IS_ERR(tb)) { 5268d5c65159SKalle Valo ret = PTR_ERR(tb); 5269d5c65159SKalle Valo ath11k_warn(ab, "failed to parse tlv: %d\n", ret); 5270d5c65159SKalle Valo return ret; 5271d5c65159SKalle Valo } 5272d5c65159SKalle Valo 5273d5c65159SKalle Valo ev = tb[WMI_TAG_VDEV_INSTALL_KEY_COMPLETE_EVENT]; 5274d5c65159SKalle Valo if (!ev) { 5275d5c65159SKalle Valo ath11k_warn(ab, "failed to fetch vdev install key compl ev"); 5276d5c65159SKalle Valo kfree(tb); 5277d5c65159SKalle Valo return -EPROTO; 5278d5c65159SKalle Valo } 5279d5c65159SKalle Valo 5280d5c65159SKalle Valo arg->vdev_id = ev->vdev_id; 5281d5c65159SKalle Valo arg->macaddr = ev->peer_macaddr.addr; 5282d5c65159SKalle Valo arg->key_idx = ev->key_idx; 5283d5c65159SKalle Valo arg->key_flags = ev->key_flags; 5284d5c65159SKalle Valo arg->status = ev->status; 5285d5c65159SKalle Valo 5286d5c65159SKalle Valo kfree(tb); 5287d5c65159SKalle Valo return 0; 5288d5c65159SKalle Valo } 5289d5c65159SKalle Valo 5290d5c65159SKalle Valo static int ath11k_pull_peer_assoc_conf_ev(struct ath11k_base *ab, struct sk_buff *skb, 5291d5c65159SKalle Valo struct wmi_peer_assoc_conf_arg *peer_assoc_conf) 5292d5c65159SKalle Valo { 5293d5c65159SKalle Valo const void **tb; 5294d5c65159SKalle Valo const struct wmi_peer_assoc_conf_event *ev; 5295d5c65159SKalle Valo int ret; 5296d5c65159SKalle Valo 5297d5c65159SKalle Valo tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC); 5298d5c65159SKalle Valo if (IS_ERR(tb)) { 5299d5c65159SKalle Valo ret = PTR_ERR(tb); 5300d5c65159SKalle Valo ath11k_warn(ab, "failed to parse tlv: %d\n", ret); 5301d5c65159SKalle Valo return ret; 5302d5c65159SKalle Valo } 5303d5c65159SKalle Valo 5304d5c65159SKalle Valo ev = tb[WMI_TAG_PEER_ASSOC_CONF_EVENT]; 5305d5c65159SKalle Valo if (!ev) { 5306d5c65159SKalle Valo ath11k_warn(ab, "failed to fetch peer assoc conf ev"); 5307d5c65159SKalle Valo kfree(tb); 5308d5c65159SKalle Valo return -EPROTO; 5309d5c65159SKalle Valo } 5310d5c65159SKalle Valo 5311d5c65159SKalle Valo peer_assoc_conf->vdev_id = ev->vdev_id; 5312d5c65159SKalle Valo peer_assoc_conf->macaddr = ev->peer_macaddr.addr; 5313d5c65159SKalle Valo 5314d5c65159SKalle Valo kfree(tb); 5315d5c65159SKalle Valo return 0; 5316d5c65159SKalle Valo } 5317d5c65159SKalle Valo 5318d5c65159SKalle Valo static void ath11k_wmi_pull_pdev_stats_base(const struct wmi_pdev_stats_base *src, 5319d5c65159SKalle Valo struct ath11k_fw_stats_pdev *dst) 5320d5c65159SKalle Valo { 5321d5c65159SKalle Valo dst->ch_noise_floor = src->chan_nf; 5322d5c65159SKalle Valo dst->tx_frame_count = src->tx_frame_count; 5323d5c65159SKalle Valo dst->rx_frame_count = src->rx_frame_count; 5324d5c65159SKalle Valo dst->rx_clear_count = src->rx_clear_count; 5325d5c65159SKalle Valo dst->cycle_count = src->cycle_count; 5326d5c65159SKalle Valo dst->phy_err_count = src->phy_err_count; 5327d5c65159SKalle Valo dst->chan_tx_power = src->chan_tx_pwr; 5328d5c65159SKalle Valo } 5329d5c65159SKalle Valo 5330d5c65159SKalle Valo static void 5331d5c65159SKalle Valo ath11k_wmi_pull_pdev_stats_tx(const struct wmi_pdev_stats_tx *src, 5332d5c65159SKalle Valo struct ath11k_fw_stats_pdev *dst) 5333d5c65159SKalle Valo { 5334d5c65159SKalle Valo dst->comp_queued = src->comp_queued; 5335d5c65159SKalle Valo dst->comp_delivered = src->comp_delivered; 5336d5c65159SKalle Valo dst->msdu_enqued = src->msdu_enqued; 5337d5c65159SKalle Valo dst->mpdu_enqued = src->mpdu_enqued; 5338d5c65159SKalle Valo dst->wmm_drop = src->wmm_drop; 5339d5c65159SKalle Valo dst->local_enqued = src->local_enqued; 5340d5c65159SKalle Valo dst->local_freed = src->local_freed; 5341d5c65159SKalle Valo dst->hw_queued = src->hw_queued; 5342d5c65159SKalle Valo dst->hw_reaped = src->hw_reaped; 5343d5c65159SKalle Valo dst->underrun = src->underrun; 5344f394e4eaSSriram R dst->hw_paused = src->hw_paused; 5345d5c65159SKalle Valo dst->tx_abort = src->tx_abort; 534617818dfaSColin Ian King dst->mpdus_requeued = src->mpdus_requeued; 5347d5c65159SKalle Valo dst->tx_ko = src->tx_ko; 5348f394e4eaSSriram R dst->tx_xretry = src->tx_xretry; 5349d5c65159SKalle Valo dst->data_rc = src->data_rc; 5350d5c65159SKalle Valo dst->self_triggers = src->self_triggers; 5351d5c65159SKalle Valo dst->sw_retry_failure = src->sw_retry_failure; 5352d5c65159SKalle Valo dst->illgl_rate_phy_err = src->illgl_rate_phy_err; 5353d5c65159SKalle Valo dst->pdev_cont_xretry = src->pdev_cont_xretry; 5354d5c65159SKalle Valo dst->pdev_tx_timeout = src->pdev_tx_timeout; 5355d5c65159SKalle Valo dst->pdev_resets = src->pdev_resets; 5356d5c65159SKalle Valo dst->stateless_tid_alloc_failure = src->stateless_tid_alloc_failure; 5357d5c65159SKalle Valo dst->phy_underrun = src->phy_underrun; 5358d5c65159SKalle Valo dst->txop_ovf = src->txop_ovf; 5359f394e4eaSSriram R dst->seq_posted = src->seq_posted; 5360f394e4eaSSriram R dst->seq_failed_queueing = src->seq_failed_queueing; 5361f394e4eaSSriram R dst->seq_completed = src->seq_completed; 5362f394e4eaSSriram R dst->seq_restarted = src->seq_restarted; 5363f394e4eaSSriram R dst->mu_seq_posted = src->mu_seq_posted; 5364f394e4eaSSriram R dst->mpdus_sw_flush = src->mpdus_sw_flush; 5365f394e4eaSSriram R dst->mpdus_hw_filter = src->mpdus_hw_filter; 5366f394e4eaSSriram R dst->mpdus_truncated = src->mpdus_truncated; 5367f394e4eaSSriram R dst->mpdus_ack_failed = src->mpdus_ack_failed; 5368f394e4eaSSriram R dst->mpdus_expired = src->mpdus_expired; 5369d5c65159SKalle Valo } 5370d5c65159SKalle Valo 5371d5c65159SKalle Valo static void ath11k_wmi_pull_pdev_stats_rx(const struct wmi_pdev_stats_rx *src, 5372d5c65159SKalle Valo struct ath11k_fw_stats_pdev *dst) 5373d5c65159SKalle Valo { 5374d5c65159SKalle Valo dst->mid_ppdu_route_change = src->mid_ppdu_route_change; 5375d5c65159SKalle Valo dst->status_rcvd = src->status_rcvd; 5376d5c65159SKalle Valo dst->r0_frags = src->r0_frags; 5377d5c65159SKalle Valo dst->r1_frags = src->r1_frags; 5378d5c65159SKalle Valo dst->r2_frags = src->r2_frags; 5379d5c65159SKalle Valo dst->r3_frags = src->r3_frags; 5380d5c65159SKalle Valo dst->htt_msdus = src->htt_msdus; 5381d5c65159SKalle Valo dst->htt_mpdus = src->htt_mpdus; 5382d5c65159SKalle Valo dst->loc_msdus = src->loc_msdus; 5383d5c65159SKalle Valo dst->loc_mpdus = src->loc_mpdus; 5384d5c65159SKalle Valo dst->oversize_amsdu = src->oversize_amsdu; 5385d5c65159SKalle Valo dst->phy_errs = src->phy_errs; 5386d5c65159SKalle Valo dst->phy_err_drop = src->phy_err_drop; 5387d5c65159SKalle Valo dst->mpdu_errs = src->mpdu_errs; 5388f394e4eaSSriram R dst->rx_ovfl_errs = src->rx_ovfl_errs; 5389d5c65159SKalle Valo } 5390d5c65159SKalle Valo 5391d5c65159SKalle Valo static void 5392d5c65159SKalle Valo ath11k_wmi_pull_vdev_stats(const struct wmi_vdev_stats *src, 5393d5c65159SKalle Valo struct ath11k_fw_stats_vdev *dst) 5394d5c65159SKalle Valo { 5395d5c65159SKalle Valo int i; 5396d5c65159SKalle Valo 5397d5c65159SKalle Valo dst->vdev_id = src->vdev_id; 5398d5c65159SKalle Valo dst->beacon_snr = src->beacon_snr; 5399d5c65159SKalle Valo dst->data_snr = src->data_snr; 5400d5c65159SKalle Valo dst->num_rx_frames = src->num_rx_frames; 5401d5c65159SKalle Valo dst->num_rts_fail = src->num_rts_fail; 5402d5c65159SKalle Valo dst->num_rts_success = src->num_rts_success; 5403d5c65159SKalle Valo dst->num_rx_err = src->num_rx_err; 5404d5c65159SKalle Valo dst->num_rx_discard = src->num_rx_discard; 5405d5c65159SKalle Valo dst->num_tx_not_acked = src->num_tx_not_acked; 5406d5c65159SKalle Valo 5407d5c65159SKalle Valo for (i = 0; i < ARRAY_SIZE(src->num_tx_frames); i++) 5408d5c65159SKalle Valo dst->num_tx_frames[i] = src->num_tx_frames[i]; 5409d5c65159SKalle Valo 5410d5c65159SKalle Valo for (i = 0; i < ARRAY_SIZE(src->num_tx_frames_retries); i++) 5411d5c65159SKalle Valo dst->num_tx_frames_retries[i] = src->num_tx_frames_retries[i]; 5412d5c65159SKalle Valo 5413d5c65159SKalle Valo for (i = 0; i < ARRAY_SIZE(src->num_tx_frames_failures); i++) 5414d5c65159SKalle Valo dst->num_tx_frames_failures[i] = src->num_tx_frames_failures[i]; 5415d5c65159SKalle Valo 5416d5c65159SKalle Valo for (i = 0; i < ARRAY_SIZE(src->tx_rate_history); i++) 5417d5c65159SKalle Valo dst->tx_rate_history[i] = src->tx_rate_history[i]; 5418d5c65159SKalle Valo 5419d5c65159SKalle Valo for (i = 0; i < ARRAY_SIZE(src->beacon_rssi_history); i++) 5420d5c65159SKalle Valo dst->beacon_rssi_history[i] = src->beacon_rssi_history[i]; 5421d5c65159SKalle Valo } 5422d5c65159SKalle Valo 5423d5c65159SKalle Valo static void 5424d5c65159SKalle Valo ath11k_wmi_pull_bcn_stats(const struct wmi_bcn_stats *src, 5425d5c65159SKalle Valo struct ath11k_fw_stats_bcn *dst) 5426d5c65159SKalle Valo { 5427d5c65159SKalle Valo dst->vdev_id = src->vdev_id; 5428d5c65159SKalle Valo dst->tx_bcn_succ_cnt = src->tx_bcn_succ_cnt; 5429d5c65159SKalle Valo dst->tx_bcn_outage_cnt = src->tx_bcn_outage_cnt; 5430d5c65159SKalle Valo } 5431d5c65159SKalle Valo 5432d5c65159SKalle Valo int ath11k_wmi_pull_fw_stats(struct ath11k_base *ab, struct sk_buff *skb, 5433d5c65159SKalle Valo struct ath11k_fw_stats *stats) 5434d5c65159SKalle Valo { 5435d5c65159SKalle Valo const void **tb; 5436d5c65159SKalle Valo const struct wmi_stats_event *ev; 5437d5c65159SKalle Valo const void *data; 5438d5c65159SKalle Valo int i, ret; 5439d5c65159SKalle Valo u32 len = skb->len; 5440d5c65159SKalle Valo 5441d5c65159SKalle Valo tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, len, GFP_ATOMIC); 5442d5c65159SKalle Valo if (IS_ERR(tb)) { 5443d5c65159SKalle Valo ret = PTR_ERR(tb); 5444d5c65159SKalle Valo ath11k_warn(ab, "failed to parse tlv: %d\n", ret); 5445d5c65159SKalle Valo return ret; 5446d5c65159SKalle Valo } 5447d5c65159SKalle Valo 5448d5c65159SKalle Valo ev = tb[WMI_TAG_STATS_EVENT]; 5449d5c65159SKalle Valo data = tb[WMI_TAG_ARRAY_BYTE]; 5450d5c65159SKalle Valo if (!ev || !data) { 5451d5c65159SKalle Valo ath11k_warn(ab, "failed to fetch update stats ev"); 5452d5c65159SKalle Valo kfree(tb); 5453d5c65159SKalle Valo return -EPROTO; 5454d5c65159SKalle Valo } 5455d5c65159SKalle Valo 5456d5c65159SKalle Valo ath11k_dbg(ab, ATH11K_DBG_WMI, 5457d5c65159SKalle Valo "wmi stats update ev pdev_id %d pdev %i vdev %i bcn %i\n", 5458d5c65159SKalle Valo ev->pdev_id, 5459d5c65159SKalle Valo ev->num_pdev_stats, ev->num_vdev_stats, 5460d5c65159SKalle Valo ev->num_bcn_stats); 5461d5c65159SKalle Valo 5462d5c65159SKalle Valo stats->pdev_id = ev->pdev_id; 5463d5c65159SKalle Valo stats->stats_id = 0; 5464d5c65159SKalle Valo 5465d5c65159SKalle Valo for (i = 0; i < ev->num_pdev_stats; i++) { 5466d5c65159SKalle Valo const struct wmi_pdev_stats *src; 5467d5c65159SKalle Valo struct ath11k_fw_stats_pdev *dst; 5468d5c65159SKalle Valo 5469d5c65159SKalle Valo src = data; 5470d5c65159SKalle Valo if (len < sizeof(*src)) { 5471d5c65159SKalle Valo kfree(tb); 5472d5c65159SKalle Valo return -EPROTO; 5473d5c65159SKalle Valo } 5474d5c65159SKalle Valo 5475d5c65159SKalle Valo stats->stats_id = WMI_REQUEST_PDEV_STAT; 5476d5c65159SKalle Valo 5477d5c65159SKalle Valo data += sizeof(*src); 5478d5c65159SKalle Valo len -= sizeof(*src); 5479d5c65159SKalle Valo 5480d5c65159SKalle Valo dst = kzalloc(sizeof(*dst), GFP_ATOMIC); 5481d5c65159SKalle Valo if (!dst) 5482d5c65159SKalle Valo continue; 5483d5c65159SKalle Valo 5484d5c65159SKalle Valo ath11k_wmi_pull_pdev_stats_base(&src->base, dst); 5485d5c65159SKalle Valo ath11k_wmi_pull_pdev_stats_tx(&src->tx, dst); 5486d5c65159SKalle Valo ath11k_wmi_pull_pdev_stats_rx(&src->rx, dst); 5487d5c65159SKalle Valo list_add_tail(&dst->list, &stats->pdevs); 5488d5c65159SKalle Valo } 5489d5c65159SKalle Valo 5490d5c65159SKalle Valo for (i = 0; i < ev->num_vdev_stats; i++) { 5491d5c65159SKalle Valo const struct wmi_vdev_stats *src; 5492d5c65159SKalle Valo struct ath11k_fw_stats_vdev *dst; 5493d5c65159SKalle Valo 5494d5c65159SKalle Valo src = data; 5495d5c65159SKalle Valo if (len < sizeof(*src)) { 5496d5c65159SKalle Valo kfree(tb); 5497d5c65159SKalle Valo return -EPROTO; 5498d5c65159SKalle Valo } 5499d5c65159SKalle Valo 5500d5c65159SKalle Valo stats->stats_id = WMI_REQUEST_VDEV_STAT; 5501d5c65159SKalle Valo 5502d5c65159SKalle Valo data += sizeof(*src); 5503d5c65159SKalle Valo len -= sizeof(*src); 5504d5c65159SKalle Valo 5505d5c65159SKalle Valo dst = kzalloc(sizeof(*dst), GFP_ATOMIC); 5506d5c65159SKalle Valo if (!dst) 5507d5c65159SKalle Valo continue; 5508d5c65159SKalle Valo 5509d5c65159SKalle Valo ath11k_wmi_pull_vdev_stats(src, dst); 5510d5c65159SKalle Valo list_add_tail(&dst->list, &stats->vdevs); 5511d5c65159SKalle Valo } 5512d5c65159SKalle Valo 5513d5c65159SKalle Valo for (i = 0; i < ev->num_bcn_stats; i++) { 5514d5c65159SKalle Valo const struct wmi_bcn_stats *src; 5515d5c65159SKalle Valo struct ath11k_fw_stats_bcn *dst; 5516d5c65159SKalle Valo 5517d5c65159SKalle Valo src = data; 5518d5c65159SKalle Valo if (len < sizeof(*src)) { 5519d5c65159SKalle Valo kfree(tb); 5520d5c65159SKalle Valo return -EPROTO; 5521d5c65159SKalle Valo } 5522d5c65159SKalle Valo 5523d5c65159SKalle Valo stats->stats_id = WMI_REQUEST_BCN_STAT; 5524d5c65159SKalle Valo 5525d5c65159SKalle Valo data += sizeof(*src); 5526d5c65159SKalle Valo len -= sizeof(*src); 5527d5c65159SKalle Valo 5528d5c65159SKalle Valo dst = kzalloc(sizeof(*dst), GFP_ATOMIC); 5529d5c65159SKalle Valo if (!dst) 5530d5c65159SKalle Valo continue; 5531d5c65159SKalle Valo 5532d5c65159SKalle Valo ath11k_wmi_pull_bcn_stats(src, dst); 5533d5c65159SKalle Valo list_add_tail(&dst->list, &stats->bcn); 5534d5c65159SKalle Valo } 5535d5c65159SKalle Valo 5536d5c65159SKalle Valo kfree(tb); 5537d5c65159SKalle Valo return 0; 5538d5c65159SKalle Valo } 5539d5c65159SKalle Valo 5540d5c65159SKalle Valo size_t ath11k_wmi_fw_stats_num_vdevs(struct list_head *head) 5541d5c65159SKalle Valo { 5542d5c65159SKalle Valo struct ath11k_fw_stats_vdev *i; 5543d5c65159SKalle Valo size_t num = 0; 5544d5c65159SKalle Valo 5545d5c65159SKalle Valo list_for_each_entry(i, head, list) 5546d5c65159SKalle Valo ++num; 5547d5c65159SKalle Valo 5548d5c65159SKalle Valo return num; 5549d5c65159SKalle Valo } 5550d5c65159SKalle Valo 5551d5c65159SKalle Valo static size_t ath11k_wmi_fw_stats_num_bcn(struct list_head *head) 5552d5c65159SKalle Valo { 5553d5c65159SKalle Valo struct ath11k_fw_stats_bcn *i; 5554d5c65159SKalle Valo size_t num = 0; 5555d5c65159SKalle Valo 5556d5c65159SKalle Valo list_for_each_entry(i, head, list) 5557d5c65159SKalle Valo ++num; 5558d5c65159SKalle Valo 5559d5c65159SKalle Valo return num; 5560d5c65159SKalle Valo } 5561d5c65159SKalle Valo 5562d5c65159SKalle Valo static void 5563d5c65159SKalle Valo ath11k_wmi_fw_pdev_base_stats_fill(const struct ath11k_fw_stats_pdev *pdev, 5564d5c65159SKalle Valo char *buf, u32 *length) 5565d5c65159SKalle Valo { 5566d5c65159SKalle Valo u32 len = *length; 5567d5c65159SKalle Valo u32 buf_len = ATH11K_FW_STATS_BUF_SIZE; 5568d5c65159SKalle Valo 5569d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "\n"); 5570d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s\n", 5571d5c65159SKalle Valo "ath11k PDEV stats"); 5572d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s\n\n", 5573d5c65159SKalle Valo "================="); 5574d5c65159SKalle Valo 5575d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", 5576d5c65159SKalle Valo "Channel noise floor", pdev->ch_noise_floor); 5577d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", 5578d5c65159SKalle Valo "Channel TX power", pdev->chan_tx_power); 5579d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", 5580d5c65159SKalle Valo "TX frame count", pdev->tx_frame_count); 5581d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", 5582d5c65159SKalle Valo "RX frame count", pdev->rx_frame_count); 5583d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", 5584d5c65159SKalle Valo "RX clear count", pdev->rx_clear_count); 5585d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", 5586d5c65159SKalle Valo "Cycle count", pdev->cycle_count); 5587d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", 5588d5c65159SKalle Valo "PHY error count", pdev->phy_err_count); 5589d5c65159SKalle Valo 5590d5c65159SKalle Valo *length = len; 5591d5c65159SKalle Valo } 5592d5c65159SKalle Valo 5593d5c65159SKalle Valo static void 5594d5c65159SKalle Valo ath11k_wmi_fw_pdev_tx_stats_fill(const struct ath11k_fw_stats_pdev *pdev, 5595d5c65159SKalle Valo char *buf, u32 *length) 5596d5c65159SKalle Valo { 5597d5c65159SKalle Valo u32 len = *length; 5598d5c65159SKalle Valo u32 buf_len = ATH11K_FW_STATS_BUF_SIZE; 5599d5c65159SKalle Valo 5600d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "\n%30s\n", 5601d5c65159SKalle Valo "ath11k PDEV TX stats"); 5602d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s\n\n", 5603d5c65159SKalle Valo "===================="); 5604d5c65159SKalle Valo 5605d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", 5606d5c65159SKalle Valo "HTT cookies queued", pdev->comp_queued); 5607d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", 5608d5c65159SKalle Valo "HTT cookies disp.", pdev->comp_delivered); 5609d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", 5610d5c65159SKalle Valo "MSDU queued", pdev->msdu_enqued); 5611d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", 5612d5c65159SKalle Valo "MPDU queued", pdev->mpdu_enqued); 5613d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", 5614d5c65159SKalle Valo "MSDUs dropped", pdev->wmm_drop); 5615d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", 5616d5c65159SKalle Valo "Local enqued", pdev->local_enqued); 5617d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", 5618d5c65159SKalle Valo "Local freed", pdev->local_freed); 5619d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", 5620d5c65159SKalle Valo "HW queued", pdev->hw_queued); 5621d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", 5622d5c65159SKalle Valo "PPDUs reaped", pdev->hw_reaped); 5623d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", 5624d5c65159SKalle Valo "Num underruns", pdev->underrun); 5625d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", 5626f394e4eaSSriram R "Num HW Paused", pdev->hw_paused); 5627f394e4eaSSriram R len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", 5628d5c65159SKalle Valo "PPDUs cleaned", pdev->tx_abort); 5629d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", 563017818dfaSColin Ian King "MPDUs requeued", pdev->mpdus_requeued); 5631d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", 5632f394e4eaSSriram R "PPDU OK", pdev->tx_ko); 5633f394e4eaSSriram R len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", 5634f394e4eaSSriram R "Excessive retries", pdev->tx_xretry); 5635d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", 5636d5c65159SKalle Valo "HW rate", pdev->data_rc); 5637d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", 5638d5c65159SKalle Valo "Sched self triggers", pdev->self_triggers); 5639d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", 5640d5c65159SKalle Valo "Dropped due to SW retries", 5641d5c65159SKalle Valo pdev->sw_retry_failure); 5642d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", 5643d5c65159SKalle Valo "Illegal rate phy errors", 5644d5c65159SKalle Valo pdev->illgl_rate_phy_err); 5645d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", 5646d5c65159SKalle Valo "PDEV continuous xretry", pdev->pdev_cont_xretry); 5647d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", 5648d5c65159SKalle Valo "TX timeout", pdev->pdev_tx_timeout); 5649d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", 5650d5c65159SKalle Valo "PDEV resets", pdev->pdev_resets); 5651d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", 5652d5c65159SKalle Valo "Stateless TIDs alloc failures", 5653d5c65159SKalle Valo pdev->stateless_tid_alloc_failure); 5654d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", 5655d5c65159SKalle Valo "PHY underrun", pdev->phy_underrun); 5656d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", 5657d5c65159SKalle Valo "MPDU is more than txop limit", pdev->txop_ovf); 5658f394e4eaSSriram R len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", 5659f394e4eaSSriram R "Num sequences posted", pdev->seq_posted); 5660f394e4eaSSriram R len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", 5661f394e4eaSSriram R "Num seq failed queueing ", pdev->seq_failed_queueing); 5662f394e4eaSSriram R len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", 5663f394e4eaSSriram R "Num sequences completed ", pdev->seq_completed); 5664f394e4eaSSriram R len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", 5665f394e4eaSSriram R "Num sequences restarted ", pdev->seq_restarted); 5666f394e4eaSSriram R len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", 5667f394e4eaSSriram R "Num of MU sequences posted ", pdev->mu_seq_posted); 5668f394e4eaSSriram R len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", 5669f394e4eaSSriram R "Num of MPDUS SW flushed ", pdev->mpdus_sw_flush); 5670f394e4eaSSriram R len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", 5671f394e4eaSSriram R "Num of MPDUS HW filtered ", pdev->mpdus_hw_filter); 5672f394e4eaSSriram R len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", 5673f394e4eaSSriram R "Num of MPDUS truncated ", pdev->mpdus_truncated); 5674f394e4eaSSriram R len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", 5675f394e4eaSSriram R "Num of MPDUS ACK failed ", pdev->mpdus_ack_failed); 5676f394e4eaSSriram R len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", 5677f394e4eaSSriram R "Num of MPDUS expired ", pdev->mpdus_expired); 5678d5c65159SKalle Valo *length = len; 5679d5c65159SKalle Valo } 5680d5c65159SKalle Valo 5681d5c65159SKalle Valo static void 5682d5c65159SKalle Valo ath11k_wmi_fw_pdev_rx_stats_fill(const struct ath11k_fw_stats_pdev *pdev, 5683d5c65159SKalle Valo char *buf, u32 *length) 5684d5c65159SKalle Valo { 5685d5c65159SKalle Valo u32 len = *length; 5686d5c65159SKalle Valo u32 buf_len = ATH11K_FW_STATS_BUF_SIZE; 5687d5c65159SKalle Valo 5688d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "\n%30s\n", 5689d5c65159SKalle Valo "ath11k PDEV RX stats"); 5690d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s\n\n", 5691d5c65159SKalle Valo "===================="); 5692d5c65159SKalle Valo 5693d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", 5694d5c65159SKalle Valo "Mid PPDU route change", 5695d5c65159SKalle Valo pdev->mid_ppdu_route_change); 5696d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", 5697d5c65159SKalle Valo "Tot. number of statuses", pdev->status_rcvd); 5698d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", 5699d5c65159SKalle Valo "Extra frags on rings 0", pdev->r0_frags); 5700d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", 5701d5c65159SKalle Valo "Extra frags on rings 1", pdev->r1_frags); 5702d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", 5703d5c65159SKalle Valo "Extra frags on rings 2", pdev->r2_frags); 5704d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", 5705d5c65159SKalle Valo "Extra frags on rings 3", pdev->r3_frags); 5706d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", 5707d5c65159SKalle Valo "MSDUs delivered to HTT", pdev->htt_msdus); 5708d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", 5709d5c65159SKalle Valo "MPDUs delivered to HTT", pdev->htt_mpdus); 5710d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", 5711d5c65159SKalle Valo "MSDUs delivered to stack", pdev->loc_msdus); 5712d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", 5713d5c65159SKalle Valo "MPDUs delivered to stack", pdev->loc_mpdus); 5714d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", 5715d5c65159SKalle Valo "Oversized AMSUs", pdev->oversize_amsdu); 5716d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", 5717d5c65159SKalle Valo "PHY errors", pdev->phy_errs); 5718d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", 5719d5c65159SKalle Valo "PHY errors drops", pdev->phy_err_drop); 5720d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", 5721d5c65159SKalle Valo "MPDU errors (FCS, MIC, ENC)", pdev->mpdu_errs); 5722f394e4eaSSriram R len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", 5723f394e4eaSSriram R "Overflow errors", pdev->rx_ovfl_errs); 5724d5c65159SKalle Valo *length = len; 5725d5c65159SKalle Valo } 5726d5c65159SKalle Valo 5727d5c65159SKalle Valo static void 5728d5c65159SKalle Valo ath11k_wmi_fw_vdev_stats_fill(struct ath11k *ar, 5729d5c65159SKalle Valo const struct ath11k_fw_stats_vdev *vdev, 5730d5c65159SKalle Valo char *buf, u32 *length) 5731d5c65159SKalle Valo { 5732d5c65159SKalle Valo u32 len = *length; 5733d5c65159SKalle Valo u32 buf_len = ATH11K_FW_STATS_BUF_SIZE; 5734d5c65159SKalle Valo struct ath11k_vif *arvif = ath11k_mac_get_arvif(ar, vdev->vdev_id); 5735d5c65159SKalle Valo u8 *vif_macaddr; 5736d5c65159SKalle Valo int i; 5737d5c65159SKalle Valo 5738d5c65159SKalle Valo /* VDEV stats has all the active VDEVs of other PDEVs as well, 5739d5c65159SKalle Valo * ignoring those not part of requested PDEV 5740d5c65159SKalle Valo */ 5741d5c65159SKalle Valo if (!arvif) 5742d5c65159SKalle Valo return; 5743d5c65159SKalle Valo 5744d5c65159SKalle Valo vif_macaddr = arvif->vif->addr; 5745d5c65159SKalle Valo 5746d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %u\n", 5747d5c65159SKalle Valo "VDEV ID", vdev->vdev_id); 5748d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %pM\n", 5749d5c65159SKalle Valo "VDEV MAC address", vif_macaddr); 5750d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %u\n", 5751d5c65159SKalle Valo "beacon snr", vdev->beacon_snr); 5752d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %u\n", 5753d5c65159SKalle Valo "data snr", vdev->data_snr); 5754d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %u\n", 5755d5c65159SKalle Valo "num rx frames", vdev->num_rx_frames); 5756d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %u\n", 5757d5c65159SKalle Valo "num rts fail", vdev->num_rts_fail); 5758d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %u\n", 5759d5c65159SKalle Valo "num rts success", vdev->num_rts_success); 5760d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %u\n", 5761d5c65159SKalle Valo "num rx err", vdev->num_rx_err); 5762d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %u\n", 5763d5c65159SKalle Valo "num rx discard", vdev->num_rx_discard); 5764d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %u\n", 5765d5c65159SKalle Valo "num tx not acked", vdev->num_tx_not_acked); 5766d5c65159SKalle Valo 5767d5c65159SKalle Valo for (i = 0 ; i < ARRAY_SIZE(vdev->num_tx_frames); i++) 5768d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, 5769d5c65159SKalle Valo "%25s [%02d] %u\n", 5770d5c65159SKalle Valo "num tx frames", i, 5771d5c65159SKalle Valo vdev->num_tx_frames[i]); 5772d5c65159SKalle Valo 5773d5c65159SKalle Valo for (i = 0 ; i < ARRAY_SIZE(vdev->num_tx_frames_retries); i++) 5774d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, 5775d5c65159SKalle Valo "%25s [%02d] %u\n", 5776d5c65159SKalle Valo "num tx frames retries", i, 5777d5c65159SKalle Valo vdev->num_tx_frames_retries[i]); 5778d5c65159SKalle Valo 5779d5c65159SKalle Valo for (i = 0 ; i < ARRAY_SIZE(vdev->num_tx_frames_failures); i++) 5780d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, 5781d5c65159SKalle Valo "%25s [%02d] %u\n", 5782d5c65159SKalle Valo "num tx frames failures", i, 5783d5c65159SKalle Valo vdev->num_tx_frames_failures[i]); 5784d5c65159SKalle Valo 5785d5c65159SKalle Valo for (i = 0 ; i < ARRAY_SIZE(vdev->tx_rate_history); i++) 5786d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, 5787d5c65159SKalle Valo "%25s [%02d] 0x%08x\n", 5788d5c65159SKalle Valo "tx rate history", i, 5789d5c65159SKalle Valo vdev->tx_rate_history[i]); 5790d5c65159SKalle Valo 5791d5c65159SKalle Valo for (i = 0 ; i < ARRAY_SIZE(vdev->beacon_rssi_history); i++) 5792d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, 5793d5c65159SKalle Valo "%25s [%02d] %u\n", 5794d5c65159SKalle Valo "beacon rssi history", i, 5795d5c65159SKalle Valo vdev->beacon_rssi_history[i]); 5796d5c65159SKalle Valo 5797d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "\n"); 5798d5c65159SKalle Valo *length = len; 5799d5c65159SKalle Valo } 5800d5c65159SKalle Valo 5801d5c65159SKalle Valo static void 5802d5c65159SKalle Valo ath11k_wmi_fw_bcn_stats_fill(struct ath11k *ar, 5803d5c65159SKalle Valo const struct ath11k_fw_stats_bcn *bcn, 5804d5c65159SKalle Valo char *buf, u32 *length) 5805d5c65159SKalle Valo { 5806d5c65159SKalle Valo u32 len = *length; 5807d5c65159SKalle Valo u32 buf_len = ATH11K_FW_STATS_BUF_SIZE; 5808d5c65159SKalle Valo struct ath11k_vif *arvif = ath11k_mac_get_arvif(ar, bcn->vdev_id); 5809d5c65159SKalle Valo u8 *vdev_macaddr; 5810d5c65159SKalle Valo 5811d5c65159SKalle Valo if (!arvif) { 5812d5c65159SKalle Valo ath11k_warn(ar->ab, "invalid vdev id %d in bcn stats", 5813d5c65159SKalle Valo bcn->vdev_id); 5814d5c65159SKalle Valo return; 5815d5c65159SKalle Valo } 5816d5c65159SKalle Valo 5817d5c65159SKalle Valo vdev_macaddr = arvif->vif->addr; 5818d5c65159SKalle Valo 5819d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %u\n", 5820d5c65159SKalle Valo "VDEV ID", bcn->vdev_id); 5821d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %pM\n", 5822d5c65159SKalle Valo "VDEV MAC address", vdev_macaddr); 5823d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s\n\n", 5824d5c65159SKalle Valo "================"); 5825d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %u\n", 5826d5c65159SKalle Valo "Num of beacon tx success", bcn->tx_bcn_succ_cnt); 5827d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s %u\n", 5828d5c65159SKalle Valo "Num of beacon tx failures", bcn->tx_bcn_outage_cnt); 5829d5c65159SKalle Valo 5830d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "\n"); 5831d5c65159SKalle Valo *length = len; 5832d5c65159SKalle Valo } 5833d5c65159SKalle Valo 5834d5c65159SKalle Valo void ath11k_wmi_fw_stats_fill(struct ath11k *ar, 5835d5c65159SKalle Valo struct ath11k_fw_stats *fw_stats, 5836d5c65159SKalle Valo u32 stats_id, char *buf) 5837d5c65159SKalle Valo { 5838d5c65159SKalle Valo u32 len = 0; 5839d5c65159SKalle Valo u32 buf_len = ATH11K_FW_STATS_BUF_SIZE; 5840d5c65159SKalle Valo const struct ath11k_fw_stats_pdev *pdev; 5841d5c65159SKalle Valo const struct ath11k_fw_stats_vdev *vdev; 5842d5c65159SKalle Valo const struct ath11k_fw_stats_bcn *bcn; 5843d5c65159SKalle Valo size_t num_bcn; 5844d5c65159SKalle Valo 5845d5c65159SKalle Valo spin_lock_bh(&ar->data_lock); 5846d5c65159SKalle Valo 5847d5c65159SKalle Valo if (stats_id == WMI_REQUEST_PDEV_STAT) { 5848d5c65159SKalle Valo pdev = list_first_entry_or_null(&fw_stats->pdevs, 5849d5c65159SKalle Valo struct ath11k_fw_stats_pdev, list); 5850d5c65159SKalle Valo if (!pdev) { 5851d5c65159SKalle Valo ath11k_warn(ar->ab, "failed to get pdev stats\n"); 5852d5c65159SKalle Valo goto unlock; 5853d5c65159SKalle Valo } 5854d5c65159SKalle Valo 5855d5c65159SKalle Valo ath11k_wmi_fw_pdev_base_stats_fill(pdev, buf, &len); 5856d5c65159SKalle Valo ath11k_wmi_fw_pdev_tx_stats_fill(pdev, buf, &len); 5857d5c65159SKalle Valo ath11k_wmi_fw_pdev_rx_stats_fill(pdev, buf, &len); 5858d5c65159SKalle Valo } 5859d5c65159SKalle Valo 5860d5c65159SKalle Valo if (stats_id == WMI_REQUEST_VDEV_STAT) { 5861d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "\n"); 5862d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s\n", 5863d5c65159SKalle Valo "ath11k VDEV stats"); 5864d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s\n\n", 5865d5c65159SKalle Valo "================="); 5866d5c65159SKalle Valo 5867d5c65159SKalle Valo list_for_each_entry(vdev, &fw_stats->vdevs, list) 5868d5c65159SKalle Valo ath11k_wmi_fw_vdev_stats_fill(ar, vdev, buf, &len); 5869d5c65159SKalle Valo } 5870d5c65159SKalle Valo 5871d5c65159SKalle Valo if (stats_id == WMI_REQUEST_BCN_STAT) { 5872d5c65159SKalle Valo num_bcn = ath11k_wmi_fw_stats_num_bcn(&fw_stats->bcn); 5873d5c65159SKalle Valo 5874d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "\n"); 5875d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n", 5876d5c65159SKalle Valo "ath11k Beacon stats", num_bcn); 5877d5c65159SKalle Valo len += scnprintf(buf + len, buf_len - len, "%30s\n\n", 5878d5c65159SKalle Valo "==================="); 5879d5c65159SKalle Valo 5880d5c65159SKalle Valo list_for_each_entry(bcn, &fw_stats->bcn, list) 5881d5c65159SKalle Valo ath11k_wmi_fw_bcn_stats_fill(ar, bcn, buf, &len); 5882d5c65159SKalle Valo } 5883d5c65159SKalle Valo 5884d5c65159SKalle Valo unlock: 5885d5c65159SKalle Valo spin_unlock_bh(&ar->data_lock); 5886d5c65159SKalle Valo 5887d5c65159SKalle Valo if (len >= buf_len) 5888d5c65159SKalle Valo buf[len - 1] = 0; 5889d5c65159SKalle Valo else 5890d5c65159SKalle Valo buf[len] = 0; 5891d5c65159SKalle Valo } 5892d5c65159SKalle Valo 5893d5c65159SKalle Valo static void ath11k_wmi_op_ep_tx_credits(struct ath11k_base *ab) 5894d5c65159SKalle Valo { 5895d5c65159SKalle Valo /* try to send pending beacons first. they take priority */ 58966bc9d6f7SJohn Crispin wake_up(&ab->wmi_ab.tx_credits_wq); 5897d5c65159SKalle Valo } 5898d5c65159SKalle Valo 5899d5c65159SKalle Valo static void ath11k_wmi_htc_tx_complete(struct ath11k_base *ab, 5900d5c65159SKalle Valo struct sk_buff *skb) 5901d5c65159SKalle Valo { 5902f951380aSP Praneesh struct ath11k_pdev_wmi *wmi = NULL; 5903f951380aSP Praneesh u32 i; 5904f951380aSP Praneesh u8 wmi_ep_count; 5905f951380aSP Praneesh u8 eid; 5906f951380aSP Praneesh 5907f951380aSP Praneesh eid = ATH11K_SKB_CB(skb)->eid; 5908d5c65159SKalle Valo dev_kfree_skb(skb); 5909f951380aSP Praneesh 5910f951380aSP Praneesh if (eid >= ATH11K_HTC_EP_COUNT) 5911f951380aSP Praneesh return; 5912f951380aSP Praneesh 5913f951380aSP Praneesh wmi_ep_count = ab->htc.wmi_ep_count; 5914f951380aSP Praneesh if (wmi_ep_count > ab->hw_params.max_radios) 5915f951380aSP Praneesh return; 5916f951380aSP Praneesh 5917f951380aSP Praneesh for (i = 0; i < ab->htc.wmi_ep_count; i++) { 5918f951380aSP Praneesh if (ab->wmi_ab.wmi[i].eid == eid) { 5919f951380aSP Praneesh wmi = &ab->wmi_ab.wmi[i]; 5920f951380aSP Praneesh break; 5921f951380aSP Praneesh } 5922f951380aSP Praneesh } 5923f951380aSP Praneesh 5924f951380aSP Praneesh if (wmi) 5925f951380aSP Praneesh wake_up(&wmi->tx_ce_desc_wq); 5926d5c65159SKalle Valo } 5927d5c65159SKalle Valo 5928d5c65159SKalle Valo static bool ath11k_reg_is_world_alpha(char *alpha) 5929d5c65159SKalle Valo { 5930d5c65159SKalle Valo return alpha[0] == '0' && alpha[1] == '0'; 5931d5c65159SKalle Valo } 5932d5c65159SKalle Valo 5933d5c65159SKalle Valo static int ath11k_reg_chan_list_event(struct ath11k_base *ab, struct sk_buff *skb) 5934d5c65159SKalle Valo { 5935d5c65159SKalle Valo struct cur_regulatory_info *reg_info = NULL; 5936d5c65159SKalle Valo struct ieee80211_regdomain *regd = NULL; 5937d5c65159SKalle Valo bool intersect = false; 5938d5c65159SKalle Valo int ret = 0, pdev_idx; 5939d5c65159SKalle Valo struct ath11k *ar; 5940d5c65159SKalle Valo 5941d5c65159SKalle Valo reg_info = kzalloc(sizeof(*reg_info), GFP_ATOMIC); 5942d5c65159SKalle Valo if (!reg_info) { 5943d5c65159SKalle Valo ret = -ENOMEM; 5944d5c65159SKalle Valo goto fallback; 5945d5c65159SKalle Valo } 5946d5c65159SKalle Valo 5947d5c65159SKalle Valo ret = ath11k_pull_reg_chan_list_update_ev(ab, skb, reg_info); 5948d5c65159SKalle Valo if (ret) { 5949d5c65159SKalle Valo ath11k_warn(ab, "failed to extract regulatory info from received event\n"); 5950d5c65159SKalle Valo goto fallback; 5951d5c65159SKalle Valo } 5952d5c65159SKalle Valo 5953d5c65159SKalle Valo if (reg_info->status_code != REG_SET_CC_STATUS_PASS) { 5954d5c65159SKalle Valo /* In case of failure to set the requested ctry, 5955d5c65159SKalle Valo * fw retains the current regd. We print a failure info 5956d5c65159SKalle Valo * and return from here. 5957d5c65159SKalle Valo */ 5958d5c65159SKalle Valo ath11k_warn(ab, "Failed to set the requested Country regulatory setting\n"); 5959d5c65159SKalle Valo goto mem_free; 5960d5c65159SKalle Valo } 5961d5c65159SKalle Valo 5962d5c65159SKalle Valo pdev_idx = reg_info->phy_id; 5963d5c65159SKalle Valo 596469a0fcf8SSriram R /* Avoid default reg rule updates sent during FW recovery if 596569a0fcf8SSriram R * it is already available 596669a0fcf8SSriram R */ 596769a0fcf8SSriram R spin_lock(&ab->base_lock); 596869a0fcf8SSriram R if (test_bit(ATH11K_FLAG_RECOVERY, &ab->dev_flags) && 596969a0fcf8SSriram R ab->default_regd[pdev_idx]) { 597069a0fcf8SSriram R spin_unlock(&ab->base_lock); 597169a0fcf8SSriram R goto mem_free; 597269a0fcf8SSriram R } 597369a0fcf8SSriram R spin_unlock(&ab->base_lock); 597469a0fcf8SSriram R 59755f859bc0SCarl Huang if (pdev_idx >= ab->num_radios) { 597684eee3c8SCarl Huang /* Process the event for phy0 only if single_pdev_only 597784eee3c8SCarl Huang * is true. If pdev_idx is valid but not 0, discard the 597884eee3c8SCarl Huang * event. Otherwise, it goes to fallback. 597984eee3c8SCarl Huang */ 598084eee3c8SCarl Huang if (ab->hw_params.single_pdev_only && 598184eee3c8SCarl Huang pdev_idx < ab->hw_params.num_rxmda_per_pdev) 59825f859bc0SCarl Huang goto mem_free; 59835f859bc0SCarl Huang else 5984d5c65159SKalle Valo goto fallback; 59855f859bc0SCarl Huang } 5986d5c65159SKalle Valo 5987d5c65159SKalle Valo /* Avoid multiple overwrites to default regd, during core 5988d5c65159SKalle Valo * stop-start after mac registration. 5989d5c65159SKalle Valo */ 5990d5c65159SKalle Valo if (ab->default_regd[pdev_idx] && !ab->new_regd[pdev_idx] && 5991d5c65159SKalle Valo !memcmp((char *)ab->default_regd[pdev_idx]->alpha2, 5992d5c65159SKalle Valo (char *)reg_info->alpha2, 2)) 5993b5316db2SColin Ian King goto mem_free; 5994d5c65159SKalle Valo 5995d5c65159SKalle Valo /* Intersect new rules with default regd if a new country setting was 5996d5c65159SKalle Valo * requested, i.e a default regd was already set during initialization 5997d5c65159SKalle Valo * and the regd coming from this event has a valid country info. 5998d5c65159SKalle Valo */ 5999d5c65159SKalle Valo if (ab->default_regd[pdev_idx] && 6000d5c65159SKalle Valo !ath11k_reg_is_world_alpha((char *) 6001d5c65159SKalle Valo ab->default_regd[pdev_idx]->alpha2) && 6002d5c65159SKalle Valo !ath11k_reg_is_world_alpha((char *)reg_info->alpha2)) 6003d5c65159SKalle Valo intersect = true; 6004d5c65159SKalle Valo 6005d5c65159SKalle Valo regd = ath11k_reg_build_regd(ab, reg_info, intersect); 6006d5c65159SKalle Valo if (!regd) { 6007d5c65159SKalle Valo ath11k_warn(ab, "failed to build regd from reg_info\n"); 6008d5c65159SKalle Valo goto fallback; 6009d5c65159SKalle Valo } 6010d5c65159SKalle Valo 6011d5c65159SKalle Valo spin_lock(&ab->base_lock); 60121db2b0d0SSriram R if (ab->default_regd[pdev_idx]) { 60131db2b0d0SSriram R /* The initial rules from FW after WMI Init is to build 60141db2b0d0SSriram R * the default regd. From then on, any rules updated for 60151db2b0d0SSriram R * the pdev could be due to user reg changes. 6016d5c65159SKalle Valo * Free previously built regd before assigning the newly 6017d5c65159SKalle Valo * generated regd to ar. NULL pointer handling will be 6018d5c65159SKalle Valo * taken care by kfree itself. 6019d5c65159SKalle Valo */ 6020d5c65159SKalle Valo ar = ab->pdevs[pdev_idx].ar; 6021d5c65159SKalle Valo kfree(ab->new_regd[pdev_idx]); 6022d5c65159SKalle Valo ab->new_regd[pdev_idx] = regd; 6023d5c65159SKalle Valo ieee80211_queue_work(ar->hw, &ar->regd_update_work); 6024d5c65159SKalle Valo } else { 60251db2b0d0SSriram R /* This regd would be applied during mac registration and is 60261db2b0d0SSriram R * held constant throughout for regd intersection purpose 6027d5c65159SKalle Valo */ 6028d5c65159SKalle Valo ab->default_regd[pdev_idx] = regd; 6029d5c65159SKalle Valo } 6030d5c65159SKalle Valo ab->dfs_region = reg_info->dfs_region; 6031d5c65159SKalle Valo spin_unlock(&ab->base_lock); 6032d5c65159SKalle Valo 6033d5c65159SKalle Valo goto mem_free; 6034d5c65159SKalle Valo 6035d5c65159SKalle Valo fallback: 6036d5c65159SKalle Valo /* Fallback to older reg (by sending previous country setting 6037d5c65159SKalle Valo * again if fw has succeded and we failed to process here. 6038d5c65159SKalle Valo * The Regdomain should be uniform across driver and fw. Since the 6039d5c65159SKalle Valo * FW has processed the command and sent a success status, we expect 6040d5c65159SKalle Valo * this function to succeed as well. If it doesn't, CTRY needs to be 6041d5c65159SKalle Valo * reverted at the fw and the old SCAN_CHAN_LIST cmd needs to be sent. 6042d5c65159SKalle Valo */ 6043d5c65159SKalle Valo /* TODO: This is rare, but still should also be handled */ 6044d5c65159SKalle Valo WARN_ON(1); 6045d5c65159SKalle Valo mem_free: 6046d5c65159SKalle Valo if (reg_info) { 6047d5c65159SKalle Valo kfree(reg_info->reg_rules_2g_ptr); 6048d5c65159SKalle Valo kfree(reg_info->reg_rules_5g_ptr); 6049d5c65159SKalle Valo kfree(reg_info); 6050d5c65159SKalle Valo } 6051d5c65159SKalle Valo return ret; 6052d5c65159SKalle Valo } 6053d5c65159SKalle Valo 6054d5c65159SKalle Valo static int ath11k_wmi_tlv_rdy_parse(struct ath11k_base *ab, u16 tag, u16 len, 6055d5c65159SKalle Valo const void *ptr, void *data) 6056d5c65159SKalle Valo { 6057d5c65159SKalle Valo struct wmi_tlv_rdy_parse *rdy_parse = data; 605821c1b063SMaharaja Kennadyrajan struct wmi_ready_event fixed_param; 6059d5c65159SKalle Valo struct wmi_mac_addr *addr_list; 6060d5c65159SKalle Valo struct ath11k_pdev *pdev; 6061d5c65159SKalle Valo u32 num_mac_addr; 6062d5c65159SKalle Valo int i; 6063d5c65159SKalle Valo 6064d5c65159SKalle Valo switch (tag) { 6065d5c65159SKalle Valo case WMI_TAG_READY_EVENT: 606621c1b063SMaharaja Kennadyrajan memset(&fixed_param, 0, sizeof(fixed_param)); 606721c1b063SMaharaja Kennadyrajan memcpy(&fixed_param, (struct wmi_ready_event *)ptr, 606821c1b063SMaharaja Kennadyrajan min_t(u16, sizeof(fixed_param), len)); 606921c1b063SMaharaja Kennadyrajan ab->wlan_init_status = fixed_param.ready_event_min.status; 607021c1b063SMaharaja Kennadyrajan rdy_parse->num_extra_mac_addr = 607121c1b063SMaharaja Kennadyrajan fixed_param.ready_event_min.num_extra_mac_addr; 6072d5c65159SKalle Valo 607321c1b063SMaharaja Kennadyrajan ether_addr_copy(ab->mac_addr, 607421c1b063SMaharaja Kennadyrajan fixed_param.ready_event_min.mac_addr.addr); 607521c1b063SMaharaja Kennadyrajan ab->pktlog_defs_checksum = fixed_param.pktlog_defs_checksum; 6076d5c65159SKalle Valo ab->wmi_ready = true; 6077d5c65159SKalle Valo break; 6078d5c65159SKalle Valo case WMI_TAG_ARRAY_FIXED_STRUCT: 6079d5c65159SKalle Valo addr_list = (struct wmi_mac_addr *)ptr; 6080d5c65159SKalle Valo num_mac_addr = rdy_parse->num_extra_mac_addr; 6081d5c65159SKalle Valo 6082d5c65159SKalle Valo if (!(ab->num_radios > 1 && num_mac_addr >= ab->num_radios)) 6083d5c65159SKalle Valo break; 6084d5c65159SKalle Valo 6085d5c65159SKalle Valo for (i = 0; i < ab->num_radios; i++) { 6086d5c65159SKalle Valo pdev = &ab->pdevs[i]; 6087d5c65159SKalle Valo ether_addr_copy(pdev->mac_addr, addr_list[i].addr); 6088d5c65159SKalle Valo } 6089d5c65159SKalle Valo ab->pdevs_macaddr_valid = true; 6090d5c65159SKalle Valo break; 6091d5c65159SKalle Valo default: 6092d5c65159SKalle Valo break; 6093d5c65159SKalle Valo } 6094d5c65159SKalle Valo 6095d5c65159SKalle Valo return 0; 6096d5c65159SKalle Valo } 6097d5c65159SKalle Valo 6098d5c65159SKalle Valo static int ath11k_ready_event(struct ath11k_base *ab, struct sk_buff *skb) 6099d5c65159SKalle Valo { 6100d5c65159SKalle Valo struct wmi_tlv_rdy_parse rdy_parse = { }; 6101d5c65159SKalle Valo int ret; 6102d5c65159SKalle Valo 6103d5c65159SKalle Valo ret = ath11k_wmi_tlv_iter(ab, skb->data, skb->len, 6104d5c65159SKalle Valo ath11k_wmi_tlv_rdy_parse, &rdy_parse); 6105d5c65159SKalle Valo if (ret) { 6106d5c65159SKalle Valo ath11k_warn(ab, "failed to parse tlv %d\n", ret); 6107d5c65159SKalle Valo return ret; 6108d5c65159SKalle Valo } 6109d5c65159SKalle Valo 61106bc9d6f7SJohn Crispin complete(&ab->wmi_ab.unified_ready); 6111d5c65159SKalle Valo return 0; 6112d5c65159SKalle Valo } 6113d5c65159SKalle Valo 6114d5c65159SKalle Valo static void ath11k_peer_delete_resp_event(struct ath11k_base *ab, struct sk_buff *skb) 6115d5c65159SKalle Valo { 6116d5c65159SKalle Valo struct wmi_peer_delete_resp_event peer_del_resp; 6117690ace20SRitesh Singh struct ath11k *ar; 6118d5c65159SKalle Valo 6119d5c65159SKalle Valo if (ath11k_pull_peer_del_resp_ev(ab, skb, &peer_del_resp) != 0) { 6120d5c65159SKalle Valo ath11k_warn(ab, "failed to extract peer delete resp"); 6121d5c65159SKalle Valo return; 6122d5c65159SKalle Valo } 6123d5c65159SKalle Valo 6124690ace20SRitesh Singh rcu_read_lock(); 6125690ace20SRitesh Singh ar = ath11k_mac_get_ar_by_vdev_id(ab, peer_del_resp.vdev_id); 6126690ace20SRitesh Singh if (!ar) { 6127690ace20SRitesh Singh ath11k_warn(ab, "invalid vdev id in peer delete resp ev %d", 6128690ace20SRitesh Singh peer_del_resp.vdev_id); 6129690ace20SRitesh Singh rcu_read_unlock(); 6130690ace20SRitesh Singh return; 6131690ace20SRitesh Singh } 6132690ace20SRitesh Singh 6133690ace20SRitesh Singh complete(&ar->peer_delete_done); 6134690ace20SRitesh Singh rcu_read_unlock(); 6135690ace20SRitesh Singh ath11k_dbg(ab, ATH11K_DBG_WMI, "peer delete resp for vdev id %d addr %pM\n", 6136690ace20SRitesh Singh peer_del_resp.vdev_id, peer_del_resp.peer_macaddr.addr); 6137d5c65159SKalle Valo } 6138d5c65159SKalle Valo 61393cbbdfbeSRitesh Singh static void ath11k_vdev_delete_resp_event(struct ath11k_base *ab, 61403cbbdfbeSRitesh Singh struct sk_buff *skb) 61413cbbdfbeSRitesh Singh { 61423cbbdfbeSRitesh Singh struct ath11k *ar; 61433cbbdfbeSRitesh Singh u32 vdev_id = 0; 61443cbbdfbeSRitesh Singh 61453cbbdfbeSRitesh Singh if (ath11k_pull_vdev_del_resp_ev(ab, skb, &vdev_id) != 0) { 61463cbbdfbeSRitesh Singh ath11k_warn(ab, "failed to extract vdev delete resp"); 61473cbbdfbeSRitesh Singh return; 61483cbbdfbeSRitesh Singh } 61493cbbdfbeSRitesh Singh 61503cbbdfbeSRitesh Singh rcu_read_lock(); 61513cbbdfbeSRitesh Singh ar = ath11k_mac_get_ar_by_vdev_id(ab, vdev_id); 61523cbbdfbeSRitesh Singh if (!ar) { 61533cbbdfbeSRitesh Singh ath11k_warn(ab, "invalid vdev id in vdev delete resp ev %d", 61543cbbdfbeSRitesh Singh vdev_id); 61553cbbdfbeSRitesh Singh rcu_read_unlock(); 61563cbbdfbeSRitesh Singh return; 61573cbbdfbeSRitesh Singh } 61583cbbdfbeSRitesh Singh 61593cbbdfbeSRitesh Singh complete(&ar->vdev_delete_done); 61603cbbdfbeSRitesh Singh 61613cbbdfbeSRitesh Singh rcu_read_unlock(); 61623cbbdfbeSRitesh Singh 61633cbbdfbeSRitesh Singh ath11k_dbg(ab, ATH11K_DBG_WMI, "vdev delete resp for vdev id %d\n", 61643cbbdfbeSRitesh Singh vdev_id); 61653cbbdfbeSRitesh Singh } 61663cbbdfbeSRitesh Singh 6167d5c65159SKalle Valo static inline const char *ath11k_wmi_vdev_resp_print(u32 vdev_resp_status) 6168d5c65159SKalle Valo { 6169d5c65159SKalle Valo switch (vdev_resp_status) { 6170d5c65159SKalle Valo case WMI_VDEV_START_RESPONSE_INVALID_VDEVID: 6171d5c65159SKalle Valo return "invalid vdev id"; 6172d5c65159SKalle Valo case WMI_VDEV_START_RESPONSE_NOT_SUPPORTED: 6173d5c65159SKalle Valo return "not supported"; 6174d5c65159SKalle Valo case WMI_VDEV_START_RESPONSE_DFS_VIOLATION: 6175d5c65159SKalle Valo return "dfs violation"; 6176d5c65159SKalle Valo case WMI_VDEV_START_RESPONSE_INVALID_REGDOMAIN: 6177d5c65159SKalle Valo return "invalid regdomain"; 6178d5c65159SKalle Valo default: 6179d5c65159SKalle Valo return "unknown"; 6180d5c65159SKalle Valo } 6181d5c65159SKalle Valo } 6182d5c65159SKalle Valo 6183d5c65159SKalle Valo static void ath11k_vdev_start_resp_event(struct ath11k_base *ab, struct sk_buff *skb) 6184d5c65159SKalle Valo { 6185d5c65159SKalle Valo struct wmi_vdev_start_resp_event vdev_start_resp; 6186d5c65159SKalle Valo struct ath11k *ar; 6187d5c65159SKalle Valo u32 status; 6188d5c65159SKalle Valo 6189d5c65159SKalle Valo if (ath11k_pull_vdev_start_resp_tlv(ab, skb, &vdev_start_resp) != 0) { 6190d5c65159SKalle Valo ath11k_warn(ab, "failed to extract vdev start resp"); 6191d5c65159SKalle Valo return; 6192d5c65159SKalle Valo } 6193d5c65159SKalle Valo 6194d5c65159SKalle Valo rcu_read_lock(); 6195d5c65159SKalle Valo ar = ath11k_mac_get_ar_by_vdev_id(ab, vdev_start_resp.vdev_id); 6196d5c65159SKalle Valo if (!ar) { 6197d5c65159SKalle Valo ath11k_warn(ab, "invalid vdev id in vdev start resp ev %d", 6198d5c65159SKalle Valo vdev_start_resp.vdev_id); 6199d5c65159SKalle Valo rcu_read_unlock(); 6200d5c65159SKalle Valo return; 6201d5c65159SKalle Valo } 6202d5c65159SKalle Valo 6203d5c65159SKalle Valo ar->last_wmi_vdev_start_status = 0; 6204d5c65159SKalle Valo 6205d5c65159SKalle Valo status = vdev_start_resp.status; 6206d5c65159SKalle Valo 6207d5c65159SKalle Valo if (WARN_ON_ONCE(status)) { 6208d5c65159SKalle Valo ath11k_warn(ab, "vdev start resp error status %d (%s)\n", 6209d5c65159SKalle Valo status, ath11k_wmi_vdev_resp_print(status)); 6210d5c65159SKalle Valo ar->last_wmi_vdev_start_status = status; 6211d5c65159SKalle Valo } 6212d5c65159SKalle Valo 6213d5c65159SKalle Valo complete(&ar->vdev_setup_done); 6214d5c65159SKalle Valo 6215d5c65159SKalle Valo rcu_read_unlock(); 6216d5c65159SKalle Valo 6217d5c65159SKalle Valo ath11k_dbg(ab, ATH11K_DBG_WMI, "vdev start resp for vdev id %d", 6218d5c65159SKalle Valo vdev_start_resp.vdev_id); 6219d5c65159SKalle Valo } 6220d5c65159SKalle Valo 6221d5c65159SKalle Valo static void ath11k_bcn_tx_status_event(struct ath11k_base *ab, struct sk_buff *skb) 6222d5c65159SKalle Valo { 6223886433a9SJohn Crispin struct ath11k_vif *arvif; 6224d5c65159SKalle Valo u32 vdev_id, tx_status; 6225d5c65159SKalle Valo 6226d5c65159SKalle Valo if (ath11k_pull_bcn_tx_status_ev(ab, skb->data, skb->len, 6227d5c65159SKalle Valo &vdev_id, &tx_status) != 0) { 6228d5c65159SKalle Valo ath11k_warn(ab, "failed to extract bcn tx status"); 6229d5c65159SKalle Valo return; 6230d5c65159SKalle Valo } 6231886433a9SJohn Crispin 6232886433a9SJohn Crispin arvif = ath11k_mac_get_arvif_by_vdev_id(ab, vdev_id); 6233886433a9SJohn Crispin if (!arvif) { 6234886433a9SJohn Crispin ath11k_warn(ab, "invalid vdev id %d in bcn_tx_status", 6235886433a9SJohn Crispin vdev_id); 6236886433a9SJohn Crispin return; 6237886433a9SJohn Crispin } 6238886433a9SJohn Crispin ath11k_mac_bcn_tx_event(arvif); 6239d5c65159SKalle Valo } 6240d5c65159SKalle Valo 6241d5c65159SKalle Valo static void ath11k_vdev_stopped_event(struct ath11k_base *ab, struct sk_buff *skb) 6242d5c65159SKalle Valo { 6243d5c65159SKalle Valo struct ath11k *ar; 6244d5c65159SKalle Valo u32 vdev_id = 0; 6245d5c65159SKalle Valo 6246d5c65159SKalle Valo if (ath11k_pull_vdev_stopped_param_tlv(ab, skb, &vdev_id) != 0) { 6247d5c65159SKalle Valo ath11k_warn(ab, "failed to extract vdev stopped event"); 6248d5c65159SKalle Valo return; 6249d5c65159SKalle Valo } 6250d5c65159SKalle Valo 6251d5c65159SKalle Valo rcu_read_lock(); 6252fae0385bSRitesh Singh ar = ath11k_mac_get_ar_by_vdev_id(ab, vdev_id); 6253d5c65159SKalle Valo if (!ar) { 6254d5c65159SKalle Valo ath11k_warn(ab, "invalid vdev id in vdev stopped ev %d", 6255d5c65159SKalle Valo vdev_id); 6256d5c65159SKalle Valo rcu_read_unlock(); 6257d5c65159SKalle Valo return; 6258d5c65159SKalle Valo } 6259d5c65159SKalle Valo 6260d5c65159SKalle Valo complete(&ar->vdev_setup_done); 6261d5c65159SKalle Valo 6262d5c65159SKalle Valo rcu_read_unlock(); 6263d5c65159SKalle Valo 6264d5c65159SKalle Valo ath11k_dbg(ab, ATH11K_DBG_WMI, "vdev stopped for vdev id %d", vdev_id); 6265d5c65159SKalle Valo } 6266d5c65159SKalle Valo 6267d5c65159SKalle Valo static void ath11k_mgmt_rx_event(struct ath11k_base *ab, struct sk_buff *skb) 6268d5c65159SKalle Valo { 6269d5c65159SKalle Valo struct mgmt_rx_event_params rx_ev = {0}; 6270d5c65159SKalle Valo struct ath11k *ar; 6271d5c65159SKalle Valo struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); 6272d5c65159SKalle Valo struct ieee80211_hdr *hdr; 6273d5c65159SKalle Valo u16 fc; 6274d5c65159SKalle Valo struct ieee80211_supported_band *sband; 6275d5c65159SKalle Valo 6276d5c65159SKalle Valo if (ath11k_pull_mgmt_rx_params_tlv(ab, skb, &rx_ev) != 0) { 6277d5c65159SKalle Valo ath11k_warn(ab, "failed to extract mgmt rx event"); 6278d5c65159SKalle Valo dev_kfree_skb(skb); 6279d5c65159SKalle Valo return; 6280d5c65159SKalle Valo } 6281d5c65159SKalle Valo 6282d5c65159SKalle Valo memset(status, 0, sizeof(*status)); 6283d5c65159SKalle Valo 6284d5c65159SKalle Valo ath11k_dbg(ab, ATH11K_DBG_MGMT, "mgmt rx event status %08x\n", 6285d5c65159SKalle Valo rx_ev.status); 6286d5c65159SKalle Valo 6287d5c65159SKalle Valo rcu_read_lock(); 6288d5c65159SKalle Valo ar = ath11k_mac_get_ar_by_pdev_id(ab, rx_ev.pdev_id); 6289d5c65159SKalle Valo 6290d5c65159SKalle Valo if (!ar) { 6291d5c65159SKalle Valo ath11k_warn(ab, "invalid pdev_id %d in mgmt_rx_event\n", 6292d5c65159SKalle Valo rx_ev.pdev_id); 6293d5c65159SKalle Valo dev_kfree_skb(skb); 6294d5c65159SKalle Valo goto exit; 6295d5c65159SKalle Valo } 6296d5c65159SKalle Valo 6297d5c65159SKalle Valo if ((test_bit(ATH11K_CAC_RUNNING, &ar->dev_flags)) || 6298d5c65159SKalle Valo (rx_ev.status & (WMI_RX_STATUS_ERR_DECRYPT | 6299d5c65159SKalle Valo WMI_RX_STATUS_ERR_KEY_CACHE_MISS | WMI_RX_STATUS_ERR_CRC))) { 6300d5c65159SKalle Valo dev_kfree_skb(skb); 6301d5c65159SKalle Valo goto exit; 6302d5c65159SKalle Valo } 6303d5c65159SKalle Valo 6304d5c65159SKalle Valo if (rx_ev.status & WMI_RX_STATUS_ERR_MIC) 6305d5c65159SKalle Valo status->flag |= RX_FLAG_MMIC_ERROR; 6306d5c65159SKalle Valo 63079d6ae1f5SPradeep Kumar Chitrapu if (rx_ev.chan_freq >= ATH11K_MIN_6G_FREQ && 63089d6ae1f5SPradeep Kumar Chitrapu rx_ev.chan_freq <= ATH11K_MAX_6G_FREQ) { 63095dcf42f8SPradeep Kumar Chitrapu status->band = NL80211_BAND_6GHZ; 63109d6ae1f5SPradeep Kumar Chitrapu status->freq = rx_ev.chan_freq; 63115dcf42f8SPradeep Kumar Chitrapu } else if (rx_ev.channel >= 1 && rx_ev.channel <= 14) { 6312d5c65159SKalle Valo status->band = NL80211_BAND_2GHZ; 6313d5c65159SKalle Valo } else if (rx_ev.channel >= 36 && rx_ev.channel <= ATH11K_MAX_5G_CHAN) { 6314d5c65159SKalle Valo status->band = NL80211_BAND_5GHZ; 6315d5c65159SKalle Valo } else { 6316d5c65159SKalle Valo /* Shouldn't happen unless list of advertised channels to 6317d5c65159SKalle Valo * mac80211 has been changed. 6318d5c65159SKalle Valo */ 6319d5c65159SKalle Valo WARN_ON_ONCE(1); 6320d5c65159SKalle Valo dev_kfree_skb(skb); 6321d5c65159SKalle Valo goto exit; 6322d5c65159SKalle Valo } 6323d5c65159SKalle Valo 632422eeadcdSPradeep Kumar Chitrapu if (rx_ev.phy_mode == MODE_11B && 632522eeadcdSPradeep Kumar Chitrapu (status->band == NL80211_BAND_5GHZ || status->band == NL80211_BAND_6GHZ)) 6326d5c65159SKalle Valo ath11k_dbg(ab, ATH11K_DBG_WMI, 632722eeadcdSPradeep Kumar Chitrapu "wmi mgmt rx 11b (CCK) on 5/6GHz, band = %d\n", status->band); 6328d5c65159SKalle Valo 6329d5c65159SKalle Valo sband = &ar->mac.sbands[status->band]; 6330d5c65159SKalle Valo 63319d6ae1f5SPradeep Kumar Chitrapu if (status->band != NL80211_BAND_6GHZ) 6332d5c65159SKalle Valo status->freq = ieee80211_channel_to_frequency(rx_ev.channel, 6333d5c65159SKalle Valo status->band); 63349d6ae1f5SPradeep Kumar Chitrapu 6335d5c65159SKalle Valo status->signal = rx_ev.snr + ATH11K_DEFAULT_NOISE_FLOOR; 6336d5c65159SKalle Valo status->rate_idx = ath11k_mac_bitrate_to_idx(sband, rx_ev.rate / 100); 6337d5c65159SKalle Valo 6338d5c65159SKalle Valo hdr = (struct ieee80211_hdr *)skb->data; 6339d5c65159SKalle Valo fc = le16_to_cpu(hdr->frame_control); 6340d5c65159SKalle Valo 6341d5c65159SKalle Valo /* Firmware is guaranteed to report all essential management frames via 6342d5c65159SKalle Valo * WMI while it can deliver some extra via HTT. Since there can be 6343d5c65159SKalle Valo * duplicates split the reporting wrt monitor/sniffing. 6344d5c65159SKalle Valo */ 6345d5c65159SKalle Valo status->flag |= RX_FLAG_SKIP_MONITOR; 6346d5c65159SKalle Valo 6347d5c65159SKalle Valo /* In case of PMF, FW delivers decrypted frames with Protected Bit set. 6348d5c65159SKalle Valo * Don't clear that. Also, FW delivers broadcast management frames 6349d5c65159SKalle Valo * (ex: group privacy action frames in mesh) as encrypted payload. 6350d5c65159SKalle Valo */ 6351d5c65159SKalle Valo if (ieee80211_has_protected(hdr->frame_control) && 6352d5c65159SKalle Valo !is_multicast_ether_addr(ieee80211_get_DA(hdr))) { 6353d5c65159SKalle Valo status->flag |= RX_FLAG_DECRYPTED; 6354d5c65159SKalle Valo 6355d5c65159SKalle Valo if (!ieee80211_is_robust_mgmt_frame(skb)) { 6356d5c65159SKalle Valo status->flag |= RX_FLAG_IV_STRIPPED | 6357d5c65159SKalle Valo RX_FLAG_MMIC_STRIPPED; 6358d5c65159SKalle Valo hdr->frame_control = __cpu_to_le16(fc & 6359d5c65159SKalle Valo ~IEEE80211_FCTL_PROTECTED); 6360d5c65159SKalle Valo } 6361d5c65159SKalle Valo } 6362d5c65159SKalle Valo 636326f69792SLavanya Suresh if (ieee80211_is_beacon(hdr->frame_control)) 636426f69792SLavanya Suresh ath11k_mac_handle_beacon(ar, skb); 6365d5c65159SKalle Valo 6366d5c65159SKalle Valo ath11k_dbg(ab, ATH11K_DBG_MGMT, 6367d5c65159SKalle Valo "event mgmt rx skb %pK len %d ftype %02x stype %02x\n", 6368d5c65159SKalle Valo skb, skb->len, 6369d5c65159SKalle Valo fc & IEEE80211_FCTL_FTYPE, fc & IEEE80211_FCTL_STYPE); 6370d5c65159SKalle Valo 6371d5c65159SKalle Valo ath11k_dbg(ab, ATH11K_DBG_MGMT, 6372d5c65159SKalle Valo "event mgmt rx freq %d band %d snr %d, rate_idx %d\n", 6373d5c65159SKalle Valo status->freq, status->band, status->signal, 6374d5c65159SKalle Valo status->rate_idx); 6375d5c65159SKalle Valo 6376d5c65159SKalle Valo ieee80211_rx_ni(ar->hw, skb); 6377d5c65159SKalle Valo 6378d5c65159SKalle Valo exit: 6379d5c65159SKalle Valo rcu_read_unlock(); 6380d5c65159SKalle Valo } 6381d5c65159SKalle Valo 6382d5c65159SKalle Valo static void ath11k_mgmt_tx_compl_event(struct ath11k_base *ab, struct sk_buff *skb) 6383d5c65159SKalle Valo { 6384d5c65159SKalle Valo struct wmi_mgmt_tx_compl_event tx_compl_param = {0}; 6385d5c65159SKalle Valo struct ath11k *ar; 6386d5c65159SKalle Valo 6387d5c65159SKalle Valo if (ath11k_pull_mgmt_tx_compl_param_tlv(ab, skb, &tx_compl_param) != 0) { 6388d5c65159SKalle Valo ath11k_warn(ab, "failed to extract mgmt tx compl event"); 6389d5c65159SKalle Valo return; 6390d5c65159SKalle Valo } 6391d5c65159SKalle Valo 6392d5c65159SKalle Valo rcu_read_lock(); 6393d5c65159SKalle Valo ar = ath11k_mac_get_ar_by_pdev_id(ab, tx_compl_param.pdev_id); 6394d5c65159SKalle Valo if (!ar) { 6395d5c65159SKalle Valo ath11k_warn(ab, "invalid pdev id %d in mgmt_tx_compl_event\n", 6396d5c65159SKalle Valo tx_compl_param.pdev_id); 6397d5c65159SKalle Valo goto exit; 6398d5c65159SKalle Valo } 6399d5c65159SKalle Valo 6400d5c65159SKalle Valo wmi_process_mgmt_tx_comp(ar, tx_compl_param.desc_id, 6401d5c65159SKalle Valo tx_compl_param.status); 6402d5c65159SKalle Valo 6403d5c65159SKalle Valo ath11k_dbg(ab, ATH11K_DBG_MGMT, 6404d5c65159SKalle Valo "mgmt tx compl ev pdev_id %d, desc_id %d, status %d", 6405d5c65159SKalle Valo tx_compl_param.pdev_id, tx_compl_param.desc_id, 6406d5c65159SKalle Valo tx_compl_param.status); 6407d5c65159SKalle Valo 6408d5c65159SKalle Valo exit: 6409d5c65159SKalle Valo rcu_read_unlock(); 6410d5c65159SKalle Valo } 6411d5c65159SKalle Valo 6412c677d4b1SWen Gong static struct ath11k *ath11k_get_ar_on_scan_state(struct ath11k_base *ab, 6413c677d4b1SWen Gong u32 vdev_id, 6414c677d4b1SWen Gong enum ath11k_scan_state state) 6415d5c65159SKalle Valo { 6416d5c65159SKalle Valo int i; 6417d5c65159SKalle Valo struct ath11k_pdev *pdev; 6418d5c65159SKalle Valo struct ath11k *ar; 6419d5c65159SKalle Valo 6420d5c65159SKalle Valo for (i = 0; i < ab->num_radios; i++) { 6421d5c65159SKalle Valo pdev = rcu_dereference(ab->pdevs_active[i]); 6422d5c65159SKalle Valo if (pdev && pdev->ar) { 6423d5c65159SKalle Valo ar = pdev->ar; 6424d5c65159SKalle Valo 6425d5c65159SKalle Valo spin_lock_bh(&ar->data_lock); 6426c677d4b1SWen Gong if (ar->scan.state == state && 6427d5c65159SKalle Valo ar->scan.vdev_id == vdev_id) { 6428d5c65159SKalle Valo spin_unlock_bh(&ar->data_lock); 6429d5c65159SKalle Valo return ar; 6430d5c65159SKalle Valo } 6431d5c65159SKalle Valo spin_unlock_bh(&ar->data_lock); 6432d5c65159SKalle Valo } 6433d5c65159SKalle Valo } 6434d5c65159SKalle Valo return NULL; 6435d5c65159SKalle Valo } 6436d5c65159SKalle Valo 6437d5c65159SKalle Valo static void ath11k_scan_event(struct ath11k_base *ab, struct sk_buff *skb) 6438d5c65159SKalle Valo { 6439d5c65159SKalle Valo struct ath11k *ar; 6440d5c65159SKalle Valo struct wmi_scan_event scan_ev = {0}; 6441d5c65159SKalle Valo 6442d5c65159SKalle Valo if (ath11k_pull_scan_ev(ab, skb, &scan_ev) != 0) { 6443d5c65159SKalle Valo ath11k_warn(ab, "failed to extract scan event"); 6444d5c65159SKalle Valo return; 6445d5c65159SKalle Valo } 6446d5c65159SKalle Valo 6447d5c65159SKalle Valo rcu_read_lock(); 6448d5c65159SKalle Valo 6449d5c65159SKalle Valo /* In case the scan was cancelled, ex. during interface teardown, 6450d5c65159SKalle Valo * the interface will not be found in active interfaces. 6451d5c65159SKalle Valo * Rather, in such scenarios, iterate over the active pdev's to 6452d5c65159SKalle Valo * search 'ar' if the corresponding 'ar' scan is ABORTING and the 6453d5c65159SKalle Valo * aborting scan's vdev id matches this event info. 6454d5c65159SKalle Valo */ 6455d5c65159SKalle Valo if (scan_ev.event_type == WMI_SCAN_EVENT_COMPLETED && 6456c677d4b1SWen Gong scan_ev.reason == WMI_SCAN_REASON_CANCELLED) { 6457c677d4b1SWen Gong ar = ath11k_get_ar_on_scan_state(ab, scan_ev.vdev_id, 6458c677d4b1SWen Gong ATH11K_SCAN_ABORTING); 6459c677d4b1SWen Gong if (!ar) 6460c677d4b1SWen Gong ar = ath11k_get_ar_on_scan_state(ab, scan_ev.vdev_id, 6461c677d4b1SWen Gong ATH11K_SCAN_RUNNING); 6462c677d4b1SWen Gong } else { 6463d5c65159SKalle Valo ar = ath11k_mac_get_ar_by_vdev_id(ab, scan_ev.vdev_id); 6464c677d4b1SWen Gong } 6465d5c65159SKalle Valo 6466d5c65159SKalle Valo if (!ar) { 6467d5c65159SKalle Valo ath11k_warn(ab, "Received scan event for unknown vdev"); 6468d5c65159SKalle Valo rcu_read_unlock(); 6469d5c65159SKalle Valo return; 6470d5c65159SKalle Valo } 6471d5c65159SKalle Valo 6472d5c65159SKalle Valo spin_lock_bh(&ar->data_lock); 6473d5c65159SKalle Valo 6474d5c65159SKalle Valo ath11k_dbg(ab, ATH11K_DBG_WMI, 6475d5c65159SKalle Valo "scan event %s type %d reason %d freq %d req_id %d scan_id %d vdev_id %d state %s (%d)\n", 6476d5c65159SKalle Valo ath11k_wmi_event_scan_type_str(scan_ev.event_type, scan_ev.reason), 6477d5c65159SKalle Valo scan_ev.event_type, scan_ev.reason, scan_ev.channel_freq, 6478d5c65159SKalle Valo scan_ev.scan_req_id, scan_ev.scan_id, scan_ev.vdev_id, 6479d5c65159SKalle Valo ath11k_scan_state_str(ar->scan.state), ar->scan.state); 6480d5c65159SKalle Valo 6481d5c65159SKalle Valo switch (scan_ev.event_type) { 6482d5c65159SKalle Valo case WMI_SCAN_EVENT_STARTED: 6483d5c65159SKalle Valo ath11k_wmi_event_scan_started(ar); 6484d5c65159SKalle Valo break; 6485d5c65159SKalle Valo case WMI_SCAN_EVENT_COMPLETED: 6486d5c65159SKalle Valo ath11k_wmi_event_scan_completed(ar); 6487d5c65159SKalle Valo break; 6488d5c65159SKalle Valo case WMI_SCAN_EVENT_BSS_CHANNEL: 6489d5c65159SKalle Valo ath11k_wmi_event_scan_bss_chan(ar); 6490d5c65159SKalle Valo break; 6491d5c65159SKalle Valo case WMI_SCAN_EVENT_FOREIGN_CHAN: 6492d5c65159SKalle Valo ath11k_wmi_event_scan_foreign_chan(ar, scan_ev.channel_freq); 6493d5c65159SKalle Valo break; 6494d5c65159SKalle Valo case WMI_SCAN_EVENT_START_FAILED: 6495d5c65159SKalle Valo ath11k_warn(ab, "received scan start failure event\n"); 6496d5c65159SKalle Valo ath11k_wmi_event_scan_start_failed(ar); 6497d5c65159SKalle Valo break; 6498d5c65159SKalle Valo case WMI_SCAN_EVENT_DEQUEUED: 6499441b3b59SWen Gong __ath11k_mac_scan_finish(ar); 6500441b3b59SWen Gong break; 6501d5c65159SKalle Valo case WMI_SCAN_EVENT_PREEMPTED: 6502d5c65159SKalle Valo case WMI_SCAN_EVENT_RESTARTED: 6503d5c65159SKalle Valo case WMI_SCAN_EVENT_FOREIGN_CHAN_EXIT: 6504d5c65159SKalle Valo default: 6505d5c65159SKalle Valo break; 6506d5c65159SKalle Valo } 6507d5c65159SKalle Valo 6508d5c65159SKalle Valo spin_unlock_bh(&ar->data_lock); 6509d5c65159SKalle Valo 6510d5c65159SKalle Valo rcu_read_unlock(); 6511d5c65159SKalle Valo } 6512d5c65159SKalle Valo 6513d5c65159SKalle Valo static void ath11k_peer_sta_kickout_event(struct ath11k_base *ab, struct sk_buff *skb) 6514d5c65159SKalle Valo { 6515d5c65159SKalle Valo struct wmi_peer_sta_kickout_arg arg = {}; 6516d5c65159SKalle Valo struct ieee80211_sta *sta; 6517d5c65159SKalle Valo struct ath11k_peer *peer; 6518d5c65159SKalle Valo struct ath11k *ar; 65194c375743SKarthikeyan Periyasamy u32 vdev_id; 6520d5c65159SKalle Valo 6521d5c65159SKalle Valo if (ath11k_pull_peer_sta_kickout_ev(ab, skb, &arg) != 0) { 6522d5c65159SKalle Valo ath11k_warn(ab, "failed to extract peer sta kickout event"); 6523d5c65159SKalle Valo return; 6524d5c65159SKalle Valo } 6525d5c65159SKalle Valo 6526d5c65159SKalle Valo rcu_read_lock(); 6527d5c65159SKalle Valo 6528d5c65159SKalle Valo spin_lock_bh(&ab->base_lock); 6529d5c65159SKalle Valo 6530d5c65159SKalle Valo peer = ath11k_peer_find_by_addr(ab, arg.mac_addr); 6531d5c65159SKalle Valo 6532d5c65159SKalle Valo if (!peer) { 6533d5c65159SKalle Valo ath11k_warn(ab, "peer not found %pM\n", 6534d5c65159SKalle Valo arg.mac_addr); 65354c375743SKarthikeyan Periyasamy spin_unlock_bh(&ab->base_lock); 6536d5c65159SKalle Valo goto exit; 6537d5c65159SKalle Valo } 6538d5c65159SKalle Valo 65394c375743SKarthikeyan Periyasamy vdev_id = peer->vdev_id; 65404c375743SKarthikeyan Periyasamy 65414c375743SKarthikeyan Periyasamy spin_unlock_bh(&ab->base_lock); 65424c375743SKarthikeyan Periyasamy 65434c375743SKarthikeyan Periyasamy ar = ath11k_mac_get_ar_by_vdev_id(ab, vdev_id); 6544d5c65159SKalle Valo if (!ar) { 6545d5c65159SKalle Valo ath11k_warn(ab, "invalid vdev id in peer sta kickout ev %d", 6546d5c65159SKalle Valo peer->vdev_id); 6547d5c65159SKalle Valo goto exit; 6548d5c65159SKalle Valo } 6549d5c65159SKalle Valo 6550d5c65159SKalle Valo sta = ieee80211_find_sta_by_ifaddr(ar->hw, 6551d5c65159SKalle Valo arg.mac_addr, NULL); 6552d5c65159SKalle Valo if (!sta) { 6553d5c65159SKalle Valo ath11k_warn(ab, "Spurious quick kickout for STA %pM\n", 6554d5c65159SKalle Valo arg.mac_addr); 6555d5c65159SKalle Valo goto exit; 6556d5c65159SKalle Valo } 6557d5c65159SKalle Valo 6558d5c65159SKalle Valo ath11k_dbg(ab, ATH11K_DBG_WMI, "peer sta kickout event %pM", 6559d5c65159SKalle Valo arg.mac_addr); 6560d5c65159SKalle Valo 6561d5c65159SKalle Valo ieee80211_report_low_ack(sta, 10); 6562d5c65159SKalle Valo 6563d5c65159SKalle Valo exit: 6564d5c65159SKalle Valo rcu_read_unlock(); 6565d5c65159SKalle Valo } 6566d5c65159SKalle Valo 6567d5c65159SKalle Valo static void ath11k_roam_event(struct ath11k_base *ab, struct sk_buff *skb) 6568d5c65159SKalle Valo { 6569d5c65159SKalle Valo struct wmi_roam_event roam_ev = {}; 6570d5c65159SKalle Valo struct ath11k *ar; 6571d5c65159SKalle Valo 6572d5c65159SKalle Valo if (ath11k_pull_roam_ev(ab, skb, &roam_ev) != 0) { 6573d5c65159SKalle Valo ath11k_warn(ab, "failed to extract roam event"); 6574d5c65159SKalle Valo return; 6575d5c65159SKalle Valo } 6576d5c65159SKalle Valo 6577d5c65159SKalle Valo ath11k_dbg(ab, ATH11K_DBG_WMI, 6578d5c65159SKalle Valo "wmi roam event vdev %u reason 0x%08x rssi %d\n", 6579d5c65159SKalle Valo roam_ev.vdev_id, roam_ev.reason, roam_ev.rssi); 6580d5c65159SKalle Valo 6581d5c65159SKalle Valo rcu_read_lock(); 6582d5c65159SKalle Valo ar = ath11k_mac_get_ar_by_vdev_id(ab, roam_ev.vdev_id); 6583d5c65159SKalle Valo if (!ar) { 6584d5c65159SKalle Valo ath11k_warn(ab, "invalid vdev id in roam ev %d", 6585d5c65159SKalle Valo roam_ev.vdev_id); 6586d5c65159SKalle Valo rcu_read_unlock(); 6587d5c65159SKalle Valo return; 6588d5c65159SKalle Valo } 6589d5c65159SKalle Valo 6590d5c65159SKalle Valo if (roam_ev.reason >= WMI_ROAM_REASON_MAX) 6591d5c65159SKalle Valo ath11k_warn(ab, "ignoring unknown roam event reason %d on vdev %i\n", 6592d5c65159SKalle Valo roam_ev.reason, roam_ev.vdev_id); 6593d5c65159SKalle Valo 6594d5c65159SKalle Valo switch (roam_ev.reason) { 6595d5c65159SKalle Valo case WMI_ROAM_REASON_BEACON_MISS: 659626f69792SLavanya Suresh ath11k_mac_handle_beacon_miss(ar, roam_ev.vdev_id); 6597d5c65159SKalle Valo break; 6598d5c65159SKalle Valo case WMI_ROAM_REASON_BETTER_AP: 6599d5c65159SKalle Valo case WMI_ROAM_REASON_LOW_RSSI: 6600d5c65159SKalle Valo case WMI_ROAM_REASON_SUITABLE_AP_FOUND: 6601d5c65159SKalle Valo case WMI_ROAM_REASON_HO_FAILED: 6602d5c65159SKalle Valo ath11k_warn(ab, "ignoring not implemented roam event reason %d on vdev %i\n", 6603d5c65159SKalle Valo roam_ev.reason, roam_ev.vdev_id); 6604d5c65159SKalle Valo break; 6605d5c65159SKalle Valo } 6606d5c65159SKalle Valo 6607d5c65159SKalle Valo rcu_read_unlock(); 6608d5c65159SKalle Valo } 6609d5c65159SKalle Valo 6610d5c65159SKalle Valo static void ath11k_chan_info_event(struct ath11k_base *ab, struct sk_buff *skb) 6611d5c65159SKalle Valo { 6612d5c65159SKalle Valo struct wmi_chan_info_event ch_info_ev = {0}; 6613d5c65159SKalle Valo struct ath11k *ar; 6614d5c65159SKalle Valo struct survey_info *survey; 6615d5c65159SKalle Valo int idx; 6616d5c65159SKalle Valo /* HW channel counters frequency value in hertz */ 6617d5c65159SKalle Valo u32 cc_freq_hz = ab->cc_freq_hz; 6618d5c65159SKalle Valo 6619d5c65159SKalle Valo if (ath11k_pull_chan_info_ev(ab, skb->data, skb->len, &ch_info_ev) != 0) { 6620d5c65159SKalle Valo ath11k_warn(ab, "failed to extract chan info event"); 6621d5c65159SKalle Valo return; 6622d5c65159SKalle Valo } 6623d5c65159SKalle Valo 6624d5c65159SKalle Valo ath11k_dbg(ab, ATH11K_DBG_WMI, 6625d5c65159SKalle Valo "chan info vdev_id %d err_code %d freq %d cmd_flags %d noise_floor %d rx_clear_count %d cycle_count %d mac_clk_mhz %d\n", 6626d5c65159SKalle Valo ch_info_ev.vdev_id, ch_info_ev.err_code, ch_info_ev.freq, 6627d5c65159SKalle Valo ch_info_ev.cmd_flags, ch_info_ev.noise_floor, 6628d5c65159SKalle Valo ch_info_ev.rx_clear_count, ch_info_ev.cycle_count, 6629d5c65159SKalle Valo ch_info_ev.mac_clk_mhz); 6630d5c65159SKalle Valo 6631d5c65159SKalle Valo if (ch_info_ev.cmd_flags == WMI_CHAN_INFO_END_RESP) { 6632d5c65159SKalle Valo ath11k_dbg(ab, ATH11K_DBG_WMI, "chan info report completed\n"); 6633d5c65159SKalle Valo return; 6634d5c65159SKalle Valo } 6635d5c65159SKalle Valo 6636d5c65159SKalle Valo rcu_read_lock(); 6637d5c65159SKalle Valo ar = ath11k_mac_get_ar_by_vdev_id(ab, ch_info_ev.vdev_id); 6638d5c65159SKalle Valo if (!ar) { 6639d5c65159SKalle Valo ath11k_warn(ab, "invalid vdev id in chan info ev %d", 6640d5c65159SKalle Valo ch_info_ev.vdev_id); 6641d5c65159SKalle Valo rcu_read_unlock(); 6642d5c65159SKalle Valo return; 6643d5c65159SKalle Valo } 6644d5c65159SKalle Valo spin_lock_bh(&ar->data_lock); 6645d5c65159SKalle Valo 6646d5c65159SKalle Valo switch (ar->scan.state) { 6647d5c65159SKalle Valo case ATH11K_SCAN_IDLE: 6648d5c65159SKalle Valo case ATH11K_SCAN_STARTING: 6649d5c65159SKalle Valo ath11k_warn(ab, "received chan info event without a scan request, ignoring\n"); 6650d5c65159SKalle Valo goto exit; 6651d5c65159SKalle Valo case ATH11K_SCAN_RUNNING: 6652d5c65159SKalle Valo case ATH11K_SCAN_ABORTING: 6653d5c65159SKalle Valo break; 6654d5c65159SKalle Valo } 6655d5c65159SKalle Valo 6656d5c65159SKalle Valo idx = freq_to_idx(ar, ch_info_ev.freq); 6657d5c65159SKalle Valo if (idx >= ARRAY_SIZE(ar->survey)) { 6658d5c65159SKalle Valo ath11k_warn(ab, "chan info: invalid frequency %d (idx %d out of bounds)\n", 6659d5c65159SKalle Valo ch_info_ev.freq, idx); 6660d5c65159SKalle Valo goto exit; 6661d5c65159SKalle Valo } 6662d5c65159SKalle Valo 6663d5c65159SKalle Valo /* If FW provides MAC clock frequency in Mhz, overriding the initialized 6664d5c65159SKalle Valo * HW channel counters frequency value 6665d5c65159SKalle Valo */ 6666d5c65159SKalle Valo if (ch_info_ev.mac_clk_mhz) 6667d5c65159SKalle Valo cc_freq_hz = (ch_info_ev.mac_clk_mhz * 1000); 6668d5c65159SKalle Valo 6669d5c65159SKalle Valo if (ch_info_ev.cmd_flags == WMI_CHAN_INFO_START_RESP) { 6670d5c65159SKalle Valo survey = &ar->survey[idx]; 6671d5c65159SKalle Valo memset(survey, 0, sizeof(*survey)); 6672d5c65159SKalle Valo survey->noise = ch_info_ev.noise_floor; 6673d5c65159SKalle Valo survey->filled = SURVEY_INFO_NOISE_DBM | SURVEY_INFO_TIME | 6674d5c65159SKalle Valo SURVEY_INFO_TIME_BUSY; 6675d5c65159SKalle Valo survey->time = div_u64(ch_info_ev.cycle_count, cc_freq_hz); 6676d5c65159SKalle Valo survey->time_busy = div_u64(ch_info_ev.rx_clear_count, cc_freq_hz); 6677d5c65159SKalle Valo } 6678d5c65159SKalle Valo exit: 6679d5c65159SKalle Valo spin_unlock_bh(&ar->data_lock); 6680d5c65159SKalle Valo rcu_read_unlock(); 6681d5c65159SKalle Valo } 6682d5c65159SKalle Valo 6683d5c65159SKalle Valo static void 6684d5c65159SKalle Valo ath11k_pdev_bss_chan_info_event(struct ath11k_base *ab, struct sk_buff *skb) 6685d5c65159SKalle Valo { 6686d5c65159SKalle Valo struct wmi_pdev_bss_chan_info_event bss_ch_info_ev = {}; 6687d5c65159SKalle Valo struct survey_info *survey; 6688d5c65159SKalle Valo struct ath11k *ar; 6689d5c65159SKalle Valo u32 cc_freq_hz = ab->cc_freq_hz; 6690d5c65159SKalle Valo u64 busy, total, tx, rx, rx_bss; 6691d5c65159SKalle Valo int idx; 6692d5c65159SKalle Valo 6693d5c65159SKalle Valo if (ath11k_pull_pdev_bss_chan_info_ev(ab, skb, &bss_ch_info_ev) != 0) { 6694d5c65159SKalle Valo ath11k_warn(ab, "failed to extract pdev bss chan info event"); 6695d5c65159SKalle Valo return; 6696d5c65159SKalle Valo } 6697d5c65159SKalle Valo 6698d5c65159SKalle Valo busy = (u64)(bss_ch_info_ev.rx_clear_count_high) << 32 | 6699d5c65159SKalle Valo bss_ch_info_ev.rx_clear_count_low; 6700d5c65159SKalle Valo 6701d5c65159SKalle Valo total = (u64)(bss_ch_info_ev.cycle_count_high) << 32 | 6702d5c65159SKalle Valo bss_ch_info_ev.cycle_count_low; 6703d5c65159SKalle Valo 6704d5c65159SKalle Valo tx = (u64)(bss_ch_info_ev.tx_cycle_count_high) << 32 | 6705d5c65159SKalle Valo bss_ch_info_ev.tx_cycle_count_low; 6706d5c65159SKalle Valo 6707d5c65159SKalle Valo rx = (u64)(bss_ch_info_ev.rx_cycle_count_high) << 32 | 6708d5c65159SKalle Valo bss_ch_info_ev.rx_cycle_count_low; 6709d5c65159SKalle Valo 6710d5c65159SKalle Valo rx_bss = (u64)(bss_ch_info_ev.rx_bss_cycle_count_high) << 32 | 6711d5c65159SKalle Valo bss_ch_info_ev.rx_bss_cycle_count_low; 6712d5c65159SKalle Valo 6713d5c65159SKalle Valo ath11k_dbg(ab, ATH11K_DBG_WMI, 6714d5c65159SKalle Valo "pdev bss chan info:\n pdev_id: %d freq: %d noise: %d cycle: busy %llu total %llu tx %llu rx %llu rx_bss %llu\n", 6715d5c65159SKalle Valo bss_ch_info_ev.pdev_id, bss_ch_info_ev.freq, 6716d5c65159SKalle Valo bss_ch_info_ev.noise_floor, busy, total, 6717d5c65159SKalle Valo tx, rx, rx_bss); 6718d5c65159SKalle Valo 6719d5c65159SKalle Valo rcu_read_lock(); 6720d5c65159SKalle Valo ar = ath11k_mac_get_ar_by_pdev_id(ab, bss_ch_info_ev.pdev_id); 6721d5c65159SKalle Valo 6722d5c65159SKalle Valo if (!ar) { 6723d5c65159SKalle Valo ath11k_warn(ab, "invalid pdev id %d in bss_chan_info event\n", 6724d5c65159SKalle Valo bss_ch_info_ev.pdev_id); 6725d5c65159SKalle Valo rcu_read_unlock(); 6726d5c65159SKalle Valo return; 6727d5c65159SKalle Valo } 6728d5c65159SKalle Valo 6729d5c65159SKalle Valo spin_lock_bh(&ar->data_lock); 6730d5c65159SKalle Valo idx = freq_to_idx(ar, bss_ch_info_ev.freq); 6731d5c65159SKalle Valo if (idx >= ARRAY_SIZE(ar->survey)) { 6732d5c65159SKalle Valo ath11k_warn(ab, "bss chan info: invalid frequency %d (idx %d out of bounds)\n", 6733d5c65159SKalle Valo bss_ch_info_ev.freq, idx); 6734d5c65159SKalle Valo goto exit; 6735d5c65159SKalle Valo } 6736d5c65159SKalle Valo 6737d5c65159SKalle Valo survey = &ar->survey[idx]; 6738d5c65159SKalle Valo 6739d5c65159SKalle Valo survey->noise = bss_ch_info_ev.noise_floor; 6740d5c65159SKalle Valo survey->time = div_u64(total, cc_freq_hz); 6741d5c65159SKalle Valo survey->time_busy = div_u64(busy, cc_freq_hz); 6742d5c65159SKalle Valo survey->time_rx = div_u64(rx_bss, cc_freq_hz); 6743d5c65159SKalle Valo survey->time_tx = div_u64(tx, cc_freq_hz); 6744d5c65159SKalle Valo survey->filled |= (SURVEY_INFO_NOISE_DBM | 6745d5c65159SKalle Valo SURVEY_INFO_TIME | 6746d5c65159SKalle Valo SURVEY_INFO_TIME_BUSY | 6747d5c65159SKalle Valo SURVEY_INFO_TIME_RX | 6748d5c65159SKalle Valo SURVEY_INFO_TIME_TX); 6749d5c65159SKalle Valo exit: 6750d5c65159SKalle Valo spin_unlock_bh(&ar->data_lock); 6751d5c65159SKalle Valo complete(&ar->bss_survey_done); 6752d5c65159SKalle Valo 6753d5c65159SKalle Valo rcu_read_unlock(); 6754d5c65159SKalle Valo } 6755d5c65159SKalle Valo 6756d5c65159SKalle Valo static void ath11k_vdev_install_key_compl_event(struct ath11k_base *ab, 6757d5c65159SKalle Valo struct sk_buff *skb) 6758d5c65159SKalle Valo { 6759d5c65159SKalle Valo struct wmi_vdev_install_key_complete_arg install_key_compl = {0}; 6760d5c65159SKalle Valo struct ath11k *ar; 6761d5c65159SKalle Valo 6762d5c65159SKalle Valo if (ath11k_pull_vdev_install_key_compl_ev(ab, skb, &install_key_compl) != 0) { 6763d5c65159SKalle Valo ath11k_warn(ab, "failed to extract install key compl event"); 6764d5c65159SKalle Valo return; 6765d5c65159SKalle Valo } 6766d5c65159SKalle Valo 6767d5c65159SKalle Valo ath11k_dbg(ab, ATH11K_DBG_WMI, 6768d5c65159SKalle Valo "vdev install key ev idx %d flags %08x macaddr %pM status %d\n", 6769d5c65159SKalle Valo install_key_compl.key_idx, install_key_compl.key_flags, 6770d5c65159SKalle Valo install_key_compl.macaddr, install_key_compl.status); 6771d5c65159SKalle Valo 6772d5c65159SKalle Valo rcu_read_lock(); 6773d5c65159SKalle Valo ar = ath11k_mac_get_ar_by_vdev_id(ab, install_key_compl.vdev_id); 6774d5c65159SKalle Valo if (!ar) { 6775d5c65159SKalle Valo ath11k_warn(ab, "invalid vdev id in install key compl ev %d", 6776d5c65159SKalle Valo install_key_compl.vdev_id); 6777d5c65159SKalle Valo rcu_read_unlock(); 6778d5c65159SKalle Valo return; 6779d5c65159SKalle Valo } 6780d5c65159SKalle Valo 6781d5c65159SKalle Valo ar->install_key_status = 0; 6782d5c65159SKalle Valo 6783d5c65159SKalle Valo if (install_key_compl.status != WMI_VDEV_INSTALL_KEY_COMPL_STATUS_SUCCESS) { 6784d5c65159SKalle Valo ath11k_warn(ab, "install key failed for %pM status %d\n", 6785d5c65159SKalle Valo install_key_compl.macaddr, install_key_compl.status); 6786d5c65159SKalle Valo ar->install_key_status = install_key_compl.status; 6787d5c65159SKalle Valo } 6788d5c65159SKalle Valo 6789d5c65159SKalle Valo complete(&ar->install_key_done); 6790d5c65159SKalle Valo rcu_read_unlock(); 6791d5c65159SKalle Valo } 6792d5c65159SKalle Valo 6793d5c65159SKalle Valo static void ath11k_service_available_event(struct ath11k_base *ab, struct sk_buff *skb) 6794d5c65159SKalle Valo { 6795d5c65159SKalle Valo const void **tb; 6796d5c65159SKalle Valo const struct wmi_service_available_event *ev; 6797d5c65159SKalle Valo int ret; 6798d5c65159SKalle Valo int i, j; 6799d5c65159SKalle Valo 6800d5c65159SKalle Valo tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC); 6801d5c65159SKalle Valo if (IS_ERR(tb)) { 6802d5c65159SKalle Valo ret = PTR_ERR(tb); 6803d5c65159SKalle Valo ath11k_warn(ab, "failed to parse tlv: %d\n", ret); 6804d5c65159SKalle Valo return; 6805d5c65159SKalle Valo } 6806d5c65159SKalle Valo 6807d5c65159SKalle Valo ev = tb[WMI_TAG_SERVICE_AVAILABLE_EVENT]; 6808d5c65159SKalle Valo if (!ev) { 6809d5c65159SKalle Valo ath11k_warn(ab, "failed to fetch svc available ev"); 6810d5c65159SKalle Valo kfree(tb); 6811d5c65159SKalle Valo return; 6812d5c65159SKalle Valo } 6813d5c65159SKalle Valo 6814d5c65159SKalle Valo /* TODO: Use wmi_service_segment_offset information to get the service 6815d5c65159SKalle Valo * especially when more services are advertised in multiple sevice 6816d5c65159SKalle Valo * available events. 6817d5c65159SKalle Valo */ 6818d5c65159SKalle Valo for (i = 0, j = WMI_MAX_SERVICE; 6819d5c65159SKalle Valo i < WMI_SERVICE_SEGMENT_BM_SIZE32 && j < WMI_MAX_EXT_SERVICE; 6820d5c65159SKalle Valo i++) { 6821d5c65159SKalle Valo do { 6822d5c65159SKalle Valo if (ev->wmi_service_segment_bitmap[i] & 6823d5c65159SKalle Valo BIT(j % WMI_AVAIL_SERVICE_BITS_IN_SIZE32)) 68246bc9d6f7SJohn Crispin set_bit(j, ab->wmi_ab.svc_map); 6825d5c65159SKalle Valo } while (++j % WMI_AVAIL_SERVICE_BITS_IN_SIZE32); 6826d5c65159SKalle Valo } 6827d5c65159SKalle Valo 6828d5c65159SKalle Valo ath11k_dbg(ab, ATH11K_DBG_WMI, 6829d5c65159SKalle Valo "wmi_ext_service_bitmap 0:0x%x, 1:0x%x, 2:0x%x, 3:0x%x", 6830d5c65159SKalle Valo ev->wmi_service_segment_bitmap[0], ev->wmi_service_segment_bitmap[1], 6831d5c65159SKalle Valo ev->wmi_service_segment_bitmap[2], ev->wmi_service_segment_bitmap[3]); 6832d5c65159SKalle Valo 6833d5c65159SKalle Valo kfree(tb); 6834d5c65159SKalle Valo } 6835d5c65159SKalle Valo 6836d5c65159SKalle Valo static void ath11k_peer_assoc_conf_event(struct ath11k_base *ab, struct sk_buff *skb) 6837d5c65159SKalle Valo { 6838d5c65159SKalle Valo struct wmi_peer_assoc_conf_arg peer_assoc_conf = {0}; 6839d5c65159SKalle Valo struct ath11k *ar; 6840d5c65159SKalle Valo 6841d5c65159SKalle Valo if (ath11k_pull_peer_assoc_conf_ev(ab, skb, &peer_assoc_conf) != 0) { 6842d5c65159SKalle Valo ath11k_warn(ab, "failed to extract peer assoc conf event"); 6843d5c65159SKalle Valo return; 6844d5c65159SKalle Valo } 6845d5c65159SKalle Valo 6846d5c65159SKalle Valo ath11k_dbg(ab, ATH11K_DBG_WMI, 6847d5c65159SKalle Valo "peer assoc conf ev vdev id %d macaddr %pM\n", 6848d5c65159SKalle Valo peer_assoc_conf.vdev_id, peer_assoc_conf.macaddr); 6849d5c65159SKalle Valo 6850db0889abSKarthikeyan Periyasamy rcu_read_lock(); 6851d5c65159SKalle Valo ar = ath11k_mac_get_ar_by_vdev_id(ab, peer_assoc_conf.vdev_id); 6852d5c65159SKalle Valo 6853d5c65159SKalle Valo if (!ar) { 6854d5c65159SKalle Valo ath11k_warn(ab, "invalid vdev id in peer assoc conf ev %d", 6855d5c65159SKalle Valo peer_assoc_conf.vdev_id); 6856db0889abSKarthikeyan Periyasamy rcu_read_unlock(); 6857d5c65159SKalle Valo return; 6858d5c65159SKalle Valo } 6859d5c65159SKalle Valo 6860d5c65159SKalle Valo complete(&ar->peer_assoc_done); 6861db0889abSKarthikeyan Periyasamy rcu_read_unlock(); 6862d5c65159SKalle Valo } 6863d5c65159SKalle Valo 6864d5c65159SKalle Valo static void ath11k_update_stats_event(struct ath11k_base *ab, struct sk_buff *skb) 6865d5c65159SKalle Valo { 6866cb4e57dbSKalle Valo ath11k_debugfs_fw_stats_process(ab, skb); 6867d5c65159SKalle Valo } 6868d5c65159SKalle Valo 6869d5c65159SKalle Valo /* PDEV_CTL_FAILSAFE_CHECK_EVENT is received from FW when the frequency scanned 6870d5c65159SKalle Valo * is not part of BDF CTL(Conformance test limits) table entries. 6871d5c65159SKalle Valo */ 6872d5c65159SKalle Valo static void ath11k_pdev_ctl_failsafe_check_event(struct ath11k_base *ab, 6873d5c65159SKalle Valo struct sk_buff *skb) 6874d5c65159SKalle Valo { 6875d5c65159SKalle Valo const void **tb; 6876d5c65159SKalle Valo const struct wmi_pdev_ctl_failsafe_chk_event *ev; 6877d5c65159SKalle Valo int ret; 6878d5c65159SKalle Valo 6879d5c65159SKalle Valo tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC); 6880d5c65159SKalle Valo if (IS_ERR(tb)) { 6881d5c65159SKalle Valo ret = PTR_ERR(tb); 6882d5c65159SKalle Valo ath11k_warn(ab, "failed to parse tlv: %d\n", ret); 6883d5c65159SKalle Valo return; 6884d5c65159SKalle Valo } 6885d5c65159SKalle Valo 6886d5c65159SKalle Valo ev = tb[WMI_TAG_PDEV_CTL_FAILSAFE_CHECK_EVENT]; 6887d5c65159SKalle Valo if (!ev) { 6888d5c65159SKalle Valo ath11k_warn(ab, "failed to fetch pdev ctl failsafe check ev"); 6889d5c65159SKalle Valo kfree(tb); 6890d5c65159SKalle Valo return; 6891d5c65159SKalle Valo } 6892d5c65159SKalle Valo 6893d5c65159SKalle Valo ath11k_dbg(ab, ATH11K_DBG_WMI, 6894d5c65159SKalle Valo "pdev ctl failsafe check ev status %d\n", 6895d5c65159SKalle Valo ev->ctl_failsafe_status); 6896d5c65159SKalle Valo 6897d5c65159SKalle Valo /* If ctl_failsafe_status is set to 1 FW will max out the Transmit power 6898d5c65159SKalle Valo * to 10 dBm else the CTL power entry in the BDF would be picked up. 6899d5c65159SKalle Valo */ 6900d5c65159SKalle Valo if (ev->ctl_failsafe_status != 0) 6901d5c65159SKalle Valo ath11k_warn(ab, "pdev ctl failsafe failure status %d", 6902d5c65159SKalle Valo ev->ctl_failsafe_status); 6903d5c65159SKalle Valo 6904d5c65159SKalle Valo kfree(tb); 6905d5c65159SKalle Valo } 6906d5c65159SKalle Valo 6907d5c65159SKalle Valo static void 6908d5c65159SKalle Valo ath11k_wmi_process_csa_switch_count_event(struct ath11k_base *ab, 6909d5c65159SKalle Valo const struct wmi_pdev_csa_switch_ev *ev, 6910d5c65159SKalle Valo const u32 *vdev_ids) 6911d5c65159SKalle Valo { 6912d5c65159SKalle Valo int i; 6913d5c65159SKalle Valo struct ath11k_vif *arvif; 6914d5c65159SKalle Valo 6915d5c65159SKalle Valo /* Finish CSA once the switch count becomes NULL */ 6916d5c65159SKalle Valo if (ev->current_switch_count) 6917d5c65159SKalle Valo return; 6918d5c65159SKalle Valo 6919d5c65159SKalle Valo rcu_read_lock(); 6920d5c65159SKalle Valo for (i = 0; i < ev->num_vdevs; i++) { 6921d5c65159SKalle Valo arvif = ath11k_mac_get_arvif_by_vdev_id(ab, vdev_ids[i]); 6922d5c65159SKalle Valo 6923d5c65159SKalle Valo if (!arvif) { 6924d5c65159SKalle Valo ath11k_warn(ab, "Recvd csa status for unknown vdev %d", 6925d5c65159SKalle Valo vdev_ids[i]); 6926d5c65159SKalle Valo continue; 6927d5c65159SKalle Valo } 6928d5c65159SKalle Valo 6929d5c65159SKalle Valo if (arvif->is_up && arvif->vif->csa_active) 6930d5c65159SKalle Valo ieee80211_csa_finish(arvif->vif); 6931d5c65159SKalle Valo } 6932d5c65159SKalle Valo rcu_read_unlock(); 6933d5c65159SKalle Valo } 6934d5c65159SKalle Valo 6935d5c65159SKalle Valo static void 6936d5c65159SKalle Valo ath11k_wmi_pdev_csa_switch_count_status_event(struct ath11k_base *ab, 6937d5c65159SKalle Valo struct sk_buff *skb) 6938d5c65159SKalle Valo { 6939d5c65159SKalle Valo const void **tb; 6940d5c65159SKalle Valo const struct wmi_pdev_csa_switch_ev *ev; 6941d5c65159SKalle Valo const u32 *vdev_ids; 6942d5c65159SKalle Valo int ret; 6943d5c65159SKalle Valo 6944d5c65159SKalle Valo tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC); 6945d5c65159SKalle Valo if (IS_ERR(tb)) { 6946d5c65159SKalle Valo ret = PTR_ERR(tb); 6947d5c65159SKalle Valo ath11k_warn(ab, "failed to parse tlv: %d\n", ret); 6948d5c65159SKalle Valo return; 6949d5c65159SKalle Valo } 6950d5c65159SKalle Valo 6951d5c65159SKalle Valo ev = tb[WMI_TAG_PDEV_CSA_SWITCH_COUNT_STATUS_EVENT]; 6952d5c65159SKalle Valo vdev_ids = tb[WMI_TAG_ARRAY_UINT32]; 6953d5c65159SKalle Valo 6954d5c65159SKalle Valo if (!ev || !vdev_ids) { 6955d5c65159SKalle Valo ath11k_warn(ab, "failed to fetch pdev csa switch count ev"); 6956d5c65159SKalle Valo kfree(tb); 6957d5c65159SKalle Valo return; 6958d5c65159SKalle Valo } 6959d5c65159SKalle Valo 6960d5c65159SKalle Valo ath11k_dbg(ab, ATH11K_DBG_WMI, 6961d5c65159SKalle Valo "pdev csa switch count %d for pdev %d, num_vdevs %d", 6962d5c65159SKalle Valo ev->current_switch_count, ev->pdev_id, 6963d5c65159SKalle Valo ev->num_vdevs); 6964d5c65159SKalle Valo 6965d5c65159SKalle Valo ath11k_wmi_process_csa_switch_count_event(ab, ev, vdev_ids); 6966d5c65159SKalle Valo 6967d5c65159SKalle Valo kfree(tb); 6968d5c65159SKalle Valo } 6969d5c65159SKalle Valo 6970d5c65159SKalle Valo static void 6971d5c65159SKalle Valo ath11k_wmi_pdev_dfs_radar_detected_event(struct ath11k_base *ab, struct sk_buff *skb) 6972d5c65159SKalle Valo { 6973d5c65159SKalle Valo const void **tb; 6974d5c65159SKalle Valo const struct wmi_pdev_radar_ev *ev; 6975d5c65159SKalle Valo struct ath11k *ar; 6976d5c65159SKalle Valo int ret; 6977d5c65159SKalle Valo 6978d5c65159SKalle Valo tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC); 6979d5c65159SKalle Valo if (IS_ERR(tb)) { 6980d5c65159SKalle Valo ret = PTR_ERR(tb); 6981d5c65159SKalle Valo ath11k_warn(ab, "failed to parse tlv: %d\n", ret); 6982d5c65159SKalle Valo return; 6983d5c65159SKalle Valo } 6984d5c65159SKalle Valo 6985d5c65159SKalle Valo ev = tb[WMI_TAG_PDEV_DFS_RADAR_DETECTION_EVENT]; 6986d5c65159SKalle Valo 6987d5c65159SKalle Valo if (!ev) { 6988d5c65159SKalle Valo ath11k_warn(ab, "failed to fetch pdev dfs radar detected ev"); 6989d5c65159SKalle Valo kfree(tb); 6990d5c65159SKalle Valo return; 6991d5c65159SKalle Valo } 6992d5c65159SKalle Valo 6993d5c65159SKalle Valo ath11k_dbg(ab, ATH11K_DBG_WMI, 6994d5c65159SKalle Valo "pdev dfs radar detected on pdev %d, detection mode %d, chan freq %d, chan_width %d, detector id %d, seg id %d, timestamp %d, chirp %d, freq offset %d, sidx %d", 6995d5c65159SKalle Valo ev->pdev_id, ev->detection_mode, ev->chan_freq, ev->chan_width, 6996d5c65159SKalle Valo ev->detector_id, ev->segment_id, ev->timestamp, ev->is_chirp, 6997d5c65159SKalle Valo ev->freq_offset, ev->sidx); 6998d5c65159SKalle Valo 6999d5c65159SKalle Valo ar = ath11k_mac_get_ar_by_pdev_id(ab, ev->pdev_id); 7000d5c65159SKalle Valo 7001d5c65159SKalle Valo if (!ar) { 7002d5c65159SKalle Valo ath11k_warn(ab, "radar detected in invalid pdev %d\n", 7003d5c65159SKalle Valo ev->pdev_id); 7004d5c65159SKalle Valo goto exit; 7005d5c65159SKalle Valo } 7006d5c65159SKalle Valo 7007d5c65159SKalle Valo ath11k_dbg(ar->ab, ATH11K_DBG_REG, "DFS Radar Detected in pdev %d\n", 7008d5c65159SKalle Valo ev->pdev_id); 7009d5c65159SKalle Valo 7010d5c65159SKalle Valo if (ar->dfs_block_radar_events) 7011d5c65159SKalle Valo ath11k_info(ab, "DFS Radar detected, but ignored as requested\n"); 7012d5c65159SKalle Valo else 7013d5c65159SKalle Valo ieee80211_radar_detected(ar->hw); 7014d5c65159SKalle Valo 7015d5c65159SKalle Valo exit: 7016d5c65159SKalle Valo kfree(tb); 7017d5c65159SKalle Valo } 7018d5c65159SKalle Valo 7019a41d1034SPradeep Kumar Chitrapu static void 7020a41d1034SPradeep Kumar Chitrapu ath11k_wmi_pdev_temperature_event(struct ath11k_base *ab, 7021a41d1034SPradeep Kumar Chitrapu struct sk_buff *skb) 7022a41d1034SPradeep Kumar Chitrapu { 7023a41d1034SPradeep Kumar Chitrapu struct ath11k *ar; 7024e3de5bb7SPradeep Kumar Chitrapu const void **tb; 7025e3de5bb7SPradeep Kumar Chitrapu const struct wmi_pdev_temperature_event *ev; 7026e3de5bb7SPradeep Kumar Chitrapu int ret; 7027a41d1034SPradeep Kumar Chitrapu 7028e3de5bb7SPradeep Kumar Chitrapu tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC); 7029e3de5bb7SPradeep Kumar Chitrapu if (IS_ERR(tb)) { 7030e3de5bb7SPradeep Kumar Chitrapu ret = PTR_ERR(tb); 7031e3de5bb7SPradeep Kumar Chitrapu ath11k_warn(ab, "failed to parse tlv: %d\n", ret); 7032e3de5bb7SPradeep Kumar Chitrapu return; 7033e3de5bb7SPradeep Kumar Chitrapu } 7034e3de5bb7SPradeep Kumar Chitrapu 7035e3de5bb7SPradeep Kumar Chitrapu ev = tb[WMI_TAG_PDEV_TEMPERATURE_EVENT]; 7036e3de5bb7SPradeep Kumar Chitrapu if (!ev) { 7037e3de5bb7SPradeep Kumar Chitrapu ath11k_warn(ab, "failed to fetch pdev temp ev"); 7038e3de5bb7SPradeep Kumar Chitrapu kfree(tb); 7039a41d1034SPradeep Kumar Chitrapu return; 7040a41d1034SPradeep Kumar Chitrapu } 7041a41d1034SPradeep Kumar Chitrapu 7042a41d1034SPradeep Kumar Chitrapu ath11k_dbg(ab, ATH11K_DBG_WMI, 7043e3de5bb7SPradeep Kumar Chitrapu "pdev temperature ev temp %d pdev_id %d\n", ev->temp, ev->pdev_id); 7044a41d1034SPradeep Kumar Chitrapu 7045e3de5bb7SPradeep Kumar Chitrapu ar = ath11k_mac_get_ar_by_pdev_id(ab, ev->pdev_id); 7046a41d1034SPradeep Kumar Chitrapu if (!ar) { 7047e3de5bb7SPradeep Kumar Chitrapu ath11k_warn(ab, "invalid pdev id in pdev temperature ev %d", ev->pdev_id); 7048e3de5bb7SPradeep Kumar Chitrapu kfree(tb); 7049a41d1034SPradeep Kumar Chitrapu return; 7050a41d1034SPradeep Kumar Chitrapu } 7051a41d1034SPradeep Kumar Chitrapu 7052e3de5bb7SPradeep Kumar Chitrapu ath11k_thermal_event_temperature(ar, ev->temp); 7053e3de5bb7SPradeep Kumar Chitrapu 7054e3de5bb7SPradeep Kumar Chitrapu kfree(tb); 7055a41d1034SPradeep Kumar Chitrapu } 7056a41d1034SPradeep Kumar Chitrapu 7057047679e3SAloka Dixit static void ath11k_fils_discovery_event(struct ath11k_base *ab, 7058047679e3SAloka Dixit struct sk_buff *skb) 7059047679e3SAloka Dixit { 7060047679e3SAloka Dixit const void **tb; 7061047679e3SAloka Dixit const struct wmi_fils_discovery_event *ev; 7062047679e3SAloka Dixit int ret; 7063047679e3SAloka Dixit 7064047679e3SAloka Dixit tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC); 7065047679e3SAloka Dixit if (IS_ERR(tb)) { 7066047679e3SAloka Dixit ret = PTR_ERR(tb); 7067047679e3SAloka Dixit ath11k_warn(ab, 7068047679e3SAloka Dixit "failed to parse FILS discovery event tlv %d\n", 7069047679e3SAloka Dixit ret); 7070047679e3SAloka Dixit return; 7071047679e3SAloka Dixit } 7072047679e3SAloka Dixit 7073047679e3SAloka Dixit ev = tb[WMI_TAG_HOST_SWFDA_EVENT]; 7074047679e3SAloka Dixit if (!ev) { 7075047679e3SAloka Dixit ath11k_warn(ab, "failed to fetch FILS discovery event\n"); 7076047679e3SAloka Dixit kfree(tb); 7077047679e3SAloka Dixit return; 7078047679e3SAloka Dixit } 7079047679e3SAloka Dixit 7080047679e3SAloka Dixit ath11k_warn(ab, 7081047679e3SAloka Dixit "FILS discovery frame expected from host for vdev_id: %u, transmission scheduled at %u, next TBTT: %u\n", 7082047679e3SAloka Dixit ev->vdev_id, ev->fils_tt, ev->tbtt); 7083047679e3SAloka Dixit 7084047679e3SAloka Dixit kfree(tb); 7085047679e3SAloka Dixit } 7086047679e3SAloka Dixit 7087047679e3SAloka Dixit static void ath11k_probe_resp_tx_status_event(struct ath11k_base *ab, 7088047679e3SAloka Dixit struct sk_buff *skb) 7089047679e3SAloka Dixit { 7090047679e3SAloka Dixit const void **tb; 7091047679e3SAloka Dixit const struct wmi_probe_resp_tx_status_event *ev; 7092047679e3SAloka Dixit int ret; 7093047679e3SAloka Dixit 7094047679e3SAloka Dixit tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC); 7095047679e3SAloka Dixit if (IS_ERR(tb)) { 7096047679e3SAloka Dixit ret = PTR_ERR(tb); 7097047679e3SAloka Dixit ath11k_warn(ab, 7098047679e3SAloka Dixit "failed to parse probe response transmission status event tlv: %d\n", 7099047679e3SAloka Dixit ret); 7100047679e3SAloka Dixit return; 7101047679e3SAloka Dixit } 7102047679e3SAloka Dixit 7103047679e3SAloka Dixit ev = tb[WMI_TAG_OFFLOAD_PRB_RSP_TX_STATUS_EVENT]; 7104047679e3SAloka Dixit if (!ev) { 7105047679e3SAloka Dixit ath11k_warn(ab, 7106047679e3SAloka Dixit "failed to fetch probe response transmission status event"); 7107047679e3SAloka Dixit kfree(tb); 7108047679e3SAloka Dixit return; 7109047679e3SAloka Dixit } 7110047679e3SAloka Dixit 7111047679e3SAloka Dixit if (ev->tx_status) 7112047679e3SAloka Dixit ath11k_warn(ab, 7113047679e3SAloka Dixit "Probe response transmission failed for vdev_id %u, status %u\n", 7114047679e3SAloka Dixit ev->vdev_id, ev->tx_status); 7115047679e3SAloka Dixit 7116047679e3SAloka Dixit kfree(tb); 7117047679e3SAloka Dixit } 7118047679e3SAloka Dixit 711979802b13SCarl Huang static int ath11k_wmi_tlv_wow_wakeup_host_parse(struct ath11k_base *ab, 712079802b13SCarl Huang u16 tag, u16 len, 712179802b13SCarl Huang const void *ptr, void *data) 712279802b13SCarl Huang { 712379802b13SCarl Huang struct wmi_wow_ev_arg *ev = data; 712479802b13SCarl Huang const char *wow_pg_fault; 712579802b13SCarl Huang int wow_pg_len; 712679802b13SCarl Huang 712779802b13SCarl Huang switch (tag) { 712879802b13SCarl Huang case WMI_TAG_WOW_EVENT_INFO: 712979802b13SCarl Huang memcpy(ev, ptr, sizeof(*ev)); 713079802b13SCarl Huang ath11k_dbg(ab, ATH11K_DBG_WMI, "wow wakeup host reason %d %s\n", 713179802b13SCarl Huang ev->wake_reason, wow_reason(ev->wake_reason)); 713279802b13SCarl Huang break; 713379802b13SCarl Huang 713479802b13SCarl Huang case WMI_TAG_ARRAY_BYTE: 713579802b13SCarl Huang if (ev && ev->wake_reason == WOW_REASON_PAGE_FAULT) { 713679802b13SCarl Huang wow_pg_fault = ptr; 713779802b13SCarl Huang /* the first 4 bytes are length */ 713879802b13SCarl Huang wow_pg_len = *(int *)wow_pg_fault; 713979802b13SCarl Huang wow_pg_fault += sizeof(int); 714079802b13SCarl Huang ath11k_dbg(ab, ATH11K_DBG_WMI, "wow data_len = %d\n", 714179802b13SCarl Huang wow_pg_len); 714279802b13SCarl Huang ath11k_dbg_dump(ab, ATH11K_DBG_WMI, 714379802b13SCarl Huang "wow_event_info_type packet present", 714479802b13SCarl Huang "wow_pg_fault ", 714579802b13SCarl Huang wow_pg_fault, 714679802b13SCarl Huang wow_pg_len); 714779802b13SCarl Huang } 714879802b13SCarl Huang break; 714979802b13SCarl Huang default: 715079802b13SCarl Huang break; 715179802b13SCarl Huang } 715279802b13SCarl Huang 715379802b13SCarl Huang return 0; 715479802b13SCarl Huang } 715579802b13SCarl Huang 715679802b13SCarl Huang static void ath11k_wmi_event_wow_wakeup_host(struct ath11k_base *ab, struct sk_buff *skb) 715779802b13SCarl Huang { 715879802b13SCarl Huang struct wmi_wow_ev_arg ev = { }; 715979802b13SCarl Huang int ret; 716079802b13SCarl Huang 716179802b13SCarl Huang ret = ath11k_wmi_tlv_iter(ab, skb->data, skb->len, 716279802b13SCarl Huang ath11k_wmi_tlv_wow_wakeup_host_parse, 716379802b13SCarl Huang &ev); 716479802b13SCarl Huang if (ret) { 716579802b13SCarl Huang ath11k_warn(ab, "failed to parse wmi wow tlv: %d\n", ret); 716679802b13SCarl Huang return; 716779802b13SCarl Huang } 716879802b13SCarl Huang 716979802b13SCarl Huang complete(&ab->wow.wakeup_completed); 717079802b13SCarl Huang } 717179802b13SCarl Huang 7172d5c65159SKalle Valo static void ath11k_wmi_tlv_op_rx(struct ath11k_base *ab, struct sk_buff *skb) 7173d5c65159SKalle Valo { 7174d5c65159SKalle Valo struct wmi_cmd_hdr *cmd_hdr; 7175d5c65159SKalle Valo enum wmi_tlv_event_id id; 7176d5c65159SKalle Valo 7177d5c65159SKalle Valo cmd_hdr = (struct wmi_cmd_hdr *)skb->data; 7178d5c65159SKalle Valo id = FIELD_GET(WMI_CMD_HDR_CMD_ID, (cmd_hdr->cmd_id)); 7179d5c65159SKalle Valo 7180fb12305aSVenkateswara Naralasetty trace_ath11k_wmi_event(ab, id, skb->data, skb->len); 7181fb12305aSVenkateswara Naralasetty 7182d5c65159SKalle Valo if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL) 7183d5c65159SKalle Valo goto out; 7184d5c65159SKalle Valo 7185d5c65159SKalle Valo switch (id) { 7186d5c65159SKalle Valo /* Process all the WMI events here */ 7187d5c65159SKalle Valo case WMI_SERVICE_READY_EVENTID: 7188d5c65159SKalle Valo ath11k_service_ready_event(ab, skb); 7189d5c65159SKalle Valo break; 7190d5c65159SKalle Valo case WMI_SERVICE_READY_EXT_EVENTID: 7191d5c65159SKalle Valo ath11k_service_ready_ext_event(ab, skb); 7192d5c65159SKalle Valo break; 7193bd647855SKarthikeyan Periyasamy case WMI_SERVICE_READY_EXT2_EVENTID: 7194bd647855SKarthikeyan Periyasamy ath11k_service_ready_ext2_event(ab, skb); 7195bd647855SKarthikeyan Periyasamy break; 7196d5c65159SKalle Valo case WMI_REG_CHAN_LIST_CC_EVENTID: 7197d5c65159SKalle Valo ath11k_reg_chan_list_event(ab, skb); 7198d5c65159SKalle Valo break; 7199d5c65159SKalle Valo case WMI_READY_EVENTID: 7200d5c65159SKalle Valo ath11k_ready_event(ab, skb); 7201d5c65159SKalle Valo break; 7202d5c65159SKalle Valo case WMI_PEER_DELETE_RESP_EVENTID: 7203d5c65159SKalle Valo ath11k_peer_delete_resp_event(ab, skb); 7204d5c65159SKalle Valo break; 7205d5c65159SKalle Valo case WMI_VDEV_START_RESP_EVENTID: 7206d5c65159SKalle Valo ath11k_vdev_start_resp_event(ab, skb); 7207d5c65159SKalle Valo break; 7208d5c65159SKalle Valo case WMI_OFFLOAD_BCN_TX_STATUS_EVENTID: 7209d5c65159SKalle Valo ath11k_bcn_tx_status_event(ab, skb); 7210d5c65159SKalle Valo break; 7211d5c65159SKalle Valo case WMI_VDEV_STOPPED_EVENTID: 7212d5c65159SKalle Valo ath11k_vdev_stopped_event(ab, skb); 7213d5c65159SKalle Valo break; 7214d5c65159SKalle Valo case WMI_MGMT_RX_EVENTID: 7215d5c65159SKalle Valo ath11k_mgmt_rx_event(ab, skb); 7216d5c65159SKalle Valo /* mgmt_rx_event() owns the skb now! */ 7217d5c65159SKalle Valo return; 7218d5c65159SKalle Valo case WMI_MGMT_TX_COMPLETION_EVENTID: 7219d5c65159SKalle Valo ath11k_mgmt_tx_compl_event(ab, skb); 7220d5c65159SKalle Valo break; 7221d5c65159SKalle Valo case WMI_SCAN_EVENTID: 7222d5c65159SKalle Valo ath11k_scan_event(ab, skb); 7223d5c65159SKalle Valo break; 7224d5c65159SKalle Valo case WMI_PEER_STA_KICKOUT_EVENTID: 7225d5c65159SKalle Valo ath11k_peer_sta_kickout_event(ab, skb); 7226d5c65159SKalle Valo break; 7227d5c65159SKalle Valo case WMI_ROAM_EVENTID: 7228d5c65159SKalle Valo ath11k_roam_event(ab, skb); 7229d5c65159SKalle Valo break; 7230d5c65159SKalle Valo case WMI_CHAN_INFO_EVENTID: 7231d5c65159SKalle Valo ath11k_chan_info_event(ab, skb); 7232d5c65159SKalle Valo break; 7233d5c65159SKalle Valo case WMI_PDEV_BSS_CHAN_INFO_EVENTID: 7234d5c65159SKalle Valo ath11k_pdev_bss_chan_info_event(ab, skb); 7235d5c65159SKalle Valo break; 7236d5c65159SKalle Valo case WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID: 7237d5c65159SKalle Valo ath11k_vdev_install_key_compl_event(ab, skb); 7238d5c65159SKalle Valo break; 7239d5c65159SKalle Valo case WMI_SERVICE_AVAILABLE_EVENTID: 7240d5c65159SKalle Valo ath11k_service_available_event(ab, skb); 7241d5c65159SKalle Valo break; 7242d5c65159SKalle Valo case WMI_PEER_ASSOC_CONF_EVENTID: 7243d5c65159SKalle Valo ath11k_peer_assoc_conf_event(ab, skb); 7244d5c65159SKalle Valo break; 7245d5c65159SKalle Valo case WMI_UPDATE_STATS_EVENTID: 7246d5c65159SKalle Valo ath11k_update_stats_event(ab, skb); 7247d5c65159SKalle Valo break; 7248d5c65159SKalle Valo case WMI_PDEV_CTL_FAILSAFE_CHECK_EVENTID: 7249d5c65159SKalle Valo ath11k_pdev_ctl_failsafe_check_event(ab, skb); 7250d5c65159SKalle Valo break; 7251d5c65159SKalle Valo case WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID: 7252d5c65159SKalle Valo ath11k_wmi_pdev_csa_switch_count_status_event(ab, skb); 7253d5c65159SKalle Valo break; 7254a41d1034SPradeep Kumar Chitrapu case WMI_PDEV_TEMPERATURE_EVENTID: 7255a41d1034SPradeep Kumar Chitrapu ath11k_wmi_pdev_temperature_event(ab, skb); 7256a41d1034SPradeep Kumar Chitrapu break; 72579d11b7bfSKarthikeyan Periyasamy case WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID: 72589d11b7bfSKarthikeyan Periyasamy ath11k_wmi_pdev_dma_ring_buf_release_event(ab, skb); 72599d11b7bfSKarthikeyan Periyasamy break; 7260047679e3SAloka Dixit case WMI_HOST_FILS_DISCOVERY_EVENTID: 7261047679e3SAloka Dixit ath11k_fils_discovery_event(ab, skb); 7262047679e3SAloka Dixit break; 7263047679e3SAloka Dixit case WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID: 7264047679e3SAloka Dixit ath11k_probe_resp_tx_status_event(ab, skb); 7265047679e3SAloka Dixit break; 7266886433a9SJohn Crispin case WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID: 7267886433a9SJohn Crispin ath11k_wmi_obss_color_collision_event(ab, skb); 7268886433a9SJohn Crispin break; 7269d5c65159SKalle Valo /* add Unsupported events here */ 7270d5c65159SKalle Valo case WMI_TBTTOFFSET_EXT_UPDATE_EVENTID: 72719cfbae46SJohn Crispin case WMI_PEER_OPER_MODE_CHANGE_EVENTID: 72726d293d44SJohn Crispin case WMI_TWT_ENABLE_EVENTID: 72736d293d44SJohn Crispin case WMI_TWT_DISABLE_EVENTID: 72749d11b7bfSKarthikeyan Periyasamy case WMI_PDEV_DMA_RING_CFG_RSP_EVENTID: 727594a6df31SP Praneesh case WMI_PEER_CREATE_CONF_EVENTID: 7276d5c65159SKalle Valo ath11k_dbg(ab, ATH11K_DBG_WMI, 7277d5c65159SKalle Valo "ignoring unsupported event 0x%x\n", id); 7278d5c65159SKalle Valo break; 7279d5c65159SKalle Valo case WMI_PDEV_DFS_RADAR_DETECTION_EVENTID: 7280d5c65159SKalle Valo ath11k_wmi_pdev_dfs_radar_detected_event(ab, skb); 7281d5c65159SKalle Valo break; 72823cbbdfbeSRitesh Singh case WMI_VDEV_DELETE_RESP_EVENTID: 72833cbbdfbeSRitesh Singh ath11k_vdev_delete_resp_event(ab, skb); 72843cbbdfbeSRitesh Singh break; 728579802b13SCarl Huang case WMI_WOW_WAKEUP_HOST_EVENTID: 728679802b13SCarl Huang ath11k_wmi_event_wow_wakeup_host(ab, skb); 728779802b13SCarl Huang break; 7288d5c65159SKalle Valo /* TODO: Add remaining events */ 7289d5c65159SKalle Valo default: 729082b4f9b8SGovind Singh ath11k_dbg(ab, ATH11K_DBG_WMI, "Unknown eventid: 0x%x\n", id); 7291d5c65159SKalle Valo break; 7292d5c65159SKalle Valo } 7293d5c65159SKalle Valo 7294d5c65159SKalle Valo out: 7295d5c65159SKalle Valo dev_kfree_skb(skb); 7296d5c65159SKalle Valo } 7297d5c65159SKalle Valo 7298d5c65159SKalle Valo static int ath11k_connect_pdev_htc_service(struct ath11k_base *ab, 7299d5c65159SKalle Valo u32 pdev_idx) 7300d5c65159SKalle Valo { 7301d5c65159SKalle Valo int status; 7302d5c65159SKalle Valo u32 svc_id[] = { ATH11K_HTC_SVC_ID_WMI_CONTROL, 7303d5c65159SKalle Valo ATH11K_HTC_SVC_ID_WMI_CONTROL_MAC1, 7304d5c65159SKalle Valo ATH11K_HTC_SVC_ID_WMI_CONTROL_MAC2 }; 7305d5c65159SKalle Valo 7306d5c65159SKalle Valo struct ath11k_htc_svc_conn_req conn_req; 7307d5c65159SKalle Valo struct ath11k_htc_svc_conn_resp conn_resp; 7308d5c65159SKalle Valo 7309d5c65159SKalle Valo memset(&conn_req, 0, sizeof(conn_req)); 7310d5c65159SKalle Valo memset(&conn_resp, 0, sizeof(conn_resp)); 7311d5c65159SKalle Valo 7312d5c65159SKalle Valo /* these fields are the same for all service endpoints */ 7313d5c65159SKalle Valo conn_req.ep_ops.ep_tx_complete = ath11k_wmi_htc_tx_complete; 7314d5c65159SKalle Valo conn_req.ep_ops.ep_rx_complete = ath11k_wmi_tlv_op_rx; 7315d5c65159SKalle Valo conn_req.ep_ops.ep_tx_credits = ath11k_wmi_op_ep_tx_credits; 7316d5c65159SKalle Valo 7317d5c65159SKalle Valo /* connect to control service */ 7318d5c65159SKalle Valo conn_req.service_id = svc_id[pdev_idx]; 7319d5c65159SKalle Valo 7320d5c65159SKalle Valo status = ath11k_htc_connect_service(&ab->htc, &conn_req, &conn_resp); 7321d5c65159SKalle Valo if (status) { 7322d5c65159SKalle Valo ath11k_warn(ab, "failed to connect to WMI CONTROL service status: %d\n", 7323d5c65159SKalle Valo status); 7324d5c65159SKalle Valo return status; 7325d5c65159SKalle Valo } 7326d5c65159SKalle Valo 73276bc9d6f7SJohn Crispin ab->wmi_ab.wmi_endpoint_id[pdev_idx] = conn_resp.eid; 73286bc9d6f7SJohn Crispin ab->wmi_ab.wmi[pdev_idx].eid = conn_resp.eid; 73296bc9d6f7SJohn Crispin ab->wmi_ab.max_msg_len[pdev_idx] = conn_resp.max_msg_len; 7330f951380aSP Praneesh init_waitqueue_head(&ab->wmi_ab.wmi[pdev_idx].tx_ce_desc_wq); 7331d5c65159SKalle Valo 7332d5c65159SKalle Valo return 0; 7333d5c65159SKalle Valo } 7334d5c65159SKalle Valo 7335d5c65159SKalle Valo static int 7336d5c65159SKalle Valo ath11k_wmi_send_unit_test_cmd(struct ath11k *ar, 7337d5c65159SKalle Valo struct wmi_unit_test_cmd ut_cmd, 7338d5c65159SKalle Valo u32 *test_args) 7339d5c65159SKalle Valo { 7340d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi = ar->wmi; 7341d5c65159SKalle Valo struct wmi_unit_test_cmd *cmd; 7342d5c65159SKalle Valo struct sk_buff *skb; 7343d5c65159SKalle Valo struct wmi_tlv *tlv; 7344d5c65159SKalle Valo void *ptr; 7345d5c65159SKalle Valo u32 *ut_cmd_args; 7346d5c65159SKalle Valo int buf_len, arg_len; 7347d5c65159SKalle Valo int ret; 7348d5c65159SKalle Valo int i; 7349d5c65159SKalle Valo 7350d5c65159SKalle Valo arg_len = sizeof(u32) * ut_cmd.num_args; 7351d5c65159SKalle Valo buf_len = sizeof(ut_cmd) + arg_len + TLV_HDR_SIZE; 7352d5c65159SKalle Valo 73536bc9d6f7SJohn Crispin skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, buf_len); 7354d5c65159SKalle Valo if (!skb) 7355d5c65159SKalle Valo return -ENOMEM; 7356d5c65159SKalle Valo 7357d5c65159SKalle Valo cmd = (struct wmi_unit_test_cmd *)skb->data; 7358d5c65159SKalle Valo cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_UNIT_TEST_CMD) | 7359d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, sizeof(ut_cmd) - TLV_HDR_SIZE); 7360d5c65159SKalle Valo 7361d5c65159SKalle Valo cmd->vdev_id = ut_cmd.vdev_id; 7362d5c65159SKalle Valo cmd->module_id = ut_cmd.module_id; 7363d5c65159SKalle Valo cmd->num_args = ut_cmd.num_args; 7364d5c65159SKalle Valo cmd->diag_token = ut_cmd.diag_token; 7365d5c65159SKalle Valo 7366d5c65159SKalle Valo ptr = skb->data + sizeof(ut_cmd); 7367d5c65159SKalle Valo 7368d5c65159SKalle Valo tlv = ptr; 7369d5c65159SKalle Valo tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_UINT32) | 7370d5c65159SKalle Valo FIELD_PREP(WMI_TLV_LEN, arg_len); 7371d5c65159SKalle Valo 7372d5c65159SKalle Valo ptr += TLV_HDR_SIZE; 7373d5c65159SKalle Valo 7374d5c65159SKalle Valo ut_cmd_args = ptr; 7375d5c65159SKalle Valo for (i = 0; i < ut_cmd.num_args; i++) 7376d5c65159SKalle Valo ut_cmd_args[i] = test_args[i]; 7377d5c65159SKalle Valo 7378d5c65159SKalle Valo ret = ath11k_wmi_cmd_send(wmi, skb, WMI_UNIT_TEST_CMDID); 7379d5c65159SKalle Valo 7380d5c65159SKalle Valo if (ret) { 7381d5c65159SKalle Valo ath11k_warn(ar->ab, "failed to send WMI_UNIT_TEST CMD :%d\n", 7382d5c65159SKalle Valo ret); 7383d5c65159SKalle Valo dev_kfree_skb(skb); 7384d5c65159SKalle Valo } 7385d5c65159SKalle Valo 7386d5c65159SKalle Valo ath11k_dbg(ar->ab, ATH11K_DBG_WMI, 7387d5c65159SKalle Valo "WMI unit test : module %d vdev %d n_args %d token %d\n", 7388d5c65159SKalle Valo cmd->module_id, cmd->vdev_id, cmd->num_args, 7389d5c65159SKalle Valo cmd->diag_token); 7390d5c65159SKalle Valo 7391d5c65159SKalle Valo return ret; 7392d5c65159SKalle Valo } 7393d5c65159SKalle Valo 7394d5c65159SKalle Valo int ath11k_wmi_simulate_radar(struct ath11k *ar) 7395d5c65159SKalle Valo { 7396d5c65159SKalle Valo struct ath11k_vif *arvif; 7397d5c65159SKalle Valo u32 dfs_args[DFS_MAX_TEST_ARGS]; 7398d5c65159SKalle Valo struct wmi_unit_test_cmd wmi_ut; 7399d5c65159SKalle Valo bool arvif_found = false; 7400d5c65159SKalle Valo 7401d5c65159SKalle Valo list_for_each_entry(arvif, &ar->arvifs, list) { 7402d5c65159SKalle Valo if (arvif->is_started && arvif->vdev_type == WMI_VDEV_TYPE_AP) { 7403d5c65159SKalle Valo arvif_found = true; 7404d5c65159SKalle Valo break; 7405d5c65159SKalle Valo } 7406d5c65159SKalle Valo } 7407d5c65159SKalle Valo 7408d5c65159SKalle Valo if (!arvif_found) 7409d5c65159SKalle Valo return -EINVAL; 7410d5c65159SKalle Valo 7411d5c65159SKalle Valo dfs_args[DFS_TEST_CMDID] = 0; 7412d5c65159SKalle Valo dfs_args[DFS_TEST_PDEV_ID] = ar->pdev->pdev_id; 7413d5c65159SKalle Valo /* Currently we could pass segment_id(b0 - b1), chirp(b2) 7414d5c65159SKalle Valo * freq offset (b3 - b10) to unit test. For simulation 7415d5c65159SKalle Valo * purpose this can be set to 0 which is valid. 7416d5c65159SKalle Valo */ 7417d5c65159SKalle Valo dfs_args[DFS_TEST_RADAR_PARAM] = 0; 7418d5c65159SKalle Valo 7419d5c65159SKalle Valo wmi_ut.vdev_id = arvif->vdev_id; 7420d5c65159SKalle Valo wmi_ut.module_id = DFS_UNIT_TEST_MODULE; 7421d5c65159SKalle Valo wmi_ut.num_args = DFS_MAX_TEST_ARGS; 7422d5c65159SKalle Valo wmi_ut.diag_token = DFS_UNIT_TEST_TOKEN; 7423d5c65159SKalle Valo 7424d5c65159SKalle Valo ath11k_dbg(ar->ab, ATH11K_DBG_REG, "Triggering Radar Simulation\n"); 7425d5c65159SKalle Valo 7426d5c65159SKalle Valo return ath11k_wmi_send_unit_test_cmd(ar, wmi_ut, dfs_args); 7427d5c65159SKalle Valo } 7428d5c65159SKalle Valo 7429d5c65159SKalle Valo int ath11k_wmi_connect(struct ath11k_base *ab) 7430d5c65159SKalle Valo { 7431d5c65159SKalle Valo u32 i; 7432d5c65159SKalle Valo u8 wmi_ep_count; 7433d5c65159SKalle Valo 7434d5c65159SKalle Valo wmi_ep_count = ab->htc.wmi_ep_count; 7435b1cc29e9SAnilkumar Kolli if (wmi_ep_count > ab->hw_params.max_radios) 7436d5c65159SKalle Valo return -1; 7437d5c65159SKalle Valo 7438d5c65159SKalle Valo for (i = 0; i < wmi_ep_count; i++) 7439d5c65159SKalle Valo ath11k_connect_pdev_htc_service(ab, i); 7440d5c65159SKalle Valo 7441d5c65159SKalle Valo return 0; 7442d5c65159SKalle Valo } 7443d5c65159SKalle Valo 7444d5c65159SKalle Valo static void ath11k_wmi_pdev_detach(struct ath11k_base *ab, u8 pdev_id) 7445d5c65159SKalle Valo { 7446d5c65159SKalle Valo if (WARN_ON(pdev_id >= MAX_RADIOS)) 7447d5c65159SKalle Valo return; 7448d5c65159SKalle Valo 7449d5c65159SKalle Valo /* TODO: Deinit any pdev specific wmi resource */ 7450d5c65159SKalle Valo } 7451d5c65159SKalle Valo 7452d5c65159SKalle Valo int ath11k_wmi_pdev_attach(struct ath11k_base *ab, 7453d5c65159SKalle Valo u8 pdev_id) 7454d5c65159SKalle Valo { 7455d5c65159SKalle Valo struct ath11k_pdev_wmi *wmi_handle; 7456d5c65159SKalle Valo 7457b1cc29e9SAnilkumar Kolli if (pdev_id >= ab->hw_params.max_radios) 7458d5c65159SKalle Valo return -EINVAL; 7459d5c65159SKalle Valo 74606bc9d6f7SJohn Crispin wmi_handle = &ab->wmi_ab.wmi[pdev_id]; 7461d5c65159SKalle Valo 74626bc9d6f7SJohn Crispin wmi_handle->wmi_ab = &ab->wmi_ab; 7463d5c65159SKalle Valo 74646bc9d6f7SJohn Crispin ab->wmi_ab.ab = ab; 7465d5c65159SKalle Valo /* TODO: Init remaining resource specific to pdev */ 7466d5c65159SKalle Valo 7467d5c65159SKalle Valo return 0; 7468d5c65159SKalle Valo } 7469d5c65159SKalle Valo 7470d5c65159SKalle Valo int ath11k_wmi_attach(struct ath11k_base *ab) 7471d5c65159SKalle Valo { 7472d5c65159SKalle Valo int ret; 7473d5c65159SKalle Valo 7474d5c65159SKalle Valo ret = ath11k_wmi_pdev_attach(ab, 0); 7475d5c65159SKalle Valo if (ret) 7476d5c65159SKalle Valo return ret; 7477d5c65159SKalle Valo 74786bc9d6f7SJohn Crispin ab->wmi_ab.ab = ab; 74796bc9d6f7SJohn Crispin ab->wmi_ab.preferred_hw_mode = WMI_HOST_HW_MODE_MAX; 7480d5c65159SKalle Valo 74815f859bc0SCarl Huang /* It's overwritten when service_ext_ready is handled */ 74825f859bc0SCarl Huang if (ab->hw_params.single_pdev_only) 74835f859bc0SCarl Huang ab->wmi_ab.preferred_hw_mode = WMI_HOST_HW_MODE_SINGLE; 74845f859bc0SCarl Huang 7485d5c65159SKalle Valo /* TODO: Init remaining wmi soc resources required */ 74866bc9d6f7SJohn Crispin init_completion(&ab->wmi_ab.service_ready); 74876bc9d6f7SJohn Crispin init_completion(&ab->wmi_ab.unified_ready); 7488d5c65159SKalle Valo 7489d5c65159SKalle Valo return 0; 7490d5c65159SKalle Valo } 7491d5c65159SKalle Valo 7492d5c65159SKalle Valo void ath11k_wmi_detach(struct ath11k_base *ab) 7493d5c65159SKalle Valo { 7494d5c65159SKalle Valo int i; 7495d5c65159SKalle Valo 7496d5c65159SKalle Valo /* TODO: Deinit wmi resource specific to SOC as required */ 7497d5c65159SKalle Valo 7498d5c65159SKalle Valo for (i = 0; i < ab->htc.wmi_ep_count; i++) 7499d5c65159SKalle Valo ath11k_wmi_pdev_detach(ab, i); 7500bd647855SKarthikeyan Periyasamy 7501bd647855SKarthikeyan Periyasamy ath11k_wmi_free_dbring_caps(ab); 7502d5c65159SKalle Valo } 750379802b13SCarl Huang 750479802b13SCarl Huang int ath11k_wmi_wow_host_wakeup_ind(struct ath11k *ar) 750579802b13SCarl Huang { 750679802b13SCarl Huang struct wmi_wow_host_wakeup_ind *cmd; 750779802b13SCarl Huang struct sk_buff *skb; 750879802b13SCarl Huang size_t len; 750979802b13SCarl Huang 751079802b13SCarl Huang len = sizeof(*cmd); 751179802b13SCarl Huang skb = ath11k_wmi_alloc_skb(ar->wmi->wmi_ab, len); 751279802b13SCarl Huang if (!skb) 751379802b13SCarl Huang return -ENOMEM; 751479802b13SCarl Huang 751579802b13SCarl Huang cmd = (struct wmi_wow_host_wakeup_ind *)skb->data; 751679802b13SCarl Huang cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, 751779802b13SCarl Huang WMI_TAG_WOW_HOSTWAKEUP_FROM_SLEEP_CMD) | 751879802b13SCarl Huang FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 751979802b13SCarl Huang 752079802b13SCarl Huang ath11k_dbg(ar->ab, ATH11K_DBG_WMI, "wmi tlv wow host wakeup ind\n"); 752179802b13SCarl Huang 752279802b13SCarl Huang return ath11k_wmi_cmd_send(ar->wmi, skb, WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID); 752379802b13SCarl Huang } 752479802b13SCarl Huang 752579802b13SCarl Huang int ath11k_wmi_wow_enable(struct ath11k *ar) 752679802b13SCarl Huang { 752779802b13SCarl Huang struct wmi_wow_enable_cmd *cmd; 752879802b13SCarl Huang struct sk_buff *skb; 752979802b13SCarl Huang int len; 753079802b13SCarl Huang 753179802b13SCarl Huang len = sizeof(*cmd); 753279802b13SCarl Huang skb = ath11k_wmi_alloc_skb(ar->wmi->wmi_ab, len); 753379802b13SCarl Huang if (!skb) 753479802b13SCarl Huang return -ENOMEM; 753579802b13SCarl Huang 753679802b13SCarl Huang cmd = (struct wmi_wow_enable_cmd *)skb->data; 753779802b13SCarl Huang cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_WOW_ENABLE_CMD) | 753879802b13SCarl Huang FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); 753979802b13SCarl Huang 754079802b13SCarl Huang cmd->enable = 1; 754179802b13SCarl Huang cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED; 754279802b13SCarl Huang ath11k_dbg(ar->ab, ATH11K_DBG_WMI, "wmi tlv wow enable\n"); 754379802b13SCarl Huang 754479802b13SCarl Huang return ath11k_wmi_cmd_send(ar->wmi, skb, WMI_WOW_ENABLE_CMDID); 754579802b13SCarl Huang } 7546