Skip to content

Commit

Permalink
wifi: mac80211: clean up band switch in duration
Browse files Browse the repository at this point in the history
Most devices now do duration calculations, so we don't hit
this code at all any more. Clearly the approach of warning
at compile time here when new bands are added didn't work,
the new bands were just added with "TODO". Clean it up, it
won't matter for new bands since they'll just not have any
need to calculate durations in software.

While at it, also clean up and unify the code a bit.

Link: https://msgid.link/20240129194108.70a97bd69265.Icdd8b0ac60a382244466510090eb0f5868151f39@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  • Loading branch information
Johannes Berg committed Feb 8, 2024
1 parent efa2cce commit 61f0261
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions net/mac80211/tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ static __le16 ieee80211_duration(struct ieee80211_tx_data *tx,
mrate = sband->bitrates[0].bitrate;
for (i = 0; i < sband->n_bitrates; i++) {
struct ieee80211_rate *r = &sband->bitrates[i];
u32 flag;

if (r->bitrate > txrate->bitrate)
break;
Expand All @@ -145,28 +146,24 @@ static __le16 ieee80211_duration(struct ieee80211_tx_data *tx,

switch (sband->band) {
case NL80211_BAND_2GHZ:
case NL80211_BAND_LC: {
u32 flag;
case NL80211_BAND_LC:
if (tx->sdata->deflink.operating_11g_mode)
flag = IEEE80211_RATE_MANDATORY_G;
else
flag = IEEE80211_RATE_MANDATORY_B;
if (r->flags & flag)
mrate = r->bitrate;
break;
}
case NL80211_BAND_5GHZ:
case NL80211_BAND_6GHZ:
if (r->flags & IEEE80211_RATE_MANDATORY_A)
mrate = r->bitrate;
flag = IEEE80211_RATE_MANDATORY_A;
break;
case NL80211_BAND_S1GHZ:
case NL80211_BAND_60GHZ:
/* TODO, for now fall through */
case NUM_NL80211_BANDS:
default:
flag = 0;
WARN_ON(1);
break;
}

if (r->flags & flag)
mrate = r->bitrate;
}
if (rate == -1) {
/* No matching basic rate found; use highest suitable mandatory
Expand Down

0 comments on commit 61f0261

Please sign in to comment.