blob: 60996ce89f778932e0fa7270e6154e1ad86c03d0 [file] [log] [blame]
Randy Dunlap8973a6e2011-04-26 15:25:29 -07001/*
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..
5 */
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
Kiran Divekare86dc1c2010-06-14 22:01:26 +05309#include "defs.h"
Daniel Drake534111c2012-04-16 23:53:26 +010010#include "decl.h"
Kiran Divekare86dc1c2010-06-14 22:01:26 +053011#include "host.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
Randy Dunlap8973a6e2011-04-26 15:25:29 -070015/* sleep_params */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020016struct 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
Daniel Drake49fee692011-07-21 20:43:17 +010025/* Mesh statistics */
26struct lbs_mesh_stats {
27 u32 fwd_bcast_cnt; /* Fwd: Broadcast counter */
28 u32 fwd_unicast_cnt; /* Fwd: Unicast counter */
29 u32 fwd_drop_ttl; /* Fwd: TTL zero */
30 u32 fwd_drop_rbt; /* Fwd: Recently Broadcasted */
31 u32 fwd_drop_noroute; /* Fwd: No route to Destination */
32 u32 fwd_drop_nobuf; /* Fwd: Run out of internal buffers */
33 u32 drop_blind; /* Rx: Dropped by blinding table */
34 u32 tx_failed_cnt; /* Tx: Failed transmissions */
35};
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020036
Randy Dunlap8973a6e2011-04-26 15:25:29 -070037/* Private structure for the MV device */
Holger Schurig69f90322007-11-23 15:43:44 +010038struct lbs_private {
Holger Schurig5e047692009-10-22 15:30:49 +020039
40 /* Basic networking */
41 struct net_device *dev;
42 u32 connect_status;
Holger Schurig5e047692009-10-22 15:30:49 +020043 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;
Daniel Mack73714002010-03-29 17:14:18 +020049 bool wiphy_registered;
Kiran Divekare86dc1c2010-06-14 22:01:26 +053050 struct cfg80211_scan_request *scan_req;
51 u8 assoc_bss[ETH_ALEN];
52 u8 disassoc_reason;
Holger Schurig5e047692009-10-22 15:30:49 +020053
54 /* Mesh */
55 struct net_device *mesh_dev; /* Virtual device */
Holger Schurig4143a232009-12-02 15:26:02 +010056#ifdef CONFIG_LIBERTAS_MESH
Holger Schurig5e047692009-10-22 15:30:49 +020057 struct lbs_mesh_stats mstats;
Holger Schurig5e047692009-10-22 15:30:49 +020058 uint16_t mesh_tlv;
59 u8 mesh_ssid[IEEE80211_MAX_SSID_LEN + 1];
60 u8 mesh_ssid_len;
Johannes Berge8c9bd52012-06-06 08:18:22 +020061 u8 mesh_channel;
Holger Schurig4143a232009-12-02 15:26:02 +010062#endif
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020063
Holger Schurig5e047692009-10-22 15:30:49 +020064 /* Debugfs */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020065 struct dentry *debugfs_dir;
66 struct dentry *debugfs_debug;
67 struct dentry *debugfs_files[6];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020068 struct dentry *events_dir;
69 struct dentry *debugfs_events_files[6];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020070 struct dentry *regs_dir;
71 struct dentry *debugfs_regs_files[6];
72
Holger Schurig5e047692009-10-22 15:30:49 +020073 /* Hardware debugging */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020074 u32 mac_offset;
75 u32 bbp_offset;
76 u32 rf_offset;
77
Holger Schurig5e047692009-10-22 15:30:49 +020078 /* Power management */
79 u16 psmode;
80 u32 psstate;
81 u8 needtowakeup;
82
83 /* Deep sleep */
Amitkumar Karwar49125452009-09-30 20:04:38 -070084 int is_deep_sleep;
Amitkumar Karwar66fceb62010-05-19 03:24:38 -070085 int deep_sleep_required;
Amitkumar Karwar49125452009-09-30 20:04:38 -070086 int is_auto_deep_sleep_enabled;
Amitkumar Karwar49125452009-09-30 20:04:38 -070087 int wakeup_dev_required;
Amitkumar Karwar49125452009-09-30 20:04:38 -070088 int is_activity_detected;
Holger Schurig5e047692009-10-22 15:30:49 +020089 int auto_deep_sleep_timeout; /* in ms */
90 wait_queue_head_t ds_awake_q;
91 struct timer_list auto_deepsleep_timer;
Amitkumar Karwar49125452009-09-30 20:04:38 -070092
Amitkumar Karwar66fceb62010-05-19 03:24:38 -070093 /* Host sleep*/
94 int is_host_sleep_configured;
95 int is_host_sleep_activated;
96 wait_queue_head_t host_sleep_q;
97
Holger Schurig5e047692009-10-22 15:30:49 +020098 /* Hardware access */
99 void *card;
Daniel Draked2e7b342011-08-01 16:43:13 +0100100 bool iface_running;
Holger Schurig5e047692009-10-22 15:30:49 +0200101 u8 fw_ready;
102 u8 surpriseremoved;
Vasily Khoruzhick75abde42011-01-21 22:44:49 +0200103 u8 setup_fw_on_resume;
Holger Schurig69f90322007-11-23 15:43:44 +0100104 int (*hw_host_to_card) (struct lbs_private *priv, u8 type, u8 *payload, u16 nb);
David Woodhouseedf5dab2008-05-20 16:43:31 +0100105 void (*reset_card) (struct lbs_private *priv);
Daniel Draked2e7b342011-08-01 16:43:13 +0100106 int (*power_save) (struct lbs_private *priv);
107 int (*power_restore) (struct lbs_private *priv);
Amitkumar Karwar49125452009-09-30 20:04:38 -0700108 int (*enter_deep_sleep) (struct lbs_private *priv);
109 int (*exit_deep_sleep) (struct lbs_private *priv);
110 int (*reset_deep_sleep_wakeup) (struct lbs_private *priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200111
Holger Schurig5e047692009-10-22 15:30:49 +0200112 /* Adapter info (from EEPROM) */
Holger Schurigdac10a92008-01-16 15:55:22 +0100113 u32 fwrelease;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200114 u32 fwcapinfo;
Holger Schurig5e047692009-10-22 15:30:49 +0200115 u16 regioncode;
116 u8 current_addr[ETH_ALEN];
Vasily Khoruzhick75abde42011-01-21 22:44:49 +0200117 u8 copied_hwaddr;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200118
Holger Schurig5e047692009-10-22 15:30:49 +0200119 /* Command download */
120 u8 dnld_sent;
121 /* bit0 1/0=data_sent/data_tx_done,
122 bit1 1/0=cmd_sent/cmd_tx_done,
123 all other bits reserved 0 */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200124 u16 seqnum;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200125 struct cmd_ctrl_node *cmd_array;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200126 struct cmd_ctrl_node *cur_cmd;
Holger Schurig5e047692009-10-22 15:30:49 +0200127 struct list_head cmdfreeq; /* free command buffers */
128 struct list_head cmdpendingq; /* pending command buffers */
Holger Schurig5e047692009-10-22 15:30:49 +0200129 struct timer_list command_timer;
Holger Schurig5e047692009-10-22 15:30:49 +0200130 int cmd_timed_out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200131
Holger Schurig7919b892008-04-01 14:50:43 +0200132 /* Command responses sent from the hardware to the driver */
133 u8 resp_idx;
134 u8 resp_buf[2][LBS_UPLD_SIZE];
135 u32 resp_len[2];
136
137 /* Events sent from hardware to driver */
Stefani Seibold45465482009-12-21 14:37:26 -0800138 struct kfifo event_fifo;
Holger Schurig7919b892008-04-01 14:50:43 +0200139
Randy Dunlap8973a6e2011-04-26 15:25:29 -0700140 /* thread to service interrupts */
Holger Schurig5e047692009-10-22 15:30:49 +0200141 struct task_struct *main_thread;
142 wait_queue_head_t waitq;
143 struct workqueue_struct *work_thread;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200144
Randy Dunlap8973a6e2011-04-26 15:25:29 -0700145 /* Encryption stuff */
Amitkumar Karwar921ca032010-02-25 17:16:36 -0800146 u8 authtype_auto;
Kiran Divekare86dc1c2010-06-14 22:01:26 +0530147 u8 wep_tx_key;
148 u8 wep_key[4][WLAN_KEY_LEN_WEP104];
149 u8 wep_key_len[4];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200150
Holger Schurig5e047692009-10-22 15:30:49 +0200151 /* Wake On LAN */
152 uint32_t wol_criteria;
153 uint8_t wol_gpio;
154 uint8_t wol_gap;
Deepak Saxenaae63a332010-10-31 13:40:33 +0000155 bool ehs_remove_supported;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200156
Holger Schurig5e047692009-10-22 15:30:49 +0200157 /* Transmitting */
158 int tx_pending_len; /* -1 while building packet */
159 u8 tx_pending_buf[LBS_UPLD_SIZE];
160 /* protected by hard_start_xmit serialization */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200161 u8 txretrycount;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200162 struct sk_buff *currenttxskb;
Daniel Drake8f641d92011-10-03 11:33:02 +0100163 struct timer_list tx_lockup_timer;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200164
Holger Schurig5e047692009-10-22 15:30:49 +0200165 /* Locks */
166 struct mutex lock;
167 spinlock_t driver_lock;
168
169 /* NIC/link operation characteristics */
Holger Schurigd9e97782008-03-12 16:06:43 +0100170 u16 mac_control;
Holger Schurig5e047692009-10-22 15:30:49 +0200171 u8 radio_on;
Kiran Divekare86dc1c2010-06-14 22:01:26 +0530172 u8 cur_rate;
Holger Schurigc14951f2009-10-22 15:30:50 +0200173 u8 channel;
Dan Williams87c8c722008-08-19 15:15:35 -0400174 s16 txpower_cur;
175 s16 txpower_min;
176 s16 txpower_max;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200177
Randy Dunlap8973a6e2011-04-26 15:25:29 -0700178 /* Scanning */
Holger Schurig5e047692009-10-22 15:30:49 +0200179 struct delayed_work scan_work;
180 int scan_channel;
Dan Williamscc026812010-08-04 00:43:47 -0500181 /* Queue of things waiting for scan completion */
182 wait_queue_head_t scan_q;
183 /* Whether the scan was initiated internally and not by cfg80211 */
184 bool internal_scan;
Daniel Drake534111c2012-04-16 23:53:26 +0100185
186 /* Firmware load */
187 u32 fw_model;
188 wait_queue_head_t fw_waitq;
189 struct device *fw_device;
190 const struct firmware *helper_fw;
191 const struct lbs_fw_table *fw_table;
192 const struct lbs_fw_table *fw_iter;
193 lbs_fw_cb fw_callback;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200194};
195
Holger Schurigf539f2e2008-03-26 13:22:11 +0100196extern struct cmd_confirm_sleep confirm_sleep;
197
Daniel Draked2e7b342011-08-01 16:43:13 +0100198/* Check if there is an interface active. */
199static inline int lbs_iface_active(struct lbs_private *priv)
200{
201 int r;
202
203 r = netif_running(priv->dev);
Dan Carpenterbfe2ed82011-08-15 14:25:35 +0300204 if (priv->mesh_dev)
205 r |= netif_running(priv->mesh_dev);
Daniel Draked2e7b342011-08-01 16:43:13 +0100206
207 return r;
208}
209
Holger Schurig10078322007-11-15 18:05:47 -0500210#endif