package/devel/binutils: Update to 2.27
[openwrt/staging/dedeckeh.git] / package / kernel / mac80211 / patches / 653-0018-rtl8xxxu-Split-filling-of-TX-descriptors-into-separa.patch
1 From b59415c2dd088ffce62fbde737c8b2d04fb6e015 Mon Sep 17 00:00:00 2001
2 From: Jes Sorensen <Jes.Sorensen@redhat.com>
3 Date: Fri, 19 Aug 2016 17:46:40 -0400
4 Subject: [PATCH] rtl8xxxu: Split filling of TX descriptors into separate
5 functions
6
7 Split the filling of TX descriptors into a generic portion used on all
8 devices, and format specific helper functions provided in the fops
9 structure.
10
11 This also cleaned up some mess, even if non harmful, in the handling
12 of txdesc40 descriptors, where the code randomly would switch between
13 the pointer to tx_desc and tx_desc40.
14
15 Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
16 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
17 ---
18 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 12 ++
19 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c | 1 +
20 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c | 1 +
21 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c | 1 +
22 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c | 1 +
23 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 198 ++++++++++++---------
24 6 files changed, 125 insertions(+), 89 deletions(-)
25
26 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
27 +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
28 @@ -1336,6 +1336,10 @@ struct rtl8xxxu_fileops {
29 u32 ramask, int sgi);
30 void (*report_connect) (struct rtl8xxxu_priv *priv,
31 u8 macid, bool connect);
32 + void (*fill_txdesc) (struct ieee80211_hdr *hdr,
33 + struct rtl8xxxu_txdesc32 *tx_desc, u32 rate,
34 + u16 rate_flag, bool sgi, bool short_preamble,
35 + bool ampdu_enable);
36 int writeN_block_size;
37 int rx_agg_buf_size;
38 char tx_desc_size;
39 @@ -1429,6 +1433,14 @@ int rtl8xxxu_parse_rxdesc24(struct rtl8x
40 int rtl8xxxu_gen2_channel_to_group(int channel);
41 bool rtl8xxxu_gen2_simularity_compare(struct rtl8xxxu_priv *priv,
42 int result[][8], int c1, int c2);
43 +void rtl8xxxu_fill_txdesc_v1(struct ieee80211_hdr *hdr,
44 + struct rtl8xxxu_txdesc32 *tx_desc, u32 rate,
45 + u16 rate_flag, bool sgi, bool short_preamble,
46 + bool ampdu_enable);
47 +void rtl8xxxu_fill_txdesc_v2(struct ieee80211_hdr *hdr,
48 + struct rtl8xxxu_txdesc32 *tx_desc32, u32 rate,
49 + u16 rate_flag, bool sgi, bool short_preamble,
50 + bool ampdu_enable);
51
52 extern struct rtl8xxxu_fileops rtl8192cu_fops;
53 extern struct rtl8xxxu_fileops rtl8192eu_fops;
54 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c
55 +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c
56 @@ -567,6 +567,7 @@ struct rtl8xxxu_fileops rtl8192cu_fops =
57 .set_tx_power = rtl8xxxu_gen1_set_tx_power,
58 .update_rate_mask = rtl8xxxu_update_rate_mask,
59 .report_connect = rtl8xxxu_gen1_report_connect,
60 + .fill_txdesc = rtl8xxxu_fill_txdesc_v1,
61 .writeN_block_size = 128,
62 .rx_agg_buf_size = 16000,
63 .tx_desc_size = sizeof(struct rtl8xxxu_txdesc32),
64 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
65 +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
66 @@ -1501,6 +1501,7 @@ struct rtl8xxxu_fileops rtl8192eu_fops =
67 .set_tx_power = rtl8192e_set_tx_power,
68 .update_rate_mask = rtl8xxxu_gen2_update_rate_mask,
69 .report_connect = rtl8xxxu_gen2_report_connect,
70 + .fill_txdesc = rtl8xxxu_fill_txdesc_v2,
71 .writeN_block_size = 128,
72 .tx_desc_size = sizeof(struct rtl8xxxu_txdesc40),
73 .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc24),
74 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c
75 +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c
76 @@ -384,6 +384,7 @@ struct rtl8xxxu_fileops rtl8723au_fops =
77 .set_tx_power = rtl8xxxu_gen1_set_tx_power,
78 .update_rate_mask = rtl8xxxu_update_rate_mask,
79 .report_connect = rtl8xxxu_gen1_report_connect,
80 + .fill_txdesc = rtl8xxxu_fill_txdesc_v1,
81 .writeN_block_size = 1024,
82 .rx_agg_buf_size = 16000,
83 .tx_desc_size = sizeof(struct rtl8xxxu_txdesc32),
84 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
85 +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
86 @@ -1662,6 +1662,7 @@ struct rtl8xxxu_fileops rtl8723bu_fops =
87 .set_tx_power = rtl8723b_set_tx_power,
88 .update_rate_mask = rtl8xxxu_gen2_update_rate_mask,
89 .report_connect = rtl8xxxu_gen2_report_connect,
90 + .fill_txdesc = rtl8xxxu_fill_txdesc_v2,
91 .writeN_block_size = 1024,
92 .tx_desc_size = sizeof(struct rtl8xxxu_txdesc40),
93 .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc24),
94 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
95 +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
96 @@ -4750,6 +4750,113 @@ static void rtl8xxxu_dump_action(struct
97 }
98 }
99
100 +/*
101 + * Fill in v1 (gen1) specific TX descriptor bits.
102 + * This format is used on 8188cu/8192cu/8723au
103 + */
104 +void
105 +rtl8xxxu_fill_txdesc_v1(struct ieee80211_hdr *hdr,
106 + struct rtl8xxxu_txdesc32 *tx_desc, u32 rate,
107 + u16 rate_flag, bool sgi, bool short_preamble,
108 + bool ampdu_enable)
109 +{
110 + u16 seq_number;
111 +
112 + seq_number = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl));
113 +
114 + tx_desc->txdw5 = cpu_to_le32(rate);
115 +
116 + if (ieee80211_is_data(hdr->frame_control))
117 + tx_desc->txdw5 |= cpu_to_le32(0x0001ff00);
118 +
119 + tx_desc->txdw3 = cpu_to_le32((u32)seq_number << TXDESC32_SEQ_SHIFT);
120 +
121 + if (ampdu_enable)
122 + tx_desc->txdw1 |= cpu_to_le32(TXDESC32_AGG_ENABLE);
123 + else
124 + tx_desc->txdw1 |= cpu_to_le32(TXDESC32_AGG_BREAK);
125 +
126 + if (ieee80211_is_mgmt(hdr->frame_control)) {
127 + tx_desc->txdw5 = cpu_to_le32(rate);
128 + tx_desc->txdw4 |= cpu_to_le32(TXDESC32_USE_DRIVER_RATE);
129 + tx_desc->txdw5 |= cpu_to_le32(6 << TXDESC32_RETRY_LIMIT_SHIFT);
130 + tx_desc->txdw5 |= cpu_to_le32(TXDESC32_RETRY_LIMIT_ENABLE);
131 + }
132 +
133 + if (ieee80211_is_data_qos(hdr->frame_control))
134 + tx_desc->txdw4 |= cpu_to_le32(TXDESC32_QOS);
135 +
136 + if (short_preamble)
137 + tx_desc->txdw4 |= cpu_to_le32(TXDESC32_SHORT_PREAMBLE);
138 +
139 + if (sgi)
140 + tx_desc->txdw5 |= cpu_to_le32(TXDESC32_SHORT_GI);
141 +
142 + if (rate_flag & IEEE80211_TX_RC_USE_RTS_CTS) {
143 + /*
144 + * Use RTS rate 24M - does the mac80211 tell
145 + * us which to use?
146 + */
147 + tx_desc->txdw4 |= cpu_to_le32(DESC_RATE_24M <<
148 + TXDESC32_RTS_RATE_SHIFT);
149 + tx_desc->txdw4 |= cpu_to_le32(TXDESC32_RTS_CTS_ENABLE);
150 + tx_desc->txdw4 |= cpu_to_le32(TXDESC32_HW_RTS_ENABLE);
151 + }
152 +}
153 +
154 +/*
155 + * Fill in v2 (gen2) specific TX descriptor bits.
156 + * This format is used on 8192eu/8723bu
157 + */
158 +void
159 +rtl8xxxu_fill_txdesc_v2(struct ieee80211_hdr *hdr,
160 + struct rtl8xxxu_txdesc32 *tx_desc32, u32 rate,
161 + u16 rate_flag, bool sgi, bool short_preamble,
162 + bool ampdu_enable)
163 +{
164 + struct rtl8xxxu_txdesc40 *tx_desc40;
165 + u16 seq_number;
166 +
167 + tx_desc40 = (struct rtl8xxxu_txdesc40 *)tx_desc32;
168 +
169 + seq_number = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl));
170 +
171 + tx_desc40->txdw4 = cpu_to_le32(rate);
172 + if (ieee80211_is_data(hdr->frame_control)) {
173 + tx_desc40->txdw4 |= cpu_to_le32(0x1f <<
174 + TXDESC40_DATA_RATE_FB_SHIFT);
175 + }
176 +
177 + tx_desc40->txdw9 = cpu_to_le32((u32)seq_number << TXDESC40_SEQ_SHIFT);
178 +
179 + if (ampdu_enable)
180 + tx_desc40->txdw2 |= cpu_to_le32(TXDESC40_AGG_ENABLE);
181 + else
182 + tx_desc40->txdw2 |= cpu_to_le32(TXDESC40_AGG_BREAK);
183 +
184 + if (ieee80211_is_mgmt(hdr->frame_control)) {
185 + tx_desc40->txdw4 = cpu_to_le32(rate);
186 + tx_desc40->txdw3 |= cpu_to_le32(TXDESC40_USE_DRIVER_RATE);
187 + tx_desc40->txdw4 |=
188 + cpu_to_le32(6 << TXDESC40_RETRY_LIMIT_SHIFT);
189 + tx_desc40->txdw4 |= cpu_to_le32(TXDESC40_RETRY_LIMIT_ENABLE);
190 + }
191 +
192 + if (short_preamble)
193 + tx_desc40->txdw5 |= cpu_to_le32(TXDESC40_SHORT_PREAMBLE);
194 +
195 + if (rate_flag & IEEE80211_TX_RC_USE_RTS_CTS) {
196 + /*
197 + * Use RTS rate 24M - does the mac80211 tell
198 + * us which to use?
199 + */
200 + tx_desc40->txdw4 |= cpu_to_le32(DESC_RATE_24M <<
201 + TXDESC40_RTS_RATE_SHIFT);
202 + tx_desc40->txdw3 |= cpu_to_le32(TXDESC40_RTS_CTS_ENABLE);
203 + tx_desc40->txdw3 |= cpu_to_le32(TXDESC40_HW_RTS_ENABLE);
204 + }
205 +}
206 +
207 static void rtl8xxxu_tx(struct ieee80211_hw *hw,
208 struct ieee80211_tx_control *control,
209 struct sk_buff *skb)
210 @@ -4759,7 +4866,6 @@ static void rtl8xxxu_tx(struct ieee80211
211 struct ieee80211_rate *tx_rate = ieee80211_get_tx_rate(hw, tx_info);
212 struct rtl8xxxu_priv *priv = hw->priv;
213 struct rtl8xxxu_txdesc32 *tx_desc;
214 - struct rtl8xxxu_txdesc40 *tx_desc40;
215 struct rtl8xxxu_tx_urb *tx_urb;
216 struct ieee80211_sta *sta = NULL;
217 struct ieee80211_vif *vif = tx_info->control.vif;
218 @@ -4865,95 +4971,9 @@ static void rtl8xxxu_tx(struct ieee80211
219 short_preamble = true;
220
221 seq_number = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl));
222 - if (!usedesc40) {
223 - tx_desc->txdw5 = cpu_to_le32(rate);
224 -
225 - if (ieee80211_is_data(hdr->frame_control))
226 - tx_desc->txdw5 |= cpu_to_le32(0x0001ff00);
227 -
228 - tx_desc->txdw3 =
229 - cpu_to_le32((u32)seq_number << TXDESC32_SEQ_SHIFT);
230 -
231 - if (ampdu_enable)
232 - tx_desc->txdw1 |= cpu_to_le32(TXDESC32_AGG_ENABLE);
233 - else
234 - tx_desc->txdw1 |= cpu_to_le32(TXDESC32_AGG_BREAK);
235 -
236 - if (ieee80211_is_mgmt(hdr->frame_control)) {
237 - tx_desc->txdw5 = cpu_to_le32(rate);
238 - tx_desc->txdw4 |=
239 - cpu_to_le32(TXDESC32_USE_DRIVER_RATE);
240 - tx_desc->txdw5 |=
241 - cpu_to_le32(6 << TXDESC32_RETRY_LIMIT_SHIFT);
242 - tx_desc->txdw5 |=
243 - cpu_to_le32(TXDESC32_RETRY_LIMIT_ENABLE);
244 - }
245 -
246 - if (ieee80211_is_data_qos(hdr->frame_control))
247 - tx_desc->txdw4 |= cpu_to_le32(TXDESC32_QOS);
248
249 - if (short_preamble)
250 - tx_desc->txdw4 |= cpu_to_le32(TXDESC32_SHORT_PREAMBLE);
251 -
252 - if (sgi)
253 - tx_desc->txdw5 |= cpu_to_le32(TXDESC32_SHORT_GI);
254 -
255 - if (rate_flag & IEEE80211_TX_RC_USE_RTS_CTS) {
256 - /*
257 - * Use RTS rate 24M - does the mac80211 tell
258 - * us which to use?
259 - */
260 - tx_desc->txdw4 |=
261 - cpu_to_le32(DESC_RATE_24M <<
262 - TXDESC32_RTS_RATE_SHIFT);
263 - tx_desc->txdw4 |=
264 - cpu_to_le32(TXDESC32_RTS_CTS_ENABLE);
265 - tx_desc->txdw4 |= cpu_to_le32(TXDESC32_HW_RTS_ENABLE);
266 - }
267 - } else {
268 - tx_desc40 = (struct rtl8xxxu_txdesc40 *)tx_desc;
269 -
270 - tx_desc40->txdw4 = cpu_to_le32(rate);
271 - if (ieee80211_is_data(hdr->frame_control)) {
272 - tx_desc->txdw4 |=
273 - cpu_to_le32(0x1f <<
274 - TXDESC40_DATA_RATE_FB_SHIFT);
275 - }
276 -
277 - tx_desc40->txdw9 =
278 - cpu_to_le32((u32)seq_number << TXDESC40_SEQ_SHIFT);
279 -
280 - if (ampdu_enable)
281 - tx_desc40->txdw2 |= cpu_to_le32(TXDESC40_AGG_ENABLE);
282 - else
283 - tx_desc40->txdw2 |= cpu_to_le32(TXDESC40_AGG_BREAK);
284 -
285 - if (ieee80211_is_mgmt(hdr->frame_control)) {
286 - tx_desc40->txdw4 = cpu_to_le32(rate);
287 - tx_desc40->txdw3 |=
288 - cpu_to_le32(TXDESC40_USE_DRIVER_RATE);
289 - tx_desc40->txdw4 |=
290 - cpu_to_le32(6 << TXDESC40_RETRY_LIMIT_SHIFT);
291 - tx_desc40->txdw4 |=
292 - cpu_to_le32(TXDESC40_RETRY_LIMIT_ENABLE);
293 - }
294 -
295 - if (short_preamble)
296 - tx_desc40->txdw5 |=
297 - cpu_to_le32(TXDESC40_SHORT_PREAMBLE);
298 -
299 - if (rate_flag & IEEE80211_TX_RC_USE_RTS_CTS) {
300 - /*
301 - * Use RTS rate 24M - does the mac80211 tell
302 - * us which to use?
303 - */
304 - tx_desc->txdw4 |=
305 - cpu_to_le32(DESC_RATE_24M <<
306 - TXDESC40_RTS_RATE_SHIFT);
307 - tx_desc->txdw3 |= cpu_to_le32(TXDESC40_RTS_CTS_ENABLE);
308 - tx_desc->txdw3 |= cpu_to_le32(TXDESC40_HW_RTS_ENABLE);
309 - }
310 - }
311 + priv->fops->fill_txdesc(hdr, tx_desc, rate, rate_flag,
312 + sgi, short_preamble, ampdu_enable);
313
314 rtl8xxxu_calc_tx_desc_csum(tx_desc);
315