Skip to content

Commit 940b57f

Browse files
Karthikeyan Periyasamykvalo
authored andcommitted
wifi: ath12k: avoid repeated hw access from ar
Currently, the helper functions are accessing mac80211 hw data from the radio (ar) structure repeatedly. So optimize these helper functions by storing mac80211 hw data locally and accessing it directly. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1 Signed-off-by: Karthikeyan Periyasamy <[email protected]> Acked-by: Jeff Johnson <[email protected]> Signed-off-by: Kalle Valo <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 842adda commit 940b57f

File tree

3 files changed

+90
-83
lines changed

3 files changed

+90
-83
lines changed

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

Lines changed: 82 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -6266,10 +6266,11 @@ ath12k_mac_update_active_vif_chan(struct ath12k *ar,
62666266
struct ieee80211_chanctx_conf *ctx)
62676267
{
62686268
struct ath12k_mac_change_chanctx_arg arg = { .ctx = ctx };
6269+
struct ieee80211_hw *hw = ar->hw;
62696270

62706271
lockdep_assert_held(&ar->conf_mutex);
62716272

6272-
ieee80211_iterate_active_interfaces_atomic(ar->hw,
6273+
ieee80211_iterate_active_interfaces_atomic(hw,
62736274
IEEE80211_IFACE_ITER_NORMAL,
62746275
ath12k_mac_change_chanctx_cnt_iter,
62756276
&arg);
@@ -6280,7 +6281,7 @@ ath12k_mac_update_active_vif_chan(struct ath12k *ar,
62806281
if (!arg.vifs)
62816282
return;
62826283

6283-
ieee80211_iterate_active_interfaces_atomic(ar->hw,
6284+
ieee80211_iterate_active_interfaces_atomic(hw,
62846285
IEEE80211_IFACE_ITER_NORMAL,
62856286
ath12k_mac_change_chanctx_fill_iter,
62866287
&arg);
@@ -7159,6 +7160,7 @@ static u32 ath12k_get_phy_id(struct ath12k *ar, u32 band)
71597160
static int ath12k_mac_setup_channels_rates(struct ath12k *ar,
71607161
u32 supported_bands)
71617162
{
7163+
struct ieee80211_hw *hw = ar->hw;
71627164
struct ieee80211_supported_band *band;
71637165
struct ath12k_wmi_hal_reg_capabilities_ext_arg *reg_cap;
71647166
void *channels;
@@ -7184,7 +7186,7 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar,
71847186
band->channels = channels;
71857187
band->n_bitrates = ath12k_g_rates_size;
71867188
band->bitrates = ath12k_g_rates;
7187-
ar->hw->wiphy->bands[NL80211_BAND_2GHZ] = band;
7189+
hw->wiphy->bands[NL80211_BAND_2GHZ] = band;
71887190

71897191
if (ar->ab->hw_params->single_pdev_only) {
71907192
phy_id = ath12k_get_phy_id(ar, WMI_HOST_WLAN_2G_CAP);
@@ -7211,7 +7213,7 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar,
72117213
band->channels = channels;
72127214
band->n_bitrates = ath12k_a_rates_size;
72137215
band->bitrates = ath12k_a_rates;
7214-
ar->hw->wiphy->bands[NL80211_BAND_6GHZ] = band;
7216+
hw->wiphy->bands[NL80211_BAND_6GHZ] = band;
72157217
ath12k_mac_update_ch_list(ar, band,
72167218
reg_cap->low_5ghz_chan,
72177219
reg_cap->high_5ghz_chan);
@@ -7233,7 +7235,7 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar,
72337235
band->channels = channels;
72347236
band->n_bitrates = ath12k_a_rates_size;
72357237
band->bitrates = ath12k_a_rates;
7236-
ar->hw->wiphy->bands[NL80211_BAND_5GHZ] = band;
7238+
hw->wiphy->bands[NL80211_BAND_5GHZ] = band;
72377239

72387240
if (ar->ab->hw_params->single_pdev_only) {
72397241
phy_id = ath12k_get_phy_id(ar, WMI_HOST_WLAN_5G_CAP);
@@ -7252,6 +7254,7 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar,
72527254
static int ath12k_mac_setup_iface_combinations(struct ath12k *ar)
72537255
{
72547256
struct ath12k_base *ab = ar->ab;
7257+
struct ieee80211_hw *hw = ar->hw;
72557258
struct ieee80211_iface_combination *combinations;
72567259
struct ieee80211_iface_limit *limits;
72577260
int n_limits, max_interfaces;
@@ -7302,8 +7305,8 @@ static int ath12k_mac_setup_iface_combinations(struct ath12k *ar)
73027305
BIT(NL80211_CHAN_WIDTH_40) |
73037306
BIT(NL80211_CHAN_WIDTH_80);
73047307

7305-
ar->hw->wiphy->iface_combinations = combinations;
7306-
ar->hw->wiphy->n_iface_combinations = 1;
7308+
hw->wiphy->iface_combinations = combinations;
7309+
hw->wiphy->n_iface_combinations = 1;
73077310

73087311
return 0;
73097312
}
@@ -7347,9 +7350,11 @@ static const struct wiphy_iftype_ext_capab ath12k_iftypes_ext_capa[] = {
73477350

73487351
static void __ath12k_mac_unregister(struct ath12k *ar)
73497352
{
7353+
struct ieee80211_hw *hw = ar->hw;
7354+
73507355
cancel_work_sync(&ar->regd_update_work);
73517356

7352-
ieee80211_unregister_hw(ar->hw);
7357+
ieee80211_unregister_hw(hw);
73537358

73547359
idr_for_each(&ar->txmgmt_idr, ath12k_mac_tx_mgmt_pending_free, ar);
73557360
idr_destroy(&ar->txmgmt_idr);
@@ -7358,10 +7363,10 @@ static void __ath12k_mac_unregister(struct ath12k *ar)
73587363
kfree(ar->mac.sbands[NL80211_BAND_5GHZ].channels);
73597364
kfree(ar->mac.sbands[NL80211_BAND_6GHZ].channels);
73607365

7361-
kfree(ar->hw->wiphy->iface_combinations[0].limits);
7362-
kfree(ar->hw->wiphy->iface_combinations);
7366+
kfree(hw->wiphy->iface_combinations[0].limits);
7367+
kfree(hw->wiphy->iface_combinations);
73637368

7364-
SET_IEEE80211_DEV(ar->hw, NULL);
7369+
SET_IEEE80211_DEV(hw, NULL);
73657370
}
73667371

73677372
void ath12k_mac_unregister(struct ath12k_base *ab)
@@ -7383,6 +7388,7 @@ void ath12k_mac_unregister(struct ath12k_base *ab)
73837388
static int __ath12k_mac_register(struct ath12k *ar)
73847389
{
73857390
struct ath12k_base *ab = ar->ab;
7391+
struct ieee80211_hw *hw = ar->hw;
73867392
struct ath12k_pdev_cap *cap = &ar->pdev->cap;
73877393
static const u32 cipher_suites[] = {
73887394
WLAN_CIPHER_SUITE_TKIP,
@@ -7400,9 +7406,9 @@ static int __ath12k_mac_register(struct ath12k *ar)
74007406

74017407
ath12k_pdev_caps_update(ar);
74027408

7403-
SET_IEEE80211_PERM_ADDR(ar->hw, ar->mac_addr);
7409+
SET_IEEE80211_PERM_ADDR(hw, ar->mac_addr);
74047410

7405-
SET_IEEE80211_DEV(ar->hw, ab->dev);
7411+
SET_IEEE80211_DEV(hw, ab->dev);
74067412

74077413
ret = ath12k_mac_setup_channels_rates(ar,
74087414
cap->supported_bands);
@@ -7418,103 +7424,103 @@ static int __ath12k_mac_register(struct ath12k *ar)
74187424
goto err_free_channels;
74197425
}
74207426

7421-
ar->hw->wiphy->available_antennas_rx = cap->rx_chain_mask;
7422-
ar->hw->wiphy->available_antennas_tx = cap->tx_chain_mask;
7427+
hw->wiphy->available_antennas_rx = cap->rx_chain_mask;
7428+
hw->wiphy->available_antennas_tx = cap->tx_chain_mask;
74237429

7424-
ar->hw->wiphy->interface_modes = ab->hw_params->interface_modes;
7430+
hw->wiphy->interface_modes = ab->hw_params->interface_modes;
74257431

7426-
if (ar->hw->wiphy->bands[NL80211_BAND_2GHZ] &&
7427-
ar->hw->wiphy->bands[NL80211_BAND_5GHZ] &&
7428-
ar->hw->wiphy->bands[NL80211_BAND_6GHZ])
7429-
ieee80211_hw_set(ar->hw, SINGLE_SCAN_ON_ALL_BANDS);
7432+
if (hw->wiphy->bands[NL80211_BAND_2GHZ] &&
7433+
hw->wiphy->bands[NL80211_BAND_5GHZ] &&
7434+
hw->wiphy->bands[NL80211_BAND_6GHZ])
7435+
ieee80211_hw_set(hw, SINGLE_SCAN_ON_ALL_BANDS);
74307436

7431-
ieee80211_hw_set(ar->hw, SIGNAL_DBM);
7432-
ieee80211_hw_set(ar->hw, SUPPORTS_PS);
7433-
ieee80211_hw_set(ar->hw, SUPPORTS_DYNAMIC_PS);
7434-
ieee80211_hw_set(ar->hw, MFP_CAPABLE);
7435-
ieee80211_hw_set(ar->hw, REPORTS_TX_ACK_STATUS);
7436-
ieee80211_hw_set(ar->hw, HAS_RATE_CONTROL);
7437-
ieee80211_hw_set(ar->hw, AP_LINK_PS);
7438-
ieee80211_hw_set(ar->hw, SPECTRUM_MGMT);
7439-
ieee80211_hw_set(ar->hw, CONNECTION_MONITOR);
7440-
ieee80211_hw_set(ar->hw, SUPPORTS_PER_STA_GTK);
7441-
ieee80211_hw_set(ar->hw, CHANCTX_STA_CSA);
7442-
ieee80211_hw_set(ar->hw, QUEUE_CONTROL);
7443-
ieee80211_hw_set(ar->hw, SUPPORTS_TX_FRAG);
7444-
ieee80211_hw_set(ar->hw, REPORTS_LOW_ACK);
7437+
ieee80211_hw_set(hw, SIGNAL_DBM);
7438+
ieee80211_hw_set(hw, SUPPORTS_PS);
7439+
ieee80211_hw_set(hw, SUPPORTS_DYNAMIC_PS);
7440+
ieee80211_hw_set(hw, MFP_CAPABLE);
7441+
ieee80211_hw_set(hw, REPORTS_TX_ACK_STATUS);
7442+
ieee80211_hw_set(hw, HAS_RATE_CONTROL);
7443+
ieee80211_hw_set(hw, AP_LINK_PS);
7444+
ieee80211_hw_set(hw, SPECTRUM_MGMT);
7445+
ieee80211_hw_set(hw, CONNECTION_MONITOR);
7446+
ieee80211_hw_set(hw, SUPPORTS_PER_STA_GTK);
7447+
ieee80211_hw_set(hw, CHANCTX_STA_CSA);
7448+
ieee80211_hw_set(hw, QUEUE_CONTROL);
7449+
ieee80211_hw_set(hw, SUPPORTS_TX_FRAG);
7450+
ieee80211_hw_set(hw, REPORTS_LOW_ACK);
74457451

74467452
if (ht_cap & WMI_HT_CAP_ENABLED) {
7447-
ieee80211_hw_set(ar->hw, AMPDU_AGGREGATION);
7448-
ieee80211_hw_set(ar->hw, TX_AMPDU_SETUP_IN_HW);
7449-
ieee80211_hw_set(ar->hw, SUPPORTS_REORDERING_BUFFER);
7450-
ieee80211_hw_set(ar->hw, SUPPORTS_AMSDU_IN_AMPDU);
7451-
ieee80211_hw_set(ar->hw, USES_RSS);
7453+
ieee80211_hw_set(hw, AMPDU_AGGREGATION);
7454+
ieee80211_hw_set(hw, TX_AMPDU_SETUP_IN_HW);
7455+
ieee80211_hw_set(hw, SUPPORTS_REORDERING_BUFFER);
7456+
ieee80211_hw_set(hw, SUPPORTS_AMSDU_IN_AMPDU);
7457+
ieee80211_hw_set(hw, USES_RSS);
74527458
}
74537459

7454-
ar->hw->wiphy->features |= NL80211_FEATURE_STATIC_SMPS;
7455-
ar->hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
7460+
hw->wiphy->features |= NL80211_FEATURE_STATIC_SMPS;
7461+
hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
74567462

74577463
/* TODO: Check if HT capability advertised from firmware is different
74587464
* for each band for a dual band capable radio. It will be tricky to
74597465
* handle it when the ht capability different for each band.
74607466
*/
74617467
if (ht_cap & WMI_HT_CAP_DYNAMIC_SMPS)
7462-
ar->hw->wiphy->features |= NL80211_FEATURE_DYNAMIC_SMPS;
7468+
hw->wiphy->features |= NL80211_FEATURE_DYNAMIC_SMPS;
74637469

7464-
ar->hw->wiphy->max_scan_ssids = WLAN_SCAN_PARAMS_MAX_SSID;
7465-
ar->hw->wiphy->max_scan_ie_len = WLAN_SCAN_PARAMS_MAX_IE_LEN;
7470+
hw->wiphy->max_scan_ssids = WLAN_SCAN_PARAMS_MAX_SSID;
7471+
hw->wiphy->max_scan_ie_len = WLAN_SCAN_PARAMS_MAX_IE_LEN;
74667472

7467-
ar->hw->max_listen_interval = ATH12K_MAX_HW_LISTEN_INTERVAL;
7473+
hw->max_listen_interval = ATH12K_MAX_HW_LISTEN_INTERVAL;
74687474

7469-
ar->hw->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
7470-
ar->hw->wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH;
7471-
ar->hw->wiphy->max_remain_on_channel_duration = 5000;
7475+
hw->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
7476+
hw->wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH;
7477+
hw->wiphy->max_remain_on_channel_duration = 5000;
74727478

7473-
ar->hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD;
7474-
ar->hw->wiphy->features |= NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE |
7479+
hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD;
7480+
hw->wiphy->features |= NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE |
74757481
NL80211_FEATURE_AP_SCAN;
74767482

74777483
ar->max_num_stations = TARGET_NUM_STATIONS;
74787484
ar->max_num_peers = TARGET_NUM_PEERS_PDEV;
74797485

7480-
ar->hw->wiphy->max_ap_assoc_sta = ar->max_num_stations;
7486+
hw->wiphy->max_ap_assoc_sta = ar->max_num_stations;
74817487

7482-
ar->hw->queues = ATH12K_HW_MAX_QUEUES;
7483-
ar->hw->wiphy->tx_queue_len = ATH12K_QUEUE_LEN;
7484-
ar->hw->offchannel_tx_hw_queue = ATH12K_HW_MAX_QUEUES - 1;
7485-
ar->hw->max_rx_aggregation_subframes = IEEE80211_MAX_AMPDU_BUF_HE;
7488+
hw->queues = ATH12K_HW_MAX_QUEUES;
7489+
hw->wiphy->tx_queue_len = ATH12K_QUEUE_LEN;
7490+
hw->offchannel_tx_hw_queue = ATH12K_HW_MAX_QUEUES - 1;
7491+
hw->max_rx_aggregation_subframes = IEEE80211_MAX_AMPDU_BUF_HE;
74867492

7487-
ar->hw->vif_data_size = sizeof(struct ath12k_vif);
7488-
ar->hw->sta_data_size = sizeof(struct ath12k_sta);
7493+
hw->vif_data_size = sizeof(struct ath12k_vif);
7494+
hw->sta_data_size = sizeof(struct ath12k_sta);
74897495

7490-
wiphy_ext_feature_set(ar->hw->wiphy, NL80211_EXT_FEATURE_CQM_RSSI_LIST);
7491-
wiphy_ext_feature_set(ar->hw->wiphy, NL80211_EXT_FEATURE_STA_TX_PWR);
7496+
wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_CQM_RSSI_LIST);
7497+
wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_STA_TX_PWR);
74927498

7493-
ar->hw->wiphy->cipher_suites = cipher_suites;
7494-
ar->hw->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites);
7499+
hw->wiphy->cipher_suites = cipher_suites;
7500+
hw->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites);
74957501

7496-
ar->hw->wiphy->iftype_ext_capab = ath12k_iftypes_ext_capa;
7497-
ar->hw->wiphy->num_iftype_ext_capab =
7502+
hw->wiphy->iftype_ext_capab = ath12k_iftypes_ext_capa;
7503+
hw->wiphy->num_iftype_ext_capab =
74987504
ARRAY_SIZE(ath12k_iftypes_ext_capa);
74997505

75007506
if (ar->supports_6ghz) {
7501-
wiphy_ext_feature_set(ar->hw->wiphy,
7507+
wiphy_ext_feature_set(hw->wiphy,
75027508
NL80211_EXT_FEATURE_FILS_DISCOVERY);
7503-
wiphy_ext_feature_set(ar->hw->wiphy,
7509+
wiphy_ext_feature_set(hw->wiphy,
75047510
NL80211_EXT_FEATURE_UNSOL_BCAST_PROBE_RESP);
75057511
}
75067512

7507-
wiphy_ext_feature_set(ar->hw->wiphy, NL80211_EXT_FEATURE_PUNCT);
7513+
wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_PUNCT);
75087514

7509-
ath12k_reg_init(ar);
7515+
ath12k_reg_init(hw);
75107516

75117517
if (!test_bit(ATH12K_FLAG_RAW_MODE, &ab->dev_flags)) {
7512-
ar->hw->netdev_features = NETIF_F_HW_CSUM;
7513-
ieee80211_hw_set(ar->hw, SW_CRYPTO_CONTROL);
7514-
ieee80211_hw_set(ar->hw, SUPPORT_FAST_XMIT);
7518+
hw->netdev_features = NETIF_F_HW_CSUM;
7519+
ieee80211_hw_set(hw, SW_CRYPTO_CONTROL);
7520+
ieee80211_hw_set(hw, SUPPORT_FAST_XMIT);
75157521
}
75167522

7517-
ret = ieee80211_register_hw(ar->hw);
7523+
ret = ieee80211_register_hw(hw);
75187524
if (ret) {
75197525
ath12k_err(ar->ab, "ieee80211 registration failed: %d\n", ret);
75207526
goto err_free_if_combs;
@@ -7526,7 +7532,7 @@ static int __ath12k_mac_register(struct ath12k *ar)
75267532
* while. But that time is so short and in practise it make
75277533
* a difference in real life.
75287534
*/
7529-
ar->hw->wiphy->interface_modes &= ~BIT(NL80211_IFTYPE_MONITOR);
7535+
hw->wiphy->interface_modes &= ~BIT(NL80211_IFTYPE_MONITOR);
75307536

75317537
/* Apply the regd received during initialization */
75327538
ret = ath12k_regd_update(ar, true);
@@ -7538,19 +7544,19 @@ static int __ath12k_mac_register(struct ath12k *ar)
75387544
return 0;
75397545

75407546
err_unregister_hw:
7541-
ieee80211_unregister_hw(ar->hw);
7547+
ieee80211_unregister_hw(hw);
75427548

75437549
err_free_if_combs:
7544-
kfree(ar->hw->wiphy->iface_combinations[0].limits);
7545-
kfree(ar->hw->wiphy->iface_combinations);
7550+
kfree(hw->wiphy->iface_combinations[0].limits);
7551+
kfree(hw->wiphy->iface_combinations);
75467552

75477553
err_free_channels:
75487554
kfree(ar->mac.sbands[NL80211_BAND_2GHZ].channels);
75497555
kfree(ar->mac.sbands[NL80211_BAND_5GHZ].channels);
75507556
kfree(ar->mac.sbands[NL80211_BAND_6GHZ].channels);
75517557

75527558
err:
7553-
SET_IEEE80211_DEV(ar->hw, NULL);
7559+
SET_IEEE80211_DEV(hw, NULL);
75547560
return ret;
75557561
}
75567562

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ static void ath12k_copy_regd(struct ieee80211_regdomain *regd_orig,
199199

200200
int ath12k_regd_update(struct ath12k *ar, bool init)
201201
{
202+
struct ieee80211_hw *hw = ar->hw;
202203
struct ieee80211_regdomain *regd, *regd_copy = NULL;
203204
int ret, regd_len, pdev_id;
204205
struct ath12k_base *ab;
@@ -246,9 +247,9 @@ int ath12k_regd_update(struct ath12k *ar, bool init)
246247
}
247248

248249
rtnl_lock();
249-
wiphy_lock(ar->hw->wiphy);
250-
ret = regulatory_set_wiphy_regd_sync(ar->hw->wiphy, regd_copy);
251-
wiphy_unlock(ar->hw->wiphy);
250+
wiphy_lock(hw->wiphy);
251+
ret = regulatory_set_wiphy_regd_sync(hw->wiphy, regd_copy);
252+
wiphy_unlock(hw->wiphy);
252253
rtnl_unlock();
253254

254255
kfree(regd_copy);
@@ -729,10 +730,10 @@ void ath12k_regd_update_work(struct work_struct *work)
729730
}
730731
}
731732

732-
void ath12k_reg_init(struct ath12k *ar)
733+
void ath12k_reg_init(struct ieee80211_hw *hw)
733734
{
734-
ar->hw->wiphy->regulatory_flags = REGULATORY_WIPHY_SELF_MANAGED;
735-
ar->hw->wiphy->reg_notifier = ath12k_reg_notifier;
735+
hw->wiphy->regulatory_flags = REGULATORY_WIPHY_SELF_MANAGED;
736+
hw->wiphy->reg_notifier = ath12k_reg_notifier;
736737
}
737738

738739
void ath12k_reg_free(struct ath12k_base *ab)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ enum ath12k_reg_phy_bitmap {
8989
ATH12K_REG_PHY_BITMAP_NO11BE = BIT(6),
9090
};
9191

92-
void ath12k_reg_init(struct ath12k *ar);
92+
void ath12k_reg_init(struct ieee80211_hw *hw);
9393
void ath12k_reg_free(struct ath12k_base *ab);
9494
void ath12k_regd_update_work(struct work_struct *work);
9595
struct ieee80211_regdomain *ath12k_reg_build_regd(struct ath12k_base *ab,

0 commit comments

Comments
 (0)