~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/net/wireless/rtlwifi/wifi.h

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
#include <linux/firmware.h>
35
35
#include <linux/version.h>
36
36
#include <linux/etherdevice.h>
 
37
#include <linux/vmalloc.h>
 
38
#include <linux/usb.h>
37
39
#include <net/mac80211.h>
38
40
#include "debug.h"
39
41
 
66
68
#define QBSS_LOAD_SIZE                          5
67
69
#define MAX_WMMELE_LENGTH                       64
68
70
 
 
71
#define TOTAL_CAM_ENTRY                         32
 
72
 
69
73
/*slot time for 11g. */
70
74
#define RTL_SLOT_TIME_9                         9
71
75
#define RTL_SLOT_TIME_20                        20
82
86
#define MAC80211_3ADDR_LEN                      24
83
87
#define MAC80211_4ADDR_LEN                      30
84
88
 
 
89
#define CHANNEL_MAX_NUMBER      (14 + 24 + 21)  /* 14 is the max channel no */
 
90
#define CHANNEL_GROUP_MAX       (3 + 9) /*  ch1~3, 4~9, 10~14 = three groups */
 
91
#define MAX_PG_GROUP                    13
 
92
#define CHANNEL_GROUP_MAX_2G            3
 
93
#define CHANNEL_GROUP_IDX_5GL           3
 
94
#define CHANNEL_GROUP_IDX_5GM           6
 
95
#define CHANNEL_GROUP_IDX_5GH           9
 
96
#define CHANNEL_GROUP_MAX_5G            9
 
97
#define CHANNEL_MAX_NUMBER_2G           14
 
98
#define AVG_THERMAL_NUM                 8
 
99
#define MAX_TID_COUNT                   9
 
100
 
 
101
/* for early mode */
 
102
#define FCS_LEN                         4
 
103
#define EM_HDR_LEN                      8
85
104
enum intf_type {
86
105
        INTF_PCI = 0,
87
106
        INTF_USB = 1,
113
132
        HARDWARE_TYPE_RTL8192CU,
114
133
        HARDWARE_TYPE_RTL8192DE,
115
134
        HARDWARE_TYPE_RTL8192DU,
 
135
        HARDWARE_TYPE_RTL8723E,
 
136
        HARDWARE_TYPE_RTL8723U,
116
137
 
117
 
        /*keep it last*/
 
138
        /* keep it last */
118
139
        HARDWARE_TYPE_NUM
119
140
};
120
141
 
 
142
#define IS_HARDWARE_TYPE_8192SU(rtlhal)                 \
 
143
        (rtlhal->hw_type == HARDWARE_TYPE_RTL8192SU)
 
144
#define IS_HARDWARE_TYPE_8192SE(rtlhal)                 \
 
145
        (rtlhal->hw_type == HARDWARE_TYPE_RTL8192SE)
 
146
#define IS_HARDWARE_TYPE_8192CE(rtlhal)                 \
 
147
        (rtlhal->hw_type == HARDWARE_TYPE_RTL8192CE)
 
148
#define IS_HARDWARE_TYPE_8192CU(rtlhal)                 \
 
149
        (rtlhal->hw_type == HARDWARE_TYPE_RTL8192CU)
 
150
#define IS_HARDWARE_TYPE_8192DE(rtlhal)                 \
 
151
        (rtlhal->hw_type == HARDWARE_TYPE_RTL8192DE)
 
152
#define IS_HARDWARE_TYPE_8192DU(rtlhal)                 \
 
153
        (rtlhal->hw_type == HARDWARE_TYPE_RTL8192DU)
 
154
#define IS_HARDWARE_TYPE_8723E(rtlhal)                  \
 
155
        (rtlhal->hw_type == HARDWARE_TYPE_RTL8723E)
 
156
#define IS_HARDWARE_TYPE_8723U(rtlhal)                  \
 
157
        (rtlhal->hw_type == HARDWARE_TYPE_RTL8723U)
 
158
#define IS_HARDWARE_TYPE_8192S(rtlhal)                  \
 
159
(IS_HARDWARE_TYPE_8192SE(rtlhal) || IS_HARDWARE_TYPE_8192SU(rtlhal))
 
160
#define IS_HARDWARE_TYPE_8192C(rtlhal)                  \
 
161
(IS_HARDWARE_TYPE_8192CE(rtlhal) || IS_HARDWARE_TYPE_8192CU(rtlhal))
 
162
#define IS_HARDWARE_TYPE_8192D(rtlhal)                  \
 
163
(IS_HARDWARE_TYPE_8192DE(rtlhal) || IS_HARDWARE_TYPE_8192DU(rtlhal))
 
164
#define IS_HARDWARE_TYPE_8723(rtlhal)                   \
 
165
(IS_HARDWARE_TYPE_8723E(rtlhal) || IS_HARDWARE_TYPE_8723U(rtlhal))
 
166
#define IS_HARDWARE_TYPE_8723U(rtlhal)                  \
 
167
        (rtlhal->hw_type == HARDWARE_TYPE_RTL8723U)
 
168
 
121
169
enum scan_operation_backup_opt {
122
170
        SCAN_OPT_BACKUP = 0,
123
171
        SCAN_OPT_RESTORE,
255
303
        HW_VAR_DATA_FILTER,
256
304
};
257
305
 
 
306
#define HWSET_MAX_SIZE                          128
 
307
#define EFUSE_MAX_SECTION                       16
 
308
 
258
309
enum _RT_MEDIA_STATUS {
259
310
        RT_MEDIA_DISCONNECT = 0,
260
311
        RT_MEDIA_CONNECT = 1
315
366
        RF_1T1R = 0,
316
367
        RF_1T2R = 1,
317
368
        RF_2T2R = 2,
 
369
        RF_2T2R_GREEN = 3,
318
370
};
319
371
 
320
372
enum ht_channel_width {
359
411
        EFUSE_LOADER_CLK_EN,
360
412
        EFUSE_ANA8M,
361
413
        EFUSE_HWSET_MAX_SIZE,
 
414
        EFUSE_MAX_SECTION_MAP,
 
415
        EFUSE_REAL_CONTENT_SIZE,
362
416
 
363
417
        /*CAM map */
364
418
        RWCAM,
397
451
        RTL_IMR_ATIMEND,        /*For 92C,ATIM Window End Interrupt */
398
452
        RTL_IMR_BDOK,           /*Beacon Queue DMA OK Interrup */
399
453
        RTL_IMR_HIGHDOK,        /*High Queue DMA OK Interrupt */
 
454
        RTL_IMR_COMDOK,         /*Command Queue DMA OK Interrupt*/
400
455
        RTL_IMR_TBDOK,          /*Transmit Beacon OK interrup */
401
456
        RTL_IMR_MGNTDOK,        /*Management Queue DMA OK Interrupt */
402
457
        RTL_IMR_TBDER,          /*For 92C,Transmit Beacon Error Interrupt */
405
460
        RTL_IMR_VIDOK,          /*AC_VI DMA OK Interrupt */
406
461
        RTL_IMR_VODOK,          /*AC_VO DMA Interrupt */
407
462
        RTL_IMR_ROK,            /*Receive DMA OK Interrupt */
408
 
        RTL_IBSS_INT_MASKS,     /*(RTL_IMR_BcnInt|RTL_IMR_TBDOK|RTL_IMR_TBDER)*/
 
463
        RTL_IBSS_INT_MASKS,     /*(RTL_IMR_BcnInt | RTL_IMR_TBDOK |
 
464
                                 * RTL_IMR_TBDER) */
409
465
 
410
466
        /*CCK Rates, TxHT = 0 */
411
467
        RTL_RC_CCK_RATE1M,
481
537
        eAcmWay2_SW = 2,
482
538
};
483
539
 
 
540
enum macphy_mode {
 
541
        SINGLEMAC_SINGLEPHY = 0,
 
542
        DUALMAC_DUALPHY,
 
543
        DUALMAC_SINGLEPHY,
 
544
};
 
