2024-01-11 04:51:33

by Sriram R

[permalink] [raw]
Subject: [PATCH 00/12] wifi: ath12k: Add single wiphy support

With the introduction of Multi Link Operation (MLO) support in
IEEE802.11be, each EHT AP/non AP interface is capable of
operating with multiple radio links.

cfg80211/mac80211 expects drivers to abstract the communication
between such Multi Link HW and mac80211/cfg80211 since it depends
on different driver/HW implementation. Hence the single wiphy
abstraction with changes in datastructures were introduced in
"wifi: ath12k: Introduce hw abstraction"

This patchset extends the implementation to allow combination
of multiple underlying radios into a single composite hw/wiphy
for registration. Since now multiple radios are represented by
a single wiphy, changes are required in various mac ops that the
driver supports since the driver now needs to learn on how to tunnel
various mac ops properly to a specific radio.

This patchset covers the basic mac80211 ops for an interface bringup
and operation.

Note:
In addition to sanity on single radio QCN9274 and WCN7850
the single wiphy changes are tested over "wifi: ath12k: QCN9274 dualmac bring up"
where multiple radios in the dualmac SoC are combined and tested.

Monitor and hw reconfig support for Single Wiphy will be done in future
patchsets.

This patchset is dependent on "[PATCH 0/2] wifi: ath12k: Introduce hw abstraction"

Karthikeyan Periyasamy (1):
wifi: ath12k: add multiple radio support in a single MAC HW
un/register

Sriram R (11):
wifi: ath12k: Modify add and remove chanctx ops for single wiphy
support
wifi: ath12k: modify ath12k mac start/stop ops for single wiphy
wifi: ath12k: vdev statemachine changes for single wiphy
wifi: ath12k: scan statemachine changes for single wiphy
wifi: ath12k: fetch correct radio based on vdev status
wifi: ath12k: Cache vdev configs before vdev create
wifi: ath12k: Add additional checks for vif and sta iterators
wifi: ath12k: modify regulatory support for single wiphy architecture
wifi: ath12k: Modify set and get antenna mac ops for single wiphy
wifi: ath12k: Modify rts threshold mac op for single wiphy
wifi: ath12k: support get_survey mac op for single wiphy

drivers/net/wireless/ath/ath12k/core.h | 40 +-
drivers/net/wireless/ath/ath12k/hw.h | 3 +-
drivers/net/wireless/ath/ath12k/mac.c | 1014 +++++++++++++++++++-----
drivers/net/wireless/ath/ath12k/reg.c | 62 +-
4 files changed, 886 insertions(+), 233 deletions(-)

--
2.17.1



2024-01-11 04:51:39

by Sriram R

[permalink] [raw]
Subject: [PATCH 01/12] wifi: ath12k: add multiple radio support in a single MAC HW un/register

From: Karthikeyan Periyasamy <[email protected]>

Currently MAC HW un/register helper function support the single radio.
To enable single/multi link operation in the future, the following helper
functions need to be refactored to accommodate multiple radios under a
single MAC HW un/register:

* ath12k_ah_to_ar()
* ath12k_mac_hw_allocate()
* ath12k_mac_hw_register()
* ath12k_mac_hw_unregister()

This refactoring will make it easier to scale these functionalities and
support Multi link operation.

Current Multi wiphy Model

+---------------+ +---------------+ +---------------+
| Mac80211 hw | | Mac80211 hw | | Mac80211 hw |
| private data | | private data | | private data |
| | | | | |
|ath12k_hw (ah) | |ath12k_hw (ah) | |ath12k_hw (ah) |
| | | | | |
| +-----------+ | | +-----------+ | | +-----------+ |
| | ar (2GHz) | | | | ar (5GHz) | | | | ar (6GHz) | |
| +-----------+ | | +-----------+ | | +-----------+ |
| | | | | |
+---------------+ +---------------+ +---------------+

Single wiphy Model

+--------------+
| Mac80211 hw |
| private data |
| |
|ath12k hw (ah)|
| +----------+ |
| |ar (2GHz) | |
| +----------+ |
| |ar (5GHz) | |
| +----------+ |
| |ar (6GHz) | |
| +----------+ |
+--------------+

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3

Signed-off-by: Karthikeyan Periyasamy <[email protected]>
---
drivers/net/wireless/ath/ath12k/core.h | 14 +-
drivers/net/wireless/ath/ath12k/mac.c | 182 ++++++++++++++++---------
drivers/net/wireless/ath/ath12k/reg.c | 2 +-
3 files changed, 129 insertions(+), 69 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h
index e0f04d77677f..5bce55799d98 100644
--- a/drivers/net/wireless/ath/ath12k/core.h
+++ b/drivers/net/wireless/ath/ath12k/core.h
@@ -930,13 +930,23 @@ static inline struct ath12k_hw *ath12k_hw_to_ah(struct ieee80211_hw *hw)
return hw->priv;
}

-static inline struct ath12k *ath12k_ah_to_ar(struct ath12k_hw *ah)
+static inline struct ath12k *ath12k_ah_to_ar(struct ath12k_hw *ah,
+ u8 hw_link_id)
{
- return ah->radio;
+ if (WARN(hw_link_id >= ah->num_radio,
+ "bad hw link id %d, so switch to default link\n", hw_link_id))
+ hw_link_id = 0;
+
+ return &ah->radio[hw_link_id];
}

static inline struct ieee80211_hw *ath12k_ar_to_hw(struct ath12k *ar)
{
return ar->ah->hw;
}
+
+#define for_each_ar(index, ah, ar) \
+ for ((index) = 0, (ar) = (ah)->radio; (index) < (ah)->num_radio; \
+ (index)++, (ar)++)
+
#endif /* _CORE_H_ */
diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index aa1cedbf9410..fbb2d195d778 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -1130,7 +1130,7 @@ static int ath12k_mac_op_config(struct ieee80211_hw *hw, u32 changed)

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah);
+ ar = ath12k_ah_to_ar(ah, 0);

ret = ath12k_mac_config(ar, changed);
if (ret)
@@ -2804,7 +2804,7 @@ static void ath12k_mac_op_bss_info_changed(struct ieee80211_hw *hw,

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah);
+ ar = ath12k_ah_to_ar(ah, 0);

mutex_lock(&ar->conf_mutex);

@@ -2993,7 +2993,7 @@ static int ath12k_mac_op_hw_scan(struct ieee80211_hw *hw,

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah);
+ ar = ath12k_ah_to_ar(ah, 0);

mutex_lock(&ar->conf_mutex);

@@ -3087,7 +3087,7 @@ static void ath12k_mac_op_cancel_hw_scan(struct ieee80211_hw *hw,

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah);
+ ar = ath12k_ah_to_ar(ah, 0);

mutex_lock(&ar->conf_mutex);
ath12k_scan_abort(ar);
@@ -3236,7 +3236,7 @@ static int ath12k_mac_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah);
+ ar = ath12k_ah_to_ar(ah, 0);
ab = ar->ab;

