blob: 05bb298dfae9a017be7458c8055d961e289e5de6 [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;
Holger Schurig5e047692009-10-22 15:30:49 +020039
40 /* Mesh */
41 struct net_device *mesh_dev; /* Virtual device */
42 u32 mesh_connect_status;
43 struct lbs_mesh_stats mstats;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020044 int mesh_open;
Bing Zhao684d6b32009-03-25 09:51:16 -070045 int mesh_fw_ver;
Luis Carlos Cobod21b31f2007-08-02 13:16:02 -040046 int mesh_autostart_enabled;
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;
50 struct work_struct sync_channel;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020051
Holger Schurig5e047692009-10-22 15:30:49 +020052 /* Monitor mode */
Luis Carlos Cobo965f8bbc2007-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 Karwar49125452009-09-30 20:04:38 -070078 int is_auto_deep_sleep_enabled;
Amitkumar Karwar49125452009-09-30 20:04:38 -070079 int wakeup_dev_required;
Amitkumar Karwar49125452009-09-30 20:04:38 -070080 int is_activity_detected;
Holger Schurig5e047692009-10-22 15:30:49 +020081 int auto_deep_sleep_timeout; /* in ms */
82 wait_queue_head_t ds_awake_q;
83 struct timer_list auto_deepsleep_timer;
Amitkumar Karwar49125452009-09-30 20:04:38 -070084
Holger Schurig5e047692009-10-22 15:30:49 +020085 /* Hardware access */
86 void *card;
87 u8 fw_ready;
88 u8 surpriseremoved;
Holger Schurig69f90322007-11-23 15:43:44 +010089 int (*hw_host_to_card) (struct lbs_private *priv, u8 type, u8 *payload, u16 nb);
David Woodhouseedf5dab2008-05-20 16:43:31 +010090 void (*reset_card) (struct lbs_private *priv);
Amitkumar Karwar49125452009-09-30 20:04:38 -070091 int (*enter_deep_sleep) (struct lbs_private *priv);
92 int (*exit_deep_sleep) (struct lbs_private *priv);
93 int (*reset_deep_sleep_wakeup) (struct lbs_private *priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020094
Holger Schurig5e047692009-10-22 15:30:49 +020095 /* Adapter info (from EEPROM) */
Holger Schurigdac10a92008-01-16 15:55:22 +010096 u32 fwrelease;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020097 u32 fwcapinfo;
Holger Schurig5e047692009-10-22 15:30:49 +020098 u16 regioncode;
99 u8 current_addr[ETH_ALEN];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200100
Holger Schurig5e047692009-10-22 15:30:49 +0200101 /* Command download */
102 u8 dnld_sent;
103 /* bit0 1/0=data_sent/data_tx_done,
104 bit1 1/0=cmd_sent/cmd_tx_done,
105 all other bits reserved 0 */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200106 u16 seqnum;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200107 struct cmd_ctrl_node *cmd_array;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200108 struct cmd_ctrl_node *cur_cmd;
Holger Schurig5e047692009-10-22 15:30:49 +0200109 struct list_head cmdfreeq; /* free command buffers */
110 struct list_head cmdpendingq; /* pending command buffers */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200111 wait_queue_head_t cmd_pending;
Holger Schurig5e047692009-10-22 15:30:49 +0200112 struct timer_list command_timer;
113 int nr_retries;
114 int cmd_timed_out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200115
Holger Schurig7919b892008-04-01 14:50:43 +0200116 /* Command responses sent from the hardware to the driver */
Holger Schurig5e047692009-10-22 15:30:49 +0200117 int cur_cmd_retcode;
Holger Schurig7919b892008-04-01 14:50:43 +0200118 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 */
131 struct lbs_802_11_security secinfo;
132 struct enc_key wpa_mcast_key;
133 struct enc_key wpa_unicast_key;
134 u8 wpa_ie[MAX_WPA_IE_LEN];
135 u8 wpa_ie_len;
136 u16 wep_tx_keyidx;
137 struct enc_key wep_keys[4];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200138
Holger Schurig5e047692009-10-22 15:30:49 +0200139 /* Wake On LAN */
140 uint32_t wol_criteria;
141 uint8_t wol_gpio;
142 uint8_t wol_gap;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200143
Holger Schurig5e047692009-10-22 15:30:49 +0200144 /* Transmitting */
145 int tx_pending_len; /* -1 while building packet */
146 u8 tx_pending_buf[LBS_UPLD_SIZE];
147 /* protected by hard_start_xmit serialization */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200148 u8 txretrycount;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200149 struct sk_buff *currenttxskb;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200150
Holger Schurig5e047692009-10-22 15:30:49 +0200151 /* Locks */
152 struct mutex lock;
153 spinlock_t driver_lock;
154
155 /* NIC/link operation characteristics */
Holger Schurigd9e97782008-03-12 16:06:43 +0100156 u16 mac_control;
Holger Schurig5e047692009-10-22 15:30:49 +0200157 u8 radio_on;
Holger Schurigc14951f2009-10-22 15:30:50 +0200158 u8 channel;
Dan Williams87c8c722008-08-19 15:15:35 -0400159 s16 txpower_cur;
160 s16 txpower_min;
161 s16 txpower_max;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200162
Holger Schurig5e047692009-10-22 15:30:49 +0200163 /** Scanning */
164 struct delayed_work scan_work;
165 int scan_channel;
166 /* remember which channel was scanned last, != 0 if currently scanning */
167 u8 scan_ssid[IEEE80211_MAX_SSID_LEN + 1];
168 u8 scan_ssid_len;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200169
Holger Schurig5e047692009-10-22 15:30:49 +0200170 /* Associating */
171 struct delayed_work assoc_work;
172 struct current_bss_params curbssparams;
173 u8 mode;
174 struct list_head network_list;
175 struct list_head network_free_list;
176 struct bss_descriptor *networks;
Dan Williamse76850d2007-05-25 17:09:41 -0400177 struct assoc_request * pending_assoc_req;
178 struct assoc_request * in_progress_assoc_req;
Holger Schurig5e047692009-10-22 15:30:49 +0200179 u16 capability;
180 uint16_t enablehwauto;
181 uint16_t ratebitmap;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200182
Holger Schurig5e047692009-10-22 15:30:49 +0200183 /* ADHOC */
184 u16 beacon_period;
185 u8 beacon_enable;
186 u8 adhoccreate;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200187
Holger Schurig5e047692009-10-22 15:30:49 +0200188 /* WEXT */
189 char name[DEV_NAME_LEN];
190 u8 nodename[16];
191 struct iw_statistics wstats;
192 u8 cur_rate;
193#define MAX_REGION_CHANNEL_NUM 2
194 struct region_channel region_channel[MAX_REGION_CHANNEL_NUM];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200195
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200196 /** Requested Signal Strength*/
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200197 u16 SNR[MAX_TYPE_B][MAX_TYPE_AVG];
198 u16 NF[MAX_TYPE_B][MAX_TYPE_AVG];
199 u8 RSSI[MAX_TYPE_B][MAX_TYPE_AVG];
200 u8 rawSNR[DEFAULT_DATA_AVG_FACTOR];
201 u8 rawNF[DEFAULT_DATA_AVG_FACTOR];
202 u16 nextSNRNF;
203 u16 numSNRNF;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200204};
205
Holger Schurigf539f2e2008-03-26 13:22:11 +0100206extern struct cmd_confirm_sleep confirm_sleep;
207
Holger Schurig10078322007-11-15 18:05:47 -0500208#endif