545
 
 
546
enum band_type {
 
547
        BAND_ON_2_4G = 0,
 
548
        BAND_ON_5G,
 
549
        BAND_ON_BOTH,
 
550
        BANDMAX
 
551
};
 
552
 
484
553
/*aci/aifsn Field.
485
554
Ref: WMM spec 2.2.2: WME Parameter Element, p.12.*/
486
555
union aci_aifsn {
505
574
        WIRELESS_MODE_N_5G = 0x20
506
575
};
507
576
 
 
577
#define IS_WIRELESS_MODE_A(wirelessmode)        \
 
578
        (wirelessmode == WIRELESS_MODE_A)
 
579
#define IS_WIRELESS_MODE_B(wirelessmode)        \
 
580
        (wirelessmode == WIRELESS_MODE_B)
 
581
#define IS_WIRELESS_MODE_G(wirelessmode)        \
 
582
        (wirelessmode == WIRELESS_MODE_G)
 
583
#define IS_WIRELESS_MODE_N_24G(wirelessmode)    \
 
584
        (wirelessmode == WIRELESS_MODE_N_24G)
 
585
#define IS_WIRELESS_MODE_N_5G(wirelessmode)     \
 
586
        (wirelessmode == WIRELESS_MODE_N_5G)
 
587
 
508
588
enum ratr_table_mode {
509
589
        RATR_INX_WIRELESS_NGB = 0,
510
590
        RATR_INX_WIRELESS_NG = 1,
574
654
struct rtl_led {
575
655
        void *hw;
576
656
        enum rtl_led_pin ledpin;
577
 
        bool b_ledon;
 
657
        bool ledon;
578
658
};
579
659
 
580
660
struct rtl_led_ctl {
581
 
        bool bled_opendrain;
 
661
        bool led_opendrain;
582
662
        struct rtl_led sw_led0;
583
663
        struct rtl_led sw_led1;
584
664
};
603
683
        u32 cnt_rate_illegal;
604
684
        u32 cnt_crc8_fail;
605
685
        u32 cnt_mcs_fail;
 
686
        u32 cnt_fast_fsync_fail;
 
687
        u32 cnt_sb_search_fail;
606
688
        u32 cnt_ofdm_fail;
607
689
        u32 cnt_cck_fail;
608
690
        u32 cnt_all;
690
772
        bool rfkill_state;      /*0 is off, 1 is on */
691
773
};
692
774
 
 
775
#define IQK_MATRIX_REG_NUM      8
 
776
#define IQK_MATRIX_SETTINGS_NUM (1 + 24 + 21)
 
777
struct iqk_matrix_regs {
 
778
        bool iqk_done;
 
779
        long value[1][IQK_MATRIX_REG_NUM];
 
780
};
 
781
 
 
782
struct phy_parameters {
 
783
        u16 length;
 
784
        u32 *pdata;
 
785
};
 
786
 
 
787
enum hw_param_tab_index {
 
788
        PHY_REG_2T,
 
789
        PHY_REG_1T,
 
790
        PHY_REG_PG,
 
791
        RADIOA_2T,
 
792
        RADIOB_2T,
 
793
        RADIOA_1T,
 
794
        RADIOB_1T,
 
795
        MAC_REG,
 
796
        AGCTAB_2T,
 
797
        AGCTAB_1T,
 
798
        MAX_TAB
 
799
};
 
800
 
693
801
struct rtl_phy {
694
802
        struct bb_reg_def phyreg_def[4];        /*Radio A/B/C/D */
695
803
        struct init_gain initgain_backup;
705
813
        u8 current_channel;
706
814
        u8 h2c_box_num;
707
815
        u8 set_io_inprogress;
 
816
        u8 lck_inprogress;
708
817
 
709
 
        /*record for power tracking*/
 
818
        /* record for power tracking */
710
819
        s32 reg_e94;
711
820
        s32 reg_e9c;
712
821
        s32 reg_ea4;
723
832
        u32 iqk_mac_backup[IQK_MAC_REG_NUM];
724
833
        u32 iqk_bb_backup[10];
725
834
 
726
 
        bool b_rfpi_enable;
 
835
        /* Dual mac */
 
836
        bool need_iqk;
 
837
        struct iqk_matrix_regs iqk_matrix_regsetting[IQK_MATRIX_SETTINGS_NUM];
 
838
 
 
839
        bool rfpi_enable;
727
840
 
728
841
        u8 pwrgroup_cnt;
729
 
        u8 bcck_high_power;
730
 
        /* 3 groups of pwr diff by rates*/
731
 
        u32 mcs_txpwrlevel_origoffset[4][16];
 
842
        u8 cck_high_power;
 
843
        /* MAX_PG_GROUP groups of pwr diff by rates */
 
844
        u32 mcs_txpwrlevel_origoffset[MAX_PG_GROUP][16];
732
845
        u8 default_initialgain[4];
733
846
 
734
 
        /*the current Tx power level*/
 
847
        /* the current Tx power level */
735
848
        u8 cur_cck_txpwridx;
736
849
        u8 cur_ofdm24g_txpwridx;
737
850
 
738
851
        u32 rfreg_chnlval[2];
739
 
        bool b_apk_done;
 
852
        bool apk_done;
 
853
        u32 reg_rf3c[2];        /* pathA / pathB  */
740
854
 
741
 
        /*fsync*/
 
855
        /* bfsync */
742
856
        u8 framesync;
743
857
        u32 framesync_c34;
744
858
 
745
859
        u8 num_total_rfpath;
 
860
        struct phy_parameters hwparam_tables[MAX_TAB];
 
861
        u16 rf_pathmap;
746
862
};
747
863
 
748
864
#define MAX_TID_COUNT                           9
 
865
#define RTL_AGG_STOP                            0
 
866
#define RTL_AGG_PROGRESS                        1
 
867
#define RTL_AGG_START                           2
 
868
#define RTL_AGG_OPERATIONAL                     3
749
869
#define RTL_AGG_OFF                             0
750
870
#define RTL_AGG_ON                              1
751
871
#define RTL_AGG_EMPTYING_HW_QUEUE_ADDBA         2
765
885
        struct rtl_ht_agg agg;
766
886
};
767
887
 
 
888
struct rtl_sta_info {
 
889
        u8 ratr_index;
 
890
        u8 wireless_mode;
 
891
        u8 mimo_ps;
 
892
        struct rtl_tid_data tids[MAX_TID_COUNT];
 
893
} __packed;
 
894
 
768
895
struct rtl_priv;
769
896
struct rtl_io {
770
897
        struct device *dev;
 
898
        struct mutex bb_mutex;
771
899
 
772
900
        /*PCI MEM map */
773
901
        unsigned long pci_mem_end;      /*shared mem end        */
779
907
        void (*write8_async) (struct rtl_priv *rtlpriv, u32 addr, u8 val);
780
908
        void (*write16_async) (struct rtl_priv *rtlpriv, u32 addr, u16 val);
781
909
        void (*write32_async) (struct rtl_priv *rtlpriv, u32 addr, u32 val);
 
910
        int (*writeN_async) (struct rtl_priv *rtlpriv, u32 addr, u16 len,
 
911
                             u8 *pdata);
782
912
 
783
 
         u8(*read8_sync) (struct rtl_priv *rtlpriv, u32 addr);
784
 
         u16(*read16_sync) (struct rtl_priv *rtlpriv, u32 addr);
785
 
         u32(*read32_sync) (struct rtl_priv *rtlpriv, u32 addr);
 
913
        u8(*read8_sync) (struct rtl_priv *rtlpriv, u32 addr);
 
914
        u16(*read16_sync) (struct rtl_priv *rtlpriv, u32 addr);
 
915
        u32(*read32_sync) (struct rtl_priv *rtlpriv, u32 addr);
 
916
        int (*readN_sync) (struct rtl_priv *rtlpriv, u32 addr, u16 len,
 
917
                            u8 *pdata);
786
918
 
787
919
};
788
920
 
806
938
        int n_channels;
807
939
        int n_bitrates;
808
940
 
 
941
        bool offchan_deley;
 
