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