staging/otus: include slab.h from usbdrv.h
[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/uaccess.h>
39 #include <linux/wireless.h>
40 #include <linux/if_arp.h>
41 #include <linux/slab.h>
42 #include <linux/io.h>
43
44 #include "zdcompat.h"
45
46 #include "oal_dt.h"
47 #include "oal_marc.h"
48 #include "80211core/pub_zfi.h"
49 /* #include "pub_zfw.h" */
50 #include "80211core/pub_usb.h"
51
52 #include <linux/usb.h>
53 /* Please include header files for device type in the beginning of this file */
54 #define urb_t                       struct urb
55
56 #define usb_complete_t              usb_complete_t
57 #define pipe_t                      u32_t
58
59 /* USB Endpoint definition */
60 #define USB_WLAN_TX_PIPE                    1
61 #define USB_WLAN_RX_PIPE                    2
62 #define USB_REG_IN_PIPE                     3
63 #define USB_REG_OUT_PIPE                    4
64
65 #ifdef ZM_HOSTAPD_SUPPORT
66 #include "athr_common.h"
67 #endif
68
69 /**************************************************************************
70 **              Descriptor Data Structure
71 ***************************************************************************/
72 struct driver_stats {
73         struct net_device_stats net_stats;
74 };
75
76 #define ZM_MAX_RX_BUFFER_SIZE               8192
77
78 #if ZM_USB_TX_STREAM_MODE == 1
79 #define ZM_MAX_TX_AGGREGATE_NUM             4
80 #define ZM_USB_TX_BUF_SIZE                  8096
81 #define ZM_MAX_TX_URB_NUM                   4
82 #else
83 #define ZM_USB_TX_BUF_SIZE                  2048
84 #define ZM_MAX_TX_URB_NUM                   8
85 #endif
86 #define ZM_USB_REG_MAX_BUF_SIZE             64
87 #define ZM_MAX_RX_URB_NUM                   16
88 #define ZM_MAX_TX_BUF_NUM                   128
89
90 typedef struct UsbTxQ {
91     zbuf_t *buf;
92     u8_t hdr[80];
93     u16_t hdrlen;
94     u8_t snap[8];
95     u16_t snapLen;
96     u8_t tail[16];
97     u16_t tailLen;
98     u16_t offset;
99 } UsbTxQ_t;
100
101
102 struct zdap_ioctl {
103         u16_t cmd;                /* Command to run */
104         u32_t addr;               /* Length of the data buffer */
105         u32_t value;            /* Pointer to the data buffer */
106         u8_t    data[0x100];
107 };
108
109 #define ZM_OAL_MAX_STA_SUPPORT 16
110
111 struct usbdrv_private {
112         /* linux used */
113         struct net_device       *device;
114 #if (WLAN_HOSTIF == WLAN_PCI)
115         struct pci_dev          *pdev;
116 #endif
117 #if (WLAN_HOSTIF == WLAN_USB)
118         struct usb_device       *udev;
119         struct usb_interface    *interface;
120 #endif
121         struct driver_stats drv_stats;
122         char ifname[IFNAMSIZ];
123         int                       using_dac;
124         u8_t                    rev_id;         /* adapter PCI revision ID */
125         rwlock_t                isolate_lock;
126     spinlock_t      cs_lock;
127         int                     driver_isolated;
128 #if (WLAN_HOSTIF == WLAN_PCI)
129         void                    *regp;
130 #endif
131
132          /* timer for heart beat */
133         struct timer_list hbTimer10ms;
134
135         /* For driver core */
136         void *wd;
137
138 #if (WLAN_HOSTIF == WLAN_USB)
139         u8_t                  txUsbBuf[ZM_MAX_TX_URB_NUM][ZM_USB_TX_BUF_SIZE];
140         u8_t                  regUsbReadBuf[ZM_USB_REG_MAX_BUF_SIZE];
141         u8_t                  regUsbWriteBuf[ZM_USB_REG_MAX_BUF_SIZE];
142         urb_t                   *WlanTxDataUrb[ZM_MAX_TX_URB_NUM];
143         urb_t                   *WlanRxDataUrb[ZM_MAX_RX_URB_NUM];
144         urb_t                   *RegOutUrb;
145         urb_t                   *RegInUrb;
146         UsbTxQ_t                  UsbTxBufQ[ZM_MAX_TX_BUF_NUM];
147         zbuf_t              *UsbRxBufQ[ZM_MAX_RX_URB_NUM];
148          u16_t               TxBufHead;
149          u16_t               TxBufTail;
150          u16_t               TxBufCnt;
151          u16_t               TxUrbHead;
152          u16_t               TxUrbTail;
153          u16_t               TxUrbCnt;
154          u16_t               RxBufHead;
155          u16_t               RxBufTail;
156          u16_t               RxBufCnt;
157 #endif
158
159 #if ZM_USB_STREAM_MODE == 1
160          zbuf_t             *reamin_buf;
161 #endif
162
163 #ifdef ZM_HOSTAPD_SUPPORT
164          struct athr_wlan_param  athr_wpa_req;
165 #endif
166          struct sock          *netlink_sk;
167          u8_t        DeviceOpened; /* CWYang(+) */
168          u8_t        supIe[50];
169          u8_t        supLen;
170          struct ieee80211req_wpaie stawpaie[ZM_OAL_MAX_STA_SUPPORT];
171          u8_t        forwardMgmt;
172
173          struct zfCbUsbFuncTbl usbCbFunctions;
174
175          /* For keventd */
176          u32_t               flags;
177          unsigned long      kevent_flags;
178          u16_t               kevent_ready;
179
180          struct semaphore        ioctl_sem;
181          struct work_struct      kevent;
182          wait_queue_head_t      wait_queue_event;
183 #ifdef ZM_HALPLUS_LOCK
184          unsigned long      hal_irqFlag;
185 #endif
186          u16_t               adapterState;
187 };
188
189 /* WDS */
190 #define ZM_WDS_PORT_NUMBER  6
191
192 struct zsWdsStruct {
193     struct net_device *dev;
194     u16_t openFlag;
195 };
196
197 /* VAP */
198 #define ZM_VAP_PORT_NUMBER  7
199
200 struct zsVapStruct {
201     struct net_device *dev;
202     u16_t openFlag;
203 };
204
205 /***************************************/
206
207 #define ZM_IOCTL_REG_READ                       0x01
208 #define ZM_IOCTL_REG_WRITE                      0x02
209 #define ZM_IOCTL_MEM_DUMP                       0x03
210 #define ZM_IOCTL_REG_DUMP                       0x05
211 #define ZM_IOCTL_TXD_DUMP                       0x06
212 #define ZM_IOCTL_RXD_DUMP                       0x07
213 #define ZM_IOCTL_MEM_READ                       0x0B
214 #define ZM_IOCTL_MEM_WRITE                      0x0C
215 #define ZM_IOCTL_DMA_TEST                       0x10
216 #define ZM_IOCTL_REG_TEST                       0x11
217 #define ZM_IOCTL_TEST                           0x80
218 #define ZM_IOCTL_TALLY                          0x81 /* CWYang(+) */
219 #define ZM_IOCTL_RTS                            0xA0
220 #define ZM_IOCTL_MIX_MODE                       0xA1
221 #define ZM_IOCTL_FRAG                           0xA2
222 #define ZM_IOCTL_SCAN                           0xA3
223 #define ZM_IOCTL_KEY                            0xA4
224 #define ZM_IOCTL_RATE                           0xA5
225 #define ZM_IOCTL_ENCRYPTION_MODE                0xA6
226 #define ZM_IOCTL_GET_TXCNT                      0xA7
227 #define ZM_IOCTL_GET_DEAGG_CNT                  0xA8
228 #define ZM_IOCTL_DURATION_MODE                  0xA9
229 #define ZM_IOCTL_SET_AES_KEY                    0xAA
230 #define ZM_IOCTL_SET_AES_MODE                   0xAB
231 #define ZM_IOCTL_SIGNAL_STRENGTH                0xAC /* CWYang(+) */
232 #define ZM_IOCTL_SIGNAL_QUALITY                 0xAD /* CWYang(+) */
233 #define ZM_IOCTL_SET_PIBSS_MODE                 0xAE
234
235 #define ZDAPIOCTL                               SIOCDEVPRIVATE
236
237 enum devState {
238     Opened,
239     Enabled,
240     Disabled,
241     Closed
242 };
243
244 #endif  /* _USBDRV_H */
245