6e41881d8c71583e0f5bfac8f6d4379cca0b2728
[safe/jmp/linux-2.6] / drivers / staging / otus / usbdrv.h
1 /*
2  * Copyright (c) 2007-2008 Atheros Communications Inc.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 /*                                                                      */
17 /*  Module Name : usbdrv.h                                              */
18 /*                                                                      */
19 /*  Abstract                                                            */
20 /*     This module contains network interface up/down related definition*/
21 /*                                                                      */
22 /*  NOTES                                                               */
23 /*     Platform dependent.                                              */
24 /*                                                                      */
25 /************************************************************************/
26
27 #ifndef _USBDRV_H
28 #define _USBDRV_H
29
30 #define WLAN_USB    0
31 #define WLAN_PCI    1
32
33 #include <linux/module.h>
34 #include <linux/pci.h>
35 #include <linux/netdevice.h>
36 #include <linux/etherdevice.h>
37 #include <linux/skbuff.h>
38 #include <linux/version.h>
39 #include <asm/uaccess.h>
40 #include <linux/wireless.h>
41 #include <linux/if_arp.h>
42 #include <asm/io.h>
43
44 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
45     #include <asm/div64.h>
46 #endif
47
48 #include "zdcompat.h"
49
50 #include "oal_dt.h"
51 #include "oal_marc.h"
52 #include "80211core/pub_zfi.h"
53 //#include "pub_zfw.h"
54 #include "80211core/pub_usb.h"
55
56 #include <linux/usb.h>
57 /* Please include header files for device type in the beginning of this file */
58 #define urb_t                       struct urb
59
60 #define usb_complete_t              usb_complete_t
61 #define pipe_t                      u32_t
62
63 /* USB Endpoint definition */
64 #define USB_WLAN_TX_PIPE                    1
65 #define USB_WLAN_RX_PIPE                    2
66 #define USB_REG_IN_PIPE                     3
67 #define USB_REG_OUT_PIPE                    4
68
69 #if (WLAN_HOSTIF == WLAN_USB)
70 #include <linux/usb.h>
71 #endif
72
73 #ifdef ZM_HOSTAPD_SUPPORT
74 #include "athr_common.h"
75 #endif
76
77 /**************************************************************************
78 **              Descriptor Data Structure
79 ***************************************************************************/
80 struct driver_stats {
81         struct net_device_stats net_stats;
82 };
83
84 #define ZM_MAX_RX_BUFFER_SIZE               8192
85
86 #if ZM_USB_TX_STREAM_MODE == 1
87 #define ZM_MAX_TX_AGGREGATE_NUM             4
88 #define ZM_USB_TX_BUF_SIZE                  8096
89 #define ZM_MAX_TX_URB_NUM                   4
90 #else
91 #define ZM_USB_TX_BUF_SIZE                  2048
92 #define ZM_MAX_TX_URB_NUM                   8
93 #endif
94 #define ZM_USB_REG_MAX_BUF_SIZE             64
95 #define ZM_MAX_RX_URB_NUM                   16
96 #define ZM_MAX_TX_BUF_NUM                   128
97
98 typedef struct UsbTxQ
99 {
100     zbuf_t *buf;
101     u8_t hdr[80];
102     u16_t hdrlen;
103     u8_t snap[8];
104     u16_t snapLen;
105     u8_t tail[16];
106     u16_t tailLen;
107     u16_t offset;
108 } UsbTxQ_t;
109
110
111 struct zdap_ioctl {
112         u16_t cmd;                /* Command to run */
113         u32_t addr;                /* Length of the data buffer */
114         u32_t value;              /* Pointer to the data buffer */
115         u8_t    data[0x100];
116 };
117
118 #define ZM_OAL_MAX_STA_SUPPORT 16
119
120 struct usbdrv_private
121 {
122         //linux used
123         struct net_device       *device;
124 #if (WLAN_HOSTIF == WLAN_PCI)
125         struct pci_dev          *pdev;
126 #endif
127 #if (WLAN_HOSTIF == WLAN_USB)
128         struct usb_device       *udev;
129         struct usb_interface    *interface;
130 #endif
131         struct driver_stats drv_stats;
132         char ifname[IFNAMSIZ];
133         int                     using_dac;
134         u8_t                    rev_id;         /* adapter PCI revision ID */
135         rwlock_t                isolate_lock;
136     spinlock_t      cs_lock;
137         int                     driver_isolated;
138 #if (WLAN_HOSTIF == WLAN_PCI)
139         void                    *regp;
140 #endif
141
142         /* timer for heart beat */
143         struct timer_list hbTimer10ms;
144
145         /* For driver core */
146         void* wd;
147
148 #if (WLAN_HOSTIF == WLAN_USB)
149         u8_t                    txUsbBuf[ZM_MAX_TX_URB_NUM][ZM_USB_TX_BUF_SIZE];
150         u8_t                    regUsbReadBuf[ZM_USB_REG_MAX_BUF_SIZE];
151         u8_t                    regUsbWriteBuf[ZM_USB_REG_MAX_BUF_SIZE];
152         urb_t                   *WlanTxDataUrb[ZM_MAX_TX_URB_NUM];
153         urb_t                   *WlanRxDataUrb[ZM_MAX_RX_URB_NUM];
154         urb_t                   *RegOutUrb;
155         urb_t                   *RegInUrb;
156         UsbTxQ_t                UsbTxBufQ[ZM_MAX_TX_BUF_NUM];
157         zbuf_t                  *UsbRxBufQ[ZM_MAX_RX_URB_NUM];
158         u16_t                   TxBufHead;
159         u16_t                   TxBufTail;
160         u16_t                   TxBufCnt;
161         u16_t                   TxUrbHead;
162         u16_t                   TxUrbTail;
163         u16_t                   TxUrbCnt;
164         u16_t                   RxBufHead;
165         u16_t                   RxBufTail;
166         u16_t                   RxBufCnt;
167 #endif
168
169 #if ZM_USB_STREAM_MODE == 1
170         zbuf_t                  *reamin_buf;
171 #endif
172
173 #ifdef ZM_HOSTAPD_SUPPORT
174         struct athr_wlan_param  athr_wpa_req;
175 #endif
176         struct sock             *netlink_sk;
177         u8_t            DeviceOpened; //CWYang(+)
178         u8_t            supIe[50];
179         u8_t            supLen;
180         struct ieee80211req_wpaie stawpaie[ZM_OAL_MAX_STA_SUPPORT];
181         u8_t            forwardMgmt;
182
183         struct zfCbUsbFuncTbl usbCbFunctions;
184
185         /* For keventd */
186         u32_t                   flags;
187         unsigned long           kevent_flags;
188         u16_t                   kevent_ready;
189
190         struct semaphore        ioctl_sem;
191         struct work_struct      kevent;
192         wait_queue_head_t       wait_queue_event;
193 #ifdef ZM_HALPLUS_LOCK
194         unsigned long           hal_irqFlag;
195 #endif
196         u16_t                   adapterState;
197 };
198
199 /* WDS */
200 #define ZM_WDS_PORT_NUMBER  6
201
202 struct zsWdsStruct
203 {
204     struct net_device* dev;
205     u16_t openFlag;
206 };
207
208 /* VAP */
209 #define ZM_VAP_PORT_NUMBER  7
210
211 struct zsVapStruct
212 {
213     struct net_device* dev;
214     u16_t openFlag;
215 };
216
217 /***************************************/
218
219 #define ZM_IOCTL_REG_READ                       0x01
220 #define ZM_IOCTL_REG_WRITE                      0x02
221 #define ZM_IOCTL_MEM_DUMP                       0x03
222 #define ZM_IOCTL_REG_DUMP                       0x05
223 #define ZM_IOCTL_TXD_DUMP                       0x06
224 #define ZM_IOCTL_RXD_DUMP                       0x07
225 #define ZM_IOCTL_MEM_READ                       0x0B
226 #define ZM_IOCTL_MEM_WRITE                      0x0C
227 #define ZM_IOCTL_DMA_TEST           0x10
228 #define ZM_IOCTL_REG_TEST           0x11
229 #define ZM_IOCTL_TEST               0x80
230 #define ZM_IOCTL_TALLY              0x81 //CWYang(+)
231 #define ZM_IOCTL_RTS                0xA0
232 #define ZM_IOCTL_MIX_MODE           0xA1
233 #define ZM_IOCTL_FRAG               0xA2
234 #define ZM_IOCTL_SCAN               0xA3
235 #define ZM_IOCTL_KEY                0xA4
236 #define ZM_IOCTL_RATE               0xA5
237 #define ZM_IOCTL_ENCRYPTION_MODE    0xA6
238 #define ZM_IOCTL_GET_TXCNT          0xA7
239 #define ZM_IOCTL_GET_DEAGG_CNT      0xA8
240 #define ZM_IOCTL_DURATION_MODE      0xA9
241 #define ZM_IOCTL_SET_AES_KEY        0xAA
242 #define ZM_IOCTL_SET_AES_MODE       0xAB
243 #define ZM_IOCTL_SIGNAL_STRENGTH    0xAC //CWYang(+)
244 #define ZM_IOCTL_SIGNAL_QUALITY     0xAD //CWYang(+)
245 #define ZM_IOCTL_SET_PIBSS_MODE     0xAE
246
247 #define ZDAPIOCTL                               SIOCDEVPRIVATE
248
249 enum devState {
250     Opened,
251     Enabled,
252     Disabled,
253     Closed
254 };
255
256 #endif  /* _USBDRV_H */
257