942
 
809
943
        /*filters */
810
944
        u32 rx_conf;
811
945
        u16 rx_mgt_filter;
815
949
        bool act_scanning;
816
950
        u8 cnt_after_linked;
817
951
 
818
 
         /*RDG*/ bool rdg_en;
819
 
 
820
 
         /*AP*/ u8 bssid[6];
821
 
        u8 mcs[16];     /*16 bytes mcs for HT rates.*/
822
 
        u32 basic_rates; /*b/g rates*/
 
952
        /* early mode */
 
953
        /* skb wait queue */
 
954
        struct sk_buff_head skb_waitq[MAX_TID_COUNT];
 
955
        u8 earlymode_threshold;
 
956
 
 
957
        /*RDG*/
 
958
        bool rdg_en;
 
959
 
 
960
        /*AP*/
 
961
        u8 bssid[6];
 
962
        u32 vendor;
 
963
        u8 mcs[16];     /* 16 bytes mcs for HT rates. */
 
964
        u32 basic_rates; /* b/g rates */
823
965
        u8 ht_enable;
824
966
        u8 sgi_40;
825
967
        u8 sgi_20;
826
968
        u8 bw_40;
827
 
        u8 mode;                /*wireless mode*/
 
969
        u8 mode;                /* wireless mode */
828
970
        u8 slot_time;
829
971
        u8 short_preamble;
830
972
        u8 use_cts_protect;
835
977
        u8 retry_long;
836
978
        u16 assoc_id;
837
979
 
838
 
         /*IBSS*/ int beacon_interval;
 
980
        /*IBSS*/
 
981
        int beacon_interval;
839
982
 
840
 
         /*AMPDU*/ u8 min_space_cfg;    /*For Min spacing configurations */
 
983
        /*AMPDU*/
 
984
        u8 min_space_cfg;       /*For Min spacing configurations */
841
985
        u8 max_mss_density;
842
986
        u8 current_ampdu_factor;
843
987
        u8 current_ampdu_density;
852
996
 
853
997
        enum intf_type interface;
854
998
        u16 hw_type;            /*92c or 92d or 92s and so on */
 
999
        u8 ic_class;
855
1000
        u8 oem_id;
856
 
        u8 version;             /*version of chip */
 
1001
        u32 version;            /*version of chip */
857
1002
        u8 state;               /*stop 0, start 1 */
858
1003
 
859
1004
        /*firmware */
 
1005
        u32 fwsize;
860
1006
        u8 *pfirmware;
861
 
        bool b_h2c_setinprogress;
 
1007
        u16 fw_version;
 
1008
        u16 fw_subversion;
 
1009
        bool h2c_setinprogress;
862
1010
        u8 last_hmeboxnum;
863
 
        bool bfw_ready;
 
1011
        bool fw_ready;
864
1012
        /*Reserve page start offset except beacon in TxQ. */
865
1013
        u8 fw_rsvdpage_startoffset;
 
1014
        u8 h2c_txcmd_seq;
 
1015
 
 
1016
        /* FW Cmd IO related */
 
1017
        u16 fwcmd_iomap;
 
1018
        u32 fwcmd_ioparam;
 
1019
        bool set_fwcmd_inprogress;
 
1020
        u8 current_fwcmd_io;
 
1021
 
 
1022
        /**/
 
1023
        bool driver_going2unload;
 
1024
 
 
1025
        /*AMPDU init min space*/
 
1026
        u8 minspace_cfg;        /*For Min spacing configurations */
 
1027
 
 
1028
        /* Dual mac */
 
1029
        enum macphy_mode macphymode;
 
1030
        enum band_type current_bandtype;        /* 0:2.4G, 1:5G */
 
1031
        enum band_type current_bandtypebackup;
 
1032
        enum band_type bandset;
 
1033
        /* dual MAC 0--Mac0 1--Mac1 */
 
1034
        u32 interfaceindex;
 
1035
        /* just for DualMac S3S4 */
 
1036
        u8 macphyctl_reg;
 
1037
        bool earlymode_enable;
 
1038
        /* Dual mac*/
 
1039
        bool during_mac0init_radiob;
 
1040
        bool during_mac1init_radioa;
 
1041
        bool reloadtxpowerindex;
 
1042
        /* True if IMR or IQK  have done
 
1043
        for 2.4G in scan progress */
 
1044
        bool load_imrandiqk_setting_for2g;
 
1045
 
 
1046
        bool disable_amsdu_8k;
866
1047
};
867
1048
 
868
1049
struct rtl_security {
875
1056
        enum rt_enc_alg pairwise_enc_algorithm;
876
1057
        /*Encryption Algorithm for Brocast/Multicast */
877
1058
        enum rt_enc_alg group_enc_algorithm;
878
 
 
 
1059
        /*Cam Entry Bitmap */
 
1060
        u32 hwsec_cam_bitmap;
 
1061
        u8 hwsec_cam_sta_addr[TOTAL_CAM_ENTRY][ETH_ALEN];
879
1062
        /*local Key buffer, indx 0 is for
880
1063
           pairwise key 1-4 is for agoup key. */
881
1064
        u8 key_buf[KEY_BUF_SIZE][MAX_KEY_LEN];
887
1070
};
888
1071
 
889
1072
struct rtl_dm {
890
 
        /*PHY status for DM */
 
1073
        /*PHY status for Dynamic Management */
891
1074
        long entry_min_undecoratedsmoothed_pwdb;
892
1075
        long undecorated_smoothed_pwdb; /*out dm */
893
1076
        long entry_max_undecoratedsmoothed_pwdb;
894
 
        bool b_dm_initialgain_enable;
895
 
        bool bdynamic_txpower_enable;
896
 
        bool bcurrent_turbo_edca;
897
 
        bool bis_any_nonbepkts; /*out dm */
898
 
        bool bis_cur_rdlstate;
899
 
        bool btxpower_trackingInit;
900
 
        bool b_disable_framebursting;
901
 
        bool b_cck_inch14;
902
 
        bool btxpower_tracking;
903
 
        bool b_useramask;
904
 
        bool brfpath_rxenable[4];
 
1077
        bool dm_initialgain_enable;
 
1078
        bool dynamic_txpower_enable;
 
1079
        bool current_turbo_edca;
 
1080
        bool is_any_nonbepkts;  /*out dm */
 
1081
        bool is_cur_rdlstate;
 
1082
        bool txpower_trackinginit;
 
1083
        bool disable_framebursting;
 
1084
        bool cck_inch14;
 
1085
        bool txpower_tracking;
 
1086
        bool useramask;
 
1087
        bool rfpath_rxenable[4];
 
1088
        bool inform_fw_driverctrldm;
 
1089
        bool current_mrc_switch;
 
1090
        u8 txpowercount;
905
1091
 
 
1092
        u8 thermalvalue_rxgain;
906
1093
        u8 thermalvalue_iqk;
907
1094
        u8 thermalvalue_lck;
908
1095
        u8 thermalvalue;
909
1096
        u8 last_dtp_lvl;
 
1097
        u8 thermalvalue_avg[AVG_THERMAL_NUM];
 
1098
        u8 thermalvalue_avg_index;
 
1099
        bool done_txpower;
910
1100
        u8 dynamic_txhighpower_lvl;     /*Tx high power level */
911
 
        u8 dm_flag;     /*Indicate if each dynamic mechanism's status. */
 
1101
        u8 dm_flag;             /*Indicate each dynamic mechanism's status. */
912
1102
        u8 dm_type;
913
1103
        u8 txpower_track_control;
914
 
 
 
1104
        bool interrupt_migration;
 
1105
        bool disable_tx_int;
915
1106
        char ofdm_index[2];
916
1107
        char cck_index;
917
1108
};
918
1109
 
919
 
#define EFUSE_MAX_LOGICAL_SIZE                   128
 
1110
#define EFUSE_MAX_LOGICAL_SIZE                  256
920
1111
 
921
1112
struct rtl_efuse {
922
 
