ath9k: fix more-data flag for buffered multicast packets
[oweals/openwrt.git] / package / kernel / mac80211 / patches / 020-14-rt2x00-use-txdone_nomatch-on-rt2800usb.patch
1 From 293dff78ee058ec1e0b90e05a803c512b6a2097f Mon Sep 17 00:00:00 2001
2 From: Stanislaw Gruszka <sgruszka@redhat.com>
3 Date: Wed, 15 Feb 2017 10:25:10 +0100
4 Subject: [PATCH 14/19] rt2x00: use txdone_nomatch on rt2800usb
5
6 If we do not match skb entry, provide tx status via nomatch procedure.
7
8 Currently in that case we do rt2x00lib_txdone_noinfo(TXDONE_NOINFO),
9 which actually assume that entry->skb was posted without retries and
10 provide rate saved in skb desc as successful. Patch changed that to
11 rate read from TX_STAT_FIFO, however still do not provide correct
12 number of retries.
13
14 On SoC/PCI devices we keep providing status via standard txdone
15 procedure, no change in those devices, though we should thing about it.
16
17 Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
18 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
19 ---
20  drivers/net/wireless/ralink/rt2x00/rt2800lib.c  | 31 ++++++++++++++++++++-----
21  drivers/net/wireless/ralink/rt2x00/rt2800lib.h  |  3 ++-
22  drivers/net/wireless/ralink/rt2x00/rt2800mmio.c |  2 +-
23  drivers/net/wireless/ralink/rt2x00/rt2800usb.c  | 18 ++++++--------
24  4 files changed, 35 insertions(+), 19 deletions(-)
25
26 --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
27 +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
28 @@ -852,7 +852,8 @@ void rt2800_process_rxwi(struct queue_en
29  }
30  EXPORT_SYMBOL_GPL(rt2800_process_rxwi);
31  
32 -void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32 *txwi)
33 +void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32 *txwi,
34 +                        bool match)
35  {
36         struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
37         struct rt2800_drv_data *drv_data = rt2x00dev->drv_data;
38 @@ -860,8 +861,7 @@ void rt2800_txdone_entry(struct queue_en
39         struct txdone_entry_desc txdesc;
40         u32 word;
41         u16 mcs, real_mcs;
42 -       int aggr, ampdu;
43 -       int wcid;
44 +       int aggr, ampdu, wcid, ack_req;
45  
46         /*
47          * Obtain the status about this packet.
48 @@ -875,6 +875,7 @@ void rt2800_txdone_entry(struct queue_en
49         real_mcs = rt2x00_get_field32(status, TX_STA_FIFO_MCS);
50         aggr = rt2x00_get_field32(status, TX_STA_FIFO_TX_AGGRE);
51         wcid = rt2x00_get_field32(status, TX_STA_FIFO_WCID);
52 +       ack_req = rt2x00_get_field32(status, TX_STA_FIFO_TX_ACK_REQUIRED);
53  
54         /*
55          * If a frame was meant to be sent as a single non-aggregated MPDU
56 @@ -891,8 +892,12 @@ void rt2800_txdone_entry(struct queue_en
57          * Hence, replace the requested rate with the real tx rate to not
58          * confuse the rate control algortihm by providing clearly wrong
59          * data.
60 -        */
61 -       if (unlikely(aggr == 1 && ampdu == 0 && real_mcs != mcs)) {
62 +        *
63 +        * FIXME: if we do not find matching entry, we tell that frame was
64 +        * posted without any retries. We need to find a way to fix that
65 +        * and provide retry count.
66 +        */
67 +       if (unlikely((aggr == 1 && ampdu == 0 && real_mcs != mcs)) || !match) {
68                 skbdesc->tx_rate_idx = real_mcs;
69                 mcs = real_mcs;
70         }
71 @@ -900,6 +905,9 @@ void rt2800_txdone_entry(struct queue_en
72         if (aggr == 1 || ampdu == 1)
73                 __set_bit(TXDONE_AMPDU, &txdesc.flags);
74  
75 +       if (!ack_req)
76 +               __set_bit(TXDONE_NO_ACK_REQ, &txdesc.flags);
77 +
78         /*
79          * Ralink has a retry mechanism using a global fallback
80          * table. We setup this fallback table to try the immediate
81 @@ -931,7 +939,18 @@ void rt2800_txdone_entry(struct queue_en
82         if (txdesc.retry)
83                 __set_bit(TXDONE_FALLBACK, &txdesc.flags);
84  
85 -       rt2x00lib_txdone(entry, &txdesc);
86 +       if (!match) {
87 +               /* RCU assures non-null sta will not be freed by mac80211. */
88 +               rcu_read_lock();
89 +               if (likely(wcid >= WCID_START && wcid <= WCID_END))
90 +                       skbdesc->sta = drv_data->wcid_to_sta[wcid - WCID_START];
91 +               else
92 +                       skbdesc->sta = NULL;
93 +               rt2x00lib_txdone_nomatch(entry, &txdesc);
94 +               rcu_read_unlock();
95 +       } else {
96 +               rt2x00lib_txdone(entry, &txdesc);
97 +       }
98  }
99  EXPORT_SYMBOL_GPL(rt2800_txdone_entry);
100  
101 --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.h
102 +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.h
103 @@ -191,7 +191,8 @@ void rt2800_write_tx_data(struct queue_e
104                           struct txentry_desc *txdesc);
105  void rt2800_process_rxwi(struct queue_entry *entry, struct rxdone_entry_desc *txdesc);
106  
107 -void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32* txwi);
108 +void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32 *txwi,
109 +                        bool match);
110  
111  void rt2800_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc);
112  void rt2800_clear_beacon(struct queue_entry *entry);
113 --- a/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c
114 +++ b/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c
115 @@ -239,7 +239,7 @@ static bool rt2800mmio_txdone_release_en
116  {
117         if (test_bit(ENTRY_DATA_STATUS_SET, &entry->flags)) {
118                 rt2800_txdone_entry(entry, entry->status,
119 -                                   rt2800mmio_get_txwi(entry));
120 +                                   rt2800mmio_get_txwi(entry), true);
121                 return false;
122         }
123  
124 --- a/drivers/net/wireless/ralink/rt2x00/rt2800usb.c
125 +++ b/drivers/net/wireless/ralink/rt2x00/rt2800usb.c
126 @@ -501,8 +501,7 @@ static int rt2800usb_get_tx_data_len(str
127  /*
128   * TX control handlers
129   */
130 -static enum txdone_entry_desc_flags
131 -rt2800usb_txdone_entry_check(struct queue_entry *entry, u32 reg)
132 +static bool rt2800usb_txdone_entry_check(struct queue_entry *entry, u32 reg)
133  {
134         __le32 *txwi;
135         u32 word;
136 @@ -515,7 +514,7 @@ rt2800usb_txdone_entry_check(struct queu
137          * frame.
138          */
139         if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags))
140 -               return TXDONE_FAILURE;
141 +               return false;
142  
143         wcid    = rt2x00_get_field32(reg, TX_STA_FIFO_WCID);
144         ack     = rt2x00_get_field32(reg, TX_STA_FIFO_TX_ACK_REQUIRED);
145 @@ -537,10 +536,10 @@ rt2800usb_txdone_entry_check(struct queu
146                 rt2x00_dbg(entry->queue->rt2x00dev,
147                            "TX status report missed for queue %d entry %d\n",
148                            entry->queue->qid, entry->entry_idx);
149 -               return TXDONE_UNKNOWN;
150 +               return false;
151         }
152  
153 -       return TXDONE_SUCCESS;
154 +       return true;
155  }
156  
157  static void rt2800usb_txdone(struct rt2x00_dev *rt2x00dev)
158 @@ -549,7 +548,7 @@ static void rt2800usb_txdone(struct rt2x
159         struct queue_entry *entry;
160         u32 reg;
161         u8 qid;
162 -       enum txdone_entry_desc_flags done_status;
163 +       bool match;
164  
165         while (kfifo_get(&rt2x00dev->txstatus_fifo, &reg)) {
166                 /*
167 @@ -574,11 +573,8 @@ static void rt2800usb_txdone(struct rt2x
168                         break;
169                 }
170  
171 -               done_status = rt2800usb_txdone_entry_check(entry, reg);
172 -               if (likely(done_status == TXDONE_SUCCESS))
173 -                       rt2800_txdone_entry(entry, reg, rt2800usb_get_txwi(entry));
174 -               else
175 -                       rt2x00lib_txdone_noinfo(entry, done_status);
176 +               match = rt2800usb_txdone_entry_check(entry, reg);
177 +               rt2800_txdone_entry(entry, reg, rt2800usb_get_txwi(entry), match);
178         }
179  }
180