Merge remote-tracking branch 'asoc/fix/core' into asoc-linus
[cascardo/linux.git] / drivers / staging / rtl8188eu / include / drv_types.h
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2012 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 /*-----------------------------------------------------------------------------
21
22         For type defines and data structure defines
23
24 ------------------------------------------------------------------------------*/
25
26
27 #ifndef __DRV_TYPES_H__
28 #define __DRV_TYPES_H__
29
30 #define DRV_NAME "r8188eu"
31
32 #include <osdep_service.h>
33 #include <wlan_bssdef.h>
34 #include <rtw_ht.h>
35 #include <rtw_cmd.h>
36 #include <rtw_xmit.h>
37 #include <rtw_recv.h>
38 #include <hal_intf.h>
39 #include <hal_com.h>
40 #include <rtw_qos.h>
41 #include <rtw_security.h>
42 #include <rtw_pwrctrl.h>
43 #include <rtw_io.h>
44 #include <rtw_eeprom.h>
45 #include <sta_info.h>
46 #include <rtw_mlme.h>
47 #include <rtw_debug.h>
48 #include <rtw_rf.h>
49 #include <rtw_event.h>
50 #include <rtw_led.h>
51 #include <rtw_mlme_ext.h>
52 #include <rtw_p2p.h>
53 #include <rtw_ap.h>
54 #include <rtw_mp.h>
55 #include <rtw_br_ext.h>
56
57 enum _NIC_VERSION {
58         RTL8711_NIC,
59         RTL8712_NIC,
60         RTL8713_NIC,
61         RTL8716_NIC
62 };
63
64 #define SPEC_DEV_ID_NONE                BIT(0)
65 #define SPEC_DEV_ID_DISABLE_HT          BIT(1)
66 #define SPEC_DEV_ID_ENABLE_PS           BIT(2)
67 #define SPEC_DEV_ID_RF_CONFIG_1T1R      BIT(3)
68 #define SPEC_DEV_ID_RF_CONFIG_2T2R      BIT(4)
69 #define SPEC_DEV_ID_ASSIGN_IFNAME       BIT(5)
70
71 struct specific_device_id {
72         u32             flags;
73         u16             idVendor;
74         u16             idProduct;
75 };
76
77 struct registry_priv {
78         u8      chip_version;
79         u8      rfintfs;
80         u8      lbkmode;
81         u8      hci;
82         struct ndis_802_11_ssid ssid;
83         u8      network_mode;   /* infra, ad-hoc, auto */
84         u8      channel;/* ad-hoc support requirement */
85         u8      wireless_mode;/* A, B, G, auto */
86         u8      scan_mode;/* active, passive */
87         u8      radio_enable;
88         u8      preamble;/* long, short, auto */
89         u8      vrtl_carrier_sense;/* Enable, Disable, Auto */
90         u8      vcs_type;/* RTS/CTS, CTS-to-self */
91         u16     rts_thresh;
92         u16     frag_thresh;
93         u8      adhoc_tx_pwr;
94         u8      soft_ap;
95         u8      power_mgnt;
96         u8      ips_mode;
97         u8      smart_ps;
98         u8      long_retry_lmt;
99         u8      short_retry_lmt;
100         u16     busy_thresh;
101         u8      ack_policy;
102         u8      mp_mode;
103         u8      software_encrypt;
104         u8      software_decrypt;
105         u8      acm_method;
106           /* UAPSD */
107         u8      wmm_enable;
108         u8      uapsd_enable;
109         u8      uapsd_max_sp;
110         u8      uapsd_acbk_en;
111         u8      uapsd_acbe_en;
112         u8      uapsd_acvi_en;
113         u8      uapsd_acvo_en;
114
115         struct wlan_bssid_ex    dev_network;
116
117         u8      ht_enable;
118         u8      cbw40_enable;
119         u8      ampdu_enable;/* for tx */
120         u8      rx_stbc;
121         u8      ampdu_amsdu;/* A-MPDU Supports A-MSDU is permitted */
122         u8      lowrate_two_xmit;
123
124         u8      rf_config;
125         u8      low_power;
126
127         u8      wifi_spec;/*  !turbo_mode */
128
129         u8      channel_plan;
130         bool    bAcceptAddbaReq;
131
132         u8      antdiv_cfg;
133         u8      antdiv_type;
134
135         u8      usbss_enable;/* 0:disable,1:enable */
136         u8      hwpdn_mode;/* 0:disable,1:enable,2:decide by EFUSE config */
137         u8      hwpwrp_detect;/* 0:disable,1:enable */
138
139         u8      hw_wps_pbc;/* 0:disable,1:enable */
140
141         u8      max_roaming_times; /*  the max number driver will try */
142
143         u8      fw_iol; /* enable iol without other concern */
144
145         u8      enable80211d;
146
147         u8      ifname[16];
148         u8      if2name[16];
149
150         u8      notch_filter;
151 };
152
153 /* For registry parameters */
154 #define RGTRY_OFT(field) ((u32)FIELD_OFFSET(struct registry_priv, field))
155 #define RGTRY_SZ(field)   sizeof(((struct registry_priv *)0)->field)
156 #define BSSID_OFT(field) ((u32)FIELD_OFFSET(struct wlan_bssid_ex, field))
157 #define BSSID_SZ(field)   sizeof(((struct wlan_bssid_ex *)0)->field)
158
159 #define MAX_CONTINUAL_URB_ERR           4
160
161 struct rt_firmware {
162         u8                      *szFwBuffer;
163         u32                     ulFwLength;
164 };
165
166 struct dvobj_priv {
167         struct adapter *if1;
168         struct adapter *if2;
169         struct rt_firmware firmware;
170
171         /* For 92D, DMDP have 2 interface. */
172         u8      InterfaceNumber;
173         u8      NumInterfaces;
174
175         /* In /Out Pipe information */
176         int     RtInPipe[2];
177         int     RtOutPipe[3];
178         u8      Queue2Pipe[HW_QUEUE_ENTRY];/* for out pipe mapping */
179
180         u8      irq_alloc;
181
182 /*-------- below is for USB INTERFACE --------*/
183
184         u8      nr_endpoint;
185         u8      ishighspeed;
186         u8      RtNumInPipes;
187         u8      RtNumOutPipes;
188         int     ep_num[5]; /* endpoint number */
189         int     RegUsbSS;
190         struct semaphore usb_suspend_sema;
191         struct mutex  usb_vendor_req_mutex;
192
193         u8 *usb_alloc_vendor_req_buf;
194         u8 *usb_vendor_req_buf;
195
196         struct usb_interface *pusbintf;
197         struct usb_device *pusbdev;
198
199         atomic_t continual_urb_error;
200 };
201
202 static inline struct device *dvobj_to_dev(struct dvobj_priv *dvobj)
203 {
204         /* todo: get interface type from dvobj and the return
205          * the dev accordingly */
206         return &dvobj->pusbintf->dev;
207 };
208
209 enum _IFACE_TYPE {
210         IFACE_PORT0, /* mapping to port0 for C/D series chips */
211         IFACE_PORT1, /* mapping to port1 for C/D series chip */
212         MAX_IFACE_PORT,
213 };
214
215 enum _ADAPTER_TYPE {
216         PRIMARY_ADAPTER,
217         SECONDARY_ADAPTER,
218         MAX_ADAPTER,
219 };
220
221 enum driver_state {
222         DRIVER_NORMAL = 0,
223         DRIVER_DISAPPEAR = 1,
224         DRIVER_REPLACE_DONGLE = 2,
225 };
226
227 struct adapter {
228         int     DriverState;/* for disable driver using module, use dongle toi
229                              * replace module. */
230         int     pid[3];/* process id from UI, 0:wps, 1:hostapd, 2:dhcpcd */
231         int     bDongle;/* build-in module or external dongle */
232         u16     chip_type;
233
234         struct dvobj_priv *dvobj;
235         struct  mlme_priv mlmepriv;
236         struct  mlme_ext_priv mlmeextpriv;
237         struct  cmd_priv        cmdpriv;
238         struct  evt_priv        evtpriv;
239         struct  io_priv iopriv;
240         struct  xmit_priv       xmitpriv;
241         struct  recv_priv       recvpriv;
242         struct  sta_priv        stapriv;
243         struct  security_priv   securitypriv;
244         struct  registry_priv   registrypriv;
245         struct  pwrctrl_priv    pwrctrlpriv;
246         struct  eeprom_priv eeprompriv;
247         struct  led_priv        ledpriv;
248         struct  mp_priv mppriv;
249
250 #ifdef CONFIG_88EU_AP_MODE
251         struct  hostapd_priv    *phostapdpriv;
252 #endif
253
254         struct wifidirect_info  wdinfo;
255
256         void *HalData;
257         u32 hal_data_sz;
258         struct hal_ops  HalFunc;
259
260         s32     bDriverStopped;
261         s32     bSurpriseRemoved;
262         s32     bCardDisableWOHSM;
263
264         u32     IsrContent;
265         u32     ImrContent;
266
267         u8      EepromAddressSize;
268         u8      hw_init_completed;
269         u8      bDriverIsGoingToUnload;
270         u8      init_adpt_in_progress;
271         u8      bHaltInProgress;
272
273         void *cmdThread;
274         void *evtThread;
275         void *xmitThread;
276         void *recvThread;
277         void (*intf_start)(struct adapter *adapter);
278         void (*intf_stop)(struct adapter *adapter);
279         struct  net_device *pnetdev;
280
281         /*  used by rtw_rereg_nd_name related function */
282         struct rereg_nd_name_data {
283                 struct  net_device *old_pnetdev;
284                 char old_ifname[IFNAMSIZ];
285                 u8 old_ips_mode;
286                 u8 old_bRegUseLed;
287         } rereg_nd_name_priv;
288
289         int bup;
290         struct net_device_stats stats;
291         struct iw_statistics iwstats;
292         struct proc_dir_entry *dir_dev;/*  for proc directory */
293
294         int net_closed;
295         u8 bFWReady;
296         u8 bBTFWReady;
297         u8 bReadPortCancel;
298         u8 bWritePortCancel;
299         u8 bRxRSSIDisplay;
300         /* The driver will show up the desired channel number
301          * when this flag is 1. */
302         u8 bNotifyChannelChange;
303 #ifdef CONFIG_88EU_P2P
304         /* The driver will show the current P2P status when the
305          * upper application reads it. */
306         u8 bShowGetP2PState;
307 #endif
308         struct adapter *pbuddy_adapter;
309
310         struct mutex *hw_init_mutex;
311
312         spinlock_t br_ext_lock;
313         struct nat25_network_db_entry   *nethash[NAT25_HASH_SIZE];
314         int                             pppoe_connection_in_progress;
315         unsigned char                   pppoe_addr[MACADDRLEN];
316         unsigned char                   scdb_mac[MACADDRLEN];
317         unsigned char                   scdb_ip[4];
318         struct nat25_network_db_entry   *scdb_entry;
319         unsigned char                   br_mac[MACADDRLEN];
320         unsigned char                   br_ip[4];
321         struct br_ext_info              ethBrExtInfo;
322
323         u8      fix_rate;
324
325         unsigned char     in_cta_test;
326 };
327
328 #define adapter_to_dvobj(adapter) (adapter->dvobj)
329
330 int rtw_handle_dualmac(struct adapter *adapter, bool init);
331
332 static inline u8 *myid(struct eeprom_priv *peepriv)
333 {
334         return peepriv->mac_addr;
335 }
336
337 #endif /* __DRV_TYPES_H__ */