Skip to content

Commit b856f02

Browse files
Karthikeyan Periyasamykvalo
authored andcommitted
wifi: ath12k: Refactor the mac80211 hw access from link/radio
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
1 parent 955df16 commit b856f02

File tree

8 files changed

+60
-44
lines changed

8 files changed

+60
-44
lines changed

drivers/net/wireless/ath/ath12k/core.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: BSD-3-Clause-Clear
22
/*
33
* Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
4-
* Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4+
* Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
55
*/
66

77
#include <linux/module.h>
@@ -879,6 +879,7 @@ static void ath12k_rfkill_work(struct work_struct *work)
879879
{
880880
struct ath12k_base *ab = container_of(work, struct ath12k_base, rfkill_work);
881881
struct ath12k *ar;
882+
struct ieee80211_hw *hw;
882883
bool rfkill_radio_on;
883884
int i;
884885

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

895+
hw = ath12k_ar_to_hw(ar);
894896
ath12k_mac_rfkill_enable_radio(ar, rfkill_radio_on);
895-
wiphy_rfkill_set_hw_state(ar->hw->wiphy, !rfkill_radio_on);
897+
wiphy_rfkill_set_hw_state(hw->wiphy, !rfkill_radio_on);
896898
}
897899
}
898900

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

939-
ieee80211_stop_queues(ar->hw);
941+
ieee80211_stop_queues(ath12k_ar_to_hw(ar));
940942
ath12k_mac_drain_tx(ar);
941943
complete(&ar->scan.started);
942944
complete(&ar->scan.completed);
@@ -976,7 +978,7 @@ static void ath12k_core_post_reconfigure_recovery(struct ath12k_base *ab)
976978
case ATH12K_STATE_ON:
977979
ar->state = ATH12K_STATE_RESTARTING;
978980
ath12k_core_halt(ar);
979-
ieee80211_restart_hw(ar->hw);
981+
ieee80211_restart_hw(ath12k_ar_to_hw(ar));
980982
break;
981983
case ATH12K_STATE_OFF:
982984
ath12k_warn(ab,

drivers/net/wireless/ath/ath12k/core.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* SPDX-License-Identifier: BSD-3-Clause-Clear */
22
/*
33
* Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
4-
* Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4+
* Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
55
*/
66

77
#ifndef ATH12K_CORE_H
@@ -896,4 +896,8 @@ static inline const char *ath12k_bus_str(enum ath12k_bus bus)
896896
return "unknown";
897897
}
898898

899+
static inline struct ieee80211_hw *ath12k_ar_to_hw(struct ath12k *ar)
900+
{
901+
return ar->hw;
902+
}
899903
#endif /* _CORE_H_ */

drivers/net/wireless/ath/ath12k/dp_mon.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: BSD-3-Clause-Clear
22
/*
33
* Copyright (c) 2019-2021 The Linux Foundation. All rights reserved.
4-
* Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4+
* Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
55
*/
66

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

1133-
ieee80211_rx_napi(ar->hw, pubsta, msdu, napi);
1133+
ieee80211_rx_napi(ath12k_ar_to_hw(ar), pubsta, msdu, napi);
11341134
}
11351135

11361136
static int ath12k_dp_mon_rx_deliver(struct ath12k *ar, u32 mac_id,

drivers/net/wireless/ath/ath12k/dp_rx.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: BSD-3-Clause-Clear
22
/*
33
* Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
4-
* Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4+
* Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
55
*/
66

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

2461-
ieee80211_rx_napi(ar->hw, pubsta, msdu, napi);
2461+
ieee80211_rx_napi(ath12k_ar_to_hw(ar), pubsta, msdu, napi);
24622462
}
24632463

24642464
static int ath12k_dp_rx_process_msdu(struct ath12k *ar,
@@ -2844,7 +2844,7 @@ static int ath12k_dp_rx_h_verify_tkip_mic(struct ath12k *ar, struct ath12k_peer
28442844
ath12k_dp_rx_h_ppdu(ar, rx_desc, rxs);
28452845
ath12k_dp_rx_h_undecap(ar, msdu, rx_desc,
28462846
HAL_ENCRYPT_TYPE_TKIP_MIC, rxs, true);
2847-
ieee80211_rx(ar->hw, msdu);
2847+
ieee80211_rx(ath12k_ar_to_hw(ar), msdu);
28482848
return -EINVAL;
28492849
}
28502850

drivers/net/wireless/ath/ath12k/dp_tx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ ath12k_dp_tx_htt_tx_complete_buf(struct ath12k_base *ab,
401401
}
402402
}
403403

