2013-10-08 21:25:58 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2013 Eugene Krasnikov <k.eugene.e@gmail.com>
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
|
|
|
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
|
|
|
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
2014-02-12 19:04:43 +00:00
|
|
|
#include <linux/firmware.h>
|
2013-10-08 21:25:58 +01:00
|
|
|
#include <linux/platform_device.h>
|
2023-07-24 15:19:13 -06:00
|
|
|
#include <linux/of.h>
|
2016-06-19 23:19:45 -07:00
|
|
|
#include <linux/of_address.h>
|
2017-03-27 22:26:33 -07:00
|
|
|
#include <linux/rpmsg.h>
|
2017-01-11 16:32:18 +02:00
|
|
|
#include <linux/soc/qcom/smem_state.h>
|
|
|
|
#include <linux/soc/qcom/wcnss_ctrl.h>
|
2021-06-05 02:11:33 +01:00
|
|
|
#include <net/ipv6.h>
|
2013-10-08 21:25:58 +01:00
|
|
|
#include "wcn36xx.h"
|
2018-05-22 22:02:56 +03:00
|
|
|
#include "testmode.h"
|
2022-07-27 17:16:53 +01:00
|
|
|
#include "firmware.h"
|
2013-10-08 21:25:58 +01:00
|
|
|
|
|
|
|
unsigned int wcn36xx_dbg_mask;
|
|
|
|
module_param_named(debug_mask, wcn36xx_dbg_mask, uint, 0644);
|
|
|
|
MODULE_PARM_DESC(debug_mask, "Debugging mask");
|
|
|
|
|
|
|
|
#define CHAN2G(_freq, _idx) { \
|
2016-04-12 15:56:15 +02:00
|
|
|
.band = NL80211_BAND_2GHZ, \
|
2013-10-08 21:25:58 +01:00
|
|
|
.center_freq = (_freq), \
|
|
|
|
.hw_value = (_idx), \
|
|
|
|
.max_power = 25, \
|
|
|
|
}
|
|
|
|
|
2020-09-21 16:21:17 +03:00
|
|
|
#define CHAN5G(_freq, _idx, _phy_val) { \
|
2016-04-12 15:56:15 +02:00
|
|
|
.band = NL80211_BAND_5GHZ, \
|
2013-10-08 21:25:58 +01:00
|
|
|
.center_freq = (_freq), \
|
2020-09-21 16:21:17 +03:00
|
|
|
.hw_value = (_phy_val) << HW_VALUE_PHY_SHIFT | HW_VALUE_CHANNEL(_idx), \
|
2013-10-08 21:25:58 +01:00
|
|
|
.max_power = 25, \
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The wcn firmware expects channel values to matching
|
|
|
|
* their mnemonic values. So use these for .hw_value. */
|
|
|
|
static struct ieee80211_channel wcn_2ghz_channels[] = {
|
|
|
|
CHAN2G(2412, 1), /* Channel 1 */
|
|
|
|
CHAN2G(2417, 2), /* Channel 2 */
|
|
|
|
CHAN2G(2422, 3), /* Channel 3 */
|
|
|
|
CHAN2G(2427, 4), /* Channel 4 */
|
|
|
|
CHAN2G(2432, 5), /* Channel 5 */
|
|
|
|
CHAN2G(2437, 6), /* Channel 6 */
|
|
|
|
CHAN2G(2442, 7), /* Channel 7 */
|
|
|
|
CHAN2G(2447, 8), /* Channel 8 */
|
|
|
|
CHAN2G(2452, 9), /* Channel 9 */
|
|
|
|
CHAN2G(2457, 10), /* Channel 10 */
|
|
|
|
CHAN2G(2462, 11), /* Channel 11 */
|
|
|
|
CHAN2G(2467, 12), /* Channel 12 */
|
|
|
|
CHAN2G(2472, 13), /* Channel 13 */
|
|
|
|
CHAN2G(2484, 14) /* Channel 14 */
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct ieee80211_channel wcn_5ghz_channels[] = {
|
2020-09-21 16:21:17 +03:00
|
|
|
CHAN5G(5180, 36, PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW),
|
|
|
|
CHAN5G(5200, 40, PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW),
|
|
|
|
CHAN5G(5220, 44, PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH),
|
|
|
|
CHAN5G(5240, 48, PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH),
|
|
|
|
CHAN5G(5260, 52, PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW),
|
|
|
|
CHAN5G(5280, 56, PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW),
|
|
|
|
CHAN5G(5300, 60, PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH),
|
|
|
|
CHAN5G(5320, 64, PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH),
|
|
|
|
CHAN5G(5500, 100, PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW),
|
|
|
|
CHAN5G(5520, 104, PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW),
|
|
|
|
CHAN5G(5540, 108, PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH),
|
|
|
|
CHAN5G(5560, 112, PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH),
|
|
|
|
CHAN5G(5580, 116, PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW),
|
|
|
|
CHAN5G(5600, 120, PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW),
|
|
|
|
CHAN5G(5620, 124, PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH),
|
|
|
|
CHAN5G(5640, 128, PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH),
|
|
|
|
CHAN5G(5660, 132, PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW),
|
2021-10-25 10:53:58 -07:00
|
|
|
CHAN5G(5680, 136, PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW),
|
2020-09-21 16:21:17 +03:00
|
|
|
CHAN5G(5700, 140, PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH),
|
2021-10-25 10:53:58 -07:00
|
|
|
CHAN5G(5720, 144, PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH),
|
2020-09-21 16:21:17 +03:00
|
|
|
CHAN5G(5745, 149, PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW),
|
|
|
|
CHAN5G(5765, 153, PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW),
|
|
|
|
CHAN5G(5785, 157, PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH),
|
|
|
|
CHAN5G(5805, 161, PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH),
|
|
|
|
CHAN5G(5825, 165, 0)
|
2013-10-08 21:25:58 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#define RATE(_bitrate, _hw_rate, _flags) { \
|
|
|
|
.bitrate = (_bitrate), \
|
|
|
|
.flags = (_flags), \
|
|
|
|
.hw_value = (_hw_rate), \
|
|
|
|
.hw_value_short = (_hw_rate) \
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct ieee80211_rate wcn_2ghz_rates[] = {
|
|
|
|
RATE(10, HW_RATE_INDEX_1MBPS, 0),
|
|
|
|
RATE(20, HW_RATE_INDEX_2MBPS, IEEE80211_RATE_SHORT_PREAMBLE),
|
|
|
|
RATE(55, HW_RATE_INDEX_5_5MBPS, IEEE80211_RATE_SHORT_PREAMBLE),
|
|
|
|
RATE(110, HW_RATE_INDEX_11MBPS, IEEE80211_RATE_SHORT_PREAMBLE),
|
|
|
|
RATE(60, HW_RATE_INDEX_6MBPS, 0),
|
|
|
|
RATE(90, HW_RATE_INDEX_9MBPS, 0),
|
|
|
|
RATE(120, HW_RATE_INDEX_12MBPS, 0),
|
|
|
|
RATE(180, HW_RATE_INDEX_18MBPS, 0),
|
|
|
|
RATE(240, HW_RATE_INDEX_24MBPS, 0),
|
|
|
|
RATE(360, HW_RATE_INDEX_36MBPS, 0),
|
|
|
|
RATE(480, HW_RATE_INDEX_48MBPS, 0),
|
|
|
|
RATE(540, HW_RATE_INDEX_54MBPS, 0)
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct ieee80211_rate wcn_5ghz_rates[] = {
|
|
|
|
RATE(60, HW_RATE_INDEX_6MBPS, 0),
|
|
|
|
RATE(90, HW_RATE_INDEX_9MBPS, 0),
|
|
|
|
RATE(120, HW_RATE_INDEX_12MBPS, 0),
|
|
|
|
RATE(180, HW_RATE_INDEX_18MBPS, 0),
|
|
|
|
RATE(240, HW_RATE_INDEX_24MBPS, 0),
|
|
|
|
RATE(360, HW_RATE_INDEX_36MBPS, 0),
|
|
|
|
RATE(480, HW_RATE_INDEX_48MBPS, 0),
|
|
|
|
RATE(540, HW_RATE_INDEX_54MBPS, 0)
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct ieee80211_supported_band wcn_band_2ghz = {
|
|
|
|
.channels = wcn_2ghz_channels,
|
|
|
|
.n_channels = ARRAY_SIZE(wcn_2ghz_channels),
|
|
|
|
.bitrates = wcn_2ghz_rates,
|
|
|
|
.n_bitrates = ARRAY_SIZE(wcn_2ghz_rates),
|
|
|
|
.ht_cap = {
|
|
|
|
.cap = IEEE80211_HT_CAP_GRN_FLD |
|
|
|
|
IEEE80211_HT_CAP_SGI_20 |
|
|
|
|
IEEE80211_HT_CAP_DSSSCCK40 |
|
2021-10-20 15:38:53 +02:00
|
|
|
IEEE80211_HT_CAP_LSIG_TXOP_PROT |
|
|
|
|
IEEE80211_HT_CAP_SGI_40 |
|
|
|
|
IEEE80211_HT_CAP_SUP_WIDTH_20_40,
|
2013-10-08 21:25:58 +01:00
|
|
|
.ht_supported = true,
|
|
|
|
.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
|
|
|
|
.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
|
|
|
|
.mcs = {
|
|
|
|
.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
|
|
|
|
.rx_highest = cpu_to_le16(72),
|
|
|
|
.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct ieee80211_supported_band wcn_band_5ghz = {
|
|
|
|
.channels = wcn_5ghz_channels,
|
|
|
|
.n_channels = ARRAY_SIZE(wcn_5ghz_channels),
|
|
|
|
.bitrates = wcn_5ghz_rates,
|
|
|
|
.n_bitrates = ARRAY_SIZE(wcn_5ghz_rates),
|
|
|
|
.ht_cap = {
|
|
|
|
.cap = IEEE80211_HT_CAP_GRN_FLD |
|
|
|
|
IEEE80211_HT_CAP_SGI_20 |
|
|
|
|
IEEE80211_HT_CAP_DSSSCCK40 |
|
|
|
|
IEEE80211_HT_CAP_LSIG_TXOP_PROT |
|
|
|
|
IEEE80211_HT_CAP_SGI_40 |
|
|
|
|
IEEE80211_HT_CAP_SUP_WIDTH_20_40,
|
|
|
|
.ht_supported = true,
|
|
|
|
.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
|
|
|
|
.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
|
|
|
|
.mcs = {
|
|
|
|
.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
|
2020-08-02 01:48:24 +01:00
|
|
|
.rx_highest = cpu_to_le16(150),
|
2013-10-08 21:25:58 +01:00
|
|
|
.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef CONFIG_PM
|
|
|
|
|
|
|
|
static const struct wiphy_wowlan_support wowlan_support = {
|
2021-06-05 02:11:40 +01:00
|
|
|
.flags = WIPHY_WOWLAN_ANY |
|
|
|
|
WIPHY_WOWLAN_MAGIC_PKT |
|
|
|
|
WIPHY_WOWLAN_SUPPORTS_GTK_REKEY
|
2013-10-08 21:25:58 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static inline u8 get_sta_index(struct ieee80211_vif *vif,
|
|
|
|
struct wcn36xx_sta *sta_priv)
|
|
|
|
{
|
|
|
|
return NL80211_IFTYPE_STATION == vif->type ?
|
|
|
|
sta_priv->bss_sta_index :
|
|
|
|
sta_priv->sta_index;
|
|
|
|
}
|
|
|
|
|
2014-02-12 19:04:44 +00:00
|
|
|
static void wcn36xx_feat_caps_info(struct wcn36xx *wcn)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_FEATURE_SUPPORTED; i++) {
|
2022-07-27 17:16:54 +01:00
|
|
|
if (wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, i)) {
|
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC, "FW Cap %s\n",
|
|
|
|
wcn36xx_firmware_get_cap_name(i));
|
|
|
|
}
|
2014-02-12 19:04:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-08 21:25:58 +01:00
|
|
|
static int wcn36xx_start(struct ieee80211_hw *hw)
|
|
|
|
{
|
|
|
|
struct wcn36xx *wcn = hw->priv;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC, "mac start\n");
|
|
|
|
|
|
|
|
/* SMD initialization */
|
|
|
|
ret = wcn36xx_smd_open(wcn);
|
|
|
|
if (ret) {
|
|
|
|
wcn36xx_err("Failed to open smd channel: %d\n", ret);
|
|
|
|
goto out_err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate memory pools for Mgmt BD headers and Data BD headers */
|
|
|
|
ret = wcn36xx_dxe_allocate_mem_pools(wcn);
|
|
|
|
if (ret) {
|
|
|
|
wcn36xx_err("Failed to alloc DXE mempool: %d\n", ret);
|
|
|
|
goto out_smd_close;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = wcn36xx_dxe_alloc_ctl_blks(wcn);
|
|
|
|
if (ret) {
|
|
|
|
wcn36xx_err("Failed to alloc DXE ctl blocks: %d\n", ret);
|
|
|
|
goto out_free_dxe_pool;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = wcn36xx_smd_load_nv(wcn);
|
|
|
|
if (ret) {
|
|
|
|
wcn36xx_err("Failed to push NV to chip\n");
|
2021-06-05 18:33:47 +01:00
|
|
|
goto out_free_dxe_ctl;
|
2013-10-08 21:25:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ret = wcn36xx_smd_start(wcn);
|
|
|
|
if (ret) {
|
|
|
|
wcn36xx_err("Failed to start chip\n");
|
2021-06-05 18:33:47 +01:00
|
|
|
goto out_free_dxe_ctl;
|
2013-10-08 21:25:58 +01:00
|
|
|
}
|
|
|
|
|
2014-02-12 19:04:45 +00:00
|
|
|
if (!wcn36xx_is_fw_version(wcn, 1, 2, 2, 24)) {
|
|
|
|
ret = wcn36xx_smd_feature_caps_exchange(wcn);
|
|
|
|
if (ret)
|
|
|
|
wcn36xx_warn("Exchange feature caps failed\n");
|
|
|
|
else
|
|
|
|
wcn36xx_feat_caps_info(wcn);
|
|
|
|
}
|
|
|
|
|
2013-10-08 21:25:58 +01:00
|
|
|
/* DMA channel initialization */
|
|
|
|
ret = wcn36xx_dxe_init(wcn);
|
|
|
|
if (ret) {
|
|
|
|
wcn36xx_err("DXE init failed\n");
|
|
|
|
goto out_smd_stop;
|
|
|
|
}
|
|
|
|
|
|
|
|
wcn36xx_debugfs_init(wcn);
|
|
|
|
|
|
|
|
INIT_LIST_HEAD(&wcn->vif_list);
|
2015-01-09 14:15:50 -05:00
|
|
|
spin_lock_init(&wcn->dxe_lock);
|
2022-01-15 00:16:45 +00:00
|
|
|
spin_lock_init(&wcn->survey_lock);
|
2015-01-09 14:15:50 -05:00
|
|
|
|
2013-10-08 21:25:58 +01:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
out_smd_stop:
|
|
|
|
wcn36xx_smd_stop(wcn);
|
|
|
|
out_free_dxe_ctl:
|
|
|
|
wcn36xx_dxe_free_ctl_blks(wcn);
|
2017-03-08 13:52:09 +02:00
|
|
|
out_free_dxe_pool:
|
|
|
|
wcn36xx_dxe_free_mem_pools(wcn);
|
2013-10-08 21:25:58 +01:00
|
|
|
out_smd_close:
|
|
|
|
wcn36xx_smd_close(wcn);
|
|
|
|
out_err:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2024-06-18 19:25:56 +03:00
|
|
|
static void wcn36xx_stop(struct ieee80211_hw *hw, bool suspend)
|
2013-10-08 21:25:58 +01:00
|
|
|
{
|
|
|
|
struct wcn36xx *wcn = hw->priv;
|
|
|
|
|
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC, "mac stop\n");
|
|
|
|
|
2018-04-17 15:23:34 +02:00
|
|
|
mutex_lock(&wcn->scan_lock);
|
|
|
|
if (wcn->scan_req) {
|
|
|
|
struct cfg80211_scan_info scan_info = {
|
|
|
|
.aborted = true,
|
|
|
|
};
|
|
|
|
|
|
|
|
ieee80211_scan_completed(wcn->hw, &scan_info);
|
|
|
|
}
|
|
|
|
wcn->scan_req = NULL;
|
|
|
|
mutex_unlock(&wcn->scan_lock);
|
|
|
|
|
2013-10-08 21:25:58 +01:00
|
|
|
wcn36xx_debugfs_exit(wcn);
|
|
|
|
wcn36xx_smd_stop(wcn);
|
|
|
|
wcn36xx_dxe_deinit(wcn);
|
|
|
|
wcn36xx_smd_close(wcn);
|
|
|
|
|
|
|
|
wcn36xx_dxe_free_mem_pools(wcn);
|
|
|
|
wcn36xx_dxe_free_ctl_blks(wcn);
|
|
|
|
}
|
|
|
|
|
2020-08-24 18:53:55 +02:00
|
|
|
static void wcn36xx_change_ps(struct wcn36xx *wcn, bool enable)
|
|
|
|
{
|
|
|
|
struct ieee80211_vif *vif = NULL;
|
|
|
|
struct wcn36xx_vif *tmp;
|
|
|
|
|
|
|
|
list_for_each_entry(tmp, &wcn->vif_list, list) {
|
|
|
|
vif = wcn36xx_priv_to_vif(tmp);
|
|
|
|
if (enable && !wcn->sw_scan) {
|
2022-06-24 15:02:16 +02:00
|
|
|
if (vif->cfg.ps) /* ps allowed ? */
|
2020-08-24 18:53:55 +02:00
|
|
|
wcn36xx_pmc_enter_bmps_state(wcn, vif);
|
|
|
|
} else {
|
|
|
|
wcn36xx_pmc_exit_bmps_state(wcn, vif);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wcn36xx_change_opchannel(struct wcn36xx *wcn, int ch)
|
2013-10-08 21:25:58 +01:00
|
|
|
{
|
|
|
|
struct ieee80211_vif *vif = NULL;
|
|
|
|
struct wcn36xx_vif *tmp;
|
2022-01-15 00:16:44 +00:00
|
|
|
struct ieee80211_supported_band *band;
|
2022-02-01 15:59:41 +03:00
|
|
|
struct ieee80211_channel *channel = NULL;
|
2022-01-15 00:16:45 +00:00
|
|
|
unsigned long flags;
|
2022-01-15 00:16:44 +00:00
|
|
|
int i, j;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(wcn->hw->wiphy->bands); i++) {
|
|
|
|
band = wcn->hw->wiphy->bands[i];
|
|
|
|
if (!band)
|
|
|
|
break;
|
|
|
|
for (j = 0; j < band->n_channels; j++) {
|
|
|
|
if (HW_VALUE_CHANNEL(band->channels[j].hw_value) == ch) {
|
|
|
|
channel = &band->channels[j];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (channel)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!channel) {
|
|
|
|
wcn36xx_err("Cannot tune to channel %d\n", ch);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-01-15 00:16:45 +00:00
|
|
|
spin_lock_irqsave(&wcn->survey_lock, flags);
|
2022-01-15 00:16:44 +00:00
|
|
|
wcn->band = band;
|
|
|
|
wcn->channel = channel;
|
2022-01-15 00:16:45 +00:00
|
|
|
spin_unlock_irqrestore(&wcn->survey_lock, flags);
|
2013-10-08 21:25:58 +01:00
|
|
|
|
2020-08-24 18:53:55 +02:00
|
|
|
list_for_each_entry(tmp, &wcn->vif_list, list) {
|
|
|
|
vif = wcn36xx_priv_to_vif(tmp);
|
|
|
|
wcn36xx_smd_switch_channel(wcn, vif, ch);
|
|
|
|
}
|
2022-01-15 00:16:44 +00:00
|
|
|
|
|
|
|
return;
|
2020-08-24 18:53:55 +02:00
|
|
|
}
|
|
|
|
|
2025-06-15 13:53:09 +05:30
|
|
|
static int wcn36xx_config(struct ieee80211_hw *hw, int radio_idx, u32 changed)
|
2020-08-24 18:53:55 +02:00
|
|
|
{
|
|
|
|
struct wcn36xx *wcn = hw->priv;
|
wcn36xx: ensure pairing of init_scan/finish_scan and start_scan/end_scan
An SMD capture from the downstream prima driver on WCN3680B shows the
following command sequence for connected scans:
- init_scan_req
- start_scan_req, channel 1
- end_scan_req, channel 1
- start_scan_req, channel 2
- ...
- end_scan_req, channel 3
- finish_scan_req
- init_scan_req
- start_scan_req, channel 4
- ...
- end_scan_req, channel 6
- finish_scan_req
- ...
- end_scan_req, channel 165
- finish_scan_req
Upstream currently never calls wcn36xx_smd_end_scan, and in some cases[1]
still sends finish_scan_req twice in a row or before init_scan_req. A
typical connected scan looks like this:
- init_scan_req
- start_scan_req, channel 1
- finish_scan_req
- init_scan_req
- start_scan_req, channel 2
- ...
- start_scan_req, channel 165
- finish_scan_req
- finish_scan_req
This patch cleans up scanning so that init/finish and start/end are always
paired together and correctly nested.
- init_scan_req
- start_scan_req, channel 1
- end_scan_req, channel 1
- finish_scan_req
- init_scan_req
- start_scan_req, channel 2
- end_scan_req, channel 2
- ...
- start_scan_req, channel 165
- end_scan_req, channel 165
- finish_scan_req
Note that upstream will not do batching of 3 active-probe scans before
returning to the operating channel, and this patch does not change that.
To match downstream in this aspect, adjust IEEE80211_PROBE_DELAY and/or
the 125ms max off-channel time in ieee80211_scan_state_decision.
[1]: commit d195d7aac09b ("wcn36xx: Ensure finish scan is not requested
before start scan") addressed one case of finish_scan_req being sent
without a preceding init_scan_req (the case of the operating channel
coinciding with the first scan channel); two other cases are:
1) if SW scan is started and aborted immediately, without scanning any
channels, we send a finish_scan_req without ever sending init_scan_req,
and
2) as SW scan logic always returns us to the operating channel before
calling wcn36xx_sw_scan_complete, finish_scan_req is always sent twice
at the end of a SW scan
Fixes: 8e84c2582169 ("wcn36xx: mac80211 driver for Qualcomm WCN3660/WCN3680 hardware")
Signed-off-by: Benjamin Li <benl@squareup.com>
Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20211027170306.555535-4-benl@squareup.com
2021-10-27 10:03:05 -07:00
|
|
|
int ret;
|
2020-08-24 18:53:55 +02:00
|
|
|
|
2013-10-08 21:25:58 +01:00
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC, "mac config changed 0x%08x\n", changed);
|
|
|
|
|
2017-08-02 18:28:00 -07:00
|
|
|
mutex_lock(&wcn->conf_mutex);
|
|
|
|
|
2013-10-08 21:25:58 +01:00
|
|
|
if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
|
|
|
|
int ch = WCN36XX_HW_CHANNEL(wcn);
|
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC, "wcn36xx_config channel switch=%d\n",
|
|
|
|
ch);
|
|
|
|
|
2021-08-18 13:31:43 +02:00
|
|
|
if (wcn->sw_scan_opchannel == ch && wcn->sw_scan_channel) {
|
2020-08-24 18:53:55 +02:00
|
|
|
/* If channel is the initial operating channel, we may
|
|
|
|
* want to receive/transmit regular data packets, then
|
|
|
|
* simply stop the scan session and exit PS mode.
|
|
|
|
*/
|
wcn36xx: ensure pairing of init_scan/finish_scan and start_scan/end_scan
An SMD capture from the downstream prima driver on WCN3680B shows the
following command sequence for connected scans:
- init_scan_req
- start_scan_req, channel 1
- end_scan_req, channel 1
- start_scan_req, channel 2
- ...
- end_scan_req, channel 3
- finish_scan_req
- init_scan_req
- start_scan_req, channel 4
- ...
- end_scan_req, channel 6
- finish_scan_req
- ...
- end_scan_req, channel 165
- finish_scan_req
Upstream currently never calls wcn36xx_smd_end_scan, and in some cases[1]
still sends finish_scan_req twice in a row or before init_scan_req. A
typical connected scan looks like this:
- init_scan_req
- start_scan_req, channel 1
- finish_scan_req
- init_scan_req
- start_scan_req, channel 2
- ...
- start_scan_req, channel 165
- finish_scan_req
- finish_scan_req
This patch cleans up scanning so that init/finish and start/end are always
paired together and correctly nested.
- init_scan_req
- start_scan_req, channel 1
- end_scan_req, channel 1
- finish_scan_req
- init_scan_req
- start_scan_req, channel 2
- end_scan_req, channel 2
- ...
- start_scan_req, channel 165
- end_scan_req, channel 165
- finish_scan_req
Note that upstream will not do batching of 3 active-probe scans before
returning to the operating channel, and this patch does not change that.
To match downstream in this aspect, adjust IEEE80211_PROBE_DELAY and/or
the 125ms max off-channel time in ieee80211_scan_state_decision.
[1]: commit d195d7aac09b ("wcn36xx: Ensure finish scan is not requested
before start scan") addressed one case of finish_scan_req being sent
without a preceding init_scan_req (the case of the operating channel
coinciding with the first scan channel); two other cases are:
1) if SW scan is started and aborted immediately, without scanning any
channels, we send a finish_scan_req without ever sending init_scan_req,
and
2) as SW scan logic always returns us to the operating channel before
calling wcn36xx_sw_scan_complete, finish_scan_req is always sent twice
at the end of a SW scan
Fixes: 8e84c2582169 ("wcn36xx: mac80211 driver for Qualcomm WCN3660/WCN3680 hardware")
Signed-off-by: Benjamin Li <benl@squareup.com>
Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20211027170306.555535-4-benl@squareup.com
2021-10-27 10:03:05 -07:00
|
|
|
if (wcn->sw_scan_channel)
|
|
|
|
wcn36xx_smd_end_scan(wcn, wcn->sw_scan_channel);
|
|
|
|
if (wcn->sw_scan_init) {
|
|
|
|
wcn36xx_smd_finish_scan(wcn, HAL_SYS_MODE_SCAN,
|
|
|
|
wcn->sw_scan_vif);
|
|
|
|
}
|
2020-08-24 18:53:55 +02:00
|
|
|
} else if (wcn->sw_scan) {
|
|
|
|
/* A scan is ongoing, do not change the operating
|
|
|
|
* channel, but start a scan session on the channel.
|
|
|
|
*/
|
wcn36xx: ensure pairing of init_scan/finish_scan and start_scan/end_scan
An SMD capture from the downstream prima driver on WCN3680B shows the
following command sequence for connected scans:
- init_scan_req
- start_scan_req, channel 1
- end_scan_req, channel 1
- start_scan_req, channel 2
- ...
- end_scan_req, channel 3
- finish_scan_req
- init_scan_req
- start_scan_req, channel 4
- ...
- end_scan_req, channel 6
- finish_scan_req
- ...
- end_scan_req, channel 165
- finish_scan_req
Upstream currently never calls wcn36xx_smd_end_scan, and in some cases[1]
still sends finish_scan_req twice in a row or before init_scan_req. A
typical connected scan looks like this:
- init_scan_req
- start_scan_req, channel 1
- finish_scan_req
- init_scan_req
- start_scan_req, channel 2
- ...
- start_scan_req, channel 165
- finish_scan_req
- finish_scan_req
This patch cleans up scanning so that init/finish and start/end are always
paired together and correctly nested.
- init_scan_req
- start_scan_req, channel 1
- end_scan_req, channel 1
- finish_scan_req
- init_scan_req
- start_scan_req, channel 2
- end_scan_req, channel 2
- ...
- start_scan_req, channel 165
- end_scan_req, channel 165
- finish_scan_req
Note that upstream will not do batching of 3 active-probe scans before
returning to the operating channel, and this patch does not change that.
To match downstream in this aspect, adjust IEEE80211_PROBE_DELAY and/or
the 125ms max off-channel time in ieee80211_scan_state_decision.
[1]: commit d195d7aac09b ("wcn36xx: Ensure finish scan is not requested
before start scan") addressed one case of finish_scan_req being sent
without a preceding init_scan_req (the case of the operating channel
coinciding with the first scan channel); two other cases are:
1) if SW scan is started and aborted immediately, without scanning any
channels, we send a finish_scan_req without ever sending init_scan_req,
and
2) as SW scan logic always returns us to the operating channel before
calling wcn36xx_sw_scan_complete, finish_scan_req is always sent twice
at the end of a SW scan
Fixes: 8e84c2582169 ("wcn36xx: mac80211 driver for Qualcomm WCN3660/WCN3680 hardware")
Signed-off-by: Benjamin Li <benl@squareup.com>
Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20211027170306.555535-4-benl@squareup.com
2021-10-27 10:03:05 -07:00
|
|
|
if (wcn->sw_scan_channel)
|
|
|
|
wcn36xx_smd_end_scan(wcn, wcn->sw_scan_channel);
|
|
|
|
if (!wcn->sw_scan_init) {
|
|
|
|
/* This can fail if we are unable to notify the
|
|
|
|
* operating channel.
|
|
|
|
*/
|
|
|
|
ret = wcn36xx_smd_init_scan(wcn,
|
|
|
|
HAL_SYS_MODE_SCAN,
|
|
|
|
wcn->sw_scan_vif);
|
|
|
|
if (ret) {
|
|
|
|
mutex_unlock(&wcn->conf_mutex);
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
}
|
2020-08-24 18:53:55 +02:00
|
|
|
wcn36xx_smd_start_scan(wcn, ch);
|
|
|
|
} else {
|
|
|
|
wcn36xx_change_opchannel(wcn, ch);
|
2017-12-11 09:52:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-24 18:53:55 +02:00
|
|
|
if (changed & IEEE80211_CONF_CHANGE_PS)
|
|
|
|
wcn36xx_change_ps(wcn, hw->conf.flags & IEEE80211_CONF_PS);
|
|
|
|
|
2021-09-09 16:33:20 +01:00
|
|
|
if (changed & IEEE80211_CONF_CHANGE_IDLE) {
|
|
|
|
if (hw->conf.flags & IEEE80211_CONF_IDLE)
|
|
|
|
wcn36xx_smd_enter_imps(wcn);
|
|
|
|
else
|
|
|
|
wcn36xx_smd_exit_imps(wcn);
|
|
|
|
}
|
|
|
|
|
2017-08-02 18:28:00 -07:00
|
|
|
mutex_unlock(&wcn->conf_mutex);
|
|
|
|
|
2013-10-08 21:25:58 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wcn36xx_configure_filter(struct ieee80211_hw *hw,
|
|
|
|
unsigned int changed,
|
|
|
|
unsigned int *total, u64 multicast)
|
|
|
|
{
|
2016-04-18 22:00:52 -07:00
|
|
|
struct wcn36xx_hal_rcv_flt_mc_addr_list_type *fp;
|
|
|
|
struct wcn36xx *wcn = hw->priv;
|
|
|
|
struct wcn36xx_vif *tmp;
|
|
|
|
struct ieee80211_vif *vif = NULL;
|
|
|
|
|
2013-10-08 21:25:58 +01:00
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC, "mac configure filter\n");
|
|
|
|
|
2017-08-02 18:28:00 -07:00
|
|
|
mutex_lock(&wcn->conf_mutex);
|
|
|
|
|
2016-04-18 22:00:52 -07:00
|
|
|
*total &= FIF_ALLMULTI;
|
|
|
|
|
|
|
|
fp = (void *)(unsigned long)multicast;
|
|
|
|
list_for_each_entry(tmp, &wcn->vif_list, list) {
|
|
|
|
vif = wcn36xx_priv_to_vif(tmp);
|
|
|
|
|
|
|
|
/* FW handles MC filtering only when connected as STA */
|
|
|
|
if (*total & FIF_ALLMULTI)
|
|
|
|
wcn36xx_smd_set_mc_list(wcn, vif, NULL);
|
|
|
|
else if (NL80211_IFTYPE_STATION == vif->type && tmp->sta_assoc)
|
|
|
|
wcn36xx_smd_set_mc_list(wcn, vif, fp);
|
|
|
|
}
|
2017-08-02 18:28:00 -07:00
|
|
|
|
|
|
|
mutex_unlock(&wcn->conf_mutex);
|
2016-04-18 22:00:52 -07:00
|
|
|
kfree(fp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static u64 wcn36xx_prepare_multicast(struct ieee80211_hw *hw,
|
|
|
|
struct netdev_hw_addr_list *mc_list)
|
|
|
|
{
|
|
|
|
struct wcn36xx_hal_rcv_flt_mc_addr_list_type *fp;
|
|
|
|
struct netdev_hw_addr *ha;
|
|
|
|
|
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC, "mac prepare multicast list\n");
|
|
|
|
fp = kzalloc(sizeof(*fp), GFP_ATOMIC);
|
|
|
|
if (!fp) {
|
|
|
|
wcn36xx_err("Out of memory setting filters.\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
fp->mc_addr_count = 0;
|
|
|
|
/* update multicast filtering parameters */
|
|
|
|
if (netdev_hw_addr_list_count(mc_list) <=
|
|
|
|
WCN36XX_HAL_MAX_NUM_MULTICAST_ADDRESS) {
|
|
|
|
netdev_hw_addr_list_for_each(ha, mc_list) {
|
|
|
|
memcpy(fp->mc_addr[fp->mc_addr_count],
|
|
|
|
ha->addr, ETH_ALEN);
|
|
|
|
fp->mc_addr_count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (u64)(unsigned long)fp;
|
2013-10-08 21:25:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void wcn36xx_tx(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_tx_control *control,
|
|
|
|
struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
struct wcn36xx *wcn = hw->priv;
|
|
|
|
struct wcn36xx_sta *sta_priv = NULL;
|
|
|
|
|
|
|
|
if (control->sta)
|
2016-04-18 22:00:44 -07:00
|
|
|
sta_priv = wcn36xx_sta_to_priv(control->sta);
|
2013-10-08 21:25:58 +01:00
|
|
|
|
|
|
|
if (wcn36xx_start_tx(wcn, sta_priv, skb))
|
|
|
|
ieee80211_free_txskb(wcn->hw, skb);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wcn36xx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
|
|
|
|
struct ieee80211_vif *vif,
|
|
|
|
struct ieee80211_sta *sta,
|
|
|
|
struct ieee80211_key_conf *key_conf)
|
|
|
|
{
|
|
|
|
struct wcn36xx *wcn = hw->priv;
|
2016-04-18 22:00:41 -07:00
|
|
|
struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
|
2018-06-20 09:58:00 +02:00
|
|
|
struct wcn36xx_sta *sta_priv = sta ? wcn36xx_sta_to_priv(sta) : NULL;
|
2013-10-08 21:25:58 +01:00
|
|
|
int ret = 0;
|
|
|
|
u8 key[WLAN_MAX_KEY_LEN];
|
|
|
|
|
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC, "mac80211 set key\n");
|
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC, "Key: cmd=0x%x algo:0x%x, id:%d, len:%d flags 0x%x\n",
|
|
|
|
cmd, key_conf->cipher, key_conf->keyidx,
|
|
|
|
key_conf->keylen, key_conf->flags);
|
|
|
|
wcn36xx_dbg_dump(WCN36XX_DBG_MAC, "KEY: ",
|
|
|
|
key_conf->key,
|
|
|
|
key_conf->keylen);
|
|
|
|
|
2017-08-02 18:28:00 -07:00
|
|
|
mutex_lock(&wcn->conf_mutex);
|
|
|
|
|
2013-10-08 21:25:58 +01:00
|
|
|
switch (key_conf->cipher) {
|
|
|
|
case WLAN_CIPHER_SUITE_WEP40:
|
|
|
|
vif_priv->encrypt_type = WCN36XX_HAL_ED_WEP40;
|
|
|
|
break;
|
|
|
|
case WLAN_CIPHER_SUITE_WEP104:
|
2018-06-20 09:57:58 +02:00
|
|
|
vif_priv->encrypt_type = WCN36XX_HAL_ED_WEP104;
|
2013-10-08 21:25:58 +01:00
|
|
|
break;
|
|
|
|
case WLAN_CIPHER_SUITE_CCMP:
|
|
|
|
vif_priv->encrypt_type = WCN36XX_HAL_ED_CCMP;
|
|
|
|
break;
|
|
|
|
case WLAN_CIPHER_SUITE_TKIP:
|
|
|
|
vif_priv->encrypt_type = WCN36XX_HAL_ED_TKIP;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
wcn36xx_err("Unsupported key type 0x%x\n",
|
|
|
|
key_conf->cipher);
|
|
|
|
ret = -EOPNOTSUPP;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case SET_KEY:
|
|
|
|
if (WCN36XX_HAL_ED_TKIP == vif_priv->encrypt_type) {
|
|
|
|
/*
|
|
|
|
* Supplicant is sending key in the wrong order:
|
|
|
|
* Temporal Key (16 b) - TX MIC (8 b) - RX MIC (8 b)
|
|
|
|
* but HW expects it to be in the order as described in
|
|
|
|
* IEEE 802.11 spec (see chapter 11.7) like this:
|
|
|
|
* Temporal Key (16 b) - RX MIC (8 b) - TX MIC (8 b)
|
|
|
|
*/
|
|
|
|
memcpy(key, key_conf->key, 16);
|
|
|
|
memcpy(key + 16, key_conf->key + 24, 8);
|
|
|
|
memcpy(key + 24, key_conf->key + 16, 8);
|
|
|
|
} else {
|
|
|
|
memcpy(key, key_conf->key, key_conf->keylen);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IEEE80211_KEY_FLAG_PAIRWISE & key_conf->flags) {
|
|
|
|
sta_priv->is_data_encrypted = true;
|
|
|
|
/* Reconfigure bss with encrypt_type */
|
wcn36xx: Fix Antenna Diversity Switching
We have been tracking a strange bug with Antenna Diversity Switching (ADS)
on wcn3680b for a while.
ADS is configured like this:
A. Via a firmware configuration table baked into the NV area.
1. Defines if ADS is enabled.
2. Defines which GPIOs are connected to which antenna enable pin.
3. Defines which antenna/GPIO is primary and which is secondary.
B. WCN36XX_CFG_VAL(ANTENNA_DIVERSITY, N)
N is a bitmask of available antenna.
Setting N to 3 indicates a bitmask of enabled antenna (1 | 2).
Obviously then we can set N to 1 or N to 2 to fix to a particular
antenna and disable antenna diversity.
C. WCN36XX_CFG_VAL(ASD_PROBE_INTERVAL, XX)
XX is the number of beacons between each antenna RSSI check.
Setting this value to 50 means, every 50 received beacons, run the
ADS algorithm.
D. WCN36XX_CFG_VAL(ASD_TRIGGER_THRESHOLD, YY)
YY is a two's complement integer which specifies the RSSI decibel
threshold below which ADS will run.
We default to -60db here, meaning a measured RSSI <= -60db will
trigger an ADS probe.
E. WCN36XX_CFG_VAL(ASD_RTT_RSSI_HYST_THRESHOLD, Z)
Z is a hysteresis value, indicating a delta which the RSSI must
exceed for the antenna switch to be valid.
For example if HYST_THRESHOLD == 3 AntennaId1-RSSI == -60db and
AntennaId-2-RSSI == -58db then firmware will not switch antenna.
The threshold needs to be -57db or better to satisfy the criteria.
F. A firmware feature bit also exists ANTENNA_DIVERSITY_SELECTION.
This feature bit is used by the firmware to report if
ANTENNA_DIVERSITY_SELECTION is supported. The host is not required to
toggle this bit to enable or disable ADS.
ADS works like this:
A. Every XX beacons the firmware switches to or remains on the primary
antenna.
B. The firmware then sends a Request-To-Send (RTS) packet to the AP.
C. The firmware waits for a Clear-To-Send (CTS) response from the AP.
D. The firmware then notes the received RSSI on the CTS packet.
E. The firmware then repeats steps A-D on the secondary antenna.
F. Subsequently if the RSSI on the measured antenna is better than
ASD_TRIGGER_THRESHOLD + the active antenna's RSSI then the
measured antenna becomes the active antenna.
G. If RSSI rises past ASD_TRIGGER_THRESHOLD then ADS doesn't run at
all even if there is a substantially better RSSI on the alternative
antenna.
What we have been observing is that the RTS packet is being sent but the
MAC address is a byte-swapped version of the target MAC. The ADS/RTS MAC is
corrupted only when the link is encrypted, if the AP is open the RTS MAC is
correct. Similarly if we configure the firmware to an RTS/CTS sequence for
regular data - the transmitted RTS MAC is correctly formatted.
Internally the wcn36xx firmware uses the indexes in the SMD commands to
populate and extract data from specific entries in an STA lookup table. The
AP's MAC appears a number of times in different indexes within this lookup
table, so the MAC address extracted for the data-transmit RTS and the MAC
address extracted for the ADS/RTS packet are not the same STA table index.
Our analysis indicates the relevant firmware STA table index is
"bssSelfStaIdx".
There is an STA populate function responsible for formatting the MAC
address of the bssSelfStaIdx including byte-swapping the MAC address.
Its clear then that the required STA populate command did not run for
bssSelfStaIdx.
So taking a look at the sequence of SMD commands sent to the firmware we
see the following downstream when moving from an unencrypted to encrypted
BSS setup.
- WLAN_HAL_CONFIG_BSS_REQ
- WLAN_HAL_CONFIG_STA_REQ
- WLAN_HAL_SET_STAKEY_REQ
Upstream in wcn36xx we have
- WLAN_HAL_CONFIG_BSS_REQ
- WLAN_HAL_SET_STAKEY_REQ
The solution then is to add the missing WLAN_HAL_CONFIG_STA_REQ between
WLAN_HAL_CONFIG_BSS_REQ and WLAN_HAL_SET_STAKEY_REQ.
No surprise WLAN_HAL_CONFIG_STA_REQ is the routine responsible for
populating the STA lookup table in the firmware and once done the MAC sent
by the ADS routine is in the correct byte-order.
This bug is apparent with ADS but it is also the case that any other
firmware routine that depends on the "bssSelfStaIdx" would retrieve
malformed data on an encrypted link.
Fixes: 3e977c5c523d ("wcn36xx: Define wcn3680 specific firmware parameters")
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Tested-by: Benjamin Li <benl@squareup.com>
Reviewed-by: Loic Poulain <loic.poulain@linaro.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20210909144428.2564650-2-bryan.odonoghue@linaro.org
2021-09-09 15:44:27 +01:00
|
|
|
if (NL80211_IFTYPE_STATION == vif->type) {
|
2013-10-08 21:25:58 +01:00
|
|
|
wcn36xx_smd_config_bss(wcn,
|
|
|
|
vif,
|
|
|
|
sta,
|
|
|
|
sta->addr,
|
|
|
|
true);
|
wcn36xx: Fix Antenna Diversity Switching
We have been tracking a strange bug with Antenna Diversity Switching (ADS)
on wcn3680b for a while.
ADS is configured like this:
A. Via a firmware configuration table baked into the NV area.
1. Defines if ADS is enabled.
2. Defines which GPIOs are connected to which antenna enable pin.
3. Defines which antenna/GPIO is primary and which is secondary.
B. WCN36XX_CFG_VAL(ANTENNA_DIVERSITY, N)
N is a bitmask of available antenna.
Setting N to 3 indicates a bitmask of enabled antenna (1 | 2).
Obviously then we can set N to 1 or N to 2 to fix to a particular
antenna and disable antenna diversity.
C. WCN36XX_CFG_VAL(ASD_PROBE_INTERVAL, XX)
XX is the number of beacons between each antenna RSSI check.
Setting this value to 50 means, every 50 received beacons, run the
ADS algorithm.
D. WCN36XX_CFG_VAL(ASD_TRIGGER_THRESHOLD, YY)
YY is a two's complement integer which specifies the RSSI decibel
threshold below which ADS will run.
We default to -60db here, meaning a measured RSSI <= -60db will
trigger an ADS probe.
E. WCN36XX_CFG_VAL(ASD_RTT_RSSI_HYST_THRESHOLD, Z)
Z is a hysteresis value, indicating a delta which the RSSI must
exceed for the antenna switch to be valid.
For example if HYST_THRESHOLD == 3 AntennaId1-RSSI == -60db and
AntennaId-2-RSSI == -58db then firmware will not switch antenna.
The threshold needs to be -57db or better to satisfy the criteria.
F. A firmware feature bit also exists ANTENNA_DIVERSITY_SELECTION.
This feature bit is used by the firmware to report if
ANTENNA_DIVERSITY_SELECTION is supported. The host is not required to
toggle this bit to enable or disable ADS.
ADS works like this:
A. Every XX beacons the firmware switches to or remains on the primary
antenna.
B. The firmware then sends a Request-To-Send (RTS) packet to the AP.
C. The firmware waits for a Clear-To-Send (CTS) response from the AP.
D. The firmware then notes the received RSSI on the CTS packet.
E. The firmware then repeats steps A-D on the secondary antenna.
F. Subsequently if the RSSI on the measured antenna is better than
ASD_TRIGGER_THRESHOLD + the active antenna's RSSI then the
measured antenna becomes the active antenna.
G. If RSSI rises past ASD_TRIGGER_THRESHOLD then ADS doesn't run at
all even if there is a substantially better RSSI on the alternative
antenna.
What we have been observing is that the RTS packet is being sent but the
MAC address is a byte-swapped version of the target MAC. The ADS/RTS MAC is
corrupted only when the link is encrypted, if the AP is open the RTS MAC is
correct. Similarly if we configure the firmware to an RTS/CTS sequence for
regular data - the transmitted RTS MAC is correctly formatted.
Internally the wcn36xx firmware uses the indexes in the SMD commands to
populate and extract data from specific entries in an STA lookup table. The
AP's MAC appears a number of times in different indexes within this lookup
table, so the MAC address extracted for the data-transmit RTS and the MAC
address extracted for the ADS/RTS packet are not the same STA table index.
Our analysis indicates the relevant firmware STA table index is
"bssSelfStaIdx".
There is an STA populate function responsible for formatting the MAC
address of the bssSelfStaIdx including byte-swapping the MAC address.
Its clear then that the required STA populate command did not run for
bssSelfStaIdx.
So taking a look at the sequence of SMD commands sent to the firmware we
see the following downstream when moving from an unencrypted to encrypted
BSS setup.
- WLAN_HAL_CONFIG_BSS_REQ
- WLAN_HAL_CONFIG_STA_REQ
- WLAN_HAL_SET_STAKEY_REQ
Upstream in wcn36xx we have
- WLAN_HAL_CONFIG_BSS_REQ
- WLAN_HAL_SET_STAKEY_REQ
The solution then is to add the missing WLAN_HAL_CONFIG_STA_REQ between
WLAN_HAL_CONFIG_BSS_REQ and WLAN_HAL_SET_STAKEY_REQ.
No surprise WLAN_HAL_CONFIG_STA_REQ is the routine responsible for
populating the STA lookup table in the firmware and once done the MAC sent
by the ADS routine is in the correct byte-order.
This bug is apparent with ADS but it is also the case that any other
firmware routine that depends on the "bssSelfStaIdx" would retrieve
malformed data on an encrypted link.
Fixes: 3e977c5c523d ("wcn36xx: Define wcn3680 specific firmware parameters")
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Tested-by: Benjamin Li <benl@squareup.com>
Reviewed-by: Loic Poulain <loic.poulain@linaro.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20210909144428.2564650-2-bryan.odonoghue@linaro.org
2021-09-09 15:44:27 +01:00
|
|
|
wcn36xx_smd_config_sta(wcn, vif, sta);
|
|
|
|
}
|
2013-10-08 21:25:58 +01:00
|
|
|
|
|
|
|
wcn36xx_smd_set_stakey(wcn,
|
|
|
|
vif_priv->encrypt_type,
|
|
|
|
key_conf->keyidx,
|
|
|
|
key_conf->keylen,
|
|
|
|
key,
|
|
|
|
get_sta_index(vif, sta_priv));
|
|
|
|
} else {
|
|
|
|
wcn36xx_smd_set_bsskey(wcn,
|
|
|
|
vif_priv->encrypt_type,
|
2018-04-19 19:40:11 +03:00
|
|
|
vif_priv->bss_index,
|
2013-10-08 21:25:58 +01:00
|
|
|
key_conf->keyidx,
|
|
|
|
key_conf->keylen,
|
|
|
|
key);
|
2018-06-20 09:57:59 +02:00
|
|
|
|
2013-10-08 21:25:58 +01:00
|
|
|
if ((WLAN_CIPHER_SUITE_WEP40 == key_conf->cipher) ||
|
|
|
|
(WLAN_CIPHER_SUITE_WEP104 == key_conf->cipher)) {
|
2018-06-20 09:58:00 +02:00
|
|
|
list_for_each_entry(sta_priv,
|
|
|
|
&vif_priv->sta_list, list) {
|
|
|
|
sta_priv->is_data_encrypted = true;
|
|
|
|
wcn36xx_smd_set_stakey(wcn,
|
|
|
|
vif_priv->encrypt_type,
|
|
|
|
key_conf->keyidx,
|
|
|
|
key_conf->keylen,
|
|
|
|
key,
|
|
|
|
get_sta_index(vif, sta_priv));
|
|
|
|
}
|
2013-10-08 21:25:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DISABLE_KEY:
|
|
|
|
if (!(IEEE80211_KEY_FLAG_PAIRWISE & key_conf->flags)) {
|
2018-04-19 19:40:11 +03:00
|
|
|
if (vif_priv->bss_index != WCN36XX_HAL_BSS_INVALID_IDX)
|
|
|
|
wcn36xx_smd_remove_bsskey(wcn,
|
|
|
|
vif_priv->encrypt_type,
|
|
|
|
vif_priv->bss_index,
|
|
|
|
key_conf->keyidx);
|
|
|
|
|
2016-04-18 22:00:50 -07:00
|
|
|
vif_priv->encrypt_type = WCN36XX_HAL_ED_NONE;
|
2013-10-08 21:25:58 +01:00
|
|
|
} else {
|
|
|
|
sta_priv->is_data_encrypted = false;
|
|
|
|
/* do not remove key if disassociated */
|
|
|
|
if (sta_priv->aid)
|
|
|
|
wcn36xx_smd_remove_stakey(wcn,
|
|
|
|
vif_priv->encrypt_type,
|
|
|
|
key_conf->keyidx,
|
|
|
|
get_sta_index(vif, sta_priv));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
wcn36xx_err("Unsupported key cmd 0x%x\n", cmd);
|
|
|
|
ret = -EOPNOTSUPP;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
2017-08-02 18:28:00 -07:00
|
|
|
mutex_unlock(&wcn->conf_mutex);
|
|
|
|
|
2013-10-08 21:25:58 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-08-24 18:53:55 +02:00
|
|
|
static int wcn36xx_hw_scan(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_vif *vif,
|
|
|
|
struct ieee80211_scan_request *hw_req)
|
2013-10-08 21:25:58 +01:00
|
|
|
{
|
2020-08-24 18:53:55 +02:00
|
|
|
struct wcn36xx *wcn = hw->priv;
|
2017-01-11 16:32:19 +02:00
|
|
|
|
2022-07-27 17:16:53 +01:00
|
|
|
if (!wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, SCAN_OFFLOAD)) {
|
2020-08-24 18:53:55 +02:00
|
|
|
/* fallback to mac80211 software scan */
|
|
|
|
return 1;
|
2017-01-11 16:32:19 +02:00
|
|
|
}
|
|
|
|
|
2021-10-18 12:57:58 +02:00
|
|
|
/* Firmware scan offload is limited to 48 channels, fallback to
|
|
|
|
* software driven scanning otherwise.
|
2020-08-24 18:53:55 +02:00
|
|
|
*/
|
2021-10-18 12:57:58 +02:00
|
|
|
if (hw_req->req.n_channels > 48) {
|
|
|
|
wcn36xx_warn("Offload scan aborted, n_channels=%u",
|
|
|
|
hw_req->req.n_channels);
|
|
|
|
return 1;
|
2020-08-24 18:53:55 +02:00
|
|
|
}
|
2013-10-08 21:25:58 +01:00
|
|
|
|
2017-01-11 16:32:19 +02:00
|
|
|
mutex_lock(&wcn->scan_lock);
|
|
|
|
if (wcn->scan_req) {
|
|
|
|
mutex_unlock(&wcn->scan_lock);
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
2017-02-01 07:27:47 -08:00
|
|
|
|
|
|
|
wcn->scan_aborted = false;
|
2017-01-11 16:32:19 +02:00
|
|
|
wcn->scan_req = &hw_req->req;
|
2017-12-08 10:35:30 +01:00
|
|
|
|
2017-01-11 16:32:19 +02:00
|
|
|
mutex_unlock(&wcn->scan_lock);
|
|
|
|
|
2021-10-25 17:22:08 +02:00
|
|
|
wcn36xx_smd_update_channel_list(wcn, &hw_req->req);
|
2017-12-08 10:35:30 +01:00
|
|
|
return wcn36xx_smd_start_hw_scan(wcn, vif, &hw_req->req);
|
2013-10-08 21:25:58 +01:00
|
|
|
}
|
|
|
|
|
2017-02-01 07:27:47 -08:00
|
|
|
static void wcn36xx_cancel_hw_scan(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_vif *vif)
|
|
|
|
{
|
|
|
|
struct wcn36xx *wcn = hw->priv;
|
|
|
|
|
|
|
|
mutex_lock(&wcn->scan_lock);
|
|
|
|
wcn->scan_aborted = true;
|
|
|
|
mutex_unlock(&wcn->scan_lock);
|
|
|
|
|
2022-07-27 17:16:53 +01:00
|
|
|
if (wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, SCAN_OFFLOAD)) {
|
2018-04-17 15:23:35 +02:00
|
|
|
/* ieee80211_scan_completed will be called on FW scan
|
|
|
|
* indication */
|
|
|
|
wcn36xx_smd_stop_hw_scan(wcn);
|
|
|
|
}
|
2017-02-01 07:27:47 -08:00
|
|
|
}
|
|
|
|
|
2020-08-24 18:53:55 +02:00
|
|
|
static void wcn36xx_sw_scan_start(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_vif *vif,
|
|
|
|
const u8 *mac_addr)
|
|
|
|
{
|
|
|
|
struct wcn36xx *wcn = hw->priv;
|
|
|
|
struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
|
|
|
|
|
2021-10-27 10:03:03 -07:00
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC, "sw_scan_start");
|
|
|
|
|
2020-08-24 18:53:55 +02:00
|
|
|
wcn->sw_scan = true;
|
|
|
|
wcn->sw_scan_vif = vif;
|
2021-08-18 13:31:43 +02:00
|
|
|
wcn->sw_scan_channel = 0;
|
2020-08-24 18:53:55 +02:00
|
|
|
if (vif_priv->sta_assoc)
|
|
|
|
wcn->sw_scan_opchannel = WCN36XX_HW_CHANNEL(wcn);
|
|
|
|
else
|
|
|
|
wcn->sw_scan_opchannel = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wcn36xx_sw_scan_complete(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_vif *vif)
|
|
|
|
{
|
|
|
|
struct wcn36xx *wcn = hw->priv;
|
|
|
|
|
2021-10-27 10:03:03 -07:00
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC, "sw_scan_complete");
|
|
|
|
|
2020-08-24 18:53:55 +02:00
|
|
|
/* ensure that any scan session is finished */
|
wcn36xx: ensure pairing of init_scan/finish_scan and start_scan/end_scan
An SMD capture from the downstream prima driver on WCN3680B shows the
following command sequence for connected scans:
- init_scan_req
- start_scan_req, channel 1
- end_scan_req, channel 1
- start_scan_req, channel 2
- ...
- end_scan_req, channel 3
- finish_scan_req
- init_scan_req
- start_scan_req, channel 4
- ...
- end_scan_req, channel 6
- finish_scan_req
- ...
- end_scan_req, channel 165
- finish_scan_req
Upstream currently never calls wcn36xx_smd_end_scan, and in some cases[1]
still sends finish_scan_req twice in a row or before init_scan_req. A
typical connected scan looks like this:
- init_scan_req
- start_scan_req, channel 1
- finish_scan_req
- init_scan_req
- start_scan_req, channel 2
- ...
- start_scan_req, channel 165
- finish_scan_req
- finish_scan_req
This patch cleans up scanning so that init/finish and start/end are always
paired together and correctly nested.
- init_scan_req
- start_scan_req, channel 1
- end_scan_req, channel 1
- finish_scan_req
- init_scan_req
- start_scan_req, channel 2
- end_scan_req, channel 2
- ...
- start_scan_req, channel 165
- end_scan_req, channel 165
- finish_scan_req
Note that upstream will not do batching of 3 active-probe scans before
returning to the operating channel, and this patch does not change that.
To match downstream in this aspect, adjust IEEE80211_PROBE_DELAY and/or
the 125ms max off-channel time in ieee80211_scan_state_decision.
[1]: commit d195d7aac09b ("wcn36xx: Ensure finish scan is not requested
before start scan") addressed one case of finish_scan_req being sent
without a preceding init_scan_req (the case of the operating channel
coinciding with the first scan channel); two other cases are:
1) if SW scan is started and aborted immediately, without scanning any
channels, we send a finish_scan_req without ever sending init_scan_req,
and
2) as SW scan logic always returns us to the operating channel before
calling wcn36xx_sw_scan_complete, finish_scan_req is always sent twice
at the end of a SW scan
Fixes: 8e84c2582169 ("wcn36xx: mac80211 driver for Qualcomm WCN3660/WCN3680 hardware")
Signed-off-by: Benjamin Li <benl@squareup.com>
Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20211027170306.555535-4-benl@squareup.com
2021-10-27 10:03:05 -07:00
|
|
|
if (wcn->sw_scan_channel)
|
|
|
|
wcn36xx_smd_end_scan(wcn, wcn->sw_scan_channel);
|
|
|
|
if (wcn->sw_scan_init) {
|
|
|
|
wcn36xx_smd_finish_scan(wcn, HAL_SYS_MODE_SCAN,
|
|
|
|
wcn->sw_scan_vif);
|
|
|
|
}
|
2020-08-24 18:53:55 +02:00
|
|
|
wcn->sw_scan = false;
|
|
|
|
wcn->sw_scan_opchannel = 0;
|
|
|
|
}
|
|
|
|
|
2013-10-08 21:25:58 +01:00
|
|
|
static void wcn36xx_update_allowed_rates(struct ieee80211_sta *sta,
|
2016-04-12 15:56:15 +02:00
|
|
|
enum nl80211_band band)
|
2013-10-08 21:25:58 +01:00
|
|
|
{
|
|
|
|
int i, size;
|
|
|
|
u16 *rates_table;
|
2016-04-18 22:00:44 -07:00
|
|
|
struct wcn36xx_sta *sta_priv = wcn36xx_sta_to_priv(sta);
|
mac80211: prepare sta handling for MLO support
Currently in mac80211 each STA object is represented
using sta_info datastructure with the associated
STA specific information and drivers access ieee80211_sta
part of it.
With MLO (Multi Link Operation) support being added
in 802.11be standard, though the association is logically
with a single Multi Link capable STA, at the physical level
communication can happen via different advertised
links (uniquely identified by Channel, operating class,
BSSID) and hence the need to handle multiple link
STA parameters within a composite sta_info object
called the MLD STA. The different link STA part of
MLD STA are identified using the link address which can
be same or different as the MLD STA address and unique
link id based on the link vif.
To support extension of such a model, the sta_info
datastructure is modified to hold multiple link STA
objects with link specific params currently within
sta_info moved to this new structure. Similarly this is
done for ieee80211_sta as well which will be accessed
within mac80211 as well as by drivers, hence trivial
driver changes are expected to support this.
For current non MLO supported drivers, only one link STA
is present and link information is accessed via 'deflink'
member.
For MLO drivers, we still need to define the APIs etc. to
get the correct link ID and access the correct part of
the station info.
Currently in mac80211, all link STA info are accessed directly
via deflink. These will be updated to access via link pointers
indexed by link id with MLO support patches, with link id
being 0 for non MLO supported cases.
Except for couple of macro related changes, below spatch takes
care of updating mac80211 and driver code to access to the
link STA info via deflink.
@ieee80211_sta@
struct ieee80211_sta *s;
struct sta_info *si;
identifier var = {supp_rates, ht_cap, vht_cap, he_cap, he_6ghz_capa, eht_cap, rx_nss, bandwidth, txpwr};
@@
(
s->
- var
+ deflink.var
|
si->sta.
- var
+ deflink.var
)
@sta_info@
struct sta_info *si;
identifier var = {gtk, pcpu_rx_stats, rx_stats, rx_stats_avg, status_stats, tx_stats, cur_max_bandwidth};
@@
(
si->
- var
+ deflink.var
)
Signed-off-by: Sriram R <quic_srirrama@quicinc.com>
Link: https://lore.kernel.org/r/1649086883-13246-1-git-send-email-quic_srirrama@quicinc.com
[remove MLO-drivers notes from commit message, not clear yet; run spatch]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2022-04-04 21:11:23 +05:30
|
|
|
u32 rates = sta->deflink.supp_rates[band];
|
2013-10-08 21:25:58 +01:00
|
|
|
|
|
|
|
memset(&sta_priv->supported_rates, 0,
|
|
|
|
sizeof(sta_priv->supported_rates));
|
|
|
|
sta_priv->supported_rates.op_rate_mode = STA_11n;
|
|
|
|
|
|
|
|
size = ARRAY_SIZE(sta_priv->supported_rates.dsss_rates);
|
|
|
|
rates_table = sta_priv->supported_rates.dsss_rates;
|
2016-04-12 15:56:15 +02:00
|
|
|
if (band == NL80211_BAND_2GHZ) {
|
2013-10-08 21:25:58 +01:00
|
|
|
for (i = 0; i < size; i++) {
|
|
|
|
if (rates & 0x01) {
|
|
|
|
rates_table[i] = wcn_2ghz_rates[i].hw_value;
|
|
|
|
rates = rates >> 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
size = ARRAY_SIZE(sta_priv->supported_rates.ofdm_rates);
|
|
|
|
rates_table = sta_priv->supported_rates.ofdm_rates;
|
|
|
|
for (i = 0; i < size; i++) {
|
|
|
|
if (rates & 0x01) {
|
|
|
|
rates_table[i] = wcn_5ghz_rates[i].hw_value;
|
|
|
|
rates = rates >> 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
mac80211: prepare sta handling for MLO support
Currently in mac80211 each STA object is represented
using sta_info datastructure with the associated
STA specific information and drivers access ieee80211_sta
part of it.
With MLO (Multi Link Operation) support being added
in 802.11be standard, though the association is logically
with a single Multi Link capable STA, at the physical level
communication can happen via different advertised
links (uniquely identified by Channel, operating class,
BSSID) and hence the need to handle multiple link
STA parameters within a composite sta_info object
called the MLD STA. The different link STA part of
MLD STA are identified using the link address which can
be same or different as the MLD STA address and unique
link id based on the link vif.
To support extension of such a model, the sta_info
datastructure is modified to hold multiple link STA
objects with link specific params currently within
sta_info moved to this new structure. Similarly this is
done for ieee80211_sta as well which will be accessed
within mac80211 as well as by drivers, hence trivial
driver changes are expected to support this.
For current non MLO supported drivers, only one link STA
is present and link information is accessed via 'deflink'
member.
For MLO drivers, we still need to define the APIs etc. to
get the correct link ID and access the correct part of
the station info.
Currently in mac80211, all link STA info are accessed directly
via deflink. These will be updated to access via link pointers
indexed by link id with MLO support patches, with link id
being 0 for non MLO supported cases.
Except for couple of macro related changes, below spatch takes
care of updating mac80211 and driver code to access to the
link STA info via deflink.
@ieee80211_sta@
struct ieee80211_sta *s;
struct sta_info *si;
identifier var = {supp_rates, ht_cap, vht_cap, he_cap, he_6ghz_capa, eht_cap, rx_nss, bandwidth, txpwr};
@@
(
s->
- var
+ deflink.var
|
si->sta.
- var
+ deflink.var
)
@sta_info@
struct sta_info *si;
identifier var = {gtk, pcpu_rx_stats, rx_stats, rx_stats_avg, status_stats, tx_stats, cur_max_bandwidth};
@@
(
si->
- var
+ deflink.var
)
Signed-off-by: Sriram R <quic_srirrama@quicinc.com>
Link: https://lore.kernel.org/r/1649086883-13246-1-git-send-email-quic_srirrama@quicinc.com
[remove MLO-drivers notes from commit message, not clear yet; run spatch]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2022-04-04 21:11:23 +05:30
|
|
|
if (sta->deflink.ht_cap.ht_supported) {
|
|
|
|
BUILD_BUG_ON(sizeof(sta->deflink.ht_cap.mcs.rx_mask) >
|
|
|
|
sizeof(sta_priv->supported_rates.supported_mcs_set));
|
2013-10-08 21:25:58 +01:00
|
|
|
memcpy(sta_priv->supported_rates.supported_mcs_set,
|
mac80211: prepare sta handling for MLO support
Currently in mac80211 each STA object is represented
using sta_info datastructure with the associated
STA specific information and drivers access ieee80211_sta
part of it.
With MLO (Multi Link Operation) support being added
in 802.11be standard, though the association is logically
with a single Multi Link capable STA, at the physical level
communication can happen via different advertised
links (uniquely identified by Channel, operating class,
BSSID) and hence the need to handle multiple link
STA parameters within a composite sta_info object
called the MLD STA. The different link STA part of
MLD STA are identified using the link address which can
be same or different as the MLD STA address and unique
link id based on the link vif.
To support extension of such a model, the sta_info
datastructure is modified to hold multiple link STA
objects with link specific params currently within
sta_info moved to this new structure. Similarly this is
done for ieee80211_sta as well which will be accessed
within mac80211 as well as by drivers, hence trivial
driver changes are expected to support this.
For current non MLO supported drivers, only one link STA
is present and link information is accessed via 'deflink'
member.
For MLO drivers, we still need to define the APIs etc. to
get the correct link ID and access the correct part of
the station info.
Currently in mac80211, all link STA info are accessed directly
via deflink. These will be updated to access via link pointers
indexed by link id with MLO support patches, with link id
being 0 for non MLO supported cases.
Except for couple of macro related changes, below spatch takes
care of updating mac80211 and driver code to access to the
link STA info via deflink.
@ieee80211_sta@
struct ieee80211_sta *s;
struct sta_info *si;
identifier var = {supp_rates, ht_cap, vht_cap, he_cap, he_6ghz_capa, eht_cap, rx_nss, bandwidth, txpwr};
@@
(
s->
- var
+ deflink.var
|
si->sta.
- var
+ deflink.var
)
@sta_info@
struct sta_info *si;
identifier var = {gtk, pcpu_rx_stats, rx_stats, rx_stats_avg, status_stats, tx_stats, cur_max_bandwidth};
@@
(
si->
- var
+ deflink.var
)
Signed-off-by: Sriram R <quic_srirrama@quicinc.com>
Link: https://lore.kernel.org/r/1649086883-13246-1-git-send-email-quic_srirrama@quicinc.com
[remove MLO-drivers notes from commit message, not clear yet; run spatch]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2022-04-04 21:11:23 +05:30
|
|
|
sta->deflink.ht_cap.mcs.rx_mask,
|
|
|
|
sizeof(sta->deflink.ht_cap.mcs.rx_mask));
|
2013-10-08 21:25:58 +01:00
|
|
|
}
|
2020-09-21 16:21:20 +03:00
|
|
|
|
mac80211: prepare sta handling for MLO support
Currently in mac80211 each STA object is represented
using sta_info datastructure with the associated
STA specific information and drivers access ieee80211_sta
part of it.
With MLO (Multi Link Operation) support being added
in 802.11be standard, though the association is logically
with a single Multi Link capable STA, at the physical level
communication can happen via different advertised
links (uniquely identified by Channel, operating class,
BSSID) and hence the need to handle multiple link
STA parameters within a composite sta_info object
called the MLD STA. The different link STA part of
MLD STA are identified using the link address which can
be same or different as the MLD STA address and unique
link id based on the link vif.
To support extension of such a model, the sta_info
datastructure is modified to hold multiple link STA
objects with link specific params currently within
sta_info moved to this new structure. Similarly this is
done for ieee80211_sta as well which will be accessed
within mac80211 as well as by drivers, hence trivial
driver changes are expected to support this.
For current non MLO supported drivers, only one link STA
is present and link information is accessed via 'deflink'
member.
For MLO drivers, we still need to define the APIs etc. to
get the correct link ID and access the correct part of
the station info.
Currently in mac80211, all link STA info are accessed directly
via deflink. These will be updated to access via link pointers
indexed by link id with MLO support patches, with link id
being 0 for non MLO supported cases.
Except for couple of macro related changes, below spatch takes
care of updating mac80211 and driver code to access to the
link STA info via deflink.
@ieee80211_sta@
struct ieee80211_sta *s;
struct sta_info *si;
identifier var = {supp_rates, ht_cap, vht_cap, he_cap, he_6ghz_capa, eht_cap, rx_nss, bandwidth, txpwr};
@@
(
s->
- var
+ deflink.var
|
si->sta.
- var
+ deflink.var
)
@sta_info@
struct sta_info *si;
identifier var = {gtk, pcpu_rx_stats, rx_stats, rx_stats_avg, status_stats, tx_stats, cur_max_bandwidth};
@@
(
si->
- var
+ deflink.var
)
Signed-off-by: Sriram R <quic_srirrama@quicinc.com>
Link: https://lore.kernel.org/r/1649086883-13246-1-git-send-email-quic_srirrama@quicinc.com
[remove MLO-drivers notes from commit message, not clear yet; run spatch]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2022-04-04 21:11:23 +05:30
|
|
|
if (sta->deflink.vht_cap.vht_supported) {
|
2020-09-21 16:21:20 +03:00
|
|
|
sta_priv->supported_rates.op_rate_mode = STA_11ac;
|
|
|
|
sta_priv->supported_rates.vht_rx_mcs_map =
|
2024-03-20 20:24:48 +02:00
|
|
|
le16_to_cpu(sta->deflink.vht_cap.vht_mcs.rx_mcs_map);
|
2020-09-21 16:21:20 +03:00
|
|
|
sta_priv->supported_rates.vht_tx_mcs_map =
|
2024-03-20 20:24:48 +02:00
|
|
|
le16_to_cpu(sta->deflink.vht_cap.vht_mcs.tx_mcs_map);
|
2020-09-21 16:21:20 +03:00
|
|
|
}
|
2013-10-08 21:25:58 +01:00
|
|
|
}
|
2020-09-21 16:21:21 +03:00
|
|
|
|
2013-10-08 21:25:58 +01:00
|
|
|
void wcn36xx_set_default_rates(struct wcn36xx_hal_supported_rates *rates)
|
|
|
|
{
|
|
|
|
u16 ofdm_rates[WCN36XX_HAL_NUM_OFDM_RATES] = {
|
|
|
|
HW_RATE_INDEX_6MBPS,
|
|
|
|
HW_RATE_INDEX_9MBPS,
|
|
|
|
HW_RATE_INDEX_12MBPS,
|
|
|
|
HW_RATE_INDEX_18MBPS,
|
|
|
|
HW_RATE_INDEX_24MBPS,
|
|
|
|
HW_RATE_INDEX_36MBPS,
|
|
|
|
HW_RATE_INDEX_48MBPS,
|
|
|
|
HW_RATE_INDEX_54MBPS
|
|
|
|
};
|
|
|
|
u16 dsss_rates[WCN36XX_HAL_NUM_DSSS_RATES] = {
|
|
|
|
HW_RATE_INDEX_1MBPS,
|
|
|
|
HW_RATE_INDEX_2MBPS,
|
|
|
|
HW_RATE_INDEX_5_5MBPS,
|
|
|
|
HW_RATE_INDEX_11MBPS
|
|
|
|
};
|
|
|
|
|
|
|
|
rates->op_rate_mode = STA_11n;
|
|
|
|
memcpy(rates->dsss_rates, dsss_rates,
|
|
|
|
sizeof(*dsss_rates) * WCN36XX_HAL_NUM_DSSS_RATES);
|
|
|
|
memcpy(rates->ofdm_rates, ofdm_rates,
|
|
|
|
sizeof(*ofdm_rates) * WCN36XX_HAL_NUM_OFDM_RATES);
|
|
|
|
rates->supported_mcs_set[0] = 0xFF;
|
|
|
|
}
|
2020-09-10 16:05:46 +01:00
|
|
|
|
|
|
|
void wcn36xx_set_default_rates_v1(struct wcn36xx_hal_supported_rates_v1 *rates)
|
|
|
|
{
|
|
|
|
rates->op_rate_mode = STA_11ac;
|
|
|
|
rates->vht_rx_mcs_map = IEEE80211_VHT_MCS_SUPPORT_0_9;
|
|
|
|
rates->vht_tx_mcs_map = IEEE80211_VHT_MCS_SUPPORT_0_9;
|
|
|
|
}
|
|
|
|
|
2013-10-08 21:25:58 +01:00
|
|
|
static void wcn36xx_bss_info_changed(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_vif *vif,
|
|
|
|
struct ieee80211_bss_conf *bss_conf,
|
2022-05-24 10:55:56 +02:00
|
|
|
u64 changed)
|
2013-10-08 21:25:58 +01:00
|
|
|
{
|
|
|
|
struct wcn36xx *wcn = hw->priv;
|
|
|
|
struct sk_buff *skb = NULL;
|
|
|
|
u16 tim_off, tim_len;
|
|
|
|
enum wcn36xx_hal_link_state link_state;
|
2016-04-18 22:00:41 -07:00
|
|
|
struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
|
2013-10-08 21:25:58 +01:00
|
|
|
|
2022-05-24 10:55:56 +02:00
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC, "mac bss info changed vif %p changed 0x%llx\n",
|
2013-10-08 21:25:58 +01:00
|
|
|
vif, changed);
|
|
|
|
|
2017-08-02 18:28:00 -07:00
|
|
|
mutex_lock(&wcn->conf_mutex);
|
|
|
|
|
2013-10-08 21:25:58 +01:00
|
|
|
if (changed & BSS_CHANGED_BEACON_INFO) {
|
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC,
|
|
|
|
"mac bss changed dtim period %d\n",
|
|
|
|
bss_conf->dtim_period);
|
|
|
|
|
|
|
|
vif_priv->dtim_period = bss_conf->dtim_period;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changed & BSS_CHANGED_BSSID) {
|
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC, "mac bss changed_bssid %pM\n",
|
|
|
|
bss_conf->bssid);
|
|
|
|
|
|
|
|
if (!is_zero_ether_addr(bss_conf->bssid)) {
|
|
|
|
vif_priv->is_joining = true;
|
2016-04-18 22:00:43 -07:00
|
|
|
vif_priv->bss_index = WCN36XX_HAL_BSS_INVALID_IDX;
|
2018-05-23 11:14:50 +03:00
|
|
|
wcn36xx_smd_set_link_st(wcn, bss_conf->bssid, vif->addr,
|
|
|
|
WCN36XX_HAL_LINK_PREASSOC_STATE);
|
2013-10-08 21:25:58 +01:00
|
|
|
wcn36xx_smd_join(wcn, bss_conf->bssid,
|
|
|
|
vif->addr, WCN36XX_HW_CHANNEL(wcn));
|
|
|
|
wcn36xx_smd_config_bss(wcn, vif, NULL,
|
|
|
|
bss_conf->bssid, false);
|
|
|
|
} else {
|
|
|
|
vif_priv->is_joining = false;
|
|
|
|
wcn36xx_smd_delete_bss(wcn, vif);
|
2018-05-23 11:14:50 +03:00
|
|
|
wcn36xx_smd_set_link_st(wcn, bss_conf->bssid, vif->addr,
|
|
|
|
WCN36XX_HAL_LINK_IDLE_STATE);
|
2016-04-18 22:00:50 -07:00
|
|
|
vif_priv->encrypt_type = WCN36XX_HAL_ED_NONE;
|
2013-10-08 21:25:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changed & BSS_CHANGED_SSID) {
|
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC,
|
|
|
|
"mac bss changed ssid\n");
|
|
|
|
wcn36xx_dbg_dump(WCN36XX_DBG_MAC, "ssid ",
|
wifi: mac80211: move interface config to new struct
We'll use bss_conf for per-link configuration later, so
move out all the non-link-specific data out into a new
struct ieee80211_vif_cfg used in the vif.
Some adjustments were done with the following spatch:
@@
expression sdata;
struct ieee80211_vif *vifp;
identifier var = { assoc, ibss_joined, aid, arp_addr_list, arp_addr_cnt, ssid, ssid_len, s1g, ibss_creator };
@@
(
-sdata->vif.bss_conf.var
+sdata->vif.cfg.var
|
-vifp->bss_conf.var
+vifp->cfg.var
)
@bss_conf@
struct ieee80211_bss_conf *bss_conf;
identifier var = { assoc, ibss_joined, aid, arp_addr_list, arp_addr_cnt, ssid, ssid_len, s1g, ibss_creator };
@@
-bss_conf->var
+vif_cfg->var
(though more manual fixups were needed, e.g. replacing
"vif_cfg->" by "vif->cfg." in many files.)
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2022-05-10 17:05:04 +02:00
|
|
|
vif->cfg.ssid, vif->cfg.ssid_len);
|
2013-10-08 21:25:58 +01:00
|
|
|
|
wifi: mac80211: move interface config to new struct
We'll use bss_conf for per-link configuration later, so
move out all the non-link-specific data out into a new
struct ieee80211_vif_cfg used in the vif.
Some adjustments were done with the following spatch:
@@
expression sdata;
struct ieee80211_vif *vifp;
identifier var = { assoc, ibss_joined, aid, arp_addr_list, arp_addr_cnt, ssid, ssid_len, s1g, ibss_creator };
@@
(
-sdata->vif.bss_conf.var
+sdata->vif.cfg.var
|
-vifp->bss_conf.var
+vifp->cfg.var
)
@bss_conf@
struct ieee80211_bss_conf *bss_conf;
identifier var = { assoc, ibss_joined, aid, arp_addr_list, arp_addr_cnt, ssid, ssid_len, s1g, ibss_creator };
@@
-bss_conf->var
+vif_cfg->var
(though more manual fixups were needed, e.g. replacing
"vif_cfg->" by "vif->cfg." in many files.)
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2022-05-10 17:05:04 +02:00
|
|
|
vif_priv->ssid.length = vif->cfg.ssid_len;
|
2013-10-08 21:25:58 +01:00
|
|
|
memcpy(&vif_priv->ssid.ssid,
|
wifi: mac80211: move interface config to new struct
We'll use bss_conf for per-link configuration later, so
move out all the non-link-specific data out into a new
struct ieee80211_vif_cfg used in the vif.
Some adjustments were done with the following spatch:
@@
expression sdata;
struct ieee80211_vif *vifp;
identifier var = { assoc, ibss_joined, aid, arp_addr_list, arp_addr_cnt, ssid, ssid_len, s1g, ibss_creator };
@@
(
-sdata->vif.bss_conf.var
+sdata->vif.cfg.var
|
-vifp->bss_conf.var
+vifp->cfg.var
)
@bss_conf@
struct ieee80211_bss_conf *bss_conf;
identifier var = { assoc, ibss_joined, aid, arp_addr_list, arp_addr_cnt, ssid, ssid_len, s1g, ibss_creator };
@@
-bss_conf->var
+vif_cfg->var
(though more manual fixups were needed, e.g. replacing
"vif_cfg->" by "vif->cfg." in many files.)
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2022-05-10 17:05:04 +02:00
|
|
|
vif->cfg.ssid,
|
|
|
|
vif->cfg.ssid_len);
|
2013-10-08 21:25:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (changed & BSS_CHANGED_ASSOC) {
|
|
|
|
vif_priv->is_joining = false;
|
wifi: mac80211: move interface config to new struct
We'll use bss_conf for per-link configuration later, so
move out all the non-link-specific data out into a new
struct ieee80211_vif_cfg used in the vif.
Some adjustments were done with the following spatch:
@@
expression sdata;
struct ieee80211_vif *vifp;
identifier var = { assoc, ibss_joined, aid, arp_addr_list, arp_addr_cnt, ssid, ssid_len, s1g, ibss_creator };
@@
(
-sdata->vif.bss_conf.var
+sdata->vif.cfg.var
|
-vifp->bss_conf.var
+vifp->cfg.var
)
@bss_conf@
struct ieee80211_bss_conf *bss_conf;
identifier var = { assoc, ibss_joined, aid, arp_addr_list, arp_addr_cnt, ssid, ssid_len, s1g, ibss_creator };
@@
-bss_conf->var
+vif_cfg->var
(though more manual fixups were needed, e.g. replacing
"vif_cfg->" by "vif->cfg." in many files.)
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2022-05-10 17:05:04 +02:00
|
|
|
if (vif->cfg.assoc) {
|
2013-10-08 21:25:58 +01:00
|
|
|
struct ieee80211_sta *sta;
|
|
|
|
struct wcn36xx_sta *sta_priv;
|
|
|
|
|
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC,
|
|
|
|
"mac assoc bss %pM vif %pM AID=%d\n",
|
|
|
|
bss_conf->bssid,
|
|
|
|
vif->addr,
|
wifi: mac80211: move interface config to new struct
We'll use bss_conf for per-link configuration later, so
move out all the non-link-specific data out into a new
struct ieee80211_vif_cfg used in the vif.
Some adjustments were done with the following spatch:
@@
expression sdata;
struct ieee80211_vif *vifp;
identifier var = { assoc, ibss_joined, aid, arp_addr_list, arp_addr_cnt, ssid, ssid_len, s1g, ibss_creator };
@@
(
-sdata->vif.bss_conf.var
+sdata->vif.cfg.var
|
-vifp->bss_conf.var
+vifp->cfg.var
)
@bss_conf@
struct ieee80211_bss_conf *bss_conf;
identifier var = { assoc, ibss_joined, aid, arp_addr_list, arp_addr_cnt, ssid, ssid_len, s1g, ibss_creator };
@@
-bss_conf->var
+vif_cfg->var
(though more manual fixups were needed, e.g. replacing
"vif_cfg->" by "vif->cfg." in many files.)
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2022-05-10 17:05:04 +02:00
|
|
|
vif->cfg.aid);
|
2013-10-08 21:25:58 +01:00
|
|
|
|
2016-04-18 22:00:51 -07:00
|
|
|
vif_priv->sta_assoc = true;
|
2017-08-02 18:28:00 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Holding conf_mutex ensures mutal exclusion with
|
|
|
|
* wcn36xx_sta_remove() and as such ensures that sta
|
|
|
|
* won't be freed while we're operating on it. As such
|
|
|
|
* we do not need to hold the rcu_read_lock().
|
|
|
|
*/
|
2013-10-08 21:25:58 +01:00
|
|
|
sta = ieee80211_find_sta(vif, bss_conf->bssid);
|
|
|
|
if (!sta) {
|
|
|
|
wcn36xx_err("sta %pM is not found\n",
|
|
|
|
bss_conf->bssid);
|
|
|
|
goto out;
|
|
|
|
}
|
2016-04-18 22:00:44 -07:00
|
|
|
sta_priv = wcn36xx_sta_to_priv(sta);
|
2013-10-08 21:25:58 +01:00
|
|
|
|
|
|
|
wcn36xx_update_allowed_rates(sta, WCN36XX_BAND(wcn));
|
|
|
|
|
|
|
|
wcn36xx_smd_set_link_st(wcn, bss_conf->bssid,
|
|
|
|
vif->addr,
|
|
|
|
WCN36XX_HAL_LINK_POSTASSOC_STATE);
|
|
|
|
wcn36xx_smd_config_bss(wcn, vif, sta,
|
|
|
|
bss_conf->bssid,
|
|
|
|
true);
|
wifi: mac80211: move interface config to new struct
We'll use bss_conf for per-link configuration later, so
move out all the non-link-specific data out into a new
struct ieee80211_vif_cfg used in the vif.
Some adjustments were done with the following spatch:
@@
expression sdata;
struct ieee80211_vif *vifp;
identifier var = { assoc, ibss_joined, aid, arp_addr_list, arp_addr_cnt, ssid, ssid_len, s1g, ibss_creator };
@@
(
-sdata->vif.bss_conf.var
+sdata->vif.cfg.var
|
-vifp->bss_conf.var
+vifp->cfg.var
)
@bss_conf@
struct ieee80211_bss_conf *bss_conf;
identifier var = { assoc, ibss_joined, aid, arp_addr_list, arp_addr_cnt, ssid, ssid_len, s1g, ibss_creator };
@@
-bss_conf->var
+vif_cfg->var
(though more manual fixups were needed, e.g. replacing
"vif_cfg->" by "vif->cfg." in many files.)
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2022-05-10 17:05:04 +02:00
|
|
|
sta_priv->aid = vif->cfg.aid;
|
2013-10-08 21:25:58 +01:00
|
|
|
/*
|
|
|
|
* config_sta must be called from because this is the
|
|
|
|
* place where AID is available.
|
|
|
|
*/
|
|
|
|
wcn36xx_smd_config_sta(wcn, vif, sta);
|
wcn36xx: Implement beacon filtering
The prima driver facilitates the direct programming of beacon filter tables via
SMD commands.
The purpose of beacon filters is quote:
/* When beacon filtering is enabled, firmware will
* analyze the selected beacons received during BMPS,
* and monitor any changes in the IEs as listed below.
* The format of the table is:
* - EID
* - Check for IE presence
* - Byte offset
* - Byte value
* - Bit Mask
* - Byte reference
*/
The default filter table looks something like this:
tBeaconFilterIe gaBcnFilterTable[12] =
{
{ WLAN_EID_DS_PARAMS, 0u, { 0u, 0u, 0u, 0u } },
{ WLAN_EID_ERP_INFO, 0u, { 0u, 0u, 248u, 0u } },
{ WLAN_EID_EDCA_PARAM_SET, 0u, { 0u, 0u, 240u, 0u } },
{ WLAN_EID_QOS_CAPA, 0u, { 0u, 0u, 240u, 0u } },
{ WLAN_EID_CHANNEL_SWITCH, 1u, { 0u, 0u, 0u, 0u } },
{ WLAN_EID_QUIET, 1u, { 0u, 0u, 0u, 0u } },
{ WLAN_EID_HT_OPERATION, 0u, { 0u, 0u, 0u, 0u } },
{ WLAN_EID_HT_OPERATION, 0u, { 1u, 0u, 248u, 0u } },
{ WLAN_EID_HT_OPERATION, 0u, { 2u, 0u, 235u, 0u } },
{ WLAN_EID_HT_OPERATION, 0u, { 5u, 0u, 253u, 0u } },
{ WLAN_EID_PWR_CONSTRAINT, 0u, { 0u, 0u, 0u, 0u } },
{ WLAN_EID_OPMODE_NOTIF, 0u, { 0u, 0u, 0u, 0u } }
};
Add in an equivalent filter set as present in the prima Linux driver.
For now omit the beacon filter "rem" command as the driver does not have an
explicit call to that SMD command. The filter mask should only count when
we are inside BMPS anyway.
Replicating the ability to program the filter table gives us scope to add and
remove elements in future. For now though this patch makes the rote-copy of the
downstream Linux beacon filter table, which we can tweak as desired from now
on.
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20211214134630.2214840-4-bryan.odonoghue@linaro.org
2021-12-14 13:46:30 +00:00
|
|
|
if (vif->type == NL80211_IFTYPE_STATION)
|
|
|
|
wcn36xx_smd_add_beacon_filter(wcn, vif);
|
2020-11-03 12:17:35 +00:00
|
|
|
wcn36xx_enable_keep_alive_null_packet(wcn, vif);
|
2013-10-08 21:25:58 +01:00
|
|
|
} else {
|
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC,
|
|
|
|
"disassociated bss %pM vif %pM AID=%d\n",
|
|
|
|
bss_conf->bssid,
|
|
|
|
vif->addr,
|
wifi: mac80211: move interface config to new struct
We'll use bss_conf for per-link configuration later, so
move out all the non-link-specific data out into a new
struct ieee80211_vif_cfg used in the vif.
Some adjustments were done with the following spatch:
@@
expression sdata;
struct ieee80211_vif *vifp;
identifier var = { assoc, ibss_joined, aid, arp_addr_list, arp_addr_cnt, ssid, ssid_len, s1g, ibss_creator };
@@
(
-sdata->vif.bss_conf.var
+sdata->vif.cfg.var
|
-vifp->bss_conf.var
+vifp->cfg.var
)
@bss_conf@
struct ieee80211_bss_conf *bss_conf;
identifier var = { assoc, ibss_joined, aid, arp_addr_list, arp_addr_cnt, ssid, ssid_len, s1g, ibss_creator };
@@
-bss_conf->var
+vif_cfg->var
(though more manual fixups were needed, e.g. replacing
"vif_cfg->" by "vif->cfg." in many files.)
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2022-05-10 17:05:04 +02:00
|
|
|
vif->cfg.aid);
|
2016-04-18 22:00:51 -07:00
|
|
|
vif_priv->sta_assoc = false;
|
2013-10-08 21:25:58 +01:00
|
|
|
wcn36xx_smd_set_link_st(wcn,
|
|
|
|
bss_conf->bssid,
|
|
|
|
vif->addr,
|
|
|
|
WCN36XX_HAL_LINK_IDLE_STATE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changed & BSS_CHANGED_AP_PROBE_RESP) {
|
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC, "mac bss changed ap probe resp\n");
|
|
|
|
skb = ieee80211_proberesp_get(hw, vif);
|
|
|
|
if (!skb) {
|
|
|
|
wcn36xx_err("failed to alloc probereq skb\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
wcn36xx_smd_update_proberesp_tmpl(wcn, vif, skb);
|
|
|
|
dev_kfree_skb(skb);
|
|
|
|
}
|
|
|
|
|
2013-10-31 14:07:45 +08:00
|
|
|
if (changed & BSS_CHANGED_BEACON_ENABLED ||
|
|
|
|
changed & BSS_CHANGED_BEACON) {
|
2013-10-08 21:25:58 +01:00
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC,
|
|
|
|
"mac bss changed beacon enabled %d\n",
|
|
|
|
bss_conf->enable_beacon);
|
|
|
|
|
|
|
|
if (bss_conf->enable_beacon) {
|
2014-02-12 19:04:48 +00:00
|
|
|
vif_priv->dtim_period = bss_conf->dtim_period;
|
2016-04-18 22:00:43 -07:00
|
|
|
vif_priv->bss_index = WCN36XX_HAL_BSS_INVALID_IDX;
|
2013-10-08 21:25:58 +01:00
|
|
|
wcn36xx_smd_config_bss(wcn, vif, NULL,
|
|
|
|
vif->addr, false);
|
|
|
|
skb = ieee80211_beacon_get_tim(hw, vif, &tim_off,
|
2022-06-06 14:25:54 +03:00
|
|
|
&tim_len, 0);
|
2013-10-08 21:25:58 +01:00
|
|
|
if (!skb) {
|
|
|
|
wcn36xx_err("failed to alloc beacon skb\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
wcn36xx_smd_send_beacon(wcn, vif, skb, tim_off, 0);
|
|
|
|
dev_kfree_skb(skb);
|
|
|
|
|
|
|
|
if (vif->type == NL80211_IFTYPE_ADHOC ||
|
|
|
|
vif->type == NL80211_IFTYPE_MESH_POINT)
|
|
|
|
link_state = WCN36XX_HAL_LINK_IBSS_STATE;
|
|
|
|
else
|
|
|
|
link_state = WCN36XX_HAL_LINK_AP_STATE;
|
|
|
|
|
|
|
|
wcn36xx_smd_set_link_st(wcn, vif->addr, vif->addr,
|
|
|
|
link_state);
|
|
|
|
} else {
|
2016-04-18 22:00:54 -07:00
|
|
|
wcn36xx_smd_delete_bss(wcn, vif);
|
2013-10-08 21:25:58 +01:00
|
|
|
wcn36xx_smd_set_link_st(wcn, vif->addr, vif->addr,
|
|
|
|
WCN36XX_HAL_LINK_IDLE_STATE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
out:
|
2017-08-02 18:28:00 -07:00
|
|
|
|
|
|
|
mutex_unlock(&wcn->conf_mutex);
|
2013-10-08 21:25:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* this is required when using IEEE80211_HW_HAS_RATE_CONTROL */
|
2025-06-15 13:53:09 +05:30
|
|
|
static int wcn36xx_set_rts_threshold(struct ieee80211_hw *hw, int radio_idx,
|
|
|
|
u32 value)
|
2013-10-08 21:25:58 +01:00
|
|
|
{
|
|
|
|
struct wcn36xx *wcn = hw->priv;
|
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC, "mac set RTS threshold %d\n", value);
|
|
|
|
|
2017-08-02 18:28:00 -07:00
|
|
|
mutex_lock(&wcn->conf_mutex);
|
2013-10-08 21:25:58 +01:00
|
|
|
wcn36xx_smd_update_cfg(wcn, WCN36XX_HAL_CFG_RTS_THRESHOLD, value);
|
2017-08-02 18:28:00 -07:00
|
|
|
mutex_unlock(&wcn->conf_mutex);
|
|
|
|
|
2013-10-08 21:25:58 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wcn36xx_remove_interface(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_vif *vif)
|
|
|
|
{
|
|
|
|
struct wcn36xx *wcn = hw->priv;
|
2016-04-18 22:00:41 -07:00
|
|
|
struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
|
2013-10-08 21:25:58 +01:00
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC, "mac remove interface vif %p\n", vif);
|
|
|
|
|
2017-08-02 18:28:00 -07:00
|
|
|
mutex_lock(&wcn->conf_mutex);
|
|
|
|
|
2013-10-08 21:25:58 +01:00
|
|
|
list_del(&vif_priv->list);
|
|
|
|
wcn36xx_smd_delete_sta_self(wcn, vif->addr);
|
2017-08-02 18:28:00 -07:00
|
|
|
|
|
|
|
mutex_unlock(&wcn->conf_mutex);
|
2013-10-08 21:25:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int wcn36xx_add_interface(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_vif *vif)
|
|
|
|
{
|
|
|
|
struct wcn36xx *wcn = hw->priv;
|
2016-04-18 22:00:41 -07:00
|
|
|
struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
|
2013-10-08 21:25:58 +01:00
|
|
|
|
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC, "mac add interface vif %p type %d\n",
|
|
|
|
vif, vif->type);
|
|
|
|
|
|
|
|
if (!(NL80211_IFTYPE_STATION == vif->type ||
|
|
|
|
NL80211_IFTYPE_AP == vif->type ||
|
|
|
|
NL80211_IFTYPE_ADHOC == vif->type ||
|
|
|
|
NL80211_IFTYPE_MESH_POINT == vif->type)) {
|
|
|
|
wcn36xx_warn("Unsupported interface type requested: %d\n",
|
|
|
|
vif->type);
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2017-08-02 18:28:00 -07:00
|
|
|
mutex_lock(&wcn->conf_mutex);
|
|
|
|
|
2018-04-03 18:51:54 +02:00
|
|
|
vif_priv->bss_index = WCN36XX_HAL_BSS_INVALID_IDX;
|
2018-06-20 09:57:59 +02:00
|
|
|
INIT_LIST_HEAD(&vif_priv->sta_list);
|
2013-10-08 21:25:58 +01:00
|
|
|
list_add(&vif_priv->list, &wcn->vif_list);
|
|
|
|
wcn36xx_smd_add_sta_self(wcn, vif);
|
|
|
|
|
2017-08-02 18:28:00 -07:00
|
|
|
mutex_unlock(&wcn->conf_mutex);
|
|
|
|
|
2013-10-08 21:25:58 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wcn36xx_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
|
|
|
struct ieee80211_sta *sta)
|
|
|
|
{
|
|
|
|
struct wcn36xx *wcn = hw->priv;
|
2016-04-18 22:00:41 -07:00
|
|
|
struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
|
2016-04-18 22:00:44 -07:00
|
|
|
struct wcn36xx_sta *sta_priv = wcn36xx_sta_to_priv(sta);
|
2013-10-08 21:25:58 +01:00
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC, "mac sta add vif %p sta %pM\n",
|
|
|
|
vif, sta->addr);
|
|
|
|
|
2017-08-02 18:28:00 -07:00
|
|
|
mutex_lock(&wcn->conf_mutex);
|
|
|
|
|
2015-01-09 14:15:52 -05:00
|
|
|
spin_lock_init(&sta_priv->ampdu_lock);
|
2013-10-08 21:25:58 +01:00
|
|
|
sta_priv->vif = vif_priv;
|
2018-06-20 09:57:59 +02:00
|
|
|
list_add(&sta_priv->list, &vif_priv->sta_list);
|
|
|
|
|
2013-10-08 21:25:58 +01:00
|
|
|
/*
|
|
|
|
* For STA mode HW will be configured on BSS_CHANGED_ASSOC because
|
|
|
|
* at this stage AID is not available yet.
|
|
|
|
*/
|
|
|
|
if (NL80211_IFTYPE_STATION != vif->type) {
|
|
|
|
wcn36xx_update_allowed_rates(sta, WCN36XX_BAND(wcn));
|
|
|
|
sta_priv->aid = sta->aid;
|
|
|
|
wcn36xx_smd_config_sta(wcn, vif, sta);
|
|
|
|
}
|
2017-08-02 18:28:00 -07:00
|
|
|
|
|
|
|
mutex_unlock(&wcn->conf_mutex);
|
|
|
|
|
2013-10-08 21:25:58 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wcn36xx_sta_remove(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_vif *vif,
|
|
|
|
struct ieee80211_sta *sta)
|
|
|
|
{
|
|
|
|
struct wcn36xx *wcn = hw->priv;
|
2016-04-18 22:00:44 -07:00
|
|
|
struct wcn36xx_sta *sta_priv = wcn36xx_sta_to_priv(sta);
|
2013-10-08 21:25:58 +01:00
|
|
|
|
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC, "mac sta remove vif %p sta %pM index %d\n",
|
|
|
|
vif, sta->addr, sta_priv->sta_index);
|
|
|
|
|
2017-08-02 18:28:00 -07:00
|
|
|
mutex_lock(&wcn->conf_mutex);
|
|
|
|
|
2018-06-20 09:57:59 +02:00
|
|
|
list_del(&sta_priv->list);
|
2013-10-08 21:25:58 +01:00
|
|
|
wcn36xx_smd_delete_sta(wcn, sta_priv->sta_index);
|
|
|
|
sta_priv->vif = NULL;
|
2017-08-02 18:28:00 -07:00
|
|
|
|
|
|
|
mutex_unlock(&wcn->conf_mutex);
|
|
|
|
|
2013-10-08 21:25:58 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_PM
|
|
|
|
|
2021-06-05 02:11:30 +01:00
|
|
|
static struct ieee80211_vif *wcn36xx_get_first_assoc_vif(struct wcn36xx *wcn)
|
|
|
|
{
|
|
|
|
struct wcn36xx_vif *vif_priv = NULL;
|
|
|
|
struct ieee80211_vif *vif = NULL;
|
|
|
|
|
|
|
|
list_for_each_entry(vif_priv, &wcn->vif_list, list) {
|
|
|
|
if (vif_priv->sta_assoc) {
|
|
|
|
vif = wcn36xx_priv_to_vif(vif_priv);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return vif;
|
|
|
|
}
|
|
|
|
|
2013-10-08 21:25:58 +01:00
|
|
|
static int wcn36xx_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wow)
|
|
|
|
{
|
|
|
|
struct wcn36xx *wcn = hw->priv;
|
2021-06-05 02:11:30 +01:00
|
|
|
struct ieee80211_vif *vif = NULL;
|
|
|
|
int ret = 0;
|
2013-10-08 21:25:58 +01:00
|
|
|
|
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC, "mac suspend\n");
|
|
|
|
|
2021-06-05 02:11:30 +01:00
|
|
|
mutex_lock(&wcn->conf_mutex);
|
2021-06-05 02:11:31 +01:00
|
|
|
|
2021-06-05 02:11:30 +01:00
|
|
|
vif = wcn36xx_get_first_assoc_vif(wcn);
|
2021-06-05 02:11:31 +01:00
|
|
|
if (vif) {
|
|
|
|
ret = wcn36xx_smd_arp_offload(wcn, vif, true);
|
2021-06-05 02:11:34 +01:00
|
|
|
if (ret)
|
|
|
|
goto out;
|
|
|
|
ret = wcn36xx_smd_ipv6_ns_offload(wcn, vif, true);
|
2021-06-05 02:11:36 +01:00
|
|
|
if (ret)
|
|
|
|
goto out;
|
|
|
|
ret = wcn36xx_smd_gtk_offload(wcn, vif, true);
|
2021-06-05 02:11:31 +01:00
|
|
|
if (ret)
|
|
|
|
goto out;
|
2021-06-05 02:11:30 +01:00
|
|
|
ret = wcn36xx_smd_set_power_params(wcn, true);
|
2021-06-05 02:11:38 +01:00
|
|
|
if (ret)
|
|
|
|
goto out;
|
|
|
|
ret = wcn36xx_smd_wlan_host_suspend_ind(wcn);
|
2021-06-05 02:11:31 +01:00
|
|
|
}
|
2021-10-25 10:28:16 +02:00
|
|
|
|
|
|
|
/* Disable IRQ, we don't want to handle any packet before mac80211 is
|
|
|
|
* resumed and ready to receive packets.
|
|
|
|
*/
|
|
|
|
disable_irq(wcn->tx_irq);
|
|
|
|
disable_irq(wcn->rx_irq);
|
|
|
|
|
2021-06-05 02:11:31 +01:00
|
|
|
out:
|
2021-06-05 02:11:30 +01:00
|
|
|
mutex_unlock(&wcn->conf_mutex);
|
2021-06-05 02:11:29 +01:00
|
|
|
return ret;
|
2013-10-08 21:25:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int wcn36xx_resume(struct ieee80211_hw *hw)
|
|
|
|
{
|
|
|
|
struct wcn36xx *wcn = hw->priv;
|
2021-06-05 02:11:30 +01:00
|
|
|
struct ieee80211_vif *vif = NULL;
|
2013-10-08 21:25:58 +01:00
|
|
|
|
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC, "mac resume\n");
|
|
|
|
|
2021-06-05 02:11:30 +01:00
|
|
|
mutex_lock(&wcn->conf_mutex);
|
|
|
|
vif = wcn36xx_get_first_assoc_vif(wcn);
|
2021-06-05 02:11:31 +01:00
|
|
|
if (vif) {
|
2021-06-05 02:11:39 +01:00
|
|
|
wcn36xx_smd_host_resume(wcn);
|
2021-06-05 02:11:30 +01:00
|
|
|
wcn36xx_smd_set_power_params(wcn, false);
|
2021-06-05 02:11:37 +01:00
|
|
|
wcn36xx_smd_gtk_offload_get_info(wcn, vif);
|
2021-06-05 02:11:36 +01:00
|
|
|
wcn36xx_smd_gtk_offload(wcn, vif, false);
|
2021-06-05 02:11:34 +01:00
|
|
|
wcn36xx_smd_ipv6_ns_offload(wcn, vif, false);
|
2021-06-05 02:11:31 +01:00
|
|
|
wcn36xx_smd_arp_offload(wcn, vif, false);
|
|
|
|
}
|
2021-10-25 10:28:16 +02:00
|
|
|
|
|
|
|
enable_irq(wcn->tx_irq);
|
|
|
|
enable_irq(wcn->rx_irq);
|
|
|
|
|
2021-06-05 02:11:30 +01:00
|
|
|
mutex_unlock(&wcn->conf_mutex);
|
|
|
|
|
2013-10-08 21:25:58 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-06-05 02:11:35 +01:00
|
|
|
static void wcn36xx_set_rekey_data(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_vif *vif,
|
|
|
|
struct cfg80211_gtk_rekey_data *data)
|
|
|
|
{
|
|
|
|
struct wcn36xx *wcn = hw->priv;
|
|
|
|
struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
|
|
|
|
|
|
|
|
mutex_lock(&wcn->conf_mutex);
|
|
|
|
|
|
|
|
memcpy(vif_priv->rekey_data.kek, data->kek, NL80211_KEK_LEN);
|
|
|
|
memcpy(vif_priv->rekey_data.kck, data->kck, NL80211_KCK_LEN);
|
|
|
|
vif_priv->rekey_data.replay_ctr =
|
|
|
|
cpu_to_le64(be64_to_cpup((__be64 *)data->replay_ctr));
|
|
|
|
vif_priv->rekey_data.valid = true;
|
|
|
|
|
|
|
|
mutex_unlock(&wcn->conf_mutex);
|
|
|
|
}
|
|
|
|
|
2013-10-08 21:25:58 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
static int wcn36xx_ampdu_action(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_vif *vif,
|
2015-12-30 16:06:04 +02:00
|
|
|
struct ieee80211_ampdu_params *params)
|
2013-10-08 21:25:58 +01:00
|
|
|
{
|
|
|
|
struct wcn36xx *wcn = hw->priv;
|
2016-04-18 22:00:44 -07:00
|
|
|
struct wcn36xx_sta *sta_priv = wcn36xx_sta_to_priv(params->sta);
|
2015-12-30 16:06:04 +02:00
|
|
|
struct ieee80211_sta *sta = params->sta;
|
|
|
|
enum ieee80211_ampdu_mlme_action action = params->action;
|
|
|
|
u16 tid = params->tid;
|
|
|
|
u16 *ssn = ¶ms->ssn;
|
2019-10-02 11:12:25 +02:00
|
|
|
int ret = 0;
|
2021-11-22 19:04:11 +01:00
|
|
|
int session;
|
2013-10-08 21:25:58 +01:00
|
|
|
|
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC, "mac ampdu action action %d tid %d\n",
|
|
|
|
action, tid);
|
|
|
|
|
2017-08-02 18:28:00 -07:00
|
|
|
mutex_lock(&wcn->conf_mutex);
|
|
|
|
|
2013-10-08 21:25:58 +01:00
|
|
|
switch (action) {
|
|
|
|
case IEEE80211_AMPDU_RX_START:
|
|
|
|
sta_priv->tid = tid;
|
2020-07-24 12:20:47 +02:00
|
|
|
session = wcn36xx_smd_add_ba_session(wcn, sta, tid, ssn, 0,
|
|
|
|
get_sta_index(vif, sta_priv));
|
2021-11-22 19:04:11 +01:00
|
|
|
if (session < 0) {
|
|
|
|
ret = session;
|
|
|
|
goto out;
|
|
|
|
}
|
2020-07-24 12:20:47 +02:00
|
|
|
wcn36xx_smd_add_ba(wcn, session);
|
2013-10-08 21:25:58 +01:00
|
|
|
break;
|
|
|
|
case IEEE80211_AMPDU_RX_STOP:
|
2021-02-08 13:32:11 +02:00
|
|
|
wcn36xx_smd_del_ba(wcn, tid, 0, get_sta_index(vif, sta_priv));
|
2013-10-08 21:25:58 +01:00
|
|
|
break;
|
|
|
|
case IEEE80211_AMPDU_TX_START:
|
2015-01-09 14:15:52 -05:00
|
|
|
spin_lock_bh(&sta_priv->ampdu_lock);
|
|
|
|
sta_priv->ampdu_state[tid] = WCN36XX_AMPDU_START;
|
|
|
|
spin_unlock_bh(&sta_priv->ampdu_lock);
|
|
|
|
|
2021-11-22 19:04:11 +01:00
|
|
|
/* Replace the mac80211 ssn with the firmware one */
|
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC, "mac ampdu ssn = %u\n", *ssn);
|
|
|
|
wcn36xx_smd_trigger_ba(wcn, get_sta_index(vif, sta_priv), tid, ssn);
|
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC, "mac ampdu fw-ssn = %u\n", *ssn);
|
|
|
|
|
|
|
|
/* Start BA session */
|
|
|
|
session = wcn36xx_smd_add_ba_session(wcn, sta, tid, ssn, 1,
|
|
|
|
get_sta_index(vif, sta_priv));
|
|
|
|
if (session < 0) {
|
|
|
|
ret = session;
|
|
|
|
goto out;
|
|
|
|
}
|
2019-10-02 11:12:25 +02:00
|
|
|
ret = IEEE80211_AMPDU_TX_START_IMMEDIATE;
|
2013-10-08 21:25:58 +01:00
|
|
|
break;
|
|
|
|
case IEEE80211_AMPDU_TX_OPERATIONAL:
|
2015-01-09 14:15:52 -05:00
|
|
|
spin_lock_bh(&sta_priv->ampdu_lock);
|
|
|
|
sta_priv->ampdu_state[tid] = WCN36XX_AMPDU_OPERATIONAL;
|
|
|
|
spin_unlock_bh(&sta_priv->ampdu_lock);
|
|
|
|
|
2013-10-08 21:25:58 +01:00
|
|
|
break;
|
|
|
|
case IEEE80211_AMPDU_TX_STOP_FLUSH:
|
|
|
|
case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
|
|
|
|
case IEEE80211_AMPDU_TX_STOP_CONT:
|
2015-01-09 14:15:52 -05:00
|
|
|
spin_lock_bh(&sta_priv->ampdu_lock);
|
|
|
|
sta_priv->ampdu_state[tid] = WCN36XX_AMPDU_NONE;
|
|
|
|
spin_unlock_bh(&sta_priv->ampdu_lock);
|
|
|
|
|
2021-02-08 13:32:11 +02:00
|
|
|
wcn36xx_smd_del_ba(wcn, tid, 1, get_sta_index(vif, sta_priv));
|
2013-10-08 21:25:58 +01:00
|
|
|
ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
wcn36xx_err("Unknown AMPDU action\n");
|
|
|
|
}
|
|
|
|
|
2021-11-22 19:04:11 +01:00
|
|
|
out:
|
2017-08-02 18:28:00 -07:00
|
|
|
mutex_unlock(&wcn->conf_mutex);
|
|
|
|
|
2019-10-02 11:12:25 +02:00
|
|
|
return ret;
|
2013-10-08 21:25:58 +01:00
|
|
|
}
|
|
|
|
|
2021-06-05 02:11:33 +01:00
|
|
|
#if IS_ENABLED(CONFIG_IPV6)
|
|
|
|
static void wcn36xx_ipv6_addr_change(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_vif *vif,
|
|
|
|
struct inet6_dev *idev)
|
|
|
|
{
|
|
|
|
struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
|
|
|
|
struct inet6_ifaddr *ifa;
|
|
|
|
int idx = 0;
|
|
|
|
|
|
|
|
memset(vif_priv->tentative_addrs, 0, sizeof(vif_priv->tentative_addrs));
|
|
|
|
|
|
|
|
read_lock_bh(&idev->lock);
|
|
|
|
list_for_each_entry(ifa, &idev->addr_list, if_list) {
|
|
|
|
vif_priv->target_ipv6_addrs[idx] = ifa->addr;
|
|
|
|
if (ifa->flags & IFA_F_TENTATIVE)
|
|
|
|
__set_bit(idx, vif_priv->tentative_addrs);
|
|
|
|
idx++;
|
|
|
|
if (idx >= WCN36XX_HAL_IPV6_OFFLOAD_ADDR_MAX)
|
|
|
|
break;
|
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC, "%pI6 %s\n", &ifa->addr,
|
|
|
|
(ifa->flags & IFA_F_TENTATIVE) ? "tentative" : NULL);
|
|
|
|
}
|
|
|
|
read_unlock_bh(&idev->lock);
|
|
|
|
|
|
|
|
vif_priv->num_target_ipv6_addrs = idx;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-10-27 10:03:04 -07:00
|
|
|
static void wcn36xx_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
|
|
|
u32 queues, bool drop)
|
|
|
|
{
|
|
|
|
struct wcn36xx *wcn = hw->priv;
|
|
|
|
|
|
|
|
if (wcn36xx_dxe_tx_flush(wcn)) {
|
|
|
|
wcn36xx_err("Failed to flush hardware tx queues\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-15 00:16:46 +00:00
|
|
|
static int wcn36xx_get_survey(struct ieee80211_hw *hw, int idx,
|
|
|
|
struct survey_info *survey)
|
|
|
|
{
|
|
|
|
struct wcn36xx *wcn = hw->priv;
|
|
|
|
struct ieee80211_supported_band *sband;
|
|
|
|
struct wcn36xx_chan_survey *chan_survey;
|
|
|
|
int band_idx;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
sband = wcn->hw->wiphy->bands[NL80211_BAND_2GHZ];
|
|
|
|
band_idx = idx;
|
|
|
|
if (band_idx >= sband->n_channels) {
|
|
|
|
band_idx -= sband->n_channels;
|
|
|
|
sband = wcn->hw->wiphy->bands[NL80211_BAND_5GHZ];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!sband || band_idx >= sband->n_channels)
|
|
|
|
return -ENOENT;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&wcn->survey_lock, flags);
|
|
|
|
|
|
|
|
chan_survey = &wcn->chan_survey[idx];
|
|
|
|
survey->channel = &sband->channels[band_idx];
|
|
|
|
survey->noise = chan_survey->rssi - chan_survey->snr;
|
|
|
|
survey->filled = 0;
|
|
|
|
|
|
|
|
if (chan_survey->rssi > -100 && chan_survey->rssi < 0)
|
|
|
|
survey->filled |= SURVEY_INFO_NOISE_DBM;
|
|
|
|
|
|
|
|
if (survey->channel == wcn->channel)
|
|
|
|
survey->filled |= SURVEY_INFO_IN_USE;
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&wcn->survey_lock, flags);
|
|
|
|
|
2022-02-01 12:15:48 +08:00
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC,
|
|
|
|
"ch %d rssi %d snr %d noise %d filled %x freq %d\n",
|
|
|
|
HW_VALUE_CHANNEL(survey->channel->hw_value),
|
|
|
|
chan_survey->rssi, chan_survey->snr, survey->noise,
|
|
|
|
survey->filled, survey->channel->center_freq);
|
2022-01-15 00:16:46 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-03-25 17:42:12 -05:00
|
|
|
static void wcn36xx_sta_statistics(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
|
|
|
struct ieee80211_sta *sta, struct station_info *sinfo)
|
|
|
|
{
|
|
|
|
struct wcn36xx *wcn;
|
|
|
|
u8 sta_index;
|
|
|
|
int status;
|
|
|
|
|
|
|
|
wcn = hw->priv;
|
|
|
|
sta_index = get_sta_index(vif, wcn36xx_sta_to_priv(sta));
|
|
|
|
status = wcn36xx_smd_get_stats(wcn, sta_index, HAL_GLOBAL_CLASS_A_STATS_INFO, sinfo);
|
|
|
|
|
|
|
|
if (status)
|
|
|
|
wcn36xx_err("wcn36xx_smd_get_stats failed\n");
|
|
|
|
}
|
|
|
|
|
2013-10-08 21:25:58 +01:00
|
|
|
static const struct ieee80211_ops wcn36xx_ops = {
|
2024-01-29 19:34:38 +01:00
|
|
|
.add_chanctx = ieee80211_emulate_add_chanctx,
|
|
|
|
.remove_chanctx = ieee80211_emulate_remove_chanctx,
|
|
|
|
.change_chanctx = ieee80211_emulate_change_chanctx,
|
|
|
|
.switch_vif_chanctx = ieee80211_emulate_switch_vif_chanctx,
|
2013-10-08 21:25:58 +01:00
|
|
|
.start = wcn36xx_start,
|
|
|
|
.stop = wcn36xx_stop,
|
|
|
|
.add_interface = wcn36xx_add_interface,
|
|
|
|
.remove_interface = wcn36xx_remove_interface,
|
|
|
|
#ifdef CONFIG_PM
|
|
|
|
.suspend = wcn36xx_suspend,
|
|
|
|
.resume = wcn36xx_resume,
|
2021-06-05 02:11:35 +01:00
|
|
|
.set_rekey_data = wcn36xx_set_rekey_data,
|
2013-10-08 21:25:58 +01:00
|
|
|
#endif
|
|
|
|
.config = wcn36xx_config,
|
2016-04-18 22:00:52 -07:00
|
|
|
.prepare_multicast = wcn36xx_prepare_multicast,
|
2013-10-08 21:25:58 +01:00
|
|
|
.configure_filter = wcn36xx_configure_filter,
|
|
|
|
.tx = wcn36xx_tx,
|
2022-10-09 18:30:39 +02:00
|
|
|
.wake_tx_queue = ieee80211_handle_wake_tx_queue,
|
2013-10-08 21:25:58 +01:00
|
|
|
.set_key = wcn36xx_set_key,
|
2017-01-11 16:32:19 +02:00
|
|
|
.hw_scan = wcn36xx_hw_scan,
|
2017-02-01 07:27:47 -08:00
|
|
|
.cancel_hw_scan = wcn36xx_cancel_hw_scan,
|
2020-08-24 18:53:55 +02:00
|
|
|
.sw_scan_start = wcn36xx_sw_scan_start,
|
|
|
|
.sw_scan_complete = wcn36xx_sw_scan_complete,
|
2013-10-08 21:25:58 +01:00
|
|
|
.bss_info_changed = wcn36xx_bss_info_changed,
|
|
|
|
.set_rts_threshold = wcn36xx_set_rts_threshold,
|
|
|
|
.sta_add = wcn36xx_sta_add,
|
|
|
|
.sta_remove = wcn36xx_sta_remove,
|
2022-03-25 17:42:12 -05:00
|
|
|
.sta_statistics = wcn36xx_sta_statistics,
|
2013-10-08 21:25:58 +01:00
|
|
|
.ampdu_action = wcn36xx_ampdu_action,
|
2021-06-05 02:11:33 +01:00
|
|
|
#if IS_ENABLED(CONFIG_IPV6)
|
|
|
|
.ipv6_addr_change = wcn36xx_ipv6_addr_change,
|
|
|
|
#endif
|
2021-10-27 10:03:04 -07:00
|
|
|
.flush = wcn36xx_flush,
|
2022-01-15 00:16:46 +00:00
|
|
|
.get_survey = wcn36xx_get_survey,
|
2018-05-22 22:02:56 +03:00
|
|
|
|
|
|
|
CFG80211_TESTMODE_CMD(wcn36xx_tm_cmd)
|
2013-10-08 21:25:58 +01:00
|
|
|
};
|
|
|
|
|
2020-09-21 16:21:21 +03:00
|
|
|
static void
|
|
|
|
wcn36xx_set_ieee80211_vht_caps(struct ieee80211_sta_vht_cap *vht_cap)
|
|
|
|
{
|
|
|
|
vht_cap->vht_supported = true;
|
|
|
|
|
|
|
|
vht_cap->cap = (IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895 |
|
|
|
|
IEEE80211_VHT_CAP_SHORT_GI_80 |
|
|
|
|
IEEE80211_VHT_CAP_RXSTBC_1 |
|
|
|
|
IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE |
|
|
|
|
IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE |
|
|
|
|
3 << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT |
|
|
|
|
7 << IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT);
|
|
|
|
|
|
|
|
vht_cap->vht_mcs.rx_mcs_map =
|
|
|
|
cpu_to_le16(IEEE80211_VHT_MCS_SUPPORT_0_9 |
|
|
|
|
IEEE80211_VHT_MCS_NOT_SUPPORTED << 2 |
|
|
|
|
IEEE80211_VHT_MCS_NOT_SUPPORTED << 4 |
|
|
|
|
IEEE80211_VHT_MCS_NOT_SUPPORTED << 6 |
|
|
|
|
IEEE80211_VHT_MCS_NOT_SUPPORTED << 8 |
|
|
|
|
IEEE80211_VHT_MCS_NOT_SUPPORTED << 10 |
|
|
|
|
IEEE80211_VHT_MCS_NOT_SUPPORTED << 12 |
|
|
|
|
IEEE80211_VHT_MCS_NOT_SUPPORTED << 14);
|
|
|
|
|
|
|
|
vht_cap->vht_mcs.rx_highest = cpu_to_le16(433);
|
|
|
|
vht_cap->vht_mcs.tx_highest = vht_cap->vht_mcs.rx_highest;
|
|
|
|
|
|
|
|
vht_cap->vht_mcs.tx_mcs_map = vht_cap->vht_mcs.rx_mcs_map;
|
|
|
|
}
|
|
|
|
|
2013-10-08 21:25:58 +01:00
|
|
|
static int wcn36xx_init_ieee80211(struct wcn36xx *wcn)
|
|
|
|
{
|
|
|
|
static const u32 cipher_suites[] = {
|
|
|
|
WLAN_CIPHER_SUITE_WEP40,
|
|
|
|
WLAN_CIPHER_SUITE_WEP104,
|
|
|
|
WLAN_CIPHER_SUITE_TKIP,
|
|
|
|
WLAN_CIPHER_SUITE_CCMP,
|
|
|
|
};
|
|
|
|
|
2015-06-02 21:39:54 +02:00
|
|
|
ieee80211_hw_set(wcn->hw, TIMING_BEACON_ONLY);
|
|
|
|
ieee80211_hw_set(wcn->hw, AMPDU_AGGREGATION);
|
|
|
|
ieee80211_hw_set(wcn->hw, SUPPORTS_PS);
|
|
|
|
ieee80211_hw_set(wcn->hw, SIGNAL_DBM);
|
|
|
|
ieee80211_hw_set(wcn->hw, HAS_RATE_CONTROL);
|
2017-01-11 16:32:19 +02:00
|
|
|
ieee80211_hw_set(wcn->hw, SINGLE_SCAN_ON_ALL_BANDS);
|
2020-07-24 12:20:48 +02:00
|
|
|
ieee80211_hw_set(wcn->hw, REPORTS_TX_ACK_STATUS);
|
2013-10-08 21:25:58 +01:00
|
|
|
|
|
|
|
wcn->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
|
|
|
|
BIT(NL80211_IFTYPE_AP) |
|
|
|
|
BIT(NL80211_IFTYPE_ADHOC) |
|
|
|
|
BIT(NL80211_IFTYPE_MESH_POINT);
|
|
|
|
|
2016-04-12 15:56:15 +02:00
|
|
|
wcn->hw->wiphy->bands[NL80211_BAND_2GHZ] = &wcn_band_2ghz;
|
2017-09-19 14:33:23 +02:00
|
|
|
if (wcn->rf_id != RF_IRIS_WCN3620)
|
|
|
|
wcn->hw->wiphy->bands[NL80211_BAND_5GHZ] = &wcn_band_5ghz;
|
2013-10-08 21:25:58 +01:00
|
|
|
|
2020-09-21 16:21:21 +03:00
|
|
|
if (wcn->rf_id == RF_IRIS_WCN3680)
|
|
|
|
wcn36xx_set_ieee80211_vht_caps(&wcn_band_5ghz.vht_cap);
|
|
|
|
|
2017-01-11 16:32:19 +02:00
|
|
|
wcn->hw->wiphy->max_scan_ssids = WCN36XX_MAX_SCAN_SSIDS;
|
|
|
|
wcn->hw->wiphy->max_scan_ie_len = WCN36XX_MAX_SCAN_IE_LEN;
|
|
|
|
|
2013-10-08 21:25:58 +01:00
|
|
|
wcn->hw->wiphy->cipher_suites = cipher_suites;
|
|
|
|
wcn->hw->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites);
|
|
|
|
|
|
|
|
#ifdef CONFIG_PM
|
|
|
|
wcn->hw->wiphy->wowlan = &wowlan_support;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
wcn->hw->max_listen_interval = 200;
|
|
|
|
|
|
|
|
wcn->hw->queues = 4;
|
|
|
|
|
|
|
|
SET_IEEE80211_DEV(wcn->hw, wcn->dev);
|
|
|
|
|
|
|
|
wcn->hw->sta_data_size = sizeof(struct wcn36xx_sta);
|
|
|
|
wcn->hw->vif_data_size = sizeof(struct wcn36xx_vif);
|
|
|
|
|
2017-02-10 04:50:23 +01:00
|
|
|
wiphy_ext_feature_set(wcn->hw->wiphy,
|
|
|
|
NL80211_EXT_FEATURE_CQM_RSSI_LIST);
|
|
|
|
|
2018-06-29 14:37:45 +02:00
|
|
|
return 0;
|
2013-10-08 21:25:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int wcn36xx_platform_get_resources(struct wcn36xx *wcn,
|
|
|
|
struct platform_device *pdev)
|
|
|
|
{
|
2016-06-19 23:19:45 -07:00
|
|
|
struct device_node *mmio_node;
|
2017-09-19 14:33:23 +02:00
|
|
|
struct device_node *iris_node;
|
2016-06-19 23:19:45 -07:00
|
|
|
int index;
|
|
|
|
int ret;
|
|
|
|
|
2013-10-08 21:25:58 +01:00
|
|
|
/* Set TX IRQ */
|
2021-12-24 19:26:24 +00:00
|
|
|
ret = platform_get_irq_byname(pdev, "tx");
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
wcn->tx_irq = ret;
|
2013-10-08 21:25:58 +01:00
|
|
|
|
|
|
|
/* Set RX IRQ */
|
2021-12-24 19:26:24 +00:00
|
|
|
ret = platform_get_irq_byname(pdev, "rx");
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
wcn->rx_irq = ret;
|
2013-10-08 21:25:58 +01:00
|
|
|
|
2017-01-11 16:32:18 +02:00
|
|
|
/* Acquire SMSM tx enable handle */
|
|
|
|
wcn->tx_enable_state = qcom_smem_state_get(&pdev->dev,
|
|
|
|
"tx-enable", &wcn->tx_enable_state_bit);
|
|
|
|
if (IS_ERR(wcn->tx_enable_state)) {
|
|
|
|
wcn36xx_err("failed to get tx-enable state\n");
|
|
|
|
return PTR_ERR(wcn->tx_enable_state);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Acquire SMSM tx rings empty handle */
|
|
|
|
wcn->tx_rings_empty_state = qcom_smem_state_get(&pdev->dev,
|
|
|
|
"tx-rings-empty", &wcn->tx_rings_empty_state_bit);
|
|
|
|
if (IS_ERR(wcn->tx_rings_empty_state)) {
|
|
|
|
wcn36xx_err("failed to get tx-rings-empty state\n");
|
|
|
|
return PTR_ERR(wcn->tx_rings_empty_state);
|
|
|
|
}
|
|
|
|
|
2016-06-19 23:19:45 -07:00
|
|
|
mmio_node = of_parse_phandle(pdev->dev.parent->of_node, "qcom,mmio", 0);
|
|
|
|
if (!mmio_node) {
|
|
|
|
wcn36xx_err("failed to acquire qcom,mmio reference\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2016-06-19 23:19:46 -07:00
|
|
|
wcn->is_pronto = !!of_device_is_compatible(mmio_node, "qcom,pronto");
|
2023-03-11 20:36:47 +05:30
|
|
|
wcn->is_pronto_v3 = !!of_device_is_compatible(mmio_node, "qcom,pronto-v3-pil");
|
2016-06-19 23:19:46 -07:00
|
|
|
|
2016-06-19 23:19:45 -07:00
|
|
|
/* Map the CCU memory */
|
|
|
|
index = of_property_match_string(mmio_node, "reg-names", "ccu");
|
|
|
|
wcn->ccu_base = of_iomap(mmio_node, index);
|
|
|
|
if (!wcn->ccu_base) {
|
|
|
|
wcn36xx_err("failed to map ccu memory\n");
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto put_mmio_node;
|
2013-10-08 21:25:58 +01:00
|
|
|
}
|
2016-06-19 23:19:45 -07:00
|
|
|
|
|
|
|
/* Map the DXE memory */
|
|
|
|
index = of_property_match_string(mmio_node, "reg-names", "dxe");
|
|
|
|
wcn->dxe_base = of_iomap(mmio_node, index);
|
|
|
|
if (!wcn->dxe_base) {
|
|
|
|
wcn36xx_err("failed to map dxe memory\n");
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto unmap_ccu;
|
2013-10-08 21:25:58 +01:00
|
|
|
}
|
2016-06-19 23:19:45 -07:00
|
|
|
|
2017-09-19 14:33:23 +02:00
|
|
|
/* External RF module */
|
2017-11-11 18:05:32 +01:00
|
|
|
iris_node = of_get_child_by_name(mmio_node, "iris");
|
2017-09-19 14:33:23 +02:00
|
|
|
if (iris_node) {
|
|
|
|
if (of_device_is_compatible(iris_node, "qcom,wcn3620"))
|
|
|
|
wcn->rf_id = RF_IRIS_WCN3620;
|
2022-01-25 00:40:46 +00:00
|
|
|
if (of_device_is_compatible(iris_node, "qcom,wcn3660") ||
|
|
|
|
of_device_is_compatible(iris_node, "qcom,wcn3660b"))
|
|
|
|
wcn->rf_id = RF_IRIS_WCN3660;
|
2020-08-29 04:38:38 +01:00
|
|
|
if (of_device_is_compatible(iris_node, "qcom,wcn3680"))
|
|
|
|
wcn->rf_id = RF_IRIS_WCN3680;
|
2017-09-19 14:33:23 +02:00
|
|
|
of_node_put(iris_node);
|
|
|
|
}
|
|
|
|
|
2016-06-19 23:19:45 -07:00
|
|
|
of_node_put(mmio_node);
|
2013-10-08 21:25:58 +01:00
|
|
|
return 0;
|
2016-06-19 23:19:45 -07:00
|
|
|
|
|
|
|
unmap_ccu:
|
|
|
|
iounmap(wcn->ccu_base);
|
|
|
|
put_mmio_node:
|
|
|
|
of_node_put(mmio_node);
|
|
|
|
return ret;
|
2013-10-08 21:25:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int wcn36xx_probe(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
struct ieee80211_hw *hw;
|
|
|
|
struct wcn36xx *wcn;
|
2017-01-11 16:32:18 +02:00
|
|
|
void *wcnss;
|
2013-10-08 21:25:58 +01:00
|
|
|
int ret;
|
2017-01-11 16:32:18 +02:00
|
|
|
const u8 *addr;
|
2022-01-15 00:16:45 +00:00
|
|
|
int n_channels;
|
2013-10-08 21:25:58 +01:00
|
|
|
|
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC, "platform probe\n");
|
|
|
|
|
2017-01-11 16:32:18 +02:00
|
|
|
wcnss = dev_get_drvdata(pdev->dev.parent);
|
|
|
|
|
2013-10-08 21:25:58 +01:00
|
|
|
hw = ieee80211_alloc_hw(sizeof(struct wcn36xx), &wcn36xx_ops);
|
|
|
|
if (!hw) {
|
|
|
|
wcn36xx_err("failed to alloc hw\n");
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto out_err;
|
|
|
|
}
|
|
|
|
platform_set_drvdata(pdev, hw);
|
|
|
|
wcn = hw->priv;
|
|
|
|
wcn->hw = hw;
|
|
|
|
wcn->dev = &pdev->dev;
|
2018-03-14 12:14:11 +02:00
|
|
|
wcn->first_boot = true;
|
2017-08-02 18:28:00 -07:00
|
|
|
mutex_init(&wcn->conf_mutex);
|
2013-10-08 21:25:58 +01:00
|
|
|
mutex_init(&wcn->hal_mutex);
|
2017-01-11 16:32:19 +02:00
|
|
|
mutex_init(&wcn->scan_lock);
|
2021-10-25 16:26:10 +03:00
|
|
|
__skb_queue_head_init(&wcn->amsdu);
|
2017-01-11 16:32:19 +02:00
|
|
|
|
2021-06-05 18:33:47 +01:00
|
|
|
wcn->hal_buf = devm_kmalloc(wcn->dev, WCN36XX_HAL_BUF_SIZE, GFP_KERNEL);
|
|
|
|
if (!wcn->hal_buf) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto out_wq;
|
|
|
|
}
|
|
|
|
|
2022-01-15 00:16:45 +00:00
|
|
|
n_channels = wcn_band_2ghz.n_channels + wcn_band_5ghz.n_channels;
|
2024-11-04 21:00:35 +01:00
|
|
|
wcn->chan_survey = devm_kcalloc(wcn->dev,
|
|
|
|
n_channels,
|
|
|
|
sizeof(struct wcn36xx_chan_survey),
|
|
|
|
GFP_KERNEL);
|
2022-01-15 00:16:45 +00:00
|
|
|
if (!wcn->chan_survey) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto out_wq;
|
|
|
|
}
|
|
|
|
|
2018-05-23 11:14:26 +03:00
|
|
|
ret = dma_set_mask_and_coherent(wcn->dev, DMA_BIT_MASK(32));
|
|
|
|
if (ret < 0) {
|
|
|
|
wcn36xx_err("failed to set DMA mask: %d\n", ret);
|
|
|
|
goto out_wq;
|
|
|
|
}
|
|
|
|
|
2021-08-24 10:12:25 -07:00
|
|
|
wcn->nv_file = WLAN_NV_FILE;
|
|
|
|
ret = of_property_read_string(wcn->dev->parent->of_node, "firmware-name", &wcn->nv_file);
|
|
|
|
if (ret < 0 && ret != -EINVAL) {
|
|
|
|
wcn36xx_err("failed to read \"firmware-name\" property: %d\n", ret);
|
|
|
|
goto out_wq;
|
|
|
|
}
|
|
|
|
|
2017-03-27 22:26:33 -07:00
|
|
|
wcn->smd_channel = qcom_wcnss_open_channel(wcnss, "WLAN_CTRL", wcn36xx_smd_rsp_process, hw);
|
2017-01-11 16:32:18 +02:00
|
|
|
if (IS_ERR(wcn->smd_channel)) {
|
|
|
|
wcn36xx_err("failed to open WLAN_CTRL channel\n");
|
|
|
|
ret = PTR_ERR(wcn->smd_channel);
|
|
|
|
goto out_wq;
|
|
|
|
}
|
|
|
|
|
|
|
|
addr = of_get_property(pdev->dev.of_node, "local-mac-address", &ret);
|
|
|
|
if (addr && ret != ETH_ALEN) {
|
|
|
|
wcn36xx_err("invalid local-mac-address\n");
|
|
|
|
ret = -EINVAL;
|
2020-05-08 05:56:03 +03:00
|
|
|
goto out_destroy_ept;
|
2017-01-11 16:32:18 +02:00
|
|
|
} else if (addr) {
|
2013-10-08 21:25:58 +01:00
|
|
|
wcn36xx_info("mac address: %pM\n", addr);
|
|
|
|
SET_IEEE80211_PERM_ADDR(wcn->hw, addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = wcn36xx_platform_get_resources(wcn, pdev);
|
|
|
|
if (ret)
|
2020-05-08 05:56:03 +03:00
|
|
|
goto out_destroy_ept;
|
2013-10-08 21:25:58 +01:00
|
|
|
|
|
|
|
wcn36xx_init_ieee80211(wcn);
|
|
|
|
ret = ieee80211_register_hw(wcn->hw);
|
|
|
|
if (ret)
|
|
|
|
goto out_unmap;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
out_unmap:
|
2016-06-19 23:19:45 -07:00
|
|
|
iounmap(wcn->ccu_base);
|
|
|
|
iounmap(wcn->dxe_base);
|
2020-05-08 05:56:03 +03:00
|
|
|
out_destroy_ept:
|
|
|
|
rpmsg_destroy_ept(wcn->smd_channel);
|
2013-10-08 21:25:58 +01:00
|
|
|
out_wq:
|
|
|
|
ieee80211_free_hw(hw);
|
|
|
|
out_err:
|
|
|
|
return ret;
|
|
|
|
}
|
2017-01-11 16:32:18 +02:00
|
|
|
|
2023-11-17 10:31:01 +01:00
|
|
|
static void wcn36xx_remove(struct platform_device *pdev)
|
2013-10-08 21:25:58 +01:00
|
|
|
{
|
|
|
|
struct ieee80211_hw *hw = platform_get_drvdata(pdev);
|
|
|
|
struct wcn36xx *wcn = hw->priv;
|
|
|
|
wcn36xx_dbg(WCN36XX_DBG_MAC, "platform remove\n");
|
|
|
|
|
2014-02-12 19:04:43 +00:00
|
|
|
release_firmware(wcn->nv);
|
2013-10-08 21:25:58 +01:00
|
|
|
|
|
|
|
ieee80211_unregister_hw(hw);
|
2017-01-11 16:32:18 +02:00
|
|
|
|
|
|
|
qcom_smem_state_put(wcn->tx_enable_state);
|
|
|
|
qcom_smem_state_put(wcn->tx_rings_empty_state);
|
|
|
|
|
2017-05-08 21:36:37 -07:00
|
|
|
rpmsg_destroy_ept(wcn->smd_channel);
|
|
|
|
|
2016-06-19 23:19:45 -07:00
|
|
|
iounmap(wcn->dxe_base);
|
|
|
|
iounmap(wcn->ccu_base);
|
2017-01-11 16:32:21 +02:00
|
|
|
|
2021-10-25 16:26:10 +03:00
|
|
|
__skb_queue_purge(&wcn->amsdu);
|
|
|
|
|
2017-01-11 16:32:21 +02:00
|
|
|
mutex_destroy(&wcn->hal_mutex);
|
2013-10-08 21:25:58 +01:00
|
|
|
ieee80211_free_hw(hw);
|
|
|
|
}
|
2017-01-11 16:32:18 +02:00
|
|
|
|
|
|
|
static const struct of_device_id wcn36xx_of_match[] = {
|
|
|
|
{ .compatible = "qcom,wcnss-wlan" },
|
2013-10-08 21:25:58 +01:00
|
|
|
{}
|
|
|
|
};
|
2017-01-11 16:32:18 +02:00
|
|
|
MODULE_DEVICE_TABLE(of, wcn36xx_of_match);
|
2013-10-08 21:25:58 +01:00
|
|
|
|
|
|
|
static struct platform_driver wcn36xx_driver = {
|
2024-11-06 18:07:06 +01:00
|
|
|
.probe = wcn36xx_probe,
|
|
|
|
.remove = wcn36xx_remove,
|
|
|
|
.driver = {
|
|
|
|
.name = "wcn36xx",
|
2017-01-11 16:32:18 +02:00
|
|
|
.of_match_table = wcn36xx_of_match,
|
2013-10-08 21:25:58 +01:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2017-01-11 16:32:18 +02:00
|
|
|
module_platform_driver(wcn36xx_driver);
|
2013-10-08 21:25:58 +01:00
|
|
|
|
2024-01-30 02:42:39 -08:00
|
|
|
MODULE_DESCRIPTION("Qualcomm Atheros WCN3660/3680 wireless driver");
|
2013-10-08 21:25:58 +01:00
|
|
|
MODULE_LICENSE("Dual BSD/GPL");
|
|
|
|
MODULE_AUTHOR("Eugene Krasnikov k.eugene.e@gmail.com");
|
|
|
|
MODULE_FIRMWARE(WLAN_NV_FILE);
|