f7657951143cc468814696aa47a885b8fc1c4b34
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rtl8723bs / include / rtl8192e_cmd.h
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17  *
18  *
19  ******************************************************************************/
20 #ifndef __RTL8192E_CMD_H__
21 #define __RTL8192E_CMD_H__
22
23 typedef enum _RTL8192E_H2C_CMD 
24 {
25         H2C_8192E_RSVDPAGE      = 0x00,
26         H2C_8192E_MSRRPT        = 0x01,
27         H2C_8192E_SCAN          = 0x02,
28         H2C_8192E_KEEP_ALIVE_CTRL = 0x03,
29         H2C_8192E_DISCONNECT_DECISION = 0x04,
30         H2C_8192E_INIT_OFFLOAD = 0x06,
31         H2C_8192E_AP_OFFLOAD = 0x08,
32         H2C_8192E_BCN_RSVDPAGE = 0x09,
33         H2C_8192E_PROBERSP_RSVDPAGE = 0x0a,
34
35         H2C_8192E_AP_WOW_GPIO_CTRL = 0x13,
36         
37         H2C_8192E_SETPWRMODE = 0x20,            
38         H2C_8192E_PS_TUNING_PARA = 0x21,
39         H2C_8192E_PS_TUNING_PARA2 = 0x22,
40         H2C_8192E_PS_LPS_PARA = 0x23,
41         H2C_8192E_P2P_PS_OFFLOAD = 0x24,
42         H2C_8192E_SAP_PS = 0x26,
43         H2C_8192E_RA_MASK = 0x40,
44         H2C_8192E_RSSI_REPORT = 0x42,
45
46         H2C_8192E_WO_WLAN = 0x80,
47         H2C_8192E_REMOTE_WAKE_CTRL = 0x81,
48         H2C_8192E_AOAC_GLOBAL_INFO = 0x82,
49         H2C_8192E_AOAC_RSVDPAGE = 0x83,
50
51         //Not defined in new 88E H2C CMD Format
52         H2C_8192E_SELECTIVE_SUSPEND_ROF_CMD,
53         H2C_8192E_P2P_PS_MODE,
54         H2C_8192E_PSD_RESULT,
55         MAX_8192E_H2CCMD
56 }RTL8192E_H2C_CMD;
57
58 typedef enum _RTL8192E_C2H_EVT
59 {
60         C2H_8192E_DBG = 0,
61         C2H_8192E_LB = 1,
62         C2H_8192E_TXBF = 2,
63         C2H_8192E_TX_REPORT = 3,
64         C2H_8192E_BT_INFO = 9,
65         C2H_8192E_FW_SWCHNL = 0x10,
66         C2H_8192E_BT_MP = 11,
67         C2H_8192E_RA_RPT=12,    
68         
69         MAX_8192E_C2HEVENT      
70 }RTL8192E_C2H_EVT;
71
72
73 struct cmd_msg_parm {
74         u8 eid; //element id
75         u8 sz; // sz
76         u8 buf[6];
77 };
78
79 enum{
80         PWRS
81 };
82
83 typedef struct _SETPWRMODE_PARM {
84         u8 Mode;//0:Active,1:LPS,2:WMMPS
85         //u8 RLBM:4;//0:Min,1:Max,2: User define
86         u8 SmartPS_RLBM;//LPS=0:PS_Poll,1:PS_Poll,2:NullData,WMM=0:PS_Poll,1:NullData
87         u8 AwakeInterval;       // unit: beacon interval
88         u8 bAllQueueUAPSD;
89         u8 PwrState;//AllON(0x0c),RFON(0x04),RFOFF(0x00)
90 } SETPWRMODE_PARM, *PSETPWRMODE_PARM;
91
92 struct H2C_SS_RFOFF_PARAM{
93         u8 ROFOn; // 1: on, 0:off
94         u16 gpio_period; // unit: 1024 us
95 }__attribute__ ((packed));
96
97
98 typedef struct JOINBSSRPT_PARM_92E{
99         u8 OpMode;      // RT_MEDIA_STATUS
100 #ifdef CONFIG_WOWLAN
101         u8 MacID;       // MACID
102 #endif //CONFIG_WOWLAN
103 }JOINBSSRPT_PARM_92E, *PJOINBSSRPT_PARM_92E;
104
105 /* move to hal_com_h2c.h
106 typedef struct _RSVDPAGE_LOC_92E {
107         u8 LocProbeRsp;
108         u8 LocPsPoll;
109         u8 LocNullData;
110         u8 LocQosNull;
111         u8 LocBTQosNull;
112 } RSVDPAGE_LOC_92E, *PRSVDPAGE_LOC_92E;
113 */
114
115
116 //_SETPWRMODE_PARM
117 #define SET_8192E_H2CCMD_PWRMODE_PARM_MODE(__pH2CCmd, __Value)                          SET_BITS_TO_LE_1BYTE_8BIT(__pH2CCmd, 0, 8, __Value)
118 #define SET_8192E_H2CCMD_PWRMODE_PARM_RLBM(__pH2CCmd, __Value)                          SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 0, 4, __Value)
119 #define SET_8192E_H2CCMD_PWRMODE_PARM_SMART_PS(__pH2CCmd, __Value)                      SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 4, 4, __Value)
120 #define SET_8192E_H2CCMD_PWRMODE_PARM_BCN_PASS_TIME(__pH2CCmd, __Value)         SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+2, 0, 8, __Value)
121 #define SET_8192E_H2CCMD_PWRMODE_PARM_ALL_QUEUE_UAPSD(__pH2CCmd, __Value)       SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+3, 0, 8, __Value)
122 #define SET_8192E_H2CCMD_PWRMODE_PARM_PWR_STATE(__pH2CCmd, __Value)                     SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+4, 0, 8, __Value)
123 #define SET_8192E_H2CCMD_PWRMODE_PARM_BYTE5(__pH2CCmd, __Value)                         SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+5, 0, 8, __Value)
124 #define GET_8192E_H2CCMD_PWRMODE_PARM_MODE(__pH2CCmd)                                           LE_BITS_TO_1BYTE(__pH2CCmd, 0, 8)
125
126 //_P2P_PS_OFFLOAD
127 #define SET_8192E_H2CCMD_P2P_PS_OFFLOAD_ENABLE(__pH2CCmd, __Value)                      SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 1, __Value)
128 #define SET_8192E_H2CCMD_P2P_PS_OFFLOAD_ROLE(__pH2CCmd, __Value)                                SET_BITS_TO_LE_1BYTE(__pH2CCmd, 1, 1, __Value)
129 #define SET_8192E_H2CCMD_P2P_PS_OFFLOAD_CTWINDOW_EN(__pH2CCmd, __Value)         SET_BITS_TO_LE_1BYTE(__pH2CCmd, 2, 1, __Value)
130 #define SET_8192E_H2CCMD_P2P_PS_OFFLOAD_NOA0_EN(__pH2CCmd, __Value)                     SET_BITS_TO_LE_1BYTE(__pH2CCmd, 3, 1, __Value)
131 #define SET_8192E_H2CCMD_P2P_PS_OFFLOAD_NOA1_EN(__pH2CCmd, __Value)                     SET_BITS_TO_LE_1BYTE(__pH2CCmd, 4, 1, __Value)
132 #define SET_8192E_H2CCMD_P2P_PS_OFFLOAD_ALLSTASLEEP(__pH2CCmd, __Value)         SET_BITS_TO_LE_1BYTE(__pH2CCmd, 5, 1, __Value)
133
134
135 // host message to firmware cmd
136 void rtl8192e_set_FwPwrMode_cmd(PADAPTER padapter, u8 Mode);
137 void rtl8192e_set_FwJoinBssReport_cmd(PADAPTER padapter, u8 mstatus);
138 u8 rtl8192e_set_rssi_cmd(PADAPTER padapter, u8 *param);
139 void rtl8192e_set_raid_cmd(PADAPTER padapter, u32 bitmap, u8* arg);
140 void rtl8192e_Add_RateATid(PADAPTER padapter, u32 bitmap, u8 *arg, u8 rssi_level);
141 //u8 rtl8192c_set_FwSelectSuspend_cmd(PADAPTER padapter, u8 bfwpoll, u16 period);
142
143
144 #ifdef CONFIG_P2P_PS
145 void rtl8192e_set_p2p_ps_offload_cmd(PADAPTER padapter, u8 p2p_ps_state);
146 //void rtl8723a_set_p2p_ps_offload_cmd(PADAPTER padapter, u8 p2p_ps_state);
147 #endif //CONFIG_P2P
148
149 void CheckFwRsvdPageContent(PADAPTER padapter);
150 void rtl8192e_set_FwMediaStatus_cmd(PADAPTER padapter, u16 mstatus_rpt );
151
152 #ifdef CONFIG_TSF_RESET_OFFLOAD
153 //u8 rtl8188e_reset_tsf(_adapter *padapter, u8 reset_port);
154 int reset_tsf(PADAPTER Adapter, u8 reset_port );
155 #endif  // CONFIG_TSF_RESET_OFFLOAD
156
157 #ifdef CONFIG_WOWLAN
158 typedef struct _SETWOWLAN_PARM{
159         u8              mode;
160         u8              gpio_index;
161         u8              gpio_duration;
162         u8              second_mode;
163         u8              reserve;
164 }SETWOWLAN_PARM, *PSETWOWLAN_PARM;
165
166 #define FW_WOWLAN_FUN_EN                                BIT(0)
167 #define FW_WOWLAN_PATTERN_MATCH                 BIT(1)
168 #define FW_WOWLAN_MAGIC_PKT                             BIT(2)
169 #define FW_WOWLAN_UNICAST                               BIT(3)
170 #define FW_WOWLAN_ALL_PKT_DROP                  BIT(4)
171 #define FW_WOWLAN_GPIO_ACTIVE                   BIT(5)
172 #define FW_WOWLAN_REKEY_WAKEUP                  BIT(6)
173 #define FW_WOWLAN_DEAUTH_WAKEUP                 BIT(7)
174
175 #define FW_WOWLAN_GPIO_WAKEUP_EN                BIT(0)
176 #define FW_FW_PARSE_MAGIC_PKT                   BIT(1)
177
178 #define FW_REMOTE_WAKE_CTRL_EN                  BIT(0)
179 #define FW_REALWOWLAN_EN                                BIT(5)
180 #endif//CONFIG_WOWLAN
181
182 #if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN)
183 void rtl8192e_set_wowlan_cmd(_adapter* padapter, u8 enable);
184 void rtl8192e_set_ap_wowlan_cmd(_adapter* padapter, u8 enable);
185 void rtl8192e_set_ap_ps_wowlan_cmd(_adapter* padapter, u8 enable);
186 void SetFwRelatedForWoWLAN8192E(_adapter* padapter, u8 bHostIsGoingtoSleep);
187 #endif
188 /// TX Feedback Content
189 #define         USEC_UNIT_FOR_8192E_C2H_TX_RPT_QUEUE_TIME                       256
190
191 #define GET_8192E_C2H_TX_RPT_QUEUE_SELECT(_Header)                      LE_BITS_TO_1BYTE((_Header + 0), 0, 5)
192 #define GET_8192E_C2H_TX_RPT_PKT_BROCAST(_Header)                       LE_BITS_TO_1BYTE((_Header + 0), 5, 1)
193 #define GET_8192E_C2H_TX_RPT_LIFE_TIME_OVER(_Header)                    LE_BITS_TO_1BYTE((_Header + 0), 6, 1)
194 #define GET_8192E_C2H_TX_RPT_RETRY_OVER(_Header)                                LE_BITS_TO_1BYTE((_Header + 0), 7, 1)
195 #define GET_8192E_C2H_TX_RPT_MAC_ID(_Header)                                    LE_BITS_TO_1BYTE((_Header + 1), 0, 8)
196 #define GET_8192E_C2H_TX_RPT_DATA_RETRY_CNT(_Header)            LE_BITS_TO_1BYTE((_Header + 2), 0, 6)
197 #define GET_8192E_C2H_TX_RPT_QUEUE_TIME(_Header)                                LE_BITS_TO_2BYTE((_Header + 3), 0, 16)  // In unit of 256 microseconds.
198 #define GET_8192E_C2H_TX_RPT_FINAL_DATA_RATE(_Header)           LE_BITS_TO_1BYTE((_Header + 5), 0, 8)
199
200
201
202 void C2HContentParsing8192E(
203         IN      PADAPTER                Adapter,
204         IN      u1Byte                  c2hCmdId, 
205         IN      u1Byte                  c2hCmdLen,
206         IN      pu1Byte                         tmpBuf
207 );
208 VOID
209 C2HPacketHandler_8192E(
210         IN      PADAPTER                Adapter,
211         IN      pu1Byte                 Buffer,
212         IN      u1Byte                  Length
213 );
214
215 #endif//__RTL8188E_CMD_H__