        bool bautoLoad_ok;
 
1113
        bool autoLoad_ok;
923
1114
        bool bootfromefuse;
924
1115
        u16 max_physical_size;
925
 
        u8 contents[EFUSE_MAX_LOGICAL_SIZE];
926
1116
 
927
1117
        u8 efuse_map[2][EFUSE_MAX_LOGICAL_SIZE];
928
1118
        u16 efuse_usedbytes;
929
1119
        u8 efuse_usedpercentage;
 
1120
#ifdef EFUSE_REPG_WORKAROUND
 
1121
        bool efuse_re_pg_sec1flag;
 
1122
        u8 efuse_re_pg_data[8];
 
1123
#endif
930
1124
 
931
1125
        u8 autoload_failflag;
 
1126
        u8 autoload_status;
932
1127
 
933
1128
        short epromtype;
934
1129
        u16 eeprom_vid;
938
1133
        u8 eeprom_oemid;
939
1134
        u16 eeprom_channelplan;
940
1135
        u8 eeprom_version;
 
1136
        u8 board_type;
 
1137
        u8 external_pa;
941
1138
 
942
1139
        u8 dev_addr[6];
943
1140
 
944
 
        bool b_txpwr_fromeprom;
 
1141
        bool txpwr_fromeprom;
 
1142
        u8 eeprom_crystalcap;
945
1143
        u8 eeprom_tssi[2];
946
 
        u8 eeprom_pwrlimit_ht20[3];
947
 
        u8 eeprom_pwrlimit_ht40[3];
948
 
        u8 eeprom_chnlarea_txpwr_cck[2][3];
949
 
        u8 eeprom_chnlarea_txpwr_ht40_1s[2][3];
950
 
        u8 eeprom_chnlarea_txpwr_ht40_2sdiif[2][3];
951
 
        u8 txpwrlevel_cck[2][14];
952
 
        u8 txpwrlevel_ht40_1s[2][14];   /*For HT 40MHZ pwr */
953
 
        u8 txpwrlevel_ht40_2s[2][14];   /*For HT 40MHZ pwr */
 
1144
        u8 eeprom_tssi_5g[3][2]; /* for 5GL/5GM/5GH band. */
 
1145
        u8 eeprom_pwrlimit_ht20[CHANNEL_GROUP_MAX];
 
1146
        u8 eeprom_pwrlimit_ht40[CHANNEL_GROUP_MAX];
 
1147
        u8 eeprom_chnlarea_txpwr_cck[2][CHANNEL_GROUP_MAX_2G];
 
1148
        u8 eeprom_chnlarea_txpwr_ht40_1s[2][CHANNEL_GROUP_MAX];
 
1149
        u8 eeprom_chnlarea_txpwr_ht40_2sdiif[2][CHANNEL_GROUP_MAX];
 
1150
        u8 txpwrlevel_cck[2][CHANNEL_MAX_NUMBER_2G];
 
1151
        u8 txpwrlevel_ht40_1s[2][CHANNEL_MAX_NUMBER];   /*For HT 40MHZ pwr */
 
1152
        u8 txpwrlevel_ht40_2s[2][CHANNEL_MAX_NUMBER];   /*For HT 40MHZ pwr */
 
1153
 
 
1154
        u8 internal_pa_5g[2];   /* pathA / pathB */
 
1155
        u8 eeprom_c9;
 
1156
        u8 eeprom_cc;
954
1157
 
955
1158
        /*For power group */
956
 
        u8 pwrgroup_ht20[2][14];
957
 
        u8 pwrgroup_ht40[2][14];
 
1159
        u8 eeprom_pwrgroup[2][3];
 
1160
        u8 pwrgroup_ht20[2][CHANNEL_MAX_NUMBER];
 
1161
        u8 pwrgroup_ht40[2][CHANNEL_MAX_NUMBER];
958
1162
 
959
 
        char txpwr_ht20diff[2][14];     /*HT 20<->40 Pwr diff */
960
 
        u8 txpwr_legacyhtdiff[2][14];   /*For HT<->legacy pwr diff */
 
1163
        char txpwr_ht20diff[2][CHANNEL_MAX_NUMBER]; /*HT 20<->40 Pwr diff */
 
1164
        /*For HT<->legacy pwr diff*/
 
1165
        u8 txpwr_legacyhtdiff[2][CHANNEL_MAX_NUMBER];
 
1166
        u8 txpwr_safetyflag;                    /* Band edge enable flag */
 
1167
        u16 eeprom_txpowerdiff;
 
1168
        u8 legacy_httxpowerdiff;        /* Legacy to HT rate power diff */
 
1169
        u8 antenna_txpwdiff[3];
961
1170
 
962
1171
        u8 eeprom_regulatory;
963
1172
        u8 eeprom_thermalmeter;
964
 
        /*ThermalMeter, index 0 for RFIC0, and 1 for RFIC1 */
965
 
        u8 thermalmeter[2];
 
1173
        u8 thermalmeter[2]; /*ThermalMeter, index 0 for RFIC0, 1 for RFIC1 */
 
1174
        u16 tssi_13dbm;
 
1175
        u8 crystalcap;          /* CrystalCap. */
 
1176
        u8 delta_iqk;
 
1177
        u8 delta_lck;
966
1178
 
967
1179
        u8 legacy_ht_txpowerdiff;       /*Legacy to HT rate power diff */
968
 
        bool b_apk_thermalmeterignore;
 
1180
        bool apk_thermalmeterignore;
 
1181
 
 
1182
        bool b1x1_recvcombine;
 
1183
        bool b1ss_support;
 
1184
 
 
1185
        /*channel plan */
 
1186
        u8 channel_plan;
969
1187
};
970
1188
 
971
1189
struct rtl_ps_ctl {
 
1190
        bool pwrdomain_protect;
972
1191
        bool set_rfpowerstate_inprogress;
973
 
        bool b_in_powersavemode;
 
1192
        bool in_powersavemode;
974
1193
        bool rfchange_inprogress;
975
 
        bool b_swrf_processing;
976
 
        bool b_hwradiooff;
977
 
 
978
 
        u32 last_sleep_jiffies;
979
 
        u32 last_awake_jiffies;
980
 
        u32 last_delaylps_stamp_jiffies;
 
1194
        bool swrf_processing;
 
1195
        bool hwradiooff;
981
1196
 
982
1197
        /*
983
1198
         * just for PCIE ASPM
984
1199
         * If it supports ASPM, Offset[560h] = 0x40,
985
1200
         * otherwise Offset[560h] = 0x00.
986
1201
         * */
987
 
        bool b_support_aspm;
988
 
        bool b_support_backdoor;
 
1202
        bool support_aspm;
 
1203
 
 
1204
        bool support_backdoor;
989
1205
 
990
1206
        /*for LPS */
991
1207
        enum rt_psmode dot11_psmode;    /*Power save mode configured. */
992
 
        bool b_leisure_ps;
993
 
        bool b_fwctrl_lps;
 
1208
        bool swctrl_lps;
 
1209
        bool leisure_ps;
 
1210
        bool fwctrl_lps;
994
1211
        u8 fwctrl_psmode;
995
1212
        /*For Fw control LPS mode */
996
 
        u8 b_reg_fwctrl_lps;
 
1213
        u8 reg_fwctrl_lps;
997
1214
        /*Record Fw PS mode status. */
998
 
        bool b_fw_current_inpsmode;
 
1215
        bool fw_current_inpsmode;
999
1216
        u8 reg_max_lps_awakeintvl;
1000
1217
        bool report_linked;
1001
1218
 
1002
1219
        /*for IPS */
1003
 
