aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl4965-base.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl4965-base.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl4965-base.c1102
1 files changed, 287 insertions, 815 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c
index a23d4798653b..0b7335181719 100644
--- a/drivers/net/wireless/iwlwifi/iwl4965-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2003 - 2007 Intel Corporation. All rights reserved. 3 * Copyright(c) 2003 - 2008 Intel Corporation. All rights reserved.
4 * 4 *
5 * Portions of this file are derived from the ipw3945 project, as well 5 * Portions of this file are derived from the ipw3945 project, as well
6 * as portions of the ieee80211 subsystem header files. 6 * as portions of the ieee80211 subsystem header files.
@@ -45,13 +45,11 @@
45 45
46#include <asm/div64.h> 46#include <asm/div64.h>
47 47
48#include "iwl-eeprom.h"
49#include "iwl-core.h"
48#include "iwl-4965.h" 50#include "iwl-4965.h"
49#include "iwl-helpers.h" 51#include "iwl-helpers.h"
50 52
51#ifdef CONFIG_IWL4965_DEBUG
52u32 iwl4965_debug_level;
53#endif
54
55static int iwl4965_tx_queue_update_write_ptr(struct iwl4965_priv *priv, 53static int iwl4965_tx_queue_update_write_ptr(struct iwl4965_priv *priv,
56 struct iwl4965_tx_queue *txq); 54 struct iwl4965_tx_queue *txq);
57 55
@@ -90,15 +88,8 @@ int iwl4965_param_amsdu_size_8K; /* def: enable 8K amsdu size */
90#define VS 88#define VS
91#endif 89#endif
92 90
93#define IWLWIFI_VERSION "1.2.23k" VD VS 91#define DRV_VERSION IWLWIFI_VERSION VD VS
94#define DRV_COPYRIGHT "Copyright(c) 2003-2007 Intel Corporation"
95#define DRV_VERSION IWLWIFI_VERSION
96 92
97/* Change firmware file name, using "-" and incrementing number,
98 * *only* when uCode interface or architecture changes so that it
99 * is not compatible with earlier drivers.
100 * This number will also appear in << 8 position of 1st dword of uCode file */
101#define IWL4965_UCODE_API "-1"
102 93
103MODULE_DESCRIPTION(DRV_DESCRIPTION); 94MODULE_DESCRIPTION(DRV_DESCRIPTION);
104MODULE_VERSION(DRV_VERSION); 95MODULE_VERSION(DRV_VERSION);
@@ -115,16 +106,10 @@ __le16 *ieee80211_get_qos_ctrl(struct ieee80211_hdr *hdr)
115 return NULL; 106 return NULL;
116} 107}
117 108
118static const struct ieee80211_hw_mode *iwl4965_get_hw_mode( 109static const struct ieee80211_supported_band *iwl4965_get_hw_mode(
119 struct iwl4965_priv *priv, int mode) 110 struct iwl4965_priv *priv, enum ieee80211_band band)
120{ 111{
121 int i; 112 return priv->hw->wiphy->bands[band];
122
123 for (i = 0; i < 3; i++)
124 if (priv->modes[i].mode == mode)
125 return &priv->modes[i];
126
127 return NULL;
128} 113}
129 114
130static int iwl4965_is_empty_essid(const char *essid, int essid_len) 115static int iwl4965_is_empty_essid(const char *essid, int essid_len)
@@ -167,17 +152,6 @@ static const char *iwl4965_escape_essid(const char *essid, u8 essid_len)
167 return escaped; 152 return escaped;
168} 153}
169 154
170static void iwl4965_print_hex_dump(int level, void *p, u32 len)
171{
172#ifdef CONFIG_IWL4965_DEBUG
173 if (!(iwl4965_debug_level & level))
174 return;
175
176 print_hex_dump(KERN_DEBUG, "iwl data: ", DUMP_PREFIX_OFFSET, 16, 1,
177 p, len, 1);
178#endif
179}
180
181/*************** DMA-QUEUE-GENERAL-FUNCTIONS ***** 155/*************** DMA-QUEUE-GENERAL-FUNCTIONS *****
182 * DMA services 156 * DMA services
183 * 157 *
@@ -205,7 +179,7 @@ static void iwl4965_print_hex_dump(int level, void *p, u32 len)
205 * See more detailed info in iwl-4965-hw.h. 179 * See more detailed info in iwl-4965-hw.h.
206 ***************************************************/ 180 ***************************************************/
207 181
208static int iwl4965_queue_space(const struct iwl4965_queue *q) 182int iwl4965_queue_space(const struct iwl4965_queue *q)
209{ 183{
210 int s = q->read_ptr - q->write_ptr; 184 int s = q->read_ptr - q->write_ptr;
211 185
@@ -221,25 +195,6 @@ static int iwl4965_queue_space(const struct iwl4965_queue *q)
221 return s; 195 return s;
222} 196}
223 197
224/**
225 * iwl4965_queue_inc_wrap - increment queue index, wrap back to beginning
226 * @index -- current index
227 * @n_bd -- total number of entries in queue (must be power of 2)
228 */
229static inline int iwl4965_queue_inc_wrap(int index, int n_bd)
230{
231 return ++index & (n_bd - 1);
232}
233
234/**
235 * iwl4965_queue_dec_wrap - decrement queue index, wrap back to end
236 * @index -- current index
237 * @n_bd -- total number of entries in queue (must be power of 2)
238 */
239static inline int iwl4965_queue_dec_wrap(int index, int n_bd)
240{
241 return --index & (n_bd - 1);
242}
243 198
244static inline int x2_queue_used(const struct iwl4965_queue *q, int i) 199static inline int x2_queue_used(const struct iwl4965_queue *q, int i)
245{ 200{
@@ -268,8 +223,8 @@ static int iwl4965_queue_init(struct iwl4965_priv *priv, struct iwl4965_queue *q
268 q->n_window = slots_num; 223 q->n_window = slots_num;
269 q->id = id; 224 q->id = id;
270 225
271 /* count must be power-of-two size, otherwise iwl4965_queue_inc_wrap 226 /* count must be power-of-two size, otherwise iwl_queue_inc_wrap
272 * and iwl4965_queue_dec_wrap are broken. */ 227 * and iwl_queue_dec_wrap are broken. */
273 BUG_ON(!is_power_of_2(count)); 228 BUG_ON(!is_power_of_2(count));
274 229
275 /* slots_num must be power-of-two size, otherwise 230 /* slots_num must be power-of-two size, otherwise
@@ -369,7 +324,7 @@ int iwl4965_tx_queue_init(struct iwl4965_priv *priv,
369 txq->need_update = 0; 324 txq->need_update = 0;
370 325
371 /* TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise 326 /* TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise
372 * iwl4965_queue_inc_wrap and iwl4965_queue_dec_wrap are broken. */ 327 * iwl_queue_inc_wrap and iwl_queue_dec_wrap are broken. */
373 BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1)); 328 BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1));
374 329
375 /* Initialize queue's high/low-water marks, and head/tail indexes */ 330 /* Initialize queue's high/low-water marks, and head/tail indexes */
@@ -400,7 +355,7 @@ void iwl4965_tx_queue_free(struct iwl4965_priv *priv, struct iwl4965_tx_queue *t
400 355
401 /* first, empty all BD's */ 356 /* first, empty all BD's */
402 for (; q->write_ptr != q->read_ptr; 357 for (; q->write_ptr != q->read_ptr;
403 q->read_ptr = iwl4965_queue_inc_wrap(q->read_ptr, q->n_bd)) 358 q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd))
404 iwl4965_hw_txq_free_tfd(priv, txq); 359 iwl4965_hw_txq_free_tfd(priv, txq);
405 360
406 len = sizeof(struct iwl4965_cmd) * q->n_window; 361 len = sizeof(struct iwl4965_cmd) * q->n_window;
@@ -741,7 +696,7 @@ static int iwl4965_enqueue_hcmd(struct iwl4965_priv *priv, struct iwl4965_host_c
741 ret = iwl4965_tx_queue_update_wr_ptr(priv, txq, 0); 696 ret = iwl4965_tx_queue_update_wr_ptr(priv, txq, 0);
742 697
743 /* Increment and update queue's write index */ 698 /* Increment and update queue's write index */
744 q->write_ptr = iwl4965_queue_inc_wrap(q->write_ptr, q->n_bd); 699 q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd);
745 iwl4965_tx_queue_update_write_ptr(priv, txq); 700 iwl4965_tx_queue_update_write_ptr(priv, txq);
746 701
747 spin_unlock_irqrestore(&priv->hcmd_lock, flags); 702 spin_unlock_irqrestore(&priv->hcmd_lock, flags);
@@ -937,28 +892,29 @@ static int iwl4965_rxon_add_station(struct iwl4965_priv *priv,
937 * NOTE: Does not commit to the hardware; it sets appropriate bit fields 892 * NOTE: Does not commit to the hardware; it sets appropriate bit fields
938 * in the staging RXON flag structure based on the phymode 893 * in the staging RXON flag structure based on the phymode
939 */ 894 */
940static int iwl4965_set_rxon_channel(struct iwl4965_priv *priv, u8 phymode, 895static int iwl4965_set_rxon_channel(struct iwl4965_priv *priv,
896 enum ieee80211_band band,
941 u16 channel) 897 u16 channel)
942{ 898{
943 if (!iwl4965_get_channel_info(priv, phymode, channel)) { 899 if (!iwl4965_get_channel_info(priv, band, channel)) {
944 IWL_DEBUG_INFO("Could not set channel to %d [%d]\n", 900 IWL_DEBUG_INFO("Could not set channel to %d [%d]\n",
945 channel, phymode); 901 channel, band);
946 return -EINVAL; 902 return -EINVAL;
947 } 903 }
948 904
949 if ((le16_to_cpu(priv->staging_rxon.channel) == channel) && 905 if ((le16_to_cpu(priv->staging_rxon.channel) == channel) &&
950 (priv->phymode == phymode)) 906 (priv->band == band))
951 return 0; 907 return 0;
952 908
953 priv->staging_rxon.channel = cpu_to_le16(channel); 909 priv->staging_rxon.channel = cpu_to_le16(channel);
954 if (phymode == MODE_IEEE80211A) 910 if (band == IEEE80211_BAND_5GHZ)
955 priv->staging_rxon.flags &= ~RXON_FLG_BAND_24G_MSK; 911 priv->staging_rxon.flags &= ~RXON_FLG_BAND_24G_MSK;
956 else 912 else
957 priv->staging_rxon.flags |= RXON_FLG_BAND_24G_MSK; 913 priv->staging_rxon.flags |= RXON_FLG_BAND_24G_MSK;
958 914
959 priv->phymode = phymode; 915 priv->band = band;
960 916
961 IWL_DEBUG_INFO("Staging channel set to %d [%d]\n", channel, phymode); 917 IWL_DEBUG_INFO("Staging channel set to %d [%d]\n", channel, band);
962 918
963 return 0; 919 return 0;
964} 920}
@@ -1556,34 +1512,6 @@ unsigned int iwl4965_fill_beacon_frame(struct iwl4965_priv *priv,
1556 return priv->ibss_beacon->len; 1512 return priv->ibss_beacon->len;
1557} 1513}
1558 1514
1559int iwl4965_rate_index_from_plcp(int plcp)
1560{
1561 int i = 0;
1562
1563 /* 4965 HT rate format */
1564 if (plcp & RATE_MCS_HT_MSK) {
1565 i = (plcp & 0xff);
1566
1567 if (i >= IWL_RATE_MIMO_6M_PLCP)
1568 i = i - IWL_RATE_MIMO_6M_PLCP;
1569
1570 i += IWL_FIRST_OFDM_RATE;
1571 /* skip 9M not supported in ht*/
1572 if (i >= IWL_RATE_9M_INDEX)
1573 i += 1;
1574 if ((i >= IWL_FIRST_OFDM_RATE) &&
1575 (i <= IWL_LAST_OFDM_RATE))
1576 return i;
1577
1578 /* 4965 legacy rate format, search for match in table */
1579 } else {
1580 for (i = 0; i < ARRAY_SIZE(iwl4965_rates); i++)
1581 if (iwl4965_rates[i].plcp == (plcp &0xFF))
1582 return i;
1583 }
1584 return -1;
1585}
1586
1587static u8 iwl4965_rate_get_lowest_plcp(int rate_mask) 1515static u8 iwl4965_rate_get_lowest_plcp(int rate_mask)
1588{ 1516{
1589 u8 i; 1517 u8 i;
@@ -1635,230 +1563,9 @@ static int iwl4965_send_beacon_cmd(struct iwl4965_priv *priv)
1635 1563
1636/****************************************************************************** 1564/******************************************************************************
1637 * 1565 *
1638 * EEPROM related functions
1639 *
1640 ******************************************************************************/
1641
1642static void get_eeprom_mac(struct iwl4965_priv *priv, u8 *mac)
1643{
1644 memcpy(mac, priv->eeprom.mac_address, 6);
1645}
1646
1647static inline void iwl4965_eeprom_release_semaphore(struct iwl4965_priv *priv)
1648{
1649 iwl4965_clear_bit(priv, CSR_HW_IF_CONFIG_REG,
1650 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM);
1651}
1652
1653/**
1654 * iwl4965_eeprom_init - read EEPROM contents
1655 *
1656 * Load the EEPROM contents from adapter into priv->eeprom
1657 *
1658 * NOTE: This routine uses the non-debug IO access functions.
1659 */
1660int iwl4965_eeprom_init(struct iwl4965_priv *priv)
1661{
1662 u16 *e = (u16 *)&priv->eeprom;
1663 u32 gp = iwl4965_read32(priv, CSR_EEPROM_GP);
1664 u32 r;
1665 int sz = sizeof(priv->eeprom);
1666 int rc;
1667 int i;
1668 u16 addr;
1669
1670 /* The EEPROM structure has several padding buffers within it
1671 * and when adding new EEPROM maps is subject to programmer errors
1672 * which may be very difficult to identify without explicitly
1673 * checking the resulting size of the eeprom map. */
1674 BUILD_BUG_ON(sizeof(priv->eeprom) != IWL_EEPROM_IMAGE_SIZE);
1675
1676 if ((gp & CSR_EEPROM_GP_VALID_MSK) == CSR_EEPROM_GP_BAD_SIGNATURE) {
1677 IWL_ERROR("EEPROM not found, EEPROM_GP=0x%08x", gp);
1678 return -ENOENT;
1679 }
1680
1681 /* Make sure driver (instead of uCode) is allowed to read EEPROM */
1682 rc = iwl4965_eeprom_acquire_semaphore(priv);
1683 if (rc < 0) {
1684 IWL_ERROR("Failed to acquire EEPROM semaphore.\n");
1685 return -ENOENT;
1686 }
1687
1688 /* eeprom is an array of 16bit values */
1689 for (addr = 0; addr < sz; addr += sizeof(u16)) {
1690 _iwl4965_write32(priv, CSR_EEPROM_REG, addr << 1);
1691 _iwl4965_clear_bit(priv, CSR_EEPROM_REG, CSR_EEPROM_REG_BIT_CMD);
1692
1693 for (i = 0; i < IWL_EEPROM_ACCESS_TIMEOUT;
1694 i += IWL_EEPROM_ACCESS_DELAY) {
1695 r = _iwl4965_read_direct32(priv, CSR_EEPROM_REG);
1696 if (r & CSR_EEPROM_REG_READ_VALID_MSK)
1697 break;
1698 udelay(IWL_EEPROM_ACCESS_DELAY);
1699 }
1700
1701 if (!(r & CSR_EEPROM_REG_READ_VALID_MSK)) {
1702 IWL_ERROR("Time out reading EEPROM[%d]", addr);
1703 rc = -ETIMEDOUT;
1704 goto done;
1705 }
1706 e[addr / 2] = le16_to_cpu((__force __le16)(r >> 16));
1707 }
1708 rc = 0;
1709
1710done:
1711 iwl4965_eeprom_release_semaphore(priv);
1712 return rc;
1713}
1714
1715/******************************************************************************
1716 *
1717 * Misc. internal state and helper functions 1566 * Misc. internal state and helper functions
1718 * 1567 *
1719 ******************************************************************************/ 1568 ******************************************************************************/
1720#ifdef CONFIG_IWL4965_DEBUG
1721
1722/**
1723 * iwl4965_report_frame - dump frame to syslog during debug sessions
1724 *
1725 * You may hack this function to show different aspects of received frames,
1726 * including selective frame dumps.
1727 * group100 parameter selects whether to show 1 out of 100 good frames.
1728 *
1729 * TODO: This was originally written for 3945, need to audit for
1730 * proper operation with 4965.
1731 */
1732void iwl4965_report_frame(struct iwl4965_priv *priv,
1733 struct iwl4965_rx_packet *pkt,
1734 struct ieee80211_hdr *header, int group100)
1735{
1736 u32 to_us;
1737 u32 print_summary = 0;
1738 u32 print_dump = 0; /* set to 1 to dump all frames' contents */
1739 u32 hundred = 0;
1740 u32 dataframe = 0;
1741 u16 fc;
1742 u16 seq_ctl;
1743 u16 channel;
1744 u16 phy_flags;
1745 int rate_sym;
1746 u16 length;
1747 u16 status;
1748 u16 bcn_tmr;
1749 u32 tsf_low;
1750 u64 tsf;
1751 u8 rssi;
1752 u8 agc;
1753 u16 sig_avg;
1754 u16 noise_diff;
1755 struct iwl4965_rx_frame_stats *rx_stats = IWL_RX_STATS(pkt);
1756 struct iwl4965_rx_frame_hdr *rx_hdr = IWL_RX_HDR(pkt);
1757 struct iwl4965_rx_frame_end *rx_end = IWL_RX_END(pkt);
1758 u8 *data = IWL_RX_DATA(pkt);
1759
1760 /* MAC header */
1761 fc = le16_to_cpu(header->frame_control);
1762 seq_ctl = le16_to_cpu(header->seq_ctrl);
1763
1764 /* metadata */
1765 channel = le16_to_cpu(rx_hdr->channel);
1766 phy_flags = le16_to_cpu(rx_hdr->phy_flags);
1767 rate_sym = rx_hdr->rate;
1768 length = le16_to_cpu(rx_hdr->len);
1769
1770 /* end-of-frame status and timestamp */
1771 status = le32_to_cpu(rx_end->status);
1772 bcn_tmr = le32_to_cpu(rx_end->beacon_timestamp);
1773 tsf_low = le64_to_cpu(rx_end->timestamp) & 0x0ffffffff;
1774 tsf = le64_to_cpu(rx_end->timestamp);
1775
1776 /* signal statistics */
1777 rssi = rx_stats->rssi;
1778 agc = rx_stats->agc;
1779 sig_avg = le16_to_cpu(rx_stats->sig_avg);
1780 noise_diff = le16_to_cpu(rx_stats->noise_diff);
1781
1782 to_us = !compare_ether_addr(header->addr1, priv->mac_addr);
1783
1784 /* if data frame is to us and all is good,
1785 * (optionally) print summary for only 1 out of every 100 */
1786 if (to_us && (fc & ~IEEE80211_FCTL_PROTECTED) ==
1787 (IEEE80211_FCTL_FROMDS | IEEE80211_FTYPE_DATA)) {
1788 dataframe = 1;
1789 if (!group100)
1790 print_summary = 1; /* print each frame */
1791 else if (priv->framecnt_to_us < 100) {
1792 priv->framecnt_to_us++;
1793 print_summary = 0;
1794 } else {
1795 priv->framecnt_to_us = 0;
1796 print_summary = 1;
1797 hundred = 1;
1798 }
1799 } else {
1800 /* print summary for all other frames */
1801 print_summary = 1;
1802 }
1803
1804 if (print_summary) {
1805 char *title;
1806 u32 rate;
1807
1808 if (hundred)
1809 title = "100Frames";
1810 else if (fc & IEEE80211_FCTL_RETRY)
1811 title = "Retry";
1812 else if (ieee80211_is_assoc_response(fc))
1813 title = "AscRsp";
1814 else if (ieee80211_is_reassoc_response(fc))
1815 title = "RasRsp";
1816 else if (ieee80211_is_probe_response(fc)) {
1817 title = "PrbRsp";
1818 print_dump = 1; /* dump frame contents */
1819 } else if (ieee80211_is_beacon(fc)) {
1820 title = "Beacon";
1821 print_dump = 1; /* dump frame contents */
1822 } else if (ieee80211_is_atim(fc))
1823 title = "ATIM";
1824 else if (ieee80211_is_auth(fc))
1825 title = "Auth";
1826 else if (ieee80211_is_deauth(fc))
1827 title = "DeAuth";
1828 else if (ieee80211_is_disassoc(fc))
1829 title = "DisAssoc";
1830 else
1831 title = "Frame";
1832
1833 rate = iwl4965_rate_index_from_plcp(rate_sym);
1834 if (rate == -1)
1835 rate = 0;
1836 else
1837 rate = iwl4965_rates[rate].ieee / 2;
1838
1839 /* print frame summary.
1840 * MAC addresses show just the last byte (for brevity),
1841 * but you can hack it to show more, if you'd like to. */
1842 if (dataframe)
1843 IWL_DEBUG_RX("%s: mhd=0x%04x, dst=0x%02x, "
1844 "len=%u, rssi=%d, chnl=%d, rate=%u, \n",
1845 title, fc, header->addr1[5],
1846 length, rssi, channel, rate);
1847 else {
1848 /* src/dst addresses assume managed mode */
1849 IWL_DEBUG_RX("%s: 0x%04x, dst=0x%02x, "
1850 "src=0x%02x, rssi=%u, tim=%lu usec, "
1851 "phy=0x%02x, chnl=%d\n",
1852 title, fc, header->addr1[5],
1853 header->addr3[5], rssi,
1854 tsf_low - priv->scan_start_tsf,
1855 phy_flags, channel);
1856 }
1857 }
1858 if (print_dump)
1859 iwl4965_print_hex_dump(IWL_DL_RX, data, length);
1860}
1861#endif
1862 1569
1863static void iwl4965_unset_hw_setting(struct iwl4965_priv *priv) 1570static void iwl4965_unset_hw_setting(struct iwl4965_priv *priv)
1864{ 1571{
@@ -1898,24 +1605,20 @@ static u16 iwl4965_supported_rate_to_ie(u8 *ie, u16 supported_rate,
1898 return ret_rates; 1605 return ret_rates;
1899} 1606}
1900 1607
1901#ifdef CONFIG_IWL4965_HT
1902void static iwl4965_set_ht_capab(struct ieee80211_hw *hw,
1903 struct ieee80211_ht_cap *ht_cap,
1904 u8 use_current_config);
1905#endif
1906
1907/** 1608/**
1908 * iwl4965_fill_probe_req - fill in all required fields and IE for probe request 1609 * iwl4965_fill_probe_req - fill in all required fields and IE for probe request
1909 */ 1610 */
1910static u16 iwl4965_fill_probe_req(struct iwl4965_priv *priv, 1611static u16 iwl4965_fill_probe_req(struct iwl4965_priv *priv,
1911 struct ieee80211_mgmt *frame, 1612 enum ieee80211_band band,
1912 int left, int is_direct) 1613 struct ieee80211_mgmt *frame,
1614 int left, int is_direct)
1913{ 1615{
1914 int len = 0; 1616 int len = 0;
1915 u8 *pos = NULL; 1617 u8 *pos = NULL;
1916 u16 active_rates, ret_rates, cck_rates, active_rate_basic; 1618 u16 active_rates, ret_rates, cck_rates, active_rate_basic;
1917#ifdef CONFIG_IWL4965_HT 1619#ifdef CONFIG_IWL4965_HT
1918 struct ieee80211_hw_mode *mode; 1620 const struct ieee80211_supported_band *sband =
1621 iwl4965_get_hw_mode(priv, band);
1919#endif /* CONFIG_IWL4965_HT */ 1622#endif /* CONFIG_IWL4965_HT */
1920 1623
1921 /* Make sure there is enough space for the probe request, 1624 /* Make sure there is enough space for the probe request,
@@ -2000,13 +1703,18 @@ static u16 iwl4965_fill_probe_req(struct iwl4965_priv *priv,
2000 len += 2 + *pos; 1703 len += 2 + *pos;
2001 1704
2002#ifdef CONFIG_IWL4965_HT 1705#ifdef CONFIG_IWL4965_HT
2003 mode = priv->hw->conf.mode; 1706 if (sband && sband->ht_info.ht_supported) {
2004 if (mode->ht_info.ht_supported) { 1707 struct ieee80211_ht_cap *ht_cap;
2005 pos += (*pos) + 1; 1708 pos += (*pos) + 1;
2006 *pos++ = WLAN_EID_HT_CAPABILITY; 1709 *pos++ = WLAN_EID_HT_CAPABILITY;
2007 *pos++ = sizeof(struct ieee80211_ht_cap); 1710 *pos++ = sizeof(struct ieee80211_ht_cap);
2008 iwl4965_set_ht_capab(priv->hw, 1711 ht_cap = (struct ieee80211_ht_cap *)pos;
2009 (struct ieee80211_ht_cap *)pos, 0); 1712 ht_cap->cap_info = cpu_to_le16(sband->ht_info.cap);
1713 memcpy(ht_cap->supp_mcs_set, sband->ht_info.supp_mcs_set, 16);
1714 ht_cap->ampdu_params_info =(sband->ht_info.ampdu_factor &
1715 IEEE80211_HT_CAP_AMPDU_FACTOR) |
1716 ((sband->ht_info.ampdu_density << 2) &
1717 IEEE80211_HT_CAP_AMPDU_DENSITY);
2010 len += 2 + sizeof(struct ieee80211_ht_cap); 1718 len += 2 + sizeof(struct ieee80211_ht_cap);
2011 } 1719 }
2012#endif /*CONFIG_IWL4965_HT */ 1720#endif /*CONFIG_IWL4965_HT */
@@ -2018,7 +1726,6 @@ static u16 iwl4965_fill_probe_req(struct iwl4965_priv *priv,
2018/* 1726/*
2019 * QoS support 1727 * QoS support
2020*/ 1728*/
2021#ifdef CONFIG_IWL4965_QOS
2022static int iwl4965_send_qos_params_command(struct iwl4965_priv *priv, 1729static int iwl4965_send_qos_params_command(struct iwl4965_priv *priv,
2023 struct iwl4965_qosparam_cmd *qos) 1730 struct iwl4965_qosparam_cmd *qos)
2024{ 1731{
@@ -2152,7 +1859,6 @@ static void iwl4965_activate_qos(struct iwl4965_priv *priv, u8 force)
2152 } 1859 }
2153} 1860}
2154 1861
2155#endif /* CONFIG_IWL4965_QOS */
2156/* 1862/*
2157 * Power management (not Tx power!) functions 1863 * Power management (not Tx power!) functions
2158 */ 1864 */
@@ -2571,9 +2277,10 @@ static int iwl4965_set_rxon_hwcrypto(struct iwl4965_priv *priv, int hw_decrypt)
2571 return 0; 2277 return 0;
2572} 2278}
2573 2279
2574static void iwl4965_set_flags_for_phymode(struct iwl4965_priv *priv, u8 phymode) 2280static void iwl4965_set_flags_for_phymode(struct iwl4965_priv *priv,
2281 enum ieee80211_band band)
2575{ 2282{
2576 if (phymode == MODE_IEEE80211A) { 2283 if (band == IEEE80211_BAND_5GHZ) {
2577 priv->staging_rxon.flags &= 2284 priv->staging_rxon.flags &=
2578 ~(RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK 2285 ~(RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK
2579 | RXON_FLG_CCK_MSK); 2286 | RXON_FLG_CCK_MSK);
@@ -2636,7 +2343,7 @@ static void iwl4965_connection_init_rx_config(struct iwl4965_priv *priv)
2636 priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; 2343 priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK;
2637#endif 2344#endif
2638 2345
2639 ch_info = iwl4965_get_channel_info(priv, priv->phymode, 2346 ch_info = iwl4965_get_channel_info(priv, priv->band,
2640 le16_to_cpu(priv->staging_rxon.channel)); 2347 le16_to_cpu(priv->staging_rxon.channel));
2641 2348
2642 if (!ch_info) 2349 if (!ch_info)
@@ -2651,12 +2358,9 @@ static void iwl4965_connection_init_rx_config(struct iwl4965_priv *priv)
2651 ch_info = &priv->channel_info[0]; 2358 ch_info = &priv->channel_info[0];
2652 2359
2653 priv->staging_rxon.channel = cpu_to_le16(ch_info->channel); 2360 priv->staging_rxon.channel = cpu_to_le16(ch_info->channel);
2654 if (is_channel_a_band(ch_info)) 2361 priv->band = ch_info->band;
2655 priv->phymode = MODE_IEEE80211A;
2656 else
2657 priv->phymode = MODE_IEEE80211G;
2658 2362
2659 iwl4965_set_flags_for_phymode(priv, priv->phymode); 2363 iwl4965_set_flags_for_phymode(priv, priv->band);
2660 2364
2661 priv->staging_rxon.ofdm_basic_rates = 2365 priv->staging_rxon.ofdm_basic_rates =
2662 (IWL_OFDM_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF; 2366 (IWL_OFDM_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF;
@@ -2678,7 +2382,7 @@ static int iwl4965_set_mode(struct iwl4965_priv *priv, int mode)
2678 const struct iwl4965_channel_info *ch_info; 2382 const struct iwl4965_channel_info *ch_info;
2679 2383
2680 ch_info = iwl4965_get_channel_info(priv, 2384 ch_info = iwl4965_get_channel_info(priv,
2681 priv->phymode, 2385 priv->band,
2682 le16_to_cpu(priv->staging_rxon.channel)); 2386 le16_to_cpu(priv->staging_rxon.channel));
2683 2387
2684 if (!ch_info || !is_channel_ibss(ch_info)) { 2388 if (!ch_info || !is_channel_ibss(ch_info)) {
@@ -2918,7 +2622,7 @@ static int iwl4965_tx_skb(struct iwl4965_priv *priv,
2918 goto drop_unlock; 2622 goto drop_unlock;
2919 } 2623 }
2920 2624
2921 if ((ctl->tx_rate & 0xFF) == IWL_INVALID_RATE) { 2625 if ((ctl->tx_rate->hw_value & 0xFF) == IWL_INVALID_RATE) {
2922 IWL_ERROR("ERROR: No TX rate available.\n"); 2626 IWL_ERROR("ERROR: No TX rate available.\n");
2923 goto drop_unlock; 2627 goto drop_unlock;
2924 } 2628 }
@@ -2972,11 +2676,10 @@ static int iwl4965_tx_skb(struct iwl4965_priv *priv,
2972 __constant_cpu_to_le16(IEEE80211_SCTL_FRAG)); 2676 __constant_cpu_to_le16(IEEE80211_SCTL_FRAG));
2973 seq_number += 0x10; 2677 seq_number += 0x10;
2974#ifdef CONFIG_IWL4965_HT 2678#ifdef CONFIG_IWL4965_HT
2975#ifdef CONFIG_IWL4965_HT_AGG
2976 /* aggregation is on for this <sta,tid> */ 2679 /* aggregation is on for this <sta,tid> */
2977 if (ctl->flags & IEEE80211_TXCTL_HT_MPDU_AGG) 2680 if (ctl->flags & IEEE80211_TXCTL_AMPDU)
2978 txq_id = priv->stations[sta_id].tid[tid].agg.txq_id; 2681 txq_id = priv->stations[sta_id].tid[tid].agg.txq_id;
2979#endif /* CONFIG_IWL4965_HT_AGG */ 2682 priv->stations[sta_id].tid[tid].tfds_in_queue++;
2980#endif /* CONFIG_IWL4965_HT */ 2683#endif /* CONFIG_IWL4965_HT */
2981 } 2684 }
2982 2685
@@ -3076,14 +2779,6 @@ static int iwl4965_tx_skb(struct iwl4965_priv *priv,
3076 out_cmd->cmd.tx.dram_lsb_ptr = cpu_to_le32(scratch_phys); 2779 out_cmd->cmd.tx.dram_lsb_ptr = cpu_to_le32(scratch_phys);
3077 out_cmd->cmd.tx.dram_msb_ptr = iwl_get_dma_hi_address(scratch_phys); 2780 out_cmd->cmd.tx.dram_msb_ptr = iwl_get_dma_hi_address(scratch_phys);
3078 2781
3079#ifdef CONFIG_IWL4965_HT_AGG
3080#ifdef CONFIG_IWL4965_HT
3081 /* TODO: move this functionality to rate scaling */
3082 iwl4965_tl_get_stats(priv, hdr);
3083#endif /* CONFIG_IWL4965_HT_AGG */
3084#endif /*CONFIG_IWL4965_HT */
3085
3086
3087 if (!ieee80211_get_morefrag(hdr)) { 2782 if (!ieee80211_get_morefrag(hdr)) {
3088 txq->need_update = 1; 2783 txq->need_update = 1;
3089 if (qc) { 2784 if (qc) {
@@ -3105,7 +2800,7 @@ static int iwl4965_tx_skb(struct iwl4965_priv *priv,
3105 iwl4965_tx_queue_update_wr_ptr(priv, txq, len); 2800 iwl4965_tx_queue_update_wr_ptr(priv, txq, len);
3106 2801
3107 /* Tell device the write index *just past* this latest filled TFD */ 2802 /* Tell device the write index *just past* this latest filled TFD */
3108 q->write_ptr = iwl4965_queue_inc_wrap(q->write_ptr, q->n_bd); 2803 q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd);
3109 rc = iwl4965_tx_queue_update_write_ptr(priv, txq); 2804 rc = iwl4965_tx_queue_update_write_ptr(priv, txq);
3110 spin_unlock_irqrestore(&priv->lock, flags); 2805 spin_unlock_irqrestore(&priv->lock, flags);
3111 2806
@@ -3134,11 +2829,11 @@ drop:
3134 2829
3135static void iwl4965_set_rate(struct iwl4965_priv *priv) 2830static void iwl4965_set_rate(struct iwl4965_priv *priv)
3136{ 2831{
3137 const struct ieee80211_hw_mode *hw = NULL; 2832 const struct ieee80211_supported_band *hw = NULL;
3138 struct ieee80211_rate *rate; 2833 struct ieee80211_rate *rate;
3139 int i; 2834 int i;
3140 2835
3141 hw = iwl4965_get_hw_mode(priv, priv->phymode); 2836 hw = iwl4965_get_hw_mode(priv, priv->band);
3142 if (!hw) { 2837 if (!hw) {
3143 IWL_ERROR("Failed to set rate: unable to get hw mode\n"); 2838 IWL_ERROR("Failed to set rate: unable to get hw mode\n");
3144 return; 2839 return;
@@ -3147,24 +2842,10 @@ static void iwl4965_set_rate(struct iwl4965_priv *priv)
3147 priv->active_rate = 0; 2842 priv->active_rate = 0;
3148 priv->active_rate_basic = 0; 2843 priv->active_rate_basic = 0;
3149 2844
3150 IWL_DEBUG_RATE("Setting rates for 802.11%c\n", 2845 for (i = 0; i < hw->n_bitrates; i++) {
3151 hw->mode == MODE_IEEE80211A ? 2846 rate = &(hw->bitrates[i]);
3152 'a' : ((hw->mode == MODE_IEEE80211B) ? 'b' : 'g')); 2847 if (rate->hw_value < IWL_RATE_COUNT)
3153 2848 priv->active_rate |= (1 << rate->hw_value);
3154 for (i = 0; i < hw->num_rates; i++) {
3155 rate = &(hw->rates[i]);
3156 if ((rate->val < IWL_RATE_COUNT) &&
3157 (rate->flags & IEEE80211_RATE_SUPPORTED)) {
3158 IWL_DEBUG_RATE("Adding rate index %d (plcp %d)%s\n",
3159 rate->val, iwl4965_rates[rate->val].plcp,
3160 (rate->flags & IEEE80211_RATE_BASIC) ?
3161 "*" : "");
3162 priv->active_rate |= (1 << rate->val);
3163 if (rate->flags & IEEE80211_RATE_BASIC)
3164 priv->active_rate_basic |= (1 << rate->val);
3165 } else
3166 IWL_DEBUG_RATE("Not adding rate %d (plcp %d)\n",
3167 rate->val, iwl4965_rates[rate->val].plcp);
3168 } 2849 }
3169 2850
3170 IWL_DEBUG_RATE("Set active_rate = %0x, active_rate_basic = %0x\n", 2851 IWL_DEBUG_RATE("Set active_rate = %0x, active_rate_basic = %0x\n",
@@ -3513,9 +3194,9 @@ int iwl4965_tx_queue_reclaim(struct iwl4965_priv *priv, int txq_id, int index)
3513 return 0; 3194 return 0;
3514 } 3195 }
3515 3196
3516 for (index = iwl4965_queue_inc_wrap(index, q->n_bd); 3197 for (index = iwl_queue_inc_wrap(index, q->n_bd);
3517 q->read_ptr != index; 3198 q->read_ptr != index;
3518 q->read_ptr = iwl4965_queue_inc_wrap(q->read_ptr, q->n_bd)) { 3199 q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) {
3519 if (txq_id != IWL_CMD_QUEUE_NUM) { 3200 if (txq_id != IWL_CMD_QUEUE_NUM) {
3520 iwl4965_txstatus_to_ieee(priv, 3201 iwl4965_txstatus_to_ieee(priv,
3521 &(txq->txb[txq->q.read_ptr])); 3202 &(txq->txb[txq->q.read_ptr]));
@@ -3528,10 +3209,10 @@ int iwl4965_tx_queue_reclaim(struct iwl4965_priv *priv, int txq_id, int index)
3528 nfreed++; 3209 nfreed++;
3529 } 3210 }
3530 3211
3531 if (iwl4965_queue_space(q) > q->low_mark && (txq_id >= 0) && 3212/* if (iwl4965_queue_space(q) > q->low_mark && (txq_id >= 0) &&
3532 (txq_id != IWL_CMD_QUEUE_NUM) && 3213 (txq_id != IWL_CMD_QUEUE_NUM) &&
3533 priv->mac80211_registered) 3214 priv->mac80211_registered)
3534 ieee80211_wake_queue(priv->hw, txq_id); 3215 ieee80211_wake_queue(priv->hw, txq_id); */
3535 3216
3536 3217
3537 return nfreed; 3218 return nfreed;
@@ -3550,7 +3231,6 @@ static int iwl4965_is_tx_success(u32 status)
3550 * 3231 *
3551 ******************************************************************************/ 3232 ******************************************************************************/
3552#ifdef CONFIG_IWL4965_HT 3233#ifdef CONFIG_IWL4965_HT
3553#ifdef CONFIG_IWL4965_HT_AGG
3554 3234
3555static inline int iwl4965_get_ra_sta_id(struct iwl4965_priv *priv, 3235static inline int iwl4965_get_ra_sta_id(struct iwl4965_priv *priv,
3556 struct ieee80211_hdr *hdr) 3236 struct ieee80211_hdr *hdr)
@@ -3585,11 +3265,11 @@ static inline u32 iwl4965_get_scd_ssn(struct iwl4965_tx_resp *tx_resp)
3585 */ 3265 */
3586static int iwl4965_tx_status_reply_tx(struct iwl4965_priv *priv, 3266static int iwl4965_tx_status_reply_tx(struct iwl4965_priv *priv,
3587 struct iwl4965_ht_agg *agg, 3267 struct iwl4965_ht_agg *agg,
3588 struct iwl4965_tx_resp *tx_resp, 3268 struct iwl4965_tx_resp_agg *tx_resp,
3589 u16 start_idx) 3269 u16 start_idx)
3590{ 3270{
3591 u32 status; 3271 u16 status;
3592 __le32 *frame_status = &tx_resp->status; 3272 struct agg_tx_status *frame_status = &tx_resp->status;
3593 struct ieee80211_tx_status *tx_status = NULL; 3273 struct ieee80211_tx_status *tx_status = NULL;
3594 struct ieee80211_hdr *hdr = NULL; 3274 struct ieee80211_hdr *hdr = NULL;
3595 int i, sh; 3275 int i, sh;
@@ -3602,30 +3282,30 @@ static int iwl4965_tx_status_reply_tx(struct iwl4965_priv *priv,
3602 agg->frame_count = tx_resp->frame_count; 3282 agg->frame_count = tx_resp->frame_count;
3603 agg->start_idx = start_idx; 3283 agg->start_idx = start_idx;
3604 agg->rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags); 3284 agg->rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags);
3605 agg->bitmap0 = agg->bitmap1 = 0; 3285 agg->bitmap = 0;
3606 3286
3607 /* # frames attempted by Tx command */ 3287 /* # frames attempted by Tx command */
3608 if (agg->frame_count == 1) { 3288 if (agg->frame_count == 1) {
3609 /* Only one frame was attempted; no block-ack will arrive */ 3289 /* Only one frame was attempted; no block-ack will arrive */
3610 struct iwl4965_tx_queue *txq ; 3290 status = le16_to_cpu(frame_status[0].status);
3611 status = le32_to_cpu(frame_status[0]); 3291 seq = le16_to_cpu(frame_status[0].sequence);
3292 idx = SEQ_TO_INDEX(seq);
3293 txq_id = SEQ_TO_QUEUE(seq);
3612 3294
3613 txq_id = agg->txq_id;
3614 txq = &priv->txq[txq_id];
3615 /* FIXME: code repetition */ 3295 /* FIXME: code repetition */
3616 IWL_DEBUG_TX_REPLY("FrameCnt = %d, StartIdx=%d \n", 3296 IWL_DEBUG_TX_REPLY("FrameCnt = %d, StartIdx=%d idx=%d\n",
3617 agg->frame_count, agg->start_idx); 3297 agg->frame_count, agg->start_idx, idx);
3618 3298
3619 tx_status = &(priv->txq[txq_id].txb[txq->q.read_ptr].status); 3299 tx_status = &(priv->txq[txq_id].txb[idx].status);
3620 tx_status->retry_count = tx_resp->failure_frame; 3300 tx_status->retry_count = tx_resp->failure_frame;
3621 tx_status->queue_number = status & 0xff; 3301 tx_status->queue_number = status & 0xff;
3622 tx_status->queue_length = tx_resp->bt_kill_count; 3302 tx_status->queue_length = tx_resp->failure_rts;
3623 tx_status->queue_length |= tx_resp->failure_rts; 3303 tx_status->control.flags &= ~IEEE80211_TXCTL_AMPDU;
3624
3625 tx_status->flags = iwl4965_is_tx_success(status)? 3304 tx_status->flags = iwl4965_is_tx_success(status)?
3626 IEEE80211_TX_STATUS_ACK : 0; 3305 IEEE80211_TX_STATUS_ACK : 0;
3627 tx_status->control.tx_rate = 3306 iwl4965_hwrate_to_tx_control(priv,
3628 iwl4965_hw_get_rate_n_flags(tx_resp->rate_n_flags); 3307 le32_to_cpu(tx_resp->rate_n_flags),
3308 &tx_status->control);
3629 /* FIXME: code repetition end */ 3309 /* FIXME: code repetition end */
3630 3310
3631 IWL_DEBUG_TX_REPLY("1 Frame 0x%x failure :%d\n", 3311 IWL_DEBUG_TX_REPLY("1 Frame 0x%x failure :%d\n",
@@ -3642,8 +3322,8 @@ static int iwl4965_tx_status_reply_tx(struct iwl4965_priv *priv,
3642 /* Construct bit-map of pending frames within Tx window */ 3322 /* Construct bit-map of pending frames within Tx window */
3643 for (i = 0; i < agg->frame_count; i++) { 3323 for (i = 0; i < agg->frame_count; i++) {
3644 u16 sc; 3324 u16 sc;
3645 status = le32_to_cpu(frame_status[i]); 3325 status = le16_to_cpu(frame_status[i].status);
3646 seq = status >> 16; 3326 seq = le16_to_cpu(frame_status[i].sequence);
3647 idx = SEQ_TO_INDEX(seq); 3327 idx = SEQ_TO_INDEX(seq);
3648 txq_id = SEQ_TO_QUEUE(seq); 3328 txq_id = SEQ_TO_QUEUE(seq);
3649 3329
@@ -3687,13 +3367,12 @@ static int iwl4965_tx_status_reply_tx(struct iwl4965_priv *priv,
3687 start, (u32)(bitmap & 0xFFFFFFFF)); 3367 start, (u32)(bitmap & 0xFFFFFFFF));
3688 } 3368 }
3689 3369
3690 agg->bitmap0 = bitmap & 0xFFFFFFFF; 3370 agg->bitmap = bitmap;
3691 agg->bitmap1 = bitmap >> 32;
3692 agg->start_idx = start; 3371 agg->start_idx = start;
3693 agg->rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags); 3372 agg->rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags);
3694 IWL_DEBUG_TX_REPLY("Frames %d start_idx=%d bitmap=0x%x\n", 3373 IWL_DEBUG_TX_REPLY("Frames %d start_idx=%d bitmap=0x%llx\n",
3695 agg->frame_count, agg->start_idx, 3374 agg->frame_count, agg->start_idx,
3696 agg->bitmap0); 3375 agg->bitmap);
3697 3376
3698 if (bitmap) 3377 if (bitmap)
3699 agg->wait_for_ba = 1; 3378 agg->wait_for_ba = 1;
@@ -3701,7 +3380,6 @@ static int iwl4965_tx_status_reply_tx(struct iwl4965_priv *priv,
3701 return 0; 3380 return 0;
3702} 3381}
3703#endif 3382#endif
3704#endif
3705 3383
3706/** 3384/**
3707 * iwl4965_rx_reply_tx - Handle standard (non-aggregation) Tx response 3385 * iwl4965_rx_reply_tx - Handle standard (non-aggregation) Tx response
@@ -3718,9 +3396,9 @@ static void iwl4965_rx_reply_tx(struct iwl4965_priv *priv,
3718 struct iwl4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; 3396 struct iwl4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0];
3719 u32 status = le32_to_cpu(tx_resp->status); 3397 u32 status = le32_to_cpu(tx_resp->status);
3720#ifdef CONFIG_IWL4965_HT 3398#ifdef CONFIG_IWL4965_HT
3721#ifdef CONFIG_IWL4965_HT_AGG 3399 int tid = MAX_TID_COUNT, sta_id = IWL_INVALID_STATION;
3722 int tid, sta_id; 3400 struct ieee80211_hdr *hdr;
3723#endif 3401 __le16 *qc;
3724#endif 3402#endif
3725 3403
3726 if ((index >= txq->q.n_bd) || (x2_queue_used(&txq->q, index) == 0)) { 3404 if ((index >= txq->q.n_bd) || (x2_queue_used(&txq->q, index) == 0)) {
@@ -3732,44 +3410,51 @@ static void iwl4965_rx_reply_tx(struct iwl4965_priv *priv,
3732 } 3410 }
3733 3411
3734#ifdef CONFIG_IWL4965_HT 3412#ifdef CONFIG_IWL4965_HT
3735#ifdef CONFIG_IWL4965_HT_AGG 3413 hdr = iwl4965_tx_queue_get_hdr(priv, txq_id, index);
3414 qc = ieee80211_get_qos_ctrl(hdr);
3415
3416 if (qc)
3417 tid = le16_to_cpu(*qc) & 0xf;
3418
3419 sta_id = iwl4965_get_ra_sta_id(priv, hdr);
3420 if (txq->sched_retry && unlikely(sta_id == IWL_INVALID_STATION)) {
3421 IWL_ERROR("Station not known\n");
3422 return;
3423 }
3424
3736 if (txq->sched_retry) { 3425 if (txq->sched_retry) {
3737 const u32 scd_ssn = iwl4965_get_scd_ssn(tx_resp); 3426 const u32 scd_ssn = iwl4965_get_scd_ssn(tx_resp);
3738 struct ieee80211_hdr *hdr =
3739 iwl4965_tx_queue_get_hdr(priv, txq_id, index);
3740 struct iwl4965_ht_agg *agg = NULL; 3427 struct iwl4965_ht_agg *agg = NULL;
3741 __le16 *qc = ieee80211_get_qos_ctrl(hdr);
3742
3743 if (qc == NULL) {
3744 IWL_ERROR("BUG_ON qc is null!!!!\n");
3745 return;
3746 }
3747 3428
3748 tid = le16_to_cpu(*qc) & 0xf; 3429 if (!qc)
3749
3750 sta_id = iwl4965_get_ra_sta_id(priv, hdr);
3751 if (unlikely(sta_id == IWL_INVALID_STATION)) {
3752 IWL_ERROR("Station not known for\n");
3753 return; 3430 return;
3754 }
3755 3431
3756 agg = &priv->stations[sta_id].tid[tid].agg; 3432 agg = &priv->stations[sta_id].tid[tid].agg;
3757 3433
3758 iwl4965_tx_status_reply_tx(priv, agg, tx_resp, index); 3434 iwl4965_tx_status_reply_tx(priv, agg,
3435 (struct iwl4965_tx_resp_agg *)tx_resp, index);
3759 3436
3760 if ((tx_resp->frame_count == 1) && 3437 if ((tx_resp->frame_count == 1) &&
3761 !iwl4965_is_tx_success(status)) { 3438 !iwl4965_is_tx_success(status)) {
3762 /* TODO: send BAR */ 3439 /* TODO: send BAR */
3763 } 3440 }
3764 3441
3765 if ((txq->q.read_ptr != (scd_ssn & 0xff))) { 3442 if (txq->q.read_ptr != (scd_ssn & 0xff)) {
3766 index = iwl4965_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd); 3443 int freed;
3444 index = iwl_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd);
3767 IWL_DEBUG_TX_REPLY("Retry scheduler reclaim scd_ssn " 3445 IWL_DEBUG_TX_REPLY("Retry scheduler reclaim scd_ssn "
3768 "%d index %d\n", scd_ssn , index); 3446 "%d index %d\n", scd_ssn , index);
3769 iwl4965_tx_queue_reclaim(priv, txq_id, index); 3447 freed = iwl4965_tx_queue_reclaim(priv, txq_id, index);
3448 priv->stations[sta_id].tid[tid].tfds_in_queue -= freed;
3449
3450 if (iwl4965_queue_space(&txq->q) > txq->q.low_mark &&
3451 txq_id >= 0 && priv->mac80211_registered &&
3452 agg->state != IWL_EMPTYING_HW_QUEUE_DELBA)
3453 ieee80211_wake_queue(priv->hw, txq_id);
3454
3455 iwl4965_check_empty_hw_queue(priv, sta_id, tid, txq_id);
3770 } 3456 }
3771 } else { 3457 } else {
3772#endif /* CONFIG_IWL4965_HT_AGG */
3773#endif /* CONFIG_IWL4965_HT */ 3458#endif /* CONFIG_IWL4965_HT */
3774 tx_status = &(txq->txb[txq->q.read_ptr].status); 3459 tx_status = &(txq->txb[txq->q.read_ptr].status);
3775 3460
@@ -3777,12 +3462,10 @@ static void iwl4965_rx_reply_tx(struct iwl4965_priv *priv,
3777 tx_status->queue_number = status; 3462 tx_status->queue_number = status;
3778 tx_status->queue_length = tx_resp->bt_kill_count; 3463 tx_status->queue_length = tx_resp->bt_kill_count;
3779 tx_status->queue_length |= tx_resp->failure_rts; 3464 tx_status->queue_length |= tx_resp->failure_rts;
3780
3781 tx_status->flags = 3465 tx_status->flags =
3782 iwl4965_is_tx_success(status) ? IEEE80211_TX_STATUS_ACK : 0; 3466 iwl4965_is_tx_success(status) ? IEEE80211_TX_STATUS_ACK : 0;
3783 3467 iwl4965_hwrate_to_tx_control(priv, le32_to_cpu(tx_resp->rate_n_flags),
3784 tx_status->control.tx_rate = 3468 &tx_status->control);
3785 iwl4965_hw_get_rate_n_flags(tx_resp->rate_n_flags);
3786 3469
3787 IWL_DEBUG_TX("Tx queue %d Status %s (0x%08x) rate_n_flags 0x%x " 3470 IWL_DEBUG_TX("Tx queue %d Status %s (0x%08x) rate_n_flags 0x%x "
3788 "retries %d\n", txq_id, iwl4965_get_tx_fail_reason(status), 3471 "retries %d\n", txq_id, iwl4965_get_tx_fail_reason(status),
@@ -3790,12 +3473,21 @@ static void iwl4965_rx_reply_tx(struct iwl4965_priv *priv,
3790 tx_resp->failure_frame); 3473 tx_resp->failure_frame);
3791 3474
3792 IWL_DEBUG_TX_REPLY("Tx queue reclaim %d\n", index); 3475 IWL_DEBUG_TX_REPLY("Tx queue reclaim %d\n", index);
3793 if (index != -1) 3476 if (index != -1) {
3794 iwl4965_tx_queue_reclaim(priv, txq_id, index); 3477 int freed = iwl4965_tx_queue_reclaim(priv, txq_id, index);
3478#ifdef CONFIG_IWL4965_HT
3479 if (tid != MAX_TID_COUNT)
3480 priv->stations[sta_id].tid[tid].tfds_in_queue -= freed;
3481 if (iwl4965_queue_space(&txq->q) > txq->q.low_mark &&
3482 (txq_id >= 0) &&
3483 priv->mac80211_registered)
3484 ieee80211_wake_queue(priv->hw, txq_id);
3485 if (tid != MAX_TID_COUNT)
3486 iwl4965_check_empty_hw_queue(priv, sta_id, tid, txq_id);
3487#endif
3488 }
3795#ifdef CONFIG_IWL4965_HT 3489#ifdef CONFIG_IWL4965_HT
3796#ifdef CONFIG_IWL4965_HT_AGG
3797 } 3490 }
3798#endif /* CONFIG_IWL4965_HT_AGG */
3799#endif /* CONFIG_IWL4965_HT */ 3491#endif /* CONFIG_IWL4965_HT */
3800 3492
3801 if (iwl_check_bits(status, TX_ABORT_REQUIRED_MSK)) 3493 if (iwl_check_bits(status, TX_ABORT_REQUIRED_MSK))
@@ -4907,8 +4599,7 @@ static void iwl4965_dump_nic_error_log(struct iwl4965_priv *priv)
4907 4599
4908 if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) { 4600 if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) {
4909 IWL_ERROR("Start IWL Error Log Dump:\n"); 4601 IWL_ERROR("Start IWL Error Log Dump:\n");
4910 IWL_ERROR("Status: 0x%08lX, Config: %08X count: %d\n", 4602 IWL_ERROR("Status: 0x%08lX, count: %d\n", priv->status, count);
4911 priv->status, priv->config, count);
4912 } 4603 }
4913 4604
4914 desc = iwl4965_read_targ_mem(priv, base + 1 * sizeof(u32)); 4605 desc = iwl4965_read_targ_mem(priv, base + 1 * sizeof(u32));
@@ -5120,9 +4811,9 @@ static void iwl4965_irq_tasklet(struct iwl4965_priv *priv)
5120 * atomic, make sure that inta covers all the interrupts that 4811 * atomic, make sure that inta covers all the interrupts that
5121 * we've discovered, even if FH interrupt came in just after 4812 * we've discovered, even if FH interrupt came in just after
5122 * reading CSR_INT. */ 4813 * reading CSR_INT. */
5123 if (inta_fh & CSR_FH_INT_RX_MASK) 4814 if (inta_fh & CSR49_FH_INT_RX_MASK)
5124 inta |= CSR_INT_BIT_FH_RX; 4815 inta |= CSR_INT_BIT_FH_RX;
5125 if (inta_fh & CSR_FH_INT_TX_MASK) 4816 if (inta_fh & CSR49_FH_INT_TX_MASK)
5126 inta |= CSR_INT_BIT_FH_TX; 4817 inta |= CSR_INT_BIT_FH_TX;
5127 4818
5128 /* Now service all interrupt bits discovered above. */ 4819 /* Now service all interrupt bits discovered above. */
@@ -5170,7 +4861,7 @@ static void iwl4965_irq_tasklet(struct iwl4965_priv *priv)
5170 /* Queue restart only if RF_KILL switch was set to "kill" 4861 /* Queue restart only if RF_KILL switch was set to "kill"
5171 * when we loaded driver, and is now set to "enable". 4862 * when we loaded driver, and is now set to "enable".
5172 * After we're Alive, RF_KILL gets handled by 4863 * After we're Alive, RF_KILL gets handled by
5173 * iwl_rx_card_state_notif() */ 4864 * iwl4965_rx_card_state_notif() */
5174 if (!hw_rf_kill && !test_bit(STATUS_ALIVE, &priv->status)) { 4865 if (!hw_rf_kill && !test_bit(STATUS_ALIVE, &priv->status)) {
5175 clear_bit(STATUS_RF_KILL_HW, &priv->status); 4866 clear_bit(STATUS_RF_KILL_HW, &priv->status);
5176 queue_work(priv->workqueue, &priv->restart); 4867 queue_work(priv->workqueue, &priv->restart);
@@ -5416,24 +5107,23 @@ static void iwl4965_init_band_reference(const struct iwl4965_priv *priv,
5416 * Based on band and channel number. 5107 * Based on band and channel number.
5417 */ 5108 */
5418const struct iwl4965_channel_info *iwl4965_get_channel_info(const struct iwl4965_priv *priv, 5109const struct iwl4965_channel_info *iwl4965_get_channel_info(const struct iwl4965_priv *priv,
5419 int phymode, u16 channel) 5110 enum ieee80211_band band, u16 channel)
5420{ 5111{
5421 int i; 5112 int i;
5422 5113
5423 switch (phymode) { 5114 switch (band) {
5424 case MODE_IEEE80211A: 5115 case IEEE80211_BAND_5GHZ:
5425 for (i = 14; i < priv->channel_count; i++) { 5116 for (i = 14; i < priv->channel_count; i++) {
5426 if (priv->channel_info[i].channel == channel) 5117 if (priv->channel_info[i].channel == channel)
5427 return &priv->channel_info[i]; 5118 return &priv->channel_info[i];
5428 } 5119 }
5429 break; 5120 break;
5430 5121 case IEEE80211_BAND_2GHZ:
5431 case MODE_IEEE80211B:
5432 case MODE_IEEE80211G:
5433 if (channel >= 1 && channel <= 14) 5122 if (channel >= 1 && channel <= 14)
5434 return &priv->channel_info[channel - 1]; 5123 return &priv->channel_info[channel - 1];
5435 break; 5124 break;
5436 5125 default:
5126 BUG();
5437 } 5127 }
5438 5128
5439 return NULL; 5129 return NULL;
@@ -5496,8 +5186,8 @@ static int iwl4965_init_channel_map(struct iwl4965_priv *priv)
5496 /* Loop through each band adding each of the channels */ 5186 /* Loop through each band adding each of the channels */
5497 for (ch = 0; ch < eeprom_ch_count; ch++) { 5187 for (ch = 0; ch < eeprom_ch_count; ch++) {
5498 ch_info->channel = eeprom_ch_index[ch]; 5188 ch_info->channel = eeprom_ch_index[ch];
5499 ch_info->phymode = (band == 1) ? MODE_IEEE80211B : 5189 ch_info->band = (band == 1) ? IEEE80211_BAND_2GHZ :
5500 MODE_IEEE80211A; 5190 IEEE80211_BAND_5GHZ;
5501 5191
5502 /* permanently store EEPROM's channel regulatory flags 5192 /* permanently store EEPROM's channel regulatory flags
5503 * and max power in channel info database. */ 5193 * and max power in channel info database. */
@@ -5524,11 +5214,12 @@ static int iwl4965_init_channel_map(struct iwl4965_priv *priv)
5524 ch_info->scan_power = eeprom_ch_info[ch].max_power_avg; 5214 ch_info->scan_power = eeprom_ch_info[ch].max_power_avg;
5525 ch_info->min_power = 0; 5215 ch_info->min_power = 0;
5526 5216
5527 IWL_DEBUG_INFO("Ch. %d [%sGHz] %s%s%s%s%s%s(0x%02x" 5217 IWL_DEBUG_INFO("Ch. %d [%sGHz] %s%s%s%s%s%s%s(0x%02x"
5528 " %ddBm): Ad-Hoc %ssupported\n", 5218 " %ddBm): Ad-Hoc %ssupported\n",
5529 ch_info->channel, 5219 ch_info->channel,
5530 is_channel_a_band(ch_info) ? 5220 is_channel_a_band(ch_info) ?
5531 "5.2" : "2.4", 5221 "5.2" : "2.4",
5222 CHECK_AND_PRINT(VALID),
5532 CHECK_AND_PRINT(IBSS), 5223 CHECK_AND_PRINT(IBSS),
5533 CHECK_AND_PRINT(ACTIVE), 5224 CHECK_AND_PRINT(ACTIVE),
5534 CHECK_AND_PRINT(RADAR), 5225 CHECK_AND_PRINT(RADAR),
@@ -5556,14 +5247,14 @@ static int iwl4965_init_channel_map(struct iwl4965_priv *priv)
5556 5247
5557 /* Two additional EEPROM bands for 2.4 and 5 GHz FAT channels */ 5248 /* Two additional EEPROM bands for 2.4 and 5 GHz FAT channels */
5558 for (band = 6; band <= 7; band++) { 5249 for (band = 6; band <= 7; band++) {
5559 int phymode; 5250 enum ieee80211_band ieeeband;
5560 u8 fat_extension_chan; 5251 u8 fat_extension_chan;
5561 5252
5562 iwl4965_init_band_reference(priv, band, &eeprom_ch_count, 5253 iwl4965_init_band_reference(priv, band, &eeprom_ch_count,
5563 &eeprom_ch_info, &eeprom_ch_index); 5254 &eeprom_ch_info, &eeprom_ch_index);
5564 5255
5565 /* EEPROM band 6 is 2.4, band 7 is 5 GHz */ 5256 /* EEPROM band 6 is 2.4, band 7 is 5 GHz */
5566 phymode = (band == 6) ? MODE_IEEE80211B : MODE_IEEE80211A; 5257 ieeeband = (band == 6) ? IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ;
5567 5258
5568 /* Loop through each band adding each of the channels */ 5259 /* Loop through each band adding each of the channels */
5569 for (ch = 0; ch < eeprom_ch_count; ch++) { 5260 for (ch = 0; ch < eeprom_ch_count; ch++) {
@@ -5577,13 +5268,13 @@ static int iwl4965_init_channel_map(struct iwl4965_priv *priv)
5577 fat_extension_chan = HT_IE_EXT_CHANNEL_ABOVE; 5268 fat_extension_chan = HT_IE_EXT_CHANNEL_ABOVE;
5578 5269
5579 /* Set up driver's info for lower half */ 5270 /* Set up driver's info for lower half */
5580 iwl4965_set_fat_chan_info(priv, phymode, 5271 iwl4965_set_fat_chan_info(priv, ieeeband,
5581 eeprom_ch_index[ch], 5272 eeprom_ch_index[ch],
5582 &(eeprom_ch_info[ch]), 5273 &(eeprom_ch_info[ch]),
5583 fat_extension_chan); 5274 fat_extension_chan);
5584 5275
5585 /* Set up driver's info for upper half */ 5276 /* Set up driver's info for upper half */
5586 iwl4965_set_fat_chan_info(priv, phymode, 5277 iwl4965_set_fat_chan_info(priv, ieeeband,
5587 (eeprom_ch_index[ch] + 4), 5278 (eeprom_ch_index[ch] + 4),
5588 &(eeprom_ch_info[ch]), 5279 &(eeprom_ch_info[ch]),
5589 HT_IE_EXT_CHANNEL_BELOW); 5280 HT_IE_EXT_CHANNEL_BELOW);
@@ -5625,18 +5316,20 @@ static void iwl4965_free_channel_map(struct iwl4965_priv *priv)
5625#define IWL_PASSIVE_DWELL_BASE (100) 5316#define IWL_PASSIVE_DWELL_BASE (100)
5626#define IWL_CHANNEL_TUNE_TIME 5 5317#define IWL_CHANNEL_TUNE_TIME 5
5627 5318
5628static inline u16 iwl4965_get_active_dwell_time(struct iwl4965_priv *priv, int phymode) 5319static inline u16 iwl4965_get_active_dwell_time(struct iwl4965_priv *priv,
5320 enum ieee80211_band band)
5629{ 5321{
5630 if (phymode == MODE_IEEE80211A) 5322 if (band == IEEE80211_BAND_5GHZ)
5631 return IWL_ACTIVE_DWELL_TIME_52; 5323 return IWL_ACTIVE_DWELL_TIME_52;
5632 else 5324 else
5633 return IWL_ACTIVE_DWELL_TIME_24; 5325 return IWL_ACTIVE_DWELL_TIME_24;
5634} 5326}
5635 5327
5636static u16 iwl4965_get_passive_dwell_time(struct iwl4965_priv *priv, int phymode) 5328static u16 iwl4965_get_passive_dwell_time(struct iwl4965_priv *priv,
5329 enum ieee80211_band band)
5637{ 5330{
5638 u16 active = iwl4965_get_active_dwell_time(priv, phymode); 5331 u16 active = iwl4965_get_active_dwell_time(priv, band);
5639 u16 passive = (phymode != MODE_IEEE80211A) ? 5332 u16 passive = (band != IEEE80211_BAND_5GHZ) ?
5640 IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_24 : 5333 IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_24 :
5641 IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_52; 5334 IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_52;
5642 5335
@@ -5656,28 +5349,29 @@ static u16 iwl4965_get_passive_dwell_time(struct iwl4965_priv *priv, int phymode
5656 return passive; 5349 return passive;
5657} 5350}
5658 5351
5659static int iwl4965_get_channels_for_scan(struct iwl4965_priv *priv, int phymode, 5352static int iwl4965_get_channels_for_scan(struct iwl4965_priv *priv,
5353 enum ieee80211_band band,
5660 u8 is_active, u8 direct_mask, 5354 u8 is_active, u8 direct_mask,
5661 struct iwl4965_scan_channel *scan_ch) 5355 struct iwl4965_scan_channel *scan_ch)
5662{ 5356{
5663 const struct ieee80211_channel *channels = NULL; 5357 const struct ieee80211_channel *channels = NULL;
5664 const struct ieee80211_hw_mode *hw_mode; 5358 const struct ieee80211_supported_band *sband;
5665 const struct iwl4965_channel_info *ch_info; 5359 const struct iwl4965_channel_info *ch_info;
5666 u16 passive_dwell = 0; 5360 u16 passive_dwell = 0;
5667 u16 active_dwell = 0; 5361 u16 active_dwell = 0;
5668 int added, i; 5362 int added, i;
5669 5363
5670 hw_mode = iwl4965_get_hw_mode(priv, phymode); 5364 sband = iwl4965_get_hw_mode(priv, band);
5671 if (!hw_mode) 5365 if (!sband)
5672 return 0; 5366 return 0;
5673 5367
5674 channels = hw_mode->channels; 5368 channels = sband->channels;
5675 5369
5676 active_dwell = iwl4965_get_active_dwell_time(priv, phymode); 5370 active_dwell = iwl4965_get_active_dwell_time(priv, band);
5677 passive_dwell = iwl4965_get_passive_dwell_time(priv, phymode); 5371 passive_dwell = iwl4965_get_passive_dwell_time(priv, band);
5678 5372
5679 for (i = 0, added = 0; i < hw_mode->num_channels; i++) { 5373 for (i = 0, added = 0; i < sband->n_channels; i++) {
5680 if (channels[i].chan == 5374 if (ieee80211_frequency_to_channel(channels[i].center_freq) ==
5681 le16_to_cpu(priv->active_rxon.channel)) { 5375 le16_to_cpu(priv->active_rxon.channel)) {
5682 if (iwl4965_is_associated(priv)) { 5376 if (iwl4965_is_associated(priv)) {
5683 IWL_DEBUG_SCAN 5377 IWL_DEBUG_SCAN
@@ -5688,9 +5382,9 @@ static int iwl4965_get_channels_for_scan(struct iwl4965_priv *priv, int phymode,
5688 } else if (priv->only_active_channel) 5382 } else if (priv->only_active_channel)
5689 continue; 5383 continue;
5690 5384
5691 scan_ch->channel = channels[i].chan; 5385 scan_ch->channel = ieee80211_frequency_to_channel(channels[i].center_freq);
5692 5386
5693 ch_info = iwl4965_get_channel_info(priv, phymode, 5387 ch_info = iwl4965_get_channel_info(priv, band,
5694 scan_ch->channel); 5388 scan_ch->channel);
5695 if (!is_channel_valid(ch_info)) { 5389 if (!is_channel_valid(ch_info)) {
5696 IWL_DEBUG_SCAN("Channel %d is INVALID for this SKU.\n", 5390 IWL_DEBUG_SCAN("Channel %d is INVALID for this SKU.\n",
@@ -5699,7 +5393,7 @@ static int iwl4965_get_channels_for_scan(struct iwl4965_priv *priv, int phymode,
5699 } 5393 }
5700 5394
5701 if (!is_active || is_channel_passive(ch_info) || 5395 if (!is_active || is_channel_passive(ch_info) ||
5702 !(channels[i].flag & IEEE80211_CHAN_W_ACTIVE_SCAN)) 5396 (channels[i].flags & IEEE80211_CHAN_PASSIVE_SCAN))
5703 scan_ch->type = 0; /* passive */ 5397 scan_ch->type = 0; /* passive */
5704 else 5398 else
5705 scan_ch->type = 1; /* active */ 5399 scan_ch->type = 1; /* active */
@@ -5718,7 +5412,7 @@ static int iwl4965_get_channels_for_scan(struct iwl4965_priv *priv, int phymode,
5718 /* scan_pwr_info->tpc.dsp_atten; */ 5412 /* scan_pwr_info->tpc.dsp_atten; */
5719 5413
5720 /*scan_pwr_info->tpc.tx_gain; */ 5414 /*scan_pwr_info->tpc.tx_gain; */
5721 if (phymode == MODE_IEEE80211A) 5415 if (band == IEEE80211_BAND_5GHZ)
5722 scan_ch->tpc.tx_gain = ((1 << 5) | (3 << 3)) | 3; 5416 scan_ch->tpc.tx_gain = ((1 << 5) | (3 << 3)) | 3;
5723 else { 5417 else {
5724 scan_ch->tpc.tx_gain = ((1 << 5) | (5 << 3)); 5418 scan_ch->tpc.tx_gain = ((1 << 5) | (5 << 3));
@@ -5742,41 +5436,24 @@ static int iwl4965_get_channels_for_scan(struct iwl4965_priv *priv, int phymode,
5742 return added; 5436 return added;
5743} 5437}
5744 5438
5745static void iwl4965_reset_channel_flag(struct iwl4965_priv *priv)
5746{
5747 int i, j;
5748 for (i = 0; i < 3; i++) {
5749 struct ieee80211_hw_mode *hw_mode = (void *)&priv->modes[i];
5750 for (j = 0; j < hw_mode->num_channels; j++)
5751 hw_mode->channels[j].flag = hw_mode->channels[j].val;
5752 }
5753}
5754
5755static void iwl4965_init_hw_rates(struct iwl4965_priv *priv, 5439static void iwl4965_init_hw_rates(struct iwl4965_priv *priv,
5756 struct ieee80211_rate *rates) 5440 struct ieee80211_rate *rates)
5757{ 5441{
5758 int i; 5442 int i;
5759 5443
5760 for (i = 0; i < IWL_RATE_COUNT; i++) { 5444 for (i = 0; i < IWL_RATE_COUNT; i++) {
5761 rates[i].rate = iwl4965_rates[i].ieee * 5; 5445 rates[i].bitrate = iwl4965_rates[i].ieee * 5;
5762 rates[i].val = i; /* Rate scaling will work on indexes */ 5446 rates[i].hw_value = i; /* Rate scaling will work on indexes */
5763 rates[i].val2 = i; 5447 rates[i].hw_value_short = i;
5764 rates[i].flags = IEEE80211_RATE_SUPPORTED; 5448 rates[i].flags = 0;
5765 /* Only OFDM have the bits-per-symbol set */ 5449 if ((i > IWL_LAST_OFDM_RATE) || (i < IWL_FIRST_OFDM_RATE)) {
5766 if ((i <= IWL_LAST_OFDM_RATE) && (i >= IWL_FIRST_OFDM_RATE))
5767 rates[i].flags |= IEEE80211_RATE_OFDM;
5768 else {
5769 /* 5450 /*
5770 * If CCK 1M then set rate flag to CCK else CCK_2 5451 * If CCK != 1M then set short preamble rate flag.
5771 * which is CCK | PREAMBLE2
5772 */ 5452 */
5773 rates[i].flags |= (iwl4965_rates[i].plcp == 10) ? 5453 rates[i].flags |=
5774 IEEE80211_RATE_CCK : IEEE80211_RATE_CCK_2; 5454 (iwl4965_rates[i].plcp == IWL_RATE_1M_PLCP) ?
5455 0 : IEEE80211_RATE_SHORT_PREAMBLE;
5775 } 5456 }
5776
5777 /* Set up which ones are basic rates... */
5778 if (IWL_BASIC_RATES_MASK & (1 << i))
5779 rates[i].flags |= IEEE80211_RATE_BASIC;
5780 } 5457 }
5781} 5458}
5782 5459
@@ -5786,150 +5463,117 @@ static void iwl4965_init_hw_rates(struct iwl4965_priv *priv,
5786static int iwl4965_init_geos(struct iwl4965_priv *priv) 5463static int iwl4965_init_geos(struct iwl4965_priv *priv)
5787{ 5464{
5788 struct iwl4965_channel_info *ch; 5465 struct iwl4965_channel_info *ch;
5789 struct ieee80211_hw_mode *modes; 5466 struct ieee80211_supported_band *sband;
5790 struct ieee80211_channel *channels; 5467 struct ieee80211_channel *channels;
5791 struct ieee80211_channel *geo_ch; 5468 struct ieee80211_channel *geo_ch;
5792 struct ieee80211_rate *rates; 5469 struct ieee80211_rate *rates;
5793 int i = 0; 5470 int i = 0;
5794 enum {
5795 A = 0,
5796 B = 1,
5797 G = 2,
5798 };
5799 int mode_count = 3;
5800 5471
5801 if (priv->modes) { 5472 if (priv->bands[IEEE80211_BAND_2GHZ].n_bitrates ||
5473 priv->bands[IEEE80211_BAND_5GHZ].n_bitrates) {
5802 IWL_DEBUG_INFO("Geography modes already initialized.\n"); 5474 IWL_DEBUG_INFO("Geography modes already initialized.\n");
5803 set_bit(STATUS_GEO_CONFIGURED, &priv->status); 5475 set_bit(STATUS_GEO_CONFIGURED, &priv->status);
5804 return 0; 5476 return 0;
5805 } 5477 }
5806 5478
5807 modes = kzalloc(sizeof(struct ieee80211_hw_mode) * mode_count,
5808 GFP_KERNEL);
5809 if (!modes)
5810 return -ENOMEM;
5811
5812 channels = kzalloc(sizeof(struct ieee80211_channel) * 5479 channels = kzalloc(sizeof(struct ieee80211_channel) *
5813 priv->channel_count, GFP_KERNEL); 5480 priv->channel_count, GFP_KERNEL);
5814 if (!channels) { 5481 if (!channels)
5815 kfree(modes);
5816 return -ENOMEM; 5482 return -ENOMEM;
5817 }
5818 5483
5819 rates = kzalloc((sizeof(struct ieee80211_rate) * (IWL_MAX_RATES + 1)), 5484 rates = kzalloc((sizeof(struct ieee80211_rate) * (IWL_RATE_COUNT + 1)),
5820 GFP_KERNEL); 5485 GFP_KERNEL);
5821 if (!rates) { 5486 if (!rates) {
5822 kfree(modes);
5823 kfree(channels); 5487 kfree(channels);
5824 return -ENOMEM; 5488 return -ENOMEM;
5825 } 5489 }
5826 5490
5827 /* 0 = 802.11a
5828 * 1 = 802.11b
5829 * 2 = 802.11g
5830 */
5831
5832 /* 5.2GHz channels start after the 2.4GHz channels */ 5491 /* 5.2GHz channels start after the 2.4GHz channels */
5833 modes[A].mode = MODE_IEEE80211A; 5492 sband = &priv->bands[IEEE80211_BAND_5GHZ];
5834 modes[A].channels = &channels[ARRAY_SIZE(iwl4965_eeprom_band_1)]; 5493 sband->channels = &channels[ARRAY_SIZE(iwl4965_eeprom_band_1)];
5835 modes[A].rates = rates; 5494 /* just OFDM */
5836 modes[A].num_rates = 8; /* just OFDM */ 5495 sband->bitrates = &rates[IWL_FIRST_OFDM_RATE];
5837 modes[A].rates = &rates[4]; 5496 sband->n_bitrates = IWL_RATE_COUNT - IWL_FIRST_OFDM_RATE;
5838 modes[A].num_channels = 0;
5839#ifdef CONFIG_IWL4965_HT
5840 iwl4965_init_ht_hw_capab(&modes[A].ht_info, MODE_IEEE80211A);
5841#endif
5842 5497
5843 modes[B].mode = MODE_IEEE80211B; 5498 iwl4965_init_ht_hw_capab(&sband->ht_info, IEEE80211_BAND_5GHZ);
5844 modes[B].channels = channels; 5499
5845 modes[B].rates = rates; 5500 sband = &priv->bands[IEEE80211_BAND_2GHZ];
5846 modes[B].num_rates = 4; /* just CCK */ 5501 sband->channels = channels;
5847 modes[B].num_channels = 0; 5502 /* OFDM & CCK */
5848 5503 sband->bitrates = rates;
5849 modes[G].mode = MODE_IEEE80211G; 5504 sband->n_bitrates = IWL_RATE_COUNT;
5850 modes[G].channels = channels; 5505
5851 modes[G].rates = rates; 5506 iwl4965_init_ht_hw_capab(&sband->ht_info, IEEE80211_BAND_2GHZ);
5852 modes[G].num_rates = 12; /* OFDM & CCK */
5853 modes[G].num_channels = 0;
5854#ifdef CONFIG_IWL4965_HT
5855 iwl4965_init_ht_hw_capab(&modes[G].ht_info, MODE_IEEE80211G);
5856#endif
5857 5507
5858 priv->ieee_channels = channels; 5508 priv->ieee_channels = channels;
5859 priv->ieee_rates = rates; 5509 priv->ieee_rates = rates;
5860 5510
5861 iwl4965_init_hw_rates(priv, rates); 5511 iwl4965_init_hw_rates(priv, rates);
5862 5512
5863 for (i = 0, geo_ch = channels; i < priv->channel_count; i++) { 5513 for (i = 0; i < priv->channel_count; i++) {
5864 ch = &priv->channel_info[i]; 5514 ch = &priv->channel_info[i];
5865 5515
5866 if (!is_channel_valid(ch)) { 5516 /* FIXME: might be removed if scan is OK */
5867 IWL_DEBUG_INFO("Channel %d [%sGHz] is restricted -- " 5517 if (!is_channel_valid(ch))
5868 "skipping.\n",
5869 ch->channel, is_channel_a_band(ch) ?
5870 "5.2" : "2.4");
5871 continue; 5518 continue;
5872 }
5873 5519
5874 if (is_channel_a_band(ch)) { 5520 if (is_channel_a_band(ch))
5875 geo_ch = &modes[A].channels[modes[A].num_channels++]; 5521 sband = &priv->bands[IEEE80211_BAND_5GHZ];
5876 } else { 5522 else
5877 geo_ch = &modes[B].channels[modes[B].num_channels++]; 5523 sband = &priv->bands[IEEE80211_BAND_2GHZ];
5878 modes[G].num_channels++;
5879 }
5880 5524
5881 geo_ch->freq = ieee80211chan2mhz(ch->channel); 5525 geo_ch = &sband->channels[sband->n_channels++];
5882 geo_ch->chan = ch->channel; 5526
5883 geo_ch->power_level = ch->max_power_avg; 5527 geo_ch->center_freq = ieee80211_channel_to_frequency(ch->channel);
5884 geo_ch->antenna_max = 0xff; 5528 geo_ch->max_power = ch->max_power_avg;
5529 geo_ch->max_antenna_gain = 0xff;
5530 geo_ch->hw_value = ch->channel;
5885 5531
5886 if (is_channel_valid(ch)) { 5532 if (is_channel_valid(ch)) {
5887 geo_ch->flag = IEEE80211_CHAN_W_SCAN; 5533 if (!(ch->flags & EEPROM_CHANNEL_IBSS))
5888 if (ch->flags & EEPROM_CHANNEL_IBSS) 5534 geo_ch->flags |= IEEE80211_CHAN_NO_IBSS;
5889 geo_ch->flag |= IEEE80211_CHAN_W_IBSS;
5890 5535
5891 if (ch->flags & EEPROM_CHANNEL_ACTIVE) 5536 if (!(ch->flags & EEPROM_CHANNEL_ACTIVE))
5892 geo_ch->flag |= IEEE80211_CHAN_W_ACTIVE_SCAN; 5537 geo_ch->flags |= IEEE80211_CHAN_PASSIVE_SCAN;
5893 5538
5894 if (ch->flags & EEPROM_CHANNEL_RADAR) 5539 if (ch->flags & EEPROM_CHANNEL_RADAR)
5895 geo_ch->flag |= IEEE80211_CHAN_W_RADAR_DETECT; 5540 geo_ch->flags |= IEEE80211_CHAN_RADAR;
5896 5541
5897 if (ch->max_power_avg > priv->max_channel_txpower_limit) 5542 if (ch->max_power_avg > priv->max_channel_txpower_limit)
5898 priv->max_channel_txpower_limit = 5543 priv->max_channel_txpower_limit =
5899 ch->max_power_avg; 5544 ch->max_power_avg;
5545 } else {
5546 geo_ch->flags |= IEEE80211_CHAN_DISABLED;
5900 } 5547 }
5901 5548
5902 geo_ch->val = geo_ch->flag; 5549 /* Save flags for reg domain usage */
5550 geo_ch->orig_flags = geo_ch->flags;
5551
5552 IWL_DEBUG_INFO("Channel %d Freq=%d[%sGHz] %s flag=0%X\n",
5553 ch->channel, geo_ch->center_freq,
5554 is_channel_a_band(ch) ? "5.2" : "2.4",
5555 geo_ch->flags & IEEE80211_CHAN_DISABLED ?
5556 "restricted" : "valid",
5557 geo_ch->flags);
5903 } 5558 }
5904 5559
5905 if ((modes[A].num_channels == 0) && priv->is_abg) { 5560 if ((priv->bands[IEEE80211_BAND_5GHZ].n_channels == 0) &&
5561 priv->cfg->sku & IWL_SKU_A) {
5906 printk(KERN_INFO DRV_NAME 5562 printk(KERN_INFO DRV_NAME
5907 ": Incorrectly detected BG card as ABG. Please send " 5563 ": Incorrectly detected BG card as ABG. Please send "
5908 "your PCI ID 0x%04X:0x%04X to maintainer.\n", 5564 "your PCI ID 0x%04X:0x%04X to maintainer.\n",
5909 priv->pci_dev->device, priv->pci_dev->subsystem_device); 5565 priv->pci_dev->device, priv->pci_dev->subsystem_device);
5910 priv->is_abg = 0; 5566 priv->cfg->sku &= ~IWL_SKU_A;
5911 } 5567 }
5912 5568
5913 printk(KERN_INFO DRV_NAME 5569 printk(KERN_INFO DRV_NAME
5914 ": Tunable channels: %d 802.11bg, %d 802.11a channels\n", 5570 ": Tunable channels: %d 802.11bg, %d 802.11a channels\n",
5915 modes[G].num_channels, modes[A].num_channels); 5571 priv->bands[IEEE80211_BAND_2GHZ].n_channels,
5572 priv->bands[IEEE80211_BAND_5GHZ].n_channels);
5916 5573
5917 /* 5574 priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &priv->bands[IEEE80211_BAND_2GHZ];
5918 * NOTE: We register these in preference of order -- the 5575 priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = &priv->bands[IEEE80211_BAND_5GHZ];
5919 * stack doesn't currently (as of 7.0.6 / Apr 24 '07) pick
5920 * a phymode based on rates or AP capabilities but seems to
5921 * configure it purely on if the channel being configured
5922 * is supported by a mode -- and the first match is taken
5923 */
5924 5576
5925 if (modes[G].num_channels)
5926 ieee80211_register_hwmode(priv->hw, &modes[G]);
5927 if (modes[B].num_channels)
5928 ieee80211_register_hwmode(priv->hw, &modes[B]);
5929 if (modes[A].num_channels)
5930 ieee80211_register_hwmode(priv->hw, &modes[A]);
5931
5932 priv->modes = modes;
5933 set_bit(STATUS_GEO_CONFIGURED, &priv->status); 5577 set_bit(STATUS_GEO_CONFIGURED, &priv->status);
5934 5578
5935 return 0; 5579 return 0;
@@ -5940,7 +5584,6 @@ static int iwl4965_init_geos(struct iwl4965_priv *priv)
5940 */ 5584 */
5941static void iwl4965_free_geos(struct iwl4965_priv *priv) 5585static void iwl4965_free_geos(struct iwl4965_priv *priv)
5942{ 5586{
5943 kfree(priv->modes);
5944 kfree(priv->ieee_channels); 5587 kfree(priv->ieee_channels);
5945 kfree(priv->ieee_rates); 5588 kfree(priv->ieee_rates);
5946 clear_bit(STATUS_GEO_CONFIGURED, &priv->status); 5589 clear_bit(STATUS_GEO_CONFIGURED, &priv->status);
@@ -6269,7 +5912,7 @@ static int iwl4965_read_ucode(struct iwl4965_priv *priv)
6269 struct iwl4965_ucode *ucode; 5912 struct iwl4965_ucode *ucode;
6270 int ret; 5913 int ret;
6271 const struct firmware *ucode_raw; 5914 const struct firmware *ucode_raw;
6272 const char *name = "iwlwifi-4965" IWL4965_UCODE_API ".ucode"; 5915 const char *name = priv->cfg->fw_name;
6273 u8 *src; 5916 u8 *src;
6274 size_t len; 5917 size_t len;
6275 u32 ver, inst_size, data_size, init_size, init_data_size, boot_size; 5918 u32 ver, inst_size, data_size, init_size, init_data_size, boot_size;
@@ -6941,8 +6584,9 @@ static void iwl4965_bg_request_scan(struct work_struct *data)
6941 int rc = 0; 6584 int rc = 0;
6942 struct iwl4965_scan_cmd *scan; 6585 struct iwl4965_scan_cmd *scan;
6943 struct ieee80211_conf *conf = NULL; 6586 struct ieee80211_conf *conf = NULL;
6587 u16 cmd_len;
6588 enum ieee80211_band band;
6944 u8 direct_mask; 6589 u8 direct_mask;
6945 int phymode;
6946 6590
6947 conf = ieee80211_get_hw_conf(priv->hw); 6591 conf = ieee80211_get_hw_conf(priv->hw);
6948 6592
@@ -7051,18 +6695,10 @@ static void iwl4965_bg_request_scan(struct work_struct *data)
7051 } else 6695 } else
7052 direct_mask = 0; 6696 direct_mask = 0;
7053 6697
7054 /* We don't build a direct scan probe request; the uCode will do
7055 * that based on the direct_mask added to each channel entry */
7056 scan->tx_cmd.len = cpu_to_le16(
7057 iwl4965_fill_probe_req(priv, (struct ieee80211_mgmt *)scan->data,
7058 IWL_MAX_SCAN_SIZE - sizeof(*scan), 0));
7059 scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; 6698 scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK;
7060 scan->tx_cmd.sta_id = priv->hw_setting.bcast_sta_id; 6699 scan->tx_cmd.sta_id = priv->hw_setting.bcast_sta_id;
7061 scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; 6700 scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE;
7062 6701
7063 /* flags + rate selection */
7064
7065 scan->tx_cmd.tx_flags |= cpu_to_le32(0x200);
7066 6702
7067 switch (priv->scan_bands) { 6703 switch (priv->scan_bands) {
7068 case 2: 6704 case 2:
@@ -7072,7 +6708,7 @@ static void iwl4965_bg_request_scan(struct work_struct *data)
7072 RATE_MCS_ANT_B_MSK|RATE_MCS_CCK_MSK); 6708 RATE_MCS_ANT_B_MSK|RATE_MCS_CCK_MSK);
7073 6709
7074 scan->good_CRC_th = 0; 6710 scan->good_CRC_th = 0;
7075 phymode = MODE_IEEE80211G; 6711 band = IEEE80211_BAND_2GHZ;
7076 break; 6712 break;
7077 6713
7078 case 1: 6714 case 1:
@@ -7080,7 +6716,7 @@ static void iwl4965_bg_request_scan(struct work_struct *data)
7080 iwl4965_hw_set_rate_n_flags(IWL_RATE_6M_PLCP, 6716 iwl4965_hw_set_rate_n_flags(IWL_RATE_6M_PLCP,
7081 RATE_MCS_ANT_B_MSK); 6717 RATE_MCS_ANT_B_MSK);
7082 scan->good_CRC_th = IWL_GOOD_CRC_TH; 6718 scan->good_CRC_th = IWL_GOOD_CRC_TH;
7083 phymode = MODE_IEEE80211A; 6719 band = IEEE80211_BAND_5GHZ;
7084 break; 6720 break;
7085 6721
7086 default: 6722 default:
@@ -7088,6 +6724,13 @@ static void iwl4965_bg_request_scan(struct work_struct *data)
7088 goto done; 6724 goto done;
7089 } 6725 }
7090 6726
6727 /* We don't build a direct scan probe request; the uCode will do
6728 * that based on the direct_mask added to each channel entry */
6729 cmd_len = iwl4965_fill_probe_req(priv, band,
6730 (struct ieee80211_mgmt *)scan->data,
6731 IWL_MAX_SCAN_SIZE - sizeof(*scan), 0);
6732
6733 scan->tx_cmd.len = cpu_to_le16(cmd_len);
7091 /* select Rx chains */ 6734 /* select Rx chains */
7092 6735
7093 /* Force use of chains B and C (0x6) for scan Rx. 6736 /* Force use of chains B and C (0x6) for scan Rx.
@@ -7101,18 +6744,23 @@ static void iwl4965_bg_request_scan(struct work_struct *data)
7101 if (priv->iw_mode == IEEE80211_IF_TYPE_MNTR) 6744 if (priv->iw_mode == IEEE80211_IF_TYPE_MNTR)
7102 scan->filter_flags = RXON_FILTER_PROMISC_MSK; 6745 scan->filter_flags = RXON_FILTER_PROMISC_MSK;
7103 6746
7104 if (direct_mask) 6747 if (direct_mask) {
7105 IWL_DEBUG_SCAN 6748 IWL_DEBUG_SCAN
7106 ("Initiating direct scan for %s.\n", 6749 ("Initiating direct scan for %s.\n",
7107 iwl4965_escape_essid(priv->essid, priv->essid_len)); 6750 iwl4965_escape_essid(priv->essid, priv->essid_len));
7108 else 6751 scan->channel_count =
6752 iwl4965_get_channels_for_scan(
6753 priv, band, 1, /* active */
6754 direct_mask,
6755 (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]);
6756 } else {
7109 IWL_DEBUG_SCAN("Initiating indirect scan.\n"); 6757 IWL_DEBUG_SCAN("Initiating indirect scan.\n");
7110 6758 scan->channel_count =
7111 scan->channel_count = 6759 iwl4965_get_channels_for_scan(
7112 iwl4965_get_channels_for_scan( 6760 priv, band, 0, /* passive */
7113 priv, phymode, 1, /* active */ 6761 direct_mask,
7114 direct_mask, 6762 (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]);
7115 (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]); 6763 }
7116 6764
7117 cmd.len += le16_to_cpu(scan->tx_cmd.len) + 6765 cmd.len += le16_to_cpu(scan->tx_cmd.len) +
7118 scan->channel_count * sizeof(struct iwl4965_scan_channel); 6766 scan->channel_count * sizeof(struct iwl4965_scan_channel);
@@ -7281,9 +6929,8 @@ static void iwl4965_bg_post_associate(struct work_struct *data)
7281 if (priv->iw_mode == IEEE80211_IF_TYPE_IBSS) 6929 if (priv->iw_mode == IEEE80211_IF_TYPE_IBSS)
7282 priv->assoc_station_added = 1; 6930 priv->assoc_station_added = 1;
7283 6931
7284#ifdef CONFIG_IWL4965_QOS
7285 iwl4965_activate_qos(priv, 0); 6932 iwl4965_activate_qos(priv, 0);
7286#endif /* CONFIG_IWL4965_QOS */ 6933
7287 /* we have just associated, don't start scan too early */ 6934 /* we have just associated, don't start scan too early */
7288 priv->next_scan_jiffies = jiffies + IWL_DELAY_NEXT_SCAN; 6935 priv->next_scan_jiffies = jiffies + IWL_DELAY_NEXT_SCAN;
7289 mutex_unlock(&priv->mutex); 6936 mutex_unlock(&priv->mutex);
@@ -7460,7 +7107,7 @@ static int iwl4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb,
7460 } 7107 }
7461 7108
7462 IWL_DEBUG_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, 7109 IWL_DEBUG_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len,
7463 ctl->tx_rate); 7110 ctl->tx_rate->bitrate);
7464 7111
7465 if (iwl4965_tx_skb(priv, skb, ctl)) 7112 if (iwl4965_tx_skb(priv, skb, ctl))
7466 dev_kfree_skb_any(skb); 7113 dev_kfree_skb_any(skb);
@@ -7519,7 +7166,7 @@ static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *co
7519 int ret = 0; 7166 int ret = 0;
7520 7167
7521 mutex_lock(&priv->mutex); 7168 mutex_lock(&priv->mutex);
7522 IWL_DEBUG_MAC80211("enter to channel %d\n", conf->channel); 7169 IWL_DEBUG_MAC80211("enter to channel %d\n", conf->channel->hw_value);
7523 7170
7524 priv->add_radiotap = !!(conf->flags & IEEE80211_CONF_RADIOTAP); 7171 priv->add_radiotap = !!(conf->flags & IEEE80211_CONF_RADIOTAP);
7525 7172
@@ -7539,10 +7186,9 @@ static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *co
7539 7186
7540 spin_lock_irqsave(&priv->lock, flags); 7187 spin_lock_irqsave(&priv->lock, flags);
7541 7188
7542 ch_info = iwl4965_get_channel_info(priv, conf->phymode, conf->channel); 7189 ch_info = iwl4965_get_channel_info(priv, conf->channel->band,
7190 ieee80211_frequency_to_channel(conf->channel->center_freq));
7543 if (!is_channel_valid(ch_info)) { 7191 if (!is_channel_valid(ch_info)) {
7544 IWL_DEBUG_SCAN("Channel %d [%d] is INVALID for this SKU.\n",
7545 conf->channel, conf->phymode);
7546 IWL_DEBUG_MAC80211("leave - invalid channel\n"); 7192 IWL_DEBUG_MAC80211("leave - invalid channel\n");
7547 spin_unlock_irqrestore(&priv->lock, flags); 7193 spin_unlock_irqrestore(&priv->lock, flags);
7548 ret = -EINVAL; 7194 ret = -EINVAL;
@@ -7550,10 +7196,10 @@ static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *co
7550 } 7196 }
7551 7197
7552#ifdef CONFIG_IWL4965_HT 7198#ifdef CONFIG_IWL4965_HT
7553 /* if we are switching fron ht to 2.4 clear flags 7199 /* if we are switching from ht to 2.4 clear flags
7554 * from any ht related info since 2.4 does not 7200 * from any ht related info since 2.4 does not
7555 * support ht */ 7201 * support ht */
7556 if ((le16_to_cpu(priv->staging_rxon.channel) != conf->channel) 7202 if ((le16_to_cpu(priv->staging_rxon.channel) != conf->channel->hw_value)
7557#ifdef IEEE80211_CONF_CHANNEL_SWITCH 7203#ifdef IEEE80211_CONF_CHANNEL_SWITCH
7558 && !(conf->flags & IEEE80211_CONF_CHANNEL_SWITCH) 7204 && !(conf->flags & IEEE80211_CONF_CHANNEL_SWITCH)
7559#endif 7205#endif
@@ -7561,12 +7207,13 @@ static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *co
7561 priv->staging_rxon.flags = 0; 7207 priv->staging_rxon.flags = 0;
7562#endif /* CONFIG_IWL4965_HT */ 7208#endif /* CONFIG_IWL4965_HT */
7563 7209
7564 iwl4965_set_rxon_channel(priv, conf->phymode, conf->channel); 7210 iwl4965_set_rxon_channel(priv, conf->channel->band,
7211 ieee80211_frequency_to_channel(conf->channel->center_freq));
7565 7212
7566 iwl4965_set_flags_for_phymode(priv, conf->phymode); 7213 iwl4965_set_flags_for_phymode(priv, conf->channel->band);
7567 7214
7568 /* The list of supported rates and rate mask can be different 7215 /* The list of supported rates and rate mask can be different
7569 * for each phymode; since the phymode may have changed, reset 7216 * for each band; since the band may have changed, reset
7570 * the rate mask to what mac80211 lists */ 7217 * the rate mask to what mac80211 lists */
7571 iwl4965_set_rate(priv); 7218 iwl4965_set_rate(priv);
7572 7219
@@ -7658,9 +7305,7 @@ static void iwl4965_config_ap(struct iwl4965_priv *priv)
7658 /* restore RXON assoc */ 7305 /* restore RXON assoc */
7659 priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK; 7306 priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK;
7660 iwl4965_commit_rxon(priv); 7307 iwl4965_commit_rxon(priv);
7661#ifdef CONFIG_IWL4965_QOS
7662 iwl4965_activate_qos(priv, 1); 7308 iwl4965_activate_qos(priv, 1);
7663#endif
7664 iwl4965_rxon_add_station(priv, iwl4965_broadcast_addr, 0); 7309 iwl4965_rxon_add_station(priv, iwl4965_broadcast_addr, 0);
7665 } 7310 }
7666 iwl4965_send_beacon_cmd(priv); 7311 iwl4965_send_beacon_cmd(priv);
@@ -7682,6 +7327,12 @@ static int iwl4965_mac_config_interface(struct ieee80211_hw *hw,
7682 if (conf == NULL) 7327 if (conf == NULL)
7683 return -EIO; 7328 return -EIO;
7684 7329
7330 if (priv->vif != vif) {
7331 IWL_DEBUG_MAC80211("leave - priv->vif != vif\n");
7332 mutex_unlock(&priv->mutex);
7333 return 0;
7334 }
7335
7685 if ((priv->iw_mode == IEEE80211_IF_TYPE_AP) && 7336 if ((priv->iw_mode == IEEE80211_IF_TYPE_AP) &&
7686 (!conf->beacon || !conf->ssid_len)) { 7337 (!conf->beacon || !conf->ssid_len)) {
7687 IWL_DEBUG_MAC80211 7338 IWL_DEBUG_MAC80211
@@ -7704,17 +7355,6 @@ static int iwl4965_mac_config_interface(struct ieee80211_hw *hw,
7704 if (unlikely(test_bit(STATUS_SCANNING, &priv->status)) && 7355 if (unlikely(test_bit(STATUS_SCANNING, &priv->status)) &&
7705 !(priv->hw->flags & IEEE80211_HW_NO_PROBE_FILTERING)) { 7356 !(priv->hw->flags & IEEE80211_HW_NO_PROBE_FILTERING)) {
7706 */ 7357 */
7707 if (unlikely(test_bit(STATUS_SCANNING, &priv->status))) {
7708 IWL_DEBUG_MAC80211("leave - scanning\n");
7709 mutex_unlock(&priv->mutex);
7710 return 0;
7711 }
7712
7713 if (priv->vif != vif) {
7714 IWL_DEBUG_MAC80211("leave - priv->vif != vif\n");
7715 mutex_unlock(&priv->mutex);
7716 return 0;
7717 }
7718 7358
7719 if (priv->iw_mode == IEEE80211_IF_TYPE_AP) { 7359 if (priv->iw_mode == IEEE80211_IF_TYPE_AP) {
7720 if (!conf->bssid) { 7360 if (!conf->bssid) {
@@ -7836,7 +7476,7 @@ static void iwl4965_bss_info_changed(struct ieee80211_hw *hw,
7836 } 7476 }
7837 7477
7838 if (changes & BSS_CHANGED_ERP_CTS_PROT) { 7478 if (changes & BSS_CHANGED_ERP_CTS_PROT) {
7839 if (bss_conf->use_cts_prot && (priv->phymode != MODE_IEEE80211A)) 7479 if (bss_conf->use_cts_prot && (priv->band != IEEE80211_BAND_5GHZ))
7840 priv->staging_rxon.flags |= RXON_FLG_TGG_PROTECT_MSK; 7480 priv->staging_rxon.flags |= RXON_FLG_TGG_PROTECT_MSK;
7841 else 7481 else
7842 priv->staging_rxon.flags &= ~RXON_FLG_TGG_PROTECT_MSK; 7482 priv->staging_rxon.flags &= ~RXON_FLG_TGG_PROTECT_MSK;
@@ -7974,10 +7614,8 @@ static int iwl4965_mac_conf_tx(struct ieee80211_hw *hw, int queue,
7974 const struct ieee80211_tx_queue_params *params) 7614 const struct ieee80211_tx_queue_params *params)
7975{ 7615{
7976 struct iwl4965_priv *priv = hw->priv; 7616 struct iwl4965_priv *priv = hw->priv;
7977#ifdef CONFIG_IWL4965_QOS
7978 unsigned long flags; 7617 unsigned long flags;
7979 int q; 7618 int q;
7980#endif /* CONFIG_IWL4965_QOS */
7981 7619
7982 IWL_DEBUG_MAC80211("enter\n"); 7620 IWL_DEBUG_MAC80211("enter\n");
7983 7621
@@ -7991,7 +7629,6 @@ static int iwl4965_mac_conf_tx(struct ieee80211_hw *hw, int queue,
7991 return 0; 7629 return 0;
7992 } 7630 }
7993 7631
7994#ifdef CONFIG_IWL4965_QOS
7995 if (!priv->qos_data.qos_enable) { 7632 if (!priv->qos_data.qos_enable) {
7996 priv->qos_data.qos_active = 0; 7633 priv->qos_data.qos_active = 0;
7997 IWL_DEBUG_MAC80211("leave - qos not enabled\n"); 7634 IWL_DEBUG_MAC80211("leave - qos not enabled\n");
@@ -8005,7 +7642,7 @@ static int iwl4965_mac_conf_tx(struct ieee80211_hw *hw, int queue,
8005 priv->qos_data.def_qos_parm.ac[q].cw_max = cpu_to_le16(params->cw_max); 7642 priv->qos_data.def_qos_parm.ac[q].cw_max = cpu_to_le16(params->cw_max);
8006 priv->qos_data.def_qos_parm.ac[q].aifsn = params->aifs; 7643 priv->qos_data.def_qos_parm.ac[q].aifsn = params->aifs;
8007 priv->qos_data.def_qos_parm.ac[q].edca_txop = 7644 priv->qos_data.def_qos_parm.ac[q].edca_txop =
8008 cpu_to_le16((params->burst_time * 100)); 7645 cpu_to_le16((params->txop * 32));
8009 7646
8010 priv->qos_data.def_qos_parm.ac[q].reserved1 = 0; 7647 priv->qos_data.def_qos_parm.ac[q].reserved1 = 0;
8011 priv->qos_data.qos_active = 1; 7648 priv->qos_data.qos_active = 1;
@@ -8020,8 +7657,6 @@ static int iwl4965_mac_conf_tx(struct ieee80211_hw *hw, int queue,
8020 7657
8021 mutex_unlock(&priv->mutex); 7658 mutex_unlock(&priv->mutex);
8022 7659
8023#endif /*CONFIG_IWL4965_QOS */
8024
8025 IWL_DEBUG_MAC80211("leave\n"); 7660 IWL_DEBUG_MAC80211("leave\n");
8026 return 0; 7661 return 0;
8027} 7662}
@@ -8091,23 +7726,9 @@ static void iwl4965_mac_reset_tsf(struct ieee80211_hw *hw)
8091 spin_lock_irqsave(&priv->lock, flags); 7726 spin_lock_irqsave(&priv->lock, flags);
8092 memset(&priv->current_ht_config, 0, sizeof(struct iwl_ht_info)); 7727 memset(&priv->current_ht_config, 0, sizeof(struct iwl_ht_info));
8093 spin_unlock_irqrestore(&priv->lock, flags); 7728 spin_unlock_irqrestore(&priv->lock, flags);
8094#ifdef CONFIG_IWL4965_HT_AGG
8095/* if (priv->lq_mngr.agg_ctrl.granted_ba)
8096 iwl4965_turn_off_agg(priv, TID_ALL_SPECIFIED);*/
8097
8098 memset(&(priv->lq_mngr.agg_ctrl), 0, sizeof(struct iwl4965_agg_control));
8099 priv->lq_mngr.agg_ctrl.tid_traffic_load_threshold = 10;
8100 priv->lq_mngr.agg_ctrl.ba_timeout = 5000;
8101 priv->lq_mngr.agg_ctrl.auto_agg = 1;
8102
8103 if (priv->lq_mngr.agg_ctrl.auto_agg)
8104 priv->lq_mngr.agg_ctrl.requested_ba = TID_ALL_ENABLED;
8105#endif /*CONFIG_IWL4965_HT_AGG */
8106#endif /* CONFIG_IWL4965_HT */ 7729#endif /* CONFIG_IWL4965_HT */
8107 7730
8108#ifdef CONFIG_IWL4965_QOS
8109 iwl4965_reset_qos(priv); 7731 iwl4965_reset_qos(priv);
8110#endif
8111 7732
8112 cancel_delayed_work(&priv->post_associate); 7733 cancel_delayed_work(&priv->post_associate);
8113 7734
@@ -8196,9 +7817,7 @@ static int iwl4965_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *sk
8196 IWL_DEBUG_MAC80211("leave\n"); 7817 IWL_DEBUG_MAC80211("leave\n");
8197 spin_unlock_irqrestore(&priv->lock, flags); 7818 spin_unlock_irqrestore(&priv->lock, flags);
8198 7819
8199#ifdef CONFIG_IWL4965_QOS
8200 iwl4965_reset_qos(priv); 7820 iwl4965_reset_qos(priv);
8201#endif
8202 7821
8203 queue_work(priv->workqueue, &priv->post_associate.work); 7822 queue_work(priv->workqueue, &priv->post_associate.work);
8204 7823
@@ -8234,15 +7853,21 @@ static void iwl4965_ht_info_fill(struct ieee80211_conf *conf,
8234 iwl_conf->is_green_field = !!(ht_conf->cap & IEEE80211_HT_CAP_GRN_FLD); 7853 iwl_conf->is_green_field = !!(ht_conf->cap & IEEE80211_HT_CAP_GRN_FLD);
8235 iwl_conf->max_amsdu_size = 7854 iwl_conf->max_amsdu_size =
8236 !!(ht_conf->cap & IEEE80211_HT_CAP_MAX_AMSDU); 7855 !!(ht_conf->cap & IEEE80211_HT_CAP_MAX_AMSDU);
7856
8237 iwl_conf->supported_chan_width = 7857 iwl_conf->supported_chan_width =
8238 !!(ht_conf->cap & IEEE80211_HT_CAP_SUP_WIDTH); 7858 !!(ht_conf->cap & IEEE80211_HT_CAP_SUP_WIDTH);
7859 iwl_conf->extension_chan_offset =
7860 ht_bss_conf->bss_cap & IEEE80211_HT_IE_CHA_SEC_OFFSET;
7861 /* If no above or below channel supplied disable FAT channel */
7862 if (iwl_conf->extension_chan_offset != IWL_EXT_CHANNEL_OFFSET_ABOVE &&
7863 iwl_conf->extension_chan_offset != IWL_EXT_CHANNEL_OFFSET_BELOW)
7864 iwl_conf->supported_chan_width = 0;
7865
8239 iwl_conf->tx_mimo_ps_mode = 7866 iwl_conf->tx_mimo_ps_mode =
8240 (u8)((ht_conf->cap & IEEE80211_HT_CAP_MIMO_PS) >> 2); 7867 (u8)((ht_conf->cap & IEEE80211_HT_CAP_MIMO_PS) >> 2);
8241 memcpy(iwl_conf->supp_mcs_set, ht_conf->supp_mcs_set, 16); 7868 memcpy(iwl_conf->supp_mcs_set, ht_conf->supp_mcs_set, 16);
8242 7869
8243 iwl_conf->control_channel = ht_bss_conf->primary_channel; 7870 iwl_conf->control_channel = ht_bss_conf->primary_channel;
8244 iwl_conf->extension_chan_offset =
8245 ht_bss_conf->bss_cap & IEEE80211_HT_IE_CHA_SEC_OFFSET;
8246 iwl_conf->tx_chan_width = 7871 iwl_conf->tx_chan_width =
8247 !!(ht_bss_conf->bss_cap & IEEE80211_HT_IE_CHA_WIDTH); 7872 !!(ht_bss_conf->bss_cap & IEEE80211_HT_IE_CHA_WIDTH);
8248 iwl_conf->ht_protection = 7873 iwl_conf->ht_protection =
@@ -8281,28 +7906,6 @@ static int iwl4965_mac_conf_ht(struct ieee80211_hw *hw,
8281 return 0; 7906 return 0;
8282} 7907}
8283 7908
8284static void iwl4965_set_ht_capab(struct ieee80211_hw *hw,
8285 struct ieee80211_ht_cap *ht_cap,
8286 u8 use_current_config)
8287{
8288 struct ieee80211_conf *conf = &hw->conf;
8289 struct ieee80211_hw_mode *mode = conf->mode;
8290
8291 if (use_current_config) {
8292 ht_cap->cap_info = cpu_to_le16(conf->ht_conf.cap);
8293 memcpy(ht_cap->supp_mcs_set,
8294 conf->ht_conf.supp_mcs_set, 16);
8295 } else {
8296 ht_cap->cap_info = cpu_to_le16(mode->ht_info.cap);
8297 memcpy(ht_cap->supp_mcs_set,
8298 mode->ht_info.supp_mcs_set, 16);
8299 }
8300 ht_cap->ampdu_params_info =
8301 (mode->ht_info.ampdu_factor & IEEE80211_HT_CAP_AMPDU_FACTOR) |
8302 ((mode->ht_info.ampdu_density << 2) &
8303 IEEE80211_HT_CAP_AMPDU_DENSITY);
8304}
8305
8306#endif /*CONFIG_IWL4965_HT*/ 7909#endif /*CONFIG_IWL4965_HT*/
8307 7910
8308/***************************************************************************** 7911/*****************************************************************************
@@ -8497,65 +8100,6 @@ static ssize_t store_filter_flags(struct device *d,
8497static DEVICE_ATTR(filter_flags, S_IWUSR | S_IRUGO, show_filter_flags, 8100static DEVICE_ATTR(filter_flags, S_IWUSR | S_IRUGO, show_filter_flags,
8498 store_filter_flags); 8101 store_filter_flags);
8499 8102
8500static ssize_t show_tune(struct device *d,
8501 struct device_attribute *attr, char *buf)
8502{
8503 struct iwl4965_priv *priv = (struct iwl4965_priv *)d->driver_data;
8504
8505 return sprintf(buf, "0x%04X\n",
8506 (priv->phymode << 8) |
8507 le16_to_cpu(priv->active_rxon.channel));
8508}
8509
8510static void iwl4965_set_flags_for_phymode(struct iwl4965_priv *priv, u8 phymode);
8511
8512static ssize_t store_tune(struct device *d,
8513 struct device_attribute *attr,
8514 const char *buf, size_t count)
8515{
8516 struct iwl4965_priv *priv = (struct iwl4965_priv *)d->driver_data;
8517 char *p = (char *)buf;
8518 u16 tune = simple_strtoul(p, &p, 0);
8519 u8 phymode = (tune >> 8) & 0xff;
8520 u16 channel = tune & 0xff;
8521
8522 IWL_DEBUG_INFO("Tune request to:%d channel:%d\n", phymode, channel);
8523
8524 mutex_lock(&priv->mutex);
8525 if ((le16_to_cpu(priv->staging_rxon.channel) != channel) ||
8526 (priv->phymode != phymode)) {
8527 const struct iwl4965_channel_info *ch_info;
8528
8529 ch_info = iwl4965_get_channel_info(priv, phymode, channel);
8530 if (!ch_info) {
8531 IWL_WARNING("Requested invalid phymode/channel "
8532 "combination: %d %d\n", phymode, channel);
8533 mutex_unlock(&priv->mutex);
8534 return -EINVAL;
8535 }
8536
8537 /* Cancel any currently running scans... */
8538 if (iwl4965_scan_cancel_timeout(priv, 100))
8539 IWL_WARNING("Could not cancel scan.\n");
8540 else {
8541 IWL_DEBUG_INFO("Committing phymode and "
8542 "rxon.channel = %d %d\n",
8543 phymode, channel);
8544
8545 iwl4965_set_rxon_channel(priv, phymode, channel);
8546 iwl4965_set_flags_for_phymode(priv, phymode);
8547
8548 iwl4965_set_rate(priv);
8549 iwl4965_commit_rxon(priv);
8550 }
8551 }
8552 mutex_unlock(&priv->mutex);
8553
8554 return count;
8555}
8556
8557static DEVICE_ATTR(tune, S_IWUSR | S_IRUGO, show_tune, store_tune);
8558
8559#ifdef CONFIG_IWL4965_SPECTRUM_MEASUREMENT 8103#ifdef CONFIG_IWL4965_SPECTRUM_MEASUREMENT
8560 8104
8561static ssize_t show_measurement(struct device *d, 8105static ssize_t show_measurement(struct device *d,
@@ -8745,73 +8289,8 @@ static DEVICE_ATTR(power_level, S_IWUSR | S_IRUSR, show_power_level,
8745static ssize_t show_channels(struct device *d, 8289static ssize_t show_channels(struct device *d,
8746 struct device_attribute *attr, char *buf) 8290 struct device_attribute *attr, char *buf)
8747{ 8291{
8748 struct iwl4965_priv *priv = dev_get_drvdata(d); 8292 /* all this shit doesn't belong into sysfs anyway */
8749 int len = 0, i; 8293 return 0;
8750 struct ieee80211_channel *channels = NULL;
8751 const struct ieee80211_hw_mode *hw_mode = NULL;
8752 int count = 0;
8753
8754 if (!iwl4965_is_ready(priv))
8755 return -EAGAIN;
8756
8757 hw_mode = iwl4965_get_hw_mode(priv, MODE_IEEE80211G);
8758 if (!hw_mode)
8759 hw_mode = iwl4965_get_hw_mode(priv, MODE_IEEE80211B);
8760 if (hw_mode) {
8761 channels = hw_mode->channels;
8762 count = hw_mode->num_channels;
8763 }
8764
8765 len +=
8766 sprintf(&buf[len],
8767 "Displaying %d channels in 2.4GHz band "
8768 "(802.11bg):\n", count);
8769
8770 for (i = 0; i < count; i++)
8771 len += sprintf(&buf[len], "%d: %ddBm: BSS%s%s, %s.\n",
8772 channels[i].chan,
8773 channels[i].power_level,
8774 channels[i].
8775 flag & IEEE80211_CHAN_W_RADAR_DETECT ?
8776 " (IEEE 802.11h required)" : "",
8777 (!(channels[i].flag & IEEE80211_CHAN_W_IBSS)
8778 || (channels[i].
8779 flag &
8780 IEEE80211_CHAN_W_RADAR_DETECT)) ? "" :
8781 ", IBSS",
8782 channels[i].
8783 flag & IEEE80211_CHAN_W_ACTIVE_SCAN ?
8784 "active/passive" : "passive only");
8785
8786 hw_mode = iwl4965_get_hw_mode(priv, MODE_IEEE80211A);
8787 if (hw_mode) {
8788 channels = hw_mode->channels;
8789 count = hw_mode->num_channels;
8790 } else {
8791 channels = NULL;
8792 count = 0;
8793 }
8794
8795 len += sprintf(&buf[len], "Displaying %d channels in 5.2GHz band "
8796 "(802.11a):\n", count);
8797
8798 for (i = 0; i < count; i++)
8799 len += sprintf(&buf[len], "%d: %ddBm: BSS%s%s, %s.\n",
8800 channels[i].chan,
8801 channels[i].power_level,
8802 channels[i].
8803 flag & IEEE80211_CHAN_W_RADAR_DETECT ?
8804 " (IEEE 802.11h required)" : "",
8805 (!(channels[i].flag & IEEE80211_CHAN_W_IBSS)
8806 || (channels[i].
8807 flag &
8808 IEEE80211_CHAN_W_RADAR_DETECT)) ? "" :
8809 ", IBSS",
8810 channels[i].
8811 flag & IEEE80211_CHAN_W_ACTIVE_SCAN ?
8812 "active/passive" : "passive only");
8813
8814 return len;
8815} 8294}
8816 8295
8817static DEVICE_ATTR(channels, S_IRUSR, show_channels, NULL); 8296static DEVICE_ATTR(channels, S_IRUSR, show_channels, NULL);
@@ -8990,7 +8469,6 @@ static struct attribute *iwl4965_sysfs_entries[] = {
8990 &dev_attr_statistics.attr, 8469 &dev_attr_statistics.attr,
8991 &dev_attr_status.attr, 8470 &dev_attr_status.attr,
8992 &dev_attr_temperature.attr, 8471 &dev_attr_temperature.attr,
8993 &dev_attr_tune.attr,
8994 &dev_attr_tx_power.attr, 8472 &dev_attr_tx_power.attr,
8995 8473
8996 NULL 8474 NULL
@@ -9021,10 +8499,6 @@ static struct ieee80211_ops iwl4965_hw_ops = {
9021#ifdef CONFIG_IWL4965_HT 8499#ifdef CONFIG_IWL4965_HT
9022 .conf_ht = iwl4965_mac_conf_ht, 8500 .conf_ht = iwl4965_mac_conf_ht,
9023 .ampdu_action = iwl4965_mac_ampdu_action, 8501 .ampdu_action = iwl4965_mac_ampdu_action,
9024#ifdef CONFIG_IWL4965_HT_AGG
9025 .ht_tx_agg_start = iwl4965_mac_ht_tx_agg_start,
9026 .ht_tx_agg_stop = iwl4965_mac_ht_tx_agg_stop,
9027#endif /* CONFIG_IWL4965_HT_AGG */
9028#endif /* CONFIG_IWL4965_HT */ 8502#endif /* CONFIG_IWL4965_HT */
9029 .hw_scan = iwl4965_mac_hw_scan 8503 .hw_scan = iwl4965_mac_hw_scan
9030}; 8504};
@@ -9034,6 +8508,7 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
9034 int err = 0; 8508 int err = 0;
9035 struct iwl4965_priv *priv; 8509 struct iwl4965_priv *priv;
9036 struct ieee80211_hw *hw; 8510 struct ieee80211_hw *hw;
8511 struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data);
9037 int i; 8512 int i;
9038 DECLARE_MAC_BUF(mac); 8513 DECLARE_MAC_BUF(mac);
9039 8514
@@ -9067,6 +8542,7 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
9067 IWL_DEBUG_INFO("*** LOAD DRIVER ***\n"); 8542 IWL_DEBUG_INFO("*** LOAD DRIVER ***\n");
9068 priv = hw->priv; 8543 priv = hw->priv;
9069 priv->hw = hw; 8544 priv->hw = hw;
8545 priv->cfg = cfg;
9070 8546
9071 priv->pci_dev = pdev; 8547 priv->pci_dev = pdev;
9072 priv->antenna = (enum iwl4965_antenna)iwl4965_param_antenna; 8548 priv->antenna = (enum iwl4965_antenna)iwl4965_param_antenna;
@@ -9093,10 +8569,8 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
9093 /* Default value; 4 EDCA QOS priorities */ 8569 /* Default value; 4 EDCA QOS priorities */
9094 hw->queues = 4; 8570 hw->queues = 4;
9095#ifdef CONFIG_IWL4965_HT 8571#ifdef CONFIG_IWL4965_HT
9096#ifdef CONFIG_IWL4965_HT_AGG
9097 /* Enhanced value; more queues, to support 11n aggregation */ 8572 /* Enhanced value; more queues, to support 11n aggregation */
9098 hw->queues = 16; 8573 hw->queues = 16;
9099#endif /* CONFIG_IWL4965_HT_AGG */
9100#endif /* CONFIG_IWL4965_HT */ 8574#endif /* CONFIG_IWL4965_HT */
9101 8575
9102 spin_lock_init(&priv->lock); 8576 spin_lock_init(&priv->lock);
@@ -9124,7 +8598,7 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
9124 priv->data_retry_limit = -1; 8598 priv->data_retry_limit = -1;
9125 priv->ieee_channels = NULL; 8599 priv->ieee_channels = NULL;
9126 priv->ieee_rates = NULL; 8600 priv->ieee_rates = NULL;
9127 priv->phymode = -1; 8601 priv->band = IEEE80211_BAND_2GHZ;
9128 8602
9129 err = pci_set_dma_mask(pdev, DMA_32BIT_MASK); 8603 err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
9130 if (!err) 8604 if (!err)
@@ -9171,8 +8645,9 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
9171 /* Choose which receivers/antennas to use */ 8645 /* Choose which receivers/antennas to use */
9172 iwl4965_set_rxon_chain(priv); 8646 iwl4965_set_rxon_chain(priv);
9173 8647
8648
9174 printk(KERN_INFO DRV_NAME 8649 printk(KERN_INFO DRV_NAME
9175 ": Detected Intel Wireless WiFi Link 4965AGN\n"); 8650 ": Detected Intel Wireless WiFi Link %s\n", priv->cfg->name);
9176 8651
9177 /* Device-specific setup */ 8652 /* Device-specific setup */
9178 if (iwl4965_hw_set_hw_setting(priv)) { 8653 if (iwl4965_hw_set_hw_setting(priv)) {
@@ -9180,7 +8655,6 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
9180 goto out_iounmap; 8655 goto out_iounmap;
9181 } 8656 }
9182 8657
9183#ifdef CONFIG_IWL4965_QOS
9184 if (iwl4965_param_qos_enable) 8658 if (iwl4965_param_qos_enable)
9185 priv->qos_data.qos_enable = 1; 8659 priv->qos_data.qos_enable = 1;
9186 8660
@@ -9188,9 +8662,8 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
9188 8662
9189 priv->qos_data.qos_active = 0; 8663 priv->qos_data.qos_active = 0;
9190 priv->qos_data.qos_cap.val = 0; 8664 priv->qos_data.qos_cap.val = 0;
9191#endif /* CONFIG_IWL4965_QOS */
9192 8665
9193 iwl4965_set_rxon_channel(priv, MODE_IEEE80211G, 6); 8666 iwl4965_set_rxon_channel(priv, IEEE80211_BAND_2GHZ, 6);
9194 iwl4965_setup_deferred_work(priv); 8667 iwl4965_setup_deferred_work(priv);
9195 iwl4965_setup_rx_handlers(priv); 8668 iwl4965_setup_rx_handlers(priv);
9196 8669
@@ -9220,13 +8693,13 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
9220 goto out_remove_sysfs; 8693 goto out_remove_sysfs;
9221 } 8694 }
9222 /* Read the EEPROM */ 8695 /* Read the EEPROM */
9223 err = iwl4965_eeprom_init(priv); 8696 err = iwl_eeprom_init(priv);
9224 if (err) { 8697 if (err) {
9225 IWL_ERROR("Unable to init EEPROM\n"); 8698 IWL_ERROR("Unable to init EEPROM\n");
9226 goto out_remove_sysfs; 8699 goto out_remove_sysfs;
9227 } 8700 }
9228 /* MAC Address location in EEPROM same for 3945/4965 */ 8701 /* MAC Address location in EEPROM same for 3945/4965 */
9229 get_eeprom_mac(priv, priv->mac_addr); 8702 iwl_eeprom_get_mac(priv, priv->mac_addr);
9230 IWL_DEBUG_INFO("MAC address: %s\n", print_mac(mac, priv->mac_addr)); 8703 IWL_DEBUG_INFO("MAC address: %s\n", print_mac(mac, priv->mac_addr));
9231 SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr); 8704 SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr);
9232 8705
@@ -9241,7 +8714,6 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
9241 IWL_ERROR("initializing geos failed: %d\n", err); 8714 IWL_ERROR("initializing geos failed: %d\n", err);
9242 goto out_free_channel_map; 8715 goto out_free_channel_map;
9243 } 8716 }
9244 iwl4965_reset_channel_flag(priv);
9245 8717
9246 iwl4965_rate_control_register(priv->hw); 8718 iwl4965_rate_control_register(priv->hw);
9247 err = ieee80211_register_hw(priv->hw); 8719 err = ieee80211_register_hw(priv->hw);