Skip to content

Commit

Permalink
wifi: mac80211: status: look up band only where needed
Browse files Browse the repository at this point in the history
For MLD, we might eventually not really know the band on status,
but some code assumes it's there. Move the sband lookup deep to
the code that actually needs it, to make it clear where exactly
it's needed and for what purposes.

For rate control, at least initially we won't support it in MLO,
so that won't be an issue.

For TX monitoring, we may have to elide the rate and/or rely on
ieee80211_tx_status_ext() for rate information.

This also simplifies the function prototypes.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  • Loading branch information
Johannes Berg committed Jun 20, 2022
1 parent 37a7d0d commit e5c0ee0
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 23 deletions.
1 change: 0 additions & 1 deletion net/mac80211/ieee80211_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -2036,7 +2036,6 @@ struct sk_buff *
ieee80211_build_data_template(struct ieee80211_sub_if_data *sdata,
struct sk_buff *skb, u32 info_flags);
void ieee80211_tx_monitor(struct ieee80211_local *local, struct sk_buff *skb,
struct ieee80211_supported_band *sband,
int retry_count, int shift, bool send_to_cooked,
struct ieee80211_tx_status *status);

Expand Down
4 changes: 3 additions & 1 deletion net/mac80211/rate.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,18 @@ void rate_control_rate_init(struct sta_info *sta)
}

void rate_control_tx_status(struct ieee80211_local *local,
struct ieee80211_supported_band *sband,
struct ieee80211_tx_status *st)
{
struct rate_control_ref *ref = local->rate_ctrl;
struct sta_info *sta = container_of(st->sta, struct sta_info, sta);
void *priv_sta = sta->rate_ctrl_priv;
struct ieee80211_supported_band *sband;

if (!ref || !test_sta_flag(sta, WLAN_STA_RATE_CONTROL))
return;

sband = local->hw.wiphy->bands[st->info->band];

spin_lock_bh(&sta->rate_ctrl_lock);
if (ref->ops->tx_status_ext)
ref->ops->tx_status_ext(ref->priv, sband, priv_sta, st);
Expand Down
1 change: 0 additions & 1 deletion net/mac80211/rate.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,
struct ieee80211_tx_rate_control *txrc);

void rate_control_tx_status(struct ieee80211_local *local,
struct ieee80211_supported_band *sband,
struct ieee80211_tx_status *st);

void rate_control_rate_init(struct sta_info *sta);
Expand Down
22 changes: 9 additions & 13 deletions net/mac80211/status.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ static int ieee80211_tx_radiotap_len(struct ieee80211_tx_info *info,

static void
ieee80211_add_tx_radiotap_header(struct ieee80211_local *local,
struct ieee80211_supported_band *sband,
struct sk_buff *skb, int retry_count,
int rtap_len, int shift,
struct ieee80211_tx_status *status)
Expand Down Expand Up @@ -336,9 +335,13 @@ ieee80211_add_tx_radiotap_header(struct ieee80211_local *local,
legacy_rate = status_rate->rate_idx.legacy;
} else if (info->status.rates[0].idx >= 0 &&
!(info->status.rates[0].flags & (IEEE80211_TX_RC_MCS |
IEEE80211_TX_RC_VHT_MCS)))
IEEE80211_TX_RC_VHT_MCS))) {
struct ieee80211_supported_band *sband;

sband = local->hw.wiphy->bands[info->band];
legacy_rate =
sband->bitrates[info->status.rates[0].idx].bitrate;
}

