diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2009-06-28 10:20:38 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-09-15 15:01:31 -0400 |
commit | fd882783abc0760075d42982d155e8eac2f802ac (patch) | |
tree | 6a3c02feff105c3a76f83e8729540b7125e5722e /drivers/staging/rtl8187se | |
parent | 22eec79469f32f0f9153ec19a37f7e8f448c0522 (diff) |
Staging: rtl8187se: cleanup r8180_core.c
* remove commented out code
* remove useless comments
* beautify code
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/rtl8187se')
-rw-r--r-- | drivers/staging/rtl8187se/r8180_core.c | 1412 |
1 files changed, 245 insertions, 1167 deletions
diff --git a/drivers/staging/rtl8187se/r8180_core.c b/drivers/staging/rtl8187se/r8180_core.c index 68756063d14..08e00347bb6 100644 --- a/drivers/staging/rtl8187se/r8180_core.c +++ b/drivers/staging/rtl8187se/r8180_core.c | |||
@@ -31,8 +31,7 @@ | |||
31 | #undef DUMMY_RX | 31 | #undef DUMMY_RX |
32 | 32 | ||
33 | #include <linux/syscalls.h> | 33 | #include <linux/syscalls.h> |
34 | //#include <linux/fcntl.h> | 34 | |
35 | //#include <asm/uaccess.h> | ||
36 | #include "r8180_hw.h" | 35 | #include "r8180_hw.h" |
37 | #include "r8180.h" | 36 | #include "r8180.h" |
38 | #include "r8180_rtl8225.h" /* RTL8225 Radio frontend */ | 37 | #include "r8180_rtl8225.h" /* RTL8225 Radio frontend */ |
@@ -52,7 +51,6 @@ | |||
52 | static struct pci_device_id rtl8180_pci_id_tbl[] __devinitdata = { | 51 | static struct pci_device_id rtl8180_pci_id_tbl[] __devinitdata = { |
53 | { | 52 | { |
54 | .vendor = PCI_VENDOR_ID_REALTEK, | 53 | .vendor = PCI_VENDOR_ID_REALTEK, |
55 | // .device = 0x8180, | ||
56 | .device = 0x8199, | 54 | .device = 0x8199, |
57 | .subvendor = PCI_ANY_ID, | 55 | .subvendor = PCI_ANY_ID, |
58 | .subdevice = PCI_ANY_ID, | 56 | .subdevice = PCI_ANY_ID, |
@@ -70,7 +68,6 @@ static struct pci_device_id rtl8180_pci_id_tbl[] __devinitdata = { | |||
70 | 68 | ||
71 | static char* ifname = "wlan%d"; | 69 | static char* ifname = "wlan%d"; |
72 | static int hwseqnum = 0; | 70 | static int hwseqnum = 0; |
73 | //static char* ifname = "ath%d"; | ||
74 | static int hwwep = 0; | 71 | static int hwwep = 0; |
75 | static int channels = 0x3fff; | 72 | static int channels = 0x3fff; |
76 | 73 | ||
@@ -82,28 +79,12 @@ MODULE_AUTHOR("Andrea Merello <andreamrl@tiscali.it>"); | |||
82 | MODULE_DESCRIPTION("Linux driver for Realtek RTL8180 / RTL8185 WiFi cards"); | 79 | MODULE_DESCRIPTION("Linux driver for Realtek RTL8180 / RTL8185 WiFi cards"); |
83 | 80 | ||
84 | 81 | ||
85 | |||
86 | /* | ||
87 | MODULE_PARM(ifname, "s"); | ||
88 | MODULE_PARM_DESC(devname," Net interface name, wlan%d=default"); | ||
89 | |||
90 | MODULE_PARM(hwseqnum,"i"); | ||
91 | MODULE_PARM_DESC(hwseqnum," Try to use hardware 802.11 header sequence numbers. Zero=default"); | ||
92 | |||
93 | MODULE_PARM(hwwep,"i"); | ||
94 | MODULE_PARM_DESC(hwwep," Try to use hardware WEP support. Still broken and not available on all cards"); | ||
95 | |||
96 | MODULE_PARM(channels,"i"); | ||
97 | MODULE_PARM_DESC(channels," Channel bitmask for specific locales. NYI"); | ||
98 | */ | ||
99 | |||
100 | module_param(ifname, charp, S_IRUGO|S_IWUSR ); | 82 | module_param(ifname, charp, S_IRUGO|S_IWUSR ); |
101 | module_param(hwseqnum,int, S_IRUGO|S_IWUSR); | 83 | module_param(hwseqnum,int, S_IRUGO|S_IWUSR); |
102 | module_param(hwwep,int, S_IRUGO|S_IWUSR); | 84 | module_param(hwwep,int, S_IRUGO|S_IWUSR); |
103 | module_param(channels,int, S_IRUGO|S_IWUSR); | 85 | module_param(channels,int, S_IRUGO|S_IWUSR); |
104 | 86 | ||
105 | MODULE_PARM_DESC(devname," Net interface name, wlan%d=default"); | 87 | MODULE_PARM_DESC(devname," Net interface name, wlan%d=default"); |
106 | //MODULE_PARM_DESC(devname," Net interface name, ath%d=default"); | ||
107 | MODULE_PARM_DESC(hwseqnum," Try to use hardware 802.11 header sequence numbers. Zero=default"); | 88 | MODULE_PARM_DESC(hwseqnum," Try to use hardware 802.11 header sequence numbers. Zero=default"); |
108 | MODULE_PARM_DESC(hwwep," Try to use hardware WEP support. Still broken and not available on all cards"); | 89 | MODULE_PARM_DESC(hwwep," Try to use hardware WEP support. Still broken and not available on all cards"); |
109 | MODULE_PARM_DESC(channels," Channel bitmask for specific locales. NYI"); | 90 | MODULE_PARM_DESC(channels," Channel bitmask for specific locales. NYI"); |
@@ -181,18 +162,15 @@ out: | |||
181 | } | 162 | } |
182 | 163 | ||
183 | static struct pci_driver rtl8180_pci_driver = { | 164 | static struct pci_driver rtl8180_pci_driver = { |
184 | .name = RTL8180_MODULE_NAME, /* Driver name */ | 165 | .name = RTL8180_MODULE_NAME, |
185 | .id_table = rtl8180_pci_id_tbl, /* PCI_ID table */ | 166 | .id_table = rtl8180_pci_id_tbl, |
186 | .probe = rtl8180_pci_probe, /* probe fn */ | 167 | .probe = rtl8180_pci_probe, |
187 | .remove = __devexit_p(rtl8180_pci_remove),/* remove fn */ | 168 | .remove = __devexit_p(rtl8180_pci_remove), |
188 | .suspend = rtl8180_suspend, /* PM suspend fn */ | 169 | .suspend = rtl8180_suspend, |
189 | .resume = rtl8180_resume, /* PM resume fn */ | 170 | .resume = rtl8180_resume, |
190 | .shutdown = rtl8180_shutdown, | 171 | .shutdown = rtl8180_shutdown, |
191 | }; | 172 | }; |
192 | 173 | ||
193 | |||
194 | |||
195 | |||
196 | u8 read_nic_byte(struct net_device *dev, int x) | 174 | u8 read_nic_byte(struct net_device *dev, int x) |
197 | { | 175 | { |
198 | return 0xff&readb((u8*)dev->mem_start +x); | 176 | return 0xff&readb((u8*)dev->mem_start +x); |
@@ -226,18 +204,12 @@ void write_nic_word(struct net_device *dev, int x,u16 y) | |||
226 | udelay(20); | 204 | udelay(20); |
227 | } | 205 | } |
228 | 206 | ||
229 | |||
230 | |||
231 | |||
232 | |||
233 | |||
234 | inline void force_pci_posting(struct net_device *dev) | 207 | inline void force_pci_posting(struct net_device *dev) |
235 | { | 208 | { |
236 | read_nic_byte(dev,EPROM_CMD); | 209 | read_nic_byte(dev,EPROM_CMD); |
237 | mb(); | 210 | mb(); |
238 | } | 211 | } |
239 | 212 | ||
240 | |||
241 | irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs); | 213 | irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs); |
242 | void set_nic_rxring(struct net_device *dev); | 214 | void set_nic_rxring(struct net_device *dev); |
243 | void set_nic_txring(struct net_device *dev); | 215 | void set_nic_txring(struct net_device *dev); |
@@ -245,10 +217,6 @@ static struct net_device_stats *rtl8180_stats(struct net_device *dev); | |||
245 | void rtl8180_commit(struct net_device *dev); | 217 | void rtl8180_commit(struct net_device *dev); |
246 | void rtl8180_start_tx_beacon(struct net_device *dev); | 218 | void rtl8180_start_tx_beacon(struct net_device *dev); |
247 | 219 | ||
248 | /**************************************************************************** | ||
249 | -----------------------------PROCFS STUFF------------------------- | ||
250 | *****************************************************************************/ | ||
251 | |||
252 | static struct proc_dir_entry *rtl8180_proc = NULL; | 220 | static struct proc_dir_entry *rtl8180_proc = NULL; |
253 | 221 | ||
254 | static int proc_get_registers(char *page, char **start, | 222 | static int proc_get_registers(char *page, char **start, |
@@ -256,33 +224,22 @@ static int proc_get_registers(char *page, char **start, | |||
256 | int *eof, void *data) | 224 | int *eof, void *data) |
257 | { | 225 | { |
258 | struct net_device *dev = data; | 226 | struct net_device *dev = data; |
259 | // struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | ||
260 | |||
261 | int len = 0; | 227 | int len = 0; |
262 | int i,n; | 228 | int i,n; |
263 | 229 | int max = 0xff; | |
264 | int max=0xff; | ||
265 | 230 | ||
266 | /* This dump the current register page */ | 231 | /* This dump the current register page */ |
267 | for(n=0;n<=max;) | 232 | for (n = 0; n <= max;) { |
268 | { | 233 | len += snprintf(page + len, count - len, "\nD: %2x > ", n); |
269 | //printk( "\nD: %2x> ", n); | ||
270 | len += snprintf(page + len, count - len, | ||
271 | "\nD: %2x > ",n); | ||
272 | 234 | ||
273 | for(i=0;i<16 && n<=max;i++,n++) | 235 | for (i = 0; i < 16 && n <= max; i++, n++) |
274 | len += snprintf(page + len, count - len, | 236 | len += snprintf(page + len, count - len, "%2x ", |
275 | "%2x ",read_nic_byte(dev,n)); | 237 | read_nic_byte(dev, n)); |
276 | |||
277 | // printk("%2x ",read_nic_byte(dev,n)); | ||
278 | } | 238 | } |
279 | len += snprintf(page + len, count - len,"\n"); | 239 | len += snprintf(page + len, count - len,"\n"); |
280 | 240 | ||
281 | |||
282 | |||
283 | *eof = 1; | 241 | *eof = 1; |
284 | return len; | 242 | return len; |
285 | |||
286 | } | 243 | } |
287 | 244 | ||
288 | int get_curr_tx_free_desc(struct net_device *dev, int priority); | 245 | int get_curr_tx_free_desc(struct net_device *dev, int priority); |
@@ -291,16 +248,12 @@ static int proc_get_stats_hw(char *page, char **start, | |||
291 | off_t offset, int count, | 248 | off_t offset, int count, |
292 | int *eof, void *data) | 249 | int *eof, void *data) |
293 | { | 250 | { |
294 | //struct net_device *dev = data; | ||
295 | //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | ||
296 | |||
297 | int len = 0; | 251 | int len = 0; |
298 | 252 | ||
299 | *eof = 1; | 253 | *eof = 1; |
300 | return len; | 254 | return len; |
301 | } | 255 | } |
302 | 256 | ||
303 | |||
304 | static int proc_get_stats_rx(char *page, char **start, | 257 | static int proc_get_stats_rx(char *page, char **start, |
305 | off_t offset, int count, | 258 | off_t offset, int count, |
306 | int *eof, void *data) | 259 | int *eof, void *data) |
@@ -311,30 +264,6 @@ static int proc_get_stats_rx(char *page, char **start, | |||
311 | int len = 0; | 264 | int len = 0; |
312 | 265 | ||
313 | len += snprintf(page + len, count - len, | 266 | len += snprintf(page + len, count - len, |
314 | /* "RX descriptor not available: %lu\n" | ||
315 | "RX incomplete (missing last descriptor): %lu\n" | ||
316 | "RX not data: %lu\n" | ||
317 | //"RX descriptor pointer reset: %lu\n" | ||
318 | "RX descriptor pointer lost: %lu\n" | ||
319 | //"RX pointer workaround: %lu\n" | ||
320 | "RX error int: %lu\n" | ||
321 | "RX fifo overflow: %lu\n" | ||
322 | "RX int: %lu\n" | ||
323 | "RX packet: %lu\n" | ||
324 | "RX bytes: %lu\n" | ||
325 | "RX DMA fail: %lu\n", | ||
326 | priv->stats.rxrdu, | ||
327 | priv->stats.rxnolast, | ||
328 | priv->stats.rxnodata, | ||
329 | //priv->stats.rxreset, | ||
330 | priv->stats.rxnopointer, | ||
331 | //priv->stats.rxwrkaround, | ||
332 | priv->stats.rxerr, | ||
333 | priv->stats.rxoverflow, | ||
334 | priv->stats.rxint, | ||
335 | priv->ieee80211->stats.rx_packets, | ||
336 | priv->ieee80211->stats.rx_bytes, | ||
337 | priv->stats.rxdmafail */ | ||
338 | "RX OK: %lu\n" | 267 | "RX OK: %lu\n" |
339 | "RX Retry: %lu\n" | 268 | "RX Retry: %lu\n" |
340 | "RX CRC Error(0-500): %lu\n" | 269 | "RX CRC Error(0-500): %lu\n" |
@@ -365,36 +294,6 @@ static int proc_get_stats_tx(char *page, char **start, | |||
365 | 294 | ||
366 | totalOK=priv->stats.txnpokint+priv->stats.txhpokint+priv->stats.txlpokint; | 295 | totalOK=priv->stats.txnpokint+priv->stats.txhpokint+priv->stats.txlpokint; |
367 | len += snprintf(page + len, count - len, | 296 | len += snprintf(page + len, count - len, |
368 | /* "TX normal priority ok int: %lu\n" | ||
369 | "TX normal priority error int: %lu\n" | ||
370 | "TX high priority ok int: %lu\n" | ||
371 | "TX high priority failed error int: %lu\n" | ||
372 | "TX low priority ok int: %lu\n" | ||
373 | "TX low priority failed error int: %lu\n" | ||
374 | "TX bytes: %lu\n" | ||
375 | "TX packets: %lu\n" | ||
376 | "TX queue resume: %lu\n" | ||
377 | "TX queue stopped?: %d\n" | ||
378 | "TX fifo overflow: %lu\n" | ||
379 | //"SW TX stop: %lu\n" | ||
380 | //"SW TX wake: %lu\n" | ||
381 | "TX beacon: %lu\n" | ||
382 | "TX beacon aborted: %lu\n", | ||
383 | priv->stats.txnpokint, | ||
384 | priv->stats.txnperr, | ||
385 | priv->stats.txhpokint, | ||
386 | priv->stats.txhperr, | ||
387 | priv->stats.txlpokint, | ||
388 | priv->stats.txlperr, | ||
389 | priv->ieee80211->stats.tx_bytes, | ||
390 | priv->ieee80211->stats.tx_packets, | ||
391 | priv->stats.txresumed, | ||
392 | netif_queue_stopped(dev), | ||
393 | priv->stats.txoverflow, | ||
394 | //priv->ieee80211->ieee_stats.swtxstop, | ||
395 | //priv->ieee80211->ieee_stats.swtxawake, | ||
396 | priv->stats.txbeacon, | ||
397 | priv->stats.txbeaconerr */ | ||
398 | "TX OK: %lu\n" | 297 | "TX OK: %lu\n" |
399 | "TX Error: %lu\n" | 298 | "TX Error: %lu\n" |
400 | "TX Retry: %lu\n" | 299 | "TX Retry: %lu\n" |
@@ -417,13 +316,11 @@ void rtl8180_proc_module_init(void) | |||
417 | rtl8180_proc=create_proc_entry(RTL8180_MODULE_NAME, S_IFDIR, init_net.proc_net); | 316 | rtl8180_proc=create_proc_entry(RTL8180_MODULE_NAME, S_IFDIR, init_net.proc_net); |
418 | } | 317 | } |
419 | 318 | ||
420 | |||
421 | void rtl8180_proc_module_remove(void) | 319 | void rtl8180_proc_module_remove(void) |
422 | { | 320 | { |
423 | remove_proc_entry(RTL8180_MODULE_NAME, init_net.proc_net); | 321 | remove_proc_entry(RTL8180_MODULE_NAME, init_net.proc_net); |
424 | } | 322 | } |
425 | 323 | ||
426 | |||
427 | void rtl8180_proc_remove_one(struct net_device *dev) | 324 | void rtl8180_proc_remove_one(struct net_device *dev) |
428 | { | 325 | { |
429 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 326 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
@@ -431,19 +328,17 @@ void rtl8180_proc_remove_one(struct net_device *dev) | |||
431 | remove_proc_entry("stats-hw", priv->dir_dev); | 328 | remove_proc_entry("stats-hw", priv->dir_dev); |
432 | remove_proc_entry("stats-tx", priv->dir_dev); | 329 | remove_proc_entry("stats-tx", priv->dir_dev); |
433 | remove_proc_entry("stats-rx", priv->dir_dev); | 330 | remove_proc_entry("stats-rx", priv->dir_dev); |
434 | // remove_proc_entry("stats-ieee", priv->dir_dev); | ||
435 | // remove_proc_entry("stats-ap", priv->dir_dev); | ||
436 | remove_proc_entry("registers", priv->dir_dev); | 331 | remove_proc_entry("registers", priv->dir_dev); |
437 | remove_proc_entry(dev->name, rtl8180_proc); | 332 | remove_proc_entry(dev->name, rtl8180_proc); |
438 | priv->dir_dev = NULL; | 333 | priv->dir_dev = NULL; |
439 | } | 334 | } |
440 | } | 335 | } |
441 | 336 | ||
442 | |||
443 | void rtl8180_proc_init_one(struct net_device *dev) | 337 | void rtl8180_proc_init_one(struct net_device *dev) |
444 | { | 338 | { |
445 | struct proc_dir_entry *e; | 339 | struct proc_dir_entry *e; |
446 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 340 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
341 | |||
447 | priv->dir_dev = rtl8180_proc; | 342 | priv->dir_dev = rtl8180_proc; |
448 | if (!priv->dir_dev) { | 343 | if (!priv->dir_dev) { |
449 | DMESGE("Unable to initialize /proc/net/r8180/%s\n", | 344 | DMESGE("Unable to initialize /proc/net/r8180/%s\n", |
@@ -453,7 +348,6 @@ void rtl8180_proc_init_one(struct net_device *dev) | |||
453 | 348 | ||
454 | e = create_proc_read_entry("stats-hw", S_IFREG | S_IRUGO, | 349 | e = create_proc_read_entry("stats-hw", S_IFREG | S_IRUGO, |
455 | priv->dir_dev, proc_get_stats_hw, dev); | 350 | priv->dir_dev, proc_get_stats_hw, dev); |
456 | |||
457 | if (!e) { | 351 | if (!e) { |
458 | DMESGE("Unable to initialize " | 352 | DMESGE("Unable to initialize " |
459 | "/proc/net/r8180/%s/stats-hw\n", | 353 | "/proc/net/r8180/%s/stats-hw\n", |
@@ -462,7 +356,6 @@ void rtl8180_proc_init_one(struct net_device *dev) | |||
462 | 356 | ||
463 | e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO, | 357 | e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO, |
464 | priv->dir_dev, proc_get_stats_rx, dev); | 358 | priv->dir_dev, proc_get_stats_rx, dev); |
465 | |||
466 | if (!e) { | 359 | if (!e) { |
467 | DMESGE("Unable to initialize " | 360 | DMESGE("Unable to initialize " |
468 | "/proc/net/r8180/%s/stats-rx\n", | 361 | "/proc/net/r8180/%s/stats-rx\n", |
@@ -472,7 +365,6 @@ void rtl8180_proc_init_one(struct net_device *dev) | |||
472 | 365 | ||
473 | e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO, | 366 | e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO, |
474 | priv->dir_dev, proc_get_stats_tx, dev); | 367 | priv->dir_dev, proc_get_stats_tx, dev); |
475 | |||
476 | if (!e) { | 368 | if (!e) { |
477 | DMESGE("Unable to initialize " | 369 | DMESGE("Unable to initialize " |
478 | "/proc/net/r8180/%s/stats-tx\n", | 370 | "/proc/net/r8180/%s/stats-tx\n", |
@@ -481,16 +373,13 @@ void rtl8180_proc_init_one(struct net_device *dev) | |||
481 | 373 | ||
482 | e = create_proc_read_entry("registers", S_IFREG | S_IRUGO, | 374 | e = create_proc_read_entry("registers", S_IFREG | S_IRUGO, |
483 | priv->dir_dev, proc_get_registers, dev); | 375 | priv->dir_dev, proc_get_registers, dev); |
484 | |||
485 | if (!e) { | 376 | if (!e) { |
486 | DMESGE("Unable to initialize " | 377 | DMESGE("Unable to initialize " |
487 | "/proc/net/r8180/%s/registers\n", | 378 | "/proc/net/r8180/%s/registers\n", |
488 | dev->name); | 379 | dev->name); |
489 | } | 380 | } |
490 | } | 381 | } |
491 | /**************************************************************************** | 382 | |
492 | -----------------------------MISC STUFF------------------------- | ||
493 | *****************************************************************************/ | ||
494 | /* | 383 | /* |
495 | FIXME: check if we can use some standard already-existent | 384 | FIXME: check if we can use some standard already-existent |
496 | data type+functions in kernel | 385 | data type+functions in kernel |
@@ -530,7 +419,6 @@ short buffer_add(struct buffer **buffer, u32 *buf, dma_addr_t dma, | |||
530 | return 0; | 419 | return 0; |
531 | } | 420 | } |
532 | 421 | ||
533 | |||
534 | void buffer_free(struct net_device *dev,struct buffer **buffer,int len,short | 422 | void buffer_free(struct net_device *dev,struct buffer **buffer,int len,short |
535 | consistent) | 423 | consistent) |
536 | { | 424 | { |
@@ -538,14 +426,12 @@ consistent) | |||
538 | struct buffer *tmp,*next; | 426 | struct buffer *tmp,*next; |
539 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 427 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
540 | struct pci_dev *pdev=priv->pdev; | 428 | struct pci_dev *pdev=priv->pdev; |
541 | //int i; | ||
542 | 429 | ||
543 | if(! *buffer) return; | 430 | if (!*buffer) |
431 | return; | ||
544 | 432 | ||
545 | /*for(tmp=*buffer; tmp->next != *buffer; tmp=tmp->next) | 433 | tmp = *buffer; |
546 | 434 | ||
547 | */ | ||
548 | tmp=*buffer; | ||
549 | do{ | 435 | do{ |
550 | next=tmp->next; | 436 | next=tmp->next; |
551 | if(consistent){ | 437 | if(consistent){ |
@@ -564,7 +450,6 @@ consistent) | |||
564 | *buffer=NULL; | 450 | *buffer=NULL; |
565 | } | 451 | } |
566 | 452 | ||
567 | |||
568 | void print_buffer(u32 *buffer, int len) | 453 | void print_buffer(u32 *buffer, int len) |
569 | { | 454 | { |
570 | int i; | 455 | int i; |
@@ -583,7 +468,6 @@ void print_buffer(u32 *buffer, int len) | |||
583 | printk("\n"); | 468 | printk("\n"); |
584 | } | 469 | } |
585 | 470 | ||
586 | |||
587 | int get_curr_tx_free_desc(struct net_device *dev, int priority) | 471 | int get_curr_tx_free_desc(struct net_device *dev, int priority) |
588 | { | 472 | { |
589 | struct r8180_priv *priv = ieee80211_priv(dev); | 473 | struct r8180_priv *priv = ieee80211_priv(dev); |
@@ -620,34 +504,33 @@ int get_curr_tx_free_desc(struct net_device *dev, int priority) | |||
620 | return -1; | 504 | return -1; |
621 | } | 505 | } |
622 | 506 | ||
623 | //DMESG("%x %x", head, tail); | 507 | if (head <= tail) |
624 | |||
625 | /* FIXME FIXME FIXME FIXME */ | ||
626 | |||
627 | if( head <= tail ) | ||
628 | ret = priv->txringcount - (tail - head)/8; | 508 | ret = priv->txringcount - (tail - head)/8; |
629 | else | 509 | else |
630 | ret = (head - tail)/8; | 510 | ret = (head - tail)/8; |
631 | 511 | ||
632 | if(ret > priv->txringcount ) DMESG("BUG"); | 512 | if (ret > priv->txringcount) |
513 | DMESG("BUG"); | ||
514 | |||
633 | return ret; | 515 | return ret; |
634 | } | 516 | } |
635 | 517 | ||
636 | |||
637 | short check_nic_enought_desc(struct net_device *dev, int priority) | 518 | short check_nic_enought_desc(struct net_device *dev, int priority) |
638 | { | 519 | { |
639 | struct r8180_priv *priv = ieee80211_priv(dev); | 520 | struct r8180_priv *priv = ieee80211_priv(dev); |
640 | struct ieee80211_device *ieee = netdev_priv(dev); | 521 | struct ieee80211_device *ieee = netdev_priv(dev); |
641 | |||
642 | int requiredbyte, required; | 522 | int requiredbyte, required; |
523 | |||
643 | requiredbyte = priv->ieee80211->fts + sizeof(struct ieee80211_header_data); | 524 | requiredbyte = priv->ieee80211->fts + sizeof(struct ieee80211_header_data); |
644 | 525 | ||
645 | if(ieee->current_network.QoS_Enable) { | 526 | if (ieee->current_network.QoS_Enable) |
646 | requiredbyte += 2; | 527 | requiredbyte += 2; |
647 | }; | ||
648 | 528 | ||
649 | required = requiredbyte / (priv->txbuffsize-4); | 529 | required = requiredbyte / (priv->txbuffsize-4); |
650 | if (requiredbyte % priv->txbuffsize) required++; | 530 | |
531 | if (requiredbyte % priv->txbuffsize) | ||
532 | required++; | ||
533 | |||
651 | /* for now we keep two free descriptor as a safety boundary | 534 | /* for now we keep two free descriptor as a safety boundary |
652 | * between the tail and the head | 535 | * between the tail and the head |
653 | */ | 536 | */ |
@@ -734,7 +617,6 @@ void fix_tx_fifo(struct net_device *dev) | |||
734 | priv->ack_tx_to_ieee = 0; | 617 | priv->ack_tx_to_ieee = 0; |
735 | } | 618 | } |
736 | 619 | ||
737 | |||
738 | void fix_rx_fifo(struct net_device *dev) | 620 | void fix_rx_fifo(struct net_device *dev) |
739 | { | 621 | { |
740 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 622 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
@@ -759,39 +641,34 @@ void fix_rx_fifo(struct net_device *dev) | |||
759 | set_nic_rxring(dev); | 641 | set_nic_rxring(dev); |
760 | } | 642 | } |
761 | 643 | ||
762 | |||
763 | /**************************************************************************** | ||
764 | ------------------------------HW STUFF--------------------------- | ||
765 | *****************************************************************************/ | ||
766 | |||
767 | unsigned char QUALITY_MAP[] = { | 644 | unsigned char QUALITY_MAP[] = { |
768 | 0x64, 0x64, 0x64, 0x63, 0x63, 0x62, 0x62, 0x61, | 645 | 0x64, 0x64, 0x64, 0x63, 0x63, 0x62, 0x62, 0x61, |
769 | 0x61, 0x60, 0x60, 0x5f, 0x5f, 0x5e, 0x5d, 0x5c, | 646 | 0x61, 0x60, 0x60, 0x5f, 0x5f, 0x5e, 0x5d, 0x5c, |
770 | 0x5b, 0x5a, 0x59, 0x57, 0x56, 0x54, 0x52, 0x4f, | 647 | 0x5b, 0x5a, 0x59, 0x57, 0x56, 0x54, 0x52, 0x4f, |
771 | 0x4c, 0x49, 0x45, 0x41, 0x3c, 0x37, 0x31, 0x29, | 648 | 0x4c, 0x49, 0x45, 0x41, 0x3c, 0x37, 0x31, 0x29, |
772 | 0x24, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, | 649 | 0x24, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, |
773 | 0x22, 0x22, 0x21, 0x21, 0x21, 0x21, 0x21, 0x20, | 650 | 0x22, 0x22, 0x21, 0x21, 0x21, 0x21, 0x21, 0x20, |
774 | 0x20, 0x20, 0x20, 0x1f, 0x1f, 0x1e, 0x1e, 0x1e, | 651 | 0x20, 0x20, 0x20, 0x1f, 0x1f, 0x1e, 0x1e, 0x1e, |
775 | 0x1d, 0x1d, 0x1c, 0x1c, 0x1b, 0x1a, 0x19, 0x19, | 652 | 0x1d, 0x1d, 0x1c, 0x1c, 0x1b, 0x1a, 0x19, 0x19, |
776 | 0x18, 0x17, 0x16, 0x15, 0x14, 0x12, 0x11, 0x0f, | 653 | 0x18, 0x17, 0x16, 0x15, 0x14, 0x12, 0x11, 0x0f, |
777 | 0x0e, 0x0c, 0x0a, 0x08, 0x06, 0x04, 0x01, 0x00 | 654 | 0x0e, 0x0c, 0x0a, 0x08, 0x06, 0x04, 0x01, 0x00 |
778 | }; | 655 | }; |
779 | 656 | ||
780 | unsigned char STRENGTH_MAP[] = { | 657 | unsigned char STRENGTH_MAP[] = { |
781 | 0x64, 0x64, 0x63, 0x62, 0x61, 0x60, 0x5f, 0x5e, | 658 | 0x64, 0x64, 0x63, 0x62, 0x61, 0x60, 0x5f, 0x5e, |
782 | 0x5d, 0x5c, 0x5b, 0x5a, 0x57, 0x54, 0x52, 0x50, | 659 | 0x5d, 0x5c, 0x5b, 0x5a, 0x57, 0x54, 0x52, 0x50, |
783 | 0x4e, 0x4c, 0x4a, 0x48, 0x46, 0x44, 0x41, 0x3f, | 660 | 0x4e, 0x4c, 0x4a, 0x48, 0x46, 0x44, 0x41, 0x3f, |
784 | 0x3c, 0x3a, 0x37, 0x36, 0x36, 0x1c, 0x1c, 0x1b, | 661 | 0x3c, 0x3a, 0x37, 0x36, 0x36, 0x1c, 0x1c, 0x1b, |
785 | 0x1b, 0x1a, 0x1a, 0x19, 0x19, 0x18, 0x18, 0x17, | 662 | 0x1b, 0x1a, 0x1a, 0x19, 0x19, 0x18, 0x18, 0x17, |
786 | 0x17, 0x16, 0x16, 0x15, 0x15, 0x14, 0x14, 0x13, | 663 | 0x17, 0x16, 0x16, 0x15, 0x15, 0x14, 0x14, 0x13, |
787 | 0x13, 0x12, 0x12, 0x11, 0x11, 0x10, 0x10, 0x0f, | 664 | 0x13, 0x12, 0x12, 0x11, 0x11, 0x10, 0x10, 0x0f, |
788 | 0x0f, 0x0e, 0x0e, 0x0d, 0x0d, 0x0c, 0x0c, 0x0b, | 665 | 0x0f, 0x0e, 0x0e, 0x0d, 0x0d, 0x0c, 0x0c, 0x0b, |
789 | 0x0b, 0x0a, 0x0a, 0x09, 0x09, 0x08, 0x08, 0x07, | 666 | 0x0b, 0x0a, 0x0a, 0x09, 0x09, 0x08, 0x08, 0x07, |
790 | 0x07, 0x06, 0x06, 0x05, 0x04, 0x03, 0x02, 0x00 | 667 | 0x07, 0x06, 0x06, 0x05, 0x04, 0x03, 0x02, 0x00 |
791 | }; | 668 | }; |
792 | 669 | ||
793 | void rtl8180_RSSI_calc(struct net_device *dev, u8 *rssi, u8 *qual){ | 670 | void rtl8180_RSSI_calc(struct net_device *dev, u8 *rssi, u8 *qual) |
794 | //void Mlme_UpdateRssiSQ(struct net_device *dev, u8 *rssi, u8 *qual){ | 671 | { |
795 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 672 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
796 | u32 temp; | 673 | u32 temp; |
797 | u32 temp2; | 674 | u32 temp2; |
@@ -887,8 +764,6 @@ void rtl8180_RSSI_calc(struct net_device *dev, u8 *rssi, u8 *qual){ | |||
887 | } | 764 | } |
888 | } | 765 | } |
889 | break; | 766 | break; |
890 | |||
891 | /* case 4 */ | ||
892 | case RFCHIPID_MAXIM: | 767 | case RFCHIPID_MAXIM: |
893 | lsb = temp2 & 1; | 768 | lsb = temp2 & 1; |
894 | temp2 &= 0x7e; | 769 | temp2 &= 0x7e; |
@@ -913,21 +788,14 @@ void rtl8180_RSSI_calc(struct net_device *dev, u8 *rssi, u8 *qual){ | |||
913 | return; | 788 | return; |
914 | } | 789 | } |
915 | 790 | ||
916 | |||
917 | void rtl8180_irq_enable(struct net_device *dev) | 791 | void rtl8180_irq_enable(struct net_device *dev) |
918 | { | 792 | { |
919 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 793 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
794 | |||
920 | priv->irq_enabled = 1; | 795 | priv->irq_enabled = 1; |
921 | /* | ||
922 | write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\ | ||
923 | INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\ | ||
924 | INTA_NORMPRIORITYDESCERR | INTA_NORMPRIORITYDESCOK |\ | ||
925 | INTA_LOWPRIORITYDESCERR | INTA_LOWPRIORITYDESCOK | INTA_TIMEOUT); | ||
926 | */ | ||
927 | write_nic_word(dev,INTA_MASK, priv->irq_mask); | 796 | write_nic_word(dev,INTA_MASK, priv->irq_mask); |
928 | } | 797 | } |
929 | 798 | ||
930 | |||
931 | void rtl8180_irq_disable(struct net_device *dev) | 799 | void rtl8180_irq_disable(struct net_device *dev) |
932 | { | 800 | { |
933 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 801 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
@@ -937,10 +805,10 @@ void rtl8180_irq_disable(struct net_device *dev) | |||
937 | priv->irq_enabled = 0; | 805 | priv->irq_enabled = 0; |
938 | } | 806 | } |
939 | 807 | ||
940 | |||
941 | void rtl8180_set_mode(struct net_device *dev,int mode) | 808 | void rtl8180_set_mode(struct net_device *dev,int mode) |
942 | { | 809 | { |
943 | u8 ecmd; | 810 | u8 ecmd; |
811 | |||
944 | ecmd=read_nic_byte(dev, EPROM_CMD); | 812 | ecmd=read_nic_byte(dev, EPROM_CMD); |
945 | ecmd=ecmd &~ EPROM_CMD_OPERATING_MODE_MASK; | 813 | ecmd=ecmd &~ EPROM_CMD_OPERATING_MODE_MASK; |
946 | ecmd=ecmd | (mode<<EPROM_CMD_OPERATING_MODE_SHIFT); | 814 | ecmd=ecmd | (mode<<EPROM_CMD_OPERATING_MODE_SHIFT); |
@@ -982,28 +850,21 @@ void rtl8180_update_msr(struct net_device *dev) | |||
982 | 850 | ||
983 | write_nic_byte(dev, MSR, msr); | 851 | write_nic_byte(dev, MSR, msr); |
984 | write_nic_dword(dev, RX_CONF, rxconf); | 852 | write_nic_dword(dev, RX_CONF, rxconf); |
985 | |||
986 | } | 853 | } |
987 | 854 | ||
988 | |||
989 | |||
990 | void rtl8180_set_chan(struct net_device *dev,short ch) | 855 | void rtl8180_set_chan(struct net_device *dev,short ch) |
991 | { | 856 | { |
992 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 857 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
993 | 858 | ||
994 | if((ch > 14) || (ch < 1)) | 859 | if ((ch > 14) || (ch < 1)) { |
995 | { | ||
996 | printk("In %s: Invalid chnanel %d\n", __func__, ch); | 860 | printk("In %s: Invalid chnanel %d\n", __func__, ch); |
997 | return; | 861 | return; |
998 | } | 862 | } |
999 | 863 | ||
1000 | priv->chan=ch; | 864 | priv->chan=ch; |
1001 | //printk("in %s:channel is %d\n",__func__,ch); | ||
1002 | priv->rf_set_chan(dev,priv->chan); | 865 | priv->rf_set_chan(dev,priv->chan); |
1003 | |||
1004 | } | 866 | } |
1005 | 867 | ||
1006 | |||
1007 | void rtl8180_rx_enable(struct net_device *dev) | 868 | void rtl8180_rx_enable(struct net_device *dev) |
1008 | { | 869 | { |
1009 | u8 cmd; | 870 | u8 cmd; |
@@ -1017,8 +878,8 @@ void rtl8180_rx_enable(struct net_device *dev) | |||
1017 | rxconf = rxconf | (1<<ACCEPT_DATA_FRAME_SHIFT); | 878 | rxconf = rxconf | (1<<ACCEPT_DATA_FRAME_SHIFT); |
1018 | rxconf = rxconf | (1<<ACCEPT_BCAST_FRAME_SHIFT); | 879 | rxconf = rxconf | (1<<ACCEPT_BCAST_FRAME_SHIFT); |
1019 | rxconf = rxconf | (1<<ACCEPT_MCAST_FRAME_SHIFT); | 880 | rxconf = rxconf | (1<<ACCEPT_MCAST_FRAME_SHIFT); |
1020 | // rxconf = rxconf | (1<<ACCEPT_CRCERR_FRAME_SHIFT); | 881 | if (dev->flags & IFF_PROMISC) |
1021 | if (dev->flags & IFF_PROMISC) DMESG ("NIC in promisc mode"); | 882 | DMESG("NIC in promisc mode"); |
1022 | 883 | ||
1023 | if(priv->ieee80211->iw_mode == IW_MODE_MONITOR || \ | 884 | if(priv->ieee80211->iw_mode == IW_MODE_MONITOR || \ |
1024 | dev->flags & IFF_PROMISC){ | 885 | dev->flags & IFF_PROMISC){ |
@@ -1029,11 +890,6 @@ void rtl8180_rx_enable(struct net_device *dev) | |||
1029 | rxconf = rxconf | (1<<RX_CHECK_BSSID_SHIFT); | 890 | rxconf = rxconf | (1<<RX_CHECK_BSSID_SHIFT); |
1030 | } | 891 | } |
1031 | 892 | ||
1032 | /*if(priv->ieee80211->iw_mode == IW_MODE_MASTER){ | ||
1033 | rxconf = rxconf | (1<<ACCEPT_ALLMAC_FRAME_SHIFT); | ||
1034 | rxconf = rxconf | (1<<RX_CHECK_BSSID_SHIFT); | ||
1035 | }*/ | ||
1036 | |||
1037 | if(priv->ieee80211->iw_mode == IW_MODE_MONITOR){ | 893 | if(priv->ieee80211->iw_mode == IW_MODE_MONITOR){ |
1038 | rxconf = rxconf | (1<<ACCEPT_CTL_FRAME_SHIFT); | 894 | rxconf = rxconf | (1<<ACCEPT_CTL_FRAME_SHIFT); |
1039 | rxconf = rxconf | (1<<ACCEPT_ICVERR_FRAME_SHIFT); | 895 | rxconf = rxconf | (1<<ACCEPT_ICVERR_FRAME_SHIFT); |
@@ -1043,81 +899,61 @@ void rtl8180_rx_enable(struct net_device *dev) | |||
1043 | if( priv->crcmon == 1 && priv->ieee80211->iw_mode == IW_MODE_MONITOR) | 899 | if( priv->crcmon == 1 && priv->ieee80211->iw_mode == IW_MODE_MONITOR) |
1044 | rxconf = rxconf | (1<<ACCEPT_CRCERR_FRAME_SHIFT); | 900 | rxconf = rxconf | (1<<ACCEPT_CRCERR_FRAME_SHIFT); |
1045 | 901 | ||
1046 | //if(!priv->card_8185){ | 902 | rxconf = rxconf & ~RX_FIFO_THRESHOLD_MASK; |
1047 | rxconf = rxconf &~ RX_FIFO_THRESHOLD_MASK; | 903 | rxconf = rxconf | (RX_FIFO_THRESHOLD_NONE << RX_FIFO_THRESHOLD_SHIFT); |
1048 | rxconf = rxconf | (RX_FIFO_THRESHOLD_NONE<<RX_FIFO_THRESHOLD_SHIFT); | ||
1049 | //} | ||
1050 | 904 | ||
1051 | rxconf = rxconf | (1<<RX_AUTORESETPHY_SHIFT); | 905 | rxconf = rxconf | (1<<RX_AUTORESETPHY_SHIFT); |
1052 | rxconf = rxconf &~ MAX_RX_DMA_MASK; | 906 | rxconf = rxconf &~ MAX_RX_DMA_MASK; |
1053 | rxconf = rxconf | (MAX_RX_DMA_2048<<MAX_RX_DMA_SHIFT); | 907 | rxconf = rxconf | (MAX_RX_DMA_2048<<MAX_RX_DMA_SHIFT); |
1054 | 908 | ||
1055 | //if(!priv->card_8185) | 909 | rxconf = rxconf | RCR_ONLYERLPKT; |
1056 | rxconf = rxconf | RCR_ONLYERLPKT; | ||
1057 | 910 | ||
1058 | rxconf = rxconf &~ RCR_CS_MASK; | 911 | rxconf = rxconf &~ RCR_CS_MASK; |
1059 | if(!priv->card_8185) | 912 | |
913 | if (!priv->card_8185) | ||
1060 | rxconf |= (priv->rcr_csense<<RCR_CS_SHIFT); | 914 | rxconf |= (priv->rcr_csense<<RCR_CS_SHIFT); |
1061 | // rxconf &=~ 0xfff00000; | 915 | |
1062 | // rxconf |= 0x90100000;//9014f76f; | ||
1063 | write_nic_dword(dev, RX_CONF, rxconf); | 916 | write_nic_dword(dev, RX_CONF, rxconf); |
1064 | 917 | ||
1065 | fix_rx_fifo(dev); | 918 | fix_rx_fifo(dev); |
1066 | 919 | ||
1067 | cmd=read_nic_byte(dev,CMD); | 920 | cmd=read_nic_byte(dev,CMD); |
1068 | write_nic_byte(dev,CMD,cmd | (1<<CMD_RX_ENABLE_SHIFT)); | 921 | write_nic_byte(dev,CMD,cmd | (1<<CMD_RX_ENABLE_SHIFT)); |
1069 | |||
1070 | /* In rtl8139 driver seems that DMA threshold has to be written | ||
1071 | * after enabling RX, so we rewrite RX_CONFIG register | ||
1072 | */ | ||
1073 | //mdelay(100); | ||
1074 | // write_nic_dword(dev, RX_CONF, rxconf); | ||
1075 | |||
1076 | } | 922 | } |
1077 | 923 | ||
1078 | |||
1079 | void set_nic_txring(struct net_device *dev) | 924 | void set_nic_txring(struct net_device *dev) |
1080 | { | 925 | { |
1081 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 926 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
1082 | // DMESG("ring %x %x", priv->txlpringdma,read_nic_dword(dev,TLPDA)); | ||
1083 | 927 | ||
1084 | write_nic_dword(dev, TX_MANAGEPRIORITY_RING_ADDR, priv->txmapringdma); | 928 | write_nic_dword(dev, TX_MANAGEPRIORITY_RING_ADDR, priv->txmapringdma); |
1085 | // DMESG("ring %x %x", priv->txlpringdma,read_nic_dword(dev,TLPDA)); | ||
1086 | write_nic_dword(dev, TX_BKPRIORITY_RING_ADDR, priv->txbkpringdma); | 929 | write_nic_dword(dev, TX_BKPRIORITY_RING_ADDR, priv->txbkpringdma); |
1087 | // DMESG("ring %x %x", priv->txlpringdma,read_nic_dword(dev,TLPDA)); | ||
1088 | write_nic_dword(dev, TX_BEPRIORITY_RING_ADDR, priv->txbepringdma); | 930 | write_nic_dword(dev, TX_BEPRIORITY_RING_ADDR, priv->txbepringdma); |
1089 | // DMESG("ring %x %x", priv->txlpringdma,read_nic_dword(dev,TLPDA)); | ||
1090 | write_nic_dword(dev, TX_VIPRIORITY_RING_ADDR, priv->txvipringdma); | 931 | write_nic_dword(dev, TX_VIPRIORITY_RING_ADDR, priv->txvipringdma); |
1091 | // DMESG("ring %x %x", priv->txlpringdma,read_nic_dword(dev,TLPDA)); | ||
1092 | write_nic_dword(dev, TX_VOPRIORITY_RING_ADDR, priv->txvopringdma); | 932 | write_nic_dword(dev, TX_VOPRIORITY_RING_ADDR, priv->txvopringdma); |
1093 | // DMESG("ring %x %x", priv->txlpringdma,read_nic_dword(dev,TLPDA)); | ||
1094 | write_nic_dword(dev, TX_HIGHPRIORITY_RING_ADDR, priv->txhpringdma); | 933 | write_nic_dword(dev, TX_HIGHPRIORITY_RING_ADDR, priv->txhpringdma); |
1095 | // DMESG("ring %x %x", priv->txlpringdma,read_nic_dword(dev,TLPDA)); | ||
1096 | |||
1097 | write_nic_dword(dev, TX_BEACON_RING_ADDR, priv->txbeaconringdma); | 934 | write_nic_dword(dev, TX_BEACON_RING_ADDR, priv->txbeaconringdma); |
1098 | } | 935 | } |
1099 | 936 | ||
1100 | |||
1101 | void rtl8180_conttx_enable(struct net_device *dev) | 937 | void rtl8180_conttx_enable(struct net_device *dev) |
1102 | { | 938 | { |
1103 | u32 txconf; | 939 | u32 txconf; |
940 | |||
1104 | txconf = read_nic_dword(dev,TX_CONF); | 941 | txconf = read_nic_dword(dev,TX_CONF); |
1105 | txconf = txconf &~ TX_LOOPBACK_MASK; | 942 | txconf = txconf &~ TX_LOOPBACK_MASK; |
1106 | txconf = txconf | (TX_LOOPBACK_CONTINUE <<TX_LOOPBACK_SHIFT); | 943 | txconf = txconf | (TX_LOOPBACK_CONTINUE <<TX_LOOPBACK_SHIFT); |
1107 | write_nic_dword(dev,TX_CONF,txconf); | 944 | write_nic_dword(dev,TX_CONF,txconf); |
1108 | } | 945 | } |
1109 | 946 | ||
1110 | |||
1111 | void rtl8180_conttx_disable(struct net_device *dev) | 947 | void rtl8180_conttx_disable(struct net_device *dev) |
1112 | { | 948 | { |
1113 | u32 txconf; | 949 | u32 txconf; |
950 | |||
1114 | txconf = read_nic_dword(dev,TX_CONF); | 951 | txconf = read_nic_dword(dev,TX_CONF); |
1115 | txconf = txconf &~ TX_LOOPBACK_MASK; | 952 | txconf = txconf &~ TX_LOOPBACK_MASK; |
1116 | txconf = txconf | (TX_LOOPBACK_NONE <<TX_LOOPBACK_SHIFT); | 953 | txconf = txconf | (TX_LOOPBACK_NONE <<TX_LOOPBACK_SHIFT); |
1117 | write_nic_dword(dev,TX_CONF,txconf); | 954 | write_nic_dword(dev,TX_CONF,txconf); |
1118 | } | 955 | } |
1119 | 956 | ||
1120 | |||
1121 | void rtl8180_tx_enable(struct net_device *dev) | 957 | void rtl8180_tx_enable(struct net_device *dev) |
1122 | { | 958 | { |
1123 | u8 cmd; | 959 | u8 cmd; |
@@ -1125,12 +961,10 @@ void rtl8180_tx_enable(struct net_device *dev) | |||
1125 | u8 byte; | 961 | u8 byte; |
1126 | u32 txconf; | 962 | u32 txconf; |
1127 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 963 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
1128 | txconf= read_nic_dword(dev,TX_CONF); | ||
1129 | |||
1130 | |||
1131 | if(priv->card_8185){ | ||
1132 | 964 | ||
965 | txconf = read_nic_dword(dev, TX_CONF); | ||
1133 | 966 | ||
967 | if (priv->card_8185) { | ||
1134 | byte = read_nic_byte(dev,CW_CONF); | 968 | byte = read_nic_byte(dev,CW_CONF); |
1135 | byte &= ~(1<<CW_CONF_PERPACKET_CW_SHIFT); | 969 | byte &= ~(1<<CW_CONF_PERPACKET_CW_SHIFT); |
1136 | byte &= ~(1<<CW_CONF_PERPACKET_RETRY_SHIFT); | 970 | byte &= ~(1<<CW_CONF_PERPACKET_RETRY_SHIFT); |
@@ -1141,26 +975,12 @@ void rtl8180_tx_enable(struct net_device *dev) | |||
1141 | tx_agc_ctl &= ~(1<<TX_AGC_CTL_PERPACKET_ANTSEL_SHIFT); | 975 | tx_agc_ctl &= ~(1<<TX_AGC_CTL_PERPACKET_ANTSEL_SHIFT); |
1142 | tx_agc_ctl |=(1<<TX_AGC_CTL_FEEDBACK_ANT); | 976 | tx_agc_ctl |=(1<<TX_AGC_CTL_FEEDBACK_ANT); |
1143 | write_nic_byte(dev, TX_AGC_CTL, tx_agc_ctl); | 977 | write_nic_byte(dev, TX_AGC_CTL, tx_agc_ctl); |
1144 | /* | ||
1145 | write_nic_word(dev, 0x5e, 0x01); | ||
1146 | force_pci_posting(dev); | ||
1147 | mdelay(1); | ||
1148 | write_nic_word(dev, 0xfe, 0x10); | ||
1149 | force_pci_posting(dev); | ||
1150 | mdelay(1); | ||
1151 | write_nic_word(dev, 0x5e, 0x00); | ||
1152 | force_pci_posting(dev); | ||
1153 | mdelay(1); | ||
1154 | */ | ||
1155 | write_nic_byte(dev, 0xec, 0x3f); /* Disable early TX */ | 978 | write_nic_byte(dev, 0xec, 0x3f); /* Disable early TX */ |
1156 | } | 979 | } |
1157 | 980 | ||
1158 | if(priv->card_8185){ | 981 | if (priv->card_8185) |
1159 | |||
1160 | txconf = txconf &~ (1<<TCR_PROBE_NOTIMESTAMP_SHIFT); | 982 | txconf = txconf &~ (1<<TCR_PROBE_NOTIMESTAMP_SHIFT); |
1161 | 983 | else { | |
1162 | }else{ | ||
1163 | |||
1164 | if(hwseqnum) | 984 | if(hwseqnum) |
1165 | txconf= txconf &~ (1<<TX_CONF_HEADER_AUTOICREMENT_SHIFT); | 985 | txconf= txconf &~ (1<<TX_CONF_HEADER_AUTOICREMENT_SHIFT); |
1166 | else | 986 | else |
@@ -1175,43 +995,31 @@ void rtl8180_tx_enable(struct net_device *dev) | |||
1175 | txconf = txconf | (priv->retry_rts<<TX_RTSRETRY_SHIFT); | 995 | txconf = txconf | (priv->retry_rts<<TX_RTSRETRY_SHIFT); |
1176 | txconf = txconf &~ (1<<TX_NOCRC_SHIFT); | 996 | txconf = txconf &~ (1<<TX_NOCRC_SHIFT); |
1177 | 997 | ||
1178 | if(priv->card_8185){ | 998 | if (priv->card_8185) { |
1179 | if(priv->hw_plcp_len) | 999 | if (priv->hw_plcp_len) |
1180 | txconf = txconf &~ TCR_PLCP_LEN; | 1000 | txconf = txconf &~ TCR_PLCP_LEN; |
1181 | else | 1001 | else |
1182 | txconf = txconf | TCR_PLCP_LEN; | 1002 | txconf = txconf | TCR_PLCP_LEN; |
1183 | }else{ | 1003 | } else |
1184 | txconf = txconf &~ TCR_SAT; | 1004 | txconf = txconf &~ TCR_SAT; |
1185 | } | 1005 | |
1186 | txconf = txconf &~ TCR_MXDMA_MASK; | 1006 | txconf = txconf &~ TCR_MXDMA_MASK; |
1187 | txconf = txconf | (TCR_MXDMA_2048<<TCR_MXDMA_SHIFT); | 1007 | txconf = txconf | (TCR_MXDMA_2048<<TCR_MXDMA_SHIFT); |
1188 | txconf = txconf | TCR_CWMIN; | 1008 | txconf = txconf | TCR_CWMIN; |
1189 | txconf = txconf | TCR_DISCW; | 1009 | txconf = txconf | TCR_DISCW; |
1190 | 1010 | ||
1191 | // if(priv->ieee80211->hw_wep) | 1011 | txconf = txconf | (1 << TX_NOICV_SHIFT); |
1192 | // txconf=txconf &~ (1<<TX_NOICV_SHIFT); | ||
1193 | // else | ||
1194 | txconf=txconf | (1<<TX_NOICV_SHIFT); | ||
1195 | 1012 | ||
1196 | write_nic_dword(dev,TX_CONF,txconf); | 1013 | write_nic_dword(dev,TX_CONF,txconf); |
1197 | 1014 | ||
1198 | |||
1199 | fix_tx_fifo(dev); | 1015 | fix_tx_fifo(dev); |
1200 | 1016 | ||
1201 | cmd=read_nic_byte(dev,CMD); | 1017 | cmd=read_nic_byte(dev,CMD); |
1202 | write_nic_byte(dev,CMD,cmd | (1<<CMD_TX_ENABLE_SHIFT)); | 1018 | write_nic_byte(dev,CMD,cmd | (1<<CMD_TX_ENABLE_SHIFT)); |
1203 | 1019 | ||
1204 | // mdelay(100); | ||
1205 | write_nic_dword(dev,TX_CONF,txconf); | 1020 | write_nic_dword(dev,TX_CONF,txconf); |
1206 | // #endif | ||
1207 | /* | ||
1208 | rtl8180_set_mode(dev,EPROM_CMD_CONFIG); | ||
1209 | write_nic_byte(dev, TX_DMA_POLLING, priv->dma_poll_mask); | ||
1210 | rtl8180_set_mode(dev,EPROM_CMD_NORMAL); | ||
1211 | */ | ||
1212 | } | 1021 | } |
1213 | 1022 | ||
1214 | |||
1215 | void rtl8180_beacon_tx_enable(struct net_device *dev) | 1023 | void rtl8180_beacon_tx_enable(struct net_device *dev) |
1216 | { | 1024 | { |
1217 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 1025 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
@@ -1222,7 +1030,6 @@ void rtl8180_beacon_tx_enable(struct net_device *dev) | |||
1222 | rtl8180_set_mode(dev,EPROM_CMD_NORMAL); | 1030 | rtl8180_set_mode(dev,EPROM_CMD_NORMAL); |
1223 | } | 1031 | } |
1224 | 1032 | ||
1225 | |||
1226 | void rtl8180_beacon_tx_disable(struct net_device *dev) | 1033 | void rtl8180_beacon_tx_disable(struct net_device *dev) |
1227 | { | 1034 | { |
1228 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 1035 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
@@ -1234,7 +1041,6 @@ void rtl8180_beacon_tx_disable(struct net_device *dev) | |||
1234 | 1041 | ||
1235 | } | 1042 | } |
1236 | 1043 | ||
1237 | |||
1238 | void rtl8180_rtx_disable(struct net_device *dev) | 1044 | void rtl8180_rtx_disable(struct net_device *dev) |
1239 | { | 1045 | { |
1240 | u8 cmd; | 1046 | u8 cmd; |
@@ -1245,9 +1051,6 @@ void rtl8180_rtx_disable(struct net_device *dev) | |||
1245 | ((1<<CMD_RX_ENABLE_SHIFT)|(1<<CMD_TX_ENABLE_SHIFT))); | 1051 | ((1<<CMD_RX_ENABLE_SHIFT)|(1<<CMD_TX_ENABLE_SHIFT))); |
1246 | force_pci_posting(dev); | 1052 | force_pci_posting(dev); |
1247 | mdelay(10); | 1053 | mdelay(10); |
1248 | /*while (read_nic_byte(dev,CMD) & (1<<CMD_RX_ENABLE_SHIFT)) | ||
1249 | udelay(10); | ||
1250 | */ | ||
1251 | 1054 | ||
1252 | if(!priv->rx_skb_complete) | 1055 | if(!priv->rx_skb_complete) |
1253 | dev_kfree_skb_any(priv->rx_skb); | 1056 | dev_kfree_skb_any(priv->rx_skb); |
@@ -1270,20 +1073,22 @@ short alloc_tx_desc_ring(struct net_device *dev, int bufsize, int count, | |||
1270 | } | 1073 | } |
1271 | desc = (u32*)pci_alloc_consistent(pdev, | 1074 | desc = (u32*)pci_alloc_consistent(pdev, |
1272 | sizeof(u32)*8*count+256, &dma_desc); | 1075 | sizeof(u32)*8*count+256, &dma_desc); |
1273 | if(desc==NULL) return -1; | 1076 | if (desc == NULL) |
1274 | if(dma_desc & 0xff){ | 1077 | return -1; |
1275 | 1078 | ||
1079 | if (dma_desc & 0xff) | ||
1276 | /* | 1080 | /* |
1277 | * descriptor's buffer must be 256 byte aligned | 1081 | * descriptor's buffer must be 256 byte aligned |
1278 | * we shouldn't be here, since we set DMA mask ! | 1082 | * we shouldn't be here, since we set DMA mask ! |
1279 | */ | 1083 | */ |
1280 | WARN(1, "DMA buffer is not aligned\n"); | 1084 | WARN(1, "DMA buffer is not aligned\n"); |
1281 | } | 1085 | |
1282 | tmp=desc; | 1086 | tmp = desc; |
1283 | for (i=0;i<count;i++) | 1087 | |
1284 | { | 1088 | for (i = 0; i < count; i++) { |
1285 | buf = (void*)pci_alloc_consistent(pdev,bufsize,&dma_tmp); | 1089 | buf = (void *)pci_alloc_consistent(pdev, bufsize, &dma_tmp); |
1286 | if (buf == NULL) return -ENOMEM; | 1090 | if (buf == NULL) |
1091 | return -ENOMEM; | ||
1287 | 1092 | ||
1288 | switch(addr) { | 1093 | switch(addr) { |
1289 | case TX_MANAGEPRIORITY_RING_ADDR: | 1094 | case TX_MANAGEPRIORITY_RING_ADDR: |
@@ -1292,7 +1097,6 @@ short alloc_tx_desc_ring(struct net_device *dev, int bufsize, int count, | |||
1292 | return -ENOMEM; | 1097 | return -ENOMEM; |
1293 | } | 1098 | } |
1294 | break; | 1099 | break; |
1295 | |||
1296 | case TX_BKPRIORITY_RING_ADDR: | 1100 | case TX_BKPRIORITY_RING_ADDR: |
1297 | if(-1 == buffer_add(&(priv->txbkpbufs),buf,dma_tmp,NULL)){ | 1101 | if(-1 == buffer_add(&(priv->txbkpbufs),buf,dma_tmp,NULL)){ |
1298 | DMESGE("Unable to allocate mem for buffer LP"); | 1102 | DMESGE("Unable to allocate mem for buffer LP"); |
@@ -1305,7 +1109,6 @@ short alloc_tx_desc_ring(struct net_device *dev, int bufsize, int count, | |||
1305 | return -ENOMEM; | 1109 | return -ENOMEM; |
1306 | } | 1110 | } |
1307 | break; | 1111 | break; |
1308 | |||
1309 | case TX_VIPRIORITY_RING_ADDR: | 1112 | case TX_VIPRIORITY_RING_ADDR: |
1310 | if(-1 == buffer_add(&(priv->txvipbufs),buf,dma_tmp,NULL)){ | 1113 | if(-1 == buffer_add(&(priv->txvipbufs),buf,dma_tmp,NULL)){ |
1311 | DMESGE("Unable to allocate mem for buffer LP"); | 1114 | DMESGE("Unable to allocate mem for buffer LP"); |
@@ -1348,32 +1151,26 @@ short alloc_tx_desc_ring(struct net_device *dev, int bufsize, int count, | |||
1348 | priv->txmapringdma=dma_desc; | 1151 | priv->txmapringdma=dma_desc; |
1349 | priv->txmapring=desc; | 1152 | priv->txmapring=desc; |
1350 | break; | 1153 | break; |
1351 | |||
1352 | case TX_BKPRIORITY_RING_ADDR: | 1154 | case TX_BKPRIORITY_RING_ADDR: |
1353 | priv->txbkpringdma=dma_desc; | 1155 | priv->txbkpringdma=dma_desc; |
1354 | priv->txbkpring=desc; | 1156 | priv->txbkpring=desc; |
1355 | break; | 1157 | break; |
1356 | |||
1357 | case TX_BEPRIORITY_RING_ADDR: | 1158 | case TX_BEPRIORITY_RING_ADDR: |
1358 | priv->txbepringdma=dma_desc; | 1159 | priv->txbepringdma=dma_desc; |
1359 | priv->txbepring=desc; | 1160 | priv->txbepring=desc; |
1360 | break; | 1161 | break; |
1361 | |||
1362 | case TX_VIPRIORITY_RING_ADDR: | 1162 | case TX_VIPRIORITY_RING_ADDR: |
1363 | priv->txvipringdma=dma_desc; | 1163 | priv->txvipringdma=dma_desc; |
1364 | priv->txvipring=desc; | 1164 | priv->txvipring=desc; |
1365 | break; | 1165 | break; |
1366 | |||
1367 | case TX_VOPRIORITY_RING_ADDR: | 1166 | case TX_VOPRIORITY_RING_ADDR: |
1368 | priv->txvopringdma=dma_desc; | 1167 | priv->txvopringdma=dma_desc; |
1369 | priv->txvopring=desc; | 1168 | priv->txvopring=desc; |
1370 | break; | 1169 | break; |
1371 | |||
1372 | case TX_HIGHPRIORITY_RING_ADDR: | 1170 | case TX_HIGHPRIORITY_RING_ADDR: |
1373 | priv->txhpringdma=dma_desc; | 1171 | priv->txhpringdma=dma_desc; |
1374 | priv->txhpring=desc; | 1172 | priv->txhpring=desc; |
1375 | break; | 1173 | break; |
1376 | |||
1377 | case TX_BEACON_RING_ADDR: | 1174 | case TX_BEACON_RING_ADDR: |
1378 | priv->txbeaconringdma=dma_desc; | 1175 | priv->txbeaconringdma=dma_desc; |
1379 | priv->txbeaconring=desc; | 1176 | priv->txbeaconring=desc; |
@@ -1384,10 +1181,8 @@ short alloc_tx_desc_ring(struct net_device *dev, int bufsize, int count, | |||
1384 | return 0; | 1181 | return 0; |
1385 | } | 1182 | } |
1386 | 1183 | ||
1387 | |||
1388 | void free_tx_desc_rings(struct net_device *dev) | 1184 | void free_tx_desc_rings(struct net_device *dev) |
1389 | { | 1185 | { |
1390 | |||
1391 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 1186 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
1392 | struct pci_dev *pdev=priv->pdev; | 1187 | struct pci_dev *pdev=priv->pdev; |
1393 | int count = priv->txringcount; | 1188 | int count = priv->txringcount; |
@@ -1426,7 +1221,6 @@ void free_rx_desc_ring(struct net_device *dev) | |||
1426 | { | 1221 | { |
1427 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 1222 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
1428 | struct pci_dev *pdev = priv->pdev; | 1223 | struct pci_dev *pdev = priv->pdev; |
1429 | |||
1430 | int count = priv->rxringcount; | 1224 | int count = priv->rxringcount; |
1431 | 1225 | ||
1432 | pci_free_consistent(pdev, sizeof(u32)*8*count+256, | 1226 | pci_free_consistent(pdev, sizeof(u32)*8*count+256, |
@@ -1435,7 +1229,6 @@ void free_rx_desc_ring(struct net_device *dev) | |||
1435 | buffer_free(dev,&(priv->rxbuffer),priv->rxbuffersize,0); | 1229 | buffer_free(dev,&(priv->rxbuffer),priv->rxbuffersize,0); |
1436 | } | 1230 | } |
1437 | 1231 | ||
1438 | |||
1439 | short alloc_rx_desc_ring(struct net_device *dev, u16 bufsize, int count) | 1232 | short alloc_rx_desc_ring(struct net_device *dev, u16 bufsize, int count) |
1440 | { | 1233 | { |
1441 | int i; | 1234 | int i; |
@@ -1457,21 +1250,18 @@ short alloc_rx_desc_ring(struct net_device *dev, u16 bufsize, int count) | |||
1457 | desc = (u32*)pci_alloc_consistent(pdev,sizeof(u32)*rx_desc_size*count+256, | 1250 | desc = (u32*)pci_alloc_consistent(pdev,sizeof(u32)*rx_desc_size*count+256, |
1458 | &dma_desc); | 1251 | &dma_desc); |
1459 | 1252 | ||
1460 | if(dma_desc & 0xff){ | 1253 | if (dma_desc & 0xff) |
1461 | |||
1462 | /* | 1254 | /* |
1463 | * descriptor's buffer must be 256 byte aligned | 1255 | * descriptor's buffer must be 256 byte aligned |
1464 | * should never happen since we specify the DMA mask | 1256 | * should never happen since we specify the DMA mask |
1465 | */ | 1257 | */ |
1466 | WARN(1, "DMA buffer is not aligned\n"); | 1258 | WARN(1, "DMA buffer is not aligned\n"); |
1467 | } | ||
1468 | 1259 | ||
1469 | priv->rxring=desc; | 1260 | priv->rxring=desc; |
1470 | priv->rxringdma=dma_desc; | 1261 | priv->rxringdma=dma_desc; |
1471 | tmp=desc; | 1262 | tmp=desc; |
1472 | 1263 | ||
1473 | for (i=0;i<count;i++){ | 1264 | for (i = 0; i < count; i++) { |
1474 | |||
1475 | if ((buf= kmalloc(bufsize * sizeof(u8),GFP_ATOMIC)) == NULL){ | 1265 | if ((buf= kmalloc(bufsize * sizeof(u8),GFP_ATOMIC)) == NULL){ |
1476 | DMESGE("Failed to kmalloc RX buffer"); | 1266 | DMESGE("Failed to kmalloc RX buffer"); |
1477 | return -1; | 1267 | return -1; |
@@ -1480,7 +1270,6 @@ short alloc_rx_desc_ring(struct net_device *dev, u16 bufsize, int count) | |||
1480 | dma_tmp = pci_map_single(pdev,buf,bufsize * sizeof(u8), | 1270 | dma_tmp = pci_map_single(pdev,buf,bufsize * sizeof(u8), |
1481 | PCI_DMA_FROMDEVICE); | 1271 | PCI_DMA_FROMDEVICE); |
1482 | 1272 | ||
1483 | //buf = (void*)pci_alloc_consistent(pdev,bufsize,&dma_tmp); | ||
1484 | if(-1 == buffer_add(&(priv->rxbuffer), buf,dma_tmp, | 1273 | if(-1 == buffer_add(&(priv->rxbuffer), buf,dma_tmp, |
1485 | &(priv->rxbufferhead))){ | 1274 | &(priv->rxbufferhead))){ |
1486 | DMESGE("Unable to allocate mem RX buf"); | 1275 | DMESGE("Unable to allocate mem RX buf"); |
@@ -1505,24 +1294,16 @@ void set_nic_rxring(struct net_device *dev) | |||
1505 | u8 pgreg; | 1294 | u8 pgreg; |
1506 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 1295 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
1507 | 1296 | ||
1508 | //rtl8180_set_mode(dev, EPROM_CMD_CONFIG); | ||
1509 | |||
1510 | pgreg=read_nic_byte(dev, PGSELECT); | 1297 | pgreg=read_nic_byte(dev, PGSELECT); |
1511 | write_nic_byte(dev, PGSELECT, pgreg &~ (1<<PGSELECT_PG_SHIFT)); | 1298 | write_nic_byte(dev, PGSELECT, pgreg &~ (1<<PGSELECT_PG_SHIFT)); |
1512 | 1299 | ||
1513 | //rtl8180_set_mode(dev, EPROM_CMD_NORMAL); | ||
1514 | |||
1515 | write_nic_dword(dev, RXRING_ADDR,priv->rxringdma); | 1300 | write_nic_dword(dev, RXRING_ADDR,priv->rxringdma); |
1516 | } | 1301 | } |
1517 | 1302 | ||
1518 | |||
1519 | void rtl8180_reset(struct net_device *dev) | 1303 | void rtl8180_reset(struct net_device *dev) |
1520 | { | 1304 | { |
1521 | //u32 txconf = 0x80e00707; //FIXME: Make me understandable | ||
1522 | u8 cr; | 1305 | u8 cr; |
1523 | 1306 | ||
1524 | //write_nic_dword(dev,TX_CONF,txconf); | ||
1525 | |||
1526 | rtl8180_irq_disable(dev); | 1307 | rtl8180_irq_disable(dev); |
1527 | 1308 | ||
1528 | cr=read_nic_byte(dev,CMD); | 1309 | cr=read_nic_byte(dev,CMD); |
@@ -1539,83 +1320,80 @@ void rtl8180_reset(struct net_device *dev) | |||
1539 | else | 1320 | else |
1540 | DMESG("Card successfully reset"); | 1321 | DMESG("Card successfully reset"); |
1541 | 1322 | ||
1542 | //#ifndef CONFIG_RTL8185B | ||
1543 | rtl8180_set_mode(dev,EPROM_CMD_LOAD); | 1323 | rtl8180_set_mode(dev,EPROM_CMD_LOAD); |
1544 | force_pci_posting(dev); | 1324 | force_pci_posting(dev); |
1545 | mdelay(200); | 1325 | mdelay(200); |
1546 | //#endif | ||
1547 | } | 1326 | } |
1548 | 1327 | ||
1549 | inline u16 ieeerate2rtlrate(int rate) | 1328 | inline u16 ieeerate2rtlrate(int rate) |
1550 | { | 1329 | { |
1551 | switch(rate){ | 1330 | switch(rate){ |
1552 | case 10: | 1331 | case 10: |
1553 | return 0; | 1332 | return 0; |
1554 | case 20: | 1333 | case 20: |
1555 | return 1; | 1334 | return 1; |
1556 | case 55: | 1335 | case 55: |
1557 | return 2; | 1336 | return 2; |
1558 | case 110: | 1337 | case 110: |
1559 | return 3; | 1338 | return 3; |
1560 | case 60: | 1339 | case 60: |
1561 | return 4; | 1340 | return 4; |
1562 | case 90: | 1341 | case 90: |
1563 | return 5; | 1342 | return 5; |
1564 | case 120: | 1343 | case 120: |
1565 | return 6; | 1344 | return 6; |
1566 | case 180: | 1345 | case 180: |
1567 | return 7; | 1346 | return 7; |
1568 | case 240: | 1347 | case 240: |
1569 | return 8; | 1348 | return 8; |
1570 | case 360: | 1349 | case 360: |
1571 | return 9; | 1350 | return 9; |
1572 | case 480: | 1351 | case 480: |
1573 | return 10; | 1352 | return 10; |
1574 | case 540: | 1353 | case 540: |
1575 | return 11; | 1354 | return 11; |
1576 | default: | 1355 | default: |
1577 | return 3; | 1356 | return 3; |
1578 | |||
1579 | } | 1357 | } |
1580 | } | 1358 | } |
1581 | 1359 | ||
1582 | static u16 rtl_rate[] = {10,20,55,110,60,90,120,180,240,360,480,540,720}; | 1360 | static u16 rtl_rate[] = {10,20,55,110,60,90,120,180,240,360,480,540,720}; |
1361 | |||
1583 | inline u16 rtl8180_rate2rate(short rate) | 1362 | inline u16 rtl8180_rate2rate(short rate) |
1584 | { | 1363 | { |
1585 | if (rate >12) return 10; | 1364 | if (rate > 12) |
1365 | return 10; | ||
1586 | return rtl_rate[rate]; | 1366 | return rtl_rate[rate]; |
1587 | } | 1367 | } |
1368 | |||
1588 | inline u8 rtl8180_IsWirelessBMode(u16 rate) | 1369 | inline u8 rtl8180_IsWirelessBMode(u16 rate) |
1589 | { | 1370 | { |
1590 | if( ((rate <= 110) && (rate != 60) && (rate != 90)) || (rate == 220) ) | 1371 | if( ((rate <= 110) && (rate != 60) && (rate != 90)) || (rate == 220) ) |
1591 | return 1; | 1372 | return 1; |
1592 | else return 0; | 1373 | else |
1374 | return 0; | ||
1593 | } | 1375 | } |
1376 | |||
1594 | u16 N_DBPSOfRate(u16 DataRate); | 1377 | u16 N_DBPSOfRate(u16 DataRate); |
1595 | u16 ComputeTxTime( | 1378 | |
1596 | u16 FrameLength, | 1379 | u16 ComputeTxTime(u16 FrameLength, u16 DataRate, u8 bManagementFrame, |
1597 | u16 DataRate, | 1380 | u8 bShortPreamble) |
1598 | u8 bManagementFrame, | ||
1599 | u8 bShortPreamble | ||
1600 | ) | ||
1601 | { | 1381 | { |
1602 | u16 FrameTime; | 1382 | u16 FrameTime; |
1603 | u16 N_DBPS; | 1383 | u16 N_DBPS; |
1604 | u16 Ceiling; | 1384 | u16 Ceiling; |
1605 | 1385 | ||
1606 | if( rtl8180_IsWirelessBMode(DataRate) ) | 1386 | if (rtl8180_IsWirelessBMode(DataRate)) { |
1607 | { | 1387 | if (bManagementFrame || !bShortPreamble || DataRate == 10) |
1608 | if( bManagementFrame || !bShortPreamble || DataRate == 10 ) | 1388 | /* long preamble */ |
1609 | { // long preamble | ||
1610 | FrameTime = (u16)(144+48+(FrameLength*8/(DataRate/10))); | 1389 | FrameTime = (u16)(144+48+(FrameLength*8/(DataRate/10))); |
1611 | } | ||
1612 | else | 1390 | else |
1613 | { // Short preamble | 1391 | /* short preamble */ |
1614 | FrameTime = (u16)(72+24+(FrameLength*8/(DataRate/10))); | 1392 | FrameTime = (u16)(72+24+(FrameLength*8/(DataRate/10))); |
1615 | } | 1393 | |
1616 | if( ( FrameLength*8 % (DataRate/10) ) != 0 ) //Get the Ceilling | 1394 | if ((FrameLength*8 % (DataRate/10)) != 0) /* get the ceilling */ |
1617 | FrameTime ++; | 1395 | FrameTime++; |
1618 | } else { //802.11g DSSS-OFDM PLCP length field calculation. | 1396 | } else { /* 802.11g DSSS-OFDM PLCP length field calculation. */ |
1619 | N_DBPS = N_DBPSOfRate(DataRate); | 1397 | N_DBPS = N_DBPSOfRate(DataRate); |
1620 | Ceiling = (16 + 8*FrameLength + 6) / N_DBPS | 1398 | Ceiling = (16 + 8*FrameLength + 6) / N_DBPS |
1621 | + (((16 + 8*FrameLength + 6) % N_DBPS) ? 1 : 0); | 1399 | + (((16 + 8*FrameLength + 6) % N_DBPS) ? 1 : 0); |
@@ -1623,49 +1401,41 @@ u16 ComputeTxTime( | |||
1623 | } | 1401 | } |
1624 | return FrameTime; | 1402 | return FrameTime; |
1625 | } | 1403 | } |
1404 | |||
1626 | u16 N_DBPSOfRate(u16 DataRate) | 1405 | u16 N_DBPSOfRate(u16 DataRate) |
1627 | { | 1406 | { |
1628 | u16 N_DBPS = 24; | 1407 | u16 N_DBPS = 24; |
1629 | 1408 | ||
1630 | switch(DataRate) | 1409 | switch (DataRate) { |
1631 | { | 1410 | case 60: |
1632 | case 60: | 1411 | N_DBPS = 24; |
1633 | N_DBPS = 24; | 1412 | break; |
1634 | break; | 1413 | case 90: |
1635 | 1414 | N_DBPS = 36; | |
1636 | case 90: | 1415 | break; |
1637 | N_DBPS = 36; | 1416 | case 120: |
1638 | break; | 1417 | N_DBPS = 48; |
1639 | 1418 | break; | |
1640 | case 120: | 1419 | case 180: |
1641 | N_DBPS = 48; | 1420 | N_DBPS = 72; |
1642 | break; | 1421 | break; |
1643 | 1422 | case 240: | |
1644 | case 180: | 1423 | N_DBPS = 96; |
1645 | N_DBPS = 72; | 1424 | break; |
1646 | break; | 1425 | case 360: |
1647 | 1426 | N_DBPS = 144; | |
1648 | case 240: | 1427 | break; |
1649 | N_DBPS = 96; | 1428 | case 480: |
1650 | break; | 1429 | N_DBPS = 192; |
1651 | 1430 | break; | |
1652 | case 360: | 1431 | case 540: |
1653 | N_DBPS = 144; | 1432 | N_DBPS = 216; |
1654 | break; | 1433 | break; |
1655 | 1434 | default: | |
1656 | case 480: | 1435 | break; |
1657 | N_DBPS = 192; | 1436 | } |
1658 | break; | ||
1659 | |||
1660 | case 540: | ||
1661 | N_DBPS = 216; | ||
1662 | break; | ||
1663 | |||
1664 | default: | ||
1665 | break; | ||
1666 | } | ||
1667 | 1437 | ||
1668 | return N_DBPS; | 1438 | return N_DBPS; |
1669 | } | 1439 | } |
1670 | 1440 | ||
1671 | //{by amy 080312 | 1441 | //{by amy 080312 |
@@ -1674,76 +1444,46 @@ u16 N_DBPSOfRate(u16 DataRate) | |||
1674 | // For Netgear case, they want good-looking singal strength. | 1444 | // For Netgear case, they want good-looking singal strength. |
1675 | // 2004.12.05, by rcnjko. | 1445 | // 2004.12.05, by rcnjko. |
1676 | // | 1446 | // |
1677 | long | 1447 | long NetgearSignalStrengthTranslate(long LastSS, long CurrSS) |
1678 | NetgearSignalStrengthTranslate( | ||
1679 | long LastSS, | ||
1680 | long CurrSS | ||
1681 | ) | ||
1682 | { | 1448 | { |
1683 | long RetSS; | 1449 | long RetSS; |
1684 | 1450 | ||
1685 | // Step 1. Scale mapping. | 1451 | // Step 1. Scale mapping. |
1686 | if(CurrSS >= 71 && CurrSS <= 100) | 1452 | if (CurrSS >= 71 && CurrSS <= 100) |
1687 | { | ||
1688 | RetSS = 90 + ((CurrSS - 70) / 3); | 1453 | RetSS = 90 + ((CurrSS - 70) / 3); |
1689 | } | 1454 | else if (CurrSS >= 41 && CurrSS <= 70) |
1690 | else if(CurrSS >= 41 && CurrSS <= 70) | ||
1691 | { | ||
1692 | RetSS = 78 + ((CurrSS - 40) / 3); | 1455 | RetSS = 78 + ((CurrSS - 40) / 3); |
1693 | } | 1456 | else if (CurrSS >= 31 && CurrSS <= 40) |
1694 | else if(CurrSS >= 31 && CurrSS <= 40) | ||
1695 | { | ||
1696 | RetSS = 66 + (CurrSS - 30); | 1457 | RetSS = 66 + (CurrSS - 30); |
1697 | } | 1458 | else if (CurrSS >= 21 && CurrSS <= 30) |
1698 | else if(CurrSS >= 21 && CurrSS <= 30) | ||
1699 | { | ||
1700 | RetSS = 54 + (CurrSS - 20); | 1459 | RetSS = 54 + (CurrSS - 20); |
1701 | } | 1460 | else if (CurrSS >= 5 && CurrSS <= 20) |
1702 | else if(CurrSS >= 5 && CurrSS <= 20) | ||
1703 | { | ||
1704 | RetSS = 42 + (((CurrSS - 5) * 2) / 3); | 1461 | RetSS = 42 + (((CurrSS - 5) * 2) / 3); |
1705 | } | 1462 | else if (CurrSS == 4) |
1706 | else if(CurrSS == 4) | ||
1707 | { | ||
1708 | RetSS = 36; | 1463 | RetSS = 36; |
1709 | } | 1464 | else if (CurrSS == 3) |
1710 | else if(CurrSS == 3) | ||
1711 | { | ||
1712 | RetSS = 27; | 1465 | RetSS = 27; |
1713 | } | 1466 | else if (CurrSS == 2) |
1714 | else if(CurrSS == 2) | ||
1715 | { | ||
1716 | RetSS = 18; | 1467 | RetSS = 18; |
1717 | } | 1468 | else if (CurrSS == 1) |
1718 | else if(CurrSS == 1) | ||
1719 | { | ||
1720 | RetSS = 9; | 1469 | RetSS = 9; |
1721 | } | ||
1722 | else | 1470 | else |
1723 | { | ||
1724 | RetSS = CurrSS; | 1471 | RetSS = CurrSS; |
1725 | } | ||
1726 | //RT_TRACE(COMP_DBG, DBG_LOUD, ("##### After Mapping: LastSS: %d, CurrSS: %d, RetSS: %d\n", LastSS, CurrSS, RetSS)); | ||
1727 | 1472 | ||
1728 | // Step 2. Smoothing. | 1473 | // Step 2. Smoothing. |
1729 | if(LastSS > 0) | 1474 | if(LastSS > 0) |
1730 | { | ||
1731 | RetSS = ((LastSS * 5) + (RetSS)+ 5) / 6; | 1475 | RetSS = ((LastSS * 5) + (RetSS)+ 5) / 6; |
1732 | } | ||
1733 | //RT_TRACE(COMP_DBG, DBG_LOUD, ("$$$$$ After Smoothing: LastSS: %d, CurrSS: %d, RetSS: %d\n", LastSS, CurrSS, RetSS)); | ||
1734 | 1476 | ||
1735 | return RetSS; | 1477 | return RetSS; |
1736 | } | 1478 | } |
1479 | |||
1737 | // | 1480 | // |
1738 | // Description: | 1481 | // Description: |
1739 | // Translate 0-100 signal strength index into dBm. | 1482 | // Translate 0-100 signal strength index into dBm. |
1740 | // | 1483 | // |
1741 | long | 1484 | long TranslateToDbm8185(u8 SignalStrengthIndex) |
1742 | TranslateToDbm8185( | ||
1743 | u8 SignalStrengthIndex // 0-100 index. | ||
1744 | ) | ||
1745 | { | 1485 | { |
1746 | long SignalPower; // in dBm. | 1486 | long SignalPower; |
1747 | 1487 | ||
1748 | // Translate to dBm (x=0.5y-95). | 1488 | // Translate to dBm (x=0.5y-95). |
1749 | SignalPower = (long)((SignalStrengthIndex + 1) >> 1); | 1489 | SignalPower = (long)((SignalStrengthIndex + 1) >> 1); |
@@ -1751,6 +1491,7 @@ TranslateToDbm8185( | |||
1751 | 1491 | ||
1752 | return SignalPower; | 1492 | return SignalPower; |
1753 | } | 1493 | } |
1494 | |||
1754 | // | 1495 | // |
1755 | // Description: | 1496 | // Description: |
1756 | // Perform signal smoothing for dynamic mechanism. | 1497 | // Perform signal smoothing for dynamic mechanism. |
@@ -1759,53 +1500,23 @@ TranslateToDbm8185( | |||
1759 | // of correctness. Ported from 8187B. | 1500 | // of correctness. Ported from 8187B. |
1760 | // 2007-02-26, by Bruce. | 1501 | // 2007-02-26, by Bruce. |
1761 | // | 1502 | // |
1762 | void | 1503 | void PerformUndecoratedSignalSmoothing8185(struct r8180_priv *priv, |
1763 | PerformUndecoratedSignalSmoothing8185( | 1504 | bool bCckRate) |
1764 | struct r8180_priv *priv, | ||
1765 | bool bCckRate | ||
1766 | ) | ||
1767 | { | 1505 | { |
1768 | |||
1769 | |||
1770 | // Determin the current packet is CCK rate. | 1506 | // Determin the current packet is CCK rate. |
1771 | priv->bCurCCKPkt = bCckRate; | 1507 | priv->bCurCCKPkt = bCckRate; |
1772 | 1508 | ||
1773 | if(priv->UndecoratedSmoothedSS >= 0) | 1509 | if (priv->UndecoratedSmoothedSS >= 0) |
1774 | { | ||
1775 | priv->UndecoratedSmoothedSS = ( (priv->UndecoratedSmoothedSS * 5) + (priv->SignalStrength * 10) ) / 6; | 1510 | priv->UndecoratedSmoothedSS = ( (priv->UndecoratedSmoothedSS * 5) + (priv->SignalStrength * 10) ) / 6; |
1776 | } | ||
1777 | else | 1511 | else |
1778 | { | ||
1779 | priv->UndecoratedSmoothedSS = priv->SignalStrength * 10; | 1512 | priv->UndecoratedSmoothedSS = priv->SignalStrength * 10; |
1780 | } | ||
1781 | 1513 | ||
1782 | priv->UndercorateSmoothedRxPower = ( (priv->UndercorateSmoothedRxPower * 50) + (priv->RxPower* 11)) / 60; | 1514 | priv->UndercorateSmoothedRxPower = ( (priv->UndercorateSmoothedRxPower * 50) + (priv->RxPower* 11)) / 60; |
1783 | 1515 | ||
1784 | // printk("Sommthing SignalSterngth (%d) => UndecoratedSmoothedSS (%d)\n", priv->SignalStrength, priv->UndecoratedSmoothedSS); | 1516 | if (bCckRate) |
1785 | // printk("Sommthing RxPower (%d) => UndecoratedRxPower (%d)\n", priv->RxPower, priv->UndercorateSmoothedRxPower); | ||
1786 | |||
1787 | //if(priv->CurCCKRSSI >= 0 && bCckRate) | ||
1788 | if(bCckRate) | ||
1789 | { | ||
1790 | priv->CurCCKRSSI = priv->RSSI; | 1517 | priv->CurCCKRSSI = priv->RSSI; |
1791 | } | ||
1792 | else | 1518 | else |
1793 | { | ||
1794 | priv->CurCCKRSSI = 0; | 1519 | priv->CurCCKRSSI = 0; |
1795 | } | ||
1796 | |||
1797 | // Boundary checking. | ||
1798 | // TODO: The overflow condition does happen, if we want to fix, | ||
1799 | // we shall recalculate thresholds first. | ||
1800 | if(priv->UndecoratedSmoothedSS > 100) | ||
1801 | { | ||
1802 | // printk("UndecoratedSmoothedSS(%d) overflow, SignalStrength(%d)\n", priv->UndecoratedSmoothedSS, priv->SignalStrength); | ||
1803 | } | ||
1804 | if(priv->UndecoratedSmoothedSS < 0) | ||
1805 | { | ||
1806 | // printk("UndecoratedSmoothedSS(%d) underflow, SignalStrength(%d)\n", priv->UndecoratedSmoothedSS, priv->SignalStrength); | ||
1807 | } | ||
1808 | |||
1809 | } | 1520 | } |
1810 | 1521 | ||
1811 | //by amy 080312} | 1522 | //by amy 080312} |
@@ -1815,70 +1526,47 @@ void rtl8180_rx(struct net_device *dev) | |||
1815 | { | 1526 | { |
1816 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 1527 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
1817 | struct sk_buff *tmp_skb; | 1528 | struct sk_buff *tmp_skb; |
1818 | |||
1819 | //struct sk_buff *skb; | ||
1820 | short first,last; | 1529 | short first,last; |
1821 | u32 len; | 1530 | u32 len; |
1822 | int lastlen; | 1531 | int lastlen; |
1823 | unsigned char quality, signal; | 1532 | unsigned char quality, signal; |
1824 | u8 rate; | 1533 | u8 rate; |
1825 | //u32 *prism_hdr; | ||
1826 | u32 *tmp,*tmp2; | 1534 | u32 *tmp,*tmp2; |
1827 | u8 rx_desc_size; | 1535 | u8 rx_desc_size; |
1828 | u8 padding; | 1536 | u8 padding; |
1829 | //u32 count=0; | ||
1830 | char rxpower = 0; | 1537 | char rxpower = 0; |
1831 | u32 RXAGC = 0; | 1538 | u32 RXAGC = 0; |
1832 | long RxAGC_dBm = 0; | 1539 | long RxAGC_dBm = 0; |
1833 | u8 LNA=0, BB=0; | 1540 | u8 LNA=0, BB=0; |
1834 | u8 LNA_gain[4]={02, 17, 29, 39}; | 1541 | u8 LNA_gain[4]={02, 17, 29, 39}; |
1835 | u8 Antenna = 0; | 1542 | u8 Antenna = 0; |
1836 | struct ieee80211_hdr *hdr;//by amy | 1543 | struct ieee80211_hdr *hdr; |
1837 | u16 fc,type; | 1544 | u16 fc,type; |
1838 | u8 bHwError = 0,bCRC = 0,bICV = 0; | 1545 | u8 bHwError = 0,bCRC = 0,bICV = 0; |
1839 | //bHwError = 0; | ||
1840 | //bCRC = 0; | ||
1841 | //bICV = 0; | ||
1842 | bool bCckRate = false; | 1546 | bool bCckRate = false; |
1843 | u8 RSSI = 0; | 1547 | u8 RSSI = 0; |
1844 | long SignalStrengthIndex = 0;//+by amy 080312 | 1548 | long SignalStrengthIndex = 0; |
1845 | // u8 SignalStrength = 0; | ||
1846 | struct ieee80211_rx_stats stats = { | 1549 | struct ieee80211_rx_stats stats = { |
1847 | .signal = 0, | 1550 | .signal = 0, |
1848 | .noise = -98, | 1551 | .noise = -98, |
1849 | .rate = 0, | 1552 | .rate = 0, |
1850 | // .mac_time = jiffies, | ||
1851 | .freq = IEEE80211_24GHZ_BAND, | 1553 | .freq = IEEE80211_24GHZ_BAND, |
1852 | }; | 1554 | }; |
1853 | 1555 | ||
1854 | stats.nic_type = NIC_8185B; | 1556 | stats.nic_type = NIC_8185B; |
1855 | rx_desc_size = 8; | 1557 | rx_desc_size = 8; |
1856 | 1558 | ||
1857 | //printk("receive frame!%d\n",count++); | ||
1858 | //if (!priv->rxbuffer) DMESG ("EE: NIC RX ack, but RX queue corrupted!"); | ||
1859 | //else { | ||
1860 | |||
1861 | if ((*(priv->rxringtail)) & (1<<31)) { | 1559 | if ((*(priv->rxringtail)) & (1<<31)) { |
1862 | |||
1863 | /* we have got an RX int, but the descriptor | 1560 | /* we have got an RX int, but the descriptor |
1864 | * we are pointing is empty*/ | 1561 | * we are pointing is empty*/ |
1865 | 1562 | ||
1866 | priv->stats.rxnodata++; | 1563 | priv->stats.rxnodata++; |
1867 | priv->ieee80211->stats.rx_errors++; | 1564 | priv->ieee80211->stats.rx_errors++; |
1868 | 1565 | ||
1869 | /* if (! *(priv->rxring) & (1<<31)) { | ||
1870 | |||
1871 | priv->stats.rxreset++; | ||
1872 | priv->rxringtail=priv->rxring; | ||
1873 | priv->rxbuffer=priv->rxbufferhead; | ||
1874 | |||
1875 | }else{*/ | ||
1876 | |||
1877 | tmp2 = NULL; | 1566 | tmp2 = NULL; |
1878 | tmp = priv->rxringtail; | 1567 | tmp = priv->rxringtail; |
1879 | do{ | 1568 | do{ |
1880 | if(tmp == priv->rxring) | 1569 | if(tmp == priv->rxring) |
1881 | //tmp = priv->rxring + (priv->rxringcount )*rx_desc_size; xiong-2006-11-15 | ||
1882 | tmp = priv->rxring + (priv->rxringcount - 1)*rx_desc_size; | 1570 | tmp = priv->rxring + (priv->rxringcount - 1)*rx_desc_size; |
1883 | else | 1571 | else |
1884 | tmp -= rx_desc_size; | 1572 | tmp -= rx_desc_size; |
@@ -1888,7 +1576,6 @@ void rtl8180_rx(struct net_device *dev) | |||
1888 | }while(tmp != priv->rxring); | 1576 | }while(tmp != priv->rxring); |
1889 | 1577 | ||
1890 | if(tmp2) priv->rxringtail = tmp2; | 1578 | if(tmp2) priv->rxringtail = tmp2; |
1891 | //} | ||
1892 | } | 1579 | } |
1893 | 1580 | ||
1894 | /* while there are filled descriptors */ | 1581 | /* while there are filled descriptors */ |
@@ -1930,7 +1617,6 @@ void rtl8180_rx(struct net_device *dev) | |||
1930 | len=lastlen-priv->rx_prevlen; | 1617 | len=lastlen-priv->rx_prevlen; |
1931 | 1618 | ||
1932 | if(*(priv->rxringtail) & (1<<13)) { | 1619 | if(*(priv->rxringtail) & (1<<13)) { |
1933 | //lastlen=((*priv->rxringtail) &0xfff); | ||
1934 | if ((*(priv->rxringtail) & 0xfff) <500) | 1620 | if ((*(priv->rxringtail) & 0xfff) <500) |
1935 | priv->stats.rxcrcerrmin++; | 1621 | priv->stats.rxcrcerrmin++; |
1936 | else if ((*(priv->rxringtail) & 0x0fff) >1000) | 1622 | else if ((*(priv->rxringtail) & 0x0fff) >1000) |
@@ -1982,9 +1668,7 @@ void rtl8180_rx(struct net_device *dev) | |||
1982 | ((1<<23)|(1<<22)|(1<<21)|(1<<20)))>>20; | 1668 | ((1<<23)|(1<<22)|(1<<21)|(1<<20)))>>20; |
1983 | 1669 | ||
1984 | stats.rate = rtl8180_rate2rate(rate); | 1670 | stats.rate = rtl8180_rate2rate(rate); |
1985 | //DMESG("%d",rate); | ||
1986 | Antenna = (((*(priv->rxringtail +3))& (0x00008000)) == 0 )? 0:1 ; | 1671 | Antenna = (((*(priv->rxringtail +3))& (0x00008000)) == 0 )? 0:1 ; |
1987 | // printk("in rtl8180_rx():Antenna is %d\n",Antenna); | ||
1988 | //by amy for antenna | 1672 | //by amy for antenna |
1989 | if(!rtl8180_IsWirelessBMode(stats.rate)) | 1673 | if(!rtl8180_IsWirelessBMode(stats.rate)) |
1990 | { // OFDM rate. | 1674 | { // OFDM rate. |
@@ -2089,12 +1773,6 @@ void rtl8180_rx(struct net_device *dev) | |||
2089 | } | 1773 | } |
2090 | 1774 | ||
2091 | //by amy for antenna | 1775 | //by amy for antenna |
2092 | |||
2093 | |||
2094 | |||
2095 | |||
2096 | |||
2097 | |||
2098 | #ifndef DUMMY_RX | 1776 | #ifndef DUMMY_RX |
2099 | if(first){ | 1777 | if(first){ |
2100 | if(!priv->rx_skb_complete){ | 1778 | if(!priv->rx_skb_complete){ |
@@ -2164,16 +1842,13 @@ void rtl8180_rx(struct net_device *dev) | |||
2164 | } | 1842 | } |
2165 | 1843 | ||
2166 | #endif //DUMMY_RX | 1844 | #endif //DUMMY_RX |
2167 | |||
2168 | pci_dma_sync_single_for_device(priv->pdev, | 1845 | pci_dma_sync_single_for_device(priv->pdev, |
2169 | priv->rxbuffer->dma, | 1846 | priv->rxbuffer->dma, |
2170 | priv->rxbuffersize * \ | 1847 | priv->rxbuffersize * \ |
2171 | sizeof(u8), | 1848 | sizeof(u8), |
2172 | PCI_DMA_FROMDEVICE); | 1849 | PCI_DMA_FROMDEVICE); |
2173 | 1850 | ||
2174 | |||
2175 | drop: // this is used when we have not enought mem | 1851 | drop: // this is used when we have not enought mem |
2176 | |||
2177 | /* restore the descriptor */ | 1852 | /* restore the descriptor */ |
2178 | *(priv->rxringtail+2)=priv->rxbuffer->dma; | 1853 | *(priv->rxringtail+2)=priv->rxbuffer->dma; |
2179 | *(priv->rxringtail)=*(priv->rxringtail) &~ 0xfff; | 1854 | *(priv->rxringtail)=*(priv->rxringtail) &~ 0xfff; |
@@ -2182,32 +1857,14 @@ drop: // this is used when we have not enought mem | |||
2182 | 1857 | ||
2183 | *(priv->rxringtail)= | 1858 | *(priv->rxringtail)= |
2184 | *(priv->rxringtail) | (1<<31); | 1859 | *(priv->rxringtail) | (1<<31); |
2185 | //^empty descriptor | ||
2186 | |||
2187 | //wmb(); | ||
2188 | |||
2189 | //unsigned long flags; | ||
2190 | //spin_lock_irqsave(&priv->irq_lock,flags); | ||
2191 | 1860 | ||
2192 | priv->rxringtail+=rx_desc_size; | 1861 | priv->rxringtail+=rx_desc_size; |
2193 | if(priv->rxringtail >= | 1862 | if(priv->rxringtail >= |
2194 | (priv->rxring)+(priv->rxringcount )*rx_desc_size) | 1863 | (priv->rxring)+(priv->rxringcount )*rx_desc_size) |
2195 | priv->rxringtail=priv->rxring; | 1864 | priv->rxringtail=priv->rxring; |
2196 | 1865 | ||
2197 | //spin_unlock_irqrestore(&priv->irq_lock,flags); | ||
2198 | |||
2199 | |||
2200 | priv->rxbuffer=(priv->rxbuffer->next); | 1866 | priv->rxbuffer=(priv->rxbuffer->next); |
2201 | |||
2202 | } | 1867 | } |
2203 | |||
2204 | |||
2205 | |||
2206 | // if(get_curr_tx_free_desc(dev,priority)) | ||
2207 | // ieee80211_sta_ps_sleep(priv->ieee80211, &tmp, &tmp2); | ||
2208 | |||
2209 | |||
2210 | |||
2211 | } | 1868 | } |
2212 | 1869 | ||
2213 | 1870 | ||
@@ -2216,33 +1873,6 @@ void rtl8180_dma_kick(struct net_device *dev, int priority) | |||
2216 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 1873 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
2217 | 1874 | ||
2218 | rtl8180_set_mode(dev,EPROM_CMD_CONFIG); | 1875 | rtl8180_set_mode(dev,EPROM_CMD_CONFIG); |
2219 | /* | ||
2220 | |||
2221 | switch(priority){ | ||
2222 | |||
2223 | case LOW_PRIORITY: | ||
2224 | |||
2225 | write_nic_byte(dev,TX_DMA_POLLING, | ||
2226 | (1<< TX_DMA_POLLING_LOWPRIORITY_SHIFT) | | ||
2227 | priv->dma_poll_mask); | ||
2228 | break; | ||
2229 | |||
2230 | case NORM_PRIORITY: | ||
2231 | |||
2232 | write_nic_byte(dev,TX_DMA_POLLING, | ||
2233 | (1<< TX_DMA_POLLING_NORMPRIORITY_SHIFT) | | ||
2234 | priv->dma_poll_mask); | ||
2235 | break; | ||
2236 | |||
2237 | case HI_PRIORITY: | ||
2238 | |||
2239 | write_nic_byte(dev,TX_DMA_POLLING, | ||
2240 | (1<< TX_DMA_POLLING_HIPRIORITY_SHIFT) | | ||
2241 | priv->dma_poll_mask); | ||
2242 | break; | ||
2243 | |||
2244 | } | ||
2245 | */ | ||
2246 | write_nic_byte(dev, TX_DMA_POLLING, | 1876 | write_nic_byte(dev, TX_DMA_POLLING, |
2247 | (1 << (priority + 1)) | priv->dma_poll_mask); | 1877 | (1 << (priority + 1)) | priv->dma_poll_mask); |
2248 | rtl8180_set_mode(dev,EPROM_CMD_NORMAL); | 1878 | rtl8180_set_mode(dev,EPROM_CMD_NORMAL); |
@@ -2260,7 +1890,6 @@ void rtl8180_data_hard_stop(struct net_device *dev) | |||
2260 | rtl8180_set_mode(dev,EPROM_CMD_NORMAL); | 1890 | rtl8180_set_mode(dev,EPROM_CMD_NORMAL); |
2261 | } | 1891 | } |
2262 | 1892 | ||
2263 | |||
2264 | void rtl8180_data_hard_resume(struct net_device *dev) | 1893 | void rtl8180_data_hard_resume(struct net_device *dev) |
2265 | { | 1894 | { |
2266 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 1895 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
@@ -2271,7 +1900,6 @@ void rtl8180_data_hard_resume(struct net_device *dev) | |||
2271 | rtl8180_set_mode(dev,EPROM_CMD_NORMAL); | 1900 | rtl8180_set_mode(dev,EPROM_CMD_NORMAL); |
2272 | } | 1901 | } |
2273 | 1902 | ||
2274 | |||
2275 | /* this function TX data frames when the ieee80211 stack requires this. | 1903 | /* this function TX data frames when the ieee80211 stack requires this. |
2276 | * It checks also if we need to stop the ieee tx queue, eventually do it | 1904 | * It checks also if we need to stop the ieee tx queue, eventually do it |
2277 | */ | 1905 | */ |
@@ -2284,7 +1912,6 @@ rate) | |||
2284 | short morefrag = (h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS; | 1912 | short morefrag = (h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS; |
2285 | unsigned long flags; | 1913 | unsigned long flags; |
2286 | int priority; | 1914 | int priority; |
2287 | //static int count = 0; | ||
2288 | 1915 | ||
2289 | mode = priv->ieee80211->iw_mode; | 1916 | mode = priv->ieee80211->iw_mode; |
2290 | 1917 | ||
@@ -2306,22 +1933,16 @@ rate) | |||
2306 | return; | 1933 | return; |
2307 | } | 1934 | } |
2308 | 1935 | ||
2309 | //printk(KERN_WARNING "priority = %d@%d\n", priority, count++); | ||
2310 | if (!check_nic_enought_desc(dev, priority)){ | 1936 | if (!check_nic_enought_desc(dev, priority)){ |
2311 | //DMESG("Error: no descriptor left by previous TX (avail %d) ", | ||
2312 | // get_curr_tx_free_desc(dev, priority)); | ||
2313 | DMESGW("Error: no descriptor left by previous TX (avail %d) ", | 1937 | DMESGW("Error: no descriptor left by previous TX (avail %d) ", |
2314 | get_curr_tx_free_desc(dev, priority)); | 1938 | get_curr_tx_free_desc(dev, priority)); |
2315 | //printk(KERN_WARNING "==============================================================> \n"); | ||
2316 | ieee80211_stop_queue(priv->ieee80211); | 1939 | ieee80211_stop_queue(priv->ieee80211); |
2317 | } | 1940 | } |
2318 | rtl8180_tx(dev, skb->data, skb->len, priority, morefrag,0,rate); | 1941 | rtl8180_tx(dev, skb->data, skb->len, priority, morefrag,0,rate); |
2319 | if (!check_nic_enought_desc(dev, priority)) | 1942 | if (!check_nic_enought_desc(dev, priority)) |
2320 | ieee80211_stop_queue(priv->ieee80211); | 1943 | ieee80211_stop_queue(priv->ieee80211); |
2321 | 1944 | ||
2322 | //dev_kfree_skb_any(skb); | ||
2323 | spin_unlock_irqrestore(&priv->tx_lock,flags); | 1945 | spin_unlock_irqrestore(&priv->tx_lock,flags); |
2324 | |||
2325 | } | 1946 | } |
2326 | 1947 | ||
2327 | /* This is a rough attempt to TX a frame | 1948 | /* This is a rough attempt to TX a frame |
@@ -2338,19 +1959,15 @@ rate) | |||
2338 | int rtl8180_hard_start_xmit(struct sk_buff *skb,struct net_device *dev) | 1959 | int rtl8180_hard_start_xmit(struct sk_buff *skb,struct net_device *dev) |
2339 | { | 1960 | { |
2340 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 1961 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
2341 | |||
2342 | unsigned long flags; | 1962 | unsigned long flags; |
2343 | |||
2344 | int priority; | 1963 | int priority; |
2345 | 1964 | ||
2346 | priority = MANAGE_PRIORITY; | 1965 | priority = MANAGE_PRIORITY; |
2347 | 1966 | ||
2348 | spin_lock_irqsave(&priv->tx_lock,flags); | 1967 | spin_lock_irqsave(&priv->tx_lock,flags); |
2349 | 1968 | ||
2350 | if(priv->ieee80211->bHwRadioOff) | 1969 | if (priv->ieee80211->bHwRadioOff) { |
2351 | { | ||
2352 | spin_unlock_irqrestore(&priv->tx_lock,flags); | 1970 | spin_unlock_irqrestore(&priv->tx_lock,flags); |
2353 | |||
2354 | dev_kfree_skb_any(skb); | 1971 | dev_kfree_skb_any(skb); |
2355 | return NETDEV_TX_OK; | 1972 | return NETDEV_TX_OK; |
2356 | } | 1973 | } |
@@ -2381,7 +1998,6 @@ u16 rtl8180_len2duration(u32 len, short rate,short* ext) | |||
2381 | if(drift ==0 ) break; | 1998 | if(drift ==0 ) break; |
2382 | duration++; | 1999 | duration++; |
2383 | break; | 2000 | break; |
2384 | |||
2385 | case 1://2mbps | 2001 | case 1://2mbps |
2386 | *ext=0; | 2002 | *ext=0; |
2387 | duration = ((len+4)<<4) /0x4; | 2003 | duration = ((len+4)<<4) /0x4; |
@@ -2389,7 +2005,6 @@ u16 rtl8180_len2duration(u32 len, short rate,short* ext) | |||
2389 | if(drift ==0 ) break; | 2005 | if(drift ==0 ) break; |
2390 | duration++; | 2006 | duration++; |
2391 | break; | 2007 | break; |
2392 | |||
2393 | case 2: //5.5mbps | 2008 | case 2: //5.5mbps |
2394 | *ext=0; | 2009 | *ext=0; |
2395 | duration = ((len+4)<<4) /0xb; | 2010 | duration = ((len+4)<<4) /0xb; |
@@ -2398,7 +2013,6 @@ u16 rtl8180_len2duration(u32 len, short rate,short* ext) | |||
2398 | break; | 2013 | break; |
2399 | duration++; | 2014 | duration++; |
2400 | break; | 2015 | break; |
2401 | |||
2402 | default: | 2016 | default: |
2403 | case 3://11mbps | 2017 | case 3://11mbps |
2404 | *ext=0; | 2018 | *ext=0; |
@@ -2416,12 +2030,9 @@ u16 rtl8180_len2duration(u32 len, short rate,short* ext) | |||
2416 | return duration; | 2030 | return duration; |
2417 | } | 2031 | } |
2418 | 2032 | ||
2419 | |||
2420 | void rtl8180_prepare_beacon(struct net_device *dev) | 2033 | void rtl8180_prepare_beacon(struct net_device *dev) |
2421 | { | 2034 | { |
2422 | |||
2423 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 2035 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
2424 | |||
2425 | struct sk_buff *skb; | 2036 | struct sk_buff *skb; |
2426 | 2037 | ||
2427 | u16 word = read_nic_word(dev, BcnItv); | 2038 | u16 word = read_nic_word(dev, BcnItv); |
@@ -2429,7 +2040,6 @@ void rtl8180_prepare_beacon(struct net_device *dev) | |||
2429 | word |= cpu_to_le16(priv->ieee80211->current_network.beacon_interval);//0x64; | 2040 | word |= cpu_to_le16(priv->ieee80211->current_network.beacon_interval);//0x64; |
2430 | write_nic_word(dev, BcnItv, word); | 2041 | write_nic_word(dev, BcnItv, word); |
2431 | 2042 | ||
2432 | |||
2433 | skb = ieee80211_get_beacon(priv->ieee80211); | 2043 | skb = ieee80211_get_beacon(priv->ieee80211); |
2434 | if(skb){ | 2044 | if(skb){ |
2435 | rtl8180_tx(dev,skb->data,skb->len,BEACON_PRIORITY, | 2045 | rtl8180_tx(dev,skb->data,skb->len,BEACON_PRIORITY, |
@@ -2453,19 +2063,14 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority, | |||
2453 | int remain; | 2063 | int remain; |
2454 | int buflen; | 2064 | int buflen; |
2455 | int count; | 2065 | int count; |
2456 | //u16 AckCtsTime; | ||
2457 | //u16 FrameTime; | ||
2458 | u16 duration; | 2066 | u16 duration; |
2459 | short ext; | 2067 | short ext; |
2460 | struct buffer* buflist; | 2068 | struct buffer* buflist; |
2461 | //unsigned long flags; | ||
2462 | struct ieee80211_hdr_3addr *frag_hdr = (struct ieee80211_hdr_3addr *)txbuf; | 2069 | struct ieee80211_hdr_3addr *frag_hdr = (struct ieee80211_hdr_3addr *)txbuf; |
2463 | u8 dest[ETH_ALEN]; | 2070 | u8 dest[ETH_ALEN]; |
2464 | u8 bUseShortPreamble = 0; | 2071 | u8 bUseShortPreamble = 0; |
2465 | u8 bCTSEnable = 0; | 2072 | u8 bCTSEnable = 0; |
2466 | u8 bRTSEnable = 0; | 2073 | u8 bRTSEnable = 0; |
2467 | //u16 RTSRate = 22; | ||
2468 | //u8 RetryLimit = 0; | ||
2469 | u16 Duration = 0; | 2074 | u16 Duration = 0; |
2470 | u16 RtsDur = 0; | 2075 | u16 RtsDur = 0; |
2471 | u16 ThisFrameTime = 0; | 2076 | u16 ThisFrameTime = 0; |
@@ -2479,56 +2084,47 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority, | |||
2479 | buflist = priv->txmapbufstail; | 2084 | buflist = priv->txmapbufstail; |
2480 | count = priv->txringcount; | 2085 | count = priv->txringcount; |
2481 | break; | 2086 | break; |
2482 | |||
2483 | case BK_PRIORITY: | 2087 | case BK_PRIORITY: |
2484 | tail=priv->txbkpringtail; | 2088 | tail=priv->txbkpringtail; |
2485 | begin=priv->txbkpring; | 2089 | begin=priv->txbkpring; |
2486 | buflist = priv->txbkpbufstail; | 2090 | buflist = priv->txbkpbufstail; |
2487 | count = priv->txringcount; | 2091 | count = priv->txringcount; |
2488 | break; | 2092 | break; |
2489 | |||
2490 | case BE_PRIORITY: | 2093 | case BE_PRIORITY: |
2491 | tail=priv->txbepringtail; | 2094 | tail=priv->txbepringtail; |
2492 | begin=priv->txbepring; | 2095 | begin=priv->txbepring; |
2493 | buflist = priv->txbepbufstail; | 2096 | buflist = priv->txbepbufstail; |
2494 | count = priv->txringcount; | 2097 | count = priv->txringcount; |
2495 | break; | 2098 | break; |
2496 | |||
2497 | case VI_PRIORITY: | 2099 | case VI_PRIORITY: |
2498 | tail=priv->txvipringtail; | 2100 | tail=priv->txvipringtail; |
2499 | begin=priv->txvipring; | 2101 | begin=priv->txvipring; |
2500 | buflist = priv->txvipbufstail; | 2102 | buflist = priv->txvipbufstail; |
2501 | count = priv->txringcount; | 2103 | count = priv->txringcount; |
2502 | break; | 2104 | break; |
2503 | |||
2504 | case VO_PRIORITY: | 2105 | case VO_PRIORITY: |
2505 | tail=priv->txvopringtail; | 2106 | tail=priv->txvopringtail; |
2506 | begin=priv->txvopring; | 2107 | begin=priv->txvopring; |
2507 | buflist = priv->txvopbufstail; | 2108 | buflist = priv->txvopbufstail; |
2508 | count = priv->txringcount; | 2109 | count = priv->txringcount; |
2509 | break; | 2110 | break; |
2510 | |||
2511 | case HI_PRIORITY: | 2111 | case HI_PRIORITY: |
2512 | tail=priv->txhpringtail; | 2112 | tail=priv->txhpringtail; |
2513 | begin=priv->txhpring; | 2113 | begin=priv->txhpring; |
2514 | buflist = priv->txhpbufstail; | 2114 | buflist = priv->txhpbufstail; |
2515 | count = priv->txringcount; | 2115 | count = priv->txringcount; |
2516 | break; | 2116 | break; |
2517 | |||
2518 | case BEACON_PRIORITY: | 2117 | case BEACON_PRIORITY: |
2519 | tail=priv->txbeaconringtail; | 2118 | tail=priv->txbeaconringtail; |
2520 | begin=priv->txbeaconring; | 2119 | begin=priv->txbeaconring; |
2521 | buflist = priv->txbeaconbufstail; | 2120 | buflist = priv->txbeaconbufstail; |
2522 | count = priv->txbeaconcount; | 2121 | count = priv->txbeaconcount; |
2523 | break; | 2122 | break; |
2524 | |||
2525 | default: | 2123 | default: |
2526 | return -1; | 2124 | return -1; |
2527 | break; | 2125 | break; |
2528 | } | 2126 | } |
2529 | 2127 | ||
2530 | //printk("in rtl8180_tx(): rate is %d\n",priv->ieee80211->rate); | ||
2531 | #if 1 | ||
2532 | memcpy(&dest, frag_hdr->addr1, ETH_ALEN); | 2128 | memcpy(&dest, frag_hdr->addr1, ETH_ALEN); |
2533 | if (is_multicast_ether_addr(dest) || | 2129 | if (is_multicast_ether_addr(dest) || |
2534 | is_broadcast_ether_addr(dest)) | 2130 | is_broadcast_ether_addr(dest)) |
@@ -2541,20 +2137,13 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority, | |||
2541 | ThisFrameTime = ComputeTxTime(len + sCrcLng, rtl8180_rate2rate(rate), 0, bUseShortPreamble); | 2137 | ThisFrameTime = ComputeTxTime(len + sCrcLng, rtl8180_rate2rate(rate), 0, bUseShortPreamble); |
2542 | TxDescDuration = ThisFrameTime; | 2138 | TxDescDuration = ThisFrameTime; |
2543 | } else {// Unicast packet | 2139 | } else {// Unicast packet |
2544 | //u8 AckRate; | ||
2545 | u16 AckTime; | 2140 | u16 AckTime; |
2546 | 2141 | ||
2547 | //YJ,add,080828,for Keep alive | 2142 | //YJ,add,080828,for Keep alive |
2548 | priv->NumTxUnicast++; | 2143 | priv->NumTxUnicast++; |
2549 | 2144 | ||
2550 | // Figure out ACK rate according to BSS basic rate and Tx rate, 2006.03.08 by rcnjko. | 2145 | // Figure out ACK rate according to BSS basic rate and Tx rate, 2006.03.08 by rcnjko. |
2551 | //AckRate = ComputeAckRate( pMgntInfo->mBrates, (u1Byte)(pTcb->DataRate) ); | ||
2552 | // Figure out ACK time according to the AckRate and assume long preamble is used on receiver, 2006.03.08, by rcnjko. | ||
2553 | //AckTime = ComputeTxTime( sAckCtsLng/8, AckRate, FALSE, FALSE); | ||
2554 | //For simplicity, just use the 1M basic rate | ||
2555 | //AckTime = ComputeTxTime(14, 540,0, 0); // AckCTSLng = 14 use 1M bps send | ||
2556 | AckTime = ComputeTxTime(14, 10,0, 0); // AckCTSLng = 14 use 1M bps send | 2146 | AckTime = ComputeTxTime(14, 10,0, 0); // AckCTSLng = 14 use 1M bps send |
2557 | //AckTime = ComputeTxTime(14, 2,false, false); // AckCTSLng = 14 use 1M bps send | ||
2558 | 2147 | ||
2559 | if ( ((len + sCrcLng) > priv->rts) && priv->rts ) | 2148 | if ( ((len + sCrcLng) > priv->rts) && priv->rts ) |
2560 | { // RTS/CTS. | 2149 | { // RTS/CTS. |
@@ -2605,30 +2194,24 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority, | |||
2605 | } // End of Unicast packet | 2194 | } // End of Unicast packet |
2606 | 2195 | ||
2607 | frag_hdr->duration_id = Duration; | 2196 | frag_hdr->duration_id = Duration; |
2608 | #endif | ||
2609 | 2197 | ||
2610 | buflen=priv->txbuffsize; | 2198 | buflen=priv->txbuffsize; |
2611 | remain=len; | 2199 | remain=len; |
2612 | temp_tail = tail; | 2200 | temp_tail = tail; |
2613 | //printk("================================>buflen = %d, remain = %d!\n", buflen,remain); | 2201 | |
2614 | while(remain!=0){ | 2202 | while(remain!=0){ |
2615 | mb(); | 2203 | mb(); |
2616 | if(!buflist){ | 2204 | if(!buflist){ |
2617 | DMESGE("TX buffer error, cannot TX frames. pri %d.", priority); | 2205 | DMESGE("TX buffer error, cannot TX frames. pri %d.", priority); |
2618 | //spin_unlock_irqrestore(&priv->tx_lock,flags); | ||
2619 | return -1; | 2206 | return -1; |
2620 | } | 2207 | } |
2621 | buf=buflist->buf; | 2208 | buf=buflist->buf; |
2622 | 2209 | ||
2623 | if( (*tail & (1<<31)) && (priority != BEACON_PRIORITY)){ | 2210 | if ((*tail & (1 << 31)) && (priority != BEACON_PRIORITY)) { |
2624 | 2211 | DMESGW("No more TX desc, returning %x of %x", | |
2625 | DMESGW("No more TX desc, returning %x of %x", | 2212 | remain, len); |
2626 | remain,len); | 2213 | priv->stats.txrdu++; |
2627 | priv->stats.txrdu++; | ||
2628 | // spin_unlock_irqrestore(&priv->tx_lock,flags); | ||
2629 | |||
2630 | return remain; | 2214 | return remain; |
2631 | |||
2632 | } | 2215 | } |
2633 | 2216 | ||
2634 | *tail= 0; // zeroes header | 2217 | *tail= 0; // zeroes header |
@@ -2641,9 +2224,8 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority, | |||
2641 | if(priv->card_8185){ | 2224 | if(priv->card_8185){ |
2642 | //FIXME: this should be triggered by HW encryption parameters. | 2225 | //FIXME: this should be triggered by HW encryption parameters. |
2643 | *tail |= (1<<15); //no encrypt | 2226 | *tail |= (1<<15); //no encrypt |
2644 | // *tail |= (1<<30); //raise int when completed | ||
2645 | } | 2227 | } |
2646 | // *tail = *tail | (1<<16); | 2228 | |
2647 | if(remain==len && !descfrag) { | 2229 | if(remain==len && !descfrag) { |
2648 | ownbit_flag = false; //added by david woo,2007.12.14 | 2230 | ownbit_flag = false; //added by david woo,2007.12.14 |
2649 | *tail = *tail| (1<<29) ; //fist segment of the packet | 2231 | *tail = *tail| (1<<29) ; //fist segment of the packet |
@@ -2681,19 +2263,11 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority, | |||
2681 | *(tail+5) |= (11<<8);//(priv->retry_data<<8); //retry lim ; | 2263 | *(tail+5) |= (11<<8);//(priv->retry_data<<8); //retry lim ; |
2682 | 2264 | ||
2683 | *tail = *tail | ((rate&0xf) << 24); | 2265 | *tail = *tail | ((rate&0xf) << 24); |
2684 | //DMESG("rate %d",rate); | ||
2685 | |||
2686 | if(priv->card_8185){ | ||
2687 | // *(tail+5) = 0; | ||
2688 | } | ||
2689 | 2266 | ||
2690 | /* hw_plcp_len is not used for rtl8180 chip */ | 2267 | /* hw_plcp_len is not used for rtl8180 chip */ |
2691 | /* FIXME */ | 2268 | /* FIXME */ |
2692 | if(priv->card_8185 == 0 || !priv->hw_plcp_len){ | 2269 | if(priv->card_8185 == 0 || !priv->hw_plcp_len){ |
2693 | 2270 | duration = rtl8180_len2duration(len, rate, &ext); | |
2694 | duration = rtl8180_len2duration(len, | ||
2695 | rate,&ext); | ||
2696 | |||
2697 | *(tail+1) = *(tail+1) | ((duration & 0x7fff)<<16); | 2271 | *(tail+1) = *(tail+1) | ((duration & 0x7fff)<<16); |
2698 | if(ext) *(tail+1) = *(tail+1) |(1<<31); //plcp length extension | 2272 | if(ext) *(tail+1) = *(tail+1) |(1<<31); //plcp length extension |
2699 | } | 2273 | } |
@@ -2712,7 +2286,6 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority, | |||
2712 | 2286 | ||
2713 | if((tail - begin)/8 == count-1) | 2287 | if((tail - begin)/8 == count-1) |
2714 | tail=begin; | 2288 | tail=begin; |
2715 | |||
2716 | else | 2289 | else |
2717 | tail=tail+8; | 2290 | tail=tail+8; |
2718 | 2291 | ||
@@ -2725,75 +2298,56 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority, | |||
2725 | priv->txmapringtail=tail; | 2298 | priv->txmapringtail=tail; |
2726 | priv->txmapbufstail=buflist; | 2299 | priv->txmapbufstail=buflist; |
2727 | break; | 2300 | break; |
2728 | |||
2729 | case BK_PRIORITY: | 2301 | case BK_PRIORITY: |
2730 | priv->txbkpringtail=tail; | 2302 | priv->txbkpringtail=tail; |
2731 | priv->txbkpbufstail=buflist; | 2303 | priv->txbkpbufstail=buflist; |
2732 | break; | 2304 | break; |
2733 | |||
2734 | case BE_PRIORITY: | 2305 | case BE_PRIORITY: |
2735 | priv->txbepringtail=tail; | 2306 | priv->txbepringtail=tail; |
2736 | priv->txbepbufstail=buflist; | 2307 | priv->txbepbufstail=buflist; |
2737 | break; | 2308 | break; |
2738 | |||
2739 | case VI_PRIORITY: | 2309 | case VI_PRIORITY: |
2740 | priv->txvipringtail=tail; | 2310 | priv->txvipringtail=tail; |
2741 | priv->txvipbufstail=buflist; | 2311 | priv->txvipbufstail=buflist; |
2742 | break; | 2312 | break; |
2743 | |||
2744 | case VO_PRIORITY: | 2313 | case VO_PRIORITY: |
2745 | priv->txvopringtail=tail; | 2314 | priv->txvopringtail=tail; |
2746 | priv->txvopbufstail=buflist; | 2315 | priv->txvopbufstail=buflist; |
2747 | break; | 2316 | break; |
2748 | |||
2749 | case HI_PRIORITY: | 2317 | case HI_PRIORITY: |
2750 | priv->txhpringtail=tail; | 2318 | priv->txhpringtail=tail; |
2751 | priv->txhpbufstail = buflist; | 2319 | priv->txhpbufstail = buflist; |
2752 | break; | 2320 | break; |
2753 | |||
2754 | case BEACON_PRIORITY: | 2321 | case BEACON_PRIORITY: |
2755 | /* the HW seems to be happy with the 1st | 2322 | /* the HW seems to be happy with the 1st |
2756 | * descriptor filled and the 2nd empty... | 2323 | * descriptor filled and the 2nd empty... |
2757 | * So always update descriptor 1 and never | 2324 | * So always update descriptor 1 and never |
2758 | * touch 2nd | 2325 | * touch 2nd |
2759 | */ | 2326 | */ |
2760 | // priv->txbeaconringtail=tail; | ||
2761 | // priv->txbeaconbufstail=buflist; | ||
2762 | |||
2763 | break; | 2327 | break; |
2764 | |||
2765 | } | 2328 | } |
2766 | |||
2767 | //rtl8180_dma_kick(dev,priority); | ||
2768 | } | 2329 | } |
2769 | *temp_tail = *temp_tail | (1<<31); // descriptor ready to be txed | 2330 | *temp_tail = *temp_tail | (1<<31); // descriptor ready to be txed |
2770 | rtl8180_dma_kick(dev,priority); | 2331 | rtl8180_dma_kick(dev,priority); |
2771 | //spin_unlock_irqrestore(&priv->tx_lock,flags); | ||
2772 | 2332 | ||
2773 | return 0; | 2333 | return 0; |
2774 | |||
2775 | } | 2334 | } |
2776 | 2335 | ||
2777 | |||
2778 | void rtl8180_irq_rx_tasklet(struct r8180_priv * priv); | 2336 | void rtl8180_irq_rx_tasklet(struct r8180_priv * priv); |
2779 | 2337 | ||
2780 | |||
2781 | void rtl8180_link_change(struct net_device *dev) | 2338 | void rtl8180_link_change(struct net_device *dev) |
2782 | { | 2339 | { |
2783 | struct r8180_priv *priv = ieee80211_priv(dev); | 2340 | struct r8180_priv *priv = ieee80211_priv(dev); |
2784 | u16 beacon_interval; | 2341 | u16 beacon_interval; |
2785 | |||
2786 | struct ieee80211_network *net = &priv->ieee80211->current_network; | 2342 | struct ieee80211_network *net = &priv->ieee80211->current_network; |
2787 | // rtl8180_adapter_start(dev); | ||
2788 | rtl8180_update_msr(dev); | ||
2789 | 2343 | ||
2344 | rtl8180_update_msr(dev); | ||
2790 | 2345 | ||
2791 | rtl8180_set_mode(dev,EPROM_CMD_CONFIG); | 2346 | rtl8180_set_mode(dev,EPROM_CMD_CONFIG); |
2792 | 2347 | ||
2793 | write_nic_dword(dev,BSSID,((u32*)net->bssid)[0]); | 2348 | write_nic_dword(dev,BSSID,((u32*)net->bssid)[0]); |
2794 | write_nic_word(dev,BSSID+4,((u16*)net->bssid)[2]); | 2349 | write_nic_word(dev,BSSID+4,((u16*)net->bssid)[2]); |
2795 | 2350 | ||
2796 | |||
2797 | beacon_interval = read_nic_dword(dev,BEACON_INTERVAL); | 2351 | beacon_interval = read_nic_dword(dev,BEACON_INTERVAL); |
2798 | beacon_interval &= ~ BEACON_INTERVAL_MASK; | 2352 | beacon_interval &= ~ BEACON_INTERVAL_MASK; |
2799 | beacon_interval |= net->beacon_interval; | 2353 | beacon_interval |= net->beacon_interval; |
@@ -2801,23 +2355,14 @@ void rtl8180_link_change(struct net_device *dev) | |||
2801 | 2355 | ||
2802 | rtl8180_set_mode(dev, EPROM_CMD_NORMAL); | 2356 | rtl8180_set_mode(dev, EPROM_CMD_NORMAL); |
2803 | 2357 | ||
2804 | |||
2805 | /* | ||
2806 | u16 atim = read_nic_dword(dev,ATIM); | ||
2807 | u16 = u16 &~ ATIM_MASK; | ||
2808 | u16 = u16 | beacon->atim; | ||
2809 | */ | ||
2810 | |||
2811 | if(priv->card_8185) | 2358 | if(priv->card_8185) |
2812 | rtl8180_set_chan(dev, priv->chan); | 2359 | rtl8180_set_chan(dev, priv->chan); |
2813 | |||
2814 | |||
2815 | } | 2360 | } |
2816 | 2361 | ||
2817 | void rtl8180_rq_tx_ack(struct net_device *dev){ | 2362 | void rtl8180_rq_tx_ack(struct net_device *dev){ |
2818 | 2363 | ||
2819 | struct r8180_priv *priv = ieee80211_priv(dev); | 2364 | struct r8180_priv *priv = ieee80211_priv(dev); |
2820 | // printk("====================>%s\n",__func__); | 2365 | |
2821 | write_nic_byte(dev,CONFIG4,read_nic_byte(dev,CONFIG4)|CONFIG4_PWRMGT); | 2366 | write_nic_byte(dev,CONFIG4,read_nic_byte(dev,CONFIG4)|CONFIG4_PWRMGT); |
2822 | priv->ack_tx_to_ieee = 1; | 2367 | priv->ack_tx_to_ieee = 1; |
2823 | } | 2368 | } |
@@ -2858,39 +2403,29 @@ short rtl8180_is_tx_queue_empty(struct net_device *dev){ | |||
2858 | void rtl8180_hw_wakeup(struct net_device *dev) | 2403 | void rtl8180_hw_wakeup(struct net_device *dev) |
2859 | { | 2404 | { |
2860 | unsigned long flags; | 2405 | unsigned long flags; |
2861 | |||
2862 | struct r8180_priv *priv = ieee80211_priv(dev); | 2406 | struct r8180_priv *priv = ieee80211_priv(dev); |
2863 | 2407 | ||
2864 | spin_lock_irqsave(&priv->ps_lock,flags); | 2408 | spin_lock_irqsave(&priv->ps_lock,flags); |
2865 | //DMESG("Waken up!"); | ||
2866 | write_nic_byte(dev,CONFIG4,read_nic_byte(dev,CONFIG4)&~CONFIG4_PWRMGT); | 2409 | write_nic_byte(dev,CONFIG4,read_nic_byte(dev,CONFIG4)&~CONFIG4_PWRMGT); |
2867 | 2410 | if (priv->rf_wakeup) | |
2868 | if(priv->rf_wakeup) | ||
2869 | priv->rf_wakeup(dev); | 2411 | priv->rf_wakeup(dev); |
2870 | // mdelay(HW_WAKE_DELAY); | ||
2871 | spin_unlock_irqrestore(&priv->ps_lock,flags); | 2412 | spin_unlock_irqrestore(&priv->ps_lock,flags); |
2872 | } | 2413 | } |
2873 | 2414 | ||
2874 | void rtl8180_hw_sleep_down(struct net_device *dev) | 2415 | void rtl8180_hw_sleep_down(struct net_device *dev) |
2875 | { | 2416 | { |
2876 | unsigned long flags; | 2417 | unsigned long flags; |
2877 | |||
2878 | struct r8180_priv *priv = ieee80211_priv(dev); | 2418 | struct r8180_priv *priv = ieee80211_priv(dev); |
2879 | 2419 | ||
2880 | spin_lock_irqsave(&priv->ps_lock,flags); | 2420 | spin_lock_irqsave(&priv->ps_lock,flags); |
2881 | //DMESG("Sleep!"); | ||
2882 | |||
2883 | if(priv->rf_sleep) | 2421 | if(priv->rf_sleep) |
2884 | priv->rf_sleep(dev); | 2422 | priv->rf_sleep(dev); |
2885 | spin_unlock_irqrestore(&priv->ps_lock,flags); | 2423 | spin_unlock_irqrestore(&priv->ps_lock,flags); |
2886 | } | 2424 | } |
2887 | 2425 | ||
2888 | |||
2889 | void rtl8180_hw_sleep(struct net_device *dev, u32 th, u32 tl) | 2426 | void rtl8180_hw_sleep(struct net_device *dev, u32 th, u32 tl) |
2890 | { | 2427 | { |
2891 | |||
2892 | struct r8180_priv *priv = ieee80211_priv(dev); | 2428 | struct r8180_priv *priv = ieee80211_priv(dev); |
2893 | |||
2894 | u32 rb = jiffies; | 2429 | u32 rb = jiffies; |
2895 | unsigned long flags; | 2430 | unsigned long flags; |
2896 | 2431 | ||
@@ -2901,14 +2436,6 @@ void rtl8180_hw_sleep(struct net_device *dev, u32 th, u32 tl) | |||
2901 | */ | 2436 | */ |
2902 | tl -= MSECS(4+16+7); | 2437 | tl -= MSECS(4+16+7); |
2903 | 2438 | ||
2904 | //if(tl == 0) tl = 1; | ||
2905 | |||
2906 | /* FIXME HACK FIXME HACK */ | ||
2907 | // force_pci_posting(dev); | ||
2908 | //mdelay(1); | ||
2909 | |||
2910 | // rb = read_nic_dword(dev, TSFTR); | ||
2911 | |||
2912 | /* If the interval in witch we are requested to sleep is too | 2439 | /* If the interval in witch we are requested to sleep is too |
2913 | * short then give up and remain awake | 2440 | * short then give up and remain awake |
2914 | */ | 2441 | */ |
@@ -2919,13 +2446,9 @@ void rtl8180_hw_sleep(struct net_device *dev, u32 th, u32 tl) | |||
2919 | return; | 2446 | return; |
2920 | } | 2447 | } |
2921 | 2448 | ||
2922 | // write_nic_dword(dev, TimerInt, tl); | ||
2923 | // rb = read_nic_dword(dev, TSFTR); | ||
2924 | { | 2449 | { |
2925 | u32 tmp = (tl>rb)?(tl-rb):(rb-tl); | 2450 | u32 tmp = (tl>rb)?(tl-rb):(rb-tl); |
2926 | // if (tl<rb) | ||
2927 | 2451 | ||
2928 | //lzm,add,080828 | ||
2929 | priv->DozePeriodInPast2Sec += jiffies_to_msecs(tmp); | 2452 | priv->DozePeriodInPast2Sec += jiffies_to_msecs(tmp); |
2930 | 2453 | ||
2931 | queue_delayed_work(priv->ieee80211->wq, &priv->ieee80211->hw_wakeup_wq, tmp); //as tl may be less than rb | 2454 | queue_delayed_work(priv->ieee80211->wq, &priv->ieee80211->hw_wakeup_wq, tmp); //as tl may be less than rb |
@@ -2933,26 +2456,20 @@ void rtl8180_hw_sleep(struct net_device *dev, u32 th, u32 tl) | |||
2933 | /* if we suspect the TimerInt is gone beyond tl | 2456 | /* if we suspect the TimerInt is gone beyond tl |
2934 | * while setting it, then give up | 2457 | * while setting it, then give up |
2935 | */ | 2458 | */ |
2936 | #if 1 | 2459 | |
2937 | if(((tl > rb) && ((tl-rb) > MSECS(MAX_SLEEP_TIME)))|| | 2460 | if(((tl > rb) && ((tl-rb) > MSECS(MAX_SLEEP_TIME)))|| |
2938 | ((tl < rb) && ((rb-tl) > MSECS(MAX_SLEEP_TIME)))) { | 2461 | ((tl < rb) && ((rb-tl) > MSECS(MAX_SLEEP_TIME)))) { |
2939 | spin_unlock_irqrestore(&priv->ps_lock,flags); | 2462 | spin_unlock_irqrestore(&priv->ps_lock,flags); |
2940 | return; | 2463 | return; |
2941 | } | 2464 | } |
2942 | #endif | ||
2943 | // if(priv->rf_sleep) | ||
2944 | // priv->rf_sleep(dev); | ||
2945 | 2465 | ||
2946 | queue_work(priv->ieee80211->wq, (void *)&priv->ieee80211->hw_sleep_wq); | 2466 | queue_work(priv->ieee80211->wq, (void *)&priv->ieee80211->hw_sleep_wq); |
2947 | spin_unlock_irqrestore(&priv->ps_lock,flags); | 2467 | spin_unlock_irqrestore(&priv->ps_lock,flags); |
2948 | } | 2468 | } |
2949 | 2469 | ||
2950 | |||
2951 | //void rtl8180_wmm_param_update(struct net_device *dev,u8 *ac_param) | ||
2952 | void rtl8180_wmm_param_update(struct work_struct * work) | 2470 | void rtl8180_wmm_param_update(struct work_struct * work) |
2953 | { | 2471 | { |
2954 | struct ieee80211_device * ieee = container_of(work, struct ieee80211_device,wmm_param_update_wq); | 2472 | struct ieee80211_device * ieee = container_of(work, struct ieee80211_device,wmm_param_update_wq); |
2955 | //struct r8180_priv *priv = (struct r8180_priv*)(ieee->priv); | ||
2956 | struct net_device *dev = ieee->dev; | 2473 | struct net_device *dev = ieee->dev; |
2957 | u8 *ac_param = (u8 *)(ieee->current_network.wmm_param); | 2474 | u8 *ac_param = (u8 *)(ieee->current_network.wmm_param); |
2958 | u8 mode = ieee->current_network.mode; | 2475 | u8 mode = ieee->current_network.mode; |
@@ -2985,19 +2502,15 @@ void rtl8180_wmm_param_update(struct work_struct * work) | |||
2985 | case AC1_BK: | 2502 | case AC1_BK: |
2986 | write_nic_dword(dev, AC_BK_PARAM, u4bAcParam); | 2503 | write_nic_dword(dev, AC_BK_PARAM, u4bAcParam); |
2987 | break; | 2504 | break; |
2988 | |||
2989 | case AC0_BE: | 2505 | case AC0_BE: |
2990 | write_nic_dword(dev, AC_BE_PARAM, u4bAcParam); | 2506 | write_nic_dword(dev, AC_BE_PARAM, u4bAcParam); |
2991 | break; | 2507 | break; |
2992 | |||
2993 | case AC2_VI: | 2508 | case AC2_VI: |
2994 | write_nic_dword(dev, AC_VI_PARAM, u4bAcParam); | 2509 | write_nic_dword(dev, AC_VI_PARAM, u4bAcParam); |
2995 | break; | 2510 | break; |
2996 | |||
2997 | case AC3_VO: | 2511 | case AC3_VO: |
2998 | write_nic_dword(dev, AC_VO_PARAM, u4bAcParam); | 2512 | write_nic_dword(dev, AC_VO_PARAM, u4bAcParam); |
2999 | break; | 2513 | break; |
3000 | |||
3001 | default: | 2514 | default: |
3002 | printk(KERN_WARNING "SetHwReg8185():invalid ACI: %d!\n", eACI); | 2515 | printk(KERN_WARNING "SetHwReg8185():invalid ACI: %d!\n", eACI); |
3003 | break; | 2516 | break; |
@@ -3028,19 +2541,15 @@ void rtl8180_wmm_param_update(struct work_struct * work) | |||
3028 | case AC1_BK: | 2541 | case AC1_BK: |
3029 | write_nic_dword(dev, AC_BK_PARAM, u4bAcParam); | 2542 | write_nic_dword(dev, AC_BK_PARAM, u4bAcParam); |
3030 | break; | 2543 | break; |
3031 | |||
3032 | case AC0_BE: | 2544 | case AC0_BE: |
3033 | write_nic_dword(dev, AC_BE_PARAM, u4bAcParam); | 2545 | write_nic_dword(dev, AC_BE_PARAM, u4bAcParam); |
3034 | break; | 2546 | break; |
3035 | |||
3036 | case AC2_VI: | 2547 | case AC2_VI: |
3037 | write_nic_dword(dev, AC_VI_PARAM, u4bAcParam); | 2548 | write_nic_dword(dev, AC_VI_PARAM, u4bAcParam); |
3038 | break; | 2549 | break; |
3039 | |||
3040 | case AC3_VO: | 2550 | case AC3_VO: |
3041 | write_nic_dword(dev, AC_VO_PARAM, u4bAcParam); | 2551 | write_nic_dword(dev, AC_VO_PARAM, u4bAcParam); |
3042 | break; | 2552 | break; |
3043 | |||
3044 | default: | 2553 | default: |
3045 | printk(KERN_WARNING "SetHwReg8185(): invalid ACI: %d !\n", eACI); | 2554 | printk(KERN_WARNING "SetHwReg8185(): invalid ACI: %d !\n", eACI); |
3046 | break; | 2555 | break; |
@@ -3061,17 +2570,13 @@ void rtl8180_watch_dog(struct net_device *dev); | |||
3061 | 2570 | ||
3062 | void watch_dog_adaptive(unsigned long data) | 2571 | void watch_dog_adaptive(unsigned long data) |
3063 | { | 2572 | { |
3064 | struct r8180_priv* priv = ieee80211_priv((struct net_device *)data); | 2573 | struct r8180_priv* priv = ieee80211_priv((struct net_device *)data); |
3065 | // DMESG("---->watch_dog_adaptive()\n"); | 2574 | |
3066 | if(!priv->up) | 2575 | if (!priv->up) { |
3067 | { | ||
3068 | DMESG("<----watch_dog_adaptive():driver is not up!\n"); | 2576 | DMESG("<----watch_dog_adaptive():driver is not up!\n"); |
3069 | return; | 2577 | return; |
3070 | } | 2578 | } |
3071 | 2579 | ||
3072 | // queue_work(priv->ieee80211->wq,&priv->ieee80211->watch_dog_wq); | ||
3073 | //{by amy 080312 | ||
3074 | #if 1 | ||
3075 | // Tx High Power Mechanism. | 2580 | // Tx High Power Mechanism. |
3076 | #ifdef HIGH_POWER | 2581 | #ifdef HIGH_POWER |
3077 | if(CheckHighPower((struct net_device *)data)) | 2582 | if(CheckHighPower((struct net_device *)data)) |
@@ -3094,19 +2599,14 @@ void watch_dog_adaptive(unsigned long data) | |||
3094 | queue_work(priv->ieee80211->wq, (void *)&priv->ieee80211->hw_dig_wq); | 2599 | queue_work(priv->ieee80211->wq, (void *)&priv->ieee80211->hw_dig_wq); |
3095 | } | 2600 | } |
3096 | #endif | 2601 | #endif |
3097 | #endif | ||
3098 | //by amy 080312} | ||
3099 | rtl8180_watch_dog((struct net_device *)data); | 2602 | rtl8180_watch_dog((struct net_device *)data); |
3100 | 2603 | ||
3101 | |||
3102 | queue_work(priv->ieee80211->wq, (void *)&priv->ieee80211->GPIOChangeRFWorkItem); | 2604 | queue_work(priv->ieee80211->wq, (void *)&priv->ieee80211->GPIOChangeRFWorkItem); |
3103 | 2605 | ||
3104 | priv->watch_dog_timer.expires = jiffies + MSECS(IEEE80211_WATCH_DOG_TIME); | 2606 | priv->watch_dog_timer.expires = jiffies + MSECS(IEEE80211_WATCH_DOG_TIME); |
3105 | add_timer(&priv->watch_dog_timer); | 2607 | add_timer(&priv->watch_dog_timer); |
3106 | // DMESG("<----watch_dog_adaptive()\n"); | ||
3107 | } | 2608 | } |
3108 | 2609 | ||
3109 | |||
3110 | static CHANNEL_LIST ChannelPlan[] = { | 2610 | static CHANNEL_LIST ChannelPlan[] = { |
3111 | {{1,2,3,4,5,6,7,8,9,10,11,36,40,44,48,52,56,60,64},19}, //FCC | 2611 | {{1,2,3,4,5,6,7,8,9,10,11,36,40,44,48,52,56,60,64},19}, //FCC |
3112 | {{1,2,3,4,5,6,7,8,9,10,11},11}, //IC | 2612 | {{1,2,3,4,5,6,7,8,9,10,11},11}, //IC |
@@ -3182,7 +2682,6 @@ static void rtl8180_set_channel_map(u8 channel_plan, struct ieee80211_device *ie | |||
3182 | } | 2682 | } |
3183 | } | 2683 | } |
3184 | 2684 | ||
3185 | //Add for RF power on power off by lizhaoming 080512 | ||
3186 | void GPIOChangeRFWorkItemCallBack(struct work_struct *work); | 2685 | void GPIOChangeRFWorkItemCallBack(struct work_struct *work); |
3187 | 2686 | ||
3188 | //YJ,add,080828 | 2687 | //YJ,add,080828 |
@@ -3190,6 +2689,7 @@ static void rtl8180_statistics_init(struct Stats *pstats) | |||
3190 | { | 2689 | { |
3191 | memset(pstats, 0, sizeof(struct Stats)); | 2690 | memset(pstats, 0, sizeof(struct Stats)); |
3192 | } | 2691 | } |
2692 | |||
3193 | static void rtl8180_link_detect_init(plink_detect_t plink_detect) | 2693 | static void rtl8180_link_detect_init(plink_detect_t plink_detect) |
3194 | { | 2694 | { |
3195 | memset(plink_detect, 0, sizeof(link_detect_t)); | 2695 | memset(plink_detect, 0, sizeof(link_detect_t)); |
@@ -3213,13 +2713,10 @@ short rtl8180_init(struct net_device *dev) | |||
3213 | printk("rtl8180_init:Error channel plan! Set to default.\n"); | 2713 | printk("rtl8180_init:Error channel plan! Set to default.\n"); |
3214 | priv->channel_plan = 0; | 2714 | priv->channel_plan = 0; |
3215 | } | 2715 | } |
3216 | //priv->channel_plan = 9; //Global Domain | ||
3217 | 2716 | ||
3218 | DMESG("Channel plan is %d\n",priv->channel_plan); | 2717 | DMESG("Channel plan is %d\n",priv->channel_plan); |
3219 | rtl8180_set_channel_map(priv->channel_plan, priv->ieee80211); | 2718 | rtl8180_set_channel_map(priv->channel_plan, priv->ieee80211); |
3220 | 2719 | ||
3221 | //memcpy(priv->stats,0,sizeof(struct Stats)); | ||
3222 | |||
3223 | //FIXME: these constants are placed in a bad pleace. | 2720 | //FIXME: these constants are placed in a bad pleace. |
3224 | priv->txbuffsize = 2048;//1024; | 2721 | priv->txbuffsize = 2048;//1024; |
3225 | priv->txringcount = 32;//32; | 2722 | priv->txringcount = 32;//32; |
@@ -3227,14 +2724,9 @@ short rtl8180_init(struct net_device *dev) | |||
3227 | priv->rxringcount = 64;//32; | 2724 | priv->rxringcount = 64;//32; |
3228 | priv->txbeaconcount = 2; | 2725 | priv->txbeaconcount = 2; |
3229 | priv->rx_skb_complete = 1; | 2726 | priv->rx_skb_complete = 1; |
3230 | //priv->txnp_pending.ispending=0; | ||
3231 | /* ^^ the SKB does not containt a partial RXed | ||
3232 | * packet (is empty) | ||
3233 | */ | ||
3234 | 2727 | ||
3235 | priv->RegThreeWireMode = HW_THREE_WIRE_SI; | 2728 | priv->RegThreeWireMode = HW_THREE_WIRE_SI; |
3236 | 2729 | ||
3237 | //Add for RF power on power off by lizhaoming 080512 | ||
3238 | priv->RFChangeInProgress = false; | 2730 | priv->RFChangeInProgress = false; |
3239 | priv->SetRFPowerStateInProgress = false; | 2731 | priv->SetRFPowerStateInProgress = false; |
3240 | priv->RFProgType = 0; | 2732 | priv->RFProgType = 0; |
@@ -3242,11 +2734,8 @@ short rtl8180_init(struct net_device *dev) | |||
3242 | 2734 | ||
3243 | priv->irq_enabled=0; | 2735 | priv->irq_enabled=0; |
3244 | 2736 | ||
3245 | //YJ,modified,080828 | ||
3246 | rtl8180_statistics_init(&priv->stats); | 2737 | rtl8180_statistics_init(&priv->stats); |
3247 | rtl8180_link_detect_init(&priv->link_detect); | 2738 | rtl8180_link_detect_init(&priv->link_detect); |
3248 | //YJ,modified,080828,end | ||
3249 | |||
3250 | 2739 | ||
3251 | priv->ack_tx_to_ieee = 0; | 2740 | priv->ack_tx_to_ieee = 0; |
3252 | priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; | 2741 | priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; |
@@ -3279,8 +2768,6 @@ short rtl8180_init(struct net_device *dev) | |||
3279 | priv->eRFPowerState = eRfOff; | 2768 | priv->eRFPowerState = eRfOff; |
3280 | priv->RfOffReason = 0; | 2769 | priv->RfOffReason = 0; |
3281 | priv->LedStrategy = SW_LED_MODE0; | 2770 | priv->LedStrategy = SW_LED_MODE0; |
3282 | //priv->NumRxOkInPeriod = 0; //YJ,del,080828 | ||
3283 | //priv->NumTxOkInPeriod = 0; //YJ,del,080828 | ||
3284 | priv->TxPollingTimes = 0;//lzm add 080826 | 2771 | priv->TxPollingTimes = 0;//lzm add 080826 |
3285 | priv->bLeisurePs = true; | 2772 | priv->bLeisurePs = true; |
3286 | priv->dot11PowerSaveMode = eActive; | 2773 | priv->dot11PowerSaveMode = eActive; |
@@ -3336,13 +2823,10 @@ short rtl8180_init(struct net_device *dev) | |||
3336 | priv->CurCCKRSSI = 0; | 2823 | priv->CurCCKRSSI = 0; |
3337 | priv->RxPower = 0; | 2824 | priv->RxPower = 0; |
3338 | priv->RSSI = 0; | 2825 | priv->RSSI = 0; |
3339 | //YJ,add,080828 | ||
3340 | priv->NumTxOkTotal = 0; | 2826 | priv->NumTxOkTotal = 0; |
3341 | priv->NumTxUnicast = 0; | 2827 | priv->NumTxUnicast = 0; |
3342 | priv->keepAliveLevel = DEFAULT_KEEP_ALIVE_LEVEL; | 2828 | priv->keepAliveLevel = DEFAULT_KEEP_ALIVE_LEVEL; |
3343 | priv->PowerProfile = POWER_PROFILE_AC; | 2829 | priv->PowerProfile = POWER_PROFILE_AC; |
3344 | //YJ,add,080828,end | ||
3345 | //by amy for rate adaptive | ||
3346 | priv->CurrRetryCnt=0; | 2830 | priv->CurrRetryCnt=0; |
3347 | priv->LastRetryCnt=0; | 2831 | priv->LastRetryCnt=0; |
3348 | priv->LastTxokCnt=0; | 2832 | priv->LastTxokCnt=0; |
@@ -3363,8 +2847,6 @@ short rtl8180_init(struct net_device *dev) | |||
3363 | priv->ForcedDataRate = 0; | 2847 | priv->ForcedDataRate = 0; |
3364 | priv->RegBModeGainStage = 1; | 2848 | priv->RegBModeGainStage = 1; |
3365 | 2849 | ||
3366 | //by amy for rate adaptive | ||
3367 | //by amy 080312} | ||
3368 | priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0; | 2850 | priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0; |
3369 | spin_lock_init(&priv->irq_lock); | 2851 | spin_lock_init(&priv->irq_lock); |
3370 | spin_lock_init(&priv->irq_th_lock); | 2852 | spin_lock_init(&priv->irq_th_lock); |
@@ -3377,39 +2859,26 @@ short rtl8180_init(struct net_device *dev) | |||
3377 | INIT_WORK(&priv->tx_irq_wq,(void*) rtl8180_tx_irq_wq); | 2859 | INIT_WORK(&priv->tx_irq_wq,(void*) rtl8180_tx_irq_wq); |
3378 | INIT_DELAYED_WORK(&priv->ieee80211->hw_wakeup_wq,(void*) rtl8180_hw_wakeup_wq); | 2860 | INIT_DELAYED_WORK(&priv->ieee80211->hw_wakeup_wq,(void*) rtl8180_hw_wakeup_wq); |
3379 | INIT_DELAYED_WORK(&priv->ieee80211->hw_sleep_wq,(void*) rtl8180_hw_sleep_wq); | 2861 | INIT_DELAYED_WORK(&priv->ieee80211->hw_sleep_wq,(void*) rtl8180_hw_sleep_wq); |
3380 | //INIT_DELAYED_WORK(&priv->ieee80211->watch_dog_wq,(void*) rtl8180_watch_dog_wq); | ||
3381 | //INIT_DELAYED_WORK(&priv->ieee80211->sw_antenna_wq,(void*) rtl8180_sw_antenna_wq); | ||
3382 | INIT_WORK(&priv->ieee80211->wmm_param_update_wq,(void*) rtl8180_wmm_param_update); | 2862 | INIT_WORK(&priv->ieee80211->wmm_param_update_wq,(void*) rtl8180_wmm_param_update); |
3383 | INIT_DELAYED_WORK(&priv->ieee80211->rate_adapter_wq,(void*)rtl8180_rate_adapter);//+by amy 080312 | 2863 | INIT_DELAYED_WORK(&priv->ieee80211->rate_adapter_wq,(void*)rtl8180_rate_adapter);//+by amy 080312 |
3384 | INIT_DELAYED_WORK(&priv->ieee80211->hw_dig_wq,(void*)rtl8180_hw_dig_wq);//+by amy 080312 | 2864 | INIT_DELAYED_WORK(&priv->ieee80211->hw_dig_wq,(void*)rtl8180_hw_dig_wq);//+by amy 080312 |
3385 | INIT_DELAYED_WORK(&priv->ieee80211->tx_pw_wq,(void*)rtl8180_tx_pw_wq);//+by amy 080312 | 2865 | INIT_DELAYED_WORK(&priv->ieee80211->tx_pw_wq,(void*)rtl8180_tx_pw_wq);//+by amy 080312 |
3386 | 2866 | ||
3387 | //add for RF power on power off by lizhaoming 080512 | ||
3388 | INIT_DELAYED_WORK(&priv->ieee80211->GPIOChangeRFWorkItem,(void*) GPIOChangeRFWorkItemCallBack); | 2867 | INIT_DELAYED_WORK(&priv->ieee80211->GPIOChangeRFWorkItem,(void*) GPIOChangeRFWorkItemCallBack); |
3389 | //INIT_WORK(&priv->reset_wq,(void*) rtl8180_restart_wq,dev); | ||
3390 | 2868 | ||
3391 | tasklet_init(&priv->irq_rx_tasklet, | 2869 | tasklet_init(&priv->irq_rx_tasklet, |
3392 | (void(*)(unsigned long)) rtl8180_irq_rx_tasklet, | 2870 | (void(*)(unsigned long)) rtl8180_irq_rx_tasklet, |
3393 | (unsigned long)priv); | 2871 | (unsigned long)priv); |
3394 | //by amy | 2872 | |
3395 | init_timer(&priv->watch_dog_timer); | 2873 | init_timer(&priv->watch_dog_timer); |
3396 | priv->watch_dog_timer.data = (unsigned long)dev; | 2874 | priv->watch_dog_timer.data = (unsigned long)dev; |
3397 | priv->watch_dog_timer.function = watch_dog_adaptive; | 2875 | priv->watch_dog_timer.function = watch_dog_adaptive; |
3398 | //by amy | ||
3399 | 2876 | ||
3400 | //{by amy 080312 | ||
3401 | //by amy for rate adaptive | ||
3402 | init_timer(&priv->rateadapter_timer); | 2877 | init_timer(&priv->rateadapter_timer); |
3403 | priv->rateadapter_timer.data = (unsigned long)dev; | 2878 | priv->rateadapter_timer.data = (unsigned long)dev; |
3404 | priv->rateadapter_timer.function = timer_rate_adaptive; | 2879 | priv->rateadapter_timer.function = timer_rate_adaptive; |
3405 | priv->RateAdaptivePeriod= RATE_ADAPTIVE_TIMER_PERIOD; | 2880 | priv->RateAdaptivePeriod= RATE_ADAPTIVE_TIMER_PERIOD; |
3406 | priv->bEnhanceTxPwr=false; | 2881 | priv->bEnhanceTxPwr=false; |
3407 | //by amy for rate adaptive | ||
3408 | //by amy 080312} | ||
3409 | //priv->ieee80211->func = | ||
3410 | // kmalloc(sizeof(struct ieee80211_helper_functions),GFP_KERNEL); | ||
3411 | //memset(priv->ieee80211->func, 0, | ||
3412 | // sizeof(struct ieee80211_helper_functions)); | ||
3413 | 2882 | ||
3414 | priv->ieee80211->softmac_hard_start_xmit = rtl8180_hard_start_xmit; | 2883 | priv->ieee80211->softmac_hard_start_xmit = rtl8180_hard_start_xmit; |
3415 | priv->ieee80211->set_chan = rtl8180_set_chan; | 2884 | priv->ieee80211->set_chan = rtl8180_set_chan; |
@@ -3440,11 +2909,9 @@ short rtl8180_init(struct net_device *dev) | |||
3440 | (0 ? TCR_SAT : 0); // FALSE: HW provies PLCP length and LENGEXT, TURE: SW proiveds them | 2909 | (0 ? TCR_SAT : 0); // FALSE: HW provies PLCP length and LENGEXT, TURE: SW proiveds them |
3441 | 2910 | ||
3442 | priv->ReceiveConfig = | 2911 | priv->ReceiveConfig = |
3443 | // RCR_ENMARP | | ||
3444 | RCR_AMF | RCR_ADF | //accept management/data | 2912 | RCR_AMF | RCR_ADF | //accept management/data |
3445 | RCR_ACF | //accept control frame for SW AP needs PS-poll, 2005.07.07, by rcnjko. | 2913 | RCR_ACF | //accept control frame for SW AP needs PS-poll, 2005.07.07, by rcnjko. |
3446 | RCR_AB | RCR_AM | RCR_APM | //accept BC/MC/UC | 2914 | RCR_AB | RCR_AM | RCR_APM | //accept BC/MC/UC |
3447 | //RCR_AICV | RCR_ACRC32 | //accept ICV/CRC error packet | ||
3448 | (7<<RCR_MXDMA_OFFSET) | // Max DMA Burst Size per Rx DMA Burst, 7: unlimited. | 2915 | (7<<RCR_MXDMA_OFFSET) | // Max DMA Burst Size per Rx DMA Burst, 7: unlimited. |
3449 | (priv->EarlyRxThreshold<<RCR_FIFO_OFFSET) | // Rx FIFO Threshold, 7: No Rx threshold. | 2916 | (priv->EarlyRxThreshold<<RCR_FIFO_OFFSET) | // Rx FIFO Threshold, 7: No Rx threshold. |
3450 | (priv->EarlyRxThreshold == 7 ? RCR_ONLYERLPKT:0); | 2917 | (priv->EarlyRxThreshold == 7 ? RCR_ONLYERLPKT:0); |
@@ -3475,24 +2942,20 @@ short rtl8180_init(struct net_device *dev) | |||
3475 | /* you should not find a card with 8225 PHY ver < C*/ | 2942 | /* you should not find a card with 8225 PHY ver < C*/ |
3476 | priv->phy_ver = 2; | 2943 | priv->phy_ver = 2; |
3477 | break; | 2944 | break; |
3478 | |||
3479 | case HW_VERID_R8185_D: | 2945 | case HW_VERID_R8185_D: |
3480 | DMESG("MAC controller is a RTL8185 b/g (V. D)"); | 2946 | DMESG("MAC controller is a RTL8185 b/g (V. D)"); |
3481 | priv->card_8185 = 2; | 2947 | priv->card_8185 = 2; |
3482 | /* you should not find a card with 8225 PHY ver < C*/ | 2948 | /* you should not find a card with 8225 PHY ver < C*/ |
3483 | priv->phy_ver = 2; | 2949 | priv->phy_ver = 2; |
3484 | break; | 2950 | break; |
3485 | |||
3486 | case HW_VERID_R8180_ABCD: | 2951 | case HW_VERID_R8180_ABCD: |
3487 | DMESG("MAC controller is a RTL8180"); | 2952 | DMESG("MAC controller is a RTL8180"); |
3488 | priv->card_8185 = 0; | 2953 | priv->card_8185 = 0; |
3489 | break; | 2954 | break; |
3490 | |||
3491 | case HW_VERID_R8180_F: | 2955 | case HW_VERID_R8180_F: |
3492 | DMESG("MAC controller is a RTL8180 (v. F)"); | 2956 | DMESG("MAC controller is a RTL8180 (v. F)"); |
3493 | priv->card_8185 = 0; | 2957 | priv->card_8185 = 0; |
3494 | break; | 2958 | break; |
3495 | |||
3496 | default: | 2959 | default: |
3497 | DMESGW("MAC chip not recognized: version %x. Assuming RTL8180",hw_version); | 2960 | DMESGW("MAC chip not recognized: version %x. Assuming RTL8180",hw_version); |
3498 | priv->card_8185 = 0; | 2961 | priv->card_8185 = 0; |
@@ -3511,72 +2974,45 @@ short rtl8180_init(struct net_device *dev) | |||
3511 | DMESG("This is a PCI NIC"); | 2974 | DMESG("This is a PCI NIC"); |
3512 | priv->enable_gpio0 = 0; | 2975 | priv->enable_gpio0 = 0; |
3513 | 2976 | ||
3514 | //by amy for antenna | ||
3515 | usValue = eprom_read(dev, EEPROM_SW_REVD_OFFSET); | 2977 | usValue = eprom_read(dev, EEPROM_SW_REVD_OFFSET); |
3516 | DMESG("usValue is 0x%x\n",usValue); | 2978 | DMESG("usValue is 0x%x\n",usValue); |
3517 | //3Read AntennaDiversity | 2979 | //3Read AntennaDiversity |
2980 | |||
3518 | // SW Antenna Diversity. | 2981 | // SW Antenna Diversity. |
3519 | if( (usValue & EEPROM_SW_AD_MASK) != EEPROM_SW_AD_ENABLE ) | 2982 | if ((usValue & EEPROM_SW_AD_MASK) != EEPROM_SW_AD_ENABLE) |
3520 | { | ||
3521 | priv->EEPROMSwAntennaDiversity = false; | 2983 | priv->EEPROMSwAntennaDiversity = false; |
3522 | //printk("EEPROM Disable SW Antenna Diversity\n"); | ||
3523 | } | ||
3524 | else | 2984 | else |
3525 | { | ||
3526 | priv->EEPROMSwAntennaDiversity = true; | 2985 | priv->EEPROMSwAntennaDiversity = true; |
3527 | //printk("EEPROM Enable SW Antenna Diversity\n"); | 2986 | |
3528 | } | ||
3529 | // Default Antenna to use. | 2987 | // Default Antenna to use. |
3530 | if( (usValue & EEPROM_DEF_ANT_MASK) != EEPROM_DEF_ANT_1 ) | 2988 | if ((usValue & EEPROM_DEF_ANT_MASK) != EEPROM_DEF_ANT_1) |
3531 | { | ||
3532 | priv->EEPROMDefaultAntenna1 = false; | 2989 | priv->EEPROMDefaultAntenna1 = false; |
3533 | //printk("EEPROM Default Antenna 0\n"); | ||
3534 | } | ||
3535 | else | 2990 | else |
3536 | { | ||
3537 | priv->EEPROMDefaultAntenna1 = true; | 2991 | priv->EEPROMDefaultAntenna1 = true; |
3538 | //printk("EEPROM Default Antenna 1\n"); | ||
3539 | } | ||
3540 | 2992 | ||
3541 | // | ||
3542 | // Antenna diversity mechanism. Added by Roger, 2007.11.05. | ||
3543 | // | ||
3544 | if( priv->RegSwAntennaDiversityMechanism == 0 ) // Auto | 2993 | if( priv->RegSwAntennaDiversityMechanism == 0 ) // Auto |
3545 | {// 0: default from EEPROM. | 2994 | /* 0: default from EEPROM. */ |
3546 | priv->bSwAntennaDiverity = priv->EEPROMSwAntennaDiversity; | 2995 | priv->bSwAntennaDiverity = priv->EEPROMSwAntennaDiversity; |
3547 | } | ||
3548 | else | 2996 | else |
3549 | {// 1:disable antenna diversity, 2: enable antenna diversity. | 2997 | /* 1:disable antenna diversity, 2: enable antenna diversity. */ |
3550 | priv->bSwAntennaDiverity = ((priv->RegSwAntennaDiversityMechanism == 1)? false : true); | 2998 | priv->bSwAntennaDiverity = ((priv->RegSwAntennaDiversityMechanism == 1)? false : true); |
3551 | } | ||
3552 | //printk("bSwAntennaDiverity = %d\n", priv->bSwAntennaDiverity); | ||
3553 | |||
3554 | 2999 | ||
3555 | // | 3000 | if (priv->RegDefaultAntenna == 0) |
3556 | // Default antenna settings. Added by Roger, 2007.11.05. | 3001 | /* 0: default from EEPROM. */ |
3557 | // | ||
3558 | if( priv->RegDefaultAntenna == 0) | ||
3559 | {// 0: default from EEPROM. | ||
3560 | priv->bDefaultAntenna1 = priv->EEPROMDefaultAntenna1; | 3002 | priv->bDefaultAntenna1 = priv->EEPROMDefaultAntenna1; |
3561 | } | ||
3562 | else | 3003 | else |
3563 | {// 1: main, 2: aux. | 3004 | /* 1: main, 2: aux. */ |
3564 | priv->bDefaultAntenna1 = ((priv->RegDefaultAntenna== 2) ? true : false); | 3005 | priv->bDefaultAntenna1 = ((priv->RegDefaultAntenna== 2) ? true : false); |
3565 | } | 3006 | |
3566 | //printk("bDefaultAntenna1 = %d\n", priv->bDefaultAntenna1); | ||
3567 | //by amy for antenna | ||
3568 | /* rtl8185 can calc plcp len in HW.*/ | 3007 | /* rtl8185 can calc plcp len in HW.*/ |
3569 | priv->hw_plcp_len = 1; | 3008 | priv->hw_plcp_len = 1; |
3570 | 3009 | ||
3571 | priv->plcp_preamble_mode = 2; | 3010 | priv->plcp_preamble_mode = 2; |
3572 | /*the eeprom type is stored in RCR register bit #6 */ | 3011 | /*the eeprom type is stored in RCR register bit #6 */ |
3573 | if (RCR_9356SEL & read_nic_dword(dev, RCR)){ | 3012 | if (RCR_9356SEL & read_nic_dword(dev, RCR)) |
3574 | priv->epromtype=EPROM_93c56; | 3013 | priv->epromtype=EPROM_93c56; |
3575 | //DMESG("Reported EEPROM chip is a 93c56 (2Kbit)"); | 3014 | else |
3576 | }else{ | ||
3577 | priv->epromtype=EPROM_93c46; | 3015 | priv->epromtype=EPROM_93c46; |
3578 | //DMESG("Reported EEPROM chip is a 93c46 (1Kbit)"); | ||
3579 | } | ||
3580 | 3016 | ||
3581 | dev->dev_addr[0]=eprom_read(dev,MAC_ADR) & 0xff; | 3017 | dev->dev_addr[0]=eprom_read(dev,MAC_ADR) & 0xff; |
3582 | dev->dev_addr[1]=(eprom_read(dev,MAC_ADR) & 0xff00)>>8; | 3018 | dev->dev_addr[1]=(eprom_read(dev,MAC_ADR) & 0xff00)>>8; |
@@ -3584,32 +3020,26 @@ short rtl8180_init(struct net_device *dev) | |||
3584 | dev->dev_addr[3]=(eprom_read(dev,MAC_ADR+1) & 0xff00)>>8; | 3020 | dev->dev_addr[3]=(eprom_read(dev,MAC_ADR+1) & 0xff00)>>8; |
3585 | dev->dev_addr[4]=eprom_read(dev,MAC_ADR+2) & 0xff; | 3021 | dev->dev_addr[4]=eprom_read(dev,MAC_ADR+2) & 0xff; |
3586 | dev->dev_addr[5]=(eprom_read(dev,MAC_ADR+2) & 0xff00)>>8; | 3022 | dev->dev_addr[5]=(eprom_read(dev,MAC_ADR+2) & 0xff00)>>8; |
3587 | //DMESG("Card MAC address is "MAC_FMT, MAC_ARG(dev->dev_addr)); | ||
3588 | |||
3589 | 3023 | ||
3590 | for(i=1,j=0; i<14; i+=2,j++){ | 3024 | for(i=1,j=0; i<14; i+=2,j++){ |
3591 | |||
3592 | word = eprom_read(dev,EPROM_TXPW_CH1_2 + j); | 3025 | word = eprom_read(dev,EPROM_TXPW_CH1_2 + j); |
3593 | priv->chtxpwr[i]=word & 0xff; | 3026 | priv->chtxpwr[i]=word & 0xff; |
3594 | priv->chtxpwr[i+1]=(word & 0xff00)>>8; | 3027 | priv->chtxpwr[i+1]=(word & 0xff00)>>8; |
3595 | } | 3028 | } |
3596 | if(priv->card_8185){ | 3029 | if(priv->card_8185){ |
3597 | for(i=1,j=0; i<14; i+=2,j++){ | 3030 | for(i=1,j=0; i<14; i+=2,j++){ |
3598 | |||
3599 | word = eprom_read(dev,EPROM_TXPW_OFDM_CH1_2 + j); | 3031 | word = eprom_read(dev,EPROM_TXPW_OFDM_CH1_2 + j); |
3600 | priv->chtxpwr_ofdm[i]=word & 0xff; | 3032 | priv->chtxpwr_ofdm[i]=word & 0xff; |
3601 | priv->chtxpwr_ofdm[i+1]=(word & 0xff00)>>8; | 3033 | priv->chtxpwr_ofdm[i+1]=(word & 0xff00)>>8; |
3602 | } | 3034 | } |
3603 | } | 3035 | } |
3604 | //{by amy 080312 | 3036 | |
3605 | //3Read crystal calibtration and thermal meter indication on 87SE. | 3037 | //3Read crystal calibtration and thermal meter indication on 87SE. |
3606 | 3038 | ||
3607 | // By SD3 SY's request. Added by Roger, 2007.12.11. | 3039 | // By SD3 SY's request. Added by Roger, 2007.12.11. |
3608 | 3040 | ||
3609 | tmpu16 = eprom_read(dev, EEPROM_RSV>>1); | 3041 | tmpu16 = eprom_read(dev, EEPROM_RSV>>1); |
3610 | 3042 | ||
3611 | //printk("ReadAdapterInfo8185(): EEPROM_RSV(%04x)\n", tmpu16); | ||
3612 | |||
3613 | // Crystal calibration for Xin and Xout resp. | 3043 | // Crystal calibration for Xin and Xout resp. |
3614 | priv->XtalCal_Xout = tmpu16 & EEPROM_XTAL_CAL_XOUT_MASK; // 0~7.5pF | 3044 | priv->XtalCal_Xout = tmpu16 & EEPROM_XTAL_CAL_XOUT_MASK; // 0~7.5pF |
3615 | priv->XtalCal_Xin = (tmpu16 & EEPROM_XTAL_CAL_XIN_MASK)>>4; // 0~7.5pF | 3045 | priv->XtalCal_Xin = (tmpu16 & EEPROM_XTAL_CAL_XIN_MASK)>>4; // 0~7.5pF |
@@ -3621,7 +3051,6 @@ short rtl8180_init(struct net_device *dev) | |||
3621 | if((tmpu16 & EEPROM_THERMAL_METER_ENABLE)>>13) | 3051 | if((tmpu16 & EEPROM_THERMAL_METER_ENABLE)>>13) |
3622 | priv->bTxPowerTrack = true; | 3052 | priv->bTxPowerTrack = true; |
3623 | 3053 | ||
3624 | //by amy 080312} | ||
3625 | word = eprom_read(dev,EPROM_TXPW_BASE); | 3054 | word = eprom_read(dev,EPROM_TXPW_BASE); |
3626 | priv->cck_txpwr_base = word & 0xf; | 3055 | priv->cck_txpwr_base = word & 0xf; |
3627 | priv->ofdm_txpwr_base = (word>>4) & 0xf; | 3056 | priv->ofdm_txpwr_base = (word>>4) & 0xf; |
@@ -3663,9 +3092,6 @@ DMESG output to andreamrl@tiscali.it THANKS"); | |||
3663 | priv->rf_chip = RF_ZEBRA4; | 3092 | priv->rf_chip = RF_ZEBRA4; |
3664 | priv->rf_sleep = rtl8225z4_rf_sleep; | 3093 | priv->rf_sleep = rtl8225z4_rf_sleep; |
3665 | priv->rf_wakeup = rtl8225z4_rf_wakeup; | 3094 | priv->rf_wakeup = rtl8225z4_rf_wakeup; |
3666 | //DMESG("Card reports RF frontend Realtek 8225z2"); | ||
3667 | //DMESGW("This driver has EXPERIMENTAL support for this chipset."); | ||
3668 | //DMESGW("use it with care and at your own risk and"); | ||
3669 | DMESGW("**PLEASE** REPORT SUCCESSFUL/UNSUCCESSFUL TO Realtek!"); | 3095 | DMESGW("**PLEASE** REPORT SUCCESSFUL/UNSUCCESSFUL TO Realtek!"); |
3670 | 3096 | ||
3671 | priv->rf_close = rtl8225z2_rf_close; | 3097 | priv->rf_close = rtl8225z2_rf_close; |
@@ -3718,11 +3144,7 @@ DMESG output to andreamrl@tiscali.it THANKS"); | |||
3718 | TX_BEACON_RING_ADDR)) | 3144 | TX_BEACON_RING_ADDR)) |
3719 | return -ENOMEM; | 3145 | return -ENOMEM; |
3720 | 3146 | ||
3721 | |||
3722 | //priv->beacon_buf=NULL; | ||
3723 | |||
3724 | if(!priv->card_8185){ | 3147 | if(!priv->card_8185){ |
3725 | |||
3726 | if(read_nic_byte(dev, CONFIG0) & (1<<CONFIG0_WEP40_SHIFT)) | 3148 | if(read_nic_byte(dev, CONFIG0) & (1<<CONFIG0_WEP40_SHIFT)) |
3727 | DMESG ("40-bit WEP is supported in hardware"); | 3149 | DMESG ("40-bit WEP is supported in hardware"); |
3728 | else | 3150 | else |
@@ -3746,16 +3168,13 @@ DMESG output to andreamrl@tiscali.it THANKS"); | |||
3746 | } | 3168 | } |
3747 | 3169 | ||
3748 | return 0; | 3170 | return 0; |
3749 | |||
3750 | } | 3171 | } |
3751 | 3172 | ||
3752 | |||
3753 | void rtl8180_no_hw_wep(struct net_device *dev) | 3173 | void rtl8180_no_hw_wep(struct net_device *dev) |
3754 | { | 3174 | { |
3755 | struct r8180_priv *priv = ieee80211_priv(dev); | 3175 | struct r8180_priv *priv = ieee80211_priv(dev); |
3756 | 3176 | ||
3757 | if(!priv->card_8185) | 3177 | if (!priv->card_8185) { |
3758 | { | ||
3759 | u8 security; | 3178 | u8 security; |
3760 | 3179 | ||
3761 | security = read_nic_byte(dev, SECURITY); | 3180 | security = read_nic_byte(dev, SECURITY); |
@@ -3763,19 +3182,9 @@ void rtl8180_no_hw_wep(struct net_device *dev) | |||
3763 | security &=~(1<<SECURITY_WEP_RX_ENABLE_SHIFT); | 3182 | security &=~(1<<SECURITY_WEP_RX_ENABLE_SHIFT); |
3764 | 3183 | ||
3765 | write_nic_byte(dev, SECURITY, security); | 3184 | write_nic_byte(dev, SECURITY, security); |
3766 | |||
3767 | }else{ | ||
3768 | |||
3769 | //FIXME!!! | ||
3770 | } | 3185 | } |
3771 | /* | ||
3772 | write_nic_dword(dev,TX_CONF,read_nic_dword(dev,TX_CONF) | | ||
3773 | (1<<TX_NOICV_SHIFT) ); | ||
3774 | */ | ||
3775 | // priv->ieee80211->hw_wep=0; | ||
3776 | } | 3186 | } |
3777 | 3187 | ||
3778 | |||
3779 | void rtl8180_set_hw_wep(struct net_device *dev) | 3188 | void rtl8180_set_hw_wep(struct net_device *dev) |
3780 | { | 3189 | { |
3781 | struct r8180_priv *priv = ieee80211_priv(dev); | 3190 | struct r8180_priv *priv = ieee80211_priv(dev); |
@@ -3794,10 +3203,6 @@ void rtl8180_set_hw_wep(struct net_device *dev) | |||
3794 | write_nic_dword(dev,KEY0+4+4,(priv->key0[2])); | 3203 | write_nic_dword(dev,KEY0+4+4,(priv->key0[2])); |
3795 | write_nic_dword(dev,KEY0+4+4+4,(key0_word4)); | 3204 | write_nic_dword(dev,KEY0+4+4+4,(key0_word4)); |
3796 | 3205 | ||
3797 | /* | ||
3798 | TX_CONF,read_nic_dword(dev,TX_CONF) &~(1<<TX_NOICV_SHIFT)); | ||
3799 | */ | ||
3800 | |||
3801 | security = read_nic_byte(dev,SECURITY); | 3206 | security = read_nic_byte(dev,SECURITY); |
3802 | security |= (1<<SECURITY_WEP_TX_ENABLE_SHIFT); | 3207 | security |= (1<<SECURITY_WEP_TX_ENABLE_SHIFT); |
3803 | security |= (1<<SECURITY_WEP_RX_ENABLE_SHIFT); | 3208 | security |= (1<<SECURITY_WEP_RX_ENABLE_SHIFT); |
@@ -3809,8 +3214,6 @@ void rtl8180_set_hw_wep(struct net_device *dev) | |||
3809 | DMESG("key %x %x %x %x",read_nic_dword(dev,KEY0+4+4+4), | 3214 | DMESG("key %x %x %x %x",read_nic_dword(dev,KEY0+4+4+4), |
3810 | read_nic_dword(dev,KEY0+4+4),read_nic_dword(dev,KEY0+4), | 3215 | read_nic_dword(dev,KEY0+4+4),read_nic_dword(dev,KEY0+4), |
3811 | read_nic_dword(dev,KEY0)); | 3216 | read_nic_dword(dev,KEY0)); |
3812 | |||
3813 | //priv->ieee80211->hw_wep=1; | ||
3814 | } | 3217 | } |
3815 | 3218 | ||
3816 | 3219 | ||
@@ -3819,10 +3222,8 @@ void rtl8185_rf_pins_enable(struct net_device *dev) | |||
3819 | // u16 tmp; | 3222 | // u16 tmp; |
3820 | // tmp = read_nic_word(dev, RFPinsEnable); | 3223 | // tmp = read_nic_word(dev, RFPinsEnable); |
3821 | write_nic_word(dev, RFPinsEnable, 0x1fff);// | tmp); | 3224 | write_nic_word(dev, RFPinsEnable, 0x1fff);// | tmp); |
3822 | // write_nic_word(dev, RFPinsEnable,7 | tmp); | ||
3823 | } | 3225 | } |
3824 | 3226 | ||
3825 | |||
3826 | void rtl8185_set_anaparam2(struct net_device *dev, u32 a) | 3227 | void rtl8185_set_anaparam2(struct net_device *dev, u32 a) |
3827 | { | 3228 | { |
3828 | u8 conf3; | 3229 | u8 conf3; |
@@ -3836,10 +3237,8 @@ void rtl8185_set_anaparam2(struct net_device *dev, u32 a) | |||
3836 | conf3 = read_nic_byte(dev, CONFIG3); | 3237 | conf3 = read_nic_byte(dev, CONFIG3); |
3837 | write_nic_byte(dev, CONFIG3, conf3 &~(1<<CONFIG3_ANAPARAM_W_SHIFT)); | 3238 | write_nic_byte(dev, CONFIG3, conf3 &~(1<<CONFIG3_ANAPARAM_W_SHIFT)); |
3838 | rtl8180_set_mode(dev, EPROM_CMD_NORMAL); | 3239 | rtl8180_set_mode(dev, EPROM_CMD_NORMAL); |
3839 | |||
3840 | } | 3240 | } |
3841 | 3241 | ||
3842 | |||
3843 | void rtl8180_set_anaparam(struct net_device *dev, u32 a) | 3242 | void rtl8180_set_anaparam(struct net_device *dev, u32 a) |
3844 | { | 3243 | { |
3845 | u8 conf3; | 3244 | u8 conf3; |
@@ -3855,7 +3254,6 @@ void rtl8180_set_anaparam(struct net_device *dev, u32 a) | |||
3855 | rtl8180_set_mode(dev, EPROM_CMD_NORMAL); | 3254 | rtl8180_set_mode(dev, EPROM_CMD_NORMAL); |
3856 | } | 3255 | } |
3857 | 3256 | ||
3858 | |||
3859 | void rtl8185_tx_antenna(struct net_device *dev, u8 ant) | 3257 | void rtl8185_tx_antenna(struct net_device *dev, u8 ant) |
3860 | { | 3258 | { |
3861 | write_nic_byte(dev, TX_ANTENNA, ant); | 3259 | write_nic_byte(dev, TX_ANTENNA, ant); |
@@ -3863,12 +3261,9 @@ void rtl8185_tx_antenna(struct net_device *dev, u8 ant) | |||
3863 | mdelay(1); | 3261 | mdelay(1); |
3864 | } | 3262 | } |
3865 | 3263 | ||
3866 | |||
3867 | void rtl8185_write_phy(struct net_device *dev, u8 adr, u32 data) | 3264 | void rtl8185_write_phy(struct net_device *dev, u8 adr, u32 data) |
3868 | { | 3265 | { |
3869 | //u8 phyr; | ||
3870 | u32 phyw; | 3266 | u32 phyw; |
3871 | //int i; | ||
3872 | 3267 | ||
3873 | adr |= 0x80; | 3268 | adr |= 0x80; |
3874 | 3269 | ||
@@ -3886,21 +3281,18 @@ void rtl8185_write_phy(struct net_device *dev, u8 adr, u32 data) | |||
3886 | //if(phyr != (data&0xff)) DMESGW("Phy write timeout %x %x %x", phyr, data,adr); | 3281 | //if(phyr != (data&0xff)) DMESGW("Phy write timeout %x %x %x", phyr, data,adr); |
3887 | } | 3282 | } |
3888 | 3283 | ||
3889 | |||
3890 | inline void write_phy_ofdm (struct net_device *dev, u8 adr, u32 data) | 3284 | inline void write_phy_ofdm (struct net_device *dev, u8 adr, u32 data) |
3891 | { | 3285 | { |
3892 | data = data & 0xff; | 3286 | data = data & 0xff; |
3893 | rtl8185_write_phy(dev, adr, data); | 3287 | rtl8185_write_phy(dev, adr, data); |
3894 | } | 3288 | } |
3895 | 3289 | ||
3896 | |||
3897 | void write_phy_cck (struct net_device *dev, u8 adr, u32 data) | 3290 | void write_phy_cck (struct net_device *dev, u8 adr, u32 data) |
3898 | { | 3291 | { |
3899 | data = data & 0xff; | 3292 | data = data & 0xff; |
3900 | rtl8185_write_phy(dev, adr, data | 0x10000); | 3293 | rtl8185_write_phy(dev, adr, data | 0x10000); |
3901 | } | 3294 | } |
3902 | 3295 | ||
3903 | |||
3904 | /* 70*3 = 210 ms | 3296 | /* 70*3 = 210 ms |
3905 | * I hope this is enougth | 3297 | * I hope this is enougth |
3906 | */ | 3298 | */ |
@@ -3944,55 +3336,32 @@ void rtl8185_set_rate(struct net_device *dev) | |||
3944 | u16 word; | 3336 | u16 word; |
3945 | int basic_rate,min_rr_rate,max_rr_rate; | 3337 | int basic_rate,min_rr_rate,max_rr_rate; |
3946 | 3338 | ||
3947 | // struct r8180_priv *priv = ieee80211_priv(dev); | ||
3948 | |||
3949 | //if (ieee80211_is_54g(priv->ieee80211->current_network) && | ||
3950 | // priv->ieee80211->state == IEEE80211_LINKED){ | ||
3951 | basic_rate = ieeerate2rtlrate(240); | 3339 | basic_rate = ieeerate2rtlrate(240); |
3952 | min_rr_rate = ieeerate2rtlrate(60); | 3340 | min_rr_rate = ieeerate2rtlrate(60); |
3953 | max_rr_rate = ieeerate2rtlrate(240); | 3341 | max_rr_rate = ieeerate2rtlrate(240); |
3954 | 3342 | ||
3955 | // | ||
3956 | // }else{ | ||
3957 | // basic_rate = ieeerate2rtlrate(20); | ||
3958 | // min_rr_rate = ieeerate2rtlrate(10); | ||
3959 | // max_rr_rate = ieeerate2rtlrate(110); | ||
3960 | // } | ||
3961 | |||
3962 | write_nic_byte(dev, RESP_RATE, | 3343 | write_nic_byte(dev, RESP_RATE, |
3963 | max_rr_rate<<MAX_RESP_RATE_SHIFT| min_rr_rate<<MIN_RESP_RATE_SHIFT); | 3344 | max_rr_rate<<MAX_RESP_RATE_SHIFT| min_rr_rate<<MIN_RESP_RATE_SHIFT); |
3964 | 3345 | ||
3965 | word = read_nic_word(dev, BRSR); | 3346 | word = read_nic_word(dev, BRSR); |
3966 | word &= ~BRSR_MBR_8185; | 3347 | word &= ~BRSR_MBR_8185; |
3967 | 3348 | ||
3968 | |||
3969 | for(i=0;i<=basic_rate;i++) | 3349 | for(i=0;i<=basic_rate;i++) |
3970 | word |= (1<<i); | 3350 | word |= (1<<i); |
3971 | 3351 | ||
3972 | write_nic_word(dev, BRSR, word); | 3352 | write_nic_word(dev, BRSR, word); |
3973 | //DMESG("RR:%x BRSR: %x", read_nic_byte(dev,RESP_RATE),read_nic_word(dev,BRSR)); | ||
3974 | } | 3353 | } |
3975 | 3354 | ||
3976 | |||
3977 | |||
3978 | void rtl8180_adapter_start(struct net_device *dev) | 3355 | void rtl8180_adapter_start(struct net_device *dev) |
3979 | { | 3356 | { |
3980 | struct r8180_priv *priv = ieee80211_priv(dev); | 3357 | struct r8180_priv *priv = ieee80211_priv(dev); |
3981 | u32 anaparam; | 3358 | u32 anaparam; |
3982 | u16 word; | 3359 | u16 word; |
3983 | u8 config3; | 3360 | u8 config3; |
3984 | // int i; | ||
3985 | 3361 | ||
3986 | rtl8180_rtx_disable(dev); | 3362 | rtl8180_rtx_disable(dev); |
3987 | rtl8180_reset(dev); | 3363 | rtl8180_reset(dev); |
3988 | 3364 | ||
3989 | /* seems that 0xffff or 0xafff will cause | ||
3990 | * HW interrupt line crash | ||
3991 | */ | ||
3992 | |||
3993 | //priv->irq_mask = 0xafff; | ||
3994 | // priv->irq_mask = 0x4fcf; | ||
3995 | |||
3996 | /* enable beacon timeout, beacon TX ok and err | 3365 | /* enable beacon timeout, beacon TX ok and err |
3997 | * LP tx ok and err, HP TX ok and err, NP TX ok and err, | 3366 | * LP tx ok and err, HP TX ok and err, NP TX ok and err, |
3998 | * RX ok and ERR, and GP timer */ | 3367 | * RX ok and ERR, and GP timer */ |
@@ -4024,8 +3393,6 @@ void rtl8180_adapter_start(struct net_device *dev) | |||
4024 | /* These might be unnecessary since we do in rx_enable / tx_enable */ | 3393 | /* These might be unnecessary since we do in rx_enable / tx_enable */ |
4025 | fix_rx_fifo(dev); | 3394 | fix_rx_fifo(dev); |
4026 | fix_tx_fifo(dev); | 3395 | fix_tx_fifo(dev); |
4027 | /*set_nic_rxring(dev); | ||
4028 | set_nic_txring(dev);*/ | ||
4029 | 3396 | ||
4030 | rtl8180_set_mode(dev, EPROM_CMD_CONFIG); | 3397 | rtl8180_set_mode(dev, EPROM_CMD_CONFIG); |
4031 | 3398 | ||
@@ -4060,7 +3427,6 @@ void rtl8180_adapter_start(struct net_device *dev) | |||
4060 | write_nic_byte(dev, CONFIG5, | 3427 | write_nic_byte(dev, CONFIG5, |
4061 | read_nic_byte(dev, CONFIG5) &~ (1<<AGCRESET_SHIFT)); | 3428 | read_nic_byte(dev, CONFIG5) &~ (1<<AGCRESET_SHIFT)); |
4062 | }else{ | 3429 | }else{ |
4063 | |||
4064 | write_nic_byte(dev, WPA_CONFIG, 0); | 3430 | write_nic_byte(dev, WPA_CONFIG, 0); |
4065 | //write_nic_byte(dev, TESTR, 0xd); | 3431 | //write_nic_byte(dev, TESTR, 0xd); |
4066 | } | 3432 | } |
@@ -4070,28 +3436,23 @@ void rtl8180_adapter_start(struct net_device *dev) | |||
4070 | if(priv->card_8185){ | 3436 | if(priv->card_8185){ |
4071 | rtl8185_set_rate(dev); | 3437 | rtl8185_set_rate(dev); |
4072 | write_nic_byte(dev, RATE_FALLBACK, 0x81); | 3438 | write_nic_byte(dev, RATE_FALLBACK, 0x81); |
4073 | // write_nic_byte(dev, 0xdf, 0x15); | ||
4074 | }else{ | 3439 | }else{ |
4075 | word = read_nic_word(dev, BRSR); | 3440 | word = read_nic_word(dev, BRSR); |
4076 | word &= ~BRSR_MBR; | 3441 | word &= ~BRSR_MBR; |
4077 | word &= ~BRSR_BPLCP; | 3442 | word &= ~BRSR_BPLCP; |
4078 | word |= ieeerate2rtlrate(priv->ieee80211->basic_rate); | 3443 | word |= ieeerate2rtlrate(priv->ieee80211->basic_rate); |
4079 | //by amy | 3444 | word |= 0x0f; |
4080 | word |= 0x0f; | ||
4081 | //by amy | ||
4082 | write_nic_word(dev, BRSR, word); | 3445 | write_nic_word(dev, BRSR, word); |
4083 | } | 3446 | } |
4084 | 3447 | ||
4085 | |||
4086 | if(priv->card_8185){ | 3448 | if(priv->card_8185){ |
4087 | write_nic_byte(dev, GP_ENABLE,read_nic_byte(dev, GP_ENABLE) & ~(1<<6)); | 3449 | write_nic_byte(dev, GP_ENABLE,read_nic_byte(dev, GP_ENABLE) & ~(1<<6)); |
4088 | 3450 | ||
4089 | //FIXME cfg 3 ClkRun enable - isn't it ReadOnly ? | 3451 | //FIXME cfg 3 ClkRun enable - isn't it ReadOnly ? |
4090 | rtl8180_set_mode(dev, EPROM_CMD_CONFIG); | 3452 | rtl8180_set_mode(dev, EPROM_CMD_CONFIG); |
4091 | write_nic_byte(dev,CONFIG3, read_nic_byte(dev, CONFIG3) | 3453 | write_nic_byte(dev,CONFIG3, read_nic_byte(dev, CONFIG3) |
4092 | |(1<<CONFIG3_CLKRUN_SHIFT)); | 3454 | | (1 << CONFIG3_CLKRUN_SHIFT)); |
4093 | rtl8180_set_mode(dev, EPROM_CMD_NORMAL); | 3455 | rtl8180_set_mode(dev, EPROM_CMD_NORMAL); |
4094 | |||
4095 | } | 3456 | } |
4096 | 3457 | ||
4097 | priv->rf_init(dev); | 3458 | priv->rf_init(dev); |
@@ -4101,39 +3462,23 @@ void rtl8180_adapter_start(struct net_device *dev) | |||
4101 | rtl8180_irq_enable(dev); | 3462 | rtl8180_irq_enable(dev); |
4102 | 3463 | ||
4103 | netif_start_queue(dev); | 3464 | netif_start_queue(dev); |
4104 | /*DMESG ("lfree %d",get_curr_tx_free_desc(dev,LOW_PRIORITY)); | ||
4105 | |||
4106 | DMESG ("nfree %d",get_curr_tx_free_desc(dev,NORM_PRIORITY)); | ||
4107 | |||
4108 | DMESG ("hfree %d",get_curr_tx_free_desc(dev,HI_PRIORITY)); | ||
4109 | if(check_nic_enought_desc(dev,NORM_PRIORITY)) DMESG("NORM OK"); | ||
4110 | if(check_nic_enought_desc(dev,HI_PRIORITY)) DMESG("HI OK"); | ||
4111 | if(check_nic_enought_desc(dev,LOW_PRIORITY)) DMESG("LOW OK");*/ | ||
4112 | } | 3465 | } |
4113 | 3466 | ||
4114 | |||
4115 | |||
4116 | /* this configures registers for beacon tx and enables it via | 3467 | /* this configures registers for beacon tx and enables it via |
4117 | * rtl8180_beacon_tx_enable(). rtl8180_beacon_tx_disable() might | 3468 | * rtl8180_beacon_tx_enable(). rtl8180_beacon_tx_disable() might |
4118 | * be used to stop beacon transmission | 3469 | * be used to stop beacon transmission |
4119 | */ | 3470 | */ |
4120 | void rtl8180_start_tx_beacon(struct net_device *dev) | 3471 | void rtl8180_start_tx_beacon(struct net_device *dev) |
4121 | { | 3472 | { |
4122 | // struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | ||
4123 | u16 word; | 3473 | u16 word; |
4124 | // DMESG("ring %x %x", priv->txlpringdma,read_nic_dword(dev,TLPDA)); | ||
4125 | 3474 | ||
4126 | DMESG("Enabling beacon TX"); | 3475 | DMESG("Enabling beacon TX"); |
4127 | //write_nic_byte(dev, 0x42,0xe6);// TCR | ||
4128 | // set_nic_txring(dev); | ||
4129 | // fix_tx_fifo(dev); | ||
4130 | rtl8180_prepare_beacon(dev); | 3476 | rtl8180_prepare_beacon(dev); |
4131 | rtl8180_irq_disable(dev); | 3477 | rtl8180_irq_disable(dev); |
4132 | rtl8180_beacon_tx_enable(dev); | 3478 | rtl8180_beacon_tx_enable(dev); |
4133 | 3479 | ||
4134 | word = read_nic_word(dev, AtimWnd) &~ AtimWnd_AtimWnd; | 3480 | word = read_nic_word(dev, AtimWnd) &~ AtimWnd_AtimWnd; |
4135 | write_nic_word(dev, AtimWnd,word);// word |= | 3481 | write_nic_word(dev, AtimWnd,word);// word |= |
4136 | //priv->ieee80211->current_network.atim_window); | ||
4137 | 3482 | ||
4138 | word = read_nic_word(dev, BintrItv); | 3483 | word = read_nic_word(dev, BintrItv); |
4139 | word &= ~BintrItv_BintrItv; | 3484 | word &= ~BintrItv_BintrItv; |
@@ -4143,26 +3488,11 @@ void rtl8180_start_tx_beacon(struct net_device *dev) | |||
4143 | */ | 3488 | */ |
4144 | write_nic_word(dev, BintrItv, word); | 3489 | write_nic_word(dev, BintrItv, word); |
4145 | 3490 | ||
4146 | |||
4147 | rtl8180_set_mode(dev, EPROM_CMD_NORMAL); | 3491 | rtl8180_set_mode(dev, EPROM_CMD_NORMAL); |
4148 | 3492 | ||
4149 | // rtl8180_beacon_tx_enable(dev); | ||
4150 | rtl8185b_irq_enable(dev); | 3493 | rtl8185b_irq_enable(dev); |
4151 | /* VV !!!!!!!!!! VV*/ | ||
4152 | /* | ||
4153 | rtl8180_set_mode(dev,EPROM_CMD_CONFIG); | ||
4154 | write_nic_byte(dev,0x9d,0x00); | ||
4155 | rtl8180_set_mode(dev,EPROM_CMD_NORMAL); | ||
4156 | */ | ||
4157 | // DMESG("ring %x %x", priv->txlpringdma,read_nic_dword(dev,TLPDA)); | ||
4158 | |||
4159 | } | 3494 | } |
4160 | 3495 | ||
4161 | |||
4162 | |||
4163 | /*************************************************************************** | ||
4164 | -------------------------------NET STUFF--------------------------- | ||
4165 | ***************************************************************************/ | ||
4166 | static struct net_device_stats *rtl8180_stats(struct net_device *dev) | 3496 | static struct net_device_stats *rtl8180_stats(struct net_device *dev) |
4167 | { | 3497 | { |
4168 | struct r8180_priv *priv = ieee80211_priv(dev); | 3498 | struct r8180_priv *priv = ieee80211_priv(dev); |
@@ -4179,93 +3509,42 @@ MgntActSet_802_11_PowerSaveMode( | |||
4179 | RT_PS_MODE rtPsMode | 3509 | RT_PS_MODE rtPsMode |
4180 | ) | 3510 | ) |
4181 | { | 3511 | { |
4182 | |||
4183 | // Currently, we do not change power save mode on IBSS mode. | 3512 | // Currently, we do not change power save mode on IBSS mode. |
4184 | if(priv->ieee80211->iw_mode == IW_MODE_ADHOC) | 3513 | if(priv->ieee80211->iw_mode == IW_MODE_ADHOC) |
4185 | { | ||
4186 | return false; | 3514 | return false; |
4187 | } | ||
4188 | 3515 | ||
4189 | // | ||
4190 | // <RJ_NOTE> If we make HW to fill up the PwrMgt bit for us, | ||
4191 | // some AP will not response to our mgnt frames with PwrMgt bit set, | ||
4192 | // e.g. cannot associate the AP. | ||
4193 | // So I commented out it. 2005.02.16, by rcnjko. | ||
4194 | // | ||
4195 | // // Change device's power save mode. | ||
4196 | // Adapter->HalFunc.SetPSModeHandler( Adapter, rtPsMode ); | ||
4197 | |||
4198 | // Update power save mode configured. | ||
4199 | // priv->dot11PowerSaveMode = rtPsMode; | ||
4200 | priv->ieee80211->ps = rtPsMode; | 3516 | priv->ieee80211->ps = rtPsMode; |
4201 | // Determine ListenInterval. | ||
4202 | 3517 | ||
4203 | return true; | 3518 | return true; |
4204 | } | 3519 | } |
4205 | 3520 | ||
4206 | //================================================================================ | 3521 | void LeisurePSEnter(struct r8180_priv *priv) |
4207 | // Leisure Power Save in linked state. | ||
4208 | //================================================================================ | ||
4209 | |||
4210 | // | ||
4211 | // Description: | ||
4212 | // Enter the leisure power save mode. | ||
4213 | // | ||
4214 | void | ||
4215 | LeisurePSEnter( | ||
4216 | struct r8180_priv *priv | ||
4217 | ) | ||
4218 | { | 3522 | { |
4219 | if (priv->bLeisurePs) | 3523 | if (priv->bLeisurePs) { |
4220 | { | ||
4221 | if (priv->ieee80211->ps == IEEE80211_PS_DISABLED) | 3524 | if (priv->ieee80211->ps == IEEE80211_PS_DISABLED) |
4222 | { | ||
4223 | //printk("----Enter PS\n"); | ||
4224 | MgntActSet_802_11_PowerSaveMode(priv, IEEE80211_PS_MBCAST|IEEE80211_PS_UNICAST);//IEEE80211_PS_ENABLE | 3525 | MgntActSet_802_11_PowerSaveMode(priv, IEEE80211_PS_MBCAST|IEEE80211_PS_UNICAST);//IEEE80211_PS_ENABLE |
4225 | } | ||
4226 | } | 3526 | } |
4227 | } | 3527 | } |
4228 | 3528 | ||
4229 | 3529 | void LeisurePSLeave(struct r8180_priv *priv) | |
4230 | // | ||
4231 | // Description: | ||
4232 | // Leave the leisure power save mode. | ||
4233 | // | ||
4234 | void | ||
4235 | LeisurePSLeave( | ||
4236 | struct r8180_priv *priv | ||
4237 | ) | ||
4238 | { | 3530 | { |
4239 | if (priv->bLeisurePs) | 3531 | if (priv->bLeisurePs) { |
4240 | { | ||
4241 | if (priv->ieee80211->ps != IEEE80211_PS_DISABLED) | 3532 | if (priv->ieee80211->ps != IEEE80211_PS_DISABLED) |
4242 | { | ||
4243 | //printk("----Leave PS\n"); | ||
4244 | MgntActSet_802_11_PowerSaveMode(priv, IEEE80211_PS_DISABLED); | 3533 | MgntActSet_802_11_PowerSaveMode(priv, IEEE80211_PS_DISABLED); |
4245 | } | ||
4246 | } | 3534 | } |
4247 | } | 3535 | } |
4248 | 3536 | ||
4249 | void rtl8180_hw_wakeup_wq (struct work_struct *work) | 3537 | void rtl8180_hw_wakeup_wq (struct work_struct *work) |
4250 | { | 3538 | { |
4251 | // struct r8180_priv *priv = container_of(work, struct r8180_priv, watch_dog_wq); | ||
4252 | // struct ieee80211_device * ieee = (struct ieee80211_device*) | ||
4253 | // container_of(work, struct ieee80211_device, watch_dog_wq); | ||
4254 | struct delayed_work *dwork = to_delayed_work(work); | 3539 | struct delayed_work *dwork = to_delayed_work(work); |
4255 | struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,hw_wakeup_wq); | 3540 | struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,hw_wakeup_wq); |
4256 | struct net_device *dev = ieee->dev; | 3541 | struct net_device *dev = ieee->dev; |
4257 | 3542 | ||
4258 | // printk("dev is %d\n",dev); | ||
4259 | // printk("&*&(^*(&(&=========>%s()\n", __func__); | ||
4260 | rtl8180_hw_wakeup(dev); | 3543 | rtl8180_hw_wakeup(dev); |
4261 | |||
4262 | } | 3544 | } |
4263 | 3545 | ||
4264 | void rtl8180_hw_sleep_wq (struct work_struct *work) | 3546 | void rtl8180_hw_sleep_wq (struct work_struct *work) |
4265 | { | 3547 | { |
4266 | // struct r8180_priv *priv = container_of(work, struct r8180_priv, watch_dog_wq); | ||
4267 | // struct ieee80211_device * ieee = (struct ieee80211_device*) | ||
4268 | // container_of(work, struct ieee80211_device, watch_dog_wq); | ||
4269 | struct delayed_work *dwork = to_delayed_work(work); | 3548 | struct delayed_work *dwork = to_delayed_work(work); |
4270 | struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,hw_sleep_wq); | 3549 | struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,hw_sleep_wq); |
4271 | struct net_device *dev = ieee->dev; | 3550 | struct net_device *dev = ieee->dev; |
@@ -4273,7 +3552,6 @@ void rtl8180_hw_sleep_wq (struct work_struct *work) | |||
4273 | rtl8180_hw_sleep_down(dev); | 3552 | rtl8180_hw_sleep_down(dev); |
4274 | } | 3553 | } |
4275 | 3554 | ||
4276 | //YJ,add,080828,for KeepAlive | ||
4277 | static void MgntLinkKeepAlive(struct r8180_priv *priv ) | 3555 | static void MgntLinkKeepAlive(struct r8180_priv *priv ) |
4278 | { | 3556 | { |
4279 | if (priv->keepAliveLevel == 0) | 3557 | if (priv->keepAliveLevel == 0) |
@@ -4284,7 +3562,6 @@ static void MgntLinkKeepAlive(struct r8180_priv *priv ) | |||
4284 | // | 3562 | // |
4285 | // Keep-Alive. | 3563 | // Keep-Alive. |
4286 | // | 3564 | // |
4287 | //printk("LastTx:%d Tx:%d LastRx:%d Rx:%ld Idle:%d\n",priv->link_detect.LastNumTxUnicast,priv->NumTxUnicast, priv->link_detect.LastNumRxUnicast, priv->ieee80211->NumRxUnicast, priv->link_detect.IdleCount); | ||
4288 | 3565 | ||
4289 | if ( (priv->keepAliveLevel== 2) || | 3566 | if ( (priv->keepAliveLevel== 2) || |
4290 | (priv->link_detect.LastNumTxUnicast == priv->NumTxUnicast && | 3567 | (priv->link_detect.LastNumTxUnicast == priv->NumTxUnicast && |
@@ -4310,9 +3587,9 @@ static void MgntLinkKeepAlive(struct r8180_priv *priv ) | |||
4310 | priv->link_detect.LastNumRxUnicast = priv->ieee80211->NumRxUnicast; | 3587 | priv->link_detect.LastNumRxUnicast = priv->ieee80211->NumRxUnicast; |
4311 | } | 3588 | } |
4312 | } | 3589 | } |
4313 | //YJ,add,080828,for KeepAlive,end | ||
4314 | 3590 | ||
4315 | static u8 read_acadapter_file(char *filename); | 3591 | static u8 read_acadapter_file(char *filename); |
3592 | |||
4316 | void rtl8180_watch_dog(struct net_device *dev) | 3593 | void rtl8180_watch_dog(struct net_device *dev) |
4317 | { | 3594 | { |
4318 | struct r8180_priv *priv = ieee80211_priv(dev); | 3595 | struct r8180_priv *priv = ieee80211_priv(dev); |
@@ -4334,7 +3611,7 @@ void rtl8180_watch_dog(struct net_device *dev) | |||
4334 | priv->link_detect.RxFrameNum[SlotIndex] = priv->ieee80211->NumRxDataInPeriod + priv->ieee80211->NumRxBcnInPeriod; | 3611 | priv->link_detect.RxFrameNum[SlotIndex] = priv->ieee80211->NumRxDataInPeriod + priv->ieee80211->NumRxBcnInPeriod; |
4335 | for( i=0; i<priv->link_detect.SlotNum; i++ ) | 3612 | for( i=0; i<priv->link_detect.SlotNum; i++ ) |
4336 | TotalRxNum+= priv->link_detect.RxFrameNum[i]; | 3613 | TotalRxNum+= priv->link_detect.RxFrameNum[i]; |
4337 | //printk("&&&&&=== TotalRxNum = %d\n", TotalRxNum); | 3614 | |
4338 | if(TotalRxNum == 0){ | 3615 | if(TotalRxNum == 0){ |
4339 | priv->ieee80211->state = IEEE80211_ASSOCIATING; | 3616 | priv->ieee80211->state = IEEE80211_ASSOCIATING; |
4340 | queue_work(priv->ieee80211->wq, &priv->ieee80211->associate_procedure_wq); | 3617 | queue_work(priv->ieee80211->wq, &priv->ieee80211->associate_procedure_wq); |
@@ -4346,22 +3623,13 @@ void rtl8180_watch_dog(struct net_device *dev) | |||
4346 | 3623 | ||
4347 | //YJ,add,080828,for LPS | 3624 | //YJ,add,080828,for LPS |
4348 | #ifdef ENABLE_LPS | 3625 | #ifdef ENABLE_LPS |
4349 | if(priv->PowerProfile == POWER_PROFILE_BATTERY ) | 3626 | if (priv->PowerProfile == POWER_PROFILE_BATTERY) |
4350 | { | ||
4351 | //Turn on LeisurePS on battery power | ||
4352 | //printk("!!!!!On battery power\n"); | ||
4353 | priv->bLeisurePs = true; | 3627 | priv->bLeisurePs = true; |
4354 | } | 3628 | else if (priv->PowerProfile == POWER_PROFILE_AC) { |
4355 | else if(priv->PowerProfile == POWER_PROFILE_AC ) | ||
4356 | { | ||
4357 | // Turn off LeisurePS on AC power | ||
4358 | //printk("----On AC power\n"); | ||
4359 | LeisurePSLeave(priv); | 3629 | LeisurePSLeave(priv); |
4360 | priv->bLeisurePs= false; | 3630 | priv->bLeisurePs= false; |
4361 | } | 3631 | } |
4362 | #endif | ||
4363 | 3632 | ||
4364 | #ifdef ENABLE_LPS | ||
4365 | if(priv->ieee80211->state == IEEE80211_LINKED){ | 3633 | if(priv->ieee80211->state == IEEE80211_LINKED){ |
4366 | priv->link_detect.NumRxOkInPeriod = priv->ieee80211->NumRxDataInPeriod; | 3634 | priv->link_detect.NumRxOkInPeriod = priv->ieee80211->NumRxDataInPeriod; |
4367 | //printk("TxOk=%d RxOk=%d\n", priv->link_detect.NumTxOkInPeriod, priv->link_detect.NumRxOkInPeriod); | 3635 | //printk("TxOk=%d RxOk=%d\n", priv->link_detect.NumTxOkInPeriod, priv->link_detect.NumRxOkInPeriod); |
@@ -4372,21 +3640,15 @@ void rtl8180_watch_dog(struct net_device *dev) | |||
4372 | if(((priv->link_detect.NumRxOkInPeriod + priv->link_detect.NumTxOkInPeriod) > 8) | 3640 | if(((priv->link_detect.NumRxOkInPeriod + priv->link_detect.NumTxOkInPeriod) > 8) |
4373 | || (priv->link_detect.NumRxOkInPeriod > 2)) { | 3641 | || (priv->link_detect.NumRxOkInPeriod > 2)) { |
4374 | bEnterPS= false; | 3642 | bEnterPS= false; |
4375 | } | 3643 | } else |
4376 | else { | ||
4377 | bEnterPS= true; | 3644 | bEnterPS= true; |
4378 | } | ||
4379 | 3645 | ||
4380 | if(bEnterPS) { | 3646 | if (bEnterPS) |
4381 | LeisurePSEnter(priv); | 3647 | LeisurePSEnter(priv); |
4382 | } | 3648 | else |
4383 | else { | ||
4384 | LeisurePSLeave(priv); | 3649 | LeisurePSLeave(priv); |
4385 | } | 3650 | } else |
4386 | } | ||
4387 | else{ | ||
4388 | LeisurePSLeave(priv); | 3651 | LeisurePSLeave(priv); |
4389 | } | ||
4390 | #endif | 3652 | #endif |
4391 | priv->link_detect.bBusyTraffic = bBusyTraffic; | 3653 | priv->link_detect.bBusyTraffic = bBusyTraffic; |
4392 | priv->link_detect.NumRxOkInPeriod = 0; | 3654 | priv->link_detect.NumRxOkInPeriod = 0; |
@@ -4394,10 +3656,10 @@ void rtl8180_watch_dog(struct net_device *dev) | |||
4394 | priv->ieee80211->NumRxDataInPeriod = 0; | 3656 | priv->ieee80211->NumRxDataInPeriod = 0; |
4395 | priv->ieee80211->NumRxBcnInPeriod = 0; | 3657 | priv->ieee80211->NumRxBcnInPeriod = 0; |
4396 | } | 3658 | } |
3659 | |||
4397 | int _rtl8180_up(struct net_device *dev) | 3660 | int _rtl8180_up(struct net_device *dev) |
4398 | { | 3661 | { |
4399 | struct r8180_priv *priv = ieee80211_priv(dev); | 3662 | struct r8180_priv *priv = ieee80211_priv(dev); |
4400 | //int i; | ||
4401 | 3663 | ||
4402 | priv->up=1; | 3664 | priv->up=1; |
4403 | 3665 | ||
@@ -4411,28 +3673,19 @@ int _rtl8180_up(struct net_device *dev) | |||
4411 | IPSLeave(dev); | 3673 | IPSLeave(dev); |
4412 | } | 3674 | } |
4413 | #endif | 3675 | #endif |
4414 | //by amy 080312 | ||
4415 | #ifdef RATE_ADAPT | 3676 | #ifdef RATE_ADAPT |
4416 | timer_rate_adaptive((unsigned long)dev); | 3677 | timer_rate_adaptive((unsigned long)dev); |
4417 | #endif | 3678 | #endif |
4418 | //by amy 080312 | ||
4419 | watch_dog_adaptive((unsigned long)dev); | 3679 | watch_dog_adaptive((unsigned long)dev); |
4420 | #ifdef SW_ANTE | 3680 | #ifdef SW_ANTE |
4421 | if(priv->bSwAntennaDiverity) | 3681 | if(priv->bSwAntennaDiverity) |
4422 | SwAntennaDiversityTimerCallback(dev); | 3682 | SwAntennaDiversityTimerCallback(dev); |
4423 | #endif | 3683 | #endif |
4424 | // IPSEnter(dev); | ||
4425 | ieee80211_softmac_start_protocol(priv->ieee80211); | 3684 | ieee80211_softmac_start_protocol(priv->ieee80211); |
4426 | 3685 | ||
4427 | //Add for RF power on power off by lizhaoming 080512 | ||
4428 | // priv->eRFPowerState = eRfOn; | ||
4429 | // printk("\n--------Start queue_work:GPIOChangeRFWorkItem"); | ||
4430 | // queue_delayed_work(priv->ieee80211->wq,&priv->ieee80211->GPIOChangeRFWorkItem,1000); | ||
4431 | |||
4432 | return 0; | 3686 | return 0; |
4433 | } | 3687 | } |
4434 | 3688 | ||
4435 | |||
4436 | int rtl8180_open(struct net_device *dev) | 3689 | int rtl8180_open(struct net_device *dev) |
4437 | { | 3690 | { |
4438 | struct r8180_priv *priv = ieee80211_priv(dev); | 3691 | struct r8180_priv *priv = ieee80211_priv(dev); |
@@ -4442,10 +3695,8 @@ int rtl8180_open(struct net_device *dev) | |||
4442 | ret = rtl8180_up(dev); | 3695 | ret = rtl8180_up(dev); |
4443 | up(&priv->wx_sem); | 3696 | up(&priv->wx_sem); |
4444 | return ret; | 3697 | return ret; |
4445 | |||
4446 | } | 3698 | } |
4447 | 3699 | ||
4448 | |||
4449 | int rtl8180_up(struct net_device *dev) | 3700 | int rtl8180_up(struct net_device *dev) |
4450 | { | 3701 | { |
4451 | struct r8180_priv *priv = ieee80211_priv(dev); | 3702 | struct r8180_priv *priv = ieee80211_priv(dev); |
@@ -4455,7 +3706,6 @@ int rtl8180_up(struct net_device *dev) | |||
4455 | return _rtl8180_up(dev); | 3706 | return _rtl8180_up(dev); |
4456 | } | 3707 | } |
4457 | 3708 | ||
4458 | |||
4459 | int rtl8180_close(struct net_device *dev) | 3709 | int rtl8180_close(struct net_device *dev) |
4460 | { | 3710 | { |
4461 | struct r8180_priv *priv = ieee80211_priv(dev); | 3711 | struct r8180_priv *priv = ieee80211_priv(dev); |
@@ -4466,14 +3716,14 @@ int rtl8180_close(struct net_device *dev) | |||
4466 | up(&priv->wx_sem); | 3716 | up(&priv->wx_sem); |
4467 | 3717 | ||
4468 | return ret; | 3718 | return ret; |
4469 | |||
4470 | } | 3719 | } |
4471 | 3720 | ||
4472 | int rtl8180_down(struct net_device *dev) | 3721 | int rtl8180_down(struct net_device *dev) |
4473 | { | 3722 | { |
4474 | struct r8180_priv *priv = ieee80211_priv(dev); | 3723 | struct r8180_priv *priv = ieee80211_priv(dev); |
4475 | 3724 | ||
4476 | if (priv->up == 0) return -1; | 3725 | if (priv->up == 0) |
3726 | return -1; | ||
4477 | 3727 | ||
4478 | priv->up=0; | 3728 | priv->up=0; |
4479 | 3729 | ||
@@ -4484,18 +3734,14 @@ int rtl8180_down(struct net_device *dev) | |||
4484 | rtl8180_rtx_disable(dev); | 3734 | rtl8180_rtx_disable(dev); |
4485 | rtl8180_irq_disable(dev); | 3735 | rtl8180_irq_disable(dev); |
4486 | del_timer_sync(&priv->watch_dog_timer); | 3736 | del_timer_sync(&priv->watch_dog_timer); |
4487 | //cancel_delayed_work(&priv->ieee80211->watch_dog_wq); | 3737 | del_timer_sync(&priv->rateadapter_timer); |
4488 | //{by amy 080312 | 3738 | cancel_delayed_work(&priv->ieee80211->rate_adapter_wq); |
4489 | del_timer_sync(&priv->rateadapter_timer); | ||
4490 | cancel_delayed_work(&priv->ieee80211->rate_adapter_wq); | ||
4491 | //by amy 080312} | ||
4492 | cancel_delayed_work(&priv->ieee80211->hw_wakeup_wq); | 3739 | cancel_delayed_work(&priv->ieee80211->hw_wakeup_wq); |
4493 | cancel_delayed_work(&priv->ieee80211->hw_sleep_wq); | 3740 | cancel_delayed_work(&priv->ieee80211->hw_sleep_wq); |
4494 | cancel_delayed_work(&priv->ieee80211->hw_dig_wq); | 3741 | cancel_delayed_work(&priv->ieee80211->hw_dig_wq); |
4495 | cancel_delayed_work(&priv->ieee80211->tx_pw_wq); | 3742 | cancel_delayed_work(&priv->ieee80211->tx_pw_wq); |
4496 | del_timer_sync(&priv->SwAntennaDiversityTimer); | 3743 | del_timer_sync(&priv->SwAntennaDiversityTimer); |
4497 | SetZebraRFPowerState8185(dev,eRfOff); | 3744 | SetZebraRFPowerState8185(dev,eRfOff); |
4498 | //ieee80211_softmac_stop_protocol(priv->ieee80211); | ||
4499 | memset(&(priv->ieee80211->current_network),0,sizeof(struct ieee80211_network)); | 3745 | memset(&(priv->ieee80211->current_network),0,sizeof(struct ieee80211_network)); |
4500 | priv->ieee80211->state = IEEE80211_NOLINK; | 3746 | priv->ieee80211->state = IEEE80211_NOLINK; |
4501 | return 0; | 3747 | return 0; |
@@ -4516,26 +3762,20 @@ void rtl8180_restart_wq(struct work_struct *work) | |||
4516 | void rtl8180_restart(struct net_device *dev) | 3762 | void rtl8180_restart(struct net_device *dev) |
4517 | { | 3763 | { |
4518 | struct r8180_priv *priv = ieee80211_priv(dev); | 3764 | struct r8180_priv *priv = ieee80211_priv(dev); |
4519 | //rtl8180_commit(dev); | 3765 | |
4520 | schedule_work(&priv->reset_wq); | 3766 | schedule_work(&priv->reset_wq); |
4521 | //DMESG("TXTIMEOUT"); | ||
4522 | } | 3767 | } |
4523 | 3768 | ||
4524 | |||
4525 | void rtl8180_commit(struct net_device *dev) | 3769 | void rtl8180_commit(struct net_device *dev) |
4526 | { | 3770 | { |
4527 | struct r8180_priv *priv = ieee80211_priv(dev); | 3771 | struct r8180_priv *priv = ieee80211_priv(dev); |
4528 | 3772 | ||
4529 | if (priv->up == 0) return ; | 3773 | if (priv->up == 0) |
4530 | //+by amy 080312 | 3774 | return ; |
3775 | |||
4531 | del_timer_sync(&priv->watch_dog_timer); | 3776 | del_timer_sync(&priv->watch_dog_timer); |
4532 | //cancel_delayed_work(&priv->ieee80211->watch_dog_wq); | 3777 | del_timer_sync(&priv->rateadapter_timer); |
4533 | //{by amy 080312 | 3778 | cancel_delayed_work(&priv->ieee80211->rate_adapter_wq); |
4534 | //by amy for rate adaptive | ||
4535 | del_timer_sync(&priv->rateadapter_timer); | ||
4536 | cancel_delayed_work(&priv->ieee80211->rate_adapter_wq); | ||
4537 | //by amy for rate adaptive | ||
4538 | //by amy 080312} | ||
4539 | cancel_delayed_work(&priv->ieee80211->hw_wakeup_wq); | 3779 | cancel_delayed_work(&priv->ieee80211->hw_wakeup_wq); |
4540 | cancel_delayed_work(&priv->ieee80211->hw_sleep_wq); | 3780 | cancel_delayed_work(&priv->ieee80211->hw_sleep_wq); |
4541 | cancel_delayed_work(&priv->ieee80211->hw_dig_wq); | 3781 | cancel_delayed_work(&priv->ieee80211->hw_dig_wq); |
@@ -4547,22 +3787,17 @@ void rtl8180_commit(struct net_device *dev) | |||
4547 | _rtl8180_up(dev); | 3787 | _rtl8180_up(dev); |
4548 | } | 3788 | } |
4549 | 3789 | ||
4550 | |||
4551 | static void r8180_set_multicast(struct net_device *dev) | 3790 | static void r8180_set_multicast(struct net_device *dev) |
4552 | { | 3791 | { |
4553 | struct r8180_priv *priv = ieee80211_priv(dev); | 3792 | struct r8180_priv *priv = ieee80211_priv(dev); |
4554 | short promisc; | 3793 | short promisc; |
4555 | 3794 | ||
4556 | //down(&priv->wx_sem); | ||
4557 | |||
4558 | promisc = (dev->flags & IFF_PROMISC) ? 1:0; | 3795 | promisc = (dev->flags & IFF_PROMISC) ? 1:0; |
4559 | 3796 | ||
4560 | if (promisc != priv->promisc) | 3797 | if (promisc != priv->promisc) |
4561 | rtl8180_restart(dev); | 3798 | rtl8180_restart(dev); |
4562 | 3799 | ||
4563 | priv->promisc = promisc; | 3800 | priv->promisc = promisc; |
4564 | |||
4565 | //up(&priv->wx_sem); | ||
4566 | } | 3801 | } |
4567 | 3802 | ||
4568 | int r8180_set_mac_adr(struct net_device *dev, void *mac) | 3803 | int r8180_set_mac_adr(struct net_device *dev, void *mac) |
@@ -4591,27 +3826,20 @@ int r8180_set_mac_adr(struct net_device *dev, void *mac) | |||
4591 | int rtl8180_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) | 3826 | int rtl8180_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) |
4592 | { | 3827 | { |
4593 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 3828 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
4594 | |||
4595 | struct iwreq *wrq = (struct iwreq *) rq; | 3829 | struct iwreq *wrq = (struct iwreq *) rq; |
4596 | int ret=-1; | 3830 | int ret=-1; |
3831 | |||
4597 | switch (cmd) { | 3832 | switch (cmd) { |
4598 | case RTL_IOCTL_WPA_SUPPLICANT: | 3833 | case RTL_IOCTL_WPA_SUPPLICANT: |
4599 | ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data); | 3834 | ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data); |
4600 | return ret; | 3835 | return ret; |
4601 | 3836 | default: | |
4602 | default: | ||
4603 | return -EOPNOTSUPP; | 3837 | return -EOPNOTSUPP; |
4604 | } | 3838 | } |
4605 | 3839 | ||
4606 | return -EOPNOTSUPP; | 3840 | return -EOPNOTSUPP; |
4607 | } | 3841 | } |
4608 | 3842 | ||
4609 | |||
4610 | |||
4611 | /**************************************************************************** | ||
4612 | -----------------------------PCI STUFF--------------------------- | ||
4613 | *****************************************************************************/ | ||
4614 | |||
4615 | static const struct net_device_ops rtl8180_netdev_ops = { | 3843 | static const struct net_device_ops rtl8180_netdev_ops = { |
4616 | .ndo_open = rtl8180_open, | 3844 | .ndo_open = rtl8180_open, |
4617 | .ndo_stop = rtl8180_close, | 3845 | .ndo_stop = rtl8180_close, |
@@ -4631,7 +3859,6 @@ static int __devinit rtl8180_pci_probe(struct pci_dev *pdev, | |||
4631 | unsigned long ioaddr = 0; | 3859 | unsigned long ioaddr = 0; |
4632 | struct net_device *dev = NULL; | 3860 | struct net_device *dev = NULL; |
4633 | struct r8180_priv *priv= NULL; | 3861 | struct r8180_priv *priv= NULL; |
4634 | //u8 *ptr; | ||
4635 | u8 unit = 0; | 3862 | u8 unit = 0; |
4636 | 3863 | ||
4637 | unsigned long pmem_start, pmem_len, pmem_flags; | 3864 | unsigned long pmem_start, pmem_len, pmem_flags; |
@@ -4644,7 +3871,6 @@ static int __devinit rtl8180_pci_probe(struct pci_dev *pdev, | |||
4644 | } | 3871 | } |
4645 | 3872 | ||
4646 | pci_set_master(pdev); | 3873 | pci_set_master(pdev); |
4647 | //pci_set_wmi(pdev); | ||
4648 | pci_set_dma_mask(pdev, 0xffffff00ULL); | 3874 | pci_set_dma_mask(pdev, 0xffffff00ULL); |
4649 | pci_set_consistent_dma_mask(pdev,0xffffff00ULL); | 3875 | pci_set_consistent_dma_mask(pdev,0xffffff00ULL); |
4650 | dev = alloc_ieee80211(sizeof(struct r8180_priv)); | 3876 | dev = alloc_ieee80211(sizeof(struct r8180_priv)); |
@@ -4657,10 +3883,7 @@ static int __devinit rtl8180_pci_probe(struct pci_dev *pdev, | |||
4657 | SET_NETDEV_DEV(dev, &pdev->dev); | 3883 | SET_NETDEV_DEV(dev, &pdev->dev); |
4658 | 3884 | ||
4659 | priv = ieee80211_priv(dev); | 3885 | priv = ieee80211_priv(dev); |
4660 | // memset(priv,0,sizeof(struct r8180_priv)); | 3886 | priv->pdev = pdev; |
4661 | priv->pdev=pdev; | ||
4662 | |||
4663 | |||
4664 | 3887 | ||
4665 | pmem_start = pci_resource_start(pdev, 1); | 3888 | pmem_start = pci_resource_start(pdev, 1); |
4666 | pmem_len = pci_resource_len(pdev, 1); | 3889 | pmem_len = pci_resource_len(pdev, 1); |
@@ -4671,26 +3894,20 @@ static int __devinit rtl8180_pci_probe(struct pci_dev *pdev, | |||
4671 | goto fail; | 3894 | goto fail; |
4672 | } | 3895 | } |
4673 | 3896 | ||
4674 | //DMESG("Memory mapped space @ 0x%08lx ", pmem_start); | ||
4675 | if( ! request_mem_region(pmem_start, pmem_len, RTL8180_MODULE_NAME)) { | 3897 | if( ! request_mem_region(pmem_start, pmem_len, RTL8180_MODULE_NAME)) { |
4676 | DMESG("request_mem_region failed!"); | 3898 | DMESG("request_mem_region failed!"); |
4677 | goto fail; | 3899 | goto fail; |
4678 | } | 3900 | } |
4679 | 3901 | ||
4680 | |||
4681 | ioaddr = (unsigned long)ioremap_nocache( pmem_start, pmem_len); | 3902 | ioaddr = (unsigned long)ioremap_nocache( pmem_start, pmem_len); |
4682 | if( ioaddr == (unsigned long)NULL ){ | 3903 | if( ioaddr == (unsigned long)NULL ){ |
4683 | DMESG("ioremap failed!"); | 3904 | DMESG("ioremap failed!"); |
4684 | // release_mem_region( pmem_start, pmem_len ); | ||
4685 | goto fail1; | 3905 | goto fail1; |
4686 | } | 3906 | } |
4687 | 3907 | ||
4688 | dev->mem_start = ioaddr; // shared mem start | 3908 | dev->mem_start = ioaddr; // shared mem start |
4689 | dev->mem_end = ioaddr + pci_resource_len(pdev, 0); // shared mem end | 3909 | dev->mem_end = ioaddr + pci_resource_len(pdev, 0); // shared mem end |
4690 | 3910 | ||
4691 | |||
4692 | //pci_read_config_byte(pdev, 0x05, ptr); | ||
4693 | //pci_write_config_byte(pdev, 0x05, (*ptr) & (~0x04)); | ||
4694 | pci_read_config_byte(pdev, 0x05, &unit); | 3911 | pci_read_config_byte(pdev, 0x05, &unit); |
4695 | pci_write_config_byte(pdev, 0x05, unit & (~0x04)); | 3912 | pci_write_config_byte(pdev, 0x05, unit & (~0x04)); |
4696 | 3913 | ||
@@ -4706,11 +3923,9 @@ static int __devinit rtl8180_pci_probe(struct pci_dev *pdev, | |||
4706 | if (dev_alloc_name(dev, ifname) < 0){ | 3923 | if (dev_alloc_name(dev, ifname) < 0){ |
4707 | DMESG("Oops: devname already taken! Trying wlan%%d...\n"); | 3924 | DMESG("Oops: devname already taken! Trying wlan%%d...\n"); |
4708 | ifname = "wlan%d"; | 3925 | ifname = "wlan%d"; |
4709 | // ifname = "ath%d"; | ||
4710 | dev_alloc_name(dev, ifname); | 3926 | dev_alloc_name(dev, ifname); |
4711 | } | 3927 | } |
4712 | 3928 | ||
4713 | |||
4714 | if(rtl8180_init(dev)!=0){ | 3929 | if(rtl8180_init(dev)!=0){ |
4715 | DMESG("Initialization failed"); | 3930 | DMESG("Initialization failed"); |
4716 | goto fail1; | 3931 | goto fail1; |
@@ -4724,19 +3939,14 @@ static int __devinit rtl8180_pci_probe(struct pci_dev *pdev, | |||
4724 | 3939 | ||
4725 | DMESG("Driver probe completed\n"); | 3940 | DMESG("Driver probe completed\n"); |
4726 | return 0; | 3941 | return 0; |
4727 | |||
4728 | fail1: | 3942 | fail1: |
4729 | |||
4730 | if( dev->mem_start != (unsigned long)NULL ){ | 3943 | if( dev->mem_start != (unsigned long)NULL ){ |
4731 | iounmap( (void *)dev->mem_start ); | 3944 | iounmap( (void *)dev->mem_start ); |
4732 | release_mem_region( pci_resource_start(pdev, 1), | 3945 | release_mem_region( pci_resource_start(pdev, 1), |
4733 | pci_resource_len(pdev, 1) ); | 3946 | pci_resource_len(pdev, 1) ); |
4734 | } | 3947 | } |
4735 | |||
4736 | |||
4737 | fail: | 3948 | fail: |
4738 | if(dev){ | 3949 | if(dev){ |
4739 | |||
4740 | if (priv->irq) { | 3950 | if (priv->irq) { |
4741 | free_irq(dev->irq, dev); | 3951 | free_irq(dev->irq, dev); |
4742 | dev->irq=0; | 3952 | dev->irq=0; |
@@ -4749,42 +3959,32 @@ fail: | |||
4749 | DMESG("wlan driver load failed\n"); | 3959 | DMESG("wlan driver load failed\n"); |
4750 | pci_set_drvdata(pdev, NULL); | 3960 | pci_set_drvdata(pdev, NULL); |
4751 | return -ENODEV; | 3961 | return -ENODEV; |
4752 | |||
4753 | } | 3962 | } |
4754 | 3963 | ||
4755 | |||
4756 | static void __devexit rtl8180_pci_remove(struct pci_dev *pdev) | 3964 | static void __devexit rtl8180_pci_remove(struct pci_dev *pdev) |
4757 | { | 3965 | { |
4758 | struct r8180_priv *priv; | 3966 | struct r8180_priv *priv; |
4759 | struct net_device *dev = pci_get_drvdata(pdev); | 3967 | struct net_device *dev = pci_get_drvdata(pdev); |
4760 | if(dev){ | ||
4761 | 3968 | ||
3969 | if (dev) { | ||
4762 | unregister_netdev(dev); | 3970 | unregister_netdev(dev); |
4763 | 3971 | ||
4764 | priv=ieee80211_priv(dev); | 3972 | priv = ieee80211_priv(dev); |
4765 | 3973 | ||
4766 | rtl8180_proc_remove_one(dev); | 3974 | rtl8180_proc_remove_one(dev); |
4767 | rtl8180_down(dev); | 3975 | rtl8180_down(dev); |
4768 | priv->rf_close(dev); | 3976 | priv->rf_close(dev); |
4769 | rtl8180_reset(dev); | 3977 | rtl8180_reset(dev); |
4770 | //rtl8180_rtx_disable(dev); | ||
4771 | //rtl8180_irq_disable(dev); | ||
4772 | mdelay(10); | 3978 | mdelay(10); |
4773 | //write_nic_word(dev,INTA,read_nic_word(dev,INTA)); | ||
4774 | //force_pci_posting(dev); | ||
4775 | //mdelay(10); | ||
4776 | 3979 | ||
4777 | if(priv->irq){ | 3980 | if(priv->irq){ |
4778 | |||
4779 | DMESG("Freeing irq %d",dev->irq); | 3981 | DMESG("Freeing irq %d",dev->irq); |
4780 | free_irq(dev->irq, dev); | 3982 | free_irq(dev->irq, dev); |
4781 | priv->irq=0; | 3983 | priv->irq=0; |
4782 | |||
4783 | } | 3984 | } |
4784 | 3985 | ||
4785 | free_rx_desc_ring(dev); | 3986 | free_rx_desc_ring(dev); |
4786 | free_tx_desc_rings(dev); | 3987 | free_tx_desc_rings(dev); |
4787 | // free_beacon_desc_ring(dev,priv->txbeaconcount); | ||
4788 | 3988 | ||
4789 | if( dev->mem_start != (unsigned long)NULL ){ | 3989 | if( dev->mem_start != (unsigned long)NULL ){ |
4790 | iounmap( (void *)dev->mem_start ); | 3990 | iounmap( (void *)dev->mem_start ); |
@@ -4799,7 +3999,6 @@ static void __devexit rtl8180_pci_remove(struct pci_dev *pdev) | |||
4799 | DMESG("wlan driver removed\n"); | 3999 | DMESG("wlan driver removed\n"); |
4800 | } | 4000 | } |
4801 | 4001 | ||
4802 | |||
4803 | /* fun with the built-in ieee80211 stack... */ | 4002 | /* fun with the built-in ieee80211 stack... */ |
4804 | extern int ieee80211_crypto_init(void); | 4003 | extern int ieee80211_crypto_init(void); |
4805 | extern void ieee80211_crypto_deinit(void); | 4004 | extern void ieee80211_crypto_deinit(void); |
@@ -4842,17 +4041,13 @@ static int __init rtl8180_pci_module_init(void) | |||
4842 | DMESG("Wireless extensions version %d", WIRELESS_EXT); | 4041 | DMESG("Wireless extensions version %d", WIRELESS_EXT); |
4843 | rtl8180_proc_module_init(); | 4042 | rtl8180_proc_module_init(); |
4844 | 4043 | ||
4845 | if(0!=pci_register_driver(&rtl8180_pci_driver)) | 4044 | if (pci_register_driver(&rtl8180_pci_driver)) { |
4846 | //if(0!=pci_module_init(&rtl8180_pci_driver)) | ||
4847 | { | ||
4848 | DMESG("No device found"); | 4045 | DMESG("No device found"); |
4849 | /*pci_unregister_driver (&rtl8180_pci_driver);*/ | ||
4850 | return -ENODEV; | 4046 | return -ENODEV; |
4851 | } | 4047 | } |
4852 | return 0; | 4048 | return 0; |
4853 | } | 4049 | } |
4854 | 4050 | ||
4855 | |||
4856 | static void __exit rtl8180_pci_module_exit(void) | 4051 | static void __exit rtl8180_pci_module_exit(void) |
4857 | { | 4052 | { |
4858 | pci_unregister_driver (&rtl8180_pci_driver); | 4053 | pci_unregister_driver (&rtl8180_pci_driver); |
@@ -4864,7 +4059,6 @@ static void __exit rtl8180_pci_module_exit(void) | |||
4864 | DMESG("Exiting"); | 4059 | DMESG("Exiting"); |
4865 | } | 4060 | } |
4866 | 4061 | ||
4867 | |||
4868 | void rtl8180_try_wake_queue(struct net_device *dev, int pri) | 4062 | void rtl8180_try_wake_queue(struct net_device *dev, int pri) |
4869 | { | 4063 | { |
4870 | unsigned long flags; | 4064 | unsigned long flags; |
@@ -4879,25 +4073,17 @@ void rtl8180_try_wake_queue(struct net_device *dev, int pri) | |||
4879 | ieee80211_wake_queue(priv->ieee80211); | 4073 | ieee80211_wake_queue(priv->ieee80211); |
4880 | } | 4074 | } |
4881 | 4075 | ||
4882 | /***************************************************************************** | ||
4883 | -----------------------------IRQ STUFF--------------------------- | ||
4884 | ******************************************************************************/ | ||
4885 | |||
4886 | void rtl8180_tx_isr(struct net_device *dev, int pri,short error) | 4076 | void rtl8180_tx_isr(struct net_device *dev, int pri,short error) |
4887 | { | 4077 | { |
4888 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 4078 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
4889 | |||
4890 | u32 *tail; //tail virtual addr | 4079 | u32 *tail; //tail virtual addr |
4891 | u32 *head; //head virtual addr | 4080 | u32 *head; //head virtual addr |
4892 | u32 *begin;//start of ring virtual addr | 4081 | u32 *begin;//start of ring virtual addr |
4893 | u32 *nicv; //nic pointer virtual addr | 4082 | u32 *nicv; //nic pointer virtual addr |
4894 | // u32 *txdv; //packet just TXed | ||
4895 | u32 nic; //nic pointer physical addr | 4083 | u32 nic; //nic pointer physical addr |
4896 | u32 nicbegin;// start of ring physical addr | 4084 | u32 nicbegin;// start of ring physical addr |
4897 | // short txed; | ||
4898 | unsigned long flag; | 4085 | unsigned long flag; |
4899 | /* physical addr are ok on 32 bits since we set DMA mask*/ | 4086 | /* physical addr are ok on 32 bits since we set DMA mask*/ |
4900 | |||
4901 | int offs; | 4087 | int offs; |
4902 | int j,i; | 4088 | int j,i; |
4903 | int hd; | 4089 | int hd; |
@@ -4911,7 +4097,6 @@ void rtl8180_tx_isr(struct net_device *dev, int pri,short error) | |||
4911 | nic = read_nic_dword(dev,TX_MANAGEPRIORITY_RING_ADDR); | 4097 | nic = read_nic_dword(dev,TX_MANAGEPRIORITY_RING_ADDR); |
4912 | nicbegin = priv->txmapringdma; | 4098 | nicbegin = priv->txmapringdma; |
4913 | break; | 4099 | break; |
4914 | |||
4915 | case BK_PRIORITY: | 4100 | case BK_PRIORITY: |
4916 | tail = priv->txbkpringtail; | 4101 | tail = priv->txbkpringtail; |
4917 | begin = priv->txbkpring; | 4102 | begin = priv->txbkpring; |
@@ -4919,7 +4104,6 @@ void rtl8180_tx_isr(struct net_device *dev, int pri,short error) | |||
4919 | nic = read_nic_dword(dev,TX_BKPRIORITY_RING_ADDR); | 4104 | nic = read_nic_dword(dev,TX_BKPRIORITY_RING_ADDR); |
4920 | nicbegin = priv->txbkpringdma; | 4105 | nicbegin = priv->txbkpringdma; |
4921 | break; | 4106 | break; |
4922 | |||
4923 | case BE_PRIORITY: | 4107 | case BE_PRIORITY: |
4924 | tail = priv->txbepringtail; | 4108 | tail = priv->txbepringtail; |
4925 | begin = priv->txbepring; | 4109 | begin = priv->txbepring; |
@@ -4927,7 +4111,6 @@ void rtl8180_tx_isr(struct net_device *dev, int pri,short error) | |||
4927 | nic = read_nic_dword(dev,TX_BEPRIORITY_RING_ADDR); | 4111 | nic = read_nic_dword(dev,TX_BEPRIORITY_RING_ADDR); |
4928 | nicbegin = priv->txbepringdma; | 4112 | nicbegin = priv->txbepringdma; |
4929 | break; | 4113 | break; |
4930 | |||
4931 | case VI_PRIORITY: | 4114 | case VI_PRIORITY: |
4932 | tail = priv->txvipringtail; | 4115 | tail = priv->txvipringtail; |
4933 | begin = priv->txvipring; | 4116 | begin = priv->txvipring; |
@@ -4935,7 +4118,6 @@ void rtl8180_tx_isr(struct net_device *dev, int pri,short error) | |||
4935 | nic = read_nic_dword(dev,TX_VIPRIORITY_RING_ADDR); | 4118 | nic = read_nic_dword(dev,TX_VIPRIORITY_RING_ADDR); |
4936 | nicbegin = priv->txvipringdma; | 4119 | nicbegin = priv->txvipringdma; |
4937 | break; | 4120 | break; |
4938 | |||
4939 | case VO_PRIORITY: | 4121 | case VO_PRIORITY: |
4940 | tail = priv->txvopringtail; | 4122 | tail = priv->txvopringtail; |
4941 | begin = priv->txvopring; | 4123 | begin = priv->txvopring; |
@@ -4943,7 +4125,6 @@ void rtl8180_tx_isr(struct net_device *dev, int pri,short error) | |||
4943 | nic = read_nic_dword(dev,TX_VOPRIORITY_RING_ADDR); | 4125 | nic = read_nic_dword(dev,TX_VOPRIORITY_RING_ADDR); |
4944 | nicbegin = priv->txvopringdma; | 4126 | nicbegin = priv->txvopringdma; |
4945 | break; | 4127 | break; |
4946 | |||
4947 | case HI_PRIORITY: | 4128 | case HI_PRIORITY: |
4948 | tail = priv->txhpringtail; | 4129 | tail = priv->txhpringtail; |
4949 | begin = priv->txhpring; | 4130 | begin = priv->txhpring; |
@@ -4956,12 +4137,7 @@ void rtl8180_tx_isr(struct net_device *dev, int pri,short error) | |||
4956 | spin_unlock_irqrestore(&priv->tx_lock,flag); | 4137 | spin_unlock_irqrestore(&priv->tx_lock,flag); |
4957 | return ; | 4138 | return ; |
4958 | } | 4139 | } |
4959 | /* DMESG("%x %s %x %x",((int)nic & 0xfff)/8/4, | 4140 | |
4960 | *(priv->txnpring + ((int)nic&0xfff)/4/8) & (1<<31) ? "filled" : "empty", | ||
4961 | (priv->txnpringtail - priv->txnpring)/8,(priv->txnpringhead - | ||
4962 | priv->txnpring)/8); | ||
4963 | */ | ||
4964 | //nicv = (u32*) ((nic - nicbegin) + (int)begin); | ||
4965 | nicv = (u32*) ((nic - nicbegin) + (u8*)begin); | 4141 | nicv = (u32*) ((nic - nicbegin) + (u8*)begin); |
4966 | if((head <= tail && (nicv > tail || nicv < head)) || | 4142 | if((head <= tail && (nicv > tail || nicv < head)) || |
4967 | (head > tail && (nicv > tail && nicv < head))){ | 4143 | (head > tail && (nicv > tail && nicv < head))){ |
@@ -4975,56 +4151,39 @@ priv->txnpring)/8); | |||
4975 | * but not the currenly pointed by the nic (the next to be txed) | 4151 | * but not the currenly pointed by the nic (the next to be txed) |
4976 | * and the previous of the pointed (might be in process ??) | 4152 | * and the previous of the pointed (might be in process ??) |
4977 | */ | 4153 | */ |
4978 | //if (head == nic) return; | ||
4979 | //DMESG("%x %x",head,nic); | ||
4980 | offs = (nic - nicbegin); | 4154 | offs = (nic - nicbegin); |
4981 | //DMESG("%x %x %x",nic ,(u32)nicbegin, (int)nic -nicbegin); | ||
4982 | |||
4983 | offs = offs / 8 /4; | 4155 | offs = offs / 8 /4; |
4984 | |||
4985 | hd = (head - begin) /8; | 4156 | hd = (head - begin) /8; |
4986 | 4157 | ||
4987 | if(offs >= hd) | 4158 | if(offs >= hd) |
4988 | j = offs - hd; | 4159 | j = offs - hd; |
4989 | else | 4160 | else |
4990 | j = offs + (priv->txringcount -1 -hd); | 4161 | j = offs + (priv->txringcount -1 -hd); |
4991 | // j= priv->txringcount -1- (hd - offs); | ||
4992 | 4162 | ||
4993 | j-=2; | 4163 | j-=2; |
4994 | if(j<0) j=0; | 4164 | if(j<0) j=0; |
4995 | 4165 | ||
4996 | |||
4997 | for(i=0;i<j;i++) | 4166 | for(i=0;i<j;i++) |
4998 | { | 4167 | { |
4999 | // printk("+++++++++++++check status desc\n"); | ||
5000 | if((*head) & (1<<31)) | 4168 | if((*head) & (1<<31)) |
5001 | break; | 4169 | break; |
5002 | if(((*head)&(0x10000000)) != 0){ | 4170 | if(((*head)&(0x10000000)) != 0){ |
5003 | // printk("++++++++++++++last desc,retry count is %d\n",((*head) & (0x000000ff))); | ||
5004 | priv->CurrRetryCnt += (u16)((*head) & (0x000000ff)); | 4171 | priv->CurrRetryCnt += (u16)((*head) & (0x000000ff)); |
5005 | #if 1 | 4172 | if (!error) |
5006 | if(!error) | ||
5007 | { | ||
5008 | priv->NumTxOkTotal++; | 4173 | priv->NumTxOkTotal++; |
5009 | // printk("NumTxOkTotal is %d\n",priv->NumTxOkTotal++); | ||
5010 | } | ||
5011 | #endif | ||
5012 | // printk("in function %s:curr_retry_count is %d\n",__func__,((*head) & (0x000000ff))); | ||
5013 | } | 4174 | } |
5014 | if(!error){ | 4175 | |
4176 | if (!error) | ||
5015 | priv->NumTxOkBytesTotal += (*(head+3)) & (0x00000fff); | 4177 | priv->NumTxOkBytesTotal += (*(head+3)) & (0x00000fff); |
5016 | } | 4178 | |
5017 | // printk("in function %s:curr_txokbyte_count is %d\n",__func__,(*(head+3)) & (0x00000fff)); | ||
5018 | *head = *head &~ (1<<31); | 4179 | *head = *head &~ (1<<31); |
5019 | 4180 | ||
5020 | if((head - begin)/8 == priv->txringcount-1) | 4181 | if((head - begin)/8 == priv->txringcount-1) |
5021 | head=begin; | 4182 | head=begin; |
5022 | |||
5023 | else | 4183 | else |
5024 | head+=8; | 4184 | head+=8; |
5025 | } | 4185 | } |
5026 | 4186 | ||
5027 | //DMESG("%x",txdv[0]); | ||
5028 | /* the head has been moved to the last certainly TXed | 4187 | /* the head has been moved to the last certainly TXed |
5029 | * (or at least processed by the nic) packet. | 4188 | * (or at least processed by the nic) packet. |
5030 | * The driver take forcefully owning of all these packets | 4189 | * The driver take forcefully owning of all these packets |
@@ -5037,53 +4196,36 @@ priv->txnpring)/8); | |||
5037 | switch(pri) { | 4196 | switch(pri) { |
5038 | case MANAGE_PRIORITY: | 4197 | case MANAGE_PRIORITY: |
5039 | priv->txmapringhead = head; | 4198 | priv->txmapringhead = head; |
5040 | //printk("1==========================================> priority check!\n"); | 4199 | |
5041 | if(priv->ack_tx_to_ieee){ | 4200 | if(priv->ack_tx_to_ieee){ |
5042 | // try to implement power-save mode 2008.1.22 | ||
5043 | // printk("2==========================================> priority check!\n"); | ||
5044 | #if 1 | ||
5045 | if(rtl8180_is_tx_queue_empty(dev)){ | 4201 | if(rtl8180_is_tx_queue_empty(dev)){ |
5046 | // printk("tx queue empty, after send null sleep packet, try to sleep !\n"); | ||
5047 | priv->ack_tx_to_ieee = 0; | 4202 | priv->ack_tx_to_ieee = 0; |
5048 | ieee80211_ps_tx_ack(priv->ieee80211,!error); | 4203 | ieee80211_ps_tx_ack(priv->ieee80211,!error); |
5049 | } | 4204 | } |
5050 | #endif | ||
5051 | } | 4205 | } |
5052 | break; | 4206 | break; |
5053 | |||
5054 | case BK_PRIORITY: | 4207 | case BK_PRIORITY: |
5055 | priv->txbkpringhead = head; | 4208 | priv->txbkpringhead = head; |
5056 | break; | 4209 | break; |
5057 | |||
5058 | case BE_PRIORITY: | 4210 | case BE_PRIORITY: |
5059 | priv->txbepringhead = head; | 4211 | priv->txbepringhead = head; |
5060 | break; | 4212 | break; |
5061 | |||
5062 | case VI_PRIORITY: | 4213 | case VI_PRIORITY: |
5063 | priv->txvipringhead = head; | 4214 | priv->txvipringhead = head; |
5064 | break; | 4215 | break; |
5065 | |||
5066 | case VO_PRIORITY: | 4216 | case VO_PRIORITY: |
5067 | priv->txvopringhead = head; | 4217 | priv->txvopringhead = head; |
5068 | break; | 4218 | break; |
5069 | |||
5070 | case HI_PRIORITY: | 4219 | case HI_PRIORITY: |
5071 | priv->txhpringhead = head; | 4220 | priv->txhpringhead = head; |
5072 | break; | 4221 | break; |
5073 | } | 4222 | } |
5074 | 4223 | ||
5075 | /*DMESG("%x %x %x", (priv->txnpringhead - priv->txnpring) /8 , | ||
5076 | (priv->txnpringtail - priv->txnpring) /8, | ||
5077 | offs ); | ||
5078 | */ | ||
5079 | |||
5080 | spin_unlock_irqrestore(&priv->tx_lock,flag); | 4224 | spin_unlock_irqrestore(&priv->tx_lock,flag); |
5081 | |||
5082 | } | 4225 | } |
5083 | 4226 | ||
5084 | void rtl8180_tx_irq_wq(struct work_struct *work) | 4227 | void rtl8180_tx_irq_wq(struct work_struct *work) |
5085 | { | 4228 | { |
5086 | //struct r8180_priv *priv = container_of(work, struct r8180_priv, reset_wq); | ||
5087 | struct delayed_work *dwork = to_delayed_work(work); | 4229 | struct delayed_work *dwork = to_delayed_work(work); |
5088 | struct ieee80211_device * ieee = (struct ieee80211_device*) | 4230 | struct ieee80211_device * ieee = (struct ieee80211_device*) |
5089 | container_of(dwork, struct ieee80211_device, watch_dog_wq); | 4231 | container_of(dwork, struct ieee80211_device, watch_dog_wq); |
@@ -5109,8 +4251,6 @@ irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs) | |||
5109 | 4251 | ||
5110 | priv->stats.shints++; | 4252 | priv->stats.shints++; |
5111 | 4253 | ||
5112 | //DMESG("Enter interrupt, ISR value = 0x%08x", inta); | ||
5113 | |||
5114 | if(!inta){ | 4254 | if(!inta){ |
5115 | spin_unlock_irqrestore(&priv->irq_th_lock,flags); | 4255 | spin_unlock_irqrestore(&priv->irq_th_lock,flags); |
5116 | return IRQ_HANDLED; | 4256 | return IRQ_HANDLED; |
@@ -5120,41 +4260,30 @@ irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs) | |||
5120 | */ | 4260 | */ |
5121 | } | 4261 | } |
5122 | 4262 | ||
5123 | if(inta == 0xffff){ | 4263 | if (inta == 0xffff) { |
5124 | /* HW disappared */ | 4264 | /* HW disappared */ |
5125 | spin_unlock_irqrestore(&priv->irq_th_lock,flags); | 4265 | spin_unlock_irqrestore(&priv->irq_th_lock, flags); |
5126 | return IRQ_HANDLED; | 4266 | return IRQ_HANDLED; |
5127 | } | 4267 | } |
5128 | 4268 | ||
5129 | priv->stats.ints++; | 4269 | priv->stats.ints++; |
5130 | //priv->irqpending = inta; | ||
5131 | |||
5132 | 4270 | ||
5133 | if(!netif_running(dev)) { | 4271 | if(!netif_running(dev)) { |
5134 | spin_unlock_irqrestore(&priv->irq_th_lock,flags); | 4272 | spin_unlock_irqrestore(&priv->irq_th_lock,flags); |
5135 | return IRQ_HANDLED; | 4273 | return IRQ_HANDLED; |
5136 | } | 4274 | } |
5137 | 4275 | ||
5138 | if(inta & ISR_TimeOut){ | 4276 | if (inta & ISR_TimeOut) |
5139 | write_nic_dword(dev, TimerInt, 0); | 4277 | write_nic_dword(dev, TimerInt, 0); |
5140 | //DMESG("=================>waking up"); | ||
5141 | // rtl8180_hw_wakeup(dev); | ||
5142 | } | ||
5143 | 4278 | ||
5144 | if(inta & ISR_TBDOK){ | 4279 | if (inta & ISR_TBDOK) |
5145 | priv->stats.txbeacon++; | 4280 | priv->stats.txbeacon++; |
5146 | } | ||
5147 | 4281 | ||
5148 | if(inta & ISR_TBDER){ | 4282 | if (inta & ISR_TBDER) |
5149 | priv->stats.txbeaconerr++; | 4283 | priv->stats.txbeaconerr++; |
5150 | } | ||
5151 | 4284 | ||
5152 | if(inta & IMR_TMGDOK ) { | 4285 | if (inta & IMR_TMGDOK) |
5153 | // priv->NumTxOkTotal++; | ||
5154 | rtl8180_tx_isr(dev,MANAGE_PRIORITY,0); | 4286 | rtl8180_tx_isr(dev,MANAGE_PRIORITY,0); |
5155 | // schedule_work(&priv->tx_irq_wq); | ||
5156 | |||
5157 | } | ||
5158 | 4287 | ||
5159 | if(inta & ISR_THPDER){ | 4288 | if(inta & ISR_THPDER){ |
5160 | priv->stats.txhperr++; | 4289 | priv->stats.txhperr++; |
@@ -5163,8 +4292,6 @@ irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs) | |||
5163 | } | 4292 | } |
5164 | 4293 | ||
5165 | if(inta & ISR_THPDOK){ //High priority tx ok | 4294 | if(inta & ISR_THPDOK){ //High priority tx ok |
5166 | // priv->NumTxOkTotal++; | ||
5167 | //priv->NumTxOkInPeriod++; //YJ,del,080828 | ||
5168 | priv->link_detect.NumTxOkInPeriod++; //YJ,add,080828 | 4295 | priv->link_detect.NumTxOkInPeriod++; //YJ,add,080828 |
5169 | priv->stats.txhpokint++; | 4296 | priv->stats.txhpokint++; |
5170 | rtl8180_tx_isr(dev,HI_PRIORITY,0); | 4297 | rtl8180_tx_isr(dev,HI_PRIORITY,0); |
@@ -5176,7 +4303,6 @@ irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs) | |||
5176 | if(inta & ISR_TBKDER){ //corresponding to BK_PRIORITY | 4303 | if(inta & ISR_TBKDER){ //corresponding to BK_PRIORITY |
5177 | priv->stats.txbkperr++; | 4304 | priv->stats.txbkperr++; |
5178 | priv->ieee80211->stats.tx_errors++; | 4305 | priv->ieee80211->stats.tx_errors++; |
5179 | //tasklet_schedule(&priv->irq_tx_tasklet); | ||
5180 | rtl8180_tx_isr(dev,BK_PRIORITY,1); | 4306 | rtl8180_tx_isr(dev,BK_PRIORITY,1); |
5181 | rtl8180_try_wake_queue(dev, BE_PRIORITY); | 4307 | rtl8180_try_wake_queue(dev, BE_PRIORITY); |
5182 | } | 4308 | } |
@@ -5185,13 +4311,11 @@ irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs) | |||
5185 | priv->stats.txbeperr++; | 4311 | priv->stats.txbeperr++; |
5186 | priv->ieee80211->stats.tx_errors++; | 4312 | priv->ieee80211->stats.tx_errors++; |
5187 | rtl8180_tx_isr(dev,BE_PRIORITY,1); | 4313 | rtl8180_tx_isr(dev,BE_PRIORITY,1); |
5188 | //tasklet_schedule(&priv->irq_tx_tasklet); | ||
5189 | rtl8180_try_wake_queue(dev, BE_PRIORITY); | 4314 | rtl8180_try_wake_queue(dev, BE_PRIORITY); |
5190 | } | 4315 | } |
5191 | if(inta & ISR_TNPDER){ //corresponding to VO_PRIORITY | 4316 | if(inta & ISR_TNPDER){ //corresponding to VO_PRIORITY |
5192 | priv->stats.txnperr++; | 4317 | priv->stats.txnperr++; |
5193 | priv->ieee80211->stats.tx_errors++; | 4318 | priv->ieee80211->stats.tx_errors++; |
5194 | //tasklet_schedule(&priv->irq_tx_tasklet); | ||
5195 | rtl8180_tx_isr(dev,NORM_PRIORITY,1); | 4319 | rtl8180_tx_isr(dev,NORM_PRIORITY,1); |
5196 | rtl8180_try_wake_queue(dev, NORM_PRIORITY); | 4320 | rtl8180_try_wake_queue(dev, NORM_PRIORITY); |
5197 | } | 4321 | } |
@@ -5200,23 +4324,19 @@ irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs) | |||
5200 | priv->stats.txlperr++; | 4324 | priv->stats.txlperr++; |
5201 | priv->ieee80211->stats.tx_errors++; | 4325 | priv->ieee80211->stats.tx_errors++; |
5202 | rtl8180_tx_isr(dev,LOW_PRIORITY,1); | 4326 | rtl8180_tx_isr(dev,LOW_PRIORITY,1); |
5203 | //tasklet_schedule(&priv->irq_tx_tasklet); | ||
5204 | rtl8180_try_wake_queue(dev, LOW_PRIORITY); | 4327 | rtl8180_try_wake_queue(dev, LOW_PRIORITY); |
5205 | } | 4328 | } |
5206 | 4329 | ||
5207 | if(inta & ISR_ROK){ | 4330 | if(inta & ISR_ROK){ |
5208 | //priv->NumRxOkInPeriod++; //YJ,del,080828 | ||
5209 | priv->stats.rxint++; | 4331 | priv->stats.rxint++; |
5210 | tasklet_schedule(&priv->irq_rx_tasklet); | 4332 | tasklet_schedule(&priv->irq_rx_tasklet); |
5211 | } | 4333 | } |
5212 | 4334 | ||
5213 | if(inta & ISR_RQoSOK ){ | 4335 | if(inta & ISR_RQoSOK ){ |
5214 | //priv->NumRxOkInPeriod++; //YJ,del,080828 | ||
5215 | priv->stats.rxint++; | 4336 | priv->stats.rxint++; |
5216 | tasklet_schedule(&priv->irq_rx_tasklet); | 4337 | tasklet_schedule(&priv->irq_rx_tasklet); |
5217 | } | 4338 | } |
5218 | if(inta & ISR_BcnInt) { | 4339 | if(inta & ISR_BcnInt) { |
5219 | //DMESG("Preparing Beacons"); | ||
5220 | rtl8180_prepare_beacon(dev); | 4340 | rtl8180_prepare_beacon(dev); |
5221 | } | 4341 | } |
5222 | 4342 | ||
@@ -5224,31 +4344,24 @@ irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs) | |||
5224 | DMESGW("No RX descriptor available"); | 4344 | DMESGW("No RX descriptor available"); |
5225 | priv->stats.rxrdu++; | 4345 | priv->stats.rxrdu++; |
5226 | tasklet_schedule(&priv->irq_rx_tasklet); | 4346 | tasklet_schedule(&priv->irq_rx_tasklet); |
5227 | /*queue_work(priv->workqueue ,&priv->restart_work);*/ | ||
5228 | |||
5229 | } | 4347 | } |
4348 | |||
5230 | if(inta & ISR_RXFOVW){ | 4349 | if(inta & ISR_RXFOVW){ |
5231 | priv->stats.rxoverflow++; | 4350 | priv->stats.rxoverflow++; |
5232 | tasklet_schedule(&priv->irq_rx_tasklet); | 4351 | tasklet_schedule(&priv->irq_rx_tasklet); |
5233 | //queue_work(priv->workqueue ,&priv->restart_work); | ||
5234 | } | 4352 | } |
5235 | 4353 | ||
5236 | if(inta & ISR_TXFOVW) priv->stats.txoverflow++; | 4354 | if (inta & ISR_TXFOVW) |
4355 | priv->stats.txoverflow++; | ||
5237 | 4356 | ||
5238 | if(inta & ISR_TNPDOK){ //Normal priority tx ok | 4357 | if(inta & ISR_TNPDOK){ //Normal priority tx ok |
5239 | // priv->NumTxOkTotal++; | ||
5240 | //priv->NumTxOkInPeriod++; //YJ,del,080828 | ||
5241 | priv->link_detect.NumTxOkInPeriod++; //YJ,add,080828 | 4358 | priv->link_detect.NumTxOkInPeriod++; //YJ,add,080828 |
5242 | // priv->ieee80211->stats.tx_packets++; | ||
5243 | priv->stats.txnpokint++; | 4359 | priv->stats.txnpokint++; |
5244 | rtl8180_tx_isr(dev,NORM_PRIORITY,0); | 4360 | rtl8180_tx_isr(dev,NORM_PRIORITY,0); |
5245 | } | 4361 | } |
5246 | 4362 | ||
5247 | if(inta & ISR_TLPDOK){ //Low priority tx ok | 4363 | if(inta & ISR_TLPDOK){ //Low priority tx ok |
5248 | // priv->NumTxOkTotal++; | ||
5249 | //priv->NumTxOkInPeriod++; //YJ,del,080828 | ||
5250 | priv->link_detect.NumTxOkInPeriod++; //YJ,add,080828 | 4364 | priv->link_detect.NumTxOkInPeriod++; //YJ,add,080828 |
5251 | // priv->ieee80211->stats.tx_packets++; | ||
5252 | priv->stats.txlpokint++; | 4365 | priv->stats.txlpokint++; |
5253 | rtl8180_tx_isr(dev,LOW_PRIORITY,0); | 4366 | rtl8180_tx_isr(dev,LOW_PRIORITY,0); |
5254 | rtl8180_try_wake_queue(dev, LOW_PRIORITY); | 4367 | rtl8180_try_wake_queue(dev, LOW_PRIORITY); |
@@ -5256,8 +4369,6 @@ irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs) | |||
5256 | 4369 | ||
5257 | if(inta & ISR_TBKDOK){ //corresponding to BK_PRIORITY | 4370 | if(inta & ISR_TBKDOK){ //corresponding to BK_PRIORITY |
5258 | priv->stats.txbkpokint++; | 4371 | priv->stats.txbkpokint++; |
5259 | // priv->NumTxOkTotal++; | ||
5260 | //priv->NumTxOkInPeriod++; //YJ,del,080828 | ||
5261 | priv->link_detect.NumTxOkInPeriod++; //YJ,add,080828 | 4372 | priv->link_detect.NumTxOkInPeriod++; //YJ,add,080828 |
5262 | rtl8180_tx_isr(dev,BK_PRIORITY,0); | 4373 | rtl8180_tx_isr(dev,BK_PRIORITY,0); |
5263 | rtl8180_try_wake_queue(dev, BE_PRIORITY); | 4374 | rtl8180_try_wake_queue(dev, BE_PRIORITY); |
@@ -5265,8 +4376,6 @@ irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs) | |||
5265 | 4376 | ||
5266 | if(inta & ISR_TBEDOK){ //corresponding to BE_PRIORITY | 4377 | if(inta & ISR_TBEDOK){ //corresponding to BE_PRIORITY |
5267 | priv->stats.txbeperr++; | 4378 | priv->stats.txbeperr++; |
5268 | // priv->NumTxOkTotal++; | ||
5269 | //priv->NumTxOkInPeriod++; //YJ,del,080828 | ||
5270 | priv->link_detect.NumTxOkInPeriod++; //YJ,add,080828 | 4379 | priv->link_detect.NumTxOkInPeriod++; //YJ,add,080828 |
5271 | rtl8180_tx_isr(dev,BE_PRIORITY,0); | 4380 | rtl8180_tx_isr(dev,BE_PRIORITY,0); |
5272 | rtl8180_try_wake_queue(dev, BE_PRIORITY); | 4381 | rtl8180_try_wake_queue(dev, BE_PRIORITY); |
@@ -5277,40 +4386,16 @@ irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs) | |||
5277 | return IRQ_HANDLED; | 4386 | return IRQ_HANDLED; |
5278 | } | 4387 | } |
5279 | 4388 | ||
5280 | |||
5281 | void rtl8180_irq_rx_tasklet(struct r8180_priv* priv) | 4389 | void rtl8180_irq_rx_tasklet(struct r8180_priv* priv) |
5282 | { | 4390 | { |
5283 | // unsigned long flags; | ||
5284 | |||
5285 | /* spin_lock_irqsave(&priv->irq_lock, flags); | ||
5286 | priv->irq_mask &=~IMR_ROK; | ||
5287 | priv->irq_mask &=~IMR_RDU; | ||
5288 | |||
5289 | rtl8180_irq_enable(priv->dev); | ||
5290 | spin_unlock_irqrestore(&priv->irq_lock, flags); | ||
5291 | */ | ||
5292 | rtl8180_rx(priv->dev); | 4391 | rtl8180_rx(priv->dev); |
5293 | |||
5294 | /* spin_lock_irqsave(&priv->irq_lock, flags); | ||
5295 | priv->irq_mask |= IMR_ROK; | ||
5296 | priv->irq_mask |= IMR_RDU; | ||
5297 | rtl8180_irq_enable(priv->dev); | ||
5298 | spin_unlock_irqrestore(&priv->irq_lock, flags); | ||
5299 | */ | ||
5300 | } | 4392 | } |
5301 | 4393 | ||
5302 | /**************************************************************************** | ||
5303 | lizhaoming--------------------------- RF power on/power off ----------------- | ||
5304 | *****************************************************************************/ | ||
5305 | |||
5306 | void GPIOChangeRFWorkItemCallBack(struct work_struct *work) | 4394 | void GPIOChangeRFWorkItemCallBack(struct work_struct *work) |
5307 | { | 4395 | { |
5308 | //struct delayed_work *dwork = to_delayed_work(work); | ||
5309 | struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, GPIOChangeRFWorkItem.work); | 4396 | struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, GPIOChangeRFWorkItem.work); |
5310 | struct net_device *dev = ieee->dev; | 4397 | struct net_device *dev = ieee->dev; |
5311 | struct r8180_priv *priv = ieee80211_priv(dev); | 4398 | struct r8180_priv *priv = ieee80211_priv(dev); |
5312 | |||
5313 | //u16 tmp2byte; | ||
5314 | u8 btPSR; | 4399 | u8 btPSR; |
5315 | u8 btConfig0; | 4400 | u8 btConfig0; |
5316 | RT_RF_POWER_STATE eRfPowerStateToSet; | 4401 | RT_RF_POWER_STATE eRfPowerStateToSet; |
@@ -5320,7 +4405,6 @@ void GPIOChangeRFWorkItemCallBack(struct work_struct *work) | |||
5320 | static char *RadioPowerPath = "/etc/acpi/events/RadioPower.sh"; | 4405 | static char *RadioPowerPath = "/etc/acpi/events/RadioPower.sh"; |
5321 | static char *envp[] = {"HOME=/", "TERM=linux", "PATH=/usr/bin:/bin", NULL}; | 4406 | static char *envp[] = {"HOME=/", "TERM=linux", "PATH=/usr/bin:/bin", NULL}; |
5322 | static int readf_count = 0; | 4407 | static int readf_count = 0; |
5323 | //printk("============>%s in \n", __func__); | ||
5324 | 4408 | ||
5325 | #ifdef ENABLE_LPS | 4409 | #ifdef ENABLE_LPS |
5326 | if(readf_count % 10 == 0) | 4410 | if(readf_count % 10 == 0) |
@@ -5375,9 +4459,7 @@ void GPIOChangeRFWorkItemCallBack(struct work_struct *work) | |||
5375 | 4459 | ||
5376 | call_usermodehelper(RadioPowerPath,argv,envp,1); | 4460 | call_usermodehelper(RadioPowerPath,argv,envp,1); |
5377 | } | 4461 | } |
5378 | |||
5379 | } | 4462 | } |
5380 | |||
5381 | } | 4463 | } |
5382 | 4464 | ||
5383 | static u8 read_acadapter_file(char *filename) | 4465 | static u8 read_acadapter_file(char *filename) |
@@ -5385,9 +4467,5 @@ static u8 read_acadapter_file(char *filename) | |||
5385 | return 0; | 4467 | return 0; |
5386 | } | 4468 | } |
5387 | 4469 | ||
5388 | /*************************************************************************** | ||
5389 | ------------------- module init / exit stubs ---------------- | ||
5390 | ****************************************************************************/ | ||
5391 | module_init(rtl8180_pci_module_init); | 4470 | module_init(rtl8180_pci_module_init); |
5392 | module_exit(rtl8180_pci_module_exit); | 4471 | module_exit(rtl8180_pci_module_exit); |
5393 | |||