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