Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 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 | * |
| 15 | * You should have received a copy of the GNU General Public License along |
| 16 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | * |
| 19 | * File: device.h |
| 20 | * |
| 21 | * Purpose: MAC Data structure |
| 22 | * |
| 23 | * Author: Tevin Chen |
| 24 | * |
| 25 | * Date: Mar 17, 1997 |
| 26 | * |
| 27 | */ |
| 28 | |
| 29 | #ifndef __DEVICE_H__ |
| 30 | #define __DEVICE_H__ |
| 31 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 32 | #include <linux/module.h> |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 33 | #include <linux/kernel.h> |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 34 | #include <linux/slab.h> |
Malcolm Priestley | 11d404c | 2012-11-24 14:19:34 +0000 | [diff] [blame] | 35 | #include <linux/delay.h> |
| 36 | #include <linux/device.h> |
Ben Hutchings | 31d5bbf | 2011-01-09 04:16:48 +0000 | [diff] [blame] | 37 | #include <linux/firmware.h> |
Malcolm Priestley | 11d404c | 2012-11-24 14:19:34 +0000 | [diff] [blame] | 38 | #include <linux/suspend.h> |
| 39 | #include <linux/if_arp.h> |
| 40 | #include <linux/wireless.h> |
Malcolm Priestley | 11d404c | 2012-11-24 14:19:34 +0000 | [diff] [blame] | 41 | #include <linux/timer.h> |
| 42 | #include <linux/usb.h> |
Malcolm Priestley | f0fde11 | 2013-11-03 19:02:41 +0000 | [diff] [blame] | 43 | #include <linux/crc32.h> |
Malcolm Priestley | 63b9907 | 2014-06-25 21:14:22 +0100 | [diff] [blame] | 44 | #include <net/mac80211.h> |
Malcolm Priestley | 11d404c | 2012-11-24 14:19:34 +0000 | [diff] [blame] | 45 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 46 | #ifdef SIOCETHTOOL |
| 47 | #define DEVICE_ETHTOOL_IOCTL_SUPPORT |
| 48 | #include <linux/ethtool.h> |
| 49 | #else |
| 50 | #undef DEVICE_ETHTOOL_IOCTL_SUPPORT |
| 51 | #endif |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 52 | |
Malcolm Priestley | f07e9fb | 2014-06-25 21:14:34 +0100 | [diff] [blame] | 53 | #define RATE_1M 0 |
| 54 | #define RATE_2M 1 |
| 55 | #define RATE_5M 2 |
| 56 | #define RATE_11M 3 |
| 57 | #define RATE_6M 4 |
| 58 | #define RATE_9M 5 |
| 59 | #define RATE_12M 6 |
| 60 | #define RATE_18M 7 |
| 61 | #define RATE_24M 8 |
| 62 | #define RATE_36M 9 |
| 63 | #define RATE_48M 10 |
| 64 | #define RATE_54M 11 |
| 65 | #define RATE_AUTO 12 |
| 66 | |
Malcolm Priestley | 4aeaf15 | 2014-05-17 09:50:24 +0100 | [diff] [blame] | 67 | #define MAX_RATE 12 |
| 68 | |
Andres More | d3e2395 | 2013-01-31 15:57:19 -0500 | [diff] [blame] | 69 | /* |
| 70 | * device specific |
| 71 | */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 72 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 73 | #include "wcmd.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 74 | #include "desc.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 75 | #include "key.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 76 | #include "card.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 77 | |
Otavio Salvador | 5008c45 | 2009-10-12 23:47:36 -0300 | [diff] [blame] | 78 | #define VNT_USB_VENDOR_ID 0x160a |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 79 | #define VNT_USB_PRODUCT_ID 0x3184 |
| 80 | |
Malcolm Priestley | 4aeaf15 | 2014-05-17 09:50:24 +0100 | [diff] [blame] | 81 | #define DEVICE_NAME "vt6656" |
| 82 | #define DEVICE_FULL_DRV_NAM "VIA Networking Wireless LAN USB Driver" |
| 83 | |
| 84 | #define DEVICE_VERSION "1.19_12" |
| 85 | |
| 86 | #define CONFIG_PATH "/etc/vntconfiguration.dat" |
| 87 | |
| 88 | #define MAX_UINTS 8 |
| 89 | #define OPTION_DEFAULT { [0 ... MAX_UINTS-1] = -1} |
| 90 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 91 | #define DUPLICATE_RX_CACHE_LENGTH 5 |
| 92 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 93 | #define AUTO_FB_NONE 0 |
| 94 | #define AUTO_FB_0 1 |
| 95 | #define AUTO_FB_1 2 |
| 96 | |
| 97 | #define FB_RATE0 0 |
| 98 | #define FB_RATE1 1 |
| 99 | |
Andres More | d3e2395 | 2013-01-31 15:57:19 -0500 | [diff] [blame] | 100 | /* Antenna Mode */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 101 | #define ANT_A 0 |
| 102 | #define ANT_B 1 |
| 103 | #define ANT_DIVERSITY 2 |
| 104 | #define ANT_RXD_TXA 3 |
| 105 | #define ANT_RXD_TXB 4 |
| 106 | #define ANT_UNKNOWN 0xFF |
| 107 | #define ANT_TXA 0 |
| 108 | #define ANT_TXB 1 |
| 109 | #define ANT_RXA 2 |
| 110 | #define ANT_RXB 3 |
| 111 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 112 | #define BB_VGA_LEVEL 4 |
| 113 | #define BB_VGA_CHANGE_THRESHOLD 3 |
| 114 | |
Malcolm Priestley | 15baf4f | 2014-05-17 09:50:28 +0100 | [diff] [blame] | 115 | #define EEP_MAX_CONTEXT_SIZE 256 |
| 116 | |
| 117 | /* Contents in the EEPROM */ |
| 118 | #define EEP_OFS_PAR 0x0 |
| 119 | #define EEP_OFS_ANTENNA 0x17 |
| 120 | #define EEP_OFS_RADIOCTL 0x18 |
| 121 | #define EEP_OFS_RFTYPE 0x1b |
| 122 | #define EEP_OFS_MINCHANNEL 0x1c |
| 123 | #define EEP_OFS_MAXCHANNEL 0x1d |
| 124 | #define EEP_OFS_SIGNATURE 0x1e |
| 125 | #define EEP_OFS_ZONETYPE 0x1f |
| 126 | #define EEP_OFS_RFTABLE 0x20 |
| 127 | #define EEP_OFS_PWR_CCK 0x20 |
| 128 | #define EEP_OFS_SETPT_CCK 0x21 |
| 129 | #define EEP_OFS_PWR_OFDMG 0x23 |
| 130 | |
| 131 | #define EEP_OFS_CALIB_TX_IQ 0x24 |
| 132 | #define EEP_OFS_CALIB_TX_DC 0x25 |
| 133 | #define EEP_OFS_CALIB_RX_IQ 0x26 |
| 134 | |
| 135 | #define EEP_OFS_MAJOR_VER 0x2e |
| 136 | #define EEP_OFS_MINOR_VER 0x2f |
| 137 | |
| 138 | #define EEP_OFS_CCK_PWR_TBL 0x30 |
| 139 | #define EEP_OFS_OFDM_PWR_TBL 0x40 |
| 140 | #define EEP_OFS_OFDMA_PWR_TBL 0x50 |
| 141 | |
| 142 | /* Bits in EEP_OFS_ANTENNA */ |
| 143 | #define EEP_ANTENNA_MAIN 0x1 |
| 144 | #define EEP_ANTENNA_AUX 0x2 |
| 145 | #define EEP_ANTINV 0x4 |
| 146 | |
| 147 | /* Bits in EEP_OFS_RADIOCTL */ |
| 148 | #define EEP_RADIOCTL_ENABLE 0x80 |
| 149 | |
Malcolm Priestley | 60f8ce8 | 2014-05-17 09:50:30 +0100 | [diff] [blame] | 150 | /* control commands */ |
| 151 | #define MESSAGE_TYPE_READ 0x1 |
| 152 | #define MESSAGE_TYPE_WRITE 0x0 |
| 153 | #define MESSAGE_TYPE_LOCK_OR 0x2 |
| 154 | #define MESSAGE_TYPE_LOCK_AND 0x3 |
| 155 | #define MESSAGE_TYPE_WRITE_MASK 0x4 |
| 156 | #define MESSAGE_TYPE_CARDINIT 0x5 |
| 157 | #define MESSAGE_TYPE_INIT_RSP 0x6 |
| 158 | #define MESSAGE_TYPE_MACSHUTDOWN 0x7 |
| 159 | #define MESSAGE_TYPE_SETKEY 0x8 |
| 160 | #define MESSAGE_TYPE_CLRKEYENTRY 0x9 |
| 161 | #define MESSAGE_TYPE_WRITE_MISCFF 0xa |
| 162 | #define MESSAGE_TYPE_SET_ANTMD 0xb |
| 163 | #define MESSAGE_TYPE_SELECT_CHANNLE 0xc |
| 164 | #define MESSAGE_TYPE_SET_TSFTBTT 0xd |
| 165 | #define MESSAGE_TYPE_SET_SSTIFS 0xe |
| 166 | #define MESSAGE_TYPE_CHANGE_BBTYPE 0xf |
| 167 | #define MESSAGE_TYPE_DISABLE_PS 0x10 |
| 168 | #define MESSAGE_TYPE_WRITE_IFRF 0x11 |
| 169 | |
| 170 | /* command read/write(index) */ |
| 171 | #define MESSAGE_REQUEST_MEM 0x1 |
| 172 | #define MESSAGE_REQUEST_BBREG 0x2 |
| 173 | #define MESSAGE_REQUEST_MACREG 0x3 |
| 174 | #define MESSAGE_REQUEST_EEPROM 0x4 |
| 175 | #define MESSAGE_REQUEST_TSF 0x5 |
| 176 | #define MESSAGE_REQUEST_TBTT 0x6 |
| 177 | #define MESSAGE_REQUEST_BBAGC 0x7 |
| 178 | #define MESSAGE_REQUEST_VERSION 0x8 |
| 179 | #define MESSAGE_REQUEST_RF_INIT 0x9 |
| 180 | #define MESSAGE_REQUEST_RF_INIT2 0xa |
| 181 | #define MESSAGE_REQUEST_RF_CH0 0xb |
| 182 | #define MESSAGE_REQUEST_RF_CH1 0xc |
| 183 | #define MESSAGE_REQUEST_RF_CH2 0xd |
| 184 | |
| 185 | /* USB registers */ |
| 186 | #define USB_REG4 0x604 |
| 187 | |
Malcolm Priestley | 302433d | 2013-11-03 17:40:51 +0000 | [diff] [blame] | 188 | #define DEVICE_INIT_COLD 0x0 /* cold init */ |
| 189 | #define DEVICE_INIT_RESET 0x1 /* reset init or Dx to D0 power remain */ |
| 190 | #define DEVICE_INIT_DXPL 0x2 /* Dx to D0 power lost init */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 191 | |
Malcolm Priestley | 60f8ce8 | 2014-05-17 09:50:30 +0100 | [diff] [blame] | 192 | /* Device init */ |
| 193 | struct vnt_cmd_card_init { |
| 194 | u8 init_class; |
| 195 | u8 exist_sw_net_addr; |
| 196 | u8 sw_net_addr[6]; |
| 197 | u8 short_retry_limit; |
| 198 | u8 long_retry_limit; |
| 199 | }; |
| 200 | |
| 201 | struct vnt_rsp_card_init { |
| 202 | u8 status; |
| 203 | u8 net_addr[6]; |
| 204 | u8 rf_type; |
| 205 | u8 min_channel; |
| 206 | u8 max_channel; |
| 207 | }; |
| 208 | |
Andres More | d3e2395 | 2013-01-31 15:57:19 -0500 | [diff] [blame] | 209 | /* USB */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 210 | |
Andres More | d3e2395 | 2013-01-31 15:57:19 -0500 | [diff] [blame] | 211 | /* |
| 212 | * Enum of context types for SendPacket |
| 213 | */ |
Malcolm Priestley | 1450ba6 | 2014-02-19 21:56:33 +0000 | [diff] [blame] | 214 | enum { |
| 215 | CONTEXT_DATA_PACKET = 1, |
Malcolm Priestley | d38b13a | 2014-06-25 21:14:23 +0100 | [diff] [blame] | 216 | CONTEXT_MGMT_PACKET, |
| 217 | CONTEXT_BEACON_PACKET |
Malcolm Priestley | 1450ba6 | 2014-02-19 21:56:33 +0000 | [diff] [blame] | 218 | }; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 219 | |
Andres More | d3e2395 | 2013-01-31 15:57:19 -0500 | [diff] [blame] | 220 | /* RCB (Receive Control Block) */ |
Malcolm Priestley | 115cac2 | 2013-08-28 21:12:35 +0100 | [diff] [blame] | 221 | struct vnt_rcb { |
Malcolm Priestley | 325de98 | 2014-07-18 06:36:11 +0100 | [diff] [blame] | 222 | void *priv; |
| 223 | struct urb *urb; |
Malcolm Priestley | dd0a774 | 2012-12-10 21:59:10 +0000 | [diff] [blame] | 224 | struct sk_buff *skb; |
Malcolm Priestley | 325de98 | 2014-07-18 06:36:11 +0100 | [diff] [blame] | 225 | int in_use; |
Malcolm Priestley | 115cac2 | 2013-08-28 21:12:35 +0100 | [diff] [blame] | 226 | }; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 227 | |
Andres More | d3e2395 | 2013-01-31 15:57:19 -0500 | [diff] [blame] | 228 | /* used to track bulk out irps */ |
Malcolm Priestley | dcdf1d0 | 2013-08-27 12:41:50 +0100 | [diff] [blame] | 229 | struct vnt_usb_send_context { |
Malcolm Priestley | 30a05b3 | 2014-05-15 22:49:11 +0100 | [diff] [blame] | 230 | void *priv; |
| 231 | struct sk_buff *skb; |
| 232 | struct urb *urb; |
Malcolm Priestley | 1622c8f | 2014-05-31 13:34:58 +0100 | [diff] [blame] | 233 | struct ieee80211_hdr *hdr; |
Malcolm Priestley | 30a05b3 | 2014-05-15 22:49:11 +0100 | [diff] [blame] | 234 | unsigned int buf_len; |
Malcolm Priestley | 1622c8f | 2014-05-31 13:34:58 +0100 | [diff] [blame] | 235 | u16 tx_hdr_size; |
Malcolm Priestley | 1450ba6 | 2014-02-19 21:56:33 +0000 | [diff] [blame] | 236 | u8 type; |
Malcolm Priestley | 71d764a | 2014-07-05 19:24:27 +0100 | [diff] [blame] | 237 | u8 pkt_no; |
| 238 | u8 fb_option; |
Malcolm Priestley | 30a05b3 | 2014-05-15 22:49:11 +0100 | [diff] [blame] | 239 | bool in_use; |
| 240 | unsigned char data[MAX_TOTAL_SIZE_WITH_ALL_HEADERS]; |
Malcolm Priestley | dcdf1d0 | 2013-08-27 12:41:50 +0100 | [diff] [blame] | 241 | }; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 242 | |
Andres More | d3e2395 | 2013-01-31 15:57:19 -0500 | [diff] [blame] | 243 | /* |
| 244 | * Structure to keep track of USB interrupt packets |
| 245 | */ |
Malcolm Priestley | f764e00 | 2014-02-19 18:39:09 +0000 | [diff] [blame] | 246 | struct vnt_interrupt_buffer { |
| 247 | u8 *data_buf; |
| 248 | bool in_use; |
| 249 | }; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 250 | |
Andres More | d3e2395 | 2013-01-31 15:57:19 -0500 | [diff] [blame] | 251 | /*++ NDIS related */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 252 | |
Peter Senna Tschudin | 879be45 | 2014-07-16 18:13:43 +0200 | [diff] [blame] | 253 | enum { |
| 254 | STATUS_SUCCESS = 0, |
| 255 | STATUS_FAILURE, |
| 256 | STATUS_RESOURCES, |
| 257 | STATUS_PENDING, |
| 258 | }; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 259 | |
Andres More | d3e2395 | 2013-01-31 15:57:19 -0500 | [diff] [blame] | 260 | /* flags for options */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 261 | #define DEVICE_FLAGS_UNPLUG 0x00000001UL |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 262 | |
Andres More | d3e2395 | 2013-01-31 15:57:19 -0500 | [diff] [blame] | 263 | /* flags for driver status */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 264 | #define DEVICE_FLAGS_OPENED 0x00010000UL |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 265 | |
Malcolm Priestley | 14c5ef5 | 2013-01-17 23:19:37 +0000 | [diff] [blame] | 266 | struct vnt_private { |
Malcolm Priestley | 63b9907 | 2014-06-25 21:14:22 +0100 | [diff] [blame] | 267 | /* mac80211 */ |
| 268 | struct ieee80211_hw *hw; |
Malcolm Priestley | db8f37f | 2014-06-25 21:14:25 +0100 | [diff] [blame] | 269 | struct ieee80211_vif *vif; |
Malcolm Priestley | 30816f8 | 2014-06-25 21:14:27 +0100 | [diff] [blame] | 270 | u8 mac_hw; |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 271 | /* netdev */ |
| 272 | struct usb_device *usb; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 273 | |
Malcolm Priestley | 63b9907 | 2014-06-25 21:14:22 +0100 | [diff] [blame] | 274 | u64 tsf_time; |
| 275 | u8 rx_rate; |
| 276 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 277 | u32 rx_buf_sz; |
Malcolm Priestley | db8f37f | 2014-06-25 21:14:25 +0100 | [diff] [blame] | 278 | int mc_list_count; |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 279 | |
| 280 | spinlock_t lock; |
Malcolm Priestley | c91b186 | 2014-05-15 22:49:19 +0100 | [diff] [blame] | 281 | struct mutex usb_lock; |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 282 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 283 | u32 flags; |
| 284 | unsigned long Flags; |
| 285 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 286 | /* USB */ |
Malcolm Priestley | 3d58248 | 2014-07-18 06:36:14 +0100 | [diff] [blame] | 287 | struct urb *interrupt_urb; |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 288 | u32 int_interval; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 289 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 290 | /* Variables to track resources for the BULK In Pipe */ |
Malcolm Priestley | 8577011 | 2014-07-18 06:36:15 +0100 | [diff] [blame] | 291 | struct vnt_rcb *rcb[CB_MAX_RX_DESC]; |
Malcolm Priestley | 6da4738 | 2014-07-19 12:30:03 +0100 | [diff] [blame] | 292 | u32 num_rcb; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 293 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 294 | /* Variables to track resources for the BULK Out Pipe */ |
Malcolm Priestley | f7e4a8f | 2014-07-18 06:36:16 +0100 | [diff] [blame] | 295 | struct vnt_usb_send_context *tx_context[CB_MAX_TX_DESC]; |
Malcolm Priestley | 03b7e35 | 2014-07-19 12:30:04 +0100 | [diff] [blame] | 296 | u32 num_tx_context; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 297 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 298 | /* Variables to track resources for the Interrupt In Pipe */ |
Malcolm Priestley | f764e00 | 2014-02-19 18:39:09 +0000 | [diff] [blame] | 299 | struct vnt_interrupt_buffer int_buf; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 300 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 301 | /* Version control */ |
Malcolm Priestley | 8a73f9d | 2014-07-19 12:30:05 +0100 | [diff] [blame] | 302 | u16 firmware_version; |
Malcolm Priestley | f1945a1 | 2014-07-19 12:30:06 +0100 | [diff] [blame] | 303 | u8 local_id; |
Malcolm Priestley | 6242eca | 2014-07-19 12:30:07 +0100 | [diff] [blame] | 304 | u8 rf_type; |
Malcolm Priestley | cd5856a | 2014-07-19 12:30:08 +0100 | [diff] [blame] | 305 | u8 bb_rx_conf; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 306 | |
Malcolm Priestley | 748bf69 | 2013-11-03 17:49:32 +0000 | [diff] [blame] | 307 | struct vnt_cmd_card_init init_command; |
| 308 | struct vnt_rsp_card_init init_response; |
Malcolm Priestley | ebf9b31 | 2014-07-19 12:30:10 +0100 | [diff] [blame] | 309 | u8 current_net_addr[ETH_ALEN]; |
Malcolm Priestley | 41e8321 | 2014-07-19 12:30:11 +0100 | [diff] [blame] | 310 | u8 permanent_net_addr[ETH_ALEN]; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 311 | |
Malcolm Priestley | 35cc8f9 | 2014-07-19 12:30:12 +0100 | [diff] [blame] | 312 | u8 exist_sw_net_addr; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 313 | |
Malcolm Priestley | 113f0b9 | 2014-07-19 12:30:13 +0100 | [diff] [blame] | 314 | u64 current_tsf; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 315 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 316 | /* 802.11 MAC specific */ |
Malcolm Priestley | 125cfc6 | 2014-07-19 12:30:14 +0100 | [diff] [blame] | 317 | u32 current_rssi; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 318 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 319 | /* Antenna Diversity */ |
Malcolm Priestley | 2044dbd | 2014-07-19 12:30:16 +0100 | [diff] [blame] | 320 | int tx_rx_ant_inv; |
| 321 | u32 rx_antenna_sel; |
| 322 | u8 rx_antenna_mode; |
| 323 | u8 tx_antenna_mode; |
| 324 | u8 radio_ctl; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 325 | |
Andres More | cc856e6 | 2010-05-17 21:34:01 -0300 | [diff] [blame] | 326 | /* IFS & Cw */ |
Malcolm Priestley | ff5fee2 | 2014-07-19 12:30:18 +0100 | [diff] [blame] | 327 | u32 sifs; /* Current SIFS */ |
| 328 | u32 difs; /* Current DIFS */ |
| 329 | u32 eifs; /* Current EIFS */ |
| 330 | u32 slot; /* Current SlotTime */ |
Andres More | cc856e6 | 2010-05-17 21:34:01 -0300 | [diff] [blame] | 331 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 332 | /* Rate */ |
Malcolm Priestley | 65df77e | 2014-07-20 15:33:11 +0100 | [diff] [blame^] | 333 | u8 bb_type; /* 0: 11A, 1:11B, 2:11G */ |
Malcolm Priestley | bf1c820 | 2014-02-15 21:58:55 +0000 | [diff] [blame] | 334 | u8 byPacketType; /* 0:11a 1:11b 2:11gb 3:11ga */ |
Malcolm Priestley | ee61fde | 2014-06-25 21:14:28 +0100 | [diff] [blame] | 335 | u32 wBasicRate; |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 336 | u8 byTopOFDMBasicRate; |
| 337 | u8 byTopCCKBasicRate; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 338 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 339 | u8 abyEEPROM[EEP_MAX_CONTEXT_SIZE]; /*u32 alignment */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 340 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 341 | u8 byPreambleType; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 342 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 343 | /* For RF Power table */ |
| 344 | u8 byCCKPwr; |
| 345 | u8 byOFDMPwrG; |
| 346 | u8 byOFDMPwrA; |
| 347 | u8 byCurPwr; |
| 348 | u8 abyCCKPwrTbl[14]; |
| 349 | u8 abyOFDMPwrTbl[14]; |
| 350 | u8 abyOFDMAPwrTbl[42]; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 351 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 352 | u16 wCurrentRate; |
Malcolm Priestley | f84cdf6 | 2013-10-15 21:00:09 +0100 | [diff] [blame] | 353 | u16 tx_rate_fb0; |
| 354 | u16 tx_rate_fb1; |
| 355 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 356 | u8 byShortRetryLimit; |
| 357 | u8 byLongRetryLimit; |
Malcolm Priestley | a0ad277 | 2014-02-15 21:56:20 +0000 | [diff] [blame] | 358 | |
| 359 | enum nl80211_iftype op_mode; |
| 360 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 361 | int bShortSlotTime; |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 362 | int bBarkerPreambleMd; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 363 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 364 | /* Power save */ |
Malcolm Priestley | db8f37f | 2014-06-25 21:14:25 +0100 | [diff] [blame] | 365 | u16 current_aid; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 366 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 367 | /* Beacon releated */ |
| 368 | u16 wSeqCounter; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 369 | |
Malcolm Priestley | ad74e91 | 2014-07-13 10:42:42 +0100 | [diff] [blame] | 370 | enum vnt_cmd_state command_state; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 371 | |
Malcolm Priestley | 80f0d09 | 2014-07-13 10:42:41 +0100 | [diff] [blame] | 372 | enum vnt_cmd command; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 373 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 374 | /* 802.11 counter */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 375 | |
Malcolm Priestley | b595f9b | 2014-07-13 10:42:43 +0100 | [diff] [blame] | 376 | enum vnt_cmd cmd_queue[CMD_Q_SIZE]; |
Malcolm Priestley | 33a60b8 | 2014-07-13 10:42:45 +0100 | [diff] [blame] | 377 | u32 cmd_dequeue_idx; |
| 378 | u32 cmd_enqueue_idx; |
| 379 | u32 free_cmd_queue; |
| 380 | int cmd_running; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 381 | |
Malcolm Priestley | d1eb500 | 2014-06-25 21:14:24 +0100 | [diff] [blame] | 382 | unsigned long key_entry_inuse; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 383 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 384 | u8 byAutoFBCtrl; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 385 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 386 | /* For Update BaseBand VGA Gain Offset */ |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 387 | u8 abyBBVGA[BB_VGA_LEVEL]; |
| 388 | signed long ldBmThreshold[BB_VGA_LEVEL]; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 389 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 390 | u8 byBBPreEDRSSI; |
| 391 | u8 byBBPreEDIndex; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 392 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 393 | /* command timer */ |
Malcolm Priestley | 94488a7 | 2013-09-27 16:48:14 +0100 | [diff] [blame] | 394 | struct delayed_work run_command_work; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 395 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 396 | int bChannelSwitch; |
| 397 | u8 byNewChannel; |
| 398 | u8 byChannelSwitchCount; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 399 | |
Malcolm Priestley | 1786384 | 2014-06-29 20:39:54 +0100 | [diff] [blame] | 400 | struct ieee80211_low_level_stats low_stats; |
Malcolm Priestley | 14c5ef5 | 2013-01-17 23:19:37 +0000 | [diff] [blame] | 401 | }; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 402 | |
Peter Senna Tschudin | dbf0a03 | 2014-07-15 23:23:24 +0200 | [diff] [blame] | 403 | #define ADD_ONE_WITH_WRAP_AROUND(uVar, uModulo) { \ |
| 404 | if ((uVar) >= ((uModulo) - 1)) \ |
| 405 | (uVar) = 0; \ |
| 406 | else \ |
| 407 | (uVar)++; \ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 408 | } |
| 409 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 410 | #define fMP_DISCONNECTED 0x00000002 |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 411 | #define fMP_POST_READS 0x00000100 |
| 412 | #define fMP_POST_WRITES 0x00000200 |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 413 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 414 | #define MP_SET_FLAG(_M, _F) ((_M)->Flags |= (_F)) |
| 415 | #define MP_CLEAR_FLAG(_M, _F) ((_M)->Flags &= ~(_F)) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 416 | #define MP_TEST_FLAGS(_M, _F) (((_M)->Flags & (_F)) == (_F)) |
| 417 | |
Malcolm Priestley | d4f376d | 2014-05-17 09:50:25 +0100 | [diff] [blame] | 418 | #define MP_IS_READY(_M) (((_M)->Flags & fMP_DISCONNECTED) == 0) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 419 | |
Malcolm Priestley | 30816f8 | 2014-06-25 21:14:27 +0100 | [diff] [blame] | 420 | int vnt_init(struct vnt_private *priv); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 421 | |
| 422 | #endif |