Skip to content

Commit

Permalink
wifi: ath12k: Refactor the mac80211 hw access from link/radio
Browse files Browse the repository at this point in the history
Currently, mac80211 hardware accesses link/radio structure directly in
multiple locations. Introduce helper function to avoid this direct
access, as this change will facilitate refactoring for Multi-link
operation support.

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 <quic_periyasa@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://msgid.link/20240118010320.3918136-2-quic_periyasa@quicinc.com
  • Loading branch information
Karthikeyan Periyasamy authored and Kalle Valo committed Jan 19, 2024
1 parent 955df16 commit b856f02
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 44 deletions.
10 changes: 6 additions & 4 deletions drivers/net/wireless/ath/ath12k/core.c
Original file line number Diff line number Diff line change
@@ -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.
*/

#include <linux/module.h>
Expand Down Expand Up @@ -879,6 +879,7 @@ static void ath12k_rfkill_work(struct work_struct *work)
{
struct ath12k_base *ab = container_of(work, struct ath12k_base, rfkill_work);
struct ath12k *ar;
struct ieee80211_hw *hw;
bool rfkill_radio_on;
int i;

Expand All @@ -891,8 +892,9 @@ static void ath12k_rfkill_work(struct work_struct *work)
if (!ar)
continue;

hw = ath12k_ar_to_hw(ar);
ath12k_mac_rfkill_enable_radio(ar, rfkill_radio_on);
wiphy_rfkill_set_hw_state(ar->hw->wiphy, !rfkill_radio_on);
wiphy_rfkill_set_hw_state(hw->wiphy, !rfkill_radio_on);
}
}

Expand Down Expand Up @@ -936,7 +938,7 @@ static void ath12k_core_pre_reconfigure_recovery(struct ath12k_base *ab)
if (!ar || ar->state == ATH12K_STATE_OFF)
continue;

ieee80211_stop_queues(ar->hw);
ieee80211_stop_queues(ath12k_ar_to_hw(ar));
ath12k_mac_drain_tx(ar);
complete(&ar->scan.started);
complete(&ar->scan.completed);
Expand Down Expand Up @@ -976,7 +978,7 @@ static void ath12k_core_post_reconfigure_recovery(struct ath12k_base *ab)
case ATH12K_STATE_ON:
ar->state = ATH12K_STATE_RESTARTING;
ath12k_core_halt(ar);
ieee80211_restart_hw(ar->hw);
ieee80211_restart_hw(ath12k_ar_to_hw(ar));
break;
case ATH12K_STATE_OFF:
ath12k_warn(ab,
Expand Down
6 changes: 5 additions & 1 deletion drivers/net/wireless/ath/ath12k/core.h
Original file line number Diff line number Diff line change
@@ -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_CORE_H
Expand Down Expand Up @@ -896,4 +896,8 @@ static inline const char *ath12k_bus_str(enum ath12k_bus bus)
return "unknown";
}

static inline struct ieee80211_hw *ath12k_ar_to_hw(struct ath12k *ar)
{
return ar->hw;
}
#endif /* _CORE_H_ */
4 changes: 2 additions & 2 deletions drivers/net/wireless/ath/ath12k/dp_mon.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: BSD-3-Clause-Clear
/*
* Copyright (c) 2019-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.
*/

#include "dp_mon.h"
Expand Down Expand Up @@ -1130,7 +1130,7 @@ static void ath12k_dp_mon_rx_deliver_msdu(struct ath12k *ar, struct napi_struct
!(is_mcbc && rx_status->flag & RX_FLAG_DECRYPTED))
rx_status->flag |= RX_FLAG_8023;

ieee80211_rx_napi(ar->hw, pubsta, msdu, napi);
ieee80211_rx_napi(ath12k_ar_to_hw(ar), pubsta, msdu, napi);
}

static int ath12k_dp_mon_rx_deliver(struct ath12k *ar, u32 mac_id,
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/wireless/ath/ath12k/dp_rx.c
Original file line number Diff line number Diff line change
@@ -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.
*/

#include <linux/ieee80211.h>
Expand Down Expand Up @@ -2458,7 +2458,7 @@ static void ath12k_dp_rx_deliver_msdu(struct ath12k *ar, struct napi_struct *nap
!(is_mcbc && rx_status->flag & RX_FLAG_DECRYPTED))
rx_status->flag |= RX_FLAG_8023;

ieee80211_rx_napi(ar->hw, pubsta, msdu, napi);
ieee80211_rx_napi(ath12k_ar_to_hw(ar), pubsta, msdu, napi);
}

