forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
....@@ -1,27 +1,5 @@
1
-/******************************************************************************
2
- *
3
- * Copyright(c) 2009-2012 Realtek Corporation. All rights reserved.
4
- *
5
- * This program is free software; you can redistribute it and/or modify it
6
- * under the terms of version 2 of the GNU General Public License as
7
- * published by the Free Software Foundation.
8
- *
9
- * This program is distributed in the hope that it will be useful, but WITHOUT
10
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
- * more details.
13
- *
14
- * The full GNU General Public License is included in this distribution in the
15
- * file called LICENSE.
16
- *
17
- * Contact Information:
18
- * wlanfae <wlanfae@realtek.com>
19
- * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
20
- * Hsinchu 300, Taiwan.
21
- *
22
- * Larry Finger <Larry.Finger@lwfinger.net>
23
- *
24
- *****************************************************************************/
1
+// SPDX-License-Identifier: GPL-2.0
2
+/* Copyright(c) 2009-2012 Realtek Corporation.*/
253
264 #include "../wifi.h"
275 #include "../usb.h"
....@@ -36,7 +14,7 @@
3614 #include "trx.h"
3715 #include "../rtl8192c/fw_common.h"
3816
39
-static int _ConfigVerTOutEP(struct ieee80211_hw *hw)
17
+static int configvertoutep(struct ieee80211_hw *hw)
4018 {
4119 u8 ep_cfg, txqsele;
4220 u8 ep_nums = 0;
....@@ -69,7 +47,7 @@
6947 return (rtlusb->out_ep_nums == ep_nums) ? 0 : -EINVAL;
7048 }
7149
72
-static int _ConfigVerNOutEP(struct ieee80211_hw *hw)
50
+static int configvernoutep(struct ieee80211_hw *hw)
7351 {
7452 u8 ep_cfg;
7553 u8 ep_nums = 0;
....@@ -98,14 +76,14 @@
9876 return (rtlusb->out_ep_nums == ep_nums) ? 0 : -EINVAL;
9977 }
10078
101
-static void _TwoOutEpMapping(struct ieee80211_hw *hw, bool bIsChipB,
79
+static void twooutepmapping(struct ieee80211_hw *hw, bool is_chip8,
10280 bool bwificfg, struct rtl_ep_map *ep_map)
10381 {
10482 struct rtl_priv *rtlpriv = rtl_priv(hw);
10583
10684 if (bwificfg) { /* for WMM */
107
- RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
108
- "USB Chip-B & WMM Setting.....\n");
85
+ rtl_dbg(rtlpriv, COMP_INIT, DBG_DMESG,
86
+ "USB Chip-B & WMM Setting.....\n");
10987 ep_map->ep_mapping[RTL_TXQ_BE] = 2;
11088 ep_map->ep_mapping[RTL_TXQ_BK] = 3;
11189 ep_map->ep_mapping[RTL_TXQ_VI] = 3;
....@@ -114,8 +92,8 @@
11492 ep_map->ep_mapping[RTL_TXQ_BCN] = 2;
11593 ep_map->ep_mapping[RTL_TXQ_HI] = 2;
11694 } else { /* typical setting */
117
- RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
118
- "USB typical Setting.....\n");
95
+ rtl_dbg(rtlpriv, COMP_INIT, DBG_DMESG,
96
+ "USB typical Setting.....\n");
11997 ep_map->ep_mapping[RTL_TXQ_BE] = 3;
12098 ep_map->ep_mapping[RTL_TXQ_BK] = 3;
12199 ep_map->ep_mapping[RTL_TXQ_VI] = 2;
....@@ -126,13 +104,14 @@
126104 }
127105 }
128106
129
-static void _ThreeOutEpMapping(struct ieee80211_hw *hw, bool bwificfg,
107
+static void threeoutepmapping(struct ieee80211_hw *hw, bool bwificfg,
130108 struct rtl_ep_map *ep_map)
131109 {
132110 struct rtl_priv *rtlpriv = rtl_priv(hw);
111
+
133112 if (bwificfg) { /* for WMM */
134
- RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
135
- "USB 3EP Setting for WMM.....\n");
113
+ rtl_dbg(rtlpriv, COMP_INIT, DBG_DMESG,
114
+ "USB 3EP Setting for WMM.....\n");
136115 ep_map->ep_mapping[RTL_TXQ_BE] = 5;
137116 ep_map->ep_mapping[RTL_TXQ_BK] = 3;
138117 ep_map->ep_mapping[RTL_TXQ_VI] = 3;
....@@ -141,8 +120,8 @@
141120 ep_map->ep_mapping[RTL_TXQ_BCN] = 2;
142121 ep_map->ep_mapping[RTL_TXQ_HI] = 2;
143122 } else { /* typical setting */
144
- RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
145
- "USB 3EP Setting for typical.....\n");
123
+ rtl_dbg(rtlpriv, COMP_INIT, DBG_DMESG,
124
+ "USB 3EP Setting for typical.....\n");
146125 ep_map->ep_mapping[RTL_TXQ_BE] = 5;
147126 ep_map->ep_mapping[RTL_TXQ_BK] = 5;
148127 ep_map->ep_mapping[RTL_TXQ_VI] = 3;
....@@ -153,7 +132,7 @@
153132 }
154133 }
155134
156
-static void _OneOutEpMapping(struct ieee80211_hw *hw, struct rtl_ep_map *ep_map)
135
+static void oneoutepmapping(struct ieee80211_hw *hw, struct rtl_ep_map *ep_map)
157136 {
158137 ep_map->ep_mapping[RTL_TXQ_BE] = 2;
159138 ep_map->ep_mapping[RTL_TXQ_BK] = 2;
....@@ -163,30 +142,31 @@
163142 ep_map->ep_mapping[RTL_TXQ_BCN] = 2;
164143 ep_map->ep_mapping[RTL_TXQ_HI] = 2;
165144 }
145
+
166146 static int _out_ep_mapping(struct ieee80211_hw *hw)
167147 {
168148 int err = 0;
169
- bool bIsChipN, bwificfg = false;
149
+ bool ischipn, bwificfg = false;
170150 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
171151 struct rtl_usb_priv *usb_priv = rtl_usbpriv(hw);
172152 struct rtl_usb *rtlusb = rtl_usbdev(usb_priv);
173153 struct rtl_ep_map *ep_map = &(rtlusb->ep_map);
174154
175
- bIsChipN = IS_NORMAL_CHIP(rtlhal->version);
155
+ ischipn = IS_NORMAL_CHIP(rtlhal->version);
176156 switch (rtlusb->out_ep_nums) {
177157 case 2:
178
- _TwoOutEpMapping(hw, bIsChipN, bwificfg, ep_map);
158
+ twooutepmapping(hw, ischipn, bwificfg, ep_map);
179159 break;
180160 case 3:
181161 /* Test chip doesn't support three out EPs. */
182
- if (!bIsChipN) {
162
+ if (!ischipn) {
183163 err = -EINVAL;
184164 goto err_out;
185165 }
186
- _ThreeOutEpMapping(hw, bIsChipN, ep_map);
166
+ threeoutepmapping(hw, ischipn, ep_map);
187167 break;
188168 case 1:
189
- _OneOutEpMapping(hw, ep_map);
169
+ oneoutepmapping(hw, ep_map);
190170 break;
191171 default:
192172 err = -EINVAL;
....@@ -196,15 +176,17 @@
196176 return err;
197177
198178 }
179
+
199180 /* endpoint mapping */
200181 int rtl8192cu_endpoint_mapping(struct ieee80211_hw *hw)
201182 {
202183 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
203184 int error = 0;
185
+
204186 if (likely(IS_NORMAL_CHIP(rtlhal->version)))
205
- error = _ConfigVerNOutEP(hw);
187
+ error = configvernoutep(hw);
206188 else
207
- error = _ConfigVerTOutEP(hw);
189
+ error = configvertoutep(hw);
208190 if (error)
209191 goto err_out;
210192 error = _out_ep_mapping(hw);
....@@ -266,24 +248,24 @@
266248 switch (mac80211_queue_index) {
267249 case 0: /* VO */
268250 qsel = QSLT_VO;
269
- RT_TRACE(rtlpriv, COMP_USB, DBG_DMESG,
270
- "VO queue, set qsel = 0x%x\n", QSLT_VO);
251
+ rtl_dbg(rtlpriv, COMP_USB, DBG_DMESG,
252
+ "VO queue, set qsel = 0x%x\n", QSLT_VO);
271253 break;
272254 case 1: /* VI */
273255 qsel = QSLT_VI;
274
- RT_TRACE(rtlpriv, COMP_USB, DBG_DMESG,
275
- "VI queue, set qsel = 0x%x\n", QSLT_VI);
256
+ rtl_dbg(rtlpriv, COMP_USB, DBG_DMESG,
257
+ "VI queue, set qsel = 0x%x\n", QSLT_VI);
276258 break;
277259 case 3: /* BK */
278260 qsel = QSLT_BK;
279
- RT_TRACE(rtlpriv, COMP_USB, DBG_DMESG,
280
- "BK queue, set qsel = 0x%x\n", QSLT_BK);
261
+ rtl_dbg(rtlpriv, COMP_USB, DBG_DMESG,
262
+ "BK queue, set qsel = 0x%x\n", QSLT_BK);
281263 break;
282264 case 2: /* BE */
283265 default:
284266 qsel = QSLT_BE;
285
- RT_TRACE(rtlpriv, COMP_USB, DBG_DMESG,
286
- "BE queue, set qsel = 0x%x\n", QSLT_BE);
267
+ rtl_dbg(rtlpriv, COMP_USB, DBG_DMESG,
268
+ "BE queue, set qsel = 0x%x\n", QSLT_BE);
287269 break;
288270 }
289271 out:
....@@ -300,44 +282,45 @@
300282 bool rtl92cu_rx_query_desc(struct ieee80211_hw *hw,
301283 struct rtl_stats *stats,
302284 struct ieee80211_rx_status *rx_status,
303
- u8 *pdesc, struct sk_buff *skb)
285
+ u8 *pdesc8, struct sk_buff *skb)
304286 {
305287 struct rx_fwinfo_92c *p_drvinfo;
306
- struct rx_desc_92c *p_desc = (struct rx_desc_92c *)pdesc;
307
- u32 phystatus = GET_RX_DESC_PHY_STATUS(pdesc);
288
+ struct rx_desc_92c *p_desc = (struct rx_desc_92c *)pdesc8;
289
+ __le32 *pdesc = (__le32 *)pdesc8;
290
+ u32 phystatus = get_rx_desc_phy_status(pdesc);
308291
309
- stats->length = (u16) GET_RX_DESC_PKT_LEN(pdesc);
310
- stats->rx_drvinfo_size = (u8)GET_RX_DESC_DRVINFO_SIZE(pdesc) *
292
+ stats->length = (u16)get_rx_desc_pkt_len(pdesc);
293
+ stats->rx_drvinfo_size = (u8)get_rx_desc_drvinfo_size(pdesc) *
311294 RX_DRV_INFO_SIZE_UNIT;
312
- stats->rx_bufshift = (u8) (GET_RX_DESC_SHIFT(pdesc) & 0x03);
313
- stats->icv = (u16) GET_RX_DESC_ICV(pdesc);
314
- stats->crc = (u16) GET_RX_DESC_CRC32(pdesc);
295
+ stats->rx_bufshift = (u8)(get_rx_desc_shift(pdesc) & 0x03);
296
+ stats->icv = (u16)get_rx_desc_icv(pdesc);
297
+ stats->crc = (u16)get_rx_desc_crc32(pdesc);
315298 stats->hwerror = (stats->crc | stats->icv);
316
- stats->decrypted = !GET_RX_DESC_SWDEC(pdesc);
317
- stats->rate = (u8) GET_RX_DESC_RX_MCS(pdesc);
318
- stats->shortpreamble = (u16) GET_RX_DESC_SPLCP(pdesc);
319
- stats->isampdu = (bool) (GET_RX_DESC_PAGGR(pdesc) == 1);
320
- stats->isfirst_ampdu = (bool)((GET_RX_DESC_PAGGR(pdesc) == 1)
321
- && (GET_RX_DESC_FAGGR(pdesc) == 1));
322
- stats->timestamp_low = GET_RX_DESC_TSFL(pdesc);
323
- stats->rx_is40Mhzpacket = (bool) GET_RX_DESC_BW(pdesc);
324
- stats->is_ht = (bool)GET_RX_DESC_RX_HT(pdesc);
299
+ stats->decrypted = !get_rx_desc_swdec(pdesc);
300
+ stats->rate = (u8)get_rx_desc_rx_mcs(pdesc);
301
+ stats->shortpreamble = (u16)get_rx_desc_splcp(pdesc);
302
+ stats->isampdu = (bool)(get_rx_desc_paggr(pdesc) == 1);
303
+ stats->isfirst_ampdu = (bool)((get_rx_desc_paggr(pdesc) == 1) &&
304
+ (get_rx_desc_faggr(pdesc) == 1));
305
+ stats->timestamp_low = get_rx_desc_tsfl(pdesc);
306
+ stats->rx_is40mhzpacket = (bool)get_rx_desc_bw(pdesc);
307
+ stats->is_ht = (bool)get_rx_desc_rx_ht(pdesc);
325308 rx_status->freq = hw->conf.chandef.chan->center_freq;
326309 rx_status->band = hw->conf.chandef.chan->band;
327
- if (GET_RX_DESC_CRC32(pdesc))
310
+ if (get_rx_desc_crc32(pdesc))
328311 rx_status->flag |= RX_FLAG_FAILED_FCS_CRC;
329
- if (!GET_RX_DESC_SWDEC(pdesc))
312
+ if (!get_rx_desc_swdec(pdesc))
330313 rx_status->flag |= RX_FLAG_DECRYPTED;
331
- if (GET_RX_DESC_BW(pdesc))
314
+ if (get_rx_desc_bw(pdesc))
332315 rx_status->bw = RATE_INFO_BW_40;
333
- if (GET_RX_DESC_RX_HT(pdesc))
316
+ if (get_rx_desc_rx_ht(pdesc))
334317 rx_status->encoding = RX_ENC_HT;
335318 rx_status->flag |= RX_FLAG_MACTIME_START;
336319 if (stats->decrypted)
337320 rx_status->flag |= RX_FLAG_DECRYPTED;
338321 rx_status->rate_idx = rtlwifi_rate_mapping(hw, stats->is_ht,
339322 false, stats->rate);
340
- rx_status->mactime = GET_RX_DESC_TSFL(pdesc);
323
+ rx_status->mactime = get_rx_desc_tsfl(pdesc);
341324 if (phystatus) {
342325 p_drvinfo = (struct rx_fwinfo_92c *)(skb->data +
343326 stats->rx_bufshift);
....@@ -357,7 +340,7 @@
357340 (struct ieee80211_rx_status *)IEEE80211_SKB_RXCB(skb);
358341 u32 skb_len, pkt_len, drvinfo_len;
359342 struct rtl_priv *rtlpriv = rtl_priv(hw);
360
- u8 *rxdesc;
343
+ __le32 *rxdesc;
361344 struct rtl_stats stats = {
362345 .signal = 0,
363346 .rate = 0,
....@@ -368,44 +351,44 @@
368351 struct ieee80211_hdr *hdr;
369352
370353 memset(rx_status, 0, sizeof(*rx_status));
371
- rxdesc = skb->data;
354
+ rxdesc = (__le32 *)skb->data;
372355 skb_len = skb->len;
373
- drvinfo_len = (GET_RX_DESC_DRVINFO_SIZE(rxdesc) * RTL_RX_DRV_INFO_UNIT);
374
- pkt_len = GET_RX_DESC_PKT_LEN(rxdesc);
356
+ drvinfo_len = (get_rx_desc_drvinfo_size(rxdesc) * RTL_RX_DRV_INFO_UNIT);
357
+ pkt_len = get_rx_desc_pkt_len(rxdesc);
375358 /* TODO: Error recovery. drop this skb or something. */
376359 WARN_ON(skb_len < (pkt_len + RTL_RX_DESC_SIZE + drvinfo_len));
377
- stats.length = (u16) GET_RX_DESC_PKT_LEN(rxdesc);
378
- stats.rx_drvinfo_size = (u8)GET_RX_DESC_DRVINFO_SIZE(rxdesc) *
360
+ stats.length = (u16)get_rx_desc_pkt_len(rxdesc);
361
+ stats.rx_drvinfo_size = (u8)get_rx_desc_drvinfo_size(rxdesc) *
379362 RX_DRV_INFO_SIZE_UNIT;
380
- stats.rx_bufshift = (u8) (GET_RX_DESC_SHIFT(rxdesc) & 0x03);
381
- stats.icv = (u16) GET_RX_DESC_ICV(rxdesc);
382
- stats.crc = (u16) GET_RX_DESC_CRC32(rxdesc);
363
+ stats.rx_bufshift = (u8)(get_rx_desc_shift(rxdesc) & 0x03);
364
+ stats.icv = (u16)get_rx_desc_icv(rxdesc);
365
+ stats.crc = (u16)get_rx_desc_crc32(rxdesc);
383366 stats.hwerror = (stats.crc | stats.icv);
384
- stats.decrypted = !GET_RX_DESC_SWDEC(rxdesc);
385
- stats.rate = (u8) GET_RX_DESC_RX_MCS(rxdesc);
386
- stats.shortpreamble = (u16) GET_RX_DESC_SPLCP(rxdesc);
387
- stats.isampdu = (bool) ((GET_RX_DESC_PAGGR(rxdesc) == 1)
388
- && (GET_RX_DESC_FAGGR(rxdesc) == 1));
389
- stats.timestamp_low = GET_RX_DESC_TSFL(rxdesc);
390
- stats.rx_is40Mhzpacket = (bool) GET_RX_DESC_BW(rxdesc);
391
- stats.is_ht = (bool)GET_RX_DESC_RX_HT(rxdesc);
367
+ stats.decrypted = !get_rx_desc_swdec(rxdesc);
368
+ stats.rate = (u8)get_rx_desc_rx_mcs(rxdesc);
369
+ stats.shortpreamble = (u16)get_rx_desc_splcp(rxdesc);
370
+ stats.isampdu = (bool)((get_rx_desc_paggr(rxdesc) == 1) &&
371
+ (get_rx_desc_faggr(rxdesc) == 1));
372
+ stats.timestamp_low = get_rx_desc_tsfl(rxdesc);
373
+ stats.rx_is40mhzpacket = (bool)get_rx_desc_bw(rxdesc);
374
+ stats.is_ht = (bool)get_rx_desc_rx_ht(rxdesc);
392375 /* TODO: is center_freq changed when doing scan? */
393376 /* TODO: Shall we add protection or just skip those two step? */
394377 rx_status->freq = hw->conf.chandef.chan->center_freq;
395378 rx_status->band = hw->conf.chandef.chan->band;
396
- if (GET_RX_DESC_CRC32(rxdesc))
379
+ if (get_rx_desc_crc32(rxdesc))
397380 rx_status->flag |= RX_FLAG_FAILED_FCS_CRC;
398
- if (!GET_RX_DESC_SWDEC(rxdesc))
381
+ if (!get_rx_desc_swdec(rxdesc))
399382 rx_status->flag |= RX_FLAG_DECRYPTED;
400
- if (GET_RX_DESC_BW(rxdesc))
383
+ if (get_rx_desc_bw(rxdesc))
401384 rx_status->bw = RATE_INFO_BW_40;
402
- if (GET_RX_DESC_RX_HT(rxdesc))
385
+ if (get_rx_desc_rx_ht(rxdesc))
403386 rx_status->encoding = RX_ENC_HT;
404387 /* Data rate */
405388 rx_status->rate_idx = rtlwifi_rate_mapping(hw, stats.is_ht,
406389 false, stats.rate);
407390 /* There is a phy status after this rx descriptor. */
408
- if (GET_RX_DESC_PHY_STATUS(rxdesc)) {
391
+ if (get_rx_desc_phy_status(rxdesc)) {
409392 p_drvinfo = (struct rx_fwinfo_92c *)(rxdesc + RTL_RX_DESC_SIZE);
410393 rtl92c_translate_rx_signal_stuff(hw, skb, &stats,
411394 (struct rx_desc_92c *)rxdesc, p_drvinfo);
....@@ -415,18 +398,18 @@
415398 fc = hdr->frame_control;
416399 bv = ieee80211_is_probe_resp(fc);
417400 if (bv)
418
- RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
419
- "Got probe response frame\n");
401
+ rtl_dbg(rtlpriv, COMP_INIT, DBG_DMESG,
402
+ "Got probe response frame\n");
420403 if (ieee80211_is_beacon(fc))
421
- RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "Got beacon frame\n");
404
+ rtl_dbg(rtlpriv, COMP_INIT, DBG_DMESG, "Got beacon frame\n");
422405 if (ieee80211_is_data(fc))
423
- RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "Got data frame\n");
424
- RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
425
- "Fram: fc = 0x%X addr1 = 0x%02X:0x%02X:0x%02X:0x%02X:0x%02X:0x%02X\n",
426
- fc,
427
- (u32)hdr->addr1[0], (u32)hdr->addr1[1],
428
- (u32)hdr->addr1[2], (u32)hdr->addr1[3],
429
- (u32)hdr->addr1[4], (u32)hdr->addr1[5]);
406
+ rtl_dbg(rtlpriv, COMP_INIT, DBG_DMESG, "Got data frame\n");
407
+ rtl_dbg(rtlpriv, COMP_INIT, DBG_DMESG,
408
+ "Fram: fc = 0x%X addr1 = 0x%02X:0x%02X:0x%02X:0x%02X:0x%02X:0x%02X\n",
409
+ fc,
410
+ (u32)hdr->addr1[0], (u32)hdr->addr1[1],
411
+ (u32)hdr->addr1[2], (u32)hdr->addr1[3],
412
+ (u32)hdr->addr1[4], (u32)hdr->addr1[5]);
430413 ieee80211_rx(hw, skb);
431414 }
432415
....@@ -458,26 +441,27 @@
458441
459442 /*======================================== trx ===============================*/
460443
461
-static void _rtl_fill_usb_tx_desc(u8 *txdesc)
444
+static void _rtl_fill_usb_tx_desc(__le32 *txdesc)
462445 {
463
- SET_TX_DESC_OWN(txdesc, 1);
464
- SET_TX_DESC_LAST_SEG(txdesc, 1);
465
- SET_TX_DESC_FIRST_SEG(txdesc, 1);
446
+ set_tx_desc_own(txdesc, 1);
447
+ set_tx_desc_last_seg(txdesc, 1);
448
+ set_tx_desc_first_seg(txdesc, 1);
466449 }
450
+
467451 /**
468452 * For HW recovery information
469453 */
470
-static void _rtl_tx_desc_checksum(u8 *txdesc)
454
+static void _rtl_tx_desc_checksum(__le32 *txdesc)
471455 {
472456 __le16 *ptr = (__le16 *)txdesc;
473457 u16 checksum = 0;
474458 u32 index;
475459
476460 /* Clear first */
477
- SET_TX_DESC_TX_DESC_CHECKSUM(txdesc, 0);
461
+ set_tx_desc_tx_desc_checksum(txdesc, 0);
478462 for (index = 0; index < 16; index++)
479463 checksum = checksum ^ le16_to_cpu(*(ptr + index));
480
- SET_TX_DESC_TX_DESC_CHECKSUM(txdesc, checksum);
464
+ set_tx_desc_tx_desc_checksum(txdesc, checksum);
481465 }
482466
483467 void rtl92cu_tx_fill_desc(struct ieee80211_hw *hw,
....@@ -500,169 +484,178 @@
500484 u16 pktlen = skb->len;
501485 enum rtl_desc_qsel fw_qsel = _rtl8192cu_mq_to_descq(hw, fc,
502486 skb_get_queue_mapping(skb));
503
- u8 *txdesc;
487
+ u8 *txdesc8;
488
+ __le32 *txdesc;
504489
505490 seq_number = (le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_SEQ) >> 4;
506491 rtl_get_tcb_desc(hw, info, sta, skb, tcb_desc);
507
- txdesc = skb_push(skb, RTL_TX_HEADER_SIZE);
492
+ txdesc8 = skb_push(skb, RTL_TX_HEADER_SIZE);
493
+ txdesc = (__le32 *)txdesc8;
508494 memset(txdesc, 0, RTL_TX_HEADER_SIZE);
509
- SET_TX_DESC_PKT_SIZE(txdesc, pktlen);
510
- SET_TX_DESC_LINIP(txdesc, 0);
511
- SET_TX_DESC_PKT_OFFSET(txdesc, RTL_DUMMY_OFFSET);
512
- SET_TX_DESC_OFFSET(txdesc, RTL_TX_HEADER_SIZE);
513
- SET_TX_DESC_TX_RATE(txdesc, tcb_desc->hw_rate);
495
+ set_tx_desc_pkt_size(txdesc, pktlen);
496
+ set_tx_desc_linip(txdesc, 0);
497
+ set_tx_desc_pkt_offset(txdesc, RTL_DUMMY_OFFSET);
498
+ set_tx_desc_offset(txdesc, RTL_TX_HEADER_SIZE);
499
+ set_tx_desc_tx_rate(txdesc, tcb_desc->hw_rate);
514500 if (tcb_desc->use_shortgi || tcb_desc->use_shortpreamble)
515
- SET_TX_DESC_DATA_SHORTGI(txdesc, 1);
501
+ set_tx_desc_data_shortgi(txdesc, 1);
516502 if (mac->tids[tid].agg.agg_state == RTL_AGG_ON &&
517503 info->flags & IEEE80211_TX_CTL_AMPDU) {
518
- SET_TX_DESC_AGG_ENABLE(txdesc, 1);
519
- SET_TX_DESC_MAX_AGG_NUM(txdesc, 0x14);
504
+ set_tx_desc_agg_enable(txdesc, 1);
505
+ set_tx_desc_max_agg_num(txdesc, 0x14);
520506 } else {
521
- SET_TX_DESC_AGG_BREAK(txdesc, 1);
507
+ set_tx_desc_agg_break(txdesc, 1);
522508 }
523
- SET_TX_DESC_SEQ(txdesc, seq_number);
524
- SET_TX_DESC_RTS_ENABLE(txdesc, ((tcb_desc->rts_enable &&
525
- !tcb_desc->cts_enable) ? 1 : 0));
526
- SET_TX_DESC_HW_RTS_ENABLE(txdesc, ((tcb_desc->rts_enable ||
527
- tcb_desc->cts_enable) ? 1 : 0));
528
- SET_TX_DESC_CTS2SELF(txdesc, ((tcb_desc->cts_enable) ? 1 : 0));
529
- SET_TX_DESC_RTS_STBC(txdesc, ((tcb_desc->rts_stbc) ? 1 : 0));
530
- SET_TX_DESC_RTS_RATE(txdesc, tcb_desc->rts_rate);
531
- SET_TX_DESC_RTS_BW(txdesc, 0);
532
- SET_TX_DESC_RTS_SC(txdesc, tcb_desc->rts_sc);
533
- SET_TX_DESC_RTS_SHORT(txdesc,
509
+ set_tx_desc_seq(txdesc, seq_number);
510
+ set_tx_desc_rts_enable(txdesc,
511
+ ((tcb_desc->rts_enable &&
512
+ !tcb_desc->cts_enable) ? 1 : 0));
513
+ set_tx_desc_hw_rts_enable(txdesc,
514
+ ((tcb_desc->rts_enable ||
515
+ tcb_desc->cts_enable) ? 1 : 0));
516
+ set_tx_desc_cts2self(txdesc, ((tcb_desc->cts_enable) ? 1 : 0));
517
+ set_tx_desc_rts_stbc(txdesc, ((tcb_desc->rts_stbc) ? 1 : 0));
518
+ set_tx_desc_rts_rate(txdesc, tcb_desc->rts_rate);
519
+ set_tx_desc_rts_bw(txdesc, 0);
520
+ set_tx_desc_rts_sc(txdesc, tcb_desc->rts_sc);
521
+ set_tx_desc_rts_short(txdesc,
534522 ((tcb_desc->rts_rate <= DESC_RATE54M) ?
535523 (tcb_desc->rts_use_shortpreamble ? 1 : 0)
536524 : (tcb_desc->rts_use_shortgi ? 1 : 0)));
537525 if (mac->bw_40) {
538526 if (rate_flag & IEEE80211_TX_RC_DUP_DATA) {
539
- SET_TX_DESC_DATA_BW(txdesc, 1);
540
- SET_TX_DESC_DATA_SC(txdesc, 3);
527
+ set_tx_desc_data_bw(txdesc, 1);
528
+ set_tx_desc_data_sc(txdesc, 3);
541529 } else if(rate_flag & IEEE80211_TX_RC_40_MHZ_WIDTH){
542
- SET_TX_DESC_DATA_BW(txdesc, 1);
543
- SET_TX_DESC_DATA_SC(txdesc, mac->cur_40_prime_sc);
530
+ set_tx_desc_data_bw(txdesc, 1);
531
+ set_tx_desc_data_sc(txdesc, mac->cur_40_prime_sc);
544532 } else {
545
- SET_TX_DESC_DATA_BW(txdesc, 0);
546
- SET_TX_DESC_DATA_SC(txdesc, 0);
533
+ set_tx_desc_data_bw(txdesc, 0);
534
+ set_tx_desc_data_sc(txdesc, 0);
547535 }
548536 } else {
549
- SET_TX_DESC_DATA_BW(txdesc, 0);
550
- SET_TX_DESC_DATA_SC(txdesc, 0);
537
+ set_tx_desc_data_bw(txdesc, 0);
538
+ set_tx_desc_data_sc(txdesc, 0);
551539 }
552540 rcu_read_lock();
553541 sta = ieee80211_find_sta(mac->vif, mac->bssid);
554542 if (sta) {
555543 u8 ampdu_density = sta->ht_cap.ampdu_density;
556
- SET_TX_DESC_AMPDU_DENSITY(txdesc, ampdu_density);
544
+
545
+ set_tx_desc_ampdu_density(txdesc, ampdu_density);
557546 }
558547 rcu_read_unlock();
559548 if (info->control.hw_key) {
560549 struct ieee80211_key_conf *keyconf = info->control.hw_key;
550
+
561551 switch (keyconf->cipher) {
562552 case WLAN_CIPHER_SUITE_WEP40:
563553 case WLAN_CIPHER_SUITE_WEP104:
564554 case WLAN_CIPHER_SUITE_TKIP:
565
- SET_TX_DESC_SEC_TYPE(txdesc, 0x1);
555
+ set_tx_desc_sec_type(txdesc, 0x1);
566556 break;
567557 case WLAN_CIPHER_SUITE_CCMP:
568
- SET_TX_DESC_SEC_TYPE(txdesc, 0x3);
558
+ set_tx_desc_sec_type(txdesc, 0x3);
569559 break;
570560 default:
571
- SET_TX_DESC_SEC_TYPE(txdesc, 0x0);
561
+ set_tx_desc_sec_type(txdesc, 0x0);
572562 break;
573563 }
574564 }
575
- SET_TX_DESC_PKT_ID(txdesc, 0);
576
- SET_TX_DESC_QUEUE_SEL(txdesc, fw_qsel);
577
- SET_TX_DESC_DATA_RATE_FB_LIMIT(txdesc, 0x1F);
578
- SET_TX_DESC_RTS_RATE_FB_LIMIT(txdesc, 0xF);
579
- SET_TX_DESC_DISABLE_FB(txdesc, 0);
580
- SET_TX_DESC_USE_RATE(txdesc, tcb_desc->use_driver_rate ? 1 : 0);
565
+ set_tx_desc_pkt_id(txdesc, 0);
566
+ set_tx_desc_queue_sel(txdesc, fw_qsel);
567
+ set_tx_desc_data_rate_fb_limit(txdesc, 0x1F);
568
+ set_tx_desc_rts_rate_fb_limit(txdesc, 0xF);
569
+ set_tx_desc_disable_fb(txdesc, 0);
570
+ set_tx_desc_use_rate(txdesc, tcb_desc->use_driver_rate ? 1 : 0);
581571 if (ieee80211_is_data_qos(fc)) {
582572 if (mac->rdg_en) {
583
- RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE,
584
- "Enable RDG function\n");
585
- SET_TX_DESC_RDG_ENABLE(txdesc, 1);
586
- SET_TX_DESC_HTC(txdesc, 1);
573
+ rtl_dbg(rtlpriv, COMP_SEND, DBG_TRACE,
574
+ "Enable RDG function\n");
575
+ set_tx_desc_rdg_enable(txdesc, 1);
576
+ set_tx_desc_htc(txdesc, 1);
587577 }
588578 }
589579 if (rtlpriv->dm.useramask) {
590
- SET_TX_DESC_RATE_ID(txdesc, tcb_desc->ratr_index);
591
- SET_TX_DESC_MACID(txdesc, tcb_desc->mac_id);
580
+ set_tx_desc_rate_id(txdesc, tcb_desc->ratr_index);
581
+ set_tx_desc_macid(txdesc, tcb_desc->mac_id);
592582 } else {
593
- SET_TX_DESC_RATE_ID(txdesc, 0xC + tcb_desc->ratr_index);
594
- SET_TX_DESC_MACID(txdesc, tcb_desc->ratr_index);
583
+ set_tx_desc_rate_id(txdesc, 0xC + tcb_desc->ratr_index);
584
+ set_tx_desc_macid(txdesc, tcb_desc->ratr_index);
595585 }
596586 if ((!ieee80211_is_data_qos(fc)) && ppsc->leisure_ps &&
597587 ppsc->fwctrl_lps) {
598
- SET_TX_DESC_HWSEQ_EN(txdesc, 1);
599
- SET_TX_DESC_PKT_ID(txdesc, 8);
588
+ set_tx_desc_hwseq_en(txdesc, 1);
589
+ set_tx_desc_pkt_id(txdesc, 8);
600590 if (!defaultadapter)
601
- SET_TX_DESC_QOS(txdesc, 1);
591
+ set_tx_desc_qos(txdesc, 1);
602592 }
603593 if (ieee80211_has_morefrags(fc))
604
- SET_TX_DESC_MORE_FRAG(txdesc, 1);
594
+ set_tx_desc_more_frag(txdesc, 1);
605595 if (is_multicast_ether_addr(ieee80211_get_DA(hdr)) ||
606596 is_broadcast_ether_addr(ieee80211_get_DA(hdr)))
607
- SET_TX_DESC_BMC(txdesc, 1);
597
+ set_tx_desc_bmc(txdesc, 1);
608598 _rtl_fill_usb_tx_desc(txdesc);
609599 _rtl_tx_desc_checksum(txdesc);
610
- RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, "==>\n");
600
+ rtl_dbg(rtlpriv, COMP_SEND, DBG_TRACE, "==>\n");
611601 }
612602
613
-void rtl92cu_fill_fake_txdesc(struct ieee80211_hw *hw, u8 * pDesc,
614
- u32 buffer_len, bool bIsPsPoll)
603
+void rtl92cu_fill_fake_txdesc(struct ieee80211_hw *hw, u8 *pdesc8,
604
+ u32 buffer_len, bool is_pspoll)
615605 {
606
+ __le32 *pdesc = (__le32 *)pdesc8;
607
+
616608 /* Clear all status */
617
- memset(pDesc, 0, RTL_TX_HEADER_SIZE);
618
- SET_TX_DESC_FIRST_SEG(pDesc, 1); /* bFirstSeg; */
619
- SET_TX_DESC_LAST_SEG(pDesc, 1); /* bLastSeg; */
620
- SET_TX_DESC_OFFSET(pDesc, RTL_TX_HEADER_SIZE); /* Offset = 32 */
621
- SET_TX_DESC_PKT_SIZE(pDesc, buffer_len); /* Buffer size + command hdr */
622
- SET_TX_DESC_QUEUE_SEL(pDesc, QSLT_MGNT); /* Fixed queue of Mgnt queue */
609
+ memset(pdesc, 0, RTL_TX_HEADER_SIZE);
610
+ set_tx_desc_first_seg(pdesc, 1); /* bFirstSeg; */
611
+ set_tx_desc_last_seg(pdesc, 1); /* bLastSeg; */
612
+ set_tx_desc_offset(pdesc, RTL_TX_HEADER_SIZE); /* Offset = 32 */
613
+ set_tx_desc_pkt_size(pdesc, buffer_len); /* Buffer size + command hdr */
614
+ set_tx_desc_queue_sel(pdesc, QSLT_MGNT); /* Fixed queue of Mgnt queue */
623615 /* Set NAVUSEHDR to prevent Ps-poll AId filed to be changed to error
624616 * vlaue by Hw. */
625
- if (bIsPsPoll) {
626
- SET_TX_DESC_NAV_USE_HDR(pDesc, 1);
617
+ if (is_pspoll) {
618
+ set_tx_desc_nav_use_hdr(pdesc, 1);
627619 } else {
628
- SET_TX_DESC_HWSEQ_EN(pDesc, 1); /* Hw set sequence number */
629
- SET_TX_DESC_PKT_ID(pDesc, 0x100); /* set bit3 to 1. */
620
+ set_tx_desc_hwseq_en(pdesc, 1); /* Hw set sequence number */
621
+ set_tx_desc_pkt_id(pdesc, BIT(3)); /* set bit3 to 1. */
630622 }
631
- SET_TX_DESC_USE_RATE(pDesc, 1); /* use data rate which is set by Sw */
632
- SET_TX_DESC_OWN(pDesc, 1);
633
- SET_TX_DESC_TX_RATE(pDesc, DESC_RATE1M);
634
- _rtl_tx_desc_checksum(pDesc);
623
+ set_tx_desc_use_rate(pdesc, 1); /* use data rate which is set by Sw */
624
+ set_tx_desc_own(pdesc, 1);
625
+ set_tx_desc_tx_rate(pdesc, DESC_RATE1M);
626
+ _rtl_tx_desc_checksum(pdesc);
635627 }
636628
637629 void rtl92cu_tx_fill_cmddesc(struct ieee80211_hw *hw,
638
- u8 *pdesc, bool firstseg,
630
+ u8 *pdesc8, bool firstseg,
639631 bool lastseg, struct sk_buff *skb)
640632 {
641633 struct rtl_priv *rtlpriv = rtl_priv(hw);
642634 u8 fw_queue = QSLT_BEACON;
643635 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)(skb->data);
644636 __le16 fc = hdr->frame_control;
637
+ __le32 *pdesc = (__le32 *)pdesc8;
645638
646639 memset((void *)pdesc, 0, RTL_TX_HEADER_SIZE);
647640 if (firstseg)
648
- SET_TX_DESC_OFFSET(pdesc, RTL_TX_HEADER_SIZE);
649
- SET_TX_DESC_TX_RATE(pdesc, DESC_RATE1M);
650
- SET_TX_DESC_SEQ(pdesc, 0);
651
- SET_TX_DESC_LINIP(pdesc, 0);
652
- SET_TX_DESC_QUEUE_SEL(pdesc, fw_queue);
653
- SET_TX_DESC_FIRST_SEG(pdesc, 1);
654
- SET_TX_DESC_LAST_SEG(pdesc, 1);
655
- SET_TX_DESC_RATE_ID(pdesc, 7);
656
- SET_TX_DESC_MACID(pdesc, 0);
657
- SET_TX_DESC_OWN(pdesc, 1);
658
- SET_TX_DESC_PKT_SIZE(pdesc, (u16)skb->len);
659
- SET_TX_DESC_FIRST_SEG(pdesc, 1);
660
- SET_TX_DESC_LAST_SEG(pdesc, 1);
661
- SET_TX_DESC_OFFSET(pdesc, 0x20);
662
- SET_TX_DESC_USE_RATE(pdesc, 1);
641
+ set_tx_desc_offset(pdesc, RTL_TX_HEADER_SIZE);
642
+ set_tx_desc_tx_rate(pdesc, DESC_RATE1M);
643
+ set_tx_desc_seq(pdesc, 0);
644
+ set_tx_desc_linip(pdesc, 0);
645
+ set_tx_desc_queue_sel(pdesc, fw_queue);
646
+ set_tx_desc_first_seg(pdesc, 1);
647
+ set_tx_desc_last_seg(pdesc, 1);
648
+ set_tx_desc_rate_id(pdesc, 7);
649
+ set_tx_desc_macid(pdesc, 0);
650
+ set_tx_desc_own(pdesc, 1);
651
+ set_tx_desc_pkt_size(pdesc, (u16)skb->len);
652
+ set_tx_desc_first_seg(pdesc, 1);
653
+ set_tx_desc_last_seg(pdesc, 1);
654
+ set_tx_desc_offset(pdesc, 0x20);
655
+ set_tx_desc_use_rate(pdesc, 1);
663656 if (!ieee80211_is_data_qos(fc)) {
664
- SET_TX_DESC_HWSEQ_EN(pdesc, 1);
665
- SET_TX_DESC_PKT_ID(pdesc, 8);
657
+ set_tx_desc_hwseq_en(pdesc, 1);
658
+ set_tx_desc_pkt_id(pdesc, 8);
666659 }
667660 RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD, "H2C Tx Cmd Content",
668661 pdesc, RTL_TX_DESC_SIZE);