blob: 7330ab8521cc8da1136a95025fcef1d7d1203ba0 [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
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020013
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 */
Holger Schurig4143a232009-12-02 15:26:02 +010042#ifdef CONFIG_LIBERTAS_MESH
Holger Schurig5e047692009-10-22 15:30:49 +020043 u32 mesh_connect_status;
44 struct lbs_mesh_stats mstats;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020045 int mesh_open;
Holger Schurig5e047692009-10-22 15:30:49 +020046 uint16_t mesh_tlv;
47 u8 mesh_ssid[IEEE80211_MAX_SSID_LEN + 1];
48 u8 mesh_ssid_len;
Holger Schurig4143a232009-12-02 15:26:02 +010049#endif
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020050
Holger Schurig5e047692009-10-22 15:30:49 +020051 /* Monitor mode */
Luis Carlos Cobo965f8bb2007-08-02 13:16:55 -040052 struct net_device *rtap_net_dev;
Holger Schurig5e047692009-10-22 15:30:49 +020053 u32 monitormode;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020054
Holger Schurig5e047692009-10-22 15:30:49 +020055 /* Debugfs */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020056 struct dentry *debugfs_dir;
57 struct dentry *debugfs_debug;
58 struct dentry *debugfs_files[6];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020059 struct dentry *events_dir;
60 struct dentry *debugfs_events_files[6];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020061 struct dentry *regs_dir;
62 struct dentry *debugfs_regs_files[6];
63
Holger Schurig5e047692009-10-22 15:30:49 +020064 /* Hardware debugging */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020065 u32 mac_offset;
66 u32 bbp_offset;
67 u32 rf_offset;
Holger Schurig5e047692009-10-22 15:30:49 +020068 struct lbs_offset_value offsetvalue;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020069
Holger Schurig5e047692009-10-22 15:30:49 +020070 /* Power management */
71 u16 psmode;
72 u32 psstate;
73 u8 needtowakeup;
74
75 /* Deep sleep */
Amitkumar Karwar49125452009-09-30 20:04:38 -070076 int is_deep_sleep;
Amitkumar Karwar49125452009-09-30 20:04:38 -070077 int is_auto_deep_sleep_enabled;
Amitkumar Karwar49125452009-09-30 20:04:38 -070078 int wakeup_dev_required;
Amitkumar Karwar49125452009-09-30 20:04:38 -070079 int is_activity_detected;
Holger Schurig5e047692009-10-22 15:30:49 +020080 int auto_deep_sleep_timeout; /* in ms */
81 wait_queue_head_t ds_awake_q;
82 struct timer_list auto_deepsleep_timer;
Amitkumar Karwar49125452009-09-30 20:04:38 -070083
Holger Schurig5e047692009-10-22 15:30:49 +020084 /* Hardware access */
85 void *card;
86 u8 fw_ready;
87 u8 surpriseremoved;
Holger Schurig69f90322007-11-23 15:43:44 +010088 int (*hw_host_to_card) (struct lbs_private *priv, u8 type, u8 *payload, u16 nb);
David Woodhouseedf5dab2008-05-20 16:43:31 +010089 void (*reset_card) (struct lbs_private *priv);
Amitkumar Karwar49125452009-09-30 20:04:38 -070090 int (*enter_deep_sleep) (struct lbs_private *priv);
91 int (*exit_deep_sleep) (struct lbs_private *priv);
92 int (*reset_deep_sleep_wakeup) (struct lbs_private *priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020093
Holger Schurig5e047692009-10-22 15:30:49 +020094 /* Adapter info (from EEPROM) */
Holger Schurigdac10a92008-01-16 15:55:22 +010095 u32 fwrelease;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020096 u32 fwcapinfo;
Holger Schurig5e047692009-10-22 15:30:49 +020097 u16 regioncode;
98 u8 current_addr[ETH_ALEN];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020099
Holger Schurig5e047692009-10-22 15:30:49 +0200100 /* Command download */
101 u8 dnld_sent;
102 /* bit0 1/0=data_sent/data_tx_done,
103 bit1 1/0=cmd_sent/cmd_tx_done,
104 all other bits reserved 0 */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200105 u16 seqnum;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200106 struct cmd_ctrl_node *cmd_array;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200107 struct cmd_ctrl_node *cur_cmd;
Holger Schurig5e047692009-10-22 15:30:49 +0200108 struct list_head cmdfreeq; /* free command buffers */
109 struct list_head cmdpendingq; /* pending command buffers */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200110 wait_queue_head_t cmd_pending;
Holger Schurig5e047692009-10-22 15:30:49 +0200111 struct timer_list command_timer;
112 int nr_retries;
113 int cmd_timed_out;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200114
Holger Schurig7919b892008-04-01 14:50:43 +0200115 /* Command responses sent from the hardware to the driver */
Holger Schurig5e047692009-10-22 15:30:49 +0200116 int cur_cmd_retcode;
Holger Schurig7919b892008-04-01 14:50:43 +0200117 u8 resp_idx;
118 u8 resp_buf[2][LBS_UPLD_SIZE];
119 u32 resp_len[2];
120
121 /* Events sent from hardware to driver */
122 struct kfifo *event_fifo;
123
Holger Schurig5e047692009-10-22 15:30:49 +0200124 /** thread to service interrupts */
125 struct task_struct *main_thread;
126 wait_queue_head_t waitq;
127 struct workqueue_struct *work_thread;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200128
Holger Schurig5e047692009-10-22 15:30:49 +0200129 /** Encryption stuff */
130 struct lbs_802_11_security secinfo;
131 struct enc_key wpa_mcast_key;
132 struct enc_key wpa_unicast_key;
133 u8 wpa_ie[MAX_WPA_IE_LEN];
134 u8 wpa_ie_len;
135 u16 wep_tx_keyidx;
136 struct enc_key wep_keys[4];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200137
Holger Schurig5e047692009-10-22 15:30:49 +0200138 /* Wake On LAN */
139 uint32_t wol_criteria;
140 uint8_t wol_gpio;
141 uint8_t wol_gap;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200142
Holger Schurig5e047692009-10-22 15:30:49 +0200143 /* Transmitting */
144 int tx_pending_len; /* -1 while building packet */
145 u8 tx_pending_buf[LBS_UPLD_SIZE];
146 /* protected by hard_start_xmit serialization */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200147 u8 txretrycount;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200148 struct sk_buff *currenttxskb;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200149
Holger Schurig5e047692009-10-22 15:30:49 +0200150 /* Locks */
151 struct mutex lock;
152 spinlock_t driver_lock;
153
154 /* NIC/link operation characteristics */
Holger Schurigd9e97782008-03-12 16:06:43 +0100155 u16 mac_control;
Holger Schurig5e047692009-10-22 15:30:49 +0200156 u8 radio_on;
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;
165 /* remember which channel was scanned last, != 0 if currently scanning */
166 u8 scan_ssid[IEEE80211_MAX_SSID_LEN + 1];
167 u8 scan_ssid_len;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200168
Holger Schurig5e047692009-10-22 15:30:49 +0200169 /* Associating */
170 struct delayed_work assoc_work;
171 struct current_bss_params curbssparams;
172 u8 mode;
173 struct list_head network_list;
174 struct list_head network_free_list;
175 struct bss_descriptor *networks;
Dan Williamse76850d2007-05-25 17:09:41 -0400176 struct assoc_request * pending_assoc_req;
177 struct assoc_request * in_progress_assoc_req;
Holger Schurig5e047692009-10-22 15:30:49 +0200178 u16 capability;
179 uint16_t enablehwauto;
180 uint16_t ratebitmap;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200181
Holger Schurig5e047692009-10-22 15:30:49 +0200182 /* ADHOC */
183 u16 beacon_period;
184 u8 beacon_enable;
185 u8 adhoccreate;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200186
Holger Schurig5e047692009-10-22 15:30:49 +0200187 /* WEXT */
188 char name[DEV_NAME_LEN];
189 u8 nodename[16];
190 struct iw_statistics wstats;
191 u8 cur_rate;
192#define MAX_REGION_CHANNEL_NUM 2
193 struct region_channel region_channel[MAX_REGION_CHANNEL_NUM];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200194
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200195 /** Requested Signal Strength*/
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200196 u16 SNR[MAX_TYPE_B][MAX_TYPE_AVG];
197 u16 NF[MAX_TYPE_B][MAX_TYPE_AVG];
198 u8 RSSI[MAX_TYPE_B][MAX_TYPE_AVG];
199 u8 rawSNR[DEFAULT_DATA_AVG_FACTOR];
200 u8 rawNF[DEFAULT_DATA_AVG_FACTOR];
201 u16 nextSNRNF;
202 u16 numSNRNF;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200203};
204
Holger Schurigf539f2e2008-03-26 13:22:11 +0100205extern struct cmd_confirm_sleep confirm_sleep;
206
Holger Schurig10078322007-11-15 18:05:47 -0500207#endif