From: Johannes Berg <johannes.berg@xxxxxxxxx> For drivers that have accurate TX status reporting we can report the number of consecutive lost packets to userspace using the new cfg80211 CQM event. The threshold is fixed right now, this may need to be improved in the future. Signed-off-by: Johannes Berg <johannes.berg@xxxxxxxxx> --- net/mac80211/sta_info.h | 3 +++ net/mac80211/status.c | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) --- wireless-testing.orig/net/mac80211/sta_info.h 2010-11-12 13:34:33.000000000 -0800 +++ wireless-testing/net/mac80211/sta_info.h 2010-11-12 13:34:41.000000000 -0800 @@ -248,6 +248,7 @@ enum plink_state { * @sta: station information we share with the driver * @dead: set to true when sta is unlinked * @uploaded: set to true when sta is uploaded to the driver + * @lost_packets: number of consecutive lost packets */ struct sta_info { /* General information, mostly static */ @@ -335,6 +336,8 @@ struct sta_info { } debugfs; #endif + unsigned int lost_packets; + /* keep last! */ struct ieee80211_sta sta; }; --- wireless-testing.orig/net/mac80211/status.c 2010-11-12 13:34:33.000000000 -0800 +++ wireless-testing/net/mac80211/status.c 2010-11-12 13:34:41.000000000 -0800 @@ -157,6 +157,15 @@ static void ieee80211_frame_acked(struct } } +/* + * Use a static threshold for now, best value to be determined + * by testing ... + * Should it depend on: + * - on # of retransmissions + * - current throughput (higher value for higher tpt)? + */ +#define STA_LOST_PKT_THRESHOLD 50 + void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb) { struct sk_buff *skb2; @@ -243,6 +252,16 @@ void ieee80211_tx_status(struct ieee8021 if (!(info->flags & IEEE80211_TX_CTL_INJECTED) && (info->flags & IEEE80211_TX_STAT_ACK)) ieee80211_frame_acked(sta, skb); + + if (local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS) { + if (info->flags & IEEE80211_TX_STAT_ACK) + sta->lost_packets = 0; + else if (++sta->lost_packets >= STA_LOST_PKT_THRESHOLD) + cfg80211_cqm_pktloss_notify(sta->sdata->dev, + sta->sta.addr, + sta->lost_packets, + GFP_ATOMIC); + } } rcu_read_unlock(); -------------------------------------------------------------------------------------- Intel GmbH Dornacher Strasse 1 85622 Feldkirchen/Muenchen, Deutschland Sitz der Gesellschaft: Feldkirchen bei Muenchen Geschaeftsfuehrer: Douglas Lusk, Peter Gleissner, Hannes Schwaderer Registergericht: Muenchen HRB 47456 Ust.-IdNr./VAT Registration No.: DE129385895 Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052 ÿô.nÇ·®+%˱é¥wÿº{.nÇ·¥{±ÿ«zW¬³ø¡Ü}©²ÆzÚj:+v¨þø®w¥þàÞ¨è&¢)ß«a¶Úÿûz¹ÞúÝjÿwèf