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