if (test_bit(ATH12K_FLAG_HW_CRYPTO_DISABLED, &ar->ab->dev_flags)) {
@@ -3833,7 +3833,7 @@ static int ath12k_mac_op_sta_state(struct ieee80211_hw *hw,

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah);
+ ar = ath12k_ah_to_ar(ah, 0);

mutex_lock(&ar->conf_mutex);

@@ -3959,7 +3959,7 @@ static int ath12k_mac_op_sta_set_txpwr(struct ieee80211_hw *hw,

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah);
+ ar = ath12k_ah_to_ar(ah, 0);

mutex_lock(&ar->conf_mutex);

@@ -3989,7 +3989,7 @@ static void ath12k_mac_op_sta_rc_update(struct ieee80211_hw *hw,
struct ath12k_peer *peer;
u32 bw, smps;

- ar = ath12k_ah_to_ar(ah);
+ ar = ath12k_ah_to_ar(ah, 0);

spin_lock_bh(&ar->ab->base_lock);

@@ -4172,7 +4172,7 @@ static int ath12k_mac_op_conf_tx(struct ieee80211_hw *hw,

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah);
+ ar = ath12k_ah_to_ar(ah, 0);

mutex_lock(&ar->conf_mutex);
ret = ath12k_mac_conf_tx(arvif, link_id, ac, params);
@@ -5275,7 +5275,7 @@ static int ath12k_mac_start(struct ath12k *ar)
static int ath12k_mac_op_start(struct ieee80211_hw *hw)
{
struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
- struct ath12k *ar = ath12k_ah_to_ar(ah);
+ struct ath12k *ar = ath12k_ah_to_ar(ah, 0);
struct ath12k_base *ab = ar->ab;
int ret;

@@ -5389,7 +5389,7 @@ static void ath12k_mac_stop(struct ath12k *ar)
static void ath12k_mac_op_stop(struct ieee80211_hw *hw)
{
struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
- struct ath12k *ar = ath12k_ah_to_ar(ah);
+ struct ath12k *ar = ath12k_ah_to_ar(ah, 0);

ath12k_mac_drain_tx(ar);

@@ -5589,7 +5589,7 @@ static int ath12k_mac_op_add_interface(struct ieee80211_hw *hw,

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah);
+ ar = ath12k_ah_to_ar(ah, 0);
ab = ar->ab;

mutex_lock(&ar->conf_mutex);
@@ -5849,7 +5849,7 @@ static void ath12k_mac_op_remove_interface(struct ieee80211_hw *hw,

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah);
+ ar = ath12k_ah_to_ar(ah, 0);
ab = ar->ab;

mutex_lock(&ar->conf_mutex);
@@ -5967,7 +5967,7 @@ static void ath12k_mac_op_configure_filter(struct ieee80211_hw *hw,

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah);
+ ar = ath12k_ah_to_ar(ah, 0);

mutex_lock(&ar->conf_mutex);

@@ -5986,7 +5986,7 @@ static int ath12k_mac_op_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah);
+ ar = ath12k_ah_to_ar(ah, 0);

mutex_lock(&ar->conf_mutex);

@@ -6008,7 +6008,7 @@ static int ath12k_mac_op_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah);
+ ar = ath12k_ah_to_ar(ah, 0);

mutex_lock(&ar->conf_mutex);
ret = __ath12k_set_antenna(ar, tx_ant, rx_ant);
@@ -6060,7 +6060,7 @@ static int ath12k_mac_op_ampdu_action(struct ieee80211_hw *hw,

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah);
+ ar = ath12k_ah_to_ar(ah, 0);

mutex_lock(&ar->conf_mutex);
ret = ath12k_mac_ampdu_action(arvif, params);
@@ -6084,7 +6084,7 @@ static int ath12k_mac_op_add_chanctx(struct ieee80211_hw *hw,

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah);
+ ar = ath12k_ah_to_ar(ah, 0);
ab = ar->ab;

ath12k_dbg(ab, ATH12K_DBG_MAC,
@@ -6116,7 +6116,7 @@ static void ath12k_mac_op_remove_chanctx(struct ieee80211_hw *hw,

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah);
+ ar = ath12k_ah_to_ar(ah, 0);
ab = ar->ab;

ath12k_dbg(ab, ATH12K_DBG_MAC,
@@ -6533,7 +6533,7 @@ static void ath12k_mac_op_change_chanctx(struct ieee80211_hw *hw,

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah);
+ ar = ath12k_ah_to_ar(ah, 0);
ab = ar->ab;

mutex_lock(&ar->conf_mutex);
@@ -6606,7 +6606,7 @@ ath12k_mac_op_assign_vif_chanctx(struct ieee80211_hw *hw,

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah);
+ ar = ath12k_ah_to_ar(ah, 0);
ab = ar->ab;

mutex_lock(&ar->conf_mutex);
@@ -6691,7 +6691,7 @@ ath12k_mac_op_unassign_vif_chanctx(struct ieee80211_hw *hw,

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah);
+ ar = ath12k_ah_to_ar(ah, 0);
ab = ar->ab;

mutex_lock(&ar->conf_mutex);
@@ -6748,7 +6748,7 @@ ath12k_mac_op_switch_vif_chanctx(struct ieee80211_hw *hw,

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah);
+ ar = ath12k_ah_to_ar(ah, 0);

mutex_lock(&ar->conf_mutex);

@@ -6798,7 +6798,7 @@ static int ath12k_mac_op_set_rts_threshold(struct ieee80211_hw *hw, u32 value)

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah);
+ ar = ath12k_ah_to_ar(ah, 0);

ret = ath12k_set_vdev_param_to_all_vifs(ar, param_id, value);

@@ -6844,7 +6844,7 @@ static void ath12k_mac_op_flush(struct ieee80211_hw *hw, struct ieee80211_vif *v
u32 queues, bool drop)
{
struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
- struct ath12k *ar = ath12k_ah_to_ar(ah);
+ struct ath12k *ar = ath12k_ah_to_ar(ah, 0);

if (drop)
return;
@@ -7218,7 +7218,7 @@ ath12k_mac_op_reconfig_complete(struct ieee80211_hw *hw,

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah);
+ ar = ath12k_ah_to_ar(ah, 0);
ab = ar->ab;

mutex_lock(&ar->conf_mutex);
@@ -7317,7 +7317,7 @@ static int ath12k_mac_op_get_survey(struct ieee80211_hw *hw, int idx,

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah);
+ ar = ath12k_ah_to_ar(ah, 0);

ar_survey = &ar->survey[idx];

@@ -7553,10 +7553,12 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar,

static u16 ath12k_mac_get_ifmodes(struct ath12k_hw *ah)
{
- struct ath12k *ar = ath12k_ah_to_ar(ah);
+ struct ath12k *ar;
+ int i;
u16 interface_modes = U16_MAX;

- interface_modes &= ar->ab->hw_params->interface_modes;
+ for_each_ar(i, ah, ar)
+ interface_modes &= ar->ab->hw_params->interface_modes;

return interface_modes == U16_MAX ? 0 : interface_modes;
}
@@ -7564,15 +7566,19 @@ static u16 ath12k_mac_get_ifmodes(struct ath12k_hw *ah)
static bool ath12k_mac_is_iface_mode_enable(struct ath12k_hw *ah,
enum nl80211_iftype type)
{
- struct ath12k *ar = ath12k_ah_to_ar(ah);
+ struct ath12k *ar;
+ int i;
u16 interface_modes, mode;
bool is_enable = true;

mode = BIT(type);
-
- interface_modes = ar->ab->hw_params->interface_modes;
- if (!(interface_modes & mode))
- is_enable = false;
+ for_each_ar(i, ah, ar) {
+ interface_modes = ar->ab->hw_params->interface_modes;
+ if (!(interface_modes & mode)) {
+ is_enable = false;
+ break;
+ }
+ }

return is_enable;
}
@@ -7687,13 +7693,16 @@ void ath12k_mac_hw_unregister(struct ath12k_hw *ah)
{
struct ieee80211_hw *hw = ah->hw;
struct wiphy *wiphy = hw->wiphy;
- struct ath12k *ar = ath12k_ah_to_ar(ah);
+ struct ath12k *ar;
+ int i;

- cancel_work_sync(&ar->regd_update_work);
+ for_each_ar(i, ah, ar)
+ cancel_work_sync(&ar->regd_update_work);

ieee80211_unregister_hw(hw);

- ath12k_mac_cleanup_unregister(ar);
+ for_each_ar(i, ah, ar)
+ ath12k_mac_cleanup_unregister(ar);

kfree(wiphy->iface_combinations[0].limits);
kfree(wiphy->iface_combinations);
@@ -7733,7 +7742,7 @@ int ath12k_mac_hw_register(struct ath12k_hw *ah)
{
struct ieee80211_hw *hw = ah->hw;
struct wiphy *wiphy = hw->wiphy;
- struct ath12k *ar = ath12k_ah_to_ar(ah);
+ struct ath12k *ar = ath12k_ah_to_ar(ah, 0);
struct ath12k_base *ab = ar->ab;
struct ath12k_pdev *pdev;
struct ath12k_pdev_cap *cap;
@@ -7748,39 +7757,72 @@ int ath12k_mac_hw_register(struct ath12k_hw *ah)
WLAN_CIPHER_SUITE_GCMP_256,
WLAN_CIPHER_SUITE_CCMP_256,
};
- int ret;
- u32 ht_cap = 0;
+ int ret, i, j;
+ u32 ht_cap = U32_MAX, antennas_rx = 0, antennas_tx = 0;
+ bool is_6ghz = false, is_raw_mode = false, is_monitor_disable = false;
+ u8 *mac_addr = NULL;

- pdev = ar->pdev;
+ wiphy->max_ap_assoc_sta = 0;

- if (ab->pdevs_macaddr_valid)
- ether_addr_copy(ar->mac_addr, pdev->mac_addr);
- else
- ether_addr_copy(ar->mac_addr, ab->mac_addr);
+ for_each_ar(i, ah, ar) {
+ u32 ht_cap_info = 0;

- ret = ath12k_mac_setup_register(ar, &ht_cap, hw->wiphy->bands);
- if (ret)
- goto out;
+ pdev = ar->pdev;
+
+ if (ab->pdevs_macaddr_valid) {
+ ether_addr_copy(ar->mac_addr, pdev->mac_addr);
+ } else {
+ ether_addr_copy(ar->mac_addr, ab->mac_addr);
+ ar->mac_addr[4] += i;
+ }
+
+ ret = ath12k_mac_setup_register(ar, &ht_cap_info, hw->wiphy->bands);
+ if (ret)
+ goto err_cleanup_unregister;

- wiphy->max_ap_assoc_sta = ar->max_num_stations;
+ ht_cap &= ht_cap_info;
+ wiphy->max_ap_assoc_sta += ar->max_num_stations;
+
+ /* Advertise the max antenna support of all radios, driver can handle
+ * per pdev specific antenna setting based on pdev cap when antenna
+ * changes are made
+ */
+ cap = &pdev->cap;

- cap = &pdev->cap;
+ antennas_rx = max_t(u32, antennas_rx, cap->rx_chain_mask);
+ antennas_tx = max_t(u32, antennas_tx, cap->tx_chain_mask);

- wiphy->available_antennas_rx = cap->rx_chain_mask;
- wiphy->available_antennas_tx = cap->tx_chain_mask;
+ if (ar->supports_6ghz)
+ is_6ghz = true;

- SET_IEEE80211_PERM_ADDR(hw, ar->mac_addr);
+ if (test_bit(ATH12K_FLAG_RAW_MODE, &ar->ab->dev_flags))
+ is_raw_mode = true;
+
+ if (!ar->ab->hw_params->supports_monitor)
+ is_monitor_disable = true;
+
+ if (i == 0)
+ mac_addr = ar->mac_addr;
+ else
+ mac_addr = ab->mac_addr;
+ }
+
+ wiphy->available_antennas_rx = antennas_rx;
+ wiphy->available_antennas_tx = antennas_tx;
+
+ SET_IEEE80211_PERM_ADDR(hw, mac_addr);
SET_IEEE80211_DEV(hw, ab->dev);

ret = ath12k_mac_setup_iface_combinations(ah);
if (ret) {
ath12k_err(ab, "failed to setup interface combinations: %d\n", ret);
- goto err_cleanup_unregister;
+ goto err_complete_cleanup_unregister;
}

wiphy->interface_modes = ath12k_mac_get_ifmodes(ah);

- if (wiphy->bands[NL80211_BAND_2GHZ] &&
+ if (ah->num_radio == 1 &&
+ wiphy->bands[NL80211_BAND_2GHZ] &&
wiphy->bands[NL80211_BAND_5GHZ] &&
wiphy->bands[NL80211_BAND_6GHZ])
ieee80211_hw_set(hw, SINGLE_SCAN_ON_ALL_BANDS);
@@ -7848,7 +7890,7 @@ int ath12k_mac_hw_register(struct ath12k_hw *ah)
wiphy->iftype_ext_capab = ath12k_iftypes_ext_capa;
wiphy->num_iftype_ext_capab = ARRAY_SIZE(ath12k_iftypes_ext_capa);

- if (ar->supports_6ghz) {
+ if (is_6ghz) {
wiphy_ext_feature_set(wiphy,
NL80211_EXT_FEATURE_FILS_DISCOVERY);
wiphy_ext_feature_set(wiphy,
@@ -7859,7 +7901,7 @@ int ath12k_mac_hw_register(struct ath12k_hw *ah)

ath12k_reg_init(hw);

- if (!test_bit(ATH12K_FLAG_RAW_MODE, &ab->dev_flags)) {
+ if (!is_raw_mode) {
hw->netdev_features = NETIF_F_HW_CSUM;
ieee80211_hw_set(hw, SW_CRYPTO_CONTROL);
ieee80211_hw_set(hw, SUPPORT_FAST_XMIT);
@@ -7871,7 +7913,7 @@ int ath12k_mac_hw_register(struct ath12k_hw *ah)
goto err_free_if_combs;
}

- if (!ab->hw_params->supports_monitor)
+ if (is_monitor_disable)
/* There's a race between calling ieee80211_register_hw()
* and here where the monitor mode is enabled for a little
* while. But that time is so short and in practise it make
@@ -7879,11 +7921,13 @@ int ath12k_mac_hw_register(struct ath12k_hw *ah)
*/
wiphy->interface_modes &= ~BIT(NL80211_IFTYPE_MONITOR);

- /* Apply the regd received during initialization */
- ret = ath12k_regd_update(ar, true);
- if (ret) {
- ath12k_err(ar->ab, "ath12k regd update failed: %d\n", ret);
- goto err_unregister_hw;
+ for_each_ar(i, ah, ar) {
+ /* Apply the regd received during initialization */
+ ret = ath12k_regd_update(ar, true);
+ if (ret) {
+ ath12k_err(ar->ab, "ath12k regd update failed: %d\n", ret);
+ goto err_unregister_hw;
+ }
}

return 0;
@@ -7895,10 +7939,16 @@ int ath12k_mac_hw_register(struct ath12k_hw *ah)
kfree(wiphy->iface_combinations[0].limits);
kfree(wiphy->iface_combinations);

+err_complete_cleanup_unregister:
+ i = ah->num_radio;
+
err_cleanup_unregister:
- ath12k_mac_cleanup_unregister(ar);
+ ar = ath12k_ah_to_ar(ah, 0);
+ for (j = 0; j < i; j++) {
+ ath12k_mac_cleanup_unregister(ar);
+ ar++;
+ }

-out:
SET_IEEE80211_DEV(hw, NULL);

return ret;
@@ -7971,7 +8021,7 @@ struct ath12k_hw *ath12k_mac_hw_allocate(struct ath12k_base *ab,
pdev_idx = pdev_map[i].pdev_idx;
pdev = &ab->pdevs[pdev_idx];

- ar = ath12k_ah_to_ar(ah);
+ ar = ath12k_ah_to_ar(ah, i);
ar->ah = ah;
ar->ab = ab;
ar->hw_link_id = i;
diff --git a/drivers/net/wireless/ath/ath12k/reg.c b/drivers/net/wireless/ath/ath12k/reg.c
index a164f15d1e2b..da64482f1024 100644
--- a/drivers/net/wireless/ath/ath12k/reg.c
+++ b/drivers/net/wireless/ath/ath12k/reg.c
@@ -49,7 +49,7 @@ ath12k_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request)
struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
struct ath12k_wmi_init_country_arg arg;
struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
- struct ath12k *ar = ath12k_ah_to_ar(ah);
+ struct ath12k *ar = ath12k_ah_to_ar(ah, 0);
int ret;

ath12k_dbg(ar->ab, ATH12K_DBG_REG,
--
2.17.1


2024-01-11 04:51:46

by Sriram R

[permalink] [raw]
Subject: [PATCH 02/12] wifi: ath12k: Modify add and remove chanctx ops for single wiphy support

Modify add and remove chanctx mac80211 ops to fetch the correct
radio(ar) based on channel context.

This change also introduces new helper function to fetch the
radio/ar based on channel context and ieee80211_chan which internally
uses the radio's low/high freq range.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3

Signed-off-by: Sriram R <[email protected]>
---
drivers/net/wireless/ath/ath12k/core.h | 3 ++
drivers/net/wireless/ath/ath12k/mac.c | 54 ++++++++++++++++++++++++--
2 files changed, 54 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h
index 5bce55799d98..69c926ba0e73 100644
--- a/drivers/net/wireless/ath/ath12k/core.h
+++ b/drivers/net/wireless/ath/ath12k/core.h
@@ -595,6 +595,9 @@ struct ath12k {
bool monitor_vdev_created;
bool monitor_started;
int monitor_vdev_id;
+
+ u32 freq_low;
+ u32 freq_high;
};

struct ath12k_hw {
diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index fbb2d195d778..2a70b7a486e3 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -612,6 +612,36 @@ struct ath12k *ath12k_mac_get_ar_by_pdev_id(struct ath12k_base *ab, u32 pdev_id)
return NULL;
}

+static struct ath12k *ath12k_mac_get_ar_by_chan(struct ieee80211_hw *hw,
+ struct ieee80211_channel *channel)
+{
+ struct ath12k_hw *ah = hw->priv;
+ struct ath12k *ar;
+ int i;
+
+ ar = ah->radio;
+
+ if (ah->num_radio == 1)
+ return ar;
+
+ for (i = 0; i < ah->num_radio; i++) {
+ if (channel->center_freq >= ar->freq_low &&
+ channel->center_freq <= ar->freq_high)
+ return ar;
+ ar++;
+ }
+ return NULL;
+}
+
+static struct ath12k *ath12k_get_ar_by_ctx(struct ieee80211_hw *hw,
+ struct ieee80211_chanctx_conf *ctx)
+{
+ if (!ctx)
+ return NULL;
+
+ return ath12k_mac_get_ar_by_chan(hw, ctx->def.chan);
+}
+
static void ath12k_pdev_caps_update(struct ath12k *ar)
{
struct ath12k_base *ab = ar->ab;
@@ -6084,7 +6114,12 @@ static int ath12k_mac_op_add_chanctx(struct ieee80211_hw *hw,

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah, 0);
+ ar = ath12k_get_ar_by_ctx(hw, ctx);
+ if (!ar) {
+ mutex_unlock(&ah->conf_mutex);
+ return -EINVAL;
+ }
+
ab = ar->ab;

ath12k_dbg(ab, ATH12K_DBG_MAC,
@@ -6116,7 +6151,12 @@ static void ath12k_mac_op_remove_chanctx(struct ieee80211_hw *hw,

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah, 0);
+ ar = ath12k_get_ar_by_ctx(hw, ctx);
+ if (!ar) {
+ mutex_unlock(&ah->conf_mutex);
+ return;
+ }
+
ab = ar->ab;

ath12k_dbg(ab, ATH12K_DBG_MAC,
@@ -6533,7 +6573,12 @@ static void ath12k_mac_op_change_chanctx(struct ieee80211_hw *hw,

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah, 0);
+ ar = ath12k_get_ar_by_ctx(hw, ctx);
+ if (!ar) {
+ mutex_unlock(&ah->conf_mutex);
+ return;
+ }
+
ab = ar->ab;

mutex_lock(&ar->conf_mutex);
@@ -7439,6 +7484,9 @@ static void ath12k_mac_update_ch_list(struct ath12k *ar,
band->channels[i].center_freq > freq_high)
band->channels[i].flags |= IEEE80211_CHAN_DISABLED;
}
+
+ ar->freq_low = freq_low;
+ ar->freq_high = freq_high;
}

static u32 ath12k_get_phy_id(struct ath12k *ar, u32 band)
--
2.17.1


2024-01-11 04:51:52

by Sriram R

[permalink] [raw]
Subject: [PATCH 04/12] wifi: ath12k: vdev statemachine changes for single wiphy

With single wiphy, multiple radios are combined into a single wiphy.
Since any channel can be assigned to a vif being brought up,
the vdev cannot be created during add_interface(). Hence defer the
vdev creation till channel assignment.

If only one radio is part of the wiphy, then the existing logic
is maintained, i.e vdevs are created during add interface and
started during channel assignment. This ensures no functional changes
to single pdev devices which has only one radio in the SoC.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3

Signed-off-by: Sriram R <[email protected]>
---
drivers/net/wireless/ath/ath12k/core.h | 1 +
drivers/net/wireless/ath/ath12k/hw.h | 3 +-
drivers/net/wireless/ath/ath12k/mac.c | 215 ++++++++++++++++++-------
3 files changed, 157 insertions(+), 62 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h
index 69c926ba0e73..8c107565905b 100644
--- a/drivers/net/wireless/ath/ath12k/core.h
+++ b/drivers/net/wireless/ath/ath12k/core.h
@@ -249,6 +249,7 @@ struct ath12k_vif {
} ap;
} u;

+ bool is_created;
bool is_started;
bool is_up;
u32 aid;
diff --git a/drivers/net/wireless/ath/ath12k/hw.h b/drivers/net/wireless/ath/ath12k/hw.h
index fa8230def22b..aaf68b3e9304 100644
--- a/drivers/net/wireless/ath/ath12k/hw.h
+++ b/drivers/net/wireless/ath/ath12k/hw.h
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-3-Clause-Clear */
/*
* Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
- * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
*/

#ifndef ATH12K_HW_H
@@ -67,6 +67,7 @@
#define TARGET_DMA_BURST_SIZE 1
#define TARGET_RX_BATCHMODE 1

+#define ATH12K_HW_DEFAULT_QUEUE 0
#define ATH12K_HW_MAX_QUEUES 4
#define ATH12K_QUEUE_LEN 4096

diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 7933d5993519..2dcd049009fe 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -5633,66 +5633,25 @@ static void ath12k_mac_op_update_vif_offload(struct ieee80211_hw *hw,
ath12k_mac_update_vif_offload(arvif);
}

-static int ath12k_mac_op_add_interface(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif)
+static int ath12k_mac_vdev_create(struct ath12k *ar, struct ieee80211_vif *vif)
{
- struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
- struct ath12k *ar;
- struct ath12k_base *ab;
+ struct ath12k_hw *ah = ar->ah;
+ struct ath12k_base *ab = ar->ab;
+ struct ieee80211_hw *hw = ah->hw;
struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
struct ath12k_wmi_vdev_create_arg vdev_arg = {0};
struct ath12k_wmi_peer_create_arg peer_param;
u32 param_id, param_value;
u16 nss;
int i;
- int ret;
- int bit;
-
- vif->driver_flags |= IEEE80211_VIF_SUPPORTS_UAPSD;
+ int ret, vdev_id;

- mutex_lock(&ah->conf_mutex);
-
- ar = ath12k_ah_to_ar(ah, 0);
- ab = ar->ab;
-
- mutex_lock(&ar->conf_mutex);
-
- if (vif->type == NL80211_IFTYPE_AP &&
- ar->num_peers > (ar->max_num_peers - 1)) {
- ath12k_warn(ab, "failed to create vdev due to insufficient peer entry resource in firmware\n");
- ret = -ENOBUFS;
- goto err;
- }
-
- if (ar->num_created_vdevs > (TARGET_NUM_VDEVS - 1)) {
- ath12k_warn(ab, "failed to create vdev, reached max vdev limit %d\n",
- TARGET_NUM_VDEVS);
- ret = -EBUSY;
- goto err;
- }
-
- memset(arvif, 0, sizeof(*arvif));
+ lockdep_assert_held(&ah->conf_mutex);
+ lockdep_assert_held(&ar->conf_mutex);

arvif->ar = ar;
- arvif->vif = vif;
-
- INIT_LIST_HEAD(&arvif->list);
-
- /* Should we initialize any worker to handle connection loss indication
- * from firmware in sta mode?
- */
-
- for (i = 0; i < ARRAY_SIZE(arvif->bitrate_mask.control); i++) {
- arvif->bitrate_mask.control[i].legacy = 0xffffffff;
- memset(arvif->bitrate_mask.control[i].ht_mcs, 0xff,
- sizeof(arvif->bitrate_mask.control[i].ht_mcs));
- memset(arvif->bitrate_mask.control[i].vht_mcs, 0xff,
- sizeof(arvif->bitrate_mask.control[i].vht_mcs));
- }
-
- bit = __ffs64(ab->free_vdev_map);
-
- arvif->vdev_id = bit;
+ vdev_id = __ffs64(ab->free_vdev_map);
+ arvif->vdev_id = vdev_id;
arvif->vdev_subtype = WMI_VDEV_SUBTYPE_NONE;

switch (vif->type) {
@@ -5708,14 +5667,14 @@ static int ath12k_mac_op_add_interface(struct ieee80211_hw *hw,
break;
case NL80211_IFTYPE_MONITOR:
arvif->vdev_type = WMI_VDEV_TYPE_MONITOR;
- ar->monitor_vdev_id = bit;
+ ar->monitor_vdev_id = vdev_id;
break;
default:
WARN_ON(1);
break;
}

- ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac add interface id %d type %d subtype %d map %llx\n",
+ ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac vdev create id %d type %d subtype %d map %llx\n",
arvif->vdev_id, arvif->vdev_type, arvif->vdev_subtype,
ab->free_vdev_map);

@@ -5733,6 +5692,7 @@ static int ath12k_mac_op_add_interface(struct ieee80211_hw *hw,
}

ar->num_created_vdevs++;
+ arvif->is_created = true;
ath12k_dbg(ab, ATH12K_DBG_MAC, "vdev %pM created, vdev_id %d\n",
vif->addr, arvif->vdev_id);
ar->allocated_vdev_map |= 1LL << arvif->vdev_id;
@@ -5833,9 +5793,6 @@ static int ath12k_mac_op_add_interface(struct ieee80211_hw *hw,
if (vif->type != NL80211_IFTYPE_MONITOR && ar->monitor_conf_enabled)
ath12k_mac_monitor_vdev_create(ar);

- mutex_unlock(&ar->conf_mutex);
- mutex_unlock(&ah->conf_mutex);
-
return ret;

err_peer_del:
@@ -5861,6 +5818,7 @@ static int ath12k_mac_op_add_interface(struct ieee80211_hw *hw,
err_vdev_del:
ath12k_wmi_vdev_delete(ar, arvif->vdev_id);
ar->num_created_vdevs--;
+ arvif->is_created = false;
ar->allocated_vdev_map &= ~(1LL << arvif->vdev_id);
ab->free_vdev_map |= 1LL << arvif->vdev_id;
ab->free_vdev_stats_id_map &= ~(1LL << arvif->vdev_stats_id);
@@ -5869,10 +5827,110 @@ static int ath12k_mac_op_add_interface(struct ieee80211_hw *hw,
spin_unlock_bh(&ar->data_lock);

err:
+ arvif->ar = NULL;
+ return ret;
+}
+
+static struct ath12k *ath12k_mac_assign_vif_to_vdev(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
+ struct ieee80211_chanctx_conf *ctx)
+{
+ struct ath12k_hw *ah = hw->priv;
+ struct ath12k *ar;
+ struct ath12k_base *ab;
+ struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
+ u8 bit;
+ int ret;
+
+ lockdep_assert_held(&ah->conf_mutex);
+
+ if (arvif->ar) {
+ WARN_ON(!arvif->is_created);
+ goto out;
+ }
+
+ if (ah->num_radio == 1)
+ ar = ah->radio;
+ else if (ctx)
+ ar = ath12k_get_ar_by_ctx(hw, ctx);
+ else
+ return NULL;
+
+ if (!ar)
+ goto out;
+
+ ab = ar->ab;
+
+ mutex_lock(&ar->conf_mutex);
+
+ if (vif->type == NL80211_IFTYPE_AP &&
+ ar->num_peers > (ar->max_num_peers - 1)) {
+ ath12k_warn(ab, "failed to create vdev due to insufficient peer entry resource in firmware\n");
+ ret = -ENOBUFS;
+ goto unlock;
+ }
+
+ if (ar->num_created_vdevs > (TARGET_NUM_VDEVS - 1)) {
+ ath12k_warn(ab, "failed to create vdev, reached max vdev limit %d\n",
+ TARGET_NUM_VDEVS);
+ ret = -EBUSY;
+ goto unlock;
+ }
+
+ ret = ath12k_mac_vdev_create(ar, vif);
+ if (ret) {
+ ath12k_warn(ab, "failed to create vdev %d ret %d", bit, ret);
+ goto unlock;
+ }
+
+ /* TODO If the vdev is created during channel assign and not during
+ * add_interface(), Apply any parameters for the vdev which were received
+ * after add_interface, corresponding to this vif.
+ */
+
+unlock:
mutex_unlock(&ar->conf_mutex);
- mutex_unlock(&ah->conf_mutex);
+out:
+ return arvif->ar;
+}

- return ret;
+static int ath12k_mac_op_add_interface(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif)
+{
+ struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
+ struct ath12k_hw *ah = hw->priv;
+ int i;
+
+ mutex_lock(&ah->conf_mutex);
+ memset(arvif, 0, sizeof(*arvif));
+
+ arvif->vif = vif;
+
+ INIT_LIST_HEAD(&arvif->list);
+
+ for (i = 0; i < ARRAY_SIZE(arvif->bitrate_mask.control); i++) {
+ arvif->bitrate_mask.control[i].legacy = 0xffffffff;
+ memset(arvif->bitrate_mask.control[i].ht_mcs, 0xff,
+ sizeof(arvif->bitrate_mask.control[i].ht_mcs));
+ memset(arvif->bitrate_mask.control[i].vht_mcs, 0xff,
+ sizeof(arvif->bitrate_mask.control[i].vht_mcs));
+ }
+
+ /* Allocate Default Queue now and reassign during actual vdev create */
+ vif->cab_queue = ATH12K_HW_DEFAULT_QUEUE;
+ for (i = 0; i < ARRAY_SIZE(vif->hw_queue); i++)
+ vif->hw_queue[i] = ATH12K_HW_DEFAULT_QUEUE;
+
+ vif->driver_flags |= IEEE80211_VIF_SUPPORTS_UAPSD;
+
+ /* For single radio wiphy(i.e ah->num_radio is 1), create the vdev
+ * during add_interface itself, for multi radio wiphy, defer the vdev
+ * creation until channel_assign to determine the radio on which the
+ * vdev needs to be created
+ */
+ ath12k_mac_assign_vif_to_vdev(hw, vif, NULL);
+ mutex_unlock(&ah->conf_mutex);
+ return 0;
}

static void ath12k_mac_vif_unref(struct ath12k_dp *dp, struct ieee80211_vif *vif)
@@ -5912,7 +5970,12 @@ static void ath12k_mac_op_remove_interface(struct ieee80211_hw *hw,

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah, 0);
+ if (!arvif->is_created) {
+ mutex_unlock(&ah->conf_mutex);
+ return;
+ }
+
+ ar = arvif->ar;
ab = ar->ab;

mutex_lock(&ar->conf_mutex);
@@ -5954,6 +6017,7 @@ static void ath12k_mac_op_remove_interface(struct ieee80211_hw *hw,
ar->allocated_vdev_map &= ~(1LL << arvif->vdev_id);
ab->free_vdev_stats_id_map &= ~(1LL << arvif->vdev_stats_id);
ar->num_created_vdevs--;
+ arvif->is_created = false;

ath12k_dbg(ab, ATH12K_DBG_MAC, "vdev %pM deleted, vdev_id %d\n",
vif->addr, arvif->vdev_id);
@@ -6684,7 +6748,17 @@ ath12k_mac_op_assign_vif_chanctx(struct ieee80211_hw *hw,

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah, 0);
+ /* For multi radio wiphy, the vdev was not created during add_interface
+ * create now since we have a channel ctx now to assign to a specific ar/fw
+ */
+ ar = ath12k_mac_assign_vif_to_vdev(hw, vif, ctx);
+
+ if (!ar) {
+ WARN_ON(1);
+ mutex_unlock(&ah->conf_mutex);
+ return -EINVAL;
+ }
+
ab = ar->ab;

mutex_lock(&ar->conf_mutex);
@@ -6768,8 +6842,19 @@ ath12k_mac_op_unassign_vif_chanctx(struct ieee80211_hw *hw,
int ret;

mutex_lock(&ah->conf_mutex);
+ /* The vif is expected to be attached to an ar's VDEV.
+ * We leave the vif/vdev in this function as is
+ * and not delete the vdev symmetric to assign_vif_chanctx()
+ * the VDEV will be deleted and unassigned either during
+ * remove_interface() or when there is a change in channel
+ * that moves the vif to a new ar
+ */
+ if (!arvif->is_created) {
+ mutex_unlock(&ah->conf_mutex);
+ return;
+ }

- ar = ath12k_ah_to_ar(ah, 0);
+ ar = arvif->ar;
ab = ar->ab;

mutex_lock(&ar->conf_mutex);
@@ -6824,9 +6909,17 @@ ath12k_mac_op_switch_vif_chanctx(struct ieee80211_hw *hw,
struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
struct ath12k *ar;

+ ar = ath12k_get_ar_by_ctx(hw, vifs->old_ctx);
+ if (!ar)
+ return -EINVAL;
+
mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah, 0);
+ /* Switching channels across radio is not allowed */
+ if (ar != ath12k_get_ar_by_ctx(hw, vifs->new_ctx))
+ return -EINVAL;
+
+ mutex_lock(&ah->conf_mutex);

mutex_lock(&ar->conf_mutex);

--
2.17.1


2024-01-11 04:51:54

by Sriram R

[permalink] [raw]
Subject: [PATCH 05/12] wifi: ath12k: scan statemachine changes for single wiphy

When multiple radios are advertised as a single wiphy which
supports various bands, a default scan request to mac80211
from cfg80211 will split the driver request based on band,
so each request will have channels belonging to the same band.
With this supported by default, the ath12k driver on receiving
this request checks for one of the channels in the request and
selects the corresponding radio(ar) on which the scan is going
to be performed and creates a vdev on that radio.

Note that on scan completion this vdev is not deleted. If a new
scan request is seen on that same vif for a different band the
vdev will be deleted and created on the new radio supporting the
request. The vdev delete logic is refactored to have this done
dynamically.

The reason for not deleting the vdev on scan stop is to avoid
repeated delete-create sequence if the scan is on the same band.
Also, during channel assign, new vdev creation can be optimized
as well.

Also if the scan is requested when the vdev is in started state,
no switching to new radio is allowed and scan on channels only
within same radio is allowed.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3

Signed-off-by: Sriram R <[email protected]>
---
drivers/net/wireless/ath/ath12k/mac.c | 237 +++++++++++++++++++++-----
1 file changed, 199 insertions(+), 38 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 2dcd049009fe..c20567db1e35 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -244,6 +244,8 @@ static const u32 ath12k_smps_map[] = {
static int ath12k_start_vdev_delay(struct ath12k *ar,
struct ath12k_vif *arvif);
static void ath12k_mac_stop(struct ath12k *ar);
+static int ath12k_mac_vdev_create(struct ath12k *ar, struct ieee80211_vif *vif);
+static int ath12k_mac_vdev_delete(struct ath12k *ar, struct ieee80211_vif *vif);

static const char *ath12k_mac_phymode_str(enum wmi_phy_mode mode)
{
@@ -2846,6 +2848,45 @@ static void ath12k_mac_op_bss_info_changed(struct ieee80211_hw *hw,
mutex_unlock(&ah->conf_mutex);
}

+static struct ath12k*
+ath12k_mac_select_scan_device(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
+ struct ieee80211_scan_request *req)
+{
+ struct ath12k_hw *ah = hw->priv;
+ enum nl80211_band band;
+ struct ath12k *ar;
+ int i;
+
+ if (ah->num_radio == 1)
+ return ah->radio;
+
+ /* Currently mac80211 supports splitting scan requests into
+ * multiple scan requests per band.
+ * Loop through first channel and determine the scan radio
+ * TODO: There could be 5 GHz low/high channels in that case
+ * split the hw request and perform multiple scans
+ */
+
+ if (req->req.channels[0]->center_freq < ATH12K_MIN_5G_FREQ)
+ band = NL80211_BAND_2GHZ;
+ else if (req->req.channels[0]->center_freq < ATH12K_MIN_6G_FREQ)
+ band = NL80211_BAND_5GHZ;
+ else
+ band = NL80211_BAND_6GHZ;
+
+ ar = ah->radio;
+
+ for (i = 0; i < ah->num_radio; i++) {
+ /* TODO 5 GHz low high split changes */
+ if (ar->mac.sbands[band].channels)
+ return ar;
+ ar++;
+ }
+
+ return NULL;
+}
+
void __ath12k_mac_scan_finish(struct ath12k *ar)
{
struct ieee80211_hw *hw = ath12k_ar_to_hw(ar);
@@ -3015,17 +3056,79 @@ static int ath12k_mac_op_hw_scan(struct ieee80211_hw *hw,
struct ieee80211_scan_request *hw_req)
{
struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
- struct ath12k *ar;
+ struct ath12k *ar, *prev_ar;
struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
struct cfg80211_scan_request *req = &hw_req->req;
struct ath12k_wmi_scan_req_arg arg = {};
int ret;
int i;
+ bool create = true;

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah, 0);
+ if (ah->num_radio == 1) {
+ WARN_ON(!arvif->is_created);
+ ar = ath12k_ah_to_ar(ah, 0);
+ goto scan;
+ }
+
+ /* Since the targeted scan device could depend on the frequency
+ * requested in the hw_req, select the corresponding radio
+ */
+ ar = ath12k_mac_select_scan_device(hw, vif, hw_req);
+ if (!ar) {
+ mutex_unlock(&ah->conf_mutex);
+ return -EINVAL;
+ }
+
+ /* If the vif is already assigned to a specific vdev of an ar,
+ * check whether its already started, vdev which is started
+ * are not allowed to switch to a new radio.
+ * If the vdev is not started, but was earlier created on a
+ * different ar, delete that vdev and create a new one. We don't
+ * delete at the scan stop as an optimization to avoid redundant
+ * delete-create vdev's for the same ar, in case the request is
+ * always on the same band for the vif
+ */
+ if (arvif->is_created) {
+ if (WARN_ON(!arvif->ar)) {
+ mutex_unlock(&ah->conf_mutex);
+ return -EINVAL;
+ }

+ if (ar != arvif->ar && arvif->is_started) {
+ mutex_unlock(&ah->conf_mutex);
+ return -EINVAL;
+ }
+
+ if (ar != arvif->ar) {
+ /* backup the previously used ar ptr, since the vdev delete
+ * would assign the arvif->ar to NULL after the call
+ */
+ prev_ar = arvif->ar;
+ mutex_lock(&prev_ar->conf_mutex);
+ ret = ath12k_mac_vdev_delete(prev_ar, vif);
+ mutex_unlock(&prev_ar->conf_mutex);
+ if (ret)
+ ath12k_warn(prev_ar->ab,
+ "unable to delete scan vdev %d\n", ret);
+ } else {
+ create = false;
+ }
+ }
+
+ if (create) {
+ mutex_lock(&ar->conf_mutex);
+ ret = ath12k_mac_vdev_create(ar, vif);
+ mutex_unlock(&ar->conf_mutex);
+ if (ret) {
+ mutex_unlock(&ah->conf_mutex);
+ ath12k_warn(ar->ab, "unable to create scan vdev %d\n", ret);
+ return -EINVAL;
+ }
+ }
+
+scan:
mutex_lock(&ar->conf_mutex);

spin_lock_bh(&ar->data_lock);
@@ -3115,10 +3218,16 @@ static void ath12k_mac_op_cancel_hw_scan(struct ieee80211_hw *hw,
{
struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
struct ath12k *ar;
+ struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah, 0);
+ if (!arvif->is_created) {
+ mutex_unlock(&ah->conf_mutex);
+ return;
+ }
+
+ ar = arvif->ar;

mutex_lock(&ar->conf_mutex);
ath12k_scan_abort(ar);
@@ -5793,6 +5902,7 @@ static int ath12k_mac_vdev_create(struct ath12k *ar, struct ieee80211_vif *vif)
if (vif->type != NL80211_IFTYPE_MONITOR && ar->monitor_conf_enabled)
ath12k_mac_monitor_vdev_create(ar);

+ arvif->ar = ar;
return ret;

err_peer_del:
@@ -5819,6 +5929,7 @@ static int ath12k_mac_vdev_create(struct ath12k *ar, struct ieee80211_vif *vif)
ath12k_wmi_vdev_delete(ar, arvif->vdev_id);
ar->num_created_vdevs--;
arvif->is_created = false;
+ arvif->ar = NULL;
ar->allocated_vdev_map &= ~(1LL << arvif->vdev_id);
ab->free_vdev_map |= 1LL << arvif->vdev_id;
ab->free_vdev_stats_id_map &= ~(1LL << arvif->vdev_stats_id);
@@ -5836,7 +5947,7 @@ static struct ath12k *ath12k_mac_assign_vif_to_vdev(struct ieee80211_hw *hw,
struct ieee80211_chanctx_conf *ctx)
{
struct ath12k_hw *ah = hw->priv;
- struct ath12k *ar;
+ struct ath12k *ar, *prev_ar;
struct ath12k_base *ab;
struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
u8 bit;
@@ -5845,7 +5956,42 @@ static struct ath12k *ath12k_mac_assign_vif_to_vdev(struct ieee80211_hw *hw,
lockdep_assert_held(&ah->conf_mutex);

if (arvif->ar) {
- WARN_ON(!arvif->is_created);
+ /* This is not expected really */
+ if (WARN_ON(!arvif->is_created)) {
+ arvif->ar = NULL;
+ return NULL;
+ }
+
+ if (ah->num_radio == 1)
+ goto out;
+
+ ar = ath12k_get_ar_by_ctx(hw, ctx);
+
+ /* This can happen as scan vdev gets created during multiple scans
+ * across different radios before a vdev is brought up in
+ * a certain radio
+ */
+ if (ar != arvif->ar) {
+ if (WARN_ON(arvif->is_started))
+ return NULL;
+
+ /* backup the previously used ar ptr since arvif->ar would
+ * be set to NULL after vdev delete is done
+ */
+ prev_ar = arvif->ar;
+ mutex_lock(&prev_ar->conf_mutex);
+ ret = ath12k_mac_vdev_delete(prev_ar, vif);
+ if (ret)
+ ath12k_warn(prev_ar->ab, "unable to delete vdev %d\n",
+ ret);
+ mutex_unlock(&prev_ar->conf_mutex);
+
+ mutex_lock(&ar->conf_mutex);
+ ret = ath12k_mac_vdev_create(ar, vif);
+ if (ret)
+ ath12k_warn(ar->ab, "unable to create vdev %d\n", ret);
+ mutex_unlock(&ar->conf_mutex);
+ }
goto out;
}

@@ -5958,43 +6104,21 @@ static void ath12k_mac_vif_unref(struct ath12k_dp *dp, struct ieee80211_vif *vif
}
}

-static void ath12k_mac_op_remove_interface(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif)
+static int ath12k_mac_vdev_delete(struct ath12k *ar, struct ieee80211_vif *vif)
{
- struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
- struct ath12k *ar;
struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
- struct ath12k_base *ab;
+ struct ath12k_base *ab = ar->ab;
unsigned long time_left;
int ret;

- mutex_lock(&ah->conf_mutex);
-
- if (!arvif->is_created) {
- mutex_unlock(&ah->conf_mutex);
- return;
- }
-
- ar = arvif->ar;
- ab = ar->ab;
-
- mutex_lock(&ar->conf_mutex);
-
- ath12k_dbg(ab, ATH12K_DBG_MAC, "mac remove interface (vdev %d)\n",
- arvif->vdev_id);
-
- if (arvif->vdev_type == WMI_VDEV_TYPE_AP) {
- ret = ath12k_peer_delete(ar, arvif->vdev_id, vif->addr);
- if (ret)
- ath12k_warn(ab, "failed to submit AP self-peer removal on vdev %d: %d\n",
- arvif->vdev_id, ret);
- }
+ lockdep_assert_held(&ar->ah->conf_mutex);
+ lockdep_assert_held(&ar->conf_mutex);

reinit_completion(&ar->vdev_delete_done);

ret = ath12k_wmi_vdev_delete(ar, arvif->vdev_id);
if (ret) {
- ath12k_warn(ab, "failed to delete WMI vdev %d: %d\n",
+ ath12k_warn(ab, "failed to delete WMI scan vdev %d: %d\n",
arvif->vdev_id, ret);
goto err_vdev_del;
}
@@ -6006,6 +6130,10 @@ static void ath12k_mac_op_remove_interface(struct ieee80211_hw *hw,
goto err_vdev_del;
}

+ ab->free_vdev_map |= 1LL << arvif->vdev_id;
+ ar->allocated_vdev_map &= ~(1LL << arvif->vdev_id);
+ ar->num_created_vdevs--;
+
if (arvif->vdev_type == WMI_VDEV_TYPE_MONITOR) {
ar->monitor_vdev_id = -1;
ar->monitor_vdev_created = false;
@@ -6013,12 +6141,6 @@ static void ath12k_mac_op_remove_interface(struct ieee80211_hw *hw,
ret = ath12k_mac_monitor_vdev_delete(ar);
}

- ab->free_vdev_map |= 1LL << (arvif->vdev_id);
- ar->allocated_vdev_map &= ~(1LL << arvif->vdev_id);
- ab->free_vdev_stats_id_map &= ~(1LL << arvif->vdev_stats_id);
- ar->num_created_vdevs--;
- arvif->is_created = false;
-
ath12k_dbg(ab, ATH12K_DBG_MAC, "vdev %pM deleted, vdev_id %d\n",
vif->addr, arvif->vdev_id);

@@ -6041,6 +6163,45 @@ static void ath12k_mac_op_remove_interface(struct ieee80211_hw *hw,

/* TODO: recal traffic pause state based on the available vdevs */

+ arvif->is_created = false;
+ arvif->ar = NULL;
+
+ return ret;
+}
+
+static void ath12k_mac_op_remove_interface(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif)
+{
+ struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+ struct ath12k *ar;
+ struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
+ struct ath12k_base *ab;
+ int ret;
+
+ mutex_lock(&ah->conf_mutex);
+
+ if (!arvif->is_created) {
+ mutex_unlock(&ah->conf_mutex);
+ return;
+ }
+
+ ar = arvif->ar;
+ ab = ar->ab;
+
+ mutex_lock(&ar->conf_mutex);
+
+ ath12k_dbg(ab, ATH12K_DBG_MAC, "mac remove interface (vdev %d)\n",
+ arvif->vdev_id);
+
+ if (arvif->vdev_type == WMI_VDEV_TYPE_AP) {
+ ret = ath12k_peer_delete(ar, arvif->vdev_id, vif->addr);
+ if (ret)
+ ath12k_warn(ab, "failed to submit AP self-peer removal on vdev %d: %d\n",
+ arvif->vdev_id, ret);
+ }
+
+ ath12k_mac_vdev_delete(ar, vif);
+
mutex_unlock(&ar->conf_mutex);
mutex_unlock(&ah->conf_mutex);
}
--
2.17.1


2024-01-11 04:52:02

by Sriram R

[permalink] [raw]
Subject: [PATCH 06/12] wifi: ath12k: fetch correct radio based on vdev status

For ops which passes the vif info, fetch the radio(ar)
to be used for corresponding functions based on the
the vdev creation status. If the vdev is not created yet,
which could happen when the ops are called before channel
is assigned for the vif, the data needs to be cached and this
is done in followup changes.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3

Signed-off-by: Sriram R <[email protected]>
---
drivers/net/wireless/ath/ath12k/mac.c | 84 ++++++++++++++++++++++++---
1 file changed, 77 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index c20567db1e35..13203ca500f2 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -645,6 +645,26 @@ static struct ath12k *ath12k_get_ar_by_ctx(struct ieee80211_hw *hw,
return ath12k_mac_get_ar_by_chan(hw, ctx->def.chan);
}

+static struct ath12k *ath12k_get_ar_by_vif(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif)
+{
+ struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
+ struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+
+ lockdep_assert_held(&ah->conf_mutex);
+
+ /* If there is one pdev within ah, then we return
+ * ar directly.
+ */
+ if (ah->num_radio == 1)
+ return ah->radio;
+
+ if (arvif->is_created)
+ return arvif->ar;
+
+ return NULL;
+}
+
static void ath12k_pdev_caps_update(struct ath12k *ar)
{
struct ath12k_base *ab = ar->ab;
@@ -2837,7 +2857,15 @@ static void ath12k_mac_op_bss_info_changed(struct ieee80211_hw *hw,

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah, 0);
+ ar = ath12k_get_ar_by_vif(hw, vif);
+
+ /* TODO if the vdev is not created on a certain radio,
+ * cache the info to be updated later on vdev creation
+ */
+ if (!ar) {
+ mutex_unlock(&ah->conf_mutex);
+ return;
+ }

mutex_lock(&ar->conf_mutex);

@@ -3376,7 +3404,12 @@ static int ath12k_mac_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah, 0);
+ ar = ath12k_get_ar_by_vif(hw, vif);
+ if (!ar) {
+ mutex_unlock(&ah->conf_mutex);
+ WARN_ON_ONCE(1);
+ return -EINVAL;
+ }
ab = ar->ab;

if (test_bit(ATH12K_FLAG_HW_CRYPTO_DISABLED, &ar->ab->dev_flags)) {
@@ -3973,7 +4006,12 @@ static int ath12k_mac_op_sta_state(struct ieee80211_hw *hw,

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah, 0);
+ ar = ath12k_get_ar_by_vif(hw, vif);
+ if (!ar) {
+ mutex_unlock(&ah->conf_mutex);
+ WARN_ON_ONCE(1);
+ return -EINVAL;
+ }

mutex_lock(&ar->conf_mutex);

@@ -4129,7 +4167,12 @@ static void ath12k_mac_op_sta_rc_update(struct ieee80211_hw *hw,
struct ath12k_peer *peer;
u32 bw, smps;

- ar = ath12k_ah_to_ar(ah, 0);
+ ar = ath12k_get_ar_by_vif(hw, vif);
+ if (!ar) {
+ mutex_unlock(&ah->conf_mutex);
+ WARN_ON_ONCE(1);
+ return;
+ }

spin_lock_bh(&ar->ab->base_lock);

@@ -4312,7 +4355,12 @@ static int ath12k_mac_op_conf_tx(struct ieee80211_hw *hw,

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah, 0);
+ ar = ath12k_get_ar_by_vif(hw, vif);
+ if (!ar) {
+ /* TODO cache the info and apply after vdev is created */
+ mutex_unlock(&ah->conf_mutex);
+ return -EINVAL;
+ }

mutex_lock(&ar->conf_mutex);
ret = ath12k_mac_conf_tx(arvif, link_id, ac, params);
@@ -6348,7 +6396,11 @@ static int ath12k_mac_op_ampdu_action(struct ieee80211_hw *hw,

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah, 0);
+ ar = ath12k_get_ar_by_vif(hw, vif);
+ if (!ar) {
+ mutex_unlock(&ah->conf_mutex);
+ return -EINVAL;
+ }

mutex_lock(&ar->conf_mutex);
ret = ath12k_mac_ampdu_action(arvif, params);
@@ -7176,11 +7228,29 @@ static void ath12k_mac_op_flush(struct ieee80211_hw *hw, struct ieee80211_vif *v
u32 queues, bool drop)
{
struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
- struct ath12k *ar = ath12k_ah_to_ar(ah, 0);
+ struct ath12k *ar;
+ int i;

if (drop)
return;

+ /* vif can be NULL when flush() is considered for hw */
+ if (!vif) {
+ ar = ath12k_ah_to_ar(ah, 0);
+ for (i = 0; i < ah->num_radio; i++) {
+ ath12k_mac_flush(ar);
+ ar++;
+ }
+ return;
+ }
+
+ mutex_lock(&ah->conf_mutex);
+ ar = ath12k_get_ar_by_vif(hw, vif);
+ mutex_unlock(&ah->conf_mutex);
+
+ if (!ar)
+ return;
+
ath12k_mac_flush(ar);
}

--
2.17.1


2024-01-11 04:52:07

by Sriram R

[permalink] [raw]
Subject: [PATCH 07/12] wifi: ath12k: Cache vdev configs before vdev create

Since the vdev create for a corresponding vif is deferred
until a channel is assigned, cache the information which
are received through mac80211 ops between add_interface()
and assign_vif_chanctx() and set them once the vdev is
created on one of the ath12k radios as the channel gets
assigned via assign_vif_chanctx().

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3

Signed-off-by: Sriram R <[email protected]>
---
drivers/net/wireless/ath/ath12k/core.h | 19 ++++
drivers/net/wireless/ath/ath12k/mac.c | 130 ++++++++++++++++++-------
2 files changed, 114 insertions(+), 35 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h
index 8c107565905b..0b55a3f533cd 100644
--- a/drivers/net/wireless/ath/ath12k/core.h
+++ b/drivers/net/wireless/ath/ath12k/core.h
@@ -212,6 +212,24 @@ enum ath12k_monitor_flags {
ATH12K_FLAG_MONITOR_ENABLED,
};

+struct ath12k_tx_conf {
+ bool changed;
+ u16 ac;
+ struct ieee80211_tx_queue_params tx_queue_params;
+};
+
+struct ath12k_key_conf {
+ bool changed;
+ enum set_key_cmd cmd;
+ struct ieee80211_key_conf *key;
+};
+
+struct ath12k_vif_cache {
+ struct ath12k_tx_conf tx_conf;
+ struct ath12k_key_conf key_conf;
+ u32 bss_conf_changed;
+};
+
struct ath12k_vif {
u32 vdev_id;
enum wmi_vdev_type vdev_type;
@@ -265,6 +283,7 @@ struct ath12k_vif {
u8 tx_encap_type;
u8 vdev_stats_id;
u32 punct_bitmap;
+ struct ath12k_vif_cache cache;
};

struct ath12k_vif_iter {
diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 13203ca500f2..91d378c5f2cf 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -2859,10 +2859,11 @@ static void ath12k_mac_op_bss_info_changed(struct ieee80211_hw *hw,

ar = ath12k_get_ar_by_vif(hw, vif);

- /* TODO if the vdev is not created on a certain radio,
+ /* if the vdev is not created on a certain radio,
* cache the info to be updated later on vdev creation
*/
if (!ar) {
+ arvif->cache.bss_conf_changed |= changed;
mutex_unlock(&ah->conf_mutex);
return;
}
@@ -3381,13 +3382,12 @@ static int ath12k_clear_peer_keys(struct ath12k_vif *arvif,
return first_errno;
}

-static int ath12k_mac_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
- struct ieee80211_vif *vif, struct ieee80211_sta *sta,
- struct ieee80211_key_conf *key)
+static int ath12k_mac_set_key(struct ath12k *ar, enum set_key_cmd cmd,
+ struct ieee80211_vif *vif, struct ieee80211_sta *sta,
+ struct ieee80211_key_conf *key)
{
- struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
- struct ath12k *ar;
- struct ath12k_base *ab;
+ struct ath12k_hw *ah = ar->ah;
+ struct ath12k_base *ab = ar->ab;
struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
struct ath12k_peer *peer;
struct ath12k_sta *arsta;
@@ -3395,34 +3395,11 @@ static int ath12k_mac_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
int ret = 0;
u32 flags = 0;

- /* BIP needs to be done in software */
- if (key->cipher == WLAN_CIPHER_SUITE_AES_CMAC ||
- key->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_128 ||
- key->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_256 ||
- key->cipher == WLAN_CIPHER_SUITE_BIP_CMAC_256)
- return 1;
-
- mutex_lock(&ah->conf_mutex);
-
- ar = ath12k_get_ar_by_vif(hw, vif);
- if (!ar) {
- mutex_unlock(&ah->conf_mutex);
- WARN_ON_ONCE(1);
- return -EINVAL;
- }
- ab = ar->ab;
+ lockdep_assert_held(&ah->conf_mutex);
+ lockdep_assert_held(&ar->conf_mutex);

- if (test_bit(ATH12K_FLAG_HW_CRYPTO_DISABLED, &ar->ab->dev_flags)) {
- mutex_unlock(&ah->conf_mutex);
+ if (test_bit(ATH12K_FLAG_HW_CRYPTO_DISABLED, &ab->dev_flags))
return 1;
- }
-
- if (key->keyidx > WMI_MAX_KEY_INDEX) {
- mutex_unlock(&ah->conf_mutex);
- return -ENOSPC;
- }
-
- mutex_lock(&ar->conf_mutex);

if (sta)
peer_addr = sta->addr;
@@ -3515,7 +3492,49 @@ static int ath12k_mac_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
spin_unlock_bh(&ab->base_lock);

exit:
+ return ret;
+}
+
+static int ath12k_mac_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
+ struct ieee80211_vif *vif, struct ieee80211_sta *sta,
+ struct ieee80211_key_conf *key)
+{
+ struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+ struct ath12k *ar;
+ struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
+ int ret;
+
+ /* BIP needs to be done in software */
+ if (key->cipher == WLAN_CIPHER_SUITE_AES_CMAC ||
+ key->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_128 ||
+ key->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_256 ||
+ key->cipher == WLAN_CIPHER_SUITE_BIP_CMAC_256)
+ return 1;
+
+ if (key->keyidx > WMI_MAX_KEY_INDEX)
+ return -ENOSPC;
+
+ mutex_lock(&ah->conf_mutex);
+
+ ar = ath12k_get_ar_by_vif(hw, vif);
+ if (!ar) {
+ /* ar is expected to be valid when sta ptr is available */
+ if (sta) {
+ mutex_unlock(&ah->conf_mutex);
+ WARN_ON_ONCE(1);
+ return -EINVAL;
+ }
+ arvif->cache.key_conf.cmd = cmd;
+ arvif->cache.key_conf.key = key;
+ arvif->cache.key_conf.changed = true;
+ mutex_unlock(&ah->conf_mutex);
+ return 0;
+ }
+
+ mutex_lock(&ar->conf_mutex);
+ ret = ath12k_mac_set_key(ar, cmd, vif, sta, key);
mutex_unlock(&ar->conf_mutex);
+
mutex_unlock(&ah->conf_mutex);
return ret;
}
@@ -4357,7 +4376,10 @@ static int ath12k_mac_op_conf_tx(struct ieee80211_hw *hw,

ar = ath12k_get_ar_by_vif(hw, vif);
if (!ar) {
- /* TODO cache the info and apply after vdev is created */
+ /* cache the info and apply after vdev is created */
+ arvif->cache.tx_conf.changed = true;
+ arvif->cache.tx_conf.ac = ac;
+ arvif->cache.tx_conf.tx_queue_params = *params;
mutex_unlock(&ah->conf_mutex);
return -EINVAL;
}
@@ -5990,6 +6012,43 @@ static int ath12k_mac_vdev_create(struct ath12k *ar, struct ieee80211_vif *vif)
return ret;
}

+static void ath12k_mac_vif_cache_flush(struct ath12k *ar, struct ieee80211_vif *vif)
+{
+ struct ath12k_hw *ah = ar->ah;
+ struct ath12k_base *ab = ar->ab;
+ struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
+ int ret;
+
+ lockdep_assert_held(&ah->conf_mutex);
+ lockdep_assert_held(&ar->conf_mutex);
+
+ if (arvif->cache.tx_conf.changed) {
+ ret = ath12k_mac_conf_tx(arvif, 0, arvif->cache.tx_conf.ac,
+ &arvif->cache.tx_conf.tx_queue_params);
+ if (ret)
+ ath12k_warn(ab,
+ "unable to apply tx config parameters to vdev %d\n",
+ ret);
+ }
+
+ if (arvif->cache.bss_conf_changed)
+ ath12k_mac_bss_info_changed(ar, arvif, &vif->bss_conf,
+ arvif->cache.bss_conf_changed);
+
+ if (arvif->cache.key_conf.changed) {
+ ret = ath12k_mac_set_key(ar, arvif->cache.key_conf.cmd,
+ vif, NULL,
+ arvif->cache.key_conf.key);
+ if (ret) {
+ WARN_ON_ONCE(1);
+ ath12k_warn(ab, "unable to apply set key param to vdev %d ret %d\n",
+ arvif->vdev_id, ret);
+ }
+ }
+
+ memset(&arvif->cache, 0, sizeof(struct ath12k_vif_cache));
+}
+
static struct ath12k *ath12k_mac_assign_vif_to_vdev(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct ieee80211_chanctx_conf *ctx)
@@ -6077,10 +6136,11 @@ static struct ath12k *ath12k_mac_assign_vif_to_vdev(struct ieee80211_hw *hw,
goto unlock;
}

- /* TODO If the vdev is created during channel assign and not during
+ /* If the vdev is created during channel assign and not during
* add_interface(), Apply any parameters for the vdev which were received
* after add_interface, corresponding to this vif.
*/
+ ath12k_mac_vif_cache_flush(ar, vif);

unlock:
mutex_unlock(&ar->conf_mutex);
--
2.17.1


2024-01-11 04:52:12

by Sriram R

[permalink] [raw]
Subject: [PATCH 08/12] wifi: ath12k: Add additional checks for vif and sta iterators

Since vif and sta objects of different radios are added to same
local hw list in mac80211, additional checks need to be done
in driver to ensure we are processing the intended vif
and sta corresponding to the radio when the vif and sta mac80211
iterator utils are used from driver.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3

Signed-off-by: Sriram R <[email protected]>
---
drivers/net/wireless/ath/ath12k/core.h | 1 +
drivers/net/wireless/ath/ath12k/mac.c | 22 ++++++++++++++++++++--
2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h
index 0b55a3f533cd..883556313fb0 100644
--- a/drivers/net/wireless/ath/ath12k/core.h
+++ b/drivers/net/wireless/ath/ath12k/core.h
@@ -288,6 +288,7 @@ struct ath12k_vif {

struct ath12k_vif_iter {
u32 vdev_id;
+ struct ath12k *ar;
struct ath12k_vif *arvif;
};

diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 91d378c5f2cf..25d82c6fe89a 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -533,7 +533,8 @@ static void ath12k_get_arvif_iter(void *data, u8 *mac,
struct ath12k_vif_iter *arvif_iter = data;
struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);

- if (arvif->vdev_id == arvif_iter->vdev_id)
+ if (arvif->vdev_id == arvif_iter->vdev_id &&
+ arvif->ar == arvif_iter->ar)
arvif_iter->arvif = arvif;
}

@@ -543,6 +544,7 @@ struct ath12k_vif *ath12k_mac_get_arvif(struct ath12k *ar, u32 vdev_id)
u32 flags;

arvif_iter.vdev_id = vdev_id;
+ arvif_iter.ar = ar;

flags = IEEE80211_IFACE_ITER_RESUME_ALL;
ieee80211_iterate_active_interfaces_atomic(ath12k_ar_to_hw(ar),
@@ -6770,14 +6772,19 @@ struct ath12k_mac_change_chanctx_arg {
struct ieee80211_vif_chanctx_switch *vifs;
int n_vifs;
int next_vif;
+ struct ath12k *ar;
};

static void
ath12k_mac_change_chanctx_cnt_iter(void *data, u8 *mac,
struct ieee80211_vif *vif)
{
+ struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
struct ath12k_mac_change_chanctx_arg *arg = data;

+ if (arvif->ar != arg->ar)
+ return;
+
if (rcu_access_pointer(vif->bss_conf.chanctx_conf) != arg->ctx)
return;

@@ -6788,9 +6795,13 @@ static void
ath12k_mac_change_chanctx_fill_iter(void *data, u8 *mac,
struct ieee80211_vif *vif)
{
+ struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
struct ath12k_mac_change_chanctx_arg *arg = data;
struct ieee80211_chanctx_conf *ctx;

+ if (arvif->ar != arg->ar)
+ return;
+
ctx = rcu_access_pointer(vif->bss_conf.chanctx_conf);
if (ctx != arg->ctx)
return;
@@ -6907,7 +6918,7 @@ static void
ath12k_mac_update_active_vif_chan(struct ath12k *ar,
struct ieee80211_chanctx_conf *ctx)
{
- struct ath12k_mac_change_chanctx_arg arg = { .ctx = ctx };
+ struct ath12k_mac_change_chanctx_arg arg = { .ctx = ctx, .ar = ar };
struct ieee80211_hw *hw = ath12k_ar_to_hw(ar);

lockdep_assert_held(&ar->conf_mutex);
@@ -7512,6 +7523,9 @@ static void ath12k_mac_set_bitrate_mask_iter(void *data,
struct ath12k_sta *arsta = ath12k_sta_to_arsta(sta);
struct ath12k *ar = arvif->ar;

+ if (arsta->arvif != arvif)
+ return;
+
spin_lock_bh(&ar->data_lock);
arsta->changed |= IEEE80211_RC_SUPP_RATES_CHANGED;
spin_unlock_bh(&ar->data_lock);
@@ -7522,10 +7536,14 @@ static void ath12k_mac_set_bitrate_mask_iter(void *data,
static void ath12k_mac_disable_peer_fixed_rate(void *data,
struct ieee80211_sta *sta)
{
+ struct ath12k_sta *arsta = ath12k_sta_to_arsta(sta);
struct ath12k_vif *arvif = data;
struct ath12k *ar = arvif->ar;
int ret;

+ if (arsta->arvif != arvif)
+ return;
+
ret = ath12k_wmi_set_peer_param(ar, sta->addr,
arvif->vdev_id,
WMI_PEER_PARAM_FIXED_RATE,
--
2.17.1


2024-01-11 04:52:16

by Sriram R

[permalink] [raw]
Subject: [PATCH 09/12] wifi: ath12k: modify regulatory support for single wiphy architecture

With all the radios being combined and registered as a single
mac80211 hw/wiphy, separate regd built from firmware rules need
not be updated to cfg80211. Rather we can pick one of the regd
built from the rules to update to cfg80211 for the whole
registered device. We prefer 6 GHz pdev based rules since it has
the rules for all bands. If the hw doesn't support 6 GHz, then update
rules from one of the pdevs.

Also, when regulatory notification is received, update to all the
underlying radios/ar so that it becomes aware of the change and as
well us it updates its local regd with the new country rules. Later
pick the appropriate pdev's regd(6 GHz if available) and apply to
cfg80211.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3

Signed-off-by: Sriram R <[email protected]>
---
drivers/net/wireless/ath/ath12k/core.h | 2 +
drivers/net/wireless/ath/ath12k/mac.c | 2 +
drivers/net/wireless/ath/ath12k/reg.c | 60 ++++++++++++++++++++++----
3 files changed, 55 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h
index 883556313fb0..ac7b48cc2e7e 100644
--- a/drivers/net/wireless/ath/ath12k/core.h
+++ b/drivers/net/wireless/ath/ath12k/core.h
@@ -630,6 +630,8 @@ struct ath12k_hw {
struct mutex conf_mutex;

u8 num_radio;
+ bool regd_updated;
+ bool use_6ghz_regd;
struct ath12k radio[] __aligned(sizeof(void *));
};

diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 25d82c6fe89a..2f19d6c5b741 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -7948,6 +7948,7 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar,
struct ath12k_wmi_hal_reg_capabilities_ext_arg *reg_cap;
void *channels;
u32 phy_id;
+ struct ath12k_hw *ah = ar->ah;

BUILD_BUG_ON((ARRAY_SIZE(ath12k_2ghz_channels) +
ARRAY_SIZE(ath12k_5ghz_channels) +
@@ -8000,6 +8001,7 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar,
ath12k_mac_update_ch_list(ar, band,
reg_cap->low_5ghz_chan,
reg_cap->high_5ghz_chan);
+ ah->use_6ghz_regd = true;
}

if (reg_cap->low_5ghz_chan < ATH12K_MIN_6G_FREQ) {
diff --git a/drivers/net/wireless/ath/ath12k/reg.c b/drivers/net/wireless/ath/ath12k/reg.c
index da64482f1024..3a3f66d8ea11 100644
--- a/drivers/net/wireless/ath/ath12k/reg.c
+++ b/drivers/net/wireless/ath/ath12k/reg.c
@@ -50,7 +50,7 @@ ath12k_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request)
struct ath12k_wmi_init_country_arg arg;
struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
struct ath12k *ar = ath12k_ah_to_ar(ah, 0);
- int ret;
+ int ret, i;

ath12k_dbg(ar->ab, ATH12K_DBG_REG,
"Regulatory Notification received for %s\n", wiphy_name(wiphy));
@@ -85,10 +85,17 @@ ath12k_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request)
memcpy(&arg.cc_info.alpha2, request->alpha2, 2);
arg.cc_info.alpha2[2] = 0;

- ret = ath12k_wmi_send_init_country_cmd(ar, &arg);
- if (ret)
- ath12k_warn(ar->ab,
- "INIT Country code set to fw failed : %d\n", ret);
+ /* Allow fresh updates to wiphy regd */
+ ah->regd_updated = false;
+
+ /* Send the reg change request to all the radios */
+ for (i = 0; i < ah->num_radio; i++) {
+ ret = ath12k_wmi_send_init_country_cmd(ar, &arg);
+ if (ret)
+ ath12k_warn(ar->ab,
+ "INIT Country code set to fw failed : %d\n", ret);
+ ar++;
+ }
}

int ath12k_reg_update_chan_list(struct ath12k *ar)
@@ -204,8 +211,31 @@ int ath12k_regd_update(struct ath12k *ar, bool init)
struct ieee80211_regdomain *regd, *regd_copy = NULL;
int ret, regd_len, pdev_id;
struct ath12k_base *ab;
+ struct ath12k_hw *ah;
+ int i;

ab = ar->ab;
+ ah = ar->ah;
+
+ /* If one of the radios within ah has already updated the regd for
+ * the wiphy, then avoid setting regd again
+ */
+ if (ah->regd_updated)
+ return 0;
+
+ /* firmware provides reg rules which are similar for 2 GHz and 5 GHz
+ * pdev but 6 GHz pdev has superset of all rules including rules for
+ * all bands, we prefer 6 GHz pdev's rules to be used for setup of
+ * the wiphy regd.
+ * If 6 GHz pdev was part of the ath12k_hw, wait for the 6 GHz pdev,
+ * else pick the first pdev which calls this function and use its
+ * regd to update global hw regd.
+ * The regd_updated flag set at the end will not allow any further
+ * updates.
+ */
+ if (ah->use_6ghz_regd && !ar->supports_6ghz)
+ return 0;
+
pdev_id = ar->pdev_idx;

spin_lock_bh(&ab->base_lock);
@@ -258,10 +288,22 @@ int ath12k_regd_update(struct ath12k *ar, bool init)
if (ret)
goto err;

- if (ar->state == ATH12K_STATE_ON) {
- ret = ath12k_reg_update_chan_list(ar);
- if (ret)
- goto err;
+ ah->regd_updated = true;
+
+ /* Apply the new regd to all the radios, this is expected to be received only once
+ * since we check for ah->regd_updated and allow here only once
+ */
+ ar = ah->radio;
+ ab = ar->ab;
+
+ for (i = 0; i < ah->num_radio; i++) {
+ if (ar->state == ATH12K_STATE_ON) {
+ ret = ath12k_reg_update_chan_list(ar);
+ if (ret)
+ goto err;
+ }
+ ar++;
+ ab = ar->ab;
}

return 0;
--
2.17.1


2024-01-11 04:52:26

by Sriram R

[permalink] [raw]
Subject: [PATCH 11/12] wifi: ath12k: Modify rts threshold mac op for single wiphy

Since multiple radios are abstracted under a single wiphy,
apply the rts threshold value to all the vdevs of the radios
combined under single wiphy.

This also implies that vif specific rts threshold support
needs to be added in future from cfg80211/mac80211.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3

Signed-off-by: Sriram R <[email protected]>
---
drivers/net/wireless/ath/ath12k/mac.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 00063c783e6c..900741a5f9e3 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -7266,13 +7266,26 @@ static int ath12k_mac_op_set_rts_threshold(struct ieee80211_hw *hw, u32 value)
{
struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
struct ath12k *ar;
- int param_id = WMI_VDEV_PARAM_RTS_THRESHOLD, ret;
+ int param_id = WMI_VDEV_PARAM_RTS_THRESHOLD, ret, i;

mutex_lock(&ah->conf_mutex);

ar = ath12k_ah_to_ar(ah, 0);

- ret = ath12k_set_vdev_param_to_all_vifs(ar, param_id, value);
+ /* Currently we set the rts threshold value to all the vifs across
+ * all radios of the single wiphy.
+ * TODO Once support for vif specific RTS threshold in mac80211 is
+ * available, ath12k can make use of it.
+ */
+ for (i = 0; i < ah->num_radio; i++) {
+ ret = ath12k_set_vdev_param_to_all_vifs(ar, param_id, value);
+ if (ret) {
+ ath12k_warn(ar->ab, "failed to set RTS config for all vdevs of pdev %d",
+ ar->pdev->pdev_id);
+ break;
+ }
+ ar++;
+ }

mutex_unlock(&ah->conf_mutex);

--
2.17.1


2024-01-11 04:52:34

by Sriram R

[permalink] [raw]
Subject: [PATCH 12/12] wifi: ath12k: support get_survey mac op for single wiphy

The radio for which the survey info needs to be collected
depends on the channel idx which could be based on the band.
Use the idx to identify the appropriate sband since multiple
bands could be combined for single wiphy case.

Also use the channel idx and sband to identify the corresponding
radio on which the survey results needs to be populated.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3

Signed-off-by: Sriram R <[email protected]>
---
drivers/net/wireless/ath/ath12k/mac.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 900741a5f9e3..318c4ad20898 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -7827,12 +7827,6 @@ static int ath12k_mac_op_get_survey(struct ieee80211_hw *hw, int idx,

mutex_lock(&ah->conf_mutex);

- ar = ath12k_ah_to_ar(ah, 0);
-
- ar_survey = &ar->survey[idx];
-
- mutex_lock(&ar->conf_mutex);
-
sband = hw->wiphy->bands[NL80211_BAND_2GHZ];
if (sband && idx >= sband->n_channels) {
idx -= sband->n_channels;
@@ -7847,6 +7841,21 @@ static int ath12k_mac_op_get_survey(struct ieee80211_hw *hw, int idx,
goto exit;
}

+ ar = ath12k_mac_get_ar_by_chan(hw, &sband->channels[idx]);
+ if (!ar) {
+ if (sband->channels[idx].flags & IEEE80211_CHAN_DISABLED) {
+ ret = 0;
+ memset(survey, 0, sizeof(*survey));
+ goto exit;
+ }
+ ret = -ENOENT;
+ goto exit;
+ }
+
+ ar_survey = &ar->survey[idx];
+
+ mutex_lock(&ar->conf_mutex);
+
ath12k_mac_update_bss_chan_survey(ar, &sband->channels[idx]);

spin_lock_bh(&ar->data_lock);
@@ -7858,8 +7867,8 @@ static int ath12k_mac_op_get_survey(struct ieee80211_hw *hw, int idx,
if (ar->rx_channel == survey->channel)
survey->filled |= SURVEY_INFO_IN_USE;

-exit:
mutex_unlock(&ar->conf_mutex);
+exit:
mutex_unlock(&ah->conf_mutex);

return ret;
--
2.17.1


2024-01-11 04:53:07

by Sriram R

[permalink] [raw]
Subject: [PATCH 03/12] wifi: ath12k: modify ath12k mac start/stop ops for single wiphy

When mac80211 does drv start/stop, apply the state change
for all the radios within the wiphy in ath12k.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3

Signed-off-by: Sriram R <[email protected]>
---
drivers/net/wireless/ath/ath12k/mac.c | 57 +++++++++++++++++++++------
1 file changed, 45 insertions(+), 12 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 2a70b7a486e3..7933d5993519 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -243,6 +243,7 @@ static const u32 ath12k_smps_map[] = {

static int ath12k_start_vdev_delay(struct ath12k *ar,
struct ath12k_vif *arvif);
+static void ath12k_mac_stop(struct ath12k *ar);

static const char *ath12k_mac_phymode_str(enum wmi_phy_mode mode)
{
@@ -5302,28 +5303,56 @@ static int ath12k_mac_start(struct ath12k *ar)
return ret;
}

+static void ath12k_drain_tx(struct ath12k_hw *ah)
+{
+ int i;
+ struct ath12k *ar;
+
+ ar = ah->radio;
+
+ for (i = 0; i < ah->num_radio; i++) {
+ ath12k_mac_drain_tx(ar);
+ ar++;
+ }
+}
+
static int ath12k_mac_op_start(struct ieee80211_hw *hw)
{
struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
- struct ath12k *ar = ath12k_ah_to_ar(ah, 0);
- struct ath12k_base *ab = ar->ab;
- int ret;
+ struct ath12k *ar;
+ struct ath12k_base *ab;
+ int ret = 0;
+ int i;
+
+ ath12k_drain_tx(ah);

- ath12k_mac_drain_tx(ar);
+ ar = ah->radio;
+ ab = ar->ab;

mutex_lock(&ah->conf_mutex);

- ret = ath12k_mac_start(ar);
- if (ret) {
- ath12k_err(ab, "fail to start mac operations in pdev idx %d ret %d\n",
- ar->pdev_idx, ret);
- mutex_unlock(&ah->conf_mutex);
- return ret;
+ for (i = 0; i < ah->num_radio; i++) {
+ ret = ath12k_mac_start(ar);
+ if (ret) {
+ ath12k_err(ab, "fail to start mac operations in pdev idx %d ret %d\n",
+ ar->pdev_idx, ret);
+ goto fail;
+ }
+ ar++;
+ ab = ar->ab;
}

mutex_unlock(&ah->conf_mutex);

return 0;
+fail:
+ for (; i > 0; i--) {
+ ar--;
+ ath12k_mac_stop(ar);
+ }
+
+ mutex_unlock(&ah->conf_mutex);
+ return ret;
}

int ath12k_mac_rfkill_config(struct ath12k *ar)
@@ -5420,12 +5449,16 @@ static void ath12k_mac_op_stop(struct ieee80211_hw *hw)
{
struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
struct ath12k *ar = ath12k_ah_to_ar(ah, 0);
+ int i;

- ath12k_mac_drain_tx(ar);
+ ath12k_drain_tx(ah);

mutex_lock(&ah->conf_mutex);

- ath12k_mac_stop(ar);
+ for (i = 0; i < ah->num_radio; i++) {
+ ath12k_mac_stop(ar);
+ ar++;
+ }

mutex_unlock(&ah->conf_mutex);
}
--
2.17.1


2024-01-11 04:53:56

by Sriram R

[permalink] [raw]
Subject: [PATCH 10/12] wifi: ath12k: Modify set and get antenna mac ops for single wiphy

As multiple radios are combined into a single wiphy, and
the current infrastructure supports only set/get antenna
for the wiphy, the max Tx/Rx antenna capability is advertised
during wiphy register.
Hence, When antenna set/get is received we adjust the set/get
based on max radio capability and set/get antenna accordingly.

Multi radio capability would get introduced with interface
combination changes to support single wiphy model in cfg80211
which would help extend the wiphy specific get/set configs similar
to this to per hw level.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3

Signed-off-by: Sriram R <[email protected]>
---
drivers/net/wireless/ath/ath12k/mac.c | 41 +++++++++++++++++++--------
1 file changed, 29 insertions(+), 12 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 2f19d6c5b741..00063c783e6c 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -5064,6 +5064,13 @@ static int __ath12k_set_antenna(struct ath12k *ar, u32 tx_ant, u32 rx_ant)
if (ath12k_check_chain_mask(ar, rx_ant, false))
return -EINVAL;

+ /* Since we advertised the max cap of all radios combined during wiphy
+ * registration, ensure we don't set the antenna config higher than our
+ * limits
+ */
+ tx_ant = min_t(u32, tx_ant, ar->pdev->cap.tx_chain_mask);
+ rx_ant = min_t(u32, rx_ant, ar->pdev->cap.rx_chain_mask);
+
ar->cfg_tx_chainmask = tx_ant;
ar->cfg_rx_chainmask = rx_ant;

@@ -6380,21 +6387,25 @@ static void ath12k_mac_op_configure_filter(struct ieee80211_hw *hw,
static int ath12k_mac_op_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant)
{
struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+ int antennas_rx = 0, antennas_tx = 0;
struct ath12k *ar;
+ int i;

mutex_lock(&ah->conf_mutex);

ar = ath12k_ah_to_ar(ah, 0);

- mutex_lock(&ar->conf_mutex);
-
- *tx_ant = ar->cfg_tx_chainmask;
- *rx_ant = ar->cfg_rx_chainmask;
-
- mutex_unlock(&ar->conf_mutex);
-
+ for (i = 0; i < ah->num_radio; i++) {
+ mutex_lock(&ar->conf_mutex);
+ antennas_rx = max_t(u32, antennas_rx, ar->cfg_rx_chainmask);
+ antennas_tx = max_t(u32, antennas_tx, ar->cfg_tx_chainmask);
+ mutex_unlock(&ar->conf_mutex);
+ ar++;
+ }
mutex_unlock(&ah->conf_mutex);

+ *tx_ant = antennas_rx;
+ *rx_ant = antennas_tx;
return 0;
}

@@ -6402,16 +6413,22 @@ static int ath12k_mac_op_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx
{
struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
struct ath12k *ar;
- int ret;
+ int ret = 0;
+ int i;

mutex_lock(&ah->conf_mutex);

ar = ath12k_ah_to_ar(ah, 0);

- mutex_lock(&ar->conf_mutex);
- ret = __ath12k_set_antenna(ar, tx_ant, rx_ant);
- mutex_unlock(&ar->conf_mutex);
-
+ for (i = 0; i < ah->num_radio; i++) {
+ mutex_lock(&ar->conf_mutex);
+ ret = __ath12k_set_antenna(ar, tx_ant, rx_ant);
+ mutex_unlock(&ar->conf_mutex);
+ if (ret)
+ goto out;
+ ar++;
+ }
+out:
mutex_unlock(&ah->conf_mutex);

return ret;
--
2.17.1


2024-01-11 20:16:14

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH 00/12] wifi: ath12k: Add single wiphy support

On 1/10/2024 8:50 PM, Sriram R wrote:
> This patchset is dependent on "[PATCH 0/2] wifi: ath12k: Introduce hw abstraction"

I'm currently unable to apply the prerequisite patches to my workspace,
so I won't be able to review your patches until that is resolved.

/jeff

2024-01-12 04:34:23

by Sriram R

[permalink] [raw]
Subject: RE: [PATCH 00/12] wifi: ath12k: Add single wiphy support

>-----Original Message-----
>From: Jeff Johnson (QUIC) <[email protected]>
>Sent: Friday, January 12, 2024 1:46 AM
>To: Sriram R (QUIC) <[email protected]>; [email protected]
>Cc: [email protected]
>Subject: Re: [PATCH 00/12] wifi: ath12k: Add single wiphy support
>
>On 1/10/2024 8:50 PM, Sriram R wrote:
>> This patchset is dependent on "[PATCH 0/2] wifi: ath12k: Introduce hw
>abstraction"
>
>I'm currently unable to apply the prerequisite patches to my workspace, so I won't
>be able to review your patches until that is resolved.
Sure. I believe its resolved with "[PATCH v2 0/2] wifi: ath12k: Introduce hw abstraction".

Thanks,
Sriram.R

2024-01-12 15:11:53

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH 01/12] wifi: ath12k: add multiple radio support in a single MAC HW un/register

On 1/10/2024 8:50 PM, Sriram R wrote:
> From: Karthikeyan Periyasamy <[email protected]>
>
> Currently MAC HW un/register helper function support the single radio.
> To enable single/multi link operation in the future, the following helper
> functions need to be refactored to accommodate multiple radios under a
> single MAC HW un/register:
>
> * ath12k_ah_to_ar()
> * ath12k_mac_hw_allocate()
> * ath12k_mac_hw_register()
> * ath12k_mac_hw_unregister()
>
> This refactoring will make it easier to scale these functionalities and
> support Multi link operation.
>
> Current Multi wiphy Model
>
> +---------------+ +---------------+ +---------------+
> | Mac80211 hw | | Mac80211 hw | | Mac80211 hw |
> | private data | | private data | | private data |
> | | | | | |
> |ath12k_hw (ah) | |ath12k_hw (ah) | |ath12k_hw (ah) |
> | | | | | |
> | +-----------+ | | +-----------+ | | +-----------+ |
> | | ar (2GHz) | | | | ar (5GHz) | | | | ar (6GHz) | |
> | +-----------+ | | +-----------+ | | +-----------+ |
> | | | | | |
> +---------------+ +---------------+ +---------------+
>
> Single wiphy Model
>
> +--------------+
> | Mac80211 hw |
> | private data |
> | |
> |ath12k hw (ah)|
> | +----------+ |
> | |ar (2GHz) | |
> | +----------+ |
> | |ar (5GHz) | |
> | +----------+ |
> | |ar (6GHz) | |
> | +----------+ |
> +--------------+
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
>
> Signed-off-by: Karthikeyan Periyasamy <[email protected]>

All the patches you repost that were authored by others need your S-O-B.


2024-01-12 16:44:33

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH 00/12] wifi: ath12k: Add single wiphy support

On 1/11/2024 8:34 PM, Sriram R (QUIC) wrote:
>> -----Original Message-----
>> From: Jeff Johnson (QUIC) <[email protected]>
>> Sent: Friday, January 12, 2024 1:46 AM
>> To: Sriram R (QUIC) <[email protected]>; [email protected]
>> Cc: [email protected]
>> Subject: Re: [PATCH 00/12] wifi: ath12k: Add single wiphy support
>>
>> On 1/10/2024 8:50 PM, Sriram R wrote:
>>> This patchset is dependent on "[PATCH 0/2] wifi: ath12k: Introduce hw
>> abstraction"
>>
>> I'm currently unable to apply the prerequisite patches to my workspace, so I won't
>> be able to review your patches until that is resolved.
> Sure. I believe its resolved with "[PATCH v2 0/2] wifi: ath12k: Introduce hw abstraction".

Yes, I have now processed the prerequisite patchset, and your patchset
applies cleanly on top of that.

As already mentioned you need to add your S-O-B to all patches that you
are posting on behalf of others. But let me review the individual
patches to make sure I don't have any other comments before you re-spin.

/jeff


2024-01-12 17:03:15

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH 01/12] wifi: ath12k: add multiple radio support in a single MAC HW un/register

On 1/10/2024 8:50 PM, Sriram R wrote:
...

> @@ -7553,10 +7553,12 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar,
>
> static u16 ath12k_mac_get_ifmodes(struct ath12k_hw *ah)
> {
> - struct ath12k *ar = ath12k_ah_to_ar(ah);
> + struct ath12k *ar;
> + int i;
> u16 interface_modes = U16_MAX;
>
> - interface_modes &= ar->ab->hw_params->interface_modes;
> + for_each_ar(i, ah, ar)
> + interface_modes &= ar->ab->hw_params->interface_modes;

This logic sets interface_modes to be the modes that are supported on
every radio (starts with all modes supported and then masks off the ones
that are not supported on a given radio). That means that if radio 0
supports a mode that radio 1 does not support, then we don't advertise
support for that mode. Just want to verify that is the correct logic,
and that instead we don't want to start with no modes supported and then
OR in the ones that are supported so that we get the list of modes that
are supported on ANY radio instead of ALL radios.

>
> return interface_modes == U16_MAX ? 0 : interface_modes;
> }
> @@ -7564,15 +7566,19 @@ static u16 ath12k_mac_get_ifmodes(struct ath12k_hw *ah)
> static bool ath12k_mac_is_iface_mode_enable(struct ath12k_hw *ah,
> enum nl80211_iftype type)
> {
> - struct ath12k *ar = ath12k_ah_to_ar(ah);
> + struct ath12k *ar;
> + int i;
> u16 interface_modes, mode;
> bool is_enable = true;
>
> mode = BIT(type);
> -
> - interface_modes = ar->ab->hw_params->interface_modes;
> - if (!(interface_modes & mode))
> - is_enable = false;
> + for_each_ar(i, ah, ar) {
> + interface_modes = ar->ab->hw_params->interface_modes;
> + if (!(interface_modes & mode)) {
> + is_enable = false;

note that in the example I mentioned above, this logic could say a given
mode is enabled even though the bit isn't set in the interface_modes
listed above

> + break;
> + }
> + }
>
> return is_enable;


2024-01-12 17:06:35

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH 02/12] wifi: ath12k: Modify add and remove chanctx ops for single wiphy support

On 1/10/2024 8:50 PM, Sriram R wrote:
> Modify add and remove chanctx mac80211 ops to fetch the correct
> radio(ar) based on channel context.
>
> This change also introduces new helper function to fetch the
> radio/ar based on channel context and ieee80211_chan which internally
> uses the radio's low/high freq range.
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
>
> Signed-off-by: Sriram R <[email protected]>
Acked-by: Jeff Johnson <[email protected]>


2024-01-12 17:07:47

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH 03/12] wifi: ath12k: modify ath12k mac start/stop ops for single wiphy

On 1/10/2024 8:50 PM, Sriram R wrote:
> When mac80211 does drv start/stop, apply the state change
> for all the radios within the wiphy in ath12k.
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
>
> Signed-off-by: Sriram R <[email protected]>
Acked-by: Jeff Johnson <[email protected]>



2024-01-12 17:11:30

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH 04/12] wifi: ath12k: vdev statemachine changes for single wiphy

On 1/10/2024 8:50 PM, Sriram R wrote:
> With single wiphy, multiple radios are combined into a single wiphy.
> Since any channel can be assigned to a vif being brought up,
> the vdev cannot be created during add_interface(). Hence defer the
> vdev creation till channel assignment.
>
> If only one radio is part of the wiphy, then the existing logic
> is maintained, i.e vdevs are created during add interface and
> started during channel assignment. This ensures no functional changes
> to single pdev devices which has only one radio in the SoC.
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
>
> Signed-off-by: Sriram R <[email protected]>
Acked-by: Jeff Johnson <[email protected]>


2024-01-12 17:14:18

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH 05/12] wifi: ath12k: scan statemachine changes for single wiphy

On 1/10/2024 8:50 PM, Sriram R wrote:
> When multiple radios are advertised as a single wiphy which
> supports various bands, a default scan request to mac80211
> from cfg80211 will split the driver request based on band,
> so each request will have channels belonging to the same band.
> With this supported by default, the ath12k driver on receiving
> this request checks for one of the channels in the request and
> selects the corresponding radio(ar) on which the scan is going
> to be performed and creates a vdev on that radio.
>
> Note that on scan completion this vdev is not deleted. If a new
> scan request is seen on that same vif for a different band the
> vdev will be deleted and created on the new radio supporting the
> request. The vdev delete logic is refactored to have this done
> dynamically.
>
> The reason for not deleting the vdev on scan stop is to avoid
> repeated delete-create sequence if the scan is on the same band.
> Also, during channel assign, new vdev creation can be optimized
> as well.
>
> Also if the scan is requested when the vdev is in started state,
> no switching to new radio is allowed and scan on channels only
> within same radio is allowed.
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
>
> Signed-off-by: Sriram R <[email protected]>
Acked-by: Jeff Johnson <[email protected]>



2024-01-12 17:15:48

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH 06/12] wifi: ath12k: fetch correct radio based on vdev status

On 1/10/2024 8:50 PM, Sriram R wrote:
> For ops which passes the vif info, fetch the radio(ar)
> to be used for corresponding functions based on the
> the vdev creation status. If the vdev is not created yet,
> which could happen when the ops are called before channel
> is assigned for the vif, the data needs to be cached and this
> is done in followup changes.
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
>
> Signed-off-by: Sriram R <[email protected]>
Acked-by: Jeff Johnson <[email protected]>


2024-01-12 17:24:12

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH 07/12] wifi: ath12k: Cache vdev configs before vdev create

On 1/10/2024 8:50 PM, Sriram R wrote:
> Since the vdev create for a corresponding vif is deferred
> until a channel is assigned, cache the information which
> are received through mac80211 ops between add_interface()
> and assign_vif_chanctx() and set them once the vdev is
> created on one of the ath12k radios as the channel gets
> assigned via assign_vif_chanctx().
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
>
> Signed-off-by: Sriram R <[email protected]>
> ---
...
> +static int ath12k_mac_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
> + struct ieee80211_vif *vif, struct ieee80211_sta *sta,
> + struct ieee80211_key_conf *key)
> +{
> + struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
> + struct ath12k *ar;
> + struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
> + int ret;
> +
> + /* BIP needs to be done in software */
> + if (key->cipher == WLAN_CIPHER_SUITE_AES_CMAC ||
> + key->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_128 ||
> + key->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_256 ||
> + key->cipher == WLAN_CIPHER_SUITE_BIP_CMAC_256)
> + return 1;

I know this in the existing code, but what is the significance of
returning 1? Should this be returning a -errno like the error cases that
follow?

> +
> + if (key->keyidx > WMI_MAX_KEY_INDEX)
> + return -ENOSPC;
> +
> + mutex_lock(&ah->conf_mutex);
> +
> + ar = ath12k_get_ar_by_vif(hw, vif);
> + if (!ar) {
> + /* ar is expected to be valid when sta ptr is available */
> + if (sta) {
> + mutex_unlock(&ah->conf_mutex);
> + WARN_ON_ONCE(1);
> + return -EINVAL;
> + }
> + arvif->cache.key_conf.cmd = cmd;
> + arvif->cache.key_conf.key = key;
> + arvif->cache.key_conf.changed = true;
> + mutex_unlock(&ah->conf_mutex);
> + return 0;
> + }
> +
> + mutex_lock(&ar->conf_mutex);
> + ret = ath12k_mac_set_key(ar, cmd, vif, sta, key);
> mutex_unlock(&ar->conf_mutex);
> +
> mutex_unlock(&ah->conf_mutex);
> return ret;
> }


2024-01-12 17:26:43

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH 08/12] wifi: ath12k: Add additional checks for vif and sta iterators

On 1/10/2024 8:50 PM, Sriram R wrote:
> Since vif and sta objects of different radios are added to same
> local hw list in mac80211, additional checks need to be done
> in driver to ensure we are processing the intended vif
> and sta corresponding to the radio when the vif and sta mac80211
> iterator utils are used from driver.
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
>
> Signed-off-by: Sriram R <[email protected]>
Acked-by: Jeff Johnson <[email protected]>


2024-01-12 18:16:01

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH 09/12] wifi: ath12k: modify regulatory support for single wiphy architecture

On 1/10/2024 8:50 PM, Sriram R wrote:
> With all the radios being combined and registered as a single
> mac80211 hw/wiphy, separate regd built from firmware rules need
> not be updated to cfg80211. Rather we can pick one of the regd
> built from the rules to update to cfg80211 for the whole
> registered device. We prefer 6 GHz pdev based rules since it has
> the rules for all bands. If the hw doesn't support 6 GHz, then update
> rules from one of the pdevs.

Do you need to handle the case where there are multiple instances of
hardware that have divergent regds? I'm thinking of a case where there
are 3 underlying hardware platforms, one that is 2 GHz, one that is 5
GHz, and one that is 6 GHz, and each of them has a regd that only has
the rules for the supported band. In such a case wouldn't you need to
aggregate the rules in the wiphy, not just pick one of the sets of rules?

If that is not an expected case, ideally you should describe the
requirements & assumptions that are in play here.

>
> Also, when regulatory notification is received, update to all the
> underlying radios/ar so that it becomes aware of the change and as
> well us it updates its local regd with the new country rules. Later
> pick the appropriate pdev's regd(6 GHz if available) and apply to
> cfg80211.

Here again, can you elaborate on the requirements and assumptions? Do
you update all channels to each hardware, even if each hardware only
supports a single band?

>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
>
> Signed-off-by: Sriram R <[email protected]>
> ---
> drivers/net/wireless/ath/ath12k/core.h | 2 +
> drivers/net/wireless/ath/ath12k/mac.c | 2 +
> drivers/net/wireless/ath/ath12k/reg.c | 60 ++++++++++++++++++++++----
> 3 files changed, 55 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h
> index 883556313fb0..ac7b48cc2e7e 100644
> --- a/drivers/net/wireless/ath/ath12k/core.h
> +++ b/drivers/net/wireless/ath/ath12k/core.h
> @@ -630,6 +630,8 @@ struct ath12k_hw {
> struct mutex conf_mutex;
>
> u8 num_radio;
> + bool regd_updated;
> + bool use_6ghz_regd;
> struct ath12k radio[] __aligned(sizeof(void *));
> };
>
> diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
> index 25d82c6fe89a..2f19d6c5b741 100644
> --- a/drivers/net/wireless/ath/ath12k/mac.c
> +++ b/drivers/net/wireless/ath/ath12k/mac.c
> @@ -7948,6 +7948,7 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar,
> struct ath12k_wmi_hal_reg_capabilities_ext_arg *reg_cap;
> void *channels;
> u32 phy_id;
> + struct ath12k_hw *ah = ar->ah;
>
> BUILD_BUG_ON((ARRAY_SIZE(ath12k_2ghz_channels) +
> ARRAY_SIZE(ath12k_5ghz_channels) +
> @@ -8000,6 +8001,7 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar,
> ath12k_mac_update_ch_list(ar, band,
> reg_cap->low_5ghz_chan,
> reg_cap->high_5ghz_chan);
> + ah->use_6ghz_regd = true;
> }
>
> if (reg_cap->low_5ghz_chan < ATH12K_MIN_6G_FREQ) {
> diff --git a/drivers/net/wireless/ath/ath12k/reg.c b/drivers/net/wireless/ath/ath12k/reg.c
> index da64482f1024..3a3f66d8ea11 100644
> --- a/drivers/net/wireless/ath/ath12k/reg.c
> +++ b/drivers/net/wireless/ath/ath12k/reg.c
> @@ -50,7 +50,7 @@ ath12k_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request)
> struct ath12k_wmi_init_country_arg arg;
> struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
> struct ath12k *ar = ath12k_ah_to_ar(ah, 0);
> - int ret;
> + int ret, i;
>
> ath12k_dbg(ar->ab, ATH12K_DBG_REG,
> "Regulatory Notification received for %s\n", wiphy_name(wiphy));
> @@ -85,10 +85,17 @@ ath12k_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request)
> memcpy(&arg.cc_info.alpha2, request->alpha2, 2);
> arg.cc_info.alpha2[2] = 0;
>
> - ret = ath12k_wmi_send_init_country_cmd(ar, &arg);
> - if (ret)
> - ath12k_warn(ar->ab,
> - "INIT Country code set to fw failed : %d\n", ret);
> + /* Allow fresh updates to wiphy regd */
> + ah->regd_updated = false;
> +
> + /* Send the reg change request to all the radios */
> + for (i = 0; i < ah->num_radio; i++) {
> + ret = ath12k_wmi_send_init_country_cmd(ar, &arg);
> + if (ret)
> + ath12k_warn(ar->ab,
> + "INIT Country code set to fw failed : %d\n", ret);
> + ar++;
> + }
> }
>
> int ath12k_reg_update_chan_list(struct ath12k *ar)
> @@ -204,8 +211,31 @@ int ath12k_regd_update(struct ath12k *ar, bool init)
> struct ieee80211_regdomain *regd, *regd_copy = NULL;
> int ret, regd_len, pdev_id;
> struct ath12k_base *ab;
> + struct ath12k_hw *ah;
> + int i;
>
> ab = ar->ab;
> + ah = ar->ah;
> +
> + /* If one of the radios within ah has already updated the regd for
> + * the wiphy, then avoid setting regd again
> + */
> + if (ah->regd_updated)
> + return 0;
> +
> + /* firmware provides reg rules which are similar for 2 GHz and 5 GHz
> + * pdev but 6 GHz pdev has superset of all rules including rules for
> + * all bands, we prefer 6 GHz pdev's rules to be used for setup of
> + * the wiphy regd.
> + * If 6 GHz pdev was part of the ath12k_hw, wait for the 6 GHz pdev,
> + * else pick the first pdev which calls this function and use its
> + * regd to update global hw regd.
> + * The regd_updated flag set at the end will not allow any further
> + * updates.
> + */
> + if (ah->use_6ghz_regd && !ar->supports_6ghz)
> + return 0;
> +
> pdev_id = ar->pdev_idx;
>
> spin_lock_bh(&ab->base_lock);
> @@ -258,10 +288,22 @@ int ath12k_regd_update(struct ath12k *ar, bool init)
> if (ret)
> goto err;
>
> - if (ar->state == ATH12K_STATE_ON) {
> - ret = ath12k_reg_update_chan_list(ar);
> - if (ret)
> - goto err;
> + ah->regd_updated = true;
> +
> + /* Apply the new regd to all the radios, this is expected to be received only once
> + * since we check for ah->regd_updated and allow here only once
> + */
> + ar = ah->radio;
> + ab = ar->ab;
> +
> + for (i = 0; i < ah->num_radio; i++) {
> + if (ar->state == ATH12K_STATE_ON) {
> + ret = ath12k_reg_update_chan_list(ar);
> + if (ret)
> + goto err;
> + }
> + ar++;
> + ab = ar->ab;
> }
>
> return 0;


2024-01-12 18:25:43

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH 10/12] wifi: ath12k: Modify set and get antenna mac ops for single wiphy

On 1/10/2024 8:50 PM, Sriram R wrote:
> As multiple radios are combined into a single wiphy, and
> the current infrastructure supports only set/get antenna
> for the wiphy, the max Tx/Rx antenna capability is advertised
> during wiphy register.
> Hence, When antenna set/get is received we adjust the set/get
> based on max radio capability and set/get antenna accordingly.
>
> Multi radio capability would get introduced with interface

Since this multi-radio capability is not part of the current series, I
don't think it is correct to say this "would get introduced". Rather, I
think it is more appropriate to say it "would need to be introduced in
the future" if you want per-radio configuration

> combination changes to support single wiphy model in cfg80211
> which would help extend the wiphy specific get/set configs similar
> to this to per hw level.
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
>
> Signed-off-by: Sriram R <[email protected]>
> ---
> drivers/net/wireless/ath/ath12k/mac.c | 41 +++++++++++++++++++--------
> 1 file changed, 29 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
> index 2f19d6c5b741..00063c783e6c 100644
> --- a/drivers/net/wireless/ath/ath12k/mac.c
> +++ b/drivers/net/wireless/ath/ath12k/mac.c
> @@ -5064,6 +5064,13 @@ static int __ath12k_set_antenna(struct ath12k *ar, u32 tx_ant, u32 rx_ant)
> if (ath12k_check_chain_mask(ar, rx_ant, false))
> return -EINVAL;
>
> + /* Since we advertised the max cap of all radios combined during wiphy
> + * registration, ensure we don't set the antenna config higher than our
> + * limits

*specific radio* limits

> + */
> + tx_ant = min_t(u32, tx_ant, ar->pdev->cap.tx_chain_mask);
> + rx_ant = min_t(u32, rx_ant, ar->pdev->cap.rx_chain_mask);
> +
> ar->cfg_tx_chainmask = tx_ant;
> ar->cfg_rx_chainmask = rx_ant;
>
> @@ -6380,21 +6387,25 @@ static void ath12k_mac_op_configure_filter(struct ieee80211_hw *hw,
> static int ath12k_mac_op_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant)
> {
> struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
> + int antennas_rx = 0, antennas_tx = 0;
> struct ath12k *ar;
> + int i;
>
> mutex_lock(&ah->conf_mutex);
>
> ar = ath12k_ah_to_ar(ah, 0);
>
> - mutex_lock(&ar->conf_mutex);
> -
> - *tx_ant = ar->cfg_tx_chainmask;
> - *rx_ant = ar->cfg_rx_chainmask;
> -
> - mutex_unlock(&ar->conf_mutex);
> -
> + for (i = 0; i < ah->num_radio; i++) {
> + mutex_lock(&ar->conf_mutex);
> + antennas_rx = max_t(u32, antennas_rx, ar->cfg_rx_chainmask);
> + antennas_tx = max_t(u32, antennas_tx, ar->cfg_tx_chainmask);
> + mutex_unlock(&ar->conf_mutex);
> + ar++;
> + }
> mutex_unlock(&ah->conf_mutex);
>
> + *tx_ant = antennas_rx;
> + *rx_ant = antennas_tx;
> return 0;
> }
>
> @@ -6402,16 +6413,22 @@ static int ath12k_mac_op_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx
> {
> struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
> struct ath12k *ar;
> - int ret;
> + int ret = 0;
> + int i;
>
> mutex_lock(&ah->conf_mutex);
>
> ar = ath12k_ah_to_ar(ah, 0);
>
> - mutex_lock(&ar->conf_mutex);
> - ret = __ath12k_set_antenna(ar, tx_ant, rx_ant);
> - mutex_unlock(&ar->conf_mutex);
> -
> + for (i = 0; i < ah->num_radio; i++) {
> + mutex_lock(&ar->conf_mutex);
> + ret = __ath12k_set_antenna(ar, tx_ant, rx_ant);
> + mutex_unlock(&ar->conf_mutex);
> + if (ret)
> + goto out;
> + ar++;
> + }
> +out:
> mutex_unlock(&ah->conf_mutex);
>
> return ret;
Since I just have documentation nits:

Acked-by: Jeff Johnson <[email protected]>


2024-01-12 18:26:24

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH 11/12] wifi: ath12k: Modify rts threshold mac op for single wiphy

On 1/10/2024 8:50 PM, Sriram R wrote:
> Since multiple radios are abstracted under a single wiphy,
> apply the rts threshold value to all the vdevs of the radios
> combined under single wiphy.
>
> This also implies that vif specific rts threshold support
> needs to be added in future from cfg80211/mac80211.
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
>
> Signed-off-by: Sriram R <[email protected]>
Acked-by: Jeff Johnson <[email protected]>


2024-01-12 18:27:01

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH 12/12] wifi: ath12k: support get_survey mac op for single wiphy

On 1/10/2024 8:50 PM, Sriram R wrote:
> The radio for which the survey info needs to be collected
> depends on the channel idx which could be based on the band.
> Use the idx to identify the appropriate sband since multiple
> bands could be combined for single wiphy case.
>
> Also use the channel idx and sband to identify the corresponding
> radio on which the survey results needs to be populated.
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
>
> Signed-off-by: Sriram R <[email protected]>
Acked-by: Jeff Johnson <[email protected]>


2024-01-12 18:30:28

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH 00/12] wifi: ath12k: Add single wiphy support

On 1/12/2024 8:44 AM, Jeff Johnson wrote:
> On 1/11/2024 8:34 PM, Sriram R (QUIC) wrote:
>>> -----Original Message-----
>>> From: Jeff Johnson (QUIC) <[email protected]>
>>> Sent: Friday, January 12, 2024 1:46 AM
>>> To: Sriram R (QUIC) <[email protected]>; [email protected]
>>> Cc: [email protected]
>>> Subject: Re: [PATCH 00/12] wifi: ath12k: Add single wiphy support
>>>
>>> On 1/10/2024 8:50 PM, Sriram R wrote:
>>>> This patchset is dependent on "[PATCH 0/2] wifi: ath12k: Introduce hw
>>> abstraction"
>>>
>>> I'm currently unable to apply the prerequisite patches to my workspace, so I won't
>>> be able to review your patches until that is resolved.
>> Sure. I believe its resolved with "[PATCH v2 0/2] wifi: ath12k: Introduce hw abstraction".
>
> Yes, I have now processed the prerequisite patchset, and your patchset
> applies cleanly on top of that.
>
> As already mentioned you need to add your S-O-B to all patches that you
> are posting on behalf of others. But let me review the individual
> patches to make sure I don't have any other comments before you re-spin.

OK, I've reviewed the series. You are now free to incorporate the
requested changes and to post a v2. Please include my Acked-by: Jeff
Johnson <[email protected]> on all of the patches where I have
already supplied it on the mailing list.

/jeff





2024-01-13 09:44:44

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH 07/12] wifi: ath12k: Cache vdev configs before vdev create

Jeff Johnson <[email protected]> writes:

>> +static int ath12k_mac_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
>> + struct ieee80211_vif *vif, struct ieee80211_sta *sta,
>> + struct ieee80211_key_conf *key)
>> +{
>> + struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
>> + struct ath12k *ar;
>> + struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
>> + int ret;
>> +
>> + /* BIP needs to be done in software */
>> + if (key->cipher == WLAN_CIPHER_SUITE_AES_CMAC ||
>> + key->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_128 ||
>> + key->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_256 ||
>> + key->cipher == WLAN_CIPHER_SUITE_BIP_CMAC_256)
>> + return 1;
>
> I know this in the existing code, but what is the significance of
> returning 1? Should this be returning a -errno like the error cases that
> follow?

It's to use software encryption, from mac80211.h:

* Note that in the case that the @IEEE80211_HW_SW_CRYPTO_CONTROL flag is
* set, mac80211 will not automatically fall back to software crypto if
* enabling hardware crypto failed. The set_key() call may also return the
* value 1 to permit this specific key/algorithm to be done in software.

Yeah, this is confusing. IMHO there should be a define or an enum for
this value.

--
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

2024-01-15 07:53:43

by Sriram R

[permalink] [raw]
Subject: RE: [PATCH 09/12] wifi: ath12k: modify regulatory support for single wiphy architecture

>-----Original Message-----
>From: Jeff Johnson (QUIC) <[email protected]>
>Sent: Friday, January 12, 2024 11:46 PM
>To: Sriram R (QUIC) <[email protected]>; [email protected]
>Cc: [email protected]
>Subject: Re: [PATCH 09/12] wifi: ath12k: modify regulatory support for single wiphy
>architecture
>
>On 1/10/2024 8:50 PM, Sriram R wrote:
>> With all the radios being combined and registered as a single
>> mac80211 hw/wiphy, separate regd built from firmware rules need not be
>> updated to cfg80211. Rather we can pick one of the regd built from the
>> rules to update to cfg80211 for the whole registered device. We prefer
>> 6 GHz pdev based rules since it has the rules for all bands. If the hw
>> doesn't support 6 GHz, then update rules from one of the pdevs.
>
>Do you need to handle the case where there are multiple instances of hardware
>that have divergent regds? I'm thinking of a case where there are 3 underlying
>hardware platforms, one that is 2 GHz, one that is 5 GHz, and one that is 6 GHz, and
>each of them has a regd that only has the rules for the supported band. In such a
>case wouldn't you need to aggregate the rules in the wiphy, not just pick one of the
>sets of rules?
>
>If that is not an expected case, ideally you should describe the requirements &
>assumptions that are in play here.
This is not an expected case with our understanding and testing so far. The 2GHz and 5GHz radio FW
would pass the regd comprising both 2GHz, 5GHz. The 6GHz FW is passing all of them - 2,5,6GHz, hence
the need to club all the regd info separately is not required. I will make this assumption clear in the next revision.
>
>>
>> Also, when regulatory notification is received, update to all the
>> underlying radios/ar so that it becomes aware of the change and as
>> well us it updates its local regd with the new country rules. Later
>> pick the appropriate pdev's regd(6 GHz if available) and apply to
>> cfg80211.
>
>Here again, can you elaborate on the requirements and assumptions? Do you
>update all channels to each hardware, even if each hardware only supports a
>single band?
By update during reg_notifier here we mean the country code alone to each of the FW
and the channel list update on receiving the regd would update only the corresponding
supported channels to the respective FW and not the combined list.

Thanks,
Sriram.R

2024-01-16 04:46:15

by Karthikeyan Periyasamy

[permalink] [raw]
Subject: Re: [PATCH 01/12] wifi: ath12k: add multiple radio support in a single MAC HW un/register


On 1/12/2024 10:33 PM, Jeff Johnson wrote:
> On 1/10/2024 8:50 PM, Sriram R wrote:
> ...
>
>> @@ -7553,10 +7553,12 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar,
>>
>> static u16 ath12k_mac_get_ifmodes(struct ath12k_hw *ah)
>> {
>> - struct ath12k *ar = ath12k_ah_to_ar(ah);
>> + struct ath12k *ar;
>> + int i;
>> u16 interface_modes = U16_MAX;
>>
>> - interface_modes &= ar->ab->hw_params->interface_modes;
>> + for_each_ar(i, ah, ar)
>> + interface_modes &= ar->ab->hw_params->interface_modes;
> This logic sets interface_modes to be the modes that are supported on
> every radio (starts with all modes supported and then masks off the ones
> that are not supported on a given radio). That means that if radio 0
> supports a mode that radio 1 does not support, then we don't advertise
> support for that mode. Just want to verify that is the correct logic,
> and that instead we don't want to start with no modes supported and then
> OR in the ones that are supported so that we get the list of modes that
> are supported on ANY radio instead of ALL radios.


Yes, interface_modes to be the modes that are supported on every radio
not any radio.

Any radio support can be add in the future ath12k driver once the hw
specific interface mode support is added in mac80211/cfg80211.


>>
>> return interface_modes == U16_MAX ? 0 : interface_modes;
>> }
>> @@ -7564,15 +7566,19 @@ static u16 ath12k_mac_get_ifmodes(struct ath12k_hw *ah)
>> static bool ath12k_mac_is_iface_mode_enable(struct ath12k_hw *ah,
>> enum nl80211_iftype type)
>> {
>> - struct ath12k *ar = ath12k_ah_to_ar(ah);
>> + struct ath12k *ar;
>> + int i;
>> u16 interface_modes, mode;
>> bool is_enable = true;
>>
>> mode = BIT(type);
>> -
>> - interface_modes = ar->ab->hw_params->interface_modes;
>> - if (!(interface_modes & mode))
>> - is_enable = false;
>> + for_each_ar(i, ah, ar) {
>> + interface_modes = ar->ab->hw_params->interface_modes;
>> + if (!(interface_modes & mode)) {
>> + is_enable = false;
> note that in the example I mentioned above, this logic could say a given
> mode is enabled even though the bit isn't set in the interface_modes
> listed above


The condition check "if (!(interface_modes & mode))" become true when
the the bit isn't set in the interface_modes. So no issues.


Thanks,

Karthikeyan