static int ath12k_dp_rx_process_msdu(struct ath12k *ar,
Expand Down Expand Up @@ -2844,7 +2844,7 @@ static int ath12k_dp_rx_h_verify_tkip_mic(struct ath12k *ar, struct ath12k_peer
ath12k_dp_rx_h_ppdu(ar, rx_desc, rxs);
ath12k_dp_rx_h_undecap(ar, msdu, rx_desc,
HAL_ENCRYPT_TYPE_TKIP_MIC, rxs, true);
ieee80211_rx(ar->hw, msdu);
ieee80211_rx(ath12k_ar_to_hw(ar), msdu);
return -EINVAL;
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wireless/ath/ath12k/dp_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ ath12k_dp_tx_htt_tx_complete_buf(struct ath12k_base *ab,
}
}

ieee80211_tx_status_skb(ar->hw, msdu);
ieee80211_tx_status_skb(ath12k_ar_to_hw(ar), msdu);
}

static void
Expand Down Expand Up @@ -498,7 +498,7 @@ static void ath12k_dp_tx_complete_msdu(struct ath12k *ar,
* Might end up reporting it out-of-band from HTT stats.
*/

ieee80211_tx_status_skb(ar->hw, msdu);
ieee80211_tx_status_skb(ath12k_ar_to_hw(ar), msdu);

exit:
rcu_read_unlock();
Expand Down
51 changes: 29 additions & 22 deletions drivers/net/wireless/ath/ath12k/mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ struct ath12k_vif *ath12k_mac_get_arvif(struct ath12k *ar, u32 vdev_id)
arvif_iter.vdev_id = vdev_id;

flags = IEEE80211_IFACE_ITER_RESUME_ALL;
ieee80211_iterate_active_interfaces_atomic(ar->hw,
ieee80211_iterate_active_interfaces_atomic(ath12k_ar_to_hw(ar),
flags,
ath12k_get_arvif_iter,
&arvif_iter);
Expand Down Expand Up @@ -1040,7 +1040,7 @@ static int ath12k_mac_monitor_start(struct ath12k *ar)
if (ar->monitor_started)
return 0;

ieee80211_iter_chan_contexts_atomic(ar->hw,
ieee80211_iter_chan_contexts_atomic(ath12k_ar_to_hw(ar),
ath12k_mac_get_any_chandef_iter,
&chandef);
if (!chandef)
Expand Down Expand Up @@ -1085,7 +1085,7 @@ static int ath12k_mac_monitor_stop(struct ath12k *ar)

static int ath12k_mac_config(struct ath12k *ar, u32 changed)
{
struct ieee80211_hw *hw = ar->hw;
struct ieee80211_hw *hw = ath12k_ar_to_hw(ar);
struct ieee80211_conf *conf = &hw->conf;
int ret = 0;

Expand Down Expand Up @@ -1139,7 +1139,7 @@ static int ath12k_mac_setup_bcn_tmpl(struct ath12k_vif *arvif)
{
struct ath12k *ar = arvif->ar;
struct ath12k_base *ab = ar->ab;
struct ieee80211_hw *hw = ar->hw;
struct ieee80211_hw *hw = ath12k_ar_to_hw(ar);
struct ieee80211_vif *vif = arvif->vif;
struct ieee80211_mutable_offsets offs = {};
struct sk_buff *bcn;
Expand Down Expand Up @@ -1227,6 +1227,7 @@ static void ath12k_peer_assoc_h_basic(struct ath12k *ar,
struct ath12k_wmi_peer_assoc_arg *arg)
{
struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
struct ieee80211_hw *hw = ath12k_ar_to_hw(ar);
u32 aid;

lockdep_assert_held(&ar->conf_mutex);
Expand All @@ -1241,7 +1242,7 @@ static void ath12k_peer_assoc_h_basic(struct ath12k *ar,
arg->peer_associd = aid;
arg->auth_flag = true;
/* TODO: STA WAR in ath10k for listen interval required? */
arg->peer_listen_intval = ar->hw->conf.listen_interval;
arg->peer_listen_intval = hw->conf.listen_interval;
arg->peer_nss = 1;
arg->peer_caps = vif->bss_conf.assoc_capability;
}
Expand All @@ -1255,6 +1256,7 @@ static void ath12k_peer_assoc_h_crypto(struct ath12k *ar,
struct cfg80211_chan_def def;
struct cfg80211_bss *bss;
struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
struct ieee80211_hw *hw = ath12k_ar_to_hw(ar);
const u8 *rsnie = NULL;
const u8 *wpaie = NULL;

Expand All @@ -1263,7 +1265,7 @@ static void ath12k_peer_assoc_h_crypto(struct ath12k *ar,
if (WARN_ON(ath12k_mac_vif_chan(vif, &def)))
return;

bss = cfg80211_get_bss(ar->hw->wiphy, def.chan, info->bssid, NULL, 0,
bss = cfg80211_get_bss(hw->wiphy, def.chan, info->bssid, NULL, 0,
IEEE80211_BSS_TYPE_ANY, IEEE80211_PRIVACY_ANY);

if (arvif->rsnie_present || arvif->wpaie_present) {
Expand All @@ -1283,7 +1285,7 @@ static void ath12k_peer_assoc_h_crypto(struct ath12k *ar,
ies->data,
ies->len);
rcu_read_unlock();
cfg80211_put_bss(ar->hw->wiphy, bss);
cfg80211_put_bss(hw->wiphy, bss);
}

/* FIXME: base on RSN IE/WPA IE is a correct idea? */
Expand Down Expand Up @@ -1317,6 +1319,7 @@ static void ath12k_peer_assoc_h_rates(struct ath12k *ar,
struct cfg80211_chan_def def;
const struct ieee80211_supported_band *sband;
const struct ieee80211_rate *rates;
struct ieee80211_hw *hw = ath12k_ar_to_hw(ar);
enum nl80211_band band;
u32 ratemask;
u8 rate;
Expand All @@ -1328,7 +1331,7 @@ static void ath12k_peer_assoc_h_rates(struct ath12k *ar,
return;

band = def.chan->band;
sband = ar->hw->wiphy->bands[band];
sband = hw->wiphy->bands[band];
ratemask = sta->deflink.supp_rates[band];
ratemask &= arvif->bitrate_mask.control[band].legacy;
rates = sband->bitrates;
Expand Down Expand Up @@ -2423,6 +2426,7 @@ static void ath12k_recalculate_mgmt_rate(struct ath12k *ar,
struct cfg80211_chan_def *def)
{
struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
struct ieee80211_hw *hw = ath12k_ar_to_hw(ar);
const struct ieee80211_supported_band *sband;
u8 basic_rate_idx;
int hw_rate_code;
Expand All @@ -2432,7 +2436,7 @@ static void ath12k_recalculate_mgmt_rate(struct ath12k *ar,

lockdep_assert_held(&ar->conf_mutex);

sband = ar->hw->wiphy->bands[def->chan->band];
sband = hw->wiphy->bands[def->chan->band];
basic_rate_idx = ffs(vif->bss_conf.basic_rates) - 1;
bitrate = sband->bitrates[basic_rate_idx].bitrate;

Expand All @@ -2459,6 +2463,7 @@ static int ath12k_mac_fils_discovery(struct ath12k_vif *arvif,
struct ieee80211_bss_conf *info)
{
struct ath12k *ar = arvif->ar;
struct ieee80211_hw *hw = ath12k_ar_to_hw(ar);
struct sk_buff *tmpl;
int ret;
u32 interval;
Expand All @@ -2467,15 +2472,15 @@ static int ath12k_mac_fils_discovery(struct ath12k_vif *arvif,
if (info->fils_discovery.max_interval) {
interval = info->fils_discovery.max_interval;

tmpl = ieee80211_get_fils_discovery_tmpl(ar->hw, arvif->vif);
tmpl = ieee80211_get_fils_discovery_tmpl(hw, arvif->vif);
if (tmpl)
ret = ath12k_wmi_fils_discovery_tmpl(ar, arvif->vdev_id,
tmpl);
} else if (info->unsol_bcast_probe_resp_interval) {
unsol_bcast_probe_resp_enabled = 1;
interval = info->unsol_bcast_probe_resp_interval;

tmpl = ieee80211_get_unsol_bcast_probe_resp_tmpl(ar->hw,
tmpl = ieee80211_get_unsol_bcast_probe_resp_tmpl(hw,
arvif->vif);
if (tmpl)
ret = ath12k_wmi_probe_resp_tmpl(ar, arvif->vdev_id,
Expand Down Expand Up @@ -2798,6 +2803,8 @@ static void ath12k_mac_op_bss_info_changed(struct ieee80211_hw *hw,

void __ath12k_mac_scan_finish(struct ath12k *ar)
{
struct ieee80211_hw *hw = ath12k_ar_to_hw(ar);

lockdep_assert_held(&ar->data_lock);

switch (ar->scan.state) {
Expand All @@ -2806,7 +2813,7 @@ void __ath12k_mac_scan_finish(struct ath12k *ar)
case ATH12K_SCAN_RUNNING:
case ATH12K_SCAN_ABORTING:
if (ar->scan.is_roc && ar->scan.roc_notify)
ieee80211_remain_on_channel_expired(ar->hw);
ieee80211_remain_on_channel_expired(hw);
fallthrough;
case ATH12K_SCAN_STARTING:
if (!ar->scan.is_roc) {
Expand All @@ -2817,7 +2824,7 @@ void __ath12k_mac_scan_finish(struct ath12k *ar)
ATH12K_SCAN_STARTING)),
};

ieee80211_scan_completed(ar->hw, &info);
ieee80211_scan_completed(hw, &info);
}

ar->scan.state = ATH12K_SCAN_IDLE;
Expand Down Expand Up @@ -3036,7 +3043,7 @@ static int ath12k_mac_op_hw_scan(struct ieee80211_hw *hw,
}

/* Add a margin to account for event/command processing */
ieee80211_queue_delayed_work(ar->hw, &ar->scan.timeout,
ieee80211_queue_delayed_work(ath12k_ar_to_hw(ar), &ar->scan.timeout,
msecs_to_jiffies(arg.max_scan_time +
ATH12K_MAC_SCAN_TIMEOUT_MSECS));

Expand Down Expand Up @@ -4819,7 +4826,7 @@ static void ath12k_mgmt_over_wmi_tx_drop(struct ath12k *ar, struct sk_buff *skb)
{
int num_mgmt;

ieee80211_free_txskb(ar->hw, skb);
ieee80211_free_txskb(ath12k_ar_to_hw(ar), skb);

num_mgmt = atomic_dec_if_positive(&ar->num_pending_mgmt_tx);

Expand Down Expand Up @@ -4996,7 +5003,7 @@ static int ath12k_mac_mgmt_tx(struct ath12k *ar, struct sk_buff *skb,

skb_queue_tail(q, skb);
atomic_inc(&ar->num_pending_mgmt_tx);
ieee80211_queue_work(ar->hw, &ar->wmi_mgmt_tx_work);
ieee80211_queue_work(ath12k_ar_to_hw(ar), &ar->wmi_mgmt_tx_work);

return 0;
}
Expand Down Expand Up @@ -6357,7 +6364,7 @@ ath12k_mac_update_active_vif_chan(struct ath12k *ar,
struct ieee80211_chanctx_conf *ctx)
{
struct ath12k_mac_change_chanctx_arg arg = { .ctx = ctx };
struct ieee80211_hw *hw = ar->hw;
struct ieee80211_hw *hw = ath12k_ar_to_hw(ar);

lockdep_assert_held(&ar->conf_mutex);

Expand Down Expand Up @@ -6874,7 +6881,7 @@ static void ath12k_mac_set_bitrate_mask_iter(void *data,
arsta->changed |= IEEE80211_RC_SUPP_RATES_CHANGED;
spin_unlock_bh(&ar->data_lock);

ieee80211_queue_work(ar->hw, &arsta->update_wk);
ieee80211_queue_work(ath12k_ar_to_hw(ar), &arsta->update_wk);
}

static void ath12k_mac_disable_peer_fixed_rate(void *data,
Expand Down Expand Up @@ -7350,7 +7357,7 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar,
static int ath12k_mac_setup_iface_combinations(struct ath12k *ar)
{
struct ath12k_base *ab = ar->ab;
struct ieee80211_hw *hw = ar->hw;
struct ieee80211_hw *hw = ath12k_ar_to_hw(ar);
struct wiphy *wiphy = hw->wiphy;
struct ieee80211_iface_combination *combinations;
struct ieee80211_iface_limit *limits;
Expand Down Expand Up @@ -7457,7 +7464,7 @@ static void ath12k_mac_cleanup_unregister(struct ath12k *ar)

static void ath12k_mac_hw_unregister(struct ath12k *ar)
{
struct ieee80211_hw *hw = ar->hw;
struct ieee80211_hw *hw = ath12k_ar_to_hw(ar);
struct wiphy *wiphy = hw->wiphy;

cancel_work_sync(&ar->regd_update_work);
Expand Down Expand Up @@ -7503,7 +7510,7 @@ static int ath12k_mac_setup_register(struct ath12k *ar,
static int ath12k_mac_hw_register(struct ath12k *ar)
{
struct ath12k_base *ab = ar->ab;
struct ieee80211_hw *hw = ar->hw;
struct ieee80211_hw *hw = ath12k_ar_to_hw(ar);
struct wiphy *wiphy = hw->wiphy;
struct ath12k_pdev *pdev = ar->pdev;
struct ath12k_pdev_cap *cap = &pdev->cap;
Expand Down Expand Up @@ -7777,7 +7784,7 @@ static void ath12k_mac_hw_destroy(struct ath12k_base *ab)
if (!ar)
continue;

ieee80211_free_hw(ar->hw);
ieee80211_free_hw(ath12k_ar_to_hw(ar));
pdev->ar = NULL;
}
}
Expand Down
Loading

0 comments on commit b856f02

Please sign in to comment.