Skip to content

Commit 8f2b919

Browse files
jeff-t-johnsonopsiff
authored andcommitted
wifi: ath11k: Introduce and use ath11k_sta_to_arsta()
[ Upstream commit 10c65f9 ] Currently, the logic to return an ath11k_sta pointer, given a ieee80211_sta pointer, uses typecasting throughout the driver. In general, conversion functions are preferable to typecasting since using a conversion function allows the compiler to validate the types of both the input and output parameters. ath11k already defines a conversion function ath11k_vif_to_arvif() for a similar conversion. So introduce ath11k_sta_to_arsta() for this use case, and convert all of the existing typecasting to use this function. No functional changes, compile tested only. Signed-off-by: Jeff Johnson <quic_jjohnson@quicinc.com> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> Link: https://lore.kernel.org/r/20231009-ath11k_sta_to_arsta-v1-1-1563e3a307e8@quicinc.com Stable-dep-of: 97acb02 ("wifi: ath11k: fix group data packet drops during rekey") Signed-off-by: Sasha Levin <sashal@kernel.org> (cherry picked from commit 14ed9f84c7c01c5a3c068284a9cdf28b6c33a714)
1 parent 8d62123 commit 8f2b919

8 files changed

Lines changed: 41 additions & 36 deletions

File tree

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,6 +1234,11 @@ static inline struct ath11k_vif *ath11k_vif_to_arvif(struct ieee80211_vif *vif)
12341234
return (struct ath11k_vif *)vif->drv_priv;
12351235
}
12361236