if (legacy_rate) {
rthdr->it_present |= cpu_to_le32(BIT(IEEE80211_RADIOTAP_RATE));
Expand Down Expand Up @@ -845,7 +848,6 @@ static int ieee80211_tx_get_rates(struct ieee80211_hw *hw,
}

void ieee80211_tx_monitor(struct ieee80211_local *local, struct sk_buff *skb,
struct ieee80211_supported_band *sband,
int retry_count, int shift, bool send_to_cooked,
struct ieee80211_tx_status *status)
{
Expand All @@ -862,7 +864,7 @@ void ieee80211_tx_monitor(struct ieee80211_local *local, struct sk_buff *skb,
dev_kfree_skb(skb);
return;
}
ieee80211_add_tx_radiotap_header(local, sband, skb, retry_count,
ieee80211_add_tx_radiotap_header(local, skb, retry_count,
rtap_len, shift, status);

/* XXX: is this sufficient for BPF? */
Expand Down Expand Up @@ -912,15 +914,13 @@ static void __ieee80211_tx_status(struct ieee80211_hw *hw,
struct ieee80211_tx_info *info = status->info;
struct sta_info *sta;
__le16 fc;
struct ieee80211_supported_band *sband;
bool send_to_cooked;
bool acked;
bool noack_success;
struct ieee80211_bar *bar;
int shift = 0;
int tid = IEEE80211_NUM_TIDS;

sband = local->hw.wiphy->bands[info->band];
fc = hdr->frame_control;

if (status->sta) {
Expand Down Expand Up @@ -1082,7 +1082,7 @@ static void __ieee80211_tx_status(struct ieee80211_hw *hw,
}

/* send to monitor interfaces */
ieee80211_tx_monitor(local, skb, sband, retry_count, shift,
ieee80211_tx_monitor(local, skb, retry_count, shift,
send_to_cooked, status);
}

Expand Down Expand Up @@ -1114,7 +1114,6 @@ void ieee80211_tx_status_ext(struct ieee80211_hw *hw,
struct ieee80211_tx_info *info = status->info;
struct ieee80211_sta *pubsta = status->sta;
struct sk_buff *skb = status->skb;
struct ieee80211_supported_band *sband;
struct sta_info *sta = NULL;
int rates_idx, retry_count;
bool acked, noack_success, ack_signal_valid;
Expand Down Expand Up @@ -1145,8 +1144,6 @@ void ieee80211_tx_status_ext(struct ieee80211_hw *hw,

rates_idx = ieee80211_tx_get_rates(hw, info, &retry_count);

sband = hw->wiphy->bands[info->band];

acked = !!(info->flags & IEEE80211_TX_STAT_ACK);
noack_success = !!(info->flags & IEEE80211_TX_STAT_NOACK_TRANSMITTED);
ack_signal_valid =
Expand Down Expand Up @@ -1201,7 +1198,7 @@ void ieee80211_tx_status_ext(struct ieee80211_hw *hw,
}
}

rate_control_tx_status(local, sband, status);
rate_control_tx_status(local, status);
if (ieee80211_vif_is_mesh(&sta->sdata->vif))
ieee80211s_update_metric(local, sta, status);
}
Expand Down Expand Up @@ -1239,14 +1236,13 @@ void ieee80211_tx_rate_update(struct ieee80211_hw *hw,
struct ieee80211_tx_info *info)
{
struct ieee80211_local *local = hw_to_local(hw);
struct ieee80211_supported_band *sband = hw->wiphy->bands[info->band];
struct sta_info *sta = container_of(pubsta, struct sta_info, sta);
struct ieee80211_tx_status status = {
.info = info,
.sta = pubsta,
};

rate_control_tx_status(local, sband, &status);
rate_control_tx_status(local, &status);

if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL))
sta->deflink.tx_stats.last_rate = info->status.rates[0];
Expand Down
8 changes: 1 addition & 7 deletions net/mac80211/tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -5228,7 +5228,6 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
struct ieee80211_mutable_offsets offs = {};
struct sk_buff *bcn = __ieee80211_beacon_get(hw, vif, &offs, false);
struct sk_buff *copy;
struct ieee80211_supported_band *sband;
int shift;

if (!bcn)
Expand All @@ -5250,12 +5249,7 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
return bcn;

shift = ieee80211_vif_get_shift(vif);
sband = ieee80211_get_sband(vif_to_sdata(vif));
if (!sband)
return bcn;

ieee80211_tx_monitor(hw_to_local(hw), copy, sband, 1, shift, false,
NULL);
ieee80211_tx_monitor(hw_to_local(hw), copy, 1, shift, false, NULL);

return bcn;
}
Expand Down

0 comments on commit e5c0ee0

Please sign in to comment.