aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rtlwifi/base.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/rtlwifi/base.c')
-rw-r--r--drivers/net/wireless/rtlwifi/base.c168
1 files changed, 166 insertions, 2 deletions
diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c
index 0b598db38da9..b4ce93436d2e 100644
--- a/drivers/net/wireless/rtlwifi/base.c
+++ b/drivers/net/wireless/rtlwifi/base.c
@@ -30,6 +30,7 @@
30#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 30#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31 31
32#include <linux/ip.h> 32#include <linux/ip.h>
33#include <linux/module.h>
33#include "wifi.h" 34#include "wifi.h"
34#include "rc.h" 35#include "rc.h"
35#include "base.h" 36#include "base.h"
@@ -311,6 +312,8 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw)
311 IEEE80211_HW_RX_INCLUDES_FCS | 312 IEEE80211_HW_RX_INCLUDES_FCS |
312 IEEE80211_HW_BEACON_FILTER | 313 IEEE80211_HW_BEACON_FILTER |
313 IEEE80211_HW_AMPDU_AGGREGATION | 314 IEEE80211_HW_AMPDU_AGGREGATION |
315 IEEE80211_HW_CONNECTION_MONITOR |
316 /* IEEE80211_HW_SUPPORTS_CQM_RSSI | */
314 IEEE80211_HW_REPORTS_TX_ACK_STATUS | 0; 317 IEEE80211_HW_REPORTS_TX_ACK_STATUS | 0;
315 318
316 /* swlps or hwlps has been set in diff chip in init_sw_vars */ 319 /* swlps or hwlps has been set in diff chip in init_sw_vars */
@@ -664,6 +667,167 @@ static u8 _rtl_get_highest_n_rate(struct ieee80211_hw *hw)
664 return hw_rate; 667 return hw_rate;
665} 668}
666 669
670/* mac80211's rate_idx is like this:
671 *
672 * 2.4G band:rx_status->band == IEEE80211_BAND_2GHZ
673 *
674 * B/G rate:
675 * (rx_status->flag & RX_FLAG_HT) = 0,
676 * DESC92_RATE1M-->DESC92_RATE54M ==> idx is 0-->11,
677 *
678 * N rate:
679 * (rx_status->flag & RX_FLAG_HT) = 1,
680 * DESC92_RATEMCS0-->DESC92_RATEMCS15 ==> idx is 0-->15
681 *
682 * 5G band:rx_status->band == IEEE80211_BAND_5GHZ
683 * A rate:
684 * (rx_status->flag & RX_FLAG_HT) = 0,
685 * DESC92_RATE6M-->DESC92_RATE54M ==> idx is 0-->7,
686 *
687 * N rate:
688 * (rx_status->flag & RX_FLAG_HT) = 1,
689 * DESC92_RATEMCS0-->DESC92_RATEMCS15 ==> idx is 0-->15
690 */
691int rtlwifi_rate_mapping(struct ieee80211_hw *hw,
692 bool isht, u8 desc_rate, bool first_ampdu)
693{
694 int rate_idx;
695
696 if (false == isht) {
697 if (IEEE80211_BAND_2GHZ == hw->conf.channel->band) {
698 switch (desc_rate) {
699 case DESC92_RATE1M:
700 rate_idx = 0;
701 break;
702 case DESC92_RATE2M:
703 rate_idx = 1;
704 break;
705 case DESC92_RATE5_5M:
706 rate_idx = 2;
707 break;
708 case DESC92_RATE11M:
709 rate_idx = 3;
710 break;
711 case DESC92_RATE6M:
712 rate_idx = 4;
713 break;
714 case DESC92_RATE9M:
715 rate_idx = 5;
716 break;
717 case DESC92_RATE12M:
718 rate_idx = 6;
719 break;
720 case DESC92_RATE18M:
721 rate_idx = 7;
722 break;
723 case DESC92_RATE24M:
724 rate_idx = 8;
725 break;
726 case DESC92_RATE36M:
727 rate_idx = 9;
728 break;
729 case DESC92_RATE48M:
730 rate_idx = 10;
731 break;
732 case DESC92_RATE54M:
733 rate_idx = 11;
734 break;
735 default:
736 rate_idx = 0;
737 break;
738 }
739 } else {
740 switch (desc_rate) {
741 case DESC92_RATE6M:
742 rate_idx = 0;
743 break;
744 case DESC92_RATE9M:
745 rate_idx = 1;
746 break;
747 case DESC92_RATE12M:
748 rate_idx = 2;
749 break;
750 case DESC92_RATE18M:
751 rate_idx = 3;
752 break;
753 case DESC92_RATE24M:
754 rate_idx = 4;
755 break;
756 case DESC92_RATE36M:
757 rate_idx = 5;
758 break;
759 case DESC92_RATE48M:
760 rate_idx = 6;
761 break;
762 case DESC92_RATE54M:
763 rate_idx = 7;
764 break;
765 default:
766 rate_idx = 0;
767 break;
768 }
769 }
770
771 } else {
772
773 switch (desc_rate) {
774 case DESC92_RATEMCS0:
775 rate_idx = 0;
776 break;
777 case DESC92_RATEMCS1:
778 rate_idx = 1;
779 break;
780 case DESC92_RATEMCS2:
781 rate_idx = 2;
782 break;
783 case DESC92_RATEMCS3:
784 rate_idx = 3;
785 break;
786 case DESC92_RATEMCS4:
787 rate_idx = 4;
788 break;
789 case DESC92_RATEMCS5:
790 rate_idx = 5;
791 break;
792 case DESC92_RATEMCS6:
793 rate_idx = 6;
794 break;
795 case DESC92_RATEMCS7:
796 rate_idx = 7;
797 break;
798 case DESC92_RATEMCS8:
799 rate_idx = 8;
800 break;
801 case DESC92_RATEMCS9:
802 rate_idx = 9;
803 break;
804 case DESC92_RATEMCS10:
805 rate_idx = 10;
806 break;
807 case DESC92_RATEMCS11:
808 rate_idx = 11;
809 break;
810 case DESC92_RATEMCS12:
811 rate_idx = 12;
812 break;
813 case DESC92_RATEMCS13:
814 rate_idx = 13;
815 break;
816 case DESC92_RATEMCS14:
817 rate_idx = 14;
818 break;
819 case DESC92_RATEMCS15:
820 rate_idx = 15;
821 break;
822 default:
823 rate_idx = 0;
824 break;
825 }
826 }
827 return rate_idx;
828}
829EXPORT_SYMBOL(rtlwifi_rate_mapping);
830
667void rtl_get_tcb_desc(struct ieee80211_hw *hw, 831void rtl_get_tcb_desc(struct ieee80211_hw *hw,
668 struct ieee80211_tx_info *info, 832 struct ieee80211_tx_info *info,
669 struct ieee80211_sta *sta, 833 struct ieee80211_sta *sta,
@@ -689,7 +853,7 @@ void rtl_get_tcb_desc(struct ieee80211_hw *hw,
689 *So tcb_desc->hw_rate is just used for 853 *So tcb_desc->hw_rate is just used for
690 *special data and mgt frames 854 *special data and mgt frames
691 */ 855 */
692 if (info->control.rates[0].idx == 0 && 856 if (info->control.rates[0].idx == 0 ||
693 ieee80211_is_nullfunc(fc)) { 857 ieee80211_is_nullfunc(fc)) {
694 tcb_desc->use_driver_rate = true; 858 tcb_desc->use_driver_rate = true;
695 tcb_desc->ratr_index = RATR_INX_WIRELESS_MC; 859 tcb_desc->ratr_index = RATR_INX_WIRELESS_MC;
@@ -977,7 +1141,7 @@ void rtl_watchdog_wq_callback(void *data)
977 } 1141 }
978 1142
979 /* 1143 /*
980 *<3> to check if traffic busy, if 1144 *<2> to check if traffic busy, if
981 * busytraffic we don't change channel 1145 * busytraffic we don't change channel
982 */ 1146 */
983 if (mac->link_state >= MAC80211_LINKED) { 1147 if (mac->link_state >= MAC80211_LINKED) {