404-
ieee80211_tx_status_skb(ar->hw, msdu);
404+
ieee80211_tx_status_skb(ath12k_ar_to_hw(ar), msdu);
405405
}
406406

407407
static void
@@ -498,7 +498,7 @@ static void ath12k_dp_tx_complete_msdu(struct ath12k *ar,
498498
* Might end up reporting it out-of-band from HTT stats.
499499
*/
500500

501-
ieee80211_tx_status_skb(ar->hw, msdu);
501+
ieee80211_tx_status_skb(ath12k_ar_to_hw(ar), msdu);
502502

503503
exit:
504504
rcu_read_unlock();

drivers/net/wireless/ath/ath12k/mac.c

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ struct ath12k_vif *ath12k_mac_get_arvif(struct ath12k *ar, u32 vdev_id)
542542
arvif_iter.vdev_id = vdev_id;
543543

544544
flags = IEEE80211_IFACE_ITER_RESUME_ALL;
545-
ieee80211_iterate_active_interfaces_atomic(ar->hw,
545+
ieee80211_iterate_active_interfaces_atomic(ath12k_ar_to_hw(ar),
546546
flags,
547547
ath12k_get_arvif_iter,
548548
&arvif_iter);
@@ -1040,7 +1040,7 @@ static int ath12k_mac_monitor_start(struct ath12k *ar)
10401040
if (ar->monitor_started)
10411041
return 0;
10421042

1043-
ieee80211_iter_chan_contexts_atomic(ar->hw,
1043+
ieee80211_iter_chan_contexts_atomic(ath12k_ar_to_hw(ar),
10441044
ath12k_mac_get_any_chandef_iter,
10451045
&chandef);
10461046
if (!chandef)
@@ -1085,7 +1085,7 @@ static int ath12k_mac_monitor_stop(struct ath12k *ar)
10851085

10861086
static int ath12k_mac_config(struct ath12k *ar, u32 changed)
10871087
{
1088-
struct ieee80211_hw *hw = ar->hw;
1088+
struct ieee80211_hw *hw = ath12k_ar_to_hw(ar);
10891089
struct ieee80211_conf *conf = &hw->conf;
10901090
int ret = 0;
10911091

@@ -1139,7 +1139,7 @@ static int ath12k_mac_setup_bcn_tmpl(struct ath12k_vif *arvif)
11391139
{
11401140
struct ath12k *ar = arvif->ar;
11411141
struct ath12k_base *ab = ar->ab;
1142-
struct ieee80211_hw *hw = ar->hw;
1142+
struct ieee80211_hw *hw = ath12k_ar_to_hw(ar);
11431143
struct ieee80211_vif *vif = arvif->vif;
11441144
struct ieee80211_mutable_offsets offs = {};
11451145
struct sk_buff *bcn;
@@ -1227,6 +1227,7 @@ static void ath12k_peer_assoc_h_basic(struct ath12k *ar,
12271227
struct ath12k_wmi_peer_assoc_arg *arg)
12281228
{
12291229
struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
1230+
struct ieee80211_hw *hw = ath12k_ar_to_hw(ar);
12301231
u32 aid;
12311232

12321233
lockdep_assert_held(&ar->conf_mutex);
@@ -1241,7 +1242,7 @@ static void ath12k_peer_assoc_h_basic(struct ath12k *ar,
12411242
arg->peer_associd = aid;
12421243
arg->auth_flag = true;
12431244
/* TODO: STA WAR in ath10k for listen interval required? */
1244-
arg->peer_listen_intval = ar->hw->conf.listen_interval;
1245+
arg->peer_listen_intval = hw->conf.listen_interval;
12451246
arg->peer_nss = 1;
12461247
arg->peer_caps = vif->bss_conf.assoc_capability;
12471248
}
@@ -1255,6 +1256,7 @@ static void ath12k_peer_assoc_h_crypto(struct ath12k *ar,
12551256
struct cfg80211_chan_def def;
12561257
struct cfg80211_bss *bss;
12571258
struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
1259+
struct ieee80211_hw *hw = ath12k_ar_to_hw(ar);
12581260
const u8 *rsnie = NULL;
12591261
const u8 *wpaie = NULL;
12601262

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

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

12691271
if (arvif->rsnie_present || arvif->wpaie_present) {
@@ -1283,7 +1285,7 @@ static void ath12k_peer_assoc_h_crypto(struct ath12k *ar,
12831285
ies->data,
12841286
ies->len);
12851287
rcu_read_unlock();
1286-
cfg80211_put_bss(ar->hw->wiphy, bss);
1288+
cfg80211_put_bss(hw->wiphy, bss);
12871289
}
12881290

12891291
/* FIXME: base on RSN IE/WPA IE is a correct idea? */
@@ -1317,6 +1319,7 @@ static void ath12k_peer_assoc_h_rates(struct ath12k *ar,
13171319
struct cfg80211_chan_def def;
13181320
const struct ieee80211_supported_band *sband;
13191321
const struct ieee80211_rate *rates;
1322+
struct ieee80211_hw *hw = ath12k_ar_to_hw(ar);
13201323
enum nl80211_band band;
13211324
u32 ratemask;
13221325
u8 rate;
@@ -1328,7 +1331,7 @@ static void ath12k_peer_assoc_h_rates(struct ath12k *ar,
13281331
return;
13291332

13301333
band = def.chan->band;
1331-
sband = ar->hw->wiphy->bands[band];
1334+
sband = hw->wiphy->bands[band];
13321335
ratemask = sta->deflink.supp_rates[band];
13331336
ratemask &= arvif->bitrate_mask.control[band].legacy;
13341337
rates = sband->bitrates;
@@ -2423,6 +2426,7 @@ static void ath12k_recalculate_mgmt_rate(struct ath12k *ar,
24232426
struct cfg80211_chan_def *def)
24242427
{
24252428
struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
2429+
struct ieee80211_hw *hw = ath12k_ar_to_hw(ar);
24262430
const struct ieee80211_supported_band *sband;
24272431
u8 basic_rate_idx;
24282432
int hw_rate_code;
@@ -2432,7 +2436,7 @@ static void ath12k_recalculate_mgmt_rate(struct ath12k *ar,
24322436

24332437
lockdep_assert_held(&ar->conf_mutex);
24342438

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

@@ -2459,6 +2463,7 @@ static int ath12k_mac_fils_discovery(struct ath12k_vif *arvif,
24592463
struct ieee80211_bss_conf *info)
24602464
{
24612465
struct ath12k *ar = arvif->ar;
2466+
struct ieee80211_hw *hw = ath12k_ar_to_hw(ar);
24622467
struct sk_buff *tmpl;
24632468
int ret;
24642469
u32 interval;
@@ -2467,15 +2472,15 @@ static int ath12k_mac_fils_discovery(struct ath12k_vif *arvif,
24672472
if (info->fils_discovery.max_interval) {
24682473
interval = info->fils_discovery.max_interval;
24692474

2470-
tmpl = ieee80211_get_fils_discovery_tmpl(ar->hw, arvif->vif);
2475+
tmpl = ieee80211_get_fils_discovery_tmpl(hw, arvif->vif);
24712476
if (tmpl)
24722477
ret = ath12k_wmi_fils_discovery_tmpl(ar, arvif->vdev_id,
24732478
tmpl);
24742479
} else if (info->unsol_bcast_probe_resp_interval) {
24752480
unsol_bcast_probe_resp_enabled = 1;
24762481
interval = info->unsol_bcast_probe_resp_interval;
24772482

2478-
tmpl = ieee80211_get_unsol_bcast_probe_resp_tmpl(ar->hw,
2483+
tmpl = ieee80211_get_unsol_bcast_probe_resp_tmpl(hw,
24792484
arvif->vif);
24802485
if (tmpl)
24812486
ret = ath12k_wmi_probe_resp_tmpl(ar, arvif->vdev_id,
@@ -2798,6 +2803,8 @@ static void ath12k_mac_op_bss_info_changed(struct ieee80211_hw *hw,
27982803

27992804
void __ath12k_mac_scan_finish(struct ath12k *ar)
28002805
{
2806+
struct ieee80211_hw *hw = ath12k_ar_to_hw(ar);
2807+
28012808
lockdep_assert_held(&ar->data_lock);
28022809

28032810
switch (ar->scan.state) {
@@ -2806,7 +2813,7 @@ void __ath12k_mac_scan_finish(struct ath12k *ar)
28062813
case ATH12K_SCAN_RUNNING:
28072814
case ATH12K_SCAN_ABORTING:
28082815
if (ar->scan.is_roc && ar->scan.roc_notify)
2809-
ieee80211_remain_on_channel_expired(ar->hw);
2816+
ieee80211_remain_on_channel_expired(hw);
28102817
fallthrough;
28112818
case ATH12K_SCAN_STARTING:
28122819
if (!ar->scan.is_roc) {
@@ -2817,7 +2824,7 @@ void __ath12k_mac_scan_finish(struct ath12k *ar)
28172824
ATH12K_SCAN_STARTING)),
28182825
};
28192826

2820-
ieee80211_scan_completed(ar->hw, &info);
2827+
ieee80211_scan_completed(hw, &info);
28212828
}
28222829

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

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

@@ -4819,7 +4826,7 @@ static void ath12k_mgmt_over_wmi_tx_drop(struct ath12k *ar, struct sk_buff *skb)
48194826
{
48204827
int num_mgmt;
48214828

4822-
ieee80211_free_txskb(ar->hw, skb);
4829+
ieee80211_free_txskb(ath12k_ar_to_hw(ar), skb);
48234830

48244831
num_mgmt = atomic_dec_if_positive(&ar->num_pending_mgmt_tx);
48254832

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

49975004
skb_queue_tail(q, skb);
49985005
atomic_inc(&ar->num_pending_mgmt_tx);
4999-
ieee80211_queue_work(ar->hw, &ar->wmi_mgmt_tx_work);
5006+
ieee80211_queue_work(ath12k_ar_to_hw(ar), &ar->wmi_mgmt_tx_work);
50005007

50015008
return 0;
50025009
}
@@ -6357,7 +6364,7 @@ ath12k_mac_update_active_vif_chan(struct ath12k *ar,
63576364
struct ieee80211_chanctx_conf *ctx)
63586365
{
63596366
struct ath12k_mac_change_chanctx_arg arg = { .ctx = ctx };
6360-
struct ieee80211_hw *hw = ar->hw;
6367+
struct ieee80211_hw *hw = ath12k_ar_to_hw(ar);
63616368

63626369
lockdep_assert_held(&ar->conf_mutex);
63636370

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

6877-
ieee80211_queue_work(ar->hw, &arsta->update_wk);
6884+
ieee80211_queue_work(ath12k_ar_to_hw(ar), &arsta->update_wk);
68786885
}
68796886

68806887
static void ath12k_mac_disable_peer_fixed_rate(void *data,
@@ -7350,7 +7357,7 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar,
73507357
static int ath12k_mac_setup_iface_combinations(struct ath12k *ar)
73517358
{
73527359
struct ath12k_base *ab = ar->ab;
7353-
struct ieee80211_hw *hw = ar->hw;
7360+
struct ieee80211_hw *hw = ath12k_ar_to_hw(ar);
73547361
struct wiphy *wiphy = hw->wiphy;
73557362
struct ieee80211_iface_combination *combinations;
73567363
struct ieee80211_iface_limit *limits;
@@ -7457,7 +7464,7 @@ static void ath12k_mac_cleanup_unregister(struct ath12k *ar)
74577464

74587465
static void ath12k_mac_hw_unregister(struct ath12k *ar)
74597466
{
7460-
struct ieee80211_hw *hw = ar->hw;
7467+
struct ieee80211_hw *hw = ath12k_ar_to_hw(ar);
74617468
struct wiphy *wiphy = hw->wiphy;
74627469

74637470
cancel_work_sync(&ar->regd_update_work);
@@ -7503,7 +7510,7 @@ static int ath12k_mac_setup_register(struct ath12k *ar,
75037510
static int ath12k_mac_hw_register(struct ath12k *ar)
75047511
{
75057512
struct ath12k_base *ab = ar->ab;
7506-
struct ieee80211_hw *hw = ar->hw;
7513+
struct ieee80211_hw *hw = ath12k_ar_to_hw(ar);
75077514
struct wiphy *wiphy = hw->wiphy;
75087515
struct ath12k_pdev *pdev = ar->pdev;
75097516
struct ath12k_pdev_cap *cap = &pdev->cap;
@@ -7777,7 +7784,7 @@ static void ath12k_mac_hw_destroy(struct ath12k_base *ab)
77777784
if (!ar)
77787785
continue;
77797786

7780-
ieee80211_free_hw(ar->hw);
7787+
ieee80211_free_hw(ath12k_ar_to_hw(ar));
77817788
pdev->ar = NULL;
77827789
}
77837790
}

0 commit comments

Comments
 (0)