update to latest compat-wireless version and add some new minstrel/b43 fixes
[openwrt.git] / package / mac80211 / patches / 310-b43_txstatus.patch
1 Fix the b43 tx status reporting.
2
3 If the hardware uses RTS/CTS reporting and the actual RTS/CTS
4 handshake failed, it will switch to the fallback rate, even
5 though the main rate was never actually attempted.
6 Make sure that this does not screw up rate control statistics.
7
8 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9
10 --- a/drivers/net/wireless/b43/b43.h
11 +++ b/drivers/net/wireless/b43/b43.h
12 @@ -778,6 +778,9 @@ struct b43_wldev {
13  #ifdef CONFIG_B43_DEBUG
14         struct b43_dfsentry *dfsentry;
15  #endif
16 +
17 +       /* necessary for figuring out the correct tx status */
18 +       int short_retry;
19  };
20  
21  static inline struct b43_wl *hw_to_b43_wl(struct ieee80211_hw *hw)
22 --- a/drivers/net/wireless/b43/dma.c
23 +++ b/drivers/net/wireless/b43/dma.c
24 @@ -1393,7 +1393,7 @@ void b43_dma_handle_txstatus(struct b43_
25                          * Call back to inform the ieee80211 subsystem about
26                          * the status of the transmission.
27                          */
28 -                       frame_succeed = b43_fill_txstatus_report(info, status);
29 +                       frame_succeed = b43_fill_txstatus_report(dev, info, status);
30  #ifdef CONFIG_B43_DEBUG
31                         if (frame_succeed)
32                                 ring->nr_succeed_tx_packets++;
33 --- a/drivers/net/wireless/b43/main.c
34 +++ b/drivers/net/wireless/b43/main.c
35 @@ -3892,6 +3892,7 @@ static void b43_set_retry_limits(struct 
36                         short_retry);
37         b43_shm_write16(dev, B43_SHM_SCRATCH, B43_SHM_SC_LRLIMIT,
38                         long_retry);
39 +       dev->short_retry = short_retry;
40  }
41  
42  static void b43_set_synth_pu_delay(struct b43_wldev *dev, bool idle)
43 --- a/drivers/net/wireless/b43/pio.c
44 +++ b/drivers/net/wireless/b43/pio.c
45 @@ -589,7 +589,7 @@ void b43_pio_handle_txstatus(struct b43_
46         info = IEEE80211_SKB_CB(pack->skb);
47         memset(&info->status, 0, sizeof(info->status));
48  
49 -       b43_fill_txstatus_report(info, status);
50 +       b43_fill_txstatus_report(dev, info, status);
51  
52         total_len = pack->skb->len + b43_txhdr_size(dev);
53         total_len = roundup(total_len, 4);
54 --- a/drivers/net/wireless/b43/xmit.c
55 +++ b/drivers/net/wireless/b43/xmit.c
56 @@ -687,7 +687,8 @@ void b43_handle_txstatus(struct b43_wlde
57  /* Fill out the mac80211 TXstatus report based on the b43-specific
58   * txstatus report data. This returns a boolean whether the frame was
59   * successfully transmitted. */
60 -bool b43_fill_txstatus_report(struct ieee80211_tx_info *report,
61 +bool b43_fill_txstatus_report(struct b43_wldev *dev,
62 +                             struct ieee80211_tx_info *report,
63                               const struct b43_txstatus *status)
64  {
65         bool frame_success = 1;
66 @@ -706,8 +707,19 @@ bool b43_fill_txstatus_report(struct iee
67         if (status->frame_count == 0) {
68                 /* The frame was not transmitted at all. */
69                 report->status.retry_count = 0;
70 -       } else
71 +       } else if (status->rts_count > dev->short_retry) {
72 +               /*
73 +                * If the short retries (RTS, not data frame) have exceeded
74 +                * the limit, the hw will not have tried the selected rate,
75 +                * but will have used the fallback rate instead.
76 +                * Don't let the rate control count attempts for the selected
77 +                * rate in this case, otherwise the statistics will be off.
78 +                */
79 +               report->tx_rate_idx = 0;
80 +               report->status.retry_count = 0;
81 +       } else {
82                 report->status.retry_count = status->frame_count - 1;
83 +       }
84  
85         return frame_success;
86  }
87 --- a/drivers/net/wireless/b43/xmit.h
88 +++ b/drivers/net/wireless/b43/xmit.h
89 @@ -294,7 +294,8 @@ void b43_rx(struct b43_wldev *dev, struc
90  
91  void b43_handle_txstatus(struct b43_wldev *dev,
92                          const struct b43_txstatus *status);
93 -bool b43_fill_txstatus_report(struct ieee80211_tx_info *report,
94 +bool b43_fill_txstatus_report(struct b43_wldev *dev,
95 +                             struct ieee80211_tx_info *report,
96                               const struct b43_txstatus *status);
97  
98  void b43_tx_suspend(struct b43_wldev *dev);