]>
Commit | Line | Data |
---|---|---|
ca97b838 BZ |
1 | /* |
2 | ************************************************************************* | |
3 | * Ralink Tech Inc. | |
4 | * 5F., No.36, Taiyuan St., Jhubei City, | |
5 | * Hsinchu County 302, | |
6 | * Taiwan, R.O.C. | |
7 | * | |
8 | * (c) Copyright 2002-2007, Ralink Technology, Inc. | |
9 | * | |
10 | * This program is free software; you can redistribute it and/or modify * | |
11 | * it under the terms of the GNU General Public License as published by * | |
12 | * the Free Software Foundation; either version 2 of the License, or * | |
13 | * (at your option) any later version. * | |
14 | * * | |
15 | * This program is distributed in the hope that it will be useful, * | |
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
18 | * GNU General Public License for more details. * | |
19 | * * | |
20 | * You should have received a copy of the GNU General Public License * | |
21 | * along with this program; if not, write to the * | |
22 | * Free Software Foundation, Inc., * | |
23 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * | |
24 | * * | |
25 | *************************************************************************/ | |
26 | ||
27 | #include "rt_config.h" | |
28 | ||
9f548a2a BZ |
29 | /* Following information will be show when you run 'modinfo' */ |
30 | /* *** If you have a solution for the bug in current version of driver, please mail to me. */ | |
31 | /* Otherwise post to forum in ralinktech's web site(www.ralinktech.com) and let all users help you. *** */ | |
ca97b838 BZ |
32 | MODULE_AUTHOR("Paul Lin <paul_lin@ralinktech.com>"); |
33 | MODULE_DESCRIPTION("RT2870/RT3070 Wireless Lan Linux Driver"); | |
34 | MODULE_LICENSE("GPL"); | |
35 | #ifdef MODULE_VERSION | |
36 | MODULE_VERSION(STA_DRIVER_VERSION); | |
37 | #endif | |
38 | ||
ca97b838 BZ |
39 | /* module table */ |
40 | struct usb_device_id rtusb_usb_id[] = { | |
41 | #ifdef RT2870 | |
66cd8d6e BZ |
42 | {USB_DEVICE(0x148F, 0x2770)}, /* Ralink */ |
43 | {USB_DEVICE(0x148F, 0x2870)}, /* Ralink */ | |
44 | {USB_DEVICE(0x07B8, 0x2870)}, /* AboCom */ | |
45 | {USB_DEVICE(0x07B8, 0x2770)}, /* AboCom */ | |
46 | {USB_DEVICE(0x0DF6, 0x0039)}, /* Sitecom 2770 */ | |
47 | {USB_DEVICE(0x083A, 0x7512)}, /* Arcadyan 2770 */ | |
48 | {USB_DEVICE(0x0789, 0x0162)}, /* Logitec 2870 */ | |
49 | {USB_DEVICE(0x0789, 0x0163)}, /* Logitec 2870 */ | |
50 | {USB_DEVICE(0x0789, 0x0164)}, /* Logitec 2870 */ | |
51 | {USB_DEVICE(0x177f, 0x0302)}, /* lsusb */ | |
52 | {USB_DEVICE(0x0B05, 0x1731)}, /* Asus */ | |
53 | {USB_DEVICE(0x0B05, 0x1732)}, /* Asus */ | |
54 | {USB_DEVICE(0x0B05, 0x1742)}, /* Asus */ | |
55 | {USB_DEVICE(0x0DF6, 0x0017)}, /* Sitecom */ | |
56 | {USB_DEVICE(0x0DF6, 0x002B)}, /* Sitecom */ | |
57 | {USB_DEVICE(0x0DF6, 0x002C)}, /* Sitecom */ | |
58 | {USB_DEVICE(0x0DF6, 0x002D)}, /* Sitecom */ | |
59 | {USB_DEVICE(0x14B2, 0x3C06)}, /* Conceptronic */ | |
60 | {USB_DEVICE(0x14B2, 0x3C28)}, /* Conceptronic */ | |
61 | {USB_DEVICE(0x2019, 0xED06)}, /* Planex Communications, Inc. */ | |
62 | {USB_DEVICE(0x07D1, 0x3C09)}, /* D-Link */ | |
63 | {USB_DEVICE(0x07D1, 0x3C11)}, /* D-Link */ | |
64 | {USB_DEVICE(0x14B2, 0x3C07)}, /* AL */ | |
65 | {USB_DEVICE(0x050D, 0x8053)}, /* Belkin */ | |
12840c63 | 66 | {USB_DEVICE(0x050D, 0x825B)}, /* Belkin */ |
66cd8d6e BZ |
67 | {USB_DEVICE(0x14B2, 0x3C23)}, /* Airlink */ |
68 | {USB_DEVICE(0x14B2, 0x3C27)}, /* Airlink */ | |
69 | {USB_DEVICE(0x07AA, 0x002F)}, /* Corega */ | |
70 | {USB_DEVICE(0x07AA, 0x003C)}, /* Corega */ | |
71 | {USB_DEVICE(0x07AA, 0x003F)}, /* Corega */ | |
72 | {USB_DEVICE(0x1044, 0x800B)}, /* Gigabyte */ | |
73 | {USB_DEVICE(0x15A9, 0x0006)}, /* Sparklan */ | |
74 | {USB_DEVICE(0x083A, 0xB522)}, /* SMC */ | |
75 | {USB_DEVICE(0x083A, 0xA618)}, /* SMC */ | |
76 | {USB_DEVICE(0x083A, 0x8522)}, /* Arcadyan */ | |
77 | {USB_DEVICE(0x083A, 0x7522)}, /* Arcadyan */ | |
78 | {USB_DEVICE(0x0CDE, 0x0022)}, /* ZCOM */ | |
79 | {USB_DEVICE(0x0586, 0x3416)}, /* Zyxel */ | |
80 | {USB_DEVICE(0x0CDE, 0x0025)}, /* Zyxel */ | |
81 | {USB_DEVICE(0x1740, 0x9701)}, /* EnGenius */ | |
82 | {USB_DEVICE(0x1740, 0x9702)}, /* EnGenius */ | |
83 | {USB_DEVICE(0x0471, 0x200f)}, /* Philips */ | |
84 | {USB_DEVICE(0x14B2, 0x3C25)}, /* Draytek */ | |
85 | {USB_DEVICE(0x13D3, 0x3247)}, /* AzureWave */ | |
86 | {USB_DEVICE(0x083A, 0x6618)}, /* Accton */ | |
87 | {USB_DEVICE(0x15c5, 0x0008)}, /* Amit */ | |
88 | {USB_DEVICE(0x0E66, 0x0001)}, /* Hawking */ | |
89 | {USB_DEVICE(0x0E66, 0x0003)}, /* Hawking */ | |
90 | {USB_DEVICE(0x129B, 0x1828)}, /* Siemens */ | |
91 | {USB_DEVICE(0x157E, 0x300E)}, /* U-Media */ | |
92 | {USB_DEVICE(0x050d, 0x805c)}, | |
93 | {USB_DEVICE(0x050d, 0x815c)}, | |
94 | {USB_DEVICE(0x1482, 0x3C09)}, /* Abocom */ | |
95 | {USB_DEVICE(0x14B2, 0x3C09)}, /* Alpha */ | |
96 | {USB_DEVICE(0x04E8, 0x2018)}, /* samsung */ | |
97 | {USB_DEVICE(0x5A57, 0x0280)}, /* Zinwell */ | |
98 | {USB_DEVICE(0x5A57, 0x0282)}, /* Zinwell */ | |
99 | {USB_DEVICE(0x7392, 0x7718)}, | |
100 | {USB_DEVICE(0x7392, 0x7717)}, | |
de37cd49 | 101 | {USB_DEVICE(0x0411, 0x016f)}, /* MelCo.,Inc. WLI-UC-G301N */ |
66cd8d6e BZ |
102 | {USB_DEVICE(0x1737, 0x0070)}, /* Linksys WUSB100 */ |
103 | {USB_DEVICE(0x1737, 0x0071)}, /* Linksys WUSB600N */ | |
104 | {USB_DEVICE(0x0411, 0x00e8)}, /* Buffalo WLI-UC-G300N */ | |
105 | {USB_DEVICE(0x050d, 0x815c)}, /* Belkin F5D8053 */ | |
9f548a2a | 106 | #endif /* RT2870 // */ |
ca97b838 | 107 | #ifdef RT3070 |
66cd8d6e BZ |
108 | {USB_DEVICE(0x148F, 0x3070)}, /* Ralink 3070 */ |
109 | {USB_DEVICE(0x148F, 0x3071)}, /* Ralink 3071 */ | |
110 | {USB_DEVICE(0x148F, 0x3072)}, /* Ralink 3072 */ | |
111 | {USB_DEVICE(0x0DB0, 0x3820)}, /* Ralink 3070 */ | |
112 | {USB_DEVICE(0x0DF6, 0x003E)}, /* Sitecom 3070 */ | |
113 | {USB_DEVICE(0x0DF6, 0x0042)}, /* Sitecom 3072 */ | |
114 | {USB_DEVICE(0x14B2, 0x3C12)}, /* AL 3070 */ | |
115 | {USB_DEVICE(0x18C5, 0x0012)}, /* Corega 3070 */ | |
116 | {USB_DEVICE(0x083A, 0x7511)}, /* Arcadyan 3070 */ | |
117 | {USB_DEVICE(0x1740, 0x9703)}, /* EnGenius 3070 */ | |
118 | {USB_DEVICE(0x1740, 0x9705)}, /* EnGenius 3071 */ | |
119 | {USB_DEVICE(0x1740, 0x9706)}, /* EnGenius 3072 */ | |
120 | {USB_DEVICE(0x13D3, 0x3273)}, /* AzureWave 3070 */ | |
121 | {USB_DEVICE(0x1044, 0x800D)}, /* Gigabyte GN-WB32L 3070 */ | |
122 | {USB_DEVICE(0x2019, 0xAB25)}, /* Planex Communications, Inc. RT3070 */ | |
123 | {USB_DEVICE(0x07B8, 0x3070)}, /* AboCom 3070 */ | |
124 | {USB_DEVICE(0x07B8, 0x3071)}, /* AboCom 3071 */ | |
125 | {USB_DEVICE(0x07B8, 0x3072)}, /* Abocom 3072 */ | |
126 | {USB_DEVICE(0x7392, 0x7711)}, /* Edimax 3070 */ | |
127 | {USB_DEVICE(0x1A32, 0x0304)}, /* Quanta 3070 */ | |
128 | {USB_DEVICE(0x1EDA, 0x2310)}, /* AirTies 3070 */ | |
129 | {USB_DEVICE(0x07D1, 0x3C0A)}, /* D-Link 3072 */ | |
130 | {USB_DEVICE(0x07D1, 0x3C0D)}, /* D-Link 3070 */ | |
131 | {USB_DEVICE(0x07D1, 0x3C0E)}, /* D-Link 3070 */ | |
132 | {USB_DEVICE(0x07D1, 0x3C0F)}, /* D-Link 3070 */ | |
133 | {USB_DEVICE(0x1D4D, 0x000C)}, /* Pegatron Corporation 3070 */ | |
134 | {USB_DEVICE(0x1D4D, 0x000E)}, /* Pegatron Corporation 3070 */ | |
135 | {USB_DEVICE(0x5A57, 0x5257)}, /* Zinwell 3070 */ | |
136 | {USB_DEVICE(0x5A57, 0x0283)}, /* Zinwell 3072 */ | |
137 | {USB_DEVICE(0x04BB, 0x0945)}, /* I-O DATA 3072 */ | |
138 | {USB_DEVICE(0x203D, 0x1480)}, /* Encore 3070 */ | |
9f548a2a | 139 | #endif /* RT3070 // */ |
66cd8d6e BZ |
140 | {USB_DEVICE(0x0DF6, 0x003F)}, /* Sitecom WL-608 */ |
141 | {USB_DEVICE(0x1737, 0x0077)}, /* Linksys WUSB54GC-EU v3 */ | |
142 | {USB_DEVICE(0x2001, 0x3C09)}, /* D-Link */ | |
143 | {USB_DEVICE(0x2001, 0x3C0A)}, /* D-Link 3072 */ | |
144 | {USB_DEVICE(0x2019, 0xED14)}, /* Planex Communications, Inc. */ | |
145 | {} /* Terminating entry */ | |
ca97b838 BZ |
146 | }; |
147 | ||
51126deb | 148 | int const rtusb_usb_id_len = |
66cd8d6e | 149 | sizeof(rtusb_usb_id) / sizeof(struct usb_device_id); |
ca97b838 BZ |
150 | |
151 | MODULE_DEVICE_TABLE(usb, rtusb_usb_id); | |
152 | ||
62eb734b | 153 | static void rt2870_disconnect(struct usb_device *dev, struct rt_rtmp_adapter *pAd); |
ca97b838 | 154 | |
66cd8d6e BZ |
155 | static int __devinit rt2870_probe(IN struct usb_interface *intf, |
156 | IN struct usb_device *usb_dev, | |
157 | IN const struct usb_device_id *dev_id, | |
a3327f07 | 158 | struct rt_rtmp_adapter **ppAd); |
ca97b838 BZ |
159 | |
160 | #ifndef PF_NOFREEZE | |
161 | #define PF_NOFREEZE 0 | |
162 | #endif | |
163 | ||
ca97b838 BZ |
164 | extern int rt28xx_close(IN struct net_device *net_dev); |
165 | extern int rt28xx_open(struct net_device *net_dev); | |
166 | ||
66cd8d6e BZ |
167 | static BOOLEAN USBDevConfigInit(IN struct usb_device *dev, |
168 | IN struct usb_interface *intf, | |
62eb734b | 169 | struct rt_rtmp_adapter *pAd); |
ca97b838 BZ |
170 | |
171 | /* | |
172 | ======================================================================== | |
173 | Routine Description: | |
174 | Check the chipset vendor/product ID. | |
175 | ||
176 | Arguments: | |
177 | _dev_p Point to the PCI or USB device | |
178 | ||
179 | Return Value: | |
180 | TRUE Check ok | |
181 | FALSE Check fail | |
182 | ||
183 | Note: | |
184 | ======================================================================== | |
185 | */ | |
66cd8d6e | 186 | BOOLEAN RT28XXChipsetCheck(IN void *_dev_p) |
ca97b838 BZ |
187 | { |
188 | struct usb_interface *intf = (struct usb_interface *)_dev_p; | |
189 | struct usb_device *dev_p = interface_to_usbdev(intf); | |
51126deb | 190 | u32 i; |
ca97b838 | 191 | |
66cd8d6e | 192 | for (i = 0; i < rtusb_usb_id_len; i++) { |
ca97b838 | 193 | if (dev_p->descriptor.idVendor == rtusb_usb_id[i].idVendor && |
66cd8d6e | 194 | dev_p->descriptor.idProduct == rtusb_usb_id[i].idProduct) { |
ca97b838 | 195 | printk("rt2870: idVendor = 0x%x, idProduct = 0x%x\n", |
66cd8d6e BZ |
196 | dev_p->descriptor.idVendor, |
197 | dev_p->descriptor.idProduct); | |
ca97b838 BZ |
198 | break; |
199 | } | |
200 | } | |
201 | ||
66cd8d6e | 202 | if (i == rtusb_usb_id_len) { |
ca97b838 BZ |
203 | printk("rt2870: Error! Device Descriptor not matching!\n"); |
204 | return FALSE; | |
205 | } | |
206 | ||
207 | return TRUE; | |
208 | } | |
209 | ||
210 | /**************************************************************************/ | |
211 | /**************************************************************************/ | |
9f548a2a | 212 | /*tested for kernel 2.6series */ |
ca97b838 BZ |
213 | /**************************************************************************/ |
214 | /**************************************************************************/ | |
215 | ||
216 | #ifdef CONFIG_PM | |
217 | static int rt2870_suspend(struct usb_interface *intf, pm_message_t state); | |
218 | static int rt2870_resume(struct usb_interface *intf); | |
9f548a2a | 219 | #endif /* CONFIG_PM // */ |
ca97b838 | 220 | |
66cd8d6e BZ |
221 | static BOOLEAN USBDevConfigInit(IN struct usb_device *dev, |
222 | IN struct usb_interface *intf, | |
62eb734b | 223 | struct rt_rtmp_adapter *pAd) |
ca97b838 BZ |
224 | { |
225 | struct usb_host_interface *iface_desc; | |
51126deb BZ |
226 | unsigned long BulkOutIdx; |
227 | u32 i; | |
ca97b838 | 228 | |
ca97b838 BZ |
229 | /* get the active interface descriptor */ |
230 | iface_desc = intf->cur_altsetting; | |
231 | ||
232 | /* get # of enpoints */ | |
233 | pAd->NumberOfPipes = iface_desc->desc.bNumEndpoints; | |
66cd8d6e BZ |
234 | DBGPRINT(RT_DEBUG_TRACE, |
235 | ("NumEndpoints=%d\n", iface_desc->desc.bNumEndpoints)); | |
ca97b838 BZ |
236 | |
237 | /* Configure Pipes */ | |
238 | BulkOutIdx = 0; | |
239 | ||
66cd8d6e | 240 | for (i = 0; i < pAd->NumberOfPipes; i++) { |
ca97b838 | 241 | if ((iface_desc->endpoint[i].desc.bmAttributes == |
66cd8d6e BZ |
242 | USB_ENDPOINT_XFER_BULK) && |
243 | ((iface_desc->endpoint[i].desc.bEndpointAddress & | |
244 | USB_ENDPOINT_DIR_MASK) == USB_DIR_IN)) { | |
245 | pAd->BulkInEpAddr = | |
246 | iface_desc->endpoint[i].desc.bEndpointAddress; | |
247 | pAd->BulkInMaxPacketSize = | |
248 | le2cpu16(iface_desc->endpoint[i].desc. | |
249 | wMaxPacketSize); | |
250 | ||
251 | DBGPRINT_RAW(RT_DEBUG_TRACE, | |
252 | ("BULK IN MaxPacketSize = %d\n", | |
253 | pAd->BulkInMaxPacketSize)); | |
254 | DBGPRINT_RAW(RT_DEBUG_TRACE, | |
255 | ("EP address = 0x%2x\n", | |
256 | iface_desc->endpoint[i].desc. | |
257 | bEndpointAddress)); | |
258 | } else | |
259 | if ((iface_desc->endpoint[i].desc.bmAttributes == | |
260 | USB_ENDPOINT_XFER_BULK) | |
261 | && | |
262 | ((iface_desc->endpoint[i].desc. | |
263 | bEndpointAddress & USB_ENDPOINT_DIR_MASK) == | |
264 | USB_DIR_OUT)) { | |
9f548a2a BZ |
265 | /* there are 6 bulk out EP. EP6 highest priority. */ |
266 | /* EP1-4 is EDCA. EP5 is HCCA. */ | |
66cd8d6e BZ |
267 | pAd->BulkOutEpAddr[BulkOutIdx++] = |
268 | iface_desc->endpoint[i].desc.bEndpointAddress; | |
269 | pAd->BulkOutMaxPacketSize = | |
270 | le2cpu16(iface_desc->endpoint[i].desc. | |
271 | wMaxPacketSize); | |
272 | ||
273 | DBGPRINT_RAW(RT_DEBUG_TRACE, | |
274 | ("BULK OUT MaxPacketSize = %d\n", | |
275 | pAd->BulkOutMaxPacketSize)); | |
276 | DBGPRINT_RAW(RT_DEBUG_TRACE, | |
277 | ("EP address = 0x%2x \n", | |
278 | iface_desc->endpoint[i].desc. | |
279 | bEndpointAddress)); | |
ca97b838 BZ |
280 | } |
281 | } | |
282 | ||
66cd8d6e BZ |
283 | if (!(pAd->BulkInEpAddr && pAd->BulkOutEpAddr[0])) { |
284 | printk | |
285 | ("%s: Could not find both bulk-in and bulk-out endpoints\n", | |
286 | __FUNCTION__); | |
ca97b838 BZ |
287 | return FALSE; |
288 | } | |
289 | ||
290 | pAd->config = &dev->config->desc; | |
291 | usb_set_intfdata(intf, pAd); | |
292 | ||
293 | return TRUE; | |
294 | ||
295 | } | |
296 | ||
c33c2065 | 297 | static int __devinit rtusb_probe(struct usb_interface *intf, |
66cd8d6e | 298 | const struct usb_device_id *id) |
ca97b838 | 299 | { |
62eb734b | 300 | struct rt_rtmp_adapter *pAd; |
ca97b838 BZ |
301 | struct usb_device *dev; |
302 | int rv; | |
303 | ||
304 | dev = interface_to_usbdev(intf); | |
305 | dev = usb_get_dev(dev); | |
306 | ||
307 | rv = rt2870_probe(intf, dev, id, &pAd); | |
308 | if (rv != 0) | |
309 | usb_put_dev(dev); | |
310 | ||
311 | return rv; | |
312 | } | |
313 | ||
ca97b838 BZ |
314 | static void rtusb_disconnect(struct usb_interface *intf) |
315 | { | |
66cd8d6e | 316 | struct usb_device *dev = interface_to_usbdev(intf); |
62eb734b | 317 | struct rt_rtmp_adapter *pAd; |
ca97b838 BZ |
318 | |
319 | pAd = usb_get_intfdata(intf); | |
320 | usb_set_intfdata(intf, NULL); | |
321 | ||
322 | rt2870_disconnect(dev, pAd); | |
323 | } | |
324 | ||
ca97b838 | 325 | struct usb_driver rtusb_driver = { |
66cd8d6e BZ |
326 | .name = "rt2870", |
327 | .probe = rtusb_probe, | |
328 | .disconnect = rtusb_disconnect, | |
329 | .id_table = rtusb_usb_id, | |
ca97b838 BZ |
330 | |
331 | #ifdef CONFIG_PM | |
66cd8d6e BZ |
332 | suspend:rt2870_suspend, |
333 | resume:rt2870_resume, | |
ca97b838 | 334 | #endif |
66cd8d6e | 335 | }; |
ca97b838 BZ |
336 | |
337 | #ifdef CONFIG_PM | |
338 | ||
62eb734b | 339 | void RT2870RejectPendingPackets(struct rt_rtmp_adapter *pAd) |
ca97b838 | 340 | { |
9f548a2a BZ |
341 | /* clear PS packets */ |
342 | /* clear TxSw packets */ | |
ca97b838 BZ |
343 | } |
344 | ||
66cd8d6e | 345 | static int rt2870_suspend(struct usb_interface *intf, pm_message_t state) |
ca97b838 BZ |
346 | { |
347 | struct net_device *net_dev; | |
62eb734b | 348 | struct rt_rtmp_adapter *pAd = usb_get_intfdata(intf); |
ca97b838 | 349 | |
ca97b838 BZ |
350 | DBGPRINT(RT_DEBUG_TRACE, ("===> rt2870_suspend()\n")); |
351 | net_dev = pAd->net_dev; | |
352 | netif_device_detach(net_dev); | |
353 | ||
354 | pAd->PM_FlgSuspend = 1; | |
355 | if (netif_running(net_dev)) { | |
356 | RTUSBCancelPendingBulkInIRP(pAd); | |
357 | RTUSBCancelPendingBulkOutIRP(pAd); | |
358 | } | |
359 | DBGPRINT(RT_DEBUG_TRACE, ("<=== rt2870_suspend()\n")); | |
360 | return 0; | |
361 | } | |
362 | ||
66cd8d6e | 363 | static int rt2870_resume(struct usb_interface *intf) |
ca97b838 BZ |
364 | { |
365 | struct net_device *net_dev; | |
62eb734b | 366 | struct rt_rtmp_adapter *pAd = usb_get_intfdata(intf); |
ca97b838 | 367 | |
ca97b838 BZ |
368 | DBGPRINT(RT_DEBUG_TRACE, ("===> rt2870_resume()\n")); |
369 | ||
370 | pAd->PM_FlgSuspend = 0; | |
371 | net_dev = pAd->net_dev; | |
372 | netif_device_attach(net_dev); | |
373 | netif_start_queue(net_dev); | |
374 | netif_carrier_on(net_dev); | |
375 | netif_wake_queue(net_dev); | |
376 | ||
377 | DBGPRINT(RT_DEBUG_TRACE, ("<=== rt2870_resume()\n")); | |
378 | return 0; | |
379 | } | |
9f548a2a | 380 | #endif /* CONFIG_PM // */ |
ca97b838 | 381 | |
9f548a2a | 382 | /* Init driver module */ |
51126deb | 383 | int __init rtusb_init(void) |
ca97b838 BZ |
384 | { |
385 | printk("rtusb init --->\n"); | |
386 | return usb_register(&rtusb_driver); | |
387 | } | |
388 | ||
9f548a2a | 389 | /* Deinit driver module */ |
51126deb | 390 | void __exit rtusb_exit(void) |
ca97b838 BZ |
391 | { |
392 | usb_deregister(&rtusb_driver); | |
393 | printk("<--- rtusb exit\n"); | |
394 | } | |
395 | ||
396 | module_init(rtusb_init); | |
397 | module_exit(rtusb_exit); | |
398 | ||
ca97b838 BZ |
399 | /*--------------------------------------------------------------------- */ |
400 | /* function declarations */ | |
401 | /*--------------------------------------------------------------------- */ | |
402 | ||
403 | /* | |
404 | ======================================================================== | |
405 | Routine Description: | |
406 | MLME kernel thread. | |
407 | ||
408 | Arguments: | |
409 | *Context the pAd, driver control block pointer | |
410 | ||
411 | Return Value: | |
412 | 0 close the thread | |
413 | ||
414 | Note: | |
415 | ======================================================================== | |
416 | */ | |
51126deb | 417 | int MlmeThread(IN void *Context) |
ca97b838 | 418 | { |
62eb734b BZ |
419 | struct rt_rtmp_adapter *pAd; |
420 | struct rt_rtmp_os_task *pTask; | |
ca97b838 BZ |
421 | int status; |
422 | status = 0; | |
423 | ||
62eb734b BZ |
424 | pTask = (struct rt_rtmp_os_task *)Context; |
425 | pAd = (struct rt_rtmp_adapter *)pTask->priv; | |
ca97b838 BZ |
426 | |
427 | RtmpOSTaskCustomize(pTask); | |
428 | ||
66cd8d6e | 429 | while (!pTask->task_killed) { |
ca97b838 BZ |
430 | #ifdef KTHREAD_SUPPORT |
431 | RTMP_WAIT_EVENT_INTERRUPTIBLE(pAd, pTask); | |
432 | #else | |
433 | RTMP_SEM_EVENT_WAIT(&(pTask->taskSema), status); | |
434 | ||
435 | /* unlock the device pointers */ | |
66cd8d6e | 436 | if (status != 0) { |
ca97b838 BZ |
437 | RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS); |
438 | break; | |
439 | } | |
440 | #endif | |
441 | ||
66cd8d6e | 442 | /* lock the device pointers , need to check if required */ |
9f548a2a | 443 | /*down(&(pAd->usbdev_semaphore)); */ |
ca97b838 BZ |
444 | |
445 | if (!pAd->PM_FlgSuspend) | |
446 | MlmeHandler(pAd); | |
447 | } | |
448 | ||
449 | /* notify the exit routine that we're actually exiting now | |
450 | * | |
451 | * complete()/wait_for_completion() is similar to up()/down(), | |
452 | * except that complete() is safe in the case where the structure | |
453 | * is getting deleted in a parallel mode of execution (i.e. just | |
454 | * after the down() -- that's necessary for the thread-shutdown | |
455 | * case. | |
456 | * | |
457 | * complete_and_exit() goes even further than this -- it is safe in | |
458 | * the case that the thread of the caller is going away (not just | |
459 | * the structure) -- this is necessary for the module-remove case. | |
460 | * This is important in preemption kernels, which transfer the flow | |
461 | * of execution immediately upon a complete(). | |
462 | */ | |
66cd8d6e | 463 | DBGPRINT(RT_DEBUG_TRACE, ("<---%s\n", __FUNCTION__)); |
ca97b838 BZ |
464 | #ifndef KTHREAD_SUPPORT |
465 | pTask->taskPID = THREAD_PID_INIT_VALUE; | |
66cd8d6e | 466 | complete_and_exit(&pTask->taskComplete, 0); |
ca97b838 BZ |
467 | #endif |
468 | return 0; | |
469 | ||
470 | } | |
471 | ||
ca97b838 BZ |
472 | /* |
473 | ======================================================================== | |
474 | Routine Description: | |
475 | USB command kernel thread. | |
476 | ||
477 | Arguments: | |
478 | *Context the pAd, driver control block pointer | |
479 | ||
480 | Return Value: | |
481 | 0 close the thread | |
482 | ||
483 | Note: | |
484 | ======================================================================== | |
485 | */ | |
51126deb | 486 | int RTUSBCmdThread(IN void *Context) |
ca97b838 | 487 | { |
62eb734b BZ |
488 | struct rt_rtmp_adapter *pAd; |
489 | struct rt_rtmp_os_task *pTask; | |
ca97b838 BZ |
490 | int status; |
491 | status = 0; | |
492 | ||
62eb734b BZ |
493 | pTask = (struct rt_rtmp_os_task *)Context; |
494 | pAd = (struct rt_rtmp_adapter *)pTask->priv; | |
ca97b838 BZ |
495 | |
496 | RtmpOSTaskCustomize(pTask); | |
497 | ||
498 | NdisAcquireSpinLock(&pAd->CmdQLock); | |
499 | pAd->CmdQ.CmdQState = RTMP_TASK_STAT_RUNNING; | |
500 | NdisReleaseSpinLock(&pAd->CmdQLock); | |
501 | ||
66cd8d6e | 502 | while (pAd && pAd->CmdQ.CmdQState == RTMP_TASK_STAT_RUNNING) { |
ca97b838 BZ |
503 | #ifdef KTHREAD_SUPPORT |
504 | RTMP_WAIT_EVENT_INTERRUPTIBLE(pAd, pTask); | |
505 | #else | |
506 | /* lock the device pointers */ | |
507 | RTMP_SEM_EVENT_WAIT(&(pTask->taskSema), status); | |
508 | ||
66cd8d6e | 509 | if (status != 0) { |
ca97b838 BZ |
510 | RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS); |
511 | break; | |
512 | } | |
513 | #endif | |
514 | ||
515 | if (pAd->CmdQ.CmdQState == RTMP_TASK_STAT_STOPED) | |
516 | break; | |
517 | ||
518 | if (!pAd->PM_FlgSuspend) | |
519 | CMDHandler(pAd); | |
520 | } | |
521 | ||
9f548a2a | 522 | if (pAd && !pAd->PM_FlgSuspend) { /* Clear the CmdQElements. */ |
62eb734b | 523 | struct rt_cmdqelmt *pCmdQElmt = NULL; |
ca97b838 BZ |
524 | |
525 | NdisAcquireSpinLock(&pAd->CmdQLock); | |
526 | pAd->CmdQ.CmdQState = RTMP_TASK_STAT_STOPED; | |
66cd8d6e | 527 | while (pAd->CmdQ.size) { |
ca97b838 | 528 | RTUSBDequeueCmd(&pAd->CmdQ, &pCmdQElmt); |
66cd8d6e BZ |
529 | if (pCmdQElmt) { |
530 | if (pCmdQElmt->CmdFromNdis == TRUE) { | |
ca97b838 | 531 | if (pCmdQElmt->buffer != NULL) |
66cd8d6e BZ |
532 | os_free_mem(pAd, |
533 | pCmdQElmt->buffer); | |
51126deb | 534 | os_free_mem(pAd, (u8 *)pCmdQElmt); |
66cd8d6e BZ |
535 | } else { |
536 | if ((pCmdQElmt->buffer != NULL) | |
537 | && (pCmdQElmt->bufferlength != 0)) | |
538 | os_free_mem(pAd, | |
539 | pCmdQElmt->buffer); | |
51126deb | 540 | os_free_mem(pAd, (u8 *)pCmdQElmt); |
ca97b838 BZ |
541 | } |
542 | } | |
543 | } | |
544 | ||
545 | NdisReleaseSpinLock(&pAd->CmdQLock); | |
546 | } | |
547 | /* notify the exit routine that we're actually exiting now | |
548 | * | |
549 | * complete()/wait_for_completion() is similar to up()/down(), | |
550 | * except that complete() is safe in the case where the structure | |
551 | * is getting deleted in a parallel mode of execution (i.e. just | |
552 | * after the down() -- that's necessary for the thread-shutdown | |
553 | * case. | |
554 | * | |
555 | * complete_and_exit() goes even further than this -- it is safe in | |
556 | * the case that the thread of the caller is going away (not just | |
557 | * the structure) -- this is necessary for the module-remove case. | |
558 | * This is important in preemption kernels, which transfer the flow | |
559 | * of execution immediately upon a complete(). | |
560 | */ | |
66cd8d6e | 561 | DBGPRINT(RT_DEBUG_TRACE, ("<---RTUSBCmdThread\n")); |
ca97b838 BZ |
562 | |
563 | #ifndef KTHREAD_SUPPORT | |
564 | pTask->taskPID = THREAD_PID_INIT_VALUE; | |
66cd8d6e | 565 | complete_and_exit(&pTask->taskComplete, 0); |
ca97b838 BZ |
566 | #endif |
567 | return 0; | |
568 | ||
569 | } | |
570 | ||
62eb734b | 571 | void RTUSBWatchDog(struct rt_rtmp_adapter *pAd) |
ca97b838 | 572 | { |
62eb734b | 573 | struct rt_ht_tx_context *pHTTXContext; |
66cd8d6e | 574 | int idx; |
51126deb | 575 | unsigned long irqFlags; |
66cd8d6e BZ |
576 | PURB pUrb; |
577 | BOOLEAN needDumpSeq = FALSE; | |
51126deb BZ |
578 | u32 MACValue; |
579 | u32 TxRxQ_Pcnt; | |
ca97b838 BZ |
580 | |
581 | idx = 0; | |
582 | RTMP_IO_READ32(pAd, TXRXQ_PCNT, &MACValue); | |
66cd8d6e BZ |
583 | if ((MACValue & 0xff) != 0) { |
584 | DBGPRINT(RT_DEBUG_TRACE, | |
06aea994 | 585 | ("TX QUEUE 0 Not EMPTY(Value=0x%0x)!\n", |
66cd8d6e | 586 | MACValue)); |
ca97b838 | 587 | RTMP_IO_WRITE32(pAd, PBF_CFG, 0xf40012); |
66cd8d6e BZ |
588 | while ((MACValue & 0xff) != 0 && (idx++ < 10)) { |
589 | RTMP_IO_READ32(pAd, TXRXQ_PCNT, &MACValue); | |
590 | RTMPusecDelay(1); | |
ca97b838 BZ |
591 | } |
592 | RTMP_IO_WRITE32(pAd, PBF_CFG, 0xf40006); | |
593 | } | |
594 | ||
66cd8d6e BZ |
595 | if (pAd->watchDogRxOverFlowCnt >= 2) { |
596 | DBGPRINT(RT_DEBUG_TRACE, | |
597 | ("Maybe the Rx Bulk-In hanged! Cancel the pending Rx bulks request!\n")); | |
598 | if ((!RTMP_TEST_FLAG | |
599 | (pAd, | |
600 | (fRTMP_ADAPTER_RESET_IN_PROGRESS | | |
601 | fRTMP_ADAPTER_BULKIN_RESET | | |
602 | fRTMP_ADAPTER_HALT_IN_PROGRESS | | |
603 | fRTMP_ADAPTER_NIC_NOT_EXIST)))) { | |
604 | DBGPRINT(RT_DEBUG_TRACE, | |
605 | ("Call CMDTHREAD_RESET_BULK_IN to cancel the pending Rx Bulk!\n")); | |
ca97b838 | 606 | RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKIN_RESET); |
66cd8d6e BZ |
607 | RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_IN, |
608 | NULL, 0); | |
ca97b838 BZ |
609 | needDumpSeq = TRUE; |
610 | } | |
611 | pAd->watchDogRxOverFlowCnt = 0; | |
612 | } | |
613 | ||
614 | RTUSBReadMACRegister(pAd, 0x438, &TxRxQ_Pcnt); | |
615 | ||
66cd8d6e | 616 | for (idx = 0; idx < NUM_OF_TX_RING; idx++) { |
ca97b838 BZ |
617 | pUrb = NULL; |
618 | ||
619 | RTMP_IRQ_LOCK(&pAd->BulkOutLock[idx], irqFlags); | |
66cd8d6e BZ |
620 | if ((pAd->BulkOutPending[idx] == TRUE) |
621 | && pAd->watchDogTxPendingCnt) { | |
51126deb | 622 | int actual_length = 0, transfer_buffer_length = 0; |
66cd8d6e | 623 | BOOLEAN isDataPacket = FALSE; |
ca97b838 BZ |
624 | pAd->watchDogTxPendingCnt[idx]++; |
625 | ||
626 | if ((pAd->watchDogTxPendingCnt[idx] > 2) && | |
66cd8d6e BZ |
627 | (!RTMP_TEST_FLAG |
628 | (pAd, | |
629 | (fRTMP_ADAPTER_RESET_IN_PROGRESS | | |
630 | fRTMP_ADAPTER_HALT_IN_PROGRESS | | |
631 | fRTMP_ADAPTER_NIC_NOT_EXIST | | |
632 | fRTMP_ADAPTER_BULKOUT_RESET))) | |
633 | ) { | |
9f548a2a | 634 | /* FIXME: Following code just support single bulk out. If you wanna support multiple bulk out. Modify it! */ |
66cd8d6e | 635 | pHTTXContext = |
62eb734b | 636 | (struct rt_ht_tx_context *)(&pAd->TxContext[idx]); |
9f548a2a | 637 | if (pHTTXContext->IRPPending) { /* Check TxContext. */ |
ca97b838 BZ |
638 | pUrb = pHTTXContext->pUrb; |
639 | ||
66cd8d6e BZ |
640 | actual_length = pUrb->actual_length; |
641 | transfer_buffer_length = | |
642 | pUrb->transfer_buffer_length; | |
643 | isDataPacket = TRUE; | |
644 | } else if (idx == MGMTPIPEIDX) { | |
62eb734b BZ |
645 | struct rt_tx_context *pMLMEContext, *pNULLContext, |
646 | *pPsPollContext; | |
ca97b838 | 647 | |
9f548a2a | 648 | /*Check MgmtContext. */ |
66cd8d6e | 649 | pMLMEContext = |
62eb734b | 650 | (struct rt_tx_context *)(pAd->MgmtRing. |
66cd8d6e BZ |
651 | Cell[pAd->MgmtRing. |
652 | TxDmaIdx]. | |
653 | AllocVa); | |
654 | pPsPollContext = | |
62eb734b | 655 | (struct rt_tx_context *)(&pAd->PsPollContext); |
66cd8d6e | 656 | pNULLContext = |
62eb734b | 657 | (struct rt_tx_context *)(&pAd->NullContext); |
66cd8d6e BZ |
658 | |
659 | if (pMLMEContext->IRPPending) { | |
660 | ASSERT(pMLMEContext-> | |
661 | IRPPending); | |
ca97b838 | 662 | pUrb = pMLMEContext->pUrb; |
66cd8d6e BZ |
663 | } else if (pNULLContext->IRPPending) { |
664 | ASSERT(pNULLContext-> | |
665 | IRPPending); | |
ca97b838 | 666 | pUrb = pNULLContext->pUrb; |
66cd8d6e BZ |
667 | } else if (pPsPollContext->IRPPending) { |
668 | ASSERT(pPsPollContext-> | |
669 | IRPPending); | |
ca97b838 BZ |
670 | pUrb = pPsPollContext->pUrb; |
671 | } | |
672 | } | |
673 | ||
66cd8d6e BZ |
674 | RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[idx], |
675 | irqFlags); | |
ca97b838 | 676 | |
ca58fb30 BZ |
677 | printk(KERN_INFO "%d:%lu LTL=%d , TL=%d L:%d\n", |
678 | idx, pAd->watchDogTxPendingCnt[idx], | |
679 | pAd->TransferedLength[idx], | |
680 | actual_length, transfer_buffer_length); | |
ca97b838 | 681 | |
66cd8d6e | 682 | if (pUrb) { |
ca97b838 | 683 | if ((isDataPacket |
66cd8d6e BZ |
684 | && pAd->TransferedLength[idx] == |
685 | actual_length | |
686 | && pAd->TransferedLength[idx] < | |
687 | transfer_buffer_length | |
688 | && actual_length != 0 | |
9f548a2a | 689 | /* && TxRxQ_Pcnt==0 */ |
66cd8d6e BZ |
690 | && pAd->watchDogTxPendingCnt[idx] > |
691 | 3) | |
692 | || isDataPacket == FALSE | |
693 | || pAd->watchDogTxPendingCnt[idx] > | |
694 | 6) { | |
695 | DBGPRINT(RT_DEBUG_TRACE, | |
696 | ("Maybe the Tx Bulk-Out hanged! Cancel the pending Tx bulks request of idx(%d)!\n", | |
697 | idx)); | |
698 | DBGPRINT(RT_DEBUG_TRACE, | |
699 | ("Unlink the pending URB!\n")); | |
9f548a2a | 700 | /* unlink it now */ |
66cd8d6e | 701 | RTUSB_UNLINK_URB(pUrb); |
9f548a2a BZ |
702 | /* Sleep 200 microseconds to give cancellation time to work */ |
703 | /*RTMPusecDelay(200); */ | |
66cd8d6e | 704 | needDumpSeq = TRUE; |
ca97b838 | 705 | } |
66cd8d6e BZ |
706 | } else { |
707 | DBGPRINT(RT_DEBUG_ERROR, | |
06aea994 | 708 | ("Unknown bulkOut URB maybe hanged!\n")); |
ca97b838 | 709 | } |
66cd8d6e BZ |
710 | } else { |
711 | RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[idx], | |
712 | irqFlags); | |
ca97b838 BZ |
713 | } |
714 | ||
66cd8d6e BZ |
715 | if (isDataPacket == TRUE) |
716 | pAd->TransferedLength[idx] = actual_length; | |
717 | } else { | |
ca97b838 BZ |
718 | RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[idx], irqFlags); |
719 | } | |
720 | } | |
721 | ||
9f548a2a | 722 | /* For Sigma debug, dump the ba_reordering sequence. */ |
66cd8d6e | 723 | if ((needDumpSeq == TRUE) && (pAd->CommonCfg.bDisableReordering == 0)) { |
51126deb | 724 | u16 Idx; |
62eb734b | 725 | struct rt_ba_rec_entry *pBAEntry = NULL; |
51126deb | 726 | u8 count = 0; |
ca97b838 BZ |
727 | struct reordering_mpdu *mpdu_blk; |
728 | ||
729 | Idx = pAd->MacTab.Content[BSSID_WCID].BARecWcidArray[0]; | |
730 | ||
731 | pBAEntry = &pAd->BATable.BARecEntry[Idx]; | |
66cd8d6e BZ |
732 | if ((pBAEntry->list.qlen > 0) && (pBAEntry->list.next != NULL)) { |
733 | DBGPRINT(RT_DEBUG_TRACE, | |
734 | ("NICUpdateRawCounters():The Queueing pkt in reordering buffer:\n")); | |
ca97b838 BZ |
735 | NdisAcquireSpinLock(&pBAEntry->RxReRingLock); |
736 | mpdu_blk = pBAEntry->list.next; | |
66cd8d6e BZ |
737 | while (mpdu_blk) { |
738 | DBGPRINT(RT_DEBUG_TRACE, | |
739 | ("\t%d:Seq-%d, bAMSDU-%d!\n", count, | |
740 | mpdu_blk->Sequence, | |
741 | mpdu_blk->bAMSDU)); | |
ca97b838 BZ |
742 | mpdu_blk = mpdu_blk->next; |
743 | count++; | |
744 | } | |
745 | ||
66cd8d6e BZ |
746 | DBGPRINT(RT_DEBUG_TRACE, |
747 | ("\npBAEntry->LastIndSeq=%d!\n", | |
748 | pBAEntry->LastIndSeq)); | |
ca97b838 BZ |
749 | NdisReleaseSpinLock(&pBAEntry->RxReRingLock); |
750 | } | |
751 | } | |
752 | } | |
753 | ||
754 | /* | |
755 | ======================================================================== | |
756 | Routine Description: | |
757 | Release allocated resources. | |
758 | ||
759 | Arguments: | |
760 | *dev Point to the PCI or USB device | |
761 | pAd driver control block pointer | |
762 | ||
763 | Return Value: | |
764 | None | |
765 | ||
766 | Note: | |
767 | ======================================================================== | |
768 | */ | |
62eb734b | 769 | static void rt2870_disconnect(struct usb_device *dev, struct rt_rtmp_adapter *pAd) |
ca97b838 | 770 | { |
66cd8d6e BZ |
771 | DBGPRINT(RT_DEBUG_ERROR, |
772 | ("rtusb_disconnect: unregister usbnet usb-%s-%s\n", | |
773 | dev->bus->bus_name, dev->devpath)); | |
774 | if (!pAd) { | |
ca97b838 BZ |
775 | usb_put_dev(dev); |
776 | printk("rtusb_disconnect: pAd == NULL!\n"); | |
777 | return; | |
778 | } | |
779 | RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST); | |
780 | ||
9f548a2a | 781 | /* for debug, wait to show some messages to /proc system */ |
ca97b838 BZ |
782 | udelay(1); |
783 | ||
ca97b838 BZ |
784 | RtmpPhyNetDevExit(pAd, pAd->net_dev); |
785 | ||
9f548a2a | 786 | /* FIXME: Shall we need following delay and flush the schedule?? */ |
ca97b838 BZ |
787 | udelay(1); |
788 | flush_scheduled_work(); | |
789 | udelay(1); | |
790 | ||
9f548a2a | 791 | /* free the root net_device */ |
ca97b838 BZ |
792 | RtmpOSNetDevFree(pAd->net_dev); |
793 | ||
794 | RtmpRaDevCtrlExit(pAd); | |
795 | ||
9f548a2a | 796 | /* release a use of the usb device structure */ |
ca97b838 BZ |
797 | usb_put_dev(dev); |
798 | udelay(1); | |
799 | ||
800 | DBGPRINT(RT_DEBUG_ERROR, (" RTUSB disconnect successfully\n")); | |
801 | } | |
802 | ||
66cd8d6e BZ |
803 | static int __devinit rt2870_probe(IN struct usb_interface *intf, |
804 | IN struct usb_device *usb_dev, | |
805 | IN const struct usb_device_id *dev_id, | |
a3327f07 | 806 | struct rt_rtmp_adapter **ppAd) |
ca97b838 | 807 | { |
66cd8d6e | 808 | struct net_device *net_dev = NULL; |
62eb734b | 809 | struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)NULL; |
51126deb BZ |
810 | int status, rv; |
811 | void *handle; | |
62eb734b | 812 | struct rt_rtmp_os_netdev_op_hook netDevHook; |
ca97b838 BZ |
813 | |
814 | DBGPRINT(RT_DEBUG_TRACE, ("===>rt2870_probe()!\n")); | |
815 | ||
9f548a2a BZ |
816 | /* Check chipset vendor/product ID */ |
817 | /*if (RT28XXChipsetCheck(_dev_p) == FALSE) */ | |
818 | /* goto err_out; */ | |
ca97b838 | 819 | |
9f548a2a | 820 | /*RtmpDevInit============================================= */ |
62eb734b | 821 | /* Allocate struct rt_rtmp_adapter adapter structure */ |
ca97b838 | 822 | handle = kmalloc(sizeof(struct os_cookie), GFP_KERNEL); |
66cd8d6e BZ |
823 | if (handle == NULL) { |
824 | printk | |
825 | ("rt2870_probe(): Allocate memory for os handle failed!\n"); | |
ca97b838 BZ |
826 | return -ENOMEM; |
827 | } | |
8a10a546 | 828 | ((struct os_cookie *)handle)->pUsb_Dev = usb_dev; |
ca97b838 BZ |
829 | |
830 | rv = RTMPAllocAdapterBlock(handle, &pAd); | |
66cd8d6e | 831 | if (rv != NDIS_STATUS_SUCCESS) { |
ca97b838 BZ |
832 | kfree(handle); |
833 | goto err_out; | |
834 | } | |
9f548a2a | 835 | /*USBDevInit============================================== */ |
ca97b838 BZ |
836 | if (USBDevConfigInit(usb_dev, intf, pAd) == FALSE) |
837 | goto err_out_free_radev; | |
838 | ||
839 | RtmpRaDevCtrlInit(pAd, RTMP_DEV_INF_USB); | |
840 | ||
9f548a2a | 841 | /*NetDevInit============================================== */ |
ca97b838 BZ |
842 | net_dev = RtmpPhyNetDevInit(pAd, &netDevHook); |
843 | if (net_dev == NULL) | |
844 | goto err_out_free_radev; | |
845 | ||
9f548a2a | 846 | /* Here are the net_device structure with usb specific parameters. */ |
ca97b838 | 847 | /* for supporting Network Manager. |
66cd8d6e BZ |
848 | * Set the sysfs physical device reference for the network logical device if set prior to registration will |
849 | * cause a symlink during initialization. | |
ca97b838 BZ |
850 | */ |
851 | SET_NETDEV_DEV(net_dev, &(usb_dev->dev)); | |
852 | ||
66cd8d6e | 853 | pAd->StaCfg.OriDevType = net_dev->type; |
ca97b838 | 854 | |
9f548a2a BZ |
855 | /*All done, it's time to register the net device to linux kernel. */ |
856 | /* Register this device */ | |
ca97b838 BZ |
857 | status = RtmpOSNetDevAttach(net_dev, &netDevHook); |
858 | if (status != 0) | |
859 | goto err_out_free_netdev; | |
860 | ||
861 | #ifdef KTHREAD_SUPPORT | |
862 | init_waitqueue_head(&pAd->mlmeTask.kthread_q); | |
863 | init_waitqueue_head(&pAd->timerTask.kthread_q); | |
864 | init_waitqueue_head(&pAd->cmdQTask.kthread_q); | |
865 | #endif | |
866 | ||
867 | *ppAd = pAd; | |
868 | ||
869 | DBGPRINT(RT_DEBUG_TRACE, ("<===rt2870_probe()!\n")); | |
870 | ||
871 | return 0; | |
872 | ||
873 | /* --------------------------- ERROR HANDLE --------------------------- */ | |
874 | err_out_free_netdev: | |
875 | RtmpOSNetDevFree(net_dev); | |
876 | ||
877 | err_out_free_radev: | |
878 | RTMPFreeAdapter(pAd); | |
879 | ||
880 | err_out: | |
881 | *ppAd = NULL; | |
882 | ||
883 | return -1; | |
884 | ||
885 | } |