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 <rtw_xmit.h>
42 #include <rtw_recv.h>
43 #include <hal_intf.h>
44 #include <hal_com.h>
45 #include <rtw_security.h>
46 #include <rtw_pwrctrl.h>
47 #include <rtw_io.h>
48 #include <rtw_eeprom.h>
49 #include <sta_info.h>
50 #include <rtw_mlme.h>
51 #include <rtw_debug.h>
52 #include <rtw_rf.h>
53 #include <rtw_event.h>
54 #include <rtw_led.h>
55 #include <rtw_mlme_ext.h>
56 #include <rtw_ap.h>
57
58 #include "ioctl_cfg80211.h"
59
60 struct registry_priv {
61 u8 chip_version;
62 u8 rfintfs;
63 struct cfg80211_ssid ssid;
64 u8 channel;/* ad-hoc support requirement */
65 u8 wireless_mode;/* A, B, G, auto */
66 u8 scan_mode;/* active, passive */
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 software_encrypt;
82 u8 software_decrypt;
83 u8 acm_method;
84 /* UAPSD */
85 u8 wmm_enable;
86 u8 uapsd_enable;
87
88 struct wlan_bssid_ex dev_network;
89
90 u8 ht_enable;
91 u8 cbw40_enable;
92 u8 ampdu_enable;/* for tx */
93 u8 rx_stbc;
94 u8 ampdu_amsdu;/* A-MPDU Supports A-MSDU is permitted */
95 u8 lowrate_two_xmit;
96
97 u8 rf_config;
98 u8 low_power;
99
100 u8 wifi_spec;/* !turbo_mode */
101
102 u8 channel_plan;
103 #ifdef CONFIG_8723AU_BT_COEXIST
104 u8 btcoex;
105 u8 bt_iso;
106 u8 bt_sco;
107 u8 bt_ampdu;
108 #endif
109 bool bAcceptAddbaReq;
110
111 u8 antdiv_cfg;
112 u8 antdiv_type;
113
114 u8 hwpdn_mode;/* 0:disable,1:enable,2:decide by EFUSE config */
115 u8 hwpwrp_detect;/* 0:disable,1:enable */
116
117 u8 hw_wps_pbc;/* 0:disable,1:enable */
118
119 u8 max_roaming_times; /* max number driver will try to roaming */
120
121 u8 enable80211d;
122
123 u8 ifname[16];
124 u8 if2name[16];
125
126 u8 notch_filter;
127
128 u8 regulatory_tid;
129 };
130
131
132 #define MAX_CONTINUAL_URB_ERR 4
133
134 #define GET_PRIMARY_ADAPTER(padapter) \
135 (((struct rtw_adapter *)padapter)->dvobj->if1)
136
137 enum _IFACE_ID {
138 IFACE_ID0, /* maping to PRIMARY_ADAPTER */
139 IFACE_ID1, /* maping to SECONDARY_ADAPTER */
140 IFACE_ID2,
141 IFACE_ID3,
142 IFACE_ID_MAX,
143 };
144
145 struct dvobj_priv {
146 struct rtw_adapter *if1; /* PRIMARY_ADAPTER */
147 struct rtw_adapter *if2; /* SECONDARY_ADAPTER */
148
149 /* for local/global synchronization */
150 struct mutex hw_init_mutex;
151 struct mutex h2c_fwcmd_mutex;
152 struct mutex setch_mutex;
153 struct mutex setbw_mutex;
154
155 unsigned char oper_channel; /* saved chan info when set chan bw */
156 unsigned char oper_bwmode;
157 unsigned char oper_ch_offset;/* PRIME_CHNL_OFFSET */
158
159 struct rtw_adapter *padapters[IFACE_ID_MAX];
160 u8 iface_nums; /* total number of ifaces used runtime */
161
162 /* For 92D, DMDP have 2 interface. */
163 u8 InterfaceNumber;
164 u8 NumInterfaces;
165
166 /* In /Out Pipe information */
167 int RtInPipe[2];
168 int RtOutPipe[3];
169 u8 Queue2Pipe[HW_QUEUE_ENTRY];/* for out pipe mapping */
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
179 struct mutex usb_vendor_req_mutex;
180
181 union {
182 __le32 val32;
183 __le16 val16;
184 u8 val8;
185 } usb_buf;
186
187 struct usb_interface *pusbintf;
188 struct usb_device *pusbdev;
189 atomic_t continual_urb_error;
190
191 /*-------- below is for PCIE INTERFACE --------*/
192
193 };
194
dvobj_to_dev(struct dvobj_priv * dvobj)195 static inline struct device *dvobj_to_dev(struct dvobj_priv *dvobj)
196 {
197 /* todo: get interface type from dvobj and the return the dev accordingly */
198 return &dvobj->pusbintf->dev;
199 }
200
201 enum _IFACE_TYPE {
202 IFACE_PORT0, /* mapping to port0 for C/D series chips */
203 IFACE_PORT1, /* mapping to port1 for C/D series chip */
204 MAX_IFACE_PORT,
205 };
206
207 enum _ADAPTER_TYPE {
208 PRIMARY_ADAPTER,
209 SECONDARY_ADAPTER,
210 MAX_ADAPTER,
211 };
212
213 struct rtw_adapter {
214 int pid[3];/* process id from UI, 0:wps, 1:hostapd, 2:dhcpcd */
215 int bDongle;/* build-in module or external dongle */
216 u16 chip_type;
217 u16 HardwareType;
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 xmit_priv xmitpriv;
225 struct recv_priv recvpriv;
226 struct sta_priv stapriv;
227 struct security_priv securitypriv;
228 struct registry_priv registrypriv;
229 struct pwrctrl_priv pwrctrlpriv;
230 struct eeprom_priv eeprompriv;
231 struct led_priv ledpriv;
232
233 u32 setband;
234
235 void *HalData;
236
237 s32 bDriverStopped;
238 s32 bSurpriseRemoved;
239 s32 bCardDisableWOHSM;
240
241 u32 IsrContent;
242 u32 ImrContent;
243
244 u8 EepromAddressSize;
245 u8 hw_init_completed;
246 u8 bDriverIsGoingToUnload;
247 u8 init_adpt_in_progress;
248 u8 bHaltInProgress;
249
250 struct net_device *pnetdev;
251
252 /* used by rtw_rereg_nd_name related function */
253 int bup;
254 struct net_device_stats stats;
255
256 struct wireless_dev *rtw_wdev;
257 int net_closed;
258
259 u8 bFWReady;
260 u8 bReadPortCancel;
261 u8 bWritePortCancel;
262
263 /* extend to support multi interface */
264 /* IFACE_ID0 is equals to PRIMARY_ADAPTER */
265 /* IFACE_ID1 is equals to SECONDARY_ADAPTER */
266 u8 iface_id;
267 };
268
269 #define adapter_to_dvobj(adapter) (adapter->dvobj)
270
myid(struct eeprom_priv * peepriv)271 static inline u8 *myid(struct eeprom_priv *peepriv)
272 {
273 return peepriv->mac_addr;
274 }
275
276 #endif /* __DRV_TYPES_H__ */
277