blob: 71c5ad46ebf6a5ca8627f52bb31a92e62811feb0 [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 Schurig5e8e8b52009-11-25 13:09:32 +01009#include "mesh.h"
Holger Schurig2d465022009-10-22 15:30:48 +020010#include "scan.h"
11#include "assoc.h"
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020012
Stefani Seibold45465482009-12-21 14:37:26 -080013#include <linux/kfifo.h>
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020014
15/** sleep_params */
16struct sleep_params {
David Woodhouse3fbe1042007-12-17 23:48:31 -050017 uint16_t sp_error;
18 uint16_t sp_offset;
19 uint16_t sp_stabletime;
20 uint8_t sp_calcontrol;
21 uint8_t sp_extsleepclk;
22 uint16_t sp_reserved;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020023};
24
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020025
26/** Private structure for the MV device */
Holger Schurig69f90322007-11-23 15:43:44 +010027struct lbs_private {
Holger Schurig5e047692009-10-22 15:30:49 +020028
29 /* Basic networking */
30 struct net_device *dev;
31 u32 connect_status;
32 int infra_open;
33 struct work_struct mcast_work;
34 u32 nr_of_multicastmacaddr;
35 u8 multicastlist[MRVDRV_MAX_MULTICAST_LIST_SIZE][ETH_ALEN];
36
37 /* CFG80211 */
Holger Schurigff9fc792009-10-06 16:31:54 +020038 struct wireless_dev *wdev;
Daniel Mack73714002010-03-29 17:14:18 +020039 bool wiphy_registered;
Holger Schurig5e047692009-10-22 15:30:49 +020040
41 /* Mesh */
42 struct net_device *mesh_dev; /* Virtual device */
Holger Schurig4143a232009-12-02 15:26:02 +010043#ifdef CONFIG_LIBERTAS_MESH
Holger Schurig5e047692009-10-22 15:30:49 +020044 u32 mesh_connect_status;
45 struct lbs_mesh_stats mstats;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020046 int mesh_open;
Holger Schurig5e047692009-10-22 15:30:49 +020047 uint16_t mesh_tlv;
48 u8 mesh_ssid[IEEE80211_MAX_SSID_LEN + 1];
49 u8 mesh_ssid_len;
Holger Schurig4143a232009-12-02 15:26:02 +010050#endif
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020051
Holger Schurig5e047692009-10-22 15:30:49 +020052 /* Monitor mode */
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -040053 struct net_device *rtap_net_dev;
Holger Schurig5e047692009-10-22 15:30:49 +020054 u32 monitormode;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020055
Holger Schurig5e047692009-10-22 15:30:49 +020056 /* Debugfs */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020057 struct dentry *debugfs_dir;
58 struct dentry *debugfs_debug;
59 struct dentry *debugfs_files[6];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020060 struct dentry *events_dir;
61 struct dentry *debugfs_events_files[6];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020062 struct dentry *regs_dir;
63 struct dentry *debugfs_regs_files[6];
64
Holger Schurig5e047692009-10-22 15:30:49 +020065 /* Hardware debugging */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020066 u32 mac_offset;
67 u32 bbp_offset;
68 u32 rf_offset;
Holger Schurig5e047692009-10-22 15:30:49 +020069 struct lbs_offset_value offsetvalue;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020070
Holger Schurig5e047692009-10-22 15:30:49 +020071 /* Power management */
72 u16 psmode;
73 u32 psstate;
74 u8 needtowakeup;
75
76 /* Deep sleep */
Amitkumar Karwar49125452009-09-30 20:04:38 -070077 int is_deep_sleep;
Amitkumar Karwar66fceb62010-05-19 03:24:38 -070078 int deep_sleep_required;
Amitkumar Karwar49125452009-09-30 20:04:38 -070079 int is_auto_deep_sleep_enabled;
Amitkumar Karwar49125452009-09-30 20:04:38 -070080 int wakeup_dev_required;
Amitkumar Karwar49125452009-09-30 20:04:38 -070081 int is_activity_detected;
Holger Schurig5e047692009-10-22 15:30:49 +020082 int auto_deep_sleep_timeout; /* in ms */
83 wait_queue_head_t ds_awake_q;
84 struct timer_list auto_deepsleep_timer;
Amitkumar Karwar49125452009-09-30 20:04:38 -070085
Amitkumar Karwar66fceb62010-05-19 03:24:38 -070086 /* Host sleep*/
87 int is_host_sleep_configured;
88 int is_host_sleep_activated;
89 wait_queue_head_t host_sleep_q;
90
Holger Schurig5e047692009-10-22 15:30:49 +020091 /* Hardware access */
92 void *card;
93 u8 fw_ready;
94 u8 surpriseremoved;
Holger Schurig69f90322007-11-23 15:43:44 +010095 int (*hw_host_to_card) (struct lbs_private *priv, u8 type, u8 *payload, u16 nb);
David Woodhouseedf5dab2008-05-20 16:43:31 +010096 void (*reset_card) (struct lbs_private *priv);
Amitkumar Karwar49125452009-09-30 20:04:38 -070097 int (*enter_deep_sleep) (struct lbs_private *priv);
98 int (*exit_deep_sleep) (struct lbs_private *priv);
99 int (*reset_deep_sleep_wakeup) (struct lbs_private *priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200100
Holger Schurig5e047692009-10-22 15:30:49 +0200101 /* Adapter info (from EEPROM) */
Holger Schurigdac10a92008-01-16 15:55:22 +0100102 u32 fwrelease;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200103 u32 fwcapinfo;
Holger Schurig5e047692009-10-22 15:30:49 +0200104 u16 regioncode;
105 u8 current_addr[ETH_ALEN];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200106
Holger Schurig5e047692009-10-22 15:30:49 +0200107 /* Command download */
108 u8 dnld_sent;
109 /* bit0 1/0=data_sent/data_tx_done,
110 bit1 1/0=cmd_sent/cmd_tx_done,
111 all other bits reserved 0 */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200112 u16 seqnum;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200113 struct cmd_ctrl_node *cmd_array;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200114 struct cmd_ctrl_node *cur_cmd;
Holger Schurig5e047692009-10-22 15:30:49 +0200115 struct list_head cmdfreeq; /* free command buffers */
116 struct list_head cmdpendingq; /* pending command buffers */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200117 wait_queue_head_t cmd_pending;
Holger Schurig5e047692009-10-22 15:30:49 +0200118 struct timer_list command_timer;
Holger Schurig5e047692009-10-22 15:30:49 +0200119 int cmd_timed_out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200120
Holger Schurig7919b892008-04-01 14:50:43 +0200121 /* Command responses sent from the hardware to the driver */
Holger Schurig5e047692009-10-22 15:30:49 +0200122 int cur_cmd_retcode;
Holger Schurig7919b892008-04-01 14:50:43 +0200123 u8 resp_idx;
124 u8 resp_buf[2][LBS_UPLD_SIZE];
125 u32 resp_len[2];
126
127 /* Events sent from hardware to driver */
Stefani Seibold45465482009-12-21 14:37:26 -0800128 struct kfifo event_fifo;
Holger Schurig7919b892008-04-01 14:50:43 +0200129
Holger Schurig5e047692009-10-22 15:30:49 +0200130 /** thread to service interrupts */
131 struct task_struct *main_thread;
132 wait_queue_head_t waitq;
133 struct workqueue_struct *work_thread;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200134
Holger Schurig5e047692009-10-22 15:30:49 +0200135 /** Encryption stuff */
136 struct lbs_802_11_security secinfo;
137 struct enc_key wpa_mcast_key;
138 struct enc_key wpa_unicast_key;
139 u8 wpa_ie[MAX_WPA_IE_LEN];
140 u8 wpa_ie_len;
141 u16 wep_tx_keyidx;
142 struct enc_key wep_keys[4];
Amitkumar Karwar921ca032010-02-25 17:16:36 -0800143 u8 authtype_auto;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200144
Holger Schurig5e047692009-10-22 15:30:49 +0200145 /* Wake On LAN */
146 uint32_t wol_criteria;
147 uint8_t wol_gpio;
148 uint8_t wol_gap;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200149
Holger Schurig5e047692009-10-22 15:30:49 +0200150 /* Transmitting */
151 int tx_pending_len; /* -1 while building packet */
152 u8 tx_pending_buf[LBS_UPLD_SIZE];
153 /* protected by hard_start_xmit serialization */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200154 u8 txretrycount;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200155 struct sk_buff *currenttxskb;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200156
Holger Schurig5e047692009-10-22 15:30:49 +0200157 /* Locks */
158 struct mutex lock;
159 spinlock_t driver_lock;
160
161 /* NIC/link operation characteristics */
Holger Schurigd9e97782008-03-12 16:06:43 +0100162 u16 mac_control;
Holger Schurig5e047692009-10-22 15:30:49 +0200163 u8 radio_on;
Holger Schurigc14951f2009-10-22 15:30:50 +0200164 u8 channel;
Dan Williams87c8c722008-08-19 15:15:35 -0400165 s16 txpower_cur;
166 s16 txpower_min;
167 s16 txpower_max;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200168
Holger Schurig5e047692009-10-22 15:30:49 +0200169 /** Scanning */
170 struct delayed_work scan_work;
171 int scan_channel;
172 /* remember which channel was scanned last, != 0 if currently scanning */
173 u8 scan_ssid[IEEE80211_MAX_SSID_LEN + 1];
174 u8 scan_ssid_len;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200175
Holger Schurig5e047692009-10-22 15:30:49 +0200176 /* Associating */
177 struct delayed_work assoc_work;
178 struct current_bss_params curbssparams;
179 u8 mode;
180 struct list_head network_list;
181 struct list_head network_free_list;
182 struct bss_descriptor *networks;
Dan Williamse76850d2007-05-25 17:09:41 -0400183 struct assoc_request * pending_assoc_req;
184 struct assoc_request * in_progress_assoc_req;
Holger Schurig5e047692009-10-22 15:30:49 +0200185 uint16_t enablehwauto;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200186
Holger Schurig5e047692009-10-22 15:30:49 +0200187 /* ADHOC */
188 u16 beacon_period;
189 u8 beacon_enable;
190 u8 adhoccreate;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200191
Holger Schurig5e047692009-10-22 15:30:49 +0200192 /* WEXT */
193 char name[DEV_NAME_LEN];
194 u8 nodename[16];
195 struct iw_statistics wstats;
196 u8 cur_rate;
197#define MAX_REGION_CHANNEL_NUM 2
198 struct region_channel region_channel[MAX_REGION_CHANNEL_NUM];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200199
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200200 /** Requested Signal Strength*/
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200201 u16 SNR[MAX_TYPE_B][MAX_TYPE_AVG];
202 u16 NF[MAX_TYPE_B][MAX_TYPE_AVG];
203 u8 RSSI[MAX_TYPE_B][MAX_TYPE_AVG];
204 u8 rawSNR[DEFAULT_DATA_AVG_FACTOR];
205 u8 rawNF[DEFAULT_DATA_AVG_FACTOR];
206 u16 nextSNRNF;
207 u16 numSNRNF;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200208};
209
Holger Schurigf539f2e2008-03-26 13:22:11 +0100210extern struct cmd_confirm_sleep confirm_sleep;
211
Holger Schurig10078322007-11-15 18:05:47 -0500212#endif