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