aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/ath5k/base.c
diff options
context:
space:
mode:
authorBruno Randolf <br1@einfach.org>2010-06-16 06:11:51 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-06-16 14:59:02 -0400
commit8a89f063e79bcbd38d01bb25948840fe909e62cd (patch)
tree522f58cae6bcab2d1b729bd1f474150806f56d95 /drivers/net/wireless/ath/ath5k/base.c
parentb16062facbf9952d9d69621a6bf87e1188973ccd (diff)
ath5k: split descriptor handling and frame receive
Move frame reception into it's own function to have a clearer separation between buffer and descriptor handling and things that are done when we actually receive a frame. Signed-off-by: Bruno Randolf <br1@einfach.org> Acked-by: Bob Copeland <me@bobcopeland.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath/ath5k/base.c')
-rw-r--r--drivers/net/wireless/ath/ath5k/base.c149
1 files changed, 78 insertions, 71 deletions
diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
index d9df11490ab..c54d1fd67f2 100644
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -357,7 +357,6 @@ static void ath5k_txq_release(struct ath5k_softc *sc);
357static int ath5k_rx_start(struct ath5k_softc *sc); 357static int ath5k_rx_start(struct ath5k_softc *sc);
358static void ath5k_rx_stop(struct ath5k_softc *sc); 358static void ath5k_rx_stop(struct ath5k_softc *sc);
359static unsigned int ath5k_rx_decrypted(struct ath5k_softc *sc, 359static unsigned int ath5k_rx_decrypted(struct ath5k_softc *sc,
360 struct ath5k_desc *ds,
361 struct sk_buff *skb, 360 struct sk_buff *skb,
362 struct ath5k_rx_status *rs); 361 struct ath5k_rx_status *rs);
363static void ath5k_tasklet_rx(unsigned long data); 362static void ath5k_tasklet_rx(unsigned long data);
@@ -1732,8 +1731,8 @@ ath5k_rx_stop(struct ath5k_softc *sc)
1732} 1731}
1733 1732
1734static unsigned int 1733static unsigned int
1735ath5k_rx_decrypted(struct ath5k_softc *sc, struct ath5k_desc *ds, 1734ath5k_rx_decrypted(struct ath5k_softc *sc, struct sk_buff *skb,
1736 struct sk_buff *skb, struct ath5k_rx_status *rs) 1735 struct ath5k_rx_status *rs)
1737{ 1736{
1738 struct ath5k_hw *ah = sc->ah; 1737 struct ath5k_hw *ah = sc->ah;
1739 struct ath_common *common = ath5k_hw_common(ah); 1738 struct ath_common *common = ath5k_hw_common(ah);
@@ -1900,9 +1899,83 @@ static int ath5k_remove_padding(struct sk_buff *skb)
1900} 1899}
1901 1900
1902static void 1901static void
1903ath5k_tasklet_rx(unsigned long data) 1902ath5k_receive_frame(struct ath5k_softc *sc, struct sk_buff *skb,
1903 struct ath5k_rx_status *rs)
1904{ 1904{
1905 struct ieee80211_rx_status *rxs; 1905 struct ieee80211_rx_status *rxs;
1906
1907 /* The MAC header is padded to have 32-bit boundary if the
1908 * packet payload is non-zero. The general calculation for
1909 * padsize would take into account odd header lengths:
1910 * padsize = (4 - hdrlen % 4) % 4; However, since only
1911 * even-length headers are used, padding can only be 0 or 2
1912 * bytes and we can optimize this a bit. In addition, we must
1913 * not try to remove padding from short control frames that do
1914 * not have payload. */
1915 ath5k_remove_padding(skb);
1916
1917 rxs = IEEE80211_SKB_RXCB(skb);
1918
1919 rxs->flag = 0;
1920 if (unlikely(rs->rs_status & AR5K_RXERR_MIC))
1921 rxs->flag |= RX_FLAG_MMIC_ERROR;
1922
1923 /*
1924 * always extend the mac timestamp, since this information is
1925 * also needed for proper IBSS merging.
1926 *
1927 * XXX: it might be too late to do it here, since rs_tstamp is
1928 * 15bit only. that means TSF extension has to be done within
1929 * 32768usec (about 32ms). it might be necessary to move this to
1930 * the interrupt handler, like it is done in madwifi.
1931 *
1932 * Unfortunately we don't know when the hardware takes the rx
1933 * timestamp (beginning of phy frame, data frame, end of rx?).
1934 * The only thing we know is that it is hardware specific...
1935 * On AR5213 it seems the rx timestamp is at the end of the
1936 * frame, but i'm not sure.
1937 *
1938 * NOTE: mac80211 defines mactime at the beginning of the first
1939 * data symbol. Since we don't have any time references it's
1940 * impossible to comply to that. This affects IBSS merge only
1941 * right now, so it's not too bad...
1942 */
1943 rxs->mactime = ath5k_extend_tsf(sc->ah, rs->rs_tstamp);
1944 rxs->flag |= RX_FLAG_TSFT;
1945
1946 rxs->freq = sc->curchan->center_freq;
1947 rxs->band = sc->curband->band;
1948
1949 rxs->signal = sc->ah->ah_noise_floor + rs->rs_rssi;
1950
1951 rxs->antenna = rs->rs_antenna;
1952
1953 if (rs->rs_antenna > 0 && rs->rs_antenna < 5)
1954 sc->stats.antenna_rx[rs->rs_antenna]++;
1955 else
1956 sc->stats.antenna_rx[0]++; /* invalid */
1957
1958 rxs->rate_idx = ath5k_hw_to_driver_rix(sc, rs->rs_rate);
1959 rxs->flag |= ath5k_rx_decrypted(sc, skb, rs);
1960
1961 if (rxs->rate_idx >= 0 && rs->rs_rate ==
1962 sc->curband->bitrates[rxs->rate_idx].hw_value_short)
1963 rxs->flag |= RX_FLAG_SHORTPRE;
1964
1965 ath5k_debug_dump_skb(sc, skb, "RX ", 0);
1966
1967 ath5k_update_beacon_rssi(sc, skb, rs->rs_rssi);
1968
1969 /* check beacons in IBSS mode */
1970 if (sc->opmode == NL80211_IFTYPE_ADHOC)
1971 ath5k_check_ibss_tsf(sc, skb, rxs);
1972
1973 ieee80211_rx(sc->hw, skb);
1974}
1975
1976static void
1977ath5k_tasklet_rx(unsigned long data)
1978{
1906 struct ath5k_rx_status rs = {}; 1979 struct ath5k_rx_status rs = {};
1907 struct sk_buff *skb, *next_skb; 1980 struct sk_buff *skb, *next_skb;
1908 dma_addr_t next_skb_addr; 1981 dma_addr_t next_skb_addr;
@@ -1912,7 +1985,6 @@ ath5k_tasklet_rx(unsigned long data)
1912 struct ath5k_buf *bf; 1985 struct ath5k_buf *bf;
1913 struct ath5k_desc *ds; 1986 struct ath5k_desc *ds;
1914 int ret; 1987 int ret;
1915 int rx_flag;
1916 1988
1917 spin_lock(&sc->rxbuflock); 1989 spin_lock(&sc->rxbuflock);
1918 if (list_empty(&sc->rxbuf)) { 1990 if (list_empty(&sc->rxbuf)) {
@@ -1920,8 +1992,6 @@ ath5k_tasklet_rx(unsigned long data)
1920 goto unlock; 1992 goto unlock;
1921 } 1993 }
1922 do { 1994 do {
1923 rx_flag = 0;
1924
1925 bf = list_first_entry(&sc->rxbuf, struct ath5k_buf, list); 1995 bf = list_first_entry(&sc->rxbuf, struct ath5k_buf, list);
1926 BUG_ON(bf->skb == NULL); 1996 BUG_ON(bf->skb == NULL);
1927 skb = bf->skb; 1997 skb = bf->skb;
@@ -1970,7 +2040,6 @@ ath5k_tasklet_rx(unsigned long data)
1970 goto accept; 2040 goto accept;
1971 } 2041 }
1972 if (rs.rs_status & AR5K_RXERR_MIC) { 2042 if (rs.rs_status & AR5K_RXERR_MIC) {
1973 rx_flag |= RX_FLAG_MMIC_ERROR;
1974 sc->stats.rxerr_mic++; 2043 sc->stats.rxerr_mic++;
1975 goto accept; 2044 goto accept;
1976 } 2045 }
@@ -2001,69 +2070,7 @@ accept:
2001 PCI_DMA_FROMDEVICE); 2070 PCI_DMA_FROMDEVICE);
2002 skb_put(skb, rs.rs_datalen); 2071 skb_put(skb, rs.rs_datalen);
2003 2072
2004 /* The MAC header is padded to have 32-bit boundary if the 2073 ath5k_receive_frame(sc, skb, &rs);
2005 * packet payload is non-zero. The general calculation for
2006 * padsize would take into account odd header lengths:
2007 * padsize = (4 - hdrlen % 4) % 4; However, since only
2008 * even-length headers are used, padding can only be 0 or 2
2009 * bytes and we can optimize this a bit. In addition, we must
2010 * not try to remove padding from short control frames that do
2011 * not have payload. */
2012 ath5k_remove_padding(skb);
2013
2014 rxs = IEEE80211_SKB_RXCB(skb);
2015
2016 /*
2017 * always extend the mac timestamp, since this information is
2018 * also needed for proper IBSS merging.
2019 *
2020 * XXX: it might be too late to do it here, since rs_tstamp is
2021 * 15bit only. that means TSF extension has to be done within
2022 * 32768usec (about 32ms). it might be necessary to move this to
2023 * the interrupt handler, like it is done in madwifi.
2024 *
2025 * Unfortunately we don't know when the hardware takes the rx
2026 * timestamp (beginning of phy frame, data frame, end of rx?).
2027 * The only thing we know is that it is hardware specific...
2028 * On AR5213 it seems the rx timestamp is at the end of the
2029 * frame, but i'm not sure.
2030 *
2031 * NOTE: mac80211 defines mactime at the beginning of the first
2032 * data symbol. Since we don't have any time references it's
2033 * impossible to comply to that. This affects IBSS merge only
2034 * right now, so it's not too bad...
2035 */
2036 rxs->mactime = ath5k_extend_tsf(sc->ah, rs.rs_tstamp);
2037 rxs->flag = rx_flag | RX_FLAG_TSFT;
2038
2039 rxs->freq = sc->curchan->center_freq;
2040 rxs->band = sc->curband->band;
2041
2042 rxs->signal = sc->ah->ah_noise_floor + rs.rs_rssi;
2043
2044 rxs->antenna = rs.rs_antenna;
2045
2046 if (rs.rs_antenna > 0 && rs.rs_antenna < 5)
2047 sc->stats.antenna_rx[rs.rs_antenna]++;
2048 else
2049 sc->stats.antenna_rx[0]++; /* invalid */
2050
2051 rxs->rate_idx = ath5k_hw_to_driver_rix(sc, rs.rs_rate);
2052 rxs->flag |= ath5k_rx_decrypted(sc, ds, skb, &rs);
2053
2054 if (rxs->rate_idx >= 0 && rs.rs_rate ==
2055 sc->curband->bitrates[rxs->rate_idx].hw_value_short)
2056 rxs->flag |= RX_FLAG_SHORTPRE;
2057
2058 ath5k_debug_dump_skb(sc, skb, "RX ", 0);
2059
2060 ath5k_update_beacon_rssi(sc, skb, rs.rs_rssi);
2061
2062 /* check beacons in IBSS mode */
2063 if (sc->opmode == NL80211_IFTYPE_ADHOC)
2064 ath5k_check_ibss_tsf(sc, skb, rxs);
2065
2066 ieee80211_rx(sc->hw, skb);
2067 2074
2068 bf->skb = next_skb; 2075 bf->skb = next_skb;
2069 bf->skbaddr = next_skb_addr; 2076 bf->skbaddr = next_skb_addr;