        bool b_inactiveps;
 
1220
        bool inactiveps;
1004
1221
 
1005
1222
        u32 rfoff_reason;
1006
1223
 
1010
1227
 
1011
1228
        /*just for PCIE ASPM */
1012
1229
        u8 const_amdpci_aspm;
 
1230
        bool pwrdown_mode;
1013
1231
 
1014
1232
        enum rf_pwrstate inactive_pwrstate;
1015
1233
        enum rf_pwrstate rfpwr_state;   /*cur power state */
 
1234
 
 
1235
        /* for SW LPS*/
 
1236
        bool sw_ps_enabled;
 
1237
        bool state;
 
1238
        bool state_inap;
 
1239
        bool multi_buffered;
 
1240
        u16 nullfunc_seq;
 
1241
        unsigned int dtim_counter;
 
1242
        unsigned int sleep_ms;
 
1243
        unsigned long last_sleep_jiffies;
 
1244
        unsigned long last_awake_jiffies;
 
1245
        unsigned long last_delaylps_stamp_jiffies;
 
1246
        unsigned long last_dtim;
 
1247
        unsigned long last_beacon;
 
1248
        unsigned long last_action;
 
1249
        unsigned long last_slept;
1016
1250
};
1017
1251
 
1018
1252
struct rtl_stats {
1038
1272
        s32 recvsignalpower;
1039
1273
        s8 rxpower;             /*in dBm Translate from PWdB */
1040
1274
        u8 signalstrength;      /*in 0-100 index. */
1041
 
        u16 b_hwerror:1;
1042
 
        u16 b_crc:1;
1043
 
        u16 b_icv:1;
1044
 
        u16 b_shortpreamble:1;
 
1275
        u16 hwerror:1;
 
1276
        u16 crc:1;
 
1277
        u16 icv:1;
 
1278
        u16 shortpreamble:1;
1045
1279
        u16 antenna:1;
1046
1280
        u16 decrypted:1;
1047
1281
        u16 wakeup:1;
1050
1284
 
1051
1285
        u8 rx_drvinfo_size;
1052
1286
        u8 rx_bufshift;
1053
 
        bool b_isampdu;
 
1287
        bool isampdu;
 
1288
        bool isfirst_ampdu;
1054
1289
        bool rx_is40Mhzpacket;
1055
1290
        u32 rx_pwdb_all;
1056
1291
        u8 rx_mimo_signalstrength[4];   /*in 0~100 index */
1057
1292
        s8 rx_mimo_signalquality[2];
1058
 
        bool b_packet_matchbssid;
1059
 
        bool b_is_cck;
1060
 
        bool b_packet_toself;
1061
 
        bool b_packet_beacon;   /*for rssi */
 
1293
        bool packet_matchbssid;
 
1294
        bool is_cck;
 
1295
        bool packet_toself;
 
1296
        bool packet_beacon;     /*for rssi */
1062
1297
        char cck_adc_pwdb[4];   /*for rx path selection */
1063
1298
};
1064
1299
 
1069
1304
        u32 num_tx_inperiod;
1070
1305
        u32 num_rx_inperiod;
1071
1306
 
1072
 
        bool b_busytraffic;
1073
 
        bool b_higher_busytraffic;
1074
 
        bool b_higher_busyrxtraffic;
 
1307
        bool busytraffic;
 
1308
        bool higher_busytraffic;
 
1309
        bool higher_busyrxtraffic;
 
1310
 
 
1311
        u32 tidtx_in4period[MAX_TID_COUNT][4];
 
1312
        u32 tidtx_inperiod[MAX_TID_COUNT];
 
1313
        bool higher_busytxtraffic[MAX_TID_COUNT];
1075
1314
};
1076
1315
 
1077
1316
struct rtl_tcb_desc {
1078
 
        u8 b_packet_bw:1;
1079
 
        u8 b_multicast:1;
1080
 
        u8 b_broadcast:1;
 
1317
        u8 packet_bw:1;
 
1318
        u8 multicast:1;
 
1319
        u8 broadcast:1;
1081
1320
 
1082
 
        u8 b_rts_stbc:1;
1083
 
        u8 b_rts_enable:1;
1084
 
        u8 b_cts_enable:1;
1085
 
        u8 b_rts_use_shortpreamble:1;
1086
 
        u8 b_rts_use_shortgi:1;
 
1321
        u8 rts_stbc:1;
 
1322
        u8 rts_enable:1;
 
1323
        u8 cts_enable:1;
 
1324
        u8 rts_use_shortpreamble:1;
 
1325
        u8 rts_use_shortgi:1;
1087
1326
        u8 rts_sc:1;
1088
 
        u8 b_rts_bw:1;
 
1327
        u8 rts_bw:1;
1089
1328
        u8 rts_rate;
1090
1329
 
1091
1330
        u8 use_shortgi:1;
1096
1335
        u8 ratr_index;
1097
1336
        u8 mac_id;
1098
1337
        u8 hw_rate;
 
1338
 
 
1339
        u8 last_inipkt:1;
 
1340
        u8 cmd_or_init:1;
 
1341
        u8 queue_index;
 
1342
 
 
1343
        /* early mode */
 
1344
        u8 empkt_num;
 
1345
        /* The max value by HW */
 
1346
        u32 empkt_len[5];
1099
1347
};
1100
1348
 
1101
1349
struct rtl_hal_ops {
1102
1350
        int (*init_sw_vars) (struct ieee80211_hw *hw);
1103
1351
        void (*deinit_sw_vars) (struct ieee80211_hw *hw);
 
1352
        void (*read_chip_version)(struct ieee80211_hw *hw);
1104
1353
        void (*read_eeprom_info) (struct ieee80211_hw *hw);
1105
1354
        void (*interrupt_recognized) (struct ieee80211_hw *hw,
1106
1355
                                      u32 *p_inta, u32 *p_intb);
1107
1356
        int (*hw_init) (struct ieee80211_hw *hw);
1108
1357
        void (*hw_disable) (struct ieee80211_hw *hw);
 
1358
        void (*hw_suspend) (struct ieee80211_hw *hw);
 
1359
        void (*hw_resume) (struct ieee80211_hw *hw);
1109
1360
        void (*enable_interrupt) (struct ieee80211_hw *hw);
1110
1361
        void (*disable_interrupt) (struct ieee80211_hw *hw);
1111
1362
        int (*set_network_type) (struct ieee80211_hw *hw,
1112
1363
                                 enum nl80211_iftype type);
 
1364
        void (*set_chk_bssid)(struct ieee80211_hw *hw,
 
1365
                                bool check_bssid);
1113
1366
        void (*set_bw_mode) (struct ieee80211_hw *hw,
1114
1367
                             enum nl80211_channel_type ch_type);
1115
1368
         u8(*switch_channel) (struct ieee80211_hw *hw);
1120
1373
                                       u32 add_msr, u32 rm_msr);
1121
1374
        void (*get_hw_reg) (struct ieee80211_hw *hw, u8 variable, u8 *val);
1122
1375
        void (*set_hw_reg) (struct ieee80211_hw *hw, u8 variable, u8 *val);
1123
 
        void (*update_rate_table) (struct ieee80211_hw *hw);
 
1376
        void (*update_rate_tbl) (struct ieee80211_hw *hw,
 
1377
                              struct ieee80211_sta *sta, u8 rssi_level);
1124
1378
        void (*update_rate_mask) (struct ieee80211_hw *hw, u8 rssi_level);
1125
1379
        void (*fill_tx_desc) (struct ieee80211_hw *hw,
1126
1380
                              struct ieee80211_hdr *hdr, u8 *pdesc_tx,
1127
1381
                              struct ieee80211_tx_info *info,
1128
 
                              struct sk_buff *skb, unsigned int queue_index);
 
1382
                              struct sk_buff *skb, u8 hw_queue,
 
1383
                              struct rtl_tcb_desc *ptcb_desc);
 
1384
        void (*fill_fake_txdesc) (struct ieee80211_hw *hw, u8 *pDesc,
 
1385
                                  u32 buffer_len, bool bIsPsPoll);
1129
1386
        void (*fill_tx_cmddesc) (struct ieee80211_hw *hw, u8 *pdesc,
1130
 
                                 bool b_firstseg, bool b_lastseg,
 
1387
                                 bool firstseg, bool lastseg,
1131
1388
                                 struct sk_buff *skb);