1237+
static inline struct ath11k_sta *ath11k_sta_to_arsta(struct ieee80211_sta *sta)
1238+
{
1239+
return (struct ath11k_sta *)sta->drv_priv;
1240+
}
1241+
12371242
static inline struct ath11k *ath11k_ab_to_ar(struct ath11k_base *ab,
12381243
int mac_id)
12391244
{

drivers/net/wireless/ath/ath11k/debugfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,7 +1452,7 @@ static void ath11k_reset_peer_ps_duration(void *data,
14521452
struct ieee80211_sta *sta)
14531453
{
14541454
struct ath11k *ar = data;
1455-
struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
1455+
struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
14561456

14571457
spin_lock_bh(&ar->data_lock);
14581458
arsta->ps_total_duration = 0;
@@ -1503,7 +1503,7 @@ static void ath11k_peer_ps_state_disable(void *data,
15031503
struct ieee80211_sta *sta)
15041504
{
15051505
struct ath11k *ar = data;
1506-
struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
1506+
struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
15071507

15081508
spin_lock_bh(&ar->data_lock);
15091509
arsta->peer_ps_state = WMI_PEER_PS_STATE_DISABLED;

drivers/net/wireless/ath/ath11k/debugfs_sta.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static ssize_t ath11k_dbg_sta_dump_tx_stats(struct file *file,
137137
size_t count, loff_t *ppos)
138138
{
139139
struct ieee80211_sta *sta = file->private_data;
140-
struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
140+
struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
141141
struct ath11k *ar = arsta->arvif->ar;
142142
struct ath11k_htt_data_stats *stats;
143143
static const char *str_name[ATH11K_STATS_TYPE_MAX] = {"succ", "fail",
@@ -244,7 +244,7 @@ static ssize_t ath11k_dbg_sta_dump_rx_stats(struct file *file,
244244
size_t count, loff_t *ppos)
245245
{
246246
struct ieee80211_sta *sta = file->private_data;
247-
struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
247+
struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
248248
struct ath11k *ar = arsta->arvif->ar;
249249
struct ath11k_rx_peer_stats *rx_stats = arsta->rx_stats;
250250
int len = 0, i, retval = 0;
@@ -341,7 +341,7 @@ static int
341341
ath11k_dbg_sta_open_htt_peer_stats(struct inode *inode, struct file *file)
342342
{
343343
struct ieee80211_sta *sta = inode->i_private;
344-
struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
344+
struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
345345
struct ath11k *ar = arsta->arvif->ar;
346346
struct debug_htt_stats_req *stats_req;
347347
int type = ar->debug.htt_stats.type;
@@ -377,7 +377,7 @@ static int
377377
ath11k_dbg_sta_release_htt_peer_stats(struct inode *inode, struct file *file)
378378
{
379379
struct ieee80211_sta *sta = inode->i_private;
380-
struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
380+
struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
381381
struct ath11k *ar = arsta->arvif->ar;
382382

383383
mutex_lock(&ar->conf_mutex);
@@ -414,7 +414,7 @@ static ssize_t ath11k_dbg_sta_write_peer_pktlog(struct file *file,
414414
size_t count, loff_t *ppos)
415415
{
416416
struct ieee80211_sta *sta = file->private_data;
417-
struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
417+
struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
418418
struct ath11k *ar = arsta->arvif->ar;
419419
int ret, enable;
420420

@@ -454,7 +454,7 @@ static ssize_t ath11k_dbg_sta_read_peer_pktlog(struct file *file,
454454
size_t count, loff_t *ppos)
455455
{
456456
struct ieee80211_sta *sta = file->private_data;
457-
struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
457+
struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
458458
struct ath11k *ar = arsta->arvif->ar;
459459
char buf[32] = {0};
460460
int len;
@@ -481,7 +481,7 @@ static ssize_t ath11k_dbg_sta_write_delba(struct file *file,
481481
size_t count, loff_t *ppos)
482482
{
483483
struct ieee80211_sta *sta = file->private_data;
484-
struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
484+
struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
485485
struct ath11k *ar = arsta->arvif->ar;
486486
u32 tid, initiator, reason;
487487
int ret;
@@ -532,7 +532,7 @@ static ssize_t ath11k_dbg_sta_write_addba_resp(struct file *file,
532532
size_t count, loff_t *ppos)
533533
{
534534
struct ieee80211_sta *sta = file->private_data;
535-
struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
535+
struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
536536
struct ath11k *ar = arsta->arvif->ar;
537537
u32 tid, status;
538538
int ret;
@@ -582,7 +582,7 @@ static ssize_t ath11k_dbg_sta_write_addba(struct file *file,
582582
size_t count, loff_t *ppos)
583583
{
584584
struct ieee80211_sta *sta = file->private_data;
585-
struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
585+
struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
586586
struct ath11k *ar = arsta->arvif->ar;
587587
u32 tid, buf_size;
588588
int ret;
@@ -633,7 +633,7 @@ static ssize_t ath11k_dbg_sta_read_aggr_mode(struct file *file,
633633
size_t count, loff_t *ppos)
634634
{
635635
struct ieee80211_sta *sta = file->private_data;
636-
struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
636+
struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
637637
struct ath11k *ar = arsta->arvif->ar;
638638
char buf[64];
639639
int len = 0;
@@ -653,7 +653,7 @@ static ssize_t ath11k_dbg_sta_write_aggr_mode(struct file *file,
653653
size_t count, loff_t *ppos)
654654
{
655655
struct ieee80211_sta *sta = file->private_data;
656-
struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
656+
struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
657657
struct ath11k *ar = arsta->arvif->ar;
658658
u32 aggr_mode;
659659
int ret;
@@ -698,7 +698,7 @@ ath11k_write_htt_peer_stats_reset(struct file *file,
698698
size_t count, loff_t *ppos)
699699
{
700700
struct ieee80211_sta *sta = file->private_data;
701-
struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
701+
struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
702702
struct ath11k *ar = arsta->arvif->ar;
703703
struct htt_ext_stats_cfg_params cfg_params = { 0 };
704704
int ret;
@@ -757,7 +757,7 @@ static ssize_t ath11k_dbg_sta_read_peer_ps_state(struct file *file,
757757
size_t count, loff_t *ppos)
758758
{
759759
struct ieee80211_sta *sta = file->private_data;
760-
struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
760+
struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
761761
struct ath11k *ar = arsta->arvif->ar;
762762
char buf[20];
763763
int len;
@@ -784,7 +784,7 @@ static ssize_t ath11k_dbg_sta_read_current_ps_duration(struct file *file,
784784
loff_t *ppos)
785785
{
786786
struct ieee80211_sta *sta = file->private_data;
787-
struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
787+
struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
788788
struct ath11k *ar = arsta->arvif->ar;
789789
u64 time_since_station_in_power_save;
790790
char buf[20];
@@ -818,7 +818,7 @@ static ssize_t ath11k_dbg_sta_read_total_ps_duration(struct file *file,
818818
size_t count, loff_t *ppos)
819819
{
820820
struct ieee80211_sta *sta = file->private_data;
821-
struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
821+
struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
822822
struct ath11k *ar = arsta->arvif->ar;
823823
char buf[20];
824824
u64 power_save_duration;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ int ath11k_dp_rx_ampdu_start(struct ath11k *ar,
11001100
struct ieee80211_ampdu_params *params)
11011101
{
11021102
struct ath11k_base *ab = ar->ab;
1103-
struct ath11k_sta *arsta = (void *)params->sta->drv_priv;
1103+
struct ath11k_sta *arsta = ath11k_sta_to_arsta(params->sta);
11041104
int vdev_id = arsta->arvif->vdev_id;
11051105
int ret;
11061106

@@ -1118,7 +1118,7 @@ int ath11k_dp_rx_ampdu_stop(struct ath11k *ar,
11181118
{
11191119
struct ath11k_base *ab = ar->ab;
11201120
struct ath11k_peer *peer;
1121-
struct ath11k_sta *arsta = (void *)params->sta->drv_priv;
1121+
struct ath11k_sta *arsta = ath11k_sta_to_arsta(params->sta);
11221122
int vdev_id = arsta->arvif->vdev_id;
11231123
dma_addr_t paddr;
11241124
bool active;
@@ -1460,7 +1460,7 @@ ath11k_update_per_peer_tx_stats(struct ath11k *ar,
14601460
}
14611461

14621462
sta = peer->sta;
1463-
arsta = (struct ath11k_sta *)sta->drv_priv;
1463+
arsta = ath11k_sta_to_arsta(sta);
14641464

14651465
memset(&arsta->txrate, 0, sizeof(arsta->txrate));
14661466

@@ -5269,7 +5269,7 @@ int ath11k_dp_rx_process_mon_status(struct ath11k_base *ab, int mac_id,
52695269
goto next_skb;
52705270
}
52715271

5272-
arsta = (struct ath11k_sta *)peer->sta->drv_priv;
5272+
arsta = ath11k_sta_to_arsta(peer->sta);
52735273
ath11k_dp_rx_update_peer_stats(arsta, ppdu_info);
52745274

52755275
if (ath11k_debugfs_is_pktlog_peer_valid(ar, peer->addr))

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ void ath11k_dp_tx_update_txcompl(struct ath11k *ar, struct hal_tx_status *ts)
467467
}
468468

469469
sta = peer->sta;
470-
arsta = (struct ath11k_sta *)sta->drv_priv;
470+
arsta = ath11k_sta_to_arsta(sta);
471471

472472
memset(&arsta->txrate, 0, sizeof(arsta->txrate));
473473
pkt_type = FIELD_GET(HAL_TX_RATE_STATS_INFO0_PKT_TYPE,
@@ -627,7 +627,7 @@ static void ath11k_dp_tx_complete_msdu(struct ath11k *ar,
627627
ieee80211_free_txskb(ar->hw, msdu);
628628
return;
629629
}
630-
arsta = (struct ath11k_sta *)peer->sta->drv_priv;
630+
arsta = ath11k_sta_to_arsta(peer->sta);
631631
status.sta = peer->sta;
632632
status.skb = msdu;
633633
status.info = info;

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2828,7 +2828,7 @@ static void ath11k_peer_assoc_prepare(struct ath11k *ar,
28282828

28292829
lockdep_assert_held(&ar->conf_mutex);
28302830

2831-
arsta = (struct ath11k_sta *)sta->drv_priv;
2831+
arsta = ath11k_sta_to_arsta(sta);
28322832

28332833
memset(arg, 0, sizeof(*arg));
28342834

@@ -4311,7 +4311,7 @@ static int ath11k_mac_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
43114311
ath11k_warn(ab, "peer %pM disappeared!\n", peer_addr);
43124312

43134313
if (sta) {
4314-
arsta = (struct ath11k_sta *)sta->drv_priv;
4314+
arsta = ath11k_sta_to_arsta(sta);
43154315

43164316
switch (key->cipher) {
43174317
case WLAN_CIPHER_SUITE_TKIP:
@@ -4902,7 +4902,7 @@ static int ath11k_mac_station_add(struct ath11k *ar,
49024902
{
49034903
struct ath11k_base *ab = ar->ab;
49044904
struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
4905-
struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
4905+
struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
49064906
struct peer_create_params peer_param;
49074907
int ret;
49084908

@@ -5026,7 +5026,7 @@ static int ath11k_mac_op_sta_state(struct ieee80211_hw *hw,
50265026
{
50275027
struct ath11k *ar = hw->priv;
50285028
struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
5029-
struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
5029+
struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
50305030
struct ath11k_peer *peer;
50315031
int ret = 0;
50325032

@@ -5192,7 +5192,7 @@ static void ath11k_mac_op_sta_set_4addr(struct ieee80211_hw *hw,
51925192
struct ieee80211_sta *sta, bool enabled)
51935193
{
51945194
struct ath11k *ar = hw->priv;
5195-
struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
5195+
struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
51965196

51975197
if (enabled && !arsta->use_4addr_set) {
51985198
ieee80211_queue_work(ar->hw, &arsta->set_4addr_wk);
@@ -5206,7 +5206,7 @@ static void ath11k_mac_op_sta_rc_update(struct ieee80211_hw *hw,
52065206
u32 changed)
52075207
{
52085208
struct ath11k *ar = hw->priv;
5209-
struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
5209+
struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
52105210
struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
52115211
struct ath11k_peer *peer;
52125212
u32 bw, smps;
@@ -6207,7 +6207,7 @@ static void ath11k_mac_op_tx(struct ieee80211_hw *hw,
62076207
}
62086208

62096209
if (control->sta)
6210-
arsta = (struct ath11k_sta *)control->sta->drv_priv;
6210+
arsta = ath11k_sta_to_arsta(control->sta);
62116211

62126212
ret = ath11k_dp_tx(ar, arvif, arsta, skb);
62136213
if (unlikely(ret)) {
@@ -8231,7 +8231,7 @@ static void ath11k_mac_set_bitrate_mask_iter(void *data,
82318231
struct ieee80211_sta *sta)
82328232
{
82338233
struct ath11k_vif *arvif = data;
8234-
struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
8234+
struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
82358235
struct ath11k *ar = arvif->ar;
82368236

82378237
spin_lock_bh(&ar->data_lock);
@@ -8635,7 +8635,7 @@ static void ath11k_mac_op_sta_statistics(struct ieee80211_hw *hw,
86358635
struct ieee80211_sta *sta,
86368636
struct station_info *sinfo)
86378637
{
8638-
struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
8638+
struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
86398639
struct ath11k *ar = arsta->arvif->ar;
86408640
s8 signal;
86418641
bool db2dbm = test_bit(WMI_TLV_SERVICE_HW_DB2DBM_CONVERSION_SUPPORT,

drivers/net/wireless/ath/ath11k/peer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ int ath11k_peer_create(struct ath11k *ar, struct ath11k_vif *arvif,
446446
peer->sec_type_grp = HAL_ENCRYPT_TYPE_OPEN;
447447

448448
if (sta) {
449-
arsta = (struct ath11k_sta *)sta->drv_priv;
449+
arsta = ath11k_sta_to_arsta(sta);
450450
arsta->tcl_metadata |= FIELD_PREP(HTT_TCL_META_DATA_TYPE, 0) |
451451
FIELD_PREP(HTT_TCL_META_DATA_PEER_ID,
452452
peer->peer_id);

drivers/net/wireless/ath/ath11k/wmi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6452,7 +6452,7 @@ static int ath11k_wmi_tlv_rssi_chain_parse(struct ath11k_base *ab,
64526452
goto exit;
64536453
}
64546454

6455-
arsta = (struct ath11k_sta *)sta->drv_priv;
6455+
arsta = ath11k_sta_to_arsta(sta);
64566456

64576457
BUILD_BUG_ON(ARRAY_SIZE(arsta->chain_signal) >
64586458
ARRAY_SIZE(stats_rssi->rssi_avg_beacon));
@@ -6540,7 +6540,7 @@ static int ath11k_wmi_tlv_fw_stats_data_parse(struct ath11k_base *ab,
65406540
arvif->bssid,
65416541
NULL);
65426542
if (sta) {
6543-
arsta = (struct ath11k_sta *)sta->drv_priv;
6543+
arsta = ath11k_sta_to_arsta(sta);
65446544
arsta->rssi_beacon = src->beacon_snr;
65456545
ath11k_dbg(ab, ATH11K_DBG_WMI,
65466546
"stats vdev id %d snr %d\n",
@@ -7469,7 +7469,7 @@ static void ath11k_wmi_event_peer_sta_ps_state_chg(struct ath11k_base *ab,
74697469
goto exit;
74707470
}
74717471

7472-
arsta = (struct ath11k_sta *)sta->drv_priv;
7472+
arsta = ath11k_sta_to_arsta(sta);
74737473

74747474
spin_lock_bh(&ar->data_lock);
74757475

0 commit comments

Comments
 (0)