aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-agn.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-agn.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c1022
1 files changed, 589 insertions, 433 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 8b8e3e1cbb44..aef4f71f1981 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -55,6 +55,7 @@
55#include "iwl-helpers.h" 55#include "iwl-helpers.h"
56#include "iwl-sta.h" 56#include "iwl-sta.h"
57#include "iwl-calib.h" 57#include "iwl-calib.h"
58#include "iwl-agn.h"
58 59
59 60
60/****************************************************************************** 61/******************************************************************************
@@ -83,13 +84,6 @@ MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR);
83MODULE_LICENSE("GPL"); 84MODULE_LICENSE("GPL");
84MODULE_ALIAS("iwl4965"); 85MODULE_ALIAS("iwl4965");
85 86
86/*************** STATION TABLE MANAGEMENT ****
87 * mac80211 should be examined to determine if sta_info is duplicating
88 * the functionality provided here
89 */
90
91/**************************************************************/
92
93/** 87/**
94 * iwl_commit_rxon - commit staging_rxon to hardware 88 * iwl_commit_rxon - commit staging_rxon to hardware
95 * 89 *
@@ -144,9 +138,6 @@ int iwl_commit_rxon(struct iwl_priv *priv)
144 return 0; 138 return 0;
145 } 139 }
146 140
147 /* station table will be cleared */
148 priv->assoc_station_added = 0;
149
150 /* If we are currently associated and the new config requires 141 /* If we are currently associated and the new config requires
151 * an RXON_ASSOC and the new config wants the associated mask enabled, 142 * an RXON_ASSOC and the new config wants the associated mask enabled,
152 * we must clear the associated from the active configuration 143 * we must clear the associated from the active configuration
@@ -166,6 +157,13 @@ int iwl_commit_rxon(struct iwl_priv *priv)
166 IWL_ERR(priv, "Error clearing ASSOC_MSK (%d)\n", ret); 157 IWL_ERR(priv, "Error clearing ASSOC_MSK (%d)\n", ret);
167 return ret; 158 return ret;
168 } 159 }
160 iwl_clear_ucode_stations(priv);
161 iwl_restore_stations(priv);
162 ret = iwl_restore_default_wep_keys(priv);
163 if (ret) {
164 IWL_ERR(priv, "Failed to restore WEP keys (%d)\n", ret);
165 return ret;
166 }
169 } 167 }
170 168
171 IWL_DEBUG_INFO(priv, "Sending RXON\n" 169 IWL_DEBUG_INFO(priv, "Sending RXON\n"
@@ -179,9 +177,8 @@ int iwl_commit_rxon(struct iwl_priv *priv)
179 iwl_set_rxon_hwcrypto(priv, !priv->cfg->mod_params->sw_crypto); 177 iwl_set_rxon_hwcrypto(priv, !priv->cfg->mod_params->sw_crypto);
180 178
181 /* Apply the new configuration 179 /* Apply the new configuration
182 * RXON unassoc clears the station table in uCode, send it before 180 * RXON unassoc clears the station table in uCode so restoration of
183 * we add the bcast station. If assoc bit is set, we will send RXON 181 * stations is needed after it (the RXON command) completes
184 * after having added the bcast and bssid station.
185 */ 182 */
186 if (!new_assoc) { 183 if (!new_assoc) {
187 ret = iwl_send_cmd_pdu(priv, REPLY_RXON, 184 ret = iwl_send_cmd_pdu(priv, REPLY_RXON,
@@ -190,35 +187,19 @@ int iwl_commit_rxon(struct iwl_priv *priv)
190 IWL_ERR(priv, "Error setting new RXON (%d)\n", ret); 187 IWL_ERR(priv, "Error setting new RXON (%d)\n", ret);
191 return ret; 188 return ret;
192 } 189 }
190 IWL_DEBUG_INFO(priv, "Return from !new_assoc RXON.\n");
193 memcpy(active_rxon, &priv->staging_rxon, sizeof(*active_rxon)); 191 memcpy(active_rxon, &priv->staging_rxon, sizeof(*active_rxon));
192 iwl_clear_ucode_stations(priv);
193 iwl_restore_stations(priv);
194 ret = iwl_restore_default_wep_keys(priv);
195 if (ret) {
196 IWL_ERR(priv, "Failed to restore WEP keys (%d)\n", ret);
197 return ret;
198 }
194 } 199 }
195 200
196 iwl_clear_stations_table(priv);
197
198 priv->start_calib = 0; 201 priv->start_calib = 0;
199
200 /* Add the broadcast address so we can send broadcast frames */
201 priv->cfg->ops->lib->add_bcast_station(priv);
202
203
204 /* If we have set the ASSOC_MSK and we are in BSS mode then
205 * add the IWL_AP_ID to the station rate table */
206 if (new_assoc) { 202 if (new_assoc) {
207 if (priv->iw_mode == NL80211_IFTYPE_STATION) {
208 ret = iwl_rxon_add_station(priv,
209 priv->active_rxon.bssid_addr, 1);
210 if (ret == IWL_INVALID_STATION) {
211 IWL_ERR(priv,
212 "Error adding AP address for TX.\n");
213 return -EIO;
214 }
215 priv->assoc_station_added = 1;
216 if (priv->default_wep_key &&
217 iwl_send_static_wepkey_cmd(priv, 0))
218 IWL_ERR(priv,
219 "Could not send WEP static key.\n");
220 }
221
222 /* 203 /*
223 * allow CTS-to-self if possible for new association. 204 * allow CTS-to-self if possible for new association.
224 * this is relevant only for 5000 series and up, 205 * this is relevant only for 5000 series and up,
@@ -907,10 +888,10 @@ static void iwl_setup_rx_handlers(struct iwl_priv *priv)
907 priv->rx_handlers[MISSED_BEACONS_NOTIFICATION] = 888 priv->rx_handlers[MISSED_BEACONS_NOTIFICATION] =
908 iwl_rx_missed_beacon_notif; 889 iwl_rx_missed_beacon_notif;
909 /* Rx handlers */ 890 /* Rx handlers */
910 priv->rx_handlers[REPLY_RX_PHY_CMD] = iwl_rx_reply_rx_phy; 891 priv->rx_handlers[REPLY_RX_PHY_CMD] = iwlagn_rx_reply_rx_phy;
911 priv->rx_handlers[REPLY_RX_MPDU_CMD] = iwl_rx_reply_rx; 892 priv->rx_handlers[REPLY_RX_MPDU_CMD] = iwlagn_rx_reply_rx;
912 /* block ack */ 893 /* block ack */
913 priv->rx_handlers[REPLY_COMPRESSED_BA] = iwl_rx_reply_compressed_ba; 894 priv->rx_handlers[REPLY_COMPRESSED_BA] = iwlagn_rx_reply_compressed_ba;
914 /* Set up hardware specific Rx handlers */ 895 /* Set up hardware specific Rx handlers */
915 priv->cfg->ops->lib->rx_handler_setup(priv); 896 priv->cfg->ops->lib->rx_handler_setup(priv);
916} 897}
@@ -1038,7 +1019,7 @@ void iwl_rx_handle(struct iwl_priv *priv)
1038 count++; 1019 count++;
1039 if (count >= 8) { 1020 if (count >= 8) {
1040 rxq->read = i; 1021 rxq->read = i;
1041 iwl_rx_replenish_now(priv); 1022 iwlagn_rx_replenish_now(priv);
1042 count = 0; 1023 count = 0;
1043 } 1024 }
1044 } 1025 }
@@ -1047,9 +1028,9 @@ void iwl_rx_handle(struct iwl_priv *priv)
1047 /* Backtrack one entry */ 1028 /* Backtrack one entry */
1048 rxq->read = i; 1029 rxq->read = i;
1049 if (fill_rx) 1030 if (fill_rx)
1050 iwl_rx_replenish_now(priv); 1031 iwlagn_rx_replenish_now(priv);
1051 else 1032 else
1052 iwl_rx_queue_restock(priv); 1033 iwlagn_rx_queue_restock(priv);
1053} 1034}
1054 1035
1055/* call this function to flush any scheduled tasklet */ 1036/* call this function to flush any scheduled tasklet */
@@ -1267,9 +1248,9 @@ static void iwl_irq_tasklet(struct iwl_priv *priv)
1267 * hardware bugs here by ACKing all the possible interrupts so that 1248 * hardware bugs here by ACKing all the possible interrupts so that
1268 * interrupt coalescing can still be achieved. 1249 * interrupt coalescing can still be achieved.
1269 */ 1250 */
1270 iwl_write32(priv, CSR_INT, priv->inta | ~priv->inta_mask); 1251 iwl_write32(priv, CSR_INT, priv->_agn.inta | ~priv->inta_mask);
1271 1252
1272 inta = priv->inta; 1253 inta = priv->_agn.inta;
1273 1254
1274#ifdef CONFIG_IWLWIFI_DEBUG 1255#ifdef CONFIG_IWLWIFI_DEBUG
1275 if (iwl_get_debug_level(priv) & IWL_DL_ISR) { 1256 if (iwl_get_debug_level(priv) & IWL_DL_ISR) {
@@ -1282,8 +1263,8 @@ static void iwl_irq_tasklet(struct iwl_priv *priv)
1282 1263
1283 spin_unlock_irqrestore(&priv->lock, flags); 1264 spin_unlock_irqrestore(&priv->lock, flags);
1284 1265
1285 /* saved interrupt in inta variable now we can reset priv->inta */ 1266 /* saved interrupt in inta variable now we can reset priv->_agn.inta */
1286 priv->inta = 0; 1267 priv->_agn.inta = 0;
1287 1268
1288 /* Now service all interrupt bits discovered above. */ 1269 /* Now service all interrupt bits discovered above. */
1289 if (inta & CSR_INT_BIT_HW_ERR) { 1270 if (inta & CSR_INT_BIT_HW_ERR) {
@@ -1448,6 +1429,60 @@ static void iwl_irq_tasklet(struct iwl_priv *priv)
1448 iwl_enable_interrupts(priv); 1429 iwl_enable_interrupts(priv);
1449} 1430}
1450 1431
1432/* the threshold ratio of actual_ack_cnt to expected_ack_cnt in percent */
1433#define ACK_CNT_RATIO (50)
1434#define BA_TIMEOUT_CNT (5)
1435#define BA_TIMEOUT_MAX (16)
1436
1437/**
1438 * iwl_good_ack_health - checks for ACK count ratios, BA timeout retries.
1439 *
1440 * When the ACK count ratio is 0 and aggregated BA timeout retries exceeding
1441 * the BA_TIMEOUT_MAX, reload firmware and bring system back to normal
1442 * operation state.
1443 */
1444bool iwl_good_ack_health(struct iwl_priv *priv,
1445 struct iwl_rx_packet *pkt)
1446{
1447 bool rc = true;
1448 int actual_ack_cnt_delta, expected_ack_cnt_delta;
1449 int ba_timeout_delta;
1450
1451 actual_ack_cnt_delta =
1452 le32_to_cpu(pkt->u.stats.tx.actual_ack_cnt) -
1453 le32_to_cpu(priv->statistics.tx.actual_ack_cnt);
1454 expected_ack_cnt_delta =
1455 le32_to_cpu(pkt->u.stats.tx.expected_ack_cnt) -
1456 le32_to_cpu(priv->statistics.tx.expected_ack_cnt);
1457 ba_timeout_delta =
1458 le32_to_cpu(pkt->u.stats.tx.agg.ba_timeout) -
1459 le32_to_cpu(priv->statistics.tx.agg.ba_timeout);
1460 if ((priv->_agn.agg_tids_count > 0) &&
1461 (expected_ack_cnt_delta > 0) &&
1462 (((actual_ack_cnt_delta * 100) / expected_ack_cnt_delta)
1463 < ACK_CNT_RATIO) &&
1464 (ba_timeout_delta > BA_TIMEOUT_CNT)) {
1465 IWL_DEBUG_RADIO(priv, "actual_ack_cnt delta = %d,"
1466 " expected_ack_cnt = %d\n",
1467 actual_ack_cnt_delta, expected_ack_cnt_delta);
1468
1469#ifdef CONFIG_IWLWIFI_DEBUG
1470 IWL_DEBUG_RADIO(priv, "rx_detected_cnt delta = %d\n",
1471 priv->delta_statistics.tx.rx_detected_cnt);
1472 IWL_DEBUG_RADIO(priv,
1473 "ack_or_ba_timeout_collision delta = %d\n",
1474 priv->delta_statistics.tx.
1475 ack_or_ba_timeout_collision);
1476#endif
1477 IWL_DEBUG_RADIO(priv, "agg ba_timeout delta = %d\n",
1478 ba_timeout_delta);
1479 if (!actual_ack_cnt_delta &&
1480 (ba_timeout_delta >= BA_TIMEOUT_MAX))
1481 rc = false;
1482 }
1483 return rc;
1484}
1485
1451 1486
1452/****************************************************************************** 1487/******************************************************************************
1453 * 1488 *
@@ -1471,9 +1506,13 @@ static void iwl_nic_start(struct iwl_priv *priv)
1471 iwl_write32(priv, CSR_RESET, 0); 1506 iwl_write32(priv, CSR_RESET, 0);
1472} 1507}
1473 1508
1509struct iwlagn_ucode_capabilities {
1510 u32 max_probe_length;
1511};
1474 1512
1475static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context); 1513static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context);
1476static int iwl_mac_setup_register(struct iwl_priv *priv); 1514static int iwl_mac_setup_register(struct iwl_priv *priv,
1515 struct iwlagn_ucode_capabilities *capa);
1477 1516
1478static int __must_check iwl_request_firmware(struct iwl_priv *priv, bool first) 1517static int __must_check iwl_request_firmware(struct iwl_priv *priv, bool first)
1479{ 1518{
@@ -1500,6 +1539,199 @@ static int __must_check iwl_request_firmware(struct iwl_priv *priv, bool first)
1500 iwl_ucode_callback); 1539 iwl_ucode_callback);
1501} 1540}
1502 1541
1542struct iwlagn_firmware_pieces {
1543 const void *inst, *data, *init, *init_data, *boot;
1544 size_t inst_size, data_size, init_size, init_data_size, boot_size;
1545
1546 u32 build;
1547};
1548
1549static int iwlagn_load_legacy_firmware(struct iwl_priv *priv,
1550 const struct firmware *ucode_raw,
1551 struct iwlagn_firmware_pieces *pieces)
1552{
1553 struct iwl_ucode_header *ucode = (void *)ucode_raw->data;
1554 u32 api_ver, hdr_size;
1555 const u8 *src;
1556
1557 priv->ucode_ver = le32_to_cpu(ucode->ver);
1558 api_ver = IWL_UCODE_API(priv->ucode_ver);
1559
1560 switch (api_ver) {
1561 default:
1562 /*
1563 * 4965 doesn't revision the firmware file format
1564 * along with the API version, it always uses v1
1565 * file format.
1566 */
1567 if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) !=
1568 CSR_HW_REV_TYPE_4965) {
1569 hdr_size = 28;
1570 if (ucode_raw->size < hdr_size) {
1571 IWL_ERR(priv, "File size too small!\n");
1572 return -EINVAL;
1573 }
1574 pieces->build = le32_to_cpu(ucode->u.v2.build);
1575 pieces->inst_size = le32_to_cpu(ucode->u.v2.inst_size);
1576 pieces->data_size = le32_to_cpu(ucode->u.v2.data_size);
1577 pieces->init_size = le32_to_cpu(ucode->u.v2.init_size);
1578 pieces->init_data_size = le32_to_cpu(ucode->u.v2.init_data_size);
1579 pieces->boot_size = le32_to_cpu(ucode->u.v2.boot_size);
1580 src = ucode->u.v2.data;
1581 break;
1582 }
1583 /* fall through for 4965 */
1584 case 0:
1585 case 1:
1586 case 2:
1587 hdr_size = 24;
1588 if (ucode_raw->size < hdr_size) {
1589 IWL_ERR(priv, "File size too small!\n");
1590 return -EINVAL;
1591 }
1592 pieces->build = 0;
1593 pieces->inst_size = le32_to_cpu(ucode->u.v1.inst_size);
1594 pieces->data_size = le32_to_cpu(ucode->u.v1.data_size);
1595 pieces->init_size = le32_to_cpu(ucode->u.v1.init_size);
1596 pieces->init_data_size = le32_to_cpu(ucode->u.v1.init_data_size);
1597 pieces->boot_size = le32_to_cpu(ucode->u.v1.boot_size);
1598 src = ucode->u.v1.data;
1599 break;
1600 }
1601
1602 /* Verify size of file vs. image size info in file's header */
1603 if (ucode_raw->size != hdr_size + pieces->inst_size +
1604 pieces->data_size + pieces->init_size +
1605 pieces->init_data_size + pieces->boot_size) {
1606
1607 IWL_ERR(priv,
1608 "uCode file size %d does not match expected size\n",
1609 (int)ucode_raw->size);
1610 return -EINVAL;
1611 }
1612
1613 pieces->inst = src;
1614 src += pieces->inst_size;
1615 pieces->data = src;
1616 src += pieces->data_size;
1617 pieces->init = src;
1618 src += pieces->init_size;
1619 pieces->init_data = src;
1620 src += pieces->init_data_size;
1621 pieces->boot = src;
1622 src += pieces->boot_size;
1623
1624 return 0;
1625}
1626
1627static int iwlagn_wanted_ucode_alternative = 1;
1628
1629static int iwlagn_load_firmware(struct iwl_priv *priv,
1630 const struct firmware *ucode_raw,
1631 struct iwlagn_firmware_pieces *pieces,
1632 struct iwlagn_ucode_capabilities *capa)
1633{
1634 struct iwl_tlv_ucode_header *ucode = (void *)ucode_raw->data;
1635 struct iwl_ucode_tlv *tlv;
1636 size_t len = ucode_raw->size;
1637 const u8 *data;
1638 int wanted_alternative = iwlagn_wanted_ucode_alternative, tmp;
1639 u64 alternatives;
1640
1641 if (len < sizeof(*ucode))
1642 return -EINVAL;
1643
1644 if (ucode->magic != cpu_to_le32(IWL_TLV_UCODE_MAGIC))
1645 return -EINVAL;
1646
1647 /*
1648 * Check which alternatives are present, and "downgrade"
1649 * when the chosen alternative is not present, warning
1650 * the user when that happens. Some files may not have
1651 * any alternatives, so don't warn in that case.
1652 */
1653 alternatives = le64_to_cpu(ucode->alternatives);
1654 tmp = wanted_alternative;
1655 if (wanted_alternative > 63)
1656 wanted_alternative = 63;
1657 while (wanted_alternative && !(alternatives & BIT(wanted_alternative)))
1658 wanted_alternative--;
1659 if (wanted_alternative && wanted_alternative != tmp)
1660 IWL_WARN(priv,
1661 "uCode alternative %d not available, choosing %d\n",
1662 tmp, wanted_alternative);
1663
1664 priv->ucode_ver = le32_to_cpu(ucode->ver);
1665 pieces->build = le32_to_cpu(ucode->build);
1666 data = ucode->data;
1667
1668 len -= sizeof(*ucode);
1669
1670 while (len >= sizeof(*tlv)) {
1671 u32 tlv_len;
1672 enum iwl_ucode_tlv_type tlv_type;
1673 u16 tlv_alt;
1674 const u8 *tlv_data;
1675
1676 len -= sizeof(*tlv);
1677 tlv = (void *)data;
1678
1679 tlv_len = le32_to_cpu(tlv->length);
1680 tlv_type = le16_to_cpu(tlv->type);
1681 tlv_alt = le16_to_cpu(tlv->alternative);
1682 tlv_data = tlv->data;
1683
1684 if (len < tlv_len)
1685 return -EINVAL;
1686 len -= ALIGN(tlv_len, 4);
1687 data += sizeof(*tlv) + ALIGN(tlv_len, 4);
1688
1689 /*
1690 * Alternative 0 is always valid.
1691 *
1692 * Skip alternative TLVs that are not selected.
1693 */
1694 if (tlv_alt != 0 && tlv_alt != wanted_alternative)
1695 continue;
1696
1697 switch (tlv_type) {
1698 case IWL_UCODE_TLV_INST:
1699 pieces->inst = tlv_data;
1700 pieces->inst_size = tlv_len;
1701 break;
1702 case IWL_UCODE_TLV_DATA:
1703 pieces->data = tlv_data;
1704 pieces->data_size = tlv_len;
1705 break;
1706 case IWL_UCODE_TLV_INIT:
1707 pieces->init = tlv_data;
1708 pieces->init_size = tlv_len;
1709 break;
1710 case IWL_UCODE_TLV_INIT_DATA:
1711 pieces->init_data = tlv_data;
1712 pieces->init_data_size = tlv_len;
1713 break;
1714 case IWL_UCODE_TLV_BOOT:
1715 pieces->boot = tlv_data;
1716 pieces->boot_size = tlv_len;
1717 break;
1718 case IWL_UCODE_TLV_PROBE_MAX_LEN:
1719 if (tlv_len != 4)
1720 return -EINVAL;
1721 capa->max_probe_length =
1722 le32_to_cpup((__le32 *)tlv_data);
1723 break;
1724 default:
1725 break;
1726 }
1727 }
1728
1729 if (len)
1730 return -EINVAL;
1731
1732 return 0;
1733}
1734
1503/** 1735/**
1504 * iwl_ucode_callback - callback when firmware was loaded 1736 * iwl_ucode_callback - callback when firmware was loaded
1505 * 1737 *
@@ -1510,14 +1742,18 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1510{ 1742{
1511 struct iwl_priv *priv = context; 1743 struct iwl_priv *priv = context;
1512 struct iwl_ucode_header *ucode; 1744 struct iwl_ucode_header *ucode;
1745 int err;
1746 struct iwlagn_firmware_pieces pieces;
1513 const unsigned int api_max = priv->cfg->ucode_api_max; 1747 const unsigned int api_max = priv->cfg->ucode_api_max;
1514 const unsigned int api_min = priv->cfg->ucode_api_min; 1748 const unsigned int api_min = priv->cfg->ucode_api_min;
1515 u8 *src; 1749 u32 api_ver;
1516 size_t len; 1750 char buildstr[25];
1517 u32 api_ver, build; 1751 u32 build;
1518 u32 inst_size, data_size, init_size, init_data_size, boot_size; 1752 struct iwlagn_ucode_capabilities ucode_capa = {
1519 int err; 1753 .max_probe_length = 200,
1520 u16 eeprom_ver; 1754 };
1755
1756 memset(&pieces, 0, sizeof(pieces));
1521 1757
1522 if (!ucode_raw) { 1758 if (!ucode_raw) {
1523 IWL_ERR(priv, "request for firmware file '%s' failed.\n", 1759 IWL_ERR(priv, "request for firmware file '%s' failed.\n",
@@ -1528,8 +1764,8 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1528 IWL_DEBUG_INFO(priv, "Loaded firmware file '%s' (%zd bytes).\n", 1764 IWL_DEBUG_INFO(priv, "Loaded firmware file '%s' (%zd bytes).\n",
1529 priv->firmware_name, ucode_raw->size); 1765 priv->firmware_name, ucode_raw->size);
1530 1766
1531 /* Make sure that we got at least the v1 header! */ 1767 /* Make sure that we got at least the API version number */
1532 if (ucode_raw->size < priv->cfg->ops->ucode->get_header_size(1)) { 1768 if (ucode_raw->size < 4) {
1533 IWL_ERR(priv, "File size way too small!\n"); 1769 IWL_ERR(priv, "File size way too small!\n");
1534 goto try_again; 1770 goto try_again;
1535 } 1771 }
@@ -1537,21 +1773,23 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1537 /* Data from ucode file: header followed by uCode images */ 1773 /* Data from ucode file: header followed by uCode images */
1538 ucode = (struct iwl_ucode_header *)ucode_raw->data; 1774 ucode = (struct iwl_ucode_header *)ucode_raw->data;
1539 1775
1540 priv->ucode_ver = le32_to_cpu(ucode->ver); 1776 if (ucode->ver)
1777 err = iwlagn_load_legacy_firmware(priv, ucode_raw, &pieces);
1778 else
1779 err = iwlagn_load_firmware(priv, ucode_raw, &pieces,
1780 &ucode_capa);
1781
1782 if (err)
1783 goto try_again;
1784
1541 api_ver = IWL_UCODE_API(priv->ucode_ver); 1785 api_ver = IWL_UCODE_API(priv->ucode_ver);
1542 build = priv->cfg->ops->ucode->get_build(ucode, api_ver); 1786 build = pieces.build;
1543 inst_size = priv->cfg->ops->ucode->get_inst_size(ucode, api_ver);
1544 data_size = priv->cfg->ops->ucode->get_data_size(ucode, api_ver);
1545 init_size = priv->cfg->ops->ucode->get_init_size(ucode, api_ver);
1546 init_data_size =
1547 priv->cfg->ops->ucode->get_init_data_size(ucode, api_ver);
1548 boot_size = priv->cfg->ops->ucode->get_boot_size(ucode, api_ver);
1549 src = priv->cfg->ops->ucode->get_data(ucode, api_ver);
1550
1551 /* api_ver should match the api version forming part of the
1552 * firmware filename ... but we don't check for that and only rely
1553 * on the API version read from firmware header from here on forward */
1554 1787
1788 /*
1789 * api_ver should match the api version forming part of the
1790 * firmware filename ... but we don't check for that and only rely
1791 * on the API version read from firmware header from here on forward
1792 */
1555 if (api_ver < api_min || api_ver > api_max) { 1793 if (api_ver < api_min || api_ver > api_max) {
1556 IWL_ERR(priv, "Driver unable to support your firmware API. " 1794 IWL_ERR(priv, "Driver unable to support your firmware API. "
1557 "Driver supports v%u, firmware is v%u.\n", 1795 "Driver supports v%u, firmware is v%u.\n",
@@ -1565,40 +1803,26 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1565 "from http://www.intellinuxwireless.org.\n", 1803 "from http://www.intellinuxwireless.org.\n",
1566 api_max, api_ver); 1804 api_max, api_ver);
1567 1805
1568 IWL_INFO(priv, "loaded firmware version %u.%u.%u.%u\n", 1806 if (build)
1569 IWL_UCODE_MAJOR(priv->ucode_ver), 1807 sprintf(buildstr, " build %u", build);
1570 IWL_UCODE_MINOR(priv->ucode_ver), 1808 else
1571 IWL_UCODE_API(priv->ucode_ver), 1809 buildstr[0] = '\0';
1572 IWL_UCODE_SERIAL(priv->ucode_ver)); 1810
1811 IWL_INFO(priv, "loaded firmware version %u.%u.%u.%u%s\n",
1812 IWL_UCODE_MAJOR(priv->ucode_ver),
1813 IWL_UCODE_MINOR(priv->ucode_ver),
1814 IWL_UCODE_API(priv->ucode_ver),
1815 IWL_UCODE_SERIAL(priv->ucode_ver),
1816 buildstr);
1573 1817
1574 snprintf(priv->hw->wiphy->fw_version, 1818 snprintf(priv->hw->wiphy->fw_version,
1575 sizeof(priv->hw->wiphy->fw_version), 1819 sizeof(priv->hw->wiphy->fw_version),
1576 "%u.%u.%u.%u", 1820 "%u.%u.%u.%u%s",
1577 IWL_UCODE_MAJOR(priv->ucode_ver), 1821 IWL_UCODE_MAJOR(priv->ucode_ver),
1578 IWL_UCODE_MINOR(priv->ucode_ver), 1822 IWL_UCODE_MINOR(priv->ucode_ver),
1579 IWL_UCODE_API(priv->ucode_ver), 1823 IWL_UCODE_API(priv->ucode_ver),
1580 IWL_UCODE_SERIAL(priv->ucode_ver)); 1824 IWL_UCODE_SERIAL(priv->ucode_ver),
1581 1825 buildstr);
1582 if (build)
1583 IWL_DEBUG_INFO(priv, "Build %u\n", build);
1584
1585 eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION);
1586 IWL_DEBUG_INFO(priv, "NVM Type: %s, version: 0x%x\n",
1587 (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP)
1588 ? "OTP" : "EEPROM", eeprom_ver);
1589
1590 IWL_DEBUG_INFO(priv, "f/w package hdr ucode version raw = 0x%x\n",
1591 priv->ucode_ver);
1592 IWL_DEBUG_INFO(priv, "f/w package hdr runtime inst size = %u\n",
1593 inst_size);
1594 IWL_DEBUG_INFO(priv, "f/w package hdr runtime data size = %u\n",
1595 data_size);
1596 IWL_DEBUG_INFO(priv, "f/w package hdr init inst size = %u\n",
1597 init_size);
1598 IWL_DEBUG_INFO(priv, "f/w package hdr init data size = %u\n",
1599 init_data_size);
1600 IWL_DEBUG_INFO(priv, "f/w package hdr boot inst size = %u\n",
1601 boot_size);
1602 1826
1603 /* 1827 /*
1604 * For any of the failures below (before allocating pci memory) 1828 * For any of the failures below (before allocating pci memory)
@@ -1606,43 +1830,47 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1606 * user just got a corrupted version of the latest API. 1830 * user just got a corrupted version of the latest API.
1607 */ 1831 */
1608 1832
1609 /* Verify size of file vs. image size info in file's header */ 1833 IWL_DEBUG_INFO(priv, "f/w package hdr ucode version raw = 0x%x\n",
1610 if (ucode_raw->size != 1834 priv->ucode_ver);
1611 priv->cfg->ops->ucode->get_header_size(api_ver) + 1835 IWL_DEBUG_INFO(priv, "f/w package hdr runtime inst size = %Zd\n",
1612 inst_size + data_size + init_size + 1836 pieces.inst_size);
1613 init_data_size + boot_size) { 1837 IWL_DEBUG_INFO(priv, "f/w package hdr runtime data size = %Zd\n",
1614 1838 pieces.data_size);
1615 IWL_DEBUG_INFO(priv, 1839 IWL_DEBUG_INFO(priv, "f/w package hdr init inst size = %Zd\n",
1616 "uCode file size %d does not match expected size\n", 1840 pieces.init_size);
1617 (int)ucode_raw->size); 1841 IWL_DEBUG_INFO(priv, "f/w package hdr init data size = %Zd\n",
1618 goto try_again; 1842 pieces.init_data_size);
1619 } 1843 IWL_DEBUG_INFO(priv, "f/w package hdr boot inst size = %Zd\n",
1844 pieces.boot_size);
1620 1845
1621 /* Verify that uCode images will fit in card's SRAM */ 1846 /* Verify that uCode images will fit in card's SRAM */
1622 if (inst_size > priv->hw_params.max_inst_size) { 1847 if (pieces.inst_size > priv->hw_params.max_inst_size) {
1623 IWL_DEBUG_INFO(priv, "uCode instr len %d too large to fit in\n", 1848 IWL_ERR(priv, "uCode instr len %Zd too large to fit in\n",
1624 inst_size); 1849 pieces.inst_size);
1625 goto try_again; 1850 goto try_again;
1626 } 1851 }
1627 1852
1628 if (data_size > priv->hw_params.max_data_size) { 1853 if (pieces.data_size > priv->hw_params.max_data_size) {
1629 IWL_DEBUG_INFO(priv, "uCode data len %d too large to fit in\n", 1854 IWL_ERR(priv, "uCode data len %Zd too large to fit in\n",
1630 data_size); 1855 pieces.data_size);
1631 goto try_again; 1856 goto try_again;
1632 } 1857 }
1633 if (init_size > priv->hw_params.max_inst_size) { 1858
1634 IWL_INFO(priv, "uCode init instr len %d too large to fit in\n", 1859 if (pieces.init_size > priv->hw_params.max_inst_size) {
1635 init_size); 1860 IWL_ERR(priv, "uCode init instr len %Zd too large to fit in\n",
1861 pieces.init_size);
1636 goto try_again; 1862 goto try_again;
1637 } 1863 }
1638 if (init_data_size > priv->hw_params.max_data_size) { 1864
1639 IWL_INFO(priv, "uCode init data len %d too large to fit in\n", 1865 if (pieces.init_data_size > priv->hw_params.max_data_size) {
1640 init_data_size); 1866 IWL_ERR(priv, "uCode init data len %Zd too large to fit in\n",
1867 pieces.init_data_size);
1641 goto try_again; 1868 goto try_again;
1642 } 1869 }
1643 if (boot_size > priv->hw_params.max_bsm_size) { 1870
1644 IWL_INFO(priv, "uCode boot instr len %d too large to fit in\n", 1871 if (pieces.boot_size > priv->hw_params.max_bsm_size) {
1645 boot_size); 1872 IWL_ERR(priv, "uCode boot instr len %Zd too large to fit in\n",
1873 pieces.boot_size);
1646 goto try_again; 1874 goto try_again;
1647 } 1875 }
1648 1876
@@ -1651,13 +1879,13 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1651 /* Runtime instructions and 2 copies of data: 1879 /* Runtime instructions and 2 copies of data:
1652 * 1) unmodified from disk 1880 * 1) unmodified from disk
1653 * 2) backup cache for save/restore during power-downs */ 1881 * 2) backup cache for save/restore during power-downs */
1654 priv->ucode_code.len = inst_size; 1882 priv->ucode_code.len = pieces.inst_size;
1655 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_code); 1883 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_code);
1656 1884
1657 priv->ucode_data.len = data_size; 1885 priv->ucode_data.len = pieces.data_size;
1658 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_data); 1886 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_data);
1659 1887
1660 priv->ucode_data_backup.len = data_size; 1888 priv->ucode_data_backup.len = pieces.data_size;
1661 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_data_backup); 1889 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_data_backup);
1662 1890
1663 if (!priv->ucode_code.v_addr || !priv->ucode_data.v_addr || 1891 if (!priv->ucode_code.v_addr || !priv->ucode_data.v_addr ||
@@ -1665,11 +1893,11 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1665 goto err_pci_alloc; 1893 goto err_pci_alloc;
1666 1894
1667 /* Initialization instructions and data */ 1895 /* Initialization instructions and data */
1668 if (init_size && init_data_size) { 1896 if (pieces.init_size && pieces.init_data_size) {
1669 priv->ucode_init.len = init_size; 1897 priv->ucode_init.len = pieces.init_size;
1670 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_init); 1898 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_init);
1671 1899
1672 priv->ucode_init_data.len = init_data_size; 1900 priv->ucode_init_data.len = pieces.init_data_size;
1673 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_init_data); 1901 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_init_data);
1674 1902
1675 if (!priv->ucode_init.v_addr || !priv->ucode_init_data.v_addr) 1903 if (!priv->ucode_init.v_addr || !priv->ucode_init_data.v_addr)
@@ -1677,8 +1905,8 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1677 } 1905 }
1678 1906
1679 /* Bootstrap (instructions only, no data) */ 1907 /* Bootstrap (instructions only, no data) */
1680 if (boot_size) { 1908 if (pieces.boot_size) {
1681 priv->ucode_boot.len = boot_size; 1909 priv->ucode_boot.len = pieces.boot_size;
1682 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_boot); 1910 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_boot);
1683 1911
1684 if (!priv->ucode_boot.v_addr) 1912 if (!priv->ucode_boot.v_addr)
@@ -1688,51 +1916,48 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1688 /* Copy images into buffers for card's bus-master reads ... */ 1916 /* Copy images into buffers for card's bus-master reads ... */
1689 1917
1690 /* Runtime instructions (first block of data in file) */ 1918 /* Runtime instructions (first block of data in file) */
1691 len = inst_size; 1919 IWL_DEBUG_INFO(priv, "Copying (but not loading) uCode instr len %Zd\n",
1692 IWL_DEBUG_INFO(priv, "Copying (but not loading) uCode instr len %Zd\n", len); 1920 pieces.inst_size);
1693 memcpy(priv->ucode_code.v_addr, src, len); 1921 memcpy(priv->ucode_code.v_addr, pieces.inst, pieces.inst_size);
1694 src += len;
1695 1922
1696 IWL_DEBUG_INFO(priv, "uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", 1923 IWL_DEBUG_INFO(priv, "uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n",
1697 priv->ucode_code.v_addr, (u32)priv->ucode_code.p_addr); 1924 priv->ucode_code.v_addr, (u32)priv->ucode_code.p_addr);
1698 1925
1699 /* Runtime data (2nd block) 1926 /*
1700 * NOTE: Copy into backup buffer will be done in iwl_up() */ 1927 * Runtime data
1701 len = data_size; 1928 * NOTE: Copy into backup buffer will be done in iwl_up()
1702 IWL_DEBUG_INFO(priv, "Copying (but not loading) uCode data len %Zd\n", len); 1929 */
1703 memcpy(priv->ucode_data.v_addr, src, len); 1930 IWL_DEBUG_INFO(priv, "Copying (but not loading) uCode data len %Zd\n",
1704 memcpy(priv->ucode_data_backup.v_addr, src, len); 1931 pieces.data_size);
1705 src += len; 1932 memcpy(priv->ucode_data.v_addr, pieces.data, pieces.data_size);
1706 1933 memcpy(priv->ucode_data_backup.v_addr, pieces.data, pieces.data_size);
1707 /* Initialization instructions (3rd block) */ 1934
1708 if (init_size) { 1935 /* Initialization instructions */
1709 len = init_size; 1936 if (pieces.init_size) {
1710 IWL_DEBUG_INFO(priv, "Copying (but not loading) init instr len %Zd\n", 1937 IWL_DEBUG_INFO(priv, "Copying (but not loading) init instr len %Zd\n",
1711 len); 1938 pieces.init_size);
1712 memcpy(priv->ucode_init.v_addr, src, len); 1939 memcpy(priv->ucode_init.v_addr, pieces.init, pieces.init_size);
1713 src += len;
1714 } 1940 }
1715 1941
1716 /* Initialization data (4th block) */ 1942 /* Initialization data */
1717 if (init_data_size) { 1943 if (pieces.init_data_size) {
1718 len = init_data_size;
1719 IWL_DEBUG_INFO(priv, "Copying (but not loading) init data len %Zd\n", 1944 IWL_DEBUG_INFO(priv, "Copying (but not loading) init data len %Zd\n",
1720 len); 1945 pieces.init_data_size);
1721 memcpy(priv->ucode_init_data.v_addr, src, len); 1946 memcpy(priv->ucode_init_data.v_addr, pieces.init_data,
1722 src += len; 1947 pieces.init_data_size);
1723 } 1948 }
1724 1949
1725 /* Bootstrap instructions (5th block) */ 1950 /* Bootstrap instructions */
1726 len = boot_size; 1951 IWL_DEBUG_INFO(priv, "Copying (but not loading) boot instr len %Zd\n",
1727 IWL_DEBUG_INFO(priv, "Copying (but not loading) boot instr len %Zd\n", len); 1952 pieces.boot_size);
1728 memcpy(priv->ucode_boot.v_addr, src, len); 1953 memcpy(priv->ucode_boot.v_addr, pieces.boot, pieces.boot_size);
1729 1954
1730 /************************************************** 1955 /**************************************************
1731 * This is still part of probe() in a sense... 1956 * This is still part of probe() in a sense...
1732 * 1957 *
1733 * 9. Setup and register with mac80211 and debugfs 1958 * 9. Setup and register with mac80211 and debugfs
1734 **************************************************/ 1959 **************************************************/
1735 err = iwl_mac_setup_register(priv); 1960 err = iwl_mac_setup_register(priv, &ucode_capa);
1736 if (err) 1961 if (err)
1737 goto out_unbind; 1962 goto out_unbind;
1738 1963
@@ -1742,6 +1967,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1742 1967
1743 /* We have our copies now, allow OS release its copies */ 1968 /* We have our copies now, allow OS release its copies */
1744 release_firmware(ucode_raw); 1969 release_firmware(ucode_raw);
1970 complete(&priv->_agn.firmware_loading_complete);
1745 return; 1971 return;
1746 1972
1747 try_again: 1973 try_again:
@@ -1755,6 +1981,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1755 IWL_ERR(priv, "failed to allocate pci memory\n"); 1981 IWL_ERR(priv, "failed to allocate pci memory\n");
1756 iwl_dealloc_ucode_pci(priv); 1982 iwl_dealloc_ucode_pci(priv);
1757 out_unbind: 1983 out_unbind:
1984 complete(&priv->_agn.firmware_loading_complete);
1758 device_release_driver(&priv->pci_dev->dev); 1985 device_release_driver(&priv->pci_dev->dev);
1759 release_firmware(ucode_raw); 1986 release_firmware(ucode_raw);
1760} 1987}
@@ -1809,6 +2036,7 @@ void iwl_dump_nic_error_log(struct iwl_priv *priv)
1809 u32 data2, line; 2036 u32 data2, line;
1810 u32 desc, time, count, base, data1; 2037 u32 desc, time, count, base, data1;
1811 u32 blink1, blink2, ilink1, ilink2; 2038 u32 blink1, blink2, ilink1, ilink2;
2039 u32 pc, hcmd;
1812 2040
1813 if (priv->ucode_type == UCODE_INIT) 2041 if (priv->ucode_type == UCODE_INIT)
1814 base = le32_to_cpu(priv->card_alive_init.error_event_table_ptr); 2042 base = le32_to_cpu(priv->card_alive_init.error_event_table_ptr);
@@ -1831,6 +2059,7 @@ void iwl_dump_nic_error_log(struct iwl_priv *priv)
1831 } 2059 }
1832 2060
1833 desc = iwl_read_targ_mem(priv, base + 1 * sizeof(u32)); 2061 desc = iwl_read_targ_mem(priv, base + 1 * sizeof(u32));
2062 pc = iwl_read_targ_mem(priv, base + 2 * sizeof(u32));
1834 blink1 = iwl_read_targ_mem(priv, base + 3 * sizeof(u32)); 2063 blink1 = iwl_read_targ_mem(priv, base + 3 * sizeof(u32));
1835 blink2 = iwl_read_targ_mem(priv, base + 4 * sizeof(u32)); 2064 blink2 = iwl_read_targ_mem(priv, base + 4 * sizeof(u32));
1836 ilink1 = iwl_read_targ_mem(priv, base + 5 * sizeof(u32)); 2065 ilink1 = iwl_read_targ_mem(priv, base + 5 * sizeof(u32));
@@ -1839,6 +2068,7 @@ void iwl_dump_nic_error_log(struct iwl_priv *priv)
1839 data2 = iwl_read_targ_mem(priv, base + 8 * sizeof(u32)); 2068 data2 = iwl_read_targ_mem(priv, base + 8 * sizeof(u32));
1840 line = iwl_read_targ_mem(priv, base + 9 * sizeof(u32)); 2069 line = iwl_read_targ_mem(priv, base + 9 * sizeof(u32));
1841 time = iwl_read_targ_mem(priv, base + 11 * sizeof(u32)); 2070 time = iwl_read_targ_mem(priv, base + 11 * sizeof(u32));
2071 hcmd = iwl_read_targ_mem(priv, base + 22 * sizeof(u32));
1842 2072
1843 trace_iwlwifi_dev_ucode_error(priv, desc, time, data1, data2, line, 2073 trace_iwlwifi_dev_ucode_error(priv, desc, time, data1, data2, line,
1844 blink1, blink2, ilink1, ilink2); 2074 blink1, blink2, ilink1, ilink2);
@@ -1847,10 +2077,9 @@ void iwl_dump_nic_error_log(struct iwl_priv *priv)
1847 "data1 data2 line\n"); 2077 "data1 data2 line\n");
1848 IWL_ERR(priv, "%-28s (#%02d) %010u 0x%08X 0x%08X %u\n", 2078 IWL_ERR(priv, "%-28s (#%02d) %010u 0x%08X 0x%08X %u\n",
1849 desc_lookup(desc), desc, time, data1, data2, line); 2079 desc_lookup(desc), desc, time, data1, data2, line);
1850 IWL_ERR(priv, "blink1 blink2 ilink1 ilink2\n"); 2080 IWL_ERR(priv, "pc blink1 blink2 ilink1 ilink2 hcmd\n");
1851 IWL_ERR(priv, "0x%05X 0x%05X 0x%05X 0x%05X\n", blink1, blink2, 2081 IWL_ERR(priv, "0x%05X 0x%05X 0x%05X 0x%05X 0x%05X 0x%05X\n",
1852 ilink1, ilink2); 2082 pc, blink1, blink2, ilink1, ilink2, hcmd);
1853
1854} 2083}
1855 2084
1856#define EVENT_START_OFFSET (4 * sizeof(u32)) 2085#define EVENT_START_OFFSET (4 * sizeof(u32))
@@ -1966,9 +2195,6 @@ static int iwl_print_last_event_logs(struct iwl_priv *priv, u32 capacity,
1966 return pos; 2195 return pos;
1967} 2196}
1968 2197
1969/* For sanity check only. Actual size is determined by uCode, typ. 512 */
1970#define MAX_EVENT_LOG_SIZE (512)
1971
1972#define DEFAULT_DUMP_EVENT_LOG_ENTRIES (20) 2198#define DEFAULT_DUMP_EVENT_LOG_ENTRIES (20)
1973 2199
1974int iwl_dump_nic_event_log(struct iwl_priv *priv, bool full_log, 2200int iwl_dump_nic_event_log(struct iwl_priv *priv, bool full_log,
@@ -2001,16 +2227,16 @@ int iwl_dump_nic_event_log(struct iwl_priv *priv, bool full_log,
2001 num_wraps = iwl_read_targ_mem(priv, base + (2 * sizeof(u32))); 2227 num_wraps = iwl_read_targ_mem(priv, base + (2 * sizeof(u32)));
2002 next_entry = iwl_read_targ_mem(priv, base + (3 * sizeof(u32))); 2228 next_entry = iwl_read_targ_mem(priv, base + (3 * sizeof(u32)));
2003 2229
2004 if (capacity > MAX_EVENT_LOG_SIZE) { 2230 if (capacity > priv->cfg->max_event_log_size) {
2005 IWL_ERR(priv, "Log capacity %d is bogus, limit to %d entries\n", 2231 IWL_ERR(priv, "Log capacity %d is bogus, limit to %d entries\n",
2006 capacity, MAX_EVENT_LOG_SIZE); 2232 capacity, priv->cfg->max_event_log_size);
2007 capacity = MAX_EVENT_LOG_SIZE; 2233 capacity = priv->cfg->max_event_log_size;
2008 } 2234 }
2009 2235
2010 if (next_entry > MAX_EVENT_LOG_SIZE) { 2236 if (next_entry > priv->cfg->max_event_log_size) {
2011 IWL_ERR(priv, "Log write index %d is bogus, limit to %d\n", 2237 IWL_ERR(priv, "Log write index %d is bogus, limit to %d\n",
2012 next_entry, MAX_EVENT_LOG_SIZE); 2238 next_entry, priv->cfg->max_event_log_size);
2013 next_entry = MAX_EVENT_LOG_SIZE; 2239 next_entry = priv->cfg->max_event_log_size;
2014 } 2240 }
2015 2241
2016 size = num_wraps ? capacity : next_entry; 2242 size = num_wraps ? capacity : next_entry;
@@ -2095,7 +2321,6 @@ static void iwl_alive_start(struct iwl_priv *priv)
2095 goto restart; 2321 goto restart;
2096 } 2322 }
2097 2323
2098 iwl_clear_stations_table(priv);
2099 ret = priv->cfg->ops->lib->alive_notify(priv); 2324 ret = priv->cfg->ops->lib->alive_notify(priv);
2100 if (ret) { 2325 if (ret) {
2101 IWL_WARN(priv, 2326 IWL_WARN(priv,
@@ -2106,13 +2331,19 @@ static void iwl_alive_start(struct iwl_priv *priv)
2106 /* After the ALIVE response, we can send host commands to the uCode */ 2331 /* After the ALIVE response, we can send host commands to the uCode */
2107 set_bit(STATUS_ALIVE, &priv->status); 2332 set_bit(STATUS_ALIVE, &priv->status);
2108 2333
2334 if (priv->cfg->ops->lib->recover_from_tx_stall) {
2335 /* Enable timer to monitor the driver queues */
2336 mod_timer(&priv->monitor_recover,
2337 jiffies +
2338 msecs_to_jiffies(priv->cfg->monitor_recover_period));
2339 }
2340
2109 if (iwl_is_rfkill(priv)) 2341 if (iwl_is_rfkill(priv))
2110 return; 2342 return;
2111 2343
2112 ieee80211_wake_queues(priv->hw); 2344 ieee80211_wake_queues(priv->hw);
2113 2345
2114 priv->active_rate = priv->rates_mask; 2346 priv->active_rate = IWL_RATES_MASK;
2115 priv->active_rate_basic = priv->rates_mask & IWL_BASIC_RATES_MASK;
2116 2347
2117 /* Configure Tx antenna selection based on H/W config */ 2348 /* Configure Tx antenna selection based on H/W config */
2118 if (priv->cfg->ops->hcmd->set_tx_ant) 2349 if (priv->cfg->ops->hcmd->set_tx_ant)
@@ -2126,7 +2357,7 @@ static void iwl_alive_start(struct iwl_priv *priv)
2126 active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; 2357 active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
2127 } else { 2358 } else {
2128 /* Initialize our rx_config data */ 2359 /* Initialize our rx_config data */
2129 iwl_connection_init_rx_config(priv, priv->iw_mode); 2360 iwl_connection_init_rx_config(priv, NULL);
2130 2361
2131 if (priv->cfg->ops->hcmd->set_rxon_chain) 2362 if (priv->cfg->ops->hcmd->set_rxon_chain)
2132 priv->cfg->ops->hcmd->set_rxon_chain(priv); 2363 priv->cfg->ops->hcmd->set_rxon_chain(priv);
@@ -2135,7 +2366,7 @@ static void iwl_alive_start(struct iwl_priv *priv)
2135 } 2366 }
2136 2367
2137 /* Configure Bluetooth device coexistence support */ 2368 /* Configure Bluetooth device coexistence support */
2138 iwl_send_bt_config(priv); 2369 priv->cfg->ops->hcmd->send_bt_config(priv);
2139 2370
2140 iwl_reset_run_time_calib(priv); 2371 iwl_reset_run_time_calib(priv);
2141 2372
@@ -2152,18 +2383,8 @@ static void iwl_alive_start(struct iwl_priv *priv)
2152 wake_up_interruptible(&priv->wait_command_queue); 2383 wake_up_interruptible(&priv->wait_command_queue);
2153 2384
2154 iwl_power_update_mode(priv, true); 2385 iwl_power_update_mode(priv, true);
2386 IWL_DEBUG_INFO(priv, "Updated power mode\n");
2155 2387
2156 /* reassociate for ADHOC mode */
2157 if (priv->vif && (priv->iw_mode == NL80211_IFTYPE_ADHOC)) {
2158 struct sk_buff *beacon = ieee80211_beacon_get(priv->hw,
2159 priv->vif);
2160 if (beacon)
2161 iwl_mac_beacon_update(priv->hw, beacon);
2162 }
2163
2164
2165 if (test_and_clear_bit(STATUS_MODE_PENDING, &priv->status))
2166 iwl_set_mode(priv, priv->iw_mode);
2167 2388
2168 return; 2389 return;
2169 2390
@@ -2183,7 +2404,9 @@ static void __iwl_down(struct iwl_priv *priv)
2183 if (!exit_pending) 2404 if (!exit_pending)
2184 set_bit(STATUS_EXIT_PENDING, &priv->status); 2405 set_bit(STATUS_EXIT_PENDING, &priv->status);
2185 2406
2186 iwl_clear_stations_table(priv); 2407 iwl_clear_ucode_stations(priv);
2408 iwl_dealloc_bcast_station(priv);
2409 iwl_clear_driver_stations(priv);
2187 2410
2188 /* Unblock any waiting calls */ 2411 /* Unblock any waiting calls */
2189 wake_up_interruptible_all(&priv->wait_command_queue); 2412 wake_up_interruptible_all(&priv->wait_command_queue);
@@ -2231,8 +2454,8 @@ static void __iwl_down(struct iwl_priv *priv)
2231 /* device going down, Stop using ICT table */ 2454 /* device going down, Stop using ICT table */
2232 iwl_disable_ict(priv); 2455 iwl_disable_ict(priv);
2233 2456
2234 iwl_txq_ctx_stop(priv); 2457 iwlagn_txq_ctx_stop(priv);
2235 iwl_rxq_stop(priv); 2458 iwlagn_rxq_stop(priv);
2236 2459
2237 /* Power-down device's busmaster DMA clocks */ 2460 /* Power-down device's busmaster DMA clocks */
2238 iwl_write_prph(priv, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); 2461 iwl_write_prph(priv, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT);
@@ -2292,7 +2515,7 @@ static int iwl_prepare_card_hw(struct iwl_priv *priv)
2292{ 2515{
2293 int ret = 0; 2516 int ret = 0;
2294 2517
2295 IWL_DEBUG_INFO(priv, "iwl_prepare_card_hw enter \n"); 2518 IWL_DEBUG_INFO(priv, "iwl_prepare_card_hw enter\n");
2296 2519
2297 ret = iwl_set_hw_ready(priv); 2520 ret = iwl_set_hw_ready(priv);
2298 if (priv->hw_ready) 2521 if (priv->hw_ready)
@@ -2330,6 +2553,10 @@ static int __iwl_up(struct iwl_priv *priv)
2330 return -EIO; 2553 return -EIO;
2331 } 2554 }
2332 2555
2556 ret = iwl_alloc_bcast_station(priv, true);
2557 if (ret)
2558 return ret;
2559
2333 iwl_prepare_card_hw(priv); 2560 iwl_prepare_card_hw(priv);
2334 2561
2335 if (!priv->hw_ready) { 2562 if (!priv->hw_ready) {
@@ -2353,7 +2580,7 @@ static int __iwl_up(struct iwl_priv *priv)
2353 2580
2354 iwl_write32(priv, CSR_INT, 0xFFFFFFFF); 2581 iwl_write32(priv, CSR_INT, 0xFFFFFFFF);
2355 2582
2356 ret = iwl_hw_nic_init(priv); 2583 ret = iwlagn_hw_nic_init(priv);
2357 if (ret) { 2584 if (ret) {
2358 IWL_ERR(priv, "Unable to init nic\n"); 2585 IWL_ERR(priv, "Unable to init nic\n");
2359 return ret; 2586 return ret;
@@ -2380,8 +2607,6 @@ static int __iwl_up(struct iwl_priv *priv)
2380 2607
2381 for (i = 0; i < MAX_HW_RESTARTS; i++) { 2608 for (i = 0; i < MAX_HW_RESTARTS; i++) {
2382 2609
2383 iwl_clear_stations_table(priv);
2384
2385 /* load bootstrap state machine, 2610 /* load bootstrap state machine,
2386 * load bootstrap program into processor's memory, 2611 * load bootstrap program into processor's memory,
2387 * prepare to load the "initialize" uCode */ 2612 * prepare to load the "initialize" uCode */
@@ -2467,7 +2692,6 @@ static void iwl_bg_run_time_calib_work(struct work_struct *work)
2467 } 2692 }
2468 2693
2469 mutex_unlock(&priv->mutex); 2694 mutex_unlock(&priv->mutex);
2470 return;
2471} 2695}
2472 2696
2473static void iwl_bg_restart(struct work_struct *data) 2697static void iwl_bg_restart(struct work_struct *data)
@@ -2505,34 +2729,28 @@ static void iwl_bg_rx_replenish(struct work_struct *data)
2505 return; 2729 return;
2506 2730
2507 mutex_lock(&priv->mutex); 2731 mutex_lock(&priv->mutex);
2508 iwl_rx_replenish(priv); 2732 iwlagn_rx_replenish(priv);
2509 mutex_unlock(&priv->mutex); 2733 mutex_unlock(&priv->mutex);
2510} 2734}
2511 2735
2512#define IWL_DELAY_NEXT_SCAN (HZ*2) 2736#define IWL_DELAY_NEXT_SCAN (HZ*2)
2513 2737
2514void iwl_post_associate(struct iwl_priv *priv) 2738void iwl_post_associate(struct iwl_priv *priv, struct ieee80211_vif *vif)
2515{ 2739{
2516 struct ieee80211_conf *conf = NULL; 2740 struct ieee80211_conf *conf = NULL;
2517 int ret = 0; 2741 int ret = 0;
2518 unsigned long flags;
2519 2742
2520 if (priv->iw_mode == NL80211_IFTYPE_AP) { 2743 if (!vif || !priv->is_open)
2744 return;
2745
2746 if (vif->type == NL80211_IFTYPE_AP) {
2521 IWL_ERR(priv, "%s Should not be called in AP mode\n", __func__); 2747 IWL_ERR(priv, "%s Should not be called in AP mode\n", __func__);
2522 return; 2748 return;
2523 } 2749 }
2524 2750
2525 IWL_DEBUG_ASSOC(priv, "Associated as %d to: %pM\n",
2526 priv->assoc_id, priv->active_rxon.bssid_addr);
2527
2528
2529 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 2751 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
2530 return; 2752 return;
2531 2753
2532
2533 if (!priv->vif || !priv->is_open)
2534 return;
2535
2536 iwl_scan_cancel_timeout(priv, 200); 2754 iwl_scan_cancel_timeout(priv, 200);
2537 2755
2538 conf = ieee80211_get_hw_conf(priv->hw); 2756 conf = ieee80211_get_hw_conf(priv->hw);
@@ -2540,7 +2758,7 @@ void iwl_post_associate(struct iwl_priv *priv)
2540 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 2758 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
2541 iwlcore_commit_rxon(priv); 2759 iwlcore_commit_rxon(priv);
2542 2760
2543 iwl_setup_rxon_timing(priv); 2761 iwl_setup_rxon_timing(priv, vif);
2544 ret = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING, 2762 ret = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING,
2545 sizeof(priv->rxon_timing), &priv->rxon_timing); 2763 sizeof(priv->rxon_timing), &priv->rxon_timing);
2546 if (ret) 2764 if (ret)
@@ -2554,56 +2772,44 @@ void iwl_post_associate(struct iwl_priv *priv)
2554 if (priv->cfg->ops->hcmd->set_rxon_chain) 2772 if (priv->cfg->ops->hcmd->set_rxon_chain)
2555 priv->cfg->ops->hcmd->set_rxon_chain(priv); 2773 priv->cfg->ops->hcmd->set_rxon_chain(priv);
2556 2774
2557 priv->staging_rxon.assoc_id = cpu_to_le16(priv->assoc_id); 2775 priv->staging_rxon.assoc_id = cpu_to_le16(vif->bss_conf.aid);
2558 2776
2559 IWL_DEBUG_ASSOC(priv, "assoc id %d beacon interval %d\n", 2777 IWL_DEBUG_ASSOC(priv, "assoc id %d beacon interval %d\n",
2560 priv->assoc_id, priv->beacon_int); 2778 vif->bss_conf.aid, vif->bss_conf.beacon_int);
2561 2779
2562 if (priv->assoc_capability & WLAN_CAPABILITY_SHORT_PREAMBLE) 2780 if (vif->bss_conf.assoc_capability & WLAN_CAPABILITY_SHORT_PREAMBLE)
2563 priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; 2781 priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK;
2564 else 2782 else
2565 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; 2783 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK;
2566 2784
2567 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) { 2785 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) {
2568 if (priv->assoc_capability & WLAN_CAPABILITY_SHORT_SLOT_TIME) 2786 if (vif->bss_conf.assoc_capability &
2787 WLAN_CAPABILITY_SHORT_SLOT_TIME)
2569 priv->staging_rxon.flags |= RXON_FLG_SHORT_SLOT_MSK; 2788 priv->staging_rxon.flags |= RXON_FLG_SHORT_SLOT_MSK;
2570 else 2789 else
2571 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK; 2790 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
2572 2791
2573 if (priv->iw_mode == NL80211_IFTYPE_ADHOC) 2792 if (vif->type == NL80211_IFTYPE_ADHOC)
2574 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK; 2793 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
2575
2576 } 2794 }
2577 2795
2578 iwlcore_commit_rxon(priv); 2796 iwlcore_commit_rxon(priv);
2579 2797
2580 switch (priv->iw_mode) { 2798 IWL_DEBUG_ASSOC(priv, "Associated as %d to: %pM\n",
2799 vif->bss_conf.aid, priv->active_rxon.bssid_addr);
2800
2801 switch (vif->type) {
2581 case NL80211_IFTYPE_STATION: 2802 case NL80211_IFTYPE_STATION:
2582 break; 2803 break;
2583
2584 case NL80211_IFTYPE_ADHOC: 2804 case NL80211_IFTYPE_ADHOC:
2585
2586 /* assume default assoc id */
2587 priv->assoc_id = 1;
2588
2589 iwl_rxon_add_station(priv, priv->bssid, 0);
2590 iwl_send_beacon_cmd(priv); 2805 iwl_send_beacon_cmd(priv);
2591
2592 break; 2806 break;
2593
2594 default: 2807 default:
2595 IWL_ERR(priv, "%s Should not be called in %d mode\n", 2808 IWL_ERR(priv, "%s Should not be called in %d mode\n",
2596 __func__, priv->iw_mode); 2809 __func__, vif->type);
2597 break; 2810 break;
2598 } 2811 }
2599 2812
2600 if (priv->iw_mode == NL80211_IFTYPE_ADHOC)
2601 priv->assoc_station_added = 1;
2602
2603 spin_lock_irqsave(&priv->lock, flags);
2604 iwl_activate_qos(priv, 0);
2605 spin_unlock_irqrestore(&priv->lock, flags);
2606
2607 /* the chain noise calibration will enabled PM upon completion 2813 /* the chain noise calibration will enabled PM upon completion
2608 * If chain noise has already been run, then we need to enable 2814 * If chain noise has already been run, then we need to enable
2609 * power management here */ 2815 * power management here */
@@ -2628,7 +2834,8 @@ void iwl_post_associate(struct iwl_priv *priv)
2628 * Not a mac80211 entry point function, but it fits in with all the 2834 * Not a mac80211 entry point function, but it fits in with all the
2629 * other mac80211 functions grouped here. 2835 * other mac80211 functions grouped here.
2630 */ 2836 */
2631static int iwl_mac_setup_register(struct iwl_priv *priv) 2837static int iwl_mac_setup_register(struct iwl_priv *priv,
2838 struct iwlagn_ucode_capabilities *capa)
2632{ 2839{
2633 int ret; 2840 int ret;
2634 struct ieee80211_hw *hw = priv->hw; 2841 struct ieee80211_hw *hw = priv->hw;
@@ -2636,7 +2843,6 @@ static int iwl_mac_setup_register(struct iwl_priv *priv)
2636 2843
2637 /* Tell mac80211 our characteristics */ 2844 /* Tell mac80211 our characteristics */
2638 hw->flags = IEEE80211_HW_SIGNAL_DBM | 2845 hw->flags = IEEE80211_HW_SIGNAL_DBM |
2639 IEEE80211_HW_NOISE_DBM |
2640 IEEE80211_HW_AMPDU_AGGREGATION | 2846 IEEE80211_HW_AMPDU_AGGREGATION |
2641 IEEE80211_HW_SPECTRUM_MGMT; 2847 IEEE80211_HW_SPECTRUM_MGMT;
2642 2848
@@ -2649,6 +2855,8 @@ static int iwl_mac_setup_register(struct iwl_priv *priv)
2649 IEEE80211_HW_SUPPORTS_STATIC_SMPS; 2855 IEEE80211_HW_SUPPORTS_STATIC_SMPS;
2650 2856
2651 hw->sta_data_size = sizeof(struct iwl_station_priv); 2857 hw->sta_data_size = sizeof(struct iwl_station_priv);
2858 hw->vif_data_size = sizeof(struct iwl_vif_priv);
2859
2652 hw->wiphy->interface_modes = 2860 hw->wiphy->interface_modes =
2653 BIT(NL80211_IFTYPE_STATION) | 2861 BIT(NL80211_IFTYPE_STATION) |
2654 BIT(NL80211_IFTYPE_ADHOC); 2862 BIT(NL80211_IFTYPE_ADHOC);
@@ -2664,7 +2872,7 @@ static int iwl_mac_setup_register(struct iwl_priv *priv)
2664 2872
2665 hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX; 2873 hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX;
2666 /* we create the 802.11 header and a zero-length SSID element */ 2874 /* we create the 802.11 header and a zero-length SSID element */
2667 hw->wiphy->max_scan_ie_len = IWL_MAX_PROBE_REQUEST - 24 - 2; 2875 hw->wiphy->max_scan_ie_len = capa->max_probe_length - 24 - 2;
2668 2876
2669 /* Default value; 4 EDCA QOS priorities */ 2877 /* Default value; 4 EDCA QOS priorities */
2670 hw->queues = 4; 2878 hw->queues = 4;
@@ -2770,17 +2978,16 @@ static int iwl_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
2770 IWL_DEBUG_TX(priv, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, 2978 IWL_DEBUG_TX(priv, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len,
2771 ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); 2979 ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate);
2772 2980
2773 if (iwl_tx_skb(priv, skb)) 2981 if (iwlagn_tx_skb(priv, skb))
2774 dev_kfree_skb_any(skb); 2982 dev_kfree_skb_any(skb);
2775 2983
2776 IWL_DEBUG_MACDUMP(priv, "leave\n"); 2984 IWL_DEBUG_MACDUMP(priv, "leave\n");
2777 return NETDEV_TX_OK; 2985 return NETDEV_TX_OK;
2778} 2986}
2779 2987
2780void iwl_config_ap(struct iwl_priv *priv) 2988void iwl_config_ap(struct iwl_priv *priv, struct ieee80211_vif *vif)
2781{ 2989{
2782 int ret = 0; 2990 int ret = 0;
2783 unsigned long flags;
2784 2991
2785 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 2992 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
2786 return; 2993 return;
@@ -2793,7 +3000,7 @@ void iwl_config_ap(struct iwl_priv *priv)
2793 iwlcore_commit_rxon(priv); 3000 iwlcore_commit_rxon(priv);
2794 3001
2795 /* RXON Timing */ 3002 /* RXON Timing */
2796 iwl_setup_rxon_timing(priv); 3003 iwl_setup_rxon_timing(priv, vif);
2797 ret = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING, 3004 ret = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING,
2798 sizeof(priv->rxon_timing), &priv->rxon_timing); 3005 sizeof(priv->rxon_timing), &priv->rxon_timing);
2799 if (ret) 3006 if (ret)
@@ -2807,9 +3014,10 @@ void iwl_config_ap(struct iwl_priv *priv)
2807 if (priv->cfg->ops->hcmd->set_rxon_chain) 3014 if (priv->cfg->ops->hcmd->set_rxon_chain)
2808 priv->cfg->ops->hcmd->set_rxon_chain(priv); 3015 priv->cfg->ops->hcmd->set_rxon_chain(priv);
2809 3016
2810 /* FIXME: what should be the assoc_id for AP? */ 3017 priv->staging_rxon.assoc_id = 0;
2811 priv->staging_rxon.assoc_id = cpu_to_le16(priv->assoc_id); 3018
2812 if (priv->assoc_capability & WLAN_CAPABILITY_SHORT_PREAMBLE) 3019 if (vif->bss_conf.assoc_capability &
3020 WLAN_CAPABILITY_SHORT_PREAMBLE)
2813 priv->staging_rxon.flags |= 3021 priv->staging_rxon.flags |=
2814 RXON_FLG_SHORT_PREAMBLE_MSK; 3022 RXON_FLG_SHORT_PREAMBLE_MSK;
2815 else 3023 else
@@ -2817,26 +3025,21 @@ void iwl_config_ap(struct iwl_priv *priv)
2817 ~RXON_FLG_SHORT_PREAMBLE_MSK; 3025 ~RXON_FLG_SHORT_PREAMBLE_MSK;
2818 3026
2819 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) { 3027 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) {
2820 if (priv->assoc_capability & 3028 if (vif->bss_conf.assoc_capability &
2821 WLAN_CAPABILITY_SHORT_SLOT_TIME) 3029 WLAN_CAPABILITY_SHORT_SLOT_TIME)
2822 priv->staging_rxon.flags |= 3030 priv->staging_rxon.flags |=
2823 RXON_FLG_SHORT_SLOT_MSK; 3031 RXON_FLG_SHORT_SLOT_MSK;
2824 else 3032 else
2825 priv->staging_rxon.flags &= 3033 priv->staging_rxon.flags &=
2826 ~RXON_FLG_SHORT_SLOT_MSK; 3034 ~RXON_FLG_SHORT_SLOT_MSK;
2827 3035
2828 if (priv->iw_mode == NL80211_IFTYPE_ADHOC) 3036 if (vif->type == NL80211_IFTYPE_ADHOC)
2829 priv->staging_rxon.flags &= 3037 priv->staging_rxon.flags &=
2830 ~RXON_FLG_SHORT_SLOT_MSK; 3038 ~RXON_FLG_SHORT_SLOT_MSK;
2831 } 3039 }
2832 /* restore RXON assoc */ 3040 /* restore RXON assoc */
2833 priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK; 3041 priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK;
2834 iwlcore_commit_rxon(priv); 3042 iwlcore_commit_rxon(priv);
2835 iwl_reset_qos(priv);
2836 spin_lock_irqsave(&priv->lock, flags);
2837 iwl_activate_qos(priv, 1);
2838 spin_unlock_irqrestore(&priv->lock, flags);
2839 iwl_add_bcast_station(priv);
2840 } 3043 }
2841 iwl_send_beacon_cmd(priv); 3044 iwl_send_beacon_cmd(priv);
2842 3045
@@ -2855,8 +3058,7 @@ static void iwl_mac_update_tkip_key(struct ieee80211_hw *hw,
2855 struct iwl_priv *priv = hw->priv; 3058 struct iwl_priv *priv = hw->priv;
2856 IWL_DEBUG_MAC80211(priv, "enter\n"); 3059 IWL_DEBUG_MAC80211(priv, "enter\n");
2857 3060
2858 iwl_update_tkip_key(priv, keyconf, 3061 iwl_update_tkip_key(priv, keyconf, sta,
2859 sta ? sta->addr : iwl_bcast_addr,
2860 iv32, phase1key); 3062 iv32, phase1key);
2861 3063
2862 IWL_DEBUG_MAC80211(priv, "leave\n"); 3064 IWL_DEBUG_MAC80211(priv, "leave\n");
@@ -2868,7 +3070,6 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
2868 struct ieee80211_key_conf *key) 3070 struct ieee80211_key_conf *key)
2869{ 3071{
2870 struct iwl_priv *priv = hw->priv; 3072 struct iwl_priv *priv = hw->priv;
2871 const u8 *addr;
2872 int ret; 3073 int ret;
2873 u8 sta_id; 3074 u8 sta_id;
2874 bool is_default_wep_key = false; 3075 bool is_default_wep_key = false;
@@ -2879,25 +3080,29 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
2879 IWL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n"); 3080 IWL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n");
2880 return -EOPNOTSUPP; 3081 return -EOPNOTSUPP;
2881 } 3082 }
2882 addr = sta ? sta->addr : iwl_bcast_addr;
2883 sta_id = iwl_find_station(priv, addr);
2884 if (sta_id == IWL_INVALID_STATION) {
2885 IWL_DEBUG_MAC80211(priv, "leave - %pM not in station map.\n",
2886 addr);
2887 return -EINVAL;
2888 3083
3084 if (sta) {
3085 sta_id = iwl_sta_id(sta);
3086
3087 if (sta_id == IWL_INVALID_STATION) {
3088 IWL_DEBUG_MAC80211(priv, "leave - %pM not in station map.\n",
3089 sta->addr);
3090 return -EINVAL;
3091 }
3092 } else {
3093 sta_id = priv->hw_params.bcast_sta_id;
2889 } 3094 }
2890 3095
2891 mutex_lock(&priv->mutex); 3096 mutex_lock(&priv->mutex);
2892 iwl_scan_cancel_timeout(priv, 100); 3097 iwl_scan_cancel_timeout(priv, 100);
2893 mutex_unlock(&priv->mutex);
2894 3098
2895 /* If we are getting WEP group key and we didn't receive any key mapping 3099 /*
3100 * If we are getting WEP group key and we didn't receive any key mapping
2896 * so far, we are in legacy wep mode (group key only), otherwise we are 3101 * so far, we are in legacy wep mode (group key only), otherwise we are
2897 * in 1X mode. 3102 * in 1X mode.
2898 * In legacy wep mode, we use another host command to the uCode */ 3103 * In legacy wep mode, we use another host command to the uCode.
2899 if (key->alg == ALG_WEP && sta_id == priv->hw_params.bcast_sta_id && 3104 */
2900 priv->iw_mode != NL80211_IFTYPE_AP) { 3105 if (key->alg == ALG_WEP && !sta && vif->type != NL80211_IFTYPE_AP) {
2901 if (cmd == SET_KEY) 3106 if (cmd == SET_KEY)
2902 is_default_wep_key = !priv->key_mapping_key; 3107 is_default_wep_key = !priv->key_mapping_key;
2903 else 3108 else
@@ -2926,6 +3131,7 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
2926 ret = -EINVAL; 3131 ret = -EINVAL;
2927 } 3132 }
2928 3133
3134 mutex_unlock(&priv->mutex);
2929 IWL_DEBUG_MAC80211(priv, "leave\n"); 3135 IWL_DEBUG_MAC80211(priv, "leave\n");
2930 3136
2931 return ret; 3137 return ret;
@@ -2933,8 +3139,8 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
2933 3139
2934static int iwl_mac_ampdu_action(struct ieee80211_hw *hw, 3140static int iwl_mac_ampdu_action(struct ieee80211_hw *hw,
2935 struct ieee80211_vif *vif, 3141 struct ieee80211_vif *vif,
2936 enum ieee80211_ampdu_mlme_action action, 3142 enum ieee80211_ampdu_mlme_action action,
2937 struct ieee80211_sta *sta, u16 tid, u16 *ssn) 3143 struct ieee80211_sta *sta, u16 tid, u16 *ssn)
2938{ 3144{
2939 struct iwl_priv *priv = hw->priv; 3145 struct iwl_priv *priv = hw->priv;
2940 int ret; 3146 int ret;
@@ -2948,20 +3154,31 @@ static int iwl_mac_ampdu_action(struct ieee80211_hw *hw,
2948 switch (action) { 3154 switch (action) {
2949 case IEEE80211_AMPDU_RX_START: 3155 case IEEE80211_AMPDU_RX_START:
2950 IWL_DEBUG_HT(priv, "start Rx\n"); 3156 IWL_DEBUG_HT(priv, "start Rx\n");
2951 return iwl_sta_rx_agg_start(priv, sta->addr, tid, *ssn); 3157 return iwl_sta_rx_agg_start(priv, sta, tid, *ssn);
2952 case IEEE80211_AMPDU_RX_STOP: 3158 case IEEE80211_AMPDU_RX_STOP:
2953 IWL_DEBUG_HT(priv, "stop Rx\n"); 3159 IWL_DEBUG_HT(priv, "stop Rx\n");
2954 ret = iwl_sta_rx_agg_stop(priv, sta->addr, tid); 3160 ret = iwl_sta_rx_agg_stop(priv, sta, tid);
2955 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 3161 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
2956 return 0; 3162 return 0;
2957 else 3163 else
2958 return ret; 3164 return ret;
2959 case IEEE80211_AMPDU_TX_START: 3165 case IEEE80211_AMPDU_TX_START:
2960 IWL_DEBUG_HT(priv, "start Tx\n"); 3166 IWL_DEBUG_HT(priv, "start Tx\n");
2961 return iwl_tx_agg_start(priv, sta->addr, tid, ssn); 3167 ret = iwlagn_tx_agg_start(priv, vif, sta, tid, ssn);
3168 if (ret == 0) {
3169 priv->_agn.agg_tids_count++;
3170 IWL_DEBUG_HT(priv, "priv->_agn.agg_tids_count = %u\n",
3171 priv->_agn.agg_tids_count);
3172 }
3173 return ret;
2962 case IEEE80211_AMPDU_TX_STOP: 3174 case IEEE80211_AMPDU_TX_STOP:
2963 IWL_DEBUG_HT(priv, "stop Tx\n"); 3175 IWL_DEBUG_HT(priv, "stop Tx\n");
2964 ret = iwl_tx_agg_stop(priv, sta->addr, tid); 3176 ret = iwlagn_tx_agg_stop(priv, vif, sta, tid);
3177 if ((ret == 0) && (priv->_agn.agg_tids_count > 0)) {
3178 priv->_agn.agg_tids_count--;
3179 IWL_DEBUG_HT(priv, "priv->_agn.agg_tids_count = %u\n",
3180 priv->_agn.agg_tids_count);
3181 }
2965 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 3182 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
2966 return 0; 3183 return 0;
2967 else 3184 else
@@ -2977,18 +3194,6 @@ static int iwl_mac_ampdu_action(struct ieee80211_hw *hw,
2977 return 0; 3194 return 0;
2978} 3195}
2979 3196
2980static int iwl_mac_get_stats(struct ieee80211_hw *hw,
2981 struct ieee80211_low_level_stats *stats)
2982{
2983 struct iwl_priv *priv = hw->priv;
2984
2985 priv = hw->priv;
2986 IWL_DEBUG_MAC80211(priv, "enter\n");
2987 IWL_DEBUG_MAC80211(priv, "leave\n");
2988
2989 return 0;
2990}
2991
2992static void iwl_mac_sta_notify(struct ieee80211_hw *hw, 3197static void iwl_mac_sta_notify(struct ieee80211_hw *hw,
2993 struct ieee80211_vif *vif, 3198 struct ieee80211_vif *vif,
2994 enum sta_notify_cmd cmd, 3199 enum sta_notify_cmd cmd,
@@ -2998,18 +3203,7 @@ static void iwl_mac_sta_notify(struct ieee80211_hw *hw,
2998 struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; 3203 struct iwl_station_priv *sta_priv = (void *)sta->drv_priv;
2999 int sta_id; 3204 int sta_id;
3000 3205
3001 /*
3002 * TODO: We really should use this callback to
3003 * actually maintain the station table in
3004 * the device.
3005 */
3006
3007 switch (cmd) { 3206 switch (cmd) {
3008 case STA_NOTIFY_ADD:
3009 atomic_set(&sta_priv->pending_frames, 0);
3010 if (vif->type == NL80211_IFTYPE_AP)
3011 sta_priv->client = true;
3012 break;
3013 case STA_NOTIFY_SLEEP: 3207 case STA_NOTIFY_SLEEP:
3014 WARN_ON(!sta_priv->client); 3208 WARN_ON(!sta_priv->client);
3015 sta_priv->asleep = true; 3209 sta_priv->asleep = true;
@@ -3021,7 +3215,7 @@ static void iwl_mac_sta_notify(struct ieee80211_hw *hw,
3021 if (!sta_priv->asleep) 3215 if (!sta_priv->asleep)
3022 break; 3216 break;
3023 sta_priv->asleep = false; 3217 sta_priv->asleep = false;
3024 sta_id = iwl_find_station(priv, sta->addr); 3218 sta_id = iwl_sta_id(sta);
3025 if (sta_id != IWL_INVALID_STATION) 3219 if (sta_id != IWL_INVALID_STATION)
3026 iwl_sta_modify_ps_wake(priv, sta_id); 3220 iwl_sta_modify_ps_wake(priv, sta_id);
3027 break; 3221 break;
@@ -3030,6 +3224,44 @@ static void iwl_mac_sta_notify(struct ieee80211_hw *hw,
3030 } 3224 }
3031} 3225}
3032 3226
3227static int iwlagn_mac_sta_add(struct ieee80211_hw *hw,
3228 struct ieee80211_vif *vif,
3229 struct ieee80211_sta *sta)
3230{
3231 struct iwl_priv *priv = hw->priv;
3232 struct iwl_station_priv *sta_priv = (void *)sta->drv_priv;
3233 bool is_ap = vif->type == NL80211_IFTYPE_STATION;
3234 int ret;
3235 u8 sta_id;
3236
3237 sta_priv->common.sta_id = IWL_INVALID_STATION;
3238
3239 IWL_DEBUG_INFO(priv, "received request to add station %pM\n",
3240 sta->addr);
3241
3242 atomic_set(&sta_priv->pending_frames, 0);
3243 if (vif->type == NL80211_IFTYPE_AP)
3244 sta_priv->client = true;
3245
3246 ret = iwl_add_station_common(priv, sta->addr, is_ap, &sta->ht_cap,
3247 &sta_id);
3248 if (ret) {
3249 IWL_ERR(priv, "Unable to add station %pM (%d)\n",
3250 sta->addr, ret);
3251 /* Should we return success if return code is EEXIST ? */
3252 return ret;
3253 }
3254
3255 sta_priv->common.sta_id = sta_id;
3256
3257 /* Initialize rate scaling */
3258 IWL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n",
3259 sta->addr);
3260 iwl_rs_rate_init(priv, sta, sta_id);
3261
3262 return 0;
3263}
3264
3033/***************************************************************************** 3265/*****************************************************************************
3034 * 3266 *
3035 * sysfs attributes 3267 * sysfs attributes
@@ -3130,125 +3362,6 @@ static ssize_t store_tx_power(struct device *d,
3130 3362
3131static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, show_tx_power, store_tx_power); 3363static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, show_tx_power, store_tx_power);
3132 3364
3133static ssize_t show_flags(struct device *d,
3134 struct device_attribute *attr, char *buf)
3135{
3136 struct iwl_priv *priv = dev_get_drvdata(d);
3137
3138 return sprintf(buf, "0x%04X\n", priv->active_rxon.flags);
3139}
3140
3141static ssize_t store_flags(struct device *d,
3142 struct device_attribute *attr,
3143 const char *buf, size_t count)
3144{
3145 struct iwl_priv *priv = dev_get_drvdata(d);
3146 unsigned long val;
3147 u32 flags;
3148 int ret = strict_strtoul(buf, 0, &val);
3149 if (ret)
3150 return ret;
3151 flags = (u32)val;
3152
3153 mutex_lock(&priv->mutex);
3154 if (le32_to_cpu(priv->staging_rxon.flags) != flags) {
3155 /* Cancel any currently running scans... */
3156 if (iwl_scan_cancel_timeout(priv, 100))
3157 IWL_WARN(priv, "Could not cancel scan.\n");
3158 else {
3159 IWL_DEBUG_INFO(priv, "Commit rxon.flags = 0x%04X\n", flags);
3160 priv->staging_rxon.flags = cpu_to_le32(flags);
3161 iwlcore_commit_rxon(priv);
3162 }
3163 }
3164 mutex_unlock(&priv->mutex);
3165
3166 return count;
3167}
3168
3169static DEVICE_ATTR(flags, S_IWUSR | S_IRUGO, show_flags, store_flags);
3170
3171static ssize_t show_filter_flags(struct device *d,
3172 struct device_attribute *attr, char *buf)
3173{
3174 struct iwl_priv *priv = dev_get_drvdata(d);
3175
3176 return sprintf(buf, "0x%04X\n",
3177 le32_to_cpu(priv->active_rxon.filter_flags));
3178}
3179
3180static ssize_t store_filter_flags(struct device *d,
3181 struct device_attribute *attr,
3182 const char *buf, size_t count)
3183{
3184 struct iwl_priv *priv = dev_get_drvdata(d);
3185 unsigned long val;
3186 u32 filter_flags;
3187 int ret = strict_strtoul(buf, 0, &val);
3188 if (ret)
3189 return ret;
3190 filter_flags = (u32)val;
3191
3192 mutex_lock(&priv->mutex);
3193 if (le32_to_cpu(priv->staging_rxon.filter_flags) != filter_flags) {
3194 /* Cancel any currently running scans... */
3195 if (iwl_scan_cancel_timeout(priv, 100))
3196 IWL_WARN(priv, "Could not cancel scan.\n");
3197 else {
3198 IWL_DEBUG_INFO(priv, "Committing rxon.filter_flags = "
3199 "0x%04X\n", filter_flags);
3200 priv->staging_rxon.filter_flags =
3201 cpu_to_le32(filter_flags);
3202 iwlcore_commit_rxon(priv);
3203 }
3204 }
3205 mutex_unlock(&priv->mutex);
3206
3207 return count;
3208}
3209
3210static DEVICE_ATTR(filter_flags, S_IWUSR | S_IRUGO, show_filter_flags,
3211 store_filter_flags);
3212
3213
3214static ssize_t show_statistics(struct device *d,
3215 struct device_attribute *attr, char *buf)
3216{
3217 struct iwl_priv *priv = dev_get_drvdata(d);
3218 u32 size = sizeof(struct iwl_notif_statistics);
3219 u32 len = 0, ofs = 0;
3220 u8 *data = (u8 *)&priv->statistics;
3221 int rc = 0;
3222
3223 if (!iwl_is_alive(priv))
3224 return -EAGAIN;
3225
3226 mutex_lock(&priv->mutex);
3227 rc = iwl_send_statistics_request(priv, CMD_SYNC, false);
3228 mutex_unlock(&priv->mutex);
3229
3230 if (rc) {
3231 len = sprintf(buf,
3232 "Error sending statistics request: 0x%08X\n", rc);
3233 return len;
3234 }
3235
3236 while (size && (PAGE_SIZE - len)) {
3237 hex_dump_to_buffer(data + ofs, size, 16, 1, buf + len,
3238 PAGE_SIZE - len, 1);
3239 len = strlen(buf);
3240 if (PAGE_SIZE - len)
3241 buf[len++] = '\n';
3242
3243 ofs += 16;
3244 size -= min(size, 16U);
3245 }
3246
3247 return len;
3248}
3249
3250static DEVICE_ATTR(statistics, S_IRUGO, show_statistics, NULL);
3251
3252static ssize_t show_rts_ht_protection(struct device *d, 3365static ssize_t show_rts_ht_protection(struct device *d,
3253 struct device_attribute *attr, char *buf) 3366 struct device_attribute *attr, char *buf)
3254{ 3367{
@@ -3316,6 +3429,13 @@ static void iwl_setup_deferred_work(struct iwl_priv *priv)
3316 priv->ucode_trace.data = (unsigned long)priv; 3429 priv->ucode_trace.data = (unsigned long)priv;
3317 priv->ucode_trace.function = iwl_bg_ucode_trace; 3430 priv->ucode_trace.function = iwl_bg_ucode_trace;
3318 3431
3432 if (priv->cfg->ops->lib->recover_from_tx_stall) {
3433 init_timer(&priv->monitor_recover);
3434 priv->monitor_recover.data = (unsigned long)priv;
3435 priv->monitor_recover.function =
3436 priv->cfg->ops->lib->recover_from_tx_stall;
3437 }
3438
3319 if (!priv->cfg->use_isr_legacy) 3439 if (!priv->cfg->use_isr_legacy)
3320 tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long)) 3440 tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long))
3321 iwl_irq_tasklet, (unsigned long)priv); 3441 iwl_irq_tasklet, (unsigned long)priv);
@@ -3331,10 +3451,13 @@ static void iwl_cancel_deferred_work(struct iwl_priv *priv)
3331 3451
3332 cancel_delayed_work_sync(&priv->init_alive_start); 3452 cancel_delayed_work_sync(&priv->init_alive_start);
3333 cancel_delayed_work(&priv->scan_check); 3453 cancel_delayed_work(&priv->scan_check);
3454 cancel_work_sync(&priv->start_internal_scan);
3334 cancel_delayed_work(&priv->alive_start); 3455 cancel_delayed_work(&priv->alive_start);
3335 cancel_work_sync(&priv->beacon_update); 3456 cancel_work_sync(&priv->beacon_update);
3336 del_timer_sync(&priv->statistics_periodic); 3457 del_timer_sync(&priv->statistics_periodic);
3337 del_timer_sync(&priv->ucode_trace); 3458 del_timer_sync(&priv->ucode_trace);
3459 if (priv->cfg->ops->lib->recover_from_tx_stall)
3460 del_timer_sync(&priv->monitor_recover);
3338} 3461}
3339 3462
3340static void iwl_init_hw_rates(struct iwl_priv *priv, 3463static void iwl_init_hw_rates(struct iwl_priv *priv,
@@ -3372,9 +3495,6 @@ static int iwl_init_drv(struct iwl_priv *priv)
3372 mutex_init(&priv->mutex); 3495 mutex_init(&priv->mutex);
3373 mutex_init(&priv->sync_cmd_mutex); 3496 mutex_init(&priv->sync_cmd_mutex);
3374 3497
3375 /* Clear the driver's (not device's) station table */
3376 iwl_clear_stations_table(priv);
3377
3378 priv->ieee_channels = NULL; 3498 priv->ieee_channels = NULL;
3379 priv->ieee_rates = NULL; 3499 priv->ieee_rates = NULL;
3380 priv->band = IEEE80211_BAND_2GHZ; 3500 priv->band = IEEE80211_BAND_2GHZ;
@@ -3382,6 +3502,7 @@ static int iwl_init_drv(struct iwl_priv *priv)
3382 priv->iw_mode = NL80211_IFTYPE_STATION; 3502 priv->iw_mode = NL80211_IFTYPE_STATION;
3383 priv->current_ht_config.smps = IEEE80211_SMPS_STATIC; 3503 priv->current_ht_config.smps = IEEE80211_SMPS_STATIC;
3384 priv->missed_beacon_threshold = IWL_MISSED_BEACON_THRESHOLD_DEF; 3504 priv->missed_beacon_threshold = IWL_MISSED_BEACON_THRESHOLD_DEF;
3505 priv->_agn.agg_tids_count = 0;
3385 3506
3386 /* initialize force reset */ 3507 /* initialize force reset */
3387 priv->force_reset[IWL_RF_RESET].reset_duration = 3508 priv->force_reset[IWL_RF_RESET].reset_duration =
@@ -3395,16 +3516,10 @@ static int iwl_init_drv(struct iwl_priv *priv)
3395 3516
3396 iwl_init_scan_params(priv); 3517 iwl_init_scan_params(priv);
3397 3518
3398 iwl_reset_qos(priv);
3399
3400 priv->qos_data.qos_active = 0;
3401 priv->qos_data.qos_cap.val = 0;
3402
3403 priv->rates_mask = IWL_RATES_MASK;
3404 /* Set the tx_power_user_lmt to the lowest power level 3519 /* Set the tx_power_user_lmt to the lowest power level
3405 * this value will get overwritten by channel max power avg 3520 * this value will get overwritten by channel max power avg
3406 * from eeprom */ 3521 * from eeprom */
3407 priv->tx_power_user_lmt = IWL_TX_POWER_TARGET_POWER_MIN; 3522 priv->tx_power_user_lmt = IWLAGN_TX_POWER_TARGET_POWER_MIN;
3408 3523
3409 ret = iwl_init_channel_map(priv); 3524 ret = iwl_init_channel_map(priv);
3410 if (ret) { 3525 if (ret) {
@@ -3432,13 +3547,10 @@ static void iwl_uninit_drv(struct iwl_priv *priv)
3432 iwl_calib_free_results(priv); 3547 iwl_calib_free_results(priv);
3433 iwlcore_free_geos(priv); 3548 iwlcore_free_geos(priv);
3434 iwl_free_channel_map(priv); 3549 iwl_free_channel_map(priv);
3435 kfree(priv->scan); 3550 kfree(priv->scan_cmd);
3436} 3551}
3437 3552
3438static struct attribute *iwl_sysfs_entries[] = { 3553static struct attribute *iwl_sysfs_entries[] = {
3439 &dev_attr_flags.attr,
3440 &dev_attr_filter_flags.attr,
3441 &dev_attr_statistics.attr,
3442 &dev_attr_temperature.attr, 3554 &dev_attr_temperature.attr,
3443 &dev_attr_tx_power.attr, 3555 &dev_attr_tx_power.attr,
3444 &dev_attr_rts_ht_protection.attr, 3556 &dev_attr_rts_ht_protection.attr,
@@ -3463,13 +3575,14 @@ static struct ieee80211_ops iwl_hw_ops = {
3463 .configure_filter = iwl_configure_filter, 3575 .configure_filter = iwl_configure_filter,
3464 .set_key = iwl_mac_set_key, 3576 .set_key = iwl_mac_set_key,
3465 .update_tkip_key = iwl_mac_update_tkip_key, 3577 .update_tkip_key = iwl_mac_update_tkip_key,
3466 .get_stats = iwl_mac_get_stats,
3467 .conf_tx = iwl_mac_conf_tx, 3578 .conf_tx = iwl_mac_conf_tx,
3468 .reset_tsf = iwl_mac_reset_tsf, 3579 .reset_tsf = iwl_mac_reset_tsf,
3469 .bss_info_changed = iwl_bss_info_changed, 3580 .bss_info_changed = iwl_bss_info_changed,
3470 .ampdu_action = iwl_mac_ampdu_action, 3581 .ampdu_action = iwl_mac_ampdu_action,
3471 .hw_scan = iwl_mac_hw_scan, 3582 .hw_scan = iwl_mac_hw_scan,
3472 .sta_notify = iwl_mac_sta_notify, 3583 .sta_notify = iwl_mac_sta_notify,
3584 .sta_add = iwlagn_mac_sta_add,
3585 .sta_remove = iwl_mac_sta_remove,
3473}; 3586};
3474 3587
3475static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 3588static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
@@ -3573,7 +3686,7 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3573 iwl_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); 3686 iwl_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET);
3574 3687
3575 iwl_hw_detect(priv); 3688 iwl_hw_detect(priv);
3576 IWL_INFO(priv, "Detected Intel Wireless WiFi Link %s REV=0x%X\n", 3689 IWL_INFO(priv, "Detected %s, REV=0x%X\n",
3577 priv->cfg->name, priv->hw_rev); 3690 priv->cfg->name, priv->hw_rev);
3578 3691
3579 /* We disable the RETRY_TIMEOUT register (0x41) to keep 3692 /* We disable the RETRY_TIMEOUT register (0x41) to keep
@@ -3671,6 +3784,8 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3671 iwl_power_initialize(priv); 3784 iwl_power_initialize(priv);
3672 iwl_tt_initialize(priv); 3785 iwl_tt_initialize(priv);
3673 3786
3787 init_completion(&priv->_agn.firmware_loading_complete);
3788
3674 err = iwl_request_firmware(priv, true); 3789 err = iwl_request_firmware(priv, true);
3675 if (err) 3790 if (err)
3676 goto out_remove_sysfs; 3791 goto out_remove_sysfs;
@@ -3711,6 +3826,8 @@ static void __devexit iwl_pci_remove(struct pci_dev *pdev)
3711 if (!priv) 3826 if (!priv)
3712 return; 3827 return;
3713 3828
3829 wait_for_completion(&priv->_agn.firmware_loading_complete);
3830
3714 IWL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n"); 3831 IWL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n");
3715 3832
3716 iwl_dbgfs_unregister(priv); 3833 iwl_dbgfs_unregister(priv);
@@ -3751,10 +3868,9 @@ static void __devexit iwl_pci_remove(struct pci_dev *pdev)
3751 iwl_dealloc_ucode_pci(priv); 3868 iwl_dealloc_ucode_pci(priv);
3752 3869
3753 if (priv->rxq.bd) 3870 if (priv->rxq.bd)
3754 iwl_rx_queue_free(priv, &priv->rxq); 3871 iwlagn_rx_queue_free(priv, &priv->rxq);
3755 iwl_hw_txq_ctx_free(priv); 3872 iwlagn_hw_txq_ctx_free(priv);
3756 3873
3757 iwl_clear_stations_table(priv);
3758 iwl_eeprom_free(priv); 3874 iwl_eeprom_free(priv);
3759 3875
3760 3876
@@ -3869,6 +3985,11 @@ static DEFINE_PCI_DEVICE_TABLE(iwl_hw_card_ids) = {
3869 {IWL_PCI_DEVICE(0x4239, 0x1311, iwl6000i_2agn_cfg)}, 3985 {IWL_PCI_DEVICE(0x4239, 0x1311, iwl6000i_2agn_cfg)},
3870 {IWL_PCI_DEVICE(0x4239, 0x1316, iwl6000i_2abg_cfg)}, 3986 {IWL_PCI_DEVICE(0x4239, 0x1316, iwl6000i_2abg_cfg)},
3871 3987
3988/* 6x00 Series Gen2a */
3989 {IWL_PCI_DEVICE(0x0082, 0x1201, iwl6000g2a_2agn_cfg)},
3990 {IWL_PCI_DEVICE(0x0085, 0x1211, iwl6000g2a_2agn_cfg)},
3991 {IWL_PCI_DEVICE(0x0082, 0x1221, iwl6000g2a_2agn_cfg)},
3992
3872/* 6x50 WiFi/WiMax Series */ 3993/* 6x50 WiFi/WiMax Series */
3873 {IWL_PCI_DEVICE(0x0087, 0x1301, iwl6050_2agn_cfg)}, 3994 {IWL_PCI_DEVICE(0x0087, 0x1301, iwl6050_2agn_cfg)},
3874 {IWL_PCI_DEVICE(0x0087, 0x1306, iwl6050_2abg_cfg)}, 3995 {IWL_PCI_DEVICE(0x0087, 0x1306, iwl6050_2abg_cfg)},
@@ -3950,3 +4071,38 @@ module_param_named(debug, iwl_debug_level, uint, S_IRUGO | S_IWUSR);
3950MODULE_PARM_DESC(debug, "debug output mask"); 4071MODULE_PARM_DESC(debug, "debug output mask");
3951#endif 4072#endif
3952 4073
4074module_param_named(swcrypto50, iwlagn_mod_params.sw_crypto, bool, S_IRUGO);
4075MODULE_PARM_DESC(swcrypto50,
4076 "using crypto in software (default 0 [hardware]) (deprecated)");
4077module_param_named(swcrypto, iwlagn_mod_params.sw_crypto, int, S_IRUGO);
4078MODULE_PARM_DESC(swcrypto, "using crypto in software (default 0 [hardware])");
4079module_param_named(queues_num50,
4080 iwlagn_mod_params.num_of_queues, int, S_IRUGO);
4081MODULE_PARM_DESC(queues_num50,
4082 "number of hw queues in 50xx series (deprecated)");
4083module_param_named(queues_num, iwlagn_mod_params.num_of_queues, int, S_IRUGO);
4084MODULE_PARM_DESC(queues_num, "number of hw queues.");
4085module_param_named(11n_disable50, iwlagn_mod_params.disable_11n, int, S_IRUGO);
4086MODULE_PARM_DESC(11n_disable50, "disable 50XX 11n functionality (deprecated)");
4087module_param_named(11n_disable, iwlagn_mod_params.disable_11n, int, S_IRUGO);
4088MODULE_PARM_DESC(11n_disable, "disable 11n functionality");
4089module_param_named(amsdu_size_8K50, iwlagn_mod_params.amsdu_size_8K,
4090 int, S_IRUGO);
4091MODULE_PARM_DESC(amsdu_size_8K50,
4092 "enable 8K amsdu size in 50XX series (deprecated)");
4093module_param_named(amsdu_size_8K, iwlagn_mod_params.amsdu_size_8K,
4094 int, S_IRUGO);
4095MODULE_PARM_DESC(amsdu_size_8K, "enable 8K amsdu size");
4096module_param_named(fw_restart50, iwlagn_mod_params.restart_fw, int, S_IRUGO);
4097MODULE_PARM_DESC(fw_restart50,
4098 "restart firmware in case of error (deprecated)");
4099module_param_named(fw_restart, iwlagn_mod_params.restart_fw, int, S_IRUGO);
4100MODULE_PARM_DESC(fw_restart, "restart firmware in case of error");
4101module_param_named(
4102 disable_hw_scan, iwlagn_mod_params.disable_hw_scan, int, S_IRUGO);
4103MODULE_PARM_DESC(disable_hw_scan, "disable hardware scanning (default 0)");
4104
4105module_param_named(ucode_alternative, iwlagn_wanted_ucode_alternative, int,
4106 S_IRUGO);
4107MODULE_PARM_DESC(ucode_alternative,
4108 "specify ucode alternative to use from ucode file");