aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rtlwifi/wifi.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/rtlwifi/wifi.h')
-rw-r--r--drivers/net/wireless/rtlwifi/wifi.h680
1 files changed, 503 insertions, 177 deletions
diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h
index d44d79613d2d..01226f8e70f9 100644
--- a/drivers/net/wireless/rtlwifi/wifi.h
+++ b/drivers/net/wireless/rtlwifi/wifi.h
@@ -34,6 +34,8 @@
34#include <linux/firmware.h> 34#include <linux/firmware.h>
35#include <linux/version.h> 35#include <linux/version.h>
36#include <linux/etherdevice.h> 36#include <linux/etherdevice.h>
37#include <linux/vmalloc.h>
38#include <linux/usb.h>
37#include <net/mac80211.h> 39#include <net/mac80211.h>
38#include "debug.h" 40#include "debug.h"
39 41
@@ -82,6 +84,19 @@
82#define MAC80211_3ADDR_LEN 24 84#define MAC80211_3ADDR_LEN 24
83#define MAC80211_4ADDR_LEN 30 85#define MAC80211_4ADDR_LEN 30
84 86
87#define CHANNEL_MAX_NUMBER (14 + 24 + 21) /* 14 is the max channel no */
88#define CHANNEL_GROUP_MAX (3 + 9) /* ch1~3, 4~9, 10~14 = three groups */
89#define MAX_PG_GROUP 13
90#define CHANNEL_GROUP_MAX_2G 3
91#define CHANNEL_GROUP_IDX_5GL 3
92#define CHANNEL_GROUP_IDX_5GM 6
93#define CHANNEL_GROUP_IDX_5GH 9
94#define CHANNEL_GROUP_MAX_5G 9
95#define CHANNEL_MAX_NUMBER_2G 14
96#define AVG_THERMAL_NUM 8
97
98/* for early mode */
99#define EM_HDR_LEN 8
85enum intf_type { 100enum intf_type {
86 INTF_PCI = 0, 101 INTF_PCI = 0,
87 INTF_USB = 1, 102 INTF_USB = 1,
@@ -113,11 +128,38 @@ enum hardware_type {
113 HARDWARE_TYPE_RTL8192CU, 128 HARDWARE_TYPE_RTL8192CU,
114 HARDWARE_TYPE_RTL8192DE, 129 HARDWARE_TYPE_RTL8192DE,
115 HARDWARE_TYPE_RTL8192DU, 130 HARDWARE_TYPE_RTL8192DU,
131 HARDWARE_TYPE_RTL8723E,
132 HARDWARE_TYPE_RTL8723U,
116 133
117 /*keep it last*/ 134 /* keep it last */
118 HARDWARE_TYPE_NUM 135 HARDWARE_TYPE_NUM
119}; 136};
120 137
138#define IS_HARDWARE_TYPE_8192SU(rtlhal) \
139 (rtlhal->hw_type == HARDWARE_TYPE_RTL8192SU)
140#define IS_HARDWARE_TYPE_8192SE(rtlhal) \
141 (rtlhal->hw_type == HARDWARE_TYPE_RTL8192SE)
142#define IS_HARDWARE_TYPE_8192CE(rtlhal) \
143 (rtlhal->hw_type == HARDWARE_TYPE_RTL8192CE)
144#define IS_HARDWARE_TYPE_8192CU(rtlhal) \
145 (rtlhal->hw_type == HARDWARE_TYPE_RTL8192CU)
146#define IS_HARDWARE_TYPE_8192DE(rtlhal) \
147 (rtlhal->hw_type == HARDWARE_TYPE_RTL8192DE)
148#define IS_HARDWARE_TYPE_8192DU(rtlhal) \
149 (rtlhal->hw_type == HARDWARE_TYPE_RTL8192DU)
150#define IS_HARDWARE_TYPE_8723E(rtlhal) \
151 (rtlhal->hw_type == HARDWARE_TYPE_RTL8723E)
152#define IS_HARDWARE_TYPE_8723U(rtlhal) \
153 (rtlhal->hw_type == HARDWARE_TYPE_RTL8723U)
154#define IS_HARDWARE_TYPE_8192S(rtlhal) \
155(IS_HARDWARE_TYPE_8192SE(rtlhal) || IS_HARDWARE_TYPE_8192SU(rtlhal))
156#define IS_HARDWARE_TYPE_8192C(rtlhal) \
157(IS_HARDWARE_TYPE_8192CE(rtlhal) || IS_HARDWARE_TYPE_8192CU(rtlhal))
158#define IS_HARDWARE_TYPE_8192D(rtlhal) \
159(IS_HARDWARE_TYPE_8192DE(rtlhal) || IS_HARDWARE_TYPE_8192DU(rtlhal))
160#define IS_HARDWARE_TYPE_8723(rtlhal) \
161(IS_HARDWARE_TYPE_8723E(rtlhal) || IS_HARDWARE_TYPE_8723U(rtlhal))
162
121enum scan_operation_backup_opt { 163enum scan_operation_backup_opt {
122 SCAN_OPT_BACKUP = 0, 164 SCAN_OPT_BACKUP = 0,
123 SCAN_OPT_RESTORE, 165 SCAN_OPT_RESTORE,
@@ -315,6 +357,7 @@ enum rf_type {
315 RF_1T1R = 0, 357 RF_1T1R = 0,
316 RF_1T2R = 1, 358 RF_1T2R = 1,
317 RF_2T2R = 2, 359 RF_2T2R = 2,
360 RF_2T2R_GREEN = 3,
318}; 361};
319 362
320enum ht_channel_width { 363enum ht_channel_width {
@@ -359,6 +402,8 @@ enum rtl_var_map {
359 EFUSE_LOADER_CLK_EN, 402 EFUSE_LOADER_CLK_EN,
360 EFUSE_ANA8M, 403 EFUSE_ANA8M,
361 EFUSE_HWSET_MAX_SIZE, 404 EFUSE_HWSET_MAX_SIZE,
405 EFUSE_MAX_SECTION_MAP,
406 EFUSE_REAL_CONTENT_SIZE,
362 407
363 /*CAM map */ 408 /*CAM map */
364 RWCAM, 409 RWCAM,
@@ -397,6 +442,7 @@ enum rtl_var_map {
397 RTL_IMR_ATIMEND, /*For 92C,ATIM Window End Interrupt */ 442 RTL_IMR_ATIMEND, /*For 92C,ATIM Window End Interrupt */
398 RTL_IMR_BDOK, /*Beacon Queue DMA OK Interrup */ 443 RTL_IMR_BDOK, /*Beacon Queue DMA OK Interrup */
399 RTL_IMR_HIGHDOK, /*High Queue DMA OK Interrupt */ 444 RTL_IMR_HIGHDOK, /*High Queue DMA OK Interrupt */
445 RTL_IMR_COMDOK, /*Command Queue DMA OK Interrupt*/
400 RTL_IMR_TBDOK, /*Transmit Beacon OK interrup */ 446 RTL_IMR_TBDOK, /*Transmit Beacon OK interrup */
401 RTL_IMR_MGNTDOK, /*Management Queue DMA OK Interrupt */ 447 RTL_IMR_MGNTDOK, /*Management Queue DMA OK Interrupt */
402 RTL_IMR_TBDER, /*For 92C,Transmit Beacon Error Interrupt */ 448 RTL_IMR_TBDER, /*For 92C,Transmit Beacon Error Interrupt */
@@ -405,7 +451,8 @@ enum rtl_var_map {
405 RTL_IMR_VIDOK, /*AC_VI DMA OK Interrupt */ 451 RTL_IMR_VIDOK, /*AC_VI DMA OK Interrupt */
406 RTL_IMR_VODOK, /*AC_VO DMA Interrupt */ 452 RTL_IMR_VODOK, /*AC_VO DMA Interrupt */
407 RTL_IMR_ROK, /*Receive DMA OK Interrupt */ 453 RTL_IMR_ROK, /*Receive DMA OK Interrupt */
408 RTL_IBSS_INT_MASKS, /*(RTL_IMR_BcnInt|RTL_IMR_TBDOK|RTL_IMR_TBDER)*/ 454 RTL_IBSS_INT_MASKS, /*(RTL_IMR_BcnInt | RTL_IMR_TBDOK |
455 * RTL_IMR_TBDER) */
409 456
410 /*CCK Rates, TxHT = 0 */ 457 /*CCK Rates, TxHT = 0 */
411 RTL_RC_CCK_RATE1M, 458 RTL_RC_CCK_RATE1M,
@@ -481,6 +528,19 @@ enum acm_method {
481 eAcmWay2_SW = 2, 528 eAcmWay2_SW = 2,
482}; 529};
483 530
531enum macphy_mode {
532 SINGLEMAC_SINGLEPHY = 0,
533 DUALMAC_DUALPHY,
534 DUALMAC_SINGLEPHY,
535};
536
537enum band_type {
538 BAND_ON_2_4G = 0,
539 BAND_ON_5G,
540 BAND_ON_BOTH,
541 BANDMAX
542};
543
484/*aci/aifsn Field. 544/*aci/aifsn Field.
485Ref: WMM spec 2.2.2: WME Parameter Element, p.12.*/ 545Ref: WMM spec 2.2.2: WME Parameter Element, p.12.*/
486union aci_aifsn { 546union aci_aifsn {
@@ -505,6 +565,17 @@ enum wireless_mode {
505 WIRELESS_MODE_N_5G = 0x20 565 WIRELESS_MODE_N_5G = 0x20
506}; 566};
507 567
568#define IS_WIRELESS_MODE_A(wirelessmode) \
569 (wirelessmode == WIRELESS_MODE_A)
570#define IS_WIRELESS_MODE_B(wirelessmode) \
571 (wirelessmode == WIRELESS_MODE_B)
572#define IS_WIRELESS_MODE_G(wirelessmode) \
573 (wirelessmode == WIRELESS_MODE_G)
574#define IS_WIRELESS_MODE_N_24G(wirelessmode) \
575 (wirelessmode == WIRELESS_MODE_N_24G)
576#define IS_WIRELESS_MODE_N_5G(wirelessmode) \
577 (wirelessmode == WIRELESS_MODE_N_5G)
578
508enum ratr_table_mode { 579enum ratr_table_mode {
509 RATR_INX_WIRELESS_NGB = 0, 580 RATR_INX_WIRELESS_NGB = 0,
510 RATR_INX_WIRELESS_NG = 1, 581 RATR_INX_WIRELESS_NG = 1,
@@ -574,11 +645,11 @@ struct rtl_probe_rsp {
574struct rtl_led { 645struct rtl_led {
575 void *hw; 646 void *hw;
576 enum rtl_led_pin ledpin; 647 enum rtl_led_pin ledpin;
577 bool b_ledon; 648 bool ledon;
578}; 649};
579 650
580struct rtl_led_ctl { 651struct rtl_led_ctl {
581 bool bled_opendrain; 652 bool led_opendrain;
582 struct rtl_led sw_led0; 653 struct rtl_led sw_led0;
583 struct rtl_led sw_led1; 654 struct rtl_led sw_led1;
584}; 655};
@@ -603,6 +674,8 @@ struct false_alarm_statistics {
603 u32 cnt_rate_illegal; 674 u32 cnt_rate_illegal;
604 u32 cnt_crc8_fail; 675 u32 cnt_crc8_fail;
605 u32 cnt_mcs_fail; 676 u32 cnt_mcs_fail;
677 u32 cnt_fast_fsync_fail;
678 u32 cnt_sb_search_fail;
606 u32 cnt_ofdm_fail; 679 u32 cnt_ofdm_fail;
607 u32 cnt_cck_fail; 680 u32 cnt_cck_fail;
608 u32 cnt_all; 681 u32 cnt_all;
@@ -690,6 +763,32 @@ struct rtl_rfkill {
690 bool rfkill_state; /*0 is off, 1 is on */ 763 bool rfkill_state; /*0 is off, 1 is on */
691}; 764};
692 765
766#define IQK_MATRIX_REG_NUM 8
767#define IQK_MATRIX_SETTINGS_NUM (1 + 24 + 21)
768struct iqk_matrix_regs {
769 bool b_iqk_done;
770 long value[1][IQK_MATRIX_REG_NUM];
771};
772
773struct phy_parameters {
774 u16 length;
775 u32 *pdata;
776};
777
778enum hw_param_tab_index {
779 PHY_REG_2T,
780 PHY_REG_1T,
781 PHY_REG_PG,
782 RADIOA_2T,
783 RADIOB_2T,
784 RADIOA_1T,
785 RADIOB_1T,
786 MAC_REG,
787 AGCTAB_2T,
788 AGCTAB_1T,
789 MAX_TAB
790};
791
693struct rtl_phy { 792struct rtl_phy {
694 struct bb_reg_def phyreg_def[4]; /*Radio A/B/C/D */ 793 struct bb_reg_def phyreg_def[4]; /*Radio A/B/C/D */
695 struct init_gain initgain_backup; 794 struct init_gain initgain_backup;
@@ -705,8 +804,9 @@ struct rtl_phy {
705 u8 current_channel; 804 u8 current_channel;
706 u8 h2c_box_num; 805 u8 h2c_box_num;
707 u8 set_io_inprogress; 806 u8 set_io_inprogress;
807 u8 lck_inprogress;
708 808
709 /*record for power tracking*/ 809 /* record for power tracking */
710 s32 reg_e94; 810 s32 reg_e94;
711 s32 reg_e9c; 811 s32 reg_e9c;
712 s32 reg_ea4; 812 s32 reg_ea4;
@@ -723,26 +823,32 @@ struct rtl_phy {
723 u32 iqk_mac_backup[IQK_MAC_REG_NUM]; 823 u32 iqk_mac_backup[IQK_MAC_REG_NUM];
724 u32 iqk_bb_backup[10]; 824 u32 iqk_bb_backup[10];
725 825
726 bool b_rfpi_enable; 826 /* Dual mac */
827 bool need_iqk;
828 struct iqk_matrix_regs iqk_matrix_regsetting[IQK_MATRIX_SETTINGS_NUM];
829
830 bool rfpi_enable;
727 831
728 u8 pwrgroup_cnt; 832 u8 pwrgroup_cnt;
729 u8 bcck_high_power; 833 u8 cck_high_power;
730 /* 3 groups of pwr diff by rates*/ 834 /* MAX_PG_GROUP groups of pwr diff by rates */
731 u32 mcs_txpwrlevel_origoffset[4][16]; 835 u32 mcs_txpwrlevel_origoffset[MAX_PG_GROUP][16];
732 u8 default_initialgain[4]; 836 u8 default_initialgain[4];
733 837
734 /*the current Tx power level*/ 838 /* the current Tx power level */
735 u8 cur_cck_txpwridx; 839 u8 cur_cck_txpwridx;
736 u8 cur_ofdm24g_txpwridx; 840 u8 cur_ofdm24g_txpwridx;
737 841
738 u32 rfreg_chnlval[2]; 842 u32 rfreg_chnlval[2];
739 bool b_apk_done; 843 bool apk_done;
844 u32 reg_rf3c[2]; /* pathA / pathB */
740 845
741 /*fsync*/
742 u8 framesync; 846 u8 framesync;
743 u32 framesync_c34; 847 u32 framesync_c34;
744 848
745 u8 num_total_rfpath; 849 u8 num_total_rfpath;
850 struct phy_parameters hwparam_tables[MAX_TAB];
851 u16 rf_pathmap;
746}; 852};
747 853
748#define MAX_TID_COUNT 9 854#define MAX_TID_COUNT 9
@@ -768,6 +874,7 @@ struct rtl_tid_data {
768struct rtl_priv; 874struct rtl_priv;
769struct rtl_io { 875struct rtl_io {
770 struct device *dev; 876 struct device *dev;
877 struct mutex bb_mutex;
771 878
772 /*PCI MEM map */ 879 /*PCI MEM map */
773 unsigned long pci_mem_end; /*shared mem end */ 880 unsigned long pci_mem_end; /*shared mem end */
@@ -779,11 +886,14 @@ struct rtl_io {
779 void (*write8_async) (struct rtl_priv *rtlpriv, u32 addr, u8 val); 886 void (*write8_async) (struct rtl_priv *rtlpriv, u32 addr, u8 val);
780 void (*write16_async) (struct rtl_priv *rtlpriv, u32 addr, u16 val); 887 void (*write16_async) (struct rtl_priv *rtlpriv, u32 addr, u16 val);
781 void (*write32_async) (struct rtl_priv *rtlpriv, u32 addr, u32 val); 888 void (*write32_async) (struct rtl_priv *rtlpriv, u32 addr, u32 val);
782 889 int (*writeN_async) (struct rtl_priv *rtlpriv, u32 addr, u16 len,
783 u8(*read8_sync) (struct rtl_priv *rtlpriv, u32 addr); 890 u8 *pdata);
784 u16(*read16_sync) (struct rtl_priv *rtlpriv, u32 addr); 891
785 u32(*read32_sync) (struct rtl_priv *rtlpriv, u32 addr); 892 u8(*read8_sync) (struct rtl_priv *rtlpriv, u32 addr);
786 893 u16(*read16_sync) (struct rtl_priv *rtlpriv, u32 addr);
894 u32(*read32_sync) (struct rtl_priv *rtlpriv, u32 addr);
895 int (*readN_sync) (struct rtl_priv *rtlpriv, u32 addr, u16 len,
896 u8 *pdata);
787}; 897};
788 898
789struct rtl_mac { 899struct rtl_mac {
@@ -815,16 +925,24 @@ struct rtl_mac {
815 bool act_scanning; 925 bool act_scanning;
816 u8 cnt_after_linked; 926 u8 cnt_after_linked;
817 927
818 /*RDG*/ bool rdg_en; 928 /* early mode */
929 /* skb wait queue */
930 struct sk_buff_head skb_waitq[MAX_TID_COUNT];
931 u8 earlymode_threshold;
932
933 /*RDG*/
934 bool rdg_en;
819 935
820 /*AP*/ u8 bssid[6]; 936 /*AP*/
821 u8 mcs[16]; /*16 bytes mcs for HT rates.*/ 937 u8 bssid[6];
822 u32 basic_rates; /*b/g rates*/ 938 u32 vendor;
939 u8 mcs[16]; /* 16 bytes mcs for HT rates. */
940 u32 basic_rates; /* b/g rates */
823 u8 ht_enable; 941 u8 ht_enable;
824 u8 sgi_40; 942 u8 sgi_40;
825 u8 sgi_20; 943 u8 sgi_20;
826 u8 bw_40; 944 u8 bw_40;
827 u8 mode; /*wireless mode*/ 945 u8 mode; /* wireless mode */
828 u8 slot_time; 946 u8 slot_time;
829 u8 short_preamble; 947 u8 short_preamble;
830 u8 use_cts_protect; 948 u8 use_cts_protect;
@@ -835,9 +953,11 @@ struct rtl_mac {
835 u8 retry_long; 953 u8 retry_long;
836 u16 assoc_id; 954 u16 assoc_id;
837 955
838 /*IBSS*/ int beacon_interval; 956 /*IBSS*/
957 int beacon_interval;
839 958
840 /*AMPDU*/ u8 min_space_cfg; /*For Min spacing configurations */ 959 /*AMPDU*/
960 u8 min_space_cfg; /*For Min spacing configurations */
841 u8 max_mss_density; 961 u8 max_mss_density;
842 u8 current_ampdu_factor; 962 u8 current_ampdu_factor;
843 u8 current_ampdu_density; 963 u8 current_ampdu_density;
@@ -852,17 +972,54 @@ struct rtl_hal {
852 972
853 enum intf_type interface; 973 enum intf_type interface;
854 u16 hw_type; /*92c or 92d or 92s and so on */ 974 u16 hw_type; /*92c or 92d or 92s and so on */
975 u8 ic_class;
855 u8 oem_id; 976 u8 oem_id;
856 u8 version; /*version of chip */ 977 u32 version; /*version of chip */
857 u8 state; /*stop 0, start 1 */ 978 u8 state; /*stop 0, start 1 */
858 979
859 /*firmware */ 980 /*firmware */
981 u32 fwsize;
860 u8 *pfirmware; 982 u8 *pfirmware;
861 bool b_h2c_setinprogress; 983 u16 fw_version;
984 u16 fw_subversion;
985 bool h2c_setinprogress;
862 u8 last_hmeboxnum; 986 u8 last_hmeboxnum;
863 bool bfw_ready; 987 bool fw_ready;
864 /*Reserve page start offset except beacon in TxQ. */ 988 /*Reserve page start offset except beacon in TxQ. */
865 u8 fw_rsvdpage_startoffset; 989 u8 fw_rsvdpage_startoffset;
990 u8 h2c_txcmd_seq;
991
992 /* FW Cmd IO related */
993 u16 fwcmd_iomap;
994 u32 fwcmd_ioparam;
995 bool set_fwcmd_inprogress;
996 u8 current_fwcmd_io;
997
998 /**/
999 bool driver_going2unload;
1000
1001 /*AMPDU init min space*/
1002 u8 minspace_cfg; /*For Min spacing configurations */
1003
1004 /* Dual mac */
1005 enum macphy_mode macphymode;
1006 enum band_type current_bandtype; /* 0:2.4G, 1:5G */
1007 enum band_type current_bandtypebackup;
1008 enum band_type bandset;
1009 /* dual MAC 0--Mac0 1--Mac1 */
1010 u32 interfaceindex;
1011 /* just for DualMac S3S4 */
1012 u8 macphyctl_reg;
1013 bool earlymode_enable;
1014 /* Dual mac*/
1015 bool during_mac0init_radiob;
1016 bool during_mac1init_radioa;
1017 bool reloadtxpowerindex;
1018 /* True if IMR or IQK have done
1019 for 2.4G in scan progress */
1020 bool load_imrandiqk_setting_for2g;
1021
1022 bool disable_amsdu_8k;
866}; 1023};
867 1024
868struct rtl_security { 1025struct rtl_security {
@@ -887,48 +1044,61 @@ struct rtl_security {
887}; 1044};
888 1045
889struct rtl_dm { 1046struct rtl_dm {
890 /*PHY status for DM */ 1047 /*PHY status for Dynamic Management */
891 long entry_min_undecoratedsmoothed_pwdb; 1048 long entry_min_undecoratedsmoothed_pwdb;
892 long undecorated_smoothed_pwdb; /*out dm */ 1049 long undecorated_smoothed_pwdb; /*out dm */
893 long entry_max_undecoratedsmoothed_pwdb; 1050 long entry_max_undecoratedsmoothed_pwdb;
894 bool b_dm_initialgain_enable; 1051 bool dm_initialgain_enable;
895 bool bdynamic_txpower_enable; 1052 bool dynamic_txpower_enable;
896 bool bcurrent_turbo_edca; 1053 bool current_turbo_edca;
897 bool bis_any_nonbepkts; /*out dm */ 1054 bool is_any_nonbepkts; /*out dm */
898 bool bis_cur_rdlstate; 1055 bool is_cur_rdlstate;
899 bool btxpower_trackingInit; 1056 bool txpower_trackingInit;
900 bool b_disable_framebursting; 1057 bool disable_framebursting;
901 bool b_cck_inch14; 1058 bool cck_inch14;
902 bool btxpower_tracking; 1059 bool txpower_tracking;
903 bool b_useramask; 1060 bool useramask;
904 bool brfpath_rxenable[4]; 1061 bool rfpath_rxenable[4];
905 1062 bool inform_fw_driverctrldm;
1063 bool current_mrc_switch;
1064 u8 txpowercount;
1065
1066 u8 thermalvalue_rxgain;
906 u8 thermalvalue_iqk; 1067 u8 thermalvalue_iqk;
907 u8 thermalvalue_lck; 1068 u8 thermalvalue_lck;
908 u8 thermalvalue; 1069 u8 thermalvalue;
909 u8 last_dtp_lvl; 1070 u8 last_dtp_lvl;
1071 u8 thermalvalue_avg[AVG_THERMAL_NUM];
1072 u8 thermalvalue_avg_index;
1073 bool done_txpower;
910 u8 dynamic_txhighpower_lvl; /*Tx high power level */ 1074 u8 dynamic_txhighpower_lvl; /*Tx high power level */
911 u8 dm_flag; /*Indicate if each dynamic mechanism's status. */ 1075 u8 dm_flag; /*Indicate each dynamic mechanism's status. */
912 u8 dm_type; 1076 u8 dm_type;
913 u8 txpower_track_control; 1077 u8 txpower_track_control;
914 1078 bool interrupt_migration;
1079 bool disable_tx_int;
915 char ofdm_index[2]; 1080 char ofdm_index[2];
916 char cck_index; 1081 char cck_index;
1082 u8 power_index_backup[6];
917}; 1083};
918 1084
919#define EFUSE_MAX_LOGICAL_SIZE 128 1085#define EFUSE_MAX_LOGICAL_SIZE 256
920 1086
921struct rtl_efuse { 1087struct rtl_efuse {
922 bool bautoLoad_ok; 1088 bool autoLoad_ok;
923 bool bootfromefuse; 1089 bool bootfromefuse;
924 u16 max_physical_size; 1090 u16 max_physical_size;
925 u8 contents[EFUSE_MAX_LOGICAL_SIZE];
926 1091
927 u8 efuse_map[2][EFUSE_MAX_LOGICAL_SIZE]; 1092 u8 efuse_map[2][EFUSE_MAX_LOGICAL_SIZE];
928 u16 efuse_usedbytes; 1093 u16 efuse_usedbytes;
929 u8 efuse_usedpercentage; 1094 u8 efuse_usedpercentage;
1095#ifdef EFUSE_REPG_WORKAROUND
1096 bool efuse_re_pg_sec1flag;
1097 u8 efuse_re_pg_data[8];
1098#endif
930 1099
931 u8 autoload_failflag; 1100 u8 autoload_failflag;
1101 u8 autoload_status;
932 1102
933 short epromtype; 1103 short epromtype;
934 u16 eeprom_vid; 1104 u16 eeprom_vid;
@@ -938,69 +1108,90 @@ struct rtl_efuse {
938 u8 eeprom_oemid; 1108 u8 eeprom_oemid;
939 u16 eeprom_channelplan; 1109 u16 eeprom_channelplan;
940 u8 eeprom_version; 1110 u8 eeprom_version;
1111 u8 board_type;
1112 u8 external_pa;
941 1113
942 u8 dev_addr[6]; 1114 u8 dev_addr[6];
943 1115
944 bool b_txpwr_fromeprom; 1116 bool txpwr_fromeprom;
1117 u8 eeprom_crystalcap;
945 u8 eeprom_tssi[2]; 1118 u8 eeprom_tssi[2];
946 u8 eeprom_pwrlimit_ht20[3]; 1119 u8 eeprom_tssi_5g[3][2]; /* for 5GL/5GM/5GH band. */
947 u8 eeprom_pwrlimit_ht40[3]; 1120 u8 eeprom_pwrlimit_ht20[CHANNEL_GROUP_MAX];
948 u8 eeprom_chnlarea_txpwr_cck[2][3]; 1121 u8 eeprom_pwrlimit_ht40[CHANNEL_GROUP_MAX];
949 u8 eeprom_chnlarea_txpwr_ht40_1s[2][3]; 1122 u8 eeprom_chnlarea_txpwr_cck[2][CHANNEL_GROUP_MAX_2G];
950 u8 eeprom_chnlarea_txpwr_ht40_2sdiif[2][3]; 1123 u8 eeprom_chnlarea_txpwr_ht40_1s[2][CHANNEL_GROUP_MAX];
951 u8 txpwrlevel_cck[2][14]; 1124 u8 eeprom_chnlarea_txpwr_ht40_2sdiif[2][CHANNEL_GROUP_MAX];
952 u8 txpwrlevel_ht40_1s[2][14]; /*For HT 40MHZ pwr */ 1125 u8 txpwrlevel_cck[2][CHANNEL_MAX_NUMBER_2G];
953 u8 txpwrlevel_ht40_2s[2][14]; /*For HT 40MHZ pwr */ 1126 u8 txpwrlevel_ht40_1s[2][CHANNEL_MAX_NUMBER]; /*For HT 40MHZ pwr */
1127 u8 txpwrlevel_ht40_2s[2][CHANNEL_MAX_NUMBER]; /*For HT 40MHZ pwr */
1128
1129 u8 internal_pa_5g[2]; /* pathA / pathB */
1130 u8 eeprom_c9;
1131 u8 eeprom_cc;
954 1132
955 /*For power group */ 1133 /*For power group */
956 u8 pwrgroup_ht20[2][14]; 1134 u8 eeprom_pwrgroup[2][3];
957 u8 pwrgroup_ht40[2][14]; 1135 u8 pwrgroup_ht20[2][CHANNEL_MAX_NUMBER];
958 1136 u8 pwrgroup_ht40[2][CHANNEL_MAX_NUMBER];
959 char txpwr_ht20diff[2][14]; /*HT 20<->40 Pwr diff */ 1137
960 u8 txpwr_legacyhtdiff[2][14]; /*For HT<->legacy pwr diff */ 1138 char txpwr_ht20diff[2][CHANNEL_MAX_NUMBER]; /*HT 20<->40 Pwr diff */
1139 /*For HT<->legacy pwr diff*/
1140 u8 txpwr_legacyhtdiff[2][CHANNEL_MAX_NUMBER];
1141 u8 txpwr_safetyflag; /* Band edge enable flag */
1142 u16 eeprom_txpowerdiff;
1143 u8 legacy_httxpowerdiff; /* Legacy to HT rate power diff */
1144 u8 antenna_txpwdiff[3];
961 1145
962 u8 eeprom_regulatory; 1146 u8 eeprom_regulatory;
963 u8 eeprom_thermalmeter; 1147 u8 eeprom_thermalmeter;
964 /*ThermalMeter, index 0 for RFIC0, and 1 for RFIC1 */ 1148 u8 thermalmeter[2]; /*ThermalMeter, index 0 for RFIC0, 1 for RFIC1 */
965 u8 thermalmeter[2]; 1149 u16 tssi_13dbm;
1150 u8 crystalcap; /* CrystalCap. */
1151 u8 delta_iqk;
1152 u8 delta_lck;
966 1153
967 u8 legacy_ht_txpowerdiff; /*Legacy to HT rate power diff */ 1154 u8 legacy_ht_txpowerdiff; /*Legacy to HT rate power diff */
968 bool b_apk_thermalmeterignore; 1155 bool apk_thermalmeterignore;
1156
1157 bool b1x1_recvcombine;
1158 bool b1ss_support;
1159
1160 /*channel plan */
1161 u8 channel_plan;
969}; 1162};
970 1163
971struct rtl_ps_ctl { 1164struct rtl_ps_ctl {
1165 bool pwrdomain_protect;
972 bool set_rfpowerstate_inprogress; 1166 bool set_rfpowerstate_inprogress;
973 bool b_in_powersavemode; 1167 bool in_powersavemode;
974 bool rfchange_inprogress; 1168 bool rfchange_inprogress;
975 bool b_swrf_processing; 1169 bool swrf_processing;
976 bool b_hwradiooff; 1170 bool hwradiooff;
977
978 u32 last_sleep_jiffies;
979 u32 last_awake_jiffies;
980 u32 last_delaylps_stamp_jiffies;
981 1171
982 /* 1172 /*
983 * just for PCIE ASPM 1173 * just for PCIE ASPM
984 * If it supports ASPM, Offset[560h] = 0x40, 1174 * If it supports ASPM, Offset[560h] = 0x40,
985 * otherwise Offset[560h] = 0x00. 1175 * otherwise Offset[560h] = 0x00.
986 * */ 1176 * */
987 bool b_support_aspm; 1177 bool support_aspm;
988 bool b_support_backdoor; 1178 bool support_backdoor;
989 1179
990 /*for LPS */ 1180 /*for LPS */
991 enum rt_psmode dot11_psmode; /*Power save mode configured. */ 1181 enum rt_psmode dot11_psmode; /*Power save mode configured. */
992 bool b_leisure_ps; 1182 bool swctrl_lps;
993 bool b_fwctrl_lps; 1183 bool leisure_ps;
1184 bool fwctrl_lps;
994 u8 fwctrl_psmode; 1185 u8 fwctrl_psmode;
995 /*For Fw control LPS mode */ 1186 /*For Fw control LPS mode */
996 u8 b_reg_fwctrl_lps; 1187 u8 reg_fwctrl_lps;
997 /*Record Fw PS mode status. */ 1188 /*Record Fw PS mode status. */
998 bool b_fw_current_inpsmode; 1189 bool fw_current_inpsmode;
999 u8 reg_max_lps_awakeintvl; 1190 u8 reg_max_lps_awakeintvl;
1000 bool report_linked; 1191 bool report_linked;
1001 1192
1002 /*for IPS */ 1193 /*for IPS */
1003 bool b_inactiveps; 1194 bool inactiveps;
1004 1195
1005 u32 rfoff_reason; 1196 u32 rfoff_reason;
1006 1197
@@ -1011,8 +1202,26 @@ struct rtl_ps_ctl {
1011 /*just for PCIE ASPM */ 1202 /*just for PCIE ASPM */
1012 u8 const_amdpci_aspm; 1203 u8 const_amdpci_aspm;
1013 1204
1205 bool pwrdown_mode;
1206
1014 enum rf_pwrstate inactive_pwrstate; 1207 enum rf_pwrstate inactive_pwrstate;
1015 enum rf_pwrstate rfpwr_state; /*cur power state */ 1208 enum rf_pwrstate rfpwr_state; /*cur power state */
1209
1210 /* for SW LPS*/
1211 bool sw_ps_enabled;
1212 bool state;
1213 bool state_inap;
1214 bool multi_buffered;
1215 u16 nullfunc_seq;
1216 unsigned int dtim_counter;
1217 unsigned int sleep_ms;
1218 unsigned long last_sleep_jiffies;
1219 unsigned long last_awake_jiffies;
1220 unsigned long last_delaylps_stamp_jiffies;
1221 unsigned long last_dtim;
1222 unsigned long last_beacon;
1223 unsigned long last_action;
1224 unsigned long last_slept;
1016}; 1225};
1017 1226
1018struct rtl_stats { 1227struct rtl_stats {
@@ -1038,10 +1247,10 @@ struct rtl_stats {
1038 s32 recvsignalpower; 1247 s32 recvsignalpower;
1039 s8 rxpower; /*in dBm Translate from PWdB */ 1248 s8 rxpower; /*in dBm Translate from PWdB */
1040 u8 signalstrength; /*in 0-100 index. */ 1249 u8 signalstrength; /*in 0-100 index. */
1041 u16 b_hwerror:1; 1250 u16 hwerror:1;
1042 u16 b_crc:1; 1251 u16 crc:1;
1043 u16 b_icv:1; 1252 u16 icv:1;
1044 u16 b_shortpreamble:1; 1253 u16 shortpreamble:1;
1045 u16 antenna:1; 1254 u16 antenna:1;
1046 u16 decrypted:1; 1255 u16 decrypted:1;
1047 u16 wakeup:1; 1256 u16 wakeup:1;
@@ -1050,15 +1259,16 @@ struct rtl_stats {
1050 1259
1051 u8 rx_drvinfo_size; 1260 u8 rx_drvinfo_size;
1052 u8 rx_bufshift; 1261 u8 rx_bufshift;
1053 bool b_isampdu; 1262 bool isampdu;
1263 bool isfirst_ampdu;
1054 bool rx_is40Mhzpacket; 1264 bool rx_is40Mhzpacket;
1055 u32 rx_pwdb_all; 1265 u32 rx_pwdb_all;
1056 u8 rx_mimo_signalstrength[4]; /*in 0~100 index */ 1266 u8 rx_mimo_signalstrength[4]; /*in 0~100 index */
1057 s8 rx_mimo_signalquality[2]; 1267 s8 rx_mimo_signalquality[2];
1058 bool b_packet_matchbssid; 1268 bool packet_matchbssid;
1059 bool b_is_cck; 1269 bool is_cck;
1060 bool b_packet_toself; 1270 bool packet_toself;
1061 bool b_packet_beacon; /*for rssi */ 1271 bool packet_beacon; /*for rssi */
1062 char cck_adc_pwdb[4]; /*for rx path selection */ 1272 char cck_adc_pwdb[4]; /*for rx path selection */
1063}; 1273};
1064 1274
@@ -1069,23 +1279,23 @@ struct rt_link_detect {
1069 u32 num_tx_inperiod; 1279 u32 num_tx_inperiod;
1070 u32 num_rx_inperiod; 1280 u32 num_rx_inperiod;
1071 1281
1072 bool b_busytraffic; 1282 bool busytraffic;
1073 bool b_higher_busytraffic; 1283 bool higher_busytraffic;
1074 bool b_higher_busyrxtraffic; 1284 bool higher_busyrxtraffic;
1075}; 1285};
1076 1286
1077struct rtl_tcb_desc { 1287struct rtl_tcb_desc {
1078 u8 b_packet_bw:1; 1288 u8 packet_bw:1;
1079 u8 b_multicast:1; 1289 u8 multicast:1;
1080 u8 b_broadcast:1; 1290 u8 broadcast:1;
1081 1291
1082 u8 b_rts_stbc:1; 1292 u8 rts_stbc:1;
1083 u8 b_rts_enable:1; 1293 u8 rts_enable:1;
1084 u8 b_cts_enable:1; 1294 u8 cts_enable:1;
1085 u8 b_rts_use_shortpreamble:1; 1295 u8 rts_use_shortpreamble:1;
1086 u8 b_rts_use_shortgi:1; 1296 u8 rts_use_shortgi:1;
1087 u8 rts_sc:1; 1297 u8 rts_sc:1;
1088 u8 b_rts_bw:1; 1298 u8 rts_bw:1;
1089 u8 rts_rate; 1299 u8 rts_rate;
1090 1300
1091 u8 use_shortgi:1; 1301 u8 use_shortgi:1;
@@ -1096,20 +1306,34 @@ struct rtl_tcb_desc {
1096 u8 ratr_index; 1306 u8 ratr_index;
1097 u8 mac_id; 1307 u8 mac_id;
1098 u8 hw_rate; 1308 u8 hw_rate;
1309
1310 u8 last_inipkt:1;
1311 u8 cmd_or_init:1;
1312 u8 queue_index;
1313
1314 /* early mode */
1315 u8 empkt_num;
1316 /* The max value by HW */
1317 u32 empkt_len[5];
1099}; 1318};
1100 1319
1101struct rtl_hal_ops { 1320struct rtl_hal_ops {
1102 int (*init_sw_vars) (struct ieee80211_hw *hw); 1321 int (*init_sw_vars) (struct ieee80211_hw *hw);
1103 void (*deinit_sw_vars) (struct ieee80211_hw *hw); 1322 void (*deinit_sw_vars) (struct ieee80211_hw *hw);
1323 void (*read_chip_version)(struct ieee80211_hw *hw);
1104 void (*read_eeprom_info) (struct ieee80211_hw *hw); 1324 void (*read_eeprom_info) (struct ieee80211_hw *hw);
1105 void (*interrupt_recognized) (struct ieee80211_hw *hw, 1325 void (*interrupt_recognized) (struct ieee80211_hw *hw,
1106 u32 *p_inta, u32 *p_intb); 1326 u32 *p_inta, u32 *p_intb);
1107 int (*hw_init) (struct ieee80211_hw *hw); 1327 int (*hw_init) (struct ieee80211_hw *hw);
1108 void (*hw_disable) (struct ieee80211_hw *hw); 1328 void (*hw_disable) (struct ieee80211_hw *hw);
1329 void (*hw_suspend) (struct ieee80211_hw *hw);
1330 void (*hw_resume) (struct ieee80211_hw *hw);
1109 void (*enable_interrupt) (struct ieee80211_hw *hw); 1331 void (*enable_interrupt) (struct ieee80211_hw *hw);
1110 void (*disable_interrupt) (struct ieee80211_hw *hw); 1332 void (*disable_interrupt) (struct ieee80211_hw *hw);
1111 int (*set_network_type) (struct ieee80211_hw *hw, 1333 int (*set_network_type) (struct ieee80211_hw *hw,
1112 enum nl80211_iftype type); 1334 enum nl80211_iftype type);
1335 void (*set_chk_bssid)(struct ieee80211_hw *hw,
1336 bool check_bssid);
1113 void (*set_bw_mode) (struct ieee80211_hw *hw, 1337 void (*set_bw_mode) (struct ieee80211_hw *hw,
1114 enum nl80211_channel_type ch_type); 1338 enum nl80211_channel_type ch_type);
1115 u8(*switch_channel) (struct ieee80211_hw *hw); 1339 u8(*switch_channel) (struct ieee80211_hw *hw);
@@ -1126,23 +1350,26 @@ struct rtl_hal_ops {
1126 struct ieee80211_hdr *hdr, u8 *pdesc_tx, 1350 struct ieee80211_hdr *hdr, u8 *pdesc_tx,
1127 struct ieee80211_tx_info *info, 1351 struct ieee80211_tx_info *info,
1128 struct sk_buff *skb, unsigned int queue_index); 1352 struct sk_buff *skb, unsigned int queue_index);
1353 void (*fill_fake_txdesc) (struct ieee80211_hw *hw, u8 * pDesc,
1354 u32 buffer_len, bool bIsPsPoll);
1129 void (*fill_tx_cmddesc) (struct ieee80211_hw *hw, u8 *pdesc, 1355 void (*fill_tx_cmddesc) (struct ieee80211_hw *hw, u8 *pdesc,
1130 bool b_firstseg, bool b_lastseg, 1356 bool firstseg, bool lastseg,
1131 struct sk_buff *skb); 1357 struct sk_buff *skb);
1132 bool(*query_rx_desc) (struct ieee80211_hw *hw, 1358 bool (*cmd_send_packet)(struct ieee80211_hw *hw, struct sk_buff *skb);
1359 bool (*query_rx_desc) (struct ieee80211_hw *hw,
1133 struct rtl_stats *stats, 1360 struct rtl_stats *stats,
1134 struct ieee80211_rx_status *rx_status, 1361 struct ieee80211_rx_status *rx_status,
1135 u8 *pdesc, struct sk_buff *skb); 1362 u8 *pdesc, struct sk_buff *skb);
1136 void (*set_channel_access) (struct ieee80211_hw *hw); 1363 void (*set_channel_access) (struct ieee80211_hw *hw);
1137 bool(*radio_onoff_checking) (struct ieee80211_hw *hw, u8 *valid); 1364 bool (*radio_onoff_checking) (struct ieee80211_hw *hw, u8 *valid);
1138 void (*dm_watchdog) (struct ieee80211_hw *hw); 1365 void (*dm_watchdog) (struct ieee80211_hw *hw);
1139 void (*scan_operation_backup) (struct ieee80211_hw *hw, u8 operation); 1366 void (*scan_operation_backup) (struct ieee80211_hw *hw, u8 operation);
1140 bool(*set_rf_power_state) (struct ieee80211_hw *hw, 1367 bool (*set_rf_power_state) (struct ieee80211_hw *hw,
1141 enum rf_pwrstate rfpwr_state); 1368 enum rf_pwrstate rfpwr_state);
1142 void (*led_control) (struct ieee80211_hw *hw, 1369 void (*led_control) (struct ieee80211_hw *hw,
1143 enum led_ctl_mode ledaction); 1370 enum led_ctl_mode ledaction);
1144 void (*set_desc) (u8 *pdesc, bool istx, u8 desc_name, u8 *val); 1371 void (*set_desc) (u8 *pdesc, bool istx, u8 desc_name, u8 *val);
1145 u32(*get_desc) (u8 *pdesc, bool istx, u8 desc_name); 1372 u32 (*get_desc) (u8 *pdesc, bool istx, u8 desc_name);
1146 void (*tx_polling) (struct ieee80211_hw *hw, unsigned int hw_queue); 1373 void (*tx_polling) (struct ieee80211_hw *hw, unsigned int hw_queue);
1147 void (*enable_hw_sec) (struct ieee80211_hw *hw); 1374 void (*enable_hw_sec) (struct ieee80211_hw *hw);
1148 void (*set_key) (struct ieee80211_hw *hw, u32 key_index, 1375 void (*set_key) (struct ieee80211_hw *hw, u32 key_index,
@@ -1150,22 +1377,36 @@ struct rtl_hal_ops {
1150 bool is_wepkey, bool clear_all); 1377 bool is_wepkey, bool clear_all);
1151 void (*init_sw_leds) (struct ieee80211_hw *hw); 1378 void (*init_sw_leds) (struct ieee80211_hw *hw);
1152 void (*deinit_sw_leds) (struct ieee80211_hw *hw); 1379 void (*deinit_sw_leds) (struct ieee80211_hw *hw);
1153 u32(*get_bbreg) (struct ieee80211_hw *hw, u32 regaddr, u32 bitmask); 1380 u32 (*get_bbreg) (struct ieee80211_hw *hw, u32 regaddr, u32 bitmask);
1154 void (*set_bbreg) (struct ieee80211_hw *hw, u32 regaddr, u32 bitmask, 1381 void (*set_bbreg) (struct ieee80211_hw *hw, u32 regaddr, u32 bitmask,
1155 u32 data); 1382 u32 data);
1156 u32(*get_rfreg) (struct ieee80211_hw *hw, enum radio_path rfpath, 1383 u32 (*get_rfreg) (struct ieee80211_hw *hw, enum radio_path rfpath,
1157 u32 regaddr, u32 bitmask); 1384 u32 regaddr, u32 bitmask);
1158 void (*set_rfreg) (struct ieee80211_hw *hw, enum radio_path rfpath, 1385 void (*set_rfreg) (struct ieee80211_hw *hw, enum radio_path rfpath,
1159 u32 regaddr, u32 bitmask, u32 data); 1386 u32 regaddr, u32 bitmask, u32 data);
1387 bool (*phy_rf6052_config) (struct ieee80211_hw *hw);
1388 void (*phy_rf6052_set_cck_txpower) (struct ieee80211_hw *hw,
1389 u8 *powerlevel);
1390 void (*phy_rf6052_set_ofdm_txpower) (struct ieee80211_hw *hw,
1391 u8 *ppowerlevel, u8 channel);
1392 bool (*config_bb_with_headerfile) (struct ieee80211_hw *hw,
1393 u8 configtype);
1394 bool (*config_bb_with_pgheaderfile) (struct ieee80211_hw *hw,
1395 u8 configtype);
1396 void (*phy_lc_calibrate) (struct ieee80211_hw *hw, bool is2t);
1397 void (*phy_set_bw_mode_callback) (struct ieee80211_hw *hw);
1398 void (*dm_dynamic_txpower) (struct ieee80211_hw *hw);
1160}; 1399};
1161 1400
1162struct rtl_intf_ops { 1401struct rtl_intf_ops {
1163 /*com */ 1402 /*com */
1403 void (*read_efuse_byte)(struct ieee80211_hw *hw, u16 _offset, u8 *pbuf);
1164 int (*adapter_start) (struct ieee80211_hw *hw); 1404 int (*adapter_start) (struct ieee80211_hw *hw);
1165 void (*adapter_stop) (struct ieee80211_hw *hw); 1405 void (*adapter_stop) (struct ieee80211_hw *hw);
1166 1406
1167 int (*adapter_tx) (struct ieee80211_hw *hw, struct sk_buff *skb); 1407 int (*adapter_tx) (struct ieee80211_hw *hw, struct sk_buff *skb);
1168 int (*reset_trx_ring) (struct ieee80211_hw *hw); 1408 int (*reset_trx_ring) (struct ieee80211_hw *hw);
1409 bool (*waitq_insert) (struct ieee80211_hw *hw, struct sk_buff *skb);
1169 1410
1170 /*pci */ 1411 /*pci */
1171 void (*disable_aspm) (struct ieee80211_hw *hw); 1412 void (*disable_aspm) (struct ieee80211_hw *hw);
@@ -1179,11 +1420,36 @@ struct rtl_mod_params {
1179 int sw_crypto; 1420 int sw_crypto;
1180}; 1421};
1181 1422
1423struct rtl_hal_usbint_cfg {
1424 /* data - rx */
1425 u32 in_ep_num;
1426 u32 rx_urb_num;
1427 u32 rx_max_size;
1428
1429 /* op - rx */
1430 void (*usb_rx_hdl)(struct ieee80211_hw *, struct sk_buff *);
1431 void (*usb_rx_segregate_hdl)(struct ieee80211_hw *, struct sk_buff *,
1432 struct sk_buff_head *);
1433
1434 /* tx */
1435 void (*usb_tx_cleanup)(struct ieee80211_hw *, struct sk_buff *);
1436 int (*usb_tx_post_hdl)(struct ieee80211_hw *, struct urb *,
1437 struct sk_buff *);
1438 struct sk_buff *(*usb_tx_aggregate_hdl)(struct ieee80211_hw *,
1439 struct sk_buff_head *);
1440
1441 /* endpoint mapping */
1442 int (*usb_endpoint_mapping)(struct ieee80211_hw *hw);
1443 u16 (*usb_mq_to_hwq)(__le16 fc, u16 mac80211_queue_index);
1444};
1445
1182struct rtl_hal_cfg { 1446struct rtl_hal_cfg {
1447 u8 bar_id;
1183 char *name; 1448 char *name;
1184 char *fw_name; 1449 char *fw_name;
1185 struct rtl_hal_ops *ops; 1450 struct rtl_hal_ops *ops;
1186 struct rtl_mod_params *mod_params; 1451 struct rtl_mod_params *mod_params;
1452 struct rtl_hal_usbint_cfg *usb_interface_cfg;
1187 1453
1188 /*this map used for some registers or vars 1454 /*this map used for some registers or vars
1189 defined int HAL but used in MAIN */ 1455 defined int HAL but used in MAIN */
@@ -1202,6 +1468,11 @@ struct rtl_locks {
1202 spinlock_t rf_ps_lock; 1468 spinlock_t rf_ps_lock;
1203 spinlock_t rf_lock; 1469 spinlock_t rf_lock;
1204 spinlock_t lps_lock; 1470 spinlock_t lps_lock;
1471 spinlock_t waitq_lock;
1472 spinlock_t tx_urb_lock;
1473
1474 /*Dual mac*/
1475 spinlock_t cck_and_rw_pagea_lock;
1205}; 1476};
1206 1477
1207struct rtl_works { 1478struct rtl_works {
@@ -1218,12 +1489,20 @@ struct rtl_works {
1218 struct workqueue_struct *rtl_wq; 1489 struct workqueue_struct *rtl_wq;
1219 struct delayed_work watchdog_wq; 1490 struct delayed_work watchdog_wq;
1220 struct delayed_work ips_nic_off_wq; 1491 struct delayed_work ips_nic_off_wq;
1492
1493 /* For SW LPS */
1494 struct delayed_work ps_work;
1495 struct delayed_work ps_rfon_wq;
1221}; 1496};
1222 1497
1223struct rtl_debug { 1498struct rtl_debug {
1224 u32 dbgp_type[DBGP_TYPE_MAX]; 1499 u32 dbgp_type[DBGP_TYPE_MAX];
1225 u32 global_debuglevel; 1500 u32 global_debuglevel;
1226 u64 global_debugcomponents; 1501 u64 global_debugcomponents;
1502
1503 /* add for proc debug */
1504 struct proc_dir_entry *proc_dir;
1505 char proc_name[20];
1227}; 1506};
1228 1507
1229struct rtl_priv { 1508struct rtl_priv {
@@ -1274,6 +1553,91 @@ struct rtl_priv {
1274#define rtl_efuse(rtlpriv) (&((rtlpriv)->efuse)) 1553#define rtl_efuse(rtlpriv) (&((rtlpriv)->efuse))
1275#define rtl_psc(rtlpriv) (&((rtlpriv)->psc)) 1554#define rtl_psc(rtlpriv) (&((rtlpriv)->psc))
1276 1555
1556
1557/***************************************
1558 Bluetooth Co-existance Related
1559****************************************/
1560
1561enum bt_ant_num {
1562 ANT_X2 = 0,
1563 ANT_X1 = 1,
1564};
1565
1566enum bt_co_type {
1567 BT_2WIRE = 0,
1568 BT_ISSC_3WIRE = 1,
1569 BT_ACCEL = 2,
1570 BT_CSR_BC4 = 3,
1571 BT_CSR_BC8 = 4,
1572 BT_RTL8756 = 5,
1573};
1574
1575enum bt_cur_state {
1576 BT_OFF = 0,
1577 BT_ON = 1,
1578};
1579
1580enum bt_service_type {
1581 BT_SCO = 0,
1582 BT_A2DP = 1,
1583 BT_HID = 2,
1584 BT_HID_IDLE = 3,
1585 BT_SCAN = 4,
1586 BT_IDLE = 5,
1587 BT_OTHER_ACTION = 6,
1588 BT_BUSY = 7,
1589 BT_OTHERBUSY = 8,
1590 BT_PAN = 9,
1591};
1592
1593enum bt_radio_shared {
1594 BT_RADIO_SHARED = 0,
1595 BT_RADIO_INDIVIDUAL = 1,
1596};
1597
1598struct bt_coexist_info {
1599
1600 /* EEPROM BT info. */
1601 u8 eeprom_bt_coexist;
1602 u8 eeprom_bt_type;
1603 u8 eeprom_bt_ant_num;
1604 u8 eeprom_bt_ant_isolation;
1605 u8 eeprom_bt_radio_shared;
1606
1607 u8 bt_coexistence;
1608 u8 bt_ant_num;
1609 u8 bt_coexist_type;
1610 u8 bt_state;
1611 u8 bt_cur_state; /* 0:on, 1:off */
1612 u8 bt_ant_isolation; /* 0:good, 1:bad */
1613 u8 bt_pape_ctrl; /* 0:SW, 1:SW/HW dynamic */
1614 u8 bt_service;
1615 u8 bt_radio_shared_type;
1616 u8 bt_rfreg_origin_1e;
1617 u8 bt_rfreg_origin_1f;
1618 u8 bt_rssi_state;
1619 u32 ratio_tx;
1620 u32 ratio_pri;
1621 u32 bt_edca_ul;
1622 u32 bt_edca_dl;
1623
1624 bool b_init_set;
1625 bool b_bt_busy_traffic;
1626 bool b_bt_traffic_mode_set;
1627 bool b_bt_non_traffic_mode_set;
1628
1629 bool b_fw_coexist_all_off;
1630 bool b_sw_coexist_all_off;
1631 u32 current_state;
1632 u32 previous_state;
1633 u8 bt_pre_rssi_state;
1634
1635 u8 b_reg_bt_iso;
1636 u8 b_reg_bt_sco;
1637
1638};
1639
1640
1277/**************************************** 1641/****************************************
1278 mem access macro define start 1642 mem access macro define start
1279 Call endian free function when 1643 Call endian free function when
@@ -1281,7 +1645,7 @@ struct rtl_priv {
1281 2. Before write integer to IO. 1645 2. Before write integer to IO.
1282 3. After read integer from IO. 1646 3. After read integer from IO.
1283****************************************/ 1647****************************************/
1284/* Convert little data endian to host */ 1648/* Convert little data endian to host ordering */
1285#define EF1BYTE(_val) \ 1649#define EF1BYTE(_val) \
1286 ((u8)(_val)) 1650 ((u8)(_val))
1287#define EF2BYTE(_val) \ 1651#define EF2BYTE(_val) \
@@ -1289,27 +1653,21 @@ struct rtl_priv {
1289#define EF4BYTE(_val) \ 1653#define EF4BYTE(_val) \
1290 (le32_to_cpu(_val)) 1654 (le32_to_cpu(_val))
1291 1655
1292/* Read data from memory */ 1656/* Read le16 data from memory and convert to host ordering */
1293#define READEF1BYTE(_ptr) \
1294 EF1BYTE(*((u8 *)(_ptr)))
1295#define READEF2BYTE(_ptr) \ 1657#define READEF2BYTE(_ptr) \
1296 EF2BYTE(*((u16 *)(_ptr))) 1658 EF2BYTE(*((u16 *)(_ptr)))
1297#define READEF4BYTE(_ptr) \
1298 EF4BYTE(*((u32 *)(_ptr)))
1299 1659
1300/* Write data to memory */ 1660/* Write le16 data to memory in host ordering */
1301#define WRITEEF1BYTE(_ptr, _val) \
1302 (*((u8 *)(_ptr))) = EF1BYTE(_val)
1303#define WRITEEF2BYTE(_ptr, _val) \ 1661#define WRITEEF2BYTE(_ptr, _val) \
1304 (*((u16 *)(_ptr))) = EF2BYTE(_val) 1662 (*((u16 *)(_ptr))) = EF2BYTE(_val)
1305#define WRITEEF4BYTE(_ptr, _val) \ 1663
1306 (*((u32 *)(_ptr))) = EF4BYTE(_val) 1664/* Create a bit mask
1307 1665 * Examples:
1308/*Example: 1666 * BIT_LEN_MASK_32(0) => 0x00000000
1309BIT_LEN_MASK_32(0) => 0x00000000 1667 * BIT_LEN_MASK_32(1) => 0x00000001
1310BIT_LEN_MASK_32(1) => 0x00000001 1668 * BIT_LEN_MASK_32(2) => 0x00000003
1311BIT_LEN_MASK_32(2) => 0x00000003 1669 * BIT_LEN_MASK_32(32) => 0xFFFFFFFF
1312BIT_LEN_MASK_32(32) => 0xFFFFFFFF*/ 1670 */
1313#define BIT_LEN_MASK_32(__bitlen) \ 1671#define BIT_LEN_MASK_32(__bitlen) \
1314 (0xFFFFFFFF >> (32 - (__bitlen))) 1672 (0xFFFFFFFF >> (32 - (__bitlen)))
1315#define BIT_LEN_MASK_16(__bitlen) \ 1673#define BIT_LEN_MASK_16(__bitlen) \
@@ -1317,9 +1675,11 @@ BIT_LEN_MASK_32(32) => 0xFFFFFFFF*/
1317#define BIT_LEN_MASK_8(__bitlen) \ 1675#define BIT_LEN_MASK_8(__bitlen) \
1318 (0xFF >> (8 - (__bitlen))) 1676 (0xFF >> (8 - (__bitlen)))
1319 1677
1320/*Example: 1678/* Create an offset bit mask
1321BIT_OFFSET_LEN_MASK_32(0, 2) => 0x00000003 1679 * Examples:
1322BIT_OFFSET_LEN_MASK_32(16, 2) => 0x00030000*/ 1680 * BIT_OFFSET_LEN_MASK_32(0, 2) => 0x00000003
1681 * BIT_OFFSET_LEN_MASK_32(16, 2) => 0x00030000
1682 */
1323#define BIT_OFFSET_LEN_MASK_32(__bitoffset, __bitlen) \ 1683#define BIT_OFFSET_LEN_MASK_32(__bitoffset, __bitlen) \
1324 (BIT_LEN_MASK_32(__bitlen) << (__bitoffset)) 1684 (BIT_LEN_MASK_32(__bitlen) << (__bitoffset))
1325#define BIT_OFFSET_LEN_MASK_16(__bitoffset, __bitlen) \ 1685#define BIT_OFFSET_LEN_MASK_16(__bitoffset, __bitlen) \
@@ -1328,8 +1688,9 @@ BIT_OFFSET_LEN_MASK_32(16, 2) => 0x00030000*/
1328 (BIT_LEN_MASK_8(__bitlen) << (__bitoffset)) 1688 (BIT_LEN_MASK_8(__bitlen) << (__bitoffset))
1329 1689
1330/*Description: 1690/*Description:
1331Return 4-byte value in host byte ordering from 1691 * Return 4-byte value in host byte ordering from
13324-byte pointer in little-endian system.*/ 1692 * 4-byte pointer in little-endian system.
1693 */
1333#define LE_P4BYTE_TO_HOST_4BYTE(__pstart) \ 1694#define LE_P4BYTE_TO_HOST_4BYTE(__pstart) \
1334 (EF4BYTE(*((u32 *)(__pstart)))) 1695 (EF4BYTE(*((u32 *)(__pstart))))
1335#define LE_P2BYTE_TO_HOST_2BYTE(__pstart) \ 1696#define LE_P2BYTE_TO_HOST_2BYTE(__pstart) \
@@ -1337,28 +1698,10 @@ Return 4-byte value in host byte ordering from
1337#define LE_P1BYTE_TO_HOST_1BYTE(__pstart) \ 1698#define LE_P1BYTE_TO_HOST_1BYTE(__pstart) \
1338 (EF1BYTE(*((u8 *)(__pstart)))) 1699 (EF1BYTE(*((u8 *)(__pstart))))
1339 1700
1340/*Description: 1701/* Description:
1341Translate subfield (continuous bits in little-endian) of 4-byte 1702 * Mask subfield (continuous bits in little-endian) of 4-byte value
1342value to host byte ordering.*/ 1703 * and return the result in 4-byte value in host byte ordering.
1343#define LE_BITS_TO_4BYTE(__pstart, __bitoffset, __bitlen) \ 1704 */
1344 ( \
1345 (LE_P4BYTE_TO_HOST_4BYTE(__pstart) >> (__bitoffset)) & \
1346 BIT_LEN_MASK_32(__bitlen) \
1347 )
1348#define LE_BITS_TO_2BYTE(__pstart, __bitoffset, __bitlen) \
1349 ( \
1350 (LE_P2BYTE_TO_HOST_2BYTE(__pstart) >> (__bitoffset)) & \
1351 BIT_LEN_MASK_16(__bitlen) \
1352 )
1353#define LE_BITS_TO_1BYTE(__pstart, __bitoffset, __bitlen) \
1354 ( \
1355 (LE_P1BYTE_TO_HOST_1BYTE(__pstart) >> (__bitoffset)) & \
1356 BIT_LEN_MASK_8(__bitlen) \
1357 )
1358
1359/*Description:
1360Mask subfield (continuous bits in little-endian) of 4-byte value
1361and return the result in 4-byte value in host byte ordering.*/
1362#define LE_BITS_CLEARED_TO_4BYTE(__pstart, __bitoffset, __bitlen) \ 1705#define LE_BITS_CLEARED_TO_4BYTE(__pstart, __bitoffset, __bitlen) \
1363 ( \ 1706 ( \
1364 LE_P4BYTE_TO_HOST_4BYTE(__pstart) & \ 1707 LE_P4BYTE_TO_HOST_4BYTE(__pstart) & \
@@ -1375,20 +1718,9 @@ and return the result in 4-byte value in host byte ordering.*/
1375 (~BIT_OFFSET_LEN_MASK_8(__bitoffset, __bitlen)) \ 1718 (~BIT_OFFSET_LEN_MASK_8(__bitoffset, __bitlen)) \
1376 ) 1719 )
1377 1720
1378/*Description: 1721/* Description:
1379Set subfield of little-endian 4-byte value to specified value. */ 1722 * Set subfield of little-endian 4-byte value to specified value.
1380#define SET_BITS_TO_LE_4BYTE(__pstart, __bitoffset, __bitlen, __val) \ 1723 */
1381 *((u32 *)(__pstart)) = EF4BYTE \
1382 ( \
1383 LE_BITS_CLEARED_TO_4BYTE(__pstart, __bitoffset, __bitlen) | \
1384 ((((u32)__val) & BIT_LEN_MASK_32(__bitlen)) << (__bitoffset)) \
1385 );
1386#define SET_BITS_TO_LE_2BYTE(__pstart, __bitoffset, __bitlen, __val) \
1387 *((u16 *)(__pstart)) = EF2BYTE \
1388 ( \
1389 LE_BITS_CLEARED_TO_2BYTE(__pstart, __bitoffset, __bitlen) | \
1390 ((((u16)__val) & BIT_LEN_MASK_16(__bitlen)) << (__bitoffset)) \
1391 );
1392#define SET_BITS_TO_LE_1BYTE(__pstart, __bitoffset, __bitlen, __val) \ 1724#define SET_BITS_TO_LE_1BYTE(__pstart, __bitoffset, __bitlen, __val) \
1393 *((u8 *)(__pstart)) = EF1BYTE \ 1725 *((u8 *)(__pstart)) = EF1BYTE \
1394 ( \ 1726 ( \
@@ -1400,13 +1732,14 @@ Set subfield of little-endian 4-byte value to specified value. */
1400 mem access macro define end 1732 mem access macro define end
1401****************************************/ 1733****************************************/
1402 1734
1403#define packet_get_type(_packet) (EF1BYTE((_packet).octet[0]) & 0xFC) 1735#define byte(x, n) ((x >> (8 * n)) & 0xff)
1736
1404#define RTL_WATCH_DOG_TIME 2000 1737#define RTL_WATCH_DOG_TIME 2000
1405#define MSECS(t) msecs_to_jiffies(t) 1738#define MSECS(t) msecs_to_jiffies(t)
1406#define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS) 1739#define WLAN_FC_GET_VERS(fc) (le16_to_cpu(fc) & IEEE80211_FCTL_VERS)
1407#define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE) 1740#define WLAN_FC_GET_TYPE(fc) (le16_to_cpu(fc) & IEEE80211_FCTL_FTYPE)
1408#define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE) 1741#define WLAN_FC_GET_STYPE(fc) (le16_to_cpu(fc) & IEEE80211_FCTL_STYPE)
1409#define WLAN_FC_MORE_DATA(fc) ((fc) & IEEE80211_FCTL_MOREDATA) 1742#define WLAN_FC_MORE_DATA(fc) (le16_to_cpu(fc) & IEEE80211_FCTL_MOREDATA)
1410#define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4) 1743#define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
1411#define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ) 1744#define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ)
1412#define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4) 1745#define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4)
@@ -1420,6 +1753,8 @@ Set subfield of little-endian 4-byte value to specified value. */
1420#define RT_RF_OFF_LEVL_FW_32K BIT(5) /*FW in 32k */ 1753#define RT_RF_OFF_LEVL_FW_32K BIT(5) /*FW in 32k */
1421/*Always enable ASPM and Clock Req in initialization.*/ 1754/*Always enable ASPM and Clock Req in initialization.*/
1422#define RT_RF_PS_LEVEL_ALWAYS_ASPM BIT(6) 1755#define RT_RF_PS_LEVEL_ALWAYS_ASPM BIT(6)
1756/* no matter RFOFF or SLEEP we set PS_ASPM_LEVL*/
1757#define RT_PS_LEVEL_ASPM BIT(7)
1423/*When LPS is on, disable 2R if no packet is received or transmittd.*/ 1758/*When LPS is on, disable 2R if no packet is received or transmittd.*/
1424#define RT_RF_LPS_DISALBE_2R BIT(30) 1759#define RT_RF_LPS_DISALBE_2R BIT(30)
1425#define RT_RF_LPS_LEVEL_ASPM BIT(31) /*LPS with ASPM */ 1760#define RT_RF_LPS_LEVEL_ASPM BIT(31) /*LPS with ASPM */
@@ -1433,15 +1768,6 @@ Set subfield of little-endian 4-byte value to specified value. */
1433#define container_of_dwork_rtl(x, y, z) \ 1768#define container_of_dwork_rtl(x, y, z) \
1434 container_of(container_of(x, struct delayed_work, work), y, z) 1769 container_of(container_of(x, struct delayed_work, work), y, z)
1435 1770
1436#define FILL_OCTET_STRING(_os, _octet, _len) \
1437 (_os).octet = (u8 *)(_octet); \
1438 (_os).length = (_len);
1439
1440#define CP_MACADDR(des, src) \
1441 ((des)[0] = (src)[0], (des)[1] = (src)[1],\
1442 (des)[2] = (src)[2], (des)[3] = (src)[3],\
1443 (des)[4] = (src)[4], (des)[5] = (src)[5])
1444
1445static inline u8 rtl_read_byte(struct rtl_priv *rtlpriv, u32 addr) 1771static inline u8 rtl_read_byte(struct rtl_priv *rtlpriv, u32 addr)
1446{ 1772{
1447 return rtlpriv->io.read8_sync(rtlpriv, addr); 1773 return rtlpriv->io.read8_sync(rtlpriv, addr);