diff options
author | Prashant P. Shah <pshah.mumbai@gmail.com> | 2010-05-13 13:38:43 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-05-14 16:58:53 -0400 |
commit | bbfb56520c8da666383c08220985495ff918d4ad (patch) | |
tree | fd685cfecca615331dae83f3a6c574b278276c4e | |
parent | fd4dc88e46c4d9dd845ffef50a975ceea110fd85 (diff) |
Staging: rtl8187se: fixed space style issues in r8180_core.c
This is a patch to the r8180_core.c file that fixes the space
style issues found by the checkpatch.pl tool.
Signed-off-by: Prashant P. Shah <pshah.mumbai@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/staging/rtl8187se/r8180_core.c | 1622 |
1 files changed, 806 insertions, 816 deletions
diff --git a/drivers/staging/rtl8187se/r8180_core.c b/drivers/staging/rtl8187se/r8180_core.c index 84a745bb9ca0..37be5aedf52f 100644 --- a/drivers/staging/rtl8187se/r8180_core.c +++ b/drivers/staging/rtl8187se/r8180_core.c | |||
@@ -66,23 +66,23 @@ static int hwseqnum = 0; | |||
66 | static int hwwep = 0; | 66 | static int hwwep = 0; |
67 | static int channels = 0x3fff; | 67 | static int channels = 0x3fff; |
68 | 68 | ||
69 | #define eqMacAddr(a,b) ( ((a)[0]==(b)[0] && (a)[1]==(b)[1] && (a)[2]==(b)[2] && (a)[3]==(b)[3] && (a)[4]==(b)[4] && (a)[5]==(b)[5]) ? 1:0 ) | 69 | #define eqMacAddr(a, b) (((a)[0] == (b)[0] && (a)[1] == (b)[1] && (a)[2] == (b)[2] && (a)[3] == (b)[3] && (a)[4] == (b)[4] && (a)[5] == (b)[5]) ? 1 : 0) |
70 | #define cpMacAddr(des,src) ((des)[0]=(src)[0],(des)[1]=(src)[1],(des)[2]=(src)[2],(des)[3]=(src)[3],(des)[4]=(src)[4],(des)[5]=(src)[5]) | 70 | #define cpMacAddr(des, src) ((des)[0] = (src)[0], (des)[1] = (src)[1], (des)[2] = (src)[2], (des)[3] = (src)[3], (des)[4] = (src)[4], (des)[5] = (src)[5]) |
71 | MODULE_LICENSE("GPL"); | 71 | MODULE_LICENSE("GPL"); |
72 | MODULE_DEVICE_TABLE(pci, rtl8180_pci_id_tbl); | 72 | MODULE_DEVICE_TABLE(pci, rtl8180_pci_id_tbl); |
73 | MODULE_AUTHOR("Andrea Merello <andreamrl@tiscali.it>"); | 73 | MODULE_AUTHOR("Andrea Merello <andreamrl@tiscali.it>"); |
74 | MODULE_DESCRIPTION("Linux driver for Realtek RTL8180 / RTL8185 WiFi cards"); | 74 | MODULE_DESCRIPTION("Linux driver for Realtek RTL8180 / RTL8185 WiFi cards"); |
75 | 75 | ||
76 | 76 | ||
77 | module_param(ifname, charp, S_IRUGO|S_IWUSR ); | 77 | module_param(ifname, charp, S_IRUGO|S_IWUSR); |
78 | module_param(hwseqnum,int, S_IRUGO|S_IWUSR); | 78 | module_param(hwseqnum, int, S_IRUGO|S_IWUSR); |
79 | module_param(hwwep,int, S_IRUGO|S_IWUSR); | 79 | module_param(hwwep, int, S_IRUGO|S_IWUSR); |
80 | module_param(channels,int, S_IRUGO|S_IWUSR); | 80 | module_param(channels, int, S_IRUGO|S_IWUSR); |
81 | 81 | ||
82 | MODULE_PARM_DESC(devname," Net interface name, wlan%d=default"); | 82 | MODULE_PARM_DESC(devname, " Net interface name, wlan%d=default"); |
83 | MODULE_PARM_DESC(hwseqnum," Try to use hardware 802.11 header sequence numbers. Zero=default"); | 83 | MODULE_PARM_DESC(hwseqnum, " Try to use hardware 802.11 header sequence numbers. Zero=default"); |
84 | MODULE_PARM_DESC(hwwep," Try to use hardware WEP support. Still broken and not available on all cards"); | 84 | MODULE_PARM_DESC(hwwep, " Try to use hardware WEP support. Still broken and not available on all cards"); |
85 | MODULE_PARM_DESC(channels," Channel bitmask for specific locales. NYI"); | 85 | MODULE_PARM_DESC(channels, " Channel bitmask for specific locales. NYI"); |
86 | 86 | ||
87 | 87 | ||
88 | static int __devinit rtl8180_pci_probe(struct pci_dev *pdev, | 88 | static int __devinit rtl8180_pci_probe(struct pci_dev *pdev, |
@@ -90,7 +90,7 @@ static int __devinit rtl8180_pci_probe(struct pci_dev *pdev, | |||
90 | 90 | ||
91 | static void __devexit rtl8180_pci_remove(struct pci_dev *pdev); | 91 | static void __devexit rtl8180_pci_remove(struct pci_dev *pdev); |
92 | 92 | ||
93 | static void rtl8180_shutdown (struct pci_dev *pdev) | 93 | static void rtl8180_shutdown(struct pci_dev *pdev) |
94 | { | 94 | { |
95 | struct net_device *dev = pci_get_drvdata(pdev); | 95 | struct net_device *dev = pci_get_drvdata(pdev); |
96 | if (dev->netdev_ops->ndo_stop) | 96 | if (dev->netdev_ops->ndo_stop) |
@@ -181,19 +181,19 @@ u16 read_nic_word(struct net_device *dev, int x) | |||
181 | return readw((u8 *)dev->mem_start + x); | 181 | return readw((u8 *)dev->mem_start + x); |
182 | } | 182 | } |
183 | 183 | ||
184 | void write_nic_byte(struct net_device *dev, int x,u8 y) | 184 | void write_nic_byte(struct net_device *dev, int x, u8 y) |
185 | { | 185 | { |
186 | writeb(y, (u8 *)dev->mem_start + x); | 186 | writeb(y, (u8 *)dev->mem_start + x); |
187 | udelay(20); | 187 | udelay(20); |
188 | } | 188 | } |
189 | 189 | ||
190 | void write_nic_dword(struct net_device *dev, int x,u32 y) | 190 | void write_nic_dword(struct net_device *dev, int x, u32 y) |
191 | { | 191 | { |
192 | writel(y, (u8 *)dev->mem_start + x); | 192 | writel(y, (u8 *)dev->mem_start + x); |
193 | udelay(20); | 193 | udelay(20); |
194 | } | 194 | } |
195 | 195 | ||
196 | void write_nic_word(struct net_device *dev, int x,u16 y) | 196 | void write_nic_word(struct net_device *dev, int x, u16 y) |
197 | { | 197 | { |
198 | writew(y, (u8 *)dev->mem_start + x); | 198 | writew(y, (u8 *)dev->mem_start + x); |
199 | udelay(20); | 199 | udelay(20); |
@@ -201,7 +201,7 @@ void write_nic_word(struct net_device *dev, int x,u16 y) | |||
201 | 201 | ||
202 | inline void force_pci_posting(struct net_device *dev) | 202 | inline void force_pci_posting(struct net_device *dev) |
203 | { | 203 | { |
204 | read_nic_byte(dev,EPROM_CMD); | 204 | read_nic_byte(dev, EPROM_CMD); |
205 | mb(); | 205 | mb(); |
206 | } | 206 | } |
207 | 207 | ||
@@ -220,7 +220,7 @@ static int proc_get_registers(char *page, char **start, | |||
220 | { | 220 | { |
221 | struct net_device *dev = data; | 221 | struct net_device *dev = data; |
222 | int len = 0; | 222 | int len = 0; |
223 | int i,n; | 223 | int i, n; |
224 | int max = 0xff; | 224 | int max = 0xff; |
225 | 225 | ||
226 | /* This dump the current register page */ | 226 | /* This dump the current register page */ |
@@ -231,7 +231,7 @@ static int proc_get_registers(char *page, char **start, | |||
231 | len += snprintf(page + len, count - len, "%2x ", | 231 | len += snprintf(page + len, count - len, "%2x ", |
232 | read_nic_byte(dev, n)); | 232 | read_nic_byte(dev, n)); |
233 | } | 233 | } |
234 | len += snprintf(page + len, count - len,"\n"); | 234 | len += snprintf(page + len, count - len, "\n"); |
235 | 235 | ||
236 | *eof = 1; | 236 | *eof = 1; |
237 | return len; | 237 | return len; |
@@ -287,7 +287,7 @@ static int proc_get_stats_tx(char *page, char **start, | |||
287 | int len = 0; | 287 | int len = 0; |
288 | unsigned long totalOK; | 288 | unsigned long totalOK; |
289 | 289 | ||
290 | totalOK=priv->stats.txnpokint+priv->stats.txhpokint+priv->stats.txlpokint; | 290 | totalOK = priv->stats.txnpokint+priv->stats.txhpokint+priv->stats.txlpokint; |
291 | len += snprintf(page + len, count - len, | 291 | len += snprintf(page + len, count - len, |
292 | "TX OK: %lu\n" | 292 | "TX OK: %lu\n" |
293 | "TX Error: %lu\n" | 293 | "TX Error: %lu\n" |
@@ -308,7 +308,7 @@ static int proc_get_stats_tx(char *page, char **start, | |||
308 | void rtl8180_proc_module_init(void) | 308 | void rtl8180_proc_module_init(void) |
309 | { | 309 | { |
310 | DMESG("Initializing proc filesystem"); | 310 | DMESG("Initializing proc filesystem"); |
311 | rtl8180_proc=create_proc_entry(RTL8180_MODULE_NAME, S_IFDIR, init_net.proc_net); | 311 | rtl8180_proc = create_proc_entry(RTL8180_MODULE_NAME, S_IFDIR, init_net.proc_net); |
312 | } | 312 | } |
313 | 313 | ||
314 | void rtl8180_proc_module_remove(void) | 314 | void rtl8180_proc_module_remove(void) |
@@ -385,81 +385,81 @@ short buffer_add(struct buffer **buffer, u32 *buf, dma_addr_t dma, | |||
385 | { | 385 | { |
386 | struct buffer *tmp; | 386 | struct buffer *tmp; |
387 | 387 | ||
388 | if(! *buffer){ | 388 | if (!*buffer) { |
389 | 389 | ||
390 | *buffer = kmalloc(sizeof(struct buffer),GFP_KERNEL); | 390 | *buffer = kmalloc(sizeof(struct buffer), GFP_KERNEL); |
391 | 391 | ||
392 | if (*buffer == NULL) { | 392 | if (*buffer == NULL) { |
393 | DMESGE("Failed to kmalloc head of TX/RX struct"); | 393 | DMESGE("Failed to kmalloc head of TX/RX struct"); |
394 | return -1; | 394 | return -1; |
395 | } | 395 | } |
396 | (*buffer)->next=*buffer; | 396 | (*buffer)->next = *buffer; |
397 | (*buffer)->buf=buf; | 397 | (*buffer)->buf = buf; |
398 | (*buffer)->dma=dma; | 398 | (*buffer)->dma = dma; |
399 | if(bufferhead !=NULL) | 399 | if (bufferhead != NULL) |
400 | (*bufferhead) = (*buffer); | 400 | (*bufferhead) = (*buffer); |
401 | return 0; | 401 | return 0; |
402 | } | 402 | } |
403 | tmp=*buffer; | 403 | tmp = *buffer; |
404 | 404 | ||
405 | while(tmp->next!=(*buffer)) tmp=tmp->next; | 405 | while (tmp->next != (*buffer)) |
406 | tmp->next = kmalloc(sizeof(struct buffer),GFP_KERNEL); | 406 | tmp = tmp->next; |
407 | tmp->next = kmalloc(sizeof(struct buffer), GFP_KERNEL); | ||
407 | if (tmp->next == NULL) { | 408 | if (tmp->next == NULL) { |
408 | DMESGE("Failed to kmalloc TX/RX struct"); | 409 | DMESGE("Failed to kmalloc TX/RX struct"); |
409 | return -1; | 410 | return -1; |
410 | } | 411 | } |
411 | tmp->next->buf=buf; | 412 | tmp->next->buf = buf; |
412 | tmp->next->dma=dma; | 413 | tmp->next->dma = dma; |
413 | tmp->next->next=*buffer; | 414 | tmp->next->next = *buffer; |
414 | 415 | ||
415 | return 0; | 416 | return 0; |
416 | } | 417 | } |
417 | 418 | ||
418 | void buffer_free(struct net_device *dev,struct buffer **buffer,int len,short | 419 | void buffer_free(struct net_device *dev, struct buffer **buffer, int len, short consistent) |
419 | consistent) | ||
420 | { | 420 | { |
421 | 421 | ||
422 | struct buffer *tmp,*next; | 422 | struct buffer *tmp, *next; |
423 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 423 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
424 | struct pci_dev *pdev=priv->pdev; | 424 | struct pci_dev *pdev = priv->pdev; |
425 | 425 | ||
426 | if (!*buffer) | 426 | if (!*buffer) |
427 | return; | 427 | return; |
428 | 428 | ||
429 | tmp = *buffer; | 429 | tmp = *buffer; |
430 | 430 | ||
431 | do{ | 431 | do { |
432 | next=tmp->next; | 432 | next = tmp->next; |
433 | if(consistent){ | 433 | if (consistent) { |
434 | pci_free_consistent(pdev,len, | 434 | pci_free_consistent(pdev, len, |
435 | tmp->buf,tmp->dma); | 435 | tmp->buf, tmp->dma); |
436 | }else{ | 436 | } else { |
437 | pci_unmap_single(pdev, tmp->dma, | 437 | pci_unmap_single(pdev, tmp->dma, |
438 | len,PCI_DMA_FROMDEVICE); | 438 | len, PCI_DMA_FROMDEVICE); |
439 | kfree(tmp->buf); | 439 | kfree(tmp->buf); |
440 | } | 440 | } |
441 | kfree(tmp); | 441 | kfree(tmp); |
442 | tmp = next; | 442 | tmp = next; |
443 | } | 443 | } |
444 | while(next != *buffer); | 444 | while (next != *buffer); |
445 | 445 | ||
446 | *buffer=NULL; | 446 | *buffer = NULL; |
447 | } | 447 | } |
448 | 448 | ||
449 | void print_buffer(u32 *buffer, int len) | 449 | void print_buffer(u32 *buffer, int len) |
450 | { | 450 | { |
451 | int i; | 451 | int i; |
452 | u8 *buf =(u8*)buffer; | 452 | u8 *buf = (u8 *)buffer; |
453 | 453 | ||
454 | printk("ASCII BUFFER DUMP (len: %x):\n",len); | 454 | printk("ASCII BUFFER DUMP (len: %x):\n", len); |
455 | 455 | ||
456 | for(i=0;i<len;i++) | 456 | for (i = 0; i < len; i++) |
457 | printk("%c",buf[i]); | 457 | printk("%c", buf[i]); |
458 | 458 | ||
459 | printk("\nBINARY BUFFER DUMP (len: %x):\n",len); | 459 | printk("\nBINARY BUFFER DUMP (len: %x):\n", len); |
460 | 460 | ||
461 | for(i=0;i<len;i++) | 461 | for (i = 0; i < len; i++) |
462 | printk("%02x",buf[i]); | 462 | printk("%02x", buf[i]); |
463 | 463 | ||
464 | printk("\n"); | 464 | printk("\n"); |
465 | } | 465 | } |
@@ -467,37 +467,37 @@ void print_buffer(u32 *buffer, int len) | |||
467 | int get_curr_tx_free_desc(struct net_device *dev, int priority) | 467 | int get_curr_tx_free_desc(struct net_device *dev, int priority) |
468 | { | 468 | { |
469 | struct r8180_priv *priv = ieee80211_priv(dev); | 469 | struct r8180_priv *priv = ieee80211_priv(dev); |
470 | u32* tail; | 470 | u32 *tail; |
471 | u32* head; | 471 | u32 *head; |
472 | int ret; | 472 | int ret; |
473 | 473 | ||
474 | switch (priority){ | 474 | switch (priority) { |
475 | case MANAGE_PRIORITY: | 475 | case MANAGE_PRIORITY: |
476 | head = priv->txmapringhead; | 476 | head = priv->txmapringhead; |
477 | tail = priv->txmapringtail; | 477 | tail = priv->txmapringtail; |
478 | break; | 478 | break; |
479 | case BK_PRIORITY: | 479 | case BK_PRIORITY: |
480 | head = priv->txbkpringhead; | 480 | head = priv->txbkpringhead; |
481 | tail = priv->txbkpringtail; | 481 | tail = priv->txbkpringtail; |
482 | break; | 482 | break; |
483 | case BE_PRIORITY: | 483 | case BE_PRIORITY: |
484 | head = priv->txbepringhead; | 484 | head = priv->txbepringhead; |
485 | tail = priv->txbepringtail; | 485 | tail = priv->txbepringtail; |
486 | break; | 486 | break; |
487 | case VI_PRIORITY: | 487 | case VI_PRIORITY: |
488 | head = priv->txvipringhead; | 488 | head = priv->txvipringhead; |
489 | tail = priv->txvipringtail; | 489 | tail = priv->txvipringtail; |
490 | break; | 490 | break; |
491 | case VO_PRIORITY: | 491 | case VO_PRIORITY: |
492 | head = priv->txvopringhead; | 492 | head = priv->txvopringhead; |
493 | tail = priv->txvopringtail; | 493 | tail = priv->txvopringtail; |
494 | break; | 494 | break; |
495 | case HI_PRIORITY: | 495 | case HI_PRIORITY: |
496 | head = priv->txhpringhead; | 496 | head = priv->txhpringhead; |
497 | tail = priv->txhpringtail; | 497 | tail = priv->txhpringtail; |
498 | break; | 498 | break; |
499 | default: | 499 | default: |
500 | return -1; | 500 | return -1; |
501 | } | 501 | } |
502 | 502 | ||
503 | if (head <= tail) | 503 | if (head <= tail) |
@@ -531,7 +531,7 @@ short check_nic_enought_desc(struct net_device *dev, int priority) | |||
531 | * between the tail and the head | 531 | * between the tail and the head |
532 | */ | 532 | */ |
533 | 533 | ||
534 | return (required+2 < get_curr_tx_free_desc(dev,priority)); | 534 | return (required+2 < get_curr_tx_free_desc(dev, priority)); |
535 | } | 535 | } |
536 | 536 | ||
537 | void fix_tx_fifo(struct net_device *dev) | 537 | void fix_tx_fifo(struct net_device *dev) |
@@ -540,45 +540,45 @@ void fix_tx_fifo(struct net_device *dev) | |||
540 | u32 *tmp; | 540 | u32 *tmp; |
541 | int i; | 541 | int i; |
542 | 542 | ||
543 | for (tmp=priv->txmapring, i=0; | 543 | for (tmp = priv->txmapring, i = 0; |
544 | i < priv->txringcount; | 544 | i < priv->txringcount; |
545 | tmp+=8, i++){ | 545 | tmp += 8, i++) { |
546 | *tmp = *tmp &~ (1<<31); | 546 | *tmp = *tmp & ~(1<<31); |
547 | } | 547 | } |
548 | 548 | ||
549 | for (tmp=priv->txbkpring, i=0; | 549 | for (tmp = priv->txbkpring, i = 0; |
550 | i < priv->txringcount; | 550 | i < priv->txringcount; |
551 | tmp+=8, i++) { | 551 | tmp += 8, i++) { |
552 | *tmp = *tmp &~ (1<<31); | 552 | *tmp = *tmp & ~(1<<31); |
553 | } | 553 | } |
554 | 554 | ||
555 | for (tmp=priv->txbepring, i=0; | 555 | for (tmp = priv->txbepring, i = 0; |
556 | i < priv->txringcount; | 556 | i < priv->txringcount; |
557 | tmp+=8, i++){ | 557 | tmp += 8, i++) { |
558 | *tmp = *tmp &~ (1<<31); | 558 | *tmp = *tmp & ~(1<<31); |
559 | } | 559 | } |
560 | for (tmp=priv->txvipring, i=0; | 560 | for (tmp = priv->txvipring, i = 0; |
561 | i < priv->txringcount; | 561 | i < priv->txringcount; |
562 | tmp+=8, i++) { | 562 | tmp += 8, i++) { |
563 | *tmp = *tmp &~ (1<<31); | 563 | *tmp = *tmp & ~(1<<31); |
564 | } | 564 | } |
565 | 565 | ||
566 | for (tmp=priv->txvopring, i=0; | 566 | for (tmp = priv->txvopring, i = 0; |
567 | i < priv->txringcount; | 567 | i < priv->txringcount; |
568 | tmp+=8, i++){ | 568 | tmp += 8, i++) { |
569 | *tmp = *tmp &~ (1<<31); | 569 | *tmp = *tmp & ~(1<<31); |
570 | } | 570 | } |
571 | 571 | ||
572 | for (tmp=priv->txhpring, i=0; | 572 | for (tmp = priv->txhpring, i = 0; |
573 | i < priv->txringcount; | 573 | i < priv->txringcount; |
574 | tmp+=8,i++){ | 574 | tmp += 8, i++) { |
575 | *tmp = *tmp &~ (1<<31); | 575 | *tmp = *tmp & ~(1<<31); |
576 | } | 576 | } |
577 | 577 | ||
578 | for (tmp=priv->txbeaconring, i=0; | 578 | for (tmp = priv->txbeaconring, i = 0; |
579 | i < priv->txbeaconcount; | 579 | i < priv->txbeaconcount; |
580 | tmp+=8, i++){ | 580 | tmp += 8, i++) { |
581 | *tmp = *tmp &~ (1<<31); | 581 | *tmp = *tmp & ~(1<<31); |
582 | } | 582 | } |
583 | 583 | ||
584 | priv->txmapringtail = priv->txmapring; | 584 | priv->txmapringtail = priv->txmapring; |
@@ -622,18 +622,18 @@ void fix_rx_fifo(struct net_device *dev) | |||
622 | 622 | ||
623 | rx_desc_size = 8; // 4*8 = 32 bytes | 623 | rx_desc_size = 8; // 4*8 = 32 bytes |
624 | 624 | ||
625 | for (tmp=priv->rxring, rxbuf=priv->rxbufferhead; | 625 | for (tmp = priv->rxring, rxbuf = priv->rxbufferhead; |
626 | (tmp < (priv->rxring)+(priv->rxringcount)*rx_desc_size); | 626 | (tmp < (priv->rxring)+(priv->rxringcount)*rx_desc_size); |
627 | tmp+=rx_desc_size,rxbuf=rxbuf->next){ | 627 | tmp += rx_desc_size, rxbuf = rxbuf->next) { |
628 | *(tmp+2) = rxbuf->dma; | 628 | *(tmp+2) = rxbuf->dma; |
629 | *tmp=*tmp &~ 0xfff; | 629 | *tmp = *tmp & ~0xfff; |
630 | *tmp=*tmp | priv->rxbuffersize; | 630 | *tmp = *tmp | priv->rxbuffersize; |
631 | *tmp |= (1<<31); | 631 | *tmp |= (1<<31); |
632 | } | 632 | } |
633 | 633 | ||
634 | priv->rxringtail=priv->rxring; | 634 | priv->rxringtail = priv->rxring; |
635 | priv->rxbuffer=priv->rxbufferhead; | 635 | priv->rxbuffer = priv->rxbufferhead; |
636 | priv->rx_skb_complete=1; | 636 | priv->rx_skb_complete = 1; |
637 | set_nic_rxring(dev); | 637 | set_nic_rxring(dev); |
638 | } | 638 | } |
639 | 639 | ||
@@ -678,20 +678,18 @@ void rtl8180_RSSI_calc(struct net_device *dev, u8 *rssi, u8 *qual) | |||
678 | if (q <= 0x4e) { | 678 | if (q <= 0x4e) { |
679 | temp = QUALITY_MAP[q]; | 679 | temp = QUALITY_MAP[q]; |
680 | } else { | 680 | } else { |
681 | if( q & 0x80 ) { | 681 | if (q & 0x80) |
682 | temp = 0x32; | 682 | temp = 0x32; |
683 | } else { | 683 | else |
684 | temp = 1; | 684 | temp = 1; |
685 | } | ||
686 | } | 685 | } |
687 | 686 | ||
688 | *qual = temp; | 687 | *qual = temp; |
689 | temp2 = *rssi; | 688 | temp2 = *rssi; |
690 | 689 | ||
691 | if ( _rssi < 0x64 ){ | 690 | if (_rssi < 0x64) { |
692 | if ( _rssi == 0 ) { | 691 | if (_rssi == 0) |
693 | *rssi = 1; | 692 | *rssi = 1; |
694 | } | ||
695 | } else { | 693 | } else { |
696 | *rssi = 0x64; | 694 | *rssi = 0x64; |
697 | } | 695 | } |
@@ -704,27 +702,27 @@ void rtl8180_irq_enable(struct net_device *dev) | |||
704 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 702 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
705 | 703 | ||
706 | priv->irq_enabled = 1; | 704 | priv->irq_enabled = 1; |
707 | write_nic_word(dev,INTA_MASK, priv->irq_mask); | 705 | write_nic_word(dev, INTA_MASK, priv->irq_mask); |
708 | } | 706 | } |
709 | 707 | ||
710 | void rtl8180_irq_disable(struct net_device *dev) | 708 | void rtl8180_irq_disable(struct net_device *dev) |
711 | { | 709 | { |
712 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 710 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
713 | 711 | ||
714 | write_nic_dword(dev,IMR,0); | 712 | write_nic_dword(dev, IMR, 0); |
715 | force_pci_posting(dev); | 713 | force_pci_posting(dev); |
716 | priv->irq_enabled = 0; | 714 | priv->irq_enabled = 0; |
717 | } | 715 | } |
718 | 716 | ||
719 | void rtl8180_set_mode(struct net_device *dev,int mode) | 717 | void rtl8180_set_mode(struct net_device *dev, int mode) |
720 | { | 718 | { |
721 | u8 ecmd; | 719 | u8 ecmd; |
722 | 720 | ||
723 | ecmd=read_nic_byte(dev, EPROM_CMD); | 721 | ecmd = read_nic_byte(dev, EPROM_CMD); |
724 | ecmd=ecmd &~ EPROM_CMD_OPERATING_MODE_MASK; | 722 | ecmd = ecmd & ~EPROM_CMD_OPERATING_MODE_MASK; |
725 | ecmd=ecmd | (mode<<EPROM_CMD_OPERATING_MODE_SHIFT); | 723 | ecmd = ecmd | (mode<<EPROM_CMD_OPERATING_MODE_SHIFT); |
726 | ecmd=ecmd &~ (1<<EPROM_CS_SHIFT); | 724 | ecmd = ecmd & ~(1<<EPROM_CS_SHIFT); |
727 | ecmd=ecmd &~ (1<<EPROM_CK_SHIFT); | 725 | ecmd = ecmd & ~(1<<EPROM_CK_SHIFT); |
728 | write_nic_byte(dev, EPROM_CMD, ecmd); | 726 | write_nic_byte(dev, EPROM_CMD, ecmd); |
729 | } | 727 | } |
730 | 728 | ||
@@ -738,13 +736,12 @@ void rtl8180_update_msr(struct net_device *dev) | |||
738 | u32 rxconf; | 736 | u32 rxconf; |
739 | 737 | ||
740 | msr = read_nic_byte(dev, MSR); | 738 | msr = read_nic_byte(dev, MSR); |
741 | msr &= ~ MSR_LINK_MASK; | 739 | msr &= ~MSR_LINK_MASK; |
742 | 740 | ||
743 | rxconf=read_nic_dword(dev,RX_CONF); | 741 | rxconf = read_nic_dword(dev, RX_CONF); |
744 | 742 | ||
745 | if(priv->ieee80211->state == IEEE80211_LINKED) | 743 | if (priv->ieee80211->state == IEEE80211_LINKED) { |
746 | { | 744 | if (priv->ieee80211->iw_mode == IW_MODE_ADHOC) |
747 | if(priv->ieee80211->iw_mode == IW_MODE_ADHOC) | ||
748 | msr |= (MSR_LINK_ADHOC<<MSR_LINK_SHIFT); | 745 | msr |= (MSR_LINK_ADHOC<<MSR_LINK_SHIFT); |
749 | else if (priv->ieee80211->iw_mode == IW_MODE_MASTER) | 746 | else if (priv->ieee80211->iw_mode == IW_MODE_MASTER) |
750 | msr |= (MSR_LINK_MASTER<<MSR_LINK_SHIFT); | 747 | msr |= (MSR_LINK_MASTER<<MSR_LINK_SHIFT); |
@@ -754,7 +751,7 @@ void rtl8180_update_msr(struct net_device *dev) | |||
754 | msr |= (MSR_LINK_NONE<<MSR_LINK_SHIFT); | 751 | msr |= (MSR_LINK_NONE<<MSR_LINK_SHIFT); |
755 | rxconf |= (1<<RX_CHECK_BSSID_SHIFT); | 752 | rxconf |= (1<<RX_CHECK_BSSID_SHIFT); |
756 | 753 | ||
757 | }else { | 754 | } else { |
758 | msr |= (MSR_LINK_NONE<<MSR_LINK_SHIFT); | 755 | msr |= (MSR_LINK_NONE<<MSR_LINK_SHIFT); |
759 | rxconf &= ~(1<<RX_CHECK_BSSID_SHIFT); | 756 | rxconf &= ~(1<<RX_CHECK_BSSID_SHIFT); |
760 | } | 757 | } |
@@ -763,7 +760,7 @@ void rtl8180_update_msr(struct net_device *dev) | |||
763 | write_nic_dword(dev, RX_CONF, rxconf); | 760 | write_nic_dword(dev, RX_CONF, rxconf); |
764 | } | 761 | } |
765 | 762 | ||
766 | void rtl8180_set_chan(struct net_device *dev,short ch) | 763 | void rtl8180_set_chan(struct net_device *dev, short ch) |
767 | { | 764 | { |
768 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 765 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
769 | 766 | ||
@@ -772,8 +769,8 @@ void rtl8180_set_chan(struct net_device *dev,short ch) | |||
772 | return; | 769 | return; |
773 | } | 770 | } |
774 | 771 | ||
775 | priv->chan=ch; | 772 | priv->chan = ch; |
776 | priv->rf_set_chan(dev,priv->chan); | 773 | priv->rf_set_chan(dev, priv->chan); |
777 | } | 774 | } |
778 | 775 | ||
779 | void rtl8180_rx_enable(struct net_device *dev) | 776 | void rtl8180_rx_enable(struct net_device *dev) |
@@ -783,8 +780,8 @@ void rtl8180_rx_enable(struct net_device *dev) | |||
783 | /* for now we accept data, management & ctl frame*/ | 780 | /* for now we accept data, management & ctl frame*/ |
784 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 781 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
785 | 782 | ||
786 | rxconf=read_nic_dword(dev,RX_CONF); | 783 | rxconf = read_nic_dword(dev, RX_CONF); |
787 | rxconf = rxconf &~ MAC_FILTER_MASK; | 784 | rxconf = rxconf & ~MAC_FILTER_MASK; |
788 | rxconf = rxconf | (1<<ACCEPT_MNG_FRAME_SHIFT); | 785 | rxconf = rxconf | (1<<ACCEPT_MNG_FRAME_SHIFT); |
789 | rxconf = rxconf | (1<<ACCEPT_DATA_FRAME_SHIFT); | 786 | rxconf = rxconf | (1<<ACCEPT_DATA_FRAME_SHIFT); |
790 | rxconf = rxconf | (1<<ACCEPT_BCAST_FRAME_SHIFT); | 787 | rxconf = rxconf | (1<<ACCEPT_BCAST_FRAME_SHIFT); |
@@ -792,39 +789,39 @@ void rtl8180_rx_enable(struct net_device *dev) | |||
792 | if (dev->flags & IFF_PROMISC) | 789 | if (dev->flags & IFF_PROMISC) |
793 | DMESG("NIC in promisc mode"); | 790 | DMESG("NIC in promisc mode"); |
794 | 791 | ||
795 | if(priv->ieee80211->iw_mode == IW_MODE_MONITOR || \ | 792 | if (priv->ieee80211->iw_mode == IW_MODE_MONITOR || \ |
796 | dev->flags & IFF_PROMISC){ | 793 | dev->flags & IFF_PROMISC) { |
797 | rxconf = rxconf | (1<<ACCEPT_ALLMAC_FRAME_SHIFT); | 794 | rxconf = rxconf | (1<<ACCEPT_ALLMAC_FRAME_SHIFT); |
798 | }else{ | 795 | } else { |
799 | rxconf = rxconf | (1<<ACCEPT_NICMAC_FRAME_SHIFT); | 796 | rxconf = rxconf | (1<<ACCEPT_NICMAC_FRAME_SHIFT); |
800 | } | 797 | } |
801 | 798 | ||
802 | if(priv->ieee80211->iw_mode == IW_MODE_MONITOR){ | 799 | if (priv->ieee80211->iw_mode == IW_MODE_MONITOR) { |
803 | rxconf = rxconf | (1<<ACCEPT_CTL_FRAME_SHIFT); | 800 | rxconf = rxconf | (1<<ACCEPT_CTL_FRAME_SHIFT); |
804 | rxconf = rxconf | (1<<ACCEPT_ICVERR_FRAME_SHIFT); | 801 | rxconf = rxconf | (1<<ACCEPT_ICVERR_FRAME_SHIFT); |
805 | rxconf = rxconf | (1<<ACCEPT_PWR_FRAME_SHIFT); | 802 | rxconf = rxconf | (1<<ACCEPT_PWR_FRAME_SHIFT); |
806 | } | 803 | } |
807 | 804 | ||
808 | if( priv->crcmon == 1 && priv->ieee80211->iw_mode == IW_MODE_MONITOR) | 805 | if (priv->crcmon == 1 && priv->ieee80211->iw_mode == IW_MODE_MONITOR) |
809 | rxconf = rxconf | (1<<ACCEPT_CRCERR_FRAME_SHIFT); | 806 | rxconf = rxconf | (1<<ACCEPT_CRCERR_FRAME_SHIFT); |
810 | 807 | ||
811 | rxconf = rxconf & ~RX_FIFO_THRESHOLD_MASK; | 808 | rxconf = rxconf & ~RX_FIFO_THRESHOLD_MASK; |
812 | rxconf = rxconf | (RX_FIFO_THRESHOLD_NONE << RX_FIFO_THRESHOLD_SHIFT); | 809 | rxconf = rxconf | (RX_FIFO_THRESHOLD_NONE << RX_FIFO_THRESHOLD_SHIFT); |
813 | 810 | ||
814 | rxconf = rxconf | (1<<RX_AUTORESETPHY_SHIFT); | 811 | rxconf = rxconf | (1<<RX_AUTORESETPHY_SHIFT); |
815 | rxconf = rxconf &~ MAX_RX_DMA_MASK; | 812 | rxconf = rxconf & ~MAX_RX_DMA_MASK; |
816 | rxconf = rxconf | (MAX_RX_DMA_2048<<MAX_RX_DMA_SHIFT); | 813 | rxconf = rxconf | (MAX_RX_DMA_2048<<MAX_RX_DMA_SHIFT); |
817 | 814 | ||
818 | rxconf = rxconf | RCR_ONLYERLPKT; | 815 | rxconf = rxconf | RCR_ONLYERLPKT; |
819 | 816 | ||
820 | rxconf = rxconf &~ RCR_CS_MASK; | 817 | rxconf = rxconf & ~RCR_CS_MASK; |
821 | 818 | ||
822 | write_nic_dword(dev, RX_CONF, rxconf); | 819 | write_nic_dword(dev, RX_CONF, rxconf); |
823 | 820 | ||
824 | fix_rx_fifo(dev); | 821 | fix_rx_fifo(dev); |
825 | 822 | ||
826 | cmd=read_nic_byte(dev,CMD); | 823 | cmd = read_nic_byte(dev, CMD); |
827 | write_nic_byte(dev,CMD,cmd | (1<<CMD_RX_ENABLE_SHIFT)); | 824 | write_nic_byte(dev, CMD, cmd | (1<<CMD_RX_ENABLE_SHIFT)); |
828 | } | 825 | } |
829 | 826 | ||
830 | void set_nic_txring(struct net_device *dev) | 827 | void set_nic_txring(struct net_device *dev) |
@@ -844,20 +841,20 @@ void rtl8180_conttx_enable(struct net_device *dev) | |||
844 | { | 841 | { |
845 | u32 txconf; | 842 | u32 txconf; |
846 | 843 | ||
847 | txconf = read_nic_dword(dev,TX_CONF); | 844 | txconf = read_nic_dword(dev, TX_CONF); |
848 | txconf = txconf &~ TX_LOOPBACK_MASK; | 845 | txconf = txconf & ~TX_LOOPBACK_MASK; |
849 | txconf = txconf | (TX_LOOPBACK_CONTINUE <<TX_LOOPBACK_SHIFT); | 846 | txconf = txconf | (TX_LOOPBACK_CONTINUE<<TX_LOOPBACK_SHIFT); |
850 | write_nic_dword(dev,TX_CONF,txconf); | 847 | write_nic_dword(dev, TX_CONF, txconf); |
851 | } | 848 | } |
852 | 849 | ||
853 | void rtl8180_conttx_disable(struct net_device *dev) | 850 | void rtl8180_conttx_disable(struct net_device *dev) |
854 | { | 851 | { |
855 | u32 txconf; | 852 | u32 txconf; |
856 | 853 | ||
857 | txconf = read_nic_dword(dev,TX_CONF); | 854 | txconf = read_nic_dword(dev, TX_CONF); |
858 | txconf = txconf &~ TX_LOOPBACK_MASK; | 855 | txconf = txconf & ~TX_LOOPBACK_MASK; |
859 | txconf = txconf | (TX_LOOPBACK_NONE <<TX_LOOPBACK_SHIFT); | 856 | txconf = txconf | (TX_LOOPBACK_NONE<<TX_LOOPBACK_SHIFT); |
860 | write_nic_dword(dev,TX_CONF,txconf); | 857 | write_nic_dword(dev, TX_CONF, txconf); |
861 | } | 858 | } |
862 | 859 | ||
863 | void rtl8180_tx_enable(struct net_device *dev) | 860 | void rtl8180_tx_enable(struct net_device *dev) |
@@ -884,54 +881,54 @@ void rtl8180_tx_enable(struct net_device *dev) | |||
884 | 881 | ||
885 | txconf = txconf & ~(1<<TCR_PROBE_NOTIMESTAMP_SHIFT); | 882 | txconf = txconf & ~(1<<TCR_PROBE_NOTIMESTAMP_SHIFT); |
886 | 883 | ||
887 | txconf = txconf &~ TX_LOOPBACK_MASK; | 884 | txconf = txconf & ~TX_LOOPBACK_MASK; |
888 | txconf = txconf | (TX_LOOPBACK_NONE <<TX_LOOPBACK_SHIFT); | 885 | txconf = txconf | (TX_LOOPBACK_NONE<<TX_LOOPBACK_SHIFT); |
889 | txconf = txconf &~ TCR_DPRETRY_MASK; | 886 | txconf = txconf & ~TCR_DPRETRY_MASK; |
890 | txconf = txconf &~ TCR_RTSRETRY_MASK; | 887 | txconf = txconf & ~TCR_RTSRETRY_MASK; |
891 | txconf = txconf | (priv->retry_data<<TX_DPRETRY_SHIFT); | 888 | txconf = txconf | (priv->retry_data<<TX_DPRETRY_SHIFT); |
892 | txconf = txconf | (priv->retry_rts<<TX_RTSRETRY_SHIFT); | 889 | txconf = txconf | (priv->retry_rts<<TX_RTSRETRY_SHIFT); |
893 | txconf = txconf &~ (1<<TX_NOCRC_SHIFT); | 890 | txconf = txconf & ~(1<<TX_NOCRC_SHIFT); |
894 | 891 | ||
895 | if (priv->hw_plcp_len) | 892 | if (priv->hw_plcp_len) |
896 | txconf = txconf & ~TCR_PLCP_LEN; | 893 | txconf = txconf & ~TCR_PLCP_LEN; |
897 | else | 894 | else |
898 | txconf = txconf | TCR_PLCP_LEN; | 895 | txconf = txconf | TCR_PLCP_LEN; |
899 | 896 | ||
900 | txconf = txconf &~ TCR_MXDMA_MASK; | 897 | txconf = txconf & ~TCR_MXDMA_MASK; |
901 | txconf = txconf | (TCR_MXDMA_2048<<TCR_MXDMA_SHIFT); | 898 | txconf = txconf | (TCR_MXDMA_2048<<TCR_MXDMA_SHIFT); |
902 | txconf = txconf | TCR_CWMIN; | 899 | txconf = txconf | TCR_CWMIN; |
903 | txconf = txconf | TCR_DISCW; | 900 | txconf = txconf | TCR_DISCW; |
904 | 901 | ||
905 | txconf = txconf | (1 << TX_NOICV_SHIFT); | 902 | txconf = txconf | (1 << TX_NOICV_SHIFT); |
906 | 903 | ||
907 | write_nic_dword(dev,TX_CONF,txconf); | 904 | write_nic_dword(dev, TX_CONF, txconf); |
908 | 905 | ||
909 | fix_tx_fifo(dev); | 906 | fix_tx_fifo(dev); |
910 | 907 | ||
911 | cmd=read_nic_byte(dev,CMD); | 908 | cmd = read_nic_byte(dev, CMD); |
912 | write_nic_byte(dev,CMD,cmd | (1<<CMD_TX_ENABLE_SHIFT)); | 909 | write_nic_byte(dev, CMD, cmd | (1<<CMD_TX_ENABLE_SHIFT)); |
913 | 910 | ||
914 | write_nic_dword(dev,TX_CONF,txconf); | 911 | write_nic_dword(dev, TX_CONF, txconf); |
915 | } | 912 | } |
916 | 913 | ||
917 | void rtl8180_beacon_tx_enable(struct net_device *dev) | 914 | void rtl8180_beacon_tx_enable(struct net_device *dev) |
918 | { | 915 | { |
919 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 916 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
920 | 917 | ||
921 | rtl8180_set_mode(dev,EPROM_CMD_CONFIG); | 918 | rtl8180_set_mode(dev, EPROM_CMD_CONFIG); |
922 | priv->dma_poll_stop_mask &= ~(TPPOLLSTOP_BQ); | 919 | priv->dma_poll_stop_mask &= ~(TPPOLLSTOP_BQ); |
923 | write_nic_byte(dev,TPPollStop, priv->dma_poll_mask); | 920 | write_nic_byte(dev, TPPollStop, priv->dma_poll_mask); |
924 | rtl8180_set_mode(dev,EPROM_CMD_NORMAL); | 921 | rtl8180_set_mode(dev, EPROM_CMD_NORMAL); |
925 | } | 922 | } |
926 | 923 | ||
927 | void rtl8180_beacon_tx_disable(struct net_device *dev) | 924 | void rtl8180_beacon_tx_disable(struct net_device *dev) |
928 | { | 925 | { |
929 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 926 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
930 | 927 | ||
931 | rtl8180_set_mode(dev,EPROM_CMD_CONFIG); | 928 | rtl8180_set_mode(dev, EPROM_CMD_CONFIG); |
932 | priv->dma_poll_stop_mask |= TPPOLLSTOP_BQ; | 929 | priv->dma_poll_stop_mask |= TPPOLLSTOP_BQ; |
933 | write_nic_byte(dev,TPPollStop, priv->dma_poll_stop_mask); | 930 | write_nic_byte(dev, TPPollStop, priv->dma_poll_stop_mask); |
934 | rtl8180_set_mode(dev,EPROM_CMD_NORMAL); | 931 | rtl8180_set_mode(dev, EPROM_CMD_NORMAL); |
935 | 932 | ||
936 | } | 933 | } |
937 | 934 | ||
@@ -940,13 +937,13 @@ void rtl8180_rtx_disable(struct net_device *dev) | |||
940 | u8 cmd; | 937 | u8 cmd; |
941 | struct r8180_priv *priv = ieee80211_priv(dev); | 938 | struct r8180_priv *priv = ieee80211_priv(dev); |
942 | 939 | ||
943 | cmd=read_nic_byte(dev,CMD); | 940 | cmd = read_nic_byte(dev, CMD); |
944 | write_nic_byte(dev, CMD, cmd &~ \ | 941 | write_nic_byte(dev, CMD, cmd & ~\ |
945 | ((1<<CMD_RX_ENABLE_SHIFT)|(1<<CMD_TX_ENABLE_SHIFT))); | 942 | ((1<<CMD_RX_ENABLE_SHIFT)|(1<<CMD_TX_ENABLE_SHIFT))); |
946 | force_pci_posting(dev); | 943 | force_pci_posting(dev); |
947 | mdelay(10); | 944 | mdelay(10); |
948 | 945 | ||
949 | if(!priv->rx_skb_complete) | 946 | if (!priv->rx_skb_complete) |
950 | dev_kfree_skb_any(priv->rx_skb); | 947 | dev_kfree_skb_any(priv->rx_skb); |
951 | } | 948 | } |
952 | 949 | ||
@@ -961,11 +958,11 @@ short alloc_tx_desc_ring(struct net_device *dev, int bufsize, int count, | |||
961 | struct pci_dev *pdev = priv->pdev; | 958 | struct pci_dev *pdev = priv->pdev; |
962 | void *buf; | 959 | void *buf; |
963 | 960 | ||
964 | if((bufsize & 0xfff) != bufsize) { | 961 | if ((bufsize & 0xfff) != bufsize) { |
965 | DMESGE ("TX buffer allocation too large"); | 962 | DMESGE("TX buffer allocation too large"); |
966 | return 0; | 963 | return 0; |
967 | } | 964 | } |
968 | desc = (u32*)pci_alloc_consistent(pdev, | 965 | desc = (u32 *)pci_alloc_consistent(pdev, |
969 | sizeof(u32)*8*count+256, &dma_desc); | 966 | sizeof(u32)*8*count+256, &dma_desc); |
970 | if (desc == NULL) | 967 | if (desc == NULL) |
971 | return -1; | 968 | return -1; |
@@ -984,90 +981,90 @@ short alloc_tx_desc_ring(struct net_device *dev, int bufsize, int count, | |||
984 | if (buf == NULL) | 981 | if (buf == NULL) |
985 | return -ENOMEM; | 982 | return -ENOMEM; |
986 | 983 | ||
987 | switch(addr) { | 984 | switch (addr) { |
988 | case TX_MANAGEPRIORITY_RING_ADDR: | 985 | case TX_MANAGEPRIORITY_RING_ADDR: |
989 | if(-1 == buffer_add(&(priv->txmapbufs),buf,dma_tmp,NULL)){ | 986 | if (-1 == buffer_add(&(priv->txmapbufs), buf, dma_tmp, NULL)) { |
990 | DMESGE("Unable to allocate mem for buffer NP"); | 987 | DMESGE("Unable to allocate mem for buffer NP"); |
991 | return -ENOMEM; | 988 | return -ENOMEM; |
992 | } | 989 | } |
993 | break; | 990 | break; |
994 | case TX_BKPRIORITY_RING_ADDR: | 991 | case TX_BKPRIORITY_RING_ADDR: |
995 | if(-1 == buffer_add(&(priv->txbkpbufs),buf,dma_tmp,NULL)){ | 992 | if (-1 == buffer_add(&(priv->txbkpbufs), buf, dma_tmp, NULL)) { |
996 | DMESGE("Unable to allocate mem for buffer LP"); | 993 | DMESGE("Unable to allocate mem for buffer LP"); |
997 | return -ENOMEM; | 994 | return -ENOMEM; |
998 | } | 995 | } |
999 | break; | 996 | break; |
1000 | case TX_BEPRIORITY_RING_ADDR: | 997 | case TX_BEPRIORITY_RING_ADDR: |
1001 | if(-1 == buffer_add(&(priv->txbepbufs),buf,dma_tmp,NULL)){ | 998 | if (-1 == buffer_add(&(priv->txbepbufs), buf, dma_tmp, NULL)) { |
1002 | DMESGE("Unable to allocate mem for buffer NP"); | 999 | DMESGE("Unable to allocate mem for buffer NP"); |
1003 | return -ENOMEM; | 1000 | return -ENOMEM; |
1004 | } | 1001 | } |
1005 | break; | 1002 | break; |
1006 | case TX_VIPRIORITY_RING_ADDR: | 1003 | case TX_VIPRIORITY_RING_ADDR: |
1007 | if(-1 == buffer_add(&(priv->txvipbufs),buf,dma_tmp,NULL)){ | 1004 | if (-1 == buffer_add(&(priv->txvipbufs), buf, dma_tmp, NULL)) { |
1008 | DMESGE("Unable to allocate mem for buffer LP"); | 1005 | DMESGE("Unable to allocate mem for buffer LP"); |
1009 | return -ENOMEM; | 1006 | return -ENOMEM; |
1010 | } | 1007 | } |
1011 | break; | 1008 | break; |
1012 | case TX_VOPRIORITY_RING_ADDR: | 1009 | case TX_VOPRIORITY_RING_ADDR: |
1013 | if(-1 == buffer_add(&(priv->txvopbufs),buf,dma_tmp,NULL)){ | 1010 | if (-1 == buffer_add(&(priv->txvopbufs), buf, dma_tmp, NULL)) { |
1014 | DMESGE("Unable to allocate mem for buffer NP"); | 1011 | DMESGE("Unable to allocate mem for buffer NP"); |
1015 | return -ENOMEM; | 1012 | return -ENOMEM; |
1016 | } | 1013 | } |
1017 | break; | 1014 | break; |
1018 | case TX_HIGHPRIORITY_RING_ADDR: | 1015 | case TX_HIGHPRIORITY_RING_ADDR: |
1019 | if(-1 == buffer_add(&(priv->txhpbufs),buf,dma_tmp,NULL)){ | 1016 | if (-1 == buffer_add(&(priv->txhpbufs), buf, dma_tmp, NULL)) { |
1020 | DMESGE("Unable to allocate mem for buffer HP"); | 1017 | DMESGE("Unable to allocate mem for buffer HP"); |
1021 | return -ENOMEM; | 1018 | return -ENOMEM; |
1022 | } | 1019 | } |
1023 | break; | 1020 | break; |
1024 | case TX_BEACON_RING_ADDR: | 1021 | case TX_BEACON_RING_ADDR: |
1025 | if(-1 == buffer_add(&(priv->txbeaconbufs),buf,dma_tmp,NULL)){ | 1022 | if (-1 == buffer_add(&(priv->txbeaconbufs), buf, dma_tmp, NULL)) { |
1026 | DMESGE("Unable to allocate mem for buffer BP"); | 1023 | DMESGE("Unable to allocate mem for buffer BP"); |
1027 | return -ENOMEM; | 1024 | return -ENOMEM; |
1028 | } | 1025 | } |
1029 | break; | 1026 | break; |
1030 | } | 1027 | } |
1031 | *tmp = *tmp &~ (1<<31); // descriptor empty, owned by the drv | 1028 | *tmp = *tmp & ~(1<<31); // descriptor empty, owned by the drv |
1032 | *(tmp+2) = (u32)dma_tmp; | 1029 | *(tmp+2) = (u32)dma_tmp; |
1033 | *(tmp+3) = bufsize; | 1030 | *(tmp+3) = bufsize; |
1034 | 1031 | ||
1035 | if(i+1<count) | 1032 | if (i+1 < count) |
1036 | *(tmp+4) = (u32)dma_desc+((i+1)*8*4); | 1033 | *(tmp+4) = (u32)dma_desc+((i+1)*8*4); |
1037 | else | 1034 | else |
1038 | *(tmp+4) = (u32)dma_desc; | 1035 | *(tmp+4) = (u32)dma_desc; |
1039 | 1036 | ||
1040 | tmp=tmp+8; | 1037 | tmp = tmp+8; |
1041 | } | 1038 | } |
1042 | 1039 | ||
1043 | switch(addr) { | 1040 | switch (addr) { |
1044 | case TX_MANAGEPRIORITY_RING_ADDR: | 1041 | case TX_MANAGEPRIORITY_RING_ADDR: |
1045 | priv->txmapringdma=dma_desc; | 1042 | priv->txmapringdma = dma_desc; |
1046 | priv->txmapring=desc; | 1043 | priv->txmapring = desc; |
1047 | break; | 1044 | break; |
1048 | case TX_BKPRIORITY_RING_ADDR: | 1045 | case TX_BKPRIORITY_RING_ADDR: |
1049 | priv->txbkpringdma=dma_desc; | 1046 | priv->txbkpringdma = dma_desc; |
1050 | priv->txbkpring=desc; | 1047 | priv->txbkpring = desc; |
1051 | break; | 1048 | break; |
1052 | case TX_BEPRIORITY_RING_ADDR: | 1049 | case TX_BEPRIORITY_RING_ADDR: |
1053 | priv->txbepringdma=dma_desc; | 1050 | priv->txbepringdma = dma_desc; |
1054 | priv->txbepring=desc; | 1051 | priv->txbepring = desc; |
1055 | break; | 1052 | break; |
1056 | case TX_VIPRIORITY_RING_ADDR: | 1053 | case TX_VIPRIORITY_RING_ADDR: |
1057 | priv->txvipringdma=dma_desc; | 1054 | priv->txvipringdma = dma_desc; |
1058 | priv->txvipring=desc; | 1055 | priv->txvipring = desc; |
1059 | break; | 1056 | break; |
1060 | case TX_VOPRIORITY_RING_ADDR: | 1057 | case TX_VOPRIORITY_RING_ADDR: |
1061 | priv->txvopringdma=dma_desc; | 1058 | priv->txvopringdma = dma_desc; |
1062 | priv->txvopring=desc; | 1059 | priv->txvopring = desc; |
1063 | break; | 1060 | break; |
1064 | case TX_HIGHPRIORITY_RING_ADDR: | 1061 | case TX_HIGHPRIORITY_RING_ADDR: |
1065 | priv->txhpringdma=dma_desc; | 1062 | priv->txhpringdma = dma_desc; |
1066 | priv->txhpring=desc; | 1063 | priv->txhpring = desc; |
1067 | break; | 1064 | break; |
1068 | case TX_BEACON_RING_ADDR: | 1065 | case TX_BEACON_RING_ADDR: |
1069 | priv->txbeaconringdma=dma_desc; | 1066 | priv->txbeaconringdma = dma_desc; |
1070 | priv->txbeaconring=desc; | 1067 | priv->txbeaconring = desc; |
1071 | break; | 1068 | break; |
1072 | 1069 | ||
1073 | } | 1070 | } |
@@ -1078,37 +1075,37 @@ short alloc_tx_desc_ring(struct net_device *dev, int bufsize, int count, | |||
1078 | void free_tx_desc_rings(struct net_device *dev) | 1075 | void free_tx_desc_rings(struct net_device *dev) |
1079 | { | 1076 | { |
1080 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 1077 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
1081 | struct pci_dev *pdev=priv->pdev; | 1078 | struct pci_dev *pdev = priv->pdev; |
1082 | int count = priv->txringcount; | 1079 | int count = priv->txringcount; |
1083 | 1080 | ||
1084 | pci_free_consistent(pdev, sizeof(u32)*8*count+256, | 1081 | pci_free_consistent(pdev, sizeof(u32)*8*count+256, |
1085 | priv->txmapring, priv->txmapringdma); | 1082 | priv->txmapring, priv->txmapringdma); |
1086 | buffer_free(dev,&(priv->txmapbufs),priv->txbuffsize,1); | 1083 | buffer_free(dev, &(priv->txmapbufs), priv->txbuffsize, 1); |
1087 | 1084 | ||
1088 | pci_free_consistent(pdev, sizeof(u32)*8*count+256, | 1085 | pci_free_consistent(pdev, sizeof(u32)*8*count+256, |
1089 | priv->txbkpring, priv->txbkpringdma); | 1086 | priv->txbkpring, priv->txbkpringdma); |
1090 | buffer_free(dev,&(priv->txbkpbufs),priv->txbuffsize,1); | 1087 | buffer_free(dev, &(priv->txbkpbufs), priv->txbuffsize, 1); |
1091 | 1088 | ||
1092 | pci_free_consistent(pdev, sizeof(u32)*8*count+256, | 1089 | pci_free_consistent(pdev, sizeof(u32)*8*count+256, |
1093 | priv->txbepring, priv->txbepringdma); | 1090 | priv->txbepring, priv->txbepringdma); |
1094 | buffer_free(dev,&(priv->txbepbufs),priv->txbuffsize,1); | 1091 | buffer_free(dev, &(priv->txbepbufs), priv->txbuffsize, 1); |
1095 | 1092 | ||
1096 | pci_free_consistent(pdev, sizeof(u32)*8*count+256, | 1093 | pci_free_consistent(pdev, sizeof(u32)*8*count+256, |
1097 | priv->txvipring, priv->txvipringdma); | 1094 | priv->txvipring, priv->txvipringdma); |
1098 | buffer_free(dev,&(priv->txvipbufs),priv->txbuffsize,1); | 1095 | buffer_free(dev, &(priv->txvipbufs), priv->txbuffsize, 1); |
1099 | 1096 | ||
1100 | pci_free_consistent(pdev, sizeof(u32)*8*count+256, | 1097 | pci_free_consistent(pdev, sizeof(u32)*8*count+256, |
1101 | priv->txvopring, priv->txvopringdma); | 1098 | priv->txvopring, priv->txvopringdma); |
1102 | buffer_free(dev,&(priv->txvopbufs),priv->txbuffsize,1); | 1099 | buffer_free(dev, &(priv->txvopbufs), priv->txbuffsize, 1); |
1103 | 1100 | ||
1104 | pci_free_consistent(pdev, sizeof(u32)*8*count+256, | 1101 | pci_free_consistent(pdev, sizeof(u32)*8*count+256, |
1105 | priv->txhpring, priv->txhpringdma); | 1102 | priv->txhpring, priv->txhpringdma); |
1106 | buffer_free(dev,&(priv->txhpbufs),priv->txbuffsize,1); | 1103 | buffer_free(dev, &(priv->txhpbufs), priv->txbuffsize, 1); |
1107 | 1104 | ||
1108 | count = priv->txbeaconcount; | 1105 | count = priv->txbeaconcount; |
1109 | pci_free_consistent(pdev, sizeof(u32)*8*count+256, | 1106 | pci_free_consistent(pdev, sizeof(u32)*8*count+256, |
1110 | priv->txbeaconring, priv->txbeaconringdma); | 1107 | priv->txbeaconring, priv->txbeaconringdma); |
1111 | buffer_free(dev,&(priv->txbeaconbufs),priv->txbuffsize,1); | 1108 | buffer_free(dev, &(priv->txbeaconbufs), priv->txbuffsize, 1); |
1112 | } | 1109 | } |
1113 | 1110 | ||
1114 | void free_rx_desc_ring(struct net_device *dev) | 1111 | void free_rx_desc_ring(struct net_device *dev) |
@@ -1120,7 +1117,7 @@ void free_rx_desc_ring(struct net_device *dev) | |||
1120 | pci_free_consistent(pdev, sizeof(u32)*8*count+256, | 1117 | pci_free_consistent(pdev, sizeof(u32)*8*count+256, |
1121 | priv->rxring, priv->rxringdma); | 1118 | priv->rxring, priv->rxringdma); |
1122 | 1119 | ||
1123 | buffer_free(dev,&(priv->rxbuffer),priv->rxbuffersize,0); | 1120 | buffer_free(dev, &(priv->rxbuffer), priv->rxbuffersize, 0); |
1124 | } | 1121 | } |
1125 | 1122 | ||
1126 | short alloc_rx_desc_ring(struct net_device *dev, u16 bufsize, int count) | 1123 | short alloc_rx_desc_ring(struct net_device *dev, u16 bufsize, int count) |
@@ -1128,20 +1125,20 @@ short alloc_rx_desc_ring(struct net_device *dev, u16 bufsize, int count) | |||
1128 | int i; | 1125 | int i; |
1129 | u32 *desc; | 1126 | u32 *desc; |
1130 | u32 *tmp; | 1127 | u32 *tmp; |
1131 | dma_addr_t dma_desc,dma_tmp; | 1128 | dma_addr_t dma_desc, dma_tmp; |
1132 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 1129 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
1133 | struct pci_dev *pdev=priv->pdev; | 1130 | struct pci_dev *pdev = priv->pdev; |
1134 | void *buf; | 1131 | void *buf; |
1135 | u8 rx_desc_size; | 1132 | u8 rx_desc_size; |
1136 | 1133 | ||
1137 | rx_desc_size = 8; // 4*8 = 32 bytes | 1134 | rx_desc_size = 8; // 4*8 = 32 bytes |
1138 | 1135 | ||
1139 | if((bufsize & 0xfff) != bufsize){ | 1136 | if ((bufsize & 0xfff) != bufsize) { |
1140 | DMESGE ("RX buffer allocation too large"); | 1137 | DMESGE("RX buffer allocation too large"); |
1141 | return -1; | 1138 | return -1; |
1142 | } | 1139 | } |
1143 | 1140 | ||
1144 | desc = (u32*)pci_alloc_consistent(pdev,sizeof(u32)*rx_desc_size*count+256, | 1141 | desc = (u32 *)pci_alloc_consistent(pdev, sizeof(u32)*rx_desc_size*count+256, |
1145 | &dma_desc); | 1142 | &dma_desc); |
1146 | 1143 | ||
1147 | if (dma_desc & 0xff) | 1144 | if (dma_desc & 0xff) |
@@ -1151,31 +1148,31 @@ short alloc_rx_desc_ring(struct net_device *dev, u16 bufsize, int count) | |||
1151 | */ | 1148 | */ |
1152 | WARN(1, "DMA buffer is not aligned\n"); | 1149 | WARN(1, "DMA buffer is not aligned\n"); |
1153 | 1150 | ||
1154 | priv->rxring=desc; | 1151 | priv->rxring = desc; |
1155 | priv->rxringdma=dma_desc; | 1152 | priv->rxringdma = dma_desc; |
1156 | tmp=desc; | 1153 | tmp = desc; |
1157 | 1154 | ||
1158 | for (i = 0; i < count; i++) { | 1155 | for (i = 0; i < count; i++) { |
1159 | buf = kmalloc(bufsize * sizeof(u8),GFP_ATOMIC); | 1156 | buf = kmalloc(bufsize * sizeof(u8), GFP_ATOMIC); |
1160 | if (buf == NULL) { | 1157 | if (buf == NULL) { |
1161 | DMESGE("Failed to kmalloc RX buffer"); | 1158 | DMESGE("Failed to kmalloc RX buffer"); |
1162 | return -1; | 1159 | return -1; |
1163 | } | 1160 | } |
1164 | 1161 | ||
1165 | dma_tmp = pci_map_single(pdev,buf,bufsize * sizeof(u8), | 1162 | dma_tmp = pci_map_single(pdev, buf, bufsize * sizeof(u8), |
1166 | PCI_DMA_FROMDEVICE); | 1163 | PCI_DMA_FROMDEVICE); |
1167 | 1164 | ||
1168 | if(-1 == buffer_add(&(priv->rxbuffer), buf,dma_tmp, | 1165 | if (-1 == buffer_add(&(priv->rxbuffer), buf, dma_tmp, |
1169 | &(priv->rxbufferhead))){ | 1166 | &(priv->rxbufferhead))) { |
1170 | DMESGE("Unable to allocate mem RX buf"); | 1167 | DMESGE("Unable to allocate mem RX buf"); |
1171 | return -1; | 1168 | return -1; |
1172 | } | 1169 | } |
1173 | *tmp = 0; //zero pads the header of the descriptor | 1170 | *tmp = 0; // zero pads the header of the descriptor |
1174 | *tmp = *tmp |( bufsize&0xfff); | 1171 | *tmp = *tmp | (bufsize&0xfff); |
1175 | *(tmp+2) = (u32)dma_tmp; | 1172 | *(tmp+2) = (u32)dma_tmp; |
1176 | *tmp = *tmp |(1<<31); // descriptor void, owned by the NIC | 1173 | *tmp = *tmp | (1<<31); // descriptor void, owned by the NIC |
1177 | 1174 | ||
1178 | tmp=tmp+rx_desc_size; | 1175 | tmp = tmp+rx_desc_size; |
1179 | } | 1176 | } |
1180 | 1177 | ||
1181 | *(tmp-rx_desc_size) = *(tmp-rx_desc_size) | (1<<30); // this is the last descriptor | 1178 | *(tmp-rx_desc_size) = *(tmp-rx_desc_size) | (1<<30); // this is the last descriptor |
@@ -1189,10 +1186,10 @@ void set_nic_rxring(struct net_device *dev) | |||
1189 | u8 pgreg; | 1186 | u8 pgreg; |
1190 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 1187 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
1191 | 1188 | ||
1192 | pgreg=read_nic_byte(dev, PGSELECT); | 1189 | pgreg = read_nic_byte(dev, PGSELECT); |
1193 | write_nic_byte(dev, PGSELECT, pgreg &~ (1<<PGSELECT_PG_SHIFT)); | 1190 | write_nic_byte(dev, PGSELECT, pgreg & ~(1<<PGSELECT_PG_SHIFT)); |
1194 | 1191 | ||
1195 | write_nic_dword(dev, RXRING_ADDR,priv->rxringdma); | 1192 | write_nic_dword(dev, RXRING_ADDR, priv->rxringdma); |
1196 | } | 1193 | } |
1197 | 1194 | ||
1198 | void rtl8180_reset(struct net_device *dev) | 1195 | void rtl8180_reset(struct net_device *dev) |
@@ -1201,28 +1198,28 @@ void rtl8180_reset(struct net_device *dev) | |||
1201 | 1198 | ||
1202 | rtl8180_irq_disable(dev); | 1199 | rtl8180_irq_disable(dev); |
1203 | 1200 | ||
1204 | cr=read_nic_byte(dev,CMD); | 1201 | cr = read_nic_byte(dev, CMD); |
1205 | cr = cr & 2; | 1202 | cr = cr & 2; |
1206 | cr = cr | (1<<CMD_RST_SHIFT); | 1203 | cr = cr | (1<<CMD_RST_SHIFT); |
1207 | write_nic_byte(dev,CMD,cr); | 1204 | write_nic_byte(dev, CMD, cr); |
1208 | 1205 | ||
1209 | force_pci_posting(dev); | 1206 | force_pci_posting(dev); |
1210 | 1207 | ||
1211 | mdelay(200); | 1208 | mdelay(200); |
1212 | 1209 | ||
1213 | if(read_nic_byte(dev,CMD) & (1<<CMD_RST_SHIFT)) | 1210 | if (read_nic_byte(dev, CMD) & (1<<CMD_RST_SHIFT)) |
1214 | DMESGW("Card reset timeout!"); | 1211 | DMESGW("Card reset timeout!"); |
1215 | else | 1212 | else |
1216 | DMESG("Card successfully reset"); | 1213 | DMESG("Card successfully reset"); |
1217 | 1214 | ||
1218 | rtl8180_set_mode(dev,EPROM_CMD_LOAD); | 1215 | rtl8180_set_mode(dev, EPROM_CMD_LOAD); |
1219 | force_pci_posting(dev); | 1216 | force_pci_posting(dev); |
1220 | mdelay(200); | 1217 | mdelay(200); |
1221 | } | 1218 | } |
1222 | 1219 | ||
1223 | inline u16 ieeerate2rtlrate(int rate) | 1220 | inline u16 ieeerate2rtlrate(int rate) |
1224 | { | 1221 | { |
1225 | switch(rate){ | 1222 | switch (rate) { |
1226 | case 10: | 1223 | case 10: |
1227 | return 0; | 1224 | return 0; |
1228 | case 20: | 1225 | case 20: |
@@ -1252,7 +1249,7 @@ inline u16 ieeerate2rtlrate(int rate) | |||
1252 | } | 1249 | } |
1253 | } | 1250 | } |
1254 | 1251 | ||
1255 | static u16 rtl_rate[] = {10,20,55,110,60,90,120,180,240,360,480,540,720}; | 1252 | static u16 rtl_rate[] = {10, 20, 55, 110, 60, 90, 120, 180, 240, 360, 480, 540, 720}; |
1256 | 1253 | ||
1257 | inline u16 rtl8180_rate2rate(short rate) | 1254 | inline u16 rtl8180_rate2rate(short rate) |
1258 | { | 1255 | { |
@@ -1263,7 +1260,7 @@ inline u16 rtl8180_rate2rate(short rate) | |||
1263 | 1260 | ||
1264 | inline u8 rtl8180_IsWirelessBMode(u16 rate) | 1261 | inline u8 rtl8180_IsWirelessBMode(u16 rate) |
1265 | { | 1262 | { |
1266 | if( ((rate <= 110) && (rate != 60) && (rate != 90)) || (rate == 220) ) | 1263 | if (((rate <= 110) && (rate != 60) && (rate != 90)) || (rate == 220)) |
1267 | return 1; | 1264 | return 1; |
1268 | else | 1265 | else |
1269 | return 0; | 1266 | return 0; |
@@ -1335,7 +1332,7 @@ u16 N_DBPSOfRate(u16 DataRate) | |||
1335 | 1332 | ||
1336 | // | 1333 | // |
1337 | // Description: | 1334 | // Description: |
1338 | // For Netgear case, they want good-looking singal strength. | 1335 | // For Netgear case, they want good-looking singal strength. |
1339 | // | 1336 | // |
1340 | long NetgearSignalStrengthTranslate(long LastSS, long CurrSS) | 1337 | long NetgearSignalStrengthTranslate(long LastSS, long CurrSS) |
1341 | { | 1338 | { |
@@ -1364,8 +1361,8 @@ long NetgearSignalStrengthTranslate(long LastSS, long CurrSS) | |||
1364 | RetSS = CurrSS; | 1361 | RetSS = CurrSS; |
1365 | 1362 | ||
1366 | // Step 2. Smoothing. | 1363 | // Step 2. Smoothing. |
1367 | if(LastSS > 0) | 1364 | if (LastSS > 0) |
1368 | RetSS = ((LastSS * 5) + (RetSS)+ 5) / 6; | 1365 | RetSS = ((LastSS * 5) + (RetSS) + 5) / 6; |
1369 | 1366 | ||
1370 | return RetSS; | 1367 | return RetSS; |
1371 | } | 1368 | } |
@@ -1399,11 +1396,11 @@ void PerformUndecoratedSignalSmoothing8185(struct r8180_priv *priv, | |||
1399 | priv->bCurCCKPkt = bCckRate; | 1396 | priv->bCurCCKPkt = bCckRate; |
1400 | 1397 | ||
1401 | if (priv->UndecoratedSmoothedSS >= 0) | 1398 | if (priv->UndecoratedSmoothedSS >= 0) |
1402 | priv->UndecoratedSmoothedSS = ( (priv->UndecoratedSmoothedSS * 5) + (priv->SignalStrength * 10) ) / 6; | 1399 | priv->UndecoratedSmoothedSS = ((priv->UndecoratedSmoothedSS * 5) + (priv->SignalStrength * 10)) / 6; |
1403 | else | 1400 | else |
1404 | priv->UndecoratedSmoothedSS = priv->SignalStrength * 10; | 1401 | priv->UndecoratedSmoothedSS = priv->SignalStrength * 10; |
1405 | 1402 | ||
1406 | priv->UndercorateSmoothedRxPower = ( (priv->UndercorateSmoothedRxPower * 50) + (priv->RxPower* 11)) / 60; | 1403 | priv->UndercorateSmoothedRxPower = ((priv->UndercorateSmoothedRxPower * 50) + (priv->RxPower * 11)) / 60; |
1407 | 1404 | ||
1408 | if (bCckRate) | 1405 | if (bCckRate) |
1409 | priv->CurCCKRSSI = priv->RSSI; | 1406 | priv->CurCCKRSSI = priv->RSSI; |
@@ -1417,23 +1414,23 @@ void rtl8180_rx(struct net_device *dev) | |||
1417 | { | 1414 | { |
1418 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 1415 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
1419 | struct sk_buff *tmp_skb; | 1416 | struct sk_buff *tmp_skb; |
1420 | short first,last; | 1417 | short first, last; |
1421 | u32 len; | 1418 | u32 len; |
1422 | int lastlen; | 1419 | int lastlen; |
1423 | unsigned char quality, signal; | 1420 | unsigned char quality, signal; |
1424 | u8 rate; | 1421 | u8 rate; |
1425 | u32 *tmp,*tmp2; | 1422 | u32 *tmp, *tmp2; |
1426 | u8 rx_desc_size; | 1423 | u8 rx_desc_size; |
1427 | u8 padding; | 1424 | u8 padding; |
1428 | char rxpower = 0; | 1425 | char rxpower = 0; |
1429 | u32 RXAGC = 0; | 1426 | u32 RXAGC = 0; |
1430 | long RxAGC_dBm = 0; | 1427 | long RxAGC_dBm = 0; |
1431 | u8 LNA=0, BB=0; | 1428 | u8 LNA = 0, BB = 0; |
1432 | u8 LNA_gain[4] = {02, 17, 29, 39}; | 1429 | u8 LNA_gain[4] = {02, 17, 29, 39}; |
1433 | u8 Antenna = 0; | 1430 | u8 Antenna = 0; |
1434 | struct ieee80211_hdr_4addr *hdr; | 1431 | struct ieee80211_hdr_4addr *hdr; |
1435 | u16 fc,type; | 1432 | u16 fc, type; |
1436 | u8 bHwError = 0,bCRC = 0,bICV = 0; | 1433 | u8 bHwError = 0, bCRC = 0, bICV = 0; |
1437 | bool bCckRate = false; | 1434 | bool bCckRate = false; |
1438 | u8 RSSI = 0; | 1435 | u8 RSSI = 0; |
1439 | long SignalStrengthIndex = 0; | 1436 | long SignalStrengthIndex = 0; |
@@ -1456,27 +1453,28 @@ void rtl8180_rx(struct net_device *dev) | |||
1456 | 1453 | ||
1457 | tmp2 = NULL; | 1454 | tmp2 = NULL; |
1458 | tmp = priv->rxringtail; | 1455 | tmp = priv->rxringtail; |
1459 | do{ | 1456 | do { |
1460 | if(tmp == priv->rxring) | 1457 | if (tmp == priv->rxring) |
1461 | tmp = priv->rxring + (priv->rxringcount - 1)*rx_desc_size; | 1458 | tmp = priv->rxring + (priv->rxringcount - 1)*rx_desc_size; |
1462 | else | 1459 | else |
1463 | tmp -= rx_desc_size; | 1460 | tmp -= rx_desc_size; |
1464 | 1461 | ||
1465 | if(! (*tmp & (1<<31))) | 1462 | if (!(*tmp & (1<<31))) |
1466 | tmp2 = tmp; | 1463 | tmp2 = tmp; |
1467 | }while(tmp != priv->rxring); | 1464 | } while (tmp != priv->rxring); |
1468 | 1465 | ||
1469 | if(tmp2) priv->rxringtail = tmp2; | 1466 | if (tmp2) |
1467 | priv->rxringtail = tmp2; | ||
1470 | } | 1468 | } |
1471 | 1469 | ||
1472 | /* while there are filled descriptors */ | 1470 | /* while there are filled descriptors */ |
1473 | while(!(*(priv->rxringtail) & (1<<31))){ | 1471 | while (!(*(priv->rxringtail) & (1<<31))) { |
1474 | if(*(priv->rxringtail) & (1<<26)) | 1472 | if (*(priv->rxringtail) & (1<<26)) |
1475 | DMESGW("RX buffer overflow"); | 1473 | DMESGW("RX buffer overflow"); |
1476 | if(*(priv->rxringtail) & (1<<12)) | 1474 | if (*(priv->rxringtail) & (1<<12)) |
1477 | priv->stats.rxicverr++; | 1475 | priv->stats.rxicverr++; |
1478 | 1476 | ||
1479 | if(*(priv->rxringtail) & (1<<27)){ | 1477 | if (*(priv->rxringtail) & (1<<27)) { |
1480 | priv->stats.rxdmafail++; | 1478 | priv->stats.rxdmafail++; |
1481 | //DMESG("EE: RX DMA FAILED at buffer pointed by descriptor %x",(u32)priv->rxringtail); | 1479 | //DMESG("EE: RX DMA FAILED at buffer pointed by descriptor %x",(u32)priv->rxringtail); |
1482 | goto drop; | 1480 | goto drop; |
@@ -1488,12 +1486,13 @@ void rtl8180_rx(struct net_device *dev) | |||
1488 | sizeof(u8), | 1486 | sizeof(u8), |
1489 | PCI_DMA_FROMDEVICE); | 1487 | PCI_DMA_FROMDEVICE); |
1490 | 1488 | ||
1491 | first = *(priv->rxringtail) & (1<<29) ? 1:0; | 1489 | first = *(priv->rxringtail) & (1<<29) ? 1 : 0; |
1492 | if(first) priv->rx_prevlen=0; | 1490 | if (first) |
1491 | priv->rx_prevlen = 0; | ||
1493 | 1492 | ||
1494 | last = *(priv->rxringtail) & (1<<28) ? 1:0; | 1493 | last = *(priv->rxringtail) & (1<<28) ? 1 : 0; |
1495 | if(last){ | 1494 | if (last) { |
1496 | lastlen=((*priv->rxringtail) &0xfff); | 1495 | lastlen = ((*priv->rxringtail) & 0xfff); |
1497 | 1496 | ||
1498 | /* if the last descriptor (that should | 1497 | /* if the last descriptor (that should |
1499 | * tell us the total packet len) tell | 1498 | * tell us the total packet len) tell |
@@ -1502,109 +1501,101 @@ void rtl8180_rx(struct net_device *dev) | |||
1502 | * problem.. | 1501 | * problem.. |
1503 | * workaround to prevent kernel panic | 1502 | * workaround to prevent kernel panic |
1504 | */ | 1503 | */ |
1505 | if(lastlen < priv->rx_prevlen) | 1504 | if (lastlen < priv->rx_prevlen) |
1506 | len=0; | 1505 | len = 0; |
1507 | else | 1506 | else |
1508 | len=lastlen-priv->rx_prevlen; | 1507 | len = lastlen-priv->rx_prevlen; |
1509 | 1508 | ||
1510 | if(*(priv->rxringtail) & (1<<13)) { | 1509 | if (*(priv->rxringtail) & (1<<13)) { |
1511 | if ((*(priv->rxringtail) & 0xfff) <500) | 1510 | if ((*(priv->rxringtail) & 0xfff) < 500) |
1512 | priv->stats.rxcrcerrmin++; | 1511 | priv->stats.rxcrcerrmin++; |
1513 | else if ((*(priv->rxringtail) & 0x0fff) >1000) | 1512 | else if ((*(priv->rxringtail) & 0x0fff) > 1000) |
1514 | priv->stats.rxcrcerrmax++; | 1513 | priv->stats.rxcrcerrmax++; |
1515 | else | 1514 | else |
1516 | priv->stats.rxcrcerrmid++; | 1515 | priv->stats.rxcrcerrmid++; |
1517 | 1516 | ||
1518 | } | 1517 | } |
1519 | 1518 | ||
1520 | }else{ | 1519 | } else { |
1521 | len = priv->rxbuffersize; | 1520 | len = priv->rxbuffersize; |
1522 | } | 1521 | } |
1523 | 1522 | ||
1524 | if(first && last) { | 1523 | if (first && last) { |
1525 | padding = ((*(priv->rxringtail+3))&(0x04000000))>>26; | 1524 | padding = ((*(priv->rxringtail+3))&(0x04000000))>>26; |
1526 | }else if(first) { | 1525 | } else if (first) { |
1527 | padding = ((*(priv->rxringtail+3))&(0x04000000))>>26; | 1526 | padding = ((*(priv->rxringtail+3))&(0x04000000))>>26; |
1528 | if(padding) { | 1527 | if (padding) |
1529 | len -= 2; | 1528 | len -= 2; |
1530 | } | 1529 | } else { |
1531 | }else { | ||
1532 | padding = 0; | 1530 | padding = 0; |
1533 | } | 1531 | } |
1534 | padding = 0; | 1532 | padding = 0; |
1535 | priv->rx_prevlen+=len; | 1533 | priv->rx_prevlen += len; |
1536 | 1534 | ||
1537 | if(priv->rx_prevlen > MAX_FRAG_THRESHOLD + 100){ | 1535 | if (priv->rx_prevlen > MAX_FRAG_THRESHOLD + 100) { |
1538 | /* HW is probably passing several buggy frames | 1536 | /* HW is probably passing several buggy frames |
1539 | * without FD or LD flag set. | 1537 | * without FD or LD flag set. |
1540 | * Throw this garbage away to prevent skb | 1538 | * Throw this garbage away to prevent skb |
1541 | * memory exausting | 1539 | * memory exausting |
1542 | */ | 1540 | */ |
1543 | if(!priv->rx_skb_complete) | 1541 | if (!priv->rx_skb_complete) |
1544 | dev_kfree_skb_any(priv->rx_skb); | 1542 | dev_kfree_skb_any(priv->rx_skb); |
1545 | priv->rx_skb_complete = 1; | 1543 | priv->rx_skb_complete = 1; |
1546 | } | 1544 | } |
1547 | 1545 | ||
1548 | signal=(unsigned char)(((*(priv->rxringtail+3))& (0x00ff0000))>>16); | 1546 | signal = (unsigned char)(((*(priv->rxringtail+3)) & (0x00ff0000))>>16); |
1549 | signal = (signal & 0xfe) >> 1; | 1547 | signal = (signal & 0xfe) >> 1; |
1550 | 1548 | ||
1551 | quality=(unsigned char)((*(priv->rxringtail+3)) & (0xff)); | 1549 | quality = (unsigned char)((*(priv->rxringtail+3)) & (0xff)); |
1552 | 1550 | ||
1553 | stats.mac_time[0] = *(priv->rxringtail+1); | 1551 | stats.mac_time[0] = *(priv->rxringtail+1); |
1554 | stats.mac_time[1] = *(priv->rxringtail+2); | 1552 | stats.mac_time[1] = *(priv->rxringtail+2); |
1555 | rxpower =((char)(((*(priv->rxringtail+4))& (0x00ff0000))>>16))/2 - 42; | 1553 | rxpower = ((char)(((*(priv->rxringtail+4)) & (0x00ff0000))>>16))/2 - 42; |
1556 | RSSI = ((u8)(((*(priv->rxringtail+3)) & (0x0000ff00))>> 8)) & (0x7f); | 1554 | RSSI = ((u8)(((*(priv->rxringtail+3)) & (0x0000ff00))>>8)) & (0x7f); |
1557 | 1555 | ||
1558 | rate=((*(priv->rxringtail)) & | 1556 | rate = ((*(priv->rxringtail)) & |
1559 | ((1<<23)|(1<<22)|(1<<21)|(1<<20)))>>20; | 1557 | ((1<<23)|(1<<22)|(1<<21)|(1<<20)))>>20; |
1560 | 1558 | ||
1561 | stats.rate = rtl8180_rate2rate(rate); | 1559 | stats.rate = rtl8180_rate2rate(rate); |
1562 | Antenna = (((*(priv->rxringtail +3))& (0x00008000)) == 0 )? 0:1 ; | 1560 | Antenna = (((*(priv->rxringtail+3)) & (0x00008000)) == 0) ? 0 : 1; |
1563 | if(!rtl8180_IsWirelessBMode(stats.rate)) | 1561 | if (!rtl8180_IsWirelessBMode(stats.rate)) { // OFDM rate. |
1564 | { // OFDM rate. | ||
1565 | |||
1566 | RxAGC_dBm = rxpower+1; //bias | 1562 | RxAGC_dBm = rxpower+1; //bias |
1567 | } | 1563 | } else { // CCK rate. |
1568 | else | 1564 | RxAGC_dBm = signal; //bit 0 discard |
1569 | { // CCK rate. | ||
1570 | RxAGC_dBm = signal;//bit 0 discard | ||
1571 | 1565 | ||
1572 | LNA = (u8) (RxAGC_dBm & 0x60 ) >> 5 ; //bit 6~ bit 5 | 1566 | LNA = (u8) (RxAGC_dBm & 0x60) >> 5 ; //bit 6~ bit 5 |
1573 | BB = (u8) (RxAGC_dBm & 0x1F); // bit 4 ~ bit 0 | 1567 | BB = (u8) (RxAGC_dBm & 0x1F); // bit 4 ~ bit 0 |
1574 | 1568 | ||
1575 | RxAGC_dBm = -( LNA_gain[LNA] + (BB *2) ); //Pin_11b=-(LNA_gain+BB_gain) (dBm) | 1569 | RxAGC_dBm = -(LNA_gain[LNA] + (BB*2)); //Pin_11b=-(LNA_gain+BB_gain) (dBm) |
1576 | 1570 | ||
1577 | RxAGC_dBm +=4; //bias | 1571 | RxAGC_dBm += 4; //bias |
1578 | } | 1572 | } |
1579 | 1573 | ||
1580 | if(RxAGC_dBm & 0x80) //absolute value | 1574 | if (RxAGC_dBm & 0x80) //absolute value |
1581 | RXAGC= ~(RxAGC_dBm)+1; | 1575 | RXAGC = ~(RxAGC_dBm)+1; |
1582 | bCckRate = rtl8180_IsWirelessBMode(stats.rate); | 1576 | bCckRate = rtl8180_IsWirelessBMode(stats.rate); |
1583 | // Translate RXAGC into 1-100. | 1577 | // Translate RXAGC into 1-100. |
1584 | if(!rtl8180_IsWirelessBMode(stats.rate)) | 1578 | if (!rtl8180_IsWirelessBMode(stats.rate)) { // OFDM rate. |
1585 | { // OFDM rate. | 1579 | if (RXAGC > 90) |
1586 | if(RXAGC>90) | 1580 | RXAGC = 90; |
1587 | RXAGC=90; | 1581 | else if (RXAGC < 25) |
1588 | else if(RXAGC<25) | 1582 | RXAGC = 25; |
1589 | RXAGC=25; | 1583 | RXAGC = (90-RXAGC)*100/65; |
1590 | RXAGC=(90-RXAGC)*100/65; | 1584 | } else { // CCK rate. |
1591 | } | 1585 | if (RXAGC > 95) |
1592 | else | 1586 | RXAGC = 95; |
1593 | { // CCK rate. | 1587 | else if (RXAGC < 30) |
1594 | if(RXAGC>95) | 1588 | RXAGC = 30; |
1595 | RXAGC=95; | 1589 | RXAGC = (95-RXAGC)*100/65; |
1596 | else if(RXAGC<30) | ||
1597 | RXAGC=30; | ||
1598 | RXAGC=(95-RXAGC)*100/65; | ||
1599 | } | 1590 | } |
1600 | priv->SignalStrength = (u8)RXAGC; | 1591 | priv->SignalStrength = (u8)RXAGC; |
1601 | priv->RecvSignalPower = RxAGC_dBm; | 1592 | priv->RecvSignalPower = RxAGC_dBm; |
1602 | priv->RxPower = rxpower; | 1593 | priv->RxPower = rxpower; |
1603 | priv->RSSI = RSSI; | 1594 | priv->RSSI = RSSI; |
1604 | /* SQ translation formula is provided by SD3 DZ. 2006.06.27 */ | 1595 | /* SQ translation formula is provided by SD3 DZ. 2006.06.27 */ |
1605 | if(quality >= 127) | 1596 | if (quality >= 127) |
1606 | quality = 1;//0; //0 will cause epc to show signal zero , walk aroud now; | 1597 | quality = 1;//0; //0 will cause epc to show signal zero , walk aroud now; |
1607 | else if(quality < 27) | 1598 | else if (quality < 27) |
1608 | quality = 100; | 1599 | quality = 100; |
1609 | else | 1600 | else |
1610 | quality = 127 - quality; | 1601 | quality = 127 - quality; |
@@ -1612,31 +1603,30 @@ void rtl8180_rx(struct net_device *dev) | |||
1612 | 1603 | ||
1613 | stats.signal = (u8)quality;//priv->wstats.qual.level = priv->SignalStrength; | 1604 | stats.signal = (u8)quality;//priv->wstats.qual.level = priv->SignalStrength; |
1614 | stats.signalstrength = RXAGC; | 1605 | stats.signalstrength = RXAGC; |
1615 | if(stats.signalstrength > 100) | 1606 | if (stats.signalstrength > 100) |
1616 | stats.signalstrength = 100; | 1607 | stats.signalstrength = 100; |
1617 | stats.signalstrength = (stats.signalstrength * 70)/100 + 30; | 1608 | stats.signalstrength = (stats.signalstrength * 70)/100 + 30; |
1618 | // printk("==========================>rx : RXAGC is %d,signalstrength is %d\n",RXAGC,stats.signalstrength); | 1609 | // printk("==========================>rx : RXAGC is %d,signalstrength is %d\n",RXAGC,stats.signalstrength); |
1619 | stats.rssi = priv->wstats.qual.qual = priv->SignalQuality; | 1610 | stats.rssi = priv->wstats.qual.qual = priv->SignalQuality; |
1620 | stats.noise = priv->wstats.qual.noise = 100 - priv ->wstats.qual.qual; | 1611 | stats.noise = priv->wstats.qual.noise = 100 - priv->wstats.qual.qual; |
1621 | bHwError = (((*(priv->rxringtail))& (0x00000fff)) == 4080)| (((*(priv->rxringtail))& (0x04000000)) != 0 ) | 1612 | bHwError = (((*(priv->rxringtail)) & (0x00000fff)) == 4080) | (((*(priv->rxringtail)) & (0x04000000)) != 0) |
1622 | | (((*(priv->rxringtail))& (0x08000000)) != 0 )| (((~(*(priv->rxringtail)))& (0x10000000)) != 0 )| (((~(*(priv->rxringtail)))& (0x20000000)) != 0 ); | 1613 | | (((*(priv->rxringtail)) & (0x08000000)) != 0) | (((~(*(priv->rxringtail))) & (0x10000000)) != 0) | (((~(*(priv->rxringtail))) & (0x20000000)) != 0); |
1623 | bCRC = ((*(priv->rxringtail)) & (0x00002000)) >> 13; | 1614 | bCRC = ((*(priv->rxringtail)) & (0x00002000)) >> 13; |
1624 | bICV = ((*(priv->rxringtail)) & (0x00001000)) >> 12; | 1615 | bICV = ((*(priv->rxringtail)) & (0x00001000)) >> 12; |
1625 | hdr = (struct ieee80211_hdr_4addr *)priv->rxbuffer->buf; | 1616 | hdr = (struct ieee80211_hdr_4addr *)priv->rxbuffer->buf; |
1626 | fc = le16_to_cpu(hdr->frame_ctl); | 1617 | fc = le16_to_cpu(hdr->frame_ctl); |
1627 | type = WLAN_FC_GET_TYPE(fc); | 1618 | type = WLAN_FC_GET_TYPE(fc); |
1628 | 1619 | ||
1629 | if((IEEE80211_FTYPE_CTL != type) && | 1620 | if ((IEEE80211_FTYPE_CTL != type) && |
1630 | (eqMacAddr(priv->ieee80211->current_network.bssid, (fc & IEEE80211_FCTL_TODS)? hdr->addr1 : (fc & IEEE80211_FCTL_FROMDS )? hdr->addr2 : hdr->addr3)) | 1621 | (eqMacAddr(priv->ieee80211->current_network.bssid, (fc & IEEE80211_FCTL_TODS) ? hdr->addr1 : (fc & IEEE80211_FCTL_FROMDS) ? hdr->addr2 : hdr->addr3)) |
1631 | && (!bHwError) && (!bCRC)&& (!bICV)) | 1622 | && (!bHwError) && (!bCRC) && (!bICV)) { |
1632 | { | ||
1633 | /* Perform signal smoothing for dynamic | 1623 | /* Perform signal smoothing for dynamic |
1634 | * mechanism on demand. This is different | 1624 | * mechanism on demand. This is different |
1635 | * with PerformSignalSmoothing8185 in smoothing | 1625 | * with PerformSignalSmoothing8185 in smoothing |
1636 | * fomula. No dramatic adjustion is apply | 1626 | * fomula. No dramatic adjustion is apply |
1637 | * because dynamic mechanism need some degree | 1627 | * because dynamic mechanism need some degree |
1638 | * of correctness. */ | 1628 | * of correctness. */ |
1639 | PerformUndecoratedSignalSmoothing8185(priv,bCckRate); | 1629 | PerformUndecoratedSignalSmoothing8185(priv, bCckRate); |
1640 | // | 1630 | // |
1641 | // For good-looking singal strength. | 1631 | // For good-looking singal strength. |
1642 | // | 1632 | // |
@@ -1650,73 +1640,75 @@ void rtl8180_rx(struct net_device *dev) | |||
1650 | // We need more correct power of received packets and the "SignalStrength" of RxStats is beautified, | 1640 | // We need more correct power of received packets and the "SignalStrength" of RxStats is beautified, |
1651 | // so we record the correct power here. | 1641 | // so we record the correct power here. |
1652 | // | 1642 | // |
1653 | priv->Stats_SignalQuality =(long) (priv->Stats_SignalQuality * 5 + (long)priv->SignalQuality + 5) / 6; | 1643 | priv->Stats_SignalQuality = (long)(priv->Stats_SignalQuality * 5 + (long)priv->SignalQuality + 5) / 6; |
1654 | priv->Stats_RecvSignalPower = (long)(priv->Stats_RecvSignalPower * 5 + priv->RecvSignalPower -1) / 6; | 1644 | priv->Stats_RecvSignalPower = (long)(priv->Stats_RecvSignalPower * 5 + priv->RecvSignalPower - 1) / 6; |
1655 | 1645 | ||
1656 | // Figure out which antenna that received the lasted packet. | 1646 | // Figure out which antenna that received the lasted packet. |
1657 | priv->LastRxPktAntenna = Antenna ? 1 : 0; // 0: aux, 1: main. | 1647 | priv->LastRxPktAntenna = Antenna ? 1 : 0; // 0: aux, 1: main. |
1658 | SwAntennaDiversityRxOk8185(dev, priv->SignalStrength); | 1648 | SwAntennaDiversityRxOk8185(dev, priv->SignalStrength); |
1659 | } | 1649 | } |
1660 | 1650 | ||
1661 | if(first){ | 1651 | if (first) { |
1662 | if(!priv->rx_skb_complete){ | 1652 | if (!priv->rx_skb_complete) { |
1663 | /* seems that HW sometimes fails to reiceve and | 1653 | /* seems that HW sometimes fails to reiceve and |
1664 | doesn't provide the last descriptor */ | 1654 | doesn't provide the last descriptor */ |
1665 | dev_kfree_skb_any(priv->rx_skb); | 1655 | dev_kfree_skb_any(priv->rx_skb); |
1666 | priv->stats.rxnolast++; | 1656 | priv->stats.rxnolast++; |
1667 | } | 1657 | } |
1668 | /* support for prism header has been originally added by Christian */ | 1658 | /* support for prism header has been originally added by Christian */ |
1669 | if(priv->prism_hdr && priv->ieee80211->iw_mode == IW_MODE_MONITOR){ | 1659 | if (priv->prism_hdr && priv->ieee80211->iw_mode == IW_MODE_MONITOR) { |
1670 | 1660 | ||
1671 | }else{ | 1661 | } else { |
1672 | priv->rx_skb = dev_alloc_skb(len+2); | 1662 | priv->rx_skb = dev_alloc_skb(len+2); |
1673 | if( !priv->rx_skb) goto drop; | 1663 | if (!priv->rx_skb) |
1664 | goto drop; | ||
1674 | } | 1665 | } |
1675 | 1666 | ||
1676 | priv->rx_skb_complete=0; | 1667 | priv->rx_skb_complete = 0; |
1677 | priv->rx_skb->dev=dev; | 1668 | priv->rx_skb->dev = dev; |
1678 | }else{ | 1669 | } else { |
1679 | /* if we are here we should have already RXed | 1670 | /* if we are here we should have already RXed |
1680 | * the first frame. | 1671 | * the first frame. |
1681 | * If we get here and the skb is not allocated then | 1672 | * If we get here and the skb is not allocated then |
1682 | * we have just throw out garbage (skb not allocated) | 1673 | * we have just throw out garbage (skb not allocated) |
1683 | * and we are still rxing garbage.... | 1674 | * and we are still rxing garbage.... |
1684 | */ | 1675 | */ |
1685 | if(!priv->rx_skb_complete){ | 1676 | if (!priv->rx_skb_complete) { |
1686 | 1677 | ||
1687 | tmp_skb= dev_alloc_skb(priv->rx_skb->len +len+2); | 1678 | tmp_skb = dev_alloc_skb(priv->rx_skb->len+len+2); |
1688 | 1679 | ||
1689 | if(!tmp_skb) goto drop; | 1680 | if (!tmp_skb) |
1681 | goto drop; | ||
1690 | 1682 | ||
1691 | tmp_skb->dev=dev; | 1683 | tmp_skb->dev = dev; |
1692 | 1684 | ||
1693 | memcpy(skb_put(tmp_skb,priv->rx_skb->len), | 1685 | memcpy(skb_put(tmp_skb, priv->rx_skb->len), |
1694 | priv->rx_skb->data, | 1686 | priv->rx_skb->data, |
1695 | priv->rx_skb->len); | 1687 | priv->rx_skb->len); |
1696 | 1688 | ||
1697 | dev_kfree_skb_any(priv->rx_skb); | 1689 | dev_kfree_skb_any(priv->rx_skb); |
1698 | 1690 | ||
1699 | priv->rx_skb=tmp_skb; | 1691 | priv->rx_skb = tmp_skb; |
1700 | } | 1692 | } |
1701 | } | 1693 | } |
1702 | 1694 | ||
1703 | if(!priv->rx_skb_complete) { | 1695 | if (!priv->rx_skb_complete) { |
1704 | if(padding) { | 1696 | if (padding) { |
1705 | memcpy(skb_put(priv->rx_skb,len), | 1697 | memcpy(skb_put(priv->rx_skb, len), |
1706 | (((unsigned char *)priv->rxbuffer->buf) + 2),len); | 1698 | (((unsigned char *)priv->rxbuffer->buf) + 2), len); |
1707 | } else { | 1699 | } else { |
1708 | memcpy(skb_put(priv->rx_skb,len), | 1700 | memcpy(skb_put(priv->rx_skb, len), |
1709 | priv->rxbuffer->buf,len); | 1701 | priv->rxbuffer->buf, len); |
1710 | } | 1702 | } |
1711 | } | 1703 | } |
1712 | 1704 | ||
1713 | if(last && !priv->rx_skb_complete){ | 1705 | if (last && !priv->rx_skb_complete) { |
1714 | if(priv->rx_skb->len > 4) | 1706 | if (priv->rx_skb->len > 4) |
1715 | skb_trim(priv->rx_skb,priv->rx_skb->len-4); | 1707 | skb_trim(priv->rx_skb, priv->rx_skb->len-4); |
1716 | if(!ieee80211_rtl_rx(priv->ieee80211, | 1708 | if (!ieee80211_rtl_rx(priv->ieee80211, |
1717 | priv->rx_skb, &stats)) | 1709 | priv->rx_skb, &stats)) |
1718 | dev_kfree_skb_any(priv->rx_skb); | 1710 | dev_kfree_skb_any(priv->rx_skb); |
1719 | priv->rx_skb_complete=1; | 1711 | priv->rx_skb_complete = 1; |
1720 | } | 1712 | } |
1721 | 1713 | ||
1722 | pci_dma_sync_single_for_device(priv->pdev, | 1714 | pci_dma_sync_single_for_device(priv->pdev, |
@@ -1727,20 +1719,20 @@ void rtl8180_rx(struct net_device *dev) | |||
1727 | 1719 | ||
1728 | drop: // this is used when we have not enough mem | 1720 | drop: // this is used when we have not enough mem |
1729 | /* restore the descriptor */ | 1721 | /* restore the descriptor */ |
1730 | *(priv->rxringtail+2)=priv->rxbuffer->dma; | 1722 | *(priv->rxringtail+2) = priv->rxbuffer->dma; |
1731 | *(priv->rxringtail)=*(priv->rxringtail) &~ 0xfff; | 1723 | *(priv->rxringtail) = *(priv->rxringtail) & ~0xfff; |
1732 | *(priv->rxringtail)= | 1724 | *(priv->rxringtail) = |
1733 | *(priv->rxringtail) | priv->rxbuffersize; | 1725 | *(priv->rxringtail) | priv->rxbuffersize; |
1734 | 1726 | ||
1735 | *(priv->rxringtail)= | 1727 | *(priv->rxringtail) = |
1736 | *(priv->rxringtail) | (1<<31); | 1728 | *(priv->rxringtail) | (1<<31); |
1737 | 1729 | ||
1738 | priv->rxringtail+=rx_desc_size; | 1730 | priv->rxringtail += rx_desc_size; |
1739 | if(priv->rxringtail >= | 1731 | if (priv->rxringtail >= |
1740 | (priv->rxring)+(priv->rxringcount )*rx_desc_size) | 1732 | (priv->rxring)+(priv->rxringcount)*rx_desc_size) |
1741 | priv->rxringtail=priv->rxring; | 1733 | priv->rxringtail = priv->rxring; |
1742 | 1734 | ||
1743 | priv->rxbuffer=(priv->rxbuffer->next); | 1735 | priv->rxbuffer = (priv->rxbuffer->next); |
1744 | } | 1736 | } |
1745 | } | 1737 | } |
1746 | 1738 | ||
@@ -1749,10 +1741,10 @@ void rtl8180_dma_kick(struct net_device *dev, int priority) | |||
1749 | { | 1741 | { |
1750 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 1742 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
1751 | 1743 | ||
1752 | rtl8180_set_mode(dev,EPROM_CMD_CONFIG); | 1744 | rtl8180_set_mode(dev, EPROM_CMD_CONFIG); |
1753 | write_nic_byte(dev, TX_DMA_POLLING, | 1745 | write_nic_byte(dev, TX_DMA_POLLING, |
1754 | (1 << (priority + 1)) | priv->dma_poll_mask); | 1746 | (1 << (priority + 1)) | priv->dma_poll_mask); |
1755 | rtl8180_set_mode(dev,EPROM_CMD_NORMAL); | 1747 | rtl8180_set_mode(dev, EPROM_CMD_NORMAL); |
1756 | 1748 | ||
1757 | force_pci_posting(dev); | 1749 | force_pci_posting(dev); |
1758 | } | 1750 | } |
@@ -1761,31 +1753,30 @@ void rtl8180_data_hard_stop(struct net_device *dev) | |||
1761 | { | 1753 | { |
1762 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 1754 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
1763 | 1755 | ||
1764 | rtl8180_set_mode(dev,EPROM_CMD_CONFIG); | 1756 | rtl8180_set_mode(dev, EPROM_CMD_CONFIG); |
1765 | priv->dma_poll_stop_mask |= TPPOLLSTOP_AC_VIQ; | 1757 | priv->dma_poll_stop_mask |= TPPOLLSTOP_AC_VIQ; |
1766 | write_nic_byte(dev,TPPollStop, priv->dma_poll_stop_mask); | 1758 | write_nic_byte(dev, TPPollStop, priv->dma_poll_stop_mask); |
1767 | rtl8180_set_mode(dev,EPROM_CMD_NORMAL); | 1759 | rtl8180_set_mode(dev, EPROM_CMD_NORMAL); |
1768 | } | 1760 | } |
1769 | 1761 | ||
1770 | void rtl8180_data_hard_resume(struct net_device *dev) | 1762 | void rtl8180_data_hard_resume(struct net_device *dev) |
1771 | { | 1763 | { |
1772 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 1764 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
1773 | 1765 | ||
1774 | rtl8180_set_mode(dev,EPROM_CMD_CONFIG); | 1766 | rtl8180_set_mode(dev, EPROM_CMD_CONFIG); |
1775 | priv->dma_poll_stop_mask &= ~(TPPOLLSTOP_AC_VIQ); | 1767 | priv->dma_poll_stop_mask &= ~(TPPOLLSTOP_AC_VIQ); |
1776 | write_nic_byte(dev,TPPollStop, priv->dma_poll_stop_mask); | 1768 | write_nic_byte(dev, TPPollStop, priv->dma_poll_stop_mask); |
1777 | rtl8180_set_mode(dev,EPROM_CMD_NORMAL); | 1769 | rtl8180_set_mode(dev, EPROM_CMD_NORMAL); |
1778 | } | 1770 | } |
1779 | 1771 | ||
1780 | /* this function TX data frames when the ieee80211 stack requires this. | 1772 | /* this function TX data frames when the ieee80211 stack requires this. |
1781 | * It checks also if we need to stop the ieee tx queue, eventually do it | 1773 | * It checks also if we need to stop the ieee tx queue, eventually do it |
1782 | */ | 1774 | */ |
1783 | void rtl8180_hard_data_xmit(struct sk_buff *skb,struct net_device *dev, int | 1775 | void rtl8180_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int |
1784 | rate) | 1776 | rate) { |
1785 | { | ||
1786 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 1777 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
1787 | int mode; | 1778 | int mode; |
1788 | struct ieee80211_hdr_3addr *h = (struct ieee80211_hdr_3addr *) skb->data; | 1779 | struct ieee80211_hdr_3addr *h = (struct ieee80211_hdr_3addr *) skb->data; |
1789 | short morefrag = (h->frame_control) & IEEE80211_FCTL_MOREFRAGS; | 1780 | short morefrag = (h->frame_control) & IEEE80211_FCTL_MOREFRAGS; |
1790 | unsigned long flags; | 1781 | unsigned long flags; |
1791 | int priority; | 1782 | int priority; |
@@ -1801,25 +1792,24 @@ rate) | |||
1801 | * the ieee stack. | 1792 | * the ieee stack. |
1802 | */ | 1793 | */ |
1803 | priority = AC2Q(skb->priority); | 1794 | priority = AC2Q(skb->priority); |
1804 | spin_lock_irqsave(&priv->tx_lock,flags); | 1795 | spin_lock_irqsave(&priv->tx_lock, flags); |
1805 | 1796 | ||
1806 | if(priv->ieee80211->bHwRadioOff) | 1797 | if (priv->ieee80211->bHwRadioOff) { |
1807 | { | 1798 | spin_unlock_irqrestore(&priv->tx_lock, flags); |
1808 | spin_unlock_irqrestore(&priv->tx_lock,flags); | ||
1809 | 1799 | ||
1810 | return; | 1800 | return; |
1811 | } | 1801 | } |
1812 | 1802 | ||
1813 | if (!check_nic_enought_desc(dev, priority)){ | 1803 | if (!check_nic_enought_desc(dev, priority)) { |
1814 | DMESGW("Error: no descriptor left by previous TX (avail %d) ", | 1804 | DMESGW("Error: no descriptor left by previous TX (avail %d) ", |
1815 | get_curr_tx_free_desc(dev, priority)); | 1805 | get_curr_tx_free_desc(dev, priority)); |
1816 | ieee80211_rtl_stop_queue(priv->ieee80211); | 1806 | ieee80211_rtl_stop_queue(priv->ieee80211); |
1817 | } | 1807 | } |
1818 | rtl8180_tx(dev, skb->data, skb->len, priority, morefrag,0,rate); | 1808 | rtl8180_tx(dev, skb->data, skb->len, priority, morefrag, 0, rate); |
1819 | if (!check_nic_enought_desc(dev, priority)) | 1809 | if (!check_nic_enought_desc(dev, priority)) |
1820 | ieee80211_rtl_stop_queue(priv->ieee80211); | 1810 | ieee80211_rtl_stop_queue(priv->ieee80211); |
1821 | 1811 | ||
1822 | spin_unlock_irqrestore(&priv->tx_lock,flags); | 1812 | spin_unlock_irqrestore(&priv->tx_lock, flags); |
1823 | } | 1813 | } |
1824 | 1814 | ||
1825 | /* This is a rough attempt to TX a frame | 1815 | /* This is a rough attempt to TX a frame |
@@ -1833,7 +1823,7 @@ rate) | |||
1833 | * might use a different lock than tx_lock (for example mgmt_tx_lock) | 1823 | * might use a different lock than tx_lock (for example mgmt_tx_lock) |
1834 | */ | 1824 | */ |
1835 | /* these function may loops if invoked with 0 descriptors or 0 len buffer*/ | 1825 | /* these function may loops if invoked with 0 descriptors or 0 len buffer*/ |
1836 | int rtl8180_hard_start_xmit(struct sk_buff *skb,struct net_device *dev) | 1826 | int rtl8180_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) |
1837 | { | 1827 | { |
1838 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 1828 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
1839 | unsigned long flags; | 1829 | unsigned long flags; |
@@ -1841,66 +1831,68 @@ int rtl8180_hard_start_xmit(struct sk_buff *skb,struct net_device *dev) | |||
1841 | 1831 | ||
1842 | priority = MANAGE_PRIORITY; | 1832 | priority = MANAGE_PRIORITY; |
1843 | 1833 | ||
1844 | spin_lock_irqsave(&priv->tx_lock,flags); | 1834 | spin_lock_irqsave(&priv->tx_lock, flags); |
1845 | 1835 | ||
1846 | if (priv->ieee80211->bHwRadioOff) { | 1836 | if (priv->ieee80211->bHwRadioOff) { |
1847 | spin_unlock_irqrestore(&priv->tx_lock,flags); | 1837 | spin_unlock_irqrestore(&priv->tx_lock, flags); |
1848 | dev_kfree_skb_any(skb); | 1838 | dev_kfree_skb_any(skb); |
1849 | return NETDEV_TX_OK; | 1839 | return NETDEV_TX_OK; |
1850 | } | 1840 | } |
1851 | 1841 | ||
1852 | rtl8180_tx(dev, skb->data, skb->len, priority, | 1842 | rtl8180_tx(dev, skb->data, skb->len, priority, |
1853 | 0, 0,ieeerate2rtlrate(priv->ieee80211->basic_rate)); | 1843 | 0, 0, ieeerate2rtlrate(priv->ieee80211->basic_rate)); |
1854 | 1844 | ||
1855 | priv->ieee80211->stats.tx_bytes+=skb->len; | 1845 | priv->ieee80211->stats.tx_bytes += skb->len; |
1856 | priv->ieee80211->stats.tx_packets++; | 1846 | priv->ieee80211->stats.tx_packets++; |
1857 | spin_unlock_irqrestore(&priv->tx_lock,flags); | 1847 | spin_unlock_irqrestore(&priv->tx_lock, flags); |
1858 | 1848 | ||
1859 | dev_kfree_skb_any(skb); | 1849 | dev_kfree_skb_any(skb); |
1860 | return NETDEV_TX_OK; | 1850 | return NETDEV_TX_OK; |
1861 | } | 1851 | } |
1862 | 1852 | ||
1863 | // longpre 144+48 shortpre 72+24 | 1853 | // longpre 144+48 shortpre 72+24 |
1864 | u16 rtl8180_len2duration(u32 len, short rate,short* ext) | 1854 | u16 rtl8180_len2duration(u32 len, short rate, short *ext) |
1865 | { | 1855 | { |
1866 | u16 duration; | 1856 | u16 duration; |
1867 | u16 drift; | 1857 | u16 drift; |
1868 | *ext=0; | 1858 | *ext = 0; |
1869 | 1859 | ||
1870 | switch(rate){ | 1860 | switch (rate) { |
1871 | case 0://1mbps | 1861 | case 0://1mbps |
1872 | *ext=0; | 1862 | *ext = 0; |
1873 | duration = ((len+4)<<4) /0x2; | 1863 | duration = ((len+4)<<4) / 0x2; |
1874 | drift = ((len+4)<<4) % 0x2; | 1864 | drift = ((len+4)<<4) % 0x2; |
1875 | if(drift ==0 ) break; | 1865 | if (drift == 0) |
1866 | break; | ||
1876 | duration++; | 1867 | duration++; |
1877 | break; | 1868 | break; |
1878 | case 1://2mbps | 1869 | case 1://2mbps |
1879 | *ext=0; | 1870 | *ext = 0; |
1880 | duration = ((len+4)<<4) /0x4; | 1871 | duration = ((len+4)<<4) / 0x4; |
1881 | drift = ((len+4)<<4) % 0x4; | 1872 | drift = ((len+4)<<4) % 0x4; |
1882 | if(drift ==0 ) break; | 1873 | if (drift == 0) |
1874 | break; | ||
1883 | duration++; | 1875 | duration++; |
1884 | break; | 1876 | break; |
1885 | case 2: //5.5mbps | 1877 | case 2: //5.5mbps |
1886 | *ext=0; | 1878 | *ext = 0; |
1887 | duration = ((len+4)<<4) /0xb; | 1879 | duration = ((len+4)<<4) / 0xb; |
1888 | drift = ((len+4)<<4) % 0xb; | 1880 | drift = ((len+4)<<4) % 0xb; |
1889 | if(drift ==0 ) | 1881 | if (drift == 0) |
1890 | break; | 1882 | break; |
1891 | duration++; | 1883 | duration++; |
1892 | break; | 1884 | break; |
1893 | default: | 1885 | default: |
1894 | case 3://11mbps | 1886 | case 3://11mbps |
1895 | *ext=0; | 1887 | *ext = 0; |
1896 | duration = ((len+4)<<4) /0x16; | 1888 | duration = ((len+4)<<4) / 0x16; |
1897 | drift = ((len+4)<<4) % 0x16; | 1889 | drift = ((len+4)<<4) % 0x16; |
1898 | if(drift ==0 ) | 1890 | if (drift == 0) |
1899 | break; | 1891 | break; |
1900 | duration++; | 1892 | duration++; |
1901 | if(drift > 6) | 1893 | if (drift > 6) |
1902 | break; | 1894 | break; |
1903 | *ext=1; | 1895 | *ext = 1; |
1904 | break; | 1896 | break; |
1905 | } | 1897 | } |
1906 | 1898 | ||
@@ -1914,13 +1906,13 @@ void rtl8180_prepare_beacon(struct net_device *dev) | |||
1914 | 1906 | ||
1915 | u16 word = read_nic_word(dev, BcnItv); | 1907 | u16 word = read_nic_word(dev, BcnItv); |
1916 | word &= ~BcnItv_BcnItv; // clear Bcn_Itv | 1908 | word &= ~BcnItv_BcnItv; // clear Bcn_Itv |
1917 | word |= cpu_to_le16(priv->ieee80211->current_network.beacon_interval);//0x64; | 1909 | word |= cpu_to_le16(priv->ieee80211->current_network.beacon_interval); //0x64; |
1918 | write_nic_word(dev, BcnItv, word); | 1910 | write_nic_word(dev, BcnItv, word); |
1919 | 1911 | ||
1920 | skb = ieee80211_get_beacon(priv->ieee80211); | 1912 | skb = ieee80211_get_beacon(priv->ieee80211); |
1921 | if(skb){ | 1913 | if (skb) { |
1922 | rtl8180_tx(dev,skb->data,skb->len,BEACON_PRIORITY, | 1914 | rtl8180_tx(dev, skb->data, skb->len, BEACON_PRIORITY, |
1923 | 0,0,ieeerate2rtlrate(priv->ieee80211->basic_rate)); | 1915 | 0, 0, ieeerate2rtlrate(priv->ieee80211->basic_rate)); |
1924 | dev_kfree_skb_any(skb); | 1916 | dev_kfree_skb_any(skb); |
1925 | } | 1917 | } |
1926 | } | 1918 | } |
@@ -1933,7 +1925,7 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority, | |||
1933 | short morefrag, short descfrag, int rate) | 1925 | short morefrag, short descfrag, int rate) |
1934 | { | 1926 | { |
1935 | struct r8180_priv *priv = ieee80211_priv(dev); | 1927 | struct r8180_priv *priv = ieee80211_priv(dev); |
1936 | u32 *tail,*temp_tail; | 1928 | u32 *tail, *temp_tail; |
1937 | u32 *begin; | 1929 | u32 *begin; |
1938 | u32 *buf; | 1930 | u32 *buf; |
1939 | int i; | 1931 | int i; |
@@ -1942,7 +1934,7 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority, | |||
1942 | int count; | 1934 | int count; |
1943 | u16 duration; | 1935 | u16 duration; |
1944 | short ext; | 1936 | short ext; |
1945 | struct buffer* buflist; | 1937 | struct buffer *buflist; |
1946 | struct ieee80211_hdr_3addr *frag_hdr = (struct ieee80211_hdr_3addr *)txbuf; | 1938 | struct ieee80211_hdr_3addr *frag_hdr = (struct ieee80211_hdr_3addr *)txbuf; |
1947 | u8 dest[ETH_ALEN]; | 1939 | u8 dest[ETH_ALEN]; |
1948 | u8 bUseShortPreamble = 0; | 1940 | u8 bUseShortPreamble = 0; |
@@ -1954,46 +1946,46 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority, | |||
1954 | u16 TxDescDuration = 0; | 1946 | u16 TxDescDuration = 0; |
1955 | u8 ownbit_flag = false; | 1947 | u8 ownbit_flag = false; |
1956 | 1948 | ||
1957 | switch(priority) { | 1949 | switch (priority) { |
1958 | case MANAGE_PRIORITY: | 1950 | case MANAGE_PRIORITY: |
1959 | tail=priv->txmapringtail; | 1951 | tail = priv->txmapringtail; |
1960 | begin=priv->txmapring; | 1952 | begin = priv->txmapring; |
1961 | buflist = priv->txmapbufstail; | 1953 | buflist = priv->txmapbufstail; |
1962 | count = priv->txringcount; | 1954 | count = priv->txringcount; |
1963 | break; | 1955 | break; |
1964 | case BK_PRIORITY: | 1956 | case BK_PRIORITY: |
1965 | tail=priv->txbkpringtail; | 1957 | tail = priv->txbkpringtail; |
1966 | begin=priv->txbkpring; | 1958 | begin = priv->txbkpring; |
1967 | buflist = priv->txbkpbufstail; | 1959 | buflist = priv->txbkpbufstail; |
1968 | count = priv->txringcount; | 1960 | count = priv->txringcount; |
1969 | break; | 1961 | break; |
1970 | case BE_PRIORITY: | 1962 | case BE_PRIORITY: |
1971 | tail=priv->txbepringtail; | 1963 | tail = priv->txbepringtail; |
1972 | begin=priv->txbepring; | 1964 | begin = priv->txbepring; |
1973 | buflist = priv->txbepbufstail; | 1965 | buflist = priv->txbepbufstail; |
1974 | count = priv->txringcount; | 1966 | count = priv->txringcount; |
1975 | break; | 1967 | break; |
1976 | case VI_PRIORITY: | 1968 | case VI_PRIORITY: |
1977 | tail=priv->txvipringtail; | 1969 | tail = priv->txvipringtail; |
1978 | begin=priv->txvipring; | 1970 | begin = priv->txvipring; |
1979 | buflist = priv->txvipbufstail; | 1971 | buflist = priv->txvipbufstail; |
1980 | count = priv->txringcount; | 1972 | count = priv->txringcount; |
1981 | break; | 1973 | break; |
1982 | case VO_PRIORITY: | 1974 | case VO_PRIORITY: |
1983 | tail=priv->txvopringtail; | 1975 | tail = priv->txvopringtail; |
1984 | begin=priv->txvopring; | 1976 | begin = priv->txvopring; |
1985 | buflist = priv->txvopbufstail; | 1977 | buflist = priv->txvopbufstail; |
1986 | count = priv->txringcount; | 1978 | count = priv->txringcount; |
1987 | break; | 1979 | break; |
1988 | case HI_PRIORITY: | 1980 | case HI_PRIORITY: |
1989 | tail=priv->txhpringtail; | 1981 | tail = priv->txhpringtail; |
1990 | begin=priv->txhpring; | 1982 | begin = priv->txhpring; |
1991 | buflist = priv->txhpbufstail; | 1983 | buflist = priv->txhpbufstail; |
1992 | count = priv->txringcount; | 1984 | count = priv->txringcount; |
1993 | break; | 1985 | break; |
1994 | case BEACON_PRIORITY: | 1986 | case BEACON_PRIORITY: |
1995 | tail=priv->txbeaconringtail; | 1987 | tail = priv->txbeaconringtail; |
1996 | begin=priv->txbeaconring; | 1988 | begin = priv->txbeaconring; |
1997 | buflist = priv->txbeaconbufstail; | 1989 | buflist = priv->txbeaconbufstail; |
1998 | count = priv->txbeaconcount; | 1990 | count = priv->txbeaconcount; |
1999 | break; | 1991 | break; |
@@ -2004,8 +1996,7 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority, | |||
2004 | 1996 | ||
2005 | memcpy(&dest, frag_hdr->addr1, ETH_ALEN); | 1997 | memcpy(&dest, frag_hdr->addr1, ETH_ALEN); |
2006 | if (is_multicast_ether_addr(dest) || | 1998 | if (is_multicast_ether_addr(dest) || |
2007 | is_broadcast_ether_addr(dest)) | 1999 | is_broadcast_ether_addr(dest)) { |
2008 | { | ||
2009 | Duration = 0; | 2000 | Duration = 0; |
2010 | RtsDur = 0; | 2001 | RtsDur = 0; |
2011 | bRTSEnable = 0; | 2002 | bRTSEnable = 0; |
@@ -2021,19 +2012,18 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority, | |||
2021 | 2012 | ||
2022 | /* Figure out ACK rate according to BSS basic rate | 2013 | /* Figure out ACK rate according to BSS basic rate |
2023 | * and Tx rate. */ | 2014 | * and Tx rate. */ |
2024 | AckTime = ComputeTxTime(14, 10,0, 0); // AckCTSLng = 14 use 1M bps send | 2015 | AckTime = ComputeTxTime(14, 10, 0, 0); // AckCTSLng = 14 use 1M bps send |
2025 | 2016 | ||
2026 | if ( ((len + sCrcLng) > priv->rts) && priv->rts ) | 2017 | if (((len + sCrcLng) > priv->rts) && priv->rts) { // RTS/CTS. |
2027 | { // RTS/CTS. | ||
2028 | u16 RtsTime, CtsTime; | 2018 | u16 RtsTime, CtsTime; |
2029 | //u16 CtsRate; | 2019 | //u16 CtsRate; |
2030 | bRTSEnable = 1; | 2020 | bRTSEnable = 1; |
2031 | bCTSEnable = 0; | 2021 | bCTSEnable = 0; |
2032 | 2022 | ||
2033 | // Rate and time required for RTS. | 2023 | // Rate and time required for RTS. |
2034 | RtsTime = ComputeTxTime( sAckCtsLng/8,priv->ieee80211->basic_rate, 0, 0); | 2024 | RtsTime = ComputeTxTime(sAckCtsLng/8, priv->ieee80211->basic_rate, 0, 0); |
2035 | // Rate and time required for CTS. | 2025 | // Rate and time required for CTS. |
2036 | CtsTime = ComputeTxTime(14, 10,0, 0); // AckCTSLng = 14 use 1M bps send | 2026 | CtsTime = ComputeTxTime(14, 10, 0, 0); // AckCTSLng = 14 use 1M bps send |
2037 | 2027 | ||
2038 | // Figure out time required to transmit this frame. | 2028 | // Figure out time required to transmit this frame. |
2039 | ThisFrameTime = ComputeTxTime(len + sCrcLng, | 2029 | ThisFrameTime = ComputeTxTime(len + sCrcLng, |
@@ -2045,8 +2035,7 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority, | |||
2045 | RtsDur = CtsTime + ThisFrameTime + AckTime + 3*aSifsTime; | 2035 | RtsDur = CtsTime + ThisFrameTime + AckTime + 3*aSifsTime; |
2046 | 2036 | ||
2047 | TxDescDuration = RtsTime + RtsDur; | 2037 | TxDescDuration = RtsTime + RtsDur; |
2048 | } | 2038 | } else {// Normal case. |
2049 | else {// Normal case. | ||
2050 | bCTSEnable = 0; | 2039 | bCTSEnable = 0; |
2051 | bRTSEnable = 0; | 2040 | bRTSEnable = 0; |
2052 | RtsDur = 0; | 2041 | RtsDur = 0; |
@@ -2060,10 +2049,10 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority, | |||
2060 | Duration = aSifsTime + AckTime; | 2049 | Duration = aSifsTime + AckTime; |
2061 | } else { // One or more fragments remained. | 2050 | } else { // One or more fragments remained. |
2062 | u16 NextFragTime; | 2051 | u16 NextFragTime; |
2063 | NextFragTime = ComputeTxTime( len + sCrcLng, //pretend following packet length equal current packet | 2052 | NextFragTime = ComputeTxTime(len + sCrcLng, //pretend following packet length equal current packet |
2064 | rtl8180_rate2rate(rate), | 2053 | rtl8180_rate2rate(rate), |
2065 | 0, | 2054 | 0, |
2066 | bUseShortPreamble ); | 2055 | bUseShortPreamble); |
2067 | 2056 | ||
2068 | //ThisFrag-ACk-NextFrag-ACK. | 2057 | //ThisFrag-ACk-NextFrag-ACK. |
2069 | Duration = NextFragTime + 3*aSifsTime + 2*AckTime; | 2058 | Duration = NextFragTime + 3*aSifsTime + 2*AckTime; |
@@ -2073,17 +2062,17 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority, | |||
2073 | 2062 | ||
2074 | frag_hdr->duration_id = Duration; | 2063 | frag_hdr->duration_id = Duration; |
2075 | 2064 | ||
2076 | buflen=priv->txbuffsize; | 2065 | buflen = priv->txbuffsize; |
2077 | remain=len; | 2066 | remain = len; |
2078 | temp_tail = tail; | 2067 | temp_tail = tail; |
2079 | 2068 | ||
2080 | while(remain!=0){ | 2069 | while (remain != 0) { |
2081 | mb(); | 2070 | mb(); |
2082 | if(!buflist){ | 2071 | if (!buflist) { |
2083 | DMESGE("TX buffer error, cannot TX frames. pri %d.", priority); | 2072 | DMESGE("TX buffer error, cannot TX frames. pri %d.", priority); |
2084 | return -1; | 2073 | return -1; |
2085 | } | 2074 | } |
2086 | buf=buflist->buf; | 2075 | buf = buflist->buf; |
2087 | 2076 | ||
2088 | if ((*tail & (1 << 31)) && (priority != BEACON_PRIORITY)) { | 2077 | if ((*tail & (1 << 31)) && (priority != BEACON_PRIORITY)) { |
2089 | DMESGW("No more TX desc, returning %x of %x", | 2078 | DMESGW("No more TX desc, returning %x of %x", |
@@ -2092,7 +2081,7 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority, | |||
2092 | return remain; | 2081 | return remain; |
2093 | } | 2082 | } |
2094 | 2083 | ||
2095 | *tail= 0; // zeroes header | 2084 | *tail = 0; // zeroes header |
2096 | *(tail+1) = 0; | 2085 | *(tail+1) = 0; |
2097 | *(tail+3) = 0; | 2086 | *(tail+3) = 0; |
2098 | *(tail+5) = 0; | 2087 | *(tail+5) = 0; |
@@ -2102,41 +2091,40 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority, | |||
2102 | /*FIXME: this should be triggered by HW encryption parameters.*/ | 2091 | /*FIXME: this should be triggered by HW encryption parameters.*/ |
2103 | *tail |= (1<<15); /* no encrypt */ | 2092 | *tail |= (1<<15); /* no encrypt */ |
2104 | 2093 | ||
2105 | if(remain==len && !descfrag) { | 2094 | if (remain == len && !descfrag) { |
2106 | ownbit_flag = false; | 2095 | ownbit_flag = false; |
2107 | *tail = *tail| (1<<29) ; //fist segment of the packet | 2096 | *tail = *tail | (1<<29) ; //fist segment of the packet |
2108 | *tail = *tail |(len); | 2097 | *tail = *tail | (len); |
2109 | } else { | 2098 | } else { |
2110 | ownbit_flag = true; | 2099 | ownbit_flag = true; |
2111 | } | 2100 | } |
2112 | 2101 | ||
2113 | for(i=0;i<buflen&& remain >0;i++,remain--){ | 2102 | for (i = 0; i < buflen && remain > 0; i++, remain--) { |
2114 | ((u8*)buf)[i]=txbuf[i]; //copy data into descriptor pointed DMAble buffer | 2103 | ((u8 *)buf)[i] = txbuf[i]; //copy data into descriptor pointed DMAble buffer |
2115 | if(remain == 4 && i+4 >= buflen) break; | 2104 | if (remain == 4 && i+4 >= buflen) |
2105 | break; | ||
2116 | /* ensure the last desc has at least 4 bytes payload */ | 2106 | /* ensure the last desc has at least 4 bytes payload */ |
2117 | 2107 | ||
2118 | } | 2108 | } |
2119 | txbuf = txbuf + i; | 2109 | txbuf = txbuf + i; |
2120 | *(tail+3)=*(tail+3) &~ 0xfff; | 2110 | *(tail+3) = *(tail+3) & ~0xfff; |
2121 | *(tail+3)=*(tail+3) | i; // buffer lenght | 2111 | *(tail+3) = *(tail+3) | i; // buffer lenght |
2122 | // Use short preamble or not | 2112 | // Use short preamble or not |
2123 | if (priv->ieee80211->current_network.capability&WLAN_CAPABILITY_SHORT_PREAMBLE) | 2113 | if (priv->ieee80211->current_network.capability&WLAN_CAPABILITY_SHORT_PREAMBLE) |
2124 | if (priv->plcp_preamble_mode==1 && rate!=0) // short mode now, not long! | 2114 | if (priv->plcp_preamble_mode == 1 && rate != 0) // short mode now, not long! |
2125 | ;// *tail |= (1<<16); // enable short preamble mode. | 2115 | ;// *tail |= (1<<16); // enable short preamble mode. |
2126 | 2116 | ||
2127 | if(bCTSEnable) { | 2117 | if (bCTSEnable) |
2128 | *tail |= (1<<18); | 2118 | *tail |= (1<<18); |
2129 | } | ||
2130 | 2119 | ||
2131 | if(bRTSEnable) //rts enable | 2120 | if (bRTSEnable) { //rts enable |
2132 | { | ||
2133 | *tail |= ((ieeerate2rtlrate(priv->ieee80211->basic_rate))<<19);//RTS RATE | 2121 | *tail |= ((ieeerate2rtlrate(priv->ieee80211->basic_rate))<<19);//RTS RATE |
2134 | *tail |= (1<<23);//rts enable | 2122 | *tail |= (1<<23);//rts enable |
2135 | *(tail+1) |=(RtsDur&0xffff);//RTS Duration | 2123 | *(tail+1) |= (RtsDur&0xffff);//RTS Duration |
2136 | } | 2124 | } |
2137 | *(tail+3) |= ((TxDescDuration&0xffff)<<16); //DURATION | 2125 | *(tail+3) |= ((TxDescDuration&0xffff)<<16); //DURATION |
2138 | // *(tail+3) |= (0xe6<<16); | 2126 | // *(tail+3) |= (0xe6<<16); |
2139 | *(tail+5) |= (11<<8);//(priv->retry_data<<8); //retry lim ; | 2127 | *(tail+5) |= (11<<8);//(priv->retry_data<<8); //retry lim ; |
2140 | 2128 | ||
2141 | *tail = *tail | ((rate&0xf) << 24); | 2129 | *tail = *tail | ((rate&0xf) << 24); |
2142 | 2130 | ||
@@ -2145,71 +2133,72 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority, | |||
2145 | if (!priv->hw_plcp_len) { | 2133 | if (!priv->hw_plcp_len) { |
2146 | duration = rtl8180_len2duration(len, rate, &ext); | 2134 | duration = rtl8180_len2duration(len, rate, &ext); |
2147 | *(tail+1) = *(tail+1) | ((duration & 0x7fff)<<16); | 2135 | *(tail+1) = *(tail+1) | ((duration & 0x7fff)<<16); |
2148 | if(ext) *(tail+1) = *(tail+1) |(1<<31); //plcp length extension | 2136 | if (ext) |
2137 | *(tail+1) = *(tail+1) | (1<<31); //plcp length extension | ||
2149 | } | 2138 | } |
2150 | 2139 | ||
2151 | if(morefrag) *tail = (*tail) | (1<<17); // more fragment | 2140 | if (morefrag) |
2152 | if(!remain) *tail = (*tail) | (1<<28); // last segment of frame | 2141 | *tail = (*tail) | (1<<17); // more fragment |
2142 | if (!remain) | ||
2143 | *tail = (*tail) | (1<<28); // last segment of frame | ||
2153 | 2144 | ||
2154 | *(tail+5) = *(tail+5)|(2<<27); | 2145 | *(tail+5) = *(tail+5)|(2<<27); |
2155 | *(tail+7) = *(tail+7)|(1<<4); | 2146 | *(tail+7) = *(tail+7)|(1<<4); |
2156 | 2147 | ||
2157 | wmb(); | 2148 | wmb(); |
2158 | if(ownbit_flag) | 2149 | if (ownbit_flag) |
2159 | { | ||
2160 | *tail = *tail | (1<<31); // descriptor ready to be txed | 2150 | *tail = *tail | (1<<31); // descriptor ready to be txed |
2161 | } | ||
2162 | 2151 | ||
2163 | if((tail - begin)/8 == count-1) | 2152 | if ((tail - begin)/8 == count-1) |
2164 | tail=begin; | 2153 | tail = begin; |
2165 | else | 2154 | else |
2166 | tail=tail+8; | 2155 | tail = tail+8; |
2167 | 2156 | ||
2168 | buflist=buflist->next; | 2157 | buflist = buflist->next; |
2169 | 2158 | ||
2170 | mb(); | 2159 | mb(); |
2171 | 2160 | ||
2172 | switch(priority) { | 2161 | switch (priority) { |
2173 | case MANAGE_PRIORITY: | 2162 | case MANAGE_PRIORITY: |
2174 | priv->txmapringtail=tail; | 2163 | priv->txmapringtail = tail; |
2175 | priv->txmapbufstail=buflist; | 2164 | priv->txmapbufstail = buflist; |
2176 | break; | 2165 | break; |
2177 | case BK_PRIORITY: | 2166 | case BK_PRIORITY: |
2178 | priv->txbkpringtail=tail; | 2167 | priv->txbkpringtail = tail; |
2179 | priv->txbkpbufstail=buflist; | 2168 | priv->txbkpbufstail = buflist; |
2180 | break; | 2169 | break; |
2181 | case BE_PRIORITY: | 2170 | case BE_PRIORITY: |
2182 | priv->txbepringtail=tail; | 2171 | priv->txbepringtail = tail; |
2183 | priv->txbepbufstail=buflist; | 2172 | priv->txbepbufstail = buflist; |
2184 | break; | 2173 | break; |
2185 | case VI_PRIORITY: | 2174 | case VI_PRIORITY: |
2186 | priv->txvipringtail=tail; | 2175 | priv->txvipringtail = tail; |
2187 | priv->txvipbufstail=buflist; | 2176 | priv->txvipbufstail = buflist; |
2188 | break; | 2177 | break; |
2189 | case VO_PRIORITY: | 2178 | case VO_PRIORITY: |
2190 | priv->txvopringtail=tail; | 2179 | priv->txvopringtail = tail; |
2191 | priv->txvopbufstail=buflist; | 2180 | priv->txvopbufstail = buflist; |
2192 | break; | 2181 | break; |
2193 | case HI_PRIORITY: | 2182 | case HI_PRIORITY: |
2194 | priv->txhpringtail=tail; | 2183 | priv->txhpringtail = tail; |
2195 | priv->txhpbufstail = buflist; | 2184 | priv->txhpbufstail = buflist; |
2196 | break; | 2185 | break; |
2197 | case BEACON_PRIORITY: | 2186 | case BEACON_PRIORITY: |
2198 | /* the HW seems to be happy with the 1st | 2187 | /* the HW seems to be happy with the 1st |
2199 | * descriptor filled and the 2nd empty... | 2188 | * descriptor filled and the 2nd empty... |
2200 | * So always update descriptor 1 and never | 2189 | * So always update descriptor 1 and never |
2201 | * touch 2nd | 2190 | * touch 2nd |
2202 | */ | 2191 | */ |
2203 | break; | 2192 | break; |
2204 | } | 2193 | } |
2205 | } | 2194 | } |
2206 | *temp_tail = *temp_tail | (1<<31); // descriptor ready to be txed | 2195 | *temp_tail = *temp_tail | (1<<31); // descriptor ready to be txed |
2207 | rtl8180_dma_kick(dev,priority); | 2196 | rtl8180_dma_kick(dev, priority); |
2208 | 2197 | ||
2209 | return 0; | 2198 | return 0; |
2210 | } | 2199 | } |
2211 | 2200 | ||
2212 | void rtl8180_irq_rx_tasklet(struct r8180_priv * priv); | 2201 | void rtl8180_irq_rx_tasklet(struct r8180_priv *priv); |
2213 | 2202 | ||
2214 | void rtl8180_link_change(struct net_device *dev) | 2203 | void rtl8180_link_change(struct net_device *dev) |
2215 | { | 2204 | { |
@@ -2219,13 +2208,13 @@ void rtl8180_link_change(struct net_device *dev) | |||
2219 | 2208 | ||
2220 | rtl8180_update_msr(dev); | 2209 | rtl8180_update_msr(dev); |
2221 | 2210 | ||
2222 | rtl8180_set_mode(dev,EPROM_CMD_CONFIG); | 2211 | rtl8180_set_mode(dev, EPROM_CMD_CONFIG); |
2223 | 2212 | ||
2224 | write_nic_dword(dev,BSSID,((u32*)net->bssid)[0]); | 2213 | write_nic_dword(dev, BSSID, ((u32 *)net->bssid)[0]); |
2225 | write_nic_word(dev,BSSID+4,((u16*)net->bssid)[2]); | 2214 | write_nic_word(dev, BSSID+4, ((u16 *)net->bssid)[2]); |
2226 | 2215 | ||
2227 | beacon_interval = read_nic_dword(dev,BEACON_INTERVAL); | 2216 | beacon_interval = read_nic_dword(dev, BEACON_INTERVAL); |
2228 | beacon_interval &= ~ BEACON_INTERVAL_MASK; | 2217 | beacon_interval &= ~BEACON_INTERVAL_MASK; |
2229 | beacon_interval |= net->beacon_interval; | 2218 | beacon_interval |= net->beacon_interval; |
2230 | write_nic_dword(dev, BEACON_INTERVAL, beacon_interval); | 2219 | write_nic_dword(dev, BEACON_INTERVAL, beacon_interval); |
2231 | 2220 | ||
@@ -2234,42 +2223,50 @@ void rtl8180_link_change(struct net_device *dev) | |||
2234 | rtl8180_set_chan(dev, priv->chan); | 2223 | rtl8180_set_chan(dev, priv->chan); |
2235 | } | 2224 | } |
2236 | 2225 | ||
2237 | void rtl8180_rq_tx_ack(struct net_device *dev){ | 2226 | void rtl8180_rq_tx_ack(struct net_device *dev) |
2227 | { | ||
2238 | 2228 | ||
2239 | struct r8180_priv *priv = ieee80211_priv(dev); | 2229 | struct r8180_priv *priv = ieee80211_priv(dev); |
2240 | 2230 | ||
2241 | write_nic_byte(dev,CONFIG4,read_nic_byte(dev,CONFIG4)|CONFIG4_PWRMGT); | 2231 | write_nic_byte(dev, CONFIG4, read_nic_byte(dev, CONFIG4) | CONFIG4_PWRMGT); |
2242 | priv->ack_tx_to_ieee = 1; | 2232 | priv->ack_tx_to_ieee = 1; |
2243 | } | 2233 | } |
2244 | 2234 | ||
2245 | short rtl8180_is_tx_queue_empty(struct net_device *dev){ | 2235 | short rtl8180_is_tx_queue_empty(struct net_device *dev) |
2236 | { | ||
2246 | 2237 | ||
2247 | struct r8180_priv *priv = ieee80211_priv(dev); | 2238 | struct r8180_priv *priv = ieee80211_priv(dev); |
2248 | u32* d; | 2239 | u32 *d; |
2249 | 2240 | ||
2250 | for (d = priv->txmapring; | 2241 | for (d = priv->txmapring; |
2251 | d < priv->txmapring + priv->txringcount;d+=8) | 2242 | d < priv->txmapring + priv->txringcount; d += 8) |
2252 | if(*d & (1<<31)) return 0; | 2243 | if (*d & (1<<31)) |
2244 | return 0; | ||
2253 | 2245 | ||
2254 | for (d = priv->txbkpring; | 2246 | for (d = priv->txbkpring; |
2255 | d < priv->txbkpring + priv->txringcount;d+=8) | 2247 | d < priv->txbkpring + priv->txringcount; d += 8) |
2256 | if(*d & (1<<31)) return 0; | 2248 | if (*d & (1<<31)) |
2249 | return 0; | ||
2257 | 2250 | ||
2258 | for (d = priv->txbepring; | 2251 | for (d = priv->txbepring; |
2259 | d < priv->txbepring + priv->txringcount;d+=8) | 2252 | d < priv->txbepring + priv->txringcount; d += 8) |
2260 | if(*d & (1<<31)) return 0; | 2253 | if (*d & (1<<31)) |
2254 | return 0; | ||
2261 | 2255 | ||
2262 | for (d = priv->txvipring; | 2256 | for (d = priv->txvipring; |
2263 | d < priv->txvipring + priv->txringcount;d+=8) | 2257 | d < priv->txvipring + priv->txringcount; d += 8) |
2264 | if(*d & (1<<31)) return 0; | 2258 | if (*d & (1<<31)) |
2259 | return 0; | ||
2265 | 2260 | ||
2266 | for (d = priv->txvopring; | 2261 | for (d = priv->txvopring; |
2267 | d < priv->txvopring + priv->txringcount;d+=8) | 2262 | d < priv->txvopring + priv->txringcount; d += 8) |
2268 | if(*d & (1<<31)) return 0; | 2263 | if (*d & (1<<31)) |
2264 | return 0; | ||
2269 | 2265 | ||
2270 | for (d = priv->txhpring; | 2266 | for (d = priv->txhpring; |
2271 | d < priv->txhpring + priv->txringcount;d+=8) | 2267 | d < priv->txhpring + priv->txringcount; d += 8) |
2272 | if(*d & (1<<31)) return 0; | 2268 | if (*d & (1<<31)) |
2269 | return 0; | ||
2273 | return 1; | 2270 | return 1; |
2274 | } | 2271 | } |
2275 | /* FIXME FIXME 5msecs is random */ | 2272 | /* FIXME FIXME 5msecs is random */ |
@@ -2280,11 +2277,11 @@ void rtl8180_hw_wakeup(struct net_device *dev) | |||
2280 | unsigned long flags; | 2277 | unsigned long flags; |
2281 | struct r8180_priv *priv = ieee80211_priv(dev); | 2278 | struct r8180_priv *priv = ieee80211_priv(dev); |
2282 | 2279 | ||
2283 | spin_lock_irqsave(&priv->ps_lock,flags); | 2280 | spin_lock_irqsave(&priv->ps_lock, flags); |
2284 | write_nic_byte(dev,CONFIG4,read_nic_byte(dev,CONFIG4)&~CONFIG4_PWRMGT); | 2281 | write_nic_byte(dev, CONFIG4, read_nic_byte(dev, CONFIG4) & ~CONFIG4_PWRMGT); |
2285 | if (priv->rf_wakeup) | 2282 | if (priv->rf_wakeup) |
2286 | priv->rf_wakeup(dev); | 2283 | priv->rf_wakeup(dev); |
2287 | spin_unlock_irqrestore(&priv->ps_lock,flags); | 2284 | spin_unlock_irqrestore(&priv->ps_lock, flags); |
2288 | } | 2285 | } |
2289 | 2286 | ||
2290 | void rtl8180_hw_sleep_down(struct net_device *dev) | 2287 | void rtl8180_hw_sleep_down(struct net_device *dev) |
@@ -2304,7 +2301,7 @@ void rtl8180_hw_sleep(struct net_device *dev, u32 th, u32 tl) | |||
2304 | u32 rb = jiffies; | 2301 | u32 rb = jiffies; |
2305 | unsigned long flags; | 2302 | unsigned long flags; |
2306 | 2303 | ||
2307 | spin_lock_irqsave(&priv->ps_lock,flags); | 2304 | spin_lock_irqsave(&priv->ps_lock, flags); |
2308 | 2305 | ||
2309 | /* Writing HW register with 0 equals to disable | 2306 | /* Writing HW register with 0 equals to disable |
2310 | * the timer, that is not really what we want | 2307 | * the timer, that is not really what we want |
@@ -2314,15 +2311,15 @@ void rtl8180_hw_sleep(struct net_device *dev, u32 th, u32 tl) | |||
2314 | /* If the interval in witch we are requested to sleep is too | 2311 | /* If the interval in witch we are requested to sleep is too |
2315 | * short then give up and remain awake | 2312 | * short then give up and remain awake |
2316 | */ | 2313 | */ |
2317 | if(((tl>=rb)&& (tl-rb) <= MSECS(MIN_SLEEP_TIME)) | 2314 | if (((tl >= rb) && (tl-rb) <= MSECS(MIN_SLEEP_TIME)) |
2318 | ||((rb>tl)&& (rb-tl) < MSECS(MIN_SLEEP_TIME))) { | 2315 | || ((rb > tl) && (rb-tl) < MSECS(MIN_SLEEP_TIME))) { |
2319 | spin_unlock_irqrestore(&priv->ps_lock,flags); | 2316 | spin_unlock_irqrestore(&priv->ps_lock, flags); |
2320 | printk("too short to sleep\n"); | 2317 | printk("too short to sleep\n"); |
2321 | return; | 2318 | return; |
2322 | } | 2319 | } |
2323 | 2320 | ||
2324 | { | 2321 | { |
2325 | u32 tmp = (tl>rb)?(tl-rb):(rb-tl); | 2322 | u32 tmp = (tl > rb) ? (tl-rb) : (rb-tl); |
2326 | 2323 | ||
2327 | priv->DozePeriodInPast2Sec += jiffies_to_msecs(tmp); | 2324 | priv->DozePeriodInPast2Sec += jiffies_to_msecs(tmp); |
2328 | 2325 | ||
@@ -2332,19 +2329,19 @@ void rtl8180_hw_sleep(struct net_device *dev, u32 th, u32 tl) | |||
2332 | * while setting it, then give up | 2329 | * while setting it, then give up |
2333 | */ | 2330 | */ |
2334 | 2331 | ||
2335 | if(((tl > rb) && ((tl-rb) > MSECS(MAX_SLEEP_TIME)))|| | 2332 | if (((tl > rb) && ((tl-rb) > MSECS(MAX_SLEEP_TIME))) || |
2336 | ((tl < rb) && ((rb-tl) > MSECS(MAX_SLEEP_TIME)))) { | 2333 | ((tl < rb) && ((rb-tl) > MSECS(MAX_SLEEP_TIME)))) { |
2337 | spin_unlock_irqrestore(&priv->ps_lock,flags); | 2334 | spin_unlock_irqrestore(&priv->ps_lock, flags); |
2338 | return; | 2335 | return; |
2339 | } | 2336 | } |
2340 | 2337 | ||
2341 | queue_work(priv->ieee80211->wq, (void *)&priv->ieee80211->hw_sleep_wq); | 2338 | queue_work(priv->ieee80211->wq, (void *)&priv->ieee80211->hw_sleep_wq); |
2342 | spin_unlock_irqrestore(&priv->ps_lock,flags); | 2339 | spin_unlock_irqrestore(&priv->ps_lock, flags); |
2343 | } | 2340 | } |
2344 | 2341 | ||
2345 | void rtl8180_wmm_param_update(struct work_struct * work) | 2342 | void rtl8180_wmm_param_update(struct work_struct *work) |
2346 | { | 2343 | { |
2347 | struct ieee80211_device * ieee = container_of(work, struct ieee80211_device,wmm_param_update_wq); | 2344 | struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wmm_param_update_wq); |
2348 | struct net_device *dev = ieee->dev; | 2345 | struct net_device *dev = ieee->dev; |
2349 | u8 *ac_param = (u8 *)(ieee->current_network.wmm_param); | 2346 | u8 *ac_param = (u8 *)(ieee->current_network.wmm_param); |
2350 | u8 mode = ieee->current_network.mode; | 2347 | u8 mode = ieee->current_network.mode; |
@@ -2353,7 +2350,7 @@ void rtl8180_wmm_param_update(struct work_struct * work) | |||
2353 | PAC_PARAM pAcParam; | 2350 | PAC_PARAM pAcParam; |
2354 | u8 i; | 2351 | u8 i; |
2355 | 2352 | ||
2356 | if(!ieee->current_network.QoS_Enable){ | 2353 | if (!ieee->current_network.QoS_Enable) { |
2357 | //legacy ac_xx_param update | 2354 | //legacy ac_xx_param update |
2358 | AcParam.longData = 0; | 2355 | AcParam.longData = 0; |
2359 | AcParam.f.AciAifsn.f.AIFSN = 2; // Follow 802.11 DIFS. | 2356 | AcParam.f.AciAifsn.f.AIFSN = 2; // Follow 802.11 DIFS. |
@@ -2361,43 +2358,43 @@ void rtl8180_wmm_param_update(struct work_struct * work) | |||
2361 | AcParam.f.Ecw.f.ECWmin = 3; // Follow 802.11 CWmin. | 2358 | AcParam.f.Ecw.f.ECWmin = 3; // Follow 802.11 CWmin. |
2362 | AcParam.f.Ecw.f.ECWmax = 7; // Follow 802.11 CWmax. | 2359 | AcParam.f.Ecw.f.ECWmax = 7; // Follow 802.11 CWmax. |
2363 | AcParam.f.TXOPLimit = 0; | 2360 | AcParam.f.TXOPLimit = 0; |
2364 | for(eACI = 0; eACI < AC_MAX; eACI++){ | 2361 | for (eACI = 0; eACI < AC_MAX; eACI++) { |
2365 | AcParam.f.AciAifsn.f.ACI = (u8)eACI; | 2362 | AcParam.f.AciAifsn.f.ACI = (u8)eACI; |
2366 | { | 2363 | { |
2367 | u8 u1bAIFS; | 2364 | u8 u1bAIFS; |
2368 | u32 u4bAcParam; | 2365 | u32 u4bAcParam; |
2369 | pAcParam = (PAC_PARAM)(&AcParam); | 2366 | pAcParam = (PAC_PARAM)(&AcParam); |
2370 | // Retrive paramters to udpate. | 2367 | // Retrive paramters to udpate. |
2371 | u1bAIFS = pAcParam->f.AciAifsn.f.AIFSN *(((mode&IEEE_G) == IEEE_G)?9:20) + aSifsTime; | 2368 | u1bAIFS = pAcParam->f.AciAifsn.f.AIFSN * (((mode&IEEE_G) == IEEE_G) ? 9 : 20) + aSifsTime; |
2372 | u4bAcParam = ((((u32)(pAcParam->f.TXOPLimit))<<AC_PARAM_TXOP_LIMIT_OFFSET)| | 2369 | u4bAcParam = ((((u32)(pAcParam->f.TXOPLimit))<<AC_PARAM_TXOP_LIMIT_OFFSET)| |
2373 | (((u32)(pAcParam->f.Ecw.f.ECWmax))<<AC_PARAM_ECW_MAX_OFFSET)| | 2370 | (((u32)(pAcParam->f.Ecw.f.ECWmax))<<AC_PARAM_ECW_MAX_OFFSET)| |
2374 | (((u32)(pAcParam->f.Ecw.f.ECWmin))<<AC_PARAM_ECW_MIN_OFFSET)| | 2371 | (((u32)(pAcParam->f.Ecw.f.ECWmin))<<AC_PARAM_ECW_MIN_OFFSET)| |
2375 | (((u32)u1bAIFS) << AC_PARAM_AIFS_OFFSET)); | 2372 | (((u32)u1bAIFS) << AC_PARAM_AIFS_OFFSET)); |
2376 | switch(eACI){ | 2373 | switch (eACI) { |
2377 | case AC1_BK: | 2374 | case AC1_BK: |
2378 | write_nic_dword(dev, AC_BK_PARAM, u4bAcParam); | 2375 | write_nic_dword(dev, AC_BK_PARAM, u4bAcParam); |
2379 | break; | 2376 | break; |
2380 | case AC0_BE: | 2377 | case AC0_BE: |
2381 | write_nic_dword(dev, AC_BE_PARAM, u4bAcParam); | 2378 | write_nic_dword(dev, AC_BE_PARAM, u4bAcParam); |
2382 | break; | 2379 | break; |
2383 | case AC2_VI: | 2380 | case AC2_VI: |
2384 | write_nic_dword(dev, AC_VI_PARAM, u4bAcParam); | 2381 | write_nic_dword(dev, AC_VI_PARAM, u4bAcParam); |
2385 | break; | 2382 | break; |
2386 | case AC3_VO: | 2383 | case AC3_VO: |
2387 | write_nic_dword(dev, AC_VO_PARAM, u4bAcParam); | 2384 | write_nic_dword(dev, AC_VO_PARAM, u4bAcParam); |
2388 | break; | 2385 | break; |
2389 | default: | 2386 | default: |
2390 | printk(KERN_WARNING "SetHwReg8185():invalid ACI: %d!\n", eACI); | 2387 | printk(KERN_WARNING "SetHwReg8185():invalid ACI: %d!\n", eACI); |
2391 | break; | 2388 | break; |
2392 | } | 2389 | } |
2393 | } | 2390 | } |
2394 | } | 2391 | } |
2395 | return; | 2392 | return; |
2396 | } | 2393 | } |
2397 | 2394 | ||
2398 | for(i = 0; i < AC_MAX; i++){ | 2395 | for (i = 0; i < AC_MAX; i++) { |
2399 | //AcParam.longData = 0; | 2396 | //AcParam.longData = 0; |
2400 | pAcParam = (AC_PARAM * )ac_param; | 2397 | pAcParam = (AC_PARAM *)ac_param; |
2401 | { | 2398 | { |
2402 | AC_CODING eACI; | 2399 | AC_CODING eACI; |
2403 | u8 u1bAIFS; | 2400 | u8 u1bAIFS; |
@@ -2406,28 +2403,28 @@ void rtl8180_wmm_param_update(struct work_struct * work) | |||
2406 | // Retrive paramters to udpate. | 2403 | // Retrive paramters to udpate. |
2407 | eACI = pAcParam->f.AciAifsn.f.ACI; | 2404 | eACI = pAcParam->f.AciAifsn.f.ACI; |
2408 | //Mode G/A: slotTimeTimer = 9; Mode B: 20 | 2405 | //Mode G/A: slotTimeTimer = 9; Mode B: 20 |
2409 | u1bAIFS = pAcParam->f.AciAifsn.f.AIFSN * (((mode&IEEE_G) == IEEE_G)?9:20) + aSifsTime; | 2406 | u1bAIFS = pAcParam->f.AciAifsn.f.AIFSN * (((mode&IEEE_G) == IEEE_G) ? 9 : 20) + aSifsTime; |
2410 | u4bAcParam = ( (((u32)(pAcParam->f.TXOPLimit)) << AC_PARAM_TXOP_LIMIT_OFFSET) | | 2407 | u4bAcParam = ((((u32)(pAcParam->f.TXOPLimit)) << AC_PARAM_TXOP_LIMIT_OFFSET) | |
2411 | (((u32)(pAcParam->f.Ecw.f.ECWmax)) << AC_PARAM_ECW_MAX_OFFSET) | | 2408 | (((u32)(pAcParam->f.Ecw.f.ECWmax)) << AC_PARAM_ECW_MAX_OFFSET) | |
2412 | (((u32)(pAcParam->f.Ecw.f.ECWmin)) << AC_PARAM_ECW_MIN_OFFSET) | | 2409 | (((u32)(pAcParam->f.Ecw.f.ECWmin)) << AC_PARAM_ECW_MIN_OFFSET) | |
2413 | (((u32)u1bAIFS) << AC_PARAM_AIFS_OFFSET)); | 2410 | (((u32)u1bAIFS) << AC_PARAM_AIFS_OFFSET)); |
2414 | 2411 | ||
2415 | switch(eACI){ | 2412 | switch (eACI) { |
2416 | case AC1_BK: | 2413 | case AC1_BK: |
2417 | write_nic_dword(dev, AC_BK_PARAM, u4bAcParam); | 2414 | write_nic_dword(dev, AC_BK_PARAM, u4bAcParam); |
2418 | break; | 2415 | break; |
2419 | case AC0_BE: | 2416 | case AC0_BE: |
2420 | write_nic_dword(dev, AC_BE_PARAM, u4bAcParam); | 2417 | write_nic_dword(dev, AC_BE_PARAM, u4bAcParam); |
2421 | break; | 2418 | break; |
2422 | case AC2_VI: | 2419 | case AC2_VI: |
2423 | write_nic_dword(dev, AC_VI_PARAM, u4bAcParam); | 2420 | write_nic_dword(dev, AC_VI_PARAM, u4bAcParam); |
2424 | break; | 2421 | break; |
2425 | case AC3_VO: | 2422 | case AC3_VO: |
2426 | write_nic_dword(dev, AC_VO_PARAM, u4bAcParam); | 2423 | write_nic_dword(dev, AC_VO_PARAM, u4bAcParam); |
2427 | break; | 2424 | break; |
2428 | default: | 2425 | default: |
2429 | printk(KERN_WARNING "SetHwReg8185(): invalid ACI: %d !\n", eACI); | 2426 | printk(KERN_WARNING "SetHwReg8185(): invalid ACI: %d !\n", eACI); |
2430 | break; | 2427 | break; |
2431 | } | 2428 | } |
2432 | } | 2429 | } |
2433 | ac_param += (sizeof(AC_PARAM)); | 2430 | ac_param += (sizeof(AC_PARAM)); |
@@ -2453,7 +2450,7 @@ void watch_dog_adaptive(unsigned long data) | |||
2453 | } | 2450 | } |
2454 | 2451 | ||
2455 | // Tx High Power Mechanism. | 2452 | // Tx High Power Mechanism. |
2456 | if(CheckHighPower((struct net_device *)data)) | 2453 | if (CheckHighPower((struct net_device *)data)) |
2457 | queue_work(priv->ieee80211->wq, (void *)&priv->ieee80211->tx_pw_wq); | 2454 | queue_work(priv->ieee80211->wq, (void *)&priv->ieee80211->tx_pw_wq); |
2458 | 2455 | ||
2459 | // Tx Power Tracking on 87SE. | 2456 | // Tx Power Tracking on 87SE. |
@@ -2461,26 +2458,26 @@ void watch_dog_adaptive(unsigned long data) | |||
2461 | TxPwrTracking87SE((struct net_device *)data); | 2458 | TxPwrTracking87SE((struct net_device *)data); |
2462 | 2459 | ||
2463 | // Perform DIG immediately. | 2460 | // Perform DIG immediately. |
2464 | if(CheckDig((struct net_device *)data) == true) | 2461 | if (CheckDig((struct net_device *)data) == true) |
2465 | queue_work(priv->ieee80211->wq, (void *)&priv->ieee80211->hw_dig_wq); | 2462 | queue_work(priv->ieee80211->wq, (void *)&priv->ieee80211->hw_dig_wq); |
2466 | rtl8180_watch_dog((struct net_device *)data); | 2463 | rtl8180_watch_dog((struct net_device *)data); |
2467 | 2464 | ||
2468 | queue_work(priv->ieee80211->wq, (void *)&priv->ieee80211->GPIOChangeRFWorkItem); | 2465 | queue_work(priv->ieee80211->wq, (void *)&priv->ieee80211->GPIOChangeRFWorkItem); |
2469 | 2466 | ||
2470 | priv->watch_dog_timer.expires = jiffies + MSECS(IEEE80211_WATCH_DOG_TIME); | 2467 | priv->watch_dog_timer.expires = jiffies + MSECS(IEEE80211_WATCH_DOG_TIME); |
2471 | add_timer(&priv->watch_dog_timer); | 2468 | add_timer(&priv->watch_dog_timer); |
2472 | } | 2469 | } |
2473 | 2470 | ||
2474 | static CHANNEL_LIST ChannelPlan[] = { | 2471 | static CHANNEL_LIST ChannelPlan[] = { |
2475 | {{1,2,3,4,5,6,7,8,9,10,11,36,40,44,48,52,56,60,64},19}, //FCC | 2472 | {{1,2,3,4,5,6,7,8,9,10,11,36,40,44,48,52,56,60,64},19}, //FCC |
2476 | {{1,2,3,4,5,6,7,8,9,10,11},11}, //IC | 2473 | {{1,2,3,4,5,6,7,8,9,10,11},11}, //IC |
2477 | {{1,2,3,4,5,6,7,8,9,10,11,12,13,36,40,44,48,52,56,60,64},21}, //ETSI | 2474 | {{1,2,3,4,5,6,7,8,9,10,11,12,13,36,40,44,48,52,56,60,64},21}, //ETSI |
2478 | {{1,2,3,4,5,6,7,8,9,10,11,12,13,36,40,44,48,52,56,60,64},21}, //Spain. Change to ETSI. | 2475 | {{1,2,3,4,5,6,7,8,9,10,11,12,13,36,40,44,48,52,56,60,64},21}, //Spain. Change to ETSI. |
2479 | {{1,2,3,4,5,6,7,8,9,10,11,12,13,36,40,44,48,52,56,60,64},21}, //France. Change to ETSI. | 2476 | {{1,2,3,4,5,6,7,8,9,10,11,12,13,36,40,44,48,52,56,60,64},21}, //France. Change to ETSI. |
2480 | {{14,36,40,44,48,52,56,60,64},9}, //MKK | 2477 | {{14,36,40,44,48,52,56,60,64},9}, //MKK |
2481 | {{1,2,3,4,5,6,7,8,9,10,11,12,13,14, 36,40,44,48,52,56,60,64},22},//MKK1 | 2478 | {{1,2,3,4,5,6,7,8,9,10,11,12,13,14, 36,40,44,48,52,56,60,64},22},//MKK1 |
2482 | {{1,2,3,4,5,6,7,8,9,10,11,12,13,36,40,44,48,52,56,60,64},21}, //Israel. | 2479 | {{1,2,3,4,5,6,7,8,9,10,11,12,13,36,40,44,48,52,56,60,64},21}, //Israel. |
2483 | {{1,2,3,4,5,6,7,8,9,10,11,12,13,34,38,42,46},17}, // For 11a , TELEC | 2480 | {{1,2,3,4,5,6,7,8,9,10,11,12,13,34,38,42,46},17}, // For 11a , TELEC |
2484 | {{1,2,3,4,5,6,7,8,9,10,11,12,13,14},14}, //For Global Domain. 1-11:active scan, 12-14 passive scan. //+YJ, 080626 | 2481 | {{1,2,3,4,5,6,7,8,9,10,11,12,13,14},14}, //For Global Domain. 1-11:active scan, 12-14 passive scan. //+YJ, 080626 |
2485 | {{1,2,3,4,5,6,7,8,9,10,11,12,13},13} //world wide 13: ch1~ch11 active scan, ch12~13 passive //lzm add 080826 | 2482 | {{1,2,3,4,5,6,7,8,9,10,11,12,13},13} //world wide 13: ch1~ch11 active scan, ch12~13 passive //lzm add 080826 |
2486 | }; | 2483 | }; |
@@ -2490,57 +2487,53 @@ static void rtl8180_set_channel_map(u8 channel_plan, struct ieee80211_device *ie | |||
2490 | int i; | 2487 | int i; |
2491 | 2488 | ||
2492 | //lzm add 080826 | 2489 | //lzm add 080826 |
2493 | ieee->MinPassiveChnlNum=MAX_CHANNEL_NUMBER+1; | 2490 | ieee->MinPassiveChnlNum = MAX_CHANNEL_NUMBER+1; |
2494 | ieee->IbssStartChnl=0; | 2491 | ieee->IbssStartChnl = 0; |
2495 | 2492 | ||
2496 | switch (channel_plan) | 2493 | switch (channel_plan) { |
2497 | { | 2494 | case COUNTRY_CODE_FCC: |
2498 | case COUNTRY_CODE_FCC: | 2495 | case COUNTRY_CODE_IC: |
2499 | case COUNTRY_CODE_IC: | 2496 | case COUNTRY_CODE_ETSI: |
2500 | case COUNTRY_CODE_ETSI: | 2497 | case COUNTRY_CODE_SPAIN: |
2501 | case COUNTRY_CODE_SPAIN: | 2498 | case COUNTRY_CODE_FRANCE: |
2502 | case COUNTRY_CODE_FRANCE: | 2499 | case COUNTRY_CODE_MKK: |
2503 | case COUNTRY_CODE_MKK: | 2500 | case COUNTRY_CODE_MKK1: |
2504 | case COUNTRY_CODE_MKK1: | 2501 | case COUNTRY_CODE_ISRAEL: |
2505 | case COUNTRY_CODE_ISRAEL: | 2502 | case COUNTRY_CODE_TELEC: |
2506 | case COUNTRY_CODE_TELEC: | ||
2507 | { | 2503 | { |
2508 | Dot11d_Init(ieee); | 2504 | Dot11d_Init(ieee); |
2509 | ieee->bGlobalDomain = false; | 2505 | ieee->bGlobalDomain = false; |
2510 | if (ChannelPlan[channel_plan].Len != 0){ | 2506 | if (ChannelPlan[channel_plan].Len != 0) { |
2511 | // Clear old channel map | 2507 | // Clear old channel map |
2512 | memset(GET_DOT11D_INFO(ieee)->channel_map, 0, sizeof(GET_DOT11D_INFO(ieee)->channel_map)); | 2508 | memset(GET_DOT11D_INFO(ieee)->channel_map, 0, sizeof(GET_DOT11D_INFO(ieee)->channel_map)); |
2513 | // Set new channel map | 2509 | // Set new channel map |
2514 | for (i=0;i<ChannelPlan[channel_plan].Len;i++) | 2510 | for (i = 0; i < ChannelPlan[channel_plan].Len; i++) { |
2515 | { | 2511 | if (ChannelPlan[channel_plan].Channel[i] <= 14) |
2516 | if(ChannelPlan[channel_plan].Channel[i] <= 14) | ||
2517 | GET_DOT11D_INFO(ieee)->channel_map[ChannelPlan[channel_plan].Channel[i]] = 1; | 2512 | GET_DOT11D_INFO(ieee)->channel_map[ChannelPlan[channel_plan].Channel[i]] = 1; |
2518 | } | 2513 | } |
2519 | } | 2514 | } |
2520 | break; | 2515 | break; |
2521 | } | 2516 | } |
2522 | case COUNTRY_CODE_GLOBAL_DOMAIN: | 2517 | case COUNTRY_CODE_GLOBAL_DOMAIN: |
2523 | { | 2518 | { |
2524 | GET_DOT11D_INFO(ieee)->bEnabled = 0; | 2519 | GET_DOT11D_INFO(ieee)->bEnabled = 0; |
2525 | Dot11d_Reset(ieee); | 2520 | Dot11d_Reset(ieee); |
2526 | ieee->bGlobalDomain = true; | 2521 | ieee->bGlobalDomain = true; |
2527 | break; | 2522 | break; |
2528 | } | 2523 | } |
2529 | case COUNTRY_CODE_WORLD_WIDE_13_INDEX://lzm add 080826 | 2524 | case COUNTRY_CODE_WORLD_WIDE_13_INDEX://lzm add 080826 |
2530 | { | 2525 | { |
2531 | ieee->MinPassiveChnlNum=12; | 2526 | ieee->MinPassiveChnlNum = 12; |
2532 | ieee->IbssStartChnl= 10; | 2527 | ieee->IbssStartChnl = 10; |
2533 | break; | 2528 | break; |
2534 | } | 2529 | } |
2535 | default: | 2530 | default: |
2536 | { | 2531 | { |
2537 | Dot11d_Init(ieee); | 2532 | Dot11d_Init(ieee); |
2538 | ieee->bGlobalDomain = false; | 2533 | ieee->bGlobalDomain = false; |
2539 | memset(GET_DOT11D_INFO(ieee)->channel_map, 0, sizeof(GET_DOT11D_INFO(ieee)->channel_map)); | 2534 | memset(GET_DOT11D_INFO(ieee)->channel_map, 0, sizeof(GET_DOT11D_INFO(ieee)->channel_map)); |
2540 | for (i=1;i<=14;i++) | 2535 | for (i = 1; i <= 14; i++) |
2541 | { | ||
2542 | GET_DOT11D_INFO(ieee)->channel_map[i] = 1; | 2536 | GET_DOT11D_INFO(ieee)->channel_map[i] = 1; |
2543 | } | ||
2544 | break; | 2537 | break; |
2545 | } | 2538 | } |
2546 | } | 2539 | } |
@@ -2609,12 +2602,12 @@ short rtl8180_init(struct net_device *dev) | |||
2609 | 2602 | ||
2610 | eeprom_93cx6_read(&eeprom, EEPROM_COUNTRY_CODE>>1, &eeprom_val); | 2603 | eeprom_93cx6_read(&eeprom, EEPROM_COUNTRY_CODE>>1, &eeprom_val); |
2611 | priv->channel_plan = eeprom_val & 0xFF; | 2604 | priv->channel_plan = eeprom_val & 0xFF; |
2612 | if(priv->channel_plan > COUNTRY_CODE_GLOBAL_DOMAIN){ | 2605 | if (priv->channel_plan > COUNTRY_CODE_GLOBAL_DOMAIN) { |
2613 | printk("rtl8180_init:Error channel plan! Set to default.\n"); | 2606 | printk("rtl8180_init:Error channel plan! Set to default.\n"); |
2614 | priv->channel_plan = 0; | 2607 | priv->channel_plan = 0; |
2615 | } | 2608 | } |
2616 | 2609 | ||
2617 | DMESG("Channel plan is %d\n",priv->channel_plan); | 2610 | DMESG("Channel plan is %d\n", priv->channel_plan); |
2618 | rtl8180_set_channel_map(priv->channel_plan, priv->ieee80211); | 2611 | rtl8180_set_channel_map(priv->channel_plan, priv->ieee80211); |
2619 | 2612 | ||
2620 | //FIXME: these constants are placed in a bad pleace. | 2613 | //FIXME: these constants are placed in a bad pleace. |
@@ -2630,7 +2623,7 @@ short rtl8180_init(struct net_device *dev) | |||
2630 | priv->RFProgType = 0; | 2623 | priv->RFProgType = 0; |
2631 | priv->bInHctTest = false; | 2624 | priv->bInHctTest = false; |
2632 | 2625 | ||
2633 | priv->irq_enabled=0; | 2626 | priv->irq_enabled = 0; |
2634 | 2627 | ||
2635 | rtl8180_statistics_init(&priv->stats); | 2628 | rtl8180_statistics_init(&priv->stats); |
2636 | rtl8180_link_detect_init(&priv->link_detect); | 2629 | rtl8180_link_detect_init(&priv->link_detect); |
@@ -2652,8 +2645,8 @@ short rtl8180_init(struct net_device *dev) | |||
2652 | priv->ieee80211->ps_is_queue_empty = rtl8180_is_tx_queue_empty; | 2645 | priv->ieee80211->ps_is_queue_empty = rtl8180_is_tx_queue_empty; |
2653 | 2646 | ||
2654 | priv->hw_wep = hwwep; | 2647 | priv->hw_wep = hwwep; |
2655 | priv->prism_hdr=0; | 2648 | priv->prism_hdr = 0; |
2656 | priv->dev=dev; | 2649 | priv->dev = dev; |
2657 | priv->retry_rts = DEFAULT_RETRY_RTS; | 2650 | priv->retry_rts = DEFAULT_RETRY_RTS; |
2658 | priv->retry_data = DEFAULT_RETRY_DATA; | 2651 | priv->retry_data = DEFAULT_RETRY_DATA; |
2659 | priv->RFChangeInProgress = false; | 2652 | priv->RFChangeInProgress = false; |
@@ -2836,7 +2829,7 @@ short rtl8180_init(struct net_device *dev) | |||
2836 | 2829 | ||
2837 | eeprom_93cx6_read(&eeprom, EEPROM_SW_REVD_OFFSET, &eeprom_val); | 2830 | eeprom_93cx6_read(&eeprom, EEPROM_SW_REVD_OFFSET, &eeprom_val); |
2838 | usValue = eeprom_val; | 2831 | usValue = eeprom_val; |
2839 | DMESG("usValue is 0x%x\n",usValue); | 2832 | DMESG("usValue is 0x%x\n", usValue); |
2840 | //3Read AntennaDiversity | 2833 | //3Read AntennaDiversity |
2841 | 2834 | ||
2842 | // SW Antenna Diversity. | 2835 | // SW Antenna Diversity. |
@@ -2851,19 +2844,19 @@ short rtl8180_init(struct net_device *dev) | |||
2851 | else | 2844 | else |
2852 | priv->EEPROMDefaultAntenna1 = true; | 2845 | priv->EEPROMDefaultAntenna1 = true; |
2853 | 2846 | ||
2854 | if( priv->RegSwAntennaDiversityMechanism == 0 ) // Auto | 2847 | if (priv->RegSwAntennaDiversityMechanism == 0) // Auto |
2855 | /* 0: default from EEPROM. */ | 2848 | /* 0: default from EEPROM. */ |
2856 | priv->bSwAntennaDiverity = priv->EEPROMSwAntennaDiversity; | 2849 | priv->bSwAntennaDiverity = priv->EEPROMSwAntennaDiversity; |
2857 | else | 2850 | else |
2858 | /* 1:disable antenna diversity, 2: enable antenna diversity. */ | 2851 | /* 1:disable antenna diversity, 2: enable antenna diversity. */ |
2859 | priv->bSwAntennaDiverity = ((priv->RegSwAntennaDiversityMechanism == 1)? false : true); | 2852 | priv->bSwAntennaDiverity = ((priv->RegSwAntennaDiversityMechanism == 1) ? false : true); |
2860 | 2853 | ||
2861 | if (priv->RegDefaultAntenna == 0) | 2854 | if (priv->RegDefaultAntenna == 0) |
2862 | /* 0: default from EEPROM. */ | 2855 | /* 0: default from EEPROM. */ |
2863 | priv->bDefaultAntenna1 = priv->EEPROMDefaultAntenna1; | 2856 | priv->bDefaultAntenna1 = priv->EEPROMDefaultAntenna1; |
2864 | else | 2857 | else |
2865 | /* 1: main, 2: aux. */ | 2858 | /* 1: main, 2: aux. */ |
2866 | priv->bDefaultAntenna1 = ((priv->RegDefaultAntenna== 2) ? true : false); | 2859 | priv->bDefaultAntenna1 = ((priv->RegDefaultAntenna == 2) ? true : false); |
2867 | 2860 | ||
2868 | /* rtl8185 can calc plcp len in HW.*/ | 2861 | /* rtl8185 can calc plcp len in HW.*/ |
2869 | priv->hw_plcp_len = 1; | 2862 | priv->hw_plcp_len = 1; |
@@ -2871,17 +2864,17 @@ short rtl8180_init(struct net_device *dev) | |||
2871 | priv->plcp_preamble_mode = 2; | 2864 | priv->plcp_preamble_mode = 2; |
2872 | /*the eeprom type is stored in RCR register bit #6 */ | 2865 | /*the eeprom type is stored in RCR register bit #6 */ |
2873 | if (RCR_9356SEL & read_nic_dword(dev, RCR)) | 2866 | if (RCR_9356SEL & read_nic_dword(dev, RCR)) |
2874 | priv->epromtype=EPROM_93c56; | 2867 | priv->epromtype = EPROM_93c56; |
2875 | else | 2868 | else |
2876 | priv->epromtype=EPROM_93c46; | 2869 | priv->epromtype = EPROM_93c46; |
2877 | 2870 | ||
2878 | eeprom_93cx6_multiread(&eeprom, 0x7, (__le16 *) | 2871 | eeprom_93cx6_multiread(&eeprom, 0x7, (__le16 *) |
2879 | dev->dev_addr, 3); | 2872 | dev->dev_addr, 3); |
2880 | 2873 | ||
2881 | for(i=1,j=0; i<14; i+=2,j++){ | 2874 | for (i = 1, j = 0; i < 14; i += 2, j++) { |
2882 | eeprom_93cx6_read(&eeprom, EPROM_TXPW_CH1_2 + j, &word); | 2875 | eeprom_93cx6_read(&eeprom, EPROM_TXPW_CH1_2 + j, &word); |
2883 | priv->chtxpwr[i]=word & 0xff; | 2876 | priv->chtxpwr[i] = word & 0xff; |
2884 | priv->chtxpwr[i+1]=(word & 0xff00)>>8; | 2877 | priv->chtxpwr[i+1] = (word & 0xff00)>>8; |
2885 | } | 2878 | } |
2886 | for (i = 1, j = 0; i < 14; i += 2, j++) { | 2879 | for (i = 1, j = 0; i < 14; i += 2, j++) { |
2887 | eeprom_93cx6_read(&eeprom, EPROM_TXPW_OFDM_CH1_2 + j, &word); | 2880 | eeprom_93cx6_read(&eeprom, EPROM_TXPW_OFDM_CH1_2 + j, &word); |
@@ -2908,7 +2901,7 @@ short rtl8180_init(struct net_device *dev) | |||
2908 | priv->ofdm_txpwr_base = (word>>4) & 0xf; | 2901 | priv->ofdm_txpwr_base = (word>>4) & 0xf; |
2909 | 2902 | ||
2910 | eeprom_93cx6_read(&eeprom, EPROM_VERSION, &version); | 2903 | eeprom_93cx6_read(&eeprom, EPROM_VERSION, &version); |
2911 | DMESG("EEPROM version %x",version); | 2904 | DMESG("EEPROM version %x", version); |
2912 | priv->rcr_csense = 3; | 2905 | priv->rcr_csense = 3; |
2913 | 2906 | ||
2914 | eeprom_93cx6_read(&eeprom, ENERGY_TRESHOLD, &eeprom_val); | 2907 | eeprom_93cx6_read(&eeprom, ENERGY_TRESHOLD, &eeprom_val); |
@@ -2924,43 +2917,43 @@ short rtl8180_init(struct net_device *dev) | |||
2924 | priv->rf_set_chan = rtl8225z2_rf_set_chan; | 2917 | priv->rf_set_chan = rtl8225z2_rf_set_chan; |
2925 | priv->rf_set_sens = NULL; | 2918 | priv->rf_set_sens = NULL; |
2926 | 2919 | ||
2927 | if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) | 2920 | if (0 != alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) |
2928 | return -ENOMEM; | 2921 | return -ENOMEM; |
2929 | 2922 | ||
2930 | if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, | 2923 | if (0 != alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, |
2931 | TX_MANAGEPRIORITY_RING_ADDR)) | 2924 | TX_MANAGEPRIORITY_RING_ADDR)) |
2932 | return -ENOMEM; | 2925 | return -ENOMEM; |
2933 | 2926 | ||
2934 | if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, | 2927 | if (0 != alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, |
2935 | TX_BKPRIORITY_RING_ADDR)) | 2928 | TX_BKPRIORITY_RING_ADDR)) |
2936 | return -ENOMEM; | 2929 | return -ENOMEM; |
2937 | 2930 | ||
2938 | if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, | 2931 | if (0 != alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, |
2939 | TX_BEPRIORITY_RING_ADDR)) | 2932 | TX_BEPRIORITY_RING_ADDR)) |
2940 | return -ENOMEM; | 2933 | return -ENOMEM; |
2941 | 2934 | ||
2942 | if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, | 2935 | if (0 != alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, |
2943 | TX_VIPRIORITY_RING_ADDR)) | 2936 | TX_VIPRIORITY_RING_ADDR)) |
2944 | return -ENOMEM; | 2937 | return -ENOMEM; |
2945 | 2938 | ||
2946 | if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, | 2939 | if (0 != alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, |
2947 | TX_VOPRIORITY_RING_ADDR)) | 2940 | TX_VOPRIORITY_RING_ADDR)) |
2948 | return -ENOMEM; | 2941 | return -ENOMEM; |
2949 | 2942 | ||
2950 | if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, | 2943 | if (0 != alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount, |
2951 | TX_HIGHPRIORITY_RING_ADDR)) | 2944 | TX_HIGHPRIORITY_RING_ADDR)) |
2952 | return -ENOMEM; | 2945 | return -ENOMEM; |
2953 | 2946 | ||
2954 | if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txbeaconcount, | 2947 | if (0 != alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txbeaconcount, |
2955 | TX_BEACON_RING_ADDR)) | 2948 | TX_BEACON_RING_ADDR)) |
2956 | return -ENOMEM; | 2949 | return -ENOMEM; |
2957 | 2950 | ||
2958 | if(request_irq(dev->irq, (void *)rtl8180_interrupt, IRQF_SHARED, dev->name, dev)){ | 2951 | if (request_irq(dev->irq, (void *)rtl8180_interrupt, IRQF_SHARED, dev->name, dev)) { |
2959 | DMESGE("Error allocating IRQ %d", dev->irq); | 2952 | DMESGE("Error allocating IRQ %d", dev->irq); |
2960 | return -1; | 2953 | return -1; |
2961 | }else{ | 2954 | } else { |
2962 | priv->irq=dev->irq; | 2955 | priv->irq = dev->irq; |
2963 | DMESG("IRQ %d",dev->irq); | 2956 | DMESG("IRQ %d", dev->irq); |
2964 | } | 2957 | } |
2965 | 2958 | ||
2966 | return 0; | 2959 | return 0; |
@@ -2977,28 +2970,28 @@ void rtl8180_set_hw_wep(struct net_device *dev) | |||
2977 | u8 security; | 2970 | u8 security; |
2978 | u32 key0_word4; | 2971 | u32 key0_word4; |
2979 | 2972 | ||
2980 | pgreg=read_nic_byte(dev, PGSELECT); | 2973 | pgreg = read_nic_byte(dev, PGSELECT); |
2981 | write_nic_byte(dev, PGSELECT, pgreg &~ (1<<PGSELECT_PG_SHIFT)); | 2974 | write_nic_byte(dev, PGSELECT, pgreg & ~(1<<PGSELECT_PG_SHIFT)); |
2982 | 2975 | ||
2983 | key0_word4 = read_nic_dword(dev, KEY0+4+4+4); | 2976 | key0_word4 = read_nic_dword(dev, KEY0+4+4+4); |
2984 | key0_word4 &= ~ 0xff; | 2977 | key0_word4 &= ~0xff; |
2985 | key0_word4 |= priv->key0[3]& 0xff; | 2978 | key0_word4 |= priv->key0[3] & 0xff; |
2986 | write_nic_dword(dev,KEY0,(priv->key0[0])); | 2979 | write_nic_dword(dev, KEY0, (priv->key0[0])); |
2987 | write_nic_dword(dev,KEY0+4,(priv->key0[1])); | 2980 | write_nic_dword(dev, KEY0+4, (priv->key0[1])); |
2988 | write_nic_dword(dev,KEY0+4+4,(priv->key0[2])); | 2981 | write_nic_dword(dev, KEY0+4+4, (priv->key0[2])); |
2989 | write_nic_dword(dev,KEY0+4+4+4,(key0_word4)); | 2982 | write_nic_dword(dev, KEY0+4+4+4, (key0_word4)); |
2990 | 2983 | ||
2991 | security = read_nic_byte(dev,SECURITY); | 2984 | security = read_nic_byte(dev, SECURITY); |
2992 | security |= (1<<SECURITY_WEP_TX_ENABLE_SHIFT); | 2985 | security |= (1<<SECURITY_WEP_TX_ENABLE_SHIFT); |
2993 | security |= (1<<SECURITY_WEP_RX_ENABLE_SHIFT); | 2986 | security |= (1<<SECURITY_WEP_RX_ENABLE_SHIFT); |
2994 | security &= ~ SECURITY_ENCRYP_MASK; | 2987 | security &= ~SECURITY_ENCRYP_MASK; |
2995 | security |= (SECURITY_ENCRYP_104<<SECURITY_ENCRYP_SHIFT); | 2988 | security |= (SECURITY_ENCRYP_104<<SECURITY_ENCRYP_SHIFT); |
2996 | 2989 | ||
2997 | write_nic_byte(dev, SECURITY, security); | 2990 | write_nic_byte(dev, SECURITY, security); |
2998 | 2991 | ||
2999 | DMESG("key %x %x %x %x",read_nic_dword(dev,KEY0+4+4+4), | 2992 | DMESG("key %x %x %x %x", read_nic_dword(dev, KEY0+4+4+4), |
3000 | read_nic_dword(dev,KEY0+4+4),read_nic_dword(dev,KEY0+4), | 2993 | read_nic_dword(dev, KEY0+4+4), read_nic_dword(dev, KEY0+4), |
3001 | read_nic_dword(dev,KEY0)); | 2994 | read_nic_dword(dev, KEY0)); |
3002 | } | 2995 | } |
3003 | 2996 | ||
3004 | 2997 | ||
@@ -3020,7 +3013,7 @@ void rtl8185_set_anaparam2(struct net_device *dev, u32 a) | |||
3020 | write_nic_dword(dev, ANAPARAM2, a); | 3013 | write_nic_dword(dev, ANAPARAM2, a); |
3021 | 3014 | ||
3022 | conf3 = read_nic_byte(dev, CONFIG3); | 3015 | conf3 = read_nic_byte(dev, CONFIG3); |
3023 | write_nic_byte(dev, CONFIG3, conf3 &~(1<<CONFIG3_ANAPARAM_W_SHIFT)); | 3016 | write_nic_byte(dev, CONFIG3, conf3 & ~(1<<CONFIG3_ANAPARAM_W_SHIFT)); |
3024 | rtl8180_set_mode(dev, EPROM_CMD_NORMAL); | 3017 | rtl8180_set_mode(dev, EPROM_CMD_NORMAL); |
3025 | } | 3018 | } |
3026 | 3019 | ||
@@ -3035,7 +3028,7 @@ void rtl8180_set_anaparam(struct net_device *dev, u32 a) | |||
3035 | write_nic_dword(dev, ANAPARAM, a); | 3028 | write_nic_dword(dev, ANAPARAM, a); |
3036 | 3029 | ||
3037 | conf3 = read_nic_byte(dev, CONFIG3); | 3030 | conf3 = read_nic_byte(dev, CONFIG3); |
3038 | write_nic_byte(dev, CONFIG3, conf3 &~(1<<CONFIG3_ANAPARAM_W_SHIFT)); | 3031 | write_nic_byte(dev, CONFIG3, conf3 & ~(1<<CONFIG3_ANAPARAM_W_SHIFT)); |
3039 | rtl8180_set_mode(dev, EPROM_CMD_NORMAL); | 3032 | rtl8180_set_mode(dev, EPROM_CMD_NORMAL); |
3040 | } | 3033 | } |
3041 | 3034 | ||
@@ -3052,13 +3045,13 @@ void rtl8185_write_phy(struct net_device *dev, u8 adr, u32 data) | |||
3052 | 3045 | ||
3053 | adr |= 0x80; | 3046 | adr |= 0x80; |
3054 | 3047 | ||
3055 | phyw= ((data<<8) | adr); | 3048 | phyw = ((data<<8) | adr); |
3056 | 3049 | ||
3057 | // Note that, we must write 0xff7c after 0x7d-0x7f to write BB register. | 3050 | // Note that, we must write 0xff7c after 0x7d-0x7f to write BB register. |
3058 | write_nic_byte(dev, 0x7f, ((phyw & 0xff000000) >> 24)); | 3051 | write_nic_byte(dev, 0x7f, ((phyw & 0xff000000) >> 24)); |
3059 | write_nic_byte(dev, 0x7e, ((phyw & 0x00ff0000) >> 16)); | 3052 | write_nic_byte(dev, 0x7e, ((phyw & 0x00ff0000) >> 16)); |
3060 | write_nic_byte(dev, 0x7d, ((phyw & 0x0000ff00) >> 8)); | 3053 | write_nic_byte(dev, 0x7d, ((phyw & 0x0000ff00) >> 8)); |
3061 | write_nic_byte(dev, 0x7c, ((phyw & 0x000000ff) )); | 3054 | write_nic_byte(dev, 0x7c, ((phyw & 0x000000ff))); |
3062 | 3055 | ||
3063 | /* this is ok to fail when we write AGC table. check for AGC table might be | 3056 | /* this is ok to fail when we write AGC table. check for AGC table might be |
3064 | * done by masking with 0x7f instead of 0xff | 3057 | * done by masking with 0x7f instead of 0xff |
@@ -3066,13 +3059,13 @@ void rtl8185_write_phy(struct net_device *dev, u8 adr, u32 data) | |||
3066 | //if(phyr != (data&0xff)) DMESGW("Phy write timeout %x %x %x", phyr, data,adr); | 3059 | //if(phyr != (data&0xff)) DMESGW("Phy write timeout %x %x %x", phyr, data,adr); |
3067 | } | 3060 | } |
3068 | 3061 | ||
3069 | inline void write_phy_ofdm (struct net_device *dev, u8 adr, u32 data) | 3062 | inline void write_phy_ofdm(struct net_device *dev, u8 adr, u32 data) |
3070 | { | 3063 | { |
3071 | data = data & 0xff; | 3064 | data = data & 0xff; |
3072 | rtl8185_write_phy(dev, adr, data); | 3065 | rtl8185_write_phy(dev, adr, data); |
3073 | } | 3066 | } |
3074 | 3067 | ||
3075 | void write_phy_cck (struct net_device *dev, u8 adr, u32 data) | 3068 | void write_phy_cck(struct net_device *dev, u8 adr, u32 data) |
3076 | { | 3069 | { |
3077 | data = data & 0xff; | 3070 | data = data & 0xff; |
3078 | rtl8185_write_phy(dev, adr, data | 0x10000); | 3071 | rtl8185_write_phy(dev, adr, data | 0x10000); |
@@ -3082,19 +3075,19 @@ void rtl8185_set_rate(struct net_device *dev) | |||
3082 | { | 3075 | { |
3083 | int i; | 3076 | int i; |
3084 | u16 word; | 3077 | u16 word; |
3085 | int basic_rate,min_rr_rate,max_rr_rate; | 3078 | int basic_rate, min_rr_rate, max_rr_rate; |
3086 | 3079 | ||
3087 | basic_rate = ieeerate2rtlrate(240); | 3080 | basic_rate = ieeerate2rtlrate(240); |
3088 | min_rr_rate = ieeerate2rtlrate(60); | 3081 | min_rr_rate = ieeerate2rtlrate(60); |
3089 | max_rr_rate = ieeerate2rtlrate(240); | 3082 | max_rr_rate = ieeerate2rtlrate(240); |
3090 | 3083 | ||
3091 | write_nic_byte(dev, RESP_RATE, | 3084 | write_nic_byte(dev, RESP_RATE, |
3092 | max_rr_rate<<MAX_RESP_RATE_SHIFT| min_rr_rate<<MIN_RESP_RATE_SHIFT); | 3085 | max_rr_rate<<MAX_RESP_RATE_SHIFT | min_rr_rate<<MIN_RESP_RATE_SHIFT); |
3093 | 3086 | ||
3094 | word = read_nic_word(dev, BRSR); | 3087 | word = read_nic_word(dev, BRSR); |
3095 | word &= ~BRSR_MBR_8185; | 3088 | word &= ~BRSR_MBR_8185; |
3096 | 3089 | ||
3097 | for(i=0;i<=basic_rate;i++) | 3090 | for (i = 0; i <= basic_rate; i++) |
3098 | word |= (1<<i); | 3091 | word |= (1<<i); |
3099 | 3092 | ||
3100 | write_nic_word(dev, BRSR, word); | 3093 | write_nic_word(dev, BRSR, word); |
@@ -3117,8 +3110,8 @@ void rtl8180_adapter_start(struct net_device *dev) | |||
3117 | rtl8180_beacon_tx_disable(dev); | 3110 | rtl8180_beacon_tx_disable(dev); |
3118 | 3111 | ||
3119 | rtl8180_set_mode(dev, EPROM_CMD_CONFIG); | 3112 | rtl8180_set_mode(dev, EPROM_CMD_CONFIG); |
3120 | write_nic_dword(dev, MAC0, ((u32*)dev->dev_addr)[0]); | 3113 | write_nic_dword(dev, MAC0, ((u32 *)dev->dev_addr)[0]); |
3121 | write_nic_word(dev, MAC4, ((u32*)dev->dev_addr)[1] & 0xffff ); | 3114 | write_nic_word(dev, MAC4, ((u32 *)dev->dev_addr)[1] & 0xffff); |
3122 | rtl8180_set_mode(dev, EPROM_CMD_NORMAL); | 3115 | rtl8180_set_mode(dev, EPROM_CMD_NORMAL); |
3123 | 3116 | ||
3124 | rtl8180_update_msr(dev); | 3117 | rtl8180_update_msr(dev); |
@@ -3136,15 +3129,15 @@ void rtl8180_adapter_start(struct net_device *dev) | |||
3136 | */ | 3129 | */ |
3137 | 3130 | ||
3138 | write_nic_byte(dev, | 3131 | write_nic_byte(dev, |
3139 | CONFIG2, read_nic_byte(dev,CONFIG2) &~\ | 3132 | CONFIG2, read_nic_byte(dev, CONFIG2) & ~\ |
3140 | (1<<CONFIG2_DMA_POLLING_MODE_SHIFT)); | 3133 | (1<<CONFIG2_DMA_POLLING_MODE_SHIFT)); |
3141 | //^the nic isn't in test mode | 3134 | //^the nic isn't in test mode |
3142 | write_nic_byte(dev, | 3135 | write_nic_byte(dev, |
3143 | CONFIG2, read_nic_byte(dev,CONFIG2)|(1<<4)); | 3136 | CONFIG2, read_nic_byte(dev, CONFIG2)|(1<<4)); |
3144 | 3137 | ||
3145 | rtl8180_set_mode(dev,EPROM_CMD_NORMAL); | 3138 | rtl8180_set_mode(dev, EPROM_CMD_NORMAL); |
3146 | 3139 | ||
3147 | write_nic_dword(dev,INT_TIMEOUT,0); | 3140 | write_nic_dword(dev, INT_TIMEOUT, 0); |
3148 | 3141 | ||
3149 | write_nic_byte(dev, WPA_CONFIG, 0); | 3142 | write_nic_byte(dev, WPA_CONFIG, 0); |
3150 | 3143 | ||
@@ -3163,8 +3156,8 @@ void rtl8180_adapter_start(struct net_device *dev) | |||
3163 | 3156 | ||
3164 | priv->rf_init(dev); | 3157 | priv->rf_init(dev); |
3165 | 3158 | ||
3166 | if(priv->rf_set_sens != NULL) | 3159 | if (priv->rf_set_sens != NULL) |
3167 | priv->rf_set_sens(dev,priv->sens); | 3160 | priv->rf_set_sens(dev, priv->sens); |
3168 | rtl8180_irq_enable(dev); | 3161 | rtl8180_irq_enable(dev); |
3169 | 3162 | ||
3170 | netif_start_queue(dev); | 3163 | netif_start_queue(dev); |
@@ -3183,8 +3176,8 @@ void rtl8180_start_tx_beacon(struct net_device *dev) | |||
3183 | rtl8180_irq_disable(dev); | 3176 | rtl8180_irq_disable(dev); |
3184 | rtl8180_beacon_tx_enable(dev); | 3177 | rtl8180_beacon_tx_enable(dev); |
3185 | 3178 | ||
3186 | word = read_nic_word(dev, AtimWnd) &~ AtimWnd_AtimWnd; | 3179 | word = read_nic_word(dev, AtimWnd) & ~AtimWnd_AtimWnd; |
3187 | write_nic_word(dev, AtimWnd,word);// word |= | 3180 | write_nic_word(dev, AtimWnd, word); // word |= |
3188 | 3181 | ||
3189 | word = read_nic_word(dev, BintrItv); | 3182 | word = read_nic_word(dev, BintrItv); |
3190 | word &= ~BintrItv_BintrItv; | 3183 | word &= ~BintrItv_BintrItv; |
@@ -3215,7 +3208,7 @@ MgntActSet_802_11_PowerSaveMode( | |||
3215 | ) | 3208 | ) |
3216 | { | 3209 | { |
3217 | // Currently, we do not change power save mode on IBSS mode. | 3210 | // Currently, we do not change power save mode on IBSS mode. |
3218 | if(priv->ieee80211->iw_mode == IW_MODE_ADHOC) | 3211 | if (priv->ieee80211->iw_mode == IW_MODE_ADHOC) |
3219 | return false; | 3212 | return false; |
3220 | 3213 | ||
3221 | priv->ieee80211->ps = rtPsMode; | 3214 | priv->ieee80211->ps = rtPsMode; |
@@ -3239,53 +3232,48 @@ void LeisurePSLeave(struct r8180_priv *priv) | |||
3239 | } | 3232 | } |
3240 | } | 3233 | } |
3241 | 3234 | ||
3242 | void rtl8180_hw_wakeup_wq (struct work_struct *work) | 3235 | void rtl8180_hw_wakeup_wq(struct work_struct *work) |
3243 | { | 3236 | { |
3244 | struct delayed_work *dwork = to_delayed_work(work); | 3237 | struct delayed_work *dwork = to_delayed_work(work); |
3245 | struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,hw_wakeup_wq); | 3238 | struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, hw_wakeup_wq); |
3246 | struct net_device *dev = ieee->dev; | 3239 | struct net_device *dev = ieee->dev; |
3247 | 3240 | ||
3248 | rtl8180_hw_wakeup(dev); | 3241 | rtl8180_hw_wakeup(dev); |
3249 | } | 3242 | } |
3250 | 3243 | ||
3251 | void rtl8180_hw_sleep_wq (struct work_struct *work) | 3244 | void rtl8180_hw_sleep_wq(struct work_struct *work) |
3252 | { | 3245 | { |
3253 | struct delayed_work *dwork = to_delayed_work(work); | 3246 | struct delayed_work *dwork = to_delayed_work(work); |
3254 | struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,hw_sleep_wq); | 3247 | struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, hw_sleep_wq); |
3255 | struct net_device *dev = ieee->dev; | 3248 | struct net_device *dev = ieee->dev; |
3256 | 3249 | ||
3257 | rtl8180_hw_sleep_down(dev); | 3250 | rtl8180_hw_sleep_down(dev); |
3258 | } | 3251 | } |
3259 | 3252 | ||
3260 | static void MgntLinkKeepAlive(struct r8180_priv *priv ) | 3253 | static void MgntLinkKeepAlive(struct r8180_priv *priv) |
3261 | { | 3254 | { |
3262 | if (priv->keepAliveLevel == 0) | 3255 | if (priv->keepAliveLevel == 0) |
3263 | return; | 3256 | return; |
3264 | 3257 | ||
3265 | if(priv->ieee80211->state == IEEE80211_LINKED) | 3258 | if (priv->ieee80211->state == IEEE80211_LINKED) { |
3266 | { | ||
3267 | // | 3259 | // |
3268 | // Keep-Alive. | 3260 | // Keep-Alive. |
3269 | // | 3261 | // |
3270 | 3262 | ||
3271 | if ( (priv->keepAliveLevel== 2) || | 3263 | if ((priv->keepAliveLevel == 2) || |
3272 | (priv->link_detect.LastNumTxUnicast == priv->NumTxUnicast && | 3264 | (priv->link_detect.LastNumTxUnicast == priv->NumTxUnicast && |
3273 | priv->link_detect.LastNumRxUnicast == priv->ieee80211->NumRxUnicast ) | 3265 | priv->link_detect.LastNumRxUnicast == priv->ieee80211->NumRxUnicast) |
3274 | ) | 3266 | ) { |
3275 | { | ||
3276 | priv->link_detect.IdleCount++; | 3267 | priv->link_detect.IdleCount++; |
3277 | 3268 | ||
3278 | // | 3269 | // |
3279 | // Send a Keep-Alive packet packet to AP if we had been idle for a while. | 3270 | // Send a Keep-Alive packet packet to AP if we had been idle for a while. |
3280 | // | 3271 | // |
3281 | if(priv->link_detect.IdleCount >= ((KEEP_ALIVE_INTERVAL / CHECK_FOR_HANG_PERIOD)-1) ) | 3272 | if (priv->link_detect.IdleCount >= ((KEEP_ALIVE_INTERVAL / CHECK_FOR_HANG_PERIOD)-1)) { |
3282 | { | ||
3283 | priv->link_detect.IdleCount = 0; | 3273 | priv->link_detect.IdleCount = 0; |
3284 | ieee80211_sta_ps_send_null_frame(priv->ieee80211, false); | 3274 | ieee80211_sta_ps_send_null_frame(priv->ieee80211, false); |
3285 | } | 3275 | } |
3286 | } | 3276 | } else { |
3287 | else | ||
3288 | { | ||
3289 | priv->link_detect.IdleCount = 0; | 3277 | priv->link_detect.IdleCount = 0; |
3290 | } | 3278 | } |
3291 | priv->link_detect.LastNumTxUnicast = priv->NumTxUnicast; | 3279 | priv->link_detect.LastNumTxUnicast = priv->NumTxUnicast; |
@@ -3303,19 +3291,18 @@ void rtl8180_watch_dog(struct net_device *dev) | |||
3303 | u32 TotalRxNum = 0; | 3291 | u32 TotalRxNum = 0; |
3304 | u16 SlotIndex = 0; | 3292 | u16 SlotIndex = 0; |
3305 | u16 i = 0; | 3293 | u16 i = 0; |
3306 | if(priv->ieee80211->actscanning == false){ | 3294 | if (priv->ieee80211->actscanning == false) { |
3307 | if((priv->ieee80211->iw_mode != IW_MODE_ADHOC) && (priv->ieee80211->state == IEEE80211_NOLINK) && (priv->ieee80211->beinretry == false) && (priv->eRFPowerState == eRfOn)){ | 3295 | if ((priv->ieee80211->iw_mode != IW_MODE_ADHOC) && (priv->ieee80211->state == IEEE80211_NOLINK) && (priv->ieee80211->beinretry == false) && (priv->eRFPowerState == eRfOn)) |
3308 | IPSEnter(dev); | 3296 | IPSEnter(dev); |
3309 | } | ||
3310 | } | 3297 | } |
3311 | //YJ,add,080828,for link state check | 3298 | //YJ,add,080828,for link state check |
3312 | if((priv->ieee80211->state == IEEE80211_LINKED) && (priv->ieee80211->iw_mode == IW_MODE_INFRA)){ | 3299 | if ((priv->ieee80211->state == IEEE80211_LINKED) && (priv->ieee80211->iw_mode == IW_MODE_INFRA)) { |
3313 | SlotIndex = (priv->link_detect.SlotIndex++) % priv->link_detect.SlotNum; | 3300 | SlotIndex = (priv->link_detect.SlotIndex++) % priv->link_detect.SlotNum; |
3314 | priv->link_detect.RxFrameNum[SlotIndex] = priv->ieee80211->NumRxDataInPeriod + priv->ieee80211->NumRxBcnInPeriod; | 3301 | priv->link_detect.RxFrameNum[SlotIndex] = priv->ieee80211->NumRxDataInPeriod + priv->ieee80211->NumRxBcnInPeriod; |
3315 | for( i=0; i<priv->link_detect.SlotNum; i++ ) | 3302 | for (i = 0; i < priv->link_detect.SlotNum; i++) |
3316 | TotalRxNum+= priv->link_detect.RxFrameNum[i]; | 3303 | TotalRxNum += priv->link_detect.RxFrameNum[i]; |
3317 | 3304 | ||
3318 | if(TotalRxNum == 0){ | 3305 | if (TotalRxNum == 0) { |
3319 | priv->ieee80211->state = IEEE80211_ASSOCIATING; | 3306 | priv->ieee80211->state = IEEE80211_ASSOCIATING; |
3320 | queue_work(priv->ieee80211->wq, &priv->ieee80211->associate_procedure_wq); | 3307 | queue_work(priv->ieee80211->wq, &priv->ieee80211->associate_procedure_wq); |
3321 | } | 3308 | } |
@@ -3329,20 +3316,20 @@ void rtl8180_watch_dog(struct net_device *dev) | |||
3329 | priv->bLeisurePs = true; | 3316 | priv->bLeisurePs = true; |
3330 | else if (priv->PowerProfile == POWER_PROFILE_AC) { | 3317 | else if (priv->PowerProfile == POWER_PROFILE_AC) { |
3331 | LeisurePSLeave(priv); | 3318 | LeisurePSLeave(priv); |
3332 | priv->bLeisurePs= false; | 3319 | priv->bLeisurePs = false; |
3333 | } | 3320 | } |
3334 | 3321 | ||
3335 | if(priv->ieee80211->state == IEEE80211_LINKED){ | 3322 | if (priv->ieee80211->state == IEEE80211_LINKED) { |
3336 | priv->link_detect.NumRxOkInPeriod = priv->ieee80211->NumRxDataInPeriod; | 3323 | priv->link_detect.NumRxOkInPeriod = priv->ieee80211->NumRxDataInPeriod; |
3337 | if( priv->link_detect.NumRxOkInPeriod> 666 || | 3324 | if (priv->link_detect.NumRxOkInPeriod > 666 || |
3338 | priv->link_detect.NumTxOkInPeriod> 666 ) { | 3325 | priv->link_detect.NumTxOkInPeriod > 666) { |
3339 | bBusyTraffic = true; | 3326 | bBusyTraffic = true; |
3340 | } | 3327 | } |
3341 | if(((priv->link_detect.NumRxOkInPeriod + priv->link_detect.NumTxOkInPeriod) > 8) | 3328 | if (((priv->link_detect.NumRxOkInPeriod + priv->link_detect.NumTxOkInPeriod) > 8) |
3342 | || (priv->link_detect.NumRxOkInPeriod > 2)) { | 3329 | || (priv->link_detect.NumRxOkInPeriod > 2)) { |
3343 | bEnterPS= false; | 3330 | bEnterPS = false; |
3344 | } else | 3331 | } else |
3345 | bEnterPS= true; | 3332 | bEnterPS = true; |
3346 | 3333 | ||
3347 | if (bEnterPS) | 3334 | if (bEnterPS) |
3348 | LeisurePSEnter(priv); | 3335 | LeisurePSEnter(priv); |
@@ -3361,17 +3348,17 @@ int _rtl8180_up(struct net_device *dev) | |||
3361 | { | 3348 | { |
3362 | struct r8180_priv *priv = ieee80211_priv(dev); | 3349 | struct r8180_priv *priv = ieee80211_priv(dev); |
3363 | 3350 | ||
3364 | priv->up=1; | 3351 | priv->up = 1; |
3365 | 3352 | ||
3366 | DMESG("Bringing up iface"); | 3353 | DMESG("Bringing up iface"); |
3367 | rtl8185b_adapter_start(dev); | 3354 | rtl8185b_adapter_start(dev); |
3368 | rtl8185b_rx_enable(dev); | 3355 | rtl8185b_rx_enable(dev); |
3369 | rtl8185b_tx_enable(dev); | 3356 | rtl8185b_tx_enable(dev); |
3370 | if(priv->bInactivePs){ | 3357 | if (priv->bInactivePs) { |
3371 | if(priv->ieee80211->iw_mode == IW_MODE_ADHOC) | 3358 | if (priv->ieee80211->iw_mode == IW_MODE_ADHOC) |
3372 | IPSLeave(dev); | 3359 | IPSLeave(dev); |
3373 | } | 3360 | } |
3374 | timer_rate_adaptive((unsigned long)dev); | 3361 | timer_rate_adaptive((unsigned long)dev); |
3375 | watch_dog_adaptive((unsigned long)dev); | 3362 | watch_dog_adaptive((unsigned long)dev); |
3376 | if (priv->bSwAntennaDiverity) | 3363 | if (priv->bSwAntennaDiverity) |
3377 | SwAntennaDiversityTimerCallback(dev); | 3364 | SwAntennaDiversityTimerCallback(dev); |
@@ -3394,7 +3381,8 @@ int rtl8180_up(struct net_device *dev) | |||
3394 | { | 3381 | { |
3395 | struct r8180_priv *priv = ieee80211_priv(dev); | 3382 | struct r8180_priv *priv = ieee80211_priv(dev); |
3396 | 3383 | ||
3397 | if (priv->up == 1) return -1; | 3384 | if (priv->up == 1) |
3385 | return -1; | ||
3398 | 3386 | ||
3399 | return _rtl8180_up(dev); | 3387 | return _rtl8180_up(dev); |
3400 | } | 3388 | } |
@@ -3418,7 +3406,7 @@ int rtl8180_down(struct net_device *dev) | |||
3418 | if (priv->up == 0) | 3406 | if (priv->up == 0) |
3419 | return -1; | 3407 | return -1; |
3420 | 3408 | ||
3421 | priv->up=0; | 3409 | priv->up = 0; |
3422 | 3410 | ||
3423 | ieee80211_softmac_stop_protocol(priv->ieee80211); | 3411 | ieee80211_softmac_stop_protocol(priv->ieee80211); |
3424 | /* FIXME */ | 3412 | /* FIXME */ |
@@ -3434,8 +3422,8 @@ int rtl8180_down(struct net_device *dev) | |||
3434 | cancel_delayed_work(&priv->ieee80211->hw_dig_wq); | 3422 | cancel_delayed_work(&priv->ieee80211->hw_dig_wq); |
3435 | cancel_delayed_work(&priv->ieee80211->tx_pw_wq); | 3423 | cancel_delayed_work(&priv->ieee80211->tx_pw_wq); |
3436 | del_timer_sync(&priv->SwAntennaDiversityTimer); | 3424 | del_timer_sync(&priv->SwAntennaDiversityTimer); |
3437 | SetZebraRFPowerState8185(dev,eRfOff); | 3425 | SetZebraRFPowerState8185(dev, eRfOff); |
3438 | memset(&(priv->ieee80211->current_network),0,sizeof(struct ieee80211_network)); | 3426 | memset(&(priv->ieee80211->current_network), 0, sizeof(struct ieee80211_network)); |
3439 | priv->ieee80211->state = IEEE80211_NOLINK; | 3427 | priv->ieee80211->state = IEEE80211_NOLINK; |
3440 | return 0; | 3428 | return 0; |
3441 | } | 3429 | } |
@@ -3485,7 +3473,7 @@ static void r8180_set_multicast(struct net_device *dev) | |||
3485 | struct r8180_priv *priv = ieee80211_priv(dev); | 3473 | struct r8180_priv *priv = ieee80211_priv(dev); |
3486 | short promisc; | 3474 | short promisc; |
3487 | 3475 | ||
3488 | promisc = (dev->flags & IFF_PROMISC) ? 1:0; | 3476 | promisc = (dev->flags & IFF_PROMISC) ? 1 : 0; |
3489 | 3477 | ||
3490 | if (promisc != priv->promisc) | 3478 | if (promisc != priv->promisc) |
3491 | rtl8180_restart(dev); | 3479 | rtl8180_restart(dev); |
@@ -3502,7 +3490,7 @@ int r8180_set_mac_adr(struct net_device *dev, void *mac) | |||
3502 | 3490 | ||
3503 | memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); | 3491 | memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); |
3504 | 3492 | ||
3505 | if(priv->ieee80211->iw_mode == IW_MODE_MASTER) | 3493 | if (priv->ieee80211->iw_mode == IW_MODE_MASTER) |
3506 | memcpy(priv->ieee80211->current_network.bssid, dev->dev_addr, ETH_ALEN); | 3494 | memcpy(priv->ieee80211->current_network.bssid, dev->dev_addr, ETH_ALEN); |
3507 | 3495 | ||
3508 | if (priv->up) { | 3496 | if (priv->up) { |
@@ -3520,7 +3508,7 @@ int rtl8180_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) | |||
3520 | { | 3508 | { |
3521 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 3509 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
3522 | struct iwreq *wrq = (struct iwreq *) rq; | 3510 | struct iwreq *wrq = (struct iwreq *) rq; |
3523 | int ret=-1; | 3511 | int ret = -1; |
3524 | 3512 | ||
3525 | switch (cmd) { | 3513 | switch (cmd) { |
3526 | case RTL_IOCTL_WPA_SUPPLICANT: | 3514 | case RTL_IOCTL_WPA_SUPPLICANT: |
@@ -3551,21 +3539,21 @@ static int __devinit rtl8180_pci_probe(struct pci_dev *pdev, | |||
3551 | { | 3539 | { |
3552 | unsigned long ioaddr = 0; | 3540 | unsigned long ioaddr = 0; |
3553 | struct net_device *dev = NULL; | 3541 | struct net_device *dev = NULL; |
3554 | struct r8180_priv *priv= NULL; | 3542 | struct r8180_priv *priv = NULL; |
3555 | u8 unit = 0; | 3543 | u8 unit = 0; |
3556 | 3544 | ||
3557 | unsigned long pmem_start, pmem_len, pmem_flags; | 3545 | unsigned long pmem_start, pmem_len, pmem_flags; |
3558 | 3546 | ||
3559 | DMESG("Configuring chip resources"); | 3547 | DMESG("Configuring chip resources"); |
3560 | 3548 | ||
3561 | if( pci_enable_device (pdev) ){ | 3549 | if (pci_enable_device(pdev)) { |
3562 | DMESG("Failed to enable PCI device"); | 3550 | DMESG("Failed to enable PCI device"); |
3563 | return -EIO; | 3551 | return -EIO; |
3564 | } | 3552 | } |
3565 | 3553 | ||
3566 | pci_set_master(pdev); | 3554 | pci_set_master(pdev); |
3567 | pci_set_dma_mask(pdev, 0xffffff00ULL); | 3555 | pci_set_dma_mask(pdev, 0xffffff00ULL); |
3568 | pci_set_consistent_dma_mask(pdev,0xffffff00ULL); | 3556 | pci_set_consistent_dma_mask(pdev, 0xffffff00ULL); |
3569 | dev = alloc_ieee80211(sizeof(struct r8180_priv)); | 3557 | dev = alloc_ieee80211(sizeof(struct r8180_priv)); |
3570 | if (!dev) | 3558 | if (!dev) |
3571 | return -ENOMEM; | 3559 | return -ENOMEM; |
@@ -3580,20 +3568,20 @@ static int __devinit rtl8180_pci_probe(struct pci_dev *pdev, | |||
3580 | 3568 | ||
3581 | pmem_start = pci_resource_start(pdev, 1); | 3569 | pmem_start = pci_resource_start(pdev, 1); |
3582 | pmem_len = pci_resource_len(pdev, 1); | 3570 | pmem_len = pci_resource_len(pdev, 1); |
3583 | pmem_flags = pci_resource_flags (pdev, 1); | 3571 | pmem_flags = pci_resource_flags(pdev, 1); |
3584 | 3572 | ||
3585 | if (!(pmem_flags & IORESOURCE_MEM)) { | 3573 | if (!(pmem_flags & IORESOURCE_MEM)) { |
3586 | DMESG("region #1 not a MMIO resource, aborting"); | 3574 | DMESG("region #1 not a MMIO resource, aborting"); |
3587 | goto fail; | 3575 | goto fail; |
3588 | } | 3576 | } |
3589 | 3577 | ||
3590 | if( ! request_mem_region(pmem_start, pmem_len, RTL8180_MODULE_NAME)) { | 3578 | if (!request_mem_region(pmem_start, pmem_len, RTL8180_MODULE_NAME)) { |
3591 | DMESG("request_mem_region failed!"); | 3579 | DMESG("request_mem_region failed!"); |
3592 | goto fail; | 3580 | goto fail; |
3593 | } | 3581 | } |
3594 | 3582 | ||
3595 | ioaddr = (unsigned long)ioremap_nocache( pmem_start, pmem_len); | 3583 | ioaddr = (unsigned long)ioremap_nocache(pmem_start, pmem_len); |
3596 | if( ioaddr == (unsigned long)NULL ){ | 3584 | if (ioaddr == (unsigned long)NULL) { |
3597 | DMESG("ioremap failed!"); | 3585 | DMESG("ioremap failed!"); |
3598 | goto fail1; | 3586 | goto fail1; |
3599 | } | 3587 | } |
@@ -3610,16 +3598,16 @@ static int __devinit rtl8180_pci_probe(struct pci_dev *pdev, | |||
3610 | dev->netdev_ops = &rtl8180_netdev_ops; | 3598 | dev->netdev_ops = &rtl8180_netdev_ops; |
3611 | dev->wireless_handlers = &r8180_wx_handlers_def; | 3599 | dev->wireless_handlers = &r8180_wx_handlers_def; |
3612 | 3600 | ||
3613 | dev->type=ARPHRD_ETHER; | 3601 | dev->type = ARPHRD_ETHER; |
3614 | dev->watchdog_timeo = HZ*3; | 3602 | dev->watchdog_timeo = HZ*3; |
3615 | 3603 | ||
3616 | if (dev_alloc_name(dev, ifname) < 0){ | 3604 | if (dev_alloc_name(dev, ifname) < 0) { |
3617 | DMESG("Oops: devname already taken! Trying wlan%%d...\n"); | 3605 | DMESG("Oops: devname already taken! Trying wlan%%d...\n"); |
3618 | ifname = "wlan%d"; | 3606 | ifname = "wlan%d"; |
3619 | dev_alloc_name(dev, ifname); | 3607 | dev_alloc_name(dev, ifname); |
3620 | } | 3608 | } |
3621 | 3609 | ||
3622 | if(rtl8180_init(dev)!=0){ | 3610 | if (rtl8180_init(dev) != 0) { |
3623 | DMESG("Initialization failed"); | 3611 | DMESG("Initialization failed"); |
3624 | goto fail1; | 3612 | goto fail1; |
3625 | } | 3613 | } |
@@ -3633,16 +3621,16 @@ static int __devinit rtl8180_pci_probe(struct pci_dev *pdev, | |||
3633 | DMESG("Driver probe completed\n"); | 3621 | DMESG("Driver probe completed\n"); |
3634 | return 0; | 3622 | return 0; |
3635 | fail1: | 3623 | fail1: |
3636 | if( dev->mem_start != (unsigned long)NULL ){ | 3624 | if (dev->mem_start != (unsigned long)NULL) { |
3637 | iounmap( (void *)dev->mem_start ); | 3625 | iounmap((void *)dev->mem_start); |
3638 | release_mem_region( pci_resource_start(pdev, 1), | 3626 | release_mem_region(pci_resource_start(pdev, 1), |
3639 | pci_resource_len(pdev, 1) ); | 3627 | pci_resource_len(pdev, 1)); |
3640 | } | 3628 | } |
3641 | fail: | 3629 | fail: |
3642 | if(dev){ | 3630 | if (dev) { |
3643 | if (priv->irq) { | 3631 | if (priv->irq) { |
3644 | free_irq(dev->irq, dev); | 3632 | free_irq(dev->irq, dev); |
3645 | dev->irq=0; | 3633 | dev->irq = 0; |
3646 | } | 3634 | } |
3647 | free_ieee80211(dev); | 3635 | free_ieee80211(dev); |
3648 | } | 3636 | } |
@@ -3670,19 +3658,19 @@ static void __devexit rtl8180_pci_remove(struct pci_dev *pdev) | |||
3670 | rtl8180_reset(dev); | 3658 | rtl8180_reset(dev); |
3671 | mdelay(10); | 3659 | mdelay(10); |
3672 | 3660 | ||
3673 | if(priv->irq){ | 3661 | if (priv->irq) { |
3674 | DMESG("Freeing irq %d",dev->irq); | 3662 | DMESG("Freeing irq %d", dev->irq); |
3675 | free_irq(dev->irq, dev); | 3663 | free_irq(dev->irq, dev); |
3676 | priv->irq=0; | 3664 | priv->irq = 0; |
3677 | } | 3665 | } |
3678 | 3666 | ||
3679 | free_rx_desc_ring(dev); | 3667 | free_rx_desc_ring(dev); |
3680 | free_tx_desc_rings(dev); | 3668 | free_tx_desc_rings(dev); |
3681 | 3669 | ||
3682 | if( dev->mem_start != (unsigned long)NULL ){ | 3670 | if (dev->mem_start != (unsigned long)NULL) { |
3683 | iounmap( (void *)dev->mem_start ); | 3671 | iounmap((void *)dev->mem_start); |
3684 | release_mem_region( pci_resource_start(pdev, 1), | 3672 | release_mem_region(pci_resource_start(pdev, 1), |
3685 | pci_resource_len(pdev, 1) ); | 3673 | pci_resource_len(pdev, 1)); |
3686 | } | 3674 | } |
3687 | 3675 | ||
3688 | free_ieee80211(dev); | 3676 | free_ieee80211(dev); |
@@ -3742,7 +3730,7 @@ static int __init rtl8180_pci_module_init(void) | |||
3742 | 3730 | ||
3743 | static void __exit rtl8180_pci_module_exit(void) | 3731 | static void __exit rtl8180_pci_module_exit(void) |
3744 | { | 3732 | { |
3745 | pci_unregister_driver (&rtl8180_pci_driver); | 3733 | pci_unregister_driver(&rtl8180_pci_driver); |
3746 | rtl8180_proc_module_remove(); | 3734 | rtl8180_proc_module_remove(); |
3747 | ieee80211_crypto_tkip_exit(); | 3735 | ieee80211_crypto_tkip_exit(); |
3748 | ieee80211_crypto_ccmp_exit(); | 3736 | ieee80211_crypto_ccmp_exit(); |
@@ -3757,15 +3745,15 @@ void rtl8180_try_wake_queue(struct net_device *dev, int pri) | |||
3757 | short enough_desc; | 3745 | short enough_desc; |
3758 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 3746 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
3759 | 3747 | ||
3760 | spin_lock_irqsave(&priv->tx_lock,flags); | 3748 | spin_lock_irqsave(&priv->tx_lock, flags); |
3761 | enough_desc = check_nic_enought_desc(dev,pri); | 3749 | enough_desc = check_nic_enought_desc(dev, pri); |
3762 | spin_unlock_irqrestore(&priv->tx_lock,flags); | 3750 | spin_unlock_irqrestore(&priv->tx_lock, flags); |
3763 | 3751 | ||
3764 | if(enough_desc) | 3752 | if (enough_desc) |
3765 | ieee80211_rtl_wake_queue(priv->ieee80211); | 3753 | ieee80211_rtl_wake_queue(priv->ieee80211); |
3766 | } | 3754 | } |
3767 | 3755 | ||
3768 | void rtl8180_tx_isr(struct net_device *dev, int pri,short error) | 3756 | void rtl8180_tx_isr(struct net_device *dev, int pri, short error) |
3769 | { | 3757 | { |
3770 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); | 3758 | struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); |
3771 | u32 *tail; //tail virtual addr | 3759 | u32 *tail; //tail virtual addr |
@@ -3777,64 +3765,65 @@ void rtl8180_tx_isr(struct net_device *dev, int pri,short error) | |||
3777 | unsigned long flag; | 3765 | unsigned long flag; |
3778 | /* physical addr are ok on 32 bits since we set DMA mask*/ | 3766 | /* physical addr are ok on 32 bits since we set DMA mask*/ |
3779 | int offs; | 3767 | int offs; |
3780 | int j,i; | 3768 | int j, i; |
3781 | int hd; | 3769 | int hd; |
3782 | if (error) priv->stats.txretry++; //tony 20060601 | 3770 | if (error) |
3783 | spin_lock_irqsave(&priv->tx_lock,flag); | 3771 | priv->stats.txretry++; //tony 20060601 |
3784 | switch(pri) { | 3772 | spin_lock_irqsave(&priv->tx_lock, flag); |
3773 | switch (pri) { | ||
3785 | case MANAGE_PRIORITY: | 3774 | case MANAGE_PRIORITY: |
3786 | tail = priv->txmapringtail; | 3775 | tail = priv->txmapringtail; |
3787 | begin = priv->txmapring; | 3776 | begin = priv->txmapring; |
3788 | head = priv->txmapringhead; | 3777 | head = priv->txmapringhead; |
3789 | nic = read_nic_dword(dev,TX_MANAGEPRIORITY_RING_ADDR); | 3778 | nic = read_nic_dword(dev, TX_MANAGEPRIORITY_RING_ADDR); |
3790 | nicbegin = priv->txmapringdma; | 3779 | nicbegin = priv->txmapringdma; |
3791 | break; | 3780 | break; |
3792 | case BK_PRIORITY: | 3781 | case BK_PRIORITY: |
3793 | tail = priv->txbkpringtail; | 3782 | tail = priv->txbkpringtail; |
3794 | begin = priv->txbkpring; | 3783 | begin = priv->txbkpring; |
3795 | head = priv->txbkpringhead; | 3784 | head = priv->txbkpringhead; |
3796 | nic = read_nic_dword(dev,TX_BKPRIORITY_RING_ADDR); | 3785 | nic = read_nic_dword(dev, TX_BKPRIORITY_RING_ADDR); |
3797 | nicbegin = priv->txbkpringdma; | 3786 | nicbegin = priv->txbkpringdma; |
3798 | break; | 3787 | break; |
3799 | case BE_PRIORITY: | 3788 | case BE_PRIORITY: |
3800 | tail = priv->txbepringtail; | 3789 | tail = priv->txbepringtail; |
3801 | begin = priv->txbepring; | 3790 | begin = priv->txbepring; |
3802 | head = priv->txbepringhead; | 3791 | head = priv->txbepringhead; |
3803 | nic = read_nic_dword(dev,TX_BEPRIORITY_RING_ADDR); | 3792 | nic = read_nic_dword(dev, TX_BEPRIORITY_RING_ADDR); |
3804 | nicbegin = priv->txbepringdma; | 3793 | nicbegin = priv->txbepringdma; |
3805 | break; | 3794 | break; |
3806 | case VI_PRIORITY: | 3795 | case VI_PRIORITY: |
3807 | tail = priv->txvipringtail; | 3796 | tail = priv->txvipringtail; |
3808 | begin = priv->txvipring; | 3797 | begin = priv->txvipring; |
3809 | head = priv->txvipringhead; | 3798 | head = priv->txvipringhead; |
3810 | nic = read_nic_dword(dev,TX_VIPRIORITY_RING_ADDR); | 3799 | nic = read_nic_dword(dev, TX_VIPRIORITY_RING_ADDR); |
3811 | nicbegin = priv->txvipringdma; | 3800 | nicbegin = priv->txvipringdma; |
3812 | break; | 3801 | break; |
3813 | case VO_PRIORITY: | 3802 | case VO_PRIORITY: |
3814 | tail = priv->txvopringtail; | 3803 | tail = priv->txvopringtail; |
3815 | begin = priv->txvopring; | 3804 | begin = priv->txvopring; |
3816 | head = priv->txvopringhead; | 3805 | head = priv->txvopringhead; |
3817 | nic = read_nic_dword(dev,TX_VOPRIORITY_RING_ADDR); | 3806 | nic = read_nic_dword(dev, TX_VOPRIORITY_RING_ADDR); |
3818 | nicbegin = priv->txvopringdma; | 3807 | nicbegin = priv->txvopringdma; |
3819 | break; | 3808 | break; |
3820 | case HI_PRIORITY: | 3809 | case HI_PRIORITY: |
3821 | tail = priv->txhpringtail; | 3810 | tail = priv->txhpringtail; |
3822 | begin = priv->txhpring; | 3811 | begin = priv->txhpring; |
3823 | head = priv->txhpringhead; | 3812 | head = priv->txhpringhead; |
3824 | nic = read_nic_dword(dev,TX_HIGHPRIORITY_RING_ADDR); | 3813 | nic = read_nic_dword(dev, TX_HIGHPRIORITY_RING_ADDR); |
3825 | nicbegin = priv->txhpringdma; | 3814 | nicbegin = priv->txhpringdma; |
3826 | break; | 3815 | break; |
3827 | 3816 | ||
3828 | default: | 3817 | default: |
3829 | spin_unlock_irqrestore(&priv->tx_lock,flag); | 3818 | spin_unlock_irqrestore(&priv->tx_lock, flag); |
3830 | return ; | 3819 | return ; |
3831 | } | 3820 | } |
3832 | 3821 | ||
3833 | nicv = (u32*) ((nic - nicbegin) + (u8*)begin); | 3822 | nicv = (u32 *)((nic - nicbegin) + (u8*)begin); |
3834 | if((head <= tail && (nicv > tail || nicv < head)) || | 3823 | if ((head <= tail && (nicv > tail || nicv < head)) || |
3835 | (head > tail && (nicv > tail && nicv < head))){ | 3824 | (head > tail && (nicv > tail && nicv < head))) { |
3836 | DMESGW("nic has lost pointer"); | 3825 | DMESGW("nic has lost pointer"); |
3837 | spin_unlock_irqrestore(&priv->tx_lock,flag); | 3826 | spin_unlock_irqrestore(&priv->tx_lock, flag); |
3838 | rtl8180_restart(dev); | 3827 | rtl8180_restart(dev); |
3839 | return; | 3828 | return; |
3840 | } | 3829 | } |
@@ -3844,22 +3833,22 @@ void rtl8180_tx_isr(struct net_device *dev, int pri,short error) | |||
3844 | * and the previous of the pointed (might be in process ??) | 3833 | * and the previous of the pointed (might be in process ??) |
3845 | */ | 3834 | */ |
3846 | offs = (nic - nicbegin); | 3835 | offs = (nic - nicbegin); |
3847 | offs = offs / 8 /4; | 3836 | offs = offs / 8 / 4; |
3848 | hd = (head - begin) /8; | 3837 | hd = (head - begin) / 8; |
3849 | 3838 | ||
3850 | if(offs >= hd) | 3839 | if (offs >= hd) |
3851 | j = offs - hd; | 3840 | j = offs - hd; |
3852 | else | 3841 | else |
3853 | j = offs + (priv->txringcount -1 -hd); | 3842 | j = offs + (priv->txringcount-1-hd); |
3854 | 3843 | ||
3855 | j-=2; | 3844 | j -= 2; |
3856 | if(j<0) j=0; | 3845 | if (j < 0) |
3846 | j = 0; | ||
3857 | 3847 | ||
3858 | for(i=0;i<j;i++) | 3848 | for (i = 0; i < j; i++) { |
3859 | { | 3849 | if ((*head) & (1<<31)) |
3860 | if((*head) & (1<<31)) | ||
3861 | break; | 3850 | break; |
3862 | if(((*head)&(0x10000000)) != 0){ | 3851 | if (((*head)&(0x10000000)) != 0) { |
3863 | priv->CurrRetryCnt += (u16)((*head) & (0x000000ff)); | 3852 | priv->CurrRetryCnt += (u16)((*head) & (0x000000ff)); |
3864 | if (!error) | 3853 | if (!error) |
3865 | priv->NumTxOkTotal++; | 3854 | priv->NumTxOkTotal++; |
@@ -3868,12 +3857,12 @@ void rtl8180_tx_isr(struct net_device *dev, int pri,short error) | |||
3868 | if (!error) | 3857 | if (!error) |
3869 | priv->NumTxOkBytesTotal += (*(head+3)) & (0x00000fff); | 3858 | priv->NumTxOkBytesTotal += (*(head+3)) & (0x00000fff); |
3870 | 3859 | ||
3871 | *head = *head &~ (1<<31); | 3860 | *head = *head & ~(1<<31); |
3872 | 3861 | ||
3873 | if((head - begin)/8 == priv->txringcount-1) | 3862 | if ((head - begin)/8 == priv->txringcount-1) |
3874 | head=begin; | 3863 | head = begin; |
3875 | else | 3864 | else |
3876 | head+=8; | 3865 | head += 8; |
3877 | } | 3866 | } |
3878 | 3867 | ||
3879 | /* the head has been moved to the last certainly TXed | 3868 | /* the head has been moved to the last certainly TXed |
@@ -3885,14 +3874,14 @@ void rtl8180_tx_isr(struct net_device *dev, int pri,short error) | |||
3885 | * TXed no memory leak occour at all. | 3874 | * TXed no memory leak occour at all. |
3886 | */ | 3875 | */ |
3887 | 3876 | ||
3888 | switch(pri) { | 3877 | switch (pri) { |
3889 | case MANAGE_PRIORITY: | 3878 | case MANAGE_PRIORITY: |
3890 | priv->txmapringhead = head; | 3879 | priv->txmapringhead = head; |
3891 | 3880 | ||
3892 | if(priv->ack_tx_to_ieee){ | 3881 | if (priv->ack_tx_to_ieee) { |
3893 | if(rtl8180_is_tx_queue_empty(dev)){ | 3882 | if (rtl8180_is_tx_queue_empty(dev)) { |
3894 | priv->ack_tx_to_ieee = 0; | 3883 | priv->ack_tx_to_ieee = 0; |
3895 | ieee80211_ps_tx_ack(priv->ieee80211,!error); | 3884 | ieee80211_ps_tx_ack(priv->ieee80211, !error); |
3896 | } | 3885 | } |
3897 | } | 3886 | } |
3898 | break; | 3887 | break; |
@@ -3913,17 +3902,17 @@ void rtl8180_tx_isr(struct net_device *dev, int pri,short error) | |||
3913 | break; | 3902 | break; |
3914 | } | 3903 | } |
3915 | 3904 | ||
3916 | spin_unlock_irqrestore(&priv->tx_lock,flag); | 3905 | spin_unlock_irqrestore(&priv->tx_lock, flag); |
3917 | } | 3906 | } |
3918 | 3907 | ||
3919 | void rtl8180_tx_irq_wq(struct work_struct *work) | 3908 | void rtl8180_tx_irq_wq(struct work_struct *work) |
3920 | { | 3909 | { |
3921 | struct delayed_work *dwork = to_delayed_work(work); | 3910 | struct delayed_work *dwork = to_delayed_work(work); |
3922 | struct ieee80211_device * ieee = (struct ieee80211_device*) | 3911 | struct ieee80211_device * ieee = (struct ieee80211_device *) |
3923 | container_of(dwork, struct ieee80211_device, watch_dog_wq); | 3912 | container_of(dwork, struct ieee80211_device, watch_dog_wq); |
3924 | struct net_device *dev = ieee->dev; | 3913 | struct net_device *dev = ieee->dev; |
3925 | 3914 | ||
3926 | rtl8180_tx_isr(dev,MANAGE_PRIORITY,0); | 3915 | rtl8180_tx_isr(dev, MANAGE_PRIORITY, 0); |
3927 | } | 3916 | } |
3928 | irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs) | 3917 | irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs) |
3929 | { | 3918 | { |
@@ -3933,18 +3922,19 @@ irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs) | |||
3933 | u32 inta; | 3922 | u32 inta; |
3934 | 3923 | ||
3935 | /* We should return IRQ_NONE, but for now let me keep this */ | 3924 | /* We should return IRQ_NONE, but for now let me keep this */ |
3936 | if(priv->irq_enabled == 0) return IRQ_HANDLED; | 3925 | if (priv->irq_enabled == 0) |
3926 | return IRQ_HANDLED; | ||
3937 | 3927 | ||
3938 | spin_lock_irqsave(&priv->irq_th_lock,flags); | 3928 | spin_lock_irqsave(&priv->irq_th_lock, flags); |
3939 | 3929 | ||
3940 | //ISR: 4bytes | 3930 | //ISR: 4bytes |
3941 | inta = read_nic_dword(dev, ISR);// & priv->IntrMask; | 3931 | inta = read_nic_dword(dev, ISR);// & priv->IntrMask; |
3942 | write_nic_dword(dev,ISR,inta); // reset int situation | 3932 | write_nic_dword(dev, ISR, inta); // reset int situation |
3943 | 3933 | ||
3944 | priv->stats.shints++; | 3934 | priv->stats.shints++; |
3945 | 3935 | ||
3946 | if(!inta){ | 3936 | if (!inta) { |
3947 | spin_unlock_irqrestore(&priv->irq_th_lock,flags); | 3937 | spin_unlock_irqrestore(&priv->irq_th_lock, flags); |
3948 | return IRQ_HANDLED; | 3938 | return IRQ_HANDLED; |
3949 | /* | 3939 | /* |
3950 | most probably we can safely return IRQ_NONE, | 3940 | most probably we can safely return IRQ_NONE, |
@@ -3960,8 +3950,8 @@ irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs) | |||
3960 | 3950 | ||
3961 | priv->stats.ints++; | 3951 | priv->stats.ints++; |
3962 | 3952 | ||
3963 | if(!netif_running(dev)) { | 3953 | if (!netif_running(dev)) { |
3964 | spin_unlock_irqrestore(&priv->irq_th_lock,flags); | 3954 | spin_unlock_irqrestore(&priv->irq_th_lock, flags); |
3965 | return IRQ_HANDLED; | 3955 | return IRQ_HANDLED; |
3966 | } | 3956 | } |
3967 | 3957 | ||
@@ -3975,70 +3965,70 @@ irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs) | |||
3975 | priv->stats.txbeaconerr++; | 3965 | priv->stats.txbeaconerr++; |
3976 | 3966 | ||
3977 | if (inta & IMR_TMGDOK) | 3967 | if (inta & IMR_TMGDOK) |
3978 | rtl8180_tx_isr(dev,MANAGE_PRIORITY,0); | 3968 | rtl8180_tx_isr(dev, MANAGE_PRIORITY, 0); |
3979 | 3969 | ||
3980 | if(inta & ISR_THPDER){ | 3970 | if (inta & ISR_THPDER) { |
3981 | priv->stats.txhperr++; | 3971 | priv->stats.txhperr++; |
3982 | rtl8180_tx_isr(dev,HI_PRIORITY,1); | 3972 | rtl8180_tx_isr(dev, HI_PRIORITY, 1); |
3983 | priv->ieee80211->stats.tx_errors++; | 3973 | priv->ieee80211->stats.tx_errors++; |
3984 | } | 3974 | } |
3985 | 3975 | ||
3986 | if(inta & ISR_THPDOK){ //High priority tx ok | 3976 | if (inta & ISR_THPDOK) { //High priority tx ok |
3987 | priv->link_detect.NumTxOkInPeriod++; //YJ,add,080828 | 3977 | priv->link_detect.NumTxOkInPeriod++; //YJ,add,080828 |
3988 | priv->stats.txhpokint++; | 3978 | priv->stats.txhpokint++; |
3989 | rtl8180_tx_isr(dev,HI_PRIORITY,0); | 3979 | rtl8180_tx_isr(dev, HI_PRIORITY, 0); |
3990 | } | 3980 | } |
3991 | 3981 | ||
3992 | if(inta & ISR_RER) { | 3982 | if (inta & ISR_RER) |
3993 | priv->stats.rxerr++; | 3983 | priv->stats.rxerr++; |
3994 | } | 3984 | |
3995 | if(inta & ISR_TBKDER){ //corresponding to BK_PRIORITY | 3985 | if (inta & ISR_TBKDER) { //corresponding to BK_PRIORITY |
3996 | priv->stats.txbkperr++; | 3986 | priv->stats.txbkperr++; |
3997 | priv->ieee80211->stats.tx_errors++; | 3987 | priv->ieee80211->stats.tx_errors++; |
3998 | rtl8180_tx_isr(dev,BK_PRIORITY,1); | 3988 | rtl8180_tx_isr(dev, BK_PRIORITY, 1); |
3999 | rtl8180_try_wake_queue(dev, BE_PRIORITY); | 3989 | rtl8180_try_wake_queue(dev, BE_PRIORITY); |
4000 | } | 3990 | } |
4001 | 3991 | ||
4002 | if(inta & ISR_TBEDER){ //corresponding to BE_PRIORITY | 3992 | if (inta & ISR_TBEDER) { //corresponding to BE_PRIORITY |
4003 | priv->stats.txbeperr++; | 3993 | priv->stats.txbeperr++; |
4004 | priv->ieee80211->stats.tx_errors++; | 3994 | priv->ieee80211->stats.tx_errors++; |
4005 | rtl8180_tx_isr(dev,BE_PRIORITY,1); | 3995 | rtl8180_tx_isr(dev, BE_PRIORITY, 1); |
4006 | rtl8180_try_wake_queue(dev, BE_PRIORITY); | 3996 | rtl8180_try_wake_queue(dev, BE_PRIORITY); |
4007 | } | 3997 | } |
4008 | if(inta & ISR_TNPDER){ //corresponding to VO_PRIORITY | 3998 | if (inta & ISR_TNPDER) { //corresponding to VO_PRIORITY |
4009 | priv->stats.txnperr++; | 3999 | priv->stats.txnperr++; |
4010 | priv->ieee80211->stats.tx_errors++; | 4000 | priv->ieee80211->stats.tx_errors++; |
4011 | rtl8180_tx_isr(dev,NORM_PRIORITY,1); | 4001 | rtl8180_tx_isr(dev, NORM_PRIORITY, 1); |
4012 | rtl8180_try_wake_queue(dev, NORM_PRIORITY); | 4002 | rtl8180_try_wake_queue(dev, NORM_PRIORITY); |
4013 | } | 4003 | } |
4014 | 4004 | ||
4015 | if(inta & ISR_TLPDER){ //corresponding to VI_PRIORITY | 4005 | if (inta & ISR_TLPDER) { //corresponding to VI_PRIORITY |
4016 | priv->stats.txlperr++; | 4006 | priv->stats.txlperr++; |
4017 | priv->ieee80211->stats.tx_errors++; | 4007 | priv->ieee80211->stats.tx_errors++; |
4018 | rtl8180_tx_isr(dev,LOW_PRIORITY,1); | 4008 | rtl8180_tx_isr(dev, LOW_PRIORITY, 1); |
4019 | rtl8180_try_wake_queue(dev, LOW_PRIORITY); | 4009 | rtl8180_try_wake_queue(dev, LOW_PRIORITY); |
4020 | } | 4010 | } |
4021 | 4011 | ||
4022 | if(inta & ISR_ROK){ | 4012 | if (inta & ISR_ROK) { |
4023 | priv->stats.rxint++; | 4013 | priv->stats.rxint++; |
4024 | tasklet_schedule(&priv->irq_rx_tasklet); | 4014 | tasklet_schedule(&priv->irq_rx_tasklet); |
4025 | } | 4015 | } |
4026 | 4016 | ||
4027 | if(inta & ISR_RQoSOK ){ | 4017 | if (inta & ISR_RQoSOK) { |
4028 | priv->stats.rxint++; | 4018 | priv->stats.rxint++; |
4029 | tasklet_schedule(&priv->irq_rx_tasklet); | 4019 | tasklet_schedule(&priv->irq_rx_tasklet); |
4030 | } | 4020 | } |
4031 | if(inta & ISR_BcnInt) { | 4021 | |
4022 | if (inta & ISR_BcnInt) | ||
4032 | rtl8180_prepare_beacon(dev); | 4023 | rtl8180_prepare_beacon(dev); |
4033 | } | ||
4034 | 4024 | ||
4035 | if(inta & ISR_RDU){ | 4025 | if (inta & ISR_RDU) { |
4036 | DMESGW("No RX descriptor available"); | 4026 | DMESGW("No RX descriptor available"); |
4037 | priv->stats.rxrdu++; | 4027 | priv->stats.rxrdu++; |
4038 | tasklet_schedule(&priv->irq_rx_tasklet); | 4028 | tasklet_schedule(&priv->irq_rx_tasklet); |
4039 | } | 4029 | } |
4040 | 4030 | ||
4041 | if(inta & ISR_RXFOVW){ | 4031 | if (inta & ISR_RXFOVW) { |
4042 | priv->stats.rxoverflow++; | 4032 | priv->stats.rxoverflow++; |
4043 | tasklet_schedule(&priv->irq_rx_tasklet); | 4033 | tasklet_schedule(&priv->irq_rx_tasklet); |
4044 | } | 4034 | } |
@@ -4046,39 +4036,39 @@ irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs) | |||
4046 | if (inta & ISR_TXFOVW) | 4036 | if (inta & ISR_TXFOVW) |
4047 | priv->stats.txoverflow++; | 4037 | priv->stats.txoverflow++; |
4048 | 4038 | ||
4049 | if(inta & ISR_TNPDOK){ //Normal priority tx ok | 4039 | if (inta & ISR_TNPDOK) { //Normal priority tx ok |
4050 | priv->link_detect.NumTxOkInPeriod++; //YJ,add,080828 | 4040 | priv->link_detect.NumTxOkInPeriod++; //YJ,add,080828 |
4051 | priv->stats.txnpokint++; | 4041 | priv->stats.txnpokint++; |
4052 | rtl8180_tx_isr(dev,NORM_PRIORITY,0); | 4042 | rtl8180_tx_isr(dev, NORM_PRIORITY, 0); |
4053 | } | 4043 | } |
4054 | 4044 | ||
4055 | if(inta & ISR_TLPDOK){ //Low priority tx ok | 4045 | if (inta & ISR_TLPDOK) { //Low priority tx ok |
4056 | priv->link_detect.NumTxOkInPeriod++; //YJ,add,080828 | 4046 | priv->link_detect.NumTxOkInPeriod++; //YJ,add,080828 |
4057 | priv->stats.txlpokint++; | 4047 | priv->stats.txlpokint++; |
4058 | rtl8180_tx_isr(dev,LOW_PRIORITY,0); | 4048 | rtl8180_tx_isr(dev, LOW_PRIORITY, 0); |
4059 | rtl8180_try_wake_queue(dev, LOW_PRIORITY); | 4049 | rtl8180_try_wake_queue(dev, LOW_PRIORITY); |
4060 | } | 4050 | } |
4061 | 4051 | ||
4062 | if(inta & ISR_TBKDOK){ //corresponding to BK_PRIORITY | 4052 | if (inta & ISR_TBKDOK) { //corresponding to BK_PRIORITY |
4063 | priv->stats.txbkpokint++; | 4053 | priv->stats.txbkpokint++; |
4064 | priv->link_detect.NumTxOkInPeriod++; //YJ,add,080828 | 4054 | priv->link_detect.NumTxOkInPeriod++; //YJ,add,080828 |
4065 | rtl8180_tx_isr(dev,BK_PRIORITY,0); | 4055 | rtl8180_tx_isr(dev, BK_PRIORITY, 0); |
4066 | rtl8180_try_wake_queue(dev, BE_PRIORITY); | 4056 | rtl8180_try_wake_queue(dev, BE_PRIORITY); |
4067 | } | 4057 | } |
4068 | 4058 | ||
4069 | if(inta & ISR_TBEDOK){ //corresponding to BE_PRIORITY | 4059 | if (inta & ISR_TBEDOK) { //corresponding to BE_PRIORITY |
4070 | priv->stats.txbeperr++; | 4060 | priv->stats.txbeperr++; |
4071 | priv->link_detect.NumTxOkInPeriod++; //YJ,add,080828 | 4061 | priv->link_detect.NumTxOkInPeriod++; //YJ,add,080828 |
4072 | rtl8180_tx_isr(dev,BE_PRIORITY,0); | 4062 | rtl8180_tx_isr(dev, BE_PRIORITY, 0); |
4073 | rtl8180_try_wake_queue(dev, BE_PRIORITY); | 4063 | rtl8180_try_wake_queue(dev, BE_PRIORITY); |
4074 | } | 4064 | } |
4075 | force_pci_posting(dev); | 4065 | force_pci_posting(dev); |
4076 | spin_unlock_irqrestore(&priv->irq_th_lock,flags); | 4066 | spin_unlock_irqrestore(&priv->irq_th_lock, flags); |
4077 | 4067 | ||
4078 | return IRQ_HANDLED; | 4068 | return IRQ_HANDLED; |
4079 | } | 4069 | } |
4080 | 4070 | ||
4081 | void rtl8180_irq_rx_tasklet(struct r8180_priv* priv) | 4071 | void rtl8180_irq_rx_tasklet(struct r8180_priv *priv) |
4082 | { | 4072 | { |
4083 | rtl8180_rx(priv->dev); | 4073 | rtl8180_rx(priv->dev); |
4084 | } | 4074 | } |
@@ -4095,10 +4085,10 @@ void GPIOChangeRFWorkItemCallBack(struct work_struct *work) | |||
4095 | 4085 | ||
4096 | char *argv[3]; | 4086 | char *argv[3]; |
4097 | static char *RadioPowerPath = "/etc/acpi/events/RadioPower.sh"; | 4087 | static char *RadioPowerPath = "/etc/acpi/events/RadioPower.sh"; |
4098 | static char *envp[] = {"HOME=/", "TERM=linux", "PATH=/usr/bin:/bin", NULL}; | 4088 | static char *envp[] = {"HOME=/", "TERM=linux", "PATH=/usr/bin:/bin", NULL}; |
4099 | static int readf_count = 0; | 4089 | static int readf_count = 0; |
4100 | 4090 | ||
4101 | if(readf_count % 10 == 0) | 4091 | if (readf_count % 10 == 0) |
4102 | priv->PowerProfile = read_acadapter_file("/proc/acpi/ac_adapter/AC0/state"); | 4092 | priv->PowerProfile = read_acadapter_file("/proc/acpi/ac_adapter/AC0/state"); |
4103 | 4093 | ||
4104 | readf_count = (readf_count+1)%0xffff; | 4094 | readf_count = (readf_count+1)%0xffff; |