aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless
diff options
context:
space:
mode:
authorLuis R. Rodriguez <lrodriguez@atheros.com>2009-11-04 12:11:34 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-11-11 17:09:07 -0500
commitcc861f7468724e66567baf087b4e413e91b18150 (patch)
tree317cfe881552a8b2bc79fa18845e64fba76b459c /drivers/net/wireless
parent0a45da765e4bf5e8a7705266fa36e0f44787b0a1 (diff)
ath: move the rx bufsize to common to share with ath5k/ath9k
This will also be used by ath9k_htc. Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r--drivers/net/wireless/ath/ath.h2
-rw-r--r--drivers/net/wireless/ath/ath5k/base.c22
-rw-r--r--drivers/net/wireless/ath/ath9k/ath9k.h1
-rw-r--r--drivers/net/wireless/ath/ath9k/recv.c35
4 files changed, 36 insertions, 24 deletions
diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h
index b3c8ee08bb7c..4af13628bafe 100644
--- a/drivers/net/wireless/ath/ath.h
+++ b/drivers/net/wireless/ath/ath.h
@@ -87,6 +87,8 @@ struct ath_common {
87 u8 tx_chainmask; 87 u8 tx_chainmask;
88 u8 rx_chainmask; 88 u8 rx_chainmask;
89 89
90 u32 rx_bufsize;
91
90 struct ath_regulatory regulatory; 92 struct ath_regulatory regulatory;
91 const struct ath_ops *ops; 93 const struct ath_ops *ops;
92 const struct ath_bus_ops *bus_ops; 94 const struct ath_bus_ops *bus_ops;
diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
index cb3dc892d697..f1a7c77c0f8d 100644
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -323,10 +323,13 @@ static inline void ath5k_txbuf_free(struct ath5k_softc *sc,
323static inline void ath5k_rxbuf_free(struct ath5k_softc *sc, 323static inline void ath5k_rxbuf_free(struct ath5k_softc *sc,
324 struct ath5k_buf *bf) 324 struct ath5k_buf *bf)
325{ 325{
326 struct ath5k_hw *ah = sc->ah;
327 struct ath_common *common = ath5k_hw_common(ah);
328
326 BUG_ON(!bf); 329 BUG_ON(!bf);
327 if (!bf->skb) 330 if (!bf->skb)
328 return; 331 return;
329 pci_unmap_single(sc->pdev, bf->skbaddr, sc->rxbufsize, 332 pci_unmap_single(sc->pdev, bf->skbaddr, common->rx_bufsize,
330 PCI_DMA_FROMDEVICE); 333 PCI_DMA_FROMDEVICE);
331 dev_kfree_skb_any(bf->skb); 334 dev_kfree_skb_any(bf->skb);
332 bf->skb = NULL; 335 bf->skb = NULL;
@@ -1181,17 +1184,18 @@ struct sk_buff *ath5k_rx_skb_alloc(struct ath5k_softc *sc, dma_addr_t *skb_addr)
1181 * fake physical layer header at the start. 1184 * fake physical layer header at the start.
1182 */ 1185 */
1183 skb = ath_rxbuf_alloc(common, 1186 skb = ath_rxbuf_alloc(common,
1184 sc->rxbufsize + common->cachelsz - 1, 1187 common->rx_bufsize + common->cachelsz - 1,
1185 GFP_ATOMIC); 1188 GFP_ATOMIC);
1186 1189
1187 if (!skb) { 1190 if (!skb) {
1188 ATH5K_ERR(sc, "can't alloc skbuff of size %u\n", 1191 ATH5K_ERR(sc, "can't alloc skbuff of size %u\n",
1189 sc->rxbufsize + common->cachelsz - 1); 1192 common->rx_bufsize + common->cachelsz - 1);
1190 return NULL; 1193 return NULL;
1191 } 1194 }
1192 1195
1193 *skb_addr = pci_map_single(sc->pdev, 1196 *skb_addr = pci_map_single(sc->pdev,
1194 skb->data, sc->rxbufsize, PCI_DMA_FROMDEVICE); 1197 skb->data, common->rx_bufsize,
1198 PCI_DMA_FROMDEVICE);
1195 if (unlikely(pci_dma_mapping_error(sc->pdev, *skb_addr))) { 1199 if (unlikely(pci_dma_mapping_error(sc->pdev, *skb_addr))) {
1196 ATH5K_ERR(sc, "%s: DMA mapping failed\n", __func__); 1200 ATH5K_ERR(sc, "%s: DMA mapping failed\n", __func__);
1197 dev_kfree_skb(skb); 1201 dev_kfree_skb(skb);
@@ -1631,10 +1635,10 @@ ath5k_rx_start(struct ath5k_softc *sc)
1631 struct ath5k_buf *bf; 1635 struct ath5k_buf *bf;
1632 int ret; 1636 int ret;
1633 1637
1634 sc->rxbufsize = roundup(IEEE80211_MAX_LEN, common->cachelsz); 1638 common->rx_bufsize = roundup(IEEE80211_MAX_LEN, common->cachelsz);
1635 1639
1636 ATH5K_DBG(sc, ATH5K_DEBUG_RESET, "cachelsz %u rxbufsize %u\n", 1640 ATH5K_DBG(sc, ATH5K_DEBUG_RESET, "cachelsz %u rx_bufsize %u\n",
1637 common->cachelsz, sc->rxbufsize); 1641 common->cachelsz, common->rx_bufsize);
1638 1642
1639 spin_lock_bh(&sc->rxbuflock); 1643 spin_lock_bh(&sc->rxbuflock);
1640 sc->rxlink = NULL; 1644 sc->rxlink = NULL;
@@ -1769,6 +1773,8 @@ ath5k_tasklet_rx(unsigned long data)
1769 struct sk_buff *skb, *next_skb; 1773 struct sk_buff *skb, *next_skb;
1770 dma_addr_t next_skb_addr; 1774 dma_addr_t next_skb_addr;
1771 struct ath5k_softc *sc = (void *)data; 1775 struct ath5k_softc *sc = (void *)data;
1776 struct ath5k_hw *ah = sc->ah;
1777 struct ath_common *common = ath5k_hw_common(ah);
1772 struct ath5k_buf *bf; 1778 struct ath5k_buf *bf;
1773 struct ath5k_desc *ds; 1779 struct ath5k_desc *ds;
1774 int ret; 1780 int ret;
@@ -1846,7 +1852,7 @@ accept:
1846 if (!next_skb) 1852 if (!next_skb)
1847 goto next; 1853 goto next;
1848 1854
1849 pci_unmap_single(sc->pdev, bf->skbaddr, sc->rxbufsize, 1855 pci_unmap_single(sc->pdev, bf->skbaddr, common->rx_bufsize,
1850 PCI_DMA_FROMDEVICE); 1856 PCI_DMA_FROMDEVICE);
1851 skb_put(skb, rs.rs_datalen); 1857 skb_put(skb, rs.rs_datalen);
1852 1858
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index 24f61fdb1c20..377b0eac5e4c 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -323,7 +323,6 @@ struct ath_rx {
323 u8 defant; 323 u8 defant;
324 u8 rxotherant; 324 u8 rxotherant;
325 u32 *rxlink; 325 u32 *rxlink;
326 int bufsize;
327 unsigned int rxfilter; 326 unsigned int rxfilter;
328 spinlock_t rxflushlock; 327 spinlock_t rxflushlock;
329 spinlock_t rxbuflock; 328 spinlock_t rxbuflock;
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index 4420a5800bd6..48ff77255d2f 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -48,6 +48,7 @@ static struct ieee80211_hw * ath_get_virt_hw(struct ath_softc *sc,
48static void ath_rx_buf_link(struct ath_softc *sc, struct ath_buf *bf) 48static void ath_rx_buf_link(struct ath_softc *sc, struct ath_buf *bf)
49{ 49{
50 struct ath_hw *ah = sc->sc_ah; 50 struct ath_hw *ah = sc->sc_ah;
51 struct ath_common *common = ath9k_hw_common(ah);
51 struct ath_desc *ds; 52 struct ath_desc *ds;
52 struct sk_buff *skb; 53 struct sk_buff *skb;
53 54
@@ -62,11 +63,13 @@ static void ath_rx_buf_link(struct ath_softc *sc, struct ath_buf *bf)
62 BUG_ON(skb == NULL); 63 BUG_ON(skb == NULL);
63 ds->ds_vdata = skb->data; 64 ds->ds_vdata = skb->data;
64 65
65 /* setup rx descriptors. The rx.bufsize here tells the harware 66 /*
67 * setup rx descriptors. The rx_bufsize here tells the hardware
66 * how much data it can DMA to us and that we are prepared 68 * how much data it can DMA to us and that we are prepared
67 * to process */ 69 * to process
70 */
68 ath9k_hw_setuprxdesc(ah, ds, 71 ath9k_hw_setuprxdesc(ah, ds,
69 sc->rx.bufsize, 72 common->rx_bufsize,
70 0); 73 0);
71 74
72 if (sc->rx.rxlink == NULL) 75 if (sc->rx.rxlink == NULL)
@@ -344,11 +347,11 @@ int ath_rx_init(struct ath_softc *sc, int nbufs)
344 sc->sc_flags &= ~SC_OP_RXFLUSH; 347 sc->sc_flags &= ~SC_OP_RXFLUSH;
345 spin_lock_init(&sc->rx.rxbuflock); 348 spin_lock_init(&sc->rx.rxbuflock);
346 349
347 sc->rx.bufsize = roundup(IEEE80211_MAX_MPDU_LEN, 350 common->rx_bufsize = roundup(IEEE80211_MAX_MPDU_LEN,
348 min(common->cachelsz, (u16)64)); 351 min(common->cachelsz, (u16)64));
349 352
350 ath_print(common, ATH_DBG_CONFIG, "cachelsz %u rxbufsize %u\n", 353 ath_print(common, ATH_DBG_CONFIG, "cachelsz %u rxbufsize %u\n",
351 common->cachelsz, sc->rx.bufsize); 354 common->cachelsz, common->rx_bufsize);
352 355
353 /* Initialize rx descriptors */ 356 /* Initialize rx descriptors */
354 357
@@ -361,7 +364,7 @@ int ath_rx_init(struct ath_softc *sc, int nbufs)
361 } 364 }
362 365
363 list_for_each_entry(bf, &sc->rx.rxbuf, list) { 366 list_for_each_entry(bf, &sc->rx.rxbuf, list) {
364 skb = ath_rxbuf_alloc(common, sc->rx.bufsize, GFP_KERNEL); 367 skb = ath_rxbuf_alloc(common, common->rx_bufsize, GFP_KERNEL);
365 if (skb == NULL) { 368 if (skb == NULL) {
366 error = -ENOMEM; 369 error = -ENOMEM;
367 goto err; 370 goto err;
@@ -369,7 +372,7 @@ int ath_rx_init(struct ath_softc *sc, int nbufs)
369 372
370 bf->bf_mpdu = skb; 373 bf->bf_mpdu = skb;
371 bf->bf_buf_addr = dma_map_single(sc->dev, skb->data, 374 bf->bf_buf_addr = dma_map_single(sc->dev, skb->data,
372 sc->rx.bufsize, 375 common->rx_bufsize,
373 DMA_FROM_DEVICE); 376 DMA_FROM_DEVICE);
374 if (unlikely(dma_mapping_error(sc->dev, 377 if (unlikely(dma_mapping_error(sc->dev,
375 bf->bf_buf_addr))) { 378 bf->bf_buf_addr))) {
@@ -393,6 +396,8 @@ err:
393 396
394void ath_rx_cleanup(struct ath_softc *sc) 397void ath_rx_cleanup(struct ath_softc *sc)
395{ 398{
399 struct ath_hw *ah = sc->sc_ah;
400 struct ath_common *common = ath9k_hw_common(ah);
396 struct sk_buff *skb; 401 struct sk_buff *skb;
397 struct ath_buf *bf; 402 struct ath_buf *bf;
398 403
@@ -400,7 +405,7 @@ void ath_rx_cleanup(struct ath_softc *sc)
400 skb = bf->bf_mpdu; 405 skb = bf->bf_mpdu;
401 if (skb) { 406 if (skb) {
402 dma_unmap_single(sc->dev, bf->bf_buf_addr, 407 dma_unmap_single(sc->dev, bf->bf_buf_addr,
403 sc->rx.bufsize, DMA_FROM_DEVICE); 408 common->rx_bufsize, DMA_FROM_DEVICE);
404 dev_kfree_skb(skb); 409 dev_kfree_skb(skb);
405 } 410 }
406 } 411 }
@@ -780,7 +785,7 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush)
780 * 2. requeueing the same buffer to h/w 785 * 2. requeueing the same buffer to h/w
781 */ 786 */
782 dma_sync_single_for_cpu(sc->dev, bf->bf_buf_addr, 787 dma_sync_single_for_cpu(sc->dev, bf->bf_buf_addr,
783 sc->rx.bufsize, 788 common->rx_bufsize,
784 DMA_FROM_DEVICE); 789 DMA_FROM_DEVICE);
785 790
786 hdr = (struct ieee80211_hdr *) skb->data; 791 hdr = (struct ieee80211_hdr *) skb->data;
@@ -797,7 +802,7 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush)
797 goto requeue; 802 goto requeue;
798 803
799 /* The status portion of the descriptor could get corrupted. */ 804 /* The status portion of the descriptor could get corrupted. */
800 if (sc->rx.bufsize < rx_stats->rs_datalen) 805 if (common->rx_bufsize < rx_stats->rs_datalen)
801 goto requeue; 806 goto requeue;
802 807
803 if (!ath_rx_prepare(common, hw, skb, rx_stats, 808 if (!ath_rx_prepare(common, hw, skb, rx_stats,
@@ -806,7 +811,7 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush)
806 811
807 /* Ensure we always have an skb to requeue once we are done 812 /* Ensure we always have an skb to requeue once we are done
808 * processing the current buffer's skb */ 813 * processing the current buffer's skb */
809 requeue_skb = ath_rxbuf_alloc(common, sc->rx.bufsize, GFP_ATOMIC); 814 requeue_skb = ath_rxbuf_alloc(common, common->rx_bufsize, GFP_ATOMIC);
810 815
811 /* If there is no memory we ignore the current RX'd frame, 816 /* If there is no memory we ignore the current RX'd frame,
812 * tell hardware it can give us a new frame using the old 817 * tell hardware it can give us a new frame using the old
@@ -817,7 +822,7 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush)
817 822
818 /* Unmap the frame */ 823 /* Unmap the frame */
819 dma_unmap_single(sc->dev, bf->bf_buf_addr, 824 dma_unmap_single(sc->dev, bf->bf_buf_addr,
820 sc->rx.bufsize, 825 common->rx_bufsize,
821 DMA_FROM_DEVICE); 826 DMA_FROM_DEVICE);
822 827
823 skb_put(skb, rx_stats->rs_datalen); 828 skb_put(skb, rx_stats->rs_datalen);
@@ -860,8 +865,8 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush)
860 /* We will now give hardware our shiny new allocated skb */ 865 /* We will now give hardware our shiny new allocated skb */
861 bf->bf_mpdu = requeue_skb; 866 bf->bf_mpdu = requeue_skb;
862 bf->bf_buf_addr = dma_map_single(sc->dev, requeue_skb->data, 867 bf->bf_buf_addr = dma_map_single(sc->dev, requeue_skb->data,
863 sc->rx.bufsize, 868 common->rx_bufsize,
864 DMA_FROM_DEVICE); 869 DMA_FROM_DEVICE);
865 if (unlikely(dma_mapping_error(sc->dev, 870 if (unlikely(dma_mapping_error(sc->dev,
866 bf->bf_buf_addr))) { 871 bf->bf_buf_addr))) {
867 dev_kfree_skb_any(requeue_skb); 872 dev_kfree_skb_any(requeue_skb);