aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlegacy/4965.c
diff options
context:
space:
mode:
authorStanislaw Gruszka <sgruszka@redhat.com>2012-02-13 05:23:13 -0500
committerJohn W. Linville <linville@tuxdriver.com>2012-02-22 14:51:13 -0500
commit3dfea27d103e9913698cf1a2c86745a74c7c556b (patch)
tree4794a2ca538aef954ae65a913a1b9e941f36c9be /drivers/net/wireless/iwlegacy/4965.c
parent93a984a4eec83f45abddb80724da7dcb85b4db6b (diff)
iwlegacy: gather all 4965 handlers in one place
Handers belongs logically into 4965-mac.c file. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlegacy/4965.c')
-rw-r--r--drivers/net/wireless/iwlegacy/4965.c312
1 files changed, 0 insertions, 312 deletions
diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c
index aea84bf4e935..cf49a7af6c6e 100644
--- a/drivers/net/wireless/iwlegacy/4965.c
+++ b/drivers/net/wireless/iwlegacy/4965.c
@@ -1737,317 +1737,6 @@ il4965_build_addsta_hcmd(const struct il_addsta_cmd *cmd, u8 * data)
1737 return (u16) sizeof(struct il4965_addsta_cmd); 1737 return (u16) sizeof(struct il4965_addsta_cmd);
1738} 1738}
1739 1739
1740static inline u32
1741il4965_get_scd_ssn(struct il4965_tx_resp *tx_resp)
1742{
1743 return le32_to_cpup(&tx_resp->u.status + tx_resp->frame_count) & MAX_SN;
1744}
1745
1746static inline u32
1747il4965_tx_status_to_mac80211(u32 status)
1748{
1749 status &= TX_STATUS_MSK;
1750
1751 switch (status) {
1752 case TX_STATUS_SUCCESS:
1753 case TX_STATUS_DIRECT_DONE:
1754 return IEEE80211_TX_STAT_ACK;
1755 case TX_STATUS_FAIL_DEST_PS:
1756 return IEEE80211_TX_STAT_TX_FILTERED;
1757 default:
1758 return 0;
1759 }
1760}
1761
1762static inline bool
1763il4965_is_tx_success(u32 status)
1764{
1765 status &= TX_STATUS_MSK;
1766 return (status == TX_STATUS_SUCCESS || status == TX_STATUS_DIRECT_DONE);
1767}
1768
1769/**
1770 * il4965_tx_status_reply_tx - Handle Tx response for frames in aggregation queue
1771 */
1772static int
1773il4965_tx_status_reply_tx(struct il_priv *il, struct il_ht_agg *agg,
1774 struct il4965_tx_resp *tx_resp, int txq_id,
1775 u16 start_idx)
1776{
1777 u16 status;
1778 struct agg_tx_status *frame_status = tx_resp->u.agg_status;
1779 struct ieee80211_tx_info *info = NULL;
1780 struct ieee80211_hdr *hdr = NULL;
1781 u32 rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags);
1782 int i, sh, idx;
1783 u16 seq;
1784 if (agg->wait_for_ba)
1785 D_TX_REPLY("got tx response w/o block-ack\n");
1786
1787 agg->frame_count = tx_resp->frame_count;
1788 agg->start_idx = start_idx;
1789 agg->rate_n_flags = rate_n_flags;
1790 agg->bitmap = 0;
1791
1792 /* num frames attempted by Tx command */
1793 if (agg->frame_count == 1) {
1794 /* Only one frame was attempted; no block-ack will arrive */
1795 status = le16_to_cpu(frame_status[0].status);
1796 idx = start_idx;
1797
1798 D_TX_REPLY("FrameCnt = %d, StartIdx=%d idx=%d\n",
1799 agg->frame_count, agg->start_idx, idx);
1800
1801 info = IEEE80211_SKB_CB(il->txq[txq_id].skbs[idx]);
1802 info->status.rates[0].count = tx_resp->failure_frame + 1;
1803 info->flags &= ~IEEE80211_TX_CTL_AMPDU;
1804 info->flags |= il4965_tx_status_to_mac80211(status);
1805 il4965_hwrate_to_tx_control(il, rate_n_flags, info);
1806
1807 D_TX_REPLY("1 Frame 0x%x failure :%d\n", status & 0xff,
1808 tx_resp->failure_frame);
1809 D_TX_REPLY("Rate Info rate_n_flags=%x\n", rate_n_flags);
1810
1811 agg->wait_for_ba = 0;
1812 } else {
1813 /* Two or more frames were attempted; expect block-ack */
1814 u64 bitmap = 0;
1815 int start = agg->start_idx;
1816 struct sk_buff *skb;
1817
1818 /* Construct bit-map of pending frames within Tx win */
1819 for (i = 0; i < agg->frame_count; i++) {
1820 u16 sc;
1821 status = le16_to_cpu(frame_status[i].status);
1822 seq = le16_to_cpu(frame_status[i].sequence);
1823 idx = SEQ_TO_IDX(seq);
1824 txq_id = SEQ_TO_QUEUE(seq);
1825
1826 if (status &
1827 (AGG_TX_STATE_FEW_BYTES_MSK |
1828 AGG_TX_STATE_ABORT_MSK))
1829 continue;
1830
1831 D_TX_REPLY("FrameCnt = %d, txq_id=%d idx=%d\n",
1832 agg->frame_count, txq_id, idx);
1833
1834 skb = il->txq[txq_id].skbs[idx];
1835 if (WARN_ON_ONCE(skb == NULL))
1836 return -1;
1837 hdr = (struct ieee80211_hdr *) skb->data;
1838
1839 sc = le16_to_cpu(hdr->seq_ctrl);
1840 if (idx != (SEQ_TO_SN(sc) & 0xff)) {
1841 IL_ERR("BUG_ON idx doesn't match seq control"
1842 " idx=%d, seq_idx=%d, seq=%d\n", idx,
1843 SEQ_TO_SN(sc), hdr->seq_ctrl);
1844 return -1;
1845 }
1846
1847 D_TX_REPLY("AGG Frame i=%d idx %d seq=%d\n", i, idx,
1848 SEQ_TO_SN(sc));
1849
1850 sh = idx - start;
1851 if (sh > 64) {
1852 sh = (start - idx) + 0xff;
1853 bitmap = bitmap << sh;
1854 sh = 0;
1855 start = idx;
1856 } else if (sh < -64)
1857 sh = 0xff - (start - idx);
1858 else if (sh < 0) {
1859 sh = start - idx;
1860 start = idx;
1861 bitmap = bitmap << sh;
1862 sh = 0;
1863 }
1864 bitmap |= 1ULL << sh;
1865 D_TX_REPLY("start=%d bitmap=0x%llx\n", start,
1866 (unsigned long long)bitmap);
1867 }
1868
1869 agg->bitmap = bitmap;
1870 agg->start_idx = start;
1871 D_TX_REPLY("Frames %d start_idx=%d bitmap=0x%llx\n",
1872 agg->frame_count, agg->start_idx,
1873 (unsigned long long)agg->bitmap);
1874
1875 if (bitmap)
1876 agg->wait_for_ba = 1;
1877 }
1878 return 0;
1879}
1880
1881static u8
1882il4965_find_station(struct il_priv *il, const u8 * addr)
1883{
1884 int i;
1885 int start = 0;
1886 int ret = IL_INVALID_STATION;
1887 unsigned long flags;
1888
1889 if ((il->iw_mode == NL80211_IFTYPE_ADHOC))
1890 start = IL_STA_ID;
1891
1892 if (is_broadcast_ether_addr(addr))
1893 return il->hw_params.bcast_id;
1894
1895 spin_lock_irqsave(&il->sta_lock, flags);
1896 for (i = start; i < il->hw_params.max_stations; i++)
1897 if (il->stations[i].used &&
1898 (!compare_ether_addr(il->stations[i].sta.sta.addr, addr))) {
1899 ret = i;
1900 goto out;
1901 }
1902
1903 D_ASSOC("can not find STA %pM total %d\n", addr, il->num_stations);
1904
1905out:
1906 /*
1907 * It may be possible that more commands interacting with stations
1908 * arrive before we completed processing the adding of
1909 * station
1910 */
1911 if (ret != IL_INVALID_STATION &&
1912 (!(il->stations[ret].used & IL_STA_UCODE_ACTIVE) ||
1913 ((il->stations[ret].used & IL_STA_UCODE_ACTIVE) &&
1914 (il->stations[ret].used & IL_STA_UCODE_INPROGRESS)))) {
1915 IL_ERR("Requested station info for sta %d before ready.\n",
1916 ret);
1917 ret = IL_INVALID_STATION;
1918 }
1919 spin_unlock_irqrestore(&il->sta_lock, flags);
1920 return ret;
1921}
1922
1923static int
1924il4965_get_ra_sta_id(struct il_priv *il, struct ieee80211_hdr *hdr)
1925{
1926 if (il->iw_mode == NL80211_IFTYPE_STATION) {
1927 return IL_AP_ID;
1928 } else {
1929 u8 *da = ieee80211_get_DA(hdr);
1930 return il4965_find_station(il, da);
1931 }
1932}
1933
1934/**
1935 * il4965_hdl_tx - Handle standard (non-aggregation) Tx response
1936 */
1937static void
1938il4965_hdl_tx(struct il_priv *il, struct il_rx_buf *rxb)
1939{
1940 struct il_rx_pkt *pkt = rxb_addr(rxb);
1941 u16 sequence = le16_to_cpu(pkt->hdr.sequence);
1942 int txq_id = SEQ_TO_QUEUE(sequence);
1943 int idx = SEQ_TO_IDX(sequence);
1944 struct il_tx_queue *txq = &il->txq[txq_id];
1945 struct sk_buff *skb;
1946 struct ieee80211_hdr *hdr;
1947 struct ieee80211_tx_info *info;
1948 struct il4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0];
1949 u32 status = le32_to_cpu(tx_resp->u.status);
1950 int uninitialized_var(tid);
1951 int sta_id;
1952 int freed;
1953 u8 *qc = NULL;
1954 unsigned long flags;
1955
1956 if (idx >= txq->q.n_bd || il_queue_used(&txq->q, idx) == 0) {
1957 IL_ERR("Read idx for DMA queue txq_id (%d) idx %d "
1958 "is out of range [0-%d] %d %d\n", txq_id, idx,
1959 txq->q.n_bd, txq->q.write_ptr, txq->q.read_ptr);
1960 return;
1961 }
1962
1963 txq->time_stamp = jiffies;
1964
1965 skb = txq->skbs[txq->q.read_ptr];
1966 info = IEEE80211_SKB_CB(skb);
1967 memset(&info->status, 0, sizeof(info->status));
1968
1969 hdr = (struct ieee80211_hdr *) skb->data;
1970 if (ieee80211_is_data_qos(hdr->frame_control)) {
1971 qc = ieee80211_get_qos_ctl(hdr);
1972 tid = qc[0] & 0xf;
1973 }
1974
1975 sta_id = il4965_get_ra_sta_id(il, hdr);
1976 if (txq->sched_retry && unlikely(sta_id == IL_INVALID_STATION)) {
1977 IL_ERR("Station not known\n");
1978 return;
1979 }
1980
1981 spin_lock_irqsave(&il->sta_lock, flags);
1982 if (txq->sched_retry) {
1983 const u32 scd_ssn = il4965_get_scd_ssn(tx_resp);
1984 struct il_ht_agg *agg = NULL;
1985 WARN_ON(!qc);
1986
1987 agg = &il->stations[sta_id].tid[tid].agg;
1988
1989 il4965_tx_status_reply_tx(il, agg, tx_resp, txq_id, idx);
1990
1991 /* check if BAR is needed */
1992 if ((tx_resp->frame_count == 1) &&
1993 !il4965_is_tx_success(status))
1994 info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK;
1995
1996 if (txq->q.read_ptr != (scd_ssn & 0xff)) {
1997 idx = il_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd);
1998 D_TX_REPLY("Retry scheduler reclaim scd_ssn "
1999 "%d idx %d\n", scd_ssn, idx);
2000 freed = il4965_tx_queue_reclaim(il, txq_id, idx);
2001 if (qc)
2002 il4965_free_tfds_in_queue(il, sta_id, tid,
2003 freed);
2004
2005 if (il->mac80211_registered &&
2006 il_queue_space(&txq->q) > txq->q.low_mark &&
2007 agg->state != IL_EMPTYING_HW_QUEUE_DELBA)
2008 il_wake_queue(il, txq);
2009 }
2010 } else {
2011 info->status.rates[0].count = tx_resp->failure_frame + 1;
2012 info->flags |= il4965_tx_status_to_mac80211(status);
2013 il4965_hwrate_to_tx_control(il,
2014 le32_to_cpu(tx_resp->rate_n_flags),
2015 info);
2016
2017 D_TX_REPLY("TXQ %d status %s (0x%08x) "
2018 "rate_n_flags 0x%x retries %d\n", txq_id,
2019 il4965_get_tx_fail_reason(status), status,
2020 le32_to_cpu(tx_resp->rate_n_flags),
2021 tx_resp->failure_frame);
2022
2023 freed = il4965_tx_queue_reclaim(il, txq_id, idx);
2024 if (qc && likely(sta_id != IL_INVALID_STATION))
2025 il4965_free_tfds_in_queue(il, sta_id, tid, freed);
2026 else if (sta_id == IL_INVALID_STATION)
2027 D_TX_REPLY("Station not known\n");
2028
2029 if (il->mac80211_registered &&
2030 il_queue_space(&txq->q) > txq->q.low_mark)
2031 il_wake_queue(il, txq);
2032 }
2033 if (qc && likely(sta_id != IL_INVALID_STATION))
2034 il4965_txq_check_empty(il, sta_id, tid, txq_id);
2035
2036 il4965_check_abort_status(il, tx_resp->frame_count, status);
2037
2038 spin_unlock_irqrestore(&il->sta_lock, flags);
2039}
2040
2041/* Set up 4965-specific Rx frame reply handlers */
2042static void
2043il4965_handler_setup(struct il_priv *il)
2044{
2045 /* Legacy Rx frames */
2046 il->handlers[N_RX] = il4965_hdl_rx;
2047 /* Tx response */
2048 il->handlers[C_TX] = il4965_hdl_tx;
2049}
2050
2051static struct il_hcmd_ops il4965_hcmd = { 1740static struct il_hcmd_ops il4965_hcmd = {
2052 .rxon_assoc = il4965_send_rxon_assoc, 1741 .rxon_assoc = il4965_send_rxon_assoc,
2053 .commit_rxon = il4965_commit_rxon, 1742 .commit_rxon = il4965_commit_rxon,
@@ -2205,7 +1894,6 @@ static struct il_lib_ops il4965_lib = {
2205 .txq_attach_buf_to_tfd = il4965_hw_txq_attach_buf_to_tfd, 1894 .txq_attach_buf_to_tfd = il4965_hw_txq_attach_buf_to_tfd,
2206 .txq_free_tfd = il4965_hw_txq_free_tfd, 1895 .txq_free_tfd = il4965_hw_txq_free_tfd,
2207 .txq_init = il4965_hw_tx_queue_init, 1896 .txq_init = il4965_hw_tx_queue_init,
2208 .handler_setup = il4965_handler_setup,
2209 .is_valid_rtc_data_addr = il4965_hw_valid_rtc_data_addr, 1897 .is_valid_rtc_data_addr = il4965_hw_valid_rtc_data_addr,
2210 .init_alive_start = il4965_init_alive_start, 1898 .init_alive_start = il4965_init_alive_start,
2211 .load_ucode = il4965_load_bsm, 1899 .load_ucode = il4965_load_bsm,