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
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
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.
15 Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
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(-)
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 {
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,
35 int writeN_block_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,
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,
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
100 + * Fill in v1 (gen1) specific TX descriptor bits.
101 + * This format is used on 8188cu/8192cu/8723au
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,
111 + seq_number = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl));
113 + tx_desc->txdw5 = cpu_to_le32(rate);
115 + if (ieee80211_is_data(hdr->frame_control))
116 + tx_desc->txdw5 |= cpu_to_le32(0x0001ff00);
118 + tx_desc->txdw3 = cpu_to_le32((u32)seq_number << TXDESC32_SEQ_SHIFT);
121 + tx_desc->txdw1 |= cpu_to_le32(TXDESC32_AGG_ENABLE);
123 + tx_desc->txdw1 |= cpu_to_le32(TXDESC32_AGG_BREAK);
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);
132 + if (ieee80211_is_data_qos(hdr->frame_control))
133 + tx_desc->txdw4 |= cpu_to_le32(TXDESC32_QOS);
135 + if (short_preamble)
136 + tx_desc->txdw4 |= cpu_to_le32(TXDESC32_SHORT_PREAMBLE);
139 + tx_desc->txdw5 |= cpu_to_le32(TXDESC32_SHORT_GI);
141 + if (rate_flag & IEEE80211_TX_RC_USE_RTS_CTS) {
143 + * Use RTS rate 24M - does the mac80211 tell
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);
154 + * Fill in v2 (gen2) specific TX descriptor bits.
155 + * This format is used on 8192eu/8723bu
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,
163 + struct rtl8xxxu_txdesc40 *tx_desc40;
166 + tx_desc40 = (struct rtl8xxxu_txdesc40 *)tx_desc32;
168 + seq_number = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl));
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);
176 + tx_desc40->txdw9 = cpu_to_le32((u32)seq_number << TXDESC40_SEQ_SHIFT);
179 + tx_desc40->txdw2 |= cpu_to_le32(TXDESC40_AGG_ENABLE);
181 + tx_desc40->txdw2 |= cpu_to_le32(TXDESC40_AGG_BREAK);
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);
191 + if (short_preamble)
192 + tx_desc40->txdw5 |= cpu_to_le32(TXDESC40_SHORT_PREAMBLE);
194 + if (rate_flag & IEEE80211_TX_RC_USE_RTS_CTS) {
196 + * Use RTS rate 24M - does the mac80211 tell
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);
206 static void rtl8xxxu_tx(struct ieee80211_hw *hw,
207 struct ieee80211_tx_control *control,
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;
220 seq_number = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl));
222 - tx_desc->txdw5 = cpu_to_le32(rate);
224 - if (ieee80211_is_data(hdr->frame_control))
225 - tx_desc->txdw5 |= cpu_to_le32(0x0001ff00);
228 - cpu_to_le32((u32)seq_number << TXDESC32_SEQ_SHIFT);
231 - tx_desc->txdw1 |= cpu_to_le32(TXDESC32_AGG_ENABLE);
233 - tx_desc->txdw1 |= cpu_to_le32(TXDESC32_AGG_BREAK);
235 - if (ieee80211_is_mgmt(hdr->frame_control)) {
236 - tx_desc->txdw5 = cpu_to_le32(rate);
238 - cpu_to_le32(TXDESC32_USE_DRIVER_RATE);
240 - cpu_to_le32(6 << TXDESC32_RETRY_LIMIT_SHIFT);
242 - cpu_to_le32(TXDESC32_RETRY_LIMIT_ENABLE);
245 - if (ieee80211_is_data_qos(hdr->frame_control))
246 - tx_desc->txdw4 |= cpu_to_le32(TXDESC32_QOS);
248 - if (short_preamble)
249 - tx_desc->txdw4 |= cpu_to_le32(TXDESC32_SHORT_PREAMBLE);
252 - tx_desc->txdw5 |= cpu_to_le32(TXDESC32_SHORT_GI);
254 - if (rate_flag & IEEE80211_TX_RC_USE_RTS_CTS) {
256 - * Use RTS rate 24M - does the mac80211 tell
260 - cpu_to_le32(DESC_RATE_24M <<
261 - TXDESC32_RTS_RATE_SHIFT);
263 - cpu_to_le32(TXDESC32_RTS_CTS_ENABLE);
264 - tx_desc->txdw4 |= cpu_to_le32(TXDESC32_HW_RTS_ENABLE);
267 - tx_desc40 = (struct rtl8xxxu_txdesc40 *)tx_desc;
269 - tx_desc40->txdw4 = cpu_to_le32(rate);
270 - if (ieee80211_is_data(hdr->frame_control)) {
272 - cpu_to_le32(0x1f <<
273 - TXDESC40_DATA_RATE_FB_SHIFT);
277 - cpu_to_le32((u32)seq_number << TXDESC40_SEQ_SHIFT);
280 - tx_desc40->txdw2 |= cpu_to_le32(TXDESC40_AGG_ENABLE);
282 - tx_desc40->txdw2 |= cpu_to_le32(TXDESC40_AGG_BREAK);
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);
294 - if (short_preamble)
295 - tx_desc40->txdw5 |=
296 - cpu_to_le32(TXDESC40_SHORT_PREAMBLE);
298 - if (rate_flag & IEEE80211_TX_RC_USE_RTS_CTS) {
300 - * Use RTS rate 24M - does the mac80211 tell
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);
310 + priv->fops->fill_txdesc(hdr, tx_desc, rate, rate_flag,
311 + sgi, short_preamble, ampdu_enable);
313 rtl8xxxu_calc_tx_desc_csum(tx_desc);