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