1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2010 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  * Modifications for inclusion into the Linux staging tree are
19  * Copyright(c) 2010 Larry Finger. All rights reserved.
20  *
21  * Contact information:
22  * WLAN FAE <wlanfae@realtek.com>
23  * Larry Finger <Larry.Finger@lwfinger.net>
24  *
25  ******************************************************************************/
26 /*---------------------------------------------------------------------
27 
28 	For type defines and data structure defines
29 
30 -----------------------------------------------------------------------*/
31 #ifndef __DRV_TYPES_H__
32 #define __DRV_TYPES_H__
33 
34 struct _adapter;
35 
36 #include "osdep_service.h"
37 #include "wlan_bssdef.h"
38 #include "rtl8712_spec.h"
39 #include "rtl8712_hal.h"
40 #include <linux/mutex.h>
41 #include <linux/completion.h>
42 
43 enum _NIC_VERSION {
44 	RTL8711_NIC,
45 	RTL8712_NIC,
46 	RTL8713_NIC,
47 	RTL8716_NIC
48 };
49 
50 struct _adapter;
51 
52 struct	qos_priv	{
53 	/* bit mask option: u-apsd, s-apsd, ts, block ack... */
54 	unsigned int qos_option;
55 };
56 
57 #include "rtl871x_ht.h"
58 #include "rtl871x_cmd.h"
59 #include "rtl871x_xmit.h"
60 #include "rtl871x_recv.h"
61 #include "rtl871x_security.h"
62 #include "rtl871x_pwrctrl.h"
63 #include "rtl871x_io.h"
64 #include "rtl871x_eeprom.h"
65 #include "sta_info.h"
66 #include "rtl871x_mlme.h"
67 #include "rtl871x_mp.h"
68 #include "rtl871x_debug.h"
69 #include "rtl871x_rf.h"
70 #include "rtl871x_event.h"
71 #include "rtl871x_led.h"
72 
73 #define SPEC_DEV_ID_NONE BIT(0)
74 #define SPEC_DEV_ID_DISABLE_HT BIT(1)
75 #define SPEC_DEV_ID_ENABLE_PS BIT(2)
76 
77 struct specific_device_id {
78 	u32		flags;
79 	u16		idVendor;
80 	u16		idProduct;
81 
82 };
83 
84 struct registry_priv {
85 	u8	chip_version;
86 	u8	rfintfs;
87 	u8	lbkmode;
88 	u8	hci;
89 	u8	network_mode;	/*infra, ad-hoc, auto*/
90 	struct ndis_802_11_ssid	ssid;
91 	u8	channel;/* ad-hoc support requirement */
92 	u8	wireless_mode;/* A, B, G, auto */
93 	u8	vrtl_carrier_sense; /*Enable, Disable, Auto*/
94 	u8	vcs_type;/*RTS/CTS, CTS-to-self*/
95 	u16	rts_thresh;
96 	u16  frag_thresh;
97 	u8	preamble;/*long, short, auto*/
98 	u8  scan_mode;/*active, passive*/
99 	u8  adhoc_tx_pwr;
100 	u8  soft_ap;
101 	u8  smart_ps;
102 	u8 power_mgnt;
103 	u8 radio_enable;
104 	u8 long_retry_lmt;
105 	u8 short_retry_lmt;
106 	u16 busy_thresh;
107 	u8 ack_policy;
108 	u8 mp_mode;
109 	u8 software_encrypt;
110 	u8 software_decrypt;
111 	/* UAPSD */
112 	u8 wmm_enable;
113 	u8 uapsd_enable;
114 	u8 uapsd_max_sp;
115 	u8 uapsd_acbk_en;
116 	u8 uapsd_acbe_en;
117 	u8 uapsd_acvi_en;
118 	u8 uapsd_acvo_en;
119 
120 	struct wlan_bssid_ex dev_network;
121 
122 	u8 ht_enable;
123 	u8 cbw40_enable;
124 	u8 ampdu_enable;/*for tx*/
125 	u8 rf_config;
126 	u8 low_power;
127 	u8 wifi_test;
128 };
129 
130 /* For registry parameters */
131 #define RGTRY_OFT(field) ((addr_t)FIELD_OFFSET(struct registry_priv, field))
132 #define RGTRY_SZ(field)   sizeof(((struct registry_priv *)0)->field)
133 #define BSSID_OFT(field) ((addr_t)FIELD_OFFSET(struct ndis_wlan_bssid_ex, \
134 			 field))
135 #define BSSID_SZ(field)   sizeof(((struct ndis_wlan_bssid_ex *)0)->field)
136 
137 struct dvobj_priv {
138 	struct _adapter *padapter;
139 	u32 nr_endpoint;
140 	u8   ishighspeed;
141 	uint(*inirp_init)(struct _adapter *adapter);
142 	uint(*inirp_deinit)(struct _adapter *adapter);
143 	struct usb_device *pusbdev;
144 };
145 
146 /**
147  * struct _adapter - the main adapter structure for this device.
148  *
149  * bup: True indicates that the interface is Up.
150  */
151 struct _adapter {
152 	struct	dvobj_priv dvobjpriv;
153 	struct	mlme_priv mlmepriv;
154 	struct	cmd_priv	cmdpriv;
155 	struct	evt_priv	evtpriv;
156 	struct	io_queue	*pio_queue;
157 	struct	xmit_priv	xmitpriv;
158 	struct	recv_priv	recvpriv;
159 	struct	sta_priv	stapriv;
160 	struct	security_priv	securitypriv;
161 	struct	registry_priv	registrypriv;
162 	struct	wlan_acl_pool	acl_list;
163 	struct	pwrctrl_priv	pwrctrlpriv;
164 	struct	eeprom_priv eeprompriv;
165 	struct	hal_priv	halpriv;
166 	struct	led_priv	ledpriv;
167 	struct mp_priv  mppriv;
168 	s32	bDriverStopped;
169 	s32	bSurpriseRemoved;
170 	u32	IsrContent;
171 	u32	ImrContent;
172 	bool	fw_found;
173 	u8	EepromAddressSize;
174 	u8	hw_init_completed;
175 	struct task_struct *cmdThread;
176 	 pid_t evtThread;
177 	struct task_struct *xmitThread;
178 	pid_t recvThread;
179 	uint(*dvobj_init)(struct _adapter *adapter);
180 	void  (*dvobj_deinit)(struct _adapter *adapter);
181 	struct net_device *pnetdev;
182 	int bup;
183 	struct net_device_stats stats;
184 	struct iw_statistics iwstats;
185 	int pid; /*process id from UI*/
186 	_workitem wkFilterRxFF0;
187 	u8 blnEnableRxFF0Filter;
188 	spinlock_t lockRxFF0Filter;
189 	const struct firmware *fw;
190 	struct usb_interface *pusb_intf;
191 	struct mutex mutex_start;
192 	struct completion rtl8712_fw_ready;
193 };
194 
myid(struct eeprom_priv * peepriv)195 static inline u8 *myid(struct eeprom_priv *peepriv)
196 {
197 	return peepriv->mac_addr;
198 }
199 
200 u8 r8712_usb_hal_bus_init(struct _adapter *adapter);
201 
202 #endif /*__DRV_TYPES_H__*/
203 
204