]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/staging/vt6656/device.h
Merge tag 'nfs-for-4.10-1' of git://git.linux-nfs.org/projects/trondmy/linux-nfs
[mirror_ubuntu-artful-kernel.git] / drivers / staging / vt6656 / device.h
CommitLineData
92b96797
FB
1/*
2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
92b96797
FB
15 *
16 * File: device.h
17 *
18 * Purpose: MAC Data structure
19 *
20 * Author: Tevin Chen
21 *
22 * Date: Mar 17, 1997
23 *
24 */
25
26#ifndef __DEVICE_H__
27#define __DEVICE_H__
28
92b96797 29#include <linux/module.h>
92b96797 30#include <linux/kernel.h>
92b96797 31#include <linux/slab.h>
11d404cb
MP
32#include <linux/delay.h>
33#include <linux/device.h>
34#include <linux/firmware.h>
11d404cb 35#include <linux/suspend.h>
92b96797 36#include <linux/if_arp.h>
11d404cb 37#include <linux/wireless.h>
11d404cb 38#include <linux/timer.h>
92b96797 39#include <linux/usb.h>
f0fde117 40#include <linux/crc32.h>
63b9907f 41#include <net/mac80211.h>
11d404cb 42
92b96797
FB
43#ifdef SIOCETHTOOL
44#define DEVICE_ETHTOOL_IOCTL_SUPPORT
45#include <linux/ethtool.h>
46#else
47#undef DEVICE_ETHTOOL_IOCTL_SUPPORT
48#endif
92b96797 49
f07e9fb2
MP
50#define RATE_1M 0
51#define RATE_2M 1
52#define RATE_5M 2
53#define RATE_11M 3
54#define RATE_6M 4
55#define RATE_9M 5
56#define RATE_12M 6
57#define RATE_18M 7
58#define RATE_24M 8
59#define RATE_36M 9
60#define RATE_48M 10
61#define RATE_54M 11
62#define RATE_AUTO 12
63
4aeaf153
MP
64#define MAX_RATE 12
65
d3e23951
AM
66/*
67 * device specific
68 */
92b96797 69
92b96797 70#include "wcmd.h"
92b96797 71#include "desc.h"
92b96797 72#include "key.h"
92b96797 73#include "card.h"
92b96797 74
5008c456 75#define VNT_USB_VENDOR_ID 0x160a
92b96797
FB
76#define VNT_USB_PRODUCT_ID 0x3184
77
4aeaf153
MP
78#define DEVICE_NAME "vt6656"
79#define DEVICE_FULL_DRV_NAM "VIA Networking Wireless LAN USB Driver"
80
feab4810 81#define DEVICE_VERSION "mac80211"
4aeaf153
MP
82
83#define CONFIG_PATH "/etc/vntconfiguration.dat"
84
85#define MAX_UINTS 8
86#define OPTION_DEFAULT { [0 ... MAX_UINTS-1] = -1}
87
92b96797
FB
88#define DUPLICATE_RX_CACHE_LENGTH 5
89
92b96797
FB
90#define AUTO_FB_NONE 0
91#define AUTO_FB_0 1
92#define AUTO_FB_1 2
93
94#define FB_RATE0 0
95#define FB_RATE1 1
96
d3e23951 97/* Antenna Mode */
92b96797
FB
98#define ANT_A 0
99#define ANT_B 1
100#define ANT_DIVERSITY 2
101#define ANT_RXD_TXA 3
102#define ANT_RXD_TXB 4
103#define ANT_UNKNOWN 0xFF
104#define ANT_TXA 0
105#define ANT_TXB 1
106#define ANT_RXA 2
107#define ANT_RXB 3
108
92b96797
FB
109#define BB_VGA_LEVEL 4
110#define BB_VGA_CHANGE_THRESHOLD 3
111
15baf4ff
MP
112#define EEP_MAX_CONTEXT_SIZE 256
113
114/* Contents in the EEPROM */
115#define EEP_OFS_PAR 0x0
116#define EEP_OFS_ANTENNA 0x17
117#define EEP_OFS_RADIOCTL 0x18
118#define EEP_OFS_RFTYPE 0x1b
119#define EEP_OFS_MINCHANNEL 0x1c
120#define EEP_OFS_MAXCHANNEL 0x1d
121#define EEP_OFS_SIGNATURE 0x1e
122#define EEP_OFS_ZONETYPE 0x1f
123#define EEP_OFS_RFTABLE 0x20
124#define EEP_OFS_PWR_CCK 0x20
125#define EEP_OFS_SETPT_CCK 0x21
126#define EEP_OFS_PWR_OFDMG 0x23
127
128#define EEP_OFS_CALIB_TX_IQ 0x24
129#define EEP_OFS_CALIB_TX_DC 0x25
130#define EEP_OFS_CALIB_RX_IQ 0x26
131
132#define EEP_OFS_MAJOR_VER 0x2e
133#define EEP_OFS_MINOR_VER 0x2f
134
135#define EEP_OFS_CCK_PWR_TBL 0x30
136#define EEP_OFS_OFDM_PWR_TBL 0x40
137#define EEP_OFS_OFDMA_PWR_TBL 0x50
138
139/* Bits in EEP_OFS_ANTENNA */
140#define EEP_ANTENNA_MAIN 0x1
141#define EEP_ANTENNA_AUX 0x2
142#define EEP_ANTINV 0x4
143
144/* Bits in EEP_OFS_RADIOCTL */
145#define EEP_RADIOCTL_ENABLE 0x80
146
60f8ce8d
MP
147/* control commands */
148#define MESSAGE_TYPE_READ 0x1
149#define MESSAGE_TYPE_WRITE 0x0
150#define MESSAGE_TYPE_LOCK_OR 0x2
151#define MESSAGE_TYPE_LOCK_AND 0x3
152#define MESSAGE_TYPE_WRITE_MASK 0x4
153#define MESSAGE_TYPE_CARDINIT 0x5
154#define MESSAGE_TYPE_INIT_RSP 0x6
155#define MESSAGE_TYPE_MACSHUTDOWN 0x7
156#define MESSAGE_TYPE_SETKEY 0x8
157#define MESSAGE_TYPE_CLRKEYENTRY 0x9
158#define MESSAGE_TYPE_WRITE_MISCFF 0xa
159#define MESSAGE_TYPE_SET_ANTMD 0xb
733b3b07 160#define MESSAGE_TYPE_SELECT_CHANNEL 0xc
60f8ce8d
MP
161#define MESSAGE_TYPE_SET_TSFTBTT 0xd
162#define MESSAGE_TYPE_SET_SSTIFS 0xe
163#define MESSAGE_TYPE_CHANGE_BBTYPE 0xf
164#define MESSAGE_TYPE_DISABLE_PS 0x10
165#define MESSAGE_TYPE_WRITE_IFRF 0x11
166
167/* command read/write(index) */
168#define MESSAGE_REQUEST_MEM 0x1
169#define MESSAGE_REQUEST_BBREG 0x2
170#define MESSAGE_REQUEST_MACREG 0x3
171#define MESSAGE_REQUEST_EEPROM 0x4
172#define MESSAGE_REQUEST_TSF 0x5
173#define MESSAGE_REQUEST_TBTT 0x6
174#define MESSAGE_REQUEST_BBAGC 0x7
175#define MESSAGE_REQUEST_VERSION 0x8
176#define MESSAGE_REQUEST_RF_INIT 0x9
177#define MESSAGE_REQUEST_RF_INIT2 0xa
178#define MESSAGE_REQUEST_RF_CH0 0xb
179#define MESSAGE_REQUEST_RF_CH1 0xc
180#define MESSAGE_REQUEST_RF_CH2 0xd
181
182/* USB registers */
183#define USB_REG4 0x604
184
302433da
MP
185#define DEVICE_INIT_COLD 0x0 /* cold init */
186#define DEVICE_INIT_RESET 0x1 /* reset init or Dx to D0 power remain */
187#define DEVICE_INIT_DXPL 0x2 /* Dx to D0 power lost init */
92b96797 188
60f8ce8d
MP
189/* Device init */
190struct vnt_cmd_card_init {
191 u8 init_class;
192 u8 exist_sw_net_addr;
193 u8 sw_net_addr[6];
194 u8 short_retry_limit;
195 u8 long_retry_limit;
196};
197
198struct vnt_rsp_card_init {
199 u8 status;
200 u8 net_addr[6];
201 u8 rf_type;
202 u8 min_channel;
203 u8 max_channel;
204};
205
d3e23951 206/* USB */
92b96797 207
d3e23951
AM
208/*
209 * Enum of context types for SendPacket
210 */
1450ba62
MP
211enum {
212 CONTEXT_DATA_PACKET = 1,
d38b13aa
MP
213 CONTEXT_MGMT_PACKET,
214 CONTEXT_BEACON_PACKET
1450ba62 215};
92b96797 216
d3e23951 217/* RCB (Receive Control Block) */
115cac2e 218struct vnt_rcb {
325de984
MP
219 void *priv;
220 struct urb *urb;
dd0a774f 221 struct sk_buff *skb;
325de984 222 int in_use;
115cac2e 223};
92b96797 224
d3e23951 225/* used to track bulk out irps */
dcdf1d03 226struct vnt_usb_send_context {
30a05b39
MP
227 void *priv;
228 struct sk_buff *skb;
229 struct urb *urb;
1622c8fc 230 struct ieee80211_hdr *hdr;
30a05b39 231 unsigned int buf_len;
0f5567cb 232 u32 frame_len;
1622c8fc 233 u16 tx_hdr_size;
798f0601 234 u16 tx_rate;
1450ba62 235 u8 type;
71d764ae 236 u8 pkt_no;
e8c9875c 237 u8 pkt_type;
2eca8dbb 238 u8 need_ack;
71d764ae 239 u8 fb_option;
30a05b39
MP
240 bool in_use;
241 unsigned char data[MAX_TOTAL_SIZE_WITH_ALL_HEADERS];
dcdf1d03 242};
92b96797 243
d3e23951
AM
244/*
245 * Structure to keep track of USB interrupt packets
246 */
f764e00d
MP
247struct vnt_interrupt_buffer {
248 u8 *data_buf;
249 bool in_use;
250};
92b96797 251
d3e23951 252/*++ NDIS related */
92b96797 253
879be45a
PST
254enum {
255 STATUS_SUCCESS = 0,
256 STATUS_FAILURE,
257 STATUS_RESOURCES,
258 STATUS_PENDING,
259};
92b96797 260
d3e23951 261/* flags for options */
e7bda76f
AT
262#define DEVICE_FLAGS_UNPLUG 0
263#define DEVICE_FLAGS_DISCONNECTED 1
92b96797 264
14c5ef57 265struct vnt_private {
63b9907f
MP
266 /* mac80211 */
267 struct ieee80211_hw *hw;
db8f37fa 268 struct ieee80211_vif *vif;
30816f83 269 u8 mac_hw;
61462ab3
MP
270 /* netdev */
271 struct usb_device *usb;
92b96797 272
63b9907f
MP
273 u64 tsf_time;
274 u8 rx_rate;
275
61462ab3 276 u32 rx_buf_sz;
db8f37fa 277 int mc_list_count;
92b96797 278
61462ab3 279 spinlock_t lock;
c91b1869 280 struct mutex usb_lock;
92b96797 281
2746321e 282 unsigned long flags;
92b96797 283
61462ab3 284 /* USB */
3d582487 285 struct urb *interrupt_urb;
61462ab3 286 u32 int_interval;
92b96797 287
61462ab3 288 /* Variables to track resources for the BULK In Pipe */
8577011c 289 struct vnt_rcb *rcb[CB_MAX_RX_DESC];
6da4738f 290 u32 num_rcb;
92b96797 291
61462ab3 292 /* Variables to track resources for the BULK Out Pipe */
f7e4a8f4 293 struct vnt_usb_send_context *tx_context[CB_MAX_TX_DESC];
03b7e354 294 u32 num_tx_context;
92b96797 295
61462ab3 296 /* Variables to track resources for the Interrupt In Pipe */
f764e00d 297 struct vnt_interrupt_buffer int_buf;
92b96797 298
61462ab3 299 /* Version control */
8a73f9da 300 u16 firmware_version;
f1945a15 301 u8 local_id;
6242ecae 302 u8 rf_type;
cd5856ae 303 u8 bb_rx_conf;
92b96797 304
748bf69c
MP
305 struct vnt_cmd_card_init init_command;
306 struct vnt_rsp_card_init init_response;
e2382233
KA
307 u8 current_net_addr[ETH_ALEN] __aligned(2);
308 u8 permanent_net_addr[ETH_ALEN] __aligned(2);
92b96797 309
35cc8f94 310 u8 exist_sw_net_addr;
92b96797 311
113f0b91 312 u64 current_tsf;
61462ab3
MP
313
314 /* 802.11 MAC specific */
125cfc63 315 u32 current_rssi;
61462ab3
MP
316
317 /* Antenna Diversity */
2044dbdb
MP
318 int tx_rx_ant_inv;
319 u32 rx_antenna_sel;
320 u8 rx_antenna_mode;
321 u8 tx_antenna_mode;
322 u8 radio_ctl;
61462ab3 323
cc856e61 324 /* IFS & Cw */
ff5fee22
MP
325 u32 sifs; /* Current SIFS */
326 u32 difs; /* Current DIFS */
327 u32 eifs; /* Current EIFS */
328 u32 slot; /* Current SlotTime */
61462ab3 329
61462ab3 330 /* Rate */
65df77e2 331 u8 bb_type; /* 0: 11A, 1:11B, 2:11G */
e12471db 332 u8 packet_type; /* 0:11a 1:11b 2:11gb 3:11ga */
93a73558 333 u32 basic_rates;
3c8a5b25 334 u8 top_ofdm_basic_rate;
d80bf43c 335 u8 top_cck_basic_rate;
61462ab3 336
bbb11263 337 u8 eeprom[EEP_MAX_CONTEXT_SIZE]; /*u32 alignment */
61462ab3 338
98e93fe5 339 u8 preamble_type;
61462ab3
MP
340
341 /* For RF Power table */
5a97491c
MP
342 u8 cck_pwr;
343 u8 ofdm_pwr_g;
344 u8 ofdm_pwr_a;
345 u8 power;
346 u8 cck_pwr_tbl[14];
347 u8 ofdm_pwr_tbl[14];
348 u8 ofdm_a_pwr_tbl[42];
61462ab3 349
8b84c1da 350 u16 current_rate;
f84cdf65
MP
351 u16 tx_rate_fb0;
352 u16 tx_rate_fb1;
353
388e5cb8
MP
354 u8 short_retry_limit;
355 u8 long_retry_limit;
a0ad2776
MP
356
357 enum nl80211_iftype op_mode;
358
a641c9ec 359 int short_slot_time;
61462ab3 360
61462ab3 361 /* Power save */
db8f37fa 362 u16 current_aid;
61462ab3 363
59082606 364 /* Beacon related */
1b2bc0aa 365 u16 seq_counter;
61462ab3 366
ad74e91d 367 enum vnt_cmd_state command_state;
61462ab3 368
80f0d092 369 enum vnt_cmd command;
61462ab3 370
61462ab3
MP
371 /* 802.11 counter */
372
b595f9b8 373 enum vnt_cmd cmd_queue[CMD_Q_SIZE];
33a60b87
MP
374 u32 cmd_dequeue_idx;
375 u32 cmd_enqueue_idx;
376 u32 free_cmd_queue;
377 int cmd_running;
61462ab3 378
d1eb5003 379 unsigned long key_entry_inuse;
61462ab3 380
a6177aef 381 u8 auto_fb_ctrl;
61462ab3 382
61462ab3 383 /* For Update BaseBand VGA Gain Offset */
c37cbd37 384 u8 bb_vga[BB_VGA_LEVEL];
61462ab3 385
12687222 386 u8 bb_pre_ed_rssi;
43fd1924 387 u8 bb_pre_ed_index;
61462ab3 388
43c93d9b
MP
389 u16 wake_up_count;
390
61462ab3 391 /* command timer */
94488a7e 392 struct delayed_work run_command_work;
92b96797 393
1786384e 394 struct ieee80211_low_level_stats low_stats;
14c5ef57 395};
92b96797 396
dbf0a03b
PST
397#define ADD_ONE_WITH_WRAP_AROUND(uVar, uModulo) { \
398 if ((uVar) >= ((uModulo) - 1)) \
399 (uVar) = 0; \
400 else \
401 (uVar)++; \
92b96797
FB
402}
403
30816f83 404int vnt_init(struct vnt_private *priv);
92b96797
FB
405
406#endif