]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/staging/vt6655/device.h
be42e4472c84c7c740541c0c3fba539603c76935
[karo-tx-linux.git] / drivers / staging / vt6655 / device.h
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
32 #include <linux/module.h>
33 #include <linux/types.h>
34 #include <linux/mm.h>
35 #include <linux/errno.h>
36 #include <linux/ioport.h>
37 #include <linux/pci.h>
38 #include <linux/kernel.h>
39 #include <linux/netdevice.h>
40 #include <linux/etherdevice.h>
41 #include <linux/skbuff.h>
42 #include <linux/delay.h>
43 #include <linux/timer.h>
44 #include <linux/slab.h>
45 #include <linux/interrupt.h>
46 #include <linux/string.h>
47 #include <linux/wait.h>
48 #include <linux/if_arp.h>
49 #include <linux/sched.h>
50 #include <linux/io.h>
51 #include <linux/if.h>
52 #include <linux/crc32.h>
53 #include <linux/uaccess.h>
54 #include <linux/proc_fs.h>
55 #include <linux/inetdevice.h>
56 #include <linux/reboot.h>
57 #include <linux/ethtool.h>
58 /* Include Wireless Extension definition and check version - Jean II */
59 #include <net/mac80211.h>
60 #include <linux/wireless.h>
61 #include <net/iw_handler.h>     /* New driver API */
62
63 #ifndef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
64 #define WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
65 #endif
66
67 /* device specific */
68
69 #include "device_cfg.h"
70 #include "card.h"
71 #include "srom.h"
72 #include "desc.h"
73 #include "key.h"
74 #include "mac.h"
75
76 /*---------------------  Export Definitions -------------------------*/
77
78 #define RATE_1M         0
79 #define RATE_2M         1
80 #define RATE_5M         2
81 #define RATE_11M        3
82 #define RATE_6M         4
83 #define RATE_9M         5
84 #define RATE_12M        6
85 #define RATE_18M        7
86 #define RATE_24M        8
87 #define RATE_36M        9
88 #define RATE_48M        10
89 #define RATE_54M        11
90 #define RATE_AUTO       12
91 #define MAX_RATE        12
92
93 #define MAC_MAX_CONTEXT_REG     (256+128)
94
95 #define MAX_MULTICAST_ADDRESS_NUM       32
96 #define MULTICAST_ADDRESS_LIST_SIZE     (MAX_MULTICAST_ADDRESS_NUM * ETH_ALEN)
97
98 #define DUPLICATE_RX_CACHE_LENGTH       5
99
100 #define NUM_KEY_ENTRY                   11
101
102 #define TX_WEP_NONE                     0
103 #define TX_WEP_OTF                      1
104 #define TX_WEP_SW                       2
105 #define TX_WEP_SWOTP                    3
106 #define TX_WEP_OTPSW                    4
107 #define TX_WEP_SW232                    5
108
109 #define KEYSEL_WEP40                    0
110 #define KEYSEL_WEP104                   1
111 #define KEYSEL_TKIP                     2
112 #define KEYSEL_CCMP                     3
113
114 #define AUTO_FB_NONE            0
115 #define AUTO_FB_0               1
116 #define AUTO_FB_1               2
117
118 #define FB_RATE0                0
119 #define FB_RATE1                1
120
121 /* Antenna Mode */
122 #define ANT_A                   0
123 #define ANT_B                   1
124 #define ANT_DIVERSITY           2
125 #define ANT_RXD_TXA             3
126 #define ANT_RXD_TXB             4
127 #define ANT_UNKNOWN             0xFF
128
129 #define MAXCHECKHANGCNT         4
130
131 #define BB_VGA_LEVEL            4
132 #define BB_VGA_CHANGE_THRESHOLD 16
133
134 #ifndef RUN_AT
135 #define RUN_AT(x)                       (jiffies+(x))
136 #endif
137
138 #define MAKE_BEACON_RESERVED    10  /* (us) */
139
140 /* DMA related */
141 #define RESERV_AC0DMA                   4
142
143 /* BUILD OBJ mode */
144
145 #define AVAIL_TD(p, q)  ((p)->sOpts.nTxDescs[(q)] - ((p)->iTDUsed[(q)]))
146
147 #define NUM                             64
148
149 /* 0:11A 1:11B 2:11G */
150 #define BB_TYPE_11A    0
151 #define BB_TYPE_11B    1
152 #define BB_TYPE_11G    2
153
154 /* 0:11a, 1:11b, 2:11gb (only CCK in BasicRate), 3:11ga (OFDM in BasicRate) */
155 #define PK_TYPE_11A     0
156 #define PK_TYPE_11B     1
157 #define PK_TYPE_11GB    2
158 #define PK_TYPE_11GA    3
159
160 typedef enum {
161         OWNED_BY_HOST = 0,
162         OWNED_BY_NIC = 1
163 } DEVICE_OWNER_TYPE, *PDEVICE_OWNER_TYPE;
164
165 /* flags for options */
166 #define     DEVICE_FLAGS_IP_ALIGN        0x00000001UL
167 #define     DEVICE_FLAGS_PREAMBLE_TYPE   0x00000002UL
168 #define     DEVICE_FLAGS_OP_MODE         0x00000004UL
169 #define     DEVICE_FLAGS_PS_MODE         0x00000008UL
170 #define         DEVICE_FLAGS_80211h_MODE         0x00000010UL
171 #define         DEVICE_FLAGS_DiversityANT        0x00000020UL
172
173 /* flags for driver status */
174 #define     DEVICE_FLAGS_OPENED          0x00010000UL
175 #define     DEVICE_FLAGS_WOL_ENABLED     0x00080000UL
176 /* flags for capabilities */
177 #define     DEVICE_FLAGS_TX_ALIGN        0x01000000UL
178 #define     DEVICE_FLAGS_HAVE_CAM        0x02000000UL
179 #define     DEVICE_FLAGS_FLOW_CTRL       0x04000000UL
180
181 /* flags for MII status */
182 #define     DEVICE_LINK_FAIL             0x00000001UL
183 #define     DEVICE_SPEED_10              0x00000002UL
184 #define     DEVICE_SPEED_100             0x00000004UL
185 #define     DEVICE_SPEED_1000            0x00000008UL
186 #define     DEVICE_DUPLEX_FULL           0x00000010UL
187 #define     DEVICE_AUTONEG_ENABLE        0x00000020UL
188 #define     DEVICE_FORCED_BY_EEPROM      0x00000040UL
189 /* for device_set_media_duplex */
190 #define     DEVICE_LINK_CHANGE           0x00000001UL
191
192 typedef struct __device_opt {
193         int         nRxDescs0;          /* Number of RX descriptors0 */
194         int         nRxDescs1;          /* Number of RX descriptors1 */
195         int         nTxDescs[2];        /* Number of TX descriptors 0, 1 */
196         int         int_works;          /* interrupt limits */
197         int         short_retry;
198         int         long_retry;
199         int         bbp_type;
200         u32         flags;
201 } OPTIONS, *POPTIONS;
202
203 struct vnt_private {
204         struct pci_dev *pcid;
205         /* mac80211 */
206         struct ieee80211_hw *hw;
207         struct ieee80211_vif *vif;
208         unsigned long key_entry_inuse;
209         u32 basic_rates;
210         u16 current_aid;
211         int mc_list_count;
212         u8 mac_hw;
213
214 /* dma addr, rx/tx pool */
215         dma_addr_t                  pool_dma;
216         dma_addr_t                  rd0_pool_dma;
217         dma_addr_t                  rd1_pool_dma;
218
219         dma_addr_t                  td0_pool_dma;
220         dma_addr_t                  td1_pool_dma;
221
222         dma_addr_t                  tx_bufs_dma0;
223         dma_addr_t                  tx_bufs_dma1;
224         dma_addr_t                  tx_beacon_dma;
225
226         unsigned char *tx0_bufs;
227         unsigned char *tx1_bufs;
228         unsigned char *tx_beacon_bufs;
229
230         void __iomem                *PortOffset;
231         u32                         memaddr;
232         u32                         ioaddr;
233
234         unsigned char byRevId;
235         unsigned char byRxMode;
236         unsigned short SubSystemID;
237         unsigned short SubVendorID;
238
239         spinlock_t                  lock;
240
241         volatile int                iTDUsed[TYPE_MAXTD];
242
243         struct vnt_tx_desc *apCurrTD[TYPE_MAXTD];
244         struct vnt_tx_desc *apTailTD[TYPE_MAXTD];
245
246         struct vnt_tx_desc *apTD0Rings;
247         struct vnt_tx_desc *apTD1Rings;
248
249         struct vnt_rx_desc *aRD0Ring;
250         struct vnt_rx_desc *aRD1Ring;
251         struct vnt_rx_desc *pCurrRD[TYPE_MAXRD];
252
253         OPTIONS                     sOpts;
254
255         u32                         flags;
256
257         u32                         rx_buf_sz;
258         u8 rx_rate;
259         int                         multicast_limit;
260
261         u32                         rx_bytes;
262
263         /* Version control */
264         unsigned char byLocalID;
265         unsigned char byRFType;
266
267         unsigned char byMaxPwrLevel;
268         unsigned char byZoneType;
269         bool bZoneRegExist;
270         unsigned char byOriginalZonetype;
271
272         unsigned char abyCurrentNetAddr[ETH_ALEN]; __aligned(2)
273         bool bLinkPass;          /* link status: OK or fail */
274
275         unsigned int    uCurrRSSI;
276         unsigned char byCurrSQ;
277
278         unsigned long dwTxAntennaSel;
279         unsigned long dwRxAntennaSel;
280         unsigned char byAntennaCount;
281         unsigned char byRxAntennaMode;
282         unsigned char byTxAntennaMode;
283         bool bTxRxAntInv;
284
285         unsigned char *pbyTmpBuff;
286         unsigned int    uSIFS;    /* Current SIFS */
287         unsigned int    uDIFS;    /* Current DIFS */
288         unsigned int    uEIFS;    /* Current EIFS */
289         unsigned int    uSlot;    /* Current SlotTime */
290         unsigned int    uCwMin;   /* Current CwMin */
291         unsigned int    uCwMax;   /* CwMax is fixed on 1023. */
292         /* PHY parameter */
293         unsigned char bySIFS;
294         unsigned char byDIFS;
295         unsigned char byEIFS;
296         unsigned char bySlot;
297         unsigned char byCWMaxMin;
298
299         u8              byBBType; /* 0:11A, 1:11B, 2:11G */
300         u8              byPacketType; /*
301                                        * 0:11a,1:11b,2:11gb (only CCK
302                                        * in BasicRate), 3:11ga (OFDM in
303                                        * Basic Rate)
304                                        */
305         unsigned short wBasicRate;
306         unsigned char byACKRate;
307         unsigned char byTopOFDMBasicRate;
308         unsigned char byTopCCKBasicRate;
309
310         unsigned char byMinChannel;
311         unsigned char byMaxChannel;
312
313         unsigned char byPreambleType;
314         unsigned char byShortPreamble;
315
316         unsigned short wCurrentRate;
317         unsigned char byShortRetryLimit;
318         unsigned char byLongRetryLimit;
319         enum nl80211_iftype op_mode;
320         bool bBSSIDFilter;
321         unsigned short wMaxTransmitMSDULifetime;
322
323         bool bEncryptionEnable;
324         bool bLongHeader;
325         bool bShortSlotTime;
326         bool bProtectMode;
327         bool bNonERPPresent;
328         bool bBarkerPreambleMd;
329
330         bool bRadioControlOff;
331         bool bRadioOff;
332         bool bEnablePSMode;
333         unsigned short wListenInterval;
334         bool bPWBitOn;
335
336         /* GPIO Radio Control */
337         unsigned char byRadioCtl;
338         unsigned char byGPIO;
339         bool bHWRadioOff;
340         bool bPrvActive4RadioOFF;
341         bool bGPIOBlockRead;
342
343         /* Beacon related */
344         unsigned short wSeqCounter;
345         unsigned short wBCNBufLen;
346         bool bBeaconBufReady;
347         bool bBeaconSent;
348         bool bIsBeaconBufReadySet;
349         unsigned int    cbBeaconBufReadySetCnt;
350         bool bFixRate;
351         u16 byCurrentCh;
352
353         bool bAES;
354
355         unsigned char byAutoFBCtrl;
356
357         /* For Update BaseBand VGA Gain Offset */
358         bool bUpdateBBVGA;
359         unsigned int    uBBVGADiffCount;
360         unsigned char byBBVGANew;
361         unsigned char byBBVGACurrent;
362         unsigned char abyBBVGA[BB_VGA_LEVEL];
363         long                    ldBmThreshold[BB_VGA_LEVEL];
364
365         unsigned char byBBPreEDRSSI;
366         unsigned char byBBPreEDIndex;
367
368         unsigned long dwDiagRefCount;
369
370         /* For FOE Tuning */
371         unsigned char byFOETuning;
372
373         /* For RF Power table */
374         unsigned char byCCKPwr;
375         unsigned char byOFDMPwrG;
376         unsigned char byCurPwr;
377         char     byCurPwrdBm;
378         unsigned char abyCCKPwrTbl[CB_MAX_CHANNEL_24G+1];
379         unsigned char abyOFDMPwrTbl[CB_MAX_CHANNEL+1];
380         char    abyCCKDefaultPwr[CB_MAX_CHANNEL_24G+1];
381         char    abyOFDMDefaultPwr[CB_MAX_CHANNEL+1];
382         char    abyRegPwr[CB_MAX_CHANNEL+1];
383         char    abyLocalPwr[CB_MAX_CHANNEL+1];
384
385         /* BaseBand Loopback Use */
386         unsigned char byBBCR4d;
387         unsigned char byBBCRc9;
388         unsigned char byBBCR88;
389         unsigned char byBBCR09;
390
391         unsigned char abyEEPROM[EEP_MAX_CONTEXT_SIZE]; /* unsigned long alignment */
392
393         unsigned short wBeaconInterval;
394         u16 wake_up_count;
395
396         struct work_struct interrupt_work;
397
398         struct ieee80211_low_level_stats low_stats;
399 };
400
401 static inline struct vnt_rd_info *alloc_rd_info(void)
402 {
403         return kzalloc(sizeof(struct vnt_rd_info), GFP_ATOMIC);
404 }
405
406 static inline struct vnt_td_info *alloc_td_info(void)
407 {
408         return kzalloc(sizeof(struct vnt_td_info), GFP_ATOMIC);
409 }
410 #endif