recv.c (57b8628bb0ac4e47c806e45c5bbd89282e93869b) recv.c (990e08a0f6115ce93b480325a575b535c92513ee)
1/*
2 * Copyright (c) 2008-2011 Atheros Communications Inc.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES

--- 810 unchanged lines hidden (view full) ---

819 /*
820 * Key miss events are only relevant for pairwise keys where the
821 * descriptor does contain a valid key index. This has been observed
822 * mostly with CCMP encryption.
823 */
824 if (rx_stats->rs_keyix == ATH9K_RXKEYIX_INVALID)
825 rx_stats->rs_status &= ~ATH9K_RXERR_KEYMISS;
826
1/*
2 * Copyright (c) 2008-2011 Atheros Communications Inc.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES

--- 810 unchanged lines hidden (view full) ---

819 /*
820 * Key miss events are only relevant for pairwise keys where the
821 * descriptor does contain a valid key index. This has been observed
822 * mostly with CCMP encryption.
823 */
824 if (rx_stats->rs_keyix == ATH9K_RXKEYIX_INVALID)
825 rx_stats->rs_status &= ~ATH9K_RXERR_KEYMISS;
826
827 if (!rx_stats->rs_datalen)
827 if (!rx_stats->rs_datalen) {
828 RX_STAT_INC(rx_len_err);
828 return false;
829 return false;
830 }
831
829 /*
830 * rs_status follows rs_datalen so if rs_datalen is too large
831 * we can take a hint that hardware corrupted it, so ignore
832 * those frames.
833 */
832 /*
833 * rs_status follows rs_datalen so if rs_datalen is too large
834 * we can take a hint that hardware corrupted it, so ignore
835 * those frames.
836 */
834 if (rx_stats->rs_datalen > (common->rx_bufsize - rx_status_len))
837 if (rx_stats->rs_datalen > (common->rx_bufsize - rx_status_len)) {
838 RX_STAT_INC(rx_len_err);
835 return false;
839 return false;
840 }
836
837 /* Only use error bits from the last fragment */
838 if (rx_stats->rs_more)
839 return true;
840
841 mic_error = is_valid_tkip && !ieee80211_is_ctl(fc) &&
842 !ieee80211_has_morefrags(fc) &&
843 !(le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG) &&

--- 53 unchanged lines hidden (view full) ---

897static int ath9k_process_rate(struct ath_common *common,
898 struct ieee80211_hw *hw,
899 struct ath_rx_status *rx_stats,
900 struct ieee80211_rx_status *rxs)
901{
902 struct ieee80211_supported_band *sband;
903 enum ieee80211_band band;
904 unsigned int i = 0;
841
842 /* Only use error bits from the last fragment */
843 if (rx_stats->rs_more)
844 return true;
845
846 mic_error = is_valid_tkip && !ieee80211_is_ctl(fc) &&
847 !ieee80211_has_morefrags(fc) &&
848 !(le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG) &&

--- 53 unchanged lines hidden (view full) ---

902static int ath9k_process_rate(struct ath_common *common,
903 struct ieee80211_hw *hw,
904 struct ath_rx_status *rx_stats,
905 struct ieee80211_rx_status *rxs)
906{
907 struct ieee80211_supported_band *sband;
908 enum ieee80211_band band;
909 unsigned int i = 0;
910 struct ath_softc __maybe_unused *sc = common->priv;
905
906 band = hw->conf.channel->band;
907 sband = hw->wiphy->bands[band];
908
909 if (rx_stats->rs_rate & 0x80) {
910 /* HT rate */
911 rxs->flag |= RX_FLAG_HT;
912 if (rx_stats->rs_flags & ATH9K_RX_2040)

--- 18 unchanged lines hidden (view full) ---

931
932 /*
933 * No valid hardware bitrate found -- we should not get here
934 * because hardware has already validated this frame as OK.
935 */
936 ath_dbg(common, ANY,
937 "unsupported hw bitrate detected 0x%02x using 1 Mbit\n",
938 rx_stats->rs_rate);
911
912 band = hw->conf.channel->band;
913 sband = hw->wiphy->bands[band];
914
915 if (rx_stats->rs_rate & 0x80) {
916 /* HT rate */
917 rxs->flag |= RX_FLAG_HT;
918 if (rx_stats->rs_flags & ATH9K_RX_2040)

--- 18 unchanged lines hidden (view full) ---

937
938 /*
939 * No valid hardware bitrate found -- we should not get here
940 * because hardware has already validated this frame as OK.
941 */
942 ath_dbg(common, ANY,
943 "unsupported hw bitrate detected 0x%02x using 1 Mbit\n",
944 rx_stats->rs_rate);
939
945 RX_STAT_INC(rx_rate_err);
940 return -EINVAL;
941}
942
943static void ath9k_process_rssi(struct ath_common *common,
944 struct ieee80211_hw *hw,
945 struct ieee80211_hdr *hdr,
946 struct ath_rx_status *rx_stats)
947{

--- 870 unchanged lines hidden (view full) ---

1818 */
1819 if (sc->rx.frag)
1820 hdr_skb = sc->rx.frag;
1821 else
1822 hdr_skb = skb;
1823
1824 hdr = (struct ieee80211_hdr *) (hdr_skb->data + rx_status_len);
1825 rxs = IEEE80211_SKB_RXCB(hdr_skb);
946 return -EINVAL;
947}
948
949static void ath9k_process_rssi(struct ath_common *common,
950 struct ieee80211_hw *hw,
951 struct ieee80211_hdr *hdr,
952 struct ath_rx_status *rx_stats)
953{

--- 870 unchanged lines hidden (view full) ---

1824 */
1825 if (sc->rx.frag)
1826 hdr_skb = sc->rx.frag;
1827 else
1828 hdr_skb = skb;
1829
1830 hdr = (struct ieee80211_hdr *) (hdr_skb->data + rx_status_len);
1831 rxs = IEEE80211_SKB_RXCB(hdr_skb);
1826 if (ieee80211_is_beacon(hdr->frame_control) &&
1827 !is_zero_ether_addr(common->curbssid) &&
1828 !compare_ether_addr(hdr->addr3, common->curbssid))
1829 rs.is_mybeacon = true;
1832 if (ieee80211_is_beacon(hdr->frame_control)) {
1833 RX_STAT_INC(rx_beacons);
1834 if (!is_zero_ether_addr(common->curbssid) &&
1835 !compare_ether_addr(hdr->addr3, common->curbssid))
1836 rs.is_mybeacon = true;
1837 else
1838 rs.is_mybeacon = false;
1839 }
1830 else
1831 rs.is_mybeacon = false;
1832
1833 ath_debug_stat_rx(sc, &rs);
1834
1835 /*
1836 * If we're asked to flush receive queue, directly
1837 * chain it back at the queue without processing it.
1838 */
1840 else
1841 rs.is_mybeacon = false;
1842
1843 ath_debug_stat_rx(sc, &rs);
1844
1845 /*
1846 * If we're asked to flush receive queue, directly
1847 * chain it back at the queue without processing it.
1848 */
1839 if (sc->sc_flags & SC_OP_RXFLUSH)
1849 if (sc->sc_flags & SC_OP_RXFLUSH) {
1850 RX_STAT_INC(rx_drop_rxflush);
1840 goto requeue_drop_frag;
1851 goto requeue_drop_frag;
1852 }
1841
1842 memset(rxs, 0, sizeof(struct ieee80211_rx_status));
1843
1844 rxs->mactime = (tsf & ~0xffffffffULL) | rs.rs_tstamp;
1845 if (rs.rs_tstamp > tsf_lower &&
1846 unlikely(rs.rs_tstamp - tsf_lower > 0x10000000))
1847 rxs->mactime -= 0x100000000ULL;
1848
1849 if (rs.rs_tstamp < tsf_lower &&
1850 unlikely(tsf_lower - rs.rs_tstamp > 0x10000000))
1851 rxs->mactime += 0x100000000ULL;
1852
1853 retval = ath9k_rx_skb_preprocess(common, hw, hdr, &rs,
1854 rxs, &decrypt_error);
1855 if (retval)
1856 goto requeue_drop_frag;
1857
1853
1854 memset(rxs, 0, sizeof(struct ieee80211_rx_status));
1855
1856 rxs->mactime = (tsf & ~0xffffffffULL) | rs.rs_tstamp;
1857 if (rs.rs_tstamp > tsf_lower &&
1858 unlikely(rs.rs_tstamp - tsf_lower > 0x10000000))
1859 rxs->mactime -= 0x100000000ULL;
1860
1861 if (rs.rs_tstamp < tsf_lower &&
1862 unlikely(tsf_lower - rs.rs_tstamp > 0x10000000))
1863 rxs->mactime += 0x100000000ULL;
1864
1865 retval = ath9k_rx_skb_preprocess(common, hw, hdr, &rs,
1866 rxs, &decrypt_error);
1867 if (retval)
1868 goto requeue_drop_frag;
1869
1870 if (rs.is_mybeacon) {
1871 sc->hw_busy_count = 0;
1872 ath_start_rx_poll(sc, 3);
1873 }
1858 /* Ensure we always have an skb to requeue once we are done
1859 * processing the current buffer's skb */
1860 requeue_skb = ath_rxbuf_alloc(common, common->rx_bufsize, GFP_ATOMIC);
1861
1862 /* If there is no memory we ignore the current RX'd frame,
1863 * tell hardware it can give us a new frame using the old
1864 * skb and put it at the tail of the sc->rx.rxbuf list for
1865 * processing. */
1874 /* Ensure we always have an skb to requeue once we are done
1875 * processing the current buffer's skb */
1876 requeue_skb = ath_rxbuf_alloc(common, common->rx_bufsize, GFP_ATOMIC);
1877
1878 /* If there is no memory we ignore the current RX'd frame,
1879 * tell hardware it can give us a new frame using the old
1880 * skb and put it at the tail of the sc->rx.rxbuf list for
1881 * processing. */
1866 if (!requeue_skb)
1882 if (!requeue_skb) {
1883 RX_STAT_INC(rx_oom_err);
1867 goto requeue_drop_frag;
1884 goto requeue_drop_frag;
1885 }
1868
1869 /* Unmap the frame */
1870 dma_unmap_single(sc->dev, bf->bf_buf_addr,
1871 common->rx_bufsize,
1872 dma_type);
1873
1874 skb_put(skb, rs.rs_datalen + ah->caps.rx_status_len);
1875 if (ah->caps.rx_status_len)

--- 14 unchanged lines hidden (view full) ---

1890 bf->bf_mpdu = NULL;
1891 bf->bf_buf_addr = 0;
1892 ath_err(common, "dma_mapping_error() on RX\n");
1893 ieee80211_rx(hw, skb);
1894 break;
1895 }
1896
1897 if (rs.rs_more) {
1886
1887 /* Unmap the frame */
1888 dma_unmap_single(sc->dev, bf->bf_buf_addr,
1889 common->rx_bufsize,
1890 dma_type);
1891
1892 skb_put(skb, rs.rs_datalen + ah->caps.rx_status_len);
1893 if (ah->caps.rx_status_len)

--- 14 unchanged lines hidden (view full) ---

1908 bf->bf_mpdu = NULL;
1909 bf->bf_buf_addr = 0;
1910 ath_err(common, "dma_mapping_error() on RX\n");
1911 ieee80211_rx(hw, skb);
1912 break;
1913 }
1914
1915 if (rs.rs_more) {
1916 RX_STAT_INC(rx_frags);
1898 /*
1899 * rs_more indicates chained descriptors which can be
1900 * used to link buffers together for a sort of
1901 * scatter-gather operation.
1902 */
1903 if (sc->rx.frag) {
1904 /* too many fragments - cannot handle frame */
1905 dev_kfree_skb_any(sc->rx.frag);
1906 dev_kfree_skb_any(skb);
1917 /*
1918 * rs_more indicates chained descriptors which can be
1919 * used to link buffers together for a sort of
1920 * scatter-gather operation.
1921 */
1922 if (sc->rx.frag) {
1923 /* too many fragments - cannot handle frame */
1924 dev_kfree_skb_any(sc->rx.frag);
1925 dev_kfree_skb_any(skb);
1926 RX_STAT_INC(rx_too_many_frags_err);
1907 skb = NULL;
1908 }
1909 sc->rx.frag = skb;
1910 goto requeue;
1911 }
1912
1913 if (sc->rx.frag) {
1914 int space = skb->len - skb_tailroom(hdr_skb);
1915
1916 if (pskb_expand_head(hdr_skb, 0, space, GFP_ATOMIC) < 0) {
1917 dev_kfree_skb(skb);
1927 skb = NULL;
1928 }
1929 sc->rx.frag = skb;
1930 goto requeue;
1931 }
1932
1933 if (sc->rx.frag) {
1934 int space = skb->len - skb_tailroom(hdr_skb);
1935
1936 if (pskb_expand_head(hdr_skb, 0, space, GFP_ATOMIC) < 0) {
1937 dev_kfree_skb(skb);
1938 RX_STAT_INC(rx_oom_err);
1918 goto requeue_drop_frag;
1919 }
1920
1921 sc->rx.frag = NULL;
1922
1923 skb_copy_from_linear_data(skb, skb_put(hdr_skb, skb->len),
1924 skb->len);
1925 dev_kfree_skb_any(skb);

--- 62 unchanged lines hidden ---
1939 goto requeue_drop_frag;
1940 }
1941
1942 sc->rx.frag = NULL;
1943
1944 skb_copy_from_linear_data(skb, skb_put(hdr_skb, skb->len),
1945 skb->len);
1946 dev_kfree_skb_any(skb);

--- 62 unchanged lines hidden ---