blob: 27f0f1f2a58a9f8b1ec1f41266fe2f54e42f2cfc [file] [log] [blame]
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001/**
2 * This file contains definitions and data structures specific
3 * to Marvell 802.11 NIC. It contains the Device Information
David Woodhouseaa21c002007-12-08 20:04:36 +00004 * structure struct lbs_private..
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02005 */
Holger Schurig10078322007-11-15 18:05:47 -05006#ifndef _LBS_DEV_H_
7#define _LBS_DEV_H_
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02008
Holger Schurig2d465022009-10-22 15:30:48 +02009#include "scan.h"
10#include "assoc.h"
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020011
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020012
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020013
14/** sleep_params */
15struct sleep_params {
David Woodhouse3fbe1042007-12-17 23:48:31 -050016 uint16_t sp_error;
17 uint16_t sp_offset;
18 uint16_t sp_stabletime;
19 uint8_t sp_calcontrol;
20 uint8_t sp_extsleepclk;
21 uint16_t sp_reserved;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020022};
23
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020024/* Mesh statistics */
Holger Schurig10078322007-11-15 18:05:47 -050025struct lbs_mesh_stats {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020026 u32 fwd_bcast_cnt; /* Fwd: Broadcast counter */
27 u32 fwd_unicast_cnt; /* Fwd: Unicast counter */
28 u32 fwd_drop_ttl; /* Fwd: TTL zero */
29 u32 fwd_drop_rbt; /* Fwd: Recently Broadcasted */
30 u32 fwd_drop_noroute; /* Fwd: No route to Destination */
31 u32 fwd_drop_nobuf; /* Fwd: Run out of internal buffers */
32 u32 drop_blind; /* Rx: Dropped by blinding table */
Javier Cardona0601e7e2007-05-25 12:12:06 -040033 u32 tx_failed_cnt; /* Tx: Failed transmissions */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020034};
35
36/** Private structure for the MV device */
Holger Schurig69f90322007-11-23 15:43:44 +010037struct lbs_private {
Holger Schurig5e047692009-10-22 15:30:49 +020038
39 /* Basic networking */
40 struct net_device *dev;
41 u32 connect_status;
42 int infra_open;
43 struct work_struct mcast_work;
44 u32 nr_of_multicastmacaddr;
45 u8 multicastlist[MRVDRV_MAX_MULTICAST_LIST_SIZE][ETH_ALEN];
46
47 /* CFG80211 */
Holger Schurigff9fc792009-10-06 16:31:54 +020048 struct wireless_dev *wdev;
Holger Schurig5e047692009-10-22 15:30:49 +020049
50 /* Mesh */
51 struct net_device *mesh_dev; /* Virtual device */
52 u32 mesh_connect_status;
53 struct lbs_mesh_stats mstats;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020054 int mesh_open;
Bing Zhao684d6b32009-03-25 09:51:16 -070055 int mesh_fw_ver;
Luis Carlos Cobod21b31f2007-08-02 13:16:02 -040056 int mesh_autostart_enabled;
Holger Schurig5e047692009-10-22 15:30:49 +020057 uint16_t mesh_tlv;
58 u8 mesh_ssid[IEEE80211_MAX_SSID_LEN + 1];
59 u8 mesh_ssid_len;
60 struct work_struct sync_channel;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020061
Holger Schurig5e047692009-10-22 15:30:49 +020062 /* Monitor mode */
Luis Carlos Cobo965f8bbc2007-08-02 13:16:55 -040063 struct net_device *rtap_net_dev;
Holger Schurig5e047692009-10-22 15:30:49 +020064 u32 monitormode;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020065
Holger Schurig5e047692009-10-22 15:30:49 +020066 /* Debugfs */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020067 struct dentry *debugfs_dir;
68 struct dentry *debugfs_debug;
69 struct dentry *debugfs_files[6];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020070 struct dentry *events_dir;
71 struct dentry *debugfs_events_files[6];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020072 struct dentry *regs_dir;
73 struct dentry *debugfs_regs_files[6];
74
Holger Schurig5e047692009-10-22 15:30:49 +020075 /* Hardware debugging */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020076 u32 mac_offset;
77 u32 bbp_offset;
78 u32 rf_offset;
Holger Schurig5e047692009-10-22 15:30:49 +020079 struct lbs_offset_value offsetvalue;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020080
Holger Schurig5e047692009-10-22 15:30:49 +020081 /* Power management */
82 u16 psmode;
83 u32 psstate;
84 u8 needtowakeup;
85
86 /* Deep sleep */
Amitkumar Karwar49125452009-09-30 20:04:38 -070087 int is_deep_sleep;
Amitkumar Karwar49125452009-09-30 20:04:38 -070088 int is_auto_deep_sleep_enabled;
Amitkumar Karwar49125452009-09-30 20:04:38 -070089 int wakeup_dev_required;
Amitkumar Karwar49125452009-09-30 20:04:38 -070090 int is_activity_detected;
Holger Schurig5e047692009-10-22 15:30:49 +020091 int auto_deep_sleep_timeout; /* in ms */
92 wait_queue_head_t ds_awake_q;
93 struct timer_list auto_deepsleep_timer;
Amitkumar Karwar49125452009-09-30 20:04:38 -070094
Holger Schurig5e047692009-10-22 15:30:49 +020095 /* Hardware access */
96 void *card;
97 u8 fw_ready;
98 u8 surpriseremoved;
Holger Schurig69f90322007-11-23 15:43:44 +010099 int (*hw_host_to_card) (struct lbs_private *priv, u8 type, u8 *payload, u16 nb);
David Woodhouseedf5dab2008-05-20 16:43:31 +0100100 void (*reset_card) (struct lbs_private *priv);
Amitkumar Karwar49125452009-09-30 20:04:38 -0700101 int (*enter_deep_sleep) (struct lbs_private *priv);
102 int (*exit_deep_sleep) (struct lbs_private *priv);
103 int (*reset_deep_sleep_wakeup) (struct lbs_private *priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200104
Holger Schurig5e047692009-10-22 15:30:49 +0200105 /* Adapter info (from EEPROM) */
Holger Schurigdac10a92008-01-16 15:55:22 +0100106 u32 fwrelease;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200107 u32 fwcapinfo;
Holger Schurig5e047692009-10-22 15:30:49 +0200108 u16 regioncode;
109 u8 current_addr[ETH_ALEN];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200110
Holger Schurig5e047692009-10-22 15:30:49 +0200111 /* Command download */
112 u8 dnld_sent;
113 /* bit0 1/0=data_sent/data_tx_done,
114 bit1 1/0=cmd_sent/cmd_tx_done,
115 all other bits reserved 0 */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200116 u16 seqnum;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200117 struct cmd_ctrl_node *cmd_array;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200118 struct cmd_ctrl_node *cur_cmd;
Holger Schurig5e047692009-10-22 15:30:49 +0200119 struct list_head cmdfreeq; /* free command buffers */
120 struct list_head cmdpendingq; /* pending command buffers */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200121 wait_queue_head_t cmd_pending;
Holger Schurig5e047692009-10-22 15:30:49 +0200122 struct timer_list command_timer;
123 int nr_retries;
124 int cmd_timed_out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200125
Holger Schurig7919b892008-04-01 14:50:43 +0200126 /* Command responses sent from the hardware to the driver */
Holger Schurig5e047692009-10-22 15:30:49 +0200127 int cur_cmd_retcode;
Holger Schurig7919b892008-04-01 14:50:43 +0200128 u8 resp_idx;
129 u8 resp_buf[2][LBS_UPLD_SIZE];
130 u32 resp_len[2];
131
132 /* Events sent from hardware to driver */
133 struct kfifo *event_fifo;
134
Holger Schurig5e047692009-10-22 15:30:49 +0200135 /** thread to service interrupts */
136 struct task_struct *main_thread;
137 wait_queue_head_t waitq;
138 struct workqueue_struct *work_thread;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200139
Holger Schurig5e047692009-10-22 15:30:49 +0200140 /** Encryption stuff */
141 struct lbs_802_11_security secinfo;
142 struct enc_key wpa_mcast_key;
143 struct enc_key wpa_unicast_key;
144 u8 wpa_ie[MAX_WPA_IE_LEN];
145 u8 wpa_ie_len;
146 u16 wep_tx_keyidx;
147 struct enc_key wep_keys[4];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200148
Holger Schurig5e047692009-10-22 15:30:49 +0200149 /* Wake On LAN */
150 uint32_t wol_criteria;
151 uint8_t wol_gpio;
152 uint8_t wol_gap;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200153
Holger Schurig5e047692009-10-22 15:30:49 +0200154 /* Transmitting */
155 int tx_pending_len; /* -1 while building packet */
156 u8 tx_pending_buf[LBS_UPLD_SIZE];
157 /* protected by hard_start_xmit serialization */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200158 u8 txretrycount;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200159 struct sk_buff *currenttxskb;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200160
Holger Schurig5e047692009-10-22 15:30:49 +0200161 /* Locks */
162 struct mutex lock;
163 spinlock_t driver_lock;
164
165 /* NIC/link operation characteristics */
Holger Schurigd9e97782008-03-12 16:06:43 +0100166 u16 mac_control;
Holger Schurig5e047692009-10-22 15:30:49 +0200167 u8 radio_on;
Dan Williams87c8c722008-08-19 15:15:35 -0400168 s16 txpower_cur;
169 s16 txpower_min;
170 s16 txpower_max;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200171
Holger Schurig5e047692009-10-22 15:30:49 +0200172 /** Scanning */
173 struct delayed_work scan_work;
174 int scan_channel;
175 /* remember which channel was scanned last, != 0 if currently scanning */
176 u8 scan_ssid[IEEE80211_MAX_SSID_LEN + 1];
177 u8 scan_ssid_len;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200178
Holger Schurig5e047692009-10-22 15:30:49 +0200179 /* Associating */
180 struct delayed_work assoc_work;
181 struct current_bss_params curbssparams;
182 u8 mode;
183 struct list_head network_list;
184 struct list_head network_free_list;
185 struct bss_descriptor *networks;
Dan Williamse76850d2007-05-25 17:09:41 -0400186 struct assoc_request * pending_assoc_req;
187 struct assoc_request * in_progress_assoc_req;
Holger Schurig5e047692009-10-22 15:30:49 +0200188 u16 capability;
189 uint16_t enablehwauto;
190 uint16_t ratebitmap;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200191
Holger Schurig5e047692009-10-22 15:30:49 +0200192 /* ADHOC */
193 u16 beacon_period;
194 u8 beacon_enable;
195 u8 adhoccreate;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200196
Holger Schurig5e047692009-10-22 15:30:49 +0200197 /* WEXT */
198 char name[DEV_NAME_LEN];
199 u8 nodename[16];
200 struct iw_statistics wstats;
201 u8 cur_rate;
202#define MAX_REGION_CHANNEL_NUM 2
203 struct region_channel region_channel[MAX_REGION_CHANNEL_NUM];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200204
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200205 /** Requested Signal Strength*/
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200206 u16 SNR[MAX_TYPE_B][MAX_TYPE_AVG];
207 u16 NF[MAX_TYPE_B][MAX_TYPE_AVG];
208 u8 RSSI[MAX_TYPE_B][MAX_TYPE_AVG];
209 u8 rawSNR[DEFAULT_DATA_AVG_FACTOR];
210 u8 rawNF[DEFAULT_DATA_AVG_FACTOR];
211 u16 nextSNRNF;
212 u16 numSNRNF;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200213};
214
Holger Schurigf539f2e2008-03-26 13:22:11 +0100215extern struct cmd_confirm_sleep confirm_sleep;
216
Holger Schurig10078322007-11-15 18:05:47 -0500217#endif