aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennert Buytenhek <buytenh@wantstofly.org>2009-10-22 14:20:56 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-11-06 16:54:37 -0500
commit788838ebe8a4caca93a91982c7bbf393edf24c08 (patch)
tree5572f3e9d6a460d28556bb295e49f37b5c32dc3a
parenteae74e6545d995ab0baa8fb07309f714d9616293 (diff)
mwl8k: use pci_unmap_addr{,set}() to keep track of unmap addresses on rx
Instead of reading back the unmap address from the receive descriptor when doing receive processing, use DECLARE_PCI_UNMAP_ADDR and pci_unmap_addr{,set}() to keep track of these addresses. Signed-off-by: Lennert Buytenhek <buytenh@marvell.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/mwl8k.c55
1 files changed, 30 insertions, 25 deletions
diff --git a/drivers/net/wireless/mwl8k.c b/drivers/net/wireless/mwl8k.c
index 8bec4652fda1..49ae31b8b621 100644
--- a/drivers/net/wireless/mwl8k.c
+++ b/drivers/net/wireless/mwl8k.c
@@ -97,7 +97,10 @@ struct mwl8k_rx_queue {
97 97
98 struct mwl8k_rx_desc *rxd; 98 struct mwl8k_rx_desc *rxd;
99 dma_addr_t rxd_dma; 99 dma_addr_t rxd_dma;
100 struct sk_buff **skb; 100 struct {
101 struct sk_buff *skb;
102 DECLARE_PCI_UNMAP_ADDR(dma)
103 } *buf;
101}; 104};
102 105
103struct mwl8k_tx_queue { 106struct mwl8k_tx_queue {
@@ -791,14 +794,14 @@ static int mwl8k_rxq_init(struct ieee80211_hw *hw, int index)
791 } 794 }
792 memset(rxq->rxd, 0, size); 795 memset(rxq->rxd, 0, size);
793 796
794 rxq->skb = kmalloc(MWL8K_RX_DESCS * sizeof(*rxq->skb), GFP_KERNEL); 797 rxq->buf = kmalloc(MWL8K_RX_DESCS * sizeof(*rxq->buf), GFP_KERNEL);
795 if (rxq->skb == NULL) { 798 if (rxq->buf == NULL) {
796 printk(KERN_ERR "%s: failed to alloc RX skbuff list\n", 799 printk(KERN_ERR "%s: failed to alloc RX skbuff list\n",
797 wiphy_name(hw->wiphy)); 800 wiphy_name(hw->wiphy));
798 pci_free_consistent(priv->pdev, size, rxq->rxd, rxq->rxd_dma); 801 pci_free_consistent(priv->pdev, size, rxq->rxd, rxq->rxd_dma);
799 return -ENOMEM; 802 return -ENOMEM;
800 } 803 }
801 memset(rxq->skb, 0, MWL8K_RX_DESCS * sizeof(*rxq->skb)); 804 memset(rxq->buf, 0, MWL8K_RX_DESCS * sizeof(*rxq->buf));
802 805
803 for (i = 0; i < MWL8K_RX_DESCS; i++) { 806 for (i = 0; i < MWL8K_RX_DESCS; i++) {
804 struct mwl8k_rx_desc *rx_desc; 807 struct mwl8k_rx_desc *rx_desc;
@@ -824,6 +827,7 @@ static int rxq_refill(struct ieee80211_hw *hw, int index, int limit)
824 refilled = 0; 827 refilled = 0;
825 while (rxq->rxd_count < MWL8K_RX_DESCS && limit--) { 828 while (rxq->rxd_count < MWL8K_RX_DESCS && limit--) {
826 struct sk_buff *skb; 829 struct sk_buff *skb;
830 dma_addr_t addr;
827 int rx; 831 int rx;
828 832
829 skb = dev_alloc_skb(MWL8K_RX_MAXSZ); 833 skb = dev_alloc_skb(MWL8K_RX_MAXSZ);
@@ -835,12 +839,13 @@ static int rxq_refill(struct ieee80211_hw *hw, int index, int limit)
835 rx = rxq->tail; 839 rx = rxq->tail;
836 rxq->tail = (rx + 1) % MWL8K_RX_DESCS; 840 rxq->tail = (rx + 1) % MWL8K_RX_DESCS;
837 841
838 rxq->rxd[rx].pkt_phys_addr = 842 addr = pci_map_single(priv->pdev, skb->data,
839 cpu_to_le32(pci_map_single(priv->pdev, skb->data, 843 MWL8K_RX_MAXSZ, DMA_FROM_DEVICE);
840 MWL8K_RX_MAXSZ, DMA_FROM_DEVICE));
841 844
842 rxq->rxd[rx].pkt_len = cpu_to_le16(MWL8K_RX_MAXSZ); 845 rxq->rxd[rx].pkt_len = cpu_to_le16(MWL8K_RX_MAXSZ);
843 rxq->skb[rx] = skb; 846 rxq->rxd[rx].pkt_phys_addr = cpu_to_le32(addr);
847 rxq->buf[rx].skb = skb;
848 pci_unmap_addr_set(&rxq->buf[rx], dma, addr);
844 wmb(); 849 wmb();
845 rxq->rxd[rx].rx_ctrl = 0; 850 rxq->rxd[rx].rx_ctrl = 0;
846 851
@@ -858,19 +863,19 @@ static void mwl8k_rxq_deinit(struct ieee80211_hw *hw, int index)
858 int i; 863 int i;
859 864
860 for (i = 0; i < MWL8K_RX_DESCS; i++) { 865 for (i = 0; i < MWL8K_RX_DESCS; i++) {
861 if (rxq->skb[i] != NULL) { 866 if (rxq->buf[i].skb != NULL) {
862 unsigned long addr; 867 pci_unmap_single(priv->pdev,
863 868 pci_unmap_addr(&rxq->buf[i], dma),
864 addr = le32_to_cpu(rxq->rxd[i].pkt_phys_addr); 869 MWL8K_RX_MAXSZ, PCI_DMA_FROMDEVICE);
865 pci_unmap_single(priv->pdev, addr, MWL8K_RX_MAXSZ, 870 pci_unmap_addr_set(&rxq->buf[i], dma, 0);
866 PCI_DMA_FROMDEVICE); 871
867 kfree_skb(rxq->skb[i]); 872 kfree_skb(rxq->buf[i].skb);
868 rxq->skb[i] = NULL; 873 rxq->buf[i].skb = NULL;
869 } 874 }
870 } 875 }
871 876
872 kfree(rxq->skb); 877 kfree(rxq->buf);
873 rxq->skb = NULL; 878 rxq->buf = NULL;
874 879
875 pci_free_consistent(priv->pdev, 880 pci_free_consistent(priv->pdev,
876 MWL8K_RX_DESCS * sizeof(struct mwl8k_rx_desc), 881 MWL8K_RX_DESCS * sizeof(struct mwl8k_rx_desc),
@@ -920,7 +925,6 @@ static int rxq_process(struct ieee80211_hw *hw, int index, int limit)
920 struct mwl8k_rx_desc *rx_desc; 925 struct mwl8k_rx_desc *rx_desc;
921 struct sk_buff *skb; 926 struct sk_buff *skb;
922 struct ieee80211_rx_status status; 927 struct ieee80211_rx_status status;
923 unsigned long addr;
924 struct ieee80211_hdr *wh; 928 struct ieee80211_hdr *wh;
925 u16 rate_info; 929 u16 rate_info;
926 930
@@ -929,18 +933,19 @@ static int rxq_process(struct ieee80211_hw *hw, int index, int limit)
929 break; 933 break;
930 rmb(); 934 rmb();
931 935
932 skb = rxq->skb[rxq->head]; 936 skb = rxq->buf[rxq->head].skb;
933 if (skb == NULL) 937 if (skb == NULL)
934 break; 938 break;
935 rxq->skb[rxq->head] = NULL; 939 rxq->buf[rxq->head].skb = NULL;
940
941 pci_unmap_single(priv->pdev,
942 pci_unmap_addr(&rxq->buf[rxq->head], dma),
943 MWL8K_RX_MAXSZ, PCI_DMA_FROMDEVICE);
944 pci_unmap_addr_set(&rxq->buf[rxq->head], dma, 0);
936 945
937 rxq->head = (rxq->head + 1) % MWL8K_RX_DESCS; 946 rxq->head = (rxq->head + 1) % MWL8K_RX_DESCS;
938 rxq->rxd_count--; 947 rxq->rxd_count--;
939 948
940 addr = le32_to_cpu(rx_desc->pkt_phys_addr);
941 pci_unmap_single(priv->pdev, addr,
942 MWL8K_RX_MAXSZ, PCI_DMA_FROMDEVICE);
943
944 skb_put(skb, le16_to_cpu(rx_desc->pkt_len)); 949 skb_put(skb, le16_to_cpu(rx_desc->pkt_len));
945 mwl8k_remove_dma_header(skb); 950 mwl8k_remove_dma_header(skb);
946 951