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
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>
16 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
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(-)
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 {
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,
36 int writeN_block_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,
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,
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
101 + * Fill in v1 (gen1) specific TX descriptor bits.
102 + * This format is used on 8188cu/8192cu/8723au
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,
112 + seq_number = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl));
114 + tx_desc->txdw5 = cpu_to_le32(rate);
116 + if (ieee80211_is_data(hdr->frame_control))
117 + tx_desc->txdw5 |= cpu_to_le32(0x0001ff00);
119 + tx_desc->txdw3 = cpu_to_le32((u32)seq_number << TXDESC32_SEQ_SHIFT);
122 + tx_desc->txdw1 |= cpu_to_le32(TXDESC32_AGG_ENABLE);
124 + tx_desc->txdw1 |= cpu_to_le32(TXDESC32_AGG_BREAK);
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);
133 + if (ieee80211_is_data_qos(hdr->frame_control))
134 + tx_desc->txdw4 |= cpu_to_le32(TXDESC32_QOS);
136 + if (short_preamble)
137 + tx_desc->txdw4 |= cpu_to_le32(TXDESC32_SHORT_PREAMBLE);
140 + tx_desc->txdw5 |= cpu_to_le32(TXDESC32_SHORT_GI);
142 + if (rate_flag & IEEE80211_TX_RC_USE_RTS_CTS) {
144 + * Use RTS rate 24M - does the mac80211 tell
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);
155 + * Fill in v2 (gen2) specific TX descriptor bits.
156 + * This format is used on 8192eu/8723bu
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,
164 + struct rtl8xxxu_txdesc40 *tx_desc40;
167 + tx_desc40 = (struct rtl8xxxu_txdesc40 *)tx_desc32;
169 + seq_number = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl));
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);
177 + tx_desc40->txdw9 = cpu_to_le32((u32)seq_number << TXDESC40_SEQ_SHIFT);
180 + tx_desc40->txdw2 |= cpu_to_le32(TXDESC40_AGG_ENABLE);
182 + tx_desc40->txdw2 |= cpu_to_le32(TXDESC40_AGG_BREAK);
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);
192 + if (short_preamble)
193 + tx_desc40->txdw5 |= cpu_to_le32(TXDESC40_SHORT_PREAMBLE);
195 + if (rate_flag & IEEE80211_TX_RC_USE_RTS_CTS) {
197 + * Use RTS rate 24M - does the mac80211 tell
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);
207 static void rtl8xxxu_tx(struct ieee80211_hw *hw,
208 struct ieee80211_tx_control *control,
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;
221 seq_number = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl));
223 - tx_desc->txdw5 = cpu_to_le32(rate);
225 - if (ieee80211_is_data(hdr->frame_control))
226 - tx_desc->txdw5 |= cpu_to_le32(0x0001ff00);
229 - cpu_to_le32((u32)seq_number << TXDESC32_SEQ_SHIFT);
232 - tx_desc->txdw1 |= cpu_to_le32(TXDESC32_AGG_ENABLE);
234 - tx_desc->txdw1 |= cpu_to_le32(TXDESC32_AGG_BREAK);
236 - if (ieee80211_is_mgmt(hdr->frame_control)) {
237 - tx_desc->txdw5 = cpu_to_le32(rate);
239 - cpu_to_le32(TXDESC32_USE_DRIVER_RATE);
241 - cpu_to_le32(6 << TXDESC32_RETRY_LIMIT_SHIFT);
243 - cpu_to_le32(TXDESC32_RETRY_LIMIT_ENABLE);
246 - if (ieee80211_is_data_qos(hdr->frame_control))
247 - tx_desc->txdw4 |= cpu_to_le32(TXDESC32_QOS);
249 - if (short_preamble)
250 - tx_desc->txdw4 |= cpu_to_le32(TXDESC32_SHORT_PREAMBLE);
253 - tx_desc->txdw5 |= cpu_to_le32(TXDESC32_SHORT_GI);
255 - if (rate_flag & IEEE80211_TX_RC_USE_RTS_CTS) {
257 - * Use RTS rate 24M - does the mac80211 tell
261 - cpu_to_le32(DESC_RATE_24M <<
262 - TXDESC32_RTS_RATE_SHIFT);
264 - cpu_to_le32(TXDESC32_RTS_CTS_ENABLE);
265 - tx_desc->txdw4 |= cpu_to_le32(TXDESC32_HW_RTS_ENABLE);
268 - tx_desc40 = (struct rtl8xxxu_txdesc40 *)tx_desc;
270 - tx_desc40->txdw4 = cpu_to_le32(rate);
271 - if (ieee80211_is_data(hdr->frame_control)) {
273 - cpu_to_le32(0x1f <<
274 - TXDESC40_DATA_RATE_FB_SHIFT);
278 - cpu_to_le32((u32)seq_number << TXDESC40_SEQ_SHIFT);
281 - tx_desc40->txdw2 |= cpu_to_le32(TXDESC40_AGG_ENABLE);
283 - tx_desc40->txdw2 |= cpu_to_le32(TXDESC40_AGG_BREAK);
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);
295 - if (short_preamble)
296 - tx_desc40->txdw5 |=
297 - cpu_to_le32(TXDESC40_SHORT_PREAMBLE);
299 - if (rate_flag & IEEE80211_TX_RC_USE_RTS_CTS) {
301 - * Use RTS rate 24M - does the mac80211 tell
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);
311 + priv->fops->fill_txdesc(hdr, tx_desc, rate, rate_flag,
312 + sgi, short_preamble, ampdu_enable);
314 rtl8xxxu_calc_tx_desc_csum(tx_desc);