blob: f5a9851fc7ee79ca2960172d99d2f3bfe0faba52 [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"
Kiran Divekare86dc1c2010-06-14 22:01:26 +053010#include "defs.h"
11#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
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;
Holger Schurig5e047692009-10-22 15:30:49 +020032 struct work_struct mcast_work;
33 u32 nr_of_multicastmacaddr;
34 u8 multicastlist[MRVDRV_MAX_MULTICAST_LIST_SIZE][ETH_ALEN];
35
36 /* CFG80211 */
Holger Schurigff9fc792009-10-06 16:31:54 +020037 struct wireless_dev *wdev;
Daniel Mack73714002010-03-29 17:14:18 +020038 bool wiphy_registered;
Kiran Divekare86dc1c2010-06-14 22:01:26 +053039 struct cfg80211_scan_request *scan_req;
40 u8 assoc_bss[ETH_ALEN];
41 u8 disassoc_reason;
Holger Schurig5e047692009-10-22 15:30:49 +020042
43 /* Mesh */
44 struct net_device *mesh_dev; /* Virtual device */
Holger Schurig4143a232009-12-02 15:26:02 +010045#ifdef CONFIG_LIBERTAS_MESH
Holger Schurig5e047692009-10-22 15:30:49 +020046 u32 mesh_connect_status;
47 struct lbs_mesh_stats mstats;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020048 int mesh_open;
Holger Schurig5e047692009-10-22 15:30:49 +020049 uint16_t mesh_tlv;
50 u8 mesh_ssid[IEEE80211_MAX_SSID_LEN + 1];
51 u8 mesh_ssid_len;
Holger Schurig4143a232009-12-02 15:26:02 +010052#endif
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020053
Holger Schurig5e047692009-10-22 15:30:49 +020054 /* Debugfs */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020055 struct dentry *debugfs_dir;
56 struct dentry *debugfs_debug;
57 struct dentry *debugfs_files[6];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020058 struct dentry *events_dir;
59 struct dentry *debugfs_events_files[6];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020060 struct dentry *regs_dir;
61 struct dentry *debugfs_regs_files[6];
62
Holger Schurig5e047692009-10-22 15:30:49 +020063 /* Hardware debugging */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020064 u32 mac_offset;
65 u32 bbp_offset;
66 u32 rf_offset;
67
Holger Schurig5e047692009-10-22 15:30:49 +020068 /* Power management */
69 u16 psmode;
70 u32 psstate;
71 u8 needtowakeup;
72
73 /* Deep sleep */
Amitkumar Karwar49125452009-09-30 20:04:38 -070074 int is_deep_sleep;
Amitkumar Karwar66fceb62010-05-19 03:24:38 -070075 int deep_sleep_required;
Amitkumar Karwar49125452009-09-30 20:04:38 -070076 int is_auto_deep_sleep_enabled;
Amitkumar Karwar49125452009-09-30 20:04:38 -070077 int wakeup_dev_required;
Amitkumar Karwar49125452009-09-30 20:04:38 -070078 int is_activity_detected;
Holger Schurig5e047692009-10-22 15:30:49 +020079 int auto_deep_sleep_timeout; /* in ms */
80 wait_queue_head_t ds_awake_q;
81 struct timer_list auto_deepsleep_timer;
Amitkumar Karwar49125452009-09-30 20:04:38 -070082
Amitkumar Karwar66fceb62010-05-19 03:24:38 -070083 /* Host sleep*/
84 int is_host_sleep_configured;
85 int is_host_sleep_activated;
86 wait_queue_head_t host_sleep_q;
87
Holger Schurig5e047692009-10-22 15:30:49 +020088 /* Hardware access */
89 void *card;
90 u8 fw_ready;
91 u8 surpriseremoved;
Holger Schurig69f90322007-11-23 15:43:44 +010092 int (*hw_host_to_card) (struct lbs_private *priv, u8 type, u8 *payload, u16 nb);
David Woodhouseedf5dab2008-05-20 16:43:31 +010093 void (*reset_card) (struct lbs_private *priv);
Amitkumar Karwar49125452009-09-30 20:04:38 -070094 int (*enter_deep_sleep) (struct lbs_private *priv);
95 int (*exit_deep_sleep) (struct lbs_private *priv);
96 int (*reset_deep_sleep_wakeup) (struct lbs_private *priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020097
Holger Schurig5e047692009-10-22 15:30:49 +020098 /* Adapter info (from EEPROM) */
Holger Schurigdac10a92008-01-16 15:55:22 +010099 u32 fwrelease;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200100 u32 fwcapinfo;
Holger Schurig5e047692009-10-22 15:30:49 +0200101 u16 regioncode;
102 u8 current_addr[ETH_ALEN];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200103
Holger Schurig5e047692009-10-22 15:30:49 +0200104 /* Command download */
105 u8 dnld_sent;
106 /* bit0 1/0=data_sent/data_tx_done,
107 bit1 1/0=cmd_sent/cmd_tx_done,
108 all other bits reserved 0 */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200109 u16 seqnum;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200110 struct cmd_ctrl_node *cmd_array;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200111 struct cmd_ctrl_node *cur_cmd;
Holger Schurig5e047692009-10-22 15:30:49 +0200112 struct list_head cmdfreeq; /* free command buffers */
113 struct list_head cmdpendingq; /* pending command buffers */
Holger Schurig5e047692009-10-22 15:30:49 +0200114 struct timer_list command_timer;
Holger Schurig5e047692009-10-22 15:30:49 +0200115 int cmd_timed_out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200116
Holger Schurig7919b892008-04-01 14:50:43 +0200117 /* Command responses sent from the hardware to the driver */
118 u8 resp_idx;
119 u8 resp_buf[2][LBS_UPLD_SIZE];
120 u32 resp_len[2];
121
122 /* Events sent from hardware to driver */
Stefani Seibold45465482009-12-21 14:37:26 -0800123 struct kfifo event_fifo;
Holger Schurig7919b892008-04-01 14:50:43 +0200124
Holger Schurig5e047692009-10-22 15:30:49 +0200125 /** thread to service interrupts */
126 struct task_struct *main_thread;
127 wait_queue_head_t waitq;
128 struct workqueue_struct *work_thread;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200129
Holger Schurig5e047692009-10-22 15:30:49 +0200130 /** Encryption stuff */
Amitkumar Karwar921ca032010-02-25 17:16:36 -0800131 u8 authtype_auto;
Kiran Divekare86dc1c2010-06-14 22:01:26 +0530132 u8 wep_tx_key;
133 u8 wep_key[4][WLAN_KEY_LEN_WEP104];
134 u8 wep_key_len[4];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200135
Holger Schurig5e047692009-10-22 15:30:49 +0200136 /* Wake On LAN */
137 uint32_t wol_criteria;
138 uint8_t wol_gpio;
139 uint8_t wol_gap;
Deepak Saxenaae63a332010-10-31 13:40:33 +0000140 bool ehs_remove_supported;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200141
Holger Schurig5e047692009-10-22 15:30:49 +0200142 /* Transmitting */
143 int tx_pending_len; /* -1 while building packet */
144 u8 tx_pending_buf[LBS_UPLD_SIZE];
145 /* protected by hard_start_xmit serialization */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200146 u8 txretrycount;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200147 struct sk_buff *currenttxskb;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200148
Holger Schurig5e047692009-10-22 15:30:49 +0200149 /* Locks */
150 struct mutex lock;
151 spinlock_t driver_lock;
152
153 /* NIC/link operation characteristics */
Holger Schurigd9e97782008-03-12 16:06:43 +0100154 u16 mac_control;
Holger Schurig5e047692009-10-22 15:30:49 +0200155 u8 radio_on;
Kiran Divekare86dc1c2010-06-14 22:01:26 +0530156 u8 cur_rate;
Holger Schurigc14951f2009-10-22 15:30:50 +0200157 u8 channel;
Dan Williams87c8c722008-08-19 15:15:35 -0400158 s16 txpower_cur;
159 s16 txpower_min;
160 s16 txpower_max;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200161
Holger Schurig5e047692009-10-22 15:30:49 +0200162 /** Scanning */
163 struct delayed_work scan_work;
164 int scan_channel;
Dan Williamscc026812010-08-04 00:43:47 -0500165 /* Queue of things waiting for scan completion */
166 wait_queue_head_t scan_q;
167 /* Whether the scan was initiated internally and not by cfg80211 */
168 bool internal_scan;
169 unsigned long last_scan;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200170};
171
Holger Schurigf539f2e2008-03-26 13:22:11 +0100172extern struct cmd_confirm_sleep confirm_sleep;
173
Holger Schurig10078322007-11-15 18:05:47 -0500174#endif