2 * This file contains definitions and data structures specific
3 * to Marvell 802.11 NIC. It contains the Device Information
4 * structure struct lbs_private..
6 #ifndef _RDA5890_DEV_H_
7 #define _RDA5890_DEV_H_
8 #include <linux/netdevice.h>
9 #include <linux/wireless.h>
10 #include <linux/ethtool.h>
11 #include <linux/delay.h>
12 #include <linux/debugfs.h>
13 #include <linux/wakelock.h>
14 #include "rda5890_defs.h"
15 //#include "hif_sdio.h"
18 #ifndef MAX_WPA_IE_LEN
19 #define MAX_WPA_IE_LEN 100
26 #define DEV_NAME_LEN 32
28 #define RDA5890_MAX_NETWORK_NUM 32
30 /** RSSI related MACRO DEFINITIONS */
31 #define RDA5890_NF_DEFAULT_SCAN_VALUE (-96)
32 #define PERFECT_RSSI ((u8)50)
33 #define WORST_RSSI ((u8)0)
34 #define RSSI_DIFF ((u8)(PERFECT_RSSI - WORST_RSSI))
36 /** RTS/FRAG related defines */
37 #define RDA5890_RTS_MIN_VALUE 0
38 #define RDA5890_RTS_MAX_VALUE 2347
39 #define RDA5890_FRAG_MIN_VALUE 256
40 #define RDA5890_FRAG_MAX_VALUE 2346
42 #define KEY_LEN_WPA_AES 16
43 #define KEY_LEN_WPA_TKIP 32
44 #define KEY_LEN_WEP_104 13
45 #define KEY_LEN_WEP_40 5
56 #define RDA_SLEEP_ENABLE BIT0
57 #define RDA_SLEEP_PREASSO BIT1
59 //#define WIFI_UNIT_TEST
70 WID_REQUEST_POLLING_PACKET,
74 /** KEY_INFO_WPA (applies to both TKIP and AES/CCMP) */
76 KEY_INFO_WPA_MCAST = 0x01,
77 KEY_INFO_WPA_UNICAST = 0x02,
78 KEY_INFO_WPA_ENABLED = 0x04
81 /* RDA5890 defined bss descriptor, 44 bytes for each bss */
82 struct rda5890_bss_descriptor {
83 u8 ssid[IW_ESSID_MAX_SIZE + 1];
91 } __attribute__ ((packed));
94 * @brief Structure used to store information for each beacon/probe response
96 struct bss_descriptor {
97 struct rda5890_bss_descriptor data;
101 u8 ssid[IW_ESSID_MAX_SIZE + 1];
109 /* IW_MODE_AUTO, IW_MODE_ADHOC, IW_MODE_INFRA */
112 /* zero-terminated array of supported data rates */
113 u8 rates[MAX_RATES + 1];
114 u8 wpa_ie[MAX_WPA_IE_LEN];
116 u8 rsn_ie[MAX_WPA_IE_LEN];
120 size_t wapi_ie_len; //wapi valid payload length
122 unsigned long last_scanned;
125 struct list_head list;
128 /* Generic structure to hold all key types. */
131 u16 flags; /* KEY_INFO_* from defs.h */
132 u16 type; /* KEY_TYPE_* from defs.h */
136 struct rda5890_802_11_security {
145 /** Private structure for the rda5890 device */
146 struct rda5890_private {
147 char name[DEV_NAME_LEN];
150 struct net_device *dev;
152 struct net_device_stats stats;
154 /** current ssid/bssid related parameters and status */
156 struct rda5890_bss_descriptor curbssparams;
157 struct iw_statistics wstats;
159 /** association flags */
160 unsigned char assoc_ssid[IW_ESSID_MAX_SIZE + 1];
161 unsigned char assoc_bssid[6];
162 unsigned char assoc_ssid_len;
163 #define ASSOC_FLAG_SSID 1
164 #define ASSOC_FLAG_CHANNEL 2
165 #define ASSOC_FLAG_BAND 3
166 #define ASSOC_FLAG_MODE 4
167 #define ASSOC_FLAG_BSSID 5
168 #define ASSOC_FLAG_WEP_KEYS 6
169 #define ASSOC_FLAG_WEP_TX_KEYIDX 7
170 #define ASSOC_FLAG_WPA_MCAST_KEY 8
171 #define ASSOC_FLAG_WPA_UCAST_KEY 9
172 #define ASSOC_FLAG_SECINFO 10
173 #define ASSOC_FLAG_WPA_IE 11
174 #define ASSOC_FLAG_ASSOC_RETRY 12
175 #define ASSOC_FLAG_ASSOC_START 13
176 #define ASSOC_FLAG_WLAN_CONNECTING 14
178 unsigned long assoc_flags;
180 unsigned char authtype;
183 struct dentry *debugfs_dir;
184 struct dentry *debugfs_files[6];
186 /** for wid request and response */
187 struct mutex wid_lock;
188 struct completion wid_done;
191 unsigned short wid_rsp_len;
194 /** delayed worker */
195 struct workqueue_struct *work_thread;
196 struct delayed_work scan_work;
197 struct delayed_work assoc_work;
198 struct delayed_work assoc_done_work;
199 struct delayed_work wlan_connect_work;
201 /** Hardware access */
202 int (*hw_host_to_card) (struct rda5890_private *priv, u8 *payload, u16 nb,
203 unsigned char packet_type);
205 /** Scan results list */
207 struct list_head network_list;
208 struct list_head network_free_list;
209 struct bss_descriptor *networks;
211 /** Encryption parameter */
212 struct rda5890_802_11_security secinfo;
215 struct enc_key wep_keys[4];
219 struct enc_key wpa_mcast_key;
220 struct enc_key wpa_unicast_key;
222 /** WPA Information Elements*/
223 u8 wpa_ie[MAX_WPA_IE_LEN];
227 /** sleep/awake flag */
228 #ifdef WIFI_POWER_MANAGER
235 extern int rda5890_sleep_flags;
237 #ifdef WIFI_TEST_MODE
238 extern unsigned char rda_5990_wifi_in_test_mode(void);
241 #ifdef WIFI_UNLOCK_SYSTEM
242 extern atomic_t wake_lock_counter;
243 extern struct wake_lock sleep_worker_wake_lock;
244 extern void rda5990_wakeLock(void);
245 extern void rda5990_wakeUnlock(void);
246 extern void rda5990_wakeLock_destroy(void);
249 struct rda5890_private *rda5890_add_card(void *card);
250 void rda5890_remove_card(struct rda5890_private *priv);
251 int rda5890_start_card(struct rda5890_private *priv);
252 void rda5890_stop_card(struct rda5890_private *priv);
253 int rda5890_sdio_core_wake_mode(struct rda5890_private *priv);
254 int rda5890_sdio_core_sleep_mode(struct rda5890_private *priv);
255 int rda5890_sdio_core_wake_mode_polling(struct rda5890_private *priv);
257 void rda5890_sdio_set_notch_by_channel(struct rda5890_private *priv, unsigned int channel);
258 void rda5890_rssi_up_to_200(struct rda5890_private *priv);
259 void rda5990_assoc_power_save(struct rda5890_private *priv);
260 unsigned char is_sdio_init_complete(void);
261 unsigned char is_sdio_patch_complete(void);
262 int rda5890_sdio_init(struct rda5890_private *priv);
263 int rda5890_init_pm(struct rda5890_private *priv);
264 void rda5890_shedule_timeout(int msecs);
265 int rda5890_read_mac(char* buf);
266 int rda5890_write_mac(char * buf);
267 int rda5890_disable_block_bt(struct rda5890_private *priv);
268 int rda5890_disable_self_cts(struct rda5890_private *priv);
269 int rda5890_set_active_scan_time(struct rda5890_private *priv);
270 int rda5890_set_test_mode(struct rda5890_private *priv);
271 int rda5890_get_fw_version_polling(struct rda5890_private *priv, unsigned int* version);