aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/wireless/ath5k/base.c85
1 files changed, 53 insertions, 32 deletions
diff --git a/drivers/net/wireless/ath5k/base.c b/drivers/net/wireless/ath5k/base.c
index a533ed60bb4d..1d77ee9d6e99 100644
--- a/drivers/net/wireless/ath5k/base.c
+++ b/drivers/net/wireless/ath5k/base.c
@@ -1098,6 +1098,42 @@ ath5k_hw_to_driver_rix(struct ath5k_softc *sc, int hw_rix)
1098* Buffers setup * 1098* Buffers setup *
1099\***************/ 1099\***************/
1100 1100
1101static
1102struct sk_buff *ath5k_rx_skb_alloc(struct ath5k_softc *sc, dma_addr_t *skb_addr)
1103{
1104 struct sk_buff *skb;
1105 unsigned int off;
1106
1107 /*
1108 * Allocate buffer with headroom_needed space for the
1109 * fake physical layer header at the start.
1110 */
1111 skb = dev_alloc_skb(sc->rxbufsize + sc->cachelsz - 1);
1112
1113 if (!skb) {
1114 ATH5K_ERR(sc, "can't alloc skbuff of size %u\n",
1115 sc->rxbufsize + sc->cachelsz - 1);
1116 return NULL;
1117 }
1118 /*
1119 * Cache-line-align. This is important (for the
1120 * 5210 at least) as not doing so causes bogus data
1121 * in rx'd frames.
1122 */
1123 off = ((unsigned long)skb->data) % sc->cachelsz;
1124 if (off != 0)
1125 skb_reserve(skb, sc->cachelsz - off);
1126
1127 *skb_addr = pci_map_single(sc->pdev,
1128 skb->data, sc->rxbufsize, PCI_DMA_FROMDEVICE);
1129 if (unlikely(pci_dma_mapping_error(sc->pdev, *skb_addr))) {
1130 ATH5K_ERR(sc, "%s: DMA mapping failed\n", __func__);
1131 dev_kfree_skb(skb);
1132 return NULL;
1133 }
1134 return skb;
1135}
1136
1101static int 1137static int
1102ath5k_rxbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf) 1138ath5k_rxbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf)
1103{ 1139{
@@ -1105,37 +1141,11 @@ ath5k_rxbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf)
1105 struct sk_buff *skb = bf->skb; 1141 struct sk_buff *skb = bf->skb;
1106 struct ath5k_desc *ds; 1142 struct ath5k_desc *ds;
1107 1143
1108 if (likely(skb == NULL)) { 1144 if (!skb) {
1109 unsigned int off; 1145 skb = ath5k_rx_skb_alloc(sc, &bf->skbaddr);
1110 1146 if (!skb)
1111 /*
1112 * Allocate buffer with headroom_needed space for the
1113 * fake physical layer header at the start.
1114 */
1115 skb = dev_alloc_skb(sc->rxbufsize + sc->cachelsz - 1);
1116 if (unlikely(skb == NULL)) {
1117 ATH5K_ERR(sc, "can't alloc skbuff of size %u\n",
1118 sc->rxbufsize + sc->cachelsz - 1);
1119 return -ENOMEM; 1147 return -ENOMEM;
1120 }
1121 /*
1122 * Cache-line-align. This is important (for the
1123 * 5210 at least) as not doing so causes bogus data
1124 * in rx'd frames.
1125 */
1126 off = ((unsigned long)skb->data) % sc->cachelsz;
1127 if (off != 0)
1128 skb_reserve(skb, sc->cachelsz - off);
1129
1130 bf->skb = skb; 1148 bf->skb = skb;
1131 bf->skbaddr = pci_map_single(sc->pdev,
1132 skb->data, sc->rxbufsize, PCI_DMA_FROMDEVICE);
1133 if (unlikely(pci_dma_mapping_error(sc->pdev, bf->skbaddr))) {
1134 ATH5K_ERR(sc, "%s: DMA mapping failed\n", __func__);
1135 dev_kfree_skb(skb);
1136 bf->skb = NULL;
1137 return -ENOMEM;
1138 }
1139 } 1149 }
1140 1150
1141 /* 1151 /*
@@ -1664,7 +1674,8 @@ ath5k_tasklet_rx(unsigned long data)
1664{ 1674{
1665 struct ieee80211_rx_status rxs = {}; 1675 struct ieee80211_rx_status rxs = {};
1666 struct ath5k_rx_status rs = {}; 1676 struct ath5k_rx_status rs = {};
1667 struct sk_buff *skb; 1677 struct sk_buff *skb, *next_skb;
1678 dma_addr_t next_skb_addr;
1668 struct ath5k_softc *sc = (void *)data; 1679 struct ath5k_softc *sc = (void *)data;
1669 struct ath5k_buf *bf, *bf_last; 1680 struct ath5k_buf *bf, *bf_last;
1670 struct ath5k_desc *ds; 1681 struct ath5k_desc *ds;
@@ -1749,10 +1760,17 @@ ath5k_tasklet_rx(unsigned long data)
1749 goto next; 1760 goto next;
1750 } 1761 }
1751accept: 1762accept:
1763 next_skb = ath5k_rx_skb_alloc(sc, &next_skb_addr);
1764
1765 /*
1766 * If we can't replace bf->skb with a new skb under memory
1767 * pressure, just skip this packet
1768 */
1769 if (!next_skb)
1770 goto next;
1771
1752 pci_unmap_single(sc->pdev, bf->skbaddr, sc->rxbufsize, 1772 pci_unmap_single(sc->pdev, bf->skbaddr, sc->rxbufsize,
1753 PCI_DMA_FROMDEVICE); 1773 PCI_DMA_FROMDEVICE);
1754 bf->skb = NULL;
1755
1756 skb_put(skb, rs.rs_datalen); 1774 skb_put(skb, rs.rs_datalen);
1757 1775
1758 /* The MAC header is padded to have 32-bit boundary if the 1776 /* The MAC header is padded to have 32-bit boundary if the
@@ -1825,6 +1843,9 @@ accept:
1825 ath5k_check_ibss_tsf(sc, skb, &rxs); 1843 ath5k_check_ibss_tsf(sc, skb, &rxs);
1826 1844
1827 __ieee80211_rx(sc->hw, skb, &rxs); 1845 __ieee80211_rx(sc->hw, skb, &rxs);
1846
1847 bf->skb = next_skb;
1848 bf->skbaddr = next_skb_addr;
1828next: 1849next:
1829 list_move_tail(&bf->list, &sc->rxbuf); 1850 list_move_tail(&bf->list, &sc->rxbuf);
1830 } while (ath5k_rxbuf_setup(sc, bf) == 0); 1851 } while (ath5k_rxbuf_setup(sc, bf) == 0);