]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
wifi: ath11k: Introduce and use ath11k_sta_to_arsta()
authorJeff Johnson <quic_jjohnson@quicinc.com>
Mon, 9 Oct 2023 16:39:42 +0000 (09:39 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 9 Sep 2025 16:56:23 +0000 (18:56 +0200)
[ Upstream commit 10c65f97b424fcee439463f933140df2a0022f98 ]

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: 97acb0259cc9 ("wifi: ath11k: fix group data packet drops during rekey")
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wireless/ath/ath11k/core.h
drivers/net/wireless/ath/ath11k/debugfs.c
drivers/net/wireless/ath/ath11k/debugfs_sta.c
drivers/net/wireless/ath/ath11k/dp_rx.c
drivers/net/wireless/ath/ath11k/dp_tx.c
drivers/net/wireless/ath/ath11k/mac.c
drivers/net/wireless/ath/ath11k/peer.c
drivers/net/wireless/ath/ath11k/wmi.c

index 812a174f74c0b38f7cbdf6dd0aa7a9c3be2f18de..fea96620e06721198881ad208370c1b6ae5964a3 100644 (file)
@@ -1234,6 +1234,11 @@ static inline struct ath11k_vif *ath11k_vif_to_arvif(struct ieee80211_vif *vif)
        return (struct ath11k_vif *)vif->drv_priv;
 }
 
+static inline struct ath11k_sta *ath11k_sta_to_arsta(struct ieee80211_sta *sta)
+{
+       return (struct ath11k_sta *)sta->drv_priv;
+}
+
 static inline struct ath11k *ath11k_ab_to_ar(struct ath11k_base *ab,
                                             int mac_id)
 {
index 50bc17127e68a36cf42aa793efa22cb802d25634..4304fed44d5839e2d09c546acffc1f86519d59ad 100644 (file)
@@ -1452,7 +1452,7 @@ static void ath11k_reset_peer_ps_duration(void *data,
                                          struct ieee80211_sta *sta)
 {
        struct ath11k *ar = data;
-       struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
+       struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
 
        spin_lock_bh(&ar->data_lock);
        arsta->ps_total_duration = 0;
@@ -1503,7 +1503,7 @@ static void ath11k_peer_ps_state_disable(void *data,
                                         struct ieee80211_sta *sta)
 {
        struct ath11k *ar = data;
-       struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
+       struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
 
        spin_lock_bh(&ar->data_lock);
        arsta->peer_ps_state = WMI_PEER_PS_STATE_DISABLED;
index 168879a380cb2d41033a4c9eb7748de75e49c098..f56a24b6c8da21ef522dc0ece75fdbbb0a29fe8e 100644 (file)
@@ -137,7 +137,7 @@ static ssize_t ath11k_dbg_sta_dump_tx_stats(struct file *file,
                                            size_t count, loff_t *ppos)
 {
        struct ieee80211_sta *sta = file->private_data;
-       struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
+       struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
        struct ath11k *ar = arsta->arvif->ar;
        struct ath11k_htt_data_stats *stats;
        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,
                                            size_t count, loff_t *ppos)
 {
        struct ieee80211_sta *sta = file->private_data;
-       struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
+       struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
        struct ath11k *ar = arsta->arvif->ar;
        struct ath11k_rx_peer_stats *rx_stats = arsta->rx_stats;
        int len = 0, i, retval = 0;
@@ -341,7 +341,7 @@ static int
 ath11k_dbg_sta_open_htt_peer_stats(struct inode *inode, struct file *file)
 {
        struct ieee80211_sta *sta = inode->i_private;
-       struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
+       struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
        struct ath11k *ar = arsta->arvif->ar;
        struct debug_htt_stats_req *stats_req;
        int type = ar->debug.htt_stats.type;
@@ -377,7 +377,7 @@ static int
 ath11k_dbg_sta_release_htt_peer_stats(struct inode *inode, struct file *file)
 {
        struct ieee80211_sta *sta = inode->i_private;
-       struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
+       struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
        struct ath11k *ar = arsta->arvif->ar;
 
        mutex_lock(&ar->conf_mutex);
@@ -414,7 +414,7 @@ static ssize_t ath11k_dbg_sta_write_peer_pktlog(struct file *file,
                                                size_t count, loff_t *ppos)
 {
        struct ieee80211_sta *sta = file->private_data;
-       struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
+       struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
        struct ath11k *ar = arsta->arvif->ar;
        int ret, enable;
 
@@ -454,7 +454,7 @@ static ssize_t ath11k_dbg_sta_read_peer_pktlog(struct file *file,
                                               size_t count, loff_t *ppos)
 {
        struct ieee80211_sta *sta = file->private_data;
-       struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
+       struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
        struct ath11k *ar = arsta->arvif->ar;
        char buf[32] = {0};
        int len;
@@ -481,7 +481,7 @@ static ssize_t ath11k_dbg_sta_write_delba(struct file *file,
                                          size_t count, loff_t *ppos)
 {
        struct ieee80211_sta *sta = file->private_data;
-       struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
+       struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
        struct ath11k *ar = arsta->arvif->ar;
        u32 tid, initiator, reason;
        int ret;
@@ -532,7 +532,7 @@ static ssize_t ath11k_dbg_sta_write_addba_resp(struct file *file,
                                               size_t count, loff_t *ppos)
 {
        struct ieee80211_sta *sta = file->private_data;
-       struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
+       struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
        struct ath11k *ar = arsta->arvif->ar;
        u32 tid, status;
        int ret;
@@ -582,7 +582,7 @@ static ssize_t ath11k_dbg_sta_write_addba(struct file *file,
                                          size_t count, loff_t *ppos)
 {
        struct ieee80211_sta *sta = file->private_data;
-       struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
+       struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
        struct ath11k *ar = arsta->arvif->ar;
        u32 tid, buf_size;
        int ret;
@@ -633,7 +633,7 @@ static ssize_t ath11k_dbg_sta_read_aggr_mode(struct file *file,
                                             size_t count, loff_t *ppos)
 {
        struct ieee80211_sta *sta = file->private_data;
-       struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
+       struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
        struct ath11k *ar = arsta->arvif->ar;
        char buf[64];
        int len = 0;
@@ -653,7 +653,7 @@ static ssize_t ath11k_dbg_sta_write_aggr_mode(struct file *file,
                                              size_t count, loff_t *ppos)
 {
        struct ieee80211_sta *sta = file->private_data;
-       struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
+       struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
        struct ath11k *ar = arsta->arvif->ar;
        u32 aggr_mode;
        int ret;
@@ -698,7 +698,7 @@ ath11k_write_htt_peer_stats_reset(struct file *file,
                                  size_t count, loff_t *ppos)
 {
        struct ieee80211_sta *sta = file->private_data;
-       struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
+       struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
        struct ath11k *ar = arsta->arvif->ar;
        struct htt_ext_stats_cfg_params cfg_params = { 0 };
        int ret;
@@ -757,7 +757,7 @@ static ssize_t ath11k_dbg_sta_read_peer_ps_state(struct file *file,
                                                 size_t count, loff_t *ppos)
 {
        struct ieee80211_sta *sta = file->private_data;
-       struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
+       struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
        struct ath11k *ar = arsta->arvif->ar;
        char buf[20];
        int len;
@@ -784,7 +784,7 @@ static ssize_t ath11k_dbg_sta_read_current_ps_duration(struct file *file,
                                                       loff_t *ppos)
 {
        struct ieee80211_sta *sta = file->private_data;
-       struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
+       struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
        struct ath11k *ar = arsta->arvif->ar;
        u64 time_since_station_in_power_save;
        char buf[20];
@@ -818,7 +818,7 @@ static ssize_t ath11k_dbg_sta_read_total_ps_duration(struct file *file,
                                                     size_t count, loff_t *ppos)
 {
        struct ieee80211_sta *sta = file->private_data;
-       struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
+       struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
        struct ath11k *ar = arsta->arvif->ar;
        char buf[20];
        u64 power_save_duration;
index 33b9764eaa91671ae2031efece969250b83ff746..8cc51ab699de78498b1bb6bfb0f5cfe2e95e5833 100644 (file)
@@ -1100,7 +1100,7 @@ int ath11k_dp_rx_ampdu_start(struct ath11k *ar,
                             struct ieee80211_ampdu_params *params)
 {
        struct ath11k_base *ab = ar->ab;
-       struct ath11k_sta *arsta = (void *)params->sta->drv_priv;
+       struct ath11k_sta *arsta = ath11k_sta_to_arsta(params->sta);
        int vdev_id = arsta->arvif->vdev_id;
        int ret;
 
@@ -1118,7 +1118,7 @@ int ath11k_dp_rx_ampdu_stop(struct ath11k *ar,
 {
        struct ath11k_base *ab = ar->ab;
        struct ath11k_peer *peer;
-       struct ath11k_sta *arsta = (void *)params->sta->drv_priv;
+       struct ath11k_sta *arsta = ath11k_sta_to_arsta(params->sta);
        int vdev_id = arsta->arvif->vdev_id;
        dma_addr_t paddr;
        bool active;
@@ -1460,7 +1460,7 @@ ath11k_update_per_peer_tx_stats(struct ath11k *ar,
        }
 
        sta = peer->sta;
-       arsta = (struct ath11k_sta *)sta->drv_priv;
+       arsta = ath11k_sta_to_arsta(sta);
 
        memset(&arsta->txrate, 0, sizeof(arsta->txrate));
 
@@ -5269,7 +5269,7 @@ int ath11k_dp_rx_process_mon_status(struct ath11k_base *ab, int mac_id,
                        goto next_skb;
                }
 
-               arsta = (struct ath11k_sta *)peer->sta->drv_priv;
+               arsta = ath11k_sta_to_arsta(peer->sta);
                ath11k_dp_rx_update_peer_stats(arsta, ppdu_info);
 
                if (ath11k_debugfs_is_pktlog_peer_valid(ar, peer->addr))
index 7dd1ee589801775bde796c3c3ad6e92c7b2e4f5d..c1072e66e3e8fd07f921466b014c271e08f5d3ba 100644 (file)
@@ -467,7 +467,7 @@ void ath11k_dp_tx_update_txcompl(struct ath11k *ar, struct hal_tx_status *ts)
        }
 
        sta = peer->sta;
-       arsta = (struct ath11k_sta *)sta->drv_priv;
+       arsta = ath11k_sta_to_arsta(sta);
 
        memset(&arsta->txrate, 0, sizeof(arsta->txrate));
        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,
                ieee80211_free_txskb(ar->hw, msdu);
                return;
        }
-       arsta = (struct ath11k_sta *)peer->sta->drv_priv;
+       arsta = ath11k_sta_to_arsta(peer->sta);
        status.sta = peer->sta;
        status.skb = msdu;
        status.info = info;
index 9df3f6449f76896fb66c92e8c21da454863306f0..cc9c09d05f63f4e6d49c406de5c80babfa0b217a 100644 (file)
@@ -2828,7 +2828,7 @@ static void ath11k_peer_assoc_prepare(struct ath11k *ar,
 
        lockdep_assert_held(&ar->conf_mutex);
 
-       arsta = (struct ath11k_sta *)sta->drv_priv;
+       arsta = ath11k_sta_to_arsta(sta);
 
        memset(arg, 0, sizeof(*arg));
 
@@ -4311,7 +4311,7 @@ static int ath11k_mac_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
                ath11k_warn(ab, "peer %pM disappeared!\n", peer_addr);
 
        if (sta) {
-               arsta = (struct ath11k_sta *)sta->drv_priv;
+               arsta = ath11k_sta_to_arsta(sta);
 
                switch (key->cipher) {
                case WLAN_CIPHER_SUITE_TKIP:
@@ -4902,7 +4902,7 @@ static int ath11k_mac_station_add(struct ath11k *ar,
 {
        struct ath11k_base *ab = ar->ab;
        struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
-       struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
+       struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
        struct peer_create_params peer_param;
        int ret;
 
@@ -5026,7 +5026,7 @@ static int ath11k_mac_op_sta_state(struct ieee80211_hw *hw,
 {
        struct ath11k *ar = hw->priv;
        struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
-       struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
+       struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
        struct ath11k_peer *peer;
        int ret = 0;
 
@@ -5192,7 +5192,7 @@ static void ath11k_mac_op_sta_set_4addr(struct ieee80211_hw *hw,
                                        struct ieee80211_sta *sta, bool enabled)
 {
        struct ath11k *ar = hw->priv;
-       struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
+       struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
 
        if (enabled && !arsta->use_4addr_set) {
                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,
                                        u32 changed)
 {
        struct ath11k *ar = hw->priv;
-       struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
+       struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
        struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
        struct ath11k_peer *peer;
        u32 bw, smps;
@@ -6204,7 +6204,7 @@ static void ath11k_mac_op_tx(struct ieee80211_hw *hw,
        }
 
        if (control->sta)
-               arsta = (struct ath11k_sta *)control->sta->drv_priv;
+               arsta = ath11k_sta_to_arsta(control->sta);
 
        ret = ath11k_dp_tx(ar, arvif, arsta, skb);
        if (unlikely(ret)) {
@@ -8228,7 +8228,7 @@ static void ath11k_mac_set_bitrate_mask_iter(void *data,
                                             struct ieee80211_sta *sta)
 {
        struct ath11k_vif *arvif = data;
-       struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
+       struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
        struct ath11k *ar = arvif->ar;
 
        spin_lock_bh(&ar->data_lock);
@@ -8632,7 +8632,7 @@ static void ath11k_mac_op_sta_statistics(struct ieee80211_hw *hw,
                                         struct ieee80211_sta *sta,
                                         struct station_info *sinfo)
 {
-       struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
+       struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
        struct ath11k *ar = arsta->arvif->ar;
        s8 signal;
        bool db2dbm = test_bit(WMI_TLV_SERVICE_HW_DB2DBM_CONVERSION_SUPPORT,
index ca719eb3f7f82994d449c206ec432e468b06891d..6d0126c3930185a625e33592e7b4ea72642fa395 100644 (file)
@@ -446,7 +446,7 @@ int ath11k_peer_create(struct ath11k *ar, struct ath11k_vif *arvif,
        peer->sec_type_grp = HAL_ENCRYPT_TYPE_OPEN;
 
        if (sta) {
-               arsta = (struct ath11k_sta *)sta->drv_priv;
+               arsta = ath11k_sta_to_arsta(sta);
                arsta->tcl_metadata |= FIELD_PREP(HTT_TCL_META_DATA_TYPE, 0) |
                                       FIELD_PREP(HTT_TCL_META_DATA_PEER_ID,
                                                  peer->peer_id);
index 9a829b8282420a0083865f214fa86ecd263b3dfb..31dbabc9eaf330d73f72e1d9f6e58b89a09dbf0e 100644 (file)
@@ -6452,7 +6452,7 @@ static int ath11k_wmi_tlv_rssi_chain_parse(struct ath11k_base *ab,
                goto exit;
        }
 
-       arsta = (struct ath11k_sta *)sta->drv_priv;
+       arsta = ath11k_sta_to_arsta(sta);
 
        BUILD_BUG_ON(ARRAY_SIZE(arsta->chain_signal) >
                     ARRAY_SIZE(stats_rssi->rssi_avg_beacon));
@@ -6540,7 +6540,7 @@ static int ath11k_wmi_tlv_fw_stats_data_parse(struct ath11k_base *ab,
                                                           arvif->bssid,
                                                           NULL);
                        if (sta) {
-                               arsta = (struct ath11k_sta *)sta->drv_priv;
+                               arsta = ath11k_sta_to_arsta(sta);
                                arsta->rssi_beacon = src->beacon_snr;
                                ath11k_dbg(ab, ATH11K_DBG_WMI,
                                           "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,
                goto exit;
        }
 
-       arsta = (struct ath11k_sta *)sta->drv_priv;
+       arsta = ath11k_sta_to_arsta(sta);
 
        spin_lock_bh(&ar->data_lock);