diff options
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/recv.c')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/recv.c | 155 |
1 files changed, 70 insertions, 85 deletions
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c index 116f0582af24..daf171d2f610 100644 --- a/drivers/net/wireless/ath/ath9k/recv.c +++ b/drivers/net/wireless/ath/ath9k/recv.c | |||
@@ -34,27 +34,6 @@ static inline bool ath9k_check_auto_sleep(struct ath_softc *sc) | |||
34 | (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP); | 34 | (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP); |
35 | } | 35 | } |
36 | 36 | ||
37 | static struct ieee80211_hw * ath_get_virt_hw(struct ath_softc *sc, | ||
38 | struct ieee80211_hdr *hdr) | ||
39 | { | ||
40 | struct ieee80211_hw *hw = sc->pri_wiphy->hw; | ||
41 | int i; | ||
42 | |||
43 | spin_lock_bh(&sc->wiphy_lock); | ||
44 | for (i = 0; i < sc->num_sec_wiphy; i++) { | ||
45 | struct ath_wiphy *aphy = sc->sec_wiphy[i]; | ||
46 | if (aphy == NULL) | ||
47 | continue; | ||
48 | if (compare_ether_addr(hdr->addr1, aphy->hw->wiphy->perm_addr) | ||
49 | == 0) { | ||
50 | hw = aphy->hw; | ||
51 | break; | ||
52 | } | ||
53 | } | ||
54 | spin_unlock_bh(&sc->wiphy_lock); | ||
55 | return hw; | ||
56 | } | ||
57 | |||
58 | /* | 37 | /* |
59 | * Setup and link descriptors. | 38 | * Setup and link descriptors. |
60 | * | 39 | * |
@@ -230,11 +209,6 @@ static int ath_rx_edma_init(struct ath_softc *sc, int nbufs) | |||
230 | int error = 0, i; | 209 | int error = 0, i; |
231 | u32 size; | 210 | u32 size; |
232 | 211 | ||
233 | |||
234 | common->rx_bufsize = roundup(IEEE80211_MAX_MPDU_LEN + | ||
235 | ah->caps.rx_status_len, | ||
236 | min(common->cachelsz, (u16)64)); | ||
237 | |||
238 | ath9k_hw_set_rx_bufsize(ah, common->rx_bufsize - | 212 | ath9k_hw_set_rx_bufsize(ah, common->rx_bufsize - |
239 | ah->caps.rx_status_len); | 213 | ah->caps.rx_status_len); |
240 | 214 | ||
@@ -321,12 +295,12 @@ int ath_rx_init(struct ath_softc *sc, int nbufs) | |||
321 | sc->sc_flags &= ~SC_OP_RXFLUSH; | 295 | sc->sc_flags &= ~SC_OP_RXFLUSH; |
322 | spin_lock_init(&sc->rx.rxbuflock); | 296 | spin_lock_init(&sc->rx.rxbuflock); |
323 | 297 | ||
298 | common->rx_bufsize = IEEE80211_MAX_MPDU_LEN / 2 + | ||
299 | sc->sc_ah->caps.rx_status_len; | ||
300 | |||
324 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { | 301 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { |
325 | return ath_rx_edma_init(sc, nbufs); | 302 | return ath_rx_edma_init(sc, nbufs); |
326 | } else { | 303 | } else { |
327 | common->rx_bufsize = roundup(IEEE80211_MAX_MPDU_LEN, | ||
328 | min(common->cachelsz, (u16)64)); | ||
329 | |||
330 | ath_dbg(common, ATH_DBG_CONFIG, "cachelsz %u rxbufsize %u\n", | 304 | ath_dbg(common, ATH_DBG_CONFIG, "cachelsz %u rxbufsize %u\n", |
331 | common->cachelsz, common->rx_bufsize); | 305 | common->cachelsz, common->rx_bufsize); |
332 | 306 | ||
@@ -463,8 +437,7 @@ u32 ath_calcrxfilter(struct ath_softc *sc) | |||
463 | if (conf_is_ht(&sc->hw->conf)) | 437 | if (conf_is_ht(&sc->hw->conf)) |
464 | rfilt |= ATH9K_RX_FILTER_COMP_BAR; | 438 | rfilt |= ATH9K_RX_FILTER_COMP_BAR; |
465 | 439 | ||
466 | if (sc->sec_wiphy || (sc->nvifs > 1) || | 440 | if (sc->nvifs > 1 || (sc->rx.rxfilter & FIF_OTHER_BSS)) { |
467 | (sc->rx.rxfilter & FIF_OTHER_BSS)) { | ||
468 | /* The following may also be needed for other older chips */ | 441 | /* The following may also be needed for other older chips */ |
469 | if (sc->sc_ah->hw_version.macVersion == AR_SREV_VERSION_9160) | 442 | if (sc->sc_ah->hw_version.macVersion == AR_SREV_VERSION_9160) |
470 | rfilt |= ATH9K_RX_FILTER_PROM; | 443 | rfilt |= ATH9K_RX_FILTER_PROM; |
@@ -668,37 +641,6 @@ static void ath_rx_ps(struct ath_softc *sc, struct sk_buff *skb) | |||
668 | } | 641 | } |
669 | } | 642 | } |
670 | 643 | ||
671 | static void ath_rx_send_to_mac80211(struct ieee80211_hw *hw, | ||
672 | struct ath_softc *sc, struct sk_buff *skb) | ||
673 | { | ||
674 | struct ieee80211_hdr *hdr; | ||
675 | |||
676 | hdr = (struct ieee80211_hdr *)skb->data; | ||
677 | |||
678 | /* Send the frame to mac80211 */ | ||
679 | if (is_multicast_ether_addr(hdr->addr1)) { | ||
680 | int i; | ||
681 | /* | ||
682 | * Deliver broadcast/multicast frames to all suitable | ||
683 | * virtual wiphys. | ||
684 | */ | ||
685 | /* TODO: filter based on channel configuration */ | ||
686 | for (i = 0; i < sc->num_sec_wiphy; i++) { | ||
687 | struct ath_wiphy *aphy = sc->sec_wiphy[i]; | ||
688 | struct sk_buff *nskb; | ||
689 | if (aphy == NULL) | ||
690 | continue; | ||
691 | nskb = skb_copy(skb, GFP_ATOMIC); | ||
692 | if (!nskb) | ||
693 | continue; | ||
694 | ieee80211_rx(aphy->hw, nskb); | ||
695 | } | ||
696 | ieee80211_rx(sc->hw, skb); | ||
697 | } else | ||
698 | /* Deliver unicast frames based on receiver address */ | ||
699 | ieee80211_rx(hw, skb); | ||
700 | } | ||
701 | |||
702 | static bool ath_edma_get_buffers(struct ath_softc *sc, | 644 | static bool ath_edma_get_buffers(struct ath_softc *sc, |
703 | enum ath9k_rx_qtype qtype) | 645 | enum ath9k_rx_qtype qtype) |
704 | { | 646 | { |
@@ -868,15 +810,9 @@ static bool ath9k_rx_accept(struct ath_common *common, | |||
868 | if (rx_stats->rs_datalen > (common->rx_bufsize - rx_status_len)) | 810 | if (rx_stats->rs_datalen > (common->rx_bufsize - rx_status_len)) |
869 | return false; | 811 | return false; |
870 | 812 | ||
871 | /* | 813 | /* Only use error bits from the last fragment */ |
872 | * rs_more indicates chained descriptors which can be used | ||
873 | * to link buffers together for a sort of scatter-gather | ||
874 | * operation. | ||
875 | * reject the frame, we don't support scatter-gather yet and | ||
876 | * the frame is probably corrupt anyway | ||
877 | */ | ||
878 | if (rx_stats->rs_more) | 814 | if (rx_stats->rs_more) |
879 | return false; | 815 | return true; |
880 | 816 | ||
881 | /* | 817 | /* |
882 | * The rx_stats->rs_status will not be set until the end of the | 818 | * The rx_stats->rs_status will not be set until the end of the |
@@ -980,7 +916,7 @@ static void ath9k_process_rssi(struct ath_common *common, | |||
980 | struct ieee80211_hdr *hdr, | 916 | struct ieee80211_hdr *hdr, |
981 | struct ath_rx_status *rx_stats) | 917 | struct ath_rx_status *rx_stats) |
982 | { | 918 | { |
983 | struct ath_wiphy *aphy = hw->priv; | 919 | struct ath_softc *sc = hw->priv; |
984 | struct ath_hw *ah = common->ah; | 920 | struct ath_hw *ah = common->ah; |
985 | int last_rssi; | 921 | int last_rssi; |
986 | __le16 fc; | 922 | __le16 fc; |
@@ -1000,9 +936,9 @@ static void ath9k_process_rssi(struct ath_common *common, | |||
1000 | } | 936 | } |
1001 | 937 | ||
1002 | if (rx_stats->rs_rssi != ATH9K_RSSI_BAD && !rx_stats->rs_moreaggr) | 938 | if (rx_stats->rs_rssi != ATH9K_RSSI_BAD && !rx_stats->rs_moreaggr) |
1003 | ATH_RSSI_LPF(aphy->last_rssi, rx_stats->rs_rssi); | 939 | ATH_RSSI_LPF(sc->last_rssi, rx_stats->rs_rssi); |
1004 | 940 | ||
1005 | last_rssi = aphy->last_rssi; | 941 | last_rssi = sc->last_rssi; |
1006 | if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER)) | 942 | if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER)) |
1007 | rx_stats->rs_rssi = ATH_EP_RND(last_rssi, | 943 | rx_stats->rs_rssi = ATH_EP_RND(last_rssi, |
1008 | ATH_RSSI_EP_MULTIPLIER); | 944 | ATH_RSSI_EP_MULTIPLIER); |
@@ -1034,6 +970,10 @@ static int ath9k_rx_skb_preprocess(struct ath_common *common, | |||
1034 | if (!ath9k_rx_accept(common, hdr, rx_status, rx_stats, decrypt_error)) | 970 | if (!ath9k_rx_accept(common, hdr, rx_status, rx_stats, decrypt_error)) |
1035 | return -EINVAL; | 971 | return -EINVAL; |
1036 | 972 | ||
973 | /* Only use status info from the last fragment */ | ||
974 | if (rx_stats->rs_more) | ||
975 | return 0; | ||
976 | |||
1037 | ath9k_process_rssi(common, hw, hdr, rx_stats); | 977 | ath9k_process_rssi(common, hw, hdr, rx_stats); |
1038 | 978 | ||
1039 | if (ath9k_process_rate(common, hw, rx_stats, rx_status)) | 979 | if (ath9k_process_rate(common, hw, rx_stats, rx_status)) |
@@ -1635,7 +1575,7 @@ div_comb_done: | |||
1635 | int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp) | 1575 | int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp) |
1636 | { | 1576 | { |
1637 | struct ath_buf *bf; | 1577 | struct ath_buf *bf; |
1638 | struct sk_buff *skb = NULL, *requeue_skb; | 1578 | struct sk_buff *skb = NULL, *requeue_skb, *hdr_skb; |
1639 | struct ieee80211_rx_status *rxs; | 1579 | struct ieee80211_rx_status *rxs; |
1640 | struct ath_hw *ah = sc->sc_ah; | 1580 | struct ath_hw *ah = sc->sc_ah; |
1641 | struct ath_common *common = ath9k_hw_common(ah); | 1581 | struct ath_common *common = ath9k_hw_common(ah); |
@@ -1644,7 +1584,7 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp) | |||
1644 | * virtual wiphy so to account for that we iterate over the active | 1584 | * virtual wiphy so to account for that we iterate over the active |
1645 | * wiphys and find the appropriate wiphy and therefore hw. | 1585 | * wiphys and find the appropriate wiphy and therefore hw. |
1646 | */ | 1586 | */ |
1647 | struct ieee80211_hw *hw = NULL; | 1587 | struct ieee80211_hw *hw = sc->hw; |
1648 | struct ieee80211_hdr *hdr; | 1588 | struct ieee80211_hdr *hdr; |
1649 | int retval; | 1589 | int retval; |
1650 | bool decrypt_error = false; | 1590 | bool decrypt_error = false; |
@@ -1686,10 +1626,17 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp) | |||
1686 | if (!skb) | 1626 | if (!skb) |
1687 | continue; | 1627 | continue; |
1688 | 1628 | ||
1689 | hdr = (struct ieee80211_hdr *) (skb->data + rx_status_len); | 1629 | /* |
1690 | rxs = IEEE80211_SKB_RXCB(skb); | 1630 | * Take frame header from the first fragment and RX status from |
1631 | * the last one. | ||
1632 | */ | ||
1633 | if (sc->rx.frag) | ||
1634 | hdr_skb = sc->rx.frag; | ||
1635 | else | ||
1636 | hdr_skb = skb; | ||
1691 | 1637 | ||
1692 | hw = ath_get_virt_hw(sc, hdr); | 1638 | hdr = (struct ieee80211_hdr *) (hdr_skb->data + rx_status_len); |
1639 | rxs = IEEE80211_SKB_RXCB(hdr_skb); | ||
1693 | 1640 | ||
1694 | ath_debug_stat_rx(sc, &rs); | 1641 | ath_debug_stat_rx(sc, &rs); |
1695 | 1642 | ||
@@ -1698,12 +1645,12 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp) | |||
1698 | * chain it back at the queue without processing it. | 1645 | * chain it back at the queue without processing it. |
1699 | */ | 1646 | */ |
1700 | if (flush) | 1647 | if (flush) |
1701 | goto requeue; | 1648 | goto requeue_drop_frag; |
1702 | 1649 | ||
1703 | retval = ath9k_rx_skb_preprocess(common, hw, hdr, &rs, | 1650 | retval = ath9k_rx_skb_preprocess(common, hw, hdr, &rs, |
1704 | rxs, &decrypt_error); | 1651 | rxs, &decrypt_error); |
1705 | if (retval) | 1652 | if (retval) |
1706 | goto requeue; | 1653 | goto requeue_drop_frag; |
1707 | 1654 | ||
1708 | rxs->mactime = (tsf & ~0xffffffffULL) | rs.rs_tstamp; | 1655 | rxs->mactime = (tsf & ~0xffffffffULL) | rs.rs_tstamp; |
1709 | if (rs.rs_tstamp > tsf_lower && | 1656 | if (rs.rs_tstamp > tsf_lower && |
@@ -1723,7 +1670,7 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp) | |||
1723 | * skb and put it at the tail of the sc->rx.rxbuf list for | 1670 | * skb and put it at the tail of the sc->rx.rxbuf list for |
1724 | * processing. */ | 1671 | * processing. */ |
1725 | if (!requeue_skb) | 1672 | if (!requeue_skb) |
1726 | goto requeue; | 1673 | goto requeue_drop_frag; |
1727 | 1674 | ||
1728 | /* Unmap the frame */ | 1675 | /* Unmap the frame */ |
1729 | dma_unmap_single(sc->dev, bf->bf_buf_addr, | 1676 | dma_unmap_single(sc->dev, bf->bf_buf_addr, |
@@ -1734,8 +1681,9 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp) | |||
1734 | if (ah->caps.rx_status_len) | 1681 | if (ah->caps.rx_status_len) |
1735 | skb_pull(skb, ah->caps.rx_status_len); | 1682 | skb_pull(skb, ah->caps.rx_status_len); |
1736 | 1683 | ||
1737 | ath9k_rx_skb_postprocess(common, skb, &rs, | 1684 | if (!rs.rs_more) |
1738 | rxs, decrypt_error); | 1685 | ath9k_rx_skb_postprocess(common, hdr_skb, &rs, |
1686 | rxs, decrypt_error); | ||
1739 | 1687 | ||
1740 | /* We will now give hardware our shiny new allocated skb */ | 1688 | /* We will now give hardware our shiny new allocated skb */ |
1741 | bf->bf_mpdu = requeue_skb; | 1689 | bf->bf_mpdu = requeue_skb; |
@@ -1748,10 +1696,42 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp) | |||
1748 | bf->bf_mpdu = NULL; | 1696 | bf->bf_mpdu = NULL; |
1749 | bf->bf_buf_addr = 0; | 1697 | bf->bf_buf_addr = 0; |
1750 | ath_err(common, "dma_mapping_error() on RX\n"); | 1698 | ath_err(common, "dma_mapping_error() on RX\n"); |
1751 | ath_rx_send_to_mac80211(hw, sc, skb); | 1699 | ieee80211_rx(hw, skb); |
1752 | break; | 1700 | break; |
1753 | } | 1701 | } |
1754 | 1702 | ||
1703 | if (rs.rs_more) { | ||
1704 | /* | ||
1705 | * rs_more indicates chained descriptors which can be | ||
1706 | * used to link buffers together for a sort of | ||
1707 | * scatter-gather operation. | ||
1708 | */ | ||
1709 | if (sc->rx.frag) { | ||
1710 | /* too many fragments - cannot handle frame */ | ||
1711 | dev_kfree_skb_any(sc->rx.frag); | ||
1712 | dev_kfree_skb_any(skb); | ||
1713 | skb = NULL; | ||
1714 | } | ||
1715 | sc->rx.frag = skb; | ||
1716 | goto requeue; | ||
1717 | } | ||
1718 | |||
1719 | if (sc->rx.frag) { | ||
1720 | int space = skb->len - skb_tailroom(hdr_skb); | ||
1721 | |||
1722 | sc->rx.frag = NULL; | ||
1723 | |||
1724 | if (pskb_expand_head(hdr_skb, 0, space, GFP_ATOMIC) < 0) { | ||
1725 | dev_kfree_skb(skb); | ||
1726 | goto requeue_drop_frag; | ||
1727 | } | ||
1728 | |||
1729 | skb_copy_from_linear_data(skb, skb_put(hdr_skb, skb->len), | ||
1730 | skb->len); | ||
1731 | dev_kfree_skb_any(skb); | ||
1732 | skb = hdr_skb; | ||
1733 | } | ||
1734 | |||
1755 | /* | 1735 | /* |
1756 | * change the default rx antenna if rx diversity chooses the | 1736 | * change the default rx antenna if rx diversity chooses the |
1757 | * other antenna 3 times in a row. | 1737 | * other antenna 3 times in a row. |
@@ -1775,8 +1755,13 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp) | |||
1775 | if (ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) | 1755 | if (ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) |
1776 | ath_ant_comb_scan(sc, &rs); | 1756 | ath_ant_comb_scan(sc, &rs); |
1777 | 1757 | ||
1778 | ath_rx_send_to_mac80211(hw, sc, skb); | 1758 | ieee80211_rx(hw, skb); |
1779 | 1759 | ||
1760 | requeue_drop_frag: | ||
1761 | if (sc->rx.frag) { | ||
1762 | dev_kfree_skb_any(sc->rx.frag); | ||
1763 | sc->rx.frag = NULL; | ||
1764 | } | ||
1780 | requeue: | 1765 | requeue: |
1781 | if (edma) { | 1766 | if (edma) { |
1782 | list_add_tail(&bf->list, &sc->rx.rxbuf); | 1767 | list_add_tail(&bf->list, &sc->rx.rxbuf); |