1132
 
         bool(*query_rx_desc) (struct ieee80211_hw *hw,
 
1389
        bool (*cmd_send_packet)(struct ieee80211_hw *hw, struct sk_buff *skb);
 
1390
        bool (*query_rx_desc) (struct ieee80211_hw *hw,
1133
1391
                               struct rtl_stats *stats,
1134
1392
                               struct ieee80211_rx_status *rx_status,
1135
1393
                               u8 *pdesc, struct sk_buff *skb);
1136
1394
        void (*set_channel_access) (struct ieee80211_hw *hw);
1137
 
         bool(*radio_onoff_checking) (struct ieee80211_hw *hw, u8 *valid);
 
1395
        bool (*radio_onoff_checking) (struct ieee80211_hw *hw, u8 *valid);
1138
1396
        void (*dm_watchdog) (struct ieee80211_hw *hw);
1139
1397
        void (*scan_operation_backup) (struct ieee80211_hw *hw, u8 operation);
1140
 
         bool(*set_rf_power_state) (struct ieee80211_hw *hw,
 
1398
        bool (*set_rf_power_state) (struct ieee80211_hw *hw,
1141
1399
                                    enum rf_pwrstate rfpwr_state);
1142
1400
        void (*led_control) (struct ieee80211_hw *hw,
1143
1401
                             enum led_ctl_mode ledaction);
1144
1402
        void (*set_desc) (u8 *pdesc, bool istx, u8 desc_name, u8 *val);
1145
 
         u32(*get_desc) (u8 *pdesc, bool istx, u8 desc_name);
1146
 
        void (*tx_polling) (struct ieee80211_hw *hw, unsigned int hw_queue);
 
1403
        u32 (*get_desc) (u8 *pdesc, bool istx, u8 desc_name);
 
1404
        void (*tx_polling) (struct ieee80211_hw *hw, u8 hw_queue);
1147
1405
        void (*enable_hw_sec) (struct ieee80211_hw *hw);
1148
1406
        void (*set_key) (struct ieee80211_hw *hw, u32 key_index,
1149
 
                         u8 *p_macaddr, bool is_group, u8 enc_algo,
 
1407
                         u8 *macaddr, bool is_group, u8 enc_algo,
1150
1408
                         bool is_wepkey, bool clear_all);
1151
1409
        void (*init_sw_leds) (struct ieee80211_hw *hw);
1152
1410
        void (*deinit_sw_leds) (struct ieee80211_hw *hw);
1153
 
         u32(*get_bbreg) (struct ieee80211_hw *hw, u32 regaddr, u32 bitmask);
 
1411
        u32 (*get_bbreg) (struct ieee80211_hw *hw, u32 regaddr, u32 bitmask);
1154
1412
        void (*set_bbreg) (struct ieee80211_hw *hw, u32 regaddr, u32 bitmask,
1155
1413
                           u32 data);
1156
 
         u32(*get_rfreg) (struct ieee80211_hw *hw, enum radio_path rfpath,
 
1414
        u32 (*get_rfreg) (struct ieee80211_hw *hw, enum radio_path rfpath,
1157
1415
                          u32 regaddr, u32 bitmask);
1158
1416
        void (*set_rfreg) (struct ieee80211_hw *hw, enum radio_path rfpath,
1159
1417
                           u32 regaddr, u32 bitmask, u32 data);
 
1418
        void (*linked_set_reg) (struct ieee80211_hw *hw);
 
1419
        bool (*phy_rf6052_config) (struct ieee80211_hw *hw);
 
1420
        void (*phy_rf6052_set_cck_txpower) (struct ieee80211_hw *hw,
 
1421
                                            u8 *powerlevel);
 
1422
        void (*phy_rf6052_set_ofdm_txpower) (struct ieee80211_hw *hw,
 
1423
                                             u8 *ppowerlevel, u8 channel);
 
1424
        bool (*config_bb_with_headerfile) (struct ieee80211_hw *hw,
 
1425
                                           u8 configtype);
 
1426
        bool (*config_bb_with_pgheaderfile) (struct ieee80211_hw *hw,
 
1427
                                             u8 configtype);
 
1428
        void (*phy_lc_calibrate) (struct ieee80211_hw *hw, bool is2t);
 
1429
        void (*phy_set_bw_mode_callback) (struct ieee80211_hw *hw);
 
1430
        void (*dm_dynamic_txpower) (struct ieee80211_hw *hw);
1160
1431
};
1161
1432
 
1162
1433
struct rtl_intf_ops {
1163
1434
        /*com */
 
1435
        void (*read_efuse_byte)(struct ieee80211_hw *hw, u16 _offset, u8 *pbuf);
1164
1436
        int (*adapter_start) (struct ieee80211_hw *hw);
1165
1437
        void (*adapter_stop) (struct ieee80211_hw *hw);
1166
1438
 
1167
 
        int (*adapter_tx) (struct ieee80211_hw *hw, struct sk_buff *skb);
 
1439
        int (*adapter_tx) (struct ieee80211_hw *hw, struct sk_buff *skb,
 
1440
                        struct rtl_tcb_desc *ptcb_desc);
 
1441
        void (*flush)(struct ieee80211_hw *hw, bool drop);
1168
1442
        int (*reset_trx_ring) (struct ieee80211_hw *hw);
 
1443
        bool (*waitq_insert) (struct ieee80211_hw *hw, struct sk_buff *skb);
1169
1444
 
1170
1445
        /*pci */
1171
1446
        void (*disable_aspm) (struct ieee80211_hw *hw);
1177
1452
struct rtl_mod_params {
1178
1453
        /* default: 0 = using hardware encryption */
1179
1454
        int sw_crypto;
 
1455
 
 
1456
        /* default: 1 = using no linked power save */
 
1457
        bool inactiveps;
 
1458
 
 
1459
        /* default: 1 = using linked sw power save */
 
1460
        bool swctrl_lps;
 
1461
 
 
1462
        /* default: 1 = using linked fw power save */
 
1463
        bool fwctrl_lps;
 
1464
};
 
1465
 
 
1466
struct rtl_hal_usbint_cfg {
 
1467
        /* data - rx */
 
1468
        u32 in_ep_num;
 
1469
        u32 rx_urb_num;
 
1470
        u32 rx_max_size;
 
1471
 
 
1472
        /* op - rx */
 
1473
        void (*usb_rx_hdl)(struct ieee80211_hw *, struct sk_buff *);
 
1474
        void (*usb_rx_segregate_hdl)(struct ieee80211_hw *, struct sk_buff *,
 
1475
                                     struct sk_buff_head *);
 
1476
 
 
1477
        /* tx */
 
1478
        void (*usb_tx_cleanup)(struct ieee80211_hw *, struct sk_buff *);
 
1479
        int (*usb_tx_post_hdl)(struct ieee80211_hw *, struct urb *,
 
1480
                               struct sk_buff *);
 
1481
        struct sk_buff *(*usb_tx_aggregate_hdl)(struct ieee80211_hw *,
 
1482
                                                struct sk_buff_head *);
 
1483
 
 
1484
        /* endpoint mapping */
 
1485
        int (*usb_endpoint_mapping)(struct ieee80211_hw *hw);
 
1486
        u16 (*usb_mq_to_hwq)(__le16 fc, u16 mac80211_queue_index);
1180
1487
};
1181
1488
 
1182
1489
struct rtl_hal_cfg {
 
1490
        u8 bar_id;
 
1491
        bool write_readback;
1183
1492
        char *name;
1184
1493
        char *fw_name;
1185
1494
        struct rtl_hal_ops *ops;
1186
1495
        struct rtl_mod_params *mod_params;
 
1496
        struct rtl_hal_usbint_cfg *usb_interface_cfg;
1187
1497
 
1188
1498
        /*this map used for some registers or vars
1189
1499
           defined int HAL but used in MAIN */
1202
1512
        spinlock_t rf_ps_lock;
1203
1513
        spinlock_t rf_lock;
1204
1514
        spinlock_t lps_lock;
 
1515
        spinlock_t waitq_lock;
 
1516
 
 
1517
        /*Dual mac*/
 
1518
        spinlock_t cck_and_rw_pagea_lock;
1205
1519
};
1206
1520
 
1207
1521
struct rtl_works {
1218
1532
        struct workqueue_struct *rtl_wq;
1219
1533
        struct delayed_work watchdog_wq;
1220
1534
        struct delayed_work ips_nic_off_wq;
 
1535
 
 
1536
        /* For SW LPS */
 
1537
        struct delayed_work ps_work;
 
1538
        struct delayed_work ps_rfon_wq;
1221
1539
};
1222
1540
 
1223
1541
struct rtl_debug {
1224
1542
        u32 dbgp_type[DBGP_TYPE_MAX];
1225
1543
        u32 global_debuglevel;
1226
1544
        u64 global_debugcomponents;
 
1545
 
 
1546
        /* add for proc debug */
 
1547
        struct proc_dir_entry *proc_dir;
 
1548
        char proc_name[20];
1227
1549
};
1228
1550
 
1229
1551
struct rtl_priv {
1274
1596
#define rtl_efuse(rtlpriv)      (&((rtlpriv)->efuse))
1275
1597
#define rtl_psc(rtlpriv)        (&((rtlpriv)->psc))
1276
1598
 
 
1599
 
 
1600
/***************************************
 
1601
    Bluetooth Co-existence Related
 
1602
****************************************/
 
1603
 
 
1604
enum bt_ant_num {
 
1605
        ANT_X2 = 0,
 
1606
        ANT_X1 = 1,
 
1607
};
 
1608
 
 
1609
enum bt_co_type {
 
1610
        BT_2WIRE = 0,
 
1611
        BT_ISSC_3WIRE = 1,
 
1612
        BT_ACCEL = 2,
 
1613
        BT_CSR_BC4 = 3,
 
1614
        BT_CSR_BC8 = 4,
 
1615
        BT_RTL8756 = 5,
 
1616
};
 
1617
 
 
1618
enum bt_cur_state {
 
1619
        BT_OFF = 0,
 
1620
        BT_ON = 1,
 
1621
};
 
1622
 
 
1623
enum bt_service_type {
 
1624
        BT_SCO = 0,
 
1625
        BT_A2DP = 1,
 
1626
        BT_HID = 2,
 
1627
        BT_HID_IDLE = 3,
 
1628
        BT_SCAN = 4,
 
1629
        BT_IDLE = 5,
 
1630
        BT_OTHER_ACTION = 6,
 
1631
        BT_BUSY = 7,
 
1632
        BT_OTHERBUSY = 8,
 
1633
        BT_PAN = 9,
 
1634
};
 
1635
 
 
1636
enum bt_radio_shared {
 
1637
        BT_RADIO_SHARED = 0,
 
1638
        BT_RADIO_INDIVIDUAL = 1,
 
1639
};
 
1640
 
 
1641
struct bt_coexist_info {
 
1642
 
 
1643
        /* EEPROM BT info. */
 
1644
        u8 eeprom_bt_coexist;
 
1645
        u8 eeprom_bt_type;
 
1646
        u8 eeprom_bt_ant_num;
 
1647
        u8 eeprom_bt_ant_isolation;
 
1648
        u8 eeprom_bt_radio_shared;
 
1649
 
 
1650
        u8 bt_coexistence;
 
1651
        u8 bt_ant_num;
 
1652
        u8 bt_coexist_type;
 
1653
        u8 bt_state;
 
1654
        u8 bt_cur_state;        /* 0:on, 1:off */
 
1655
        u8 bt_ant_isolation;    /* 0:good, 1:bad */
 
1656
        u8 bt_pape_ctrl;        /* 0:SW, 1:SW/HW dynamic */
 
1657
        u8 bt_service;
 
1658
        u8 bt_radio_shared_type;
 
1659
        u8 bt_rfreg_origin_1e;
 
1660
        u8 bt_rfreg_origin_1f;
 
1661
        u8 bt_rssi_state;
 
1662
        u32 ratio_tx;
 
1663
        u32 ratio_pri;
 
1664
        u32 bt_edca_ul;
 
1665
        u32 bt_edca_dl;
 
1666
 
 
1667
        bool init_set;
 
1668
        bool bt_busy_traffic;
 
1669
        bool bt_traffic_mode_set;
 
1670
        bool bt_non_traffic_mode_set;
 
1671
 
 
1672
        bool fw_coexist_all_off;
 
1673
        bool sw_coexist_all_off;
 
1674
        u32 current_state;
 
1675
        u32 previous_state;
 
1676
        u8 bt_pre_rssi_state;
 
1677
 
 
1678
        u8 reg_bt_iso;
 
1679
        u8 reg_bt_sco;
 
1680
 
 
1681
};
 
1682
 
 
1683
 
1277
1684
/****************************************
1278
1685
        mem access macro define start
1279
1686
        Call endian free function when
1281
1688
        2. Before write integer to IO.
1282
1689
        3. After read integer from IO.
1283
1690
****************************************/
1284
 
/* Convert little data endian to host */
 
1691
/* Convert little data endian to host ordering */
1285
1692
#define EF1BYTE(_val)           \
1286
1693
        ((u8)(_val))
1287
1694
#define EF2BYTE(_val)           \
1292
1699
/* Read data from memory */
1293
1700
#define READEF1BYTE(_ptr)       \
1294
1701
        EF1BYTE(*((u8 *)(_ptr)))
 
1702
/* Read le16 data from memory and convert to host ordering */
1295
1703
#define READEF2BYTE(_ptr)       \
1296
1704
        EF2BYTE(*((u16 *)(_ptr)))
1297
1705
#define READEF4BYTE(_ptr)       \
1300
1708
/* Write data to memory */
1301
1709
#define WRITEEF1BYTE(_ptr, _val)        \
1302
1710
        (*((u8 *)(_ptr))) = EF1BYTE(_val)
 
1711
/* Write le16 data to memory in host ordering */
1303
1712
#define WRITEEF2BYTE(_ptr, _val)        \
1304
1713
        (*((u16 *)(_ptr))) = EF2BYTE(_val)
1305
1714
#define WRITEEF4BYTE(_ptr, _val)        \
1306
 
        (*((u32 *)(_ptr))) = EF4BYTE(_val)
 
1715
        (*((u16 *)(_ptr))) = EF2BYTE(_val)
1307
1716
 
1308
 
/*Example:
1309
 
BIT_LEN_MASK_32(0) => 0x00000000
1310
 
BIT_LEN_MASK_32(1) => 0x00000001
1311
 
BIT_LEN_MASK_32(2) => 0x00000003
1312
 
BIT_LEN_MASK_32(32) => 0xFFFFFFFF*/
 
1717
/* Create a bit mask
 
1718
 * Examples:
 
1719
 * BIT_LEN_MASK_32(0) => 0x00000000
 
1720
 * BIT_LEN_MASK_32(1) => 0x00000001
 
1721
 * BIT_LEN_MASK_32(2) => 0x00000003
 
1722
 * BIT_LEN_MASK_32(32) => 0xFFFFFFFF
 
1723
 */
1313
1724
#define BIT_LEN_MASK_32(__bitlen)        \
1314
1725
        (0xFFFFFFFF >> (32 - (__bitlen)))
1315
1726
#define BIT_LEN_MASK_16(__bitlen)        \
1317
1728
#define BIT_LEN_MASK_8(__bitlen) \
1318
1729
        (0xFF >> (8 - (__bitlen)))
1319
1730
 
1320
 
/*Example:
1321
 
BIT_OFFSET_LEN_MASK_32(0, 2) => 0x00000003
1322
 
BIT_OFFSET_LEN_MASK_32(16, 2) => 0x00030000*/
 
1731
/* Create an offset bit mask
 
1732
 * Examples:
 
1733
 * BIT_OFFSET_LEN_MASK_32(0, 2) => 0x00000003
 
1734
 * BIT_OFFSET_LEN_MASK_32(16, 2) => 0x00030000
 
1735
 */
1323
1736
#define BIT_OFFSET_LEN_MASK_32(__bitoffset, __bitlen) \
1324
1737
        (BIT_LEN_MASK_32(__bitlen) << (__bitoffset))
1325
1738
#define BIT_OFFSET_LEN_MASK_16(__bitoffset, __bitlen) \
1328
1741
        (BIT_LEN_MASK_8(__bitlen) << (__bitoffset))
1329
1742
 
1330
1743
/*Description:
1331
 
Return 4-byte value in host byte ordering from
1332
 
4-byte pointer in little-endian system.*/
 
1744
 * Return 4-byte value in host byte ordering from
 
1745
 * 4-byte pointer in little-endian system.
 
1746
 */
1333
1747
#define LE_P4BYTE_TO_HOST_4BYTE(__pstart) \
1334
1748
        (EF4BYTE(*((u32 *)(__pstart))))
1335
1749
#define LE_P2BYTE_TO_HOST_2BYTE(__pstart) \
1356
1770
                BIT_LEN_MASK_8(__bitlen) \
1357
1771
        )
1358
1772
 
1359
 
/*Description:
1360
 
Mask subfield (continuous bits in little-endian) of 4-byte value
1361
 
and return the result in 4-byte value in host byte ordering.*/
 
1773
/* Description:
 
1774
 * Mask subfield (continuous bits in little-endian) of 4-byte value
 
1775
 * and return the result in 4-byte value in host byte ordering.
 
1776
 */
1362
1777
#define LE_BITS_CLEARED_TO_4BYTE(__pstart, __bitoffset, __bitlen) \
1363
1778
        ( \
1364
1779
                LE_P4BYTE_TO_HOST_4BYTE(__pstart)  & \
1375
1790
                (~BIT_OFFSET_LEN_MASK_8(__bitoffset, __bitlen)) \
1376
1791
        )
1377
1792
 
1378
 
/*Description:
1379
 
Set subfield of little-endian 4-byte value to specified value.  */
 
1793
/* Description:
 
1794
 * Set subfield of little-endian 4-byte value to specified value.
 
1795
 */
1380
1796
#define SET_BITS_TO_LE_4BYTE(__pstart, __bitoffset, __bitlen, __val) \
1381
1797
        *((u32 *)(__pstart)) = EF4BYTE \
1382
1798
        ( \
1396
1812
                ((((u8)__val) & BIT_LEN_MASK_8(__bitlen)) << (__bitoffset)) \
1397
1813
        );
1398
1814
 
 
1815
#define N_BYTE_ALIGMENT(__value, __aligment) ((__aligment == 1) ? \
 
1816
        (__value) : (((__value + __aligment - 1) / __aligment) * __aligment))
 
1817
 
1399
1818
/****************************************
1400
1819
        mem access macro define end
1401
1820
****************************************/
1402
1821
 
 
1822
#define byte(x, n) ((x >> (8 * n)) & 0xff)
 
1823
 
1403
1824
#define packet_get_type(_packet) (EF1BYTE((_packet).octet[0]) & 0xFC)
1404
1825
#define RTL_WATCH_DOG_TIME      2000
1405
1826
#define MSECS(t)                msecs_to_jiffies(t)
1406
 
#define WLAN_FC_GET_VERS(fc)    ((fc) & IEEE80211_FCTL_VERS)
1407
 
#define WLAN_FC_GET_TYPE(fc)    ((fc) & IEEE80211_FCTL_FTYPE)
1408
 
#define WLAN_FC_GET_STYPE(fc)   ((fc) & IEEE80211_FCTL_STYPE)
1409
 
#define WLAN_FC_MORE_DATA(fc)   ((fc) & IEEE80211_FCTL_MOREDATA)
 
1827
#define WLAN_FC_GET_VERS(fc)    (le16_to_cpu(fc) & IEEE80211_FCTL_VERS)
 
1828
#define WLAN_FC_GET_TYPE(fc)    (le16_to_cpu(fc) & IEEE80211_FCTL_FTYPE)
 
1829
#define WLAN_FC_GET_STYPE(fc)   (le16_to_cpu(fc) & IEEE80211_FCTL_STYPE)
 
1830
#define WLAN_FC_MORE_DATA(fc)   (le16_to_cpu(fc) & IEEE80211_FCTL_MOREDATA)
1410
1831
#define SEQ_TO_SN(seq)          (((seq) & IEEE80211_SCTL_SEQ) >> 4)
1411
1832
#define SN_TO_SEQ(ssn)          (((ssn) << 4) & IEEE80211_SCTL_SEQ)
1412
1833
#define MAX_SN                  ((IEEE80211_SCTL_SEQ) >> 4)
1420
1841
#define RT_RF_OFF_LEVL_FW_32K           BIT(5)  /*FW in 32k */
1421
1842
/*Always enable ASPM and Clock Req in initialization.*/
1422
1843
#define RT_RF_PS_LEVEL_ALWAYS_ASPM      BIT(6)
 
1844
/* no matter RFOFF or SLEEP we set PS_ASPM_LEVL*/
 
1845
#define RT_PS_LEVEL_ASPM                BIT(7)
1423
1846
/*When LPS is on, disable 2R if no packet is received or transmittd.*/
1424
1847
#define RT_RF_LPS_DISALBE_2R            BIT(30)
1425
1848
#define RT_RF_LPS_LEVEL_ASPM            BIT(31) /*LPS with ASPM */
1460
1883
static inline void rtl_write_byte(struct rtl_priv *rtlpriv, u32 addr, u8 val8)
1461
1884
{
1462
1885
        rtlpriv->io.write8_async(rtlpriv, addr, val8);
 
1886
 
 
1887
        if (rtlpriv->cfg->write_readback)
 
1888
                rtlpriv->io.read8_sync(rtlpriv, addr);
1463
1889
}
1464
1890
 
1465
1891
static inline void rtl_write_word(struct rtl_priv *rtlpriv, u32 addr, u16 val16)
1466
1892
{
1467
1893
        rtlpriv->io.write16_async(rtlpriv, addr, val16);
 
1894
 
 
1895
        if (rtlpriv->cfg->write_readback)
 
1896
                rtlpriv->io.read16_sync(rtlpriv, addr);
1468
1897
}
1469
1898
 
1470
1899
static inline void rtl_write_dword(struct rtl_priv *rtlpriv,
1471
1900
                                   u32 addr, u32 val32)
1472
1901
{
1473
1902
        rtlpriv->io.write32_async(rtlpriv, addr, val32);
 
1903
 
 
1904
        if (rtlpriv->cfg->write_readback)
 
1905
                rtlpriv->io.read32_sync(rtlpriv, addr);
1474
1906
}
1475
1907
 
1476
1908
static inline u32 rtl_get_bbreg(struct ieee80211_hw *hw,
1529
1961
        return rtlphy->rf_type;
1530
1962
}
1531
1963
 
 
1964
static inline struct ieee80211_hdr *rtl_get_hdr(struct sk_buff *skb)
 
1965
{
 
1966
        return (struct ieee80211_hdr *)(skb->data);
 
1967
}
 
1968
 
 
1969
static inline __le16 rtl_get_fc(struct sk_buff *skb)
 
1970
{
 
1971
        return rtl_get_hdr(skb)->frame_control;
 
1972
}
 
1973
 
 
1974
static inline u16 rtl_get_tid_h(struct ieee80211_hdr *hdr)
 
1975
{
 
1976
        return (ieee80211_get_qos_ctl(hdr))[0] & IEEE80211_QOS_CTL_TID_MASK;
 
1977
}
 
1978
 
 
1979
static inline u16 rtl_get_tid(struct sk_buff *skb)
 
1980
{
 
1981
        return rtl_get_tid_h(rtl_get_hdr(skb));
 
1982
}
 
1983
 
 
1984
static inline struct ieee80211_sta *get_sta(struct ieee80211_hw *hw,
 
1985
                                            struct ieee80211_vif *vif,
 
1986
                                            u8 *bssid)
 
1987
{
 
1988
        return ieee80211_find_sta(vif, bssid);
 
1989
}
 
1990
 
1532
1991
#endif