diff options
author | Arend van Spriel <arend@broadcom.com> | 2011-12-08 18:06:52 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-12-13 15:32:46 -0500 |
commit | 2e81b9b19f20286425fed3b54df9b81189444cee (patch) | |
tree | ec2b6a8ff0af61a0dca9af8d826182e877d198f3 /drivers/net/wireless | |
parent | 16d2812e9eaaa47ca952ea81e34b4f400c861dfc (diff) |
brcm80211: smac: use DMA-API calls for descriptor allocations
Using BCMA hides the specifics about the host interface. The
driver is now using the DMA-API to do dma related calls. BCMA
provides the device object to use in the DMA-API calls.
Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
Reviewed-by: Alwin Beukers <alwin@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Franky Lin <frankyl@broadcom.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/brcm80211/brcmsmac/dma.c | 47 | ||||
-rw-r--r-- | drivers/net/wireless/brcm80211/brcmsmac/dma.h | 10 | ||||
-rw-r--r-- | drivers/net/wireless/brcm80211/brcmsmac/main.c | 8 |
3 files changed, 35 insertions, 30 deletions
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/dma.c b/drivers/net/wireless/brcm80211/brcmsmac/dma.c index 3a60eb878ffa..0c5f31b044f9 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/dma.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/dma.c | |||
@@ -220,7 +220,8 @@ struct dma_info { | |||
220 | uint *msg_level; /* message level pointer */ | 220 | uint *msg_level; /* message level pointer */ |
221 | char name[MAXNAMEL]; /* callers name for diag msgs */ | 221 | char name[MAXNAMEL]; /* callers name for diag msgs */ |
222 | 222 | ||
223 | struct pci_dev *pbus; /* bus handle */ | 223 | struct bcma_device *d11core; |
224 | struct device *dmadev; | ||
224 | 225 | ||
225 | bool dma64; /* this dma engine is operating in 64-bit mode */ | 226 | bool dma64; /* this dma engine is operating in 64-bit mode */ |
226 | bool addrext; /* this dma engine supports DmaExtendedAddrChanges */ | 227 | bool addrext; /* this dma engine supports DmaExtendedAddrChanges */ |
@@ -450,7 +451,7 @@ static bool _dma_descriptor_align(struct dma_info *di) | |||
450 | * Descriptor table must start at the DMA hardware dictated alignment, so | 451 | * Descriptor table must start at the DMA hardware dictated alignment, so |
451 | * allocated memory must be large enough to support this requirement. | 452 | * allocated memory must be large enough to support this requirement. |
452 | */ | 453 | */ |
453 | static void *dma_alloc_consistent(struct pci_dev *pdev, uint size, | 454 | static void *dma_alloc_consistent(struct dma_info *di, uint size, |
454 | u16 align_bits, uint *alloced, | 455 | u16 align_bits, uint *alloced, |
455 | dma_addr_t *pap) | 456 | dma_addr_t *pap) |
456 | { | 457 | { |
@@ -460,7 +461,7 @@ static void *dma_alloc_consistent(struct pci_dev *pdev, uint size, | |||
460 | size += align; | 461 | size += align; |
461 | *alloced = size; | 462 | *alloced = size; |
462 | } | 463 | } |
463 | return pci_alloc_consistent(pdev, size, pap); | 464 | return dma_alloc_coherent(di->dmadev, size, pap, GFP_ATOMIC); |
464 | } | 465 | } |
465 | 466 | ||
466 | static | 467 | static |
@@ -486,7 +487,7 @@ static void *dma_ringalloc(struct dma_info *di, u32 boundary, uint size, | |||
486 | u32 desc_strtaddr; | 487 | u32 desc_strtaddr; |
487 | u32 alignbytes = 1 << *alignbits; | 488 | u32 alignbytes = 1 << *alignbits; |
488 | 489 | ||
489 | va = dma_alloc_consistent(di->pbus, size, *alignbits, alloced, descpa); | 490 | va = dma_alloc_consistent(di, size, *alignbits, alloced, descpa); |
490 | 491 | ||
491 | if (NULL == va) | 492 | if (NULL == va) |
492 | return NULL; | 493 | return NULL; |
@@ -495,8 +496,8 @@ static void *dma_ringalloc(struct dma_info *di, u32 boundary, uint size, | |||
495 | if (((desc_strtaddr + size - 1) & boundary) != (desc_strtaddr | 496 | if (((desc_strtaddr + size - 1) & boundary) != (desc_strtaddr |
496 | & boundary)) { | 497 | & boundary)) { |
497 | *alignbits = dma_align_sizetobits(size); | 498 | *alignbits = dma_align_sizetobits(size); |
498 | pci_free_consistent(di->pbus, size, va, *descpa); | 499 | dma_free_coherent(di->dmadev, size, va, *descpa); |
499 | va = dma_alloc_consistent(di->pbus, size, *alignbits, | 500 | va = dma_alloc_consistent(di, size, *alignbits, |
500 | alloced, descpa); | 501 | alloced, descpa); |
501 | } | 502 | } |
502 | return va; | 503 | return va; |
@@ -556,10 +557,11 @@ static bool _dma_alloc(struct dma_info *di, uint direction) | |||
556 | } | 557 | } |
557 | 558 | ||
558 | struct dma_pub *dma_attach(char *name, struct si_pub *sih, | 559 | struct dma_pub *dma_attach(char *name, struct si_pub *sih, |
559 | void __iomem *dmaregstx, void __iomem *dmaregsrx, | 560 | struct bcma_device *d11core, |
560 | uint ntxd, uint nrxd, | 561 | void __iomem *dmaregstx, void __iomem *dmaregsrx, |
561 | uint rxbufsize, int rxextheadroom, | 562 | uint ntxd, uint nrxd, |
562 | uint nrxpost, uint rxoffset, uint *msg_level) | 563 | uint rxbufsize, int rxextheadroom, |
564 | uint nrxpost, uint rxoffset, uint *msg_level) | ||
563 | { | 565 | { |
564 | struct dma_info *di; | 566 | struct dma_info *di; |
565 | uint size; | 567 | uint size; |
@@ -575,6 +577,7 @@ struct dma_pub *dma_attach(char *name, struct si_pub *sih, | |||
575 | di->dma64 = ((ai_core_sflags(sih, 0, 0) & SISF_DMA64) == SISF_DMA64); | 577 | di->dma64 = ((ai_core_sflags(sih, 0, 0) & SISF_DMA64) == SISF_DMA64); |
576 | 578 | ||
577 | /* init dma reg pointer */ | 579 | /* init dma reg pointer */ |
580 | di->d11core = d11core; | ||
578 | di->d64txregs = (struct dma64regs __iomem *) dmaregstx; | 581 | di->d64txregs = (struct dma64regs __iomem *) dmaregstx; |
579 | di->d64rxregs = (struct dma64regs __iomem *) dmaregsrx; | 582 | di->d64rxregs = (struct dma64regs __iomem *) dmaregsrx; |
580 | 583 | ||
@@ -594,7 +597,7 @@ struct dma_pub *dma_attach(char *name, struct si_pub *sih, | |||
594 | strncpy(di->name, name, MAXNAMEL); | 597 | strncpy(di->name, name, MAXNAMEL); |
595 | di->name[MAXNAMEL - 1] = '\0'; | 598 | di->name[MAXNAMEL - 1] = '\0'; |
596 | 599 | ||
597 | di->pbus = ((struct si_info *)sih)->pcibus; | 600 | di->dmadev = d11core->dma_dev; |
598 | 601 | ||
599 | /* save tunables */ | 602 | /* save tunables */ |
600 | di->ntxd = (u16) ntxd; | 603 | di->ntxd = (u16) ntxd; |
@@ -749,13 +752,13 @@ void dma_detach(struct dma_pub *pub) | |||
749 | 752 | ||
750 | /* free dma descriptor rings */ | 753 | /* free dma descriptor rings */ |
751 | if (di->txd64) | 754 | if (di->txd64) |
752 | pci_free_consistent(di->pbus, di->txdalloc, | 755 | dma_free_coherent(di->dmadev, di->txdalloc, |
753 | ((s8 *)di->txd64 - di->txdalign), | 756 | ((s8 *)di->txd64 - di->txdalign), |
754 | (di->txdpaorig)); | 757 | (di->txdpaorig)); |
755 | if (di->rxd64) | 758 | if (di->rxd64) |
756 | pci_free_consistent(di->pbus, di->rxdalloc, | 759 | dma_free_coherent(di->dmadev, di->rxdalloc, |
757 | ((s8 *)di->rxd64 - di->rxdalign), | 760 | ((s8 *)di->rxd64 - di->rxdalign), |
758 | (di->rxdpaorig)); | 761 | (di->rxdpaorig)); |
759 | 762 | ||
760 | /* free packet pointer vectors */ | 763 | /* free packet pointer vectors */ |
761 | kfree(di->txp); | 764 | kfree(di->txp); |
@@ -882,7 +885,7 @@ static struct sk_buff *dma64_getnextrxp(struct dma_info *di, bool forceall) | |||
882 | pa = le32_to_cpu(di->rxd64[i].addrlow) - di->dataoffsetlow; | 885 | pa = le32_to_cpu(di->rxd64[i].addrlow) - di->dataoffsetlow; |
883 | 886 | ||
884 | /* clear this packet from the descriptor ring */ | 887 | /* clear this packet from the descriptor ring */ |
885 | pci_unmap_single(di->pbus, pa, di->rxbufsize, PCI_DMA_FROMDEVICE); | 888 | dma_unmap_single(di->dmadev, pa, di->rxbufsize, DMA_FROM_DEVICE); |
886 | 889 | ||
887 | di->rxd64[i].addrlow = cpu_to_le32(0xdeadbeef); | 890 | di->rxd64[i].addrlow = cpu_to_le32(0xdeadbeef); |
888 | di->rxd64[i].addrhigh = cpu_to_le32(0xdeadbeef); | 891 | di->rxd64[i].addrhigh = cpu_to_le32(0xdeadbeef); |
@@ -1048,8 +1051,8 @@ bool dma_rxfill(struct dma_pub *pub) | |||
1048 | */ | 1051 | */ |
1049 | *(u32 *) (p->data) = 0; | 1052 | *(u32 *) (p->data) = 0; |
1050 | 1053 | ||
1051 | pa = pci_map_single(di->pbus, p->data, | 1054 | pa = dma_map_single(di->dmadev, p->data, di->rxbufsize, |
1052 | di->rxbufsize, PCI_DMA_FROMDEVICE); | 1055 | DMA_FROM_DEVICE); |
1053 | 1056 | ||
1054 | /* save the free packet pointer */ | 1057 | /* save the free packet pointer */ |
1055 | di->rxp[rxout] = p; | 1058 | di->rxp[rxout] = p; |
@@ -1267,7 +1270,7 @@ int dma_txfast(struct dma_pub *pub, struct sk_buff *p, bool commit) | |||
1267 | goto outoftxd; | 1270 | goto outoftxd; |
1268 | 1271 | ||
1269 | /* get physical address of buffer start */ | 1272 | /* get physical address of buffer start */ |
1270 | pa = pci_map_single(di->pbus, data, len, PCI_DMA_TODEVICE); | 1273 | pa = dma_map_single(di->dmadev, data, len, DMA_TO_DEVICE); |
1271 | 1274 | ||
1272 | /* With a DMA segment list, Descriptor table is filled | 1275 | /* With a DMA segment list, Descriptor table is filled |
1273 | * using the segment list instead of looping over | 1276 | * using the segment list instead of looping over |
@@ -1376,7 +1379,7 @@ struct sk_buff *dma_getnexttxp(struct dma_pub *pub, enum txd_range range) | |||
1376 | txp = di->txp[i]; | 1379 | txp = di->txp[i]; |
1377 | di->txp[i] = NULL; | 1380 | di->txp[i] = NULL; |
1378 | 1381 | ||
1379 | pci_unmap_single(di->pbus, pa, size, PCI_DMA_TODEVICE); | 1382 | dma_unmap_single(di->dmadev, pa, size, DMA_TO_DEVICE); |
1380 | } | 1383 | } |
1381 | 1384 | ||
1382 | di->txin = i; | 1385 | di->txin = i; |
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/dma.h b/drivers/net/wireless/brcm80211/brcmsmac/dma.h index d317c7c12f91..2d59ad6ab8e0 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/dma.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/dma.h | |||
@@ -75,10 +75,12 @@ struct dma_pub { | |||
75 | }; | 75 | }; |
76 | 76 | ||
77 | extern struct dma_pub *dma_attach(char *name, struct si_pub *sih, | 77 | extern struct dma_pub *dma_attach(char *name, struct si_pub *sih, |
78 | void __iomem *dmaregstx, void __iomem *dmaregsrx, | 78 | struct bcma_device *d11core, |
79 | uint ntxd, uint nrxd, | 79 | void __iomem *dmaregstx, |
80 | uint rxbufsize, int rxextheadroom, | 80 | void __iomem *dmaregsrx, |
81 | uint nrxpost, uint rxoffset, uint *msg_level); | 81 | uint ntxd, uint nrxd, |
82 | uint rxbufsize, int rxextheadroom, | ||
83 | uint nrxpost, uint rxoffset, uint *msg_level); | ||
82 | 84 | ||
83 | void dma_rxinit(struct dma_pub *pub); | 85 | void dma_rxinit(struct dma_pub *pub); |
84 | int dma_rx(struct dma_pub *pub, struct sk_buff_head *skb_list); | 86 | int dma_rx(struct dma_pub *pub, struct sk_buff_head *skb_list); |
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index f4a64652fdab..f2491bdb1898 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c | |||
@@ -1098,7 +1098,7 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) | |||
1098 | * TX: TX_AC_BK_FIFO (TX AC Background data packets) | 1098 | * TX: TX_AC_BK_FIFO (TX AC Background data packets) |
1099 | * RX: RX_FIFO (RX data packets) | 1099 | * RX: RX_FIFO (RX data packets) |
1100 | */ | 1100 | */ |
1101 | wlc_hw->di[0] = dma_attach(name, wlc_hw->sih, | 1101 | wlc_hw->di[0] = dma_attach(name, wlc_hw->sih, wlc_hw->d11core, |
1102 | (wme ? dmareg(wlc_hw, DMA_TX, 0) : | 1102 | (wme ? dmareg(wlc_hw, DMA_TX, 0) : |
1103 | NULL), dmareg(wlc_hw, DMA_RX, 0), | 1103 | NULL), dmareg(wlc_hw, DMA_RX, 0), |
1104 | (wme ? NTXD : 0), NRXD, | 1104 | (wme ? NTXD : 0), NRXD, |
@@ -1112,7 +1112,7 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) | |||
1112 | * (legacy) TX_DATA_FIFO (TX data packets) | 1112 | * (legacy) TX_DATA_FIFO (TX data packets) |
1113 | * RX: UNUSED | 1113 | * RX: UNUSED |
1114 | */ | 1114 | */ |
1115 | wlc_hw->di[1] = dma_attach(name, wlc_hw->sih, | 1115 | wlc_hw->di[1] = dma_attach(name, wlc_hw->sih, wlc_hw->d11core, |
1116 | dmareg(wlc_hw, DMA_TX, 1), NULL, | 1116 | dmareg(wlc_hw, DMA_TX, 1), NULL, |
1117 | NTXD, 0, 0, -1, 0, 0, | 1117 | NTXD, 0, 0, -1, 0, 0, |
1118 | &brcm_msg_level); | 1118 | &brcm_msg_level); |
@@ -1123,7 +1123,7 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) | |||
1123 | * TX: TX_AC_VI_FIFO (TX AC Video data packets) | 1123 | * TX: TX_AC_VI_FIFO (TX AC Video data packets) |
1124 | * RX: UNUSED | 1124 | * RX: UNUSED |
1125 | */ | 1125 | */ |
1126 | wlc_hw->di[2] = dma_attach(name, wlc_hw->sih, | 1126 | wlc_hw->di[2] = dma_attach(name, wlc_hw->sih, wlc_hw->d11core, |
1127 | dmareg(wlc_hw, DMA_TX, 2), NULL, | 1127 | dmareg(wlc_hw, DMA_TX, 2), NULL, |
1128 | NTXD, 0, 0, -1, 0, 0, | 1128 | NTXD, 0, 0, -1, 0, 0, |
1129 | &brcm_msg_level); | 1129 | &brcm_msg_level); |
@@ -1133,7 +1133,7 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) | |||
1133 | * TX: TX_AC_VO_FIFO (TX AC Voice data packets) | 1133 | * TX: TX_AC_VO_FIFO (TX AC Voice data packets) |
1134 | * (legacy) TX_CTL_FIFO (TX control & mgmt packets) | 1134 | * (legacy) TX_CTL_FIFO (TX control & mgmt packets) |
1135 | */ | 1135 | */ |
1136 | wlc_hw->di[3] = dma_attach(name, wlc_hw->sih, | 1136 | wlc_hw->di[3] = dma_attach(name, wlc_hw->sih, wlc_hw->d11core, |
1137 | dmareg(wlc_hw, DMA_TX, 3), | 1137 | dmareg(wlc_hw, DMA_TX, 3), |
1138 | NULL, NTXD, 0, 0, -1, | 1138 | NULL, NTXD, 0, 0, -1, |
1139 | 0, 0, &brcm_msg_level); | 1139 | 0, 0, &brcm_msg_level); |