Skip to content

Commit e5c0ee0

Browse files
committed
wifi: mac80211: status: look up band only where needed
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 <[email protected]>
1 parent 37a7d0d commit e5c0ee0

File tree

5 files changed

+13
-23
lines changed

5 files changed

+13
-23
lines changed

net/mac80211/ieee80211_i.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2036,7 +2036,6 @@ struct sk_buff *
20362036
ieee80211_build_data_template(struct ieee80211_sub_if_data *sdata,
20372037
struct sk_buff *skb, u32 info_flags);
20382038
void ieee80211_tx_monitor(struct ieee80211_local *local, struct sk_buff *skb,
2039-
struct ieee80211_supported_band *sband,
20402039
int retry_count, int shift, bool send_to_cooked,
20412040
struct ieee80211_tx_status *status);
20422041

net/mac80211/rate.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,18 @@ void rate_control_rate_init(struct sta_info *sta)
6868
}
6969

7070
void rate_control_tx_status(struct ieee80211_local *local,
71-
struct ieee80211_supported_band *sband,
7271
struct ieee80211_tx_status *st)
7372
{
7473
struct rate_control_ref *ref = local->rate_ctrl;
7574
struct sta_info *sta = container_of(st->sta, struct sta_info, sta);
7675
void *priv_sta = sta->rate_ctrl_priv;
76+
struct ieee80211_supported_band *sband;
7777

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

81+
sband = local->hw.wiphy->bands[st->info->band];
82+
8183
spin_lock_bh(&sta->rate_ctrl_lock);
8284
if (ref->ops->tx_status_ext)
8385
ref->ops->tx_status_ext(ref->priv, sband, priv_sta, st);

net/mac80211/rate.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,
2727
struct ieee80211_tx_rate_control *txrc);
2828

2929
void rate_control_tx_status(struct ieee80211_local *local,
30-
struct ieee80211_supported_band *sband,
3130
struct ieee80211_tx_status *st);
3231

3332
void rate_control_rate_init(struct sta_info *sta);

net/mac80211/status.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,6 @@ static int ieee80211_tx_radiotap_len(struct ieee80211_tx_info *info,
293293

294294
static void
295295
ieee80211_add_tx_radiotap_header(struct ieee80211_local *local,
296-
struct ieee80211_supported_band *sband,
297296
struct sk_buff *skb, int retry_count,
298297
int rtap_len, int shift,
299298
struct ieee80211_tx_status *status)
@@ -336,9 +335,13 @@ ieee80211_add_tx_radiotap_header(struct ieee80211_local *local,
336335
legacy_rate = status_rate->rate_idx.legacy;
337336
} else if (info->status.rates[0].idx >= 0 &&
338337
!(info->status.rates[0].flags & (IEEE80211_TX_RC_MCS |
339-
IEEE80211_TX_RC_VHT_MCS)))
338+
IEEE80211_TX_RC_VHT_MCS))) {
339+
struct ieee80211_supported_band *sband;
340+
341+
sband = local->hw.wiphy->bands[info->band];
340342
legacy_rate =
341343
sband->bitrates[info->status.rates[0].idx].bitrate;
344+
}
342345

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

847850
void ieee80211_tx_monitor(struct ieee80211_local *local, struct sk_buff *skb,
848-
struct ieee80211_supported_band *sband,
849851
int retry_count, int shift, bool send_to_cooked,
850852
struct ieee80211_tx_status *status)
851853
{
@@ -862,7 +864,7 @@ void ieee80211_tx_monitor(struct ieee80211_local *local, struct sk_buff *skb,
862864
dev_kfree_skb(skb);
863865
return;
864866
}
865-
ieee80211_add_tx_radiotap_header(local, sband, skb, retry_count,
867+
ieee80211_add_tx_radiotap_header(local, skb, retry_count,
866868
rtap_len, shift, status);
867869

868870
/* XXX: is this sufficient for BPF? */
@@ -912,15 +914,13 @@ static void __ieee80211_tx_status(struct ieee80211_hw *hw,
912914
struct ieee80211_tx_info *info = status->info;
913915
struct sta_info *sta;
914916
__le16 fc;
915-
struct ieee80211_supported_band *sband;
916917
bool send_to_cooked;
917918
bool acked;
918919
bool noack_success;
919920
struct ieee80211_bar *bar;
920921
int shift = 0;
921922
int tid = IEEE80211_NUM_TIDS;
922923

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

926926
if (status->sta) {
@@ -1082,7 +1082,7 @@ static void __ieee80211_tx_status(struct ieee80211_hw *hw,
10821082
}
10831083

10841084
/* send to monitor interfaces */
1085-
ieee80211_tx_monitor(local, skb, sband, retry_count, shift,
1085+
ieee80211_tx_monitor(local, skb, retry_count, shift,
10861086
send_to_cooked, status);
10871087
}
10881088

@@ -1114,7 +1114,6 @@ void ieee80211_tx_status_ext(struct ieee80211_hw *hw,
11141114
struct ieee80211_tx_info *info = status->info;
11151115
struct ieee80211_sta *pubsta = status->sta;
11161116
struct sk_buff *skb = status->skb;
1117-
struct ieee80211_supported_band *sband;
11181117
struct sta_info *sta = NULL;
11191118
int rates_idx, retry_count;
11201119
bool acked, noack_success, ack_signal_valid;
@@ -1145,8 +1144,6 @@ void ieee80211_tx_status_ext(struct ieee80211_hw *hw,
11451144

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

1148-
sband = hw->wiphy->bands[info->band];
1149-
11501147
acked = !!(info->flags & IEEE80211_TX_STAT_ACK);
11511148
noack_success = !!(info->flags & IEEE80211_TX_STAT_NOACK_TRANSMITTED);
11521149
ack_signal_valid =
@@ -1201,7 +1198,7 @@ void ieee80211_tx_status_ext(struct ieee80211_hw *hw,
12011198
}
12021199
}
12031200

1204-
rate_control_tx_status(local, sband, status);
1201+
rate_control_tx_status(local, status);
12051202
if (ieee80211_vif_is_mesh(&sta->sdata->vif))
12061203
ieee80211s_update_metric(local, sta, status);
12071204
}
@@ -1239,14 +1236,13 @@ void ieee80211_tx_rate_update(struct ieee80211_hw *hw,
12391236
struct ieee80211_tx_info *info)
12401237
{
12411238
struct ieee80211_local *local = hw_to_local(hw);
1242-
struct ieee80211_supported_band *sband = hw->wiphy->bands[info->band];
12431239
struct sta_info *sta = container_of(pubsta, struct sta_info, sta);
12441240
struct ieee80211_tx_status status = {
12451241
.info = info,
12461242
.sta = pubsta,
12471243
};
12481244

1249-
rate_control_tx_status(local, sband, &status);
1245+
rate_control_tx_status(local, &status);
12501246

12511247
if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL))
12521248
sta->deflink.tx_stats.last_rate = info->status.rates[0];

net/mac80211/tx.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5228,7 +5228,6 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
52285228
struct ieee80211_mutable_offsets offs = {};
52295229
struct sk_buff *bcn = __ieee80211_beacon_get(hw, vif, &offs, false);
52305230
struct sk_buff *copy;
5231-
struct ieee80211_supported_band *sband;
52325231
int shift;
52335232

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

52525251
shift = ieee80211_vif_get_shift(vif);
5253-
sband = ieee80211_get_sband(vif_to_sdata(vif));
5254-
if (!sband)
5255-
return bcn;
5256-
5257-
ieee80211_tx_monitor(hw_to_local(hw), copy, sband, 1, shift, false,
5258-
NULL);
5252+
ieee80211_tx_monitor(hw_to_local(hw), copy, 1, shift, false, NULL);
52595253

52605254
return bcn;
52615255
}

0 commit comments

Comments
 (0)