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