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 | * |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 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 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 29 | #include <linux/module.h> |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 30 | #include <linux/kernel.h> |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 31 | #include <linux/slab.h> |
Malcolm Priestley | 11d404c | 2012-11-24 14:19:34 +0000 | [diff] [blame] | 32 | #include <linux/delay.h> |
| 33 | #include <linux/device.h> |
Ben Hutchings | 31d5bbf | 2011-01-09 04:16:48 +0000 | [diff] [blame] | 34 | #include <linux/firmware.h> |
Malcolm Priestley | 11d404c | 2012-11-24 14:19:34 +0000 | [diff] [blame] | 35 | #include <linux/suspend.h> |
| 36 | #include <linux/if_arp.h> |
| 37 | #include <linux/wireless.h> |
Malcolm Priestley | 11d404c | 2012-11-24 14:19:34 +0000 | [diff] [blame] | 38 | #include <linux/timer.h> |
| 39 | #include <linux/usb.h> |
Malcolm Priestley | f0fde11 | 2013-11-03 19:02:41 +0000 | [diff] [blame] | 40 | #include <linux/crc32.h> |
Malcolm Priestley | 63b9907 | 2014-06-25 21:14:22 +0100 | [diff] [blame] | 41 | #include <net/mac80211.h> |
Malcolm Priestley | 11d404c | 2012-11-24 14:19:34 +0000 | [diff] [blame] | 42 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 43 | #ifdef SIOCETHTOOL |
| 44 | #define DEVICE_ETHTOOL_IOCTL_SUPPORT |
| 45 | #include <linux/ethtool.h> |
| 46 | #else |
| 47 | #undef DEVICE_ETHTOOL_IOCTL_SUPPORT |
| 48 | #endif |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 49 | |
Malcolm Priestley | f07e9fb | 2014-06-25 21:14:34 +0100 | [diff] [blame] | 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 | |
Malcolm Priestley | 4aeaf15 | 2014-05-17 09:50:24 +0100 | [diff] [blame] | 64 | #define MAX_RATE 12 |
| 65 | |
Andres More | d3e2395 | 2013-01-31 15:57:19 -0500 | [diff] [blame] | 66 | /* |
| 67 | * device specific |
| 68 | */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 69 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 70 | #include "wcmd.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 71 | #include "desc.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 72 | #include "key.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 73 | #include "card.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 74 | |
Otavio Salvador | 5008c45 | 2009-10-12 23:47:36 -0300 | [diff] [blame] | 75 | #define VNT_USB_VENDOR_ID 0x160a |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 76 | #define VNT_USB_PRODUCT_ID 0x3184 |
| 77 | |
Malcolm Priestley | 4aeaf15 | 2014-05-17 09:50:24 +0100 | [diff] [blame] | 78 | #define DEVICE_NAME "vt6656" |
| 79 | #define DEVICE_FULL_DRV_NAM "VIA Networking Wireless LAN USB Driver" |
| 80 | |
Malcolm Priestley | feab481 | 2014-07-25 20:51:52 +0100 | [diff] [blame] | 81 | #define DEVICE_VERSION "mac80211" |
Malcolm Priestley | 4aeaf15 | 2014-05-17 09:50:24 +0100 | [diff] [blame] | 82 | |
| 83 | #define CONFIG_PATH "/etc/vntconfiguration.dat" |
| 84 | |
| 85 | #define MAX_UINTS 8 |
| 86 | #define OPTION_DEFAULT { [0 ... MAX_UINTS-1] = -1} |
| 87 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 88 | #define DUPLICATE_RX_CACHE_LENGTH 5 |
| 89 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 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 | |
Andres More | d3e2395 | 2013-01-31 15:57:19 -0500 | [diff] [blame] | 97 | /* Antenna Mode */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 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 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 109 | #define BB_VGA_LEVEL 4 |
| 110 | #define BB_VGA_CHANGE_THRESHOLD 3 |
| 111 | |
Malcolm Priestley | 15baf4f | 2014-05-17 09:50:28 +0100 | [diff] [blame] | 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 | |
Malcolm Priestley | 60f8ce8 | 2014-05-17 09:50:30 +0100 | [diff] [blame] | 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 |
Gustavo A. R. Silva | 733b3b0 | 2015-01-11 16:35:54 -0600 | [diff] [blame] | 160 | #define MESSAGE_TYPE_SELECT_CHANNEL 0xc |
Malcolm Priestley | 60f8ce8 | 2014-05-17 09:50:30 +0100 | [diff] [blame] | 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 | |
Malcolm Priestley | 302433d | 2013-11-03 17:40:51 +0000 | [diff] [blame] | 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 */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 188 | |
Malcolm Priestley | 60f8ce8 | 2014-05-17 09:50:30 +0100 | [diff] [blame] | 189 | /* Device init */ |
| 190 | struct 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 | |
| 198 | struct 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 | |
Andres More | d3e2395 | 2013-01-31 15:57:19 -0500 | [diff] [blame] | 206 | /* USB */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 207 | |
Andres More | d3e2395 | 2013-01-31 15:57:19 -0500 | [diff] [blame] | 208 | /* |
| 209 | * Enum of context types for SendPacket |
| 210 | */ |
Malcolm Priestley | 1450ba6 | 2014-02-19 21:56:33 +0000 | [diff] [blame] | 211 | enum { |
| 212 | CONTEXT_DATA_PACKET = 1, |
Malcolm Priestley | d38b13a | 2014-06-25 21:14:23 +0100 | [diff] [blame] | 213 | CONTEXT_MGMT_PACKET, |
| 214 | CONTEXT_BEACON_PACKET |
Malcolm Priestley | 1450ba6 | 2014-02-19 21:56:33 +0000 | [diff] [blame] | 215 | }; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 216 | |
Andres More | d3e2395 | 2013-01-31 15:57:19 -0500 | [diff] [blame] | 217 | /* RCB (Receive Control Block) */ |
Malcolm Priestley | 115cac2 | 2013-08-28 21:12:35 +0100 | [diff] [blame] | 218 | struct vnt_rcb { |
Malcolm Priestley | 325de98 | 2014-07-18 06:36:11 +0100 | [diff] [blame] | 219 | void *priv; |
| 220 | struct urb *urb; |
Malcolm Priestley | dd0a774 | 2012-12-10 21:59:10 +0000 | [diff] [blame] | 221 | struct sk_buff *skb; |
Malcolm Priestley | 325de98 | 2014-07-18 06:36:11 +0100 | [diff] [blame] | 222 | int in_use; |
Malcolm Priestley | 115cac2 | 2013-08-28 21:12:35 +0100 | [diff] [blame] | 223 | }; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 224 | |
Andres More | d3e2395 | 2013-01-31 15:57:19 -0500 | [diff] [blame] | 225 | /* used to track bulk out irps */ |
Malcolm Priestley | dcdf1d0 | 2013-08-27 12:41:50 +0100 | [diff] [blame] | 226 | struct vnt_usb_send_context { |
Malcolm Priestley | 30a05b3 | 2014-05-15 22:49:11 +0100 | [diff] [blame] | 227 | void *priv; |
| 228 | struct sk_buff *skb; |
| 229 | struct urb *urb; |
Malcolm Priestley | 1622c8f | 2014-05-31 13:34:58 +0100 | [diff] [blame] | 230 | struct ieee80211_hdr *hdr; |
Malcolm Priestley | 30a05b3 | 2014-05-15 22:49:11 +0100 | [diff] [blame] | 231 | unsigned int buf_len; |
Malcolm Priestley | 0f5567c | 2014-07-20 15:33:33 +0100 | [diff] [blame] | 232 | u32 frame_len; |
Malcolm Priestley | 1622c8f | 2014-05-31 13:34:58 +0100 | [diff] [blame] | 233 | u16 tx_hdr_size; |
Malcolm Priestley | 798f060 | 2014-07-20 15:33:34 +0100 | [diff] [blame] | 234 | u16 tx_rate; |
Malcolm Priestley | 1450ba6 | 2014-02-19 21:56:33 +0000 | [diff] [blame] | 235 | u8 type; |
Malcolm Priestley | 71d764a | 2014-07-05 19:24:27 +0100 | [diff] [blame] | 236 | u8 pkt_no; |
Malcolm Priestley | e8c9875 | 2014-07-20 15:33:31 +0100 | [diff] [blame] | 237 | u8 pkt_type; |
Malcolm Priestley | 2eca8db | 2014-07-20 15:33:32 +0100 | [diff] [blame] | 238 | u8 need_ack; |
Malcolm Priestley | 71d764a | 2014-07-05 19:24:27 +0100 | [diff] [blame] | 239 | u8 fb_option; |
Malcolm Priestley | 30a05b3 | 2014-05-15 22:49:11 +0100 | [diff] [blame] | 240 | bool in_use; |
| 241 | unsigned char data[MAX_TOTAL_SIZE_WITH_ALL_HEADERS]; |
Malcolm Priestley | dcdf1d0 | 2013-08-27 12:41:50 +0100 | [diff] [blame] | 242 | }; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 243 | |
Andres More | d3e2395 | 2013-01-31 15:57:19 -0500 | [diff] [blame] | 244 | /* |
| 245 | * Structure to keep track of USB interrupt packets |
| 246 | */ |
Malcolm Priestley | f764e00 | 2014-02-19 18:39:09 +0000 | [diff] [blame] | 247 | struct vnt_interrupt_buffer { |
| 248 | u8 *data_buf; |
| 249 | bool in_use; |
| 250 | }; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 251 | |
Andres More | d3e2395 | 2013-01-31 15:57:19 -0500 | [diff] [blame] | 252 | /*++ NDIS related */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 253 | |
Peter Senna Tschudin | 879be45 | 2014-07-16 18:13:43 +0200 | [diff] [blame] | 254 | enum { |
| 255 | STATUS_SUCCESS = 0, |
| 256 | STATUS_FAILURE, |
| 257 | STATUS_RESOURCES, |
| 258 | STATUS_PENDING, |
| 259 | }; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 260 | |
Andres More | d3e2395 | 2013-01-31 15:57:19 -0500 | [diff] [blame] | 261 | /* flags for options */ |
Alexey Tulia | e7bda76 | 2015-11-21 15:36:47 +0300 | [diff] [blame] | 262 | #define DEVICE_FLAGS_UNPLUG 0 |
| 263 | #define DEVICE_FLAGS_DISCONNECTED 1 |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 264 | |
Malcolm Priestley | 14c5ef5 | 2013-01-17 23:19:37 +0000 | [diff] [blame] | 265 | struct vnt_private { |
Malcolm Priestley | 63b9907 | 2014-06-25 21:14:22 +0100 | [diff] [blame] | 266 | /* mac80211 */ |
| 267 | struct ieee80211_hw *hw; |
Malcolm Priestley | db8f37f | 2014-06-25 21:14:25 +0100 | [diff] [blame] | 268 | struct ieee80211_vif *vif; |
Malcolm Priestley | 30816f8 | 2014-06-25 21:14:27 +0100 | [diff] [blame] | 269 | u8 mac_hw; |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 270 | /* netdev */ |
| 271 | struct usb_device *usb; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 272 | |
Malcolm Priestley | 63b9907 | 2014-06-25 21:14:22 +0100 | [diff] [blame] | 273 | u64 tsf_time; |
| 274 | u8 rx_rate; |
| 275 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 276 | u32 rx_buf_sz; |
Malcolm Priestley | db8f37f | 2014-06-25 21:14:25 +0100 | [diff] [blame] | 277 | int mc_list_count; |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 278 | |
| 279 | spinlock_t lock; |
Malcolm Priestley | c91b186 | 2014-05-15 22:49:19 +0100 | [diff] [blame] | 280 | struct mutex usb_lock; |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 281 | |
Malcolm Priestley | 2746321 | 2014-07-24 21:13:16 +0100 | [diff] [blame] | 282 | unsigned long flags; |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 283 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 284 | /* USB */ |
Malcolm Priestley | 3d58248 | 2014-07-18 06:36:14 +0100 | [diff] [blame] | 285 | struct urb *interrupt_urb; |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 286 | u32 int_interval; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 287 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 288 | /* Variables to track resources for the BULK In Pipe */ |
Malcolm Priestley | 8577011 | 2014-07-18 06:36:15 +0100 | [diff] [blame] | 289 | struct vnt_rcb *rcb[CB_MAX_RX_DESC]; |
Malcolm Priestley | 6da4738 | 2014-07-19 12:30:03 +0100 | [diff] [blame] | 290 | u32 num_rcb; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 291 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 292 | /* Variables to track resources for the BULK Out Pipe */ |
Malcolm Priestley | f7e4a8f | 2014-07-18 06:36:16 +0100 | [diff] [blame] | 293 | struct vnt_usb_send_context *tx_context[CB_MAX_TX_DESC]; |
Malcolm Priestley | 03b7e35 | 2014-07-19 12:30:04 +0100 | [diff] [blame] | 294 | u32 num_tx_context; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 295 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 296 | /* Variables to track resources for the Interrupt In Pipe */ |
Malcolm Priestley | f764e00 | 2014-02-19 18:39:09 +0000 | [diff] [blame] | 297 | struct vnt_interrupt_buffer int_buf; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 298 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 299 | /* Version control */ |
Malcolm Priestley | 8a73f9d | 2014-07-19 12:30:05 +0100 | [diff] [blame] | 300 | u16 firmware_version; |
Malcolm Priestley | f1945a1 | 2014-07-19 12:30:06 +0100 | [diff] [blame] | 301 | u8 local_id; |
Malcolm Priestley | 6242eca | 2014-07-19 12:30:07 +0100 | [diff] [blame] | 302 | u8 rf_type; |
Malcolm Priestley | cd5856a | 2014-07-19 12:30:08 +0100 | [diff] [blame] | 303 | u8 bb_rx_conf; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 304 | |
Malcolm Priestley | 748bf69 | 2013-11-03 17:49:32 +0000 | [diff] [blame] | 305 | struct vnt_cmd_card_init init_command; |
| 306 | struct vnt_rsp_card_init init_response; |
Krzysztof Adamski | e238223 | 2014-12-09 12:01:38 +0100 | [diff] [blame] | 307 | u8 current_net_addr[ETH_ALEN] __aligned(2); |
| 308 | u8 permanent_net_addr[ETH_ALEN] __aligned(2); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 309 | |
Malcolm Priestley | 35cc8f9 | 2014-07-19 12:30:12 +0100 | [diff] [blame] | 310 | u8 exist_sw_net_addr; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 311 | |
Malcolm Priestley | 113f0b9 | 2014-07-19 12:30:13 +0100 | [diff] [blame] | 312 | u64 current_tsf; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 313 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 314 | /* 802.11 MAC specific */ |
Malcolm Priestley | 125cfc6 | 2014-07-19 12:30:14 +0100 | [diff] [blame] | 315 | u32 current_rssi; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 316 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 317 | /* Antenna Diversity */ |
Malcolm Priestley | 2044dbd | 2014-07-19 12:30:16 +0100 | [diff] [blame] | 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; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 323 | |
Andres More | cc856e6 | 2010-05-17 21:34:01 -0300 | [diff] [blame] | 324 | /* IFS & Cw */ |
Malcolm Priestley | ff5fee2 | 2014-07-19 12:30:18 +0100 | [diff] [blame] | 325 | u32 sifs; /* Current SIFS */ |
| 326 | u32 difs; /* Current DIFS */ |
| 327 | u32 eifs; /* Current EIFS */ |
| 328 | u32 slot; /* Current SlotTime */ |
Andres More | cc856e6 | 2010-05-17 21:34:01 -0300 | [diff] [blame] | 329 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 330 | /* Rate */ |
Malcolm Priestley | 65df77e | 2014-07-20 15:33:11 +0100 | [diff] [blame] | 331 | u8 bb_type; /* 0: 11A, 1:11B, 2:11G */ |
Malcolm Priestley | e12471d | 2014-07-20 15:33:12 +0100 | [diff] [blame] | 332 | u8 packet_type; /* 0:11a 1:11b 2:11gb 3:11ga */ |
Malcolm Priestley | 93a7355 | 2014-07-20 15:33:13 +0100 | [diff] [blame] | 333 | u32 basic_rates; |
Malcolm Priestley | 3c8a5b2 | 2014-07-20 15:33:14 +0100 | [diff] [blame] | 334 | u8 top_ofdm_basic_rate; |
Malcolm Priestley | d80bf43 | 2014-07-20 15:33:15 +0100 | [diff] [blame] | 335 | u8 top_cck_basic_rate; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 336 | |
Malcolm Priestley | bbb1126 | 2014-07-20 15:33:16 +0100 | [diff] [blame] | 337 | u8 eeprom[EEP_MAX_CONTEXT_SIZE]; /*u32 alignment */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 338 | |
Malcolm Priestley | 98e93fe | 2014-07-20 15:33:17 +0100 | [diff] [blame] | 339 | u8 preamble_type; |
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 | /* For RF Power table */ |
Malcolm Priestley | 5a97491 | 2014-07-20 15:33:18 +0100 | [diff] [blame] | 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]; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 349 | |
Malcolm Priestley | 8b84c1d | 2014-07-20 15:33:19 +0100 | [diff] [blame] | 350 | u16 current_rate; |
Malcolm Priestley | f84cdf6 | 2013-10-15 21:00:09 +0100 | [diff] [blame] | 351 | u16 tx_rate_fb0; |
| 352 | u16 tx_rate_fb1; |
| 353 | |
Malcolm Priestley | 388e5cb | 2014-07-20 15:33:20 +0100 | [diff] [blame] | 354 | u8 short_retry_limit; |
| 355 | u8 long_retry_limit; |
Malcolm Priestley | a0ad277 | 2014-02-15 21:56:20 +0000 | [diff] [blame] | 356 | |
| 357 | enum nl80211_iftype op_mode; |
| 358 | |
Malcolm Priestley | a641c9e | 2014-07-20 15:33:21 +0100 | [diff] [blame] | 359 | int short_slot_time; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 360 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 361 | /* Power save */ |
Malcolm Priestley | db8f37f | 2014-06-25 21:14:25 +0100 | [diff] [blame] | 362 | u16 current_aid; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 363 | |
Colin Cronin | 5908260 | 2015-05-14 23:33:34 -0700 | [diff] [blame] | 364 | /* Beacon related */ |
Malcolm Priestley | 1b2bc0a | 2014-07-20 15:33:23 +0100 | [diff] [blame] | 365 | u16 seq_counter; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 366 | |
Malcolm Priestley | ad74e91 | 2014-07-13 10:42:42 +0100 | [diff] [blame] | 367 | enum vnt_cmd_state command_state; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 368 | |
Malcolm Priestley | 80f0d09 | 2014-07-13 10:42:41 +0100 | [diff] [blame] | 369 | enum vnt_cmd command; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 370 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 371 | /* 802.11 counter */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 372 | |
Malcolm Priestley | b595f9b | 2014-07-13 10:42:43 +0100 | [diff] [blame] | 373 | enum vnt_cmd cmd_queue[CMD_Q_SIZE]; |
Malcolm Priestley | 33a60b8 | 2014-07-13 10:42:45 +0100 | [diff] [blame] | 374 | u32 cmd_dequeue_idx; |
| 375 | u32 cmd_enqueue_idx; |
| 376 | u32 free_cmd_queue; |
| 377 | int cmd_running; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 378 | |
Malcolm Priestley | d1eb500 | 2014-06-25 21:14:24 +0100 | [diff] [blame] | 379 | unsigned long key_entry_inuse; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 380 | |
Malcolm Priestley | a6177ae | 2014-07-20 15:33:24 +0100 | [diff] [blame] | 381 | u8 auto_fb_ctrl; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 382 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 383 | /* For Update BaseBand VGA Gain Offset */ |
Malcolm Priestley | c37cbd37 | 2014-07-20 15:33:25 +0100 | [diff] [blame] | 384 | u8 bb_vga[BB_VGA_LEVEL]; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 385 | |
Malcolm Priestley | 1268722 | 2014-07-20 15:33:27 +0100 | [diff] [blame] | 386 | u8 bb_pre_ed_rssi; |
Malcolm Priestley | 43fd192 | 2014-07-20 15:33:28 +0100 | [diff] [blame] | 387 | u8 bb_pre_ed_index; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 388 | |
Malcolm Priestley | 43c93d9 | 2015-09-27 09:17:41 +0100 | [diff] [blame] | 389 | u16 wake_up_count; |
| 390 | |
Malcolm Priestley | 61462ab | 2013-01-17 23:21:50 +0000 | [diff] [blame] | 391 | /* command timer */ |
Malcolm Priestley | 94488a7 | 2013-09-27 16:48:14 +0100 | [diff] [blame] | 392 | struct delayed_work run_command_work; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 393 | |
Malcolm Priestley | 1786384e | 2014-06-29 20:39:54 +0100 | [diff] [blame] | 394 | struct ieee80211_low_level_stats low_stats; |
Malcolm Priestley | 14c5ef5 | 2013-01-17 23:19:37 +0000 | [diff] [blame] | 395 | }; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 396 | |
Peter Senna Tschudin | dbf0a03 | 2014-07-15 23:23:24 +0200 | [diff] [blame] | 397 | #define ADD_ONE_WITH_WRAP_AROUND(uVar, uModulo) { \ |
| 398 | if ((uVar) >= ((uModulo) - 1)) \ |
| 399 | (uVar) = 0; \ |
| 400 | else \ |
| 401 | (uVar)++; \ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 402 | } |
| 403 | |
Malcolm Priestley | 30816f8 | 2014-06-25 21:14:27 +0100 | [diff] [blame] | 404 | int vnt_init(struct vnt_private *priv); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 405 | |
| 406 | #endif |