blob: 6875e1498bd57e36f54e826c763bb041a9bd3283 [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 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;
Holger Schurig5e047692009-10-22 15:30:49 +0200113 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 */
Stefani Seibold45465482009-12-21 14:37:26 -0800122 struct kfifo event_fifo;
Holger Schurig7919b892008-04-01 14:50:43 +0200123
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 uint16_t enablehwauto;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200179
Holger Schurig5e047692009-10-22 15:30:49 +0200180 /* ADHOC */
181 u16 beacon_period;
182 u8 beacon_enable;
183 u8 adhoccreate;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200184
Holger Schurig5e047692009-10-22 15:30:49 +0200185 /* WEXT */
186 char name[DEV_NAME_LEN];
187 u8 nodename[16];
188 struct iw_statistics wstats;
189 u8 cur_rate;
190#define MAX_REGION_CHANNEL_NUM 2
191 struct region_channel region_channel[MAX_REGION_CHANNEL_NUM];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200192
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200193 /** Requested Signal Strength*/
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200194 u16 SNR[MAX_TYPE_B][MAX_TYPE_AVG];
195 u16 NF[MAX_TYPE_B][MAX_TYPE_AVG];
196 u8 RSSI[MAX_TYPE_B][MAX_TYPE_AVG];
197 u8 rawSNR[DEFAULT_DATA_AVG_FACTOR];
198 u8 rawNF[DEFAULT_DATA_AVG_FACTOR];
199 u16 nextSNRNF;
200 u16 numSNRNF;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200201};
202
Holger Schurigf539f2e2008-03-26 13:22:11 +0100203extern struct cmd_confirm_sleep confirm_sleep;
204
Holger Schurig10078322007-11-15 18:05:47 -0500205#endif