forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-02-19 1c055e55a242a33e574e48be530e06770a210dcd
kernel/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/trx.c
....@@ -1,27 +1,5 @@
1
-/******************************************************************************
2
- *
3
- * Copyright(c) 2009-2010 Realtek Corporation.
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-2010 Realtek Corporation.*/
253
264 #include "../wifi.h"
275 #include "../pci.h"
....@@ -29,7 +7,6 @@
297 #include "../stats.h"
308 #include "reg.h"
319 #include "def.h"
32
-#include "phy.h"
3310 #include "trx.h"
3411 #include "led.h"
3512 #include "dm.h"
....@@ -79,7 +56,7 @@
7956 }
8057
8158 static void query_rxphystatus(struct ieee80211_hw *hw,
82
- struct rtl_stats *pstatus, u8 *pdesc,
59
+ struct rtl_stats *pstatus, __le32 *pdesc,
8360 struct rx_fwinfo_8821ae *p_drvinfo,
8461 bool bpacket_match_bssid,
8562 bool bpacket_toself, bool packet_beacon)
....@@ -297,7 +274,7 @@
297274
298275 static void translate_rx_signal_stuff(struct ieee80211_hw *hw,
299276 struct sk_buff *skb,
300
- struct rtl_stats *pstatus, u8 *pdesc,
277
+ struct rtl_stats *pstatus, __le32 *pdesc,
301278 struct rx_fwinfo_8821ae *p_drvinfo)
302279 {
303280 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
....@@ -307,14 +284,12 @@
307284 u8 *praddr;
308285 u8 *psaddr;
309286 __le16 fc;
310
- u16 type;
311287 bool packet_matchbssid, packet_toself, packet_beacon;
312288
313289 tmp_buf = skb->data + pstatus->rx_drvinfo_size + pstatus->rx_bufshift;
314290
315291 hdr = (struct ieee80211_hdr *)tmp_buf;
316292 fc = hdr->frame_control;
317
- type = WLAN_FC_GET_TYPE(hdr->frame_control);
318293 praddr = hdr->addr1;
319294 psaddr = ieee80211_get_SA(hdr);
320295 ether_addr_copy(pstatus->psaddr, psaddr);
....@@ -357,14 +332,14 @@
357332 rtl_process_phyinfo(hw, tmp_buf, pstatus);
358333 }
359334
360
-static void _rtl8821ae_insert_emcontent(struct rtl_tcb_desc *ptcb_desc,
361
- u8 *virtualaddress)
335
+static void rtl8821ae_insert_emcontent(struct rtl_tcb_desc *ptcb_desc,
336
+ __le32 *virtualaddress)
362337 {
363338 u32 dwtmp = 0;
364339
365340 memset(virtualaddress, 0, 8);
366341
367
- SET_EARLYMODE_PKTNUM(virtualaddress, ptcb_desc->empkt_num);
342
+ set_earlymode_pktnum(virtualaddress, ptcb_desc->empkt_num);
368343 if (ptcb_desc->empkt_num == 1) {
369344 dwtmp = ptcb_desc->empkt_len[0];
370345 } else {
....@@ -372,7 +347,7 @@
372347 dwtmp += ((dwtmp % 4) ? (4 - dwtmp % 4) : 0)+4;
373348 dwtmp += ptcb_desc->empkt_len[1];
374349 }
375
- SET_EARLYMODE_LEN0(virtualaddress, dwtmp);
350
+ set_earlymode_len0(virtualaddress, dwtmp);
376351
377352 if (ptcb_desc->empkt_num <= 3) {
378353 dwtmp = ptcb_desc->empkt_len[2];
....@@ -381,7 +356,7 @@
381356 dwtmp += ((dwtmp % 4) ? (4 - dwtmp % 4) : 0)+4;
382357 dwtmp += ptcb_desc->empkt_len[3];
383358 }
384
- SET_EARLYMODE_LEN1(virtualaddress, dwtmp);
359
+ set_earlymode_len1(virtualaddress, dwtmp);
385360 if (ptcb_desc->empkt_num <= 5) {
386361 dwtmp = ptcb_desc->empkt_len[4];
387362 } else {
....@@ -389,8 +364,8 @@
389364 dwtmp += ((dwtmp % 4) ? (4 - dwtmp % 4) : 0)+4;
390365 dwtmp += ptcb_desc->empkt_len[5];
391366 }
392
- SET_EARLYMODE_LEN2_1(virtualaddress, dwtmp & 0xF);
393
- SET_EARLYMODE_LEN2_2(virtualaddress, dwtmp >> 4);
367
+ set_earlymode_len2_1(virtualaddress, dwtmp & 0xF);
368
+ set_earlymode_len2_2(virtualaddress, dwtmp >> 4);
394369 if (ptcb_desc->empkt_num <= 7) {
395370 dwtmp = ptcb_desc->empkt_len[6];
396371 } else {
....@@ -398,7 +373,7 @@
398373 dwtmp += ((dwtmp % 4) ? (4 - dwtmp % 4) : 0)+4;
399374 dwtmp += ptcb_desc->empkt_len[7];
400375 }
401
- SET_EARLYMODE_LEN3(virtualaddress, dwtmp);
376
+ set_earlymode_len3(virtualaddress, dwtmp);
402377 if (ptcb_desc->empkt_num <= 9) {
403378 dwtmp = ptcb_desc->empkt_len[8];
404379 } else {
....@@ -406,43 +381,43 @@
406381 dwtmp += ((dwtmp % 4) ? (4 - dwtmp % 4) : 0)+4;
407382 dwtmp += ptcb_desc->empkt_len[9];
408383 }
409
- SET_EARLYMODE_LEN4(virtualaddress, dwtmp);
384
+ set_earlymode_len4(virtualaddress, dwtmp);
410385 }
411386
412
-static bool rtl8821ae_get_rxdesc_is_ht(struct ieee80211_hw *hw, u8 *pdesc)
387
+static bool rtl8821ae_get_rxdesc_is_ht(struct ieee80211_hw *hw, __le32 *pdesc)
413388 {
414389 struct rtl_priv *rtlpriv = rtl_priv(hw);
415390 u8 rx_rate = 0;
416391
417
- rx_rate = GET_RX_DESC_RXMCS(pdesc);
392
+ rx_rate = get_rx_desc_rxmcs(pdesc);
418393
419
- RT_TRACE(rtlpriv, COMP_RXDESC, DBG_LOUD, "rx_rate=0x%02x.\n", rx_rate);
394
+ rtl_dbg(rtlpriv, COMP_RXDESC, DBG_LOUD, "rx_rate=0x%02x.\n", rx_rate);
420395
421396 if ((rx_rate >= DESC_RATEMCS0) && (rx_rate <= DESC_RATEMCS15))
422397 return true;
423398 return false;
424399 }
425400
426
-static bool rtl8821ae_get_rxdesc_is_vht(struct ieee80211_hw *hw, u8 *pdesc)
401
+static bool rtl8821ae_get_rxdesc_is_vht(struct ieee80211_hw *hw, __le32 *pdesc)
427402 {
428403 struct rtl_priv *rtlpriv = rtl_priv(hw);
429404 u8 rx_rate = 0;
430405
431
- rx_rate = GET_RX_DESC_RXMCS(pdesc);
406
+ rx_rate = get_rx_desc_rxmcs(pdesc);
432407
433
- RT_TRACE(rtlpriv, COMP_RXDESC, DBG_LOUD, "rx_rate=0x%02x.\n", rx_rate);
408
+ rtl_dbg(rtlpriv, COMP_RXDESC, DBG_LOUD, "rx_rate=0x%02x.\n", rx_rate);
434409
435410 if (rx_rate >= DESC_RATEVHT1SS_MCS0)
436411 return true;
437412 return false;
438413 }
439414
440
-static u8 rtl8821ae_get_rx_vht_nss(struct ieee80211_hw *hw, u8 *pdesc)
415
+static u8 rtl8821ae_get_rx_vht_nss(struct ieee80211_hw *hw, __le32 *pdesc)
441416 {
442417 u8 rx_rate = 0;
443418 u8 vht_nss = 0;
444419
445
- rx_rate = GET_RX_DESC_RXMCS(pdesc);
420
+ rx_rate = get_rx_desc_rxmcs(pdesc);
446421 if ((rx_rate >= DESC_RATEVHT1SS_MCS0) &&
447422 (rx_rate <= DESC_RATEVHT1SS_MCS9))
448423 vht_nss = 1;
....@@ -456,60 +431,61 @@
456431 bool rtl8821ae_rx_query_desc(struct ieee80211_hw *hw,
457432 struct rtl_stats *status,
458433 struct ieee80211_rx_status *rx_status,
459
- u8 *pdesc, struct sk_buff *skb)
434
+ u8 *pdesc8, struct sk_buff *skb)
460435 {
461436 struct rtl_priv *rtlpriv = rtl_priv(hw);
462437 struct rx_fwinfo_8821ae *p_drvinfo;
463438 struct ieee80211_hdr *hdr;
439
+ u8 wake_match;
440
+ __le32 *pdesc = (__le32 *)pdesc8;
441
+ u32 phystatus = get_rx_desc_physt(pdesc);
464442
465
- u32 phystatus = GET_RX_DESC_PHYST(pdesc);
466
-
467
- status->length = (u16)GET_RX_DESC_PKT_LEN(pdesc);
468
- status->rx_drvinfo_size = (u8)GET_RX_DESC_DRV_INFO_SIZE(pdesc) *
443
+ status->length = (u16)get_rx_desc_pkt_len(pdesc);
444
+ status->rx_drvinfo_size = (u8)get_rx_desc_drv_info_size(pdesc) *
469445 RX_DRV_INFO_SIZE_UNIT;
470
- status->rx_bufshift = (u8)(GET_RX_DESC_SHIFT(pdesc) & 0x03);
471
- status->icv = (u16)GET_RX_DESC_ICV(pdesc);
472
- status->crc = (u16)GET_RX_DESC_CRC32(pdesc);
446
+ status->rx_bufshift = (u8)(get_rx_desc_shift(pdesc) & 0x03);
447
+ status->icv = (u16)get_rx_desc_icv(pdesc);
448
+ status->crc = (u16)get_rx_desc_crc32(pdesc);
473449 status->hwerror = (status->crc | status->icv);
474
- status->decrypted = !GET_RX_DESC_SWDEC(pdesc);
475
- status->rate = (u8)GET_RX_DESC_RXMCS(pdesc);
476
- status->shortpreamble = (u16)GET_RX_DESC_SPLCP(pdesc);
477
- status->isampdu = (bool)(GET_RX_DESC_PAGGR(pdesc) == 1);
478
- status->isfirst_ampdu = (bool)(GET_RX_DESC_PAGGR(pdesc) == 1);
479
- status->timestamp_low = GET_RX_DESC_TSFL(pdesc);
480
- status->rx_packet_bw = GET_RX_DESC_BW(pdesc);
481
- status->macid = GET_RX_DESC_MACID(pdesc);
482
- status->is_short_gi = !(bool)GET_RX_DESC_SPLCP(pdesc);
450
+ status->decrypted = !get_rx_desc_swdec(pdesc);
451
+ status->rate = (u8)get_rx_desc_rxmcs(pdesc);
452
+ status->shortpreamble = (u16)get_rx_desc_splcp(pdesc);
453
+ status->isampdu = (bool)(get_rx_desc_paggr(pdesc) == 1);
454
+ status->isfirst_ampdu = (bool)(get_rx_desc_paggr(pdesc) == 1);
455
+ status->timestamp_low = get_rx_desc_tsfl(pdesc);
456
+ status->rx_packet_bw = get_rx_desc_bw(pdesc);
457
+ status->macid = get_rx_desc_macid(pdesc);
458
+ status->is_short_gi = !(bool)get_rx_desc_splcp(pdesc);
483459 status->is_ht = rtl8821ae_get_rxdesc_is_ht(hw, pdesc);
484460 status->is_vht = rtl8821ae_get_rxdesc_is_vht(hw, pdesc);
485461 status->vht_nss = rtl8821ae_get_rx_vht_nss(hw, pdesc);
486462 status->is_cck = RTL8821AE_RX_HAL_IS_CCK_RATE(status->rate);
487463
488
- RT_TRACE(rtlpriv, COMP_RXDESC, DBG_LOUD,
489
- "rx_packet_bw=%s,is_ht %d, is_vht %d, vht_nss=%d,is_short_gi %d.\n",
490
- (status->rx_packet_bw == 2) ? "80M" :
491
- (status->rx_packet_bw == 1) ? "40M" : "20M",
492
- status->is_ht, status->is_vht, status->vht_nss,
493
- status->is_short_gi);
464
+ rtl_dbg(rtlpriv, COMP_RXDESC, DBG_LOUD,
465
+ "rx_packet_bw=%s,is_ht %d, is_vht %d, vht_nss=%d,is_short_gi %d.\n",
466
+ (status->rx_packet_bw == 2) ? "80M" :
467
+ (status->rx_packet_bw == 1) ? "40M" : "20M",
468
+ status->is_ht, status->is_vht, status->vht_nss,
469
+ status->is_short_gi);
494470
495
- if (GET_RX_STATUS_DESC_RPT_SEL(pdesc))
471
+ if (get_rx_status_desc_rpt_sel(pdesc))
496472 status->packet_report_type = C2H_PACKET;
497473 else
498474 status->packet_report_type = NORMAL_RX;
499475
500
- if (GET_RX_STATUS_DESC_PATTERN_MATCH(pdesc))
501
- status->wake_match = BIT(2);
502
- else if (GET_RX_STATUS_DESC_MAGIC_MATCH(pdesc))
503
- status->wake_match = BIT(1);
504
- else if (GET_RX_STATUS_DESC_UNICAST_MATCH(pdesc))
505
- status->wake_match = BIT(0);
476
+ if (get_rx_status_desc_pattern_match(pdesc))
477
+ wake_match = BIT(2);
478
+ else if (get_rx_status_desc_magic_match(pdesc))
479
+ wake_match = BIT(1);
480
+ else if (get_rx_status_desc_unicast_match(pdesc))
481
+ wake_match = BIT(0);
506482 else
507
- status->wake_match = 0;
483
+ wake_match = 0;
508484
509
- if (status->wake_match)
510
- RT_TRACE(rtlpriv, COMP_RXDESC, DBG_LOUD,
511
- "GGGGGGGGGGGGGet Wakeup Packet!! WakeMatch=%d\n",
512
- status->wake_match);
485
+ if (wake_match)
486
+ rtl_dbg(rtlpriv, COMP_RXDESC, DBG_LOUD,
487
+ "GGGGGGGGGGGGGet Wakeup Packet!! WakeMatch=%d\n",
488
+ wake_match);
513489 rx_status->freq = hw->conf.chandef.chan->center_freq;
514490 rx_status->band = hw->conf.chandef.chan->band;
515491
....@@ -568,9 +544,9 @@
568544 rx_status->signal = status->recvsignalpower + 10;
569545 if (status->packet_report_type == TX_REPORT2) {
570546 status->macid_valid_entry[0] =
571
- GET_RX_RPT2_DESC_MACID_VALID_1(pdesc);
547
+ get_rx_rpt2_desc_macid_valid_1(pdesc);
572548 status->macid_valid_entry[1] =
573
- GET_RX_RPT2_DESC_MACID_VALID_2(pdesc);
549
+ get_rx_rpt2_desc_macid_valid_2(pdesc);
574550 }
575551 return true;
576552 }
....@@ -582,9 +558,10 @@
582558 struct rtl_phy *rtlphy = &rtlpriv->phy;
583559 u8 bw_setting_of_desc = 0;
584560
585
- RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE,
586
- "rtl8821ae_bw_mapping, current_chan_bw %d, packet_bw %d\n",
587
- rtlphy->current_chan_bw, ptcb_desc->packet_bw);
561
+ rtl_dbg(rtlpriv, COMP_SEND, DBG_TRACE,
562
+ "%s, current_chan_bw %d, packet_bw %d\n",
563
+ __func__,
564
+ rtlphy->current_chan_bw, ptcb_desc->packet_bw);
588565
589566 if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_80) {
590567 if (ptcb_desc->packet_bw == HT_CHANNEL_WIDTH_80)
....@@ -626,8 +603,9 @@
626603 sc_setting_of_desc =
627604 VHT_DATA_SC_40_UPPER_OF_80MHZ;
628605 else
629
- RT_TRACE(rtlpriv, COMP_SEND, DBG_LOUD,
630
- "rtl8821ae_sc_mapping: Not Correct Primary40MHz Setting\n");
606
+ rtl_dbg(rtlpriv, COMP_SEND, DBG_LOUD,
607
+ "%s: Not Correct Primary40MHz Setting\n",
608
+ __func__);
631609 } else {
632610 if ((mac->cur_40_prime_sc ==
633611 HAL_PRIME_CHNL_OFFSET_LOWER) &&
....@@ -654,8 +632,9 @@
654632 sc_setting_of_desc =
655633 VHT_DATA_SC_20_UPPERST_OF_80MHZ;
656634 else
657
- RT_TRACE(rtlpriv, COMP_SEND, DBG_LOUD,
658
- "rtl8821ae_sc_mapping: Not Correct Primary40MHz Setting\n");
635
+ rtl_dbg(rtlpriv, COMP_SEND, DBG_LOUD,
636
+ "%s: Not Correct Primary40MHz Setting\n",
637
+ __func__);
659638 }
660639 } else if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20_40) {
661640 if (ptcb_desc->packet_bw == HT_CHANNEL_WIDTH_20_40) {
....@@ -681,7 +660,7 @@
681660 }
682661
683662 void rtl8821ae_tx_fill_desc(struct ieee80211_hw *hw,
684
- struct ieee80211_hdr *hdr, u8 *pdesc_tx, u8 *txbd,
663
+ struct ieee80211_hdr *hdr, u8 *pdesc8, u8 *txbd,
685664 struct ieee80211_tx_info *info,
686665 struct ieee80211_sta *sta,
687666 struct sk_buff *skb,
....@@ -692,7 +671,6 @@
692671 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
693672 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
694673 struct rtlwifi_tx_info *tx_info = rtl_tx_skb_cb_info(skb);
695
- u8 *pdesc = (u8 *)pdesc_tx;
696674 u16 seq_number;
697675 __le16 fc = hdr->frame_control;
698676 unsigned int buf_len = 0;
....@@ -704,6 +682,8 @@
704682 cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) == 0);
705683 dma_addr_t mapping;
706684 u8 short_gi = 0;
685
+ bool tmp_bool;
686
+ __le32 *pdesc = (__le32 *)pdesc8;
707687
708688 seq_number = (le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_SEQ) >> 4;
709689 rtl_get_tcb_desc(hw, info, sta, skb, ptcb_desc);
....@@ -713,76 +693,77 @@
713693 memset(skb->data, 0, EM_HDR_LEN);
714694 }
715695 buf_len = skb->len;
716
- mapping = pci_map_single(rtlpci->pdev, skb->data, skb->len,
717
- PCI_DMA_TODEVICE);
718
- if (pci_dma_mapping_error(rtlpci->pdev, mapping)) {
719
- RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE,
720
- "DMA mapping error\n");
696
+ mapping = dma_map_single(&rtlpci->pdev->dev, skb->data, skb->len,
697
+ DMA_TO_DEVICE);
698
+ if (dma_mapping_error(&rtlpci->pdev->dev, mapping)) {
699
+ rtl_dbg(rtlpriv, COMP_SEND, DBG_TRACE,
700
+ "DMA mapping error\n");
721701 return;
722702 }
723
- CLEAR_PCI_TX_DESC_CONTENT(pdesc, sizeof(struct tx_desc_8821ae));
703
+ clear_pci_tx_desc_content(pdesc, sizeof(struct tx_desc_8821ae));
724704 if (ieee80211_is_nullfunc(fc) || ieee80211_is_ctl(fc)) {
725705 firstseg = true;
726706 lastseg = true;
727707 }
728708 if (firstseg) {
729709 if (rtlhal->earlymode_enable) {
730
- SET_TX_DESC_PKT_OFFSET(pdesc, 1);
731
- SET_TX_DESC_OFFSET(pdesc, USB_HWDESC_HEADER_LEN +
710
+ set_tx_desc_pkt_offset(pdesc, 1);
711
+ set_tx_desc_offset(pdesc, USB_HWDESC_HEADER_LEN +
732712 EM_HDR_LEN);
733713 if (ptcb_desc->empkt_num) {
734
- RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE,
735
- "Insert 8 byte.pTcb->EMPktNum:%d\n",
736
- ptcb_desc->empkt_num);
737
- _rtl8821ae_insert_emcontent(ptcb_desc,
738
- (u8 *)(skb->data));
714
+ rtl_dbg(rtlpriv, COMP_SEND, DBG_TRACE,
715
+ "Insert 8 byte.pTcb->EMPktNum:%d\n",
716
+ ptcb_desc->empkt_num);
717
+ rtl8821ae_insert_emcontent(ptcb_desc,
718
+ (__le32 *)skb->data);
739719 }
740720 } else {
741
- SET_TX_DESC_OFFSET(pdesc, USB_HWDESC_HEADER_LEN);
721
+ set_tx_desc_offset(pdesc, USB_HWDESC_HEADER_LEN);
742722 }
743723
744724
745725 /* ptcb_desc->use_driver_rate = true; */
746
- SET_TX_DESC_TX_RATE(pdesc, ptcb_desc->hw_rate);
726
+ set_tx_desc_tx_rate(pdesc, ptcb_desc->hw_rate);
747727 if (ptcb_desc->hw_rate > DESC_RATEMCS0)
748728 short_gi = (ptcb_desc->use_shortgi) ? 1 : 0;
749729 else
750730 short_gi = (ptcb_desc->use_shortpreamble) ? 1 : 0;
751731
752
- SET_TX_DESC_DATA_SHORTGI(pdesc, short_gi);
732
+ set_tx_desc_data_shortgi(pdesc, short_gi);
753733
754734 if (info->flags & IEEE80211_TX_CTL_AMPDU) {
755
- SET_TX_DESC_AGG_ENABLE(pdesc, 1);
756
- SET_TX_DESC_MAX_AGG_NUM(pdesc, 0x1f);
735
+ set_tx_desc_agg_enable(pdesc, 1);
736
+ set_tx_desc_max_agg_num(pdesc, 0x1f);
757737 }
758
- SET_TX_DESC_SEQ(pdesc, seq_number);
759
- SET_TX_DESC_RTS_ENABLE(pdesc, ((ptcb_desc->rts_enable &&
738
+ set_tx_desc_seq(pdesc, seq_number);
739
+ set_tx_desc_rts_enable(pdesc,
740
+ ((ptcb_desc->rts_enable &&
760741 !ptcb_desc->cts_enable) ? 1 : 0));
761
- SET_TX_DESC_HW_RTS_ENABLE(pdesc, 0);
762
- SET_TX_DESC_CTS2SELF(pdesc, ((ptcb_desc->cts_enable) ? 1 : 0));
742
+ set_tx_desc_hw_rts_enable(pdesc, 0);
743
+ set_tx_desc_cts2self(pdesc, ((ptcb_desc->cts_enable) ? 1 : 0));
763744
764
- SET_TX_DESC_RTS_RATE(pdesc, ptcb_desc->rts_rate);
765
- SET_TX_DESC_RTS_SC(pdesc, ptcb_desc->rts_sc);
766
- SET_TX_DESC_RTS_SHORT(pdesc,
767
- ((ptcb_desc->rts_rate <= DESC_RATE54M) ?
768
- (ptcb_desc->rts_use_shortpreamble ? 1 : 0) :
769
- (ptcb_desc->rts_use_shortgi ? 1 : 0)));
745
+ set_tx_desc_rts_rate(pdesc, ptcb_desc->rts_rate);
746
+ set_tx_desc_rts_sc(pdesc, ptcb_desc->rts_sc);
747
+ tmp_bool = ((ptcb_desc->rts_rate <= DESC_RATE54M) ?
748
+ (ptcb_desc->rts_use_shortpreamble ? 1 : 0) :
749
+ (ptcb_desc->rts_use_shortgi ? 1 : 0));
750
+ set_tx_desc_rts_short(pdesc, tmp_bool);
770751
771752 if (ptcb_desc->tx_enable_sw_calc_duration)
772
- SET_TX_DESC_NAV_USE_HDR(pdesc, 1);
753
+ set_tx_desc_nav_use_hdr(pdesc, 1);
773754
774
- SET_TX_DESC_DATA_BW(pdesc,
775
- rtl8821ae_bw_mapping(hw, ptcb_desc));
755
+ set_tx_desc_data_bw(pdesc,
756
+ rtl8821ae_bw_mapping(hw, ptcb_desc));
776757
777
- SET_TX_DESC_TX_SUB_CARRIER(pdesc,
778
- rtl8821ae_sc_mapping(hw, ptcb_desc));
758
+ set_tx_desc_tx_sub_carrier(pdesc,
759
+ rtl8821ae_sc_mapping(hw, ptcb_desc));
779760
780
- SET_TX_DESC_LINIP(pdesc, 0);
781
- SET_TX_DESC_PKT_SIZE(pdesc, (u16)skb_len);
761
+ set_tx_desc_linip(pdesc, 0);
762
+ set_tx_desc_pkt_size(pdesc, (u16)skb_len);
782763 if (sta) {
783764 u8 ampdu_density = sta->ht_cap.ampdu_density;
784765
785
- SET_TX_DESC_AMPDU_DENSITY(pdesc, ampdu_density);
766
+ set_tx_desc_ampdu_density(pdesc, ampdu_density);
786767 }
787768 if (info->control.hw_key) {
788769 struct ieee80211_key_conf *keyconf =
....@@ -791,121 +772,123 @@
791772 case WLAN_CIPHER_SUITE_WEP40:
792773 case WLAN_CIPHER_SUITE_WEP104:
793774 case WLAN_CIPHER_SUITE_TKIP:
794
- SET_TX_DESC_SEC_TYPE(pdesc, 0x1);
775
+ set_tx_desc_sec_type(pdesc, 0x1);
795776 break;
796777 case WLAN_CIPHER_SUITE_CCMP:
797
- SET_TX_DESC_SEC_TYPE(pdesc, 0x3);
778
+ set_tx_desc_sec_type(pdesc, 0x3);
798779 break;
799780 default:
800
- SET_TX_DESC_SEC_TYPE(pdesc, 0x0);
781
+ set_tx_desc_sec_type(pdesc, 0x0);
801782 break;
802783 }
803784 }
804785
805
- SET_TX_DESC_QUEUE_SEL(pdesc, fw_qsel);
806
- SET_TX_DESC_DATA_RATE_FB_LIMIT(pdesc, 0x1F);
807
- SET_TX_DESC_RTS_RATE_FB_LIMIT(pdesc, 0xF);
808
- SET_TX_DESC_DISABLE_FB(pdesc, ptcb_desc->disable_ratefallback ?
786
+ set_tx_desc_queue_sel(pdesc, fw_qsel);
787
+ set_tx_desc_data_rate_fb_limit(pdesc, 0x1F);
788
+ set_tx_desc_rts_rate_fb_limit(pdesc, 0xF);
789
+ set_tx_desc_disable_fb(pdesc, ptcb_desc->disable_ratefallback ?
809790 1 : 0);
810
- SET_TX_DESC_USE_RATE(pdesc, ptcb_desc->use_driver_rate ? 1 : 0);
791
+ set_tx_desc_use_rate(pdesc, ptcb_desc->use_driver_rate ? 1 : 0);
811792
812793 if (ieee80211_is_data_qos(fc)) {
813794 if (mac->rdg_en) {
814
- RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE,
815
- "Enable RDG function.\n");
816
- SET_TX_DESC_RDG_ENABLE(pdesc, 1);
817
- SET_TX_DESC_HTC(pdesc, 1);
795
+ rtl_dbg(rtlpriv, COMP_SEND, DBG_TRACE,
796
+ "Enable RDG function.\n");
797
+ set_tx_desc_rdg_enable(pdesc, 1);
798
+ set_tx_desc_htc(pdesc, 1);
818799 }
819800 }
820801 /* tx report */
821
- rtl_set_tx_report(ptcb_desc, pdesc, hw, tx_info);
802
+ rtl_set_tx_report(ptcb_desc, pdesc8, hw, tx_info);
822803 }
823804
824
- SET_TX_DESC_FIRST_SEG(pdesc, (firstseg ? 1 : 0));
825
- SET_TX_DESC_LAST_SEG(pdesc, (lastseg ? 1 : 0));
826
- SET_TX_DESC_TX_BUFFER_SIZE(pdesc, (u16)buf_len);
827
- SET_TX_DESC_TX_BUFFER_ADDRESS(pdesc, mapping);
805
+ set_tx_desc_first_seg(pdesc, (firstseg ? 1 : 0));
806
+ set_tx_desc_last_seg(pdesc, (lastseg ? 1 : 0));
807
+ set_tx_desc_tx_buffer_size(pdesc, buf_len);
808
+ set_tx_desc_tx_buffer_address(pdesc, mapping);
828809 /* if (rtlpriv->dm.useramask) { */
829810 if (1) {
830
- SET_TX_DESC_RATE_ID(pdesc, ptcb_desc->ratr_index);
831
- SET_TX_DESC_MACID(pdesc, ptcb_desc->mac_id);
811
+ set_tx_desc_rate_id(pdesc, ptcb_desc->ratr_index);
812
+ set_tx_desc_macid(pdesc, ptcb_desc->mac_id);
832813 } else {
833
- SET_TX_DESC_RATE_ID(pdesc, 0xC + ptcb_desc->ratr_index);
834
- SET_TX_DESC_MACID(pdesc, ptcb_desc->mac_id);
814
+ set_tx_desc_rate_id(pdesc, 0xC + ptcb_desc->ratr_index);
815
+ set_tx_desc_macid(pdesc, ptcb_desc->mac_id);
835816 }
836817 if (!ieee80211_is_data_qos(fc)) {
837
- SET_TX_DESC_HWSEQ_EN(pdesc, 1);
838
- SET_TX_DESC_HWSEQ_SEL(pdesc, 0);
818
+ set_tx_desc_hwseq_en(pdesc, 1);
819
+ set_tx_desc_hwseq_sel(pdesc, 0);
839820 }
840
- SET_TX_DESC_MORE_FRAG(pdesc, (lastseg ? 0 : 1));
821
+ set_tx_desc_more_frag(pdesc, (lastseg ? 0 : 1));
841822 if (is_multicast_ether_addr(ieee80211_get_DA(hdr)) ||
842823 is_broadcast_ether_addr(ieee80211_get_DA(hdr))) {
843
- SET_TX_DESC_BMC(pdesc, 1);
824
+ set_tx_desc_bmc(pdesc, 1);
844825 }
845826
846
- rtl8821ae_dm_set_tx_ant_by_tx_info(hw, pdesc, ptcb_desc->mac_id);
847
- RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, "\n");
827
+ rtl8821ae_dm_set_tx_ant_by_tx_info(hw, pdesc8, ptcb_desc->mac_id);
828
+ rtl_dbg(rtlpriv, COMP_SEND, DBG_TRACE, "\n");
848829 }
849830
850831 void rtl8821ae_tx_fill_cmddesc(struct ieee80211_hw *hw,
851
- u8 *pdesc, bool firstseg,
832
+ u8 *pdesc8, bool firstseg,
852833 bool lastseg, struct sk_buff *skb)
853834 {
854835 struct rtl_priv *rtlpriv = rtl_priv(hw);
855836 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
856837 u8 fw_queue = QSLT_BEACON;
838
+ __le32 *pdesc = (__le32 *)pdesc8;
857839
858
- dma_addr_t mapping = pci_map_single(rtlpci->pdev,
859
- skb->data, skb->len,
860
- PCI_DMA_TODEVICE);
840
+ dma_addr_t mapping = dma_map_single(&rtlpci->pdev->dev, skb->data,
841
+ skb->len, DMA_TO_DEVICE);
861842
862
- if (pci_dma_mapping_error(rtlpci->pdev, mapping)) {
863
- RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE,
864
- "DMA mapping error\n");
843
+ if (dma_mapping_error(&rtlpci->pdev->dev, mapping)) {
844
+ rtl_dbg(rtlpriv, COMP_SEND, DBG_TRACE,
845
+ "DMA mapping error\n");
865846 return;
866847 }
867
- CLEAR_PCI_TX_DESC_CONTENT(pdesc, TX_DESC_SIZE);
848
+ clear_pci_tx_desc_content(pdesc, TX_DESC_SIZE);
868849
869
- SET_TX_DESC_FIRST_SEG(pdesc, 1);
870
- SET_TX_DESC_LAST_SEG(pdesc, 1);
850
+ set_tx_desc_first_seg(pdesc, 1);
851
+ set_tx_desc_last_seg(pdesc, 1);
871852
872
- SET_TX_DESC_PKT_SIZE((u8 *)pdesc, (u16)(skb->len));
853
+ set_tx_desc_pkt_size(pdesc, (u16)(skb->len));
873854
874
- SET_TX_DESC_OFFSET(pdesc, USB_HWDESC_HEADER_LEN);
855
+ set_tx_desc_offset(pdesc, USB_HWDESC_HEADER_LEN);
875856
876
- SET_TX_DESC_USE_RATE(pdesc, 1);
877
- SET_TX_DESC_TX_RATE(pdesc, DESC_RATE1M);
878
- SET_TX_DESC_DISABLE_FB(pdesc, 1);
857
+ set_tx_desc_use_rate(pdesc, 1);
858
+ set_tx_desc_tx_rate(pdesc, DESC_RATE1M);
859
+ set_tx_desc_disable_fb(pdesc, 1);
879860
880
- SET_TX_DESC_DATA_BW(pdesc, 0);
861
+ set_tx_desc_data_bw(pdesc, 0);
881862
882
- SET_TX_DESC_HWSEQ_EN(pdesc, 1);
863
+ set_tx_desc_hwseq_en(pdesc, 1);
883864
884
- SET_TX_DESC_QUEUE_SEL(pdesc, fw_queue);
865
+ set_tx_desc_queue_sel(pdesc, fw_queue);
885866
886
- SET_TX_DESC_TX_BUFFER_SIZE(pdesc, (u16)(skb->len));
867
+ set_tx_desc_tx_buffer_size(pdesc, skb->len);
887868
888
- SET_TX_DESC_TX_BUFFER_ADDRESS(pdesc, mapping);
869
+ set_tx_desc_tx_buffer_address(pdesc, mapping);
889870
890
- SET_TX_DESC_MACID(pdesc, 0);
871
+ set_tx_desc_macid(pdesc, 0);
891872
892
- SET_TX_DESC_OWN(pdesc, 1);
873
+ set_tx_desc_own(pdesc, 1);
893874
894875 RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD,
895876 "H2C Tx Cmd Content\n",
896
- pdesc, TX_DESC_SIZE);
877
+ pdesc8, TX_DESC_SIZE);
897878 }
898879
899
-void rtl8821ae_set_desc(struct ieee80211_hw *hw, u8 *pdesc,
880
+void rtl8821ae_set_desc(struct ieee80211_hw *hw, u8 *pdesc8,
900881 bool istx, u8 desc_name, u8 *val)
901882 {
883
+ __le32 *pdesc = (__le32 *)pdesc8;
884
+
902885 if (istx) {
903886 switch (desc_name) {
904887 case HW_DESC_OWN:
905
- SET_TX_DESC_OWN(pdesc, 1);
888
+ set_tx_desc_own(pdesc, 1);
906889 break;
907890 case HW_DESC_TX_NEXTDESC_ADDR:
908
- SET_TX_DESC_NEXT_DESC_ADDRESS(pdesc, *(u32 *)val);
891
+ set_tx_desc_next_desc_address(pdesc, *(u32 *)val);
909892 break;
910893 default:
911894 WARN_ONCE(true,
....@@ -916,16 +899,16 @@
916899 } else {
917900 switch (desc_name) {
918901 case HW_DESC_RXOWN:
919
- SET_RX_DESC_OWN(pdesc, 1);
902
+ set_rx_desc_own(pdesc, 1);
920903 break;
921904 case HW_DESC_RXBUFF_ADDR:
922
- SET_RX_DESC_BUFF_ADDR(pdesc, *(u32 *)val);
905
+ set_rx_desc_buff_addr(pdesc, *(u32 *)val);
923906 break;
924907 case HW_DESC_RXPKT_LEN:
925
- SET_RX_DESC_PKT_LEN(pdesc, *(u32 *)val);
908
+ set_rx_desc_pkt_len(pdesc, *(u32 *)val);
926909 break;
927910 case HW_DESC_RXERO:
928
- SET_RX_DESC_EOR(pdesc, 1);
911
+ set_rx_desc_eor(pdesc, 1);
929912 break;
930913 default:
931914 WARN_ONCE(true,
....@@ -937,17 +920,18 @@
937920 }
938921
939922 u64 rtl8821ae_get_desc(struct ieee80211_hw *hw,
940
- u8 *pdesc, bool istx, u8 desc_name)
923
+ u8 *pdesc8, bool istx, u8 desc_name)
941924 {
942925 u32 ret = 0;
926
+ __le32 *pdesc = (__le32 *)pdesc8;
943927
944928 if (istx) {
945929 switch (desc_name) {
946930 case HW_DESC_OWN:
947
- ret = GET_TX_DESC_OWN(pdesc);
931
+ ret = get_tx_desc_own(pdesc);
948932 break;
949933 case HW_DESC_TXBUFF_ADDR:
950
- ret = GET_TX_DESC_TX_BUFFER_ADDRESS(pdesc);
934
+ ret = get_tx_desc_tx_buffer_address(pdesc);
951935 break;
952936 default:
953937 WARN_ONCE(true,
....@@ -958,13 +942,13 @@
958942 } else {
959943 switch (desc_name) {
960944 case HW_DESC_OWN:
961
- ret = GET_RX_DESC_OWN(pdesc);
945
+ ret = get_rx_desc_own(pdesc);
962946 break;
963947 case HW_DESC_RXPKT_LEN:
964
- ret = GET_RX_DESC_PKT_LEN(pdesc);
948
+ ret = get_rx_desc_pkt_len(pdesc);
965949 break;
966950 case HW_DESC_RXBUFF_ADDR:
967
- ret = GET_RX_DESC_BUFF_ADDR(pdesc);
951
+ ret = get_rx_desc_buff_addr(pdesc);
968952 break;
969953 default:
970954 WARN_ONCE(true,