aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMichael Buesch <mbuesch@freenet.de>2006-01-27 11:26:20 -0500
committerJohn W. Linville <linville@tuxdriver.com>2006-03-27 11:18:24 -0500
commitea72ab229fe9cdfe3d3f70a6e64d98c725294b24 (patch)
tree96bdbed22cac7b7256fe4b1e98f9b710edc68851 /drivers
parent70e5e983f8a3f801a96bfeb0682cd2955ec3c8ce (diff)
[PATCH] bcm43xx: sync with svn.berlios.de
Signed-off-by: Michael Buesch <mbuesch@freenet.de> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_dma.c198
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_dma.h11
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_main.c7
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_phy.c2
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_radio.c8
5 files changed, 102 insertions, 124 deletions
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_dma.c b/drivers/net/wireless/bcm43xx/bcm43xx_dma.c
index df19fbfa9ea1..af5c27f9bfda 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_dma.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_dma.c
@@ -214,7 +214,9 @@ static int alloc_ringmemory(struct bcm43xx_dmaring *ring)
214 return -ENOMEM; 214 return -ENOMEM;
215 } 215 }
216 if (ring->dmabase + BCM43xx_DMA_RINGMEMSIZE > BCM43xx_DMA_BUSADDRMAX) { 216 if (ring->dmabase + BCM43xx_DMA_RINGMEMSIZE > BCM43xx_DMA_BUSADDRMAX) {
217 printk(KERN_ERR PFX ">>>FATAL ERROR<<< DMA RINGMEMORY >1G\n"); 217 printk(KERN_ERR PFX ">>>FATAL ERROR<<< DMA RINGMEMORY >1G "
218 "(0x%08x, len: %lu)\n",
219 ring->dmabase, BCM43xx_DMA_RINGMEMSIZE);
218 dma_free_coherent(dev, BCM43xx_DMA_RINGMEMSIZE, 220 dma_free_coherent(dev, BCM43xx_DMA_RINGMEMSIZE,
219 ring->vbase, ring->dmabase); 221 ring->vbase, ring->dmabase);
220 return -ENOMEM; 222 return -ENOMEM;
@@ -261,13 +263,6 @@ int bcm43xx_dmacontroller_rx_reset(struct bcm43xx_private *bcm,
261 return 0; 263 return 0;
262} 264}
263 265
264static inline int dmacontroller_rx_reset(struct bcm43xx_dmaring *ring)
265{
266 assert(!ring->tx);
267
268 return bcm43xx_dmacontroller_rx_reset(ring->bcm, ring->mmio_base);
269}
270
271/* Reset the RX DMA channel */ 266/* Reset the RX DMA channel */
272int bcm43xx_dmacontroller_tx_reset(struct bcm43xx_private *bcm, 267int bcm43xx_dmacontroller_tx_reset(struct bcm43xx_private *bcm,
273 u16 mmio_base) 268 u16 mmio_base)
@@ -308,13 +303,6 @@ int bcm43xx_dmacontroller_tx_reset(struct bcm43xx_private *bcm,
308 return 0; 303 return 0;
309} 304}
310 305
311static inline int dmacontroller_tx_reset(struct bcm43xx_dmaring *ring)
312{
313 assert(ring->tx);
314
315 return bcm43xx_dmacontroller_tx_reset(ring->bcm, ring->mmio_base);
316}
317
318static int setup_rx_descbuffer(struct bcm43xx_dmaring *ring, 306static int setup_rx_descbuffer(struct bcm43xx_dmaring *ring,
319 struct bcm43xx_dmadesc *desc, 307 struct bcm43xx_dmadesc *desc,
320 struct bcm43xx_dmadesc_meta *meta, 308 struct bcm43xx_dmadesc_meta *meta,
@@ -337,7 +325,9 @@ static int setup_rx_descbuffer(struct bcm43xx_dmaring *ring,
337 if (unlikely(dmaaddr + ring->rx_buffersize > BCM43xx_DMA_BUSADDRMAX)) { 325 if (unlikely(dmaaddr + ring->rx_buffersize > BCM43xx_DMA_BUSADDRMAX)) {
338 unmap_descbuffer(ring, dmaaddr, ring->rx_buffersize, 0); 326 unmap_descbuffer(ring, dmaaddr, ring->rx_buffersize, 0);
339 dev_kfree_skb_any(skb); 327 dev_kfree_skb_any(skb);
340 printk(KERN_ERR PFX ">>>FATAL ERROR<<< DMA RX SKB >1G\n"); 328 printk(KERN_ERR PFX ">>>FATAL ERROR<<< DMA RX SKB >1G "
329 "(0x%08x, len: %u)\n",
330 dmaaddr, ring->rx_buffersize);
341 return -ENOMEM; 331 return -ENOMEM;
342 } 332 }
343 meta->skb = skb; 333 meta->skb = skb;
@@ -365,7 +355,7 @@ static int setup_rx_descbuffer(struct bcm43xx_dmaring *ring,
365static int alloc_initial_descbuffers(struct bcm43xx_dmaring *ring) 355static int alloc_initial_descbuffers(struct bcm43xx_dmaring *ring)
366{ 356{
367 int i, err = -ENOMEM; 357 int i, err = -ENOMEM;
368 struct bcm43xx_dmadesc *desc = NULL; 358 struct bcm43xx_dmadesc *desc;
369 struct bcm43xx_dmadesc_meta *meta; 359 struct bcm43xx_dmadesc_meta *meta;
370 360
371 for (i = 0; i < ring->nr_slots; i++) { 361 for (i = 0; i < ring->nr_slots; i++) {
@@ -375,24 +365,20 @@ static int alloc_initial_descbuffers(struct bcm43xx_dmaring *ring)
375 err = setup_rx_descbuffer(ring, desc, meta, GFP_KERNEL); 365 err = setup_rx_descbuffer(ring, desc, meta, GFP_KERNEL);
376 if (err) 366 if (err)
377 goto err_unwind; 367 goto err_unwind;
378
379 assert(ring->used_slots <= ring->nr_slots);
380 } 368 }
381 ring->used_slots = ring->nr_slots; 369 ring->used_slots = ring->nr_slots;
382
383 err = 0; 370 err = 0;
384out: 371out:
385 return err; 372 return err;
386 373
387err_unwind: 374err_unwind:
388 for ( ; i >= 0; i--) { 375 for (i--; i >= 0; i--) {
389 desc = ring->vbase + i; 376 desc = ring->vbase + i;
390 meta = ring->meta + i; 377 meta = ring->meta + i;
391 378
392 unmap_descbuffer(ring, meta->dmaaddr, ring->rx_buffersize, 0); 379 unmap_descbuffer(ring, meta->dmaaddr, ring->rx_buffersize, 0);
393 dev_kfree_skb(meta->skb); 380 dev_kfree_skb(meta->skb);
394 } 381 }
395 ring->used_slots = 0;
396 goto out; 382 goto out;
397} 383}
398 384
@@ -442,13 +428,13 @@ out:
442static void dmacontroller_cleanup(struct bcm43xx_dmaring *ring) 428static void dmacontroller_cleanup(struct bcm43xx_dmaring *ring)
443{ 429{
444 if (ring->tx) { 430 if (ring->tx) {
445 dmacontroller_tx_reset(ring); 431 bcm43xx_dmacontroller_tx_reset(ring->bcm, ring->mmio_base);
446 /* Zero out Transmit Descriptor ring address. */ 432 /* Zero out Transmit Descriptor ring address. */
447 bcm43xx_write32(ring->bcm, 433 bcm43xx_write32(ring->bcm,
448 ring->mmio_base + BCM43xx_DMA_TX_DESC_RING, 434 ring->mmio_base + BCM43xx_DMA_TX_DESC_RING,
449 0x00000000); 435 0x00000000);
450 } else { 436 } else {
451 dmacontroller_rx_reset(ring); 437 bcm43xx_dmacontroller_rx_reset(ring->bcm, ring->mmio_base);
452 /* Zero out Receive Descriptor ring address. */ 438 /* Zero out Receive Descriptor ring address. */
453 bcm43xx_write32(ring->bcm, 439 bcm43xx_write32(ring->bcm,
454 ring->mmio_base + BCM43xx_DMA_RX_DESC_RING, 440 ring->mmio_base + BCM43xx_DMA_RX_DESC_RING,
@@ -508,9 +494,7 @@ struct bcm43xx_dmaring * bcm43xx_setup_dmaring(struct bcm43xx_private *bcm,
508 if (bcm->pci_dev->bus->number == 0) 494 if (bcm->pci_dev->bus->number == 0)
509 ring->memoffset = 0; 495 ring->memoffset = 0;
510#endif 496#endif
511 497
512
513 spin_lock_init(&ring->lock);
514 ring->bcm = bcm; 498 ring->bcm = bcm;
515 ring->nr_slots = nr_descriptor_slots; 499 ring->nr_slots = nr_descriptor_slots;
516 ring->suspend_mark = ring->nr_slots * BCM43xx_TXSUSPEND_PERCENT / 100; 500 ring->suspend_mark = ring->nr_slots * BCM43xx_TXSUSPEND_PERCENT / 100;
@@ -578,22 +562,25 @@ static void bcm43xx_destroy_dmaring(struct bcm43xx_dmaring *ring)
578 562
579void bcm43xx_dma_free(struct bcm43xx_private *bcm) 563void bcm43xx_dma_free(struct bcm43xx_private *bcm)
580{ 564{
581 bcm43xx_destroy_dmaring(bcm->current_core->dma->rx_ring1); 565 struct bcm43xx_dma *dma = bcm->current_core->dma;
582 bcm->current_core->dma->rx_ring1 = NULL; 566
583 bcm43xx_destroy_dmaring(bcm->current_core->dma->rx_ring0); 567 bcm43xx_destroy_dmaring(dma->rx_ring1);
584 bcm->current_core->dma->rx_ring0 = NULL; 568 dma->rx_ring1 = NULL;
585 bcm43xx_destroy_dmaring(bcm->current_core->dma->tx_ring3); 569 bcm43xx_destroy_dmaring(dma->rx_ring0);
586 bcm->current_core->dma->tx_ring3 = NULL; 570 dma->rx_ring0 = NULL;
587 bcm43xx_destroy_dmaring(bcm->current_core->dma->tx_ring2); 571 bcm43xx_destroy_dmaring(dma->tx_ring3);
588 bcm->current_core->dma->tx_ring2 = NULL; 572 dma->tx_ring3 = NULL;
589 bcm43xx_destroy_dmaring(bcm->current_core->dma->tx_ring1); 573 bcm43xx_destroy_dmaring(dma->tx_ring2);
590 bcm->current_core->dma->tx_ring1 = NULL; 574 dma->tx_ring2 = NULL;
591 bcm43xx_destroy_dmaring(bcm->current_core->dma->tx_ring0); 575 bcm43xx_destroy_dmaring(dma->tx_ring1);
592 bcm->current_core->dma->tx_ring0 = NULL; 576 dma->tx_ring1 = NULL;
577 bcm43xx_destroy_dmaring(dma->tx_ring0);
578 dma->tx_ring0 = NULL;
593} 579}
594 580
595int bcm43xx_dma_init(struct bcm43xx_private *bcm) 581int bcm43xx_dma_init(struct bcm43xx_private *bcm)
596{ 582{
583 struct bcm43xx_dma *dma = bcm->current_core->dma;
597 struct bcm43xx_dmaring *ring; 584 struct bcm43xx_dmaring *ring;
598 int err = -ENOMEM; 585 int err = -ENOMEM;
599 586
@@ -602,39 +589,39 @@ int bcm43xx_dma_init(struct bcm43xx_private *bcm)
602 BCM43xx_TXRING_SLOTS, 1); 589 BCM43xx_TXRING_SLOTS, 1);
603 if (!ring) 590 if (!ring)
604 goto out; 591 goto out;
605 bcm->current_core->dma->tx_ring0 = ring; 592 dma->tx_ring0 = ring;
606 593
607 ring = bcm43xx_setup_dmaring(bcm, BCM43xx_MMIO_DMA2_BASE, 594 ring = bcm43xx_setup_dmaring(bcm, BCM43xx_MMIO_DMA2_BASE,
608 BCM43xx_TXRING_SLOTS, 1); 595 BCM43xx_TXRING_SLOTS, 1);
609 if (!ring) 596 if (!ring)
610 goto err_destroy_tx0; 597 goto err_destroy_tx0;
611 bcm->current_core->dma->tx_ring1 = ring; 598 dma->tx_ring1 = ring;
612 599
613 ring = bcm43xx_setup_dmaring(bcm, BCM43xx_MMIO_DMA3_BASE, 600 ring = bcm43xx_setup_dmaring(bcm, BCM43xx_MMIO_DMA3_BASE,
614 BCM43xx_TXRING_SLOTS, 1); 601 BCM43xx_TXRING_SLOTS, 1);
615 if (!ring) 602 if (!ring)
616 goto err_destroy_tx1; 603 goto err_destroy_tx1;
617 bcm->current_core->dma->tx_ring2 = ring; 604 dma->tx_ring2 = ring;
618 605
619 ring = bcm43xx_setup_dmaring(bcm, BCM43xx_MMIO_DMA4_BASE, 606 ring = bcm43xx_setup_dmaring(bcm, BCM43xx_MMIO_DMA4_BASE,
620 BCM43xx_TXRING_SLOTS, 1); 607 BCM43xx_TXRING_SLOTS, 1);
621 if (!ring) 608 if (!ring)
622 goto err_destroy_tx2; 609 goto err_destroy_tx2;
623 bcm->current_core->dma->tx_ring3 = ring; 610 dma->tx_ring3 = ring;
624 611
625 /* setup RX DMA channels. */ 612 /* setup RX DMA channels. */
626 ring = bcm43xx_setup_dmaring(bcm, BCM43xx_MMIO_DMA1_BASE, 613 ring = bcm43xx_setup_dmaring(bcm, BCM43xx_MMIO_DMA1_BASE,
627 BCM43xx_RXRING_SLOTS, 0); 614 BCM43xx_RXRING_SLOTS, 0);
628 if (!ring) 615 if (!ring)
629 goto err_destroy_tx3; 616 goto err_destroy_tx3;
630 bcm->current_core->dma->rx_ring0 = ring; 617 dma->rx_ring0 = ring;
631 618
632 if (bcm->current_core->rev < 5) { 619 if (bcm->current_core->rev < 5) {
633 ring = bcm43xx_setup_dmaring(bcm, BCM43xx_MMIO_DMA4_BASE, 620 ring = bcm43xx_setup_dmaring(bcm, BCM43xx_MMIO_DMA4_BASE,
634 BCM43xx_RXRING_SLOTS, 0); 621 BCM43xx_RXRING_SLOTS, 0);
635 if (!ring) 622 if (!ring)
636 goto err_destroy_rx0; 623 goto err_destroy_rx0;
637 bcm->current_core->dma->rx_ring1 = ring; 624 dma->rx_ring1 = ring;
638 } 625 }
639 626
640 dprintk(KERN_INFO PFX "DMA initialized\n"); 627 dprintk(KERN_INFO PFX "DMA initialized\n");
@@ -643,27 +630,26 @@ out:
643 return err; 630 return err;
644 631
645err_destroy_rx0: 632err_destroy_rx0:
646 bcm43xx_destroy_dmaring(bcm->current_core->dma->rx_ring0); 633 bcm43xx_destroy_dmaring(dma->rx_ring0);
647 bcm->current_core->dma->rx_ring0 = NULL; 634 dma->rx_ring0 = NULL;
648err_destroy_tx3: 635err_destroy_tx3:
649 bcm43xx_destroy_dmaring(bcm->current_core->dma->tx_ring3); 636 bcm43xx_destroy_dmaring(dma->tx_ring3);
650 bcm->current_core->dma->tx_ring3 = NULL; 637 dma->tx_ring3 = NULL;
651err_destroy_tx2: 638err_destroy_tx2:
652 bcm43xx_destroy_dmaring(bcm->current_core->dma->tx_ring2); 639 bcm43xx_destroy_dmaring(dma->tx_ring2);
653 bcm->current_core->dma->tx_ring2 = NULL; 640 dma->tx_ring2 = NULL;
654err_destroy_tx1: 641err_destroy_tx1:
655 bcm43xx_destroy_dmaring(bcm->current_core->dma->tx_ring1); 642 bcm43xx_destroy_dmaring(dma->tx_ring1);
656 bcm->current_core->dma->tx_ring1 = NULL; 643 dma->tx_ring1 = NULL;
657err_destroy_tx0: 644err_destroy_tx0:
658 bcm43xx_destroy_dmaring(bcm->current_core->dma->tx_ring0); 645 bcm43xx_destroy_dmaring(dma->tx_ring0);
659 bcm->current_core->dma->tx_ring0 = NULL; 646 dma->tx_ring0 = NULL;
660 goto out; 647 goto out;
661} 648}
662 649
663/* Generate a cookie for the TX header. */ 650/* Generate a cookie for the TX header. */
664static inline 651static u16 generate_cookie(struct bcm43xx_dmaring *ring,
665u16 generate_cookie(struct bcm43xx_dmaring *ring, 652 int slot)
666 int slot)
667{ 653{
668 u16 cookie = 0x0000; 654 u16 cookie = 0x0000;
669 655
@@ -693,24 +679,25 @@ u16 generate_cookie(struct bcm43xx_dmaring *ring,
693} 679}
694 680
695/* Inspect a cookie and find out to which controller/slot it belongs. */ 681/* Inspect a cookie and find out to which controller/slot it belongs. */
696static inline 682static
697struct bcm43xx_dmaring * parse_cookie(struct bcm43xx_private *bcm, 683struct bcm43xx_dmaring * parse_cookie(struct bcm43xx_private *bcm,
698 u16 cookie, int *slot) 684 u16 cookie, int *slot)
699{ 685{
686 struct bcm43xx_dma *dma = bcm->current_core->dma;
700 struct bcm43xx_dmaring *ring = NULL; 687 struct bcm43xx_dmaring *ring = NULL;
701 688
702 switch (cookie & 0xF000) { 689 switch (cookie & 0xF000) {
703 case 0x0000: 690 case 0x0000:
704 ring = bcm->current_core->dma->tx_ring0; 691 ring = dma->tx_ring0;
705 break; 692 break;
706 case 0x1000: 693 case 0x1000:
707 ring = bcm->current_core->dma->tx_ring1; 694 ring = dma->tx_ring1;
708 break; 695 break;
709 case 0x2000: 696 case 0x2000:
710 ring = bcm->current_core->dma->tx_ring2; 697 ring = dma->tx_ring2;
711 break; 698 break;
712 case 0x3000: 699 case 0x3000:
713 ring = bcm->current_core->dma->tx_ring3; 700 ring = dma->tx_ring3;
714 break; 701 break;
715 default: 702 default:
716 assert(0); 703 assert(0);
@@ -721,8 +708,8 @@ struct bcm43xx_dmaring * parse_cookie(struct bcm43xx_private *bcm,
721 return ring; 708 return ring;
722} 709}
723 710
724static inline void dmacontroller_poke_tx(struct bcm43xx_dmaring *ring, 711static void dmacontroller_poke_tx(struct bcm43xx_dmaring *ring,
725 int slot) 712 int slot)
726{ 713{
727 /* Everything is ready to start. Buffers are DMA mapped and 714 /* Everything is ready to start. Buffers are DMA mapped and
728 * associated with slots. 715 * associated with slots.
@@ -736,11 +723,10 @@ static inline void dmacontroller_poke_tx(struct bcm43xx_dmaring *ring,
736 (u32)(slot * sizeof(struct bcm43xx_dmadesc))); 723 (u32)(slot * sizeof(struct bcm43xx_dmadesc)));
737} 724}
738 725
739static inline 726static int dma_tx_fragment(struct bcm43xx_dmaring *ring,
740int dma_tx_fragment(struct bcm43xx_dmaring *ring, 727 struct sk_buff *skb,
741 struct sk_buff *skb, 728 struct ieee80211_txb *txb,
742 struct ieee80211_txb *txb, 729 u8 cur_frag)
743 u8 cur_frag)
744{ 730{
745 int slot; 731 int slot;
746 struct bcm43xx_dmadesc *desc; 732 struct bcm43xx_dmadesc *desc;
@@ -777,7 +763,9 @@ int dma_tx_fragment(struct bcm43xx_dmaring *ring,
777 meta->dmaaddr = map_descbuffer(ring, skb->data, skb->len, 1); 763 meta->dmaaddr = map_descbuffer(ring, skb->data, skb->len, 1);
778 if (unlikely(meta->dmaaddr + skb->len > BCM43xx_DMA_BUSADDRMAX)) { 764 if (unlikely(meta->dmaaddr + skb->len > BCM43xx_DMA_BUSADDRMAX)) {
779 return_slot(ring, slot); 765 return_slot(ring, slot);
780 printk(KERN_ERR PFX ">>>FATAL ERROR<<< DMA TX SKB >1G\n"); 766 printk(KERN_ERR PFX ">>>FATAL ERROR<<< DMA TX SKB >1G "
767 "(0x%08x, len: %u)\n",
768 meta->dmaaddr, skb->len);
781 return -ENOMEM; 769 return -ENOMEM;
782 } 770 }
783 771
@@ -797,14 +785,15 @@ int dma_tx_fragment(struct bcm43xx_dmaring *ring,
797 return 0; 785 return 0;
798} 786}
799 787
800static inline int dma_transfer_txb(struct bcm43xx_dmaring *ring, 788int bcm43xx_dma_tx(struct bcm43xx_private *bcm,
801 struct ieee80211_txb *txb) 789 struct ieee80211_txb *txb)
802{ 790{
803 /* We just received a packet from the kernel network subsystem. 791 /* We just received a packet from the kernel network subsystem.
804 * Add headers and DMA map the memory. Poke 792 * Add headers and DMA map the memory. Poke
805 * the device to send the stuff. 793 * the device to send the stuff.
806 * Note that this is called from atomic context. 794 * Note that this is called from atomic context.
807 */ 795 */
796 struct bcm43xx_dmaring *ring = bcm->current_core->dma->tx_ring1;
808 u8 i; 797 u8 i;
809 struct sk_buff *skb; 798 struct sk_buff *skb;
810 799
@@ -818,8 +807,6 @@ static inline int dma_transfer_txb(struct bcm43xx_dmaring *ring,
818 return -ENOMEM; 807 return -ENOMEM;
819 } 808 }
820 809
821 assert(irqs_disabled());
822 spin_lock(&ring->lock);
823 for (i = 0; i < txb->nr_frags; i++) { 810 for (i = 0; i < txb->nr_frags; i++) {
824 skb = txb->fragments[i]; 811 skb = txb->fragments[i];
825 /* We do not free the skb, as it is freed as 812 /* We do not free the skb, as it is freed as
@@ -829,22 +816,12 @@ static inline int dma_transfer_txb(struct bcm43xx_dmaring *ring,
829 dma_tx_fragment(ring, skb, txb, i); 816 dma_tx_fragment(ring, skb, txb, i);
830 //TODO: handle failure of dma_tx_fragment 817 //TODO: handle failure of dma_tx_fragment
831 } 818 }
832 spin_unlock(&ring->lock);
833 819
834 return 0; 820 return 0;
835} 821}
836 822
837int fastcall 823void bcm43xx_dma_handle_xmitstatus(struct bcm43xx_private *bcm,
838bcm43xx_dma_transfer_txb(struct bcm43xx_private *bcm, 824 struct bcm43xx_xmitstatus *status)
839 struct ieee80211_txb *txb)
840{
841 return dma_transfer_txb(bcm->current_core->dma->tx_ring1,
842 txb);
843}
844
845void fastcall
846bcm43xx_dma_handle_xmitstatus(struct bcm43xx_private *bcm,
847 struct bcm43xx_xmitstatus *status)
848{ 825{
849 struct bcm43xx_dmaring *ring; 826 struct bcm43xx_dmaring *ring;
850 struct bcm43xx_dmadesc *desc; 827 struct bcm43xx_dmadesc *desc;
@@ -855,9 +832,6 @@ bcm43xx_dma_handle_xmitstatus(struct bcm43xx_private *bcm,
855 ring = parse_cookie(bcm, status->cookie, &slot); 832 ring = parse_cookie(bcm, status->cookie, &slot);
856 assert(ring); 833 assert(ring);
857 assert(ring->tx); 834 assert(ring->tx);
858 assert(irqs_disabled());
859 spin_lock(&ring->lock);
860
861 assert(get_desc_ctl(ring->vbase + slot) & BCM43xx_DMADTOR_FRAMESTART); 835 assert(get_desc_ctl(ring->vbase + slot) & BCM43xx_DMADTOR_FRAMESTART);
862 while (1) { 836 while (1) {
863 assert(slot >= 0 && slot < ring->nr_slots); 837 assert(slot >= 0 && slot < ring->nr_slots);
@@ -877,13 +851,10 @@ bcm43xx_dma_handle_xmitstatus(struct bcm43xx_private *bcm,
877 slot = next_slot(ring, slot); 851 slot = next_slot(ring, slot);
878 } 852 }
879 bcm->stats.last_tx = jiffies; 853 bcm->stats.last_tx = jiffies;
880
881 spin_unlock(&ring->lock);
882} 854}
883 855
884static inline 856static void dma_rx(struct bcm43xx_dmaring *ring,
885void dma_rx(struct bcm43xx_dmaring *ring, 857 int *slot)
886 int *slot)
887{ 858{
888 struct bcm43xx_dmadesc *desc; 859 struct bcm43xx_dmadesc *desc;
889 struct bcm43xx_dmadesc_meta *meta; 860 struct bcm43xx_dmadesc_meta *meta;
@@ -928,8 +899,12 @@ void dma_rx(struct bcm43xx_dmaring *ring,
928 barrier(); 899 barrier();
929 len = le16_to_cpu(rxhdr->frame_length); 900 len = le16_to_cpu(rxhdr->frame_length);
930 } while (len == 0 && i++ < 5); 901 } while (len == 0 && i++ < 5);
931 if (len == 0) 902 if (unlikely(len == 0)) {
903 /* recycle the descriptor buffer. */
904 sync_descbuffer_for_device(ring, meta->dmaaddr,
905 ring->rx_buffersize);
932 goto drop; 906 goto drop;
907 }
933 } 908 }
934 if (unlikely(len > ring->rx_buffersize)) { 909 if (unlikely(len > ring->rx_buffersize)) {
935 /* The data did not fit into one descriptor buffer 910 /* The data did not fit into one descriptor buffer
@@ -937,15 +912,24 @@ void dma_rx(struct bcm43xx_dmaring *ring,
937 * This should never happen, as we try to allocate buffers 912 * This should never happen, as we try to allocate buffers
938 * big enough. So simply ignore this packet. 913 * big enough. So simply ignore this packet.
939 */ 914 */
940 int cnt = 1; 915 int cnt = 0;
941 s32 tmp = len - ring->rx_buffersize; 916 s32 tmp = len;
942 917
943 for ( ; tmp > 0; tmp -= ring->rx_buffersize) { 918 while (1) {
919 desc = ring->vbase + *slot;
920 meta = ring->meta + *slot;
921 /* recycle the descriptor buffer. */
922 sync_descbuffer_for_device(ring, meta->dmaaddr,
923 ring->rx_buffersize);
944 *slot = next_slot(ring, *slot); 924 *slot = next_slot(ring, *slot);
945 cnt++; 925 cnt++;
926 tmp -= ring->rx_buffersize;
927 if (tmp <= 0)
928 break;
946 } 929 }
947 printkl(KERN_ERR PFX "DMA RX buffer too small. %d dropped.\n", 930 printkl(KERN_ERR PFX "DMA RX buffer too small "
948 cnt); 931 "(len: %u, buffer: %u, nr-dropped: %d)\n",
932 len, ring->rx_buffersize, cnt);
949 goto drop; 933 goto drop;
950 } 934 }
951 len -= IEEE80211_FCS_LEN; 935 len -= IEEE80211_FCS_LEN;
@@ -954,6 +938,8 @@ void dma_rx(struct bcm43xx_dmaring *ring,
954 err = setup_rx_descbuffer(ring, desc, meta, GFP_ATOMIC); 938 err = setup_rx_descbuffer(ring, desc, meta, GFP_ATOMIC);
955 if (unlikely(err)) { 939 if (unlikely(err)) {
956 dprintkl(KERN_ERR PFX "DMA RX: setup_rx_descbuffer() failed\n"); 940 dprintkl(KERN_ERR PFX "DMA RX: setup_rx_descbuffer() failed\n");
941 sync_descbuffer_for_device(ring, dmaaddr,
942 ring->rx_buffersize);
957 goto drop; 943 goto drop;
958 } 944 }
959 945
@@ -971,8 +957,7 @@ drop:
971 return; 957 return;
972} 958}
973 959
974void fastcall 960void bcm43xx_dma_rx(struct bcm43xx_dmaring *ring)
975bcm43xx_dma_rx(struct bcm43xx_dmaring *ring)
976{ 961{
977 u32 status; 962 u32 status;
978 u16 descptr; 963 u16 descptr;
@@ -982,9 +967,6 @@ bcm43xx_dma_rx(struct bcm43xx_dmaring *ring)
982#endif 967#endif
983 968
984 assert(!ring->tx); 969 assert(!ring->tx);
985 assert(irqs_disabled());
986 spin_lock(&ring->lock);
987
988 status = bcm43xx_read32(ring->bcm, ring->mmio_base + BCM43xx_DMA_RX_STATUS); 970 status = bcm43xx_read32(ring->bcm, ring->mmio_base + BCM43xx_DMA_RX_STATUS);
989 descptr = (status & BCM43xx_DMA_RXSTAT_DPTR_MASK); 971 descptr = (status & BCM43xx_DMA_RXSTAT_DPTR_MASK);
990 current_slot = descptr / sizeof(struct bcm43xx_dmadesc); 972 current_slot = descptr / sizeof(struct bcm43xx_dmadesc);
@@ -1002,8 +984,6 @@ bcm43xx_dma_rx(struct bcm43xx_dmaring *ring)
1002 ring->mmio_base + BCM43xx_DMA_RX_DESC_INDEX, 984 ring->mmio_base + BCM43xx_DMA_RX_DESC_INDEX,
1003 (u32)(slot * sizeof(struct bcm43xx_dmadesc))); 985 (u32)(slot * sizeof(struct bcm43xx_dmadesc)));
1004 ring->current_slot = slot; 986 ring->current_slot = slot;
1005
1006 spin_unlock(&ring->lock);
1007} 987}
1008 988
1009/* vim: set ts=8 sw=8 sts=8: */ 989/* vim: set ts=8 sw=8 sts=8: */
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_dma.h b/drivers/net/wireless/bcm43xx/bcm43xx_dma.h
index e32cf68f8e1d..93e99d61f2e1 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_dma.h
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_dma.h
@@ -122,7 +122,6 @@ struct bcm43xx_dmadesc_meta {
122}; 122};
123 123
124struct bcm43xx_dmaring { 124struct bcm43xx_dmaring {
125 spinlock_t lock;
126 struct bcm43xx_private *bcm; 125 struct bcm43xx_private *bcm;
127 /* Kernel virtual base address of the ring memory. */ 126 /* Kernel virtual base address of the ring memory. */
128 struct bcm43xx_dmadesc *vbase; 127 struct bcm43xx_dmadesc *vbase;
@@ -166,11 +165,11 @@ int bcm43xx_dmacontroller_rx_reset(struct bcm43xx_private *bcm,
166int bcm43xx_dmacontroller_tx_reset(struct bcm43xx_private *bcm, 165int bcm43xx_dmacontroller_tx_reset(struct bcm43xx_private *bcm,
167 u16 dmacontroller_mmio_base); 166 u16 dmacontroller_mmio_base);
168 167
169int FASTCALL(bcm43xx_dma_transfer_txb(struct bcm43xx_private *bcm, 168void bcm43xx_dma_handle_xmitstatus(struct bcm43xx_private *bcm,
170 struct ieee80211_txb *txb)); 169 struct bcm43xx_xmitstatus *status);
171void FASTCALL(bcm43xx_dma_handle_xmitstatus(struct bcm43xx_private *bcm,
172 struct bcm43xx_xmitstatus *status));
173 170
174void FASTCALL(bcm43xx_dma_rx(struct bcm43xx_dmaring *ring)); 171int bcm43xx_dma_tx(struct bcm43xx_private *bcm,
172 struct ieee80211_txb *txb);
173void bcm43xx_dma_rx(struct bcm43xx_dmaring *ring);
175 174
176#endif /* BCM43xx_DMA_H_ */ 175#endif /* BCM43xx_DMA_H_ */
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_main.c b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
index be60a6509f20..4b4e60a22c0b 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_main.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
@@ -4097,7 +4097,6 @@ int fastcall bcm43xx_rx(struct bcm43xx_private *bcm,
4097 } 4097 }
4098 4098
4099 frame_ctl = le16_to_cpu(wlhdr->frame_ctl); 4099 frame_ctl = le16_to_cpu(wlhdr->frame_ctl);
4100
4101 if ((frame_ctl & IEEE80211_FCTL_PROTECTED) && !bcm->ieee->host_decrypt) { 4100 if ((frame_ctl & IEEE80211_FCTL_PROTECTED) && !bcm->ieee->host_decrypt) {
4102 frame_ctl &= ~IEEE80211_FCTL_PROTECTED; 4101 frame_ctl &= ~IEEE80211_FCTL_PROTECTED;
4103 wlhdr->frame_ctl = cpu_to_le16(frame_ctl); 4102 wlhdr->frame_ctl = cpu_to_le16(frame_ctl);
@@ -4113,12 +4112,12 @@ int fastcall bcm43xx_rx(struct bcm43xx_private *bcm,
4113 skb_trim(skb, skb->len - 4); 4112 skb_trim(skb, skb->len - 4);
4114 stats.len -= 8; 4113 stats.len -= 8;
4115 } 4114 }
4116 /* do _not_ use wlhdr again without reassigning it */ 4115 wlhdr = (struct ieee80211_hdr_4addr *)(skb->data);
4117 } 4116 }
4118 4117
4119 switch (WLAN_FC_GET_TYPE(frame_ctl)) { 4118 switch (WLAN_FC_GET_TYPE(frame_ctl)) {
4120 case IEEE80211_FTYPE_MGMT: 4119 case IEEE80211_FTYPE_MGMT:
4121 ieee80211_rx_mgt(bcm->ieee, skb->data, &stats); 4120 ieee80211_rx_mgt(bcm->ieee, wlhdr, &stats);
4122 break; 4121 break;
4123 case IEEE80211_FTYPE_DATA: 4122 case IEEE80211_FTYPE_DATA:
4124 if (is_packet_for_us) 4123 if (is_packet_for_us)
@@ -4143,7 +4142,7 @@ static inline int bcm43xx_tx(struct bcm43xx_private *bcm,
4143 if (bcm->pio_mode) 4142 if (bcm->pio_mode)
4144 err = bcm43xx_pio_transfer_txb(bcm, txb); 4143 err = bcm43xx_pio_transfer_txb(bcm, txb);
4145 else 4144 else
4146 err = bcm43xx_dma_transfer_txb(bcm, txb); 4145 err = bcm43xx_dma_tx(bcm, txb);
4147 4146
4148 return err; 4147 return err;
4149} 4148}
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_phy.c b/drivers/net/wireless/bcm43xx/bcm43xx_phy.c
index 41b9cd7fc9e2..f5e7a6ab93cb 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_phy.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_phy.c
@@ -1161,7 +1161,7 @@ void bcm43xx_phy_lo_b_measure(struct bcm43xx_private *bcm)
1161 phy->minlowsigpos[1] += 0x0101; 1161 phy->minlowsigpos[1] += 0x0101;
1162 1162
1163 bcm43xx_phy_write(bcm, 0x002F, phy->minlowsigpos[1]); 1163 bcm43xx_phy_write(bcm, 0x002F, phy->minlowsigpos[1]);
1164 if (radio->version == 2053) { 1164 if (radio->version == 0x2053) {
1165 bcm43xx_phy_write(bcm, 0x000A, regstack[2]); 1165 bcm43xx_phy_write(bcm, 0x000A, regstack[2]);
1166 bcm43xx_phy_write(bcm, 0x002A, regstack[3]); 1166 bcm43xx_phy_write(bcm, 0x002A, regstack[3]);
1167 bcm43xx_phy_write(bcm, 0x0035, regstack[4]); 1167 bcm43xx_phy_write(bcm, 0x0035, regstack[4]);
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_radio.c b/drivers/net/wireless/bcm43xx/bcm43xx_radio.c
index 1e65658552b0..5ce6acef2c4a 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_radio.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_radio.c
@@ -467,8 +467,8 @@ static void bcm43xx_calc_nrssi_offset(struct bcm43xx_private *bcm)
467 bcm43xx_phy_write(bcm, 0x0003, 467 bcm43xx_phy_write(bcm, 0x0003,
468 (bcm43xx_phy_read(bcm, 0x0003) & 0xFF9F) 468 (bcm43xx_phy_read(bcm, 0x0003) & 0xFF9F)
469 | 0x0040); 469 | 0x0040);
470 bcm43xx_phy_write(bcm, 0x007A, 470 bcm43xx_radio_write16(bcm, 0x007A,
471 bcm43xx_phy_read(bcm, 0x007A) | 0x000F); 471 bcm43xx_radio_read16(bcm, 0x007A) | 0x000F);
472 bcm43xx_set_all_gains(bcm, 3, 0, 1); 472 bcm43xx_set_all_gains(bcm, 3, 0, 1);
473 bcm43xx_radio_write16(bcm, 0x0043, 473 bcm43xx_radio_write16(bcm, 0x0043,
474 (bcm43xx_radio_read16(bcm, 0x0043) 474 (bcm43xx_radio_read16(bcm, 0x0043)
@@ -761,8 +761,8 @@ void bcm43xx_calc_nrssi_slope(struct bcm43xx_private *bcm)
761 bcm43xx_phy_write(bcm, 0x0802, 761 bcm43xx_phy_write(bcm, 0x0802,
762 bcm43xx_phy_read(bcm, 0x0802) | (0x0001 | 0x0002)); 762 bcm43xx_phy_read(bcm, 0x0802) | (0x0001 | 0x0002));
763 bcm43xx_set_original_gains(bcm); 763 bcm43xx_set_original_gains(bcm);
764 bcm43xx_phy_write(bcm, 0x0802, 764 bcm43xx_phy_write(bcm, BCM43xx_PHY_G_CRS,
765 bcm43xx_phy_read(bcm, 0x0802) | 0x8000); 765 bcm43xx_phy_read(bcm, BCM43xx_PHY_G_CRS) | 0x8000);
766 if (phy->rev >= 3) { 766 if (phy->rev >= 3) {
767 bcm43xx_phy_write(bcm, 0x0801, backup[14]); 767 bcm43xx_phy_write(bcm, 0x0801, backup[14]);
768 bcm43xx_phy_write(bcm, 0x0060, backup[15]); 768 bcm43xx_phy_write(bcm, 0x0060, backup[15]);