blob: 5ae2ef4680d6cb59aebded8974d978edea223f68 [file] [log] [blame]
// SPDX-License-Identifier: BSD-3-Clause-Clear
/*
* Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
*/
#include <linux/skbuff.h>
#include <linux/ctype.h>
#include <net/mac80211.h>
#include <net/cfg80211.h>
#include <linux/completion.h>
#include <linux/if_ether.h>
#include <linux/types.h>
#include <linux/pci.h>
#include <linux/uuid.h>
#include <linux/time.h>
#include <linux/of.h>
#include "core.h"
#include "debug.h"
#include "mac.h"
#include "hw.h"
#include "peer.h"
struct wmi_tlv_policy {
size_t min_len;
};
struct wmi_tlv_svc_ready_parse {
bool wmi_svc_bitmap_done;
};
struct wmi_tlv_dma_ring_caps_parse {
struct wmi_dma_ring_capabilities *dma_ring_caps;
u32 n_dma_ring_caps;
};
struct wmi_tlv_svc_rdy_ext_parse {
struct ath11k_service_ext_param param;
struct wmi_soc_mac_phy_hw_mode_caps *hw_caps;
struct wmi_hw_mode_capabilities *hw_mode_caps;
u32 n_hw_mode_caps;
u32 tot_phy_id;
struct wmi_hw_mode_capabilities pref_hw_mode_caps;
struct wmi_mac_phy_capabilities *mac_phy_caps;
u32 n_mac_phy_caps;
struct wmi_soc_hal_reg_capabilities *soc_hal_reg_caps;
struct wmi_hal_reg_capabilities_ext *ext_hal_reg_caps;
u32 n_ext_hal_reg_caps;
struct wmi_tlv_dma_ring_caps_parse dma_caps_parse;
bool hw_mode_done;
bool mac_phy_done;
bool ext_hal_reg_done;
bool mac_phy_chainmask_combo_done;
bool mac_phy_chainmask_cap_done;
bool oem_dma_ring_cap_done;
bool dma_ring_cap_done;
};
struct wmi_tlv_svc_rdy_ext2_parse {
struct wmi_tlv_dma_ring_caps_parse dma_caps_parse;
bool dma_ring_cap_done;
};
struct wmi_tlv_rdy_parse {
u32 num_extra_mac_addr;
};
struct wmi_tlv_dma_buf_release_parse {
struct ath11k_wmi_dma_buf_release_fixed_param fixed;
struct wmi_dma_buf_release_entry *buf_entry;
struct wmi_dma_buf_release_meta_data *meta_data;
u32 num_buf_entry;
u32 num_meta;
bool buf_entry_done;
bool meta_data_done;
};
static const struct wmi_tlv_policy wmi_tlv_policies[] = {
[WMI_TAG_ARRAY_BYTE]
= { .min_len = 0 },
[WMI_TAG_ARRAY_UINT32]
= { .min_len = 0 },
[WMI_TAG_SERVICE_READY_EVENT]
= { .min_len = sizeof(struct wmi_service_ready_event) },
[WMI_TAG_SERVICE_READY_EXT_EVENT]
= { .min_len = sizeof(struct wmi_service_ready_ext_event) },
[WMI_TAG_SOC_MAC_PHY_HW_MODE_CAPS]
= { .min_len = sizeof(struct wmi_soc_mac_phy_hw_mode_caps) },
[WMI_TAG_SOC_HAL_REG_CAPABILITIES]
= { .min_len = sizeof(struct wmi_soc_hal_reg_capabilities) },
[WMI_TAG_VDEV_START_RESPONSE_EVENT]
= { .min_len = sizeof(struct wmi_vdev_start_resp_event) },
[WMI_TAG_PEER_DELETE_RESP_EVENT]
= { .min_len = sizeof(struct wmi_peer_delete_resp_event) },
[WMI_TAG_OFFLOAD_BCN_TX_STATUS_EVENT]
= { .min_len = sizeof(struct wmi_bcn_tx_status_event) },
[WMI_TAG_VDEV_STOPPED_EVENT]
= { .min_len = sizeof(struct wmi_vdev_stopped_event) },
[WMI_TAG_REG_CHAN_LIST_CC_EVENT]
= { .min_len = sizeof(struct wmi_reg_chan_list_cc_event) },
[WMI_TAG_MGMT_RX_HDR]
= { .min_len = sizeof(struct wmi_mgmt_rx_hdr) },
[WMI_TAG_MGMT_TX_COMPL_EVENT]
= { .min_len = sizeof(struct wmi_mgmt_tx_compl_event) },
[WMI_TAG_SCAN_EVENT]
= { .min_len = sizeof(struct wmi_scan_event) },
[WMI_TAG_PEER_STA_KICKOUT_EVENT]
= { .min_len = sizeof(struct wmi_peer_sta_kickout_event) },
[WMI_TAG_ROAM_EVENT]
= { .min_len = sizeof(struct wmi_roam_event) },
[WMI_TAG_CHAN_INFO_EVENT]
= { .min_len = sizeof(struct wmi_chan_info_event) },
[WMI_TAG_PDEV_BSS_CHAN_INFO_EVENT]
= { .min_len = sizeof(struct wmi_pdev_bss_chan_info_event) },
[WMI_TAG_VDEV_INSTALL_KEY_COMPLETE_EVENT]
= { .min_len = sizeof(struct wmi_vdev_install_key_compl_event) },
[WMI_TAG_READY_EVENT] = {
.min_len = sizeof(struct wmi_ready_event_min) },
[WMI_TAG_SERVICE_AVAILABLE_EVENT]
= {.min_len = sizeof(struct wmi_service_available_event) },
[WMI_TAG_PEER_ASSOC_CONF_EVENT]
= { .min_len = sizeof(struct wmi_peer_assoc_conf_event) },
[WMI_TAG_STATS_EVENT]
= { .min_len = sizeof(struct wmi_stats_event) },
[WMI_TAG_PDEV_CTL_FAILSAFE_CHECK_EVENT]
= { .min_len = sizeof(struct wmi_pdev_ctl_failsafe_chk_event) },
[WMI_TAG_HOST_SWFDA_EVENT] = {
.min_len = sizeof(struct wmi_fils_discovery_event) },
[WMI_TAG_OFFLOAD_PRB_RSP_TX_STATUS_EVENT] = {
.min_len = sizeof(struct wmi_probe_resp_tx_status_event) },
[WMI_TAG_VDEV_DELETE_RESP_EVENT] = {
.min_len = sizeof(struct wmi_vdev_delete_resp_event) },
};
#define PRIMAP(_hw_mode_) \
[_hw_mode_] = _hw_mode_##_PRI
static const int ath11k_hw_mode_pri_map[] = {
PRIMAP(WMI_HOST_HW_MODE_SINGLE),
PRIMAP(WMI_HOST_HW_MODE_DBS),
PRIMAP(WMI_HOST_HW_MODE_SBS_PASSIVE),
PRIMAP(WMI_HOST_HW_MODE_SBS),
PRIMAP(WMI_HOST_HW_MODE_DBS_SBS),
PRIMAP(WMI_HOST_HW_MODE_DBS_OR_SBS),
/* keep last */
PRIMAP(WMI_HOST_HW_MODE_MAX),
};
static int
ath11k_wmi_tlv_iter(struct ath11k_base *ab, const void *ptr, size_t len,
int (*iter)(struct ath11k_base *ab, u16 tag, u16 len,
const void *ptr, void *data),
void *data)
{
const void *begin = ptr;
const struct wmi_tlv *tlv;
u16 tlv_tag, tlv_len;
int ret;
while (len > 0) {
if (len < sizeof(*tlv)) {
ath11k_err(ab, "wmi tlv parse failure at byte %zd (%zu bytes left, %zu expected)\n",
ptr - begin, len, sizeof(*tlv));
return -EINVAL;
}
tlv = ptr;
tlv_tag = FIELD_GET(WMI_TLV_TAG, tlv->header);
tlv_len = FIELD_GET(WMI_TLV_LEN, tlv->header);
ptr += sizeof(*tlv);
len -= sizeof(*tlv);
if (tlv_len > len) {
ath11k_err(ab, "wmi tlv parse failure of tag %u at byte %zd (%zu bytes left, %u expected)\n",
tlv_tag, ptr - begin, len, tlv_len);
return -EINVAL;
}
if (tlv_tag < ARRAY_SIZE(wmi_tlv_policies) &&
wmi_tlv_policies[tlv_tag].min_len &&
wmi_tlv_policies[tlv_tag].min_len > tlv_len) {
ath11k_err(ab, "wmi tlv parse failure of tag %u at byte %zd (%u bytes is less than min length %zu)\n",
tlv_tag, ptr - begin, tlv_len,
wmi_tlv_policies[tlv_tag].min_len);
return -EINVAL;
}
ret = iter(ab, tlv_tag, tlv_len, ptr, data);
if (ret)
return ret;
ptr += tlv_len;
len -= tlv_len;
}
return 0;
}
static int ath11k_wmi_tlv_iter_parse(struct ath11k_base *ab, u16 tag, u16 len,
const void *ptr, void *data)
{
const void **tb = data;
if (tag < WMI_TAG_MAX)
tb[tag] = ptr;
return 0;
}
static int ath11k_wmi_tlv_parse(struct ath11k_base *ar, const void **tb,
const void *ptr, size_t len)
{
return ath11k_wmi_tlv_iter(ar, ptr, len, ath11k_wmi_tlv_iter_parse,
(void *)tb);
}
static const void **
ath11k_wmi_tlv_parse_alloc(struct ath11k_base *ab, const void *ptr,
size_t len, gfp_t gfp)
{
const void **tb;
int ret;
tb = kcalloc(WMI_TAG_MAX, sizeof(*tb), gfp);
if (!tb)
return ERR_PTR(-ENOMEM);
ret = ath11k_wmi_tlv_parse(ab, tb, ptr, len);
if (ret) {
kfree(tb);
return ERR_PTR(ret);
}
return tb;
}
static int ath11k_wmi_cmd_send_nowait(struct ath11k_pdev_wmi *wmi, struct sk_buff *skb,
u32 cmd_id)
{
struct ath11k_skb_cb *skb_cb = ATH11K_SKB_CB(skb);
struct ath11k_base *ab = wmi->wmi_ab->ab;
struct wmi_cmd_hdr *cmd_hdr;
int ret;
u32 cmd = 0;
if (skb_push(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
return -ENOMEM;
cmd |= FIELD_PREP(WMI_CMD_HDR_CMD_ID, cmd_id);
cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
cmd_hdr->cmd_id = cmd;
memset(skb_cb, 0, sizeof(*skb_cb));
ret = ath11k_htc_send(&ab->htc, wmi->eid, skb);
if (ret)
goto err_pull;
return 0;
err_pull:
skb_pull(skb, sizeof(struct wmi_cmd_hdr));
return ret;
}
int ath11k_wmi_cmd_send(struct ath11k_pdev_wmi *wmi, struct sk_buff *skb,
u32 cmd_id)
{
struct ath11k_wmi_base *wmi_sc = wmi->wmi_ab;
int ret = -EOPNOTSUPP;
might_sleep();
wait_event_timeout(wmi_sc->tx_credits_wq, ({
ret = ath11k_wmi_cmd_send_nowait(wmi, skb, cmd_id);
if (ret && test_bit(ATH11K_FLAG_CRASH_FLUSH, &wmi_sc->ab->dev_flags))
ret = -ESHUTDOWN;
(ret != -EAGAIN);
}), WMI_SEND_TIMEOUT_HZ);
if (ret == -EAGAIN)
ath11k_warn(wmi_sc->ab, "wmi command %d timeout\n", cmd_id);
return ret;
}
static int ath11k_pull_svc_ready_ext(struct ath11k_pdev_wmi *wmi_handle,
const void *ptr,
struct ath11k_service_ext_param *param)
{
const struct wmi_service_ready_ext_event *ev = ptr;
if (!ev)
return -EINVAL;
/* Move this to host based bitmap */
param->default_conc_scan_config_bits = ev->default_conc_scan_config_bits;
param->default_fw_config_bits = ev->default_fw_config_bits;
param->he_cap_info = ev->he_cap_info;
param->mpdu_density = ev->mpdu_density;
param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
memcpy(&param->ppet, &ev->ppet, sizeof(param->ppet));
return 0;
}
static int
ath11k_pull_mac_phy_cap_svc_ready_ext(struct ath11k_pdev_wmi *wmi_handle,
struct wmi_soc_mac_phy_hw_mode_caps *hw_caps,
struct wmi_hw_mode_capabilities *wmi_hw_mode_caps,
struct wmi_soc_hal_reg_capabilities *hal_reg_caps,
struct wmi_mac_phy_capabilities *wmi_mac_phy_caps,
u8 hw_mode_id, u8 phy_id,
struct ath11k_pdev *pdev)
{
struct wmi_mac_phy_capabilities *mac_phy_caps;
struct ath11k_band_cap *cap_band;
struct ath11k_pdev_cap *pdev_cap = &pdev->cap;
u32 phy_map;
u32 hw_idx, phy_idx = 0;
if (!hw_caps || !wmi_hw_mode_caps || !hal_reg_caps)
return -EINVAL;
for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
if (hw_mode_id == wmi_hw_mode_caps[hw_idx].hw_mode_id)
break;
phy_map = wmi_hw_mode_caps[hw_idx].phy_id_map;
while (phy_map) {
phy_map >>= 1;
phy_idx++;
}
}
if (hw_idx == hw_caps->num_hw_modes)
return -EINVAL;
phy_idx += phy_id;
if (phy_id >= hal_reg_caps->num_phy)
return -EINVAL;
mac_phy_caps = wmi_mac_phy_caps + phy_idx;
pdev->pdev_id = mac_phy_caps->pdev_id;
pdev_cap->supported_bands |= mac_phy_caps->supported_bands;
pdev_cap->ampdu_density = mac_phy_caps->ampdu_density;
/* Take non-zero tx/rx chainmask. If tx/rx chainmask differs from
* band to band for a single radio, need to see how this should be
* handled.
*/
if (mac_phy_caps->supported_bands & WMI_HOST_WLAN_2G_CAP) {
pdev_cap->tx_chain_mask = mac_phy_caps->tx_chain_mask_2g;
pdev_cap->rx_chain_mask = mac_phy_caps->rx_chain_mask_2g;
} else if (mac_phy_caps->supported_bands & WMI_HOST_WLAN_5G_CAP) {
pdev_cap->vht_cap = mac_phy_caps->vht_cap_info_5g;
pdev_cap->vht_mcs = mac_phy_caps->vht_supp_mcs_5g;
pdev_cap->he_mcs = mac_phy_caps->he_supp_mcs_5g;
pdev_cap->tx_chain_mask = mac_phy_caps->tx_chain_mask_5g;
pdev_cap->rx_chain_mask = mac_phy_caps->rx_chain_mask_5g;
pdev_cap->nss_ratio_enabled =
WMI_NSS_RATIO_ENABLE_DISABLE_GET(mac_phy_caps->nss_ratio);
pdev_cap->nss_ratio_info =
WMI_NSS_RATIO_INFO_GET(mac_phy_caps->nss_ratio);
} else {
return -EINVAL;
}
/* tx/rx chainmask reported from fw depends on the actual hw chains used,
* For example, for 4x4 capable macphys, first 4 chains can be used for first
* mac and the remaing 4 chains can be used for the second mac or vice-versa.
* In this case, tx/rx chainmask 0xf will be advertised for first mac and 0xf0
* will be advertised for second mac or vice-versa. Compute the shift value
* for tx/rx chainmask which will be used to advertise supported ht/vht rates to
* mac80211.
*/
pdev_cap->tx_chain_mask_shift =
find_first_bit((unsigned long *)&pdev_cap->tx_chain_mask, 32);
pdev_cap->rx_chain_mask_shift =
find_first_bit((unsigned long *)&pdev_cap->rx_chain_mask, 32);
if (mac_phy_caps->supported_bands & WMI_HOST_WLAN_2G_CAP) {
cap_band = &pdev_cap->band[NL80211_BAND_2GHZ];
cap_band->phy_id = mac_phy_caps->phy_id;
cap_band->max_bw_supported = mac_phy_caps->max_bw_supported_2g;
cap_band->ht_cap_info = mac_phy_caps->ht_cap_info_2g;
cap_band->he_cap_info[0] = mac_phy_caps->he_cap_info_2g;
cap_band->he_cap_info[1] = mac_phy_caps->he_cap_info_2g_ext;
cap_band->he_mcs = mac_phy_caps->he_supp_mcs_2g;
memcpy(cap_band->he_cap_phy_info, &mac_phy_caps->he_cap_phy_info_2g,
sizeof(u32) * PSOC_HOST_MAX_PHY_SIZE);
memcpy(&cap_band->he_ppet, &mac_phy_caps->he_ppet2g,
sizeof(struct ath11k_ppe_threshold));
}
if (mac_phy_caps->supported_bands & WMI_HOST_WLAN_5G_CAP) {
cap_band = &pdev_cap->band[NL80211_BAND_5GHZ];
cap_band->phy_id = mac_phy_caps->phy_id;
cap_band->max_bw_supported = mac_phy_caps->max_bw_supported_5g;
cap_band->ht_cap_info = mac_phy_caps->ht_cap_info_5g;
cap_band->he_cap_info[0] = mac_phy_caps->he_cap_info_5g;
cap_band->he_cap_info[1] = mac_phy_caps->he_cap_info_5g_ext;
cap_band->he_mcs = mac_phy_caps->he_supp_mcs_5g;
memcpy(cap_band->he_cap_phy_info, &mac_phy_caps->he_cap_phy_info_5g,
sizeof(u32) * PSOC_HOST_MAX_PHY_SIZE);
memcpy(&cap_band->he_ppet, &mac_phy_caps->he_ppet5g,
sizeof(struct ath11k_ppe_threshold));
cap_band = &pdev_cap->band[NL80211_BAND_6GHZ];
cap_band->max_bw_supported = mac_phy_caps->max_bw_supported_5g;
cap_band->ht_cap_info = mac_phy_caps->ht_cap_info_5g;
cap_band->he_cap_info[0] = mac_phy_caps->he_cap_info_5g;
cap_band->he_cap_info[1] = mac_phy_caps->he_cap_info_5g_ext;
cap_band->he_mcs = mac_phy_caps->he_supp_mcs_5g;
memcpy(cap_band->he_cap_phy_info, &mac_phy_caps->he_cap_phy_info_5g,
sizeof(u32) * PSOC_HOST_MAX_PHY_SIZE);
memcpy(&cap_band->he_ppet, &mac_phy_caps->he_ppet5g,
sizeof(struct ath11k_ppe_threshold));
}
return 0;
}
static int
ath11k_pull_reg_cap_svc_rdy_ext(struct ath11k_pdev_wmi *wmi_handle,
struct wmi_soc_hal_reg_capabilities *reg_caps,
struct wmi_hal_reg_capabilities_ext *wmi_ext_reg_cap,
u8 phy_idx,
struct ath11k_hal_reg_capabilities_ext *param)
{
struct wmi_hal_reg_capabilities_ext *ext_reg_cap;
if (!reg_caps || !wmi_ext_reg_cap)
return -EINVAL;
if (phy_idx >= reg_caps->num_phy)
return -EINVAL;
ext_reg_cap = &wmi_ext_reg_cap[phy_idx];
param->phy_id = ext_reg_cap->phy_id;
param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
param->eeprom_reg_domain_ext =
ext_reg_cap->eeprom_reg_domain_ext;
param->regcap1 = ext_reg_cap->regcap1;
param->regcap2 = ext_reg_cap->regcap2;
/* check if param->wireless_mode is needed */
param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
return 0;
}
static int ath11k_pull_service_ready_tlv(struct ath11k_base *ab,
const void *evt_buf,
struct ath11k_targ_cap *cap)
{
const struct wmi_service_ready_event *ev = evt_buf;
if (!ev) {
ath11k_err(ab, "%s: failed by NULL param\n",
__func__);
return -EINVAL;
}
cap->phy_capability = ev->phy_capability;
cap->max_frag_entry = ev->max_frag_entry;
cap->num_rf_chains = ev->num_rf_chains;
cap->ht_cap_info = ev->ht_cap_info;
cap->vht_cap_info = ev->vht_cap_info;
cap->vht_supp_mcs = ev->vht_supp_mcs;
cap->hw_min_tx_power = ev->hw_min_tx_power;
cap->hw_max_tx_power = ev->hw_max_tx_power;
cap->sys_cap_info = ev->sys_cap_info;
cap->min_pkt_size_enable = ev->min_pkt_size_enable;
cap->max_bcn_ie_size = ev->max_bcn_ie_size;
cap->max_num_scan_channels = ev->max_num_scan_channels;
cap->max_supported_macs = ev->max_supported_macs;
cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
cap->txrx_chainmask = ev->txrx_chainmask;
cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
cap->num_msdu_desc = ev->num_msdu_desc;
return 0;
}
/* Save the wmi_service_bitmap into a linear bitmap. The wmi_services in
* wmi_service ready event are advertised in b0-b3 (LSB 4-bits) of each
* 4-byte word.
*/
static void ath11k_wmi_service_bitmap_copy(struct ath11k_pdev_wmi *wmi,
const u32 *wmi_svc_bm)
{
int i, j;
for (i = 0, j = 0; i < WMI_SERVICE_BM_SIZE && j < WMI_MAX_SERVICE; i++) {
do {
if (wmi_svc_bm[i] & BIT(j % WMI_SERVICE_BITS_IN_SIZE32))
set_bit(j, wmi->wmi_ab->svc_map);
} while (++j % WMI_SERVICE_BITS_IN_SIZE32);
}
}
static int ath11k_wmi_tlv_svc_rdy_parse(struct ath11k_base *ab, u16 tag, u16 len,
const void *ptr, void *data)
{
struct wmi_tlv_svc_ready_parse *svc_ready = data;
struct ath11k_pdev_wmi *wmi_handle = &ab->wmi_ab.wmi[0];
u16 expect_len;
switch (tag) {
case WMI_TAG_SERVICE_READY_EVENT:
if (ath11k_pull_service_ready_tlv(ab, ptr, &ab->target_caps))
return -EINVAL;
break;
case WMI_TAG_ARRAY_UINT32:
if (!svc_ready->wmi_svc_bitmap_done) {
expect_len = WMI_SERVICE_BM_SIZE * sizeof(u32);
if (len < expect_len) {
ath11k_warn(ab, "invalid len %d for the tag 0x%x\n",
len, tag);
return -EINVAL;
}
ath11k_wmi_service_bitmap_copy(wmi_handle, ptr);
svc_ready->wmi_svc_bitmap_done = true;
}
break;
default:
break;
}
return 0;
}
static int ath11k_service_ready_event(struct ath11k_base *ab, struct sk_buff *skb)
{
struct wmi_tlv_svc_ready_parse svc_ready = { };
int ret;
ret = ath11k_wmi_tlv_iter(ab, skb->data, skb->len,
ath11k_wmi_tlv_svc_rdy_parse,
&svc_ready);
if (ret) {
ath11k_warn(ab, "failed to parse tlv %d\n", ret);
return ret;
}
return 0;
}
struct sk_buff *ath11k_wmi_alloc_skb(struct ath11k_wmi_base *wmi_sc, u32 len)
{
struct sk_buff *skb;
struct ath11k_base *ab = wmi_sc->ab;
u32 round_len = roundup(len, 4);
skb = ath11k_htc_alloc_skb(ab, WMI_SKB_HEADROOM + round_len);
if (!skb)
return NULL;
skb_reserve(skb, WMI_SKB_HEADROOM);
if (!IS_ALIGNED((unsigned long)skb->data, 4))
ath11k_warn(ab, "unaligned WMI skb data\n");
skb_put(skb, round_len);
memset(skb->data, 0, round_len);
return skb;
}
int ath11k_wmi_mgmt_send(struct ath11k *ar, u32 vdev_id, u32 buf_id,
struct sk_buff *frame)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_mgmt_send_cmd *cmd;
struct wmi_tlv *frame_tlv;
struct sk_buff *skb;
u32 buf_len;
int ret, len;
buf_len = frame->len < WMI_MGMT_SEND_DOWNLD_LEN ?
frame->len : WMI_MGMT_SEND_DOWNLD_LEN;
len = sizeof(*cmd) + sizeof(*frame_tlv) + roundup(buf_len, 4);
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len);
if (!skb)
return -ENOMEM;
cmd = (struct wmi_mgmt_send_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_MGMT_TX_SEND_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->vdev_id = vdev_id;
cmd->desc_id = buf_id;
cmd->chanfreq = 0;
cmd->paddr_lo = lower_32_bits(ATH11K_SKB_CB(frame)->paddr);
cmd->paddr_hi = upper_32_bits(ATH11K_SKB_CB(frame)->paddr);
cmd->frame_len = frame->len;
cmd->buf_len = buf_len;
cmd->tx_params_valid = 0;
frame_tlv = (struct wmi_tlv *)(skb->data + sizeof(*cmd));
frame_tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_BYTE) |
FIELD_PREP(WMI_TLV_LEN, buf_len);
memcpy(frame_tlv->value, frame->data, buf_len);
ath11k_ce_byte_swap(frame_tlv->value, buf_len);
ret = ath11k_wmi_cmd_send(wmi, skb, WMI_MGMT_TX_SEND_CMDID);
if (ret) {
ath11k_warn(ar->ab,
"failed to submit WMI_MGMT_TX_SEND_CMDID cmd\n");
dev_kfree_skb(skb);
}
return ret;
}
int ath11k_wmi_vdev_create(struct ath11k *ar, u8 *macaddr,
struct vdev_create_params *param)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_vdev_create_cmd *cmd;
struct sk_buff *skb;
struct wmi_vdev_txrx_streams *txrx_streams;
struct wmi_tlv *tlv;
int ret, len;
void *ptr;
/* It can be optimized my sending tx/rx chain configuration
* only for supported bands instead of always sending it for
* both the bands.
*/
len = sizeof(*cmd) + TLV_HDR_SIZE +
(WMI_NUM_SUPPORTED_BAND_MAX * sizeof(*txrx_streams));
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len);
if (!skb)
return -ENOMEM;
cmd = (struct wmi_vdev_create_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_VDEV_CREATE_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->vdev_id = param->if_id;
cmd->vdev_type = param->type;
cmd->vdev_subtype = param->subtype;
cmd->num_cfg_txrx_streams = WMI_NUM_SUPPORTED_BAND_MAX;
cmd->pdev_id = param->pdev_id;
ether_addr_copy(cmd->vdev_macaddr.addr, macaddr);
ptr = skb->data + sizeof(*cmd);
len = WMI_NUM_SUPPORTED_BAND_MAX * sizeof(*txrx_streams);
tlv = ptr;
tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_STRUCT) |
FIELD_PREP(WMI_TLV_LEN, len);
ptr += TLV_HDR_SIZE;
txrx_streams = ptr;
len = sizeof(*txrx_streams);
txrx_streams->tlv_header =
FIELD_PREP(WMI_TLV_TAG, WMI_TAG_VDEV_TXRX_STREAMS) |
FIELD_PREP(WMI_TLV_LEN, len - TLV_HDR_SIZE);
txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_2G;
txrx_streams->supported_tx_streams =
param->chains[NL80211_BAND_2GHZ].tx;
txrx_streams->supported_rx_streams =
param->chains[NL80211_BAND_2GHZ].rx;
txrx_streams++;
txrx_streams->tlv_header =
FIELD_PREP(WMI_TLV_TAG, WMI_TAG_VDEV_TXRX_STREAMS) |
FIELD_PREP(WMI_TLV_LEN, len - TLV_HDR_SIZE);
txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_5G;
txrx_streams->supported_tx_streams =
param->chains[NL80211_BAND_5GHZ].tx;
txrx_streams->supported_rx_streams =
param->chains[NL80211_BAND_5GHZ].rx;
ret = ath11k_wmi_cmd_send(wmi, skb, WMI_VDEV_CREATE_CMDID);
if (ret) {
ath11k_warn(ar->ab,
"failed to submit WMI_VDEV_CREATE_CMDID\n");
dev_kfree_skb(skb);
}
ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
"WMI vdev create: id %d type %d subtype %d macaddr %pM pdevid %d\n",
param->if_id, param->type, param->subtype,
macaddr, param->pdev_id);
return ret;
}
int ath11k_wmi_vdev_delete(struct ath11k *ar, u8 vdev_id)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_vdev_delete_cmd *cmd;
struct sk_buff *skb;
int ret;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd));
if (!skb)
return -ENOMEM;
cmd = (struct wmi_vdev_delete_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_VDEV_DELETE_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->vdev_id = vdev_id;
ret = ath11k_wmi_cmd_send(wmi, skb, WMI_VDEV_DELETE_CMDID);
if (ret) {
ath11k_warn(ar->ab, "failed to submit WMI_VDEV_DELETE_CMDID\n");
dev_kfree_skb(skb);
}
ath11k_dbg(ar->ab, ATH11K_DBG_WMI, "WMI vdev delete id %d\n", vdev_id);
return ret;
}
int ath11k_wmi_vdev_stop(struct ath11k *ar, u8 vdev_id)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_vdev_stop_cmd *cmd;
struct sk_buff *skb;
int ret;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd));
if (!skb)
return -ENOMEM;
cmd = (struct wmi_vdev_stop_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_VDEV_STOP_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->vdev_id = vdev_id;
ret = ath11k_wmi_cmd_send(wmi, skb, WMI_VDEV_STOP_CMDID);
if (ret) {
ath11k_warn(ar->ab, "failed to submit WMI_VDEV_STOP cmd\n");
dev_kfree_skb(skb);
}
ath11k_dbg(ar->ab, ATH11K_DBG_WMI, "WMI vdev stop id 0x%x\n", vdev_id);
return ret;
}
int ath11k_wmi_vdev_down(struct ath11k *ar, u8 vdev_id)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_vdev_down_cmd *cmd;
struct sk_buff *skb;
int ret;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd));
if (!skb)
return -ENOMEM;
cmd = (struct wmi_vdev_down_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_VDEV_DOWN_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->vdev_id = vdev_id;
ret = ath11k_wmi_cmd_send(wmi, skb, WMI_VDEV_DOWN_CMDID);
if (ret) {
ath11k_warn(ar->ab, "failed to submit WMI_VDEV_DOWN cmd\n");
dev_kfree_skb(skb);
}
ath11k_dbg(ar->ab, ATH11K_DBG_WMI, "WMI vdev down id 0x%x\n", vdev_id);
return ret;
}
static void ath11k_wmi_put_wmi_channel(struct wmi_channel *chan,
struct wmi_vdev_start_req_arg *arg)
{
u32 center_freq1 = arg->channel.band_center_freq1;
memset(chan, 0, sizeof(*chan));
chan->mhz = arg->channel.freq;
chan->band_center_freq1 = arg->channel.band_center_freq1;
if (arg->channel.mode == MODE_11AX_HE160) {
if (arg->channel.freq > arg->channel.band_center_freq1)
chan->band_center_freq1 = center_freq1 + 40;
else
chan->band_center_freq1 = center_freq1 - 40;
chan->band_center_freq2 = arg->channel.band_center_freq1;
} else if (arg->channel.mode == MODE_11AC_VHT80_80) {
chan->band_center_freq2 = arg->channel.band_center_freq2;
} else {
chan->band_center_freq2 = 0;
}
chan->info |= FIELD_PREP(WMI_CHAN_INFO_MODE, arg->channel.mode);
if (arg->channel.passive)
chan->info |= WMI_CHAN_INFO_PASSIVE;
if (arg->channel.allow_ibss)
chan->info |= WMI_CHAN_INFO_ADHOC_ALLOWED;
if (arg->channel.allow_ht)
chan->info |= WMI_CHAN_INFO_ALLOW_HT;
if (arg->channel.allow_vht)
chan->info |= WMI_CHAN_INFO_ALLOW_VHT;
if (arg->channel.allow_he)
chan->info |= WMI_CHAN_INFO_ALLOW_HE;
if (arg->channel.ht40plus)
chan->info |= WMI_CHAN_INFO_HT40_PLUS;
if (arg->channel.chan_radar)
chan->info |= WMI_CHAN_INFO_DFS;
if (arg->channel.freq2_radar)
chan->info |= WMI_CHAN_INFO_DFS_FREQ2;
chan->reg_info_1 = FIELD_PREP(WMI_CHAN_REG_INFO1_MAX_PWR,
arg->channel.max_power) |
FIELD_PREP(WMI_CHAN_REG_INFO1_MAX_REG_PWR,
arg->channel.max_reg_power);
chan->reg_info_2 = FIELD_PREP(WMI_CHAN_REG_INFO2_ANT_MAX,
arg->channel.max_antenna_gain) |
FIELD_PREP(WMI_CHAN_REG_INFO2_MAX_TX_PWR,
arg->channel.max_power);
}
int ath11k_wmi_vdev_start(struct ath11k *ar, struct wmi_vdev_start_req_arg *arg,
bool restart)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_vdev_start_request_cmd *cmd;
struct sk_buff *skb;
struct wmi_channel *chan;
struct wmi_tlv *tlv;
void *ptr;
int ret, len;
if (WARN_ON(arg->ssid_len > sizeof(cmd->ssid.ssid)))
return -EINVAL;
len = sizeof(*cmd) + sizeof(*chan) + TLV_HDR_SIZE;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len);
if (!skb)
return -ENOMEM;
cmd = (struct wmi_vdev_start_request_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG,
WMI_TAG_VDEV_START_REQUEST_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->vdev_id = arg->vdev_id;
cmd->beacon_interval = arg->bcn_intval;
cmd->bcn_tx_rate = arg->bcn_tx_rate;
cmd->dtim_period = arg->dtim_period;
cmd->num_noa_descriptors = arg->num_noa_descriptors;
cmd->preferred_rx_streams = arg->pref_rx_streams;
cmd->preferred_tx_streams = arg->pref_tx_streams;
cmd->cac_duration_ms = arg->cac_duration_ms;
cmd->regdomain = arg->regdomain;
cmd->he_ops = arg->he_ops;
if (!restart) {
if (arg->ssid) {
cmd->ssid.ssid_len = arg->ssid_len;
memcpy(cmd->ssid.ssid, arg->ssid, arg->ssid_len);
}
if (arg->hidden_ssid)
cmd->flags |= WMI_VDEV_START_HIDDEN_SSID;
if (arg->pmf_enabled)
cmd->flags |= WMI_VDEV_START_PMF_ENABLED;
}
cmd->flags |= WMI_VDEV_START_LDPC_RX_ENABLED;
if (test_bit(ATH11K_FLAG_HW_CRYPTO_DISABLED, &ar->ab->dev_flags))
cmd->flags |= WMI_VDEV_START_HW_ENCRYPTION_DISABLED;
ptr = skb->data + sizeof(*cmd);
chan = ptr;
ath11k_wmi_put_wmi_channel(chan, arg);
chan->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_CHANNEL) |
FIELD_PREP(WMI_TLV_LEN,
sizeof(*chan) - TLV_HDR_SIZE);
ptr += sizeof(*chan);
tlv = ptr;
tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_STRUCT) |
FIELD_PREP(WMI_TLV_LEN, 0);
/* Note: This is a nested TLV containing:
* [wmi_tlv][wmi_p2p_noa_descriptor][wmi_tlv]..
*/
ptr += sizeof(*tlv);
if (restart)
ret = ath11k_wmi_cmd_send(wmi, skb,
WMI_VDEV_RESTART_REQUEST_CMDID);
else
ret = ath11k_wmi_cmd_send(wmi, skb,
WMI_VDEV_START_REQUEST_CMDID);
if (ret) {
ath11k_warn(ar->ab, "failed to submit vdev_%s cmd\n",
restart ? "restart" : "start");
dev_kfree_skb(skb);
}
ath11k_dbg(ar->ab, ATH11K_DBG_WMI, "vdev %s id 0x%x freq 0x%x mode 0x%x\n",
restart ? "restart" : "start", arg->vdev_id,
arg->channel.freq, arg->channel.mode);
return ret;
}
int ath11k_wmi_vdev_up(struct ath11k *ar, u32 vdev_id, u32 aid, const u8 *bssid)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_vdev_up_cmd *cmd;
struct sk_buff *skb;
int ret;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd));
if (!skb)
return -ENOMEM;
cmd = (struct wmi_vdev_up_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_VDEV_UP_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->vdev_id = vdev_id;
cmd->vdev_assoc_id = aid;
ether_addr_copy(cmd->vdev_bssid.addr, bssid);
ret = ath11k_wmi_cmd_send(wmi, skb, WMI_VDEV_UP_CMDID);
if (ret) {
ath11k_warn(ar->ab, "failed to submit WMI_VDEV_UP cmd\n");
dev_kfree_skb(skb);
}
ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
"WMI mgmt vdev up id 0x%x assoc id %d bssid %pM\n",
vdev_id, aid, bssid);
return ret;
}
int ath11k_wmi_send_peer_create_cmd(struct ath11k *ar,
struct peer_create_params *param)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_peer_create_cmd *cmd;
struct sk_buff *skb;
int ret;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd));
if (!skb)
return -ENOMEM;
cmd = (struct wmi_peer_create_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_PEER_CREATE_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
ether_addr_copy(cmd->peer_macaddr.addr, param->peer_addr);
cmd->peer_type = param->peer_type;
cmd->vdev_id = param->vdev_id;
ret = ath11k_wmi_cmd_send(wmi, skb, WMI_PEER_CREATE_CMDID);
if (ret) {
ath11k_warn(ar->ab, "failed to submit WMI_PEER_CREATE cmd\n");
dev_kfree_skb(skb);
}
ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
"WMI peer create vdev_id %d peer_addr %pM\n",
param->vdev_id, param->peer_addr);
return ret;
}
int ath11k_wmi_send_peer_delete_cmd(struct ath11k *ar,
const u8 *peer_addr, u8 vdev_id)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_peer_delete_cmd *cmd;
struct sk_buff *skb;
int ret;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd));
if (!skb)
return -ENOMEM;
cmd = (struct wmi_peer_delete_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_PEER_DELETE_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
cmd->vdev_id = vdev_id;
ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
"WMI peer delete vdev_id %d peer_addr %pM\n",
vdev_id, peer_addr);
ret = ath11k_wmi_cmd_send(wmi, skb, WMI_PEER_DELETE_CMDID);
if (ret) {
ath11k_warn(ar->ab, "failed to send WMI_PEER_DELETE cmd\n");
dev_kfree_skb(skb);
}
return ret;
}
int ath11k_wmi_send_pdev_set_regdomain(struct ath11k *ar,
struct pdev_set_regdomain_params *param)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_pdev_set_regdomain_cmd *cmd;
struct sk_buff *skb;
int ret;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd));
if (!skb)
return -ENOMEM;
cmd = (struct wmi_pdev_set_regdomain_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG,
WMI_TAG_PDEV_SET_REGDOMAIN_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->reg_domain = param->current_rd_in_use;
cmd->reg_domain_2g = param->current_rd_2g;
cmd->reg_domain_5g = param->current_rd_5g;
cmd->conformance_test_limit_2g = param->ctl_2g;
cmd->conformance_test_limit_5g = param->ctl_5g;
cmd->dfs_domain = param->dfs_domain;
cmd->pdev_id = param->pdev_id;
ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
"WMI pdev regd rd %d rd2g %d rd5g %d domain %d pdev id %d\n",
param->current_rd_in_use, param->current_rd_2g,
param->current_rd_5g, param->dfs_domain, param->pdev_id);
ret = ath11k_wmi_cmd_send(wmi, skb, WMI_PDEV_SET_REGDOMAIN_CMDID);
if (ret) {
ath11k_warn(ar->ab,
"failed to send WMI_PDEV_SET_REGDOMAIN cmd\n");
dev_kfree_skb(skb);
}
return ret;
}
int ath11k_wmi_set_peer_param(struct ath11k *ar, const u8 *peer_addr,
u32 vdev_id, u32 param_id, u32 param_val)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_peer_set_param_cmd *cmd;
struct sk_buff *skb;
int ret;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd));
if (!skb)
return -ENOMEM;
cmd = (struct wmi_peer_set_param_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_PEER_SET_PARAM_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
cmd->vdev_id = vdev_id;
cmd->param_id = param_id;
cmd->param_value = param_val;
ret = ath11k_wmi_cmd_send(wmi, skb, WMI_PEER_SET_PARAM_CMDID);
if (ret) {
ath11k_warn(ar->ab, "failed to send WMI_PEER_SET_PARAM cmd\n");
dev_kfree_skb(skb);
}
ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
"WMI vdev %d peer 0x%pM set param %d value %d\n",
vdev_id, peer_addr, param_id, param_val);
return ret;
}
int ath11k_wmi_send_peer_flush_tids_cmd(struct ath11k *ar,
u8 peer_addr[ETH_ALEN],
struct peer_flush_params *param)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_peer_flush_tids_cmd *cmd;
struct sk_buff *skb;
int ret;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd));
if (!skb)
return -ENOMEM;
cmd = (struct wmi_peer_flush_tids_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_PEER_FLUSH_TIDS_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
cmd->peer_tid_bitmap = param->peer_tid_bitmap;
cmd->vdev_id = param->vdev_id;
ret = ath11k_wmi_cmd_send(wmi, skb, WMI_PEER_FLUSH_TIDS_CMDID);
if (ret) {
ath11k_warn(ar->ab,
"failed to send WMI_PEER_FLUSH_TIDS cmd\n");
dev_kfree_skb(skb);
}
ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
"WMI peer flush vdev_id %d peer_addr %pM tids %08x\n",
param->vdev_id, peer_addr, param->peer_tid_bitmap);
return ret;
}
int ath11k_wmi_peer_rx_reorder_queue_setup(struct ath11k *ar,
int vdev_id, const u8 *addr,
dma_addr_t paddr, u8 tid,
u8 ba_window_size_valid,
u32 ba_window_size)
{
struct wmi_peer_reorder_queue_setup_cmd *cmd;
struct sk_buff *skb;
int ret;
skb = ath11k_wmi_alloc_skb(ar->wmi->wmi_ab, sizeof(*cmd));
if (!skb)
return -ENOMEM;
cmd = (struct wmi_peer_reorder_queue_setup_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG,
WMI_TAG_REORDER_QUEUE_SETUP_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
ether_addr_copy(cmd->peer_macaddr.addr, addr);
cmd->vdev_id = vdev_id;
cmd->tid = tid;
cmd->queue_ptr_lo = lower_32_bits(paddr);
cmd->queue_ptr_hi = upper_32_bits(paddr);
cmd->queue_no = tid;
cmd->ba_window_size_valid = ba_window_size_valid;
cmd->ba_window_size = ba_window_size;
ret = ath11k_wmi_cmd_send(ar->wmi, skb,
WMI_PEER_REORDER_QUEUE_SETUP_CMDID);
if (ret) {
ath11k_warn(ar->ab,
"failed to send WMI_PEER_REORDER_QUEUE_SETUP\n");
dev_kfree_skb(skb);
}
ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
"wmi rx reorder queue setup addr %pM vdev_id %d tid %d\n",
addr, vdev_id, tid);
return ret;
}
int
ath11k_wmi_rx_reord_queue_remove(struct ath11k *ar,
struct rx_reorder_queue_remove_params *param)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_peer_reorder_queue_remove_cmd *cmd;
struct sk_buff *skb;
int ret;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd));
if (!skb)
return -ENOMEM;
cmd = (struct wmi_peer_reorder_queue_remove_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG,
WMI_TAG_REORDER_QUEUE_REMOVE_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
ether_addr_copy(cmd->peer_macaddr.addr, param->peer_macaddr);
cmd->vdev_id = param->vdev_id;
cmd->tid_mask = param->peer_tid_bitmap;
ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
"%s: peer_macaddr %pM vdev_id %d, tid_map %d", __func__,
param->peer_macaddr, param->vdev_id, param->peer_tid_bitmap);
ret = ath11k_wmi_cmd_send(wmi, skb,
WMI_PEER_REORDER_QUEUE_REMOVE_CMDID);
if (ret) {
ath11k_warn(ar->ab,
"failed to send WMI_PEER_REORDER_QUEUE_REMOVE_CMDID");
dev_kfree_skb(skb);
}
return ret;
}
int ath11k_wmi_pdev_set_param(struct ath11k *ar, u32 param_id,
u32 param_value, u8 pdev_id)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_pdev_set_param_cmd *cmd;
struct sk_buff *skb;
int ret;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd));
if (!skb)
return -ENOMEM;
cmd = (struct wmi_pdev_set_param_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_PDEV_SET_PARAM_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->pdev_id = pdev_id;
cmd->param_id = param_id;
cmd->param_value = param_value;
ret = ath11k_wmi_cmd_send(wmi, skb, WMI_PDEV_SET_PARAM_CMDID);
if (ret) {
ath11k_warn(ar->ab, "failed to send WMI_PDEV_SET_PARAM cmd\n");
dev_kfree_skb(skb);
}
ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
"WMI pdev set param %d pdev id %d value %d\n",
param_id, pdev_id, param_value);
return ret;
}
int ath11k_wmi_pdev_set_ps_mode(struct ath11k *ar, int vdev_id, u32 enable)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_pdev_set_ps_mode_cmd *cmd;
struct sk_buff *skb;
int ret;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd));
if (!skb)
return -ENOMEM;
cmd = (struct wmi_pdev_set_ps_mode_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_STA_POWERSAVE_MODE_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->vdev_id = vdev_id;
cmd->sta_ps_mode = enable;
ret = ath11k_wmi_cmd_send(wmi, skb, WMI_STA_POWERSAVE_MODE_CMDID);
if (ret) {
ath11k_warn(ar->ab, "failed to send WMI_PDEV_SET_PARAM cmd\n");
dev_kfree_skb(skb);
}
ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
"WMI vdev set psmode %d vdev id %d\n",
enable, vdev_id);
return ret;
}
int ath11k_wmi_pdev_suspend(struct ath11k *ar, u32 suspend_opt,
u32 pdev_id)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_pdev_suspend_cmd *cmd;
struct sk_buff *skb;
int ret;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd));
if (!skb)
return -ENOMEM;
cmd = (struct wmi_pdev_suspend_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_PDEV_SUSPEND_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->suspend_opt = suspend_opt;
cmd->pdev_id = pdev_id;
ret = ath11k_wmi_cmd_send(wmi, skb, WMI_PDEV_SUSPEND_CMDID);
if (ret) {
ath11k_warn(ar->ab, "failed to send WMI_PDEV_SUSPEND cmd\n");
dev_kfree_skb(skb);
}
ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
"WMI pdev suspend pdev_id %d\n", pdev_id);
return ret;
}
int ath11k_wmi_pdev_resume(struct ath11k *ar, u32 pdev_id)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_pdev_resume_cmd *cmd;
struct sk_buff *skb;
int ret;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd));
if (!skb)
return -ENOMEM;
cmd = (struct wmi_pdev_resume_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_PDEV_RESUME_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->pdev_id = pdev_id;
ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
"WMI pdev resume pdev id %d\n", pdev_id);
ret = ath11k_wmi_cmd_send(wmi, skb, WMI_PDEV_RESUME_CMDID);
if (ret) {
ath11k_warn(ar->ab, "failed to send WMI_PDEV_RESUME cmd\n");
dev_kfree_skb(skb);
}
return ret;
}
/* TODO FW Support for the cmd is not available yet.
* Can be tested once the command and corresponding
* event is implemented in FW
*/
int ath11k_wmi_pdev_bss_chan_info_request(struct ath11k *ar,
enum wmi_bss_chan_info_req_type type)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_pdev_bss_chan_info_req_cmd *cmd;
struct sk_buff *skb;
int ret;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd));
if (!skb)
return -ENOMEM;
cmd = (struct wmi_pdev_bss_chan_info_req_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG,
WMI_TAG_PDEV_BSS_CHAN_INFO_REQUEST) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->req_type = type;
cmd->pdev_id = ar->pdev->pdev_id;
ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
"WMI bss chan info req type %d\n", type);
ret = ath11k_wmi_cmd_send(wmi, skb,
WMI_PDEV_BSS_CHAN_INFO_REQUEST_CMDID);
if (ret) {
ath11k_warn(ar->ab,
"failed to send WMI_PDEV_BSS_CHAN_INFO_REQUEST cmd\n");
dev_kfree_skb(skb);
}
return ret;
}
int ath11k_wmi_send_set_ap_ps_param_cmd(struct ath11k *ar, u8 *peer_addr,
struct ap_ps_params *param)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_ap_ps_peer_cmd *cmd;
struct sk_buff *skb;
int ret;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd));
if (!skb)
return -ENOMEM;
cmd = (struct wmi_ap_ps_peer_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_AP_PS_PEER_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->vdev_id = param->vdev_id;
ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
cmd->param = param->param;
cmd->value = param->value;
ret = ath11k_wmi_cmd_send(wmi, skb, WMI_AP_PS_PEER_PARAM_CMDID);
if (ret) {
ath11k_warn(ar->ab,
"failed to send WMI_AP_PS_PEER_PARAM_CMDID\n");
dev_kfree_skb(skb);
}
ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
"WMI set ap ps vdev id %d peer %pM param %d value %d\n",
param->vdev_id, peer_addr, param->param, param->value);
return ret;
}
int ath11k_wmi_set_sta_ps_param(struct ath11k *ar, u32 vdev_id,
u32 param, u32 param_value)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_sta_powersave_param_cmd *cmd;
struct sk_buff *skb;
int ret;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd));
if (!skb)
return -ENOMEM;
cmd = (struct wmi_sta_powersave_param_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG,
WMI_TAG_STA_POWERSAVE_PARAM_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->vdev_id = vdev_id;
cmd->param = param;
cmd->value = param_value;
ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
"WMI set sta ps vdev_id %d param %d value %d\n",
vdev_id, param, param_value);
ret = ath11k_wmi_cmd_send(wmi, skb, WMI_STA_POWERSAVE_PARAM_CMDID);
if (ret) {
ath11k_warn(ar->ab, "failed to send WMI_STA_POWERSAVE_PARAM_CMDID");
dev_kfree_skb(skb);
}
return ret;
}
int ath11k_wmi_force_fw_hang_cmd(struct ath11k *ar, u32 type, u32 delay_time_ms)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_force_fw_hang_cmd *cmd;
struct sk_buff *skb;
int ret, len;
len = sizeof(*cmd);
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len);
if (!skb)
return -ENOMEM;
cmd = (struct wmi_force_fw_hang_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_FORCE_FW_HANG_CMD) |
FIELD_PREP(WMI_TLV_LEN, len - TLV_HDR_SIZE);
cmd->type = type;
cmd->delay_time_ms = delay_time_ms;
ret = ath11k_wmi_cmd_send(wmi, skb, WMI_FORCE_FW_HANG_CMDID);
if (ret) {
ath11k_warn(ar->ab, "Failed to send WMI_FORCE_FW_HANG_CMDID");
dev_kfree_skb(skb);
}
return ret;
}
int ath11k_wmi_vdev_set_param_cmd(struct ath11k *ar, u32 vdev_id,
u32 param_id, u32 param_value)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_vdev_set_param_cmd *cmd;
struct sk_buff *skb;
int ret;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd));
if (!skb)
return -ENOMEM;
cmd = (struct wmi_vdev_set_param_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_VDEV_SET_PARAM_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->vdev_id = vdev_id;
cmd->param_id = param_id;
cmd->param_value = param_value;
ret = ath11k_wmi_cmd_send(wmi, skb, WMI_VDEV_SET_PARAM_CMDID);
if (ret) {
ath11k_warn(ar->ab,
"failed to send WMI_VDEV_SET_PARAM_CMDID\n");
dev_kfree_skb(skb);
}
ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
"WMI vdev id 0x%x set param %d value %d\n",
vdev_id, param_id, param_value);
return ret;
}
int ath11k_wmi_send_stats_request_cmd(struct ath11k *ar,
struct stats_request_params *param)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_request_stats_cmd *cmd;
struct sk_buff *skb;
int ret;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd));
if (!skb)
return -ENOMEM;
cmd = (struct wmi_request_stats_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_REQUEST_STATS_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->stats_id = param->stats_id;
cmd->vdev_id = param->vdev_id;
cmd->pdev_id = param->pdev_id;
ret = ath11k_wmi_cmd_send(wmi, skb, WMI_REQUEST_STATS_CMDID);
if (ret) {
ath11k_warn(ar->ab, "failed to send WMI_REQUEST_STATS cmd\n");
dev_kfree_skb(skb);
}
ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
"WMI request stats 0x%x vdev id %d pdev id %d\n",
param->stats_id, param->vdev_id, param->pdev_id);
return ret;
}
int ath11k_wmi_send_pdev_temperature_cmd(struct ath11k *ar)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_get_pdev_temperature_cmd *cmd;
struct sk_buff *skb;
int ret;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd));
if (!skb)
return -ENOMEM;
cmd = (struct wmi_get_pdev_temperature_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_PDEV_GET_TEMPERATURE_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->pdev_id = ar->pdev->pdev_id;
ret = ath11k_wmi_cmd_send(wmi, skb, WMI_PDEV_GET_TEMPERATURE_CMDID);
if (ret) {
ath11k_warn(ar->ab, "failed to send WMI_PDEV_GET_TEMPERATURE cmd\n");
dev_kfree_skb(skb);
}
ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
"WMI pdev get temperature for pdev_id %d\n", ar->pdev->pdev_id);
return ret;
}
int ath11k_wmi_send_bcn_offload_control_cmd(struct ath11k *ar,
u32 vdev_id, u32 bcn_ctrl_op)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_bcn_offload_ctrl_cmd *cmd;
struct sk_buff *skb;
int ret;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd));
if (!skb)
return -ENOMEM;
cmd = (struct wmi_bcn_offload_ctrl_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG,
WMI_TAG_BCN_OFFLOAD_CTRL_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->vdev_id = vdev_id;
cmd->bcn_ctrl_op = bcn_ctrl_op;
ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
"WMI bcn ctrl offload vdev id %d ctrl_op %d\n",
vdev_id, bcn_ctrl_op);
ret = ath11k_wmi_cmd_send(wmi, skb, WMI_BCN_OFFLOAD_CTRL_CMDID);
if (ret) {
ath11k_warn(ar->ab,
"failed to send WMI_BCN_OFFLOAD_CTRL_CMDID\n");
dev_kfree_skb(skb);
}
return ret;
}
int ath11k_wmi_bcn_tmpl(struct ath11k *ar, u32 vdev_id,
struct ieee80211_mutable_offsets *offs,
struct sk_buff *bcn)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_bcn_tmpl_cmd *cmd;
struct wmi_bcn_prb_info *bcn_prb_info;
struct wmi_tlv *tlv;
struct sk_buff *skb;
void *ptr;
int ret, len;
size_t aligned_len = roundup(bcn->len, 4);
len = sizeof(*cmd) + sizeof(*bcn_prb_info) + TLV_HDR_SIZE + aligned_len;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len);
if (!skb)
return -ENOMEM;
cmd = (struct wmi_bcn_tmpl_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_BCN_TMPL_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->vdev_id = vdev_id;
cmd->tim_ie_offset = offs->tim_offset;
cmd->csa_switch_count_offset = offs->cntdwn_counter_offs[0];
cmd->ext_csa_switch_count_offset = offs->cntdwn_counter_offs[1];
cmd->buf_len = bcn->len;
ptr = skb->data + sizeof(*cmd);
bcn_prb_info = ptr;
len = sizeof(*bcn_prb_info);
bcn_prb_info->tlv_header = FIELD_PREP(WMI_TLV_TAG,
WMI_TAG_BCN_PRB_INFO) |
FIELD_PREP(WMI_TLV_LEN, len - TLV_HDR_SIZE);
bcn_prb_info->caps = 0;
bcn_prb_info->erp = 0;
ptr += sizeof(*bcn_prb_info);
tlv = ptr;
tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_BYTE) |
FIELD_PREP(WMI_TLV_LEN, aligned_len);
memcpy(tlv->value, bcn->data, bcn->len);
ret = ath11k_wmi_cmd_send(wmi, skb, WMI_BCN_TMPL_CMDID);
if (ret) {
ath11k_warn(ar->ab, "failed to send WMI_BCN_TMPL_CMDID\n");
dev_kfree_skb(skb);
}
return ret;
}
int ath11k_wmi_vdev_install_key(struct ath11k *ar,
struct wmi_vdev_install_key_arg *arg)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_vdev_install_key_cmd *cmd;
struct wmi_tlv *tlv;
struct sk_buff *skb;
int ret, len;
int key_len_aligned = roundup(arg->key_len, sizeof(uint32_t));
len = sizeof(*cmd) + TLV_HDR_SIZE + key_len_aligned;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len);
if (!skb)
return -ENOMEM;
cmd = (struct wmi_vdev_install_key_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_VDEV_INSTALL_KEY_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->vdev_id = arg->vdev_id;
ether_addr_copy(cmd->peer_macaddr.addr, arg->macaddr);
cmd->key_idx = arg->key_idx;
cmd->key_flags = arg->key_flags;
cmd->key_cipher = arg->key_cipher;
cmd->key_len = arg->key_len;
cmd->key_txmic_len = arg->key_txmic_len;
cmd->key_rxmic_len = arg->key_rxmic_len;
if (arg->key_rsc_counter)
memcpy(&cmd->key_rsc_counter, &arg->key_rsc_counter,
sizeof(struct wmi_key_seq_counter));
tlv = (struct wmi_tlv *)(skb->data + sizeof(*cmd));
tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_BYTE) |
FIELD_PREP(WMI_TLV_LEN, key_len_aligned);
memcpy(tlv->value, (u8 *)arg->key_data, key_len_aligned);
ret = ath11k_wmi_cmd_send(wmi, skb, WMI_VDEV_INSTALL_KEY_CMDID);
if (ret) {
ath11k_warn(ar->ab,
"failed to send WMI_VDEV_INSTALL_KEY cmd\n");
dev_kfree_skb(skb);
}
ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
"WMI vdev install key idx %d cipher %d len %d\n",
arg->key_idx, arg->key_cipher, arg->key_len);
return ret;
}
static inline void
ath11k_wmi_copy_peer_flags(struct wmi_peer_assoc_complete_cmd *cmd,
struct peer_assoc_params *param,
bool hw_crypto_disabled)
{
cmd->peer_flags = 0;
if (param->is_wme_set) {
if (param->qos_flag)
cmd->peer_flags |= WMI_PEER_QOS;
if (param->apsd_flag)
cmd->peer_flags |= WMI_PEER_APSD;
if (param->ht_flag)
cmd->peer_flags |= WMI_PEER_HT;
if (param->bw_40)
cmd->peer_flags |= WMI_PEER_40MHZ;
if (param->bw_80)
cmd->peer_flags |= WMI_PEER_80MHZ;
if (param->bw_160)
cmd->peer_flags |= WMI_PEER_160MHZ;
/* Typically if STBC is enabled for VHT it should be enabled
* for HT as well
**/
if (param->stbc_flag)
cmd->peer_flags |= WMI_PEER_STBC;
/* Typically if LDPC is enabled for VHT it should be enabled
* for HT as well
**/
if (param->ldpc_flag)
cmd->peer_flags |= WMI_PEER_LDPC;
if (param->static_mimops_flag)
cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS;
if (param->dynamic_mimops_flag)
cmd->peer_flags |= WMI_PEER_DYN_MIMOPS;
if (param->spatial_mux_flag)
cmd->peer_flags |= WMI_PEER_SPATIAL_MUX;
if (param->vht_flag)
cmd->peer_flags |= WMI_PEER_VHT;
if (param->he_flag)
cmd->peer_flags |= WMI_PEER_HE;
if (param->twt_requester)
cmd->peer_flags |= WMI_PEER_TWT_REQ;
if (param->twt_responder)
cmd->peer_flags |= WMI_PEER_TWT_RESP;
}
/* Suppress authorization for all AUTH modes that need 4-way handshake
* (during re-association).
* Authorization will be done for these modes on key installation.
*/
if (param->auth_flag)
cmd->peer_flags |= WMI_PEER_AUTH;
if (param->need_ptk_4_way) {
cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
if (!hw_crypto_disabled)
cmd->peer_flags &= ~WMI_PEER_AUTH;
}
if (param->need_gtk_2_way)
cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
/* safe mode bypass the 4-way handshake */
if (param->safe_mode_enabled)
cmd->peer_flags &= ~(WMI_PEER_NEED_PTK_4_WAY |
WMI_PEER_NEED_GTK_2_WAY);
if (param->is_pmf_enabled)
cmd->peer_flags |= WMI_PEER_PMF;
/* Disable AMSDU for station transmit, if user configures it */
/* Disable AMSDU for AP transmit to 11n Stations, if user configures
* it
* if (param->amsdu_disable) Add after FW support
**/
/* Target asserts if node is marked HT and all MCS is set to 0.
* Mark the node as non-HT if all the mcs rates are disabled through
* iwpriv
**/
if (param->peer_ht_rates.num_rates == 0)
cmd->peer_flags &= ~WMI_PEER_HT;
}
int ath11k_wmi_send_peer_assoc_cmd(struct ath11k *ar,
struct peer_assoc_params *param)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_peer_assoc_complete_cmd *cmd;
struct wmi_vht_rate_set *mcs;
struct wmi_he_rate_set *he_mcs;
struct sk_buff *skb;
struct wmi_tlv *tlv;
void *ptr;
u32 peer_legacy_rates_align;
u32 peer_ht_rates_align;
int i, ret, len;
peer_legacy_rates_align = roundup(param->peer_legacy_rates.num_rates,
sizeof(u32));
peer_ht_rates_align = roundup(param->peer_ht_rates.num_rates,
sizeof(u32));
len = sizeof(*cmd) +
TLV_HDR_SIZE + (peer_legacy_rates_align * sizeof(u8)) +
TLV_HDR_SIZE + (peer_ht_rates_align * sizeof(u8)) +
sizeof(*mcs) + TLV_HDR_SIZE +
(sizeof(*he_mcs) * param->peer_he_mcs_count);
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len);
if (!skb)
return -ENOMEM;
ptr = skb->data;
cmd = ptr;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG,
WMI_TAG_PEER_ASSOC_COMPLETE_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->vdev_id = param->vdev_id;
cmd->peer_new_assoc = param->peer_new_assoc;
cmd->peer_associd = param->peer_associd;
ath11k_wmi_copy_peer_flags(cmd, param,
test_bit(ATH11K_FLAG_HW_CRYPTO_DISABLED,
&ar->ab->dev_flags));
ether_addr_copy(cmd->peer_macaddr.addr, param->peer_mac);
cmd->peer_rate_caps = param->peer_rate_caps;
cmd->peer_caps = param->peer_caps;
cmd->peer_listen_intval = param->peer_listen_intval;
cmd->peer_ht_caps = param->peer_ht_caps;
cmd->peer_max_mpdu = param->peer_max_mpdu;
cmd->peer_mpdu_density = param->peer_mpdu_density;
cmd->peer_vht_caps = param->peer_vht_caps;
cmd->peer_phymode = param->peer_phymode;
/* Update 11ax capabilities */
cmd->peer_he_cap_info = param->peer_he_cap_macinfo[0];
cmd->peer_he_cap_info_ext = param->peer_he_cap_macinfo[1];
cmd->peer_he_cap_info_internal = param->peer_he_cap_macinfo_internal;
cmd->peer_he_caps_6ghz = param->peer_he_caps_6ghz;
cmd->peer_he_ops = param->peer_he_ops;
memcpy(&cmd->peer_he_cap_phy, &param->peer_he_cap_phyinfo,
sizeof(param->peer_he_cap_phyinfo));
memcpy(&cmd->peer_ppet, &param->peer_ppet,
sizeof(param->peer_ppet));
/* Update peer legacy rate information */
ptr += sizeof(*cmd);
tlv = ptr;
tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_BYTE) |
FIELD_PREP(WMI_TLV_LEN, peer_legacy_rates_align);
ptr += TLV_HDR_SIZE;
cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
memcpy(ptr, param->peer_legacy_rates.rates,
param->peer_legacy_rates.num_rates);
/* Update peer HT rate information */
ptr += peer_legacy_rates_align;
tlv = ptr;
tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_BYTE) |
FIELD_PREP(WMI_TLV_LEN, peer_ht_rates_align);
ptr += TLV_HDR_SIZE;
cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
memcpy(ptr, param->peer_ht_rates.rates,
param->peer_ht_rates.num_rates);
/* VHT Rates */
ptr += peer_ht_rates_align;
mcs = ptr;
mcs->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_VHT_RATE_SET) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*mcs) - TLV_HDR_SIZE);
cmd->peer_nss = param->peer_nss;
/* Update bandwidth-NSS mapping */
cmd->peer_bw_rxnss_override = 0;
cmd->peer_bw_rxnss_override |= param->peer_bw_rxnss_override;
if (param->vht_capable) {
mcs->rx_max_rate = param->rx_max_rate;
mcs->rx_mcs_set = param->rx_mcs_set;
mcs->tx_max_rate = param->tx_max_rate;
mcs->tx_mcs_set = param->tx_mcs_set;
}
/* HE Rates */
cmd->peer_he_mcs = param->peer_he_mcs_count;
cmd->min_data_rate = param->min_data_rate;
ptr += sizeof(*mcs);
len = param->peer_he_mcs_count * sizeof(*he_mcs);
tlv = ptr;
tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_STRUCT) |
FIELD_PREP(WMI_TLV_LEN, len);
ptr += TLV_HDR_SIZE;
/* Loop through the HE rate set */
for (i = 0; i < param->peer_he_mcs_count; i++) {
he_mcs = ptr;
he_mcs->tlv_header = FIELD_PREP(WMI_TLV_TAG,
WMI_TAG_HE_RATE_SET) |
FIELD_PREP(WMI_TLV_LEN,
sizeof(*he_mcs) - TLV_HDR_SIZE);
he_mcs->rx_mcs_set = param->peer_he_tx_mcs_set[i];
he_mcs->tx_mcs_set = param->peer_he_rx_mcs_set[i];
ptr += sizeof(*he_mcs);
}
ret = ath11k_wmi_cmd_send(wmi, skb, WMI_PEER_ASSOC_CMDID);
if (ret) {
ath11k_warn(ar->ab,
"failed to send WMI_PEER_ASSOC_CMDID\n");
dev_kfree_skb(skb);
}
ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
"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",
cmd->vdev_id, cmd->peer_associd, param->peer_mac,
cmd->peer_flags, cmd->peer_rate_caps, cmd->peer_caps,
cmd->peer_listen_intval, cmd->peer_ht_caps,
cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
cmd->peer_mpdu_density,
cmd->peer_vht_caps, cmd->peer_he_cap_info,
cmd->peer_he_ops, cmd->peer_he_cap_info_ext,
cmd->peer_he_cap_phy[0], cmd->peer_he_cap_phy[1],
cmd->peer_he_cap_phy[2],
cmd->peer_bw_rxnss_override);
return ret;
}
void ath11k_wmi_start_scan_init(struct ath11k *ar,
struct scan_req_params *arg)
{
/* setup commonly used values */
arg->scan_req_id = 1;
arg->scan_priority = WMI_SCAN_PRIORITY_LOW;
arg->dwell_time_active = 50;
arg->dwell_time_active_2g = 0;
arg->dwell_time_passive = 150;
arg->dwell_time_active_6g = 40;
arg->dwell_time_passive_6g = 30;
arg->min_rest_time = 50;
arg->max_rest_time = 500;
arg->repeat_probe_time = 0;
arg->probe_spacing_time = 0;
arg->idle_time = 0;
arg->max_scan_time = 20000;
arg->probe_delay = 5;
arg->notify_scan_events = WMI_SCAN_EVENT_STARTED |
WMI_SCAN_EVENT_COMPLETED |
WMI_SCAN_EVENT_BSS_CHANNEL |
WMI_SCAN_EVENT_FOREIGN_CHAN |
WMI_SCAN_EVENT_DEQUEUED;
arg->scan_flags |= WMI_SCAN_CHAN_STAT_EVENT;
arg->num_bssid = 1;
/* fill bssid_list[0] with 0xff, otherwise bssid and RA will be
* ZEROs in probe request
*/
eth_broadcast_addr(arg->bssid_list[0].addr);
}
static inline void
ath11k_wmi_copy_scan_event_cntrl_flags(struct wmi_start_scan_cmd *cmd,
struct scan_req_params *param)
{
/* Scan events subscription */
if (param->scan_ev_started)
cmd->notify_scan_events |= WMI_SCAN_EVENT_STARTED;
if (param->scan_ev_completed)
cmd->notify_scan_events |= WMI_SCAN_EVENT_COMPLETED;
if (param->scan_ev_bss_chan)
cmd->notify_scan_events |= WMI_SCAN_EVENT_BSS_CHANNEL;
if (param->scan_ev_foreign_chan)
cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHAN;
if (param->scan_ev_dequeued)
cmd->notify_scan_events |= WMI_SCAN_EVENT_DEQUEUED;
if (param->scan_ev_preempted)
cmd->notify_scan_events |= WMI_SCAN_EVENT_PREEMPTED;
if (param->scan_ev_start_failed)
cmd->notify_scan_events |= WMI_SCAN_EVENT_START_FAILED;
if (param->scan_ev_restarted)
cmd->notify_scan_events |= WMI_SCAN_EVENT_RESTARTED;
if (param->scan_ev_foreign_chn_exit)
cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHAN_EXIT;
if (param->scan_ev_suspended)
cmd->notify_scan_events |= WMI_SCAN_EVENT_SUSPENDED;
if (param->scan_ev_resumed)
cmd->notify_scan_events |= WMI_SCAN_EVENT_RESUMED;
/** Set scan control flags */
cmd->scan_ctrl_flags = 0;
if (param->scan_f_passive)
cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_PASSIVE;
if (param->scan_f_strict_passive_pch)
cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_STRICT_PASSIVE_ON_PCHN;
if (param->scan_f_promisc_mode)
cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROMISCUOS;
if (param->scan_f_capture_phy_err)
cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
if (param->scan_f_half_rate)
cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_HALF_RATE_SUPPORT;
if (param->scan_f_quarter_rate)
cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_QUARTER_RATE_SUPPORT;
if (param->scan_f_cck_rates)
cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
if (param->scan_f_ofdm_rates)
cmd->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
if (param->scan_f_chan_stat_evnt)
cmd->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
if (param->scan_f_filter_prb_req)
cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROBE_REQ;
if (param->scan_f_bcast_probe)
cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
if (param->scan_f_offchan_mgmt_tx)
cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_MGMT_TX;
if (param->scan_f_offchan_data_tx)
cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_DATA_TX;
if (param->scan_f_force_active_dfs_chn)
cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_FORCE_ACTIVE_ON_DFS;
if (param->scan_f_add_tpc_ie_in_probe)
cmd->scan_ctrl_flags |= WMI_SCAN_ADD_TPC_IE_IN_PROBE_REQ;
if (param->scan_f_add_ds_ie_in_probe)
cmd->scan_ctrl_flags |= WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
if (param->scan_f_add_spoofed_mac_in_probe)
cmd->scan_ctrl_flags |= WMI_SCAN_ADD_SPOOF_MAC_IN_PROBE_REQ;
if (param->scan_f_add_rand_seq_in_probe)
cmd->scan_ctrl_flags |= WMI_SCAN_RANDOM_SEQ_NO_IN_PROBE_REQ;
if (param->scan_f_en_ie_whitelist_in_probe)
cmd->scan_ctrl_flags |=
WMI_SCAN_ENABLE_IE_WHTELIST_IN_PROBE_REQ;
/* for adaptive scan mode using 3 bits (21 - 23 bits) */
WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
param->adaptive_dwell_time_mode);
}
int ath11k_wmi_send_scan_start_cmd(struct ath11k *ar,
struct scan_req_params *params)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_start_scan_cmd *cmd;
struct wmi_ssid *ssid = NULL;
struct wmi_mac_addr *bssid;
struct sk_buff *skb;
struct wmi_tlv *tlv;
void *ptr;
int i, ret, len;
u32 *tmp_ptr;
u8 extraie_len_with_pad = 0;
struct hint_short_ssid *s_ssid = NULL;
struct hint_bssid *hint_bssid = NULL;
len = sizeof(*cmd);
len += TLV_HDR_SIZE;
if (params->num_chan)
len += params->num_chan * sizeof(u32);
len += TLV_HDR_SIZE;
if (params->num_ssids)
len += params->num_ssids * sizeof(*ssid);
len += TLV_HDR_SIZE;
if (params->num_bssid)
len += sizeof(*bssid) * params->num_bssid;
len += TLV_HDR_SIZE;
if (params->extraie.len)
extraie_len_with_pad =
roundup(params->extraie.len, sizeof(u32));
len += extraie_len_with_pad;
if (params->num_hint_bssid)
len += TLV_HDR_SIZE +
params->num_hint_bssid * sizeof(struct hint_bssid);
if (params->num_hint_s_ssid)
len += TLV_HDR_SIZE +
params->num_hint_s_ssid * sizeof(struct hint_short_ssid);
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len);
if (!skb)
return -ENOMEM;
ptr = skb->data;
cmd = ptr;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_START_SCAN_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->scan_id = params->scan_id;
cmd->scan_req_id = params->scan_req_id;
cmd->vdev_id = params->vdev_id;
cmd->scan_priority = params->scan_priority;
cmd->notify_scan_events = params->notify_scan_events;
ath11k_wmi_copy_scan_event_cntrl_flags(cmd, params);
cmd->dwell_time_active = params->dwell_time_active;
cmd->dwell_time_active_2g = params->dwell_time_active_2g;
cmd->dwell_time_passive = params->dwell_time_passive;
cmd->dwell_time_active_6g = params->dwell_time_active_6g;
cmd->dwell_time_passive_6g = params->dwell_time_passive_6g;
cmd->min_rest_time = params->min_rest_time;
cmd->max_rest_time = params->max_rest_time;
cmd->repeat_probe_time = params->repeat_probe_time;
cmd->probe_spacing_time = params->probe_spacing_time;
cmd->idle_time = params->idle_time;
cmd->max_scan_time = params->max_scan_time;
cmd->probe_delay = params->probe_delay;
cmd->burst_duration = params->burst_duration;
cmd->num_chan = params->num_chan;
cmd->num_bssid = params->num_bssid;
cmd->num_ssids = params->num_ssids;
cmd->ie_len = params->extraie.len;
cmd->n_probes = params->n_probes;
ptr += sizeof(*cmd);
len = params->num_chan * sizeof(u32);
tlv = ptr;
tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_UINT32) |
FIELD_PREP(WMI_TLV_LEN, len);
ptr += TLV_HDR_SIZE;
tmp_ptr = (u32 *)ptr;
for (i = 0; i < params->num_chan; ++i)
tmp_ptr[i] = params->chan_list[i];
ptr += len;
len = params->num_ssids * sizeof(*ssid);
tlv = ptr;
tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_FIXED_STRUCT) |
FIELD_PREP(WMI_TLV_LEN, len);
ptr += TLV_HDR_SIZE;
if (params->num_ssids) {
ssid = ptr;
for (i = 0; i < params->num_ssids; ++i) {
ssid->ssid_len = params->ssid[i].length;
memcpy(ssid->ssid, params->ssid[i].ssid,
params->ssid[i].length);
ssid++;
}
}
ptr += (params->num_ssids * sizeof(*ssid));
len = params->num_bssid * sizeof(*bssid);
tlv = ptr;
tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_FIXED_STRUCT) |
FIELD_PREP(WMI_TLV_LEN, len);
ptr += TLV_HDR_SIZE;
bssid = ptr;
if (params->num_bssid) {
for (i = 0; i < params->num_bssid; ++i) {
ether_addr_copy(bssid->addr,
params->bssid_list[i].addr);
bssid++;
}
}
ptr += params->num_bssid * sizeof(*bssid);
len = extraie_len_with_pad;
tlv = ptr;
tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_BYTE) |
FIELD_PREP(WMI_TLV_LEN, len);
ptr += TLV_HDR_SIZE;
if (params->extraie.len)
memcpy(ptr, params->extraie.ptr,
params->extraie.len);
ptr += extraie_len_with_pad;
if (params->num_hint_s_ssid) {
len = params->num_hint_s_ssid * sizeof(struct hint_short_ssid);
tlv = ptr;
tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_FIXED_STRUCT) |
FIELD_PREP(WMI_TLV_LEN, len);
ptr += TLV_HDR_SIZE;
s_ssid = ptr;
for (i = 0; i < params->num_hint_s_ssid; ++i) {
s_ssid->freq_flags = params->hint_s_ssid[i].freq_flags;
s_ssid->short_ssid = params->hint_s_ssid[i].short_ssid;
s_ssid++;
}
ptr += len;
}
if (params->num_hint_bssid) {
len = params->num_hint_bssid * sizeof(struct hint_bssid);
tlv = ptr;
tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_FIXED_STRUCT) |
FIELD_PREP(WMI_TLV_LEN, len);
ptr += TLV_HDR_SIZE;
hint_bssid = ptr;
for (i = 0; i < params->num_hint_bssid; ++i) {
hint_bssid->freq_flags =
params->hint_bssid[i].freq_flags;
ether_addr_copy(&params->hint_bssid[i].bssid.addr[0],
&hint_bssid->bssid.addr[0]);
hint_bssid++;
}
}
ret = ath11k_wmi_cmd_send(wmi, skb,
WMI_START_SCAN_CMDID);
if (ret) {
ath11k_warn(ar->ab, "failed to send WMI_START_SCAN_CMDID\n");
dev_kfree_skb(skb);
}
return ret;
}
int ath11k_wmi_send_scan_stop_cmd(struct ath11k *ar,
struct scan_cancel_param *param)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_stop_scan_cmd *cmd;
struct sk_buff *skb;
int ret;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd));
if (!skb)
return -ENOMEM;
cmd = (struct wmi_stop_scan_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_STOP_SCAN_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->vdev_id = param->vdev_id;
cmd->requestor = param->requester;
cmd->scan_id = param->scan_id;
cmd->pdev_id = param->pdev_id;
/* stop the scan with the corresponding scan_id */
if (param->req_type == WLAN_SCAN_CANCEL_PDEV_ALL) {
/* Cancelling all scans */
cmd->req_type = WMI_SCAN_STOP_ALL;
} else if (param->req_type == WLAN_SCAN_CANCEL_VDEV_ALL) {
/* Cancelling VAP scans */
cmd->req_type = WMI_SCN_STOP_VAP_ALL;
} else if (param->req_type == WLAN_SCAN_CANCEL_SINGLE) {
/* Cancelling specific scan */
cmd->req_type = WMI_SCAN_STOP_ONE;
} else {
ath11k_warn(ar->ab, "invalid scan cancel param %d",
param->req_type);
dev_kfree_skb(skb);
return -EINVAL;
}
ret = ath11k_wmi_cmd_send(wmi, skb,
WMI_STOP_SCAN_CMDID);
if (ret) {
ath11k_warn(ar->ab, "failed to send WMI_STOP_SCAN_CMDID\n");
dev_kfree_skb(skb);
}
return ret;
}
int ath11k_wmi_send_scan_chan_list_cmd(struct ath11k *ar,
struct scan_chan_list_params *chan_list)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_scan_chan_list_cmd *cmd;
struct sk_buff *skb;
struct wmi_channel *chan_info;
struct channel_param *tchan_info;
struct wmi_tlv *tlv;
void *ptr;
int i, ret, len;
u16 num_send_chans, num_sends = 0, max_chan_limit = 0;
u32 *reg1, *reg2;
tchan_info = chan_list->ch_param;
while (chan_list->nallchans) {
len = sizeof(*cmd) + TLV_HDR_SIZE;
max_chan_limit = (wmi->wmi_ab->max_msg_len[ar->pdev_idx] - len) /
sizeof(*chan_info);
if (chan_list->nallchans > max_chan_limit)
num_send_chans = max_chan_limit;
else
num_send_chans = chan_list->nallchans;
chan_list->nallchans -= num_send_chans;
len += sizeof(*chan_info) * num_send_chans;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len);
if (!skb)
return -ENOMEM;
cmd = (struct wmi_scan_chan_list_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_SCAN_CHAN_LIST_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->pdev_id = chan_list->pdev_id;
cmd->num_scan_chans = num_send_chans;
if (num_sends)
cmd->flags |= WMI_APPEND_TO_EXISTING_CHAN_LIST_FLAG;
ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
"WMI no.of chan = %d len = %d pdev_id = %d num_sends = %d\n",
num_send_chans, len, cmd->pdev_id, num_sends);
ptr = skb->data + sizeof(*cmd);
len = sizeof(*chan_info) * num_send_chans;
tlv = ptr;
tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_STRUCT) |
FIELD_PREP(WMI_TLV_LEN, len - TLV_HDR_SIZE);
ptr += TLV_HDR_SIZE;
for (i = 0; i < num_send_chans; ++i) {
chan_info = ptr;
memset(chan_info, 0, sizeof(*chan_info));
len = sizeof(*chan_info);
chan_info->tlv_header = FIELD_PREP(WMI_TLV_TAG,
WMI_TAG_CHANNEL) |
FIELD_PREP(WMI_TLV_LEN,
len - TLV_HDR_SIZE);
reg1 = &chan_info->reg_info_1;
reg2 = &chan_info->reg_info_2;
chan_info->mhz = tchan_info->mhz;
chan_info->band_center_freq1 = tchan_info->cfreq1;
chan_info->band_center_freq2 = tchan_info->cfreq2;
if (tchan_info->is_chan_passive)
chan_info->info |= WMI_CHAN_INFO_PASSIVE;
if (tchan_info->allow_he)
chan_info->info |= WMI_CHAN_INFO_ALLOW_HE;
else if (tchan_info->allow_vht)
chan_info->info |= WMI_CHAN_INFO_ALLOW_VHT;
else if (tchan_info->allow_ht)
chan_info->info |= WMI_CHAN_INFO_ALLOW_HT;
if (tchan_info->half_rate)
chan_info->info |= WMI_CHAN_INFO_HALF_RATE;
if (tchan_info->quarter_rate)
chan_info->info |= WMI_CHAN_INFO_QUARTER_RATE;
if (tchan_info->psc_channel)
chan_info->info |= WMI_CHAN_INFO_PSC;
if (tchan_info->dfs_set)
chan_info->info |= WMI_CHAN_INFO_DFS;
chan_info->info |= FIELD_PREP(WMI_CHAN_INFO_MODE,
tchan_info->phy_mode);
*reg1 |= FIELD_PREP(WMI_CHAN_REG_INFO1_MIN_PWR,
tchan_info->minpower);
*reg1 |= FIELD_PREP(WMI_CHAN_REG_INFO1_MAX_PWR,
tchan_info->maxpower);
*reg1 |= FIELD_PREP(WMI_CHAN_REG_INFO1_MAX_REG_PWR,
tchan_info->maxregpower);
*reg1 |= FIELD_PREP(WMI_CHAN_REG_INFO1_REG_CLS,
tchan_info->reg_class_id);
*reg2 |= FIELD_PREP(WMI_CHAN_REG_INFO2_ANT_MAX,
tchan_info->antennamax);
ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
"WMI chan scan list chan[%d] = %u, chan_info->info %8x\n",
i, chan_info->mhz, chan_info->info);
ptr += sizeof(*chan_info);
tchan_info++;
}
ret = ath11k_wmi_cmd_send(wmi, skb, WMI_SCAN_CHAN_LIST_CMDID);
if (ret) {
ath11k_warn(ar->ab, "failed to send WMI_SCAN_CHAN_LIST cmd\n");
dev_kfree_skb(skb);
return ret;
}
num_sends++;
}
return 0;
}
int ath11k_wmi_send_wmm_update_cmd_tlv(struct ath11k *ar, u32 vdev_id,
struct wmi_wmm_params_all_arg *param)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_vdev_set_wmm_params_cmd *cmd;
struct wmi_wmm_params *wmm_param;
struct wmi_wmm_params_arg *wmi_wmm_arg;
struct sk_buff *skb;
int ret, ac;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd));
if (!skb)
return -ENOMEM;
cmd = (struct wmi_vdev_set_wmm_params_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG,
WMI_TAG_VDEV_SET_WMM_PARAMS_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->vdev_id = vdev_id;
cmd->wmm_param_type = 0;
for (ac = 0; ac < WME_NUM_AC; ac++) {
switch (ac) {
case WME_AC_BE:
wmi_wmm_arg = &param->ac_be;
break;
case WME_AC_BK:
wmi_wmm_arg = &param->ac_bk;
break;
case WME_AC_VI:
wmi_wmm_arg = &param->ac_vi;
break;
case WME_AC_VO:
wmi_wmm_arg = &param->ac_vo;
break;
}
wmm_param = (struct wmi_wmm_params *)&cmd->wmm_params[ac];
wmm_param->tlv_header =
FIELD_PREP(WMI_TLV_TAG,
WMI_TAG_VDEV_SET_WMM_PARAMS_CMD) |
FIELD_PREP(WMI_TLV_LEN,
sizeof(*wmm_param) - TLV_HDR_SIZE);
wmm_param->aifs = wmi_wmm_arg->aifs;
wmm_param->cwmin = wmi_wmm_arg->cwmin;
wmm_param->cwmax = wmi_wmm_arg->cwmax;
wmm_param->txoplimit = wmi_wmm_arg->txop;
wmm_param->acm = wmi_wmm_arg->acm;
wmm_param->no_ack = wmi_wmm_arg->no_ack;
ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
"wmi wmm set ac %d aifs %d cwmin %d cwmax %d txop %d acm %d no_ack %d\n",
ac, wmm_param->aifs, wmm_param->cwmin,
wmm_param->cwmax, wmm_param->txoplimit,
wmm_param->acm, wmm_param->no_ack);
}
ret = ath11k_wmi_cmd_send(wmi, skb,
WMI_VDEV_SET_WMM_PARAMS_CMDID);
if (ret) {
ath11k_warn(ar->ab,
"failed to send WMI_VDEV_SET_WMM_PARAMS_CMDID");
dev_kfree_skb(skb);
}
return ret;
}
int ath11k_wmi_send_dfs_phyerr_offload_enable_cmd(struct ath11k *ar,
u32 pdev_id)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_dfs_phyerr_offload_cmd *cmd;
struct sk_buff *skb;
int ret;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd));
if (!skb)
return -ENOMEM;
cmd = (struct wmi_dfs_phyerr_offload_cmd *)skb->data;
cmd->tlv_header =
FIELD_PREP(WMI_TLV_TAG,
WMI_TAG_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->pdev_id = pdev_id;
ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
"WMI dfs phy err offload enable pdev id %d\n", pdev_id);
ret = ath11k_wmi_cmd_send(wmi, skb,
WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID);
if (ret) {
ath11k_warn(ar->ab,
"failed to send WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE cmd\n");
dev_kfree_skb(skb);
}
return ret;
}
int ath11k_wmi_delba_send(struct ath11k *ar, u32 vdev_id, const u8 *mac,
u32 tid, u32 initiator, u32 reason)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_delba_send_cmd *cmd;
struct sk_buff *skb;
int ret;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd));
if (!skb)
return -ENOMEM;
cmd = (struct wmi_delba_send_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_DELBA_SEND_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->vdev_id = vdev_id;
ether_addr_copy(cmd->peer_macaddr.addr, mac);
cmd->tid = tid;
cmd->initiator = initiator;
cmd->reasoncode = reason;
ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
"wmi delba send vdev_id 0x%X mac_addr %pM tid %u initiator %u reason %u\n",
vdev_id, mac, tid, initiator, reason);
ret = ath11k_wmi_cmd_send(wmi, skb, WMI_DELBA_SEND_CMDID);
if (ret) {
ath11k_warn(ar->ab,
"failed to send WMI_DELBA_SEND_CMDID cmd\n");
dev_kfree_skb(skb);
}
return ret;
}
int ath11k_wmi_addba_set_resp(struct ath11k *ar, u32 vdev_id, const u8 *mac,
u32 tid, u32 status)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_addba_setresponse_cmd *cmd;
struct sk_buff *skb;
int ret;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd));
if (!skb)
return -ENOMEM;
cmd = (struct wmi_addba_setresponse_cmd *)skb->data;
cmd->tlv_header =
FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ADDBA_SETRESPONSE_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->vdev_id = vdev_id;
ether_addr_copy(cmd->peer_macaddr.addr, mac);
cmd->tid = tid;
cmd->statuscode = status;
ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
"wmi addba set resp vdev_id 0x%X mac_addr %pM tid %u status %u\n",
vdev_id, mac, tid, status);
ret = ath11k_wmi_cmd_send(wmi, skb, WMI_ADDBA_SET_RESP_CMDID);
if (ret) {
ath11k_warn(ar->ab,
"failed to send WMI_ADDBA_SET_RESP_CMDID cmd\n");
dev_kfree_skb(skb);
}
return ret;
}
int ath11k_wmi_addba_send(struct ath11k *ar, u32 vdev_id, const u8 *mac,
u32 tid, u32 buf_size)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_addba_send_cmd *cmd;
struct sk_buff *skb;
int ret;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd));
if (!skb)
return -ENOMEM;
cmd = (struct wmi_addba_send_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ADDBA_SEND_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->vdev_id = vdev_id;
ether_addr_copy(cmd->peer_macaddr.addr, mac);
cmd->tid = tid;
cmd->buffersize = buf_size;
ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
"wmi addba send vdev_id 0x%X mac_addr %pM tid %u bufsize %u\n",
vdev_id, mac, tid, buf_size);
ret = ath11k_wmi_cmd_send(wmi, skb, WMI_ADDBA_SEND_CMDID);
if (ret) {
ath11k_warn(ar->ab,
"failed to send WMI_ADDBA_SEND_CMDID cmd\n");
dev_kfree_skb(skb);
}
return ret;
}
int ath11k_wmi_addba_clear_resp(struct ath11k *ar, u32 vdev_id, const u8 *mac)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_addba_clear_resp_cmd *cmd;
struct sk_buff *skb;
int ret;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd));
if (!skb)
return -ENOMEM;
cmd = (struct wmi_addba_clear_resp_cmd *)skb->data;
cmd->tlv_header =
FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ADDBA_CLEAR_RESP_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->vdev_id = vdev_id;
ether_addr_copy(cmd->peer_macaddr.addr, mac);
ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
"wmi addba clear resp vdev_id 0x%X mac_addr %pM\n",
vdev_id, mac);
ret = ath11k_wmi_cmd_send(wmi, skb, WMI_ADDBA_CLEAR_RESP_CMDID);
if (ret) {
ath11k_warn(ar->ab,
"failed to send WMI_ADDBA_CLEAR_RESP_CMDID cmd\n");
dev_kfree_skb(skb);
}
return ret;
}
int ath11k_wmi_pdev_peer_pktlog_filter(struct ath11k *ar, u8 *addr, u8 enable)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_pdev_pktlog_filter_cmd *cmd;
struct wmi_pdev_pktlog_filter_info *info;
struct sk_buff *skb;
struct wmi_tlv *tlv;
void *ptr;
int ret, len;
len = sizeof(*cmd) + sizeof(*info) + TLV_HDR_SIZE;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len);
if (!skb)
return -ENOMEM;
cmd = (struct wmi_pdev_pktlog_filter_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_PDEV_PEER_PKTLOG_FILTER_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->pdev_id = DP_HW2SW_MACID(ar->pdev->pdev_id);
cmd->num_mac = 1;
cmd->enable = enable;
ptr = skb->data + sizeof(*cmd);
tlv = ptr;
tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_STRUCT) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*info));
ptr += TLV_HDR_SIZE;
info = ptr;
ether_addr_copy(info->peer_macaddr.addr, addr);
info->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_PDEV_PEER_PKTLOG_FILTER_INFO) |
FIELD_PREP(WMI_TLV_LEN,
sizeof(*info) - TLV_HDR_SIZE);
ret = ath11k_wmi_cmd_send(wmi, skb,
WMI_PDEV_PKTLOG_FILTER_CMDID);
if (ret) {
ath11k_warn(ar->ab, "failed to send WMI_PDEV_PKTLOG_ENABLE_CMDID\n");
dev_kfree_skb(skb);
}
return ret;
}
int
ath11k_wmi_send_init_country_cmd(struct ath11k *ar,
struct wmi_init_country_params init_cc_params)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_init_country_cmd *cmd;
struct sk_buff *skb;
int ret;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd));
if (!skb)
return -ENOMEM;
cmd = (struct wmi_init_country_cmd *)skb->data;
cmd->tlv_header =
FIELD_PREP(WMI_TLV_TAG,
WMI_TAG_SET_INIT_COUNTRY_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->pdev_id = ar->pdev->pdev_id;
switch (init_cc_params.flags) {
case ALPHA_IS_SET:
cmd->init_cc_type = WMI_COUNTRY_INFO_TYPE_ALPHA;
memcpy((u8 *)&cmd->cc_info.alpha2,
init_cc_params.cc_info.alpha2, 3);
break;
case CC_IS_SET:
cmd->init_cc_type = WMI_COUNTRY_INFO_TYPE_COUNTRY_CODE;
cmd->cc_info.country_code = init_cc_params.cc_info.country_code;
break;
case REGDMN_IS_SET:
cmd->init_cc_type = WMI_COUNTRY_INFO_TYPE_REGDOMAIN;
cmd->cc_info.regdom_id = init_cc_params.cc_info.regdom_id;
break;
default:
ret = -EINVAL;
goto out;
}
ret = ath11k_wmi_cmd_send(wmi, skb,
WMI_SET_INIT_COUNTRY_CMDID);
out:
if (ret) {
ath11k_warn(ar->ab,
"failed to send WMI_SET_INIT_COUNTRY CMD :%d\n",
ret);
dev_kfree_skb(skb);
}
return ret;
}
int
ath11k_wmi_send_thermal_mitigation_param_cmd(struct ath11k *ar,
struct thermal_mitigation_params *param)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_therm_throt_config_request_cmd *cmd;
struct wmi_therm_throt_level_config_info *lvl_conf;
struct wmi_tlv *tlv;
struct sk_buff *skb;
int i, ret, len;
len = sizeof(*cmd) + TLV_HDR_SIZE +
THERMAL_LEVELS * sizeof(struct wmi_therm_throt_level_config_info);
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len);
if (!skb)
return -ENOMEM;
cmd = (struct wmi_therm_throt_config_request_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_THERM_THROT_CONFIG_REQUEST) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->pdev_id = ar->pdev->pdev_id;
cmd->enable = param->enable;
cmd->dc = param->dc;
cmd->dc_per_event = param->dc_per_event;
cmd->therm_throt_levels = THERMAL_LEVELS;
tlv = (struct wmi_tlv *)(skb->data + sizeof(*cmd));
tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_STRUCT) |
FIELD_PREP(WMI_TLV_LEN,
(THERMAL_LEVELS *
sizeof(struct wmi_therm_throt_level_config_info)));
lvl_conf = (struct wmi_therm_throt_level_config_info *)(skb->data +
sizeof(*cmd) +
TLV_HDR_SIZE);
for (i = 0; i < THERMAL_LEVELS; i++) {
lvl_conf->tlv_header =
FIELD_PREP(WMI_TLV_TAG, WMI_TAG_THERM_THROT_LEVEL_CONFIG_INFO) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*lvl_conf) - TLV_HDR_SIZE);
lvl_conf->temp_lwm = param->levelconf[i].tmplwm;
lvl_conf->temp_hwm = param->levelconf[i].tmphwm;
lvl_conf->dc_off_percent = param->levelconf[i].dcoffpercent;
lvl_conf->prio = param->levelconf[i].priority;
lvl_conf++;
}
ret = ath11k_wmi_cmd_send(wmi, skb, WMI_THERM_THROT_SET_CONF_CMDID);
if (ret) {
ath11k_warn(ar->ab, "failed to send THERM_THROT_SET_CONF cmd\n");
dev_kfree_skb(skb);
}
ath11k_dbg(ar->ab, ATH11K_DBG_WMI,
"WMI vdev set thermal throt pdev_id %d enable %d dc %d dc_per_event %x levels %d\n",
ar->pdev->pdev_id, param->enable, param->dc,
param->dc_per_event, THERMAL_LEVELS);
return ret;
}
int ath11k_wmi_pdev_pktlog_enable(struct ath11k *ar, u32 pktlog_filter)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_pktlog_enable_cmd *cmd;
struct sk_buff *skb;
int ret;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd));
if (!skb)
return -ENOMEM;
cmd = (struct wmi_pktlog_enable_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_PDEV_PKTLOG_ENABLE_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->pdev_id = DP_HW2SW_MACID(ar->pdev->pdev_id);
cmd->evlist = pktlog_filter;
cmd->enable = ATH11K_WMI_PKTLOG_ENABLE_FORCE;
ret = ath11k_wmi_cmd_send(wmi, skb,
WMI_PDEV_PKTLOG_ENABLE_CMDID);
if (ret) {
ath11k_warn(ar->ab, "failed to send WMI_PDEV_PKTLOG_ENABLE_CMDID\n");
dev_kfree_skb(skb);
}
return ret;
}
int ath11k_wmi_pdev_pktlog_disable(struct ath11k *ar)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct wmi_pktlog_disable_cmd *cmd;
struct sk_buff *skb;
int ret;
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, sizeof(*cmd));
if (!skb)
return -ENOMEM;
cmd = (struct wmi_pktlog_disable_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_PDEV_PKTLOG_DISABLE_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->pdev_id = DP_HW2SW_MACID(ar->pdev->pdev_id);
ret = ath11k_wmi_cmd_send(wmi, skb,
WMI_PDEV_PKTLOG_DISABLE_CMDID);
if (ret) {
ath11k_warn(ar->ab, "failed to send WMI_PDEV_PKTLOG_ENABLE_CMDID\n");
dev_kfree_skb(skb);
}
return ret;
}
int
ath11k_wmi_send_twt_enable_cmd(struct ath11k *ar, u32 pdev_id)
{
struct ath11k_pdev_wmi *wmi = ar->wmi;
struct ath11k_base *ab = wmi->wmi_ab->ab;
struct wmi_twt_enable_params_cmd *cmd;
struct sk_buff *skb;
int ret, len;
len = sizeof(*cmd);
skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len);
if (!skb)
return -ENOMEM;
cmd = (struct wmi_twt_enable_params_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_TWT_ENABLE_CMD) |
FIELD_PREP(WMI_TLV_LEN, len - TLV_HDR_SIZE);
cmd->pdev_id = pdev_id;
cmd->sta_cong_timer_ms = ATH11K_TWT_DEF_STA_CONG_TIMER_MS;
cmd->default_slot_size = ATH11K_TWT_DEF_DEFAULT_SLOT_SIZE;
cmd->congestion_thresh_setup = ATH11K_TWT_DEF_CONGESTION_THRESH_SETUP;
cmd->congestion_thresh_teardown =
ATH11K_TWT_DEF_CONGESTION_THRESH_TEARDOWN;
cmd->congestion_thresh_critical =
ATH11K_TWT_DEF_CONGESTION_THRESH_CRITICAL;
cmd->interference_thresh_teardown =
ATH11K_TWT_DEF_INTERFERENCE_THRESH_TEARDOWN;
cmd->interference_thresh_setup =
ATH11K_TWT_DEF_INTERFERENCE_THRESH_SETUP;
cmd->min_no_sta_setup = ATH11K_TWT_DEF_MIN_NO_STA_SETUP;
cmd->min_no_sta_teardown = ATH11K_TWT_DEF_MIN_NO_STA_TEARDOWN;
cmd->no_of_bcast_mcast_slots = ATH11K_TWT_DEF_NO_OF_BCAST_MCAST_SLOTS;
cmd->min_no_twt_slots = ATH11K_TWT_DEF_MIN_NO_TWT_SLOTS;
cmd->max_no_sta_twt = ATH11K_TWT_DEF_MAX_NO_STA_TWT;