Commit 10c65f97 authored by Jeff Johnson's avatar Jeff Johnson Committed by Kalle Valo
Browse files

wifi: ath11k: Introduce and use ath11k_sta_to_arsta()



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: default avatarJeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: default avatarKalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231009-ath11k_sta_to_arsta-v1-1-1563e3a307e8@quicinc.com
parent 480d230b
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1223,6 +1223,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)
{
+2 −2
Original line number Diff line number Diff line
@@ -1459,7 +1459,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;
@@ -1510,7 +1510,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;
+15 −15
Original line number Diff line number Diff line
@@ -136,7 +136,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",
@@ -243,7 +243,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;
@@ -340,7 +340,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;
@@ -376,7 +376,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);
@@ -413,7 +413,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;

@@ -453,7 +453,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;
@@ -480,7 +480,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;
@@ -531,7 +531,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;
@@ -581,7 +581,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;
@@ -632,7 +632,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;
@@ -652,7 +652,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;
@@ -697,7 +697,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;
@@ -756,7 +756,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;
@@ -783,7 +783,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];
@@ -817,7 +817,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;
+4 −4
Original line number Diff line number Diff line
@@ -1099,7 +1099,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;

@@ -1117,7 +1117,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;
@@ -1456,7 +1456,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));

@@ -5242,7 +5242,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))
+2 −2
Original line number Diff line number Diff line
@@ -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;
Loading