Merge branch 'linus' into timers/core
[pandora-kernel.git] / drivers / staging / otus / usbdrv.c
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 /*  Module Name : usbdrv.c                                              */
17 /*                                                                      */
18 /*  Abstract                                                            */
19 /*     This module contains network interface up/down related functions.*/
20 /*                                                                      */
21 /*  NOTES                                                               */
22 /*     Platform dependent.                                              */
23 /*                                                                      */
24 /************************************************************************/
25
26 /* src/usbdrv.c */
27
28 #define ZM_PIBSS_MODE   0
29 #define ZM_AP_MODE      0
30 #define ZM_CHANNEL      11
31 #define ZM_WEP_MOME     0
32 #define ZM_SHARE_AUTH   0
33 #define ZM_DISABLE_XMIT 0
34
35 #include "usbdrv.h"
36 #include "oal_dt.h"
37 #include "80211core/pub_zfi.h"
38
39 #include "linux/netlink.h"
40 #include "linux/rtnetlink.h"
41 #include "linux/slab.h"
42
43 #include <net/iw_handler.h>
44
45 #ifdef ZM_HOSTAPD_SUPPORT
46 #include "athr_common.h"
47 #endif
48
49 extern void zfDumpDescriptor(zdev_t* dev, u16_t type);
50 //extern void zfiWlanQueryMacAddress(zdev_t* dev, u8_t* addr);
51
52 // ISR handler
53 irqreturn_t usbdrv_intr(int, void *, struct pt_regs *);
54
55 // Network Device interface related function
56 int usbdrv_open(struct net_device *);
57 int usbdrv_close(struct net_device *);
58 int usbdrv_change_mtu(struct net_device *, int);
59 int usbdrv_set_mac(struct net_device *, void *);
60 int usbdrv_xmit_frame(struct sk_buff *, struct net_device *);
61 void usbdrv_set_multi(struct net_device *);
62 struct net_device_stats *usbdrv_get_stats(struct net_device *);
63
64 //wireless extension helper functions
65 int usbdrv_ioctl_setessid(struct net_device *dev, struct iw_point *erq);
66 int usbdrv_ioctl_getessid(struct net_device *dev, struct iw_point *erq);
67 int usbdrv_ioctl_setrts(struct net_device *dev, struct iw_param *rrq);
68 /* Wireless Extension Handler functions */
69 int usbdrvwext_giwmode(struct net_device *dev, struct iw_request_info* info,
70         __u32 *mode, char *extra);
71 int zfLnxPrivateIoctl(struct usbdrv_private *macp, struct zdap_ioctl *zdreq);
72
73 void zfLnx10msTimer(struct net_device* dev);
74 int zfUnregisterWdsDev(struct net_device* parentDev, u16_t wdsId);
75 int zfRegisterWdsDev(struct net_device* parentDev, u16_t wdsId);
76 int zfWdsOpen(struct net_device *dev);
77 int zfWdsClose(struct net_device *dev);
78 int zfLnxVapOpen(struct net_device *dev);
79 int zfLnxVapClose(struct net_device *dev);
80 int zfLnxVapXmitFrame(struct sk_buff *skb, struct net_device *dev);
81 int zfLnxRegisterVapDev(struct net_device* parentDev, u16_t vapId);
82 int usbdrv_wpa_ioctl(struct net_device *dev, struct athr_wlan_param *zdparm);
83 extern u16_t zfLnxGetVapId(zdev_t* dev);
84 extern u16_t zfLnxCheckTxBufferCnt(zdev_t *dev);
85 extern UsbTxQ_t *zfLnxGetUsbTxBuffer(zdev_t *dev);
86
87 extern u16_t zfLnxAuthNotify(zdev_t* dev, u16_t* macAddr);
88 extern u16_t zfLnxAsocNotify(zdev_t* dev, u16_t* macAddr, u8_t* body, u16_t bodySize, u16_t port);
89 extern u16_t zfLnxDisAsocNotify(zdev_t* dev, u8_t* macAddr, u16_t port);
90 extern u16_t zfLnxApConnectNotify(zdev_t* dev, u8_t* macAddr, u16_t port);
91 extern void zfLnxConnectNotify(zdev_t* dev, u16_t status, u16_t* bssid);
92 extern void zfLnxScanNotify(zdev_t* dev, struct zsScanResult* result);
93 extern void zfLnxStatisticsNotify(zdev_t* dev, struct zsStastics* result);
94 extern void zfLnxMicFailureNotify(zdev_t* dev, u16_t* addr, u16_t status);
95 extern void zfLnxApMicFailureNotify(zdev_t* dev, u8_t* addr, zbuf_t* buf);
96 extern void zfLnxIbssPartnerNotify(zdev_t* dev, u16_t status, struct zsPartnerNotifyEvent *event);
97 extern void zfLnxMacAddressNotify(zdev_t* dev, u8_t* addr);
98 extern void zfLnxSendCompleteIndication(zdev_t* dev, zbuf_t* buf);
99 extern void zfLnxRecvEth(zdev_t* dev, zbuf_t* buf, u16_t port);
100 extern void zfLnxRestoreBufData(zdev_t* dev, zbuf_t* buf);
101 #ifdef ZM_ENABLE_CENC
102 extern u16_t zfLnxCencAsocNotify(zdev_t* dev, u16_t* macAddr, u8_t* body, u16_t bodySize, u16_t port);
103 #endif //ZM_ENABLE_CENC
104 extern void zfLnxWatchDogNotify(zdev_t* dev);
105 extern void zfLnxRecv80211(zdev_t* dev, zbuf_t* buf, struct zsAdditionInfo* addInfo);
106 extern u8_t zfLnxCreateThread(zdev_t *dev);
107
108 /******************************************************************************
109 *                        P U B L I C   D A T A
110 *******************************************************************************
111 */
112
113 /* Definition of Wireless Extension */
114
115 /* wireless extension helper functions */
116 extern int usbdrv_ioctl_setessid(struct net_device *dev, struct iw_point *erq);
117 extern int usbdrv_ioctl_setrts(struct net_device *dev, struct iw_param *rrq);
118 /* Wireless Extension Handler functions */
119 extern int usbdrvwext_giwname(struct net_device *dev, struct iw_request_info *info,
120         union iwreq_data *wrq, char *extra);
121 extern int usbdrvwext_siwfreq(struct net_device *dev, struct iw_request_info *info,
122         struct iw_freq *freq, char *extra);
123 extern int usbdrvwext_giwfreq(struct net_device *dev, struct iw_request_info *info,
124         struct iw_freq *freq, char *extra);
125 extern int usbdrvwext_siwmode(struct net_device *dev, struct iw_request_info *info,
126         union iwreq_data *wrq, char *extra);
127 extern int usbdrvwext_giwmode(struct net_device *dev, struct iw_request_info *info,
128         __u32 *mode, char *extra);
129 extern int usbdrvwext_siwsens(struct net_device *dev, struct iw_request_info *info,
130                 struct iw_param *sens, char *extra);
131 extern int usbdrvwext_giwsens(struct net_device *dev, struct iw_request_info *info,
132                 struct iw_param *sens, char *extra);
133 extern int usbdrvwext_giwrange(struct net_device *dev, struct iw_request_info *info,
134         struct iw_point *data, char *extra);
135 extern int usbdrvwext_siwap(struct net_device *dev, struct iw_request_info *info,
136         struct sockaddr *MacAddr, char *extra);
137 extern int usbdrvwext_giwap(struct net_device *dev, struct iw_request_info *info,
138         struct sockaddr *MacAddr, char *extra);
139 extern int usbdrvwext_iwaplist(struct net_device *dev, struct iw_request_info *info,
140                 struct iw_point *data, char *extra);
141 extern int usbdrvwext_siwscan(struct net_device *dev, struct iw_request_info *info,
142         struct iw_point *data, char *extra);
143 extern int usbdrvwext_giwscan(struct net_device *dev, struct iw_request_info *info,
144         struct iw_point *data, char *extra);
145 extern int usbdrvwext_siwessid(struct net_device *dev, struct iw_request_info *info,
146         struct iw_point *essid, char *extra);
147 extern int usbdrvwext_giwessid(struct net_device *dev, struct iw_request_info *info,
148         struct iw_point *essid, char *extra);
149 extern int usbdrvwext_siwnickn(struct net_device *dev, struct iw_request_info *info,
150             struct iw_point *data, char *nickname);
151 extern int usbdrvwext_giwnickn(struct net_device *dev, struct iw_request_info *info,
152             struct iw_point *data, char *nickname);
153 extern int usbdrvwext_siwrate(struct net_device *dev, struct iw_request_info *info,
154         struct iw_param *frq, char *extra);
155 extern int usbdrvwext_giwrate(struct net_device *dev, struct iw_request_info *info,
156         struct iw_param *frq, char *extra);
157 extern int usbdrvwext_siwrts(struct net_device *dev, struct iw_request_info *info,
158         struct iw_param *rts, char *extra);
159 extern int usbdrvwext_giwrts(struct net_device *dev, struct iw_request_info *info,
160         struct iw_param *rts, char *extra);
161 extern int usbdrvwext_siwfrag(struct net_device *dev, struct iw_request_info *info,
162         struct iw_param *frag, char *extra);
163 extern int usbdrvwext_giwfrag(struct net_device *dev, struct iw_request_info *info,
164         struct iw_param *frag, char *extra);
165 extern int usbdrvwext_siwtxpow(struct net_device *dev, struct iw_request_info *info,
166                 struct iw_param *rrq, char *extra);
167 extern int usbdrvwext_giwtxpow(struct net_device *dev, struct iw_request_info *info,
168                 struct iw_param *rrq, char *extra);
169 extern int usbdrvwext_siwretry(struct net_device *dev, struct iw_request_info *info,
170             struct iw_param *rrq, char *extra);
171 extern int usbdrvwext_giwretry(struct net_device *dev, struct iw_request_info *info,
172             struct iw_param *rrq, char *extra);
173 extern int usbdrvwext_siwencode(struct net_device *dev, struct iw_request_info *info,
174         struct iw_point *erq, char *key);
175 extern int usbdrvwext_giwencode(struct net_device *dev, struct iw_request_info *info,
176         struct iw_point *erq, char *key);
177 extern int usbdrvwext_siwpower(struct net_device *dev, struct iw_request_info *info,
178         struct iw_param *frq, char *extra);
179 extern int usbdrvwext_giwpower(struct net_device *dev, struct iw_request_info *info,
180         struct iw_param *frq, char *extra);
181 extern int usbdrv_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
182 /*
183  * Structures to export the Wireless Handlers
184  */
185
186 struct iw_priv_args usbdrv_private_args[] = {
187 //    { SIOCIWFIRSTPRIV + 0x0, 0, 0, "list_bss" },
188 //    { SIOCIWFIRSTPRIV + 0x1, 0, 0, "card_reset" },
189     { SIOCIWFIRSTPRIV + 0x2, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_auth" },  /* 0 - open, 1 - shared key */
190     { SIOCIWFIRSTPRIV + 0x3, 0, IW_PRIV_TYPE_CHAR | 12, "get_auth" },
191 //    { SIOCIWFIRSTPRIV + 0x4, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_preamble" },  /* 0 - long, 1 - short */
192 //    { SIOCIWFIRSTPRIV + 0x5, 0, IW_PRIV_TYPE_CHAR | 6, "get_preamble" },
193 //    { SIOCIWFIRSTPRIV + 0x6, 0, 0, "cnt" },
194 //    { SIOCIWFIRSTPRIV + 0x7, 0, 0, "regs" },
195 //    { SIOCIWFIRSTPRIV + 0x8, 0, 0, "probe" },
196 //    { SIOCIWFIRSTPRIV + 0x9, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "dbg_flag" },
197 //    { SIOCIWFIRSTPRIV + 0xA, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "connect" },
198 //    { SIOCIWFIRSTPRIV + 0xB, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_mac_mode" },
199 //    { SIOCIWFIRSTPRIV + 0xC, 0, IW_PRIV_TYPE_CHAR | 12, "get_mac_mode" },
200 };
201
202 static iw_handler usbdrvwext_handler[] = {
203     (iw_handler) NULL,                              /* SIOCSIWCOMMIT */
204     (iw_handler) usbdrvwext_giwname,                /* SIOCGIWNAME */
205     (iw_handler) NULL,                              /* SIOCSIWNWID */
206     (iw_handler) NULL,                              /* SIOCGIWNWID */
207     (iw_handler) usbdrvwext_siwfreq,                /* SIOCSIWFREQ */
208     (iw_handler) usbdrvwext_giwfreq,                /* SIOCGIWFREQ */
209     (iw_handler) usbdrvwext_siwmode,                /* SIOCSIWMODE */
210     (iw_handler) usbdrvwext_giwmode,                /* SIOCGIWMODE */
211     (iw_handler) usbdrvwext_siwsens,                /* SIOCSIWSENS */
212     (iw_handler) usbdrvwext_giwsens,                /* SIOCGIWSENS */
213     (iw_handler) NULL, /* not used */               /* SIOCSIWRANGE */
214     (iw_handler) usbdrvwext_giwrange,               /* SIOCGIWRANGE */
215     (iw_handler) NULL, /* not used */               /* SIOCSIWPRIV */
216     (iw_handler) NULL, /* kernel code */            /* SIOCGIWPRIV */
217     (iw_handler) NULL, /* not used */               /* SIOCSIWSTATS */
218     (iw_handler) NULL, /* kernel code */            /* SIOCGIWSTATS */
219     (iw_handler) NULL,                              /* SIOCSIWSPY */
220     (iw_handler) NULL,                              /* SIOCGIWSPY */
221     (iw_handler) NULL,                              /* -- hole -- */
222     (iw_handler) NULL,                              /* -- hole -- */
223     (iw_handler) usbdrvwext_siwap,                  /* SIOCSIWAP */
224     (iw_handler) usbdrvwext_giwap,                  /* SIOCGIWAP */
225     (iw_handler) NULL,              /* -- hole -- */
226     (iw_handler) usbdrvwext_iwaplist,               /* SIOCGIWAPLIST */
227     (iw_handler) usbdrvwext_siwscan,                /* SIOCSIWSCAN */
228     (iw_handler) usbdrvwext_giwscan,                /* SIOCGIWSCAN */
229     (iw_handler) usbdrvwext_siwessid,               /* SIOCSIWESSID */
230     (iw_handler) usbdrvwext_giwessid,               /* SIOCGIWESSID */
231
232     (iw_handler) usbdrvwext_siwnickn,               /* SIOCSIWNICKN */
233     (iw_handler) usbdrvwext_giwnickn,               /* SIOCGIWNICKN */
234     (iw_handler) NULL,                              /* -- hole -- */
235     (iw_handler) NULL,                              /* -- hole -- */
236     (iw_handler) usbdrvwext_siwrate,                /* SIOCSIWRATE */
237     (iw_handler) usbdrvwext_giwrate,                /* SIOCGIWRATE */
238     (iw_handler) usbdrvwext_siwrts,                 /* SIOCSIWRTS */
239     (iw_handler) usbdrvwext_giwrts,                 /* SIOCGIWRTS */
240     (iw_handler) usbdrvwext_siwfrag,                /* SIOCSIWFRAG */
241     (iw_handler) usbdrvwext_giwfrag,                /* SIOCGIWFRAG */
242     (iw_handler) usbdrvwext_siwtxpow,               /* SIOCSIWTXPOW */
243     (iw_handler) usbdrvwext_giwtxpow,               /* SIOCGIWTXPOW */
244     (iw_handler) usbdrvwext_siwretry,               /* SIOCSIWRETRY */
245     (iw_handler) usbdrvwext_giwretry,               /* SIOCGIWRETRY */
246     (iw_handler) usbdrvwext_siwencode,              /* SIOCSIWENCODE */
247     (iw_handler) usbdrvwext_giwencode,              /* SIOCGIWENCODE */
248     (iw_handler) usbdrvwext_siwpower,               /* SIOCSIWPOWER */
249     (iw_handler) usbdrvwext_giwpower,               /* SIOCGIWPOWER */
250 };
251
252 static const iw_handler usbdrv_private_handler[] =
253 {
254         //(iw_handler) usbdrvwext_setparam,             /* SIOCWFIRSTPRIV+0 */
255         //(iw_handler) usbdrvwext_getparam,             /* SIOCWFIRSTPRIV+1 */
256         //(iw_handler) usbdrvwext_setkey,                   /* SIOCWFIRSTPRIV+2 */
257         //(iw_handler) usbdrvwext_setwmmparams, /* SIOCWFIRSTPRIV+3 */
258         //(iw_handler) usbdrvwext_delkey,                   /* SIOCWFIRSTPRIV+4 */
259         //(iw_handler) usbdrvwext_getwmmparams, /* SIOCWFIRSTPRIV+5 */
260         //(iw_handler) usbdrvwext_setmlme,              /* SIOCWFIRSTPRIV+6 */
261         //(iw_handler) usbdrvwext_getchaninfo,  /* SIOCWFIRSTPRIV+7 */
262         //(iw_handler) usbdrvwext_setoptie,             /* SIOCWFIRSTPRIV+8 */
263         //(iw_handler) usbdrvwext_getoptie,             /* SIOCWFIRSTPRIV+9 */
264         //(iw_handler) usbdrvwext_addmac,                   /* SIOCWFIRSTPRIV+10 */
265         //(iw_handler) usbdrvwext_getscanresults,       /* SIOCWFIRSTPRIV+11 */
266         //(iw_handler) usbdrvwext_delmac,                   /* SIOCWFIRSTPRIV+12 */
267         //(iw_handler) usbdrvwext_getchanlist,  /* SIOCWFIRSTPRIV+13 */
268         //(iw_handler) usbdrvwext_setchanlist,  /* SIOCWFIRSTPRIV+14 */
269         //(iw_handler) NULL,                                    /* SIOCWFIRSTPRIV+15 */
270         //(iw_handler) usbdrvwext_chanswitch,       /* SIOCWFIRSTPRIV+16 */
271         //(iw_handler) usbdrvwext_setmode,              /* SIOCWFIRSTPRIV+17 */
272         //(iw_handler) usbdrvwext_getmode,              /* SIOCWFIRSTPRIV+18 */
273     NULL,               /* SIOCIWFIRSTPRIV */
274 };
275
276 static struct iw_handler_def p80211wext_handler_def = {
277     .num_standard = sizeof(usbdrvwext_handler) / sizeof(iw_handler),
278     .num_private = sizeof(usbdrv_private_handler)/sizeof(iw_handler),
279     .num_private_args = sizeof(usbdrv_private_args)/sizeof(struct iw_priv_args),
280     .standard = usbdrvwext_handler,
281     .private = (iw_handler *) usbdrv_private_handler,
282     .private_args = (struct iw_priv_args *) usbdrv_private_args
283 };
284
285 /* WDS */
286 /* struct zsWdsStruct wds[ZM_WDS_PORT_NUMBER]; */
287 /* void zfInitWdsStruct(void);  */
288
289 /* VAP */
290 struct zsVapStruct vap[ZM_VAP_PORT_NUMBER];
291 void zfLnxInitVapStruct(void);
292
293
294 /**
295  * usbdrv_intr - interrupt handler
296  * @irq: the IRQ number
297  * @dev_inst: the net_device struct
298  * @regs: registers (unused)
299  *
300  * This routine is the ISR for the usbdrv board. It services
301  * the RX & TX queues & starts the RU if it has stopped due
302  * to no resources.
303  */
304 irqreturn_t usbdrv_intr(int irq, void *dev_inst, struct pt_regs *regs)
305 {
306     struct net_device *dev;
307     struct usbdrv_private *macp;
308
309     dev = dev_inst;
310     macp = dev->ml_priv;
311
312
313     /* Read register error, card may be unpluged */
314     if (0)//(intr_status == -1)
315         return IRQ_NONE;
316
317     /* the device is closed, don't continue or else bad things may happen. */
318     if (!netif_running(dev))
319         return IRQ_NONE;
320
321     if (macp->driver_isolated)
322         return IRQ_NONE;
323
324 #if (WLAN_HOSTIF == WLAN_PCI)
325     //zfiIsrPci(dev);
326 #endif
327
328     return IRQ_HANDLED;
329 }
330
331 int usbdrv_open(struct net_device *dev)
332 {
333     struct usbdrv_private *macp = dev->ml_priv;
334     int rc = 0;
335     u16_t size;
336     void* mem;
337     //unsigned char addr[6];
338     struct zsCbFuncTbl cbFuncTbl;
339
340     printk("Enter open()\n");
341
342 /*
343  * #ifndef CONFIG_SMP
344  *   read_lock(&(macp->isolate_lock));
345  * #endif
346  */
347     if (macp->driver_isolated) {
348         rc = -EBUSY;
349         goto exit;
350     }
351
352     size = zfiGlobalDataSize(dev);
353     if ((mem = kmalloc(size, GFP_KERNEL)) == NULL)
354     {
355         rc = -EBUSY;
356         goto exit;
357     }
358     macp->wd = mem;
359
360     memset(&cbFuncTbl, 0, sizeof(struct zsCbFuncTbl));
361     cbFuncTbl.zfcbAuthNotify = zfLnxAuthNotify;
362     cbFuncTbl.zfcbAuthNotify = zfLnxAuthNotify;
363     cbFuncTbl.zfcbAsocNotify = zfLnxAsocNotify;
364     cbFuncTbl.zfcbDisAsocNotify = zfLnxDisAsocNotify;
365     cbFuncTbl.zfcbApConnectNotify = zfLnxApConnectNotify;
366     cbFuncTbl.zfcbConnectNotify = zfLnxConnectNotify;
367     cbFuncTbl.zfcbScanNotify = zfLnxScanNotify;
368     cbFuncTbl.zfcbMicFailureNotify = zfLnxMicFailureNotify;
369     cbFuncTbl.zfcbApMicFailureNotify = zfLnxApMicFailureNotify;
370     cbFuncTbl.zfcbIbssPartnerNotify = zfLnxIbssPartnerNotify;
371     cbFuncTbl.zfcbMacAddressNotify = zfLnxMacAddressNotify;
372     cbFuncTbl.zfcbSendCompleteIndication = zfLnxSendCompleteIndication;
373     cbFuncTbl.zfcbRecvEth = zfLnxRecvEth;
374     cbFuncTbl.zfcbRecv80211 = zfLnxRecv80211;
375     cbFuncTbl.zfcbRestoreBufData = zfLnxRestoreBufData;
376 #ifdef ZM_ENABLE_CENC
377     cbFuncTbl.zfcbCencAsocNotify = zfLnxCencAsocNotify;
378 #endif //ZM_ENABLE_CENC
379     cbFuncTbl.zfcbHwWatchDogNotify = zfLnxWatchDogNotify;
380     zfiWlanOpen(dev, &cbFuncTbl);
381
382 #if 0
383     {
384         //u16_t mac[3] = {0x1300, 0xb6d4, 0x5aaf};
385         u16_t mac[3] = {0x8000, 0x00ab, 0x0000};
386         //zfiWlanSetMacAddress(dev, mac);
387     }
388     /* MAC address */
389     zfiWlanQueryMacAddress(dev, addr);
390     dev->dev_addr[0] = addr[0];
391     dev->dev_addr[1] = addr[1];
392     dev->dev_addr[2] = addr[2];
393     dev->dev_addr[3] = addr[3];
394     dev->dev_addr[4] = addr[4];
395     dev->dev_addr[5] = addr[5];
396 #endif
397     /* zfwMacAddressNotify() will be called to setup dev->dev_addr[] */
398
399     zfLnxCreateThread(dev);
400
401     mod_timer(&(macp->hbTimer10ms), jiffies + (1*HZ)/100);   /* 10 ms */
402
403     netif_carrier_on(dev);
404
405     netif_start_queue(dev);
406
407 #if ZM_AP_MODE == 1
408     zfiWlanSetWlanMode(dev, ZM_MODE_AP);
409     zfiWlanSetBasicRate(dev, 0xf, 0, 0);
410     zfiWlanSetSSID(dev, "OTUS_CWY", 8);
411     zfiWlanSetDtimCount(dev, 3);
412
413   #if ZM_WEP_MOME == 1
414     {
415         u8_t key[16] = {0x12, 0x34, 0x56, 0x78, 0x90};
416         struct zsKeyInfo keyInfo;
417
418         keyInfo.keyLength = 5;
419         keyInfo.keyIndex = 0;
420         keyInfo.flag = 0;
421         keyInfo.key = key;
422         zfiWlanSetKey(dev, keyInfo);
423
424         zfiWlanSetEncryMode(dev, ZM_WEP64);
425     }
426
427     #if ZM_SHARE_AUTH == 1
428     zfiWlanSetAuthenticationMode(dev, 1);
429     #endif /* #if ZM_SHARE_AUTH == 1 */
430   #endif /* #if ZM_WEP_MOME == 1 */
431
432 #elif ZM_PIBSS_MODE == 1
433     zfiWlanSetWlanMode(dev, ZM_MODE_PSEUDO);
434 #else
435     zfiWlanSetWlanMode(dev, ZM_MODE_INFRASTRUCTURE);
436 #endif
437     /* zfiWlanSetChannel(dev, ZM_CHANNEL, FALSE); */
438     zfiWlanSetFrequency(dev, 2462000, FALSE);
439     zfiWlanSetRtsThreshold(dev, 32767);
440     zfiWlanSetFragThreshold(dev, 0);
441
442     zfiWlanEnable(dev);
443
444 #ifdef ZM_ENABLE_CENC
445     macp->netlink_sk = netlink_kernel_create(NETLINK_USERSOCK, 1, NULL, THIS_MODULE);
446
447     if (macp->netlink_sk == NULL)
448     {
449         printk(KERN_ERR "Can't create NETLINK socket\n");
450     }
451 #endif
452
453     macp->DeviceOpened = 1;
454 exit:
455 //#ifndef CONFIG_SMP
456 //    read_unlock(&(macp->isolate_lock));
457 //#endif
458     //zfRegisterWdsDev(dev, 0);
459     //zfLnxRegisterVapDev(dev, 0);
460
461     return rc;
462 }
463
464
465
466
467 /**
468  * usbdrv_get_stats - get driver statistics
469  * @dev: adapter's net_device struct
470  *
471  * This routine is called when the OS wants the adapter's stats returned.
472  * It returns the address of the net_device_stats stucture for the device.
473  * If the statistics are currently being updated, then they might be incorrect
474  * for a short while. However, since this cannot actually cause damage, no
475  * locking is used.
476  */
477
478 struct net_device_stats * usbdrv_get_stats(struct net_device *dev)
479 {
480     struct usbdrv_private *macp = dev->ml_priv;
481
482     macp->drv_stats.net_stats.tx_errors =
483         macp->drv_stats.net_stats.tx_carrier_errors +
484         macp->drv_stats.net_stats.tx_aborted_errors;
485
486     macp->drv_stats.net_stats.rx_errors =
487         macp->drv_stats.net_stats.rx_crc_errors +
488         macp->drv_stats.net_stats.rx_frame_errors +
489         macp->drv_stats.net_stats.rx_length_errors;
490
491
492     return &(macp->drv_stats.net_stats);
493 }
494
495
496 /**
497  * usbdrv_set_mac - set the MAC address
498  * @dev: adapter's net_device struct
499  * @addr: the new address
500  *
501  * This routine sets the ethernet address of the board
502  * Returns:
503  * 0  - if successful
504  * -1 - otherwise
505  */
506
507 int usbdrv_set_mac(struct net_device *dev, void *addr)
508 {
509     struct usbdrv_private *macp;
510     int rc = -1;
511
512     macp = dev->ml_priv;
513     read_lock(&(macp->isolate_lock));
514
515     if (macp->driver_isolated) {
516         goto exit;
517     }
518
519     rc = 0;
520
521
522 exit:
523     read_unlock(&(macp->isolate_lock));
524     return rc;
525 }
526
527
528
529 void
530 usbdrv_isolate_driver(struct usbdrv_private *macp)
531 {
532 #ifndef CONFIG_SMP
533     write_lock_irq(&(macp->isolate_lock));
534 #endif
535     macp->driver_isolated = TRUE;
536 #ifndef CONFIG_SMP
537     write_unlock_irq(&(macp->isolate_lock));
538 #endif
539
540     if (netif_running(macp->device))
541     {
542         netif_carrier_off(macp->device);
543         netif_stop_queue(macp->device);
544     }
545 }
546
547 #define VLAN_SIZE       4
548 int usbdrv_change_mtu(struct net_device *dev, int new_mtu)
549 {
550     if ((new_mtu < 68) || (new_mtu > (ETH_DATA_LEN + VLAN_SIZE)))
551         return -EINVAL;
552
553     dev->mtu = new_mtu;
554     return 0;
555 }
556
557 void zfLnxUnlinkAllUrbs(struct usbdrv_private *macp);
558
559 int usbdrv_close(struct net_device *dev)
560 {
561 extern void zfHpLedCtrl(struct net_device *dev, u16_t ledId, u8_t mode);
562
563     struct usbdrv_private *macp = dev->ml_priv;
564
565     printk(KERN_DEBUG "usbdrv_close\n");
566
567     netif_carrier_off(macp->device);
568
569     del_timer_sync(&macp->hbTimer10ms);
570
571     printk(KERN_DEBUG "usbdrv_netif_carrier_off\n");
572
573     usbdrv_isolate_driver(macp);
574
575     printk(KERN_DEBUG "usbdrv_isolate_driver\n");
576
577     netif_carrier_off(macp->device);
578 #ifdef ZM_ENABLE_CENC
579     /* CENC */
580     if (macp->netlink_sk != NULL)
581     {
582     //    sock_release(macp->netlink_sk);
583         printk(KERN_ERR "usbdrv close netlink socket\n");
584     }
585 #endif //ZM_ENABLE_CENC
586 #if (WLAN_HOSTIF == WLAN_PCI)
587     //free_irq(dev->irq, dev);
588 #endif
589
590     /* Turn off LED */
591     zfHpLedCtrl(dev, 0, 0);
592     zfHpLedCtrl(dev, 1, 0);
593
594     /* Delay for a while */
595     mdelay(10);
596
597     /* clear WPA/RSN IE */
598     macp->supIe[1] = 0;
599
600     /* set the isolate flag to false, so usbdrv_open can be called */
601     macp->driver_isolated = FALSE;
602
603     zfiWlanClose(dev);
604     kfree(macp->wd);
605
606     zfLnxUnlinkAllUrbs(macp);
607
608     return 0;
609 }
610
611
612
613
614 int usbdrv_xmit_frame(struct sk_buff *skb, struct net_device *dev)
615 {
616     int notify_stop = FALSE;
617     struct usbdrv_private *macp = dev->ml_priv;
618
619 #if 0
620     /* Test code */
621     {
622         struct sk_buff* s;
623
624         s = skb_copy_expand(skb, 8, 0, GFP_ATOMIC);
625         skb_push(s, 8);
626         s->data[0] = 'z';
627         s->data[1] = 'y';
628         s->data[2] = 'd';
629         s->data[3] = 'a';
630         s->data[4] = 's';
631         printk("len1=%d, len2=%d", skb->len, s->len);
632         netlink_broadcast(rtnl, s, 0, RTMGRP_LINK, GFP_ATOMIC);
633     }
634 #endif
635
636 #if ZM_DISABLE_XMIT
637     dev_kfree_skb_irq(skb);
638 #else
639     zfiTxSendEth(dev, skb, 0);
640 #endif
641     macp->drv_stats.net_stats.tx_bytes += skb->len;
642     macp->drv_stats.net_stats.tx_packets++;
643
644     //dev_kfree_skb_irq(skb);
645
646     if (notify_stop) {
647         netif_carrier_off(dev);
648         netif_stop_queue(dev);
649     }
650
651     return NETDEV_TX_OK;
652 }
653
654
655
656
657 void usbdrv_set_multi(struct net_device *dev)
658 {
659
660
661     if (!(dev->flags & IFF_UP))
662         return;
663
664         return;
665
666 }
667
668
669
670 /**
671  * usbdrv_clear_structs - free resources
672
673  * @dev: adapter's net_device struct
674  *
675  * Free all device specific structs, unmap i/o address, etc.
676  */
677 void usbdrv_clear_structs(struct net_device *dev)
678 {
679     struct usbdrv_private *macp = dev->ml_priv;
680
681
682 #if (WLAN_HOSTIF == WLAN_PCI)
683     iounmap(macp->regp);
684
685     pci_release_regions(macp->pdev);
686     pci_disable_device(macp->pdev);
687     pci_set_drvdata(macp->pdev, NULL);
688 #endif
689
690     kfree(macp);
691
692     kfree(dev);
693
694 }
695
696 void usbdrv_remove1(struct pci_dev *pcid)
697 {
698     struct net_device *dev;
699     struct usbdrv_private *macp;
700
701     if (!(dev = (struct net_device *) pci_get_drvdata(pcid)))
702         return;
703
704     macp = dev->ml_priv;
705     unregister_netdev(dev);
706
707     usbdrv_clear_structs(dev);
708 }
709
710
711 void zfLnx10msTimer(struct net_device* dev)
712 {
713     struct usbdrv_private *macp = dev->ml_priv;
714
715     mod_timer(&(macp->hbTimer10ms), jiffies + (1*HZ)/100);   //10 ms
716     zfiHeartBeat(dev);
717     return;
718 }
719
720 void zfLnxInitVapStruct(void)
721 {
722     u16_t i;
723
724     for (i = 0; i < ZM_VAP_PORT_NUMBER; i++)
725     {
726         vap[i].dev = NULL;
727         vap[i].openFlag = 0;
728     }
729 }
730
731 int zfLnxVapOpen(struct net_device *dev)
732 {
733     u16_t vapId;
734
735     vapId = zfLnxGetVapId(dev);
736
737     if (vap[vapId].openFlag == 0)
738     {
739         vap[vapId].openFlag = 1;
740         printk("zfLnxVapOpen : device name=%s, vap ID=%d\n", dev->name, vapId);
741         zfiWlanSetSSID(dev, "vap1", 4);
742         zfiWlanEnable(dev);
743         netif_start_queue(dev);
744     }
745     else
746     {
747         printk("VAP opened error : vap ID=%d\n", vapId);
748     }
749         return 0;
750 }
751
752 int zfLnxVapClose(struct net_device *dev)
753 {
754     u16_t vapId;
755
756     vapId = zfLnxGetVapId(dev);
757
758     if (vapId != 0xffff)
759     {
760         if (vap[vapId].openFlag == 1)
761         {
762             printk("zfLnxVapClose: device name=%s, vap ID=%d\n", dev->name, vapId);
763
764             netif_stop_queue(dev);
765             vap[vapId].openFlag = 0;
766         }
767         else
768         {
769             printk("VAP port was not opened : vap ID=%d\n", vapId);
770         }
771     }
772         return 0;
773 }
774
775 int zfLnxVapXmitFrame(struct sk_buff *skb, struct net_device *dev)
776 {
777     int notify_stop = FALSE;
778     struct usbdrv_private *macp = dev->ml_priv;
779     u16_t vapId;
780
781     vapId = zfLnxGetVapId(dev);
782     //printk("zfLnxVapXmitFrame: vap ID=%d\n", vapId);
783     //printk("zfLnxVapXmitFrame(), skb=%lxh\n", (u32_t)skb);
784
785     if (vapId >= ZM_VAP_PORT_NUMBER)
786     {
787         dev_kfree_skb_irq(skb);
788         return NETDEV_TX_OK;
789     }
790 #if 1
791     if (vap[vapId].openFlag == 0)
792     {
793         dev_kfree_skb_irq(skb);
794         return NETDEV_TX_OK;
795     }
796 #endif
797
798
799     zfiTxSendEth(dev, skb, 0x1);
800
801     macp->drv_stats.net_stats.tx_bytes += skb->len;
802     macp->drv_stats.net_stats.tx_packets++;
803
804     //dev_kfree_skb_irq(skb);
805
806     if (notify_stop) {
807         netif_carrier_off(dev);
808         netif_stop_queue(dev);
809     }
810
811     return NETDEV_TX_OK;
812 }
813
814 static const struct net_device_ops vap_netdev_ops = {
815         .ndo_open               = zfLnxVapOpen,
816         .ndo_stop               = zfLnxVapClose,
817         .ndo_start_xmit         = zfLnxVapXmitFrame,
818         .ndo_get_stats          = usbdrv_get_stats,
819         .ndo_change_mtu         = usbdrv_change_mtu,
820         .ndo_validate_addr      = eth_validate_addr,
821         .ndo_set_mac_address    = eth_mac_addr,
822 #ifdef ZM_HOSTAPD_SUPPORT
823         .ndo_do_ioctl           = usbdrv_ioctl,
824 #else
825         .ndo_do_ioctl           = NULL,
826 #endif
827 };
828
829 int zfLnxRegisterVapDev(struct net_device* parentDev, u16_t vapId)
830 {
831     /* Allocate net device structure */
832     vap[vapId].dev = alloc_etherdev(0);
833     printk("Register vap dev=%p\n", vap[vapId].dev);
834
835     if(vap[vapId].dev == NULL) {
836         printk("alloc_etherdev fail\n");
837         return -ENOMEM;
838     }
839
840     /* Setup the default settings */
841     ether_setup(vap[vapId].dev);
842
843     /* MAC address */
844     memcpy(vap[vapId].dev->dev_addr, parentDev->dev_addr, ETH_ALEN);
845
846     vap[vapId].dev->irq = parentDev->irq;
847     vap[vapId].dev->base_addr = parentDev->base_addr;
848     vap[vapId].dev->mem_start = parentDev->mem_start;
849     vap[vapId].dev->mem_end = parentDev->mem_end;
850     vap[vapId].dev->ml_priv = parentDev->ml_priv;
851
852     //dev->hard_start_xmit = &zd1212_wds_xmit_frame;
853     vap[vapId].dev->netdev_ops = &vap_netdev_ops;
854     vap[vapId].dev->destructor = free_netdev;
855
856     vap[vapId].dev->tx_queue_len = 0;
857
858     vap[vapId].dev->dev_addr[0] = parentDev->dev_addr[0];
859     vap[vapId].dev->dev_addr[1] = parentDev->dev_addr[1];
860     vap[vapId].dev->dev_addr[2] = parentDev->dev_addr[2];
861     vap[vapId].dev->dev_addr[3] = parentDev->dev_addr[3];
862     vap[vapId].dev->dev_addr[4] = parentDev->dev_addr[4];
863     vap[vapId].dev->dev_addr[5] = parentDev->dev_addr[5] + (vapId+1);
864
865     /* Stop the network queue first */
866     netif_stop_queue(vap[vapId].dev);
867
868     sprintf(vap[vapId].dev->name, "vap%d", vapId);
869     printk("Register VAP dev success : %s\n", vap[vapId].dev->name);
870
871     if(register_netdevice(vap[vapId].dev) != 0) {
872         printk("register VAP device fail\n");
873         vap[vapId].dev = NULL;
874         return -EINVAL;
875     }
876
877     return 0;
878 }
879
880 int zfLnxUnregisterVapDev(struct net_device* parentDev, u16_t vapId)
881 {
882     int ret = 0;
883
884     printk("Unregister VAP dev : %s\n", vap[vapId].dev->name);
885
886     if(vap[vapId].dev != NULL) {
887         printk("Unregister vap dev=%p\n", vap[vapId].dev);
888         //
889         //unregister_netdevice(wds[wdsId].dev);
890         unregister_netdev(vap[vapId].dev);
891
892         printk("VAP unregister_netdevice\n");
893         vap[vapId].dev = NULL;
894     }
895     else {
896         printk("unregister VAP device: %d fail\n", vapId);
897         ret = -EINVAL;
898     }
899
900     return ret;
901 }
902
903
904
905 #  define SUBMIT_URB(u,f)       usb_submit_urb(u,f)
906 #  define USB_ALLOC_URB(u,f)    usb_alloc_urb(u,f)
907
908 //extern void zfiWlanQueryMacAddress(zdev_t* dev, u8_t* addr);
909
910 extern int usbdrv_open(struct net_device *dev);
911 extern int usbdrv_close(struct net_device *dev);
912 extern int usbdrv_xmit_frame(struct sk_buff *skb, struct net_device *dev);
913 extern int usbdrv_xmit_frame(struct sk_buff *skb, struct net_device *dev);
914 extern int usbdrv_change_mtu(struct net_device *dev, int new_mtu);
915 extern void usbdrv_set_multi(struct net_device *dev);
916 extern int usbdrv_set_mac(struct net_device *dev, void *addr);
917 extern struct net_device_stats * usbdrv_get_stats(struct net_device *dev);
918 extern int usbdrv_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
919 extern UsbTxQ_t *zfLnxGetUsbTxBuffer(struct net_device *dev);
920
921 int zfLnxAllocAllUrbs(struct usbdrv_private *macp)
922 {
923     struct usb_interface *interface = macp->interface;
924     struct usb_host_interface *iface_desc = &interface->altsetting[0];
925
926     struct usb_endpoint_descriptor *endpoint;
927     int i;
928
929     /* descriptor matches, let's find the endpoints needed */
930     /* check out the endpoints */
931     for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i)
932     {
933         endpoint = &iface_desc->endpoint[i].desc;
934          if (usb_endpoint_is_bulk_in(endpoint))
935         {
936             /* we found a bulk in endpoint */
937             printk(KERN_ERR "bulk in: wMaxPacketSize = %x\n", le16_to_cpu(endpoint->wMaxPacketSize));
938         }
939
940          if (usb_endpoint_is_bulk_out(endpoint))
941         {
942             /* we found a bulk out endpoint */
943             printk(KERN_ERR "bulk out: wMaxPacketSize = %x\n", le16_to_cpu(endpoint->wMaxPacketSize));
944         }
945
946          if (usb_endpoint_is_int_in(endpoint))
947         {
948             /* we found a interrupt in endpoint */
949             printk(KERN_ERR "interrupt in: wMaxPacketSize = %x\n", le16_to_cpu(endpoint->wMaxPacketSize));
950             printk(KERN_ERR "interrupt in: int_interval = %d\n", endpoint->bInterval);
951         }
952
953          if (usb_endpoint_is_int_out(endpoint))
954         {
955             /* we found a interrupt out endpoint */
956             printk(KERN_ERR "interrupt out: wMaxPacketSize = %x\n", le16_to_cpu(endpoint->wMaxPacketSize));
957             printk(KERN_ERR "interrupt out: int_interval = %d\n", endpoint->bInterval);
958         }
959     }
960
961     /* Allocate all Tx URBs */
962     for (i = 0; i < ZM_MAX_TX_URB_NUM; i++)
963     {
964         macp->WlanTxDataUrb[i] = USB_ALLOC_URB(0, GFP_KERNEL);
965
966         if (macp->WlanTxDataUrb[i] == 0)
967         {
968             int j;
969
970             /* Free all urbs */
971             for (j = 0; j < i; j++)
972             {
973                 usb_free_urb(macp->WlanTxDataUrb[j]);
974             }
975
976             return 0;
977         }
978     }
979
980     /* Allocate all Rx URBs */
981     for (i = 0; i < ZM_MAX_RX_URB_NUM; i++)
982     {
983         macp->WlanRxDataUrb[i] = USB_ALLOC_URB(0, GFP_KERNEL);
984
985         if (macp->WlanRxDataUrb[i] == 0)
986         {
987             int j;
988
989             /* Free all urbs */
990             for (j = 0; j < i; j++)
991             {
992                 usb_free_urb(macp->WlanRxDataUrb[j]);
993             }
994
995             for (j = 0; j < ZM_MAX_TX_URB_NUM; j++)
996             {
997                 usb_free_urb(macp->WlanTxDataUrb[j]);
998             }
999
1000             return 0;
1001         }
1002     }
1003
1004     /* Allocate Register Read/Write USB */
1005     macp->RegOutUrb = USB_ALLOC_URB(0, GFP_KERNEL);
1006     macp->RegInUrb = USB_ALLOC_URB(0, GFP_KERNEL);
1007
1008     return 1;
1009 }
1010
1011 void zfLnxFreeAllUrbs(struct usbdrv_private *macp)
1012 {
1013     int i;
1014
1015     /* Free all Tx URBs */
1016     for (i = 0; i < ZM_MAX_TX_URB_NUM; i++)
1017     {
1018         if (macp->WlanTxDataUrb[i] != NULL)
1019         {
1020             usb_free_urb(macp->WlanTxDataUrb[i]);
1021         }
1022     }
1023
1024     /* Free all Rx URBs */
1025     for (i = 0; i < ZM_MAX_RX_URB_NUM; i++)
1026     {
1027         if (macp->WlanRxDataUrb[i] != NULL)
1028         {
1029             usb_free_urb(macp->WlanRxDataUrb[i]);
1030         }
1031     }
1032
1033     /* Free USB Register Read/Write URB */
1034     usb_free_urb(macp->RegOutUrb);
1035     usb_free_urb(macp->RegInUrb);
1036 }
1037
1038 void zfLnxUnlinkAllUrbs(struct usbdrv_private *macp)
1039 {
1040     int i;
1041
1042     /* Unlink all Tx URBs */
1043     for (i = 0; i < ZM_MAX_TX_URB_NUM; i++)
1044     {
1045         if (macp->WlanTxDataUrb[i] != NULL)
1046         {
1047             usb_unlink_urb(macp->WlanTxDataUrb[i]);
1048         }
1049     }
1050
1051     /* Unlink all Rx URBs */
1052     for (i = 0; i < ZM_MAX_RX_URB_NUM; i++)
1053     {
1054         if (macp->WlanRxDataUrb[i] != NULL)
1055         {
1056             usb_unlink_urb(macp->WlanRxDataUrb[i]);
1057         }
1058     }
1059
1060     /* Unlink USB Register Read/Write URB */
1061     usb_unlink_urb(macp->RegOutUrb);
1062
1063     usb_unlink_urb(macp->RegInUrb);
1064 }
1065
1066 static const struct net_device_ops otus_netdev_ops = {
1067         .ndo_open               = usbdrv_open,
1068         .ndo_stop               = usbdrv_close,
1069         .ndo_start_xmit         = usbdrv_xmit_frame,
1070         .ndo_change_mtu         = usbdrv_change_mtu,
1071         .ndo_get_stats          = usbdrv_get_stats,
1072         .ndo_set_multicast_list = usbdrv_set_multi,
1073         .ndo_set_mac_address    = usbdrv_set_mac,
1074         .ndo_do_ioctl           = usbdrv_ioctl,
1075         .ndo_validate_addr      = eth_validate_addr,
1076 };
1077
1078 u8_t zfLnxInitSetup(struct net_device *dev, struct usbdrv_private *macp)
1079 {
1080     //unsigned char addr[6];
1081
1082     //init_MUTEX(&macp->ps_sem);
1083     //init_MUTEX(&macp->reg_sem);
1084     //init_MUTEX(&macp->bcn_sem);
1085     //init_MUTEX(&macp->config_sem);
1086
1087     spin_lock_init(&(macp->cs_lock));
1088 #if 0
1089     /* MAC address */
1090     zfiWlanQueryMacAddress(dev, addr);
1091     dev->dev_addr[0] = addr[0];
1092     dev->dev_addr[1] = addr[1];
1093     dev->dev_addr[2] = addr[2];
1094     dev->dev_addr[3] = addr[3];
1095     dev->dev_addr[4] = addr[4];
1096     dev->dev_addr[5] = addr[5];
1097 #endif
1098     dev->wireless_handlers = (struct iw_handler_def *)&p80211wext_handler_def;
1099
1100     dev->netdev_ops = &otus_netdev_ops;
1101
1102     dev->flags |= IFF_MULTICAST;
1103
1104     dev->dev_addr[0] = 0x00;
1105     dev->dev_addr[1] = 0x03;
1106     dev->dev_addr[2] = 0x7f;
1107     dev->dev_addr[3] = 0x11;
1108     dev->dev_addr[4] = 0x22;
1109     dev->dev_addr[5] = 0x33;
1110
1111     /* Initialize Heart Beat timer */
1112     init_timer(&macp->hbTimer10ms);
1113     macp->hbTimer10ms.data = (unsigned long)dev;
1114     macp->hbTimer10ms.function = (void *)&zfLnx10msTimer;
1115
1116     /* Initialize WDS and VAP data structure */
1117     //zfInitWdsStruct();
1118     zfLnxInitVapStruct();
1119
1120     return 1;
1121 }
1122
1123 u8_t zfLnxClearStructs(struct net_device *dev)
1124 {
1125     u16_t ii;
1126     u16_t TxQCnt;
1127
1128     TxQCnt = zfLnxCheckTxBufferCnt(dev);
1129
1130     printk(KERN_ERR "TxQCnt: %d\n", TxQCnt);
1131
1132     for (ii = 0; ii < TxQCnt; ii++) {
1133         UsbTxQ_t *TxQ = zfLnxGetUsbTxBuffer(dev);
1134
1135         printk(KERN_ERR "dev_kfree_skb_any\n");
1136         /* Free buffer */
1137         dev_kfree_skb_any(TxQ->buf);
1138     }
1139
1140     return 0;
1141 }