When injecting frames via radiotap, an HT MCS rate can be specified. The number of chains for that MCS implies a minimum number of antennas that must be enabled in the antenna bitmap. Previously, if the antenna bitmap specified fewer antennas than required by the MCS, the bitmap was silently cleared. This makes it hard to debug issues with injected frames. Add a WARN_ONCE() to log a descriptive error when this happens, make it clear that the antenna configuration was insufficient and has been reset. Signed-off-by: WangYuli <wangyuli@xxxxxxxxxxxxx> --- net/mac80211/tx.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index d58b80813bdd..e1464ef7397d 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -2251,14 +2251,21 @@ bool ieee80211_parse_tx_radiotap(struct sk_buff *skb, if (rate_flags & IEEE80211_TX_RC_MCS) { /* reset antennas if not enough */ if (IEEE80211_HT_MCS_CHAINS(rate) > - hweight8(info->control.antennas)) + hweight8(info->control.antennas)) { + WARN_ONCE(1, "Not enough antennas set for HT MCS chains (required: %d, set: %d), resetting antennas bitmap to 0\n", + IEEE80211_HT_MCS_CHAINS(rate), + hweight8(info->control.antennas)); info->control.antennas = 0; + } info->control.rates[0].idx = rate; } else if (rate_flags & IEEE80211_TX_RC_VHT_MCS) { /* reset antennas if not enough */ - if (vht_nss > hweight8(info->control.antennas)) + if (vht_nss > hweight8(info->control.antennas)) { + WARN_ONCE(1, "Not enough antennas set for VHT MCS chains (required: %d, set: %d), resetting antennas bitmap to 0\n", + vht_nss, hweight8(info->control.antennas)); info->control.antennas = 0; + } ieee80211_rate_set_vht(info->control.rates, vht_mcs, vht_nss); -- 2.50.0