ath9k_hw: fix a regression in key miss handling
PATCH 1/2 ath9k_hw: fix a regression in key miss handling
The commit "ath9k_hw: Fix incorrect key_miss handling" changed the code to only report key miss errors if a MIC error wasn't reported. When checking the flags in that order in the MAC code, it might miss some real events, because the value of the MIC error flag is undefined under some conditions.
The primary issue addressed by the previous commit is making sure that MIC errors are properly reported on the STA side. This can be fixed in a better way by adding a separate rx status flag for key miss and ignoring it for multicast frames.
This fix slightly improves stability in AP mode on some older hardware, like AR9132.
--- drivers/net/wireless/ath/ath9k/ar9003_mac.c | 4 ++-- drivers/net/wireless/ath/ath9k/mac.c | 4 ++-- drivers/net/wireless/ath/ath9k/mac.h | 1 + drivers/net/wireless/ath/ath9k/recv.c | 27 ++++++++++++++------------- 4 files changed, 19 insertions(+), 17 deletions(-)
drivers/net/wireless/ath/ath9k/ar9003_mac.c +2 -2
@@ -525,8 +525,8 @@ int ath9k_hw_process_rxdesc_edma(struct ath_hw *ah, struct ath_rx_status *rxs, rxs->rs_status |=ATH9K_RXERR_DECRYPT ; else if (rxsp->status11 & AR_MichaelErr) rxs->rs_status |= ATH9K_RXERR_MIC; - else if (rxsp->status11 & AR_KeyMiss) - rxs->rs_status |= ATH9K_RXERR_DECRYPT; +if (rxsp->status11 & AR_KeyMiss) + rxs->rs_status |=ATH9K_RXERR_KEYMISS ; }return 0 ;
drivers/net/wireless/ath/ath9k/mac.c +2 -2
@@ -620,8 +620,8 @@ int ath9k_hw_rxprocdesc(struct ath_hw *ah, struct ath_desc *ds, rs->rs_status |=ATH9K_RXERR_DECRYPT ; else if (ads.ds_rxstatus8 & AR_MichaelErr) rs->rs_status |= ATH9K_RXERR_MIC; - else if (ads.ds_rxstatus8 & AR_KeyMiss) - rs->rs_status |= ATH9K_RXERR_DECRYPT; +if (ads.ds_rxstatus8 & AR_KeyMiss) + rs->rs_status |=ATH9K_RXERR_KEYMISS ; }return 0 ;
drivers/net/wireless/ath/ath9k/mac.h +1 -0
@@ -181,6 +181,7 @@ struct ath_htc_rx_status {#define ATH9K_RXERR_FIFO 0x04#define ATH9K_RXERR_DECRYPT 0x08#define ATH9K_RXERR_MIC 0x10 +#define ATH9K_RXERR_KEYMISS 0x20#define ATH9K_RX_MORE 0x01#define ATH9K_RX_MORE_AGGR 0x02
drivers/net/wireless/ath/ath9k/recv.c +14 -13
@@ -823,7 +823,8 @@ static bool ath9k_rx_accept(struct ath_common *common,test_bit (rx_stats->rs_keyix, common->tkip_keymap); strip_mic = is_valid_tkip &&ieee80211_is_data (fc) && !(rx_stats->rs_status & - (ATH9K_RXERR_DECRYPT |ATH9K_RXERR_CRC |ATH9K_RXERR_MIC )); + (ATH9K_RXERR_DECRYPT |ATH9K_RXERR_CRC |ATH9K_RXERR_MIC | +ATH9K_RXERR_KEYMISS ));if (!rx_stats->rs_datalen)return false;
@@ -851,6 +852,8 @@ static bool ath9k_rx_accept(struct ath_common *common,* descriptors. */ if (rx_stats->rs_status !=0 ) { +u8 status_mask; +if (rx_stats->rs_status &ATH9K_RXERR_CRC ) { rxs->flag |=RX_FLAG_FAILED_FCS_CRC ; mic_error = false;
@@ -858,7 +861,8 @@ static bool ath9k_rx_accept(struct ath_common *common,if (rx_stats->rs_status &ATH9K_RXERR_PHY )return false; -if (rx_stats->rs_status &ATH9K_RXERR_DECRYPT ) { +if ((rx_stats->rs_status &ATH9K_RXERR_DECRYPT ) || + (!is_mc && (rx_stats->rs_status &ATH9K_RXERR_KEYMISS ))) { *decrypt_error = true; mic_error = false; }
@@ -868,17 +872,14 @@ static bool ath9k_rx_accept(struct ath_common *common,* decryption and MIC failures. For monitor mode, * we also ignore the CRC error. */ -if (ah->is_monitoring) { -if (rx_stats->rs_status & - ~(ATH9K_RXERR_DECRYPT |ATH9K_RXERR_MIC | -ATH9K_RXERR_CRC )) -return false; - }else { -if (rx_stats->rs_status & - ~(ATH9K_RXERR_DECRYPT |ATH9K_RXERR_MIC )) { -return false; - } - } + status_mask =ATH9K_RXERR_DECRYPT |ATH9K_RXERR_MIC | +ATH9K_RXERR_KEYMISS ; + +if (ah->is_monitoring) + status_mask |=ATH9K_RXERR_CRC ; + +if (rx_stats->rs_status & ~status_mask) +return false; }/*
Signature · 1 line
1.7.3.2
PATCH 2/2 ath9k: only send FCS-fail packets to mac80211 if requested
Prevents lots of broken frames from showing up on monitor interfaces by default.
--- drivers/net/wireless/ath/ath9k/recv.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/net/wireless/ath/ath9k/recv.c +2 -1
@@ -811,6 +811,7 @@ static bool ath9k_rx_accept(struct ath_common *common,struct ath_rx_status *rx_stats, bool *decrypt_error) { + struct ath_softc *sc = (struct ath_softc *) common->priv;bool is_mc, is_valid_tkip, strip_mic, mic_error;struct ath_hw *ah = common->ah;__le16 fc;
@@ -875,7 +876,7 @@ static bool ath9k_rx_accept(struct ath_common *common, status_mask =ATH9K_RXERR_DECRYPT |ATH9K_RXERR_MIC |ATH9K_RXERR_KEYMISS ; -if (ah->is_monitoring) +if (ah->is_monitoring && (sc->rx.rxfilter &FIF_FCSFAIL )) status_mask |=ATH9K_RXERR_CRC ;if (rx_stats->rs_status & ~status_mask)
Signature · 1 line
1.7.3.2