ath9k: Handle invalid RSSI
PATCH 1/4 ath9k: Handle invalid RSSI
From: Sujith Manoharan <[email protected]>
The combined RSSI can be invalid which is indicated by the value -128. Use RX_FLAG_NO_SIGNAL_VAL for such cases.
--- drivers/net/wireless/ath/ath9k/recv.c | 49 +++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 16 deletions(-)
drivers/net/wireless/ath/ath9k/recv.c +33 -16
@@ -885,29 +885,49 @@ static int ath9k_process_rate(struct ath_common *common,static void ath9k_process_rssi (struct ath_common *common,struct ieee80211_hw *hw, -struct ath_rx_status *rx_stats) +struct ath_rx_status *rx_stats, +struct ieee80211_rx_status *rxs) {struct ath_softc *sc = hw->priv;struct ath_hw *ah = common->ah;int last_rssi;int rssi = rx_stats->rs_rssi; -if (!rx_stats->is_mybeacon || - ((ah->opmode !=NL80211_IFTYPE_STATION ) && - (ah->opmode !=NL80211_IFTYPE_ADHOC ))) +/* +* RSSI is not available for subframes in an A-MPDU. +*/ +if (rx_stats->rs_moreaggr) { + rxs->flag |=RX_FLAG_NO_SIGNAL_VAL ; +return ; + } + +/* +* Check if the RSSI for the last subframe in an A-MPDU +* or an unaggregated frame is valid. +*/ +if (rx_stats->rs_rssi ==ATH9K_RSSI_BAD ) { + rxs->flag |=RX_FLAG_NO_SIGNAL_VAL ;return ; + } -if (rx_stats->rs_rssi !=ATH9K_RSSI_BAD && !rx_stats->rs_moreaggr) +/* +* Update Beacon RSSI, this is used by ANI. +*/ +if (rx_stats->is_mybeacon && + ((ah->opmode ==NL80211_IFTYPE_STATION ) || + (ah->opmode ==NL80211_IFTYPE_ADHOC ))) {ATH_RSSI_LPF (sc->last_rssi, rx_stats->rs_rssi); + last_rssi = sc->last_rssi; + +if (likely (last_rssi !=ATH_RSSI_DUMMY_MARKER )) + rssi =ATH_EP_RND (last_rssi,ATH_RSSI_EP_MULTIPLIER ); +if (rssi <0 ) + rssi =0 ; - last_rssi = sc->last_rssi; -if (likely (last_rssi !=ATH_RSSI_DUMMY_MARKER )) - rssi =ATH_EP_RND (last_rssi,ATH_RSSI_EP_MULTIPLIER ); -if (rssi <0 ) - rssi =0 ; + ah->stats.avgbrssi = rssi; + } -/* Update Beacon RSSI, this is used by ANI. */ - ah->stats.avgbrssi = rssi; + rxs->signal = ah->noise + rx_stats->rs_rssi; } static void ath9k_process_tsf(struct ath_rx_status *rs,
@@ -1149,15 +1169,12 @@ static int ath9k_rx_skb_preprocess(struct ath_softc *sc, goto exit; } -ath9k_process_rssi (common, hw, rx_stats); +ath9k_process_rssi (common, hw, rx_stats, rx_status); rx_status->band = hw->conf.chandef.chan->band; rx_status->freq = hw->conf.chandef.chan->center_freq; - rx_status->signal = ah->noise + rx_stats->rs_rssi; rx_status->antenna = rx_stats->rs_antenna; rx_status->flag |=RX_FLAG_MACTIME_END ; -if (rx_stats->rs_moreaggr) - rx_status->flag |=RX_FLAG_NO_SIGNAL_VAL ;#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT if (ieee80211_is_data_present(hdr->frame_control) &&
Signature · 1 line
1.8.3.4
PATCH 2/4 ath9k: Identify first subframe in an A-MPDU
From: Sujith Manoharan <[email protected]>
--- drivers/net/wireless/ath/ath9k/ar9003_mac.c | 1 + drivers/net/wireless/ath/ath9k/mac.c | 4 ++-- drivers/net/wireless/ath/ath9k/mac.h | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath9k/ar9003_mac.c +1 -0
@@ -491,6 +491,7 @@ int ath9k_hw_process_rxdesc_edma(struct ath_hw *ah, struct ath_rx_status *rxs, rxs->rs_rate =MS (rxsp->status1, AR_RxRate); rxs->rs_more = (rxsp->status2 & AR_RxMore) ?1 :0 ; + rxs->rs_firstaggr = (rxsp->status11 & AR_RxFirstAggr) ?1 :0 ; rxs->rs_isaggr = (rxsp->status11 & AR_RxAggr) ?1 :0 ; rxs->rs_moreaggr = (rxsp->status11 & AR_RxMoreAggr) ?1 :0 ; rxs->rs_antenna = (MS (rxsp->status4, AR_RxAntenna) &0x7 );
drivers/net/wireless/ath/ath9k/mac.c +2 -2
@@ -583,9 +583,9 @@ int ath9k_hw_rxprocdesc(struct ath_hw *ah, struct ath_desc *ds, rs->rs_rate =MS (ads.ds_rxstatus0, AR_RxRate); rs->rs_more = (ads.ds_rxstatus1 & AR_RxMore) ?1 :0 ; + rs->rs_firstaggr = (ads.ds_rxstatus8 & AR_RxFirstAggr) ?1 :0 ; rs->rs_isaggr = (ads.ds_rxstatus8 & AR_RxAggr) ?1 :0 ; - rs->rs_moreaggr = - (ads.ds_rxstatus8 & AR_RxMoreAggr) ?1 :0 ; + rs->rs_moreaggr = (ads.ds_rxstatus8 & AR_RxMoreAggr) ?1 :0 ; rs->rs_antenna =MS (ads.ds_rxstatus3, AR_RxAntenna);/* directly mapped flags for ieee80211_rx_status */
drivers/net/wireless/ath/ath9k/mac.h +2 -0
@@ -140,6 +140,7 @@ struct ath_rx_status {int8_t rs_rssi_ext1;int8_t rs_rssi_ext2;u8 rs_isaggr; +u8 rs_firstaggr;u8 rs_moreaggr;u8 rs_num_delims;u8 rs_flags;
@@ -569,6 +570,7 @@ struct ar5416_desc {#define AR_RxAggr 0x00020000#define AR_PostDelimCRCErr 0x00040000#define AR_RxStatusRsvd71 0x3ff80000 +#define AR_RxFirstAggr 0x20000000#define AR_DecryptBusyErr 0x40000000#define AR_KeyMiss 0x80000000
Signature · 1 line
1.8.3.4
PATCH 3/4 ath9k: Optimize LNA check
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
The documentation for antenna diversity says:
"The decision of diversity is done at 802.11 preamble. So, for 11G/11B, for every MAC packet hardware will do a decision. But in 11N with aggregation, the decision is made only at the preamble and all other MPDUs will use the same LNA as the first MPDU."
Make use of rs_firstaggr to avoid needlessly scanning for LNA changes.
--- drivers/net/wireless/ath/ath9k/recv.c | 77 +++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 30 deletions(-)
drivers/net/wireless/ath/ath9k/recv.c +47 -30
@@ -1238,6 +1238,52 @@ static void ath9k_rx_skb_postprocess(struct ath_common *common, rxs->flag &= ~RX_FLAG_DECRYPTED ; } +/* +* Run the LNA combining algorithm only in these cases: +* +* Standalone WLAN cards with both LNA/Antenna diversity +* enabled in the EEPROM. +* +* WLAN+BT cards which are in the supported card list +* in ath_pci_id_table and the user has loaded the +* driver with "bt_ant_diversity" set to true. +*/ +static void ath9k_antenna_check (struct ath_softc *sc, +struct ath_rx_status *rs) +{ +struct ath_hw *ah = sc->sc_ah; +struct ath9k_hw_capabilities *pCap = &ah->caps; +struct ath_common *common =ath9k_hw_common (ah); + +if (!(ah->caps.hw_caps &ATH9K_HW_CAP_ANT_DIV_COMB )) +return ; + +/* +* All MPDUs in an aggregate will use the same LNA +* as the first MPDU. +*/ +if (rs->rs_isaggr && !rs->rs_firstaggr) +return ; + +/* +* Change the default rx antenna if rx diversity +* chooses the other antenna 3 times in a row. +*/ +if (sc->rx.defant != rs->rs_antenna) { +if (++sc->rx.rxotherant >=3 ) +ath_setdefantenna (sc, rs->rs_antenna); + }else { + sc->rx.rxotherant =0 ; + } + +if (pCap->hw_caps &ATH9K_HW_CAP_BT_ANT_DIV ) { +if (common->bt_ant_diversity) +ath_ant_comb_scan (sc, rs); + }else { +ath_ant_comb_scan (sc, rs); + } +} +static void ath9k_apply_ampdu_details (struct ath_softc *sc,struct ath_rx_status *rs,struct ieee80211_rx_status *rxs) {
@@ -1262,7 +1308,6 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)struct sk_buff *skb =NULL , *requeue_skb, *hdr_skb;struct ieee80211_rx_status *rxs;struct ath_hw *ah = sc->sc_ah; -struct ath9k_hw_capabilities *pCap = &ah->caps;struct ath_common *common =ath9k_hw_common (ah);struct ieee80211_hw *hw = sc->hw;int retval;
@@ -1398,35 +1443,7 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)ath_rx_ps (sc, skb, rs.is_mybeacon);spin_unlock_irqrestore (&sc->sc_pm_lock, flags); -/* -* Run the LNA combining algorithm only in these cases: -* -* Standalone WLAN cards with both LNA/Antenna diversity -* enabled in the EEPROM. -* -* WLAN+BT cards which are in the supported card list -* in ath_pci_id_table and the user has loaded the -* driver with "bt_ant_diversity" set to true. -*/ -if (ah->caps.hw_caps &ATH9K_HW_CAP_ANT_DIV_COMB ) { -/* -* Change the default rx antenna if rx diversity -* chooses the other antenna 3 times in a row. -*/ -if (sc->rx.defant != rs.rs_antenna) { -if (++sc->rx.rxotherant >=3 ) -ath_setdefantenna (sc, rs.rs_antenna); - }else { - sc->rx.rxotherant =0 ; - } - -if (pCap->hw_caps &ATH9K_HW_CAP_BT_ANT_DIV ) { -if (common->bt_ant_diversity) -ath_ant_comb_scan (sc, &rs); - }else { -ath_ant_comb_scan (sc, &rs); - } - } +ath9k_antenna_check (sc, &rs);ath9k_apply_ampdu_details (sc, &rs, rxs);
Signature · 1 line
1.8.3.4
PATCH 4/4 ath9k: Use lockless variant to initialize RX fifo
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
Since the rx_fifo queue is accessed only using the various lockless SKB queue routines, there is no need to initialize the lock and __skb_queue_head_init() can be used.
--- drivers/net/wireless/ath/ath9k/recv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath9k/recv.c +1 -1
@@ -190,7 +190,7 @@ static void ath_rx_edma_cleanup(struct ath_softc *sc)static void ath_rx_edma_init_queue (struct ath_rx_edma *rx_edma,int size) { -skb_queue_head_init (&rx_edma->rx_fifo); +__skb_queue_head_init (&rx_edma->rx_fifo); rx_edma->rx_fifo_hwsize = size; }
Signature · 1 line
1.8.3.4