diff options
author | David S. Miller <davem@davemloft.net> | 2008-06-10 04:54:31 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-06-10 04:54:31 -0400 |
commit | 788c0a53164c05c5ccdb1472474372b72ba74644 (patch) | |
tree | 5f274102e3dc4bcca6cb3a695aa2c8228ad5fc4f /drivers/net | |
parent | e64bda89b8fe81cce9b4a20885d2c204c2d52532 (diff) | |
parent | 78cf07472f0ede8394bacc4bc02354505080cfe1 (diff) |
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/linville/wireless-next-2.6
Conflicts:
drivers/net/ps3_gelic_wireless.c
drivers/net/wireless/libertas/main.c
Diffstat (limited to 'drivers/net')
99 files changed, 6415 insertions, 4160 deletions
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index d415d81b5444..654a78c31087 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig | |||
@@ -2284,6 +2284,19 @@ config GELIC_WIRELESS | |||
2284 | the driver automatically distinguishes the models, you can | 2284 | the driver automatically distinguishes the models, you can |
2285 | safely enable this option even if you have a wireless-less model. | 2285 | safely enable this option even if you have a wireless-less model. |
2286 | 2286 | ||
2287 | config GELIC_WIRELESS_OLD_PSK_INTERFACE | ||
2288 | bool "PS3 Wireless private PSK interface (OBSOLETE)" | ||
2289 | depends on GELIC_WIRELESS | ||
2290 | help | ||
2291 | This option retains the obsolete private interface to pass | ||
2292 | the PSK from user space programs to the driver. The PSK | ||
2293 | stands for 'Pre Shared Key' and is used for WPA[2]-PSK | ||
2294 | (WPA-Personal) environment. | ||
2295 | If WPA[2]-PSK is used and you need to use old programs that | ||
2296 | support only this old interface, say Y. Otherwise N. | ||
2297 | |||
2298 | If unsure, say N. | ||
2299 | |||
2287 | config GIANFAR | 2300 | config GIANFAR |
2288 | tristate "Gianfar Ethernet" | 2301 | tristate "Gianfar Ethernet" |
2289 | depends on FSL_SOC | 2302 | depends on FSL_SOC |
diff --git a/drivers/net/ps3_gelic_wireless.c b/drivers/net/ps3_gelic_wireless.c index e5e02339a5cc..aa963ac1e37b 100644 --- a/drivers/net/ps3_gelic_wireless.c +++ b/drivers/net/ps3_gelic_wireless.c | |||
@@ -45,7 +45,8 @@ | |||
45 | #include "ps3_gelic_wireless.h" | 45 | #include "ps3_gelic_wireless.h" |
46 | 46 | ||
47 | 47 | ||
48 | static int gelic_wl_start_scan(struct gelic_wl_info *wl, int always_scan); | 48 | static int gelic_wl_start_scan(struct gelic_wl_info *wl, int always_scan, |
49 | u8 *essid, size_t essid_len); | ||
49 | static int gelic_wl_try_associate(struct net_device *netdev); | 50 | static int gelic_wl_try_associate(struct net_device *netdev); |
50 | 51 | ||
51 | /* | 52 | /* |
@@ -105,6 +106,7 @@ static const struct eurus_cmd_arg_info cmd_info[GELIC_EURUS_CMD_MAX_INDEX] = { | |||
105 | [GELIC_EURUS_CMD_GET_WEP_CFG] = { .post_arg = 1}, | 106 | [GELIC_EURUS_CMD_GET_WEP_CFG] = { .post_arg = 1}, |
106 | [GELIC_EURUS_CMD_GET_WPA_CFG] = { .post_arg = 1}, | 107 | [GELIC_EURUS_CMD_GET_WPA_CFG] = { .post_arg = 1}, |
107 | [GELIC_EURUS_CMD_GET_RSSI_CFG] = { .post_arg = 1}, | 108 | [GELIC_EURUS_CMD_GET_RSSI_CFG] = { .post_arg = 1}, |
109 | [GELIC_EURUS_CMD_START_SCAN] = { .pre_arg = 1}, | ||
108 | [GELIC_EURUS_CMD_GET_SCAN] = { .post_arg = 1}, | 110 | [GELIC_EURUS_CMD_GET_SCAN] = { .post_arg = 1}, |
109 | }; | 111 | }; |
110 | 112 | ||
@@ -163,7 +165,9 @@ static void gelic_eurus_sync_cmd_worker(struct work_struct *work) | |||
163 | card = port_to_card(wl_port(wl)); | 165 | card = port_to_card(wl_port(wl)); |
164 | 166 | ||
165 | if (cmd_info[cmd->cmd].pre_arg) { | 167 | if (cmd_info[cmd->cmd].pre_arg) { |
166 | arg1 = ps3_mm_phys_to_lpar(__pa(cmd->buffer)); | 168 | arg1 = (cmd->buffer) ? |
169 | ps3_mm_phys_to_lpar(__pa(cmd->buffer)) : | ||
170 | 0; | ||
167 | arg2 = cmd->buf_size; | 171 | arg2 = cmd->buf_size; |
168 | } else { | 172 | } else { |
169 | arg1 = 0; | 173 | arg1 = 0; |
@@ -350,7 +354,8 @@ static int gelic_wl_get_range(struct net_device *netdev, | |||
350 | 354 | ||
351 | /* encryption capability */ | 355 | /* encryption capability */ |
352 | range->enc_capa = IW_ENC_CAPA_WPA | | 356 | range->enc_capa = IW_ENC_CAPA_WPA | |
353 | IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP; | 357 | IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP | |
358 | IW_ENC_CAPA_4WAY_HANDSHAKE; | ||
354 | if (wpa2_capable()) | 359 | if (wpa2_capable()) |
355 | range->enc_capa |= IW_ENC_CAPA_WPA2; | 360 | range->enc_capa |= IW_ENC_CAPA_WPA2; |
356 | range->encoding_size[0] = 5; /* 40bit WEP */ | 361 | range->encoding_size[0] = 5; /* 40bit WEP */ |
@@ -359,6 +364,9 @@ static int gelic_wl_get_range(struct net_device *netdev, | |||
359 | range->num_encoding_sizes = 3; | 364 | range->num_encoding_sizes = 3; |
360 | range->max_encoding_tokens = GELIC_WEP_KEYS; | 365 | range->max_encoding_tokens = GELIC_WEP_KEYS; |
361 | 366 | ||
367 | /* scan capability */ | ||
368 | range->scan_capa = IW_SCAN_CAPA_ESSID; | ||
369 | |||
362 | pr_debug("%s: ->\n", __func__); | 370 | pr_debug("%s: ->\n", __func__); |
363 | return 0; | 371 | return 0; |
364 | 372 | ||
@@ -370,8 +378,18 @@ static int gelic_wl_set_scan(struct net_device *netdev, | |||
370 | union iwreq_data *wrqu, char *extra) | 378 | union iwreq_data *wrqu, char *extra) |
371 | { | 379 | { |
372 | struct gelic_wl_info *wl = port_wl(netdev_priv(netdev)); | 380 | struct gelic_wl_info *wl = port_wl(netdev_priv(netdev)); |
373 | 381 | struct iw_scan_req *req; | |
374 | return gelic_wl_start_scan(wl, 1); | 382 | u8 *essid = NULL; |
383 | size_t essid_len = 0; | ||
384 | |||
385 | if (wrqu->data.length == sizeof(struct iw_scan_req) && | ||
386 | wrqu->data.flags & IW_SCAN_THIS_ESSID) { | ||
387 | req = (struct iw_scan_req*)extra; | ||
388 | essid = req->essid; | ||
389 | essid_len = req->essid_len; | ||
390 | pr_debug("%s: ESSID scan =%s\n", __func__, essid); | ||
391 | } | ||
392 | return gelic_wl_start_scan(wl, 1, essid, essid_len); | ||
375 | } | 393 | } |
376 | 394 | ||
377 | #define OUI_LEN 3 | 395 | #define OUI_LEN 3 |
@@ -1256,42 +1274,19 @@ static int gelic_wl_set_encodeext(struct net_device *netdev, | |||
1256 | set_bit(key_index, &wl->key_enabled); | 1274 | set_bit(key_index, &wl->key_enabled); |
1257 | /* remember wep info changed */ | 1275 | /* remember wep info changed */ |
1258 | set_bit(GELIC_WL_STAT_CONFIGURED, &wl->stat); | 1276 | set_bit(GELIC_WL_STAT_CONFIGURED, &wl->stat); |
1259 | } else if ((alg == IW_ENCODE_ALG_TKIP) || (alg == IW_ENCODE_ALG_CCMP)) { | 1277 | } else if (alg == IW_ENCODE_ALG_PMK) { |
1260 | pr_debug("%s: TKIP/CCMP requested alg=%d\n", __func__, alg); | 1278 | if (ext->key_len != WPA_PSK_LEN) { |
1261 | /* check key length */ | 1279 | pr_err("%s: PSK length wrong %d\n", __func__, |
1262 | if (IW_ENCODING_TOKEN_MAX < ext->key_len) { | 1280 | ext->key_len); |
1263 | pr_info("%s: key is too long %d\n", __func__, | ||
1264 | ext->key_len); | ||
1265 | ret = -EINVAL; | 1281 | ret = -EINVAL; |
1266 | goto done; | 1282 | goto done; |
1267 | } | 1283 | } |
1268 | if (alg == IW_ENCODE_ALG_CCMP) { | 1284 | memset(wl->psk, 0, sizeof(wl->psk)); |
1269 | pr_debug("%s: AES selected\n", __func__); | 1285 | memcpy(wl->psk, ext->key, ext->key_len); |
1270 | wl->group_cipher_method = GELIC_WL_CIPHER_AES; | 1286 | wl->psk_len = ext->key_len; |
1271 | wl->pairwise_cipher_method = GELIC_WL_CIPHER_AES; | 1287 | wl->psk_type = GELIC_EURUS_WPA_PSK_BIN; |
1272 | wl->wpa_level = GELIC_WL_WPA_LEVEL_WPA2; | 1288 | /* remember PSK configured */ |
1273 | } else { | 1289 | set_bit(GELIC_WL_STAT_WPA_PSK_SET, &wl->stat); |
1274 | pr_debug("%s: TKIP selected, WPA forced\n", __func__); | ||
1275 | wl->group_cipher_method = GELIC_WL_CIPHER_TKIP; | ||
1276 | wl->pairwise_cipher_method = GELIC_WL_CIPHER_TKIP; | ||
1277 | /* FIXME: how do we do if WPA2 + TKIP? */ | ||
1278 | wl->wpa_level = GELIC_WL_WPA_LEVEL_WPA; | ||
1279 | } | ||
1280 | if (flags & IW_ENCODE_RESTRICTED) | ||
1281 | BUG(); | ||
1282 | wl->auth_method = GELIC_EURUS_AUTH_OPEN; | ||
1283 | /* We should use same key for both and unicast */ | ||
1284 | if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) | ||
1285 | pr_debug("%s: group key \n", __func__); | ||
1286 | else | ||
1287 | pr_debug("%s: unicast key \n", __func__); | ||
1288 | /* OK, update the key */ | ||
1289 | wl->key_len[key_index] = ext->key_len; | ||
1290 | memset(wl->key[key_index], 0, IW_ENCODING_TOKEN_MAX); | ||
1291 | memcpy(wl->key[key_index], ext->key, ext->key_len); | ||
1292 | set_bit(key_index, &wl->key_enabled); | ||
1293 | /* remember info changed */ | ||
1294 | set_bit(GELIC_WL_STAT_CONFIGURED, &wl->stat); | ||
1295 | } | 1290 | } |
1296 | done: | 1291 | done: |
1297 | spin_unlock_irqrestore(&wl->lock, irqflag); | 1292 | spin_unlock_irqrestore(&wl->lock, irqflag); |
@@ -1397,6 +1392,7 @@ static int gelic_wl_get_mode(struct net_device *netdev, | |||
1397 | return 0; | 1392 | return 0; |
1398 | } | 1393 | } |
1399 | 1394 | ||
1395 | #ifdef CONFIG_GELIC_WIRELESS_OLD_PSK_INTERFACE | ||
1400 | /* SIOCIWFIRSTPRIV */ | 1396 | /* SIOCIWFIRSTPRIV */ |
1401 | static int hex2bin(u8 *str, u8 *bin, unsigned int len) | 1397 | static int hex2bin(u8 *str, u8 *bin, unsigned int len) |
1402 | { | 1398 | { |
@@ -1501,6 +1497,7 @@ static int gelic_wl_priv_get_psk(struct net_device *net_dev, | |||
1501 | pr_debug("%s:-> %d\n", __func__, data->data.length); | 1497 | pr_debug("%s:-> %d\n", __func__, data->data.length); |
1502 | return 0; | 1498 | return 0; |
1503 | } | 1499 | } |
1500 | #endif | ||
1504 | 1501 | ||
1505 | /* SIOCGIWNICKN */ | 1502 | /* SIOCGIWNICKN */ |
1506 | static int gelic_wl_get_nick(struct net_device *net_dev, | 1503 | static int gelic_wl_get_nick(struct net_device *net_dev, |
@@ -1524,15 +1521,20 @@ static struct iw_statistics *gelic_wl_get_wireless_stats( | |||
1524 | struct gelic_eurus_cmd *cmd; | 1521 | struct gelic_eurus_cmd *cmd; |
1525 | struct iw_statistics *is; | 1522 | struct iw_statistics *is; |
1526 | struct gelic_eurus_rssi_info *rssi; | 1523 | struct gelic_eurus_rssi_info *rssi; |
1524 | void *buf; | ||
1527 | 1525 | ||
1528 | pr_debug("%s: <-\n", __func__); | 1526 | pr_debug("%s: <-\n", __func__); |
1529 | 1527 | ||
1528 | buf = (void *)__get_free_page(GFP_KERNEL); | ||
1529 | if (!buf) | ||
1530 | return NULL; | ||
1531 | |||
1530 | is = &wl->iwstat; | 1532 | is = &wl->iwstat; |
1531 | memset(is, 0, sizeof(*is)); | 1533 | memset(is, 0, sizeof(*is)); |
1532 | cmd = gelic_eurus_sync_cmd(wl, GELIC_EURUS_CMD_GET_RSSI_CFG, | 1534 | cmd = gelic_eurus_sync_cmd(wl, GELIC_EURUS_CMD_GET_RSSI_CFG, |
1533 | wl->buf, sizeof(*rssi)); | 1535 | buf, sizeof(*rssi)); |
1534 | if (cmd && !cmd->status && !cmd->cmd_status) { | 1536 | if (cmd && !cmd->status && !cmd->cmd_status) { |
1535 | rssi = wl->buf; | 1537 | rssi = buf; |
1536 | is->qual.level = be16_to_cpu(rssi->rssi); | 1538 | is->qual.level = be16_to_cpu(rssi->rssi); |
1537 | is->qual.updated = IW_QUAL_LEVEL_UPDATED | | 1539 | is->qual.updated = IW_QUAL_LEVEL_UPDATED | |
1538 | IW_QUAL_QUAL_INVALID | IW_QUAL_NOISE_INVALID; | 1540 | IW_QUAL_QUAL_INVALID | IW_QUAL_NOISE_INVALID; |
@@ -1541,6 +1543,7 @@ static struct iw_statistics *gelic_wl_get_wireless_stats( | |||
1541 | is->qual.updated = IW_QUAL_ALL_INVALID; | 1543 | is->qual.updated = IW_QUAL_ALL_INVALID; |
1542 | 1544 | ||
1543 | kfree(cmd); | 1545 | kfree(cmd); |
1546 | free_page((unsigned long)buf); | ||
1544 | pr_debug("%s: ->\n", __func__); | 1547 | pr_debug("%s: ->\n", __func__); |
1545 | return is; | 1548 | return is; |
1546 | } | 1549 | } |
@@ -1548,10 +1551,13 @@ static struct iw_statistics *gelic_wl_get_wireless_stats( | |||
1548 | /* | 1551 | /* |
1549 | * scanning helpers | 1552 | * scanning helpers |
1550 | */ | 1553 | */ |
1551 | static int gelic_wl_start_scan(struct gelic_wl_info *wl, int always_scan) | 1554 | static int gelic_wl_start_scan(struct gelic_wl_info *wl, int always_scan, |
1555 | u8 *essid, size_t essid_len) | ||
1552 | { | 1556 | { |
1553 | struct gelic_eurus_cmd *cmd; | 1557 | struct gelic_eurus_cmd *cmd; |
1554 | int ret = 0; | 1558 | int ret = 0; |
1559 | void *buf = NULL; | ||
1560 | size_t len; | ||
1555 | 1561 | ||
1556 | pr_debug("%s: <- always=%d\n", __func__, always_scan); | 1562 | pr_debug("%s: <- always=%d\n", __func__, always_scan); |
1557 | if (mutex_lock_interruptible(&wl->scan_lock)) | 1563 | if (mutex_lock_interruptible(&wl->scan_lock)) |
@@ -1574,12 +1580,27 @@ static int gelic_wl_start_scan(struct gelic_wl_info *wl, int always_scan) | |||
1574 | complete(&wl->scan_done); | 1580 | complete(&wl->scan_done); |
1575 | goto out; | 1581 | goto out; |
1576 | } | 1582 | } |
1583 | |||
1584 | /* ESSID scan ? */ | ||
1585 | if (essid_len && essid) { | ||
1586 | buf = (void *)__get_free_page(GFP_KERNEL); | ||
1587 | if (!buf) { | ||
1588 | ret = -ENOMEM; | ||
1589 | goto out; | ||
1590 | } | ||
1591 | len = IW_ESSID_MAX_SIZE; /* hypervisor always requires 32 */ | ||
1592 | memset(buf, 0, len); | ||
1593 | memcpy(buf, essid, essid_len); | ||
1594 | pr_debug("%s: essid scan='%s'\n", __func__, (char *)buf); | ||
1595 | } else | ||
1596 | len = 0; | ||
1597 | |||
1577 | /* | 1598 | /* |
1578 | * issue start scan request | 1599 | * issue start scan request |
1579 | */ | 1600 | */ |
1580 | wl->scan_stat = GELIC_WL_SCAN_STAT_SCANNING; | 1601 | wl->scan_stat = GELIC_WL_SCAN_STAT_SCANNING; |
1581 | cmd = gelic_eurus_sync_cmd(wl, GELIC_EURUS_CMD_START_SCAN, | 1602 | cmd = gelic_eurus_sync_cmd(wl, GELIC_EURUS_CMD_START_SCAN, |
1582 | NULL, 0); | 1603 | buf, len); |
1583 | if (!cmd || cmd->status || cmd->cmd_status) { | 1604 | if (!cmd || cmd->status || cmd->cmd_status) { |
1584 | wl->scan_stat = GELIC_WL_SCAN_STAT_INIT; | 1605 | wl->scan_stat = GELIC_WL_SCAN_STAT_INIT; |
1585 | complete(&wl->scan_done); | 1606 | complete(&wl->scan_done); |
@@ -1588,6 +1609,7 @@ static int gelic_wl_start_scan(struct gelic_wl_info *wl, int always_scan) | |||
1588 | } | 1609 | } |
1589 | kfree(cmd); | 1610 | kfree(cmd); |
1590 | out: | 1611 | out: |
1612 | free_page((unsigned long)buf); | ||
1591 | mutex_unlock(&wl->scan_lock); | 1613 | mutex_unlock(&wl->scan_lock); |
1592 | pr_debug("%s: ->\n", __func__); | 1614 | pr_debug("%s: ->\n", __func__); |
1593 | return ret; | 1615 | return ret; |
@@ -1607,11 +1629,18 @@ static void gelic_wl_scan_complete_event(struct gelic_wl_info *wl) | |||
1607 | union iwreq_data data; | 1629 | union iwreq_data data; |
1608 | unsigned long this_time = jiffies; | 1630 | unsigned long this_time = jiffies; |
1609 | unsigned int data_len, i, found, r; | 1631 | unsigned int data_len, i, found, r; |
1632 | void *buf; | ||
1610 | DECLARE_MAC_BUF(mac); | 1633 | DECLARE_MAC_BUF(mac); |
1611 | 1634 | ||
1612 | pr_debug("%s:start\n", __func__); | 1635 | pr_debug("%s:start\n", __func__); |
1613 | mutex_lock(&wl->scan_lock); | 1636 | mutex_lock(&wl->scan_lock); |
1614 | 1637 | ||
1638 | buf = (void *)__get_free_page(GFP_KERNEL); | ||
1639 | if (!buf) { | ||
1640 | pr_info("%s: scan buffer alloc failed\n", __func__); | ||
1641 | goto out; | ||
1642 | } | ||
1643 | |||
1615 | if (wl->scan_stat != GELIC_WL_SCAN_STAT_SCANNING) { | 1644 | if (wl->scan_stat != GELIC_WL_SCAN_STAT_SCANNING) { |
1616 | /* | 1645 | /* |
1617 | * stop() may be called while scanning, ignore result | 1646 | * stop() may be called while scanning, ignore result |
@@ -1622,7 +1651,7 @@ static void gelic_wl_scan_complete_event(struct gelic_wl_info *wl) | |||
1622 | } | 1651 | } |
1623 | 1652 | ||
1624 | cmd = gelic_eurus_sync_cmd(wl, GELIC_EURUS_CMD_GET_SCAN, | 1653 | cmd = gelic_eurus_sync_cmd(wl, GELIC_EURUS_CMD_GET_SCAN, |
1625 | wl->buf, PAGE_SIZE); | 1654 | buf, PAGE_SIZE); |
1626 | if (!cmd || cmd->status || cmd->cmd_status) { | 1655 | if (!cmd || cmd->status || cmd->cmd_status) { |
1627 | wl->scan_stat = GELIC_WL_SCAN_STAT_INIT; | 1656 | wl->scan_stat = GELIC_WL_SCAN_STAT_INIT; |
1628 | pr_info("%s:cmd failed\n", __func__); | 1657 | pr_info("%s:cmd failed\n", __func__); |
@@ -1649,7 +1678,7 @@ static void gelic_wl_scan_complete_event(struct gelic_wl_info *wl) | |||
1649 | } | 1678 | } |
1650 | 1679 | ||
1651 | /* put them in the newtork_list */ | 1680 | /* put them in the newtork_list */ |
1652 | for (i = 0, scan_info_size = 0, scan_info = wl->buf; | 1681 | for (i = 0, scan_info_size = 0, scan_info = buf; |
1653 | scan_info_size < data_len; | 1682 | scan_info_size < data_len; |
1654 | i++, scan_info_size += be16_to_cpu(scan_info->size), | 1683 | i++, scan_info_size += be16_to_cpu(scan_info->size), |
1655 | scan_info = (void *)scan_info + be16_to_cpu(scan_info->size)) { | 1684 | scan_info = (void *)scan_info + be16_to_cpu(scan_info->size)) { |
@@ -1726,6 +1755,7 @@ static void gelic_wl_scan_complete_event(struct gelic_wl_info *wl) | |||
1726 | wireless_send_event(port_to_netdev(wl_port(wl)), SIOCGIWSCAN, &data, | 1755 | wireless_send_event(port_to_netdev(wl_port(wl)), SIOCGIWSCAN, &data, |
1727 | NULL); | 1756 | NULL); |
1728 | out: | 1757 | out: |
1758 | free_page((unsigned long)buf); | ||
1729 | complete(&wl->scan_done); | 1759 | complete(&wl->scan_done); |
1730 | mutex_unlock(&wl->scan_lock); | 1760 | mutex_unlock(&wl->scan_lock); |
1731 | pr_debug("%s:end\n", __func__); | 1761 | pr_debug("%s:end\n", __func__); |
@@ -1848,7 +1878,10 @@ static int gelic_wl_do_wep_setup(struct gelic_wl_info *wl) | |||
1848 | 1878 | ||
1849 | pr_debug("%s: <-\n", __func__); | 1879 | pr_debug("%s: <-\n", __func__); |
1850 | /* we can assume no one should uses the buffer */ | 1880 | /* we can assume no one should uses the buffer */ |
1851 | wep = wl->buf; | 1881 | wep = (struct gelic_eurus_wep_cfg *)__get_free_page(GFP_KERNEL); |
1882 | if (!wep) | ||
1883 | return -ENOMEM; | ||
1884 | |||
1852 | memset(wep, 0, sizeof(*wep)); | 1885 | memset(wep, 0, sizeof(*wep)); |
1853 | 1886 | ||
1854 | if (wl->group_cipher_method == GELIC_WL_CIPHER_WEP) { | 1887 | if (wl->group_cipher_method == GELIC_WL_CIPHER_WEP) { |
@@ -1898,6 +1931,7 @@ static int gelic_wl_do_wep_setup(struct gelic_wl_info *wl) | |||
1898 | 1931 | ||
1899 | kfree(cmd); | 1932 | kfree(cmd); |
1900 | out: | 1933 | out: |
1934 | free_page((unsigned long)wep); | ||
1901 | pr_debug("%s: ->\n", __func__); | 1935 | pr_debug("%s: ->\n", __func__); |
1902 | return ret; | 1936 | return ret; |
1903 | } | 1937 | } |
@@ -1941,7 +1975,10 @@ static int gelic_wl_do_wpa_setup(struct gelic_wl_info *wl) | |||
1941 | 1975 | ||
1942 | pr_debug("%s: <-\n", __func__); | 1976 | pr_debug("%s: <-\n", __func__); |
1943 | /* we can assume no one should uses the buffer */ | 1977 | /* we can assume no one should uses the buffer */ |
1944 | wpa = wl->buf; | 1978 | wpa = (struct gelic_eurus_wpa_cfg *)__get_free_page(GFP_KERNEL); |
1979 | if (!wpa) | ||
1980 | return -ENOMEM; | ||
1981 | |||
1945 | memset(wpa, 0, sizeof(*wpa)); | 1982 | memset(wpa, 0, sizeof(*wpa)); |
1946 | 1983 | ||
1947 | if (!test_bit(GELIC_WL_STAT_WPA_PSK_SET, &wl->stat)) | 1984 | if (!test_bit(GELIC_WL_STAT_WPA_PSK_SET, &wl->stat)) |
@@ -2000,6 +2037,7 @@ static int gelic_wl_do_wpa_setup(struct gelic_wl_info *wl) | |||
2000 | else if (cmd->status || cmd->cmd_status) | 2037 | else if (cmd->status || cmd->cmd_status) |
2001 | ret = -ENXIO; | 2038 | ret = -ENXIO; |
2002 | kfree(cmd); | 2039 | kfree(cmd); |
2040 | free_page((unsigned long)wpa); | ||
2003 | pr_debug("%s: --> %d\n", __func__, ret); | 2041 | pr_debug("%s: --> %d\n", __func__, ret); |
2004 | return ret; | 2042 | return ret; |
2005 | } | 2043 | } |
@@ -2018,7 +2056,10 @@ static int gelic_wl_associate_bss(struct gelic_wl_info *wl, | |||
2018 | pr_debug("%s: <-\n", __func__); | 2056 | pr_debug("%s: <-\n", __func__); |
2019 | 2057 | ||
2020 | /* do common config */ | 2058 | /* do common config */ |
2021 | common = wl->buf; | 2059 | common = (struct gelic_eurus_common_cfg *)__get_free_page(GFP_KERNEL); |
2060 | if (!common) | ||
2061 | return -ENOMEM; | ||
2062 | |||
2022 | memset(common, 0, sizeof(*common)); | 2063 | memset(common, 0, sizeof(*common)); |
2023 | common->bss_type = cpu_to_be16(GELIC_EURUS_BSS_INFRA); | 2064 | common->bss_type = cpu_to_be16(GELIC_EURUS_BSS_INFRA); |
2024 | common->op_mode = cpu_to_be16(GELIC_EURUS_OPMODE_11BG); | 2065 | common->op_mode = cpu_to_be16(GELIC_EURUS_OPMODE_11BG); |
@@ -2104,6 +2145,7 @@ static int gelic_wl_associate_bss(struct gelic_wl_info *wl, | |||
2104 | pr_info("%s: connected\n", __func__); | 2145 | pr_info("%s: connected\n", __func__); |
2105 | } | 2146 | } |
2106 | out: | 2147 | out: |
2148 | free_page((unsigned long)common); | ||
2107 | pr_debug("%s: ->\n", __func__); | 2149 | pr_debug("%s: ->\n", __func__); |
2108 | return ret; | 2150 | return ret; |
2109 | } | 2151 | } |
@@ -2255,6 +2297,9 @@ static void gelic_wl_assoc_worker(struct work_struct *work) | |||
2255 | 2297 | ||
2256 | struct gelic_wl_scan_info *best_bss; | 2298 | struct gelic_wl_scan_info *best_bss; |
2257 | int ret; | 2299 | int ret; |
2300 | unsigned long irqflag; | ||
2301 | u8 *essid; | ||
2302 | size_t essid_len; | ||
2258 | 2303 | ||
2259 | wl = container_of(work, struct gelic_wl_info, assoc_work.work); | 2304 | wl = container_of(work, struct gelic_wl_info, assoc_work.work); |
2260 | 2305 | ||
@@ -2263,7 +2308,19 @@ static void gelic_wl_assoc_worker(struct work_struct *work) | |||
2263 | if (wl->assoc_stat != GELIC_WL_ASSOC_STAT_DISCONN) | 2308 | if (wl->assoc_stat != GELIC_WL_ASSOC_STAT_DISCONN) |
2264 | goto out; | 2309 | goto out; |
2265 | 2310 | ||
2266 | ret = gelic_wl_start_scan(wl, 0); | 2311 | spin_lock_irqsave(&wl->lock, irqflag); |
2312 | if (test_bit(GELIC_WL_STAT_ESSID_SET, &wl->stat)) { | ||
2313 | pr_debug("%s: assoc ESSID configured %s\n", __func__, | ||
2314 | wl->essid); | ||
2315 | essid = wl->essid; | ||
2316 | essid_len = wl->essid_len; | ||
2317 | } else { | ||
2318 | essid = NULL; | ||
2319 | essid_len = 0; | ||
2320 | } | ||
2321 | spin_unlock_irqrestore(&wl->lock, irqflag); | ||
2322 | |||
2323 | ret = gelic_wl_start_scan(wl, 0, essid, essid_len); | ||
2267 | if (ret == -ERESTARTSYS) { | 2324 | if (ret == -ERESTARTSYS) { |
2268 | pr_debug("%s: scan start failed association\n", __func__); | 2325 | pr_debug("%s: scan start failed association\n", __func__); |
2269 | schedule_delayed_work(&wl->assoc_work, HZ/10); /*FIXME*/ | 2326 | schedule_delayed_work(&wl->assoc_work, HZ/10); /*FIXME*/ |
@@ -2351,6 +2408,7 @@ static const iw_handler gelic_wl_wext_handler[] = | |||
2351 | IW_IOCTL(SIOCGIWNICKN) = gelic_wl_get_nick, | 2408 | IW_IOCTL(SIOCGIWNICKN) = gelic_wl_get_nick, |
2352 | }; | 2409 | }; |
2353 | 2410 | ||
2411 | #ifdef CONFIG_GELIC_WIRELESS_OLD_PSK_INTERFACE | ||
2354 | static struct iw_priv_args gelic_wl_private_args[] = | 2412 | static struct iw_priv_args gelic_wl_private_args[] = |
2355 | { | 2413 | { |
2356 | { | 2414 | { |
@@ -2372,15 +2430,18 @@ static const iw_handler gelic_wl_private_handler[] = | |||
2372 | gelic_wl_priv_set_psk, | 2430 | gelic_wl_priv_set_psk, |
2373 | gelic_wl_priv_get_psk, | 2431 | gelic_wl_priv_get_psk, |
2374 | }; | 2432 | }; |
2433 | #endif | ||
2375 | 2434 | ||
2376 | static const struct iw_handler_def gelic_wl_wext_handler_def = { | 2435 | static const struct iw_handler_def gelic_wl_wext_handler_def = { |
2377 | .num_standard = ARRAY_SIZE(gelic_wl_wext_handler), | 2436 | .num_standard = ARRAY_SIZE(gelic_wl_wext_handler), |
2378 | .standard = gelic_wl_wext_handler, | 2437 | .standard = gelic_wl_wext_handler, |
2379 | .get_wireless_stats = gelic_wl_get_wireless_stats, | 2438 | .get_wireless_stats = gelic_wl_get_wireless_stats, |
2439 | #ifdef CONFIG_GELIC_WIRELESS_OLD_PSK_INTERFACE | ||
2380 | .num_private = ARRAY_SIZE(gelic_wl_private_handler), | 2440 | .num_private = ARRAY_SIZE(gelic_wl_private_handler), |
2381 | .num_private_args = ARRAY_SIZE(gelic_wl_private_args), | 2441 | .num_private_args = ARRAY_SIZE(gelic_wl_private_args), |
2382 | .private = gelic_wl_private_handler, | 2442 | .private = gelic_wl_private_handler, |
2383 | .private_args = gelic_wl_private_args, | 2443 | .private_args = gelic_wl_private_args, |
2444 | #endif | ||
2384 | }; | 2445 | }; |
2385 | 2446 | ||
2386 | static struct net_device *gelic_wl_alloc(struct gelic_card *card) | 2447 | static struct net_device *gelic_wl_alloc(struct gelic_card *card) |
@@ -2446,16 +2507,9 @@ static struct net_device *gelic_wl_alloc(struct gelic_card *card) | |||
2446 | BUILD_BUG_ON(PAGE_SIZE < | 2507 | BUILD_BUG_ON(PAGE_SIZE < |
2447 | sizeof(struct gelic_eurus_scan_info) * | 2508 | sizeof(struct gelic_eurus_scan_info) * |
2448 | GELIC_EURUS_MAX_SCAN); | 2509 | GELIC_EURUS_MAX_SCAN); |
2449 | wl->buf = (void *)get_zeroed_page(GFP_KERNEL); | ||
2450 | if (!wl->buf) { | ||
2451 | pr_info("%s:buffer allocation failed\n", __func__); | ||
2452 | goto fail_getpage; | ||
2453 | } | ||
2454 | pr_debug("%s:end\n", __func__); | 2510 | pr_debug("%s:end\n", __func__); |
2455 | return netdev; | 2511 | return netdev; |
2456 | 2512 | ||
2457 | fail_getpage: | ||
2458 | destroy_workqueue(wl->event_queue); | ||
2459 | fail_event_workqueue: | 2513 | fail_event_workqueue: |
2460 | destroy_workqueue(wl->eurus_cmd_queue); | 2514 | destroy_workqueue(wl->eurus_cmd_queue); |
2461 | fail_cmd_workqueue: | 2515 | fail_cmd_workqueue: |
@@ -2474,8 +2528,6 @@ static void gelic_wl_free(struct gelic_wl_info *wl) | |||
2474 | 2528 | ||
2475 | pr_debug("%s: <-\n", __func__); | 2529 | pr_debug("%s: <-\n", __func__); |
2476 | 2530 | ||
2477 | free_page((unsigned long)wl->buf); | ||
2478 | |||
2479 | pr_debug("%s: destroy queues\n", __func__); | 2531 | pr_debug("%s: destroy queues\n", __func__); |
2480 | destroy_workqueue(wl->eurus_cmd_queue); | 2532 | destroy_workqueue(wl->eurus_cmd_queue); |
2481 | destroy_workqueue(wl->event_queue); | 2533 | destroy_workqueue(wl->event_queue); |
diff --git a/drivers/net/ps3_gelic_wireless.h b/drivers/net/ps3_gelic_wireless.h index bc730632da5b..5339e0078d18 100644 --- a/drivers/net/ps3_gelic_wireless.h +++ b/drivers/net/ps3_gelic_wireless.h | |||
@@ -288,9 +288,6 @@ struct gelic_wl_info { | |||
288 | u8 active_bssid[ETH_ALEN]; /* associated bssid */ | 288 | u8 active_bssid[ETH_ALEN]; /* associated bssid */ |
289 | unsigned int essid_len; | 289 | unsigned int essid_len; |
290 | 290 | ||
291 | /* buffer for hypervisor IO */ | ||
292 | void *buf; | ||
293 | |||
294 | struct iw_public_data wireless_data; | 291 | struct iw_public_data wireless_data; |
295 | struct iw_statistics iwstat; | 292 | struct iw_statistics iwstat; |
296 | }; | 293 | }; |
diff --git a/drivers/net/wireless/adm8211.c b/drivers/net/wireless/adm8211.c index 7af5d8851f67..0ba55ba93958 100644 --- a/drivers/net/wireless/adm8211.c +++ b/drivers/net/wireless/adm8211.c | |||
@@ -324,7 +324,7 @@ static void adm8211_interrupt_tci(struct ieee80211_hw *dev) | |||
324 | for (dirty_tx = priv->dirty_tx; priv->cur_tx - dirty_tx; dirty_tx++) { | 324 | for (dirty_tx = priv->dirty_tx; priv->cur_tx - dirty_tx; dirty_tx++) { |
325 | unsigned int entry = dirty_tx % priv->tx_ring_size; | 325 | unsigned int entry = dirty_tx % priv->tx_ring_size; |
326 | u32 status = le32_to_cpu(priv->tx_ring[entry].status); | 326 | u32 status = le32_to_cpu(priv->tx_ring[entry].status); |
327 | struct ieee80211_tx_status tx_status; | 327 | struct ieee80211_tx_info *txi; |
328 | struct adm8211_tx_ring_info *info; | 328 | struct adm8211_tx_ring_info *info; |
329 | struct sk_buff *skb; | 329 | struct sk_buff *skb; |
330 | 330 | ||
@@ -334,24 +334,23 @@ static void adm8211_interrupt_tci(struct ieee80211_hw *dev) | |||
334 | 334 | ||
335 | info = &priv->tx_buffers[entry]; | 335 | info = &priv->tx_buffers[entry]; |
336 | skb = info->skb; | 336 | skb = info->skb; |
337 | txi = IEEE80211_SKB_CB(skb); | ||
337 | 338 | ||
338 | /* TODO: check TDES0_STATUS_TUF and TDES0_STATUS_TRO */ | 339 | /* TODO: check TDES0_STATUS_TUF and TDES0_STATUS_TRO */ |
339 | 340 | ||
340 | pci_unmap_single(priv->pdev, info->mapping, | 341 | pci_unmap_single(priv->pdev, info->mapping, |
341 | info->skb->len, PCI_DMA_TODEVICE); | 342 | info->skb->len, PCI_DMA_TODEVICE); |
342 | 343 | ||
343 | memset(&tx_status, 0, sizeof(tx_status)); | 344 | memset(&txi->status, 0, sizeof(txi->status)); |
344 | skb_pull(skb, sizeof(struct adm8211_tx_hdr)); | 345 | skb_pull(skb, sizeof(struct adm8211_tx_hdr)); |
345 | memcpy(skb_push(skb, info->hdrlen), skb->cb, info->hdrlen); | 346 | memcpy(skb_push(skb, info->hdrlen), skb->cb, info->hdrlen); |
346 | memcpy(&tx_status.control, &info->tx_control, | 347 | if (!(txi->flags & IEEE80211_TX_CTL_NO_ACK)) { |
347 | sizeof(tx_status.control)); | ||
348 | if (!(tx_status.control.flags & IEEE80211_TXCTL_NO_ACK)) { | ||
349 | if (status & TDES0_STATUS_ES) | 348 | if (status & TDES0_STATUS_ES) |
350 | tx_status.excessive_retries = 1; | 349 | txi->status.excessive_retries = 1; |
351 | else | 350 | else |
352 | tx_status.flags |= IEEE80211_TX_STATUS_ACK; | 351 | txi->flags |= IEEE80211_TX_STAT_ACK; |
353 | } | 352 | } |
354 | ieee80211_tx_status_irqsafe(dev, skb, &tx_status); | 353 | ieee80211_tx_status_irqsafe(dev, skb); |
355 | 354 | ||
356 | info->skb = NULL; | 355 | info->skb = NULL; |
357 | } | 356 | } |
@@ -1638,7 +1637,6 @@ static void adm8211_calc_durations(int *dur, int *plcp, size_t payload_len, int | |||
1638 | /* Transmit skb w/adm8211_tx_hdr (802.11 header created by hardware) */ | 1637 | /* Transmit skb w/adm8211_tx_hdr (802.11 header created by hardware) */ |
1639 | static void adm8211_tx_raw(struct ieee80211_hw *dev, struct sk_buff *skb, | 1638 | static void adm8211_tx_raw(struct ieee80211_hw *dev, struct sk_buff *skb, |
1640 | u16 plcp_signal, | 1639 | u16 plcp_signal, |
1641 | struct ieee80211_tx_control *control, | ||
1642 | size_t hdrlen) | 1640 | size_t hdrlen) |
1643 | { | 1641 | { |
1644 | struct adm8211_priv *priv = dev->priv; | 1642 | struct adm8211_priv *priv = dev->priv; |
@@ -1664,7 +1662,6 @@ static void adm8211_tx_raw(struct ieee80211_hw *dev, struct sk_buff *skb, | |||
1664 | 1662 | ||
1665 | priv->tx_buffers[entry].skb = skb; | 1663 | priv->tx_buffers[entry].skb = skb; |
1666 | priv->tx_buffers[entry].mapping = mapping; | 1664 | priv->tx_buffers[entry].mapping = mapping; |
1667 | memcpy(&priv->tx_buffers[entry].tx_control, control, sizeof(*control)); | ||
1668 | priv->tx_buffers[entry].hdrlen = hdrlen; | 1665 | priv->tx_buffers[entry].hdrlen = hdrlen; |
1669 | priv->tx_ring[entry].buffer1 = cpu_to_le32(mapping); | 1666 | priv->tx_ring[entry].buffer1 = cpu_to_le32(mapping); |
1670 | 1667 | ||
@@ -1685,18 +1682,18 @@ static void adm8211_tx_raw(struct ieee80211_hw *dev, struct sk_buff *skb, | |||
1685 | } | 1682 | } |
1686 | 1683 | ||
1687 | /* Put adm8211_tx_hdr on skb and transmit */ | 1684 | /* Put adm8211_tx_hdr on skb and transmit */ |
1688 | static int adm8211_tx(struct ieee80211_hw *dev, struct sk_buff *skb, | 1685 | static int adm8211_tx(struct ieee80211_hw *dev, struct sk_buff *skb) |
1689 | struct ieee80211_tx_control *control) | ||
1690 | { | 1686 | { |
1691 | struct adm8211_tx_hdr *txhdr; | 1687 | struct adm8211_tx_hdr *txhdr; |
1692 | u16 fc; | 1688 | u16 fc; |
1693 | size_t payload_len, hdrlen; | 1689 | size_t payload_len, hdrlen; |
1694 | int plcp, dur, len, plcp_signal, short_preamble; | 1690 | int plcp, dur, len, plcp_signal, short_preamble; |
1695 | struct ieee80211_hdr *hdr; | 1691 | struct ieee80211_hdr *hdr; |
1692 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
1693 | struct ieee80211_rate *txrate = ieee80211_get_tx_rate(dev, info); | ||
1696 | 1694 | ||
1697 | short_preamble = !!(control->tx_rate->flags & | 1695 | short_preamble = !!(txrate->flags & IEEE80211_TX_CTL_SHORT_PREAMBLE); |
1698 | IEEE80211_TXCTL_SHORT_PREAMBLE); | 1696 | plcp_signal = txrate->bitrate; |
1699 | plcp_signal = control->tx_rate->bitrate; | ||
1700 | 1697 | ||
1701 | hdr = (struct ieee80211_hdr *)skb->data; | 1698 | hdr = (struct ieee80211_hdr *)skb->data; |
1702 | fc = le16_to_cpu(hdr->frame_control) & ~IEEE80211_FCTL_PROTECTED; | 1699 | fc = le16_to_cpu(hdr->frame_control) & ~IEEE80211_FCTL_PROTECTED; |
@@ -1730,15 +1727,15 @@ static int adm8211_tx(struct ieee80211_hw *dev, struct sk_buff *skb, | |||
1730 | if (short_preamble) | 1727 | if (short_preamble) |
1731 | txhdr->header_control |= cpu_to_le16(ADM8211_TXHDRCTL_SHORT_PREAMBLE); | 1728 | txhdr->header_control |= cpu_to_le16(ADM8211_TXHDRCTL_SHORT_PREAMBLE); |
1732 | 1729 | ||
1733 | if (control->flags & IEEE80211_TXCTL_USE_RTS_CTS) | 1730 | if (info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) |
1734 | txhdr->header_control |= cpu_to_le16(ADM8211_TXHDRCTL_ENABLE_RTS); | 1731 | txhdr->header_control |= cpu_to_le16(ADM8211_TXHDRCTL_ENABLE_RTS); |
1735 | 1732 | ||
1736 | if (fc & IEEE80211_FCTL_PROTECTED) | 1733 | if (fc & IEEE80211_FCTL_PROTECTED) |
1737 | txhdr->header_control |= cpu_to_le16(ADM8211_TXHDRCTL_ENABLE_WEP_ENGINE); | 1734 | txhdr->header_control |= cpu_to_le16(ADM8211_TXHDRCTL_ENABLE_WEP_ENGINE); |
1738 | 1735 | ||
1739 | txhdr->retry_limit = control->retry_limit; | 1736 | txhdr->retry_limit = info->control.retry_limit; |
1740 | 1737 | ||
1741 | adm8211_tx_raw(dev, skb, plcp_signal, control, hdrlen); | 1738 | adm8211_tx_raw(dev, skb, plcp_signal, hdrlen); |
1742 | 1739 | ||
1743 | return NETDEV_TX_OK; | 1740 | return NETDEV_TX_OK; |
1744 | } | 1741 | } |
@@ -2015,7 +2012,7 @@ static int adm8211_resume(struct pci_dev *pdev) | |||
2015 | 2012 | ||
2016 | if (priv->mode != IEEE80211_IF_TYPE_INVALID) { | 2013 | if (priv->mode != IEEE80211_IF_TYPE_INVALID) { |
2017 | adm8211_start(dev); | 2014 | adm8211_start(dev); |
2018 | ieee80211_start_queues(dev); | 2015 | ieee80211_wake_queues(dev); |
2019 | } | 2016 | } |
2020 | 2017 | ||
2021 | return 0; | 2018 | return 0; |
diff --git a/drivers/net/wireless/adm8211.h b/drivers/net/wireless/adm8211.h index 8d7c564b3b04..9b190ee26e90 100644 --- a/drivers/net/wireless/adm8211.h +++ b/drivers/net/wireless/adm8211.h | |||
@@ -443,7 +443,6 @@ struct adm8211_rx_ring_info { | |||
443 | struct adm8211_tx_ring_info { | 443 | struct adm8211_tx_ring_info { |
444 | struct sk_buff *skb; | 444 | struct sk_buff *skb; |
445 | dma_addr_t mapping; | 445 | dma_addr_t mapping; |
446 | struct ieee80211_tx_control tx_control; | ||
447 | size_t hdrlen; | 446 | size_t hdrlen; |
448 | }; | 447 | }; |
449 | 448 | ||
diff --git a/drivers/net/wireless/ath5k/base.c b/drivers/net/wireless/ath5k/base.c index c76ada178781..85045afc1ba7 100644 --- a/drivers/net/wireless/ath5k/base.c +++ b/drivers/net/wireless/ath5k/base.c | |||
@@ -167,8 +167,7 @@ static struct pci_driver ath5k_pci_driver = { | |||
167 | /* | 167 | /* |
168 | * Prototypes - MAC 802.11 stack related functions | 168 | * Prototypes - MAC 802.11 stack related functions |
169 | */ | 169 | */ |
170 | static int ath5k_tx(struct ieee80211_hw *hw, struct sk_buff *skb, | 170 | static int ath5k_tx(struct ieee80211_hw *hw, struct sk_buff *skb); |
171 | struct ieee80211_tx_control *ctl); | ||
172 | static int ath5k_reset(struct ieee80211_hw *hw); | 171 | static int ath5k_reset(struct ieee80211_hw *hw); |
173 | static int ath5k_start(struct ieee80211_hw *hw); | 172 | static int ath5k_start(struct ieee80211_hw *hw); |
174 | static void ath5k_stop(struct ieee80211_hw *hw); | 173 | static void ath5k_stop(struct ieee80211_hw *hw); |
@@ -196,8 +195,7 @@ static int ath5k_get_tx_stats(struct ieee80211_hw *hw, | |||
196 | static u64 ath5k_get_tsf(struct ieee80211_hw *hw); | 195 | static u64 ath5k_get_tsf(struct ieee80211_hw *hw); |
197 | static void ath5k_reset_tsf(struct ieee80211_hw *hw); | 196 | static void ath5k_reset_tsf(struct ieee80211_hw *hw); |
198 | static int ath5k_beacon_update(struct ieee80211_hw *hw, | 197 | static int ath5k_beacon_update(struct ieee80211_hw *hw, |
199 | struct sk_buff *skb, | 198 | struct sk_buff *skb); |
200 | struct ieee80211_tx_control *ctl); | ||
201 | 199 | ||
202 | static struct ieee80211_ops ath5k_hw_ops = { | 200 | static struct ieee80211_ops ath5k_hw_ops = { |
203 | .tx = ath5k_tx, | 201 | .tx = ath5k_tx, |
@@ -251,9 +249,7 @@ static void ath5k_desc_free(struct ath5k_softc *sc, | |||
251 | static int ath5k_rxbuf_setup(struct ath5k_softc *sc, | 249 | static int ath5k_rxbuf_setup(struct ath5k_softc *sc, |
252 | struct ath5k_buf *bf); | 250 | struct ath5k_buf *bf); |
253 | static int ath5k_txbuf_setup(struct ath5k_softc *sc, | 251 | static int ath5k_txbuf_setup(struct ath5k_softc *sc, |
254 | struct ath5k_buf *bf, | 252 | struct ath5k_buf *bf); |
255 | struct ieee80211_tx_control *ctl); | ||
256 | |||
257 | static inline void ath5k_txbuf_free(struct ath5k_softc *sc, | 253 | static inline void ath5k_txbuf_free(struct ath5k_softc *sc, |
258 | struct ath5k_buf *bf) | 254 | struct ath5k_buf *bf) |
259 | { | 255 | { |
@@ -289,8 +285,7 @@ static void ath5k_tx_processq(struct ath5k_softc *sc, | |||
289 | static void ath5k_tasklet_tx(unsigned long data); | 285 | static void ath5k_tasklet_tx(unsigned long data); |
290 | /* Beacon handling */ | 286 | /* Beacon handling */ |
291 | static int ath5k_beacon_setup(struct ath5k_softc *sc, | 287 | static int ath5k_beacon_setup(struct ath5k_softc *sc, |
292 | struct ath5k_buf *bf, | 288 | struct ath5k_buf *bf); |
293 | struct ieee80211_tx_control *ctl); | ||
294 | static void ath5k_beacon_send(struct ath5k_softc *sc); | 289 | static void ath5k_beacon_send(struct ath5k_softc *sc); |
295 | static void ath5k_beacon_config(struct ath5k_softc *sc); | 290 | static void ath5k_beacon_config(struct ath5k_softc *sc); |
296 | static void ath5k_beacon_update_timers(struct ath5k_softc *sc, u64 bc_tsf); | 291 | static void ath5k_beacon_update_timers(struct ath5k_softc *sc, u64 bc_tsf); |
@@ -1295,36 +1290,36 @@ ath5k_rxbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf) | |||
1295 | } | 1290 | } |
1296 | 1291 | ||
1297 | static int | 1292 | static int |
1298 | ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf, | 1293 | ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf) |
1299 | struct ieee80211_tx_control *ctl) | ||
1300 | { | 1294 | { |
1301 | struct ath5k_hw *ah = sc->ah; | 1295 | struct ath5k_hw *ah = sc->ah; |
1302 | struct ath5k_txq *txq = sc->txq; | 1296 | struct ath5k_txq *txq = sc->txq; |
1303 | struct ath5k_desc *ds = bf->desc; | 1297 | struct ath5k_desc *ds = bf->desc; |
1304 | struct sk_buff *skb = bf->skb; | 1298 | struct sk_buff *skb = bf->skb; |
1299 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
1305 | unsigned int pktlen, flags, keyidx = AR5K_TXKEYIX_INVALID; | 1300 | unsigned int pktlen, flags, keyidx = AR5K_TXKEYIX_INVALID; |
1306 | int ret; | 1301 | int ret; |
1307 | 1302 | ||
1308 | flags = AR5K_TXDESC_INTREQ | AR5K_TXDESC_CLRDMASK; | 1303 | flags = AR5K_TXDESC_INTREQ | AR5K_TXDESC_CLRDMASK; |
1309 | bf->ctl = *ctl; | 1304 | |
1310 | /* XXX endianness */ | 1305 | /* XXX endianness */ |
1311 | bf->skbaddr = pci_map_single(sc->pdev, skb->data, skb->len, | 1306 | bf->skbaddr = pci_map_single(sc->pdev, skb->data, skb->len, |
1312 | PCI_DMA_TODEVICE); | 1307 | PCI_DMA_TODEVICE); |
1313 | 1308 | ||
1314 | if (ctl->flags & IEEE80211_TXCTL_NO_ACK) | 1309 | if (info->flags & IEEE80211_TX_CTL_NO_ACK) |
1315 | flags |= AR5K_TXDESC_NOACK; | 1310 | flags |= AR5K_TXDESC_NOACK; |
1316 | 1311 | ||
1317 | pktlen = skb->len; | 1312 | pktlen = skb->len; |
1318 | 1313 | ||
1319 | if (!(ctl->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT)) { | 1314 | if (!(info->flags & IEEE80211_TX_CTL_DO_NOT_ENCRYPT)) { |
1320 | keyidx = ctl->hw_key->hw_key_idx; | 1315 | keyidx = info->control.hw_key->hw_key_idx; |
1321 | pktlen += ctl->icv_len; | 1316 | pktlen += info->control.icv_len; |
1322 | } | 1317 | } |
1323 | |||
1324 | ret = ah->ah_setup_tx_desc(ah, ds, pktlen, | 1318 | ret = ah->ah_setup_tx_desc(ah, ds, pktlen, |
1325 | ieee80211_get_hdrlen_from_skb(skb), AR5K_PKT_TYPE_NORMAL, | 1319 | ieee80211_get_hdrlen_from_skb(skb), AR5K_PKT_TYPE_NORMAL, |
1326 | (sc->power_level * 2), ctl->tx_rate->hw_value, | 1320 | (sc->power_level * 2), |
1327 | ctl->retry_limit, keyidx, 0, flags, 0, 0); | 1321 | ieee80211_get_tx_rate(sc->hw, info)->hw_value, |
1322 | info->control.retry_limit, keyidx, 0, flags, 0, 0); | ||
1328 | if (ret) | 1323 | if (ret) |
1329 | goto err_unmap; | 1324 | goto err_unmap; |
1330 | 1325 | ||
@@ -1599,7 +1594,7 @@ ath5k_txq_cleanup(struct ath5k_softc *sc) | |||
1599 | sc->txqs[i].link); | 1594 | sc->txqs[i].link); |
1600 | } | 1595 | } |
1601 | } | 1596 | } |
1602 | ieee80211_start_queues(sc->hw); /* XXX move to callers */ | 1597 | ieee80211_wake_queues(sc->hw); /* XXX move to callers */ |
1603 | 1598 | ||
1604 | for (i = 0; i < ARRAY_SIZE(sc->txqs); i++) | 1599 | for (i = 0; i < ARRAY_SIZE(sc->txqs); i++) |
1605 | if (sc->txqs[i].setup) | 1600 | if (sc->txqs[i].setup) |
@@ -1926,11 +1921,11 @@ next: | |||
1926 | static void | 1921 | static void |
1927 | ath5k_tx_processq(struct ath5k_softc *sc, struct ath5k_txq *txq) | 1922 | ath5k_tx_processq(struct ath5k_softc *sc, struct ath5k_txq *txq) |
1928 | { | 1923 | { |
1929 | struct ieee80211_tx_status txs = {}; | ||
1930 | struct ath5k_tx_status ts = {}; | 1924 | struct ath5k_tx_status ts = {}; |
1931 | struct ath5k_buf *bf, *bf0; | 1925 | struct ath5k_buf *bf, *bf0; |
1932 | struct ath5k_desc *ds; | 1926 | struct ath5k_desc *ds; |
1933 | struct sk_buff *skb; | 1927 | struct sk_buff *skb; |
1928 | struct ieee80211_tx_info *info; | ||
1934 | int ret; | 1929 | int ret; |
1935 | 1930 | ||
1936 | spin_lock(&txq->lock); | 1931 | spin_lock(&txq->lock); |
@@ -1950,24 +1945,25 @@ ath5k_tx_processq(struct ath5k_softc *sc, struct ath5k_txq *txq) | |||
1950 | } | 1945 | } |
1951 | 1946 | ||
1952 | skb = bf->skb; | 1947 | skb = bf->skb; |
1948 | info = IEEE80211_SKB_CB(skb); | ||
1953 | bf->skb = NULL; | 1949 | bf->skb = NULL; |
1950 | |||
1954 | pci_unmap_single(sc->pdev, bf->skbaddr, skb->len, | 1951 | pci_unmap_single(sc->pdev, bf->skbaddr, skb->len, |
1955 | PCI_DMA_TODEVICE); | 1952 | PCI_DMA_TODEVICE); |
1956 | 1953 | ||
1957 | txs.control = bf->ctl; | 1954 | info->status.retry_count = ts.ts_shortretry + ts.ts_longretry / 6; |
1958 | txs.retry_count = ts.ts_shortretry + ts.ts_longretry / 6; | ||
1959 | if (unlikely(ts.ts_status)) { | 1955 | if (unlikely(ts.ts_status)) { |
1960 | sc->ll_stats.dot11ACKFailureCount++; | 1956 | sc->ll_stats.dot11ACKFailureCount++; |
1961 | if (ts.ts_status & AR5K_TXERR_XRETRY) | 1957 | if (ts.ts_status & AR5K_TXERR_XRETRY) |
1962 | txs.excessive_retries = 1; | 1958 | info->status.excessive_retries = 1; |
1963 | else if (ts.ts_status & AR5K_TXERR_FILT) | 1959 | else if (ts.ts_status & AR5K_TXERR_FILT) |
1964 | txs.flags |= IEEE80211_TX_STATUS_TX_FILTERED; | 1960 | info->flags |= IEEE80211_TX_STAT_TX_FILTERED; |
1965 | } else { | 1961 | } else { |
1966 | txs.flags |= IEEE80211_TX_STATUS_ACK; | 1962 | info->flags |= IEEE80211_TX_STAT_ACK; |
1967 | txs.ack_signal = ts.ts_rssi; | 1963 | info->status.ack_signal = ts.ts_rssi; |
1968 | } | 1964 | } |
1969 | 1965 | ||
1970 | ieee80211_tx_status(sc->hw, skb, &txs); | 1966 | ieee80211_tx_status(sc->hw, skb); |
1971 | sc->tx_stats[txq->qnum].count++; | 1967 | sc->tx_stats[txq->qnum].count++; |
1972 | 1968 | ||
1973 | spin_lock(&sc->txbuflock); | 1969 | spin_lock(&sc->txbuflock); |
@@ -2004,10 +2000,10 @@ ath5k_tasklet_tx(unsigned long data) | |||
2004 | * Setup the beacon frame for transmit. | 2000 | * Setup the beacon frame for transmit. |
2005 | */ | 2001 | */ |
2006 | static int | 2002 | static int |
2007 | ath5k_beacon_setup(struct ath5k_softc *sc, struct ath5k_buf *bf, | 2003 | ath5k_beacon_setup(struct ath5k_softc *sc, struct ath5k_buf *bf) |
2008 | struct ieee80211_tx_control *ctl) | ||
2009 | { | 2004 | { |
2010 | struct sk_buff *skb = bf->skb; | 2005 | struct sk_buff *skb = bf->skb; |
2006 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
2011 | struct ath5k_hw *ah = sc->ah; | 2007 | struct ath5k_hw *ah = sc->ah; |
2012 | struct ath5k_desc *ds; | 2008 | struct ath5k_desc *ds; |
2013 | int ret, antenna = 0; | 2009 | int ret, antenna = 0; |
@@ -2046,7 +2042,8 @@ ath5k_beacon_setup(struct ath5k_softc *sc, struct ath5k_buf *bf, | |||
2046 | ret = ah->ah_setup_tx_desc(ah, ds, skb->len, | 2042 | ret = ah->ah_setup_tx_desc(ah, ds, skb->len, |
2047 | ieee80211_get_hdrlen_from_skb(skb), | 2043 | ieee80211_get_hdrlen_from_skb(skb), |
2048 | AR5K_PKT_TYPE_BEACON, (sc->power_level * 2), | 2044 | AR5K_PKT_TYPE_BEACON, (sc->power_level * 2), |
2049 | ctl->tx_rate->hw_value, 1, AR5K_TXKEYIX_INVALID, | 2045 | ieee80211_get_tx_rate(sc->hw, info)->hw_value, |
2046 | 1, AR5K_TXKEYIX_INVALID, | ||
2050 | antenna, flags, 0, 0); | 2047 | antenna, flags, 0, 0); |
2051 | if (ret) | 2048 | if (ret) |
2052 | goto err_unmap; | 2049 | goto err_unmap; |
@@ -2624,11 +2621,11 @@ ath5k_led_event(struct ath5k_softc *sc, int event) | |||
2624 | \********************/ | 2621 | \********************/ |
2625 | 2622 | ||
2626 | static int | 2623 | static int |
2627 | ath5k_tx(struct ieee80211_hw *hw, struct sk_buff *skb, | 2624 | ath5k_tx(struct ieee80211_hw *hw, struct sk_buff *skb) |
2628 | struct ieee80211_tx_control *ctl) | ||
2629 | { | 2625 | { |
2630 | struct ath5k_softc *sc = hw->priv; | 2626 | struct ath5k_softc *sc = hw->priv; |
2631 | struct ath5k_buf *bf; | 2627 | struct ath5k_buf *bf; |
2628 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
2632 | unsigned long flags; | 2629 | unsigned long flags; |
2633 | int hdrlen; | 2630 | int hdrlen; |
2634 | int pad; | 2631 | int pad; |
@@ -2654,13 +2651,13 @@ ath5k_tx(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
2654 | memmove(skb->data, skb->data+pad, hdrlen); | 2651 | memmove(skb->data, skb->data+pad, hdrlen); |
2655 | } | 2652 | } |
2656 | 2653 | ||
2657 | sc->led_txrate = ctl->tx_rate->hw_value; | 2654 | sc->led_txrate = ieee80211_get_tx_rate(hw, info)->hw_value; |
2658 | 2655 | ||
2659 | spin_lock_irqsave(&sc->txbuflock, flags); | 2656 | spin_lock_irqsave(&sc->txbuflock, flags); |
2660 | if (list_empty(&sc->txbuf)) { | 2657 | if (list_empty(&sc->txbuf)) { |
2661 | ATH5K_ERR(sc, "no further txbuf available, dropping packet\n"); | 2658 | ATH5K_ERR(sc, "no further txbuf available, dropping packet\n"); |
2662 | spin_unlock_irqrestore(&sc->txbuflock, flags); | 2659 | spin_unlock_irqrestore(&sc->txbuflock, flags); |
2663 | ieee80211_stop_queue(hw, ctl->queue); | 2660 | ieee80211_stop_queue(hw, skb_get_queue_mapping(skb)); |
2664 | return -1; | 2661 | return -1; |
2665 | } | 2662 | } |
2666 | bf = list_first_entry(&sc->txbuf, struct ath5k_buf, list); | 2663 | bf = list_first_entry(&sc->txbuf, struct ath5k_buf, list); |
@@ -2672,7 +2669,7 @@ ath5k_tx(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
2672 | 2669 | ||
2673 | bf->skb = skb; | 2670 | bf->skb = skb; |
2674 | 2671 | ||
2675 | if (ath5k_txbuf_setup(sc, bf, ctl)) { | 2672 | if (ath5k_txbuf_setup(sc, bf)) { |
2676 | bf->skb = NULL; | 2673 | bf->skb = NULL; |
2677 | spin_lock_irqsave(&sc->txbuflock, flags); | 2674 | spin_lock_irqsave(&sc->txbuflock, flags); |
2678 | list_add_tail(&bf->list, &sc->txbuf); | 2675 | list_add_tail(&bf->list, &sc->txbuf); |
@@ -3050,8 +3047,7 @@ ath5k_reset_tsf(struct ieee80211_hw *hw) | |||
3050 | } | 3047 | } |
3051 | 3048 | ||
3052 | static int | 3049 | static int |
3053 | ath5k_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb, | 3050 | ath5k_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb) |
3054 | struct ieee80211_tx_control *ctl) | ||
3055 | { | 3051 | { |
3056 | struct ath5k_softc *sc = hw->priv; | 3052 | struct ath5k_softc *sc = hw->priv; |
3057 | int ret; | 3053 | int ret; |
@@ -3067,7 +3063,7 @@ ath5k_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
3067 | 3063 | ||
3068 | ath5k_txbuf_free(sc, sc->bbuf); | 3064 | ath5k_txbuf_free(sc, sc->bbuf); |
3069 | sc->bbuf->skb = skb; | 3065 | sc->bbuf->skb = skb; |
3070 | ret = ath5k_beacon_setup(sc, sc->bbuf, ctl); | 3066 | ret = ath5k_beacon_setup(sc, sc->bbuf); |
3071 | if (ret) | 3067 | if (ret) |
3072 | sc->bbuf->skb = NULL; | 3068 | sc->bbuf->skb = NULL; |
3073 | else | 3069 | else |
diff --git a/drivers/net/wireless/ath5k/base.h b/drivers/net/wireless/ath5k/base.h index ecb17495488c..bb4b26d523ab 100644 --- a/drivers/net/wireless/ath5k/base.h +++ b/drivers/net/wireless/ath5k/base.h | |||
@@ -60,7 +60,6 @@ struct ath5k_buf { | |||
60 | dma_addr_t daddr; /* physical addr of desc */ | 60 | dma_addr_t daddr; /* physical addr of desc */ |
61 | struct sk_buff *skb; /* skbuff for buf */ | 61 | struct sk_buff *skb; /* skbuff for buf */ |
62 | dma_addr_t skbaddr;/* physical addr of skb data */ | 62 | dma_addr_t skbaddr;/* physical addr of skb data */ |
63 | struct ieee80211_tx_control ctl; | ||
64 | }; | 63 | }; |
65 | 64 | ||
66 | /* | 65 | /* |
diff --git a/drivers/net/wireless/b43/b43.h b/drivers/net/wireless/b43/b43.h index 0c2bc061e8f3..e919189919bb 100644 --- a/drivers/net/wireless/b43/b43.h +++ b/drivers/net/wireless/b43/b43.h | |||
@@ -422,6 +422,26 @@ enum { | |||
422 | B43_IRQ_RFKILL | \ | 422 | B43_IRQ_RFKILL | \ |
423 | B43_IRQ_TX_OK) | 423 | B43_IRQ_TX_OK) |
424 | 424 | ||
425 | /* The firmware register to fetch the debug-IRQ reason from. */ | ||
426 | #define B43_DEBUGIRQ_REASON_REG 63 | ||
427 | /* Debug-IRQ reasons. */ | ||
428 | #define B43_DEBUGIRQ_PANIC 0 /* The firmware panic'ed */ | ||
429 | #define B43_DEBUGIRQ_DUMP_SHM 1 /* Dump shared SHM */ | ||
430 | #define B43_DEBUGIRQ_DUMP_REGS 2 /* Dump the microcode registers */ | ||
431 | #define B43_DEBUGIRQ_MARKER 3 /* A "marker" was thrown by the firmware. */ | ||
432 | #define B43_DEBUGIRQ_ACK 0xFFFF /* The host writes that to ACK the IRQ */ | ||
433 | |||
434 | /* The firmware register that contains the "marker" line. */ | ||
435 | #define B43_MARKER_ID_REG 2 | ||
436 | #define B43_MARKER_LINE_REG 3 | ||
437 | |||
438 | /* The firmware register to fetch the panic reason from. */ | ||
439 | #define B43_FWPANIC_REASON_REG 3 | ||
440 | /* Firmware panic reason codes */ | ||
441 | #define B43_FWPANIC_DIE 0 /* Firmware died. Don't auto-restart it. */ | ||
442 | #define B43_FWPANIC_RESTART 1 /* Firmware died. Schedule a controller reset. */ | ||
443 | |||
444 | |||
425 | /* Device specific rate values. | 445 | /* Device specific rate values. |
426 | * The actual values defined here are (rate_in_mbps * 2). | 446 | * The actual values defined here are (rate_in_mbps * 2). |
427 | * Some code depends on this. Don't change it. */ | 447 | * Some code depends on this. Don't change it. */ |
@@ -733,7 +753,6 @@ struct b43_wl { | |||
733 | /* The beacon we are currently using (AP or IBSS mode). | 753 | /* The beacon we are currently using (AP or IBSS mode). |
734 | * This beacon stuff is protected by the irq_lock. */ | 754 | * This beacon stuff is protected by the irq_lock. */ |
735 | struct sk_buff *current_beacon; | 755 | struct sk_buff *current_beacon; |
736 | struct ieee80211_tx_control beacon_txctl; | ||
737 | bool beacon0_uploaded; | 756 | bool beacon0_uploaded; |
738 | bool beacon1_uploaded; | 757 | bool beacon1_uploaded; |
739 | struct work_struct beacon_update_trigger; | 758 | struct work_struct beacon_update_trigger; |
@@ -766,6 +785,13 @@ struct b43_firmware { | |||
766 | u16 rev; | 785 | u16 rev; |
767 | /* Firmware patchlevel */ | 786 | /* Firmware patchlevel */ |
768 | u16 patch; | 787 | u16 patch; |
788 | |||
789 | /* Set to true, if we are using an opensource firmware. */ | ||
790 | bool opensource; | ||
791 | /* Set to true, if the core needs a PCM firmware, but | ||
792 | * we failed to load one. This is always false for | ||
793 | * core rev > 10, as these don't need PCM firmware. */ | ||
794 | bool pcm_request_failed; | ||
769 | }; | 795 | }; |
770 | 796 | ||
771 | /* Device (802.11 core) initialization status. */ | 797 | /* Device (802.11 core) initialization status. */ |
diff --git a/drivers/net/wireless/b43/dma.c b/drivers/net/wireless/b43/dma.c index f50e2014ffbe..b4eadd908bea 100644 --- a/drivers/net/wireless/b43/dma.c +++ b/drivers/net/wireless/b43/dma.c | |||
@@ -1131,10 +1131,10 @@ struct b43_dmaring *parse_cookie(struct b43_wldev *dev, u16 cookie, int *slot) | |||
1131 | } | 1131 | } |
1132 | 1132 | ||
1133 | static int dma_tx_fragment(struct b43_dmaring *ring, | 1133 | static int dma_tx_fragment(struct b43_dmaring *ring, |
1134 | struct sk_buff *skb, | 1134 | struct sk_buff *skb) |
1135 | struct ieee80211_tx_control *ctl) | ||
1136 | { | 1135 | { |
1137 | const struct b43_dma_ops *ops = ring->ops; | 1136 | const struct b43_dma_ops *ops = ring->ops; |
1137 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
1138 | u8 *header; | 1138 | u8 *header; |
1139 | int slot, old_top_slot, old_used_slots; | 1139 | int slot, old_top_slot, old_used_slots; |
1140 | int err; | 1140 | int err; |
@@ -1158,7 +1158,7 @@ static int dma_tx_fragment(struct b43_dmaring *ring, | |||
1158 | header = &(ring->txhdr_cache[slot * hdrsize]); | 1158 | header = &(ring->txhdr_cache[slot * hdrsize]); |
1159 | cookie = generate_cookie(ring, slot); | 1159 | cookie = generate_cookie(ring, slot); |
1160 | err = b43_generate_txhdr(ring->dev, header, | 1160 | err = b43_generate_txhdr(ring->dev, header, |
1161 | skb->data, skb->len, ctl, cookie); | 1161 | skb->data, skb->len, info, cookie); |
1162 | if (unlikely(err)) { | 1162 | if (unlikely(err)) { |
1163 | ring->current_slot = old_top_slot; | 1163 | ring->current_slot = old_top_slot; |
1164 | ring->used_slots = old_used_slots; | 1164 | ring->used_slots = old_used_slots; |
@@ -1180,7 +1180,6 @@ static int dma_tx_fragment(struct b43_dmaring *ring, | |||
1180 | desc = ops->idx2desc(ring, slot, &meta); | 1180 | desc = ops->idx2desc(ring, slot, &meta); |
1181 | memset(meta, 0, sizeof(*meta)); | 1181 | memset(meta, 0, sizeof(*meta)); |
1182 | 1182 | ||
1183 | memcpy(&meta->txstat.control, ctl, sizeof(*ctl)); | ||
1184 | meta->skb = skb; | 1183 | meta->skb = skb; |
1185 | meta->is_last_fragment = 1; | 1184 | meta->is_last_fragment = 1; |
1186 | 1185 | ||
@@ -1210,7 +1209,7 @@ static int dma_tx_fragment(struct b43_dmaring *ring, | |||
1210 | 1209 | ||
1211 | ops->fill_descriptor(ring, desc, meta->dmaaddr, skb->len, 0, 1, 1); | 1210 | ops->fill_descriptor(ring, desc, meta->dmaaddr, skb->len, 0, 1, 1); |
1212 | 1211 | ||
1213 | if (ctl->flags & IEEE80211_TXCTL_SEND_AFTER_DTIM) { | 1212 | if (info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) { |
1214 | /* Tell the firmware about the cookie of the last | 1213 | /* Tell the firmware about the cookie of the last |
1215 | * mcast frame, so it can clear the more-data bit in it. */ | 1214 | * mcast frame, so it can clear the more-data bit in it. */ |
1216 | b43_shm_write16(ring->dev, B43_SHM_SHARED, | 1215 | b43_shm_write16(ring->dev, B43_SHM_SHARED, |
@@ -1281,16 +1280,16 @@ static struct b43_dmaring * select_ring_by_priority(struct b43_wldev *dev, | |||
1281 | return ring; | 1280 | return ring; |
1282 | } | 1281 | } |
1283 | 1282 | ||
1284 | int b43_dma_tx(struct b43_wldev *dev, | 1283 | int b43_dma_tx(struct b43_wldev *dev, struct sk_buff *skb) |
1285 | struct sk_buff *skb, struct ieee80211_tx_control *ctl) | ||
1286 | { | 1284 | { |
1287 | struct b43_dmaring *ring; | 1285 | struct b43_dmaring *ring; |
1288 | struct ieee80211_hdr *hdr; | 1286 | struct ieee80211_hdr *hdr; |
1289 | int err = 0; | 1287 | int err = 0; |
1290 | unsigned long flags; | 1288 | unsigned long flags; |
1289 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
1291 | 1290 | ||
1292 | hdr = (struct ieee80211_hdr *)skb->data; | 1291 | hdr = (struct ieee80211_hdr *)skb->data; |
1293 | if (ctl->flags & IEEE80211_TXCTL_SEND_AFTER_DTIM) { | 1292 | if (info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) { |
1294 | /* The multicast ring will be sent after the DTIM */ | 1293 | /* The multicast ring will be sent after the DTIM */ |
1295 | ring = dev->dma.tx_ring_mcast; | 1294 | ring = dev->dma.tx_ring_mcast; |
1296 | /* Set the more-data bit. Ucode will clear it on | 1295 | /* Set the more-data bit. Ucode will clear it on |
@@ -1298,7 +1297,8 @@ int b43_dma_tx(struct b43_wldev *dev, | |||
1298 | hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREDATA); | 1297 | hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREDATA); |
1299 | } else { | 1298 | } else { |
1300 | /* Decide by priority where to put this frame. */ | 1299 | /* Decide by priority where to put this frame. */ |
1301 | ring = select_ring_by_priority(dev, ctl->queue); | 1300 | ring = select_ring_by_priority( |
1301 | dev, skb_get_queue_mapping(skb)); | ||
1302 | } | 1302 | } |
1303 | 1303 | ||
1304 | spin_lock_irqsave(&ring->lock, flags); | 1304 | spin_lock_irqsave(&ring->lock, flags); |
@@ -1316,9 +1316,9 @@ int b43_dma_tx(struct b43_wldev *dev, | |||
1316 | /* Assign the queue number to the ring (if not already done before) | 1316 | /* Assign the queue number to the ring (if not already done before) |
1317 | * so TX status handling can use it. The queue to ring mapping is | 1317 | * so TX status handling can use it. The queue to ring mapping is |
1318 | * static, so we don't need to store it per frame. */ | 1318 | * static, so we don't need to store it per frame. */ |
1319 | ring->queue_prio = ctl->queue; | 1319 | ring->queue_prio = skb_get_queue_mapping(skb); |
1320 | 1320 | ||
1321 | err = dma_tx_fragment(ring, skb, ctl); | 1321 | err = dma_tx_fragment(ring, skb); |
1322 | if (unlikely(err == -ENOKEY)) { | 1322 | if (unlikely(err == -ENOKEY)) { |
1323 | /* Drop this packet, as we don't have the encryption key | 1323 | /* Drop this packet, as we don't have the encryption key |
1324 | * anymore and must not transmit it unencrypted. */ | 1324 | * anymore and must not transmit it unencrypted. */ |
@@ -1334,7 +1334,7 @@ int b43_dma_tx(struct b43_wldev *dev, | |||
1334 | if ((free_slots(ring) < SLOTS_PER_PACKET) || | 1334 | if ((free_slots(ring) < SLOTS_PER_PACKET) || |
1335 | should_inject_overflow(ring)) { | 1335 | should_inject_overflow(ring)) { |
1336 | /* This TX ring is full. */ | 1336 | /* This TX ring is full. */ |
1337 | ieee80211_stop_queue(dev->wl->hw, ctl->queue); | 1337 | ieee80211_stop_queue(dev->wl->hw, skb_get_queue_mapping(skb)); |
1338 | ring->stopped = 1; | 1338 | ring->stopped = 1; |
1339 | if (b43_debug(dev, B43_DBG_DMAVERBOSE)) { | 1339 | if (b43_debug(dev, B43_DBG_DMAVERBOSE)) { |
1340 | b43dbg(dev->wl, "Stopped TX ring %d\n", ring->index); | 1340 | b43dbg(dev->wl, "Stopped TX ring %d\n", ring->index); |
@@ -1377,13 +1377,19 @@ void b43_dma_handle_txstatus(struct b43_wldev *dev, | |||
1377 | b43_txhdr_size(dev), 1); | 1377 | b43_txhdr_size(dev), 1); |
1378 | 1378 | ||
1379 | if (meta->is_last_fragment) { | 1379 | if (meta->is_last_fragment) { |
1380 | B43_WARN_ON(!meta->skb); | 1380 | struct ieee80211_tx_info *info; |
1381 | /* Call back to inform the ieee80211 subsystem about the | 1381 | |
1382 | * status of the transmission. | 1382 | BUG_ON(!meta->skb); |
1383 | * Some fields of txstat are already filled in dma_tx(). | 1383 | |
1384 | info = IEEE80211_SKB_CB(meta->skb); | ||
1385 | |||
1386 | memset(&info->status, 0, sizeof(info->status)); | ||
1387 | |||
1388 | /* | ||
1389 | * Call back to inform the ieee80211 subsystem about | ||
1390 | * the status of the transmission. | ||
1384 | */ | 1391 | */ |
1385 | frame_succeed = b43_fill_txstatus_report( | 1392 | frame_succeed = b43_fill_txstatus_report(info, status); |
1386 | &(meta->txstat), status); | ||
1387 | #ifdef CONFIG_B43_DEBUG | 1393 | #ifdef CONFIG_B43_DEBUG |
1388 | if (frame_succeed) | 1394 | if (frame_succeed) |
1389 | ring->nr_succeed_tx_packets++; | 1395 | ring->nr_succeed_tx_packets++; |
@@ -1391,8 +1397,8 @@ void b43_dma_handle_txstatus(struct b43_wldev *dev, | |||
1391 | ring->nr_failed_tx_packets++; | 1397 | ring->nr_failed_tx_packets++; |
1392 | ring->nr_total_packet_tries += status->frame_count; | 1398 | ring->nr_total_packet_tries += status->frame_count; |
1393 | #endif /* DEBUG */ | 1399 | #endif /* DEBUG */ |
1394 | ieee80211_tx_status_irqsafe(dev->wl->hw, meta->skb, | 1400 | ieee80211_tx_status_irqsafe(dev->wl->hw, meta->skb); |
1395 | &(meta->txstat)); | 1401 | |
1396 | /* skb is freed by ieee80211_tx_status_irqsafe() */ | 1402 | /* skb is freed by ieee80211_tx_status_irqsafe() */ |
1397 | meta->skb = NULL; | 1403 | meta->skb = NULL; |
1398 | } else { | 1404 | } else { |
diff --git a/drivers/net/wireless/b43/dma.h b/drivers/net/wireless/b43/dma.h index 20acf885dba5..d1eb5c0848a5 100644 --- a/drivers/net/wireless/b43/dma.h +++ b/drivers/net/wireless/b43/dma.h | |||
@@ -181,7 +181,6 @@ struct b43_dmadesc_meta { | |||
181 | dma_addr_t dmaaddr; | 181 | dma_addr_t dmaaddr; |
182 | /* ieee80211 TX status. Only used once per 802.11 frag. */ | 182 | /* ieee80211 TX status. Only used once per 802.11 frag. */ |
183 | bool is_last_fragment; | 183 | bool is_last_fragment; |
184 | struct ieee80211_tx_status txstat; | ||
185 | }; | 184 | }; |
186 | 185 | ||
187 | struct b43_dmaring; | 186 | struct b43_dmaring; |
@@ -285,7 +284,7 @@ void b43_dma_get_tx_stats(struct b43_wldev *dev, | |||
285 | struct ieee80211_tx_queue_stats *stats); | 284 | struct ieee80211_tx_queue_stats *stats); |
286 | 285 | ||
287 | int b43_dma_tx(struct b43_wldev *dev, | 286 | int b43_dma_tx(struct b43_wldev *dev, |
288 | struct sk_buff *skb, struct ieee80211_tx_control *ctl); | 287 | struct sk_buff *skb); |
289 | void b43_dma_handle_txstatus(struct b43_wldev *dev, | 288 | void b43_dma_handle_txstatus(struct b43_wldev *dev, |
290 | const struct b43_txstatus *status); | 289 | const struct b43_txstatus *status); |
291 | 290 | ||
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c index fc23ba5309bd..f9c14c66434e 100644 --- a/drivers/net/wireless/b43/main.c +++ b/drivers/net/wireless/b43/main.c | |||
@@ -1368,18 +1368,18 @@ static void b43_write_beacon_template(struct b43_wldev *dev, | |||
1368 | unsigned int rate; | 1368 | unsigned int rate; |
1369 | u16 ctl; | 1369 | u16 ctl; |
1370 | int antenna; | 1370 | int antenna; |
1371 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(dev->wl->current_beacon); | ||
1371 | 1372 | ||
1372 | bcn = (const struct ieee80211_mgmt *)(dev->wl->current_beacon->data); | 1373 | bcn = (const struct ieee80211_mgmt *)(dev->wl->current_beacon->data); |
1373 | len = min((size_t) dev->wl->current_beacon->len, | 1374 | len = min((size_t) dev->wl->current_beacon->len, |
1374 | 0x200 - sizeof(struct b43_plcp_hdr6)); | 1375 | 0x200 - sizeof(struct b43_plcp_hdr6)); |
1375 | rate = dev->wl->beacon_txctl.tx_rate->hw_value; | 1376 | rate = ieee80211_get_tx_rate(dev->wl->hw, info)->hw_value; |
1376 | 1377 | ||
1377 | b43_write_template_common(dev, (const u8 *)bcn, | 1378 | b43_write_template_common(dev, (const u8 *)bcn, |
1378 | len, ram_offset, shm_size_offset, rate); | 1379 | len, ram_offset, shm_size_offset, rate); |
1379 | 1380 | ||
1380 | /* Write the PHY TX control parameters. */ | 1381 | /* Write the PHY TX control parameters. */ |
1381 | antenna = b43_antenna_from_ieee80211(dev, | 1382 | antenna = b43_antenna_from_ieee80211(dev, info->antenna_sel_tx); |
1382 | dev->wl->beacon_txctl.antenna_sel_tx); | ||
1383 | antenna = b43_antenna_to_phyctl(antenna); | 1383 | antenna = b43_antenna_to_phyctl(antenna); |
1384 | ctl = b43_shm_read16(dev, B43_SHM_SHARED, B43_SHM_SH_BEACPHYCTL); | 1384 | ctl = b43_shm_read16(dev, B43_SHM_SHARED, B43_SHM_SH_BEACPHYCTL); |
1385 | /* We can't send beacons with short preamble. Would get PHY errors. */ | 1385 | /* We can't send beacons with short preamble. Would get PHY errors. */ |
@@ -1430,11 +1430,17 @@ static void b43_write_beacon_template(struct b43_wldev *dev, | |||
1430 | i += ie_len + 2; | 1430 | i += ie_len + 2; |
1431 | } | 1431 | } |
1432 | if (!tim_found) { | 1432 | if (!tim_found) { |
1433 | b43warn(dev->wl, "Did not find a valid TIM IE in " | 1433 | /* |
1434 | "the beacon template packet. AP or IBSS operation " | 1434 | * If ucode wants to modify TIM do it behind the beacon, this |
1435 | "may be broken.\n"); | 1435 | * will happen, for example, when doing mesh networking. |
1436 | } else | 1436 | */ |
1437 | b43dbg(dev->wl, "Updated beacon template\n"); | 1437 | b43_shm_write16(dev, B43_SHM_SHARED, |
1438 | B43_SHM_SH_TIMBPOS, | ||
1439 | len + sizeof(struct b43_plcp_hdr6)); | ||
1440 | b43_shm_write16(dev, B43_SHM_SHARED, | ||
1441 | B43_SHM_SH_DTIMPER, 0); | ||
1442 | } | ||
1443 | b43dbg(dev->wl, "Updated beacon template at 0x%x\n", ram_offset); | ||
1438 | } | 1444 | } |
1439 | 1445 | ||
1440 | static void b43_write_probe_resp_plcp(struct b43_wldev *dev, | 1446 | static void b43_write_probe_resp_plcp(struct b43_wldev *dev, |
@@ -1549,7 +1555,8 @@ static void handle_irq_beacon(struct b43_wldev *dev) | |||
1549 | struct b43_wl *wl = dev->wl; | 1555 | struct b43_wl *wl = dev->wl; |
1550 | u32 cmd, beacon0_valid, beacon1_valid; | 1556 | u32 cmd, beacon0_valid, beacon1_valid; |
1551 | 1557 | ||
1552 | if (!b43_is_mode(wl, IEEE80211_IF_TYPE_AP)) | 1558 | if (!b43_is_mode(wl, IEEE80211_IF_TYPE_AP) && |
1559 | !b43_is_mode(wl, IEEE80211_IF_TYPE_MESH_POINT)) | ||
1553 | return; | 1560 | return; |
1554 | 1561 | ||
1555 | /* This is the bottom half of the asynchronous beacon update. */ | 1562 | /* This is the bottom half of the asynchronous beacon update. */ |
@@ -1613,8 +1620,7 @@ static void b43_beacon_update_trigger_work(struct work_struct *work) | |||
1613 | 1620 | ||
1614 | /* Asynchronously update the packet templates in template RAM. | 1621 | /* Asynchronously update the packet templates in template RAM. |
1615 | * Locking: Requires wl->irq_lock to be locked. */ | 1622 | * Locking: Requires wl->irq_lock to be locked. */ |
1616 | static void b43_update_templates(struct b43_wl *wl, struct sk_buff *beacon, | 1623 | static void b43_update_templates(struct b43_wl *wl, struct sk_buff *beacon) |
1617 | const struct ieee80211_tx_control *txctl) | ||
1618 | { | 1624 | { |
1619 | /* This is the top half of the ansynchronous beacon update. | 1625 | /* This is the top half of the ansynchronous beacon update. |
1620 | * The bottom half is the beacon IRQ. | 1626 | * The bottom half is the beacon IRQ. |
@@ -1625,7 +1631,6 @@ static void b43_update_templates(struct b43_wl *wl, struct sk_buff *beacon, | |||
1625 | if (wl->current_beacon) | 1631 | if (wl->current_beacon) |
1626 | dev_kfree_skb_any(wl->current_beacon); | 1632 | dev_kfree_skb_any(wl->current_beacon); |
1627 | wl->current_beacon = beacon; | 1633 | wl->current_beacon = beacon; |
1628 | memcpy(&wl->beacon_txctl, txctl, sizeof(wl->beacon_txctl)); | ||
1629 | wl->beacon0_uploaded = 0; | 1634 | wl->beacon0_uploaded = 0; |
1630 | wl->beacon1_uploaded = 0; | 1635 | wl->beacon1_uploaded = 0; |
1631 | queue_work(wl->hw->workqueue, &wl->beacon_update_trigger); | 1636 | queue_work(wl->hw->workqueue, &wl->beacon_update_trigger); |
@@ -1664,9 +1669,100 @@ static void b43_set_beacon_int(struct b43_wldev *dev, u16 beacon_int) | |||
1664 | b43dbg(dev->wl, "Set beacon interval to %u\n", beacon_int); | 1669 | b43dbg(dev->wl, "Set beacon interval to %u\n", beacon_int); |
1665 | } | 1670 | } |
1666 | 1671 | ||
1672 | static void b43_handle_firmware_panic(struct b43_wldev *dev) | ||
1673 | { | ||
1674 | u16 reason; | ||
1675 | |||
1676 | /* Read the register that contains the reason code for the panic. */ | ||
1677 | reason = b43_shm_read16(dev, B43_SHM_SCRATCH, B43_FWPANIC_REASON_REG); | ||
1678 | b43err(dev->wl, "Whoopsy, firmware panic! Reason: %u\n", reason); | ||
1679 | |||
1680 | switch (reason) { | ||
1681 | default: | ||
1682 | b43dbg(dev->wl, "The panic reason is unknown.\n"); | ||
1683 | /* fallthrough */ | ||
1684 | case B43_FWPANIC_DIE: | ||
1685 | /* Do not restart the controller or firmware. | ||
1686 | * The device is nonfunctional from now on. | ||
1687 | * Restarting would result in this panic to trigger again, | ||
1688 | * so we avoid that recursion. */ | ||
1689 | break; | ||
1690 | case B43_FWPANIC_RESTART: | ||
1691 | b43_controller_restart(dev, "Microcode panic"); | ||
1692 | break; | ||
1693 | } | ||
1694 | } | ||
1695 | |||
1667 | static void handle_irq_ucode_debug(struct b43_wldev *dev) | 1696 | static void handle_irq_ucode_debug(struct b43_wldev *dev) |
1668 | { | 1697 | { |
1669 | //TODO | 1698 | unsigned int i, cnt; |
1699 | u16 reason, marker_id, marker_line; | ||
1700 | __le16 *buf; | ||
1701 | |||
1702 | /* The proprietary firmware doesn't have this IRQ. */ | ||
1703 | if (!dev->fw.opensource) | ||
1704 | return; | ||
1705 | |||
1706 | /* Read the register that contains the reason code for this IRQ. */ | ||
1707 | reason = b43_shm_read16(dev, B43_SHM_SCRATCH, B43_DEBUGIRQ_REASON_REG); | ||
1708 | |||
1709 | switch (reason) { | ||
1710 | case B43_DEBUGIRQ_PANIC: | ||
1711 | b43_handle_firmware_panic(dev); | ||
1712 | break; | ||
1713 | case B43_DEBUGIRQ_DUMP_SHM: | ||
1714 | if (!B43_DEBUG) | ||
1715 | break; /* Only with driver debugging enabled. */ | ||
1716 | buf = kmalloc(4096, GFP_ATOMIC); | ||
1717 | if (!buf) { | ||
1718 | b43dbg(dev->wl, "SHM-dump: Failed to allocate memory\n"); | ||
1719 | goto out; | ||
1720 | } | ||
1721 | for (i = 0; i < 4096; i += 2) { | ||
1722 | u16 tmp = b43_shm_read16(dev, B43_SHM_SHARED, i); | ||
1723 | buf[i / 2] = cpu_to_le16(tmp); | ||
1724 | } | ||
1725 | b43info(dev->wl, "Shared memory dump:\n"); | ||
1726 | print_hex_dump(KERN_INFO, "", DUMP_PREFIX_OFFSET, | ||
1727 | 16, 2, buf, 4096, 1); | ||
1728 | kfree(buf); | ||
1729 | break; | ||
1730 | case B43_DEBUGIRQ_DUMP_REGS: | ||
1731 | if (!B43_DEBUG) | ||
1732 | break; /* Only with driver debugging enabled. */ | ||
1733 | b43info(dev->wl, "Microcode register dump:\n"); | ||
1734 | for (i = 0, cnt = 0; i < 64; i++) { | ||
1735 | u16 tmp = b43_shm_read16(dev, B43_SHM_SCRATCH, i); | ||
1736 | if (cnt == 0) | ||
1737 | printk(KERN_INFO); | ||
1738 | printk("r%02u: 0x%04X ", i, tmp); | ||
1739 | cnt++; | ||
1740 | if (cnt == 6) { | ||
1741 | printk("\n"); | ||
1742 | cnt = 0; | ||
1743 | } | ||
1744 | } | ||
1745 | printk("\n"); | ||
1746 | break; | ||
1747 | case B43_DEBUGIRQ_MARKER: | ||
1748 | if (!B43_DEBUG) | ||
1749 | break; /* Only with driver debugging enabled. */ | ||
1750 | marker_id = b43_shm_read16(dev, B43_SHM_SCRATCH, | ||
1751 | B43_MARKER_ID_REG); | ||
1752 | marker_line = b43_shm_read16(dev, B43_SHM_SCRATCH, | ||
1753 | B43_MARKER_LINE_REG); | ||
1754 | b43info(dev->wl, "The firmware just executed the MARKER(%u) " | ||
1755 | "at line number %u\n", | ||
1756 | marker_id, marker_line); | ||
1757 | break; | ||
1758 | default: | ||
1759 | b43dbg(dev->wl, "Debug-IRQ triggered for unknown reason: %u\n", | ||
1760 | reason); | ||
1761 | } | ||
1762 | out: | ||
1763 | /* Acknowledge the debug-IRQ, so the firmware can continue. */ | ||
1764 | b43_shm_write16(dev, B43_SHM_SCRATCH, | ||
1765 | B43_DEBUGIRQ_REASON_REG, B43_DEBUGIRQ_ACK); | ||
1670 | } | 1766 | } |
1671 | 1767 | ||
1672 | /* Interrupt handler bottom-half */ | 1768 | /* Interrupt handler bottom-half */ |
@@ -1853,7 +1949,8 @@ static void b43_print_fw_helptext(struct b43_wl *wl, bool error) | |||
1853 | 1949 | ||
1854 | static int do_request_fw(struct b43_wldev *dev, | 1950 | static int do_request_fw(struct b43_wldev *dev, |
1855 | const char *name, | 1951 | const char *name, |
1856 | struct b43_firmware_file *fw) | 1952 | struct b43_firmware_file *fw, |
1953 | bool silent) | ||
1857 | { | 1954 | { |
1858 | char path[sizeof(modparam_fwpostfix) + 32]; | 1955 | char path[sizeof(modparam_fwpostfix) + 32]; |
1859 | const struct firmware *blob; | 1956 | const struct firmware *blob; |
@@ -1877,9 +1974,15 @@ static int do_request_fw(struct b43_wldev *dev, | |||
1877 | "b43%s/%s.fw", | 1974 | "b43%s/%s.fw", |
1878 | modparam_fwpostfix, name); | 1975 | modparam_fwpostfix, name); |
1879 | err = request_firmware(&blob, path, dev->dev->dev); | 1976 | err = request_firmware(&blob, path, dev->dev->dev); |
1880 | if (err) { | 1977 | if (err == -ENOENT) { |
1881 | b43err(dev->wl, "Firmware file \"%s\" not found " | 1978 | if (!silent) { |
1882 | "or load failed.\n", path); | 1979 | b43err(dev->wl, "Firmware file \"%s\" not found\n", |
1980 | path); | ||
1981 | } | ||
1982 | return err; | ||
1983 | } else if (err) { | ||
1984 | b43err(dev->wl, "Firmware file \"%s\" request failed (err=%d)\n", | ||
1985 | path, err); | ||
1883 | return err; | 1986 | return err; |
1884 | } | 1987 | } |
1885 | if (blob->size < sizeof(struct b43_fw_header)) | 1988 | if (blob->size < sizeof(struct b43_fw_header)) |
@@ -1930,7 +2033,7 @@ static int b43_request_firmware(struct b43_wldev *dev) | |||
1930 | filename = "ucode13"; | 2033 | filename = "ucode13"; |
1931 | else | 2034 | else |
1932 | goto err_no_ucode; | 2035 | goto err_no_ucode; |
1933 | err = do_request_fw(dev, filename, &fw->ucode); | 2036 | err = do_request_fw(dev, filename, &fw->ucode, 0); |
1934 | if (err) | 2037 | if (err) |
1935 | goto err_load; | 2038 | goto err_load; |
1936 | 2039 | ||
@@ -1941,8 +2044,13 @@ static int b43_request_firmware(struct b43_wldev *dev) | |||
1941 | filename = NULL; | 2044 | filename = NULL; |
1942 | else | 2045 | else |
1943 | goto err_no_pcm; | 2046 | goto err_no_pcm; |
1944 | err = do_request_fw(dev, filename, &fw->pcm); | 2047 | fw->pcm_request_failed = 0; |
1945 | if (err) | 2048 | err = do_request_fw(dev, filename, &fw->pcm, 1); |
2049 | if (err == -ENOENT) { | ||
2050 | /* We did not find a PCM file? Not fatal, but | ||
2051 | * core rev <= 10 must do without hwcrypto then. */ | ||
2052 | fw->pcm_request_failed = 1; | ||
2053 | } else if (err) | ||
1946 | goto err_load; | 2054 | goto err_load; |
1947 | 2055 | ||
1948 | /* Get initvals */ | 2056 | /* Get initvals */ |
@@ -1960,7 +2068,7 @@ static int b43_request_firmware(struct b43_wldev *dev) | |||
1960 | if ((rev >= 5) && (rev <= 10)) | 2068 | if ((rev >= 5) && (rev <= 10)) |
1961 | filename = "b0g0initvals5"; | 2069 | filename = "b0g0initvals5"; |
1962 | else if (rev >= 13) | 2070 | else if (rev >= 13) |
1963 | filename = "lp0initvals13"; | 2071 | filename = "b0g0initvals13"; |
1964 | else | 2072 | else |
1965 | goto err_no_initvals; | 2073 | goto err_no_initvals; |
1966 | break; | 2074 | break; |
@@ -1973,7 +2081,7 @@ static int b43_request_firmware(struct b43_wldev *dev) | |||
1973 | default: | 2081 | default: |
1974 | goto err_no_initvals; | 2082 | goto err_no_initvals; |
1975 | } | 2083 | } |
1976 | err = do_request_fw(dev, filename, &fw->initvals); | 2084 | err = do_request_fw(dev, filename, &fw->initvals, 0); |
1977 | if (err) | 2085 | if (err) |
1978 | goto err_load; | 2086 | goto err_load; |
1979 | 2087 | ||
@@ -2007,7 +2115,7 @@ static int b43_request_firmware(struct b43_wldev *dev) | |||
2007 | default: | 2115 | default: |
2008 | goto err_no_initvals; | 2116 | goto err_no_initvals; |
2009 | } | 2117 | } |
2010 | err = do_request_fw(dev, filename, &fw->initvals_band); | 2118 | err = do_request_fw(dev, filename, &fw->initvals_band, 0); |
2011 | if (err) | 2119 | if (err) |
2012 | goto err_load; | 2120 | goto err_load; |
2013 | 2121 | ||
@@ -2124,14 +2232,28 @@ static int b43_upload_microcode(struct b43_wldev *dev) | |||
2124 | err = -EOPNOTSUPP; | 2232 | err = -EOPNOTSUPP; |
2125 | goto error; | 2233 | goto error; |
2126 | } | 2234 | } |
2127 | b43info(dev->wl, "Loading firmware version %u.%u " | ||
2128 | "(20%.2i-%.2i-%.2i %.2i:%.2i:%.2i)\n", | ||
2129 | fwrev, fwpatch, | ||
2130 | (fwdate >> 12) & 0xF, (fwdate >> 8) & 0xF, fwdate & 0xFF, | ||
2131 | (fwtime >> 11) & 0x1F, (fwtime >> 5) & 0x3F, fwtime & 0x1F); | ||
2132 | |||
2133 | dev->fw.rev = fwrev; | 2235 | dev->fw.rev = fwrev; |
2134 | dev->fw.patch = fwpatch; | 2236 | dev->fw.patch = fwpatch; |
2237 | dev->fw.opensource = (fwdate == 0xFFFF); | ||
2238 | |||
2239 | if (dev->fw.opensource) { | ||
2240 | /* Patchlevel info is encoded in the "time" field. */ | ||
2241 | dev->fw.patch = fwtime; | ||
2242 | b43info(dev->wl, "Loading OpenSource firmware version %u.%u%s\n", | ||
2243 | dev->fw.rev, dev->fw.patch, | ||
2244 | dev->fw.pcm_request_failed ? " (Hardware crypto not supported)" : ""); | ||
2245 | } else { | ||
2246 | b43info(dev->wl, "Loading firmware version %u.%u " | ||
2247 | "(20%.2i-%.2i-%.2i %.2i:%.2i:%.2i)\n", | ||
2248 | fwrev, fwpatch, | ||
2249 | (fwdate >> 12) & 0xF, (fwdate >> 8) & 0xF, fwdate & 0xFF, | ||
2250 | (fwtime >> 11) & 0x1F, (fwtime >> 5) & 0x3F, fwtime & 0x1F); | ||
2251 | if (dev->fw.pcm_request_failed) { | ||
2252 | b43warn(dev->wl, "No \"pcm5.fw\" firmware file found. " | ||
2253 | "Hardware accelerated cryptography is disabled.\n"); | ||
2254 | b43_print_fw_helptext(dev->wl, 0); | ||
2255 | } | ||
2256 | } | ||
2135 | 2257 | ||
2136 | if (b43_is_old_txhdr_format(dev)) { | 2258 | if (b43_is_old_txhdr_format(dev)) { |
2137 | b43warn(dev->wl, "You are using an old firmware image. " | 2259 | b43warn(dev->wl, "You are using an old firmware image. " |
@@ -2376,7 +2498,8 @@ static void b43_adjust_opmode(struct b43_wldev *dev) | |||
2376 | ctl &= ~B43_MACCTL_BEACPROMISC; | 2498 | ctl &= ~B43_MACCTL_BEACPROMISC; |
2377 | ctl |= B43_MACCTL_INFRA; | 2499 | ctl |= B43_MACCTL_INFRA; |
2378 | 2500 | ||
2379 | if (b43_is_mode(wl, IEEE80211_IF_TYPE_AP)) | 2501 | if (b43_is_mode(wl, IEEE80211_IF_TYPE_AP) || |
2502 | b43_is_mode(wl, IEEE80211_IF_TYPE_MESH_POINT)) | ||
2380 | ctl |= B43_MACCTL_AP; | 2503 | ctl |= B43_MACCTL_AP; |
2381 | else if (b43_is_mode(wl, IEEE80211_IF_TYPE_IBSS)) | 2504 | else if (b43_is_mode(wl, IEEE80211_IF_TYPE_IBSS)) |
2382 | ctl &= ~B43_MACCTL_INFRA; | 2505 | ctl &= ~B43_MACCTL_INFRA; |
@@ -2813,8 +2936,7 @@ static int b43_rng_init(struct b43_wl *wl) | |||
2813 | } | 2936 | } |
2814 | 2937 | ||
2815 | static int b43_op_tx(struct ieee80211_hw *hw, | 2938 | static int b43_op_tx(struct ieee80211_hw *hw, |
2816 | struct sk_buff *skb, | 2939 | struct sk_buff *skb) |
2817 | struct ieee80211_tx_control *ctl) | ||
2818 | { | 2940 | { |
2819 | struct b43_wl *wl = hw_to_b43_wl(hw); | 2941 | struct b43_wl *wl = hw_to_b43_wl(hw); |
2820 | struct b43_wldev *dev = wl->current_dev; | 2942 | struct b43_wldev *dev = wl->current_dev; |
@@ -2836,9 +2958,9 @@ static int b43_op_tx(struct ieee80211_hw *hw, | |||
2836 | err = -ENODEV; | 2958 | err = -ENODEV; |
2837 | if (likely(b43_status(dev) >= B43_STAT_STARTED)) { | 2959 | if (likely(b43_status(dev) >= B43_STAT_STARTED)) { |
2838 | if (b43_using_pio_transfers(dev)) | 2960 | if (b43_using_pio_transfers(dev)) |
2839 | err = b43_pio_tx(dev, skb, ctl); | 2961 | err = b43_pio_tx(dev, skb); |
2840 | else | 2962 | else |
2841 | err = b43_dma_tx(dev, skb, ctl); | 2963 | err = b43_dma_tx(dev, skb); |
2842 | } | 2964 | } |
2843 | 2965 | ||
2844 | read_unlock_irqrestore(&wl->tx_lock, flags); | 2966 | read_unlock_irqrestore(&wl->tx_lock, flags); |
@@ -3244,8 +3366,9 @@ static int b43_op_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf) | |||
3244 | antenna = b43_antenna_from_ieee80211(dev, conf->antenna_sel_rx); | 3366 | antenna = b43_antenna_from_ieee80211(dev, conf->antenna_sel_rx); |
3245 | b43_set_rx_antenna(dev, antenna); | 3367 | b43_set_rx_antenna(dev, antenna); |
3246 | 3368 | ||
3247 | /* Update templates for AP mode. */ | 3369 | /* Update templates for AP/mesh mode. */ |
3248 | if (b43_is_mode(wl, IEEE80211_IF_TYPE_AP)) | 3370 | if (b43_is_mode(wl, IEEE80211_IF_TYPE_AP) || |
3371 | b43_is_mode(wl, IEEE80211_IF_TYPE_MESH_POINT)) | ||
3249 | b43_set_beacon_int(dev, conf->beacon_int); | 3372 | b43_set_beacon_int(dev, conf->beacon_int); |
3250 | 3373 | ||
3251 | if (!!conf->radio_enabled != phy->radio_on) { | 3374 | if (!!conf->radio_enabled != phy->radio_on) { |
@@ -3296,6 +3419,13 @@ static int b43_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, | |||
3296 | if (!dev || b43_status(dev) < B43_STAT_INITIALIZED) | 3419 | if (!dev || b43_status(dev) < B43_STAT_INITIALIZED) |
3297 | goto out_unlock; | 3420 | goto out_unlock; |
3298 | 3421 | ||
3422 | if (dev->fw.pcm_request_failed) { | ||
3423 | /* We don't have firmware for the crypto engine. | ||
3424 | * Must use software-crypto. */ | ||
3425 | err = -EOPNOTSUPP; | ||
3426 | goto out_unlock; | ||
3427 | } | ||
3428 | |||
3299 | err = -EINVAL; | 3429 | err = -EINVAL; |
3300 | switch (key->alg) { | 3430 | switch (key->alg) { |
3301 | case ALG_WEP: | 3431 | case ALG_WEP: |
@@ -3426,13 +3556,12 @@ static int b43_op_config_interface(struct ieee80211_hw *hw, | |||
3426 | else | 3556 | else |
3427 | memset(wl->bssid, 0, ETH_ALEN); | 3557 | memset(wl->bssid, 0, ETH_ALEN); |
3428 | if (b43_status(dev) >= B43_STAT_INITIALIZED) { | 3558 | if (b43_status(dev) >= B43_STAT_INITIALIZED) { |
3429 | if (b43_is_mode(wl, IEEE80211_IF_TYPE_AP)) { | 3559 | if (b43_is_mode(wl, IEEE80211_IF_TYPE_AP) || |
3430 | B43_WARN_ON(conf->type != IEEE80211_IF_TYPE_AP); | 3560 | b43_is_mode(wl, IEEE80211_IF_TYPE_MESH_POINT)) { |
3561 | B43_WARN_ON(conf->type != wl->if_type); | ||
3431 | b43_set_ssid(dev, conf->ssid, conf->ssid_len); | 3562 | b43_set_ssid(dev, conf->ssid, conf->ssid_len); |
3432 | if (conf->beacon) { | 3563 | if (conf->beacon) |
3433 | b43_update_templates(wl, conf->beacon, | 3564 | b43_update_templates(wl, conf->beacon); |
3434 | conf->beacon_control); | ||
3435 | } | ||
3436 | } | 3565 | } |
3437 | b43_write_mac_bssid_templates(dev); | 3566 | b43_write_mac_bssid_templates(dev); |
3438 | } | 3567 | } |
@@ -3497,7 +3626,6 @@ static int b43_wireless_core_start(struct b43_wldev *dev) | |||
3497 | /* Start data flow (TX/RX). */ | 3626 | /* Start data flow (TX/RX). */ |
3498 | b43_mac_enable(dev); | 3627 | b43_mac_enable(dev); |
3499 | b43_interrupt_enable(dev, dev->irq_savedstate); | 3628 | b43_interrupt_enable(dev, dev->irq_savedstate); |
3500 | ieee80211_start_queues(dev->wl->hw); | ||
3501 | 3629 | ||
3502 | /* Start maintainance work */ | 3630 | /* Start maintainance work */ |
3503 | b43_periodic_tasks_setup(dev); | 3631 | b43_periodic_tasks_setup(dev); |
@@ -3970,6 +4098,7 @@ static int b43_op_add_interface(struct ieee80211_hw *hw, | |||
3970 | /* TODO: allow WDS/AP devices to coexist */ | 4098 | /* TODO: allow WDS/AP devices to coexist */ |
3971 | 4099 | ||
3972 | if (conf->type != IEEE80211_IF_TYPE_AP && | 4100 | if (conf->type != IEEE80211_IF_TYPE_AP && |
4101 | conf->type != IEEE80211_IF_TYPE_MESH_POINT && | ||
3973 | conf->type != IEEE80211_IF_TYPE_STA && | 4102 | conf->type != IEEE80211_IF_TYPE_STA && |
3974 | conf->type != IEEE80211_IF_TYPE_WDS && | 4103 | conf->type != IEEE80211_IF_TYPE_WDS && |
3975 | conf->type != IEEE80211_IF_TYPE_IBSS) | 4104 | conf->type != IEEE80211_IF_TYPE_IBSS) |
@@ -4119,31 +4248,29 @@ static int b43_op_beacon_set_tim(struct ieee80211_hw *hw, int aid, int set) | |||
4119 | struct b43_wl *wl = hw_to_b43_wl(hw); | 4248 | struct b43_wl *wl = hw_to_b43_wl(hw); |
4120 | struct sk_buff *beacon; | 4249 | struct sk_buff *beacon; |
4121 | unsigned long flags; | 4250 | unsigned long flags; |
4122 | struct ieee80211_tx_control txctl; | ||
4123 | 4251 | ||
4124 | /* We could modify the existing beacon and set the aid bit in | 4252 | /* We could modify the existing beacon and set the aid bit in |
4125 | * the TIM field, but that would probably require resizing and | 4253 | * the TIM field, but that would probably require resizing and |
4126 | * moving of data within the beacon template. | 4254 | * moving of data within the beacon template. |
4127 | * Simply request a new beacon and let mac80211 do the hard work. */ | 4255 | * Simply request a new beacon and let mac80211 do the hard work. */ |
4128 | beacon = ieee80211_beacon_get(hw, wl->vif, &txctl); | 4256 | beacon = ieee80211_beacon_get(hw, wl->vif); |
4129 | if (unlikely(!beacon)) | 4257 | if (unlikely(!beacon)) |
4130 | return -ENOMEM; | 4258 | return -ENOMEM; |
4131 | spin_lock_irqsave(&wl->irq_lock, flags); | 4259 | spin_lock_irqsave(&wl->irq_lock, flags); |
4132 | b43_update_templates(wl, beacon, &txctl); | 4260 | b43_update_templates(wl, beacon); |
4133 | spin_unlock_irqrestore(&wl->irq_lock, flags); | 4261 | spin_unlock_irqrestore(&wl->irq_lock, flags); |
4134 | 4262 | ||
4135 | return 0; | 4263 | return 0; |
4136 | } | 4264 | } |
4137 | 4265 | ||
4138 | static int b43_op_ibss_beacon_update(struct ieee80211_hw *hw, | 4266 | static int b43_op_ibss_beacon_update(struct ieee80211_hw *hw, |
4139 | struct sk_buff *beacon, | 4267 | struct sk_buff *beacon) |
4140 | struct ieee80211_tx_control *ctl) | ||
4141 | { | 4268 | { |
4142 | struct b43_wl *wl = hw_to_b43_wl(hw); | 4269 | struct b43_wl *wl = hw_to_b43_wl(hw); |
4143 | unsigned long flags; | 4270 | unsigned long flags; |
4144 | 4271 | ||
4145 | spin_lock_irqsave(&wl->irq_lock, flags); | 4272 | spin_lock_irqsave(&wl->irq_lock, flags); |
4146 | b43_update_templates(wl, beacon, ctl); | 4273 | b43_update_templates(wl, beacon); |
4147 | spin_unlock_irqrestore(&wl->irq_lock, flags); | 4274 | spin_unlock_irqrestore(&wl->irq_lock, flags); |
4148 | 4275 | ||
4149 | return 0; | 4276 | return 0; |
diff --git a/drivers/net/wireless/b43/pio.c b/drivers/net/wireless/b43/pio.c index 08c8a087f30e..8b1555d95f1c 100644 --- a/drivers/net/wireless/b43/pio.c +++ b/drivers/net/wireless/b43/pio.c | |||
@@ -446,29 +446,27 @@ static void pio_tx_frame_4byte_queue(struct b43_pio_txpacket *pack, | |||
446 | } | 446 | } |
447 | 447 | ||
448 | static int pio_tx_frame(struct b43_pio_txqueue *q, | 448 | static int pio_tx_frame(struct b43_pio_txqueue *q, |
449 | struct sk_buff *skb, | 449 | struct sk_buff *skb) |
450 | struct ieee80211_tx_control *ctl) | ||
451 | { | 450 | { |
452 | struct b43_pio_txpacket *pack; | 451 | struct b43_pio_txpacket *pack; |
453 | struct b43_txhdr txhdr; | 452 | struct b43_txhdr txhdr; |
454 | u16 cookie; | 453 | u16 cookie; |
455 | int err; | 454 | int err; |
456 | unsigned int hdrlen; | 455 | unsigned int hdrlen; |
456 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
457 | 457 | ||
458 | B43_WARN_ON(list_empty(&q->packets_list)); | 458 | B43_WARN_ON(list_empty(&q->packets_list)); |
459 | pack = list_entry(q->packets_list.next, | 459 | pack = list_entry(q->packets_list.next, |
460 | struct b43_pio_txpacket, list); | 460 | struct b43_pio_txpacket, list); |
461 | memset(&pack->txstat, 0, sizeof(pack->txstat)); | ||
462 | memcpy(&pack->txstat.control, ctl, sizeof(*ctl)); | ||
463 | 461 | ||
464 | cookie = generate_cookie(q, pack); | 462 | cookie = generate_cookie(q, pack); |
465 | hdrlen = b43_txhdr_size(q->dev); | 463 | hdrlen = b43_txhdr_size(q->dev); |
466 | err = b43_generate_txhdr(q->dev, (u8 *)&txhdr, skb->data, | 464 | err = b43_generate_txhdr(q->dev, (u8 *)&txhdr, skb->data, |
467 | skb->len, ctl, cookie); | 465 | skb->len, info, cookie); |
468 | if (err) | 466 | if (err) |
469 | return err; | 467 | return err; |
470 | 468 | ||
471 | if (ctl->flags & IEEE80211_TXCTL_SEND_AFTER_DTIM) { | 469 | if (info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) { |
472 | /* Tell the firmware about the cookie of the last | 470 | /* Tell the firmware about the cookie of the last |
473 | * mcast frame, so it can clear the more-data bit in it. */ | 471 | * mcast frame, so it can clear the more-data bit in it. */ |
474 | b43_shm_write16(q->dev, B43_SHM_SHARED, | 472 | b43_shm_write16(q->dev, B43_SHM_SHARED, |
@@ -492,17 +490,18 @@ static int pio_tx_frame(struct b43_pio_txqueue *q, | |||
492 | return 0; | 490 | return 0; |
493 | } | 491 | } |
494 | 492 | ||
495 | int b43_pio_tx(struct b43_wldev *dev, | 493 | int b43_pio_tx(struct b43_wldev *dev, struct sk_buff *skb) |
496 | struct sk_buff *skb, struct ieee80211_tx_control *ctl) | ||
497 | { | 494 | { |
498 | struct b43_pio_txqueue *q; | 495 | struct b43_pio_txqueue *q; |
499 | struct ieee80211_hdr *hdr; | 496 | struct ieee80211_hdr *hdr; |
500 | unsigned long flags; | 497 | unsigned long flags; |
501 | unsigned int hdrlen, total_len; | 498 | unsigned int hdrlen, total_len; |
502 | int err = 0; | 499 | int err = 0; |
500 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
503 | 501 | ||
504 | hdr = (struct ieee80211_hdr *)skb->data; | 502 | hdr = (struct ieee80211_hdr *)skb->data; |
505 | if (ctl->flags & IEEE80211_TXCTL_SEND_AFTER_DTIM) { | 503 | |
504 | if (info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) { | ||
506 | /* The multicast queue will be sent after the DTIM. */ | 505 | /* The multicast queue will be sent after the DTIM. */ |
507 | q = dev->pio.tx_queue_mcast; | 506 | q = dev->pio.tx_queue_mcast; |
508 | /* Set the frame More-Data bit. Ucode will clear it | 507 | /* Set the frame More-Data bit. Ucode will clear it |
@@ -510,7 +509,7 @@ int b43_pio_tx(struct b43_wldev *dev, | |||
510 | hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREDATA); | 509 | hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREDATA); |
511 | } else { | 510 | } else { |
512 | /* Decide by priority where to put this frame. */ | 511 | /* Decide by priority where to put this frame. */ |
513 | q = select_queue_by_priority(dev, ctl->queue); | 512 | q = select_queue_by_priority(dev, skb_get_queue_mapping(skb)); |
514 | } | 513 | } |
515 | 514 | ||
516 | spin_lock_irqsave(&q->lock, flags); | 515 | spin_lock_irqsave(&q->lock, flags); |
@@ -533,7 +532,7 @@ int b43_pio_tx(struct b43_wldev *dev, | |||
533 | if (total_len > (q->buffer_size - q->buffer_used)) { | 532 | if (total_len > (q->buffer_size - q->buffer_used)) { |
534 | /* Not enough memory on the queue. */ | 533 | /* Not enough memory on the queue. */ |
535 | err = -EBUSY; | 534 | err = -EBUSY; |
536 | ieee80211_stop_queue(dev->wl->hw, ctl->queue); | 535 | ieee80211_stop_queue(dev->wl->hw, skb_get_queue_mapping(skb)); |
537 | q->stopped = 1; | 536 | q->stopped = 1; |
538 | goto out_unlock; | 537 | goto out_unlock; |
539 | } | 538 | } |
@@ -541,9 +540,9 @@ int b43_pio_tx(struct b43_wldev *dev, | |||
541 | /* Assign the queue number to the ring (if not already done before) | 540 | /* Assign the queue number to the ring (if not already done before) |
542 | * so TX status handling can use it. The mac80211-queue to b43-queue | 541 | * so TX status handling can use it. The mac80211-queue to b43-queue |
543 | * mapping is static, so we don't need to store it per frame. */ | 542 | * mapping is static, so we don't need to store it per frame. */ |
544 | q->queue_prio = ctl->queue; | 543 | q->queue_prio = skb_get_queue_mapping(skb); |
545 | 544 | ||
546 | err = pio_tx_frame(q, skb, ctl); | 545 | err = pio_tx_frame(q, skb); |
547 | if (unlikely(err == -ENOKEY)) { | 546 | if (unlikely(err == -ENOKEY)) { |
548 | /* Drop this packet, as we don't have the encryption key | 547 | /* Drop this packet, as we don't have the encryption key |
549 | * anymore and must not transmit it unencrypted. */ | 548 | * anymore and must not transmit it unencrypted. */ |
@@ -561,7 +560,7 @@ int b43_pio_tx(struct b43_wldev *dev, | |||
561 | if (((q->buffer_size - q->buffer_used) < roundup(2 + 2 + 6, 4)) || | 560 | if (((q->buffer_size - q->buffer_used) < roundup(2 + 2 + 6, 4)) || |
562 | (q->free_packet_slots == 0)) { | 561 | (q->free_packet_slots == 0)) { |
563 | /* The queue is full. */ | 562 | /* The queue is full. */ |
564 | ieee80211_stop_queue(dev->wl->hw, ctl->queue); | 563 | ieee80211_stop_queue(dev->wl->hw, skb_get_queue_mapping(skb)); |
565 | q->stopped = 1; | 564 | q->stopped = 1; |
566 | } | 565 | } |
567 | 566 | ||
@@ -578,6 +577,7 @@ void b43_pio_handle_txstatus(struct b43_wldev *dev, | |||
578 | struct b43_pio_txqueue *q; | 577 | struct b43_pio_txqueue *q; |
579 | struct b43_pio_txpacket *pack = NULL; | 578 | struct b43_pio_txpacket *pack = NULL; |
580 | unsigned int total_len; | 579 | unsigned int total_len; |
580 | struct ieee80211_tx_info *info; | ||
581 | 581 | ||
582 | q = parse_cookie(dev, status->cookie, &pack); | 582 | q = parse_cookie(dev, status->cookie, &pack); |
583 | if (unlikely(!q)) | 583 | if (unlikely(!q)) |
@@ -586,15 +586,17 @@ void b43_pio_handle_txstatus(struct b43_wldev *dev, | |||
586 | 586 | ||
587 | spin_lock(&q->lock); /* IRQs are already disabled. */ | 587 | spin_lock(&q->lock); /* IRQs are already disabled. */ |
588 | 588 | ||
589 | b43_fill_txstatus_report(&(pack->txstat), status); | 589 | info = (void *)pack->skb; |
590 | memset(&info->status, 0, sizeof(info->status)); | ||
591 | |||
592 | b43_fill_txstatus_report(info, status); | ||
590 | 593 | ||
591 | total_len = pack->skb->len + b43_txhdr_size(dev); | 594 | total_len = pack->skb->len + b43_txhdr_size(dev); |
592 | total_len = roundup(total_len, 4); | 595 | total_len = roundup(total_len, 4); |
593 | q->buffer_used -= total_len; | 596 | q->buffer_used -= total_len; |
594 | q->free_packet_slots += 1; | 597 | q->free_packet_slots += 1; |
595 | 598 | ||
596 | ieee80211_tx_status_irqsafe(dev->wl->hw, pack->skb, | 599 | ieee80211_tx_status_irqsafe(dev->wl->hw, pack->skb); |
597 | &(pack->txstat)); | ||
598 | pack->skb = NULL; | 600 | pack->skb = NULL; |
599 | list_add(&pack->list, &q->packets_list); | 601 | list_add(&pack->list, &q->packets_list); |
600 | 602 | ||
diff --git a/drivers/net/wireless/b43/pio.h b/drivers/net/wireless/b43/pio.h index e2ec676cc9e4..6c174c91ca20 100644 --- a/drivers/net/wireless/b43/pio.h +++ b/drivers/net/wireless/b43/pio.h | |||
@@ -62,8 +62,6 @@ struct b43_pio_txpacket { | |||
62 | struct b43_pio_txqueue *queue; | 62 | struct b43_pio_txqueue *queue; |
63 | /* The TX data packet. */ | 63 | /* The TX data packet. */ |
64 | struct sk_buff *skb; | 64 | struct sk_buff *skb; |
65 | /* The status meta data. */ | ||
66 | struct ieee80211_tx_status txstat; | ||
67 | /* Index in the (struct b43_pio_txqueue)->packets array. */ | 65 | /* Index in the (struct b43_pio_txqueue)->packets array. */ |
68 | u8 index; | 66 | u8 index; |
69 | 67 | ||
@@ -167,8 +165,7 @@ int b43_pio_init(struct b43_wldev *dev); | |||
167 | void b43_pio_stop(struct b43_wldev *dev); | 165 | void b43_pio_stop(struct b43_wldev *dev); |
168 | void b43_pio_free(struct b43_wldev *dev); | 166 | void b43_pio_free(struct b43_wldev *dev); |
169 | 167 | ||
170 | int b43_pio_tx(struct b43_wldev *dev, | 168 | int b43_pio_tx(struct b43_wldev *dev, struct sk_buff *skb); |
171 | struct sk_buff *skb, struct ieee80211_tx_control *ctl); | ||
172 | void b43_pio_handle_txstatus(struct b43_wldev *dev, | 169 | void b43_pio_handle_txstatus(struct b43_wldev *dev, |
173 | const struct b43_txstatus *status); | 170 | const struct b43_txstatus *status); |
174 | void b43_pio_get_tx_stats(struct b43_wldev *dev, | 171 | void b43_pio_get_tx_stats(struct b43_wldev *dev, |
@@ -193,8 +190,7 @@ static inline void b43_pio_stop(struct b43_wldev *dev) | |||
193 | { | 190 | { |
194 | } | 191 | } |
195 | static inline int b43_pio_tx(struct b43_wldev *dev, | 192 | static inline int b43_pio_tx(struct b43_wldev *dev, |
196 | struct sk_buff *skb, | 193 | struct sk_buff *skb) |
197 | struct ieee80211_tx_control *ctl) | ||
198 | { | 194 | { |
199 | return 0; | 195 | return 0; |
200 | } | 196 | } |
diff --git a/drivers/net/wireless/b43/xmit.c b/drivers/net/wireless/b43/xmit.c index afce9338d83a..f9e1cff2aecb 100644 --- a/drivers/net/wireless/b43/xmit.c +++ b/drivers/net/wireless/b43/xmit.c | |||
@@ -185,14 +185,14 @@ int b43_generate_txhdr(struct b43_wldev *dev, | |||
185 | u8 *_txhdr, | 185 | u8 *_txhdr, |
186 | const unsigned char *fragment_data, | 186 | const unsigned char *fragment_data, |
187 | unsigned int fragment_len, | 187 | unsigned int fragment_len, |
188 | const struct ieee80211_tx_control *txctl, | 188 | const struct ieee80211_tx_info *info, |
189 | u16 cookie) | 189 | u16 cookie) |
190 | { | 190 | { |
191 | struct b43_txhdr *txhdr = (struct b43_txhdr *)_txhdr; | 191 | struct b43_txhdr *txhdr = (struct b43_txhdr *)_txhdr; |
192 | const struct b43_phy *phy = &dev->phy; | 192 | const struct b43_phy *phy = &dev->phy; |
193 | const struct ieee80211_hdr *wlhdr = | 193 | const struct ieee80211_hdr *wlhdr = |
194 | (const struct ieee80211_hdr *)fragment_data; | 194 | (const struct ieee80211_hdr *)fragment_data; |
195 | int use_encryption = (!(txctl->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT)); | 195 | int use_encryption = (!(info->flags & IEEE80211_TX_CTL_DO_NOT_ENCRYPT)); |
196 | u16 fctl = le16_to_cpu(wlhdr->frame_control); | 196 | u16 fctl = le16_to_cpu(wlhdr->frame_control); |
197 | struct ieee80211_rate *fbrate; | 197 | struct ieee80211_rate *fbrate; |
198 | u8 rate, rate_fb; | 198 | u8 rate, rate_fb; |
@@ -201,13 +201,14 @@ int b43_generate_txhdr(struct b43_wldev *dev, | |||
201 | u32 mac_ctl = 0; | 201 | u32 mac_ctl = 0; |
202 | u16 phy_ctl = 0; | 202 | u16 phy_ctl = 0; |
203 | u8 extra_ft = 0; | 203 | u8 extra_ft = 0; |
204 | struct ieee80211_rate *txrate; | ||
204 | 205 | ||
205 | memset(txhdr, 0, sizeof(*txhdr)); | 206 | memset(txhdr, 0, sizeof(*txhdr)); |
206 | 207 | ||
207 | WARN_ON(!txctl->tx_rate); | 208 | txrate = ieee80211_get_tx_rate(dev->wl->hw, info); |
208 | rate = txctl->tx_rate ? txctl->tx_rate->hw_value : B43_CCK_RATE_1MB; | 209 | rate = txrate ? txrate->hw_value : B43_CCK_RATE_1MB; |
209 | rate_ofdm = b43_is_ofdm_rate(rate); | 210 | rate_ofdm = b43_is_ofdm_rate(rate); |
210 | fbrate = txctl->alt_retry_rate ? : txctl->tx_rate; | 211 | fbrate = ieee80211_get_alt_retry_rate(dev->wl->hw, info) ? : txrate; |
211 | rate_fb = fbrate->hw_value; | 212 | rate_fb = fbrate->hw_value; |
212 | rate_fb_ofdm = b43_is_ofdm_rate(rate_fb); | 213 | rate_fb_ofdm = b43_is_ofdm_rate(rate_fb); |
213 | 214 | ||
@@ -227,15 +228,13 @@ int b43_generate_txhdr(struct b43_wldev *dev, | |||
227 | * use the original dur_id field. */ | 228 | * use the original dur_id field. */ |
228 | txhdr->dur_fb = wlhdr->duration_id; | 229 | txhdr->dur_fb = wlhdr->duration_id; |
229 | } else { | 230 | } else { |
230 | txhdr->dur_fb = ieee80211_generic_frame_duration(dev->wl->hw, | 231 | txhdr->dur_fb = ieee80211_generic_frame_duration( |
231 | txctl->vif, | 232 | dev->wl->hw, info->control.vif, fragment_len, fbrate); |
232 | fragment_len, | ||
233 | fbrate); | ||
234 | } | 233 | } |
235 | 234 | ||
236 | plcp_fragment_len = fragment_len + FCS_LEN; | 235 | plcp_fragment_len = fragment_len + FCS_LEN; |
237 | if (use_encryption) { | 236 | if (use_encryption) { |
238 | u8 key_idx = txctl->hw_key->hw_key_idx; | 237 | u8 key_idx = info->control.hw_key->hw_key_idx; |
239 | struct b43_key *key; | 238 | struct b43_key *key; |
240 | int wlhdr_len; | 239 | int wlhdr_len; |
241 | size_t iv_len; | 240 | size_t iv_len; |
@@ -253,7 +252,7 @@ int b43_generate_txhdr(struct b43_wldev *dev, | |||
253 | } | 252 | } |
254 | 253 | ||
255 | /* Hardware appends ICV. */ | 254 | /* Hardware appends ICV. */ |
256 | plcp_fragment_len += txctl->icv_len; | 255 | plcp_fragment_len += info->control.icv_len; |
257 | 256 | ||
258 | key_idx = b43_kidx_to_fw(dev, key_idx); | 257 | key_idx = b43_kidx_to_fw(dev, key_idx); |
259 | mac_ctl |= (key_idx << B43_TXH_MAC_KEYIDX_SHIFT) & | 258 | mac_ctl |= (key_idx << B43_TXH_MAC_KEYIDX_SHIFT) & |
@@ -261,7 +260,7 @@ int b43_generate_txhdr(struct b43_wldev *dev, | |||
261 | mac_ctl |= (key->algorithm << B43_TXH_MAC_KEYALG_SHIFT) & | 260 | mac_ctl |= (key->algorithm << B43_TXH_MAC_KEYALG_SHIFT) & |
262 | B43_TXH_MAC_KEYALG; | 261 | B43_TXH_MAC_KEYALG; |
263 | wlhdr_len = ieee80211_get_hdrlen(fctl); | 262 | wlhdr_len = ieee80211_get_hdrlen(fctl); |
264 | iv_len = min((size_t) txctl->iv_len, | 263 | iv_len = min((size_t) info->control.iv_len, |
265 | ARRAY_SIZE(txhdr->iv)); | 264 | ARRAY_SIZE(txhdr->iv)); |
266 | memcpy(txhdr->iv, ((u8 *) wlhdr) + wlhdr_len, iv_len); | 265 | memcpy(txhdr->iv, ((u8 *) wlhdr) + wlhdr_len, iv_len); |
267 | } | 266 | } |
@@ -292,10 +291,10 @@ int b43_generate_txhdr(struct b43_wldev *dev, | |||
292 | phy_ctl |= B43_TXH_PHY_ENC_OFDM; | 291 | phy_ctl |= B43_TXH_PHY_ENC_OFDM; |
293 | else | 292 | else |
294 | phy_ctl |= B43_TXH_PHY_ENC_CCK; | 293 | phy_ctl |= B43_TXH_PHY_ENC_CCK; |
295 | if (txctl->flags & IEEE80211_TXCTL_SHORT_PREAMBLE) | 294 | if (info->flags & IEEE80211_TX_CTL_SHORT_PREAMBLE) |
296 | phy_ctl |= B43_TXH_PHY_SHORTPRMBL; | 295 | phy_ctl |= B43_TXH_PHY_SHORTPRMBL; |
297 | 296 | ||
298 | switch (b43_ieee80211_antenna_sanitize(dev, txctl->antenna_sel_tx)) { | 297 | switch (b43_ieee80211_antenna_sanitize(dev, info->antenna_sel_tx)) { |
299 | case 0: /* Default */ | 298 | case 0: /* Default */ |
300 | phy_ctl |= B43_TXH_PHY_ANT01AUTO; | 299 | phy_ctl |= B43_TXH_PHY_ANT01AUTO; |
301 | break; | 300 | break; |
@@ -316,34 +315,36 @@ int b43_generate_txhdr(struct b43_wldev *dev, | |||
316 | } | 315 | } |
317 | 316 | ||
318 | /* MAC control */ | 317 | /* MAC control */ |
319 | if (!(txctl->flags & IEEE80211_TXCTL_NO_ACK)) | 318 | if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) |
320 | mac_ctl |= B43_TXH_MAC_ACK; | 319 | mac_ctl |= B43_TXH_MAC_ACK; |
321 | if (!(((fctl & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) && | 320 | if (!(((fctl & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) && |
322 | ((fctl & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PSPOLL))) | 321 | ((fctl & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PSPOLL))) |
323 | mac_ctl |= B43_TXH_MAC_HWSEQ; | 322 | mac_ctl |= B43_TXH_MAC_HWSEQ; |
324 | if (txctl->flags & IEEE80211_TXCTL_FIRST_FRAGMENT) | 323 | if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT) |
325 | mac_ctl |= B43_TXH_MAC_STMSDU; | 324 | mac_ctl |= B43_TXH_MAC_STMSDU; |
326 | if (phy->type == B43_PHYTYPE_A) | 325 | if (phy->type == B43_PHYTYPE_A) |
327 | mac_ctl |= B43_TXH_MAC_5GHZ; | 326 | mac_ctl |= B43_TXH_MAC_5GHZ; |
328 | if (txctl->flags & IEEE80211_TXCTL_LONG_RETRY_LIMIT) | 327 | if (info->flags & IEEE80211_TX_CTL_LONG_RETRY_LIMIT) |
329 | mac_ctl |= B43_TXH_MAC_LONGFRAME; | 328 | mac_ctl |= B43_TXH_MAC_LONGFRAME; |
330 | 329 | ||
331 | /* Generate the RTS or CTS-to-self frame */ | 330 | /* Generate the RTS or CTS-to-self frame */ |
332 | if ((txctl->flags & IEEE80211_TXCTL_USE_RTS_CTS) || | 331 | if ((info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) || |
333 | (txctl->flags & IEEE80211_TXCTL_USE_CTS_PROTECT)) { | 332 | (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT)) { |
334 | unsigned int len; | 333 | unsigned int len; |
335 | struct ieee80211_hdr *hdr; | 334 | struct ieee80211_hdr *hdr; |
336 | int rts_rate, rts_rate_fb; | 335 | int rts_rate, rts_rate_fb; |
337 | int rts_rate_ofdm, rts_rate_fb_ofdm; | 336 | int rts_rate_ofdm, rts_rate_fb_ofdm; |
338 | struct b43_plcp_hdr6 *plcp; | 337 | struct b43_plcp_hdr6 *plcp; |
338 | struct ieee80211_rate *rts_cts_rate; | ||
339 | 339 | ||
340 | WARN_ON(!txctl->rts_cts_rate); | 340 | rts_cts_rate = ieee80211_get_rts_cts_rate(dev->wl->hw, info); |
341 | rts_rate = txctl->rts_cts_rate ? txctl->rts_cts_rate->hw_value : B43_CCK_RATE_1MB; | 341 | |
342 | rts_rate = rts_cts_rate ? rts_cts_rate->hw_value : B43_CCK_RATE_1MB; | ||
342 | rts_rate_ofdm = b43_is_ofdm_rate(rts_rate); | 343 | rts_rate_ofdm = b43_is_ofdm_rate(rts_rate); |
343 | rts_rate_fb = b43_calc_fallback_rate(rts_rate); | 344 | rts_rate_fb = b43_calc_fallback_rate(rts_rate); |
344 | rts_rate_fb_ofdm = b43_is_ofdm_rate(rts_rate_fb); | 345 | rts_rate_fb_ofdm = b43_is_ofdm_rate(rts_rate_fb); |
345 | 346 | ||
346 | if (txctl->flags & IEEE80211_TXCTL_USE_CTS_PROTECT) { | 347 | if (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) { |
347 | struct ieee80211_cts *cts; | 348 | struct ieee80211_cts *cts; |
348 | 349 | ||
349 | if (b43_is_old_txhdr_format(dev)) { | 350 | if (b43_is_old_txhdr_format(dev)) { |
@@ -353,9 +354,9 @@ int b43_generate_txhdr(struct b43_wldev *dev, | |||
353 | cts = (struct ieee80211_cts *) | 354 | cts = (struct ieee80211_cts *) |
354 | (txhdr->new_format.rts_frame); | 355 | (txhdr->new_format.rts_frame); |
355 | } | 356 | } |
356 | ieee80211_ctstoself_get(dev->wl->hw, txctl->vif, | 357 | ieee80211_ctstoself_get(dev->wl->hw, info->control.vif, |
357 | fragment_data, fragment_len, | 358 | fragment_data, fragment_len, |
358 | txctl, cts); | 359 | info, cts); |
359 | mac_ctl |= B43_TXH_MAC_SENDCTS; | 360 | mac_ctl |= B43_TXH_MAC_SENDCTS; |
360 | len = sizeof(struct ieee80211_cts); | 361 | len = sizeof(struct ieee80211_cts); |
361 | } else { | 362 | } else { |
@@ -368,9 +369,9 @@ int b43_generate_txhdr(struct b43_wldev *dev, | |||
368 | rts = (struct ieee80211_rts *) | 369 | rts = (struct ieee80211_rts *) |
369 | (txhdr->new_format.rts_frame); | 370 | (txhdr->new_format.rts_frame); |
370 | } | 371 | } |
371 | ieee80211_rts_get(dev->wl->hw, txctl->vif, | 372 | ieee80211_rts_get(dev->wl->hw, info->control.vif, |
372 | fragment_data, fragment_len, | 373 | fragment_data, fragment_len, |
373 | txctl, rts); | 374 | info, rts); |
374 | mac_ctl |= B43_TXH_MAC_SENDRTS; | 375 | mac_ctl |= B43_TXH_MAC_SENDRTS; |
375 | len = sizeof(struct ieee80211_rts); | 376 | len = sizeof(struct ieee80211_rts); |
376 | } | 377 | } |
@@ -684,27 +685,27 @@ void b43_handle_txstatus(struct b43_wldev *dev, | |||
684 | /* Fill out the mac80211 TXstatus report based on the b43-specific | 685 | /* Fill out the mac80211 TXstatus report based on the b43-specific |
685 | * txstatus report data. This returns a boolean whether the frame was | 686 | * txstatus report data. This returns a boolean whether the frame was |
686 | * successfully transmitted. */ | 687 | * successfully transmitted. */ |
687 | bool b43_fill_txstatus_report(struct ieee80211_tx_status *report, | 688 | bool b43_fill_txstatus_report(struct ieee80211_tx_info *report, |
688 | const struct b43_txstatus *status) | 689 | const struct b43_txstatus *status) |
689 | { | 690 | { |
690 | bool frame_success = 1; | 691 | bool frame_success = 1; |
691 | 692 | ||
692 | if (status->acked) { | 693 | if (status->acked) { |
693 | /* The frame was ACKed. */ | 694 | /* The frame was ACKed. */ |
694 | report->flags |= IEEE80211_TX_STATUS_ACK; | 695 | report->flags |= IEEE80211_TX_STAT_ACK; |
695 | } else { | 696 | } else { |
696 | /* The frame was not ACKed... */ | 697 | /* The frame was not ACKed... */ |
697 | if (!(report->control.flags & IEEE80211_TXCTL_NO_ACK)) { | 698 | if (!(report->flags & IEEE80211_TX_CTL_NO_ACK)) { |
698 | /* ...but we expected an ACK. */ | 699 | /* ...but we expected an ACK. */ |
699 | frame_success = 0; | 700 | frame_success = 0; |
700 | report->excessive_retries = 1; | 701 | report->status.excessive_retries = 1; |
701 | } | 702 | } |
702 | } | 703 | } |
703 | if (status->frame_count == 0) { | 704 | if (status->frame_count == 0) { |
704 | /* The frame was not transmitted at all. */ | 705 | /* The frame was not transmitted at all. */ |
705 | report->retry_count = 0; | 706 | report->status.retry_count = 0; |
706 | } else | 707 | } else |
707 | report->retry_count = status->frame_count - 1; | 708 | report->status.retry_count = status->frame_count - 1; |
708 | 709 | ||
709 | return frame_success; | 710 | return frame_success; |
710 | } | 711 | } |
diff --git a/drivers/net/wireless/b43/xmit.h b/drivers/net/wireless/b43/xmit.h index b05f44e0d626..0215faf47541 100644 --- a/drivers/net/wireless/b43/xmit.h +++ b/drivers/net/wireless/b43/xmit.h | |||
@@ -178,7 +178,7 @@ int b43_generate_txhdr(struct b43_wldev *dev, | |||
178 | u8 * txhdr, | 178 | u8 * txhdr, |
179 | const unsigned char *fragment_data, | 179 | const unsigned char *fragment_data, |
180 | unsigned int fragment_len, | 180 | unsigned int fragment_len, |
181 | const struct ieee80211_tx_control *txctl, u16 cookie); | 181 | const struct ieee80211_tx_info *txctl, u16 cookie); |
182 | 182 | ||
183 | /* Transmit Status */ | 183 | /* Transmit Status */ |
184 | struct b43_txstatus { | 184 | struct b43_txstatus { |
@@ -294,7 +294,7 @@ void b43_rx(struct b43_wldev *dev, struct sk_buff *skb, const void *_rxhdr); | |||
294 | 294 | ||
295 | void b43_handle_txstatus(struct b43_wldev *dev, | 295 | void b43_handle_txstatus(struct b43_wldev *dev, |
296 | const struct b43_txstatus *status); | 296 | const struct b43_txstatus *status); |
297 | bool b43_fill_txstatus_report(struct ieee80211_tx_status *report, | 297 | bool b43_fill_txstatus_report(struct ieee80211_tx_info *report, |
298 | const struct b43_txstatus *status); | 298 | const struct b43_txstatus *status); |
299 | 299 | ||
300 | void b43_tx_suspend(struct b43_wldev *dev); | 300 | void b43_tx_suspend(struct b43_wldev *dev); |
diff --git a/drivers/net/wireless/b43legacy/dma.c b/drivers/net/wireless/b43legacy/dma.c index d6686f713b6d..33cc256c5baf 100644 --- a/drivers/net/wireless/b43legacy/dma.c +++ b/drivers/net/wireless/b43legacy/dma.c | |||
@@ -1205,10 +1205,10 @@ struct b43legacy_dmaring *parse_cookie(struct b43legacy_wldev *dev, | |||
1205 | } | 1205 | } |
1206 | 1206 | ||
1207 | static int dma_tx_fragment(struct b43legacy_dmaring *ring, | 1207 | static int dma_tx_fragment(struct b43legacy_dmaring *ring, |
1208 | struct sk_buff *skb, | 1208 | struct sk_buff *skb) |
1209 | struct ieee80211_tx_control *ctl) | ||
1210 | { | 1209 | { |
1211 | const struct b43legacy_dma_ops *ops = ring->ops; | 1210 | const struct b43legacy_dma_ops *ops = ring->ops; |
1211 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
1212 | u8 *header; | 1212 | u8 *header; |
1213 | int slot, old_top_slot, old_used_slots; | 1213 | int slot, old_top_slot, old_used_slots; |
1214 | int err; | 1214 | int err; |
@@ -1231,7 +1231,7 @@ static int dma_tx_fragment(struct b43legacy_dmaring *ring, | |||
1231 | header = &(ring->txhdr_cache[slot * sizeof( | 1231 | header = &(ring->txhdr_cache[slot * sizeof( |
1232 | struct b43legacy_txhdr_fw3)]); | 1232 | struct b43legacy_txhdr_fw3)]); |
1233 | err = b43legacy_generate_txhdr(ring->dev, header, | 1233 | err = b43legacy_generate_txhdr(ring->dev, header, |
1234 | skb->data, skb->len, ctl, | 1234 | skb->data, skb->len, info, |
1235 | generate_cookie(ring, slot)); | 1235 | generate_cookie(ring, slot)); |
1236 | if (unlikely(err)) { | 1236 | if (unlikely(err)) { |
1237 | ring->current_slot = old_top_slot; | 1237 | ring->current_slot = old_top_slot; |
@@ -1255,7 +1255,6 @@ static int dma_tx_fragment(struct b43legacy_dmaring *ring, | |||
1255 | desc = ops->idx2desc(ring, slot, &meta); | 1255 | desc = ops->idx2desc(ring, slot, &meta); |
1256 | memset(meta, 0, sizeof(*meta)); | 1256 | memset(meta, 0, sizeof(*meta)); |
1257 | 1257 | ||
1258 | memcpy(&meta->txstat.control, ctl, sizeof(*ctl)); | ||
1259 | meta->skb = skb; | 1258 | meta->skb = skb; |
1260 | meta->is_last_fragment = 1; | 1259 | meta->is_last_fragment = 1; |
1261 | 1260 | ||
@@ -1323,14 +1322,13 @@ int should_inject_overflow(struct b43legacy_dmaring *ring) | |||
1323 | } | 1322 | } |
1324 | 1323 | ||
1325 | int b43legacy_dma_tx(struct b43legacy_wldev *dev, | 1324 | int b43legacy_dma_tx(struct b43legacy_wldev *dev, |
1326 | struct sk_buff *skb, | 1325 | struct sk_buff *skb) |
1327 | struct ieee80211_tx_control *ctl) | ||
1328 | { | 1326 | { |
1329 | struct b43legacy_dmaring *ring; | 1327 | struct b43legacy_dmaring *ring; |
1330 | int err = 0; | 1328 | int err = 0; |
1331 | unsigned long flags; | 1329 | unsigned long flags; |
1332 | 1330 | ||
1333 | ring = priority_to_txring(dev, ctl->queue); | 1331 | ring = priority_to_txring(dev, skb_get_queue_mapping(skb)); |
1334 | spin_lock_irqsave(&ring->lock, flags); | 1332 | spin_lock_irqsave(&ring->lock, flags); |
1335 | B43legacy_WARN_ON(!ring->tx); | 1333 | B43legacy_WARN_ON(!ring->tx); |
1336 | if (unlikely(free_slots(ring) < SLOTS_PER_PACKET)) { | 1334 | if (unlikely(free_slots(ring) < SLOTS_PER_PACKET)) { |
@@ -1343,7 +1341,7 @@ int b43legacy_dma_tx(struct b43legacy_wldev *dev, | |||
1343 | * That would be a mac80211 bug. */ | 1341 | * That would be a mac80211 bug. */ |
1344 | B43legacy_BUG_ON(ring->stopped); | 1342 | B43legacy_BUG_ON(ring->stopped); |
1345 | 1343 | ||
1346 | err = dma_tx_fragment(ring, skb, ctl); | 1344 | err = dma_tx_fragment(ring, skb); |
1347 | if (unlikely(err == -ENOKEY)) { | 1345 | if (unlikely(err == -ENOKEY)) { |
1348 | /* Drop this packet, as we don't have the encryption key | 1346 | /* Drop this packet, as we don't have the encryption key |
1349 | * anymore and must not transmit it unencrypted. */ | 1347 | * anymore and must not transmit it unencrypted. */ |
@@ -1401,26 +1399,29 @@ void b43legacy_dma_handle_txstatus(struct b43legacy_wldev *dev, | |||
1401 | 1); | 1399 | 1); |
1402 | 1400 | ||
1403 | if (meta->is_last_fragment) { | 1401 | if (meta->is_last_fragment) { |
1404 | B43legacy_WARN_ON(!meta->skb); | 1402 | struct ieee80211_tx_info *info; |
1403 | BUG_ON(!meta->skb); | ||
1404 | info = IEEE80211_SKB_CB(meta->skb); | ||
1405 | /* Call back to inform the ieee80211 subsystem about the | 1405 | /* Call back to inform the ieee80211 subsystem about the |
1406 | * status of the transmission. | 1406 | * status of the transmission. |
1407 | * Some fields of txstat are already filled in dma_tx(). | 1407 | * Some fields of txstat are already filled in dma_tx(). |
1408 | */ | 1408 | */ |
1409 | |||
1410 | memset(&info->status, 0, sizeof(info->status)); | ||
1411 | |||
1409 | if (status->acked) { | 1412 | if (status->acked) { |
1410 | meta->txstat.flags |= IEEE80211_TX_STATUS_ACK; | 1413 | info->flags |= IEEE80211_TX_STAT_ACK; |
1411 | } else { | 1414 | } else { |
1412 | if (!(meta->txstat.control.flags | 1415 | if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) |
1413 | & IEEE80211_TXCTL_NO_ACK)) | 1416 | info->status.excessive_retries = 1; |
1414 | meta->txstat.excessive_retries = 1; | ||
1415 | } | 1417 | } |
1416 | if (status->frame_count == 0) { | 1418 | if (status->frame_count == 0) { |
1417 | /* The frame was not transmitted at all. */ | 1419 | /* The frame was not transmitted at all. */ |
1418 | meta->txstat.retry_count = 0; | 1420 | info->status.retry_count = 0; |
1419 | } else | 1421 | } else |
1420 | meta->txstat.retry_count = status->frame_count | 1422 | info->status.retry_count = status->frame_count |
1421 | - 1; | 1423 | - 1; |
1422 | ieee80211_tx_status_irqsafe(dev->wl->hw, meta->skb, | 1424 | ieee80211_tx_status_irqsafe(dev->wl->hw, meta->skb); |
1423 | &(meta->txstat)); | ||
1424 | /* skb is freed by ieee80211_tx_status_irqsafe() */ | 1425 | /* skb is freed by ieee80211_tx_status_irqsafe() */ |
1425 | meta->skb = NULL; | 1426 | meta->skb = NULL; |
1426 | } else { | 1427 | } else { |
diff --git a/drivers/net/wireless/b43legacy/dma.h b/drivers/net/wireless/b43legacy/dma.h index 2dd488c5be2d..2f186003c31e 100644 --- a/drivers/net/wireless/b43legacy/dma.h +++ b/drivers/net/wireless/b43legacy/dma.h | |||
@@ -195,7 +195,6 @@ struct b43legacy_dmadesc_meta { | |||
195 | dma_addr_t dmaaddr; | 195 | dma_addr_t dmaaddr; |
196 | /* ieee80211 TX status. Only used once per 802.11 frag. */ | 196 | /* ieee80211 TX status. Only used once per 802.11 frag. */ |
197 | bool is_last_fragment; | 197 | bool is_last_fragment; |
198 | struct ieee80211_tx_status txstat; | ||
199 | }; | 198 | }; |
200 | 199 | ||
201 | struct b43legacy_dmaring; | 200 | struct b43legacy_dmaring; |
@@ -297,8 +296,7 @@ void b43legacy_dma_get_tx_stats(struct b43legacy_wldev *dev, | |||
297 | struct ieee80211_tx_queue_stats *stats); | 296 | struct ieee80211_tx_queue_stats *stats); |
298 | 297 | ||
299 | int b43legacy_dma_tx(struct b43legacy_wldev *dev, | 298 | int b43legacy_dma_tx(struct b43legacy_wldev *dev, |
300 | struct sk_buff *skb, | 299 | struct sk_buff *skb); |
301 | struct ieee80211_tx_control *ctl); | ||
302 | void b43legacy_dma_handle_txstatus(struct b43legacy_wldev *dev, | 300 | void b43legacy_dma_handle_txstatus(struct b43legacy_wldev *dev, |
303 | const struct b43legacy_txstatus *status); | 301 | const struct b43legacy_txstatus *status); |
304 | 302 | ||
@@ -323,8 +321,7 @@ void b43legacy_dma_get_tx_stats(struct b43legacy_wldev *dev, | |||
323 | } | 321 | } |
324 | static inline | 322 | static inline |
325 | int b43legacy_dma_tx(struct b43legacy_wldev *dev, | 323 | int b43legacy_dma_tx(struct b43legacy_wldev *dev, |
326 | struct sk_buff *skb, | 324 | struct sk_buff *skb) |
327 | struct ieee80211_tx_control *ctl) | ||
328 | { | 325 | { |
329 | return 0; | 326 | return 0; |
330 | } | 327 | } |
diff --git a/drivers/net/wireless/b43legacy/main.c b/drivers/net/wireless/b43legacy/main.c index 7755c59e0803..f706ca65f159 100644 --- a/drivers/net/wireless/b43legacy/main.c +++ b/drivers/net/wireless/b43legacy/main.c | |||
@@ -2358,8 +2358,7 @@ static int b43legacy_rng_init(struct b43legacy_wl *wl) | |||
2358 | } | 2358 | } |
2359 | 2359 | ||
2360 | static int b43legacy_op_tx(struct ieee80211_hw *hw, | 2360 | static int b43legacy_op_tx(struct ieee80211_hw *hw, |
2361 | struct sk_buff *skb, | 2361 | struct sk_buff *skb) |
2362 | struct ieee80211_tx_control *ctl) | ||
2363 | { | 2362 | { |
2364 | struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw); | 2363 | struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw); |
2365 | struct b43legacy_wldev *dev = wl->current_dev; | 2364 | struct b43legacy_wldev *dev = wl->current_dev; |
@@ -2373,10 +2372,10 @@ static int b43legacy_op_tx(struct ieee80211_hw *hw, | |||
2373 | /* DMA-TX is done without a global lock. */ | 2372 | /* DMA-TX is done without a global lock. */ |
2374 | if (b43legacy_using_pio(dev)) { | 2373 | if (b43legacy_using_pio(dev)) { |
2375 | spin_lock_irqsave(&wl->irq_lock, flags); | 2374 | spin_lock_irqsave(&wl->irq_lock, flags); |
2376 | err = b43legacy_pio_tx(dev, skb, ctl); | 2375 | err = b43legacy_pio_tx(dev, skb); |
2377 | spin_unlock_irqrestore(&wl->irq_lock, flags); | 2376 | spin_unlock_irqrestore(&wl->irq_lock, flags); |
2378 | } else | 2377 | } else |
2379 | err = b43legacy_dma_tx(dev, skb, ctl); | 2378 | err = b43legacy_dma_tx(dev, skb); |
2380 | out: | 2379 | out: |
2381 | if (unlikely(err)) | 2380 | if (unlikely(err)) |
2382 | return NETDEV_TX_BUSY; | 2381 | return NETDEV_TX_BUSY; |
@@ -2794,7 +2793,6 @@ static int b43legacy_wireless_core_start(struct b43legacy_wldev *dev) | |||
2794 | /* Start data flow (TX/RX) */ | 2793 | /* Start data flow (TX/RX) */ |
2795 | b43legacy_mac_enable(dev); | 2794 | b43legacy_mac_enable(dev); |
2796 | b43legacy_interrupt_enable(dev, dev->irq_savedstate); | 2795 | b43legacy_interrupt_enable(dev, dev->irq_savedstate); |
2797 | ieee80211_start_queues(dev->wl->hw); | ||
2798 | 2796 | ||
2799 | /* Start maintenance work */ | 2797 | /* Start maintenance work */ |
2800 | b43legacy_periodic_tasks_setup(dev); | 2798 | b43legacy_periodic_tasks_setup(dev); |
@@ -3410,7 +3408,7 @@ static int b43legacy_op_beacon_set_tim(struct ieee80211_hw *hw, | |||
3410 | * field, but that would probably require resizing and moving of data | 3408 | * field, but that would probably require resizing and moving of data |
3411 | * within the beacon template. Simply request a new beacon and let | 3409 | * within the beacon template. Simply request a new beacon and let |
3412 | * mac80211 do the hard work. */ | 3410 | * mac80211 do the hard work. */ |
3413 | beacon = ieee80211_beacon_get(hw, wl->vif, NULL); | 3411 | beacon = ieee80211_beacon_get(hw, wl->vif); |
3414 | if (unlikely(!beacon)) | 3412 | if (unlikely(!beacon)) |
3415 | return -ENOMEM; | 3413 | return -ENOMEM; |
3416 | spin_lock_irqsave(&wl->irq_lock, flags); | 3414 | spin_lock_irqsave(&wl->irq_lock, flags); |
@@ -3421,8 +3419,7 @@ static int b43legacy_op_beacon_set_tim(struct ieee80211_hw *hw, | |||
3421 | } | 3419 | } |
3422 | 3420 | ||
3423 | static int b43legacy_op_ibss_beacon_update(struct ieee80211_hw *hw, | 3421 | static int b43legacy_op_ibss_beacon_update(struct ieee80211_hw *hw, |
3424 | struct sk_buff *beacon, | 3422 | struct sk_buff *beacon) |
3425 | struct ieee80211_tx_control *ctl) | ||
3426 | { | 3423 | { |
3427 | struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw); | 3424 | struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw); |
3428 | unsigned long flags; | 3425 | unsigned long flags; |
diff --git a/drivers/net/wireless/b43legacy/pio.c b/drivers/net/wireless/b43legacy/pio.c index 8d3d27d3cd67..a86c7647fa2d 100644 --- a/drivers/net/wireless/b43legacy/pio.c +++ b/drivers/net/wireless/b43legacy/pio.c | |||
@@ -196,7 +196,7 @@ static int pio_tx_write_fragment(struct b43legacy_pioqueue *queue, | |||
196 | B43legacy_WARN_ON(skb_shinfo(skb)->nr_frags != 0); | 196 | B43legacy_WARN_ON(skb_shinfo(skb)->nr_frags != 0); |
197 | err = b43legacy_generate_txhdr(queue->dev, | 197 | err = b43legacy_generate_txhdr(queue->dev, |
198 | txhdr, skb->data, skb->len, | 198 | txhdr, skb->data, skb->len, |
199 | &packet->txstat.control, | 199 | IEEE80211_SKB_CB(skb), |
200 | generate_cookie(queue, packet)); | 200 | generate_cookie(queue, packet)); |
201 | if (err) | 201 | if (err) |
202 | return err; | 202 | return err; |
@@ -463,8 +463,7 @@ err_destroy0: | |||
463 | } | 463 | } |
464 | 464 | ||
465 | int b43legacy_pio_tx(struct b43legacy_wldev *dev, | 465 | int b43legacy_pio_tx(struct b43legacy_wldev *dev, |
466 | struct sk_buff *skb, | 466 | struct sk_buff *skb) |
467 | struct ieee80211_tx_control *ctl) | ||
468 | { | 467 | { |
469 | struct b43legacy_pioqueue *queue = dev->pio.queue1; | 468 | struct b43legacy_pioqueue *queue = dev->pio.queue1; |
470 | struct b43legacy_pio_txpacket *packet; | 469 | struct b43legacy_pio_txpacket *packet; |
@@ -476,9 +475,6 @@ int b43legacy_pio_tx(struct b43legacy_wldev *dev, | |||
476 | list); | 475 | list); |
477 | packet->skb = skb; | 476 | packet->skb = skb; |
478 | 477 | ||
479 | memset(&packet->txstat, 0, sizeof(packet->txstat)); | ||
480 | memcpy(&packet->txstat.control, ctl, sizeof(*ctl)); | ||
481 | |||
482 | list_move_tail(&packet->list, &queue->txqueue); | 478 | list_move_tail(&packet->list, &queue->txqueue); |
483 | queue->nr_txfree--; | 479 | queue->nr_txfree--; |
484 | queue->nr_tx_packets++; | 480 | queue->nr_tx_packets++; |
@@ -494,6 +490,7 @@ void b43legacy_pio_handle_txstatus(struct b43legacy_wldev *dev, | |||
494 | { | 490 | { |
495 | struct b43legacy_pioqueue *queue; | 491 | struct b43legacy_pioqueue *queue; |
496 | struct b43legacy_pio_txpacket *packet; | 492 | struct b43legacy_pio_txpacket *packet; |
493 | struct ieee80211_tx_info *info; | ||
497 | 494 | ||
498 | queue = parse_cookie(dev, status->cookie, &packet); | 495 | queue = parse_cookie(dev, status->cookie, &packet); |
499 | B43legacy_WARN_ON(!queue); | 496 | B43legacy_WARN_ON(!queue); |
@@ -505,11 +502,13 @@ void b43legacy_pio_handle_txstatus(struct b43legacy_wldev *dev, | |||
505 | queue->tx_devq_used -= (packet->skb->len + | 502 | queue->tx_devq_used -= (packet->skb->len + |
506 | sizeof(struct b43legacy_txhdr_fw3)); | 503 | sizeof(struct b43legacy_txhdr_fw3)); |
507 | 504 | ||
505 | info = IEEE80211_SKB_CB(packet->skb); | ||
506 | memset(&info->status, 0, sizeof(info->status)); | ||
507 | |||
508 | if (status->acked) | 508 | if (status->acked) |
509 | packet->txstat.flags |= IEEE80211_TX_STATUS_ACK; | 509 | info->flags |= IEEE80211_TX_STAT_ACK; |
510 | packet->txstat.retry_count = status->frame_count - 1; | 510 | info->status.retry_count = status->frame_count - 1; |
511 | ieee80211_tx_status_irqsafe(dev->wl->hw, packet->skb, | 511 | ieee80211_tx_status_irqsafe(dev->wl->hw, packet->skb); |
512 | &(packet->txstat)); | ||
513 | packet->skb = NULL; | 512 | packet->skb = NULL; |
514 | 513 | ||
515 | free_txpacket(packet, 1); | 514 | free_txpacket(packet, 1); |
diff --git a/drivers/net/wireless/b43legacy/pio.h b/drivers/net/wireless/b43legacy/pio.h index 5bfed0c40030..464fec05a06d 100644 --- a/drivers/net/wireless/b43legacy/pio.h +++ b/drivers/net/wireless/b43legacy/pio.h | |||
@@ -41,7 +41,6 @@ struct b43legacy_xmitstatus; | |||
41 | struct b43legacy_pio_txpacket { | 41 | struct b43legacy_pio_txpacket { |
42 | struct b43legacy_pioqueue *queue; | 42 | struct b43legacy_pioqueue *queue; |
43 | struct sk_buff *skb; | 43 | struct sk_buff *skb; |
44 | struct ieee80211_tx_status txstat; | ||
45 | struct list_head list; | 44 | struct list_head list; |
46 | }; | 45 | }; |
47 | 46 | ||
@@ -104,8 +103,7 @@ int b43legacy_pio_init(struct b43legacy_wldev *dev); | |||
104 | void b43legacy_pio_free(struct b43legacy_wldev *dev); | 103 | void b43legacy_pio_free(struct b43legacy_wldev *dev); |
105 | 104 | ||
106 | int b43legacy_pio_tx(struct b43legacy_wldev *dev, | 105 | int b43legacy_pio_tx(struct b43legacy_wldev *dev, |
107 | struct sk_buff *skb, | 106 | struct sk_buff *skb); |
108 | struct ieee80211_tx_control *ctl); | ||
109 | void b43legacy_pio_handle_txstatus(struct b43legacy_wldev *dev, | 107 | void b43legacy_pio_handle_txstatus(struct b43legacy_wldev *dev, |
110 | const struct b43legacy_txstatus *status); | 108 | const struct b43legacy_txstatus *status); |
111 | void b43legacy_pio_get_tx_stats(struct b43legacy_wldev *dev, | 109 | void b43legacy_pio_get_tx_stats(struct b43legacy_wldev *dev, |
@@ -132,8 +130,7 @@ void b43legacy_pio_free(struct b43legacy_wldev *dev) | |||
132 | } | 130 | } |
133 | static inline | 131 | static inline |
134 | int b43legacy_pio_tx(struct b43legacy_wldev *dev, | 132 | int b43legacy_pio_tx(struct b43legacy_wldev *dev, |
135 | struct sk_buff *skb, | 133 | struct sk_buff *skb) |
136 | struct ieee80211_tx_control *ctl) | ||
137 | { | 134 | { |
138 | return 0; | 135 | return 0; |
139 | } | 136 | } |
diff --git a/drivers/net/wireless/b43legacy/xmit.c b/drivers/net/wireless/b43legacy/xmit.c index bed9e041d6c5..82dc04d59446 100644 --- a/drivers/net/wireless/b43legacy/xmit.c +++ b/drivers/net/wireless/b43legacy/xmit.c | |||
@@ -188,11 +188,11 @@ static int generate_txhdr_fw3(struct b43legacy_wldev *dev, | |||
188 | struct b43legacy_txhdr_fw3 *txhdr, | 188 | struct b43legacy_txhdr_fw3 *txhdr, |
189 | const unsigned char *fragment_data, | 189 | const unsigned char *fragment_data, |
190 | unsigned int fragment_len, | 190 | unsigned int fragment_len, |
191 | const struct ieee80211_tx_control *txctl, | 191 | const struct ieee80211_tx_info *info, |
192 | u16 cookie) | 192 | u16 cookie) |
193 | { | 193 | { |
194 | const struct ieee80211_hdr *wlhdr; | 194 | const struct ieee80211_hdr *wlhdr; |
195 | int use_encryption = (!(txctl->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT)); | 195 | int use_encryption = (!(info->flags & IEEE80211_TX_CTL_DO_NOT_ENCRYPT)); |
196 | u16 fctl; | 196 | u16 fctl; |
197 | u8 rate; | 197 | u8 rate; |
198 | struct ieee80211_rate *rate_fb; | 198 | struct ieee80211_rate *rate_fb; |
@@ -201,15 +201,18 @@ static int generate_txhdr_fw3(struct b43legacy_wldev *dev, | |||
201 | unsigned int plcp_fragment_len; | 201 | unsigned int plcp_fragment_len; |
202 | u32 mac_ctl = 0; | 202 | u32 mac_ctl = 0; |
203 | u16 phy_ctl = 0; | 203 | u16 phy_ctl = 0; |
204 | struct ieee80211_rate *tx_rate; | ||
204 | 205 | ||
205 | wlhdr = (const struct ieee80211_hdr *)fragment_data; | 206 | wlhdr = (const struct ieee80211_hdr *)fragment_data; |
206 | fctl = le16_to_cpu(wlhdr->frame_control); | 207 | fctl = le16_to_cpu(wlhdr->frame_control); |
207 | 208 | ||
208 | memset(txhdr, 0, sizeof(*txhdr)); | 209 | memset(txhdr, 0, sizeof(*txhdr)); |
209 | 210 | ||
210 | rate = txctl->tx_rate->hw_value; | 211 | tx_rate = ieee80211_get_tx_rate(dev->wl->hw, info); |
212 | |||
213 | rate = tx_rate->hw_value; | ||
211 | rate_ofdm = b43legacy_is_ofdm_rate(rate); | 214 | rate_ofdm = b43legacy_is_ofdm_rate(rate); |
212 | rate_fb = txctl->alt_retry_rate ? : txctl->tx_rate; | 215 | rate_fb = ieee80211_get_alt_retry_rate(dev->wl->hw, info) ? : tx_rate; |
213 | rate_fb_ofdm = b43legacy_is_ofdm_rate(rate_fb->hw_value); | 216 | rate_fb_ofdm = b43legacy_is_ofdm_rate(rate_fb->hw_value); |
214 | 217 | ||
215 | txhdr->mac_frame_ctl = wlhdr->frame_control; | 218 | txhdr->mac_frame_ctl = wlhdr->frame_control; |
@@ -225,14 +228,14 @@ static int generate_txhdr_fw3(struct b43legacy_wldev *dev, | |||
225 | txhdr->dur_fb = wlhdr->duration_id; | 228 | txhdr->dur_fb = wlhdr->duration_id; |
226 | } else { | 229 | } else { |
227 | txhdr->dur_fb = ieee80211_generic_frame_duration(dev->wl->hw, | 230 | txhdr->dur_fb = ieee80211_generic_frame_duration(dev->wl->hw, |
228 | txctl->vif, | 231 | info->control.vif, |
229 | fragment_len, | 232 | fragment_len, |
230 | rate_fb); | 233 | rate_fb); |
231 | } | 234 | } |
232 | 235 | ||
233 | plcp_fragment_len = fragment_len + FCS_LEN; | 236 | plcp_fragment_len = fragment_len + FCS_LEN; |
234 | if (use_encryption) { | 237 | if (use_encryption) { |
235 | u8 key_idx = txctl->hw_key->hw_key_idx; | 238 | u8 key_idx = info->control.hw_key->hw_key_idx; |
236 | struct b43legacy_key *key; | 239 | struct b43legacy_key *key; |
237 | int wlhdr_len; | 240 | int wlhdr_len; |
238 | size_t iv_len; | 241 | size_t iv_len; |
@@ -242,7 +245,7 @@ static int generate_txhdr_fw3(struct b43legacy_wldev *dev, | |||
242 | 245 | ||
243 | if (key->enabled) { | 246 | if (key->enabled) { |
244 | /* Hardware appends ICV. */ | 247 | /* Hardware appends ICV. */ |
245 | plcp_fragment_len += txctl->icv_len; | 248 | plcp_fragment_len += info->control.icv_len; |
246 | 249 | ||
247 | key_idx = b43legacy_kidx_to_fw(dev, key_idx); | 250 | key_idx = b43legacy_kidx_to_fw(dev, key_idx); |
248 | mac_ctl |= (key_idx << B43legacy_TX4_MAC_KEYIDX_SHIFT) & | 251 | mac_ctl |= (key_idx << B43legacy_TX4_MAC_KEYIDX_SHIFT) & |
@@ -251,7 +254,7 @@ static int generate_txhdr_fw3(struct b43legacy_wldev *dev, | |||
251 | B43legacy_TX4_MAC_KEYALG_SHIFT) & | 254 | B43legacy_TX4_MAC_KEYALG_SHIFT) & |
252 | B43legacy_TX4_MAC_KEYALG; | 255 | B43legacy_TX4_MAC_KEYALG; |
253 | wlhdr_len = ieee80211_get_hdrlen(fctl); | 256 | wlhdr_len = ieee80211_get_hdrlen(fctl); |
254 | iv_len = min((size_t)txctl->iv_len, | 257 | iv_len = min((size_t)info->control.iv_len, |
255 | ARRAY_SIZE(txhdr->iv)); | 258 | ARRAY_SIZE(txhdr->iv)); |
256 | memcpy(txhdr->iv, ((u8 *)wlhdr) + wlhdr_len, iv_len); | 259 | memcpy(txhdr->iv, ((u8 *)wlhdr) + wlhdr_len, iv_len); |
257 | } else { | 260 | } else { |
@@ -275,7 +278,7 @@ static int generate_txhdr_fw3(struct b43legacy_wldev *dev, | |||
275 | phy_ctl |= B43legacy_TX4_PHY_OFDM; | 278 | phy_ctl |= B43legacy_TX4_PHY_OFDM; |
276 | if (dev->short_preamble) | 279 | if (dev->short_preamble) |
277 | phy_ctl |= B43legacy_TX4_PHY_SHORTPRMBL; | 280 | phy_ctl |= B43legacy_TX4_PHY_SHORTPRMBL; |
278 | switch (txctl->antenna_sel_tx) { | 281 | switch (info->antenna_sel_tx) { |
279 | case 0: | 282 | case 0: |
280 | phy_ctl |= B43legacy_TX4_PHY_ANTLAST; | 283 | phy_ctl |= B43legacy_TX4_PHY_ANTLAST; |
281 | break; | 284 | break; |
@@ -290,21 +293,21 @@ static int generate_txhdr_fw3(struct b43legacy_wldev *dev, | |||
290 | } | 293 | } |
291 | 294 | ||
292 | /* MAC control */ | 295 | /* MAC control */ |
293 | if (!(txctl->flags & IEEE80211_TXCTL_NO_ACK)) | 296 | if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) |
294 | mac_ctl |= B43legacy_TX4_MAC_ACK; | 297 | mac_ctl |= B43legacy_TX4_MAC_ACK; |
295 | if (!(((fctl & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) && | 298 | if (!(((fctl & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) && |
296 | ((fctl & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PSPOLL))) | 299 | ((fctl & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PSPOLL))) |
297 | mac_ctl |= B43legacy_TX4_MAC_HWSEQ; | 300 | mac_ctl |= B43legacy_TX4_MAC_HWSEQ; |
298 | if (txctl->flags & IEEE80211_TXCTL_FIRST_FRAGMENT) | 301 | if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT) |
299 | mac_ctl |= B43legacy_TX4_MAC_STMSDU; | 302 | mac_ctl |= B43legacy_TX4_MAC_STMSDU; |
300 | if (rate_fb_ofdm) | 303 | if (rate_fb_ofdm) |
301 | mac_ctl |= B43legacy_TX4_MAC_FALLBACKOFDM; | 304 | mac_ctl |= B43legacy_TX4_MAC_FALLBACKOFDM; |
302 | if (txctl->flags & IEEE80211_TXCTL_LONG_RETRY_LIMIT) | 305 | if (info->flags & IEEE80211_TX_CTL_LONG_RETRY_LIMIT) |
303 | mac_ctl |= B43legacy_TX4_MAC_LONGFRAME; | 306 | mac_ctl |= B43legacy_TX4_MAC_LONGFRAME; |
304 | 307 | ||
305 | /* Generate the RTS or CTS-to-self frame */ | 308 | /* Generate the RTS or CTS-to-self frame */ |
306 | if ((txctl->flags & IEEE80211_TXCTL_USE_RTS_CTS) || | 309 | if ((info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) || |
307 | (txctl->flags & IEEE80211_TXCTL_USE_CTS_PROTECT)) { | 310 | (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT)) { |
308 | unsigned int len; | 311 | unsigned int len; |
309 | struct ieee80211_hdr *hdr; | 312 | struct ieee80211_hdr *hdr; |
310 | int rts_rate; | 313 | int rts_rate; |
@@ -312,26 +315,26 @@ static int generate_txhdr_fw3(struct b43legacy_wldev *dev, | |||
312 | int rts_rate_ofdm; | 315 | int rts_rate_ofdm; |
313 | int rts_rate_fb_ofdm; | 316 | int rts_rate_fb_ofdm; |
314 | 317 | ||
315 | rts_rate = txctl->rts_cts_rate->hw_value; | 318 | rts_rate = ieee80211_get_rts_cts_rate(dev->wl->hw, info)->hw_value; |
316 | rts_rate_ofdm = b43legacy_is_ofdm_rate(rts_rate); | 319 | rts_rate_ofdm = b43legacy_is_ofdm_rate(rts_rate); |
317 | rts_rate_fb = b43legacy_calc_fallback_rate(rts_rate); | 320 | rts_rate_fb = b43legacy_calc_fallback_rate(rts_rate); |
318 | rts_rate_fb_ofdm = b43legacy_is_ofdm_rate(rts_rate_fb); | 321 | rts_rate_fb_ofdm = b43legacy_is_ofdm_rate(rts_rate_fb); |
319 | if (rts_rate_fb_ofdm) | 322 | if (rts_rate_fb_ofdm) |
320 | mac_ctl |= B43legacy_TX4_MAC_CTSFALLBACKOFDM; | 323 | mac_ctl |= B43legacy_TX4_MAC_CTSFALLBACKOFDM; |
321 | 324 | ||
322 | if (txctl->flags & IEEE80211_TXCTL_USE_CTS_PROTECT) { | 325 | if (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) { |
323 | ieee80211_ctstoself_get(dev->wl->hw, | 326 | ieee80211_ctstoself_get(dev->wl->hw, |
324 | txctl->vif, | 327 | info->control.vif, |
325 | fragment_data, | 328 | fragment_data, |
326 | fragment_len, txctl, | 329 | fragment_len, info, |
327 | (struct ieee80211_cts *) | 330 | (struct ieee80211_cts *) |
328 | (txhdr->rts_frame)); | 331 | (txhdr->rts_frame)); |
329 | mac_ctl |= B43legacy_TX4_MAC_SENDCTS; | 332 | mac_ctl |= B43legacy_TX4_MAC_SENDCTS; |
330 | len = sizeof(struct ieee80211_cts); | 333 | len = sizeof(struct ieee80211_cts); |
331 | } else { | 334 | } else { |
332 | ieee80211_rts_get(dev->wl->hw, | 335 | ieee80211_rts_get(dev->wl->hw, |
333 | txctl->vif, | 336 | info->control.vif, |
334 | fragment_data, fragment_len, txctl, | 337 | fragment_data, fragment_len, info, |
335 | (struct ieee80211_rts *) | 338 | (struct ieee80211_rts *) |
336 | (txhdr->rts_frame)); | 339 | (txhdr->rts_frame)); |
337 | mac_ctl |= B43legacy_TX4_MAC_SENDRTS; | 340 | mac_ctl |= B43legacy_TX4_MAC_SENDRTS; |
@@ -362,12 +365,12 @@ int b43legacy_generate_txhdr(struct b43legacy_wldev *dev, | |||
362 | u8 *txhdr, | 365 | u8 *txhdr, |
363 | const unsigned char *fragment_data, | 366 | const unsigned char *fragment_data, |
364 | unsigned int fragment_len, | 367 | unsigned int fragment_len, |
365 | const struct ieee80211_tx_control *txctl, | 368 | const struct ieee80211_tx_info *info, |
366 | u16 cookie) | 369 | u16 cookie) |
367 | { | 370 | { |
368 | return generate_txhdr_fw3(dev, (struct b43legacy_txhdr_fw3 *)txhdr, | 371 | return generate_txhdr_fw3(dev, (struct b43legacy_txhdr_fw3 *)txhdr, |
369 | fragment_data, fragment_len, | 372 | fragment_data, fragment_len, |
370 | txctl, cookie); | 373 | info, cookie); |
371 | } | 374 | } |
372 | 375 | ||
373 | static s8 b43legacy_rssi_postprocess(struct b43legacy_wldev *dev, | 376 | static s8 b43legacy_rssi_postprocess(struct b43legacy_wldev *dev, |
diff --git a/drivers/net/wireless/b43legacy/xmit.h b/drivers/net/wireless/b43legacy/xmit.h index bab47928a0c9..e56777e0feab 100644 --- a/drivers/net/wireless/b43legacy/xmit.h +++ b/drivers/net/wireless/b43legacy/xmit.h | |||
@@ -80,7 +80,7 @@ int b43legacy_generate_txhdr(struct b43legacy_wldev *dev, | |||
80 | u8 *txhdr, | 80 | u8 *txhdr, |
81 | const unsigned char *fragment_data, | 81 | const unsigned char *fragment_data, |
82 | unsigned int fragment_len, | 82 | unsigned int fragment_len, |
83 | const struct ieee80211_tx_control *txctl, | 83 | const struct ieee80211_tx_info *info, |
84 | u16 cookie); | 84 | u16 cookie); |
85 | 85 | ||
86 | 86 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c index e51eeeff6992..10c64bdb314c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c +++ b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c | |||
@@ -445,8 +445,7 @@ static int rs_adjust_next_rate(struct iwl3945_priv *priv, int rate) | |||
445 | */ | 445 | */ |
446 | static void rs_tx_status(void *priv_rate, | 446 | static void rs_tx_status(void *priv_rate, |
447 | struct net_device *dev, | 447 | struct net_device *dev, |
448 | struct sk_buff *skb, | 448 | struct sk_buff *skb) |
449 | struct ieee80211_tx_status *tx_resp) | ||
450 | { | 449 | { |
451 | u8 retries, current_count; | 450 | u8 retries, current_count; |
452 | int scale_rate_index, first_index, last_index; | 451 | int scale_rate_index, first_index, last_index; |
@@ -457,14 +456,15 @@ static void rs_tx_status(void *priv_rate, | |||
457 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 456 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
458 | struct iwl3945_rs_sta *rs_sta; | 457 | struct iwl3945_rs_sta *rs_sta; |
459 | struct ieee80211_supported_band *sband; | 458 | struct ieee80211_supported_band *sband; |
459 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
460 | 460 | ||
461 | IWL_DEBUG_RATE("enter\n"); | 461 | IWL_DEBUG_RATE("enter\n"); |
462 | 462 | ||
463 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | 463 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; |
464 | 464 | ||
465 | 465 | ||
466 | retries = tx_resp->retry_count; | 466 | retries = info->status.retry_count; |
467 | first_index = tx_resp->control.tx_rate->hw_value; | 467 | first_index = sband->bitrates[info->tx_rate_idx].hw_value; |
468 | if ((first_index < 0) || (first_index >= IWL_RATE_COUNT)) { | 468 | if ((first_index < 0) || (first_index >= IWL_RATE_COUNT)) { |
469 | IWL_DEBUG_RATE("leave: Rate out of bounds: %d\n", first_index); | 469 | IWL_DEBUG_RATE("leave: Rate out of bounds: %d\n", first_index); |
470 | return; | 470 | return; |
@@ -525,11 +525,11 @@ static void rs_tx_status(void *priv_rate, | |||
525 | /* Update the last index window with success/failure based on ACK */ | 525 | /* Update the last index window with success/failure based on ACK */ |
526 | IWL_DEBUG_RATE("Update rate %d with %s.\n", | 526 | IWL_DEBUG_RATE("Update rate %d with %s.\n", |
527 | last_index, | 527 | last_index, |
528 | (tx_resp->flags & IEEE80211_TX_STATUS_ACK) ? | 528 | (info->flags & IEEE80211_TX_STAT_ACK) ? |
529 | "success" : "failure"); | 529 | "success" : "failure"); |
530 | iwl3945_collect_tx_data(rs_sta, | 530 | iwl3945_collect_tx_data(rs_sta, |
531 | &rs_sta->win[last_index], | 531 | &rs_sta->win[last_index], |
532 | tx_resp->flags & IEEE80211_TX_STATUS_ACK, 1); | 532 | info->flags & IEEE80211_TX_STAT_ACK, 1); |
533 | 533 | ||
534 | /* We updated the rate scale window -- if its been more than | 534 | /* We updated the rate scale window -- if its been more than |
535 | * flush_time since the last run, schedule the flush | 535 | * flush_time since the last run, schedule the flush |
@@ -669,7 +669,7 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
669 | is_multicast_ether_addr(hdr->addr1) || | 669 | is_multicast_ether_addr(hdr->addr1) || |
670 | !sta || !sta->rate_ctrl_priv) { | 670 | !sta || !sta->rate_ctrl_priv) { |
671 | IWL_DEBUG_RATE("leave: No STA priv data to update!\n"); | 671 | IWL_DEBUG_RATE("leave: No STA priv data to update!\n"); |
672 | sel->rate = rate_lowest(local, sband, sta); | 672 | sel->rate_idx = rate_lowest_index(local, sband, sta); |
673 | rcu_read_unlock(); | 673 | rcu_read_unlock(); |
674 | return; | 674 | return; |
675 | } | 675 | } |
@@ -813,7 +813,7 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
813 | 813 | ||
814 | IWL_DEBUG_RATE("leave: %d\n", index); | 814 | IWL_DEBUG_RATE("leave: %d\n", index); |
815 | 815 | ||
816 | sel->rate = &sband->bitrates[sta->txrate_idx]; | 816 | sel->rate_idx = sta->txrate_idx; |
817 | } | 817 | } |
818 | 818 | ||
819 | static struct rate_control_ops rs_ops = { | 819 | static struct rate_control_ops rs_ops = { |
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c index ad4e7b74ca24..0ba6889dfd41 100644 --- a/drivers/net/wireless/iwlwifi/iwl-3945.c +++ b/drivers/net/wireless/iwlwifi/iwl-3945.c | |||
@@ -283,8 +283,7 @@ static void iwl3945_tx_queue_reclaim(struct iwl3945_priv *priv, | |||
283 | q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) { | 283 | q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) { |
284 | 284 | ||
285 | tx_info = &txq->txb[txq->q.read_ptr]; | 285 | tx_info = &txq->txb[txq->q.read_ptr]; |
286 | ieee80211_tx_status_irqsafe(priv->hw, tx_info->skb[0], | 286 | ieee80211_tx_status_irqsafe(priv->hw, tx_info->skb[0]); |
287 | &tx_info->status); | ||
288 | tx_info->skb[0] = NULL; | 287 | tx_info->skb[0] = NULL; |
289 | iwl3945_hw_txq_free_tfd(priv, txq); | 288 | iwl3945_hw_txq_free_tfd(priv, txq); |
290 | } | 289 | } |
@@ -306,7 +305,7 @@ static void iwl3945_rx_reply_tx(struct iwl3945_priv *priv, | |||
306 | int txq_id = SEQ_TO_QUEUE(sequence); | 305 | int txq_id = SEQ_TO_QUEUE(sequence); |
307 | int index = SEQ_TO_INDEX(sequence); | 306 | int index = SEQ_TO_INDEX(sequence); |
308 | struct iwl3945_tx_queue *txq = &priv->txq[txq_id]; | 307 | struct iwl3945_tx_queue *txq = &priv->txq[txq_id]; |
309 | struct ieee80211_tx_status *tx_status; | 308 | struct ieee80211_tx_info *info; |
310 | struct iwl3945_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; | 309 | struct iwl3945_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; |
311 | u32 status = le32_to_cpu(tx_resp->status); | 310 | u32 status = le32_to_cpu(tx_resp->status); |
312 | int rate_idx; | 311 | int rate_idx; |
@@ -319,19 +318,22 @@ static void iwl3945_rx_reply_tx(struct iwl3945_priv *priv, | |||
319 | return; | 318 | return; |
320 | } | 319 | } |
321 | 320 | ||
322 | tx_status = &(txq->txb[txq->q.read_ptr].status); | 321 | info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb[0]); |
322 | memset(&info->status, 0, sizeof(info->status)); | ||
323 | 323 | ||
324 | tx_status->retry_count = tx_resp->failure_frame; | 324 | info->status.retry_count = tx_resp->failure_frame; |
325 | /* tx_status->rts_retry_count = tx_resp->failure_rts; */ | 325 | /* tx_status->rts_retry_count = tx_resp->failure_rts; */ |
326 | tx_status->flags = ((status & TX_STATUS_MSK) == TX_STATUS_SUCCESS) ? | 326 | info->flags |= ((status & TX_STATUS_MSK) == TX_STATUS_SUCCESS) ? |
327 | IEEE80211_TX_STATUS_ACK : 0; | 327 | IEEE80211_TX_STAT_ACK : 0; |
328 | 328 | ||
329 | IWL_DEBUG_TX("Tx queue %d Status %s (0x%08x) plcp rate %d retries %d\n", | 329 | IWL_DEBUG_TX("Tx queue %d Status %s (0x%08x) plcp rate %d retries %d\n", |
330 | txq_id, iwl3945_get_tx_fail_reason(status), status, | 330 | txq_id, iwl3945_get_tx_fail_reason(status), status, |
331 | tx_resp->rate, tx_resp->failure_frame); | 331 | tx_resp->rate, tx_resp->failure_frame); |
332 | 332 | ||
333 | rate_idx = iwl3945_hwrate_to_plcp_idx(tx_resp->rate); | 333 | rate_idx = iwl3945_hwrate_to_plcp_idx(tx_resp->rate); |
334 | tx_status->control.tx_rate = &priv->ieee_rates[rate_idx]; | 334 | if (info->band == IEEE80211_BAND_5GHZ) |
335 | rate_idx -= IWL_FIRST_OFDM_RATE; | ||
336 | info->tx_rate_idx = rate_idx; | ||
335 | IWL_DEBUG_TX_REPLY("Tx queue reclaim %d\n", index); | 337 | IWL_DEBUG_TX_REPLY("Tx queue reclaim %d\n", index); |
336 | iwl3945_tx_queue_reclaim(priv, txq_id, index); | 338 | iwl3945_tx_queue_reclaim(priv, txq_id, index); |
337 | 339 | ||
@@ -958,11 +960,12 @@ u8 iwl3945_hw_find_station(struct iwl3945_priv *priv, const u8 *addr) | |||
958 | */ | 960 | */ |
959 | void iwl3945_hw_build_tx_cmd_rate(struct iwl3945_priv *priv, | 961 | void iwl3945_hw_build_tx_cmd_rate(struct iwl3945_priv *priv, |
960 | struct iwl3945_cmd *cmd, | 962 | struct iwl3945_cmd *cmd, |
961 | struct ieee80211_tx_control *ctrl, | 963 | struct ieee80211_tx_info *info, |
962 | struct ieee80211_hdr *hdr, int sta_id, int tx_id) | 964 | struct ieee80211_hdr *hdr, int sta_id, int tx_id) |
963 | { | 965 | { |
964 | unsigned long flags; | 966 | unsigned long flags; |
965 | u16 rate_index = min(ctrl->tx_rate->hw_value & 0xffff, IWL_RATE_COUNT - 1); | 967 | u16 hw_value = ieee80211_get_tx_rate(priv->hw, info)->hw_value; |
968 | u16 rate_index = min(hw_value & 0xffff, IWL_RATE_COUNT - 1); | ||
966 | u16 rate_mask; | 969 | u16 rate_mask; |
967 | int rate; | 970 | int rate; |
968 | u8 rts_retry_limit; | 971 | u8 rts_retry_limit; |
@@ -974,7 +977,7 @@ void iwl3945_hw_build_tx_cmd_rate(struct iwl3945_priv *priv, | |||
974 | tx_flags = cmd->cmd.tx.tx_flags; | 977 | tx_flags = cmd->cmd.tx.tx_flags; |
975 | 978 | ||
976 | /* We need to figure out how to get the sta->supp_rates while | 979 | /* We need to figure out how to get the sta->supp_rates while |
977 | * in this running context; perhaps encoding into ctrl->tx_rate? */ | 980 | * in this running context */ |
978 | rate_mask = IWL_RATES_MASK; | 981 | rate_mask = IWL_RATES_MASK; |
979 | 982 | ||
980 | spin_lock_irqsave(&priv->sta_lock, flags); | 983 | spin_lock_irqsave(&priv->sta_lock, flags); |
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.h b/drivers/net/wireless/iwlwifi/iwl-3945.h index 9fdc1405e853..a9b3edad3868 100644 --- a/drivers/net/wireless/iwlwifi/iwl-3945.h +++ b/drivers/net/wireless/iwlwifi/iwl-3945.h | |||
@@ -124,7 +124,6 @@ int iwl3945_x2_queue_used(const struct iwl3945_queue *q, int i); | |||
124 | 124 | ||
125 | /* One for each TFD */ | 125 | /* One for each TFD */ |
126 | struct iwl3945_tx_info { | 126 | struct iwl3945_tx_info { |
127 | struct ieee80211_tx_status status; | ||
128 | struct sk_buff *skb[MAX_NUM_OF_TBS]; | 127 | struct sk_buff *skb[MAX_NUM_OF_TBS]; |
129 | }; | 128 | }; |
130 | 129 | ||
@@ -645,7 +644,7 @@ extern unsigned int iwl3945_hw_get_beacon_cmd(struct iwl3945_priv *priv, | |||
645 | extern int iwl3945_hw_get_rx_read(struct iwl3945_priv *priv); | 644 | extern int iwl3945_hw_get_rx_read(struct iwl3945_priv *priv); |
646 | extern void iwl3945_hw_build_tx_cmd_rate(struct iwl3945_priv *priv, | 645 | extern void iwl3945_hw_build_tx_cmd_rate(struct iwl3945_priv *priv, |
647 | struct iwl3945_cmd *cmd, | 646 | struct iwl3945_cmd *cmd, |
648 | struct ieee80211_tx_control *ctrl, | 647 | struct ieee80211_tx_info *info, |
649 | struct ieee80211_hdr *hdr, | 648 | struct ieee80211_hdr *hdr, |
650 | int sta_id, int tx_id); | 649 | int sta_id, int tx_id); |
651 | extern int iwl3945_hw_reg_send_txpower(struct iwl3945_priv *priv); | 650 | extern int iwl3945_hw_reg_send_txpower(struct iwl3945_priv *priv); |
@@ -836,8 +835,6 @@ struct iwl3945_priv { | |||
836 | 835 | ||
837 | u8 mac80211_registered; | 836 | u8 mac80211_registered; |
838 | 837 | ||
839 | u32 notif_missed_beacons; | ||
840 | |||
841 | /* Rx'd packet timing information */ | 838 | /* Rx'd packet timing information */ |
842 | u32 last_beacon_time; | 839 | u32 last_beacon_time; |
843 | u64 last_tsf; | 840 | u64 last_tsf; |
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-hw.h b/drivers/net/wireless/iwlwifi/iwl-4965-hw.h index ee55b283226b..fc118335b60f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-4965-hw.h +++ b/drivers/net/wireless/iwlwifi/iwl-4965-hw.h | |||
@@ -100,9 +100,14 @@ | |||
100 | 100 | ||
101 | #include "iwl-commands.h" | 101 | #include "iwl-commands.h" |
102 | 102 | ||
103 | #define PCI_LINK_CTRL 0x0F0 | 103 | /* PCI registers */ |
104 | #define PCI_LINK_CTRL 0x0F0 /* 1 byte */ | ||
104 | #define PCI_POWER_SOURCE 0x0C8 | 105 | #define PCI_POWER_SOURCE 0x0C8 |
105 | #define PCI_REG_WUM8 0x0E8 | 106 | #define PCI_REG_WUM8 0x0E8 |
107 | |||
108 | /* PCI register values */ | ||
109 | #define PCI_LINK_VAL_L0S_EN 0x01 | ||
110 | #define PCI_LINK_VAL_L1_EN 0x02 | ||
106 | #define PCI_CFG_PMC_PME_FROM_D3COLD_SUPPORT (0x80000000) | 111 | #define PCI_CFG_PMC_PME_FROM_D3COLD_SUPPORT (0x80000000) |
107 | 112 | ||
108 | #define TFD_QUEUE_SIZE_MAX (256) | 113 | #define TFD_QUEUE_SIZE_MAX (256) |
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-rs.c b/drivers/net/wireless/iwlwifi/iwl-4965-rs.c index 8e3660ebba7d..a955f9c1b9ee 100644 --- a/drivers/net/wireless/iwlwifi/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlwifi/iwl-4965-rs.c | |||
@@ -282,14 +282,20 @@ static void rs_tl_rm_old_stats(struct iwl4965_traffic_load *tl, u32 curr_time) | |||
282 | * increment traffic load value for tid and also remove | 282 | * increment traffic load value for tid and also remove |
283 | * any old values if passed the certain time period | 283 | * any old values if passed the certain time period |
284 | */ | 284 | */ |
285 | static void rs_tl_add_packet(struct iwl4965_lq_sta *lq_data, u8 tid) | 285 | static void rs_tl_add_packet(struct iwl4965_lq_sta *lq_data, |
286 | struct ieee80211_hdr *hdr) | ||
286 | { | 287 | { |
287 | u32 curr_time = jiffies_to_msecs(jiffies); | 288 | u32 curr_time = jiffies_to_msecs(jiffies); |
288 | u32 time_diff; | 289 | u32 time_diff; |
289 | s32 index; | 290 | s32 index; |
290 | struct iwl4965_traffic_load *tl = NULL; | 291 | struct iwl4965_traffic_load *tl = NULL; |
292 | u16 fc = le16_to_cpu(hdr->frame_control); | ||
293 | u8 tid; | ||
291 | 294 | ||
292 | if (tid >= TID_MAX_LOAD_COUNT) | 295 | if (ieee80211_is_qos_data(fc)) { |
296 | u8 *qc = ieee80211_get_qos_ctrl(hdr, ieee80211_get_hdrlen(fc)); | ||
297 | tid = qc[0] & 0xf; | ||
298 | } else | ||
293 | return; | 299 | return; |
294 | 300 | ||
295 | tl = &lq_data->load[tid]; | 301 | tl = &lq_data->load[tid]; |
@@ -481,7 +487,7 @@ static u32 rate_n_flags_from_tbl(struct iwl4965_scale_tbl_info *tbl, | |||
481 | u32 rate_n_flags = 0; | 487 | u32 rate_n_flags = 0; |
482 | 488 | ||
483 | if (is_legacy(tbl->lq_type)) { | 489 | if (is_legacy(tbl->lq_type)) { |
484 | rate_n_flags = iwl4965_rates[index].plcp; | 490 | rate_n_flags = iwl_rates[index].plcp; |
485 | if (index >= IWL_FIRST_CCK_RATE && index <= IWL_LAST_CCK_RATE) | 491 | if (index >= IWL_FIRST_CCK_RATE && index <= IWL_LAST_CCK_RATE) |
486 | rate_n_flags |= RATE_MCS_CCK_MSK; | 492 | rate_n_flags |= RATE_MCS_CCK_MSK; |
487 | 493 | ||
@@ -493,11 +499,11 @@ static u32 rate_n_flags_from_tbl(struct iwl4965_scale_tbl_info *tbl, | |||
493 | rate_n_flags = RATE_MCS_HT_MSK; | 499 | rate_n_flags = RATE_MCS_HT_MSK; |
494 | 500 | ||
495 | if (is_siso(tbl->lq_type)) | 501 | if (is_siso(tbl->lq_type)) |
496 | rate_n_flags |= iwl4965_rates[index].plcp_siso; | 502 | rate_n_flags |= iwl_rates[index].plcp_siso; |
497 | else if (is_mimo2(tbl->lq_type)) | 503 | else if (is_mimo2(tbl->lq_type)) |
498 | rate_n_flags |= iwl4965_rates[index].plcp_mimo2; | 504 | rate_n_flags |= iwl_rates[index].plcp_mimo2; |
499 | else | 505 | else |
500 | rate_n_flags |= iwl4965_rates[index].plcp_mimo3; | 506 | rate_n_flags |= iwl_rates[index].plcp_mimo3; |
501 | } else { | 507 | } else { |
502 | IWL_ERROR("Invalid tbl->lq_type %d\n", tbl->lq_type); | 508 | IWL_ERROR("Invalid tbl->lq_type %d\n", tbl->lq_type); |
503 | } | 509 | } |
@@ -697,7 +703,7 @@ static u16 rs_get_adjacent_rate(struct iwl_priv *priv, u8 index, u16 rate_mask, | |||
697 | 703 | ||
698 | low = index; | 704 | low = index; |
699 | while (low != IWL_RATE_INVALID) { | 705 | while (low != IWL_RATE_INVALID) { |
700 | low = iwl4965_rates[low].prev_rs; | 706 | low = iwl_rates[low].prev_rs; |
701 | if (low == IWL_RATE_INVALID) | 707 | if (low == IWL_RATE_INVALID) |
702 | break; | 708 | break; |
703 | if (rate_mask & (1 << low)) | 709 | if (rate_mask & (1 << low)) |
@@ -707,7 +713,7 @@ static u16 rs_get_adjacent_rate(struct iwl_priv *priv, u8 index, u16 rate_mask, | |||
707 | 713 | ||
708 | high = index; | 714 | high = index; |
709 | while (high != IWL_RATE_INVALID) { | 715 | while (high != IWL_RATE_INVALID) { |
710 | high = iwl4965_rates[high].next_rs; | 716 | high = iwl_rates[high].next_rs; |
711 | if (high == IWL_RATE_INVALID) | 717 | if (high == IWL_RATE_INVALID) |
712 | break; | 718 | break; |
713 | if (rate_mask & (1 << high)) | 719 | if (rate_mask & (1 << high)) |
@@ -779,8 +785,7 @@ out: | |||
779 | * mac80211 sends us Tx status | 785 | * mac80211 sends us Tx status |
780 | */ | 786 | */ |
781 | static void rs_tx_status(void *priv_rate, struct net_device *dev, | 787 | static void rs_tx_status(void *priv_rate, struct net_device *dev, |
782 | struct sk_buff *skb, | 788 | struct sk_buff *skb) |
783 | struct ieee80211_tx_status *tx_resp) | ||
784 | { | 789 | { |
785 | int status; | 790 | int status; |
786 | u8 retries; | 791 | u8 retries; |
@@ -792,6 +797,7 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev, | |||
792 | struct iwl_priv *priv = (struct iwl_priv *)priv_rate; | 797 | struct iwl_priv *priv = (struct iwl_priv *)priv_rate; |
793 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 798 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
794 | struct ieee80211_hw *hw = local_to_hw(local); | 799 | struct ieee80211_hw *hw = local_to_hw(local); |
800 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
795 | struct iwl4965_rate_scale_data *window = NULL; | 801 | struct iwl4965_rate_scale_data *window = NULL; |
796 | struct iwl4965_rate_scale_data *search_win = NULL; | 802 | struct iwl4965_rate_scale_data *search_win = NULL; |
797 | u32 tx_rate; | 803 | u32 tx_rate; |
@@ -807,11 +813,11 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev, | |||
807 | return; | 813 | return; |
808 | 814 | ||
809 | /* This packet was aggregated but doesn't carry rate scale info */ | 815 | /* This packet was aggregated but doesn't carry rate scale info */ |
810 | if ((tx_resp->control.flags & IEEE80211_TXCTL_AMPDU) && | 816 | if ((info->flags & IEEE80211_TX_CTL_AMPDU) && |
811 | !(tx_resp->flags & IEEE80211_TX_STATUS_AMPDU)) | 817 | !(info->flags & IEEE80211_TX_STAT_AMPDU)) |
812 | return; | 818 | return; |
813 | 819 | ||
814 | retries = tx_resp->retry_count; | 820 | retries = info->status.retry_count; |
815 | 821 | ||
816 | if (retries > 15) | 822 | if (retries > 15) |
817 | retries = 15; | 823 | retries = 15; |
@@ -856,20 +862,20 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev, | |||
856 | if (priv->band == IEEE80211_BAND_5GHZ) | 862 | if (priv->band == IEEE80211_BAND_5GHZ) |
857 | rs_index -= IWL_FIRST_OFDM_RATE; | 863 | rs_index -= IWL_FIRST_OFDM_RATE; |
858 | 864 | ||
859 | if ((tx_resp->control.tx_rate == NULL) || | 865 | if ((info->tx_rate_idx < 0) || |
860 | (tbl_type.is_SGI ^ | 866 | (tbl_type.is_SGI ^ |
861 | !!(tx_resp->control.flags & IEEE80211_TXCTL_SHORT_GI)) || | 867 | !!(info->flags & IEEE80211_TX_CTL_SHORT_GI)) || |
862 | (tbl_type.is_fat ^ | 868 | (tbl_type.is_fat ^ |
863 | !!(tx_resp->control.flags & IEEE80211_TXCTL_40_MHZ_WIDTH)) || | 869 | !!(info->flags & IEEE80211_TX_CTL_40_MHZ_WIDTH)) || |
864 | (tbl_type.is_dup ^ | 870 | (tbl_type.is_dup ^ |
865 | !!(tx_resp->control.flags & IEEE80211_TXCTL_DUP_DATA)) || | 871 | !!(info->flags & IEEE80211_TX_CTL_DUP_DATA)) || |
866 | (tbl_type.ant_type ^ tx_resp->control.antenna_sel_tx) || | 872 | (tbl_type.ant_type ^ info->antenna_sel_tx) || |
867 | (!!(tx_rate & RATE_MCS_HT_MSK) ^ | 873 | (!!(tx_rate & RATE_MCS_HT_MSK) ^ |
868 | !!(tx_resp->control.flags & IEEE80211_TXCTL_OFDM_HT)) || | 874 | !!(info->flags & IEEE80211_TX_CTL_OFDM_HT)) || |
869 | (!!(tx_rate & RATE_MCS_GF_MSK) ^ | 875 | (!!(tx_rate & RATE_MCS_GF_MSK) ^ |
870 | !!(tx_resp->control.flags & IEEE80211_TXCTL_GREEN_FIELD)) || | 876 | !!(info->flags & IEEE80211_TX_CTL_GREEN_FIELD)) || |
871 | (hw->wiphy->bands[priv->band]->bitrates[rs_index].bitrate != | 877 | (hw->wiphy->bands[priv->band]->bitrates[rs_index].bitrate != |
872 | tx_resp->control.tx_rate->bitrate)) { | 878 | hw->wiphy->bands[info->band]->bitrates[info->tx_rate_idx].bitrate)) { |
873 | IWL_DEBUG_RATE("initial rate does not match 0x%x\n", tx_rate); | 879 | IWL_DEBUG_RATE("initial rate does not match 0x%x\n", tx_rate); |
874 | goto out; | 880 | goto out; |
875 | } | 881 | } |
@@ -923,10 +929,7 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev, | |||
923 | rs_get_tbl_info_from_mcs(tx_rate, priv->band, &tbl_type, &rs_index); | 929 | rs_get_tbl_info_from_mcs(tx_rate, priv->band, &tbl_type, &rs_index); |
924 | 930 | ||
925 | /* Update frame history window with "success" if Tx got ACKed ... */ | 931 | /* Update frame history window with "success" if Tx got ACKed ... */ |
926 | if (tx_resp->flags & IEEE80211_TX_STATUS_ACK) | 932 | status = !!(info->flags & IEEE80211_TX_STAT_ACK); |
927 | status = 1; | ||
928 | else | ||
929 | status = 0; | ||
930 | 933 | ||
931 | /* If type matches "search" table, | 934 | /* If type matches "search" table, |
932 | * add final tx status to "search" history */ | 935 | * add final tx status to "search" history */ |
@@ -937,10 +940,10 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev, | |||
937 | tpt = search_tbl->expected_tpt[rs_index]; | 940 | tpt = search_tbl->expected_tpt[rs_index]; |
938 | else | 941 | else |
939 | tpt = 0; | 942 | tpt = 0; |
940 | if (tx_resp->control.flags & IEEE80211_TXCTL_AMPDU) | 943 | if (info->flags & IEEE80211_TX_CTL_AMPDU) |
941 | rs_collect_tx_data(search_win, rs_index, tpt, | 944 | rs_collect_tx_data(search_win, rs_index, tpt, |
942 | tx_resp->ampdu_ack_len, | 945 | info->status.ampdu_ack_len, |
943 | tx_resp->ampdu_ack_map); | 946 | info->status.ampdu_ack_map); |
944 | else | 947 | else |
945 | rs_collect_tx_data(search_win, rs_index, tpt, | 948 | rs_collect_tx_data(search_win, rs_index, tpt, |
946 | 1, status); | 949 | 1, status); |
@@ -953,10 +956,10 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev, | |||
953 | tpt = curr_tbl->expected_tpt[rs_index]; | 956 | tpt = curr_tbl->expected_tpt[rs_index]; |
954 | else | 957 | else |
955 | tpt = 0; | 958 | tpt = 0; |
956 | if (tx_resp->control.flags & IEEE80211_TXCTL_AMPDU) | 959 | if (info->flags & IEEE80211_TX_CTL_AMPDU) |
957 | rs_collect_tx_data(window, rs_index, tpt, | 960 | rs_collect_tx_data(window, rs_index, tpt, |
958 | tx_resp->ampdu_ack_len, | 961 | info->status.ampdu_ack_len, |
959 | tx_resp->ampdu_ack_map); | 962 | info->status.ampdu_ack_map); |
960 | else | 963 | else |
961 | rs_collect_tx_data(window, rs_index, tpt, | 964 | rs_collect_tx_data(window, rs_index, tpt, |
962 | 1, status); | 965 | 1, status); |
@@ -965,10 +968,10 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev, | |||
965 | /* If not searching for new mode, increment success/failed counter | 968 | /* If not searching for new mode, increment success/failed counter |
966 | * ... these help determine when to start searching again */ | 969 | * ... these help determine when to start searching again */ |
967 | if (lq_sta->stay_in_tbl) { | 970 | if (lq_sta->stay_in_tbl) { |
968 | if (tx_resp->control.flags & IEEE80211_TXCTL_AMPDU) { | 971 | if (info->flags & IEEE80211_TX_CTL_AMPDU) { |
969 | lq_sta->total_success += tx_resp->ampdu_ack_map; | 972 | lq_sta->total_success += info->status.ampdu_ack_map; |
970 | lq_sta->total_failed += | 973 | lq_sta->total_failed += |
971 | (tx_resp->ampdu_ack_len - tx_resp->ampdu_ack_map); | 974 | (info->status.ampdu_ack_len - info->status.ampdu_ack_map); |
972 | } else { | 975 | } else { |
973 | if (status) | 976 | if (status) |
974 | lq_sta->total_success++; | 977 | lq_sta->total_success++; |
@@ -1333,7 +1336,7 @@ static int rs_move_legacy_other(struct iwl_priv *priv, | |||
1333 | lq_sta->search_better_tbl = 1; | 1336 | lq_sta->search_better_tbl = 1; |
1334 | goto out; | 1337 | goto out; |
1335 | } | 1338 | } |
1336 | 1339 | break; | |
1337 | case IWL_LEGACY_SWITCH_SISO: | 1340 | case IWL_LEGACY_SWITCH_SISO: |
1338 | IWL_DEBUG_RATE("LQ: Legacy switch to SISO\n"); | 1341 | IWL_DEBUG_RATE("LQ: Legacy switch to SISO\n"); |
1339 | 1342 | ||
@@ -1419,9 +1422,9 @@ static int rs_move_siso_to_other(struct iwl_priv *priv, | |||
1419 | lq_sta->search_better_tbl = 1; | 1422 | lq_sta->search_better_tbl = 1; |
1420 | goto out; | 1423 | goto out; |
1421 | } | 1424 | } |
1422 | 1425 | break; | |
1423 | case IWL_SISO_SWITCH_MIMO2: | 1426 | case IWL_SISO_SWITCH_MIMO2: |
1424 | IWL_DEBUG_RATE("LQ: SISO switch to MIMO\n"); | 1427 | IWL_DEBUG_RATE("LQ: SISO switch to MIMO2\n"); |
1425 | memcpy(search_tbl, tbl, sz); | 1428 | memcpy(search_tbl, tbl, sz); |
1426 | search_tbl->is_SGI = 0; | 1429 | search_tbl->is_SGI = 0; |
1427 | search_tbl->ant_type = ANT_AB; /*FIXME:RS*/ | 1430 | search_tbl->ant_type = ANT_AB; /*FIXME:RS*/ |
@@ -1433,6 +1436,15 @@ static int rs_move_siso_to_other(struct iwl_priv *priv, | |||
1433 | } | 1436 | } |
1434 | break; | 1437 | break; |
1435 | case IWL_SISO_SWITCH_GI: | 1438 | case IWL_SISO_SWITCH_GI: |
1439 | if (!tbl->is_fat && | ||
1440 | !(priv->current_ht_config.sgf & | ||
1441 | HT_SHORT_GI_20MHZ)) | ||
1442 | break; | ||
1443 | if (tbl->is_fat && | ||
1444 | !(priv->current_ht_config.sgf & | ||
1445 | HT_SHORT_GI_40MHZ)) | ||
1446 | break; | ||
1447 | |||
1436 | IWL_DEBUG_RATE("LQ: SISO toggle SGI/NGI\n"); | 1448 | IWL_DEBUG_RATE("LQ: SISO toggle SGI/NGI\n"); |
1437 | 1449 | ||
1438 | memcpy(search_tbl, tbl, sz); | 1450 | memcpy(search_tbl, tbl, sz); |
@@ -1515,6 +1527,15 @@ static int rs_move_mimo_to_other(struct iwl_priv *priv, | |||
1515 | break; | 1527 | break; |
1516 | 1528 | ||
1517 | case IWL_MIMO_SWITCH_GI: | 1529 | case IWL_MIMO_SWITCH_GI: |
1530 | if (!tbl->is_fat && | ||
1531 | !(priv->current_ht_config.sgf & | ||
1532 | HT_SHORT_GI_20MHZ)) | ||
1533 | break; | ||
1534 | if (tbl->is_fat && | ||
1535 | !(priv->current_ht_config.sgf & | ||
1536 | HT_SHORT_GI_40MHZ)) | ||
1537 | break; | ||
1538 | |||
1518 | IWL_DEBUG_RATE("LQ: MIMO toggle SGI/NGI\n"); | 1539 | IWL_DEBUG_RATE("LQ: MIMO toggle SGI/NGI\n"); |
1519 | 1540 | ||
1520 | /* Set up new search table for MIMO */ | 1541 | /* Set up new search table for MIMO */ |
@@ -1668,9 +1689,9 @@ static void rs_rate_scale_perform(struct iwl_priv *priv, | |||
1668 | u8 active_tbl = 0; | 1689 | u8 active_tbl = 0; |
1669 | u8 done_search = 0; | 1690 | u8 done_search = 0; |
1670 | u16 high_low; | 1691 | u16 high_low; |
1692 | s32 sr; | ||
1671 | #ifdef CONFIG_IWL4965_HT | 1693 | #ifdef CONFIG_IWL4965_HT |
1672 | u8 tid = MAX_TID_COUNT; | 1694 | u8 tid = MAX_TID_COUNT; |
1673 | __le16 *qc; | ||
1674 | #endif | 1695 | #endif |
1675 | 1696 | ||
1676 | IWL_DEBUG_RATE("rate scale calculate new rate for skb\n"); | 1697 | IWL_DEBUG_RATE("rate scale calculate new rate for skb\n"); |
@@ -1693,11 +1714,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv, | |||
1693 | lq_sta = (struct iwl4965_lq_sta *)sta->rate_ctrl_priv; | 1714 | lq_sta = (struct iwl4965_lq_sta *)sta->rate_ctrl_priv; |
1694 | 1715 | ||
1695 | #ifdef CONFIG_IWL4965_HT | 1716 | #ifdef CONFIG_IWL4965_HT |
1696 | qc = ieee80211_get_qos_ctrl(hdr); | 1717 | rs_tl_add_packet(lq_sta, hdr); |
1697 | if (qc) { | ||
1698 | tid = (u8)(le16_to_cpu(*qc) & 0xf); | ||
1699 | rs_tl_add_packet(lq_sta, tid); | ||
1700 | } | ||
1701 | #endif | 1718 | #endif |
1702 | /* | 1719 | /* |
1703 | * Select rate-scale / modulation-mode table to work with in | 1720 | * Select rate-scale / modulation-mode table to work with in |
@@ -1848,6 +1865,8 @@ static void rs_rate_scale_perform(struct iwl_priv *priv, | |||
1848 | low = high_low & 0xff; | 1865 | low = high_low & 0xff; |
1849 | high = (high_low >> 8) & 0xff; | 1866 | high = (high_low >> 8) & 0xff; |
1850 | 1867 | ||
1868 | sr = window->success_ratio; | ||
1869 | |||
1851 | /* Collect measured throughputs for current and adjacent rates */ | 1870 | /* Collect measured throughputs for current and adjacent rates */ |
1852 | current_tpt = window->average_tpt; | 1871 | current_tpt = window->average_tpt; |
1853 | if (low != IWL_RATE_INVALID) | 1872 | if (low != IWL_RATE_INVALID) |
@@ -1855,19 +1874,22 @@ static void rs_rate_scale_perform(struct iwl_priv *priv, | |||
1855 | if (high != IWL_RATE_INVALID) | 1874 | if (high != IWL_RATE_INVALID) |
1856 | high_tpt = tbl->win[high].average_tpt; | 1875 | high_tpt = tbl->win[high].average_tpt; |
1857 | 1876 | ||
1858 | /* Assume rate increase */ | 1877 | scale_action = 0; |
1859 | scale_action = 1; | ||
1860 | 1878 | ||
1861 | /* Too many failures, decrease rate */ | 1879 | /* Too many failures, decrease rate */ |
1862 | if ((window->success_ratio <= IWL_RATE_DECREASE_TH) || | 1880 | if ((sr <= IWL_RATE_DECREASE_TH) || (current_tpt == 0)) { |
1863 | (current_tpt == 0)) { | ||
1864 | IWL_DEBUG_RATE("decrease rate because of low success_ratio\n"); | 1881 | IWL_DEBUG_RATE("decrease rate because of low success_ratio\n"); |
1865 | scale_action = -1; | 1882 | scale_action = -1; |
1866 | 1883 | ||
1867 | /* No throughput measured yet for adjacent rates; try increase. */ | 1884 | /* No throughput measured yet for adjacent rates; try increase. */ |
1868 | } else if ((low_tpt == IWL_INVALID_VALUE) && | 1885 | } else if ((low_tpt == IWL_INVALID_VALUE) && |
1869 | (high_tpt == IWL_INVALID_VALUE)) | 1886 | (high_tpt == IWL_INVALID_VALUE)) { |
1870 | scale_action = 1; | 1887 | |
1888 | if (high != IWL_RATE_INVALID && sr >= IWL_RATE_INCREASE_TH) | ||
1889 | scale_action = 1; | ||
1890 | else if (low != IWL_RATE_INVALID) | ||
1891 | scale_action = -1; | ||
1892 | } | ||
1871 | 1893 | ||
1872 | /* Both adjacent throughputs are measured, but neither one has better | 1894 | /* Both adjacent throughputs are measured, but neither one has better |
1873 | * throughput; we're using the best rate, don't change it! */ | 1895 | * throughput; we're using the best rate, don't change it! */ |
@@ -1883,9 +1905,10 @@ static void rs_rate_scale_perform(struct iwl_priv *priv, | |||
1883 | /* Higher adjacent rate's throughput is measured */ | 1905 | /* Higher adjacent rate's throughput is measured */ |
1884 | if (high_tpt != IWL_INVALID_VALUE) { | 1906 | if (high_tpt != IWL_INVALID_VALUE) { |
1885 | /* Higher rate has better throughput */ | 1907 | /* Higher rate has better throughput */ |
1886 | if (high_tpt > current_tpt) | 1908 | if (high_tpt > current_tpt && |
1909 | sr >= IWL_RATE_INCREASE_TH) { | ||
1887 | scale_action = 1; | 1910 | scale_action = 1; |
1888 | else { | 1911 | } else { |
1889 | IWL_DEBUG_RATE | 1912 | IWL_DEBUG_RATE |
1890 | ("decrease rate because of high tpt\n"); | 1913 | ("decrease rate because of high tpt\n"); |
1891 | scale_action = -1; | 1914 | scale_action = -1; |
@@ -1898,23 +1921,17 @@ static void rs_rate_scale_perform(struct iwl_priv *priv, | |||
1898 | IWL_DEBUG_RATE | 1921 | IWL_DEBUG_RATE |
1899 | ("decrease rate because of low tpt\n"); | 1922 | ("decrease rate because of low tpt\n"); |
1900 | scale_action = -1; | 1923 | scale_action = -1; |
1901 | } else | 1924 | } else if (sr >= IWL_RATE_INCREASE_TH) { |
1902 | scale_action = 1; | 1925 | scale_action = 1; |
1926 | } | ||
1903 | } | 1927 | } |
1904 | } | 1928 | } |
1905 | 1929 | ||
1906 | /* Sanity check; asked for decrease, but success rate or throughput | 1930 | /* Sanity check; asked for decrease, but success rate or throughput |
1907 | * has been good at old rate. Don't change it. */ | 1931 | * has been good at old rate. Don't change it. */ |
1908 | if (scale_action == -1) { | 1932 | if ((scale_action == -1) && (low != IWL_RATE_INVALID) && |
1909 | if ((low != IWL_RATE_INVALID) && | 1933 | ((sr > IWL_RATE_HIGH_TH) || |
1910 | ((window->success_ratio > IWL_RATE_HIGH_TH) || | ||
1911 | (current_tpt > (100 * tbl->expected_tpt[low])))) | 1934 | (current_tpt > (100 * tbl->expected_tpt[low])))) |
1912 | scale_action = 0; | ||
1913 | |||
1914 | /* Sanity check; asked for increase, but success rate has not been great | ||
1915 | * even at old rate, higher rate will be worse. Don't change it. */ | ||
1916 | } else if ((scale_action == 1) && | ||
1917 | (window->success_ratio < IWL_RATE_INCREASE_TH)) | ||
1918 | scale_action = 0; | 1935 | scale_action = 0; |
1919 | 1936 | ||
1920 | switch (scale_action) { | 1937 | switch (scale_action) { |
@@ -1943,7 +1960,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv, | |||
1943 | "high %d type %d\n", | 1960 | "high %d type %d\n", |
1944 | index, scale_action, low, high, tbl->lq_type); | 1961 | index, scale_action, low, high, tbl->lq_type); |
1945 | 1962 | ||
1946 | lq_update: | 1963 | lq_update: |
1947 | /* Replace uCode's rate table for the destination station. */ | 1964 | /* Replace uCode's rate table for the destination station. */ |
1948 | if (update_lq) { | 1965 | if (update_lq) { |
1949 | rate = rate_n_flags_from_tbl(tbl, index, is_green); | 1966 | rate = rate_n_flags_from_tbl(tbl, index, is_green); |
@@ -2088,7 +2105,7 @@ static void rs_initialize_lq(struct iwl_priv *priv, | |||
2088 | i = 0; | 2105 | i = 0; |
2089 | 2106 | ||
2090 | /* FIXME:RS: This is also wrong in 4965 */ | 2107 | /* FIXME:RS: This is also wrong in 4965 */ |
2091 | rate = iwl4965_rates[i].plcp; | 2108 | rate = iwl_rates[i].plcp; |
2092 | rate |= RATE_MCS_ANT_B_MSK; | 2109 | rate |= RATE_MCS_ANT_B_MSK; |
2093 | rate &= ~RATE_MCS_ANT_A_MSK; | 2110 | rate &= ~RATE_MCS_ANT_A_MSK; |
2094 | 2111 | ||
@@ -2135,7 +2152,7 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
2135 | fc = le16_to_cpu(hdr->frame_control); | 2152 | fc = le16_to_cpu(hdr->frame_control); |
2136 | if (!ieee80211_is_data(fc) || is_multicast_ether_addr(hdr->addr1) || | 2153 | if (!ieee80211_is_data(fc) || is_multicast_ether_addr(hdr->addr1) || |
2137 | !sta || !sta->rate_ctrl_priv) { | 2154 | !sta || !sta->rate_ctrl_priv) { |
2138 | sel->rate = rate_lowest(local, sband, sta); | 2155 | sel->rate_idx = rate_lowest_index(local, sband, sta); |
2139 | goto out; | 2156 | goto out; |
2140 | } | 2157 | } |
2141 | 2158 | ||
@@ -2150,7 +2167,7 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
2150 | if (sta_id == IWL_INVALID_STATION) { | 2167 | if (sta_id == IWL_INVALID_STATION) { |
2151 | IWL_DEBUG_RATE("LQ: ADD station %s\n", | 2168 | IWL_DEBUG_RATE("LQ: ADD station %s\n", |
2152 | print_mac(mac, hdr->addr1)); | 2169 | print_mac(mac, hdr->addr1)); |
2153 | sta_id = iwl4965_add_station_flags(priv, hdr->addr1, | 2170 | sta_id = iwl_add_station_flags(priv, hdr->addr1, |
2154 | 0, CMD_ASYNC, NULL); | 2171 | 0, CMD_ASYNC, NULL); |
2155 | } | 2172 | } |
2156 | if ((sta_id != IWL_INVALID_STATION)) { | 2173 | if ((sta_id != IWL_INVALID_STATION)) { |
@@ -2165,11 +2182,13 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
2165 | 2182 | ||
2166 | done: | 2183 | done: |
2167 | if ((i < 0) || (i > IWL_RATE_COUNT)) { | 2184 | if ((i < 0) || (i > IWL_RATE_COUNT)) { |
2168 | sel->rate = rate_lowest(local, sband, sta); | 2185 | sel->rate_idx = rate_lowest_index(local, sband, sta); |
2169 | goto out; | 2186 | goto out; |
2170 | } | 2187 | } |
2171 | 2188 | ||
2172 | sel->rate = &priv->ieee_rates[i]; | 2189 | if (sband->band == IEEE80211_BAND_5GHZ) |
2190 | i -= IWL_FIRST_OFDM_RATE; | ||
2191 | sel->rate_idx = i; | ||
2173 | out: | 2192 | out: |
2174 | rcu_read_unlock(); | 2193 | rcu_read_unlock(); |
2175 | } | 2194 | } |
@@ -2234,7 +2253,7 @@ static void rs_rate_init(void *priv_rate, void *priv_sta, | |||
2234 | if (sta_id == IWL_INVALID_STATION) { | 2253 | if (sta_id == IWL_INVALID_STATION) { |
2235 | IWL_DEBUG_RATE("LQ: ADD station %s\n", | 2254 | IWL_DEBUG_RATE("LQ: ADD station %s\n", |
2236 | print_mac(mac, sta->addr)); | 2255 | print_mac(mac, sta->addr)); |
2237 | sta_id = iwl4965_add_station_flags(priv, sta->addr, | 2256 | sta_id = iwl_add_station_flags(priv, sta->addr, |
2238 | 0, CMD_ASYNC, NULL); | 2257 | 0, CMD_ASYNC, NULL); |
2239 | } | 2258 | } |
2240 | if ((sta_id != IWL_INVALID_STATION)) { | 2259 | if ((sta_id != IWL_INVALID_STATION)) { |
@@ -2425,6 +2444,7 @@ static void rs_fill_link_cmd(const struct iwl_priv *priv, | |||
2425 | repeat_rate--; | 2444 | repeat_rate--; |
2426 | } | 2445 | } |
2427 | 2446 | ||
2447 | lq_cmd->agg_params.agg_frame_cnt_limit = 64; | ||
2428 | lq_cmd->agg_params.agg_dis_start_th = 3; | 2448 | lq_cmd->agg_params.agg_dis_start_th = 3; |
2429 | lq_cmd->agg_params.agg_time_limit = cpu_to_le16(4000); | 2449 | lq_cmd->agg_params.agg_time_limit = cpu_to_le16(4000); |
2430 | } | 2450 | } |
@@ -2691,7 +2711,7 @@ int iwl4965_fill_rs_info(struct ieee80211_hw *hw, char *buf, u8 sta_id) | |||
2691 | int active = lq_sta->active_tbl; | 2711 | int active = lq_sta->active_tbl; |
2692 | 2712 | ||
2693 | cnt += | 2713 | cnt += |
2694 | sprintf(&buf[cnt], " %2dMbs: ", iwl4965_rates[i].ieee / 2); | 2714 | sprintf(&buf[cnt], " %2dMbs: ", iwl_rates[i].ieee / 2); |
2695 | 2715 | ||
2696 | mask = (1ULL << (IWL_RATE_MAX_WINDOW - 1)); | 2716 | mask = (1ULL << (IWL_RATE_MAX_WINDOW - 1)); |
2697 | for (j = 0; j < IWL_RATE_MAX_WINDOW; j++, mask >>= 1) | 2717 | for (j = 0; j < IWL_RATE_MAX_WINDOW; j++, mask >>= 1) |
@@ -2702,7 +2722,7 @@ int iwl4965_fill_rs_info(struct ieee80211_hw *hw, char *buf, u8 sta_id) | |||
2702 | samples += lq_sta->lq_info[active].win[i].counter; | 2722 | samples += lq_sta->lq_info[active].win[i].counter; |
2703 | good += lq_sta->lq_info[active].win[i].success_counter; | 2723 | good += lq_sta->lq_info[active].win[i].success_counter; |
2704 | success += lq_sta->lq_info[active].win[i].success_counter * | 2724 | success += lq_sta->lq_info[active].win[i].success_counter * |
2705 | iwl4965_rates[i].ieee; | 2725 | iwl_rates[i].ieee; |
2706 | 2726 | ||
2707 | if (lq_sta->lq_info[active].win[i].stamp) { | 2727 | if (lq_sta->lq_info[active].win[i].stamp) { |
2708 | int delta = | 2728 | int delta = |
@@ -2722,10 +2742,11 @@ int iwl4965_fill_rs_info(struct ieee80211_hw *hw, char *buf, u8 sta_id) | |||
2722 | i = j; | 2742 | i = j; |
2723 | } | 2743 | } |
2724 | 2744 | ||
2725 | /* Display the average rate of all samples taken. | 2745 | /* |
2726 | * | 2746 | * Display the average rate of all samples taken. |
2727 | * NOTE: We multiply # of samples by 2 since the IEEE measurement | 2747 | * NOTE: We multiply # of samples by 2 since the IEEE measurement |
2728 | * added from iwl4965_rates is actually 2X the rate */ | 2748 | * added from iwl_rates is actually 2X the rate. |
2749 | */ | ||
2729 | if (samples) | 2750 | if (samples) |
2730 | cnt += sprintf(&buf[cnt], | 2751 | cnt += sprintf(&buf[cnt], |
2731 | "\nAverage rate is %3d.%02dMbs over last %4dms\n" | 2752 | "\nAverage rate is %3d.%02dMbs over last %4dms\n" |
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-rs.h b/drivers/net/wireless/iwlwifi/iwl-4965-rs.h index 7ea2041a22e0..1dd4124227a5 100644 --- a/drivers/net/wireless/iwlwifi/iwl-4965-rs.h +++ b/drivers/net/wireless/iwlwifi/iwl-4965-rs.h | |||
@@ -29,7 +29,7 @@ | |||
29 | 29 | ||
30 | #include "iwl-dev.h" | 30 | #include "iwl-dev.h" |
31 | 31 | ||
32 | struct iwl4965_rate_info { | 32 | struct iwl_rate_info { |
33 | u8 plcp; /* uCode API: IWL_RATE_6M_PLCP, etc. */ | 33 | u8 plcp; /* uCode API: IWL_RATE_6M_PLCP, etc. */ |
34 | u8 plcp_siso; /* uCode API: IWL_RATE_SISO_6M_PLCP, etc. */ | 34 | u8 plcp_siso; /* uCode API: IWL_RATE_SISO_6M_PLCP, etc. */ |
35 | u8 plcp_mimo2; /* uCode API: IWL_RATE_MIMO2_6M_PLCP, etc. */ | 35 | u8 plcp_mimo2; /* uCode API: IWL_RATE_MIMO2_6M_PLCP, etc. */ |
@@ -45,7 +45,7 @@ struct iwl4965_rate_info { | |||
45 | 45 | ||
46 | /* | 46 | /* |
47 | * These serve as indexes into | 47 | * These serve as indexes into |
48 | * struct iwl4965_rate_info iwl4965_rates[IWL_RATE_COUNT]; | 48 | * struct iwl_rate_info iwl_rates[IWL_RATE_COUNT]; |
49 | */ | 49 | */ |
50 | enum { | 50 | enum { |
51 | IWL_RATE_1M_INDEX = 0, | 51 | IWL_RATE_1M_INDEX = 0, |
@@ -240,7 +240,7 @@ enum { | |||
240 | #define TID_MAX_TIME_DIFF ((TID_QUEUE_MAX_SIZE - 1) * TID_QUEUE_CELL_SPACING) | 240 | #define TID_MAX_TIME_DIFF ((TID_QUEUE_MAX_SIZE - 1) * TID_QUEUE_CELL_SPACING) |
241 | #define TIME_WRAP_AROUND(x, y) (((y) > (x)) ? (y) - (x) : (0-(x)) + (y)) | 241 | #define TIME_WRAP_AROUND(x, y) (((y) > (x)) ? (y) - (x) : (0-(x)) + (y)) |
242 | 242 | ||
243 | extern const struct iwl4965_rate_info iwl4965_rates[IWL_RATE_COUNT]; | 243 | extern const struct iwl_rate_info iwl_rates[IWL_RATE_COUNT]; |
244 | 244 | ||
245 | enum iwl_table_type { | 245 | enum iwl_table_type { |
246 | LQ_NONE, | 246 | LQ_NONE, |
@@ -279,7 +279,7 @@ static inline u8 num_of_ant(u8 mask) | |||
279 | 279 | ||
280 | static inline u8 iwl4965_get_prev_ieee_rate(u8 rate_index) | 280 | static inline u8 iwl4965_get_prev_ieee_rate(u8 rate_index) |
281 | { | 281 | { |
282 | u8 rate = iwl4965_rates[rate_index].prev_ieee; | 282 | u8 rate = iwl_rates[rate_index].prev_ieee; |
283 | 283 | ||
284 | if (rate == IWL_RATE_INVALID) | 284 | if (rate == IWL_RATE_INVALID) |
285 | rate = rate_index; | 285 | rate = rate_index; |
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c index 17847f981e11..aee7014bcb94 100644 --- a/drivers/net/wireless/iwlwifi/iwl-4965.c +++ b/drivers/net/wireless/iwlwifi/iwl-4965.c | |||
@@ -44,6 +44,7 @@ | |||
44 | #include "iwl-io.h" | 44 | #include "iwl-io.h" |
45 | #include "iwl-helpers.h" | 45 | #include "iwl-helpers.h" |
46 | #include "iwl-calib.h" | 46 | #include "iwl-calib.h" |
47 | #include "iwl-sta.h" | ||
47 | 48 | ||
48 | /* module parameters */ | 49 | /* module parameters */ |
49 | static struct iwl_mod_params iwl4965_mod_params = { | 50 | static struct iwl_mod_params iwl4965_mod_params = { |
@@ -54,30 +55,6 @@ static struct iwl_mod_params iwl4965_mod_params = { | |||
54 | /* the rest are 0 by default */ | 55 | /* the rest are 0 by default */ |
55 | }; | 56 | }; |
56 | 57 | ||
57 | #ifdef CONFIG_IWL4965_HT | ||
58 | |||
59 | static const u16 default_tid_to_tx_fifo[] = { | ||
60 | IWL_TX_FIFO_AC1, | ||
61 | IWL_TX_FIFO_AC0, | ||
62 | IWL_TX_FIFO_AC0, | ||
63 | IWL_TX_FIFO_AC1, | ||
64 | IWL_TX_FIFO_AC2, | ||
65 | IWL_TX_FIFO_AC2, | ||
66 | IWL_TX_FIFO_AC3, | ||
67 | IWL_TX_FIFO_AC3, | ||
68 | IWL_TX_FIFO_NONE, | ||
69 | IWL_TX_FIFO_NONE, | ||
70 | IWL_TX_FIFO_NONE, | ||
71 | IWL_TX_FIFO_NONE, | ||
72 | IWL_TX_FIFO_NONE, | ||
73 | IWL_TX_FIFO_NONE, | ||
74 | IWL_TX_FIFO_NONE, | ||
75 | IWL_TX_FIFO_NONE, | ||
76 | IWL_TX_FIFO_AC3 | ||
77 | }; | ||
78 | |||
79 | #endif /*CONFIG_IWL4965_HT */ | ||
80 | |||
81 | /* check contents of special bootstrap uCode SRAM */ | 58 | /* check contents of special bootstrap uCode SRAM */ |
82 | static int iwl4965_verify_bsm(struct iwl_priv *priv) | 59 | static int iwl4965_verify_bsm(struct iwl_priv *priv) |
83 | { | 60 | { |
@@ -156,15 +133,18 @@ static int iwl4965_load_bsm(struct iwl_priv *priv) | |||
156 | 133 | ||
157 | IWL_DEBUG_INFO("Begin load bsm\n"); | 134 | IWL_DEBUG_INFO("Begin load bsm\n"); |
158 | 135 | ||
136 | priv->ucode_type = UCODE_RT; | ||
137 | |||
159 | /* make sure bootstrap program is no larger than BSM's SRAM size */ | 138 | /* make sure bootstrap program is no larger than BSM's SRAM size */ |
160 | if (len > IWL_MAX_BSM_SIZE) | 139 | if (len > IWL_MAX_BSM_SIZE) |
161 | return -EINVAL; | 140 | return -EINVAL; |
162 | 141 | ||
163 | /* Tell bootstrap uCode where to find the "Initialize" uCode | 142 | /* Tell bootstrap uCode where to find the "Initialize" uCode |
164 | * in host DRAM ... host DRAM physical address bits 35:4 for 4965. | 143 | * in host DRAM ... host DRAM physical address bits 35:4 for 4965. |
165 | * NOTE: iwl4965_initialize_alive_start() will replace these values, | 144 | * NOTE: iwl_init_alive_start() will replace these values, |
166 | * after the "initialize" uCode has run, to point to | 145 | * after the "initialize" uCode has run, to point to |
167 | * runtime/protocol instructions and backup data cache. */ | 146 | * runtime/protocol instructions and backup data cache. |
147 | */ | ||
168 | pinst = priv->ucode_init.p_addr >> 4; | 148 | pinst = priv->ucode_init.p_addr >> 4; |
169 | pdata = priv->ucode_init_data.p_addr >> 4; | 149 | pdata = priv->ucode_init_data.p_addr >> 4; |
170 | inst_len = priv->ucode_init.len; | 150 | inst_len = priv->ucode_init.len; |
@@ -345,8 +325,8 @@ int iwl4965_hwrate_to_plcp_idx(u32 rate_n_flags) | |||
345 | 325 | ||
346 | /* 4965 legacy rate format, search for match in table */ | 326 | /* 4965 legacy rate format, search for match in table */ |
347 | } else { | 327 | } else { |
348 | for (idx = 0; idx < ARRAY_SIZE(iwl4965_rates); idx++) | 328 | for (idx = 0; idx < ARRAY_SIZE(iwl_rates); idx++) |
349 | if (iwl4965_rates[idx].plcp == (rate_n_flags & 0xFF)) | 329 | if (iwl_rates[idx].plcp == (rate_n_flags & 0xFF)) |
350 | return idx; | 330 | return idx; |
351 | } | 331 | } |
352 | 332 | ||
@@ -357,55 +337,26 @@ int iwl4965_hwrate_to_plcp_idx(u32 rate_n_flags) | |||
357 | * translate ucode response to mac80211 tx status control values | 337 | * translate ucode response to mac80211 tx status control values |
358 | */ | 338 | */ |
359 | void iwl4965_hwrate_to_tx_control(struct iwl_priv *priv, u32 rate_n_flags, | 339 | void iwl4965_hwrate_to_tx_control(struct iwl_priv *priv, u32 rate_n_flags, |
360 | struct ieee80211_tx_control *control) | 340 | struct ieee80211_tx_info *control) |
361 | { | 341 | { |
362 | int rate_index; | 342 | int rate_index; |
363 | 343 | ||
364 | control->antenna_sel_tx = | 344 | control->antenna_sel_tx = |
365 | ((rate_n_flags & RATE_MCS_ANT_ABC_MSK) >> RATE_MCS_ANT_POS); | 345 | ((rate_n_flags & RATE_MCS_ANT_ABC_MSK) >> RATE_MCS_ANT_POS); |
366 | if (rate_n_flags & RATE_MCS_HT_MSK) | 346 | if (rate_n_flags & RATE_MCS_HT_MSK) |
367 | control->flags |= IEEE80211_TXCTL_OFDM_HT; | 347 | control->flags |= IEEE80211_TX_CTL_OFDM_HT; |
368 | if (rate_n_flags & RATE_MCS_GF_MSK) | 348 | if (rate_n_flags & RATE_MCS_GF_MSK) |
369 | control->flags |= IEEE80211_TXCTL_GREEN_FIELD; | 349 | control->flags |= IEEE80211_TX_CTL_GREEN_FIELD; |
370 | if (rate_n_flags & RATE_MCS_FAT_MSK) | 350 | if (rate_n_flags & RATE_MCS_FAT_MSK) |
371 | control->flags |= IEEE80211_TXCTL_40_MHZ_WIDTH; | 351 | control->flags |= IEEE80211_TX_CTL_40_MHZ_WIDTH; |
372 | if (rate_n_flags & RATE_MCS_DUP_MSK) | 352 | if (rate_n_flags & RATE_MCS_DUP_MSK) |
373 | control->flags |= IEEE80211_TXCTL_DUP_DATA; | 353 | control->flags |= IEEE80211_TX_CTL_DUP_DATA; |
374 | if (rate_n_flags & RATE_MCS_SGI_MSK) | 354 | if (rate_n_flags & RATE_MCS_SGI_MSK) |
375 | control->flags |= IEEE80211_TXCTL_SHORT_GI; | 355 | control->flags |= IEEE80211_TX_CTL_SHORT_GI; |
376 | /* since iwl4965_hwrate_to_plcp_idx is band indifferent, we always use | ||
377 | * IEEE80211_BAND_2GHZ band as it contains all the rates */ | ||
378 | rate_index = iwl4965_hwrate_to_plcp_idx(rate_n_flags); | 356 | rate_index = iwl4965_hwrate_to_plcp_idx(rate_n_flags); |
379 | if (rate_index == -1) | 357 | if (control->band == IEEE80211_BAND_5GHZ) |
380 | control->tx_rate = NULL; | 358 | rate_index -= IWL_FIRST_OFDM_RATE; |
381 | else | 359 | control->tx_rate_idx = rate_index; |
382 | control->tx_rate = | ||
383 | &priv->bands[IEEE80211_BAND_2GHZ].bitrates[rate_index]; | ||
384 | } | ||
385 | |||
386 | int iwl4965_hw_rxq_stop(struct iwl_priv *priv) | ||
387 | { | ||
388 | int rc; | ||
389 | unsigned long flags; | ||
390 | |||
391 | spin_lock_irqsave(&priv->lock, flags); | ||
392 | rc = iwl_grab_nic_access(priv); | ||
393 | if (rc) { | ||
394 | spin_unlock_irqrestore(&priv->lock, flags); | ||
395 | return rc; | ||
396 | } | ||
397 | |||
398 | /* stop Rx DMA */ | ||
399 | iwl_write_direct32(priv, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); | ||
400 | rc = iwl_poll_direct_bit(priv, FH_MEM_RSSR_RX_STATUS_REG, | ||
401 | (1 << 24), 1000); | ||
402 | if (rc < 0) | ||
403 | IWL_ERROR("Can't stop Rx DMA.\n"); | ||
404 | |||
405 | iwl_release_nic_access(priv); | ||
406 | spin_unlock_irqrestore(&priv->lock, flags); | ||
407 | |||
408 | return 0; | ||
409 | } | 360 | } |
410 | 361 | ||
411 | /* | 362 | /* |
@@ -467,25 +418,13 @@ int iwl4965_set_pwr_src(struct iwl_priv *priv, enum iwl_pwr_src src) | |||
467 | return ret; | 418 | return ret; |
468 | } | 419 | } |
469 | 420 | ||
470 | static int iwl4965_disable_tx_fifo(struct iwl_priv *priv) | 421 | /* |
422 | * Activate/Deactivat Tx DMA/FIFO channels according tx fifos mask | ||
423 | * must be called under priv->lock and mac access | ||
424 | */ | ||
425 | static void iwl4965_txq_set_sched(struct iwl_priv *priv, u32 mask) | ||
471 | { | 426 | { |
472 | unsigned long flags; | 427 | iwl_write_prph(priv, IWL49_SCD_TXFACT, mask); |
473 | int ret; | ||
474 | |||
475 | spin_lock_irqsave(&priv->lock, flags); | ||
476 | |||
477 | ret = iwl_grab_nic_access(priv); | ||
478 | if (unlikely(ret)) { | ||
479 | IWL_ERROR("Tx fifo reset failed"); | ||
480 | spin_unlock_irqrestore(&priv->lock, flags); | ||
481 | return ret; | ||
482 | } | ||
483 | |||
484 | iwl_write_prph(priv, IWL49_SCD_TXFACT, 0); | ||
485 | iwl_release_nic_access(priv); | ||
486 | spin_unlock_irqrestore(&priv->lock, flags); | ||
487 | |||
488 | return 0; | ||
489 | } | 428 | } |
490 | 429 | ||
491 | static int iwl4965_apm_init(struct iwl_priv *priv) | 430 | static int iwl4965_apm_init(struct iwl_priv *priv) |
@@ -495,6 +434,10 @@ static int iwl4965_apm_init(struct iwl_priv *priv) | |||
495 | iwl_set_bit(priv, CSR_GIO_CHICKEN_BITS, | 434 | iwl_set_bit(priv, CSR_GIO_CHICKEN_BITS, |
496 | CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER); | 435 | CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER); |
497 | 436 | ||
437 | /* disable L0s without affecting L1 :don't wait for ICH L0s bug W/A) */ | ||
438 | iwl_set_bit(priv, CSR_GIO_CHICKEN_BITS, | ||
439 | CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX); | ||
440 | |||
498 | /* set "initialization complete" bit to move adapter | 441 | /* set "initialization complete" bit to move adapter |
499 | * D0U* --> D0A* state */ | 442 | * D0U* --> D0A* state */ |
500 | iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); | 443 | iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); |
@@ -513,11 +456,12 @@ static int iwl4965_apm_init(struct iwl_priv *priv) | |||
513 | goto out; | 456 | goto out; |
514 | 457 | ||
515 | /* enable DMA */ | 458 | /* enable DMA */ |
516 | iwl_write_prph(priv, APMG_CLK_CTRL_REG, | 459 | iwl_write_prph(priv, APMG_CLK_CTRL_REG, APMG_CLK_VAL_DMA_CLK_RQT | |
517 | APMG_CLK_VAL_DMA_CLK_RQT | APMG_CLK_VAL_BSM_CLK_RQT); | 460 | APMG_CLK_VAL_BSM_CLK_RQT); |
518 | 461 | ||
519 | udelay(20); | 462 | udelay(20); |
520 | 463 | ||
464 | /* disable L1-Active */ | ||
521 | iwl_set_bits_prph(priv, APMG_PCIDEV_STT_REG, | 465 | iwl_set_bits_prph(priv, APMG_PCIDEV_STT_REG, |
522 | APMG_PCIDEV_STT_VAL_L1_ACT_DIS); | 466 | APMG_PCIDEV_STT_VAL_L1_ACT_DIS); |
523 | 467 | ||
@@ -545,8 +489,13 @@ static void iwl4965_nic_config(struct iwl_priv *priv) | |||
545 | 489 | ||
546 | pci_read_config_byte(priv->pci_dev, PCI_LINK_CTRL, &val_link); | 490 | pci_read_config_byte(priv->pci_dev, PCI_LINK_CTRL, &val_link); |
547 | 491 | ||
548 | /* disable L1 entry -- workaround for pre-B1 */ | 492 | /* L1 is enabled by BIOS */ |
549 | pci_write_config_byte(priv->pci_dev, PCI_LINK_CTRL, val_link & ~0x02); | 493 | if ((val_link & PCI_LINK_VAL_L1_EN) == PCI_LINK_VAL_L1_EN) |
494 | /* diable L0S disabled L1A enabled */ | ||
495 | iwl_set_bit(priv, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); | ||
496 | else | ||
497 | /* L0S enabled L1A disabled */ | ||
498 | iwl_clear_bit(priv, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); | ||
550 | 499 | ||
551 | radio_cfg = iwl_eeprom_query16(priv, EEPROM_RADIO_CONFIG); | 500 | radio_cfg = iwl_eeprom_query16(priv, EEPROM_RADIO_CONFIG); |
552 | 501 | ||
@@ -568,10 +517,9 @@ static void iwl4965_nic_config(struct iwl_priv *priv) | |||
568 | spin_unlock_irqrestore(&priv->lock, flags); | 517 | spin_unlock_irqrestore(&priv->lock, flags); |
569 | } | 518 | } |
570 | 519 | ||
571 | int iwl4965_hw_nic_stop_master(struct iwl_priv *priv) | 520 | static int iwl4965_apm_stop_master(struct iwl_priv *priv) |
572 | { | 521 | { |
573 | int rc = 0; | 522 | int ret = 0; |
574 | u32 reg_val; | ||
575 | unsigned long flags; | 523 | unsigned long flags; |
576 | 524 | ||
577 | spin_lock_irqsave(&priv->lock, flags); | 525 | spin_lock_irqsave(&priv->lock, flags); |
@@ -579,64 +527,41 @@ int iwl4965_hw_nic_stop_master(struct iwl_priv *priv) | |||
579 | /* set stop master bit */ | 527 | /* set stop master bit */ |
580 | iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); | 528 | iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); |
581 | 529 | ||
582 | reg_val = iwl_read32(priv, CSR_GP_CNTRL); | 530 | ret = iwl_poll_bit(priv, CSR_RESET, |
583 | |||
584 | if (CSR_GP_CNTRL_REG_FLAG_MAC_POWER_SAVE == | ||
585 | (reg_val & CSR_GP_CNTRL_REG_MSK_POWER_SAVE_TYPE)) | ||
586 | IWL_DEBUG_INFO("Card in power save, master is already " | ||
587 | "stopped\n"); | ||
588 | else { | ||
589 | rc = iwl_poll_bit(priv, CSR_RESET, | ||
590 | CSR_RESET_REG_FLAG_MASTER_DISABLED, | 531 | CSR_RESET_REG_FLAG_MASTER_DISABLED, |
591 | CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); | 532 | CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); |
592 | if (rc < 0) { | 533 | if (ret < 0) |
593 | spin_unlock_irqrestore(&priv->lock, flags); | 534 | goto out; |
594 | return rc; | ||
595 | } | ||
596 | } | ||
597 | 535 | ||
536 | out: | ||
598 | spin_unlock_irqrestore(&priv->lock, flags); | 537 | spin_unlock_irqrestore(&priv->lock, flags); |
599 | IWL_DEBUG_INFO("stop master\n"); | 538 | IWL_DEBUG_INFO("stop master\n"); |
600 | 539 | ||
601 | return rc; | 540 | return ret; |
602 | } | 541 | } |
603 | 542 | ||
604 | /** | 543 | static void iwl4965_apm_stop(struct iwl_priv *priv) |
605 | * iwl4965_hw_txq_ctx_stop - Stop all Tx DMA channels, free Tx queue memory | ||
606 | */ | ||
607 | void iwl4965_hw_txq_ctx_stop(struct iwl_priv *priv) | ||
608 | { | 544 | { |
609 | |||
610 | int txq_id; | ||
611 | unsigned long flags; | 545 | unsigned long flags; |
612 | 546 | ||
613 | /* Stop each Tx DMA channel, and wait for it to be idle */ | 547 | iwl4965_apm_stop_master(priv); |
614 | for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) { | ||
615 | spin_lock_irqsave(&priv->lock, flags); | ||
616 | if (iwl_grab_nic_access(priv)) { | ||
617 | spin_unlock_irqrestore(&priv->lock, flags); | ||
618 | continue; | ||
619 | } | ||
620 | 548 | ||
621 | iwl_write_direct32(priv, | 549 | spin_lock_irqsave(&priv->lock, flags); |
622 | FH_TCSR_CHNL_TX_CONFIG_REG(txq_id), 0x0); | 550 | |
623 | iwl_poll_direct_bit(priv, FH_TSSR_TX_STATUS_REG, | 551 | iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); |
624 | FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE | ||
625 | (txq_id), 200); | ||
626 | iwl_release_nic_access(priv); | ||
627 | spin_unlock_irqrestore(&priv->lock, flags); | ||
628 | } | ||
629 | 552 | ||
630 | /* Deallocate memory for all Tx queues */ | 553 | udelay(10); |
631 | iwl_hw_txq_ctx_free(priv); | 554 | |
555 | iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); | ||
556 | spin_unlock_irqrestore(&priv->lock, flags); | ||
632 | } | 557 | } |
633 | 558 | ||
634 | int iwl4965_hw_nic_reset(struct iwl_priv *priv) | 559 | static int iwl4965_apm_reset(struct iwl_priv *priv) |
635 | { | 560 | { |
636 | int rc = 0; | 561 | int ret = 0; |
637 | unsigned long flags; | 562 | unsigned long flags; |
638 | 563 | ||
639 | iwl4965_hw_nic_stop_master(priv); | 564 | iwl4965_apm_stop_master(priv); |
640 | 565 | ||
641 | spin_lock_irqsave(&priv->lock, flags); | 566 | spin_lock_irqsave(&priv->lock, flags); |
642 | 567 | ||
@@ -644,34 +569,41 @@ int iwl4965_hw_nic_reset(struct iwl_priv *priv) | |||
644 | 569 | ||
645 | udelay(10); | 570 | udelay(10); |
646 | 571 | ||
572 | /* FIXME: put here L1A -L0S w/a */ | ||
573 | |||
647 | iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); | 574 | iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); |
648 | rc = iwl_poll_bit(priv, CSR_RESET, | 575 | |
576 | ret = iwl_poll_bit(priv, CSR_RESET, | ||
649 | CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, | 577 | CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, |
650 | CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25); | 578 | CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25); |
651 | 579 | ||
580 | if (ret) | ||
581 | goto out; | ||
582 | |||
652 | udelay(10); | 583 | udelay(10); |
653 | 584 | ||
654 | rc = iwl_grab_nic_access(priv); | 585 | ret = iwl_grab_nic_access(priv); |
655 | if (!rc) { | 586 | if (ret) |
656 | iwl_write_prph(priv, APMG_CLK_EN_REG, | 587 | goto out; |
657 | APMG_CLK_VAL_DMA_CLK_RQT | | 588 | /* Enable DMA and BSM Clock */ |
658 | APMG_CLK_VAL_BSM_CLK_RQT); | 589 | iwl_write_prph(priv, APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT | |
590 | APMG_CLK_VAL_BSM_CLK_RQT); | ||
659 | 591 | ||
660 | udelay(10); | 592 | udelay(10); |
661 | 593 | ||
662 | iwl_set_bits_prph(priv, APMG_PCIDEV_STT_REG, | 594 | /* disable L1A */ |
663 | APMG_PCIDEV_STT_VAL_L1_ACT_DIS); | 595 | iwl_set_bits_prph(priv, APMG_PCIDEV_STT_REG, |
596 | APMG_PCIDEV_STT_VAL_L1_ACT_DIS); | ||
664 | 597 | ||
665 | iwl_release_nic_access(priv); | 598 | iwl_release_nic_access(priv); |
666 | } | ||
667 | 599 | ||
668 | clear_bit(STATUS_HCMD_ACTIVE, &priv->status); | 600 | clear_bit(STATUS_HCMD_ACTIVE, &priv->status); |
669 | wake_up_interruptible(&priv->wait_command_queue); | 601 | wake_up_interruptible(&priv->wait_command_queue); |
670 | 602 | ||
603 | out: | ||
671 | spin_unlock_irqrestore(&priv->lock, flags); | 604 | spin_unlock_irqrestore(&priv->lock, flags); |
672 | 605 | ||
673 | return rc; | 606 | return ret; |
674 | |||
675 | } | 607 | } |
676 | 608 | ||
677 | #define REG_RECALIB_PERIOD (60) | 609 | #define REG_RECALIB_PERIOD (60) |
@@ -911,16 +843,6 @@ static const u16 default_queue_to_tx_fifo[] = { | |||
911 | IWL_TX_FIFO_HCCA_2 | 843 | IWL_TX_FIFO_HCCA_2 |
912 | }; | 844 | }; |
913 | 845 | ||
914 | static inline void iwl4965_txq_ctx_activate(struct iwl_priv *priv, int txq_id) | ||
915 | { | ||
916 | set_bit(txq_id, &priv->txq_ctx_active_msk); | ||
917 | } | ||
918 | |||
919 | static inline void iwl4965_txq_ctx_deactivate(struct iwl_priv *priv, int txq_id) | ||
920 | { | ||
921 | clear_bit(txq_id, &priv->txq_ctx_active_msk); | ||
922 | } | ||
923 | |||
924 | int iwl4965_alive_notify(struct iwl_priv *priv) | 846 | int iwl4965_alive_notify(struct iwl_priv *priv) |
925 | { | 847 | { |
926 | u32 a; | 848 | u32 a; |
@@ -930,15 +852,6 @@ int iwl4965_alive_notify(struct iwl_priv *priv) | |||
930 | 852 | ||
931 | spin_lock_irqsave(&priv->lock, flags); | 853 | spin_lock_irqsave(&priv->lock, flags); |
932 | 854 | ||
933 | #ifdef CONFIG_IWL4965_RUN_TIME_CALIB | ||
934 | memset(&(priv->sensitivity_data), 0, | ||
935 | sizeof(struct iwl_sensitivity_data)); | ||
936 | memset(&(priv->chain_noise_data), 0, | ||
937 | sizeof(struct iwl_chain_noise_data)); | ||
938 | for (i = 0; i < NUM_RX_CHAINS; i++) | ||
939 | priv->chain_noise_data.delta_gain_code[i] = | ||
940 | CHAIN_NOISE_DELTA_GAIN_INIT_VAL; | ||
941 | #endif /* CONFIG_IWL4965_RUN_TIME_CALIB*/ | ||
942 | ret = iwl_grab_nic_access(priv); | 855 | ret = iwl_grab_nic_access(priv); |
943 | if (ret) { | 856 | if (ret) { |
944 | spin_unlock_irqrestore(&priv->lock, flags); | 857 | spin_unlock_irqrestore(&priv->lock, flags); |
@@ -990,24 +903,20 @@ int iwl4965_alive_notify(struct iwl_priv *priv) | |||
990 | (1 << priv->hw_params.max_txq_num) - 1); | 903 | (1 << priv->hw_params.max_txq_num) - 1); |
991 | 904 | ||
992 | /* Activate all Tx DMA/FIFO channels */ | 905 | /* Activate all Tx DMA/FIFO channels */ |
993 | iwl_write_prph(priv, IWL49_SCD_TXFACT, | 906 | priv->cfg->ops->lib->txq_set_sched(priv, IWL_MASK(0, 7)); |
994 | SCD_TXFACT_REG_TXFIFO_MASK(0, 7)); | ||
995 | 907 | ||
996 | iwl4965_set_wr_ptrs(priv, IWL_CMD_QUEUE_NUM, 0); | 908 | iwl4965_set_wr_ptrs(priv, IWL_CMD_QUEUE_NUM, 0); |
997 | 909 | ||
998 | /* Map each Tx/cmd queue to its corresponding fifo */ | 910 | /* Map each Tx/cmd queue to its corresponding fifo */ |
999 | for (i = 0; i < ARRAY_SIZE(default_queue_to_tx_fifo); i++) { | 911 | for (i = 0; i < ARRAY_SIZE(default_queue_to_tx_fifo); i++) { |
1000 | int ac = default_queue_to_tx_fifo[i]; | 912 | int ac = default_queue_to_tx_fifo[i]; |
1001 | iwl4965_txq_ctx_activate(priv, i); | 913 | iwl_txq_ctx_activate(priv, i); |
1002 | iwl4965_tx_queue_set_status(priv, &priv->txq[i], ac, 0); | 914 | iwl4965_tx_queue_set_status(priv, &priv->txq[i], ac, 0); |
1003 | } | 915 | } |
1004 | 916 | ||
1005 | iwl_release_nic_access(priv); | 917 | iwl_release_nic_access(priv); |
1006 | spin_unlock_irqrestore(&priv->lock, flags); | 918 | spin_unlock_irqrestore(&priv->lock, flags); |
1007 | 919 | ||
1008 | /* Ask for statistics now, the uCode will send statistics notification | ||
1009 | * periodically after association */ | ||
1010 | iwl_send_statistics_request(priv, CMD_ASYNC); | ||
1011 | return ret; | 920 | return ret; |
1012 | } | 921 | } |
1013 | 922 | ||
@@ -1053,7 +962,6 @@ int iwl4965_hw_set_hw_params(struct iwl_priv *priv) | |||
1053 | 962 | ||
1054 | priv->hw_params.max_txq_num = priv->cfg->mod_params->num_of_queues; | 963 | priv->hw_params.max_txq_num = priv->cfg->mod_params->num_of_queues; |
1055 | priv->hw_params.sw_crypto = priv->cfg->mod_params->sw_crypto; | 964 | priv->hw_params.sw_crypto = priv->cfg->mod_params->sw_crypto; |
1056 | priv->hw_params.tx_cmd_len = sizeof(struct iwl4965_tx_cmd); | ||
1057 | priv->hw_params.max_rxq_size = RX_QUEUE_SIZE; | 965 | priv->hw_params.max_rxq_size = RX_QUEUE_SIZE; |
1058 | priv->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; | 966 | priv->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; |
1059 | if (priv->cfg->mod_params->amsdu_size_8K) | 967 | if (priv->cfg->mod_params->amsdu_size_8K) |
@@ -1857,8 +1765,8 @@ static int iwl4965_send_rxon_assoc(struct iwl_priv *priv) | |||
1857 | { | 1765 | { |
1858 | int ret = 0; | 1766 | int ret = 0; |
1859 | struct iwl4965_rxon_assoc_cmd rxon_assoc; | 1767 | struct iwl4965_rxon_assoc_cmd rxon_assoc; |
1860 | const struct iwl4965_rxon_cmd *rxon1 = &priv->staging_rxon; | 1768 | const struct iwl_rxon_cmd *rxon1 = &priv->staging_rxon; |
1861 | const struct iwl4965_rxon_cmd *rxon2 = &priv->active_rxon; | 1769 | const struct iwl_rxon_cmd *rxon2 = &priv->active_rxon; |
1862 | 1770 | ||
1863 | if ((rxon1->flags == rxon2->flags) && | 1771 | if ((rxon1->flags == rxon2->flags) && |
1864 | (rxon1->filter_flags == rxon2->filter_flags) && | 1772 | (rxon1->filter_flags == rxon2->filter_flags) && |
@@ -1934,76 +1842,6 @@ int iwl4965_hw_channel_switch(struct iwl_priv *priv, u16 channel) | |||
1934 | return rc; | 1842 | return rc; |
1935 | } | 1843 | } |
1936 | 1844 | ||
1937 | #define RTS_HCCA_RETRY_LIMIT 3 | ||
1938 | #define RTS_DFAULT_RETRY_LIMIT 60 | ||
1939 | |||
1940 | void iwl4965_hw_build_tx_cmd_rate(struct iwl_priv *priv, | ||
1941 | struct iwl_cmd *cmd, | ||
1942 | struct ieee80211_tx_control *ctrl, | ||
1943 | struct ieee80211_hdr *hdr, int sta_id, | ||
1944 | int is_hcca) | ||
1945 | { | ||
1946 | struct iwl4965_tx_cmd *tx = &cmd->cmd.tx; | ||
1947 | u8 rts_retry_limit = 0; | ||
1948 | u8 data_retry_limit = 0; | ||
1949 | u16 fc = le16_to_cpu(hdr->frame_control); | ||
1950 | u8 rate_plcp; | ||
1951 | u16 rate_flags = 0; | ||
1952 | int rate_idx = min(ctrl->tx_rate->hw_value & 0xffff, IWL_RATE_COUNT - 1); | ||
1953 | |||
1954 | rate_plcp = iwl4965_rates[rate_idx].plcp; | ||
1955 | |||
1956 | rts_retry_limit = (is_hcca) ? | ||
1957 | RTS_HCCA_RETRY_LIMIT : RTS_DFAULT_RETRY_LIMIT; | ||
1958 | |||
1959 | if ((rate_idx >= IWL_FIRST_CCK_RATE) && (rate_idx <= IWL_LAST_CCK_RATE)) | ||
1960 | rate_flags |= RATE_MCS_CCK_MSK; | ||
1961 | |||
1962 | |||
1963 | if (ieee80211_is_probe_response(fc)) { | ||
1964 | data_retry_limit = 3; | ||
1965 | if (data_retry_limit < rts_retry_limit) | ||
1966 | rts_retry_limit = data_retry_limit; | ||
1967 | } else | ||
1968 | data_retry_limit = IWL_DEFAULT_TX_RETRY; | ||
1969 | |||
1970 | if (priv->data_retry_limit != -1) | ||
1971 | data_retry_limit = priv->data_retry_limit; | ||
1972 | |||
1973 | |||
1974 | if (ieee80211_is_data(fc)) { | ||
1975 | tx->initial_rate_index = 0; | ||
1976 | tx->tx_flags |= TX_CMD_FLG_STA_RATE_MSK; | ||
1977 | } else { | ||
1978 | switch (fc & IEEE80211_FCTL_STYPE) { | ||
1979 | case IEEE80211_STYPE_AUTH: | ||
1980 | case IEEE80211_STYPE_DEAUTH: | ||
1981 | case IEEE80211_STYPE_ASSOC_REQ: | ||
1982 | case IEEE80211_STYPE_REASSOC_REQ: | ||
1983 | if (tx->tx_flags & TX_CMD_FLG_RTS_MSK) { | ||
1984 | tx->tx_flags &= ~TX_CMD_FLG_RTS_MSK; | ||
1985 | tx->tx_flags |= TX_CMD_FLG_CTS_MSK; | ||
1986 | } | ||
1987 | break; | ||
1988 | default: | ||
1989 | break; | ||
1990 | } | ||
1991 | |||
1992 | /* Alternate between antenna A and B for successive frames */ | ||
1993 | if (priv->use_ant_b_for_management_frame) { | ||
1994 | priv->use_ant_b_for_management_frame = 0; | ||
1995 | rate_flags |= RATE_MCS_ANT_B_MSK; | ||
1996 | } else { | ||
1997 | priv->use_ant_b_for_management_frame = 1; | ||
1998 | rate_flags |= RATE_MCS_ANT_A_MSK; | ||
1999 | } | ||
2000 | } | ||
2001 | |||
2002 | tx->rts_retry_limit = rts_retry_limit; | ||
2003 | tx->data_retry_limit = data_retry_limit; | ||
2004 | tx->rate_n_flags = iwl4965_hw_set_rate_n_flags(rate_plcp, rate_flags); | ||
2005 | } | ||
2006 | |||
2007 | static int iwl4965_shared_mem_rx_idx(struct iwl_priv *priv) | 1845 | static int iwl4965_shared_mem_rx_idx(struct iwl_priv *priv) |
2008 | { | 1846 | { |
2009 | struct iwl4965_shared *s = priv->shared_virt; | 1847 | struct iwl4965_shared *s = priv->shared_virt; |
@@ -2016,7 +1854,7 @@ int iwl4965_hw_get_temperature(struct iwl_priv *priv) | |||
2016 | } | 1854 | } |
2017 | 1855 | ||
2018 | unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv, | 1856 | unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv, |
2019 | struct iwl4965_frame *frame, u8 rate) | 1857 | struct iwl_frame *frame, u8 rate) |
2020 | { | 1858 | { |
2021 | struct iwl4965_tx_beacon_cmd *tx_beacon_cmd; | 1859 | struct iwl4965_tx_beacon_cmd *tx_beacon_cmd; |
2022 | unsigned int frame_size; | 1860 | unsigned int frame_size; |
@@ -2029,7 +1867,7 @@ unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv, | |||
2029 | 1867 | ||
2030 | frame_size = iwl4965_fill_beacon_frame(priv, | 1868 | frame_size = iwl4965_fill_beacon_frame(priv, |
2031 | tx_beacon_cmd->frame, | 1869 | tx_beacon_cmd->frame, |
2032 | iwl4965_broadcast_addr, | 1870 | iwl_bcast_addr, |
2033 | sizeof(frame->u) - sizeof(*tx_beacon_cmd)); | 1871 | sizeof(frame->u) - sizeof(*tx_beacon_cmd)); |
2034 | 1872 | ||
2035 | BUG_ON(frame_size > MAX_MPDU_SIZE); | 1873 | BUG_ON(frame_size > MAX_MPDU_SIZE); |
@@ -2047,40 +1885,6 @@ unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv, | |||
2047 | return (sizeof(*tx_beacon_cmd) + frame_size); | 1885 | return (sizeof(*tx_beacon_cmd) + frame_size); |
2048 | } | 1886 | } |
2049 | 1887 | ||
2050 | int iwl4965_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, void *ptr, | ||
2051 | dma_addr_t addr, u16 len) | ||
2052 | { | ||
2053 | int index, is_odd; | ||
2054 | struct iwl_tfd_frame *tfd = ptr; | ||
2055 | u32 num_tbs = IWL_GET_BITS(*tfd, num_tbs); | ||
2056 | |||
2057 | /* Each TFD can point to a maximum 20 Tx buffers */ | ||
2058 | if ((num_tbs >= MAX_NUM_OF_TBS) || (num_tbs < 0)) { | ||
2059 | IWL_ERROR("Error can not send more than %d chunks\n", | ||
2060 | MAX_NUM_OF_TBS); | ||
2061 | return -EINVAL; | ||
2062 | } | ||
2063 | |||
2064 | index = num_tbs / 2; | ||
2065 | is_odd = num_tbs & 0x1; | ||
2066 | |||
2067 | if (!is_odd) { | ||
2068 | tfd->pa[index].tb1_addr = cpu_to_le32(addr); | ||
2069 | IWL_SET_BITS(tfd->pa[index], tb1_addr_hi, | ||
2070 | iwl_get_dma_hi_address(addr)); | ||
2071 | IWL_SET_BITS(tfd->pa[index], tb1_len, len); | ||
2072 | } else { | ||
2073 | IWL_SET_BITS(tfd->pa[index], tb2_addr_lo16, | ||
2074 | (u32) (addr & 0xffff)); | ||
2075 | IWL_SET_BITS(tfd->pa[index], tb2_addr_hi20, addr >> 16); | ||
2076 | IWL_SET_BITS(tfd->pa[index], tb2_len, len); | ||
2077 | } | ||
2078 | |||
2079 | IWL_SET_BITS(*tfd, num_tbs, num_tbs + 1); | ||
2080 | |||
2081 | return 0; | ||
2082 | } | ||
2083 | |||
2084 | static int iwl4965_alloc_shared_mem(struct iwl_priv *priv) | 1888 | static int iwl4965_alloc_shared_mem(struct iwl_priv *priv) |
2085 | { | 1889 | { |
2086 | priv->shared_virt = pci_alloc_consistent(priv->pci_dev, | 1890 | priv->shared_virt = pci_alloc_consistent(priv->pci_dev, |
@@ -2436,7 +2240,7 @@ static void iwl4965_add_radiotap(struct iwl_priv *priv, | |||
2436 | if (rate == -1) | 2240 | if (rate == -1) |
2437 | iwl4965_rt->rt_rate = 0; | 2241 | iwl4965_rt->rt_rate = 0; |
2438 | else | 2242 | else |
2439 | iwl4965_rt->rt_rate = iwl4965_rates[rate].ieee; | 2243 | iwl4965_rt->rt_rate = iwl_rates[rate].ieee; |
2440 | 2244 | ||
2441 | /* | 2245 | /* |
2442 | * "antenna number" | 2246 | * "antenna number" |
@@ -2494,6 +2298,7 @@ static int iwl4965_set_decrypted_flag(struct iwl_priv *priv, | |||
2494 | RX_RES_STATUS_BAD_KEY_TTAK) | 2298 | RX_RES_STATUS_BAD_KEY_TTAK) |
2495 | break; | 2299 | break; |
2496 | 2300 | ||
2301 | case RX_RES_STATUS_SEC_TYPE_WEP: | ||
2497 | if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) == | 2302 | if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) == |
2498 | RX_RES_STATUS_BAD_ICV_MIC) { | 2303 | RX_RES_STATUS_BAD_ICV_MIC) { |
2499 | /* bad ICV, the packet is destroyed since the | 2304 | /* bad ICV, the packet is destroyed since the |
@@ -2501,7 +2306,6 @@ static int iwl4965_set_decrypted_flag(struct iwl_priv *priv, | |||
2501 | IWL_DEBUG_RX("Packet destroyed\n"); | 2306 | IWL_DEBUG_RX("Packet destroyed\n"); |
2502 | return -1; | 2307 | return -1; |
2503 | } | 2308 | } |
2504 | case RX_RES_STATUS_SEC_TYPE_WEP: | ||
2505 | case RX_RES_STATUS_SEC_TYPE_CCMP: | 2309 | case RX_RES_STATUS_SEC_TYPE_CCMP: |
2506 | if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) == | 2310 | if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) == |
2507 | RX_RES_STATUS_DECRYPT_OK) { | 2311 | RX_RES_STATUS_DECRYPT_OK) { |
@@ -2848,7 +2652,7 @@ static void iwl4965_dbg_report_frame(struct iwl_priv *priv, | |||
2848 | if (unlikely(rate_idx == -1)) | 2652 | if (unlikely(rate_idx == -1)) |
2849 | bitrate = 0; | 2653 | bitrate = 0; |
2850 | else | 2654 | else |
2851 | bitrate = iwl4965_rates[rate_idx].ieee / 2; | 2655 | bitrate = iwl_rates[rate_idx].ieee / 2; |
2852 | 2656 | ||
2853 | /* print frame summary. | 2657 | /* print frame summary. |
2854 | * MAC addresses show just the last byte (for brevity), | 2658 | * MAC addresses show just the last byte (for brevity), |
@@ -2885,7 +2689,7 @@ static inline void iwl4965_dbg_report_frame(struct iwl_priv *priv, | |||
2885 | 2689 | ||
2886 | /* Called for REPLY_RX (legacy ABG frames), or | 2690 | /* Called for REPLY_RX (legacy ABG frames), or |
2887 | * REPLY_RX_MPDU_CMD (HT high-throughput N frames). */ | 2691 | * REPLY_RX_MPDU_CMD (HT high-throughput N frames). */ |
2888 | static void iwl4965_rx_reply_rx(struct iwl_priv *priv, | 2692 | void iwl4965_rx_reply_rx(struct iwl_priv *priv, |
2889 | struct iwl_rx_mem_buffer *rxb) | 2693 | struct iwl_rx_mem_buffer *rxb) |
2890 | { | 2694 | { |
2891 | struct ieee80211_hdr *header; | 2695 | struct ieee80211_hdr *header; |
@@ -3059,57 +2863,9 @@ static void iwl4965_rx_reply_rx(struct iwl_priv *priv, | |||
3059 | } | 2863 | } |
3060 | } | 2864 | } |
3061 | 2865 | ||
3062 | /* Cache phy data (Rx signal strength, etc) for HT frame (REPLY_RX_PHY_CMD). | ||
3063 | * This will be used later in iwl4965_rx_reply_rx() for REPLY_RX_MPDU_CMD. */ | ||
3064 | static void iwl4965_rx_reply_rx_phy(struct iwl_priv *priv, | ||
3065 | struct iwl_rx_mem_buffer *rxb) | ||
3066 | { | ||
3067 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; | ||
3068 | priv->last_phy_res[0] = 1; | ||
3069 | memcpy(&priv->last_phy_res[1], &(pkt->u.raw[0]), | ||
3070 | sizeof(struct iwl4965_rx_phy_res)); | ||
3071 | } | ||
3072 | static void iwl4965_rx_missed_beacon_notif(struct iwl_priv *priv, | ||
3073 | struct iwl_rx_mem_buffer *rxb) | ||
3074 | |||
3075 | { | ||
3076 | #ifdef CONFIG_IWL4965_RUN_TIME_CALIB | ||
3077 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; | ||
3078 | struct iwl4965_missed_beacon_notif *missed_beacon; | ||
3079 | |||
3080 | missed_beacon = &pkt->u.missed_beacon; | ||
3081 | if (le32_to_cpu(missed_beacon->consequtive_missed_beacons) > 5) { | ||
3082 | IWL_DEBUG_CALIB("missed bcn cnsq %d totl %d rcd %d expctd %d\n", | ||
3083 | le32_to_cpu(missed_beacon->consequtive_missed_beacons), | ||
3084 | le32_to_cpu(missed_beacon->total_missed_becons), | ||
3085 | le32_to_cpu(missed_beacon->num_recvd_beacons), | ||
3086 | le32_to_cpu(missed_beacon->num_expected_beacons)); | ||
3087 | if (!test_bit(STATUS_SCANNING, &priv->status)) | ||
3088 | iwl_init_sensitivity(priv); | ||
3089 | } | ||
3090 | #endif /*CONFIG_IWL4965_RUN_TIME_CALIB*/ | ||
3091 | } | ||
3092 | #ifdef CONFIG_IWL4965_HT | 2866 | #ifdef CONFIG_IWL4965_HT |
3093 | 2867 | ||
3094 | /** | 2868 | /** |
3095 | * iwl4965_sta_modify_enable_tid_tx - Enable Tx for this TID in station table | ||
3096 | */ | ||
3097 | static void iwl4965_sta_modify_enable_tid_tx(struct iwl_priv *priv, | ||
3098 | int sta_id, int tid) | ||
3099 | { | ||
3100 | unsigned long flags; | ||
3101 | |||
3102 | /* Remove "disable" flag, to enable Tx for this TID */ | ||
3103 | spin_lock_irqsave(&priv->sta_lock, flags); | ||
3104 | priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_TID_DISABLE_TX; | ||
3105 | priv->stations[sta_id].sta.tid_disable_tx &= cpu_to_le16(~(1 << tid)); | ||
3106 | priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; | ||
3107 | spin_unlock_irqrestore(&priv->sta_lock, flags); | ||
3108 | |||
3109 | iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC); | ||
3110 | } | ||
3111 | |||
3112 | /** | ||
3113 | * iwl4965_tx_status_reply_compressed_ba - Update tx status from block-ack | 2869 | * iwl4965_tx_status_reply_compressed_ba - Update tx status from block-ack |
3114 | * | 2870 | * |
3115 | * Go through block-ack's bitmap of ACK'd frames, update driver's record of | 2871 | * Go through block-ack's bitmap of ACK'd frames, update driver's record of |
@@ -3126,7 +2882,7 @@ static int iwl4965_tx_status_reply_compressed_ba(struct iwl_priv *priv, | |||
3126 | u16 scd_flow = le16_to_cpu(ba_resp->scd_flow); | 2882 | u16 scd_flow = le16_to_cpu(ba_resp->scd_flow); |
3127 | u64 bitmap; | 2883 | u64 bitmap; |
3128 | int successes = 0; | 2884 | int successes = 0; |
3129 | struct ieee80211_tx_status *tx_status; | 2885 | struct ieee80211_tx_info *info; |
3130 | 2886 | ||
3131 | if (unlikely(!agg->wait_for_ba)) { | 2887 | if (unlikely(!agg->wait_for_ba)) { |
3132 | IWL_ERROR("Received BA when not expected\n"); | 2888 | IWL_ERROR("Received BA when not expected\n"); |
@@ -3164,13 +2920,13 @@ static int iwl4965_tx_status_reply_compressed_ba(struct iwl_priv *priv, | |||
3164 | agg->start_idx + i); | 2920 | agg->start_idx + i); |
3165 | } | 2921 | } |
3166 | 2922 | ||
3167 | tx_status = &priv->txq[scd_flow].txb[agg->start_idx].status; | 2923 | info = IEEE80211_SKB_CB(priv->txq[scd_flow].txb[agg->start_idx].skb[0]); |
3168 | tx_status->flags = IEEE80211_TX_STATUS_ACK; | 2924 | memset(&info->status, 0, sizeof(info->status)); |
3169 | tx_status->flags |= IEEE80211_TX_STATUS_AMPDU; | 2925 | info->flags = IEEE80211_TX_STAT_ACK; |
3170 | tx_status->ampdu_ack_map = successes; | 2926 | info->flags |= IEEE80211_TX_STAT_AMPDU; |
3171 | tx_status->ampdu_ack_len = agg->frame_count; | 2927 | info->status.ampdu_ack_map = successes; |
3172 | iwl4965_hwrate_to_tx_control(priv, agg->rate_n_flags, | 2928 | info->status.ampdu_ack_len = agg->frame_count; |
3173 | &tx_status->control); | 2929 | iwl4965_hwrate_to_tx_control(priv, agg->rate_n_flags, info); |
3174 | 2930 | ||
3175 | IWL_DEBUG_TX_REPLY("Bitmap %llx\n", (unsigned long long)bitmap); | 2931 | IWL_DEBUG_TX_REPLY("Bitmap %llx\n", (unsigned long long)bitmap); |
3176 | 2932 | ||
@@ -3195,8 +2951,8 @@ static void iwl4965_tx_queue_stop_scheduler(struct iwl_priv *priv, | |||
3195 | * txq_id must be greater than IWL_BACK_QUEUE_FIRST_ID | 2951 | * txq_id must be greater than IWL_BACK_QUEUE_FIRST_ID |
3196 | * priv->lock must be held by the caller | 2952 | * priv->lock must be held by the caller |
3197 | */ | 2953 | */ |
3198 | static int iwl4965_tx_queue_agg_disable(struct iwl_priv *priv, u16 txq_id, | 2954 | static int iwl4965_txq_agg_disable(struct iwl_priv *priv, u16 txq_id, |
3199 | u16 ssn_idx, u8 tx_fifo) | 2955 | u16 ssn_idx, u8 tx_fifo) |
3200 | { | 2956 | { |
3201 | int ret = 0; | 2957 | int ret = 0; |
3202 | 2958 | ||
@@ -3220,7 +2976,7 @@ static int iwl4965_tx_queue_agg_disable(struct iwl_priv *priv, u16 txq_id, | |||
3220 | iwl4965_set_wr_ptrs(priv, txq_id, ssn_idx); | 2976 | iwl4965_set_wr_ptrs(priv, txq_id, ssn_idx); |
3221 | 2977 | ||
3222 | iwl_clear_bits_prph(priv, IWL49_SCD_INTERRUPT_MASK, (1 << txq_id)); | 2978 | iwl_clear_bits_prph(priv, IWL49_SCD_INTERRUPT_MASK, (1 << txq_id)); |
3223 | iwl4965_txq_ctx_deactivate(priv, txq_id); | 2979 | iwl_txq_ctx_deactivate(priv, txq_id); |
3224 | iwl4965_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 0); | 2980 | iwl4965_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 0); |
3225 | 2981 | ||
3226 | iwl_release_nic_access(priv); | 2982 | iwl_release_nic_access(priv); |
@@ -3228,49 +2984,6 @@ static int iwl4965_tx_queue_agg_disable(struct iwl_priv *priv, u16 txq_id, | |||
3228 | return 0; | 2984 | return 0; |
3229 | } | 2985 | } |
3230 | 2986 | ||
3231 | int iwl4965_check_empty_hw_queue(struct iwl_priv *priv, int sta_id, | ||
3232 | u8 tid, int txq_id) | ||
3233 | { | ||
3234 | struct iwl4965_queue *q = &priv->txq[txq_id].q; | ||
3235 | u8 *addr = priv->stations[sta_id].sta.sta.addr; | ||
3236 | struct iwl_tid_data *tid_data = &priv->stations[sta_id].tid[tid]; | ||
3237 | |||
3238 | switch (priv->stations[sta_id].tid[tid].agg.state) { | ||
3239 | case IWL_EMPTYING_HW_QUEUE_DELBA: | ||
3240 | /* We are reclaiming the last packet of the */ | ||
3241 | /* aggregated HW queue */ | ||
3242 | if (txq_id == tid_data->agg.txq_id && | ||
3243 | q->read_ptr == q->write_ptr) { | ||
3244 | u16 ssn = SEQ_TO_SN(tid_data->seq_number); | ||
3245 | int tx_fifo = default_tid_to_tx_fifo[tid]; | ||
3246 | IWL_DEBUG_HT("HW queue empty: continue DELBA flow\n"); | ||
3247 | iwl4965_tx_queue_agg_disable(priv, txq_id, | ||
3248 | ssn, tx_fifo); | ||
3249 | tid_data->agg.state = IWL_AGG_OFF; | ||
3250 | ieee80211_stop_tx_ba_cb_irqsafe(priv->hw, addr, tid); | ||
3251 | } | ||
3252 | break; | ||
3253 | case IWL_EMPTYING_HW_QUEUE_ADDBA: | ||
3254 | /* We are reclaiming the last packet of the queue */ | ||
3255 | if (tid_data->tfds_in_queue == 0) { | ||
3256 | IWL_DEBUG_HT("HW queue empty: continue ADDBA flow\n"); | ||
3257 | tid_data->agg.state = IWL_AGG_ON; | ||
3258 | ieee80211_start_tx_ba_cb_irqsafe(priv->hw, addr, tid); | ||
3259 | } | ||
3260 | break; | ||
3261 | } | ||
3262 | return 0; | ||
3263 | } | ||
3264 | |||
3265 | /** | ||
3266 | * iwl4965_queue_dec_wrap - Decrement queue index, wrap back to end if needed | ||
3267 | * @index -- current index | ||
3268 | * @n_bd -- total number of entries in queue (s/b power of 2) | ||
3269 | */ | ||
3270 | static inline int iwl4965_queue_dec_wrap(int index, int n_bd) | ||
3271 | { | ||
3272 | return (index == 0) ? n_bd - 1 : index - 1; | ||
3273 | } | ||
3274 | 2987 | ||
3275 | /** | 2988 | /** |
3276 | * iwl4965_rx_reply_compressed_ba - Handler for REPLY_COMPRESSED_BA | 2989 | * iwl4965_rx_reply_compressed_ba - Handler for REPLY_COMPRESSED_BA |
@@ -3304,7 +3017,7 @@ static void iwl4965_rx_reply_compressed_ba(struct iwl_priv *priv, | |||
3304 | agg = &priv->stations[ba_resp->sta_id].tid[ba_resp->tid].agg; | 3017 | agg = &priv->stations[ba_resp->sta_id].tid[ba_resp->tid].agg; |
3305 | 3018 | ||
3306 | /* Find index just before block-ack window */ | 3019 | /* Find index just before block-ack window */ |
3307 | index = iwl4965_queue_dec_wrap(ba_resp_scd_ssn & 0xff, txq->q.n_bd); | 3020 | index = iwl_queue_dec_wrap(ba_resp_scd_ssn & 0xff, txq->q.n_bd); |
3308 | 3021 | ||
3309 | /* TODO: Need to get this copy more safely - now good for debug */ | 3022 | /* TODO: Need to get this copy more safely - now good for debug */ |
3310 | 3023 | ||
@@ -3334,15 +3047,16 @@ static void iwl4965_rx_reply_compressed_ba(struct iwl_priv *priv, | |||
3334 | /* calculate mac80211 ampdu sw queue to wake */ | 3047 | /* calculate mac80211 ampdu sw queue to wake */ |
3335 | int ampdu_q = | 3048 | int ampdu_q = |
3336 | scd_flow - IWL_BACK_QUEUE_FIRST_ID + priv->hw->queues; | 3049 | scd_flow - IWL_BACK_QUEUE_FIRST_ID + priv->hw->queues; |
3337 | int freed = iwl4965_tx_queue_reclaim(priv, scd_flow, index); | 3050 | int freed = iwl_tx_queue_reclaim(priv, scd_flow, index); |
3338 | priv->stations[ba_resp->sta_id]. | 3051 | priv->stations[ba_resp->sta_id]. |
3339 | tid[ba_resp->tid].tfds_in_queue -= freed; | 3052 | tid[ba_resp->tid].tfds_in_queue -= freed; |
3340 | if (iwl4965_queue_space(&txq->q) > txq->q.low_mark && | 3053 | if (iwl_queue_space(&txq->q) > txq->q.low_mark && |
3341 | priv->mac80211_registered && | 3054 | priv->mac80211_registered && |
3342 | agg->state != IWL_EMPTYING_HW_QUEUE_DELBA) | 3055 | agg->state != IWL_EMPTYING_HW_QUEUE_DELBA) |
3343 | ieee80211_wake_queue(priv->hw, ampdu_q); | 3056 | ieee80211_wake_queue(priv->hw, ampdu_q); |
3344 | iwl4965_check_empty_hw_queue(priv, ba_resp->sta_id, | 3057 | |
3345 | ba_resp->tid, scd_flow); | 3058 | iwl_txq_check_empty(priv, ba_resp->sta_id, |
3059 | ba_resp->tid, scd_flow); | ||
3346 | } | 3060 | } |
3347 | } | 3061 | } |
3348 | 3062 | ||
@@ -3356,7 +3070,7 @@ static int iwl4965_tx_queue_set_q2ratid(struct iwl_priv *priv, u16 ra_tid, | |||
3356 | u32 tbl_dw; | 3070 | u32 tbl_dw; |
3357 | u16 scd_q2ratid; | 3071 | u16 scd_q2ratid; |
3358 | 3072 | ||
3359 | scd_q2ratid = ra_tid & IWL49_SCD_QUEUE_RA_TID_MAP_RATID_MSK; | 3073 | scd_q2ratid = ra_tid & IWL_SCD_QUEUE_RA_TID_MAP_RATID_MSK; |
3360 | 3074 | ||
3361 | tbl_dw_addr = priv->scd_base_addr + | 3075 | tbl_dw_addr = priv->scd_base_addr + |
3362 | IWL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(txq_id); | 3076 | IWL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(txq_id); |
@@ -3380,12 +3094,11 @@ static int iwl4965_tx_queue_set_q2ratid(struct iwl_priv *priv, u16 ra_tid, | |||
3380 | * NOTE: txq_id must be greater than IWL_BACK_QUEUE_FIRST_ID, | 3094 | * NOTE: txq_id must be greater than IWL_BACK_QUEUE_FIRST_ID, |
3381 | * i.e. it must be one of the higher queues used for aggregation | 3095 | * i.e. it must be one of the higher queues used for aggregation |
3382 | */ | 3096 | */ |
3383 | static int iwl4965_tx_queue_agg_enable(struct iwl_priv *priv, int txq_id, | 3097 | static int iwl4965_txq_agg_enable(struct iwl_priv *priv, int txq_id, |
3384 | int tx_fifo, int sta_id, int tid, | 3098 | int tx_fifo, int sta_id, int tid, u16 ssn_idx) |
3385 | u16 ssn_idx) | ||
3386 | { | 3099 | { |
3387 | unsigned long flags; | 3100 | unsigned long flags; |
3388 | int rc; | 3101 | int ret; |
3389 | u16 ra_tid; | 3102 | u16 ra_tid; |
3390 | 3103 | ||
3391 | if (IWL_BACK_QUEUE_FIRST_ID > txq_id) | 3104 | if (IWL_BACK_QUEUE_FIRST_ID > txq_id) |
@@ -3395,13 +3108,13 @@ static int iwl4965_tx_queue_agg_enable(struct iwl_priv *priv, int txq_id, | |||
3395 | ra_tid = BUILD_RAxTID(sta_id, tid); | 3108 | ra_tid = BUILD_RAxTID(sta_id, tid); |
3396 | 3109 | ||
3397 | /* Modify device's station table to Tx this TID */ | 3110 | /* Modify device's station table to Tx this TID */ |
3398 | iwl4965_sta_modify_enable_tid_tx(priv, sta_id, tid); | 3111 | iwl_sta_modify_enable_tid_tx(priv, sta_id, tid); |
3399 | 3112 | ||
3400 | spin_lock_irqsave(&priv->lock, flags); | 3113 | spin_lock_irqsave(&priv->lock, flags); |
3401 | rc = iwl_grab_nic_access(priv); | 3114 | ret = iwl_grab_nic_access(priv); |
3402 | if (rc) { | 3115 | if (ret) { |
3403 | spin_unlock_irqrestore(&priv->lock, flags); | 3116 | spin_unlock_irqrestore(&priv->lock, flags); |
3404 | return rc; | 3117 | return ret; |
3405 | } | 3118 | } |
3406 | 3119 | ||
3407 | /* Stop this Tx queue before configuring it */ | 3120 | /* Stop this Tx queue before configuring it */ |
@@ -3443,109 +3156,8 @@ static int iwl4965_tx_queue_agg_enable(struct iwl_priv *priv, int txq_id, | |||
3443 | 3156 | ||
3444 | #endif /* CONFIG_IWL4965_HT */ | 3157 | #endif /* CONFIG_IWL4965_HT */ |
3445 | 3158 | ||
3446 | /** | ||
3447 | * iwl4965_add_station - Initialize a station's hardware rate table | ||
3448 | * | ||
3449 | * The uCode's station table contains a table of fallback rates | ||
3450 | * for automatic fallback during transmission. | ||
3451 | * | ||
3452 | * NOTE: This sets up a default set of values. These will be replaced later | ||
3453 | * if the driver's iwl-4965-rs rate scaling algorithm is used, instead of | ||
3454 | * rc80211_simple. | ||
3455 | * | ||
3456 | * NOTE: Run REPLY_ADD_STA command to set up station table entry, before | ||
3457 | * calling this function (which runs REPLY_TX_LINK_QUALITY_CMD, | ||
3458 | * which requires station table entry to exist). | ||
3459 | */ | ||
3460 | void iwl4965_add_station(struct iwl_priv *priv, const u8 *addr, int is_ap) | ||
3461 | { | ||
3462 | int i, r; | ||
3463 | struct iwl_link_quality_cmd link_cmd = { | ||
3464 | .reserved1 = 0, | ||
3465 | }; | ||
3466 | u16 rate_flags; | ||
3467 | |||
3468 | /* Set up the rate scaling to start at selected rate, fall back | ||
3469 | * all the way down to 1M in IEEE order, and then spin on 1M */ | ||
3470 | if (is_ap) | ||
3471 | r = IWL_RATE_54M_INDEX; | ||
3472 | else if (priv->band == IEEE80211_BAND_5GHZ) | ||
3473 | r = IWL_RATE_6M_INDEX; | ||
3474 | else | ||
3475 | r = IWL_RATE_1M_INDEX; | ||
3476 | |||
3477 | for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { | ||
3478 | rate_flags = 0; | ||
3479 | if (r >= IWL_FIRST_CCK_RATE && r <= IWL_LAST_CCK_RATE) | ||
3480 | rate_flags |= RATE_MCS_CCK_MSK; | ||
3481 | |||
3482 | /* Use Tx antenna B only */ | ||
3483 | rate_flags |= RATE_MCS_ANT_B_MSK; /*FIXME:RS*/ | ||
3484 | |||
3485 | link_cmd.rs_table[i].rate_n_flags = | ||
3486 | iwl4965_hw_set_rate_n_flags(iwl4965_rates[r].plcp, rate_flags); | ||
3487 | r = iwl4965_get_prev_ieee_rate(r); | ||
3488 | } | ||
3489 | |||
3490 | link_cmd.general_params.single_stream_ant_msk = 2; | ||
3491 | link_cmd.general_params.dual_stream_ant_msk = 3; | ||
3492 | link_cmd.agg_params.agg_dis_start_th = 3; | ||
3493 | link_cmd.agg_params.agg_time_limit = cpu_to_le16(4000); | ||
3494 | |||
3495 | /* Update the rate scaling for control frame Tx to AP */ | ||
3496 | link_cmd.sta_id = is_ap ? IWL_AP_ID : priv->hw_params.bcast_sta_id; | ||
3497 | |||
3498 | iwl_send_cmd_pdu_async(priv, REPLY_TX_LINK_QUALITY_CMD, | ||
3499 | sizeof(link_cmd), &link_cmd, NULL); | ||
3500 | } | ||
3501 | 3159 | ||
3502 | #ifdef CONFIG_IWL4965_HT | 3160 | #ifdef CONFIG_IWL4965_HT |
3503 | |||
3504 | void iwl4965_set_ht_add_station(struct iwl_priv *priv, u8 index, | ||
3505 | struct ieee80211_ht_info *sta_ht_inf) | ||
3506 | { | ||
3507 | __le32 sta_flags; | ||
3508 | u8 mimo_ps_mode; | ||
3509 | |||
3510 | if (!sta_ht_inf || !sta_ht_inf->ht_supported) | ||
3511 | goto done; | ||
3512 | |||
3513 | mimo_ps_mode = (sta_ht_inf->cap & IEEE80211_HT_CAP_MIMO_PS) >> 2; | ||
3514 | |||
3515 | sta_flags = priv->stations[index].sta.station_flags; | ||
3516 | |||
3517 | sta_flags &= ~(STA_FLG_RTS_MIMO_PROT_MSK | STA_FLG_MIMO_DIS_MSK); | ||
3518 | |||
3519 | switch (mimo_ps_mode) { | ||
3520 | case WLAN_HT_CAP_MIMO_PS_STATIC: | ||
3521 | sta_flags |= STA_FLG_MIMO_DIS_MSK; | ||
3522 | break; | ||
3523 | case WLAN_HT_CAP_MIMO_PS_DYNAMIC: | ||
3524 | sta_flags |= STA_FLG_RTS_MIMO_PROT_MSK; | ||
3525 | break; | ||
3526 | case WLAN_HT_CAP_MIMO_PS_DISABLED: | ||
3527 | break; | ||
3528 | default: | ||
3529 | IWL_WARNING("Invalid MIMO PS mode %d", mimo_ps_mode); | ||
3530 | break; | ||
3531 | } | ||
3532 | |||
3533 | sta_flags |= cpu_to_le32( | ||
3534 | (u32)sta_ht_inf->ampdu_factor << STA_FLG_MAX_AGG_SIZE_POS); | ||
3535 | |||
3536 | sta_flags |= cpu_to_le32( | ||
3537 | (u32)sta_ht_inf->ampdu_density << STA_FLG_AGG_MPDU_DENSITY_POS); | ||
3538 | |||
3539 | if (iwl_is_fat_tx_allowed(priv, sta_ht_inf)) | ||
3540 | sta_flags |= STA_FLG_FAT_EN_MSK; | ||
3541 | else | ||
3542 | sta_flags &= ~STA_FLG_FAT_EN_MSK; | ||
3543 | |||
3544 | priv->stations[index].sta.station_flags = sta_flags; | ||
3545 | done: | ||
3546 | return; | ||
3547 | } | ||
3548 | |||
3549 | static int iwl4965_rx_agg_start(struct iwl_priv *priv, | 3161 | static int iwl4965_rx_agg_start(struct iwl_priv *priv, |
3550 | const u8 *addr, int tid, u16 ssn) | 3162 | const u8 *addr, int tid, u16 ssn) |
3551 | { | 3163 | { |
@@ -3589,137 +3201,6 @@ static int iwl4965_rx_agg_stop(struct iwl_priv *priv, | |||
3589 | CMD_ASYNC); | 3201 | CMD_ASYNC); |
3590 | } | 3202 | } |
3591 | 3203 | ||
3592 | /* | ||
3593 | * Find first available (lowest unused) Tx Queue, mark it "active". | ||
3594 | * Called only when finding queue for aggregation. | ||
3595 | * Should never return anything < 7, because they should already | ||
3596 | * be in use as EDCA AC (0-3), Command (4), HCCA (5, 6). | ||
3597 | */ | ||
3598 | static int iwl4965_txq_ctx_activate_free(struct iwl_priv *priv) | ||
3599 | { | ||
3600 | int txq_id; | ||
3601 | |||
3602 | for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) | ||
3603 | if (!test_and_set_bit(txq_id, &priv->txq_ctx_active_msk)) | ||
3604 | return txq_id; | ||
3605 | return -1; | ||
3606 | } | ||
3607 | |||
3608 | static int iwl4965_tx_agg_start(struct ieee80211_hw *hw, const u8 *ra, | ||
3609 | u16 tid, u16 *start_seq_num) | ||
3610 | { | ||
3611 | struct iwl_priv *priv = hw->priv; | ||
3612 | int sta_id; | ||
3613 | int tx_fifo; | ||
3614 | int txq_id; | ||
3615 | int ssn = -1; | ||
3616 | int ret = 0; | ||
3617 | unsigned long flags; | ||
3618 | struct iwl_tid_data *tid_data; | ||
3619 | DECLARE_MAC_BUF(mac); | ||
3620 | |||
3621 | if (likely(tid < ARRAY_SIZE(default_tid_to_tx_fifo))) | ||
3622 | tx_fifo = default_tid_to_tx_fifo[tid]; | ||
3623 | else | ||
3624 | return -EINVAL; | ||
3625 | |||
3626 | IWL_WARNING("%s on ra = %s tid = %d\n", | ||
3627 | __func__, print_mac(mac, ra), tid); | ||
3628 | |||
3629 | sta_id = iwl_find_station(priv, ra); | ||
3630 | if (sta_id == IWL_INVALID_STATION) | ||
3631 | return -ENXIO; | ||
3632 | |||
3633 | if (priv->stations[sta_id].tid[tid].agg.state != IWL_AGG_OFF) { | ||
3634 | IWL_ERROR("Start AGG when state is not IWL_AGG_OFF !\n"); | ||
3635 | return -ENXIO; | ||
3636 | } | ||
3637 | |||
3638 | txq_id = iwl4965_txq_ctx_activate_free(priv); | ||
3639 | if (txq_id == -1) | ||
3640 | return -ENXIO; | ||
3641 | |||
3642 | spin_lock_irqsave(&priv->sta_lock, flags); | ||
3643 | tid_data = &priv->stations[sta_id].tid[tid]; | ||
3644 | ssn = SEQ_TO_SN(tid_data->seq_number); | ||
3645 | tid_data->agg.txq_id = txq_id; | ||
3646 | spin_unlock_irqrestore(&priv->sta_lock, flags); | ||
3647 | |||
3648 | *start_seq_num = ssn; | ||
3649 | ret = iwl4965_tx_queue_agg_enable(priv, txq_id, tx_fifo, | ||
3650 | sta_id, tid, ssn); | ||
3651 | if (ret) | ||
3652 | return ret; | ||
3653 | |||
3654 | ret = 0; | ||
3655 | if (tid_data->tfds_in_queue == 0) { | ||
3656 | printk(KERN_ERR "HW queue is empty\n"); | ||
3657 | tid_data->agg.state = IWL_AGG_ON; | ||
3658 | ieee80211_start_tx_ba_cb_irqsafe(hw, ra, tid); | ||
3659 | } else { | ||
3660 | IWL_DEBUG_HT("HW queue is NOT empty: %d packets in HW queue\n", | ||
3661 | tid_data->tfds_in_queue); | ||
3662 | tid_data->agg.state = IWL_EMPTYING_HW_QUEUE_ADDBA; | ||
3663 | } | ||
3664 | return ret; | ||
3665 | } | ||
3666 | |||
3667 | static int iwl4965_tx_agg_stop(struct ieee80211_hw *hw, const u8 *ra, u16 tid) | ||
3668 | { | ||
3669 | struct iwl_priv *priv = hw->priv; | ||
3670 | int tx_fifo_id, txq_id, sta_id, ssn = -1; | ||
3671 | struct iwl_tid_data *tid_data; | ||
3672 | int ret, write_ptr, read_ptr; | ||
3673 | unsigned long flags; | ||
3674 | DECLARE_MAC_BUF(mac); | ||
3675 | |||
3676 | if (!ra) { | ||
3677 | IWL_ERROR("ra = NULL\n"); | ||
3678 | return -EINVAL; | ||
3679 | } | ||
3680 | |||
3681 | if (likely(tid < ARRAY_SIZE(default_tid_to_tx_fifo))) | ||
3682 | tx_fifo_id = default_tid_to_tx_fifo[tid]; | ||
3683 | else | ||
3684 | return -EINVAL; | ||
3685 | |||
3686 | sta_id = iwl_find_station(priv, ra); | ||
3687 | |||
3688 | if (sta_id == IWL_INVALID_STATION) | ||
3689 | return -ENXIO; | ||
3690 | |||
3691 | if (priv->stations[sta_id].tid[tid].agg.state != IWL_AGG_ON) | ||
3692 | IWL_WARNING("Stopping AGG while state not IWL_AGG_ON\n"); | ||
3693 | |||
3694 | tid_data = &priv->stations[sta_id].tid[tid]; | ||
3695 | ssn = (tid_data->seq_number & IEEE80211_SCTL_SEQ) >> 4; | ||
3696 | txq_id = tid_data->agg.txq_id; | ||
3697 | write_ptr = priv->txq[txq_id].q.write_ptr; | ||
3698 | read_ptr = priv->txq[txq_id].q.read_ptr; | ||
3699 | |||
3700 | /* The queue is not empty */ | ||
3701 | if (write_ptr != read_ptr) { | ||
3702 | IWL_DEBUG_HT("Stopping a non empty AGG HW QUEUE\n"); | ||
3703 | priv->stations[sta_id].tid[tid].agg.state = | ||
3704 | IWL_EMPTYING_HW_QUEUE_DELBA; | ||
3705 | return 0; | ||
3706 | } | ||
3707 | |||
3708 | IWL_DEBUG_HT("HW queue is empty\n"); | ||
3709 | priv->stations[sta_id].tid[tid].agg.state = IWL_AGG_OFF; | ||
3710 | |||
3711 | spin_lock_irqsave(&priv->lock, flags); | ||
3712 | ret = iwl4965_tx_queue_agg_disable(priv, txq_id, ssn, tx_fifo_id); | ||
3713 | spin_unlock_irqrestore(&priv->lock, flags); | ||
3714 | |||
3715 | if (ret) | ||
3716 | return ret; | ||
3717 | |||
3718 | ieee80211_stop_tx_ba_cb_irqsafe(priv->hw, ra, tid); | ||
3719 | |||
3720 | return 0; | ||
3721 | } | ||
3722 | |||
3723 | int iwl4965_mac_ampdu_action(struct ieee80211_hw *hw, | 3204 | int iwl4965_mac_ampdu_action(struct ieee80211_hw *hw, |
3724 | enum ieee80211_ampdu_mlme_action action, | 3205 | enum ieee80211_ampdu_mlme_action action, |
3725 | const u8 *addr, u16 tid, u16 *ssn) | 3206 | const u8 *addr, u16 tid, u16 *ssn) |
@@ -3739,10 +3220,10 @@ int iwl4965_mac_ampdu_action(struct ieee80211_hw *hw, | |||
3739 | return iwl4965_rx_agg_stop(priv, addr, tid); | 3220 | return iwl4965_rx_agg_stop(priv, addr, tid); |
3740 | case IEEE80211_AMPDU_TX_START: | 3221 | case IEEE80211_AMPDU_TX_START: |
3741 | IWL_DEBUG_HT("start Tx\n"); | 3222 | IWL_DEBUG_HT("start Tx\n"); |
3742 | return iwl4965_tx_agg_start(hw, addr, tid, ssn); | 3223 | return iwl_tx_agg_start(priv, addr, tid, ssn); |
3743 | case IEEE80211_AMPDU_TX_STOP: | 3224 | case IEEE80211_AMPDU_TX_STOP: |
3744 | IWL_DEBUG_HT("stop Tx\n"); | 3225 | IWL_DEBUG_HT("stop Tx\n"); |
3745 | return iwl4965_tx_agg_stop(hw, addr, tid); | 3226 | return iwl_tx_agg_stop(priv, addr, tid); |
3746 | default: | 3227 | default: |
3747 | IWL_DEBUG_HT("unknown\n"); | 3228 | IWL_DEBUG_HT("unknown\n"); |
3748 | return -EINVAL; | 3229 | return -EINVAL; |
@@ -3753,6 +3234,16 @@ int iwl4965_mac_ampdu_action(struct ieee80211_hw *hw, | |||
3753 | #endif /* CONFIG_IWL4965_HT */ | 3234 | #endif /* CONFIG_IWL4965_HT */ |
3754 | 3235 | ||
3755 | 3236 | ||
3237 | static u16 iwl4965_get_hcmd_size(u8 cmd_id, u16 len) | ||
3238 | { | ||
3239 | switch (cmd_id) { | ||
3240 | case REPLY_RXON: | ||
3241 | return (u16) sizeof(struct iwl4965_rxon_cmd); | ||
3242 | default: | ||
3243 | return len; | ||
3244 | } | ||
3245 | } | ||
3246 | |||
3756 | static u16 iwl4965_build_addsta_hcmd(const struct iwl_addsta_cmd *cmd, u8 *data) | 3247 | static u16 iwl4965_build_addsta_hcmd(const struct iwl_addsta_cmd *cmd, u8 *data) |
3757 | { | 3248 | { |
3758 | struct iwl4965_addsta_cmd *addsta = (struct iwl4965_addsta_cmd *)data; | 3249 | struct iwl4965_addsta_cmd *addsta = (struct iwl4965_addsta_cmd *)data; |
@@ -3770,18 +3261,258 @@ static u16 iwl4965_build_addsta_hcmd(const struct iwl_addsta_cmd *cmd, u8 *data) | |||
3770 | 3261 | ||
3771 | return (u16)sizeof(struct iwl4965_addsta_cmd); | 3262 | return (u16)sizeof(struct iwl4965_addsta_cmd); |
3772 | } | 3263 | } |
3264 | |||
3265 | #ifdef CONFIG_IWL4965_HT | ||
3266 | static inline u32 iwl4965_get_scd_ssn(struct iwl4965_tx_resp *tx_resp) | ||
3267 | { | ||
3268 | __le32 *scd_ssn = (__le32 *)((u32 *)&tx_resp->status + | ||
3269 | tx_resp->frame_count); | ||
3270 | return le32_to_cpu(*scd_ssn) & MAX_SN; | ||
3271 | |||
3272 | } | ||
3273 | |||
3274 | /** | ||
3275 | * iwl4965_tx_status_reply_tx - Handle Tx rspnse for frames in aggregation queue | ||
3276 | */ | ||
3277 | static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv, | ||
3278 | struct iwl_ht_agg *agg, | ||
3279 | struct iwl4965_tx_resp_agg *tx_resp, | ||
3280 | u16 start_idx) | ||
3281 | { | ||
3282 | u16 status; | ||
3283 | struct agg_tx_status *frame_status = &tx_resp->status; | ||
3284 | struct ieee80211_tx_info *info = NULL; | ||
3285 | struct ieee80211_hdr *hdr = NULL; | ||
3286 | int i, sh; | ||
3287 | int txq_id, idx; | ||
3288 | u16 seq; | ||
3289 | |||
3290 | if (agg->wait_for_ba) | ||
3291 | IWL_DEBUG_TX_REPLY("got tx response w/o block-ack\n"); | ||
3292 | |||
3293 | agg->frame_count = tx_resp->frame_count; | ||
3294 | agg->start_idx = start_idx; | ||
3295 | agg->rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags); | ||
3296 | agg->bitmap = 0; | ||
3297 | |||
3298 | /* # frames attempted by Tx command */ | ||
3299 | if (agg->frame_count == 1) { | ||
3300 | /* Only one frame was attempted; no block-ack will arrive */ | ||
3301 | status = le16_to_cpu(frame_status[0].status); | ||
3302 | seq = le16_to_cpu(frame_status[0].sequence); | ||
3303 | idx = SEQ_TO_INDEX(seq); | ||
3304 | txq_id = SEQ_TO_QUEUE(seq); | ||
3305 | |||
3306 | /* FIXME: code repetition */ | ||
3307 | IWL_DEBUG_TX_REPLY("FrameCnt = %d, StartIdx=%d idx=%d\n", | ||
3308 | agg->frame_count, agg->start_idx, idx); | ||
3309 | |||
3310 | info = IEEE80211_SKB_CB(priv->txq[txq_id].txb[idx].skb[0]); | ||
3311 | info->status.retry_count = tx_resp->failure_frame; | ||
3312 | info->flags &= ~IEEE80211_TX_CTL_AMPDU; | ||
3313 | info->flags |= iwl_is_tx_success(status)? | ||
3314 | IEEE80211_TX_STAT_ACK : 0; | ||
3315 | iwl4965_hwrate_to_tx_control(priv, | ||
3316 | le32_to_cpu(tx_resp->rate_n_flags), | ||
3317 | info); | ||
3318 | /* FIXME: code repetition end */ | ||
3319 | |||
3320 | IWL_DEBUG_TX_REPLY("1 Frame 0x%x failure :%d\n", | ||
3321 | status & 0xff, tx_resp->failure_frame); | ||
3322 | IWL_DEBUG_TX_REPLY("Rate Info rate_n_flags=%x\n", | ||
3323 | iwl4965_hw_get_rate_n_flags(tx_resp->rate_n_flags)); | ||
3324 | |||
3325 | agg->wait_for_ba = 0; | ||
3326 | } else { | ||
3327 | /* Two or more frames were attempted; expect block-ack */ | ||
3328 | u64 bitmap = 0; | ||
3329 | int start = agg->start_idx; | ||
3330 | |||
3331 | /* Construct bit-map of pending frames within Tx window */ | ||
3332 | for (i = 0; i < agg->frame_count; i++) { | ||
3333 | u16 sc; | ||
3334 | status = le16_to_cpu(frame_status[i].status); | ||
3335 | seq = le16_to_cpu(frame_status[i].sequence); | ||
3336 | idx = SEQ_TO_INDEX(seq); | ||
3337 | txq_id = SEQ_TO_QUEUE(seq); | ||
3338 | |||
3339 | if (status & (AGG_TX_STATE_FEW_BYTES_MSK | | ||
3340 | AGG_TX_STATE_ABORT_MSK)) | ||
3341 | continue; | ||
3342 | |||
3343 | IWL_DEBUG_TX_REPLY("FrameCnt = %d, txq_id=%d idx=%d\n", | ||
3344 | agg->frame_count, txq_id, idx); | ||
3345 | |||
3346 | hdr = iwl_tx_queue_get_hdr(priv, txq_id, idx); | ||
3347 | |||
3348 | sc = le16_to_cpu(hdr->seq_ctrl); | ||
3349 | if (idx != (SEQ_TO_SN(sc) & 0xff)) { | ||
3350 | IWL_ERROR("BUG_ON idx doesn't match seq control" | ||
3351 | " idx=%d, seq_idx=%d, seq=%d\n", | ||
3352 | idx, SEQ_TO_SN(sc), | ||
3353 | hdr->seq_ctrl); | ||
3354 | return -1; | ||
3355 | } | ||
3356 | |||
3357 | IWL_DEBUG_TX_REPLY("AGG Frame i=%d idx %d seq=%d\n", | ||
3358 | i, idx, SEQ_TO_SN(sc)); | ||
3359 | |||
3360 | sh = idx - start; | ||
3361 | if (sh > 64) { | ||
3362 | sh = (start - idx) + 0xff; | ||
3363 | bitmap = bitmap << sh; | ||
3364 | sh = 0; | ||
3365 | start = idx; | ||
3366 | } else if (sh < -64) | ||
3367 | sh = 0xff - (start - idx); | ||
3368 | else if (sh < 0) { | ||
3369 | sh = start - idx; | ||
3370 | start = idx; | ||
3371 | bitmap = bitmap << sh; | ||
3372 | sh = 0; | ||
3373 | } | ||
3374 | bitmap |= (1 << sh); | ||
3375 | IWL_DEBUG_TX_REPLY("start=%d bitmap=0x%x\n", | ||
3376 | start, (u32)(bitmap & 0xFFFFFFFF)); | ||
3377 | } | ||
3378 | |||
3379 | agg->bitmap = bitmap; | ||
3380 | agg->start_idx = start; | ||
3381 | agg->rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags); | ||
3382 | IWL_DEBUG_TX_REPLY("Frames %d start_idx=%d bitmap=0x%llx\n", | ||
3383 | agg->frame_count, agg->start_idx, | ||
3384 | (unsigned long long)agg->bitmap); | ||
3385 | |||
3386 | if (bitmap) | ||
3387 | agg->wait_for_ba = 1; | ||
3388 | } | ||
3389 | return 0; | ||
3390 | } | ||
3391 | #endif | ||
3392 | |||
3393 | /** | ||
3394 | * iwl4965_rx_reply_tx - Handle standard (non-aggregation) Tx response | ||
3395 | */ | ||
3396 | static void iwl4965_rx_reply_tx(struct iwl_priv *priv, | ||
3397 | struct iwl_rx_mem_buffer *rxb) | ||
3398 | { | ||
3399 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; | ||
3400 | u16 sequence = le16_to_cpu(pkt->hdr.sequence); | ||
3401 | int txq_id = SEQ_TO_QUEUE(sequence); | ||
3402 | int index = SEQ_TO_INDEX(sequence); | ||
3403 | struct iwl_tx_queue *txq = &priv->txq[txq_id]; | ||
3404 | struct ieee80211_tx_info *info; | ||
3405 | struct iwl4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; | ||
3406 | u32 status = le32_to_cpu(tx_resp->status); | ||
3407 | #ifdef CONFIG_IWL4965_HT | ||
3408 | int tid = MAX_TID_COUNT, sta_id = IWL_INVALID_STATION; | ||
3409 | u16 fc; | ||
3410 | struct ieee80211_hdr *hdr; | ||
3411 | u8 *qc = NULL; | ||
3412 | #endif | ||
3413 | |||
3414 | if ((index >= txq->q.n_bd) || (iwl_queue_used(&txq->q, index) == 0)) { | ||
3415 | IWL_ERROR("Read index for DMA queue txq_id (%d) index %d " | ||
3416 | "is out of range [0-%d] %d %d\n", txq_id, | ||
3417 | index, txq->q.n_bd, txq->q.write_ptr, | ||
3418 | txq->q.read_ptr); | ||
3419 | return; | ||
3420 | } | ||
3421 | |||
3422 | info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb[0]); | ||
3423 | memset(&info->status, 0, sizeof(info->status)); | ||
3424 | |||
3425 | #ifdef CONFIG_IWL4965_HT | ||
3426 | hdr = iwl_tx_queue_get_hdr(priv, txq_id, index); | ||
3427 | fc = le16_to_cpu(hdr->frame_control); | ||
3428 | if (ieee80211_is_qos_data(fc)) { | ||
3429 | qc = ieee80211_get_qos_ctrl(hdr, ieee80211_get_hdrlen(fc)); | ||
3430 | tid = qc[0] & 0xf; | ||
3431 | } | ||
3432 | |||
3433 | sta_id = iwl_get_ra_sta_id(priv, hdr); | ||
3434 | if (txq->sched_retry && unlikely(sta_id == IWL_INVALID_STATION)) { | ||
3435 | IWL_ERROR("Station not known\n"); | ||
3436 | return; | ||
3437 | } | ||
3438 | |||
3439 | if (txq->sched_retry) { | ||
3440 | const u32 scd_ssn = iwl4965_get_scd_ssn(tx_resp); | ||
3441 | struct iwl_ht_agg *agg = NULL; | ||
3442 | |||
3443 | if (!qc) | ||
3444 | return; | ||
3445 | |||
3446 | agg = &priv->stations[sta_id].tid[tid].agg; | ||
3447 | |||
3448 | iwl4965_tx_status_reply_tx(priv, agg, | ||
3449 | (struct iwl4965_tx_resp_agg *)tx_resp, index); | ||
3450 | |||
3451 | if ((tx_resp->frame_count == 1) && !iwl_is_tx_success(status)) { | ||
3452 | /* TODO: send BAR */ | ||
3453 | } | ||
3454 | |||
3455 | if (txq->q.read_ptr != (scd_ssn & 0xff)) { | ||
3456 | int freed, ampdu_q; | ||
3457 | index = iwl_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd); | ||
3458 | IWL_DEBUG_TX_REPLY("Retry scheduler reclaim scd_ssn " | ||
3459 | "%d index %d\n", scd_ssn , index); | ||
3460 | freed = iwl_tx_queue_reclaim(priv, txq_id, index); | ||
3461 | priv->stations[sta_id].tid[tid].tfds_in_queue -= freed; | ||
3462 | |||
3463 | if (iwl_queue_space(&txq->q) > txq->q.low_mark && | ||
3464 | txq_id >= 0 && priv->mac80211_registered && | ||
3465 | agg->state != IWL_EMPTYING_HW_QUEUE_DELBA) { | ||
3466 | /* calculate mac80211 ampdu sw queue to wake */ | ||
3467 | ampdu_q = txq_id - IWL_BACK_QUEUE_FIRST_ID + | ||
3468 | priv->hw->queues; | ||
3469 | if (agg->state == IWL_AGG_OFF) | ||
3470 | ieee80211_wake_queue(priv->hw, txq_id); | ||
3471 | else | ||
3472 | ieee80211_wake_queue(priv->hw, ampdu_q); | ||
3473 | } | ||
3474 | iwl_txq_check_empty(priv, sta_id, tid, txq_id); | ||
3475 | } | ||
3476 | } else { | ||
3477 | #endif /* CONFIG_IWL4965_HT */ | ||
3478 | |||
3479 | info->status.retry_count = tx_resp->failure_frame; | ||
3480 | info->flags |= iwl_is_tx_success(status) ? IEEE80211_TX_STAT_ACK : 0; | ||
3481 | iwl4965_hwrate_to_tx_control(priv, le32_to_cpu(tx_resp->rate_n_flags), | ||
3482 | info); | ||
3483 | |||
3484 | IWL_DEBUG_TX("Tx queue %d Status %s (0x%08x) rate_n_flags 0x%x " | ||
3485 | "retries %d\n", txq_id, iwl_get_tx_fail_reason(status), | ||
3486 | status, le32_to_cpu(tx_resp->rate_n_flags), | ||
3487 | tx_resp->failure_frame); | ||
3488 | |||
3489 | IWL_DEBUG_TX_REPLY("Tx queue reclaim %d\n", index); | ||
3490 | #ifdef CONFIG_IWL4965_HT | ||
3491 | if (index != -1) { | ||
3492 | int freed = iwl_tx_queue_reclaim(priv, txq_id, index); | ||
3493 | if (tid != MAX_TID_COUNT) | ||
3494 | priv->stations[sta_id].tid[tid].tfds_in_queue -= freed; | ||
3495 | if (iwl_queue_space(&txq->q) > txq->q.low_mark && | ||
3496 | (txq_id >= 0) && priv->mac80211_registered) | ||
3497 | ieee80211_wake_queue(priv->hw, txq_id); | ||
3498 | if (tid != MAX_TID_COUNT) | ||
3499 | iwl_txq_check_empty(priv, sta_id, tid, txq_id); | ||
3500 | } | ||
3501 | } | ||
3502 | #endif /* CONFIG_IWL4965_HT */ | ||
3503 | |||
3504 | if (iwl_check_bits(status, TX_ABORT_REQUIRED_MSK)) | ||
3505 | IWL_ERROR("TODO: Implement Tx ABORT REQUIRED!!!\n"); | ||
3506 | } | ||
3507 | |||
3508 | |||
3773 | /* Set up 4965-specific Rx frame reply handlers */ | 3509 | /* Set up 4965-specific Rx frame reply handlers */ |
3774 | static void iwl4965_rx_handler_setup(struct iwl_priv *priv) | 3510 | static void iwl4965_rx_handler_setup(struct iwl_priv *priv) |
3775 | { | 3511 | { |
3776 | /* Legacy Rx frames */ | 3512 | /* Legacy Rx frames */ |
3777 | priv->rx_handlers[REPLY_RX] = iwl4965_rx_reply_rx; | 3513 | priv->rx_handlers[REPLY_RX] = iwl4965_rx_reply_rx; |
3778 | 3514 | /* Tx response */ | |
3779 | /* High-throughput (HT) Rx frames */ | 3515 | priv->rx_handlers[REPLY_TX] = iwl4965_rx_reply_tx; |
3780 | priv->rx_handlers[REPLY_RX_PHY_CMD] = iwl4965_rx_reply_rx_phy; | ||
3781 | priv->rx_handlers[REPLY_RX_MPDU_CMD] = iwl4965_rx_reply_rx; | ||
3782 | |||
3783 | priv->rx_handlers[MISSED_BEACONS_NOTIFICATION] = | ||
3784 | iwl4965_rx_missed_beacon_notif; | ||
3785 | 3516 | ||
3786 | #ifdef CONFIG_IWL4965_HT | 3517 | #ifdef CONFIG_IWL4965_HT |
3787 | priv->rx_handlers[REPLY_COMPRESSED_BA] = iwl4965_rx_reply_compressed_ba; | 3518 | priv->rx_handlers[REPLY_COMPRESSED_BA] = iwl4965_rx_reply_compressed_ba; |
@@ -3812,7 +3543,7 @@ static struct iwl_hcmd_ops iwl4965_hcmd = { | |||
3812 | }; | 3543 | }; |
3813 | 3544 | ||
3814 | static struct iwl_hcmd_utils_ops iwl4965_hcmd_utils = { | 3545 | static struct iwl_hcmd_utils_ops iwl4965_hcmd_utils = { |
3815 | .enqueue_hcmd = iwl4965_enqueue_hcmd, | 3546 | .get_hcmd_size = iwl4965_get_hcmd_size, |
3816 | .build_addsta_hcmd = iwl4965_build_addsta_hcmd, | 3547 | .build_addsta_hcmd = iwl4965_build_addsta_hcmd, |
3817 | #ifdef CONFIG_IWL4965_RUN_TIME_CALIB | 3548 | #ifdef CONFIG_IWL4965_RUN_TIME_CALIB |
3818 | .chain_noise_reset = iwl4965_chain_noise_reset, | 3549 | .chain_noise_reset = iwl4965_chain_noise_reset, |
@@ -3826,7 +3557,11 @@ static struct iwl_lib_ops iwl4965_lib = { | |||
3826 | .free_shared_mem = iwl4965_free_shared_mem, | 3557 | .free_shared_mem = iwl4965_free_shared_mem, |
3827 | .shared_mem_rx_idx = iwl4965_shared_mem_rx_idx, | 3558 | .shared_mem_rx_idx = iwl4965_shared_mem_rx_idx, |
3828 | .txq_update_byte_cnt_tbl = iwl4965_txq_update_byte_cnt_tbl, | 3559 | .txq_update_byte_cnt_tbl = iwl4965_txq_update_byte_cnt_tbl, |
3829 | .disable_tx_fifo = iwl4965_disable_tx_fifo, | 3560 | .txq_set_sched = iwl4965_txq_set_sched, |
3561 | #ifdef CONFIG_IWL4965_HT | ||
3562 | .txq_agg_enable = iwl4965_txq_agg_enable, | ||
3563 | .txq_agg_disable = iwl4965_txq_agg_disable, | ||
3564 | #endif | ||
3830 | .rx_handler_setup = iwl4965_rx_handler_setup, | 3565 | .rx_handler_setup = iwl4965_rx_handler_setup, |
3831 | .is_valid_rtc_data_addr = iwl4965_hw_valid_rtc_data_addr, | 3566 | .is_valid_rtc_data_addr = iwl4965_hw_valid_rtc_data_addr, |
3832 | .alive_notify = iwl4965_alive_notify, | 3567 | .alive_notify = iwl4965_alive_notify, |
@@ -3834,6 +3569,8 @@ static struct iwl_lib_ops iwl4965_lib = { | |||
3834 | .load_ucode = iwl4965_load_bsm, | 3569 | .load_ucode = iwl4965_load_bsm, |
3835 | .apm_ops = { | 3570 | .apm_ops = { |
3836 | .init = iwl4965_apm_init, | 3571 | .init = iwl4965_apm_init, |
3572 | .reset = iwl4965_apm_reset, | ||
3573 | .stop = iwl4965_apm_stop, | ||
3837 | .config = iwl4965_nic_config, | 3574 | .config = iwl4965_nic_config, |
3838 | .set_pwr_src = iwl4965_set_pwr_src, | 3575 | .set_pwr_src = iwl4965_set_pwr_src, |
3839 | }, | 3576 | }, |
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c index b5e28b811796..7e525ad45135 100644 --- a/drivers/net/wireless/iwlwifi/iwl-5000.c +++ b/drivers/net/wireless/iwlwifi/iwl-5000.c | |||
@@ -46,6 +46,41 @@ | |||
46 | 46 | ||
47 | #define IWL5000_UCODE_API "-1" | 47 | #define IWL5000_UCODE_API "-1" |
48 | 48 | ||
49 | static const u16 iwl5000_default_queue_to_tx_fifo[] = { | ||
50 | IWL_TX_FIFO_AC3, | ||
51 | IWL_TX_FIFO_AC2, | ||
52 | IWL_TX_FIFO_AC1, | ||
53 | IWL_TX_FIFO_AC0, | ||
54 | IWL50_CMD_FIFO_NUM, | ||
55 | IWL_TX_FIFO_HCCA_1, | ||
56 | IWL_TX_FIFO_HCCA_2 | ||
57 | }; | ||
58 | |||
59 | /* FIXME: same implementation as 4965 */ | ||
60 | static int iwl5000_apm_stop_master(struct iwl_priv *priv) | ||
61 | { | ||
62 | int ret = 0; | ||
63 | unsigned long flags; | ||
64 | |||
65 | spin_lock_irqsave(&priv->lock, flags); | ||
66 | |||
67 | /* set stop master bit */ | ||
68 | iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); | ||
69 | |||
70 | ret = iwl_poll_bit(priv, CSR_RESET, | ||
71 | CSR_RESET_REG_FLAG_MASTER_DISABLED, | ||
72 | CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); | ||
73 | if (ret < 0) | ||
74 | goto out; | ||
75 | |||
76 | out: | ||
77 | spin_unlock_irqrestore(&priv->lock, flags); | ||
78 | IWL_DEBUG_INFO("stop master\n"); | ||
79 | |||
80 | return ret; | ||
81 | } | ||
82 | |||
83 | |||
49 | static int iwl5000_apm_init(struct iwl_priv *priv) | 84 | static int iwl5000_apm_init(struct iwl_priv *priv) |
50 | { | 85 | { |
51 | int ret = 0; | 86 | int ret = 0; |
@@ -53,6 +88,10 @@ static int iwl5000_apm_init(struct iwl_priv *priv) | |||
53 | iwl_set_bit(priv, CSR_GIO_CHICKEN_BITS, | 88 | iwl_set_bit(priv, CSR_GIO_CHICKEN_BITS, |
54 | CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER); | 89 | CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER); |
55 | 90 | ||
91 | /* disable L0s without affecting L1 :don't wait for ICH L0s bug W/A) */ | ||
92 | iwl_set_bit(priv, CSR_GIO_CHICKEN_BITS, | ||
93 | CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX); | ||
94 | |||
56 | iwl_set_bit(priv, CSR_ANA_PLL_CFG, CSR50_ANA_PLL_CFG_VAL); | 95 | iwl_set_bit(priv, CSR_ANA_PLL_CFG, CSR50_ANA_PLL_CFG_VAL); |
57 | 96 | ||
58 | /* set "initialization complete" bit to move adapter | 97 | /* set "initialization complete" bit to move adapter |
@@ -73,19 +112,91 @@ static int iwl5000_apm_init(struct iwl_priv *priv) | |||
73 | return ret; | 112 | return ret; |
74 | 113 | ||
75 | /* enable DMA */ | 114 | /* enable DMA */ |
76 | iwl_write_prph(priv, APMG_CLK_EN_REG, | 115 | iwl_write_prph(priv, APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT); |
77 | APMG_CLK_VAL_DMA_CLK_RQT); | ||
78 | 116 | ||
79 | udelay(20); | 117 | udelay(20); |
80 | 118 | ||
119 | /* disable L1-Active */ | ||
81 | iwl_set_bits_prph(priv, APMG_PCIDEV_STT_REG, | 120 | iwl_set_bits_prph(priv, APMG_PCIDEV_STT_REG, |
82 | APMG_PCIDEV_STT_VAL_L1_ACT_DIS); | 121 | APMG_PCIDEV_STT_VAL_L1_ACT_DIS); |
83 | 122 | ||
84 | iwl_release_nic_access(priv); | 123 | iwl_release_nic_access(priv); |
85 | 124 | ||
86 | return ret; | 125 | return ret; |
87 | } | 126 | } |
88 | 127 | ||
128 | /* FIXME: this is indentical to 4965 */ | ||
129 | static void iwl5000_apm_stop(struct iwl_priv *priv) | ||
130 | { | ||
131 | unsigned long flags; | ||
132 | |||
133 | iwl5000_apm_stop_master(priv); | ||
134 | |||
135 | spin_lock_irqsave(&priv->lock, flags); | ||
136 | |||
137 | iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); | ||
138 | |||
139 | udelay(10); | ||
140 | |||
141 | iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); | ||
142 | |||
143 | spin_unlock_irqrestore(&priv->lock, flags); | ||
144 | } | ||
145 | |||
146 | |||
147 | static int iwl5000_apm_reset(struct iwl_priv *priv) | ||
148 | { | ||
149 | int ret = 0; | ||
150 | unsigned long flags; | ||
151 | |||
152 | iwl5000_apm_stop_master(priv); | ||
153 | |||
154 | spin_lock_irqsave(&priv->lock, flags); | ||
155 | |||
156 | iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); | ||
157 | |||
158 | udelay(10); | ||
159 | |||
160 | |||
161 | /* FIXME: put here L1A -L0S w/a */ | ||
162 | |||
163 | iwl_set_bit(priv, CSR_ANA_PLL_CFG, CSR50_ANA_PLL_CFG_VAL); | ||
164 | |||
165 | /* set "initialization complete" bit to move adapter | ||
166 | * D0U* --> D0A* state */ | ||
167 | iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); | ||
168 | |||
169 | /* wait for clock stabilization */ | ||
170 | ret = iwl_poll_bit(priv, CSR_GP_CNTRL, | ||
171 | CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, | ||
172 | CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000); | ||
173 | if (ret < 0) { | ||
174 | IWL_DEBUG_INFO("Failed to init the card\n"); | ||
175 | goto out; | ||
176 | } | ||
177 | |||
178 | ret = iwl_grab_nic_access(priv); | ||
179 | if (ret) | ||
180 | goto out; | ||
181 | |||
182 | /* enable DMA */ | ||
183 | iwl_write_prph(priv, APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT); | ||
184 | |||
185 | udelay(20); | ||
186 | |||
187 | /* disable L1-Active */ | ||
188 | iwl_set_bits_prph(priv, APMG_PCIDEV_STT_REG, | ||
189 | APMG_PCIDEV_STT_VAL_L1_ACT_DIS); | ||
190 | |||
191 | iwl_release_nic_access(priv); | ||
192 | |||
193 | out: | ||
194 | spin_unlock_irqrestore(&priv->lock, flags); | ||
195 | |||
196 | return ret; | ||
197 | } | ||
198 | |||
199 | |||
89 | static void iwl5000_nic_config(struct iwl_priv *priv) | 200 | static void iwl5000_nic_config(struct iwl_priv *priv) |
90 | { | 201 | { |
91 | unsigned long flags; | 202 | unsigned long flags; |
@@ -96,8 +207,13 @@ static void iwl5000_nic_config(struct iwl_priv *priv) | |||
96 | 207 | ||
97 | pci_read_config_byte(priv->pci_dev, PCI_LINK_CTRL, &val_link); | 208 | pci_read_config_byte(priv->pci_dev, PCI_LINK_CTRL, &val_link); |
98 | 209 | ||
99 | /* disable L1 entry -- workaround for pre-B1 */ | 210 | /* L1 is enabled by BIOS */ |
100 | pci_write_config_byte(priv->pci_dev, PCI_LINK_CTRL, val_link & ~0x02); | 211 | if ((val_link & PCI_LINK_VAL_L1_EN) == PCI_LINK_VAL_L1_EN) |
212 | /* diable L0S disabled L1A enabled */ | ||
213 | iwl_set_bit(priv, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); | ||
214 | else | ||
215 | /* L0S enabled L1A disabled */ | ||
216 | iwl_clear_bit(priv, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); | ||
101 | 217 | ||
102 | radio_cfg = iwl_eeprom_query16(priv, EEPROM_RADIO_CONFIG); | 218 | radio_cfg = iwl_eeprom_query16(priv, EEPROM_RADIO_CONFIG); |
103 | 219 | ||
@@ -279,6 +395,8 @@ static struct iwl_sensitivity_ranges iwl5000_sensitivity = { | |||
279 | 395 | ||
280 | #endif /* CONFIG_IWL5000_RUN_TIME_CALIB */ | 396 | #endif /* CONFIG_IWL5000_RUN_TIME_CALIB */ |
281 | 397 | ||
398 | |||
399 | |||
282 | static const u8 *iwl5000_eeprom_query_addr(const struct iwl_priv *priv, | 400 | static const u8 *iwl5000_eeprom_query_addr(const struct iwl_priv *priv, |
283 | size_t offset) | 401 | size_t offset) |
284 | { | 402 | { |
@@ -287,6 +405,423 @@ static const u8 *iwl5000_eeprom_query_addr(const struct iwl_priv *priv, | |||
287 | return &priv->eeprom[address]; | 405 | return &priv->eeprom[address]; |
288 | } | 406 | } |
289 | 407 | ||
408 | /* | ||
409 | * Calibration | ||
410 | */ | ||
411 | static int iwl5000_send_Xtal_calib(struct iwl_priv *priv) | ||
412 | { | ||
413 | u16 *xtal_calib = (u16 *)iwl_eeprom_query_addr(priv, EEPROM_5000_XTAL); | ||
414 | |||
415 | struct iwl5000_calibration cal_cmd = { | ||
416 | .op_code = IWL5000_PHY_CALIBRATE_CRYSTAL_FRQ_CMD, | ||
417 | .data = { | ||
418 | (u8)xtal_calib[0], | ||
419 | (u8)xtal_calib[1], | ||
420 | } | ||
421 | }; | ||
422 | |||
423 | return iwl_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD, | ||
424 | sizeof(cal_cmd), &cal_cmd); | ||
425 | } | ||
426 | |||
427 | static int iwl5000_send_calib_results(struct iwl_priv *priv) | ||
428 | { | ||
429 | int ret = 0; | ||
430 | |||
431 | struct iwl_host_cmd hcmd = { | ||
432 | .id = REPLY_PHY_CALIBRATION_CMD, | ||
433 | .meta.flags = CMD_SIZE_HUGE, | ||
434 | }; | ||
435 | |||
436 | if (priv->calib_results.lo_res) { | ||
437 | hcmd.len = priv->calib_results.lo_res_len; | ||
438 | hcmd.data = priv->calib_results.lo_res; | ||
439 | ret = iwl_send_cmd_sync(priv, &hcmd); | ||
440 | |||
441 | if (ret) | ||
442 | goto err; | ||
443 | } | ||
444 | |||
445 | if (priv->calib_results.tx_iq_res) { | ||
446 | hcmd.len = priv->calib_results.tx_iq_res_len; | ||
447 | hcmd.data = priv->calib_results.tx_iq_res; | ||
448 | ret = iwl_send_cmd_sync(priv, &hcmd); | ||
449 | |||
450 | if (ret) | ||
451 | goto err; | ||
452 | } | ||
453 | |||
454 | if (priv->calib_results.tx_iq_perd_res) { | ||
455 | hcmd.len = priv->calib_results.tx_iq_perd_res_len; | ||
456 | hcmd.data = priv->calib_results.tx_iq_perd_res; | ||
457 | ret = iwl_send_cmd_sync(priv, &hcmd); | ||
458 | |||
459 | if (ret) | ||
460 | goto err; | ||
461 | } | ||
462 | |||
463 | return 0; | ||
464 | err: | ||
465 | IWL_ERROR("Error %d\n", ret); | ||
466 | return ret; | ||
467 | } | ||
468 | |||
469 | static int iwl5000_send_calib_cfg(struct iwl_priv *priv) | ||
470 | { | ||
471 | struct iwl5000_calib_cfg_cmd calib_cfg_cmd; | ||
472 | struct iwl_host_cmd cmd = { | ||
473 | .id = CALIBRATION_CFG_CMD, | ||
474 | .len = sizeof(struct iwl5000_calib_cfg_cmd), | ||
475 | .data = &calib_cfg_cmd, | ||
476 | }; | ||
477 | |||
478 | memset(&calib_cfg_cmd, 0, sizeof(calib_cfg_cmd)); | ||
479 | calib_cfg_cmd.ucd_calib_cfg.once.is_enable = IWL_CALIB_INIT_CFG_ALL; | ||
480 | calib_cfg_cmd.ucd_calib_cfg.once.start = IWL_CALIB_INIT_CFG_ALL; | ||
481 | calib_cfg_cmd.ucd_calib_cfg.once.send_res = IWL_CALIB_INIT_CFG_ALL; | ||
482 | calib_cfg_cmd.ucd_calib_cfg.flags = IWL_CALIB_INIT_CFG_ALL; | ||
483 | |||
484 | return iwl_send_cmd(priv, &cmd); | ||
485 | } | ||
486 | |||
487 | static void iwl5000_rx_calib_result(struct iwl_priv *priv, | ||
488 | struct iwl_rx_mem_buffer *rxb) | ||
489 | { | ||
490 | struct iwl_rx_packet *pkt = (void *)rxb->skb->data; | ||
491 | struct iwl5000_calib_hdr *hdr = (struct iwl5000_calib_hdr *)pkt->u.raw; | ||
492 | int len = le32_to_cpu(pkt->len) & FH_RSCSR_FRAME_SIZE_MSK; | ||
493 | |||
494 | iwl_free_calib_results(priv); | ||
495 | |||
496 | /* reduce the size of the length field itself */ | ||
497 | len -= 4; | ||
498 | |||
499 | switch (hdr->op_code) { | ||
500 | case IWL5000_PHY_CALIBRATE_LO_CMD: | ||
501 | priv->calib_results.lo_res = kzalloc(len, GFP_ATOMIC); | ||
502 | priv->calib_results.lo_res_len = len; | ||
503 | memcpy(priv->calib_results.lo_res, pkt->u.raw, len); | ||
504 | break; | ||
505 | case IWL5000_PHY_CALIBRATE_TX_IQ_CMD: | ||
506 | priv->calib_results.tx_iq_res = kzalloc(len, GFP_ATOMIC); | ||
507 | priv->calib_results.tx_iq_res_len = len; | ||
508 | memcpy(priv->calib_results.tx_iq_res, pkt->u.raw, len); | ||
509 | break; | ||
510 | case IWL5000_PHY_CALIBRATE_TX_IQ_PERD_CMD: | ||
511 | priv->calib_results.tx_iq_perd_res = kzalloc(len, GFP_ATOMIC); | ||
512 | priv->calib_results.tx_iq_perd_res_len = len; | ||
513 | memcpy(priv->calib_results.tx_iq_perd_res, pkt->u.raw, len); | ||
514 | break; | ||
515 | default: | ||
516 | IWL_ERROR("Unknown calibration notification %d\n", | ||
517 | hdr->op_code); | ||
518 | return; | ||
519 | } | ||
520 | } | ||
521 | |||
522 | static void iwl5000_rx_calib_complete(struct iwl_priv *priv, | ||
523 | struct iwl_rx_mem_buffer *rxb) | ||
524 | { | ||
525 | IWL_DEBUG_INFO("Init. calibration is completed, restarting fw.\n"); | ||
526 | queue_work(priv->workqueue, &priv->restart); | ||
527 | } | ||
528 | |||
529 | /* | ||
530 | * ucode | ||
531 | */ | ||
532 | static int iwl5000_load_section(struct iwl_priv *priv, | ||
533 | struct fw_desc *image, | ||
534 | u32 dst_addr) | ||
535 | { | ||
536 | int ret = 0; | ||
537 | unsigned long flags; | ||
538 | |||
539 | dma_addr_t phy_addr = image->p_addr; | ||
540 | u32 byte_cnt = image->len; | ||
541 | |||
542 | spin_lock_irqsave(&priv->lock, flags); | ||
543 | ret = iwl_grab_nic_access(priv); | ||
544 | if (ret) { | ||
545 | spin_unlock_irqrestore(&priv->lock, flags); | ||
546 | return ret; | ||
547 | } | ||
548 | |||
549 | iwl_write_direct32(priv, | ||
550 | FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL), | ||
551 | FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE); | ||
552 | |||
553 | iwl_write_direct32(priv, | ||
554 | FH_SRVC_CHNL_SRAM_ADDR_REG(FH_SRVC_CHNL), dst_addr); | ||
555 | |||
556 | iwl_write_direct32(priv, | ||
557 | FH_TFDIB_CTRL0_REG(FH_SRVC_CHNL), | ||
558 | phy_addr & FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK); | ||
559 | |||
560 | /* FIME: write the MSB of the phy_addr in CTRL1 | ||
561 | * iwl_write_direct32(priv, | ||
562 | IWL_FH_TFDIB_CTRL1_REG(IWL_FH_SRVC_CHNL), | ||
563 | ((phy_addr & MSB_MSK) | ||
564 | << FH_MEM_TFDIB_REG1_ADDR_BITSHIFT) | byte_count); | ||
565 | */ | ||
566 | iwl_write_direct32(priv, | ||
567 | FH_TFDIB_CTRL1_REG(FH_SRVC_CHNL), byte_cnt); | ||
568 | iwl_write_direct32(priv, | ||
569 | FH_TCSR_CHNL_TX_BUF_STS_REG(FH_SRVC_CHNL), | ||
570 | 1 << FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM | | ||
571 | 1 << FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX | | ||
572 | FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID); | ||
573 | |||
574 | iwl_write_direct32(priv, | ||
575 | FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL), | ||
576 | FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | | ||
577 | FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE_VAL | | ||
578 | FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD); | ||
579 | |||
580 | iwl_release_nic_access(priv); | ||
581 | spin_unlock_irqrestore(&priv->lock, flags); | ||
582 | return 0; | ||
583 | } | ||
584 | |||
585 | static int iwl5000_load_given_ucode(struct iwl_priv *priv, | ||
586 | struct fw_desc *inst_image, | ||
587 | struct fw_desc *data_image) | ||
588 | { | ||
589 | int ret = 0; | ||
590 | |||
591 | ret = iwl5000_load_section( | ||
592 | priv, inst_image, RTC_INST_LOWER_BOUND); | ||
593 | if (ret) | ||
594 | return ret; | ||
595 | |||
596 | IWL_DEBUG_INFO("INST uCode section being loaded...\n"); | ||
597 | ret = wait_event_interruptible_timeout(priv->wait_command_queue, | ||
598 | priv->ucode_write_complete, 5 * HZ); | ||
599 | if (ret == -ERESTARTSYS) { | ||
600 | IWL_ERROR("Could not load the INST uCode section due " | ||
601 | "to interrupt\n"); | ||
602 | return ret; | ||
603 | } | ||
604 | if (!ret) { | ||
605 | IWL_ERROR("Could not load the INST uCode section\n"); | ||
606 | return -ETIMEDOUT; | ||
607 | } | ||
608 | |||
609 | priv->ucode_write_complete = 0; | ||
610 | |||
611 | ret = iwl5000_load_section( | ||
612 | priv, data_image, RTC_DATA_LOWER_BOUND); | ||
613 | if (ret) | ||
614 | return ret; | ||
615 | |||
616 | IWL_DEBUG_INFO("DATA uCode section being loaded...\n"); | ||
617 | |||
618 | ret = wait_event_interruptible_timeout(priv->wait_command_queue, | ||
619 | priv->ucode_write_complete, 5 * HZ); | ||
620 | if (ret == -ERESTARTSYS) { | ||
621 | IWL_ERROR("Could not load the INST uCode section due " | ||
622 | "to interrupt\n"); | ||
623 | return ret; | ||
624 | } else if (!ret) { | ||
625 | IWL_ERROR("Could not load the DATA uCode section\n"); | ||
626 | return -ETIMEDOUT; | ||
627 | } else | ||
628 | ret = 0; | ||
629 | |||
630 | priv->ucode_write_complete = 0; | ||
631 | |||
632 | return ret; | ||
633 | } | ||
634 | |||
635 | static int iwl5000_load_ucode(struct iwl_priv *priv) | ||
636 | { | ||
637 | int ret = 0; | ||
638 | |||
639 | /* check whether init ucode should be loaded, or rather runtime ucode */ | ||
640 | if (priv->ucode_init.len && (priv->ucode_type == UCODE_NONE)) { | ||
641 | IWL_DEBUG_INFO("Init ucode found. Loading init ucode...\n"); | ||
642 | ret = iwl5000_load_given_ucode(priv, | ||
643 | &priv->ucode_init, &priv->ucode_init_data); | ||
644 | if (!ret) { | ||
645 | IWL_DEBUG_INFO("Init ucode load complete.\n"); | ||
646 | priv->ucode_type = UCODE_INIT; | ||
647 | } | ||
648 | } else { | ||
649 | IWL_DEBUG_INFO("Init ucode not found, or already loaded. " | ||
650 | "Loading runtime ucode...\n"); | ||
651 | ret = iwl5000_load_given_ucode(priv, | ||
652 | &priv->ucode_code, &priv->ucode_data); | ||
653 | if (!ret) { | ||
654 | IWL_DEBUG_INFO("Runtime ucode load complete.\n"); | ||
655 | priv->ucode_type = UCODE_RT; | ||
656 | } | ||
657 | } | ||
658 | |||
659 | return ret; | ||
660 | } | ||
661 | |||
662 | static void iwl5000_init_alive_start(struct iwl_priv *priv) | ||
663 | { | ||
664 | int ret = 0; | ||
665 | |||
666 | /* Check alive response for "valid" sign from uCode */ | ||
667 | if (priv->card_alive_init.is_valid != UCODE_VALID_OK) { | ||
668 | /* We had an error bringing up the hardware, so take it | ||
669 | * all the way back down so we can try again */ | ||
670 | IWL_DEBUG_INFO("Initialize Alive failed.\n"); | ||
671 | goto restart; | ||
672 | } | ||
673 | |||
674 | /* initialize uCode was loaded... verify inst image. | ||
675 | * This is a paranoid check, because we would not have gotten the | ||
676 | * "initialize" alive if code weren't properly loaded. */ | ||
677 | if (iwl_verify_ucode(priv)) { | ||
678 | /* Runtime instruction load was bad; | ||
679 | * take it all the way back down so we can try again */ | ||
680 | IWL_DEBUG_INFO("Bad \"initialize\" uCode load.\n"); | ||
681 | goto restart; | ||
682 | } | ||
683 | |||
684 | iwlcore_clear_stations_table(priv); | ||
685 | ret = priv->cfg->ops->lib->alive_notify(priv); | ||
686 | if (ret) { | ||
687 | IWL_WARNING("Could not complete ALIVE transition: %d\n", ret); | ||
688 | goto restart; | ||
689 | } | ||
690 | |||
691 | iwl5000_send_calib_cfg(priv); | ||
692 | return; | ||
693 | |||
694 | restart: | ||
695 | /* real restart (first load init_ucode) */ | ||
696 | queue_work(priv->workqueue, &priv->restart); | ||
697 | } | ||
698 | |||
699 | static void iwl5000_set_wr_ptrs(struct iwl_priv *priv, | ||
700 | int txq_id, u32 index) | ||
701 | { | ||
702 | iwl_write_direct32(priv, HBUS_TARG_WRPTR, | ||
703 | (index & 0xff) | (txq_id << 8)); | ||
704 | iwl_write_prph(priv, IWL50_SCD_QUEUE_RDPTR(txq_id), index); | ||
705 | } | ||
706 | |||
707 | static void iwl5000_tx_queue_set_status(struct iwl_priv *priv, | ||
708 | struct iwl_tx_queue *txq, | ||
709 | int tx_fifo_id, int scd_retry) | ||
710 | { | ||
711 | int txq_id = txq->q.id; | ||
712 | int active = test_bit(txq_id, &priv->txq_ctx_active_msk)?1:0; | ||
713 | |||
714 | iwl_write_prph(priv, IWL50_SCD_QUEUE_STATUS_BITS(txq_id), | ||
715 | (active << IWL50_SCD_QUEUE_STTS_REG_POS_ACTIVE) | | ||
716 | (tx_fifo_id << IWL50_SCD_QUEUE_STTS_REG_POS_TXF) | | ||
717 | (1 << IWL50_SCD_QUEUE_STTS_REG_POS_WSL) | | ||
718 | IWL50_SCD_QUEUE_STTS_REG_MSK); | ||
719 | |||
720 | txq->sched_retry = scd_retry; | ||
721 | |||
722 | IWL_DEBUG_INFO("%s %s Queue %d on AC %d\n", | ||
723 | active ? "Activate" : "Deactivate", | ||
724 | scd_retry ? "BA" : "AC", txq_id, tx_fifo_id); | ||
725 | } | ||
726 | |||
727 | static int iwl5000_send_wimax_coex(struct iwl_priv *priv) | ||
728 | { | ||
729 | struct iwl_wimax_coex_cmd coex_cmd; | ||
730 | |||
731 | memset(&coex_cmd, 0, sizeof(coex_cmd)); | ||
732 | |||
733 | return iwl_send_cmd_pdu(priv, COEX_PRIORITY_TABLE_CMD, | ||
734 | sizeof(coex_cmd), &coex_cmd); | ||
735 | } | ||
736 | |||
737 | static int iwl5000_alive_notify(struct iwl_priv *priv) | ||
738 | { | ||
739 | u32 a; | ||
740 | int i = 0; | ||
741 | unsigned long flags; | ||
742 | int ret; | ||
743 | |||
744 | spin_lock_irqsave(&priv->lock, flags); | ||
745 | |||
746 | ret = iwl_grab_nic_access(priv); | ||
747 | if (ret) { | ||
748 | spin_unlock_irqrestore(&priv->lock, flags); | ||
749 | return ret; | ||
750 | } | ||
751 | |||
752 | priv->scd_base_addr = iwl_read_prph(priv, IWL50_SCD_SRAM_BASE_ADDR); | ||
753 | a = priv->scd_base_addr + IWL50_SCD_CONTEXT_DATA_OFFSET; | ||
754 | for (; a < priv->scd_base_addr + IWL50_SCD_TX_STTS_BITMAP_OFFSET; | ||
755 | a += 4) | ||
756 | iwl_write_targ_mem(priv, a, 0); | ||
757 | for (; a < priv->scd_base_addr + IWL50_SCD_TRANSLATE_TBL_OFFSET; | ||
758 | a += 4) | ||
759 | iwl_write_targ_mem(priv, a, 0); | ||
760 | for (; a < sizeof(u16) * priv->hw_params.max_txq_num; a += 4) | ||
761 | iwl_write_targ_mem(priv, a, 0); | ||
762 | |||
763 | iwl_write_prph(priv, IWL50_SCD_DRAM_BASE_ADDR, | ||
764 | (priv->shared_phys + | ||
765 | offsetof(struct iwl5000_shared, queues_byte_cnt_tbls)) >> 10); | ||
766 | iwl_write_prph(priv, IWL50_SCD_QUEUECHAIN_SEL, | ||
767 | IWL50_SCD_QUEUECHAIN_SEL_ALL( | ||
768 | priv->hw_params.max_txq_num)); | ||
769 | iwl_write_prph(priv, IWL50_SCD_AGGR_SEL, 0); | ||
770 | |||
771 | /* initiate the queues */ | ||
772 | for (i = 0; i < priv->hw_params.max_txq_num; i++) { | ||
773 | iwl_write_prph(priv, IWL50_SCD_QUEUE_RDPTR(i), 0); | ||
774 | iwl_write_direct32(priv, HBUS_TARG_WRPTR, 0 | (i << 8)); | ||
775 | iwl_write_targ_mem(priv, priv->scd_base_addr + | ||
776 | IWL50_SCD_CONTEXT_QUEUE_OFFSET(i), 0); | ||
777 | iwl_write_targ_mem(priv, priv->scd_base_addr + | ||
778 | IWL50_SCD_CONTEXT_QUEUE_OFFSET(i) + | ||
779 | sizeof(u32), | ||
780 | ((SCD_WIN_SIZE << | ||
781 | IWL50_SCD_QUEUE_CTX_REG2_WIN_SIZE_POS) & | ||
782 | IWL50_SCD_QUEUE_CTX_REG2_WIN_SIZE_MSK) | | ||
783 | ((SCD_FRAME_LIMIT << | ||
784 | IWL50_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) & | ||
785 | IWL50_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK)); | ||
786 | } | ||
787 | |||
788 | iwl_write_prph(priv, IWL50_SCD_INTERRUPT_MASK, | ||
789 | IWL_MASK(0, priv->hw_params.max_txq_num)); | ||
790 | |||
791 | /* Activate all Tx DMA/FIFO channels */ | ||
792 | priv->cfg->ops->lib->txq_set_sched(priv, IWL_MASK(0, 7)); | ||
793 | |||
794 | iwl5000_set_wr_ptrs(priv, IWL_CMD_QUEUE_NUM, 0); | ||
795 | /* map qos queues to fifos one-to-one */ | ||
796 | for (i = 0; i < ARRAY_SIZE(iwl5000_default_queue_to_tx_fifo); i++) { | ||
797 | int ac = iwl5000_default_queue_to_tx_fifo[i]; | ||
798 | iwl_txq_ctx_activate(priv, i); | ||
799 | iwl5000_tx_queue_set_status(priv, &priv->txq[i], ac, 0); | ||
800 | } | ||
801 | /* TODO - need to initialize those FIFOs inside the loop above, | ||
802 | * not only mark them as active */ | ||
803 | iwl_txq_ctx_activate(priv, 4); | ||
804 | iwl_txq_ctx_activate(priv, 7); | ||
805 | iwl_txq_ctx_activate(priv, 8); | ||
806 | iwl_txq_ctx_activate(priv, 9); | ||
807 | |||
808 | iwl_release_nic_access(priv); | ||
809 | spin_unlock_irqrestore(&priv->lock, flags); | ||
810 | |||
811 | |||
812 | iwl5000_send_wimax_coex(priv); | ||
813 | |||
814 | iwl5000_send_Xtal_calib(priv); | ||
815 | |||
816 | if (priv->ucode_type == UCODE_RT) { | ||
817 | iwl5000_send_calib_results(priv); | ||
818 | set_bit(STATUS_READY, &priv->status); | ||
819 | priv->is_open = 1; | ||
820 | } | ||
821 | |||
822 | return 0; | ||
823 | } | ||
824 | |||
290 | static int iwl5000_hw_set_hw_params(struct iwl_priv *priv) | 825 | static int iwl5000_hw_set_hw_params(struct iwl_priv *priv) |
291 | { | 826 | { |
292 | if ((priv->cfg->mod_params->num_of_queues > IWL50_NUM_QUEUES) || | 827 | if ((priv->cfg->mod_params->num_of_queues > IWL50_NUM_QUEUES) || |
@@ -298,7 +833,6 @@ static int iwl5000_hw_set_hw_params(struct iwl_priv *priv) | |||
298 | 833 | ||
299 | priv->hw_params.max_txq_num = priv->cfg->mod_params->num_of_queues; | 834 | priv->hw_params.max_txq_num = priv->cfg->mod_params->num_of_queues; |
300 | priv->hw_params.sw_crypto = priv->cfg->mod_params->sw_crypto; | 835 | priv->hw_params.sw_crypto = priv->cfg->mod_params->sw_crypto; |
301 | priv->hw_params.tx_cmd_len = sizeof(struct iwl4965_tx_cmd); | ||
302 | priv->hw_params.max_rxq_size = RX_QUEUE_SIZE; | 836 | priv->hw_params.max_rxq_size = RX_QUEUE_SIZE; |
303 | priv->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; | 837 | priv->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; |
304 | if (priv->cfg->mod_params->amsdu_size_8K) | 838 | if (priv->cfg->mod_params->amsdu_size_8K) |
@@ -430,6 +964,26 @@ static void iwl5000_txq_update_byte_cnt_tbl(struct iwl_priv *priv, | |||
430 | } | 964 | } |
431 | } | 965 | } |
432 | 966 | ||
967 | static void iwl5000_txq_inval_byte_cnt_tbl(struct iwl_priv *priv, | ||
968 | struct iwl_tx_queue *txq) | ||
969 | { | ||
970 | int txq_id = txq->q.id; | ||
971 | struct iwl5000_shared *shared_data = priv->shared_virt; | ||
972 | u8 sta = 0; | ||
973 | |||
974 | if (txq_id != IWL_CMD_QUEUE_NUM) | ||
975 | sta = txq->cmd[txq->q.read_ptr].cmd.tx.sta_id; | ||
976 | |||
977 | shared_data->queues_byte_cnt_tbls[txq_id].tfd_offset[txq->q.read_ptr]. | ||
978 | val = cpu_to_le16(1 | (sta << 12)); | ||
979 | |||
980 | if (txq->q.write_ptr < IWL50_MAX_WIN_SIZE) { | ||
981 | shared_data->queues_byte_cnt_tbls[txq_id]. | ||
982 | tfd_offset[IWL50_QUEUE_SIZE + txq->q.read_ptr]. | ||
983 | val = cpu_to_le16(1 | (sta << 12)); | ||
984 | } | ||
985 | } | ||
986 | |||
433 | static u16 iwl5000_build_addsta_hcmd(const struct iwl_addsta_cmd *cmd, u8 *data) | 987 | static u16 iwl5000_build_addsta_hcmd(const struct iwl_addsta_cmd *cmd, u8 *data) |
434 | { | 988 | { |
435 | u16 size = (u16)sizeof(struct iwl_addsta_cmd); | 989 | u16 size = (u16)sizeof(struct iwl_addsta_cmd); |
@@ -438,31 +992,326 @@ static u16 iwl5000_build_addsta_hcmd(const struct iwl_addsta_cmd *cmd, u8 *data) | |||
438 | } | 992 | } |
439 | 993 | ||
440 | 994 | ||
441 | static int iwl5000_disable_tx_fifo(struct iwl_priv *priv) | 995 | /* |
996 | * Activate/Deactivat Tx DMA/FIFO channels according tx fifos mask | ||
997 | * must be called under priv->lock and mac access | ||
998 | */ | ||
999 | static void iwl5000_txq_set_sched(struct iwl_priv *priv, u32 mask) | ||
442 | { | 1000 | { |
443 | unsigned long flags; | 1001 | iwl_write_prph(priv, IWL50_SCD_TXFACT, mask); |
444 | int ret; | 1002 | } |
445 | 1003 | ||
446 | spin_lock_irqsave(&priv->lock, flags); | ||
447 | 1004 | ||
448 | ret = iwl_grab_nic_access(priv); | 1005 | static inline u32 iwl5000_get_scd_ssn(struct iwl5000_tx_resp *tx_resp) |
449 | if (unlikely(ret)) { | 1006 | { |
450 | IWL_ERROR("Tx fifo reset failed"); | 1007 | __le32 *scd_ssn = (__le32 *)((u32 *)&tx_resp->status + |
451 | spin_unlock_irqrestore(&priv->lock, flags); | 1008 | tx_resp->frame_count); |
452 | return ret; | 1009 | return le32_to_cpu(*scd_ssn) & MAX_SN; |
453 | } | ||
454 | 1010 | ||
455 | iwl_write_prph(priv, IWL50_SCD_TXFACT, 0); | 1011 | } |
456 | iwl_release_nic_access(priv); | 1012 | |
457 | spin_unlock_irqrestore(&priv->lock, flags); | 1013 | static int iwl5000_tx_status_reply_tx(struct iwl_priv *priv, |
1014 | struct iwl_ht_agg *agg, | ||
1015 | struct iwl5000_tx_resp *tx_resp, | ||
1016 | u16 start_idx) | ||
1017 | { | ||
1018 | u16 status; | ||
1019 | struct agg_tx_status *frame_status = &tx_resp->status; | ||
1020 | struct ieee80211_tx_info *info = NULL; | ||
1021 | struct ieee80211_hdr *hdr = NULL; | ||
1022 | int i, sh; | ||
1023 | int txq_id, idx; | ||
1024 | u16 seq; | ||
1025 | |||
1026 | if (agg->wait_for_ba) | ||
1027 | IWL_DEBUG_TX_REPLY("got tx response w/o block-ack\n"); | ||
1028 | |||
1029 | agg->frame_count = tx_resp->frame_count; | ||
1030 | agg->start_idx = start_idx; | ||
1031 | agg->rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags); | ||
1032 | agg->bitmap = 0; | ||
1033 | |||
1034 | /* # frames attempted by Tx command */ | ||
1035 | if (agg->frame_count == 1) { | ||
1036 | /* Only one frame was attempted; no block-ack will arrive */ | ||
1037 | status = le16_to_cpu(frame_status[0].status); | ||
1038 | seq = le16_to_cpu(frame_status[0].sequence); | ||
1039 | idx = SEQ_TO_INDEX(seq); | ||
1040 | txq_id = SEQ_TO_QUEUE(seq); | ||
1041 | |||
1042 | /* FIXME: code repetition */ | ||
1043 | IWL_DEBUG_TX_REPLY("FrameCnt = %d, StartIdx=%d idx=%d\n", | ||
1044 | agg->frame_count, agg->start_idx, idx); | ||
1045 | |||
1046 | info = IEEE80211_SKB_CB(priv->txq[txq_id].txb[idx].skb[0]); | ||
1047 | info->status.retry_count = tx_resp->failure_frame; | ||
1048 | info->flags &= ~IEEE80211_TX_CTL_AMPDU; | ||
1049 | info->flags |= iwl_is_tx_success(status)? | ||
1050 | IEEE80211_TX_STAT_ACK : 0; | ||
1051 | iwl4965_hwrate_to_tx_control(priv, | ||
1052 | le32_to_cpu(tx_resp->rate_n_flags), | ||
1053 | info); | ||
1054 | /* FIXME: code repetition end */ | ||
1055 | |||
1056 | IWL_DEBUG_TX_REPLY("1 Frame 0x%x failure :%d\n", | ||
1057 | status & 0xff, tx_resp->failure_frame); | ||
1058 | IWL_DEBUG_TX_REPLY("Rate Info rate_n_flags=%x\n", | ||
1059 | iwl4965_hw_get_rate_n_flags(tx_resp->rate_n_flags)); | ||
1060 | |||
1061 | agg->wait_for_ba = 0; | ||
1062 | } else { | ||
1063 | /* Two or more frames were attempted; expect block-ack */ | ||
1064 | u64 bitmap = 0; | ||
1065 | int start = agg->start_idx; | ||
1066 | |||
1067 | /* Construct bit-map of pending frames within Tx window */ | ||
1068 | for (i = 0; i < agg->frame_count; i++) { | ||
1069 | u16 sc; | ||
1070 | status = le16_to_cpu(frame_status[i].status); | ||
1071 | seq = le16_to_cpu(frame_status[i].sequence); | ||
1072 | idx = SEQ_TO_INDEX(seq); | ||
1073 | txq_id = SEQ_TO_QUEUE(seq); | ||
1074 | |||
1075 | if (status & (AGG_TX_STATE_FEW_BYTES_MSK | | ||
1076 | AGG_TX_STATE_ABORT_MSK)) | ||
1077 | continue; | ||
1078 | |||
1079 | IWL_DEBUG_TX_REPLY("FrameCnt = %d, txq_id=%d idx=%d\n", | ||
1080 | agg->frame_count, txq_id, idx); | ||
1081 | |||
1082 | hdr = iwl_tx_queue_get_hdr(priv, txq_id, idx); | ||
1083 | |||
1084 | sc = le16_to_cpu(hdr->seq_ctrl); | ||
1085 | if (idx != (SEQ_TO_SN(sc) & 0xff)) { | ||
1086 | IWL_ERROR("BUG_ON idx doesn't match seq control" | ||
1087 | " idx=%d, seq_idx=%d, seq=%d\n", | ||
1088 | idx, SEQ_TO_SN(sc), | ||
1089 | hdr->seq_ctrl); | ||
1090 | return -1; | ||
1091 | } | ||
1092 | |||
1093 | IWL_DEBUG_TX_REPLY("AGG Frame i=%d idx %d seq=%d\n", | ||
1094 | i, idx, SEQ_TO_SN(sc)); | ||
1095 | |||
1096 | sh = idx - start; | ||
1097 | if (sh > 64) { | ||
1098 | sh = (start - idx) + 0xff; | ||
1099 | bitmap = bitmap << sh; | ||
1100 | sh = 0; | ||
1101 | start = idx; | ||
1102 | } else if (sh < -64) | ||
1103 | sh = 0xff - (start - idx); | ||
1104 | else if (sh < 0) { | ||
1105 | sh = start - idx; | ||
1106 | start = idx; | ||
1107 | bitmap = bitmap << sh; | ||
1108 | sh = 0; | ||
1109 | } | ||
1110 | bitmap |= (1 << sh); | ||
1111 | IWL_DEBUG_TX_REPLY("start=%d bitmap=0x%x\n", | ||
1112 | start, (u32)(bitmap & 0xFFFFFFFF)); | ||
1113 | } | ||
1114 | |||
1115 | agg->bitmap = bitmap; | ||
1116 | agg->start_idx = start; | ||
1117 | agg->rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags); | ||
1118 | IWL_DEBUG_TX_REPLY("Frames %d start_idx=%d bitmap=0x%llx\n", | ||
1119 | agg->frame_count, agg->start_idx, | ||
1120 | (unsigned long long)agg->bitmap); | ||
458 | 1121 | ||
1122 | if (bitmap) | ||
1123 | agg->wait_for_ba = 1; | ||
1124 | } | ||
459 | return 0; | 1125 | return 0; |
460 | } | 1126 | } |
461 | 1127 | ||
1128 | static void iwl5000_rx_reply_tx(struct iwl_priv *priv, | ||
1129 | struct iwl_rx_mem_buffer *rxb) | ||
1130 | { | ||
1131 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; | ||
1132 | u16 sequence = le16_to_cpu(pkt->hdr.sequence); | ||
1133 | int txq_id = SEQ_TO_QUEUE(sequence); | ||
1134 | int index = SEQ_TO_INDEX(sequence); | ||
1135 | struct iwl_tx_queue *txq = &priv->txq[txq_id]; | ||
1136 | struct ieee80211_tx_info *info; | ||
1137 | struct iwl5000_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; | ||
1138 | u32 status = le16_to_cpu(tx_resp->status.status); | ||
1139 | #ifdef CONFIG_IWL4965_HT | ||
1140 | int tid = MAX_TID_COUNT, sta_id = IWL_INVALID_STATION; | ||
1141 | u16 fc; | ||
1142 | struct ieee80211_hdr *hdr; | ||
1143 | u8 *qc = NULL; | ||
1144 | #endif | ||
1145 | |||
1146 | if ((index >= txq->q.n_bd) || (iwl_queue_used(&txq->q, index) == 0)) { | ||
1147 | IWL_ERROR("Read index for DMA queue txq_id (%d) index %d " | ||
1148 | "is out of range [0-%d] %d %d\n", txq_id, | ||
1149 | index, txq->q.n_bd, txq->q.write_ptr, | ||
1150 | txq->q.read_ptr); | ||
1151 | return; | ||
1152 | } | ||
1153 | |||
1154 | info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb[0]); | ||
1155 | memset(&info->status, 0, sizeof(info->status)); | ||
1156 | |||
1157 | #ifdef CONFIG_IWL4965_HT | ||
1158 | hdr = iwl_tx_queue_get_hdr(priv, txq_id, index); | ||
1159 | fc = le16_to_cpu(hdr->frame_control); | ||
1160 | if (ieee80211_is_qos_data(fc)) { | ||
1161 | qc = ieee80211_get_qos_ctrl(hdr, ieee80211_get_hdrlen(fc)); | ||
1162 | tid = qc[0] & 0xf; | ||
1163 | } | ||
1164 | |||
1165 | sta_id = iwl_get_ra_sta_id(priv, hdr); | ||
1166 | if (txq->sched_retry && unlikely(sta_id == IWL_INVALID_STATION)) { | ||
1167 | IWL_ERROR("Station not known\n"); | ||
1168 | return; | ||
1169 | } | ||
1170 | |||
1171 | if (txq->sched_retry) { | ||
1172 | const u32 scd_ssn = iwl5000_get_scd_ssn(tx_resp); | ||
1173 | struct iwl_ht_agg *agg = NULL; | ||
1174 | |||
1175 | if (!qc) | ||
1176 | return; | ||
1177 | |||
1178 | agg = &priv->stations[sta_id].tid[tid].agg; | ||
1179 | |||
1180 | iwl5000_tx_status_reply_tx(priv, agg, tx_resp, index); | ||
1181 | |||
1182 | if ((tx_resp->frame_count == 1) && !iwl_is_tx_success(status)) { | ||
1183 | /* TODO: send BAR */ | ||
1184 | } | ||
1185 | |||
1186 | if (txq->q.read_ptr != (scd_ssn & 0xff)) { | ||
1187 | int freed, ampdu_q; | ||
1188 | index = iwl_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd); | ||
1189 | IWL_DEBUG_TX_REPLY("Retry scheduler reclaim scd_ssn " | ||
1190 | "%d index %d\n", scd_ssn , index); | ||
1191 | freed = iwl_tx_queue_reclaim(priv, txq_id, index); | ||
1192 | priv->stations[sta_id].tid[tid].tfds_in_queue -= freed; | ||
1193 | |||
1194 | if (iwl_queue_space(&txq->q) > txq->q.low_mark && | ||
1195 | txq_id >= 0 && priv->mac80211_registered && | ||
1196 | agg->state != IWL_EMPTYING_HW_QUEUE_DELBA) { | ||
1197 | /* calculate mac80211 ampdu sw queue to wake */ | ||
1198 | ampdu_q = txq_id - IWL_BACK_QUEUE_FIRST_ID + | ||
1199 | priv->hw->queues; | ||
1200 | if (agg->state == IWL_AGG_OFF) | ||
1201 | ieee80211_wake_queue(priv->hw, txq_id); | ||
1202 | else | ||
1203 | ieee80211_wake_queue(priv->hw, ampdu_q); | ||
1204 | } | ||
1205 | iwl_txq_check_empty(priv, sta_id, tid, txq_id); | ||
1206 | } | ||
1207 | } else { | ||
1208 | #endif /* CONFIG_IWL4965_HT */ | ||
1209 | |||
1210 | info->status.retry_count = tx_resp->failure_frame; | ||
1211 | info->flags = iwl_is_tx_success(status) ? IEEE80211_TX_STAT_ACK : 0; | ||
1212 | iwl4965_hwrate_to_tx_control(priv, le32_to_cpu(tx_resp->rate_n_flags), | ||
1213 | info); | ||
1214 | |||
1215 | IWL_DEBUG_TX("Tx queue %d Status %s (0x%08x) rate_n_flags 0x%x " | ||
1216 | "retries %d\n", txq_id, iwl_get_tx_fail_reason(status), | ||
1217 | status, le32_to_cpu(tx_resp->rate_n_flags), | ||
1218 | tx_resp->failure_frame); | ||
1219 | |||
1220 | IWL_DEBUG_TX_REPLY("Tx queue reclaim %d\n", index); | ||
1221 | #ifdef CONFIG_IWL4965_HT | ||
1222 | if (index != -1) { | ||
1223 | int freed = iwl_tx_queue_reclaim(priv, txq_id, index); | ||
1224 | if (tid != MAX_TID_COUNT) | ||
1225 | priv->stations[sta_id].tid[tid].tfds_in_queue -= freed; | ||
1226 | if (iwl_queue_space(&txq->q) > txq->q.low_mark && | ||
1227 | (txq_id >= 0) && priv->mac80211_registered) | ||
1228 | ieee80211_wake_queue(priv->hw, txq_id); | ||
1229 | if (tid != MAX_TID_COUNT) | ||
1230 | iwl_txq_check_empty(priv, sta_id, tid, txq_id); | ||
1231 | } | ||
1232 | } | ||
1233 | #endif /* CONFIG_IWL4965_HT */ | ||
1234 | |||
1235 | if (iwl_check_bits(status, TX_ABORT_REQUIRED_MSK)) | ||
1236 | IWL_ERROR("TODO: Implement Tx ABORT REQUIRED!!!\n"); | ||
1237 | } | ||
1238 | |||
1239 | /* Currently 5000 is the supperset of everything */ | ||
1240 | static u16 iwl5000_get_hcmd_size(u8 cmd_id, u16 len) | ||
1241 | { | ||
1242 | return len; | ||
1243 | } | ||
1244 | |||
1245 | static void iwl5000_rx_handler_setup(struct iwl_priv *priv) | ||
1246 | { | ||
1247 | /* init calibration handlers */ | ||
1248 | priv->rx_handlers[CALIBRATION_RES_NOTIFICATION] = | ||
1249 | iwl5000_rx_calib_result; | ||
1250 | priv->rx_handlers[CALIBRATION_COMPLETE_NOTIFICATION] = | ||
1251 | iwl5000_rx_calib_complete; | ||
1252 | priv->rx_handlers[REPLY_TX] = iwl5000_rx_reply_tx; | ||
1253 | } | ||
1254 | |||
1255 | |||
1256 | static int iwl5000_hw_valid_rtc_data_addr(u32 addr) | ||
1257 | { | ||
1258 | return (addr >= RTC_DATA_LOWER_BOUND) && | ||
1259 | (addr < IWL50_RTC_DATA_UPPER_BOUND); | ||
1260 | } | ||
1261 | |||
1262 | static int iwl5000_send_rxon_assoc(struct iwl_priv *priv) | ||
1263 | { | ||
1264 | int ret = 0; | ||
1265 | struct iwl5000_rxon_assoc_cmd rxon_assoc; | ||
1266 | const struct iwl_rxon_cmd *rxon1 = &priv->staging_rxon; | ||
1267 | const struct iwl_rxon_cmd *rxon2 = &priv->active_rxon; | ||
1268 | |||
1269 | if ((rxon1->flags == rxon2->flags) && | ||
1270 | (rxon1->filter_flags == rxon2->filter_flags) && | ||
1271 | (rxon1->cck_basic_rates == rxon2->cck_basic_rates) && | ||
1272 | (rxon1->ofdm_ht_single_stream_basic_rates == | ||
1273 | rxon2->ofdm_ht_single_stream_basic_rates) && | ||
1274 | (rxon1->ofdm_ht_dual_stream_basic_rates == | ||
1275 | rxon2->ofdm_ht_dual_stream_basic_rates) && | ||
1276 | (rxon1->ofdm_ht_triple_stream_basic_rates == | ||
1277 | rxon2->ofdm_ht_triple_stream_basic_rates) && | ||
1278 | (rxon1->acquisition_data == rxon2->acquisition_data) && | ||
1279 | (rxon1->rx_chain == rxon2->rx_chain) && | ||
1280 | (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) { | ||
1281 | IWL_DEBUG_INFO("Using current RXON_ASSOC. Not resending.\n"); | ||
1282 | return 0; | ||
1283 | } | ||
1284 | |||
1285 | rxon_assoc.flags = priv->staging_rxon.flags; | ||
1286 | rxon_assoc.filter_flags = priv->staging_rxon.filter_flags; | ||
1287 | rxon_assoc.ofdm_basic_rates = priv->staging_rxon.ofdm_basic_rates; | ||
1288 | rxon_assoc.cck_basic_rates = priv->staging_rxon.cck_basic_rates; | ||
1289 | rxon_assoc.reserved1 = 0; | ||
1290 | rxon_assoc.reserved2 = 0; | ||
1291 | rxon_assoc.reserved3 = 0; | ||
1292 | rxon_assoc.ofdm_ht_single_stream_basic_rates = | ||
1293 | priv->staging_rxon.ofdm_ht_single_stream_basic_rates; | ||
1294 | rxon_assoc.ofdm_ht_dual_stream_basic_rates = | ||
1295 | priv->staging_rxon.ofdm_ht_dual_stream_basic_rates; | ||
1296 | rxon_assoc.rx_chain_select_flags = priv->staging_rxon.rx_chain; | ||
1297 | rxon_assoc.ofdm_ht_triple_stream_basic_rates = | ||
1298 | priv->staging_rxon.ofdm_ht_triple_stream_basic_rates; | ||
1299 | rxon_assoc.acquisition_data = priv->staging_rxon.acquisition_data; | ||
1300 | |||
1301 | ret = iwl_send_cmd_pdu_async(priv, REPLY_RXON_ASSOC, | ||
1302 | sizeof(rxon_assoc), &rxon_assoc, NULL); | ||
1303 | if (ret) | ||
1304 | return ret; | ||
1305 | |||
1306 | return ret; | ||
1307 | } | ||
1308 | |||
462 | static struct iwl_hcmd_ops iwl5000_hcmd = { | 1309 | static struct iwl_hcmd_ops iwl5000_hcmd = { |
1310 | .rxon_assoc = iwl5000_send_rxon_assoc, | ||
463 | }; | 1311 | }; |
464 | 1312 | ||
465 | static struct iwl_hcmd_utils_ops iwl5000_hcmd_utils = { | 1313 | static struct iwl_hcmd_utils_ops iwl5000_hcmd_utils = { |
1314 | .get_hcmd_size = iwl5000_get_hcmd_size, | ||
466 | .build_addsta_hcmd = iwl5000_build_addsta_hcmd, | 1315 | .build_addsta_hcmd = iwl5000_build_addsta_hcmd, |
467 | #ifdef CONFIG_IWL5000_RUN_TIME_CALIB | 1316 | #ifdef CONFIG_IWL5000_RUN_TIME_CALIB |
468 | .gain_computation = iwl5000_gain_computation, | 1317 | .gain_computation = iwl5000_gain_computation, |
@@ -476,9 +1325,17 @@ static struct iwl_lib_ops iwl5000_lib = { | |||
476 | .free_shared_mem = iwl5000_free_shared_mem, | 1325 | .free_shared_mem = iwl5000_free_shared_mem, |
477 | .shared_mem_rx_idx = iwl5000_shared_mem_rx_idx, | 1326 | .shared_mem_rx_idx = iwl5000_shared_mem_rx_idx, |
478 | .txq_update_byte_cnt_tbl = iwl5000_txq_update_byte_cnt_tbl, | 1327 | .txq_update_byte_cnt_tbl = iwl5000_txq_update_byte_cnt_tbl, |
479 | .disable_tx_fifo = iwl5000_disable_tx_fifo, | 1328 | .txq_inval_byte_cnt_tbl = iwl5000_txq_inval_byte_cnt_tbl, |
1329 | .txq_set_sched = iwl5000_txq_set_sched, | ||
1330 | .rx_handler_setup = iwl5000_rx_handler_setup, | ||
1331 | .is_valid_rtc_data_addr = iwl5000_hw_valid_rtc_data_addr, | ||
1332 | .load_ucode = iwl5000_load_ucode, | ||
1333 | .init_alive_start = iwl5000_init_alive_start, | ||
1334 | .alive_notify = iwl5000_alive_notify, | ||
480 | .apm_ops = { | 1335 | .apm_ops = { |
481 | .init = iwl5000_apm_init, | 1336 | .init = iwl5000_apm_init, |
1337 | .reset = iwl5000_apm_reset, | ||
1338 | .stop = iwl5000_apm_stop, | ||
482 | .config = iwl5000_nic_config, | 1339 | .config = iwl5000_nic_config, |
483 | .set_pwr_src = iwl4965_set_pwr_src, | 1340 | .set_pwr_src = iwl4965_set_pwr_src, |
484 | }, | 1341 | }, |
diff --git a/drivers/net/wireless/iwlwifi/iwl-calib.c b/drivers/net/wireless/iwlwifi/iwl-calib.c index 1289d4c91abe..a6c7f0d9a414 100644 --- a/drivers/net/wireless/iwlwifi/iwl-calib.c +++ b/drivers/net/wireless/iwlwifi/iwl-calib.c | |||
@@ -426,6 +426,9 @@ void iwl_init_sensitivity(struct iwl_priv *priv) | |||
426 | struct iwl_sensitivity_data *data = NULL; | 426 | struct iwl_sensitivity_data *data = NULL; |
427 | const struct iwl_sensitivity_ranges *ranges = priv->hw_params.sens; | 427 | const struct iwl_sensitivity_ranges *ranges = priv->hw_params.sens; |
428 | 428 | ||
429 | if (priv->disable_sens_cal) | ||
430 | return; | ||
431 | |||
429 | IWL_DEBUG_CALIB("Start iwl_init_sensitivity\n"); | 432 | IWL_DEBUG_CALIB("Start iwl_init_sensitivity\n"); |
430 | 433 | ||
431 | /* Clear driver's sensitivity algo data */ | 434 | /* Clear driver's sensitivity algo data */ |
@@ -486,6 +489,9 @@ void iwl_sensitivity_calibration(struct iwl_priv *priv, | |||
486 | unsigned long flags; | 489 | unsigned long flags; |
487 | struct statistics_general_data statis; | 490 | struct statistics_general_data statis; |
488 | 491 | ||
492 | if (priv->disable_sens_cal) | ||
493 | return; | ||
494 | |||
489 | data = &(priv->sensitivity_data); | 495 | data = &(priv->sensitivity_data); |
490 | 496 | ||
491 | if (!iwl_is_associated(priv)) { | 497 | if (!iwl_is_associated(priv)) { |
@@ -608,6 +614,9 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv, | |||
608 | unsigned long flags; | 614 | unsigned long flags; |
609 | struct statistics_rx_non_phy *rx_info = &(stat_resp->rx.general); | 615 | struct statistics_rx_non_phy *rx_info = &(stat_resp->rx.general); |
610 | 616 | ||
617 | if (priv->disable_chain_noise_cal) | ||
618 | return; | ||
619 | |||
611 | data = &(priv->chain_noise_data); | 620 | data = &(priv->chain_noise_data); |
612 | 621 | ||
613 | /* Accumulate just the first 20 beacons after the first association, | 622 | /* Accumulate just the first 20 beacons after the first association, |
@@ -777,3 +786,21 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv, | |||
777 | } | 786 | } |
778 | EXPORT_SYMBOL(iwl_chain_noise_calibration); | 787 | EXPORT_SYMBOL(iwl_chain_noise_calibration); |
779 | 788 | ||
789 | |||
790 | void iwl_reset_run_time_calib(struct iwl_priv *priv) | ||
791 | { | ||
792 | int i; | ||
793 | memset(&(priv->sensitivity_data), 0, | ||
794 | sizeof(struct iwl_sensitivity_data)); | ||
795 | memset(&(priv->chain_noise_data), 0, | ||
796 | sizeof(struct iwl_chain_noise_data)); | ||
797 | for (i = 0; i < NUM_RX_CHAINS; i++) | ||
798 | priv->chain_noise_data.delta_gain_code[i] = | ||
799 | CHAIN_NOISE_DELTA_GAIN_INIT_VAL; | ||
800 | |||
801 | /* Ask for statistics now, the uCode will send notification | ||
802 | * periodically after association */ | ||
803 | iwl_send_statistics_request(priv, CMD_ASYNC); | ||
804 | } | ||
805 | EXPORT_SYMBOL(iwl_reset_run_time_calib); | ||
806 | |||
diff --git a/drivers/net/wireless/iwlwifi/iwl-calib.h b/drivers/net/wireless/iwlwifi/iwl-calib.h index 933b0b0a797b..b8e57c59eac8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-calib.h +++ b/drivers/net/wireless/iwlwifi/iwl-calib.h | |||
@@ -78,10 +78,12 @@ void iwl_sensitivity_calibration(struct iwl_priv *priv, | |||
78 | struct iwl4965_notif_statistics *resp); | 78 | struct iwl4965_notif_statistics *resp); |
79 | 79 | ||
80 | void iwl_init_sensitivity(struct iwl_priv *priv); | 80 | void iwl_init_sensitivity(struct iwl_priv *priv); |
81 | 81 | void iwl_reset_run_time_calib(struct iwl_priv *priv); | |
82 | static inline void iwl_chain_noise_reset(struct iwl_priv *priv) | 82 | static inline void iwl_chain_noise_reset(struct iwl_priv *priv) |
83 | { | 83 | { |
84 | if (priv->cfg->ops->utils->chain_noise_reset) | 84 | |
85 | if (!priv->disable_chain_noise_cal && | ||
86 | priv->cfg->ops->utils->chain_noise_reset) | ||
85 | priv->cfg->ops->utils->chain_noise_reset(priv); | 87 | priv->cfg->ops->utils->chain_noise_reset(priv); |
86 | } | 88 | } |
87 | #else | 89 | #else |
@@ -99,6 +101,9 @@ static inline void iwl_init_sensitivity(struct iwl_priv *priv) | |||
99 | static inline void iwl_chain_noise_reset(struct iwl_priv *priv) | 101 | static inline void iwl_chain_noise_reset(struct iwl_priv *priv) |
100 | { | 102 | { |
101 | } | 103 | } |
104 | static inline void iwl_reset_run_time_calib(struct iwl_priv *priv) | ||
105 | { | ||
106 | } | ||
102 | #endif | 107 | #endif |
103 | 108 | ||
104 | #endif /* __iwl_calib_h__ */ | 109 | #endif /* __iwl_calib_h__ */ |
diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h index d16a853f376a..fb6f5ffb9f1d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-commands.h +++ b/drivers/net/wireless/iwlwifi/iwl-commands.h | |||
@@ -93,6 +93,11 @@ enum { | |||
93 | REPLY_LEDS_CMD = 0x48, | 93 | REPLY_LEDS_CMD = 0x48, |
94 | REPLY_TX_LINK_QUALITY_CMD = 0x4e, /* 4965 only */ | 94 | REPLY_TX_LINK_QUALITY_CMD = 0x4e, /* 4965 only */ |
95 | 95 | ||
96 | /* WiMAX coexistence */ | ||
97 | COEX_PRIORITY_TABLE_CMD = 0x5a, /*5000 only */ | ||
98 | COEX_MEDIUM_NOTIFICATION = 0x5b, | ||
99 | COEX_EVENT_CMD = 0x5c, | ||
100 | |||
96 | /* 802.11h related */ | 101 | /* 802.11h related */ |
97 | RADAR_NOTIFICATION = 0x70, /* not used */ | 102 | RADAR_NOTIFICATION = 0x70, /* not used */ |
98 | REPLY_QUIET_CMD = 0x71, /* not used */ | 103 | REPLY_QUIET_CMD = 0x71, /* not used */ |
@@ -368,7 +373,7 @@ struct iwl4965_tx_power_db { | |||
368 | * 3) Tx gain compensation to balance 4965's 2 Tx chains for MIMO operation, | 373 | * 3) Tx gain compensation to balance 4965's 2 Tx chains for MIMO operation, |
369 | * for each of 5 frequency ranges. | 374 | * for each of 5 frequency ranges. |
370 | */ | 375 | */ |
371 | struct iwl4965_init_alive_resp { | 376 | struct iwl_init_alive_resp { |
372 | u8 ucode_minor; | 377 | u8 ucode_minor; |
373 | u8 ucode_major; | 378 | u8 ucode_major; |
374 | __le16 reserved1; | 379 | __le16 reserved1; |
@@ -444,7 +449,7 @@ struct iwl4965_init_alive_resp { | |||
444 | * The Linux driver can print both logs to the system log when a uCode error | 449 | * The Linux driver can print both logs to the system log when a uCode error |
445 | * occurs. | 450 | * occurs. |
446 | */ | 451 | */ |
447 | struct iwl4965_alive_resp { | 452 | struct iwl_alive_resp { |
448 | u8 ucode_minor; | 453 | u8 ucode_minor; |
449 | u8 ucode_major; | 454 | u8 ucode_major; |
450 | __le16 reserved1; | 455 | __le16 reserved1; |
@@ -468,7 +473,7 @@ union tsf { | |||
468 | /* | 473 | /* |
469 | * REPLY_ERROR = 0x2 (response only, not a command) | 474 | * REPLY_ERROR = 0x2 (response only, not a command) |
470 | */ | 475 | */ |
471 | struct iwl4965_error_resp { | 476 | struct iwl_error_resp { |
472 | __le32 error_type; | 477 | __le32 error_type; |
473 | u8 cmd_id; | 478 | u8 cmd_id; |
474 | u8 reserved1; | 479 | u8 reserved1; |
@@ -600,6 +605,46 @@ struct iwl4965_rxon_cmd { | |||
600 | u8 ofdm_ht_dual_stream_basic_rates; | 605 | u8 ofdm_ht_dual_stream_basic_rates; |
601 | } __attribute__ ((packed)); | 606 | } __attribute__ ((packed)); |
602 | 607 | ||
608 | /* 5000 HW just extend this cmmand */ | ||
609 | struct iwl_rxon_cmd { | ||
610 | u8 node_addr[6]; | ||
611 | __le16 reserved1; | ||
612 | u8 bssid_addr[6]; | ||
613 | __le16 reserved2; | ||
614 | u8 wlap_bssid_addr[6]; | ||
615 | __le16 reserved3; | ||
616 | u8 dev_type; | ||
617 | u8 air_propagation; | ||
618 | __le16 rx_chain; | ||
619 | u8 ofdm_basic_rates; | ||
620 | u8 cck_basic_rates; | ||
621 | __le16 assoc_id; | ||
622 | __le32 flags; | ||
623 | __le32 filter_flags; | ||
624 | __le16 channel; | ||
625 | u8 ofdm_ht_single_stream_basic_rates; | ||
626 | u8 ofdm_ht_dual_stream_basic_rates; | ||
627 | u8 ofdm_ht_triple_stream_basic_rates; | ||
628 | u8 reserved5; | ||
629 | __le16 acquisition_data; | ||
630 | __le16 reserved6; | ||
631 | } __attribute__ ((packed)); | ||
632 | |||
633 | struct iwl5000_rxon_assoc_cmd { | ||
634 | __le32 flags; | ||
635 | __le32 filter_flags; | ||
636 | u8 ofdm_basic_rates; | ||
637 | u8 cck_basic_rates; | ||
638 | __le16 reserved1; | ||
639 | u8 ofdm_ht_single_stream_basic_rates; | ||
640 | u8 ofdm_ht_dual_stream_basic_rates; | ||
641 | u8 ofdm_ht_triple_stream_basic_rates; | ||
642 | u8 reserved2; | ||
643 | __le16 rx_chain_select_flags; | ||
644 | __le16 acquisition_data; | ||
645 | __le32 reserved3; | ||
646 | } __attribute__ ((packed)); | ||
647 | |||
603 | /* | 648 | /* |
604 | * REPLY_RXON_ASSOC = 0x11 (command, has simple generic response) | 649 | * REPLY_RXON_ASSOC = 0x11 (command, has simple generic response) |
605 | */ | 650 | */ |
@@ -614,6 +659,9 @@ struct iwl4965_rxon_assoc_cmd { | |||
614 | __le16 reserved; | 659 | __le16 reserved; |
615 | } __attribute__ ((packed)); | 660 | } __attribute__ ((packed)); |
616 | 661 | ||
662 | |||
663 | |||
664 | |||
617 | /* | 665 | /* |
618 | * REPLY_RXON_TIMING = 0x14 (command, has simple generic response) | 666 | * REPLY_RXON_TIMING = 0x14 (command, has simple generic response) |
619 | */ | 667 | */ |
@@ -897,10 +945,28 @@ struct iwl_addsta_cmd { | |||
897 | /* | 945 | /* |
898 | * REPLY_ADD_STA = 0x18 (response) | 946 | * REPLY_ADD_STA = 0x18 (response) |
899 | */ | 947 | */ |
900 | struct iwl4965_add_sta_resp { | 948 | struct iwl_add_sta_resp { |
901 | u8 status; /* ADD_STA_* */ | 949 | u8 status; /* ADD_STA_* */ |
902 | } __attribute__ ((packed)); | 950 | } __attribute__ ((packed)); |
903 | 951 | ||
952 | #define REM_STA_SUCCESS_MSK 0x1 | ||
953 | /* | ||
954 | * REPLY_REM_STA = 0x19 (response) | ||
955 | */ | ||
956 | struct iwl_rem_sta_resp { | ||
957 | u8 status; | ||
958 | } __attribute__ ((packed)); | ||
959 | |||
960 | /* | ||
961 | * REPLY_REM_STA = 0x19 (command) | ||
962 | */ | ||
963 | struct iwl_rem_sta_cmd { | ||
964 | u8 num_sta; /* number of removed stations */ | ||
965 | u8 reserved[3]; | ||
966 | u8 addr[ETH_ALEN]; /* MAC addr of the first station */ | ||
967 | u8 reserved2[2]; | ||
968 | } __attribute__ ((packed)); | ||
969 | |||
904 | /* | 970 | /* |
905 | * REPLY_WEP_KEY = 0x20 | 971 | * REPLY_WEP_KEY = 0x20 |
906 | */ | 972 | */ |
@@ -1170,7 +1236,7 @@ struct iwl4965_dram_scratch { | |||
1170 | /* | 1236 | /* |
1171 | * REPLY_TX = 0x1c (command) | 1237 | * REPLY_TX = 0x1c (command) |
1172 | */ | 1238 | */ |
1173 | struct iwl4965_tx_cmd { | 1239 | struct iwl_tx_cmd { |
1174 | /* | 1240 | /* |
1175 | * MPDU byte count: | 1241 | * MPDU byte count: |
1176 | * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size, | 1242 | * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size, |
@@ -1316,6 +1382,15 @@ enum { | |||
1316 | TX_ABORT_REQUIRED_MSK = 0x80000000, /* bits 31:31 */ | 1382 | TX_ABORT_REQUIRED_MSK = 0x80000000, /* bits 31:31 */ |
1317 | }; | 1383 | }; |
1318 | 1384 | ||
1385 | static inline int iwl_is_tx_success(u32 status) | ||
1386 | { | ||
1387 | status &= TX_STATUS_MSK; | ||
1388 | return (status == TX_STATUS_SUCCESS) | ||
1389 | || (status == TX_STATUS_DIRECT_DONE); | ||
1390 | } | ||
1391 | |||
1392 | |||
1393 | |||
1319 | /* ******************************* | 1394 | /* ******************************* |
1320 | * TX aggregation status | 1395 | * TX aggregation status |
1321 | ******************************* */ | 1396 | ******************************* */ |
@@ -1370,6 +1445,11 @@ enum { | |||
1370 | * within the sending station (this 4965), rather than whether it was | 1445 | * within the sending station (this 4965), rather than whether it was |
1371 | * received successfully by the destination station. | 1446 | * received successfully by the destination station. |
1372 | */ | 1447 | */ |
1448 | struct agg_tx_status { | ||
1449 | __le16 status; | ||
1450 | __le16 sequence; | ||
1451 | } __attribute__ ((packed)); | ||
1452 | |||
1373 | struct iwl4965_tx_resp { | 1453 | struct iwl4965_tx_resp { |
1374 | u8 frame_count; /* 1 no aggregation, >1 aggregation */ | 1454 | u8 frame_count; /* 1 no aggregation, >1 aggregation */ |
1375 | u8 bt_kill_count; /* # blocked by bluetooth (unused for agg) */ | 1455 | u8 bt_kill_count; /* # blocked by bluetooth (unused for agg) */ |
@@ -1404,11 +1484,6 @@ struct iwl4965_tx_resp { | |||
1404 | __le32 status; /* TX status (for aggregation status of 1st frame) */ | 1484 | __le32 status; /* TX status (for aggregation status of 1st frame) */ |
1405 | } __attribute__ ((packed)); | 1485 | } __attribute__ ((packed)); |
1406 | 1486 | ||
1407 | struct agg_tx_status { | ||
1408 | __le16 status; | ||
1409 | __le16 sequence; | ||
1410 | } __attribute__ ((packed)); | ||
1411 | |||
1412 | struct iwl4965_tx_resp_agg { | 1487 | struct iwl4965_tx_resp_agg { |
1413 | u8 frame_count; /* 1 no aggregation, >1 aggregation */ | 1488 | u8 frame_count; /* 1 no aggregation, >1 aggregation */ |
1414 | u8 reserved1; | 1489 | u8 reserved1; |
@@ -1423,6 +1498,44 @@ struct iwl4965_tx_resp_agg { | |||
1423 | /* of 1st frame) */ | 1498 | /* of 1st frame) */ |
1424 | } __attribute__ ((packed)); | 1499 | } __attribute__ ((packed)); |
1425 | 1500 | ||
1501 | struct iwl5000_tx_resp { | ||
1502 | u8 frame_count; /* 1 no aggregation, >1 aggregation */ | ||
1503 | u8 bt_kill_count; /* # blocked by bluetooth (unused for agg) */ | ||
1504 | u8 failure_rts; /* # failures due to unsuccessful RTS */ | ||
1505 | u8 failure_frame; /* # failures due to no ACK (unused for agg) */ | ||
1506 | |||
1507 | /* For non-agg: Rate at which frame was successful. | ||
1508 | * For agg: Rate at which all frames were transmitted. */ | ||
1509 | __le32 rate_n_flags; /* RATE_MCS_* */ | ||
1510 | |||
1511 | /* For non-agg: RTS + CTS + frame tx attempts time + ACK. | ||
1512 | * For agg: RTS + CTS + aggregation tx time + block-ack time. */ | ||
1513 | __le16 wireless_media_time; /* uSecs */ | ||
1514 | |||
1515 | __le16 reserved; | ||
1516 | __le32 pa_power1; /* RF power amplifier measurement (not used) */ | ||
1517 | __le32 pa_power2; | ||
1518 | |||
1519 | __le32 tfd_info; | ||
1520 | __le16 seq_ctl; | ||
1521 | __le16 byte_cnt; | ||
1522 | __le32 tlc_info; | ||
1523 | /* | ||
1524 | * For non-agg: frame status TX_STATUS_* | ||
1525 | * For agg: status of 1st frame, AGG_TX_STATE_*; other frame status | ||
1526 | * fields follow this one, up to frame_count. | ||
1527 | * Bit fields: | ||
1528 | * 11- 0: AGG_TX_STATE_* status code | ||
1529 | * 15-12: Retry count for 1st frame in aggregation (retries | ||
1530 | * occur if tx failed for this frame when it was a | ||
1531 | * member of a previous aggregation block). If rate | ||
1532 | * scaling is used, retry count indicates the rate | ||
1533 | * table entry used for all frames in the new agg. | ||
1534 | * 31-16: Sequence # for this frame's Tx cmd (not SSN!) | ||
1535 | */ | ||
1536 | struct agg_tx_status status; /* TX status (in aggregation - | ||
1537 | * status of 1st frame) */ | ||
1538 | } __attribute__ ((packed)); | ||
1426 | /* | 1539 | /* |
1427 | * REPLY_COMPRESSED_BA = 0xc5 (response only, not a command) | 1540 | * REPLY_COMPRESSED_BA = 0xc5 (response only, not a command) |
1428 | * | 1541 | * |
@@ -2109,7 +2222,7 @@ struct iwl4965_scan_cmd { | |||
2109 | 2222 | ||
2110 | /* For active scans (set to all-0s for passive scans). | 2223 | /* For active scans (set to all-0s for passive scans). |
2111 | * Does not include payload. Must specify Tx rate; no rate scaling. */ | 2224 | * Does not include payload. Must specify Tx rate; no rate scaling. */ |
2112 | struct iwl4965_tx_cmd tx_cmd; | 2225 | struct iwl_tx_cmd tx_cmd; |
2113 | 2226 | ||
2114 | /* For directed active scans (set to all-0s otherwise) */ | 2227 | /* For directed active scans (set to all-0s otherwise) */ |
2115 | struct iwl4965_ssid_ie direct_scan[PROBE_OPTION_MAX]; | 2228 | struct iwl4965_ssid_ie direct_scan[PROBE_OPTION_MAX]; |
@@ -2206,7 +2319,7 @@ struct iwl4965_beacon_notif { | |||
2206 | * REPLY_TX_BEACON = 0x91 (command, has simple generic response) | 2319 | * REPLY_TX_BEACON = 0x91 (command, has simple generic response) |
2207 | */ | 2320 | */ |
2208 | struct iwl4965_tx_beacon_cmd { | 2321 | struct iwl4965_tx_beacon_cmd { |
2209 | struct iwl4965_tx_cmd tx; | 2322 | struct iwl_tx_cmd tx; |
2210 | __le16 tim_idx; | 2323 | __le16 tim_idx; |
2211 | u8 tim_size; | 2324 | u8 tim_size; |
2212 | u8 reserved1; | 2325 | u8 reserved1; |
@@ -2729,10 +2842,59 @@ enum { | |||
2729 | IWL5000_PHY_CALIBRATE_AGC_TABLE_CMD = 14, | 2842 | IWL5000_PHY_CALIBRATE_AGC_TABLE_CMD = 14, |
2730 | IWL5000_PHY_CALIBRATE_CRYSTAL_FRQ_CMD = 15, | 2843 | IWL5000_PHY_CALIBRATE_CRYSTAL_FRQ_CMD = 15, |
2731 | IWL5000_PHY_CALIBRATE_BASE_BAND_CMD = 16, | 2844 | IWL5000_PHY_CALIBRATE_BASE_BAND_CMD = 16, |
2845 | IWL5000_PHY_CALIBRATE_TX_IQ_PERD_CMD = 17, | ||
2732 | IWL5000_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD = 18, | 2846 | IWL5000_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD = 18, |
2733 | IWL5000_PHY_CALIBRATE_CHAIN_NOISE_GAIN_CMD = 19, | 2847 | IWL5000_PHY_CALIBRATE_CHAIN_NOISE_GAIN_CMD = 19, |
2734 | }; | 2848 | }; |
2735 | 2849 | ||
2850 | enum { | ||
2851 | CALIBRATION_CFG_CMD = 0x65, | ||
2852 | CALIBRATION_RES_NOTIFICATION = 0x66, | ||
2853 | CALIBRATION_COMPLETE_NOTIFICATION = 0x67 | ||
2854 | }; | ||
2855 | |||
2856 | struct iwl_cal_crystal_freq_cmd { | ||
2857 | u8 cap_pin1; | ||
2858 | u8 cap_pin2; | ||
2859 | } __attribute__ ((packed)); | ||
2860 | |||
2861 | struct iwl5000_calibration { | ||
2862 | u8 op_code; | ||
2863 | u8 first_group; | ||
2864 | u8 num_groups; | ||
2865 | u8 all_data_valid; | ||
2866 | struct iwl_cal_crystal_freq_cmd data; | ||
2867 | } __attribute__ ((packed)); | ||
2868 | |||
2869 | #define IWL_CALIB_INIT_CFG_ALL __constant_cpu_to_le32(0xffffffff) | ||
2870 | |||
2871 | struct iwl_calib_cfg_elmnt_s { | ||
2872 | __le32 is_enable; | ||
2873 | __le32 start; | ||
2874 | __le32 send_res; | ||
2875 | __le32 apply_res; | ||
2876 | __le32 reserved; | ||
2877 | } __attribute__ ((packed)); | ||
2878 | |||
2879 | struct iwl_calib_cfg_status_s { | ||
2880 | struct iwl_calib_cfg_elmnt_s once; | ||
2881 | struct iwl_calib_cfg_elmnt_s perd; | ||
2882 | __le32 flags; | ||
2883 | } __attribute__ ((packed)); | ||
2884 | |||
2885 | struct iwl5000_calib_cfg_cmd { | ||
2886 | struct iwl_calib_cfg_status_s ucd_calib_cfg; | ||
2887 | struct iwl_calib_cfg_status_s drv_calib_cfg; | ||
2888 | __le32 reserved1; | ||
2889 | } __attribute__ ((packed)); | ||
2890 | |||
2891 | struct iwl5000_calib_hdr { | ||
2892 | u8 op_code; | ||
2893 | u8 first_group; | ||
2894 | u8 groups_num; | ||
2895 | u8 data_valid; | ||
2896 | } __attribute__ ((packed)); | ||
2897 | |||
2736 | struct iwl5000_calibration_chain_noise_reset_cmd { | 2898 | struct iwl5000_calibration_chain_noise_reset_cmd { |
2737 | u8 op_code; /* IWL5000_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD */ | 2899 | u8 op_code; /* IWL5000_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD */ |
2738 | u8 flags; /* not used */ | 2900 | u8 flags; /* not used */ |
@@ -2771,6 +2933,55 @@ struct iwl4965_led_cmd { | |||
2771 | u8 reserved; | 2933 | u8 reserved; |
2772 | } __attribute__ ((packed)); | 2934 | } __attribute__ ((packed)); |
2773 | 2935 | ||
2936 | /* | ||
2937 | * Coexistence WIFI/WIMAX Command | ||
2938 | * COEX_PRIORITY_TABLE_CMD = 0x5a | ||
2939 | * | ||
2940 | */ | ||
2941 | enum { | ||
2942 | COEX_UNASSOC_IDLE = 0, | ||
2943 | COEX_UNASSOC_MANUAL_SCAN = 1, | ||
2944 | COEX_UNASSOC_AUTO_SCAN = 2, | ||
2945 | COEX_CALIBRATION = 3, | ||
2946 | COEX_PERIODIC_CALIBRATION = 4, | ||
2947 | COEX_CONNECTION_ESTAB = 5, | ||
2948 | COEX_ASSOCIATED_IDLE = 6, | ||
2949 | COEX_ASSOC_MANUAL_SCAN = 7, | ||
2950 | COEX_ASSOC_AUTO_SCAN = 8, | ||
2951 | COEX_ASSOC_ACTIVE_LEVEL = 9, | ||
2952 | COEX_RF_ON = 10, | ||
2953 | COEX_RF_OFF = 11, | ||
2954 | COEX_STAND_ALONE_DEBUG = 12, | ||
2955 | COEX_IPAN_ASSOC_LEVEL = 13, | ||
2956 | COEX_RSRVD1 = 14, | ||
2957 | COEX_RSRVD2 = 15, | ||
2958 | COEX_NUM_OF_EVENTS = 16 | ||
2959 | }; | ||
2960 | |||
2961 | struct iwl_wimax_coex_event_entry { | ||
2962 | u8 request_prio; | ||
2963 | u8 win_medium_prio; | ||
2964 | u8 reserved; | ||
2965 | u8 flags; | ||
2966 | } __attribute__ ((packed)); | ||
2967 | |||
2968 | /* COEX flag masks */ | ||
2969 | |||
2970 | /* Staion table is valid */ | ||
2971 | #define COEX_FLAGS_STA_TABLE_VALID_MSK (0x1) | ||
2972 | /* UnMask wakeup src at unassociated sleep */ | ||
2973 | #define COEX_FLAGS_UNASSOC_WA_UNMASK_MSK (0x4) | ||
2974 | /* UnMask wakeup src at associated sleep */ | ||
2975 | #define COEX_FLAGS_ASSOC_WA_UNMASK_MSK (0x8) | ||
2976 | /* Enable CoEx feature. */ | ||
2977 | #define COEX_FLAGS_COEX_ENABLE_MSK (0x80) | ||
2978 | |||
2979 | struct iwl_wimax_coex_cmd { | ||
2980 | u8 flags; | ||
2981 | u8 reserved[3]; | ||
2982 | struct iwl_wimax_coex_event_entry sta_prio[COEX_NUM_OF_EVENTS]; | ||
2983 | } __attribute__ ((packed)); | ||
2984 | |||
2774 | /****************************************************************************** | 2985 | /****************************************************************************** |
2775 | * (13) | 2986 | * (13) |
2776 | * Union of all expected notifications/responses: | 2987 | * Union of all expected notifications/responses: |
@@ -2781,20 +2992,22 @@ struct iwl_rx_packet { | |||
2781 | __le32 len; | 2992 | __le32 len; |
2782 | struct iwl_cmd_header hdr; | 2993 | struct iwl_cmd_header hdr; |
2783 | union { | 2994 | union { |
2784 | struct iwl4965_alive_resp alive_frame; | 2995 | struct iwl_alive_resp alive_frame; |
2785 | struct iwl4965_rx_frame rx_frame; | 2996 | struct iwl4965_rx_frame rx_frame; |
2786 | struct iwl4965_tx_resp tx_resp; | 2997 | struct iwl4965_tx_resp tx_resp; |
2787 | struct iwl4965_spectrum_notification spectrum_notif; | 2998 | struct iwl4965_spectrum_notification spectrum_notif; |
2788 | struct iwl4965_csa_notification csa_notif; | 2999 | struct iwl4965_csa_notification csa_notif; |
2789 | struct iwl4965_error_resp err_resp; | 3000 | struct iwl_error_resp err_resp; |
2790 | struct iwl4965_card_state_notif card_state_notif; | 3001 | struct iwl4965_card_state_notif card_state_notif; |
2791 | struct iwl4965_beacon_notif beacon_status; | 3002 | struct iwl4965_beacon_notif beacon_status; |
2792 | struct iwl4965_add_sta_resp add_sta; | 3003 | struct iwl_add_sta_resp add_sta; |
3004 | struct iwl_rem_sta_resp rem_sta; | ||
2793 | struct iwl4965_sleep_notification sleep_notif; | 3005 | struct iwl4965_sleep_notification sleep_notif; |
2794 | struct iwl4965_spectrum_resp spectrum; | 3006 | struct iwl4965_spectrum_resp spectrum; |
2795 | struct iwl4965_notif_statistics stats; | 3007 | struct iwl4965_notif_statistics stats; |
2796 | struct iwl4965_compressed_ba_resp compressed_ba; | 3008 | struct iwl4965_compressed_ba_resp compressed_ba; |
2797 | struct iwl4965_missed_beacon_notif missed_beacon; | 3009 | struct iwl4965_missed_beacon_notif missed_beacon; |
3010 | struct iwl5000_calibration calib; | ||
2798 | __le32 status; | 3011 | __le32 status; |
2799 | u8 raw[0]; | 3012 | u8 raw[0]; |
2800 | } u; | 3013 | } u; |
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index d3cbad2bf877..61716ba90427 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c | |||
@@ -67,7 +67,7 @@ MODULE_LICENSE("GPL"); | |||
67 | * maps to IWL_RATE_INVALID | 67 | * maps to IWL_RATE_INVALID |
68 | * | 68 | * |
69 | */ | 69 | */ |
70 | const struct iwl4965_rate_info iwl4965_rates[IWL_RATE_COUNT] = { | 70 | const struct iwl_rate_info iwl_rates[IWL_RATE_COUNT] = { |
71 | IWL_DECLARE_RATE_INFO(1, INV, INV, 2, INV, 2, INV, 2), /* 1mbps */ | 71 | IWL_DECLARE_RATE_INFO(1, INV, INV, 2, INV, 2, INV, 2), /* 1mbps */ |
72 | IWL_DECLARE_RATE_INFO(2, INV, 1, 5, 1, 5, 1, 5), /* 2mbps */ | 72 | IWL_DECLARE_RATE_INFO(2, INV, 1, 5, 1, 5, 1, 5), /* 2mbps */ |
73 | IWL_DECLARE_RATE_INFO(5, INV, 2, 6, 2, 11, 2, 11), /*5.5mbps */ | 73 | IWL_DECLARE_RATE_INFO(5, INV, 2, 6, 2, 11, 2, 11), /*5.5mbps */ |
@@ -83,7 +83,12 @@ const struct iwl4965_rate_info iwl4965_rates[IWL_RATE_COUNT] = { | |||
83 | IWL_DECLARE_RATE_INFO(60, 60, 48, INV, 48, INV, 48, INV),/* 60mbps */ | 83 | IWL_DECLARE_RATE_INFO(60, 60, 48, INV, 48, INV, 48, INV),/* 60mbps */ |
84 | /* FIXME:RS: ^^ should be INV (legacy) */ | 84 | /* FIXME:RS: ^^ should be INV (legacy) */ |
85 | }; | 85 | }; |
86 | EXPORT_SYMBOL(iwl4965_rates); | 86 | EXPORT_SYMBOL(iwl_rates); |
87 | |||
88 | |||
89 | const u8 iwl_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; | ||
90 | EXPORT_SYMBOL(iwl_bcast_addr); | ||
91 | |||
87 | 92 | ||
88 | /* This function both allocates and initializes hw and priv. */ | 93 | /* This function both allocates and initializes hw and priv. */ |
89 | struct ieee80211_hw *iwl_alloc_all(struct iwl_cfg *cfg, | 94 | struct ieee80211_hw *iwl_alloc_all(struct iwl_cfg *cfg, |
@@ -317,24 +322,33 @@ void iwl_reset_qos(struct iwl_priv *priv) | |||
317 | EXPORT_SYMBOL(iwl_reset_qos); | 322 | EXPORT_SYMBOL(iwl_reset_qos); |
318 | 323 | ||
319 | #ifdef CONFIG_IWL4965_HT | 324 | #ifdef CONFIG_IWL4965_HT |
325 | #define MAX_BIT_RATE_40_MHZ 0x96; /* 150 Mbps */ | ||
326 | #define MAX_BIT_RATE_20_MHZ 0x48; /* 72 Mbps */ | ||
320 | static void iwlcore_init_ht_hw_capab(const struct iwl_priv *priv, | 327 | static void iwlcore_init_ht_hw_capab(const struct iwl_priv *priv, |
321 | struct ieee80211_ht_info *ht_info, | 328 | struct ieee80211_ht_info *ht_info, |
322 | enum ieee80211_band band) | 329 | enum ieee80211_band band) |
323 | { | 330 | { |
331 | u16 max_bit_rate = 0; | ||
332 | u8 rx_chains_num = priv->hw_params.rx_chains_num; | ||
333 | u8 tx_chains_num = priv->hw_params.tx_chains_num; | ||
334 | |||
324 | ht_info->cap = 0; | 335 | ht_info->cap = 0; |
325 | memset(ht_info->supp_mcs_set, 0, 16); | 336 | memset(ht_info->supp_mcs_set, 0, 16); |
326 | 337 | ||
327 | ht_info->ht_supported = 1; | 338 | ht_info->ht_supported = 1; |
328 | 339 | ||
340 | ht_info->cap |= (u16)IEEE80211_HT_CAP_GRN_FLD; | ||
341 | ht_info->cap |= (u16)IEEE80211_HT_CAP_SGI_20; | ||
342 | ht_info->cap |= (u16)(IEEE80211_HT_CAP_MIMO_PS & | ||
343 | (IWL_MIMO_PS_NONE << 2)); | ||
344 | |||
345 | max_bit_rate = MAX_BIT_RATE_20_MHZ; | ||
329 | if (priv->hw_params.fat_channel & BIT(band)) { | 346 | if (priv->hw_params.fat_channel & BIT(band)) { |
330 | ht_info->cap |= (u16)IEEE80211_HT_CAP_SUP_WIDTH; | 347 | ht_info->cap |= (u16)IEEE80211_HT_CAP_SUP_WIDTH; |
331 | ht_info->cap |= (u16)IEEE80211_HT_CAP_SGI_40; | 348 | ht_info->cap |= (u16)IEEE80211_HT_CAP_SGI_40; |
332 | ht_info->supp_mcs_set[4] = 0x01; | 349 | ht_info->supp_mcs_set[4] = 0x01; |
350 | max_bit_rate = MAX_BIT_RATE_40_MHZ; | ||
333 | } | 351 | } |
334 | ht_info->cap |= (u16)IEEE80211_HT_CAP_GRN_FLD; | ||
335 | ht_info->cap |= (u16)IEEE80211_HT_CAP_SGI_20; | ||
336 | ht_info->cap |= (u16)(IEEE80211_HT_CAP_MIMO_PS & | ||
337 | (IWL_MIMO_PS_NONE << 2)); | ||
338 | 352 | ||
339 | if (priv->cfg->mod_params->amsdu_size_8K) | 353 | if (priv->cfg->mod_params->amsdu_size_8K) |
340 | ht_info->cap |= (u16)IEEE80211_HT_CAP_MAX_AMSDU; | 354 | ht_info->cap |= (u16)IEEE80211_HT_CAP_MAX_AMSDU; |
@@ -343,10 +357,22 @@ static void iwlcore_init_ht_hw_capab(const struct iwl_priv *priv, | |||
343 | ht_info->ampdu_density = CFG_HT_MPDU_DENSITY_DEF; | 357 | ht_info->ampdu_density = CFG_HT_MPDU_DENSITY_DEF; |
344 | 358 | ||
345 | ht_info->supp_mcs_set[0] = 0xFF; | 359 | ht_info->supp_mcs_set[0] = 0xFF; |
346 | if (priv->hw_params.tx_chains_num >= 2) | 360 | if (rx_chains_num >= 2) |
347 | ht_info->supp_mcs_set[1] = 0xFF; | 361 | ht_info->supp_mcs_set[1] = 0xFF; |
348 | if (priv->hw_params.tx_chains_num >= 3) | 362 | if (rx_chains_num >= 3) |
349 | ht_info->supp_mcs_set[2] = 0xFF; | 363 | ht_info->supp_mcs_set[2] = 0xFF; |
364 | |||
365 | /* Highest supported Rx data rate */ | ||
366 | max_bit_rate *= rx_chains_num; | ||
367 | ht_info->supp_mcs_set[10] = (u8)(max_bit_rate & 0x00FF); | ||
368 | ht_info->supp_mcs_set[11] = (u8)((max_bit_rate & 0xFF00) >> 8); | ||
369 | |||
370 | /* Tx MCS capabilities */ | ||
371 | ht_info->supp_mcs_set[12] = IEEE80211_HT_CAP_MCS_TX_DEFINED; | ||
372 | if (tx_chains_num != rx_chains_num) { | ||
373 | ht_info->supp_mcs_set[12] |= IEEE80211_HT_CAP_MCS_TX_RX_DIFF; | ||
374 | ht_info->supp_mcs_set[12] |= ((tx_chains_num - 1) << 2); | ||
375 | } | ||
350 | } | 376 | } |
351 | #else | 377 | #else |
352 | static inline void iwlcore_init_ht_hw_capab(const struct iwl_priv *priv, | 378 | static inline void iwlcore_init_ht_hw_capab(const struct iwl_priv *priv, |
@@ -362,7 +388,7 @@ static void iwlcore_init_hw_rates(struct iwl_priv *priv, | |||
362 | int i; | 388 | int i; |
363 | 389 | ||
364 | for (i = 0; i < IWL_RATE_COUNT; i++) { | 390 | for (i = 0; i < IWL_RATE_COUNT; i++) { |
365 | rates[i].bitrate = iwl4965_rates[i].ieee * 5; | 391 | rates[i].bitrate = iwl_rates[i].ieee * 5; |
366 | rates[i].hw_value = i; /* Rate scaling will work on indexes */ | 392 | rates[i].hw_value = i; /* Rate scaling will work on indexes */ |
367 | rates[i].hw_value_short = i; | 393 | rates[i].hw_value_short = i; |
368 | rates[i].flags = 0; | 394 | rates[i].flags = 0; |
@@ -371,7 +397,7 @@ static void iwlcore_init_hw_rates(struct iwl_priv *priv, | |||
371 | * If CCK != 1M then set short preamble rate flag. | 397 | * If CCK != 1M then set short preamble rate flag. |
372 | */ | 398 | */ |
373 | rates[i].flags |= | 399 | rates[i].flags |= |
374 | (iwl4965_rates[i].plcp == IWL_RATE_1M_PLCP) ? | 400 | (iwl_rates[i].plcp == IWL_RATE_1M_PLCP) ? |
375 | 0 : IEEE80211_RATE_SHORT_PREAMBLE; | 401 | 0 : IEEE80211_RATE_SHORT_PREAMBLE; |
376 | } | 402 | } |
377 | } | 403 | } |
@@ -460,6 +486,25 @@ static int iwlcore_init_geos(struct iwl_priv *priv) | |||
460 | if (ch->flags & EEPROM_CHANNEL_RADAR) | 486 | if (ch->flags & EEPROM_CHANNEL_RADAR) |
461 | geo_ch->flags |= IEEE80211_CHAN_RADAR; | 487 | geo_ch->flags |= IEEE80211_CHAN_RADAR; |
462 | 488 | ||
489 | switch (ch->fat_extension_channel) { | ||
490 | case HT_IE_EXT_CHANNEL_ABOVE: | ||
491 | /* only above is allowed, disable below */ | ||
492 | geo_ch->flags |= IEEE80211_CHAN_NO_FAT_BELOW; | ||
493 | break; | ||
494 | case HT_IE_EXT_CHANNEL_BELOW: | ||
495 | /* only below is allowed, disable above */ | ||
496 | geo_ch->flags |= IEEE80211_CHAN_NO_FAT_ABOVE; | ||
497 | break; | ||
498 | case HT_IE_EXT_CHANNEL_NONE: | ||
499 | /* fat not allowed: disable both*/ | ||
500 | geo_ch->flags |= (IEEE80211_CHAN_NO_FAT_ABOVE | | ||
501 | IEEE80211_CHAN_NO_FAT_BELOW); | ||
502 | break; | ||
503 | case HT_IE_EXT_CHANNEL_MAX: | ||
504 | /* both above and below are permitted */ | ||
505 | break; | ||
506 | } | ||
507 | |||
463 | if (ch->max_power_avg > priv->max_channel_txpower_limit) | 508 | if (ch->max_power_avg > priv->max_channel_txpower_limit) |
464 | priv->max_channel_txpower_limit = | 509 | priv->max_channel_txpower_limit = |
465 | ch->max_power_avg; | 510 | ch->max_power_avg; |
@@ -492,12 +537,6 @@ static int iwlcore_init_geos(struct iwl_priv *priv) | |||
492 | priv->bands[IEEE80211_BAND_2GHZ].n_channels, | 537 | priv->bands[IEEE80211_BAND_2GHZ].n_channels, |
493 | priv->bands[IEEE80211_BAND_5GHZ].n_channels); | 538 | priv->bands[IEEE80211_BAND_5GHZ].n_channels); |
494 | 539 | ||
495 | if (priv->bands[IEEE80211_BAND_2GHZ].n_channels) | ||
496 | priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = | ||
497 | &priv->bands[IEEE80211_BAND_2GHZ]; | ||
498 | if (priv->bands[IEEE80211_BAND_5GHZ].n_channels) | ||
499 | priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = | ||
500 | &priv->bands[IEEE80211_BAND_5GHZ]; | ||
501 | 540 | ||
502 | set_bit(STATUS_GEO_CONFIGURED, &priv->status); | 541 | set_bit(STATUS_GEO_CONFIGURED, &priv->status); |
503 | 542 | ||
@@ -507,13 +546,12 @@ static int iwlcore_init_geos(struct iwl_priv *priv) | |||
507 | /* | 546 | /* |
508 | * iwlcore_free_geos - undo allocations in iwlcore_init_geos | 547 | * iwlcore_free_geos - undo allocations in iwlcore_init_geos |
509 | */ | 548 | */ |
510 | void iwlcore_free_geos(struct iwl_priv *priv) | 549 | static void iwlcore_free_geos(struct iwl_priv *priv) |
511 | { | 550 | { |
512 | kfree(priv->ieee_channels); | 551 | kfree(priv->ieee_channels); |
513 | kfree(priv->ieee_rates); | 552 | kfree(priv->ieee_rates); |
514 | clear_bit(STATUS_GEO_CONFIGURED, &priv->status); | 553 | clear_bit(STATUS_GEO_CONFIGURED, &priv->status); |
515 | } | 554 | } |
516 | EXPORT_SYMBOL(iwlcore_free_geos); | ||
517 | 555 | ||
518 | #ifdef CONFIG_IWL4965_HT | 556 | #ifdef CONFIG_IWL4965_HT |
519 | static u8 is_single_rx_stream(struct iwl_priv *priv) | 557 | static u8 is_single_rx_stream(struct iwl_priv *priv) |
@@ -567,7 +605,7 @@ EXPORT_SYMBOL(iwl_is_fat_tx_allowed); | |||
567 | 605 | ||
568 | void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_info *ht_info) | 606 | void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_info *ht_info) |
569 | { | 607 | { |
570 | struct iwl4965_rxon_cmd *rxon = &priv->staging_rxon; | 608 | struct iwl_rxon_cmd *rxon = &priv->staging_rxon; |
571 | u32 val; | 609 | u32 val; |
572 | 610 | ||
573 | if (!ht_info->is_ht) | 611 | if (!ht_info->is_ht) |
@@ -741,8 +779,9 @@ int iwl_set_rxon_channel(struct iwl_priv *priv, | |||
741 | } | 779 | } |
742 | EXPORT_SYMBOL(iwl_set_rxon_channel); | 780 | EXPORT_SYMBOL(iwl_set_rxon_channel); |
743 | 781 | ||
744 | static void iwlcore_init_hw(struct iwl_priv *priv) | 782 | int iwl_setup_mac(struct iwl_priv *priv) |
745 | { | 783 | { |
784 | int ret; | ||
746 | struct ieee80211_hw *hw = priv->hw; | 785 | struct ieee80211_hw *hw = priv->hw; |
747 | hw->rate_control_algorithm = "iwl-4965-rs"; | 786 | hw->rate_control_algorithm = "iwl-4965-rs"; |
748 | 787 | ||
@@ -756,9 +795,29 @@ static void iwlcore_init_hw(struct iwl_priv *priv) | |||
756 | /* Enhanced value; more queues, to support 11n aggregation */ | 795 | /* Enhanced value; more queues, to support 11n aggregation */ |
757 | hw->ampdu_queues = 12; | 796 | hw->ampdu_queues = 12; |
758 | #endif /* CONFIG_IWL4965_HT */ | 797 | #endif /* CONFIG_IWL4965_HT */ |
798 | |||
799 | hw->conf.beacon_int = 100; | ||
800 | |||
801 | if (priv->bands[IEEE80211_BAND_2GHZ].n_channels) | ||
802 | priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = | ||
803 | &priv->bands[IEEE80211_BAND_2GHZ]; | ||
804 | if (priv->bands[IEEE80211_BAND_5GHZ].n_channels) | ||
805 | priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = | ||
806 | &priv->bands[IEEE80211_BAND_5GHZ]; | ||
807 | |||
808 | ret = ieee80211_register_hw(priv->hw); | ||
809 | if (ret) { | ||
810 | IWL_ERROR("Failed to register hw (error %d)\n", ret); | ||
811 | return ret; | ||
812 | } | ||
813 | priv->mac80211_registered = 1; | ||
814 | |||
815 | return 0; | ||
759 | } | 816 | } |
817 | EXPORT_SYMBOL(iwl_setup_mac); | ||
760 | 818 | ||
761 | static int iwlcore_init_drv(struct iwl_priv *priv) | 819 | |
820 | int iwl_init_drv(struct iwl_priv *priv) | ||
762 | { | 821 | { |
763 | int ret; | 822 | int ret; |
764 | int i; | 823 | int i; |
@@ -795,6 +854,9 @@ static int iwlcore_init_drv(struct iwl_priv *priv) | |||
795 | /* Choose which receivers/antennas to use */ | 854 | /* Choose which receivers/antennas to use */ |
796 | iwl_set_rxon_chain(priv); | 855 | iwl_set_rxon_chain(priv); |
797 | 856 | ||
857 | if (priv->cfg->mod_params->enable_qos) | ||
858 | priv->qos_data.qos_enable = 1; | ||
859 | |||
798 | iwl_reset_qos(priv); | 860 | iwl_reset_qos(priv); |
799 | 861 | ||
800 | priv->qos_data.qos_active = 0; | 862 | priv->qos_data.qos_active = 0; |
@@ -819,34 +881,39 @@ static int iwlcore_init_drv(struct iwl_priv *priv) | |||
819 | goto err_free_channel_map; | 881 | goto err_free_channel_map; |
820 | } | 882 | } |
821 | 883 | ||
822 | ret = ieee80211_register_hw(priv->hw); | ||
823 | if (ret) { | ||
824 | IWL_ERROR("Failed to register network device (error %d)\n", | ||
825 | ret); | ||
826 | goto err_free_geos; | ||
827 | } | ||
828 | |||
829 | priv->hw->conf.beacon_int = 100; | ||
830 | priv->mac80211_registered = 1; | ||
831 | |||
832 | return 0; | 884 | return 0; |
833 | 885 | ||
834 | err_free_geos: | ||
835 | iwlcore_free_geos(priv); | ||
836 | err_free_channel_map: | 886 | err_free_channel_map: |
837 | iwl_free_channel_map(priv); | 887 | iwl_free_channel_map(priv); |
838 | err: | 888 | err: |
839 | return ret; | 889 | return ret; |
840 | } | 890 | } |
891 | EXPORT_SYMBOL(iwl_init_drv); | ||
841 | 892 | ||
842 | int iwl_setup(struct iwl_priv *priv) | 893 | void iwl_free_calib_results(struct iwl_priv *priv) |
843 | { | 894 | { |
844 | int ret = 0; | 895 | kfree(priv->calib_results.lo_res); |
845 | iwlcore_init_hw(priv); | 896 | priv->calib_results.lo_res = NULL; |
846 | ret = iwlcore_init_drv(priv); | 897 | priv->calib_results.lo_res_len = 0; |
847 | return ret; | 898 | |
899 | kfree(priv->calib_results.tx_iq_res); | ||
900 | priv->calib_results.tx_iq_res = NULL; | ||
901 | priv->calib_results.tx_iq_res_len = 0; | ||
902 | |||
903 | kfree(priv->calib_results.tx_iq_perd_res); | ||
904 | priv->calib_results.tx_iq_perd_res = NULL; | ||
905 | priv->calib_results.tx_iq_perd_res_len = 0; | ||
906 | } | ||
907 | EXPORT_SYMBOL(iwl_free_calib_results); | ||
908 | |||
909 | void iwl_uninit_drv(struct iwl_priv *priv) | ||
910 | { | ||
911 | iwl_free_calib_results(priv); | ||
912 | iwlcore_free_geos(priv); | ||
913 | iwl_free_channel_map(priv); | ||
914 | kfree(priv->scan); | ||
848 | } | 915 | } |
849 | EXPORT_SYMBOL(iwl_setup); | 916 | EXPORT_SYMBOL(iwl_uninit_drv); |
850 | 917 | ||
851 | /* Low level driver call this function to update iwlcore with | 918 | /* Low level driver call this function to update iwlcore with |
852 | * driver status. | 919 | * driver status. |
@@ -1024,3 +1091,185 @@ int iwl_verify_ucode(struct iwl_priv *priv) | |||
1024 | } | 1091 | } |
1025 | EXPORT_SYMBOL(iwl_verify_ucode); | 1092 | EXPORT_SYMBOL(iwl_verify_ucode); |
1026 | 1093 | ||
1094 | |||
1095 | static const char *desc_lookup(int i) | ||
1096 | { | ||
1097 | switch (i) { | ||
1098 | case 1: | ||
1099 | return "FAIL"; | ||
1100 | case 2: | ||
1101 | return "BAD_PARAM"; | ||
1102 | case 3: | ||
1103 | return "BAD_CHECKSUM"; | ||
1104 | case 4: | ||
1105 | return "NMI_INTERRUPT"; | ||
1106 | case 5: | ||
1107 | return "SYSASSERT"; | ||
1108 | case 6: | ||
1109 | return "FATAL_ERROR"; | ||
1110 | } | ||
1111 | |||
1112 | return "UNKNOWN"; | ||
1113 | } | ||
1114 | |||
1115 | #define ERROR_START_OFFSET (1 * sizeof(u32)) | ||
1116 | #define ERROR_ELEM_SIZE (7 * sizeof(u32)) | ||
1117 | |||
1118 | void iwl_dump_nic_error_log(struct iwl_priv *priv) | ||
1119 | { | ||
1120 | u32 data2, line; | ||
1121 | u32 desc, time, count, base, data1; | ||
1122 | u32 blink1, blink2, ilink1, ilink2; | ||
1123 | int ret; | ||
1124 | |||
1125 | if (priv->ucode_type == UCODE_INIT) | ||
1126 | base = le32_to_cpu(priv->card_alive_init.error_event_table_ptr); | ||
1127 | else | ||
1128 | base = le32_to_cpu(priv->card_alive.error_event_table_ptr); | ||
1129 | |||
1130 | if (!priv->cfg->ops->lib->is_valid_rtc_data_addr(base)) { | ||
1131 | IWL_ERROR("Not valid error log pointer 0x%08X\n", base); | ||
1132 | return; | ||
1133 | } | ||
1134 | |||
1135 | ret = iwl_grab_nic_access(priv); | ||
1136 | if (ret) { | ||
1137 | IWL_WARNING("Can not read from adapter at this time.\n"); | ||
1138 | return; | ||
1139 | } | ||
1140 | |||
1141 | count = iwl_read_targ_mem(priv, base); | ||
1142 | |||
1143 | if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) { | ||
1144 | IWL_ERROR("Start IWL Error Log Dump:\n"); | ||
1145 | IWL_ERROR("Status: 0x%08lX, count: %d\n", priv->status, count); | ||
1146 | } | ||
1147 | |||
1148 | desc = iwl_read_targ_mem(priv, base + 1 * sizeof(u32)); | ||
1149 | blink1 = iwl_read_targ_mem(priv, base + 3 * sizeof(u32)); | ||
1150 | blink2 = iwl_read_targ_mem(priv, base + 4 * sizeof(u32)); | ||
1151 | ilink1 = iwl_read_targ_mem(priv, base + 5 * sizeof(u32)); | ||
1152 | ilink2 = iwl_read_targ_mem(priv, base + 6 * sizeof(u32)); | ||
1153 | data1 = iwl_read_targ_mem(priv, base + 7 * sizeof(u32)); | ||
1154 | data2 = iwl_read_targ_mem(priv, base + 8 * sizeof(u32)); | ||
1155 | line = iwl_read_targ_mem(priv, base + 9 * sizeof(u32)); | ||
1156 | time = iwl_read_targ_mem(priv, base + 11 * sizeof(u32)); | ||
1157 | |||
1158 | IWL_ERROR("Desc Time " | ||
1159 | "data1 data2 line\n"); | ||
1160 | IWL_ERROR("%-13s (#%d) %010u 0x%08X 0x%08X %u\n", | ||
1161 | desc_lookup(desc), desc, time, data1, data2, line); | ||
1162 | IWL_ERROR("blink1 blink2 ilink1 ilink2\n"); | ||
1163 | IWL_ERROR("0x%05X 0x%05X 0x%05X 0x%05X\n", blink1, blink2, | ||
1164 | ilink1, ilink2); | ||
1165 | |||
1166 | iwl_release_nic_access(priv); | ||
1167 | } | ||
1168 | EXPORT_SYMBOL(iwl_dump_nic_error_log); | ||
1169 | |||
1170 | #define EVENT_START_OFFSET (4 * sizeof(u32)) | ||
1171 | |||
1172 | /** | ||
1173 | * iwl_print_event_log - Dump error event log to syslog | ||
1174 | * | ||
1175 | * NOTE: Must be called with iwl4965_grab_nic_access() already obtained! | ||
1176 | */ | ||
1177 | void iwl_print_event_log(struct iwl_priv *priv, u32 start_idx, | ||
1178 | u32 num_events, u32 mode) | ||
1179 | { | ||
1180 | u32 i; | ||
1181 | u32 base; /* SRAM byte address of event log header */ | ||
1182 | u32 event_size; /* 2 u32s, or 3 u32s if timestamp recorded */ | ||
1183 | u32 ptr; /* SRAM byte address of log data */ | ||
1184 | u32 ev, time, data; /* event log data */ | ||
1185 | |||
1186 | if (num_events == 0) | ||
1187 | return; | ||
1188 | if (priv->ucode_type == UCODE_INIT) | ||
1189 | base = le32_to_cpu(priv->card_alive_init.log_event_table_ptr); | ||
1190 | else | ||
1191 | base = le32_to_cpu(priv->card_alive.log_event_table_ptr); | ||
1192 | |||
1193 | if (mode == 0) | ||
1194 | event_size = 2 * sizeof(u32); | ||
1195 | else | ||
1196 | event_size = 3 * sizeof(u32); | ||
1197 | |||
1198 | ptr = base + EVENT_START_OFFSET + (start_idx * event_size); | ||
1199 | |||
1200 | /* "time" is actually "data" for mode 0 (no timestamp). | ||
1201 | * place event id # at far right for easier visual parsing. */ | ||
1202 | for (i = 0; i < num_events; i++) { | ||
1203 | ev = iwl_read_targ_mem(priv, ptr); | ||
1204 | ptr += sizeof(u32); | ||
1205 | time = iwl_read_targ_mem(priv, ptr); | ||
1206 | ptr += sizeof(u32); | ||
1207 | if (mode == 0) | ||
1208 | IWL_ERROR("0x%08x\t%04u\n", time, ev); /* data, ev */ | ||
1209 | else { | ||
1210 | data = iwl_read_targ_mem(priv, ptr); | ||
1211 | ptr += sizeof(u32); | ||
1212 | IWL_ERROR("%010u\t0x%08x\t%04u\n", time, data, ev); | ||
1213 | } | ||
1214 | } | ||
1215 | } | ||
1216 | EXPORT_SYMBOL(iwl_print_event_log); | ||
1217 | |||
1218 | |||
1219 | void iwl_dump_nic_event_log(struct iwl_priv *priv) | ||
1220 | { | ||
1221 | int ret; | ||
1222 | u32 base; /* SRAM byte address of event log header */ | ||
1223 | u32 capacity; /* event log capacity in # entries */ | ||
1224 | u32 mode; /* 0 - no timestamp, 1 - timestamp recorded */ | ||
1225 | u32 num_wraps; /* # times uCode wrapped to top of log */ | ||
1226 | u32 next_entry; /* index of next entry to be written by uCode */ | ||
1227 | u32 size; /* # entries that we'll print */ | ||
1228 | |||
1229 | if (priv->ucode_type == UCODE_INIT) | ||
1230 | base = le32_to_cpu(priv->card_alive_init.log_event_table_ptr); | ||
1231 | else | ||
1232 | base = le32_to_cpu(priv->card_alive.log_event_table_ptr); | ||
1233 | |||
1234 | if (!priv->cfg->ops->lib->is_valid_rtc_data_addr(base)) { | ||
1235 | IWL_ERROR("Invalid event log pointer 0x%08X\n", base); | ||
1236 | return; | ||
1237 | } | ||
1238 | |||
1239 | ret = iwl_grab_nic_access(priv); | ||
1240 | if (ret) { | ||
1241 | IWL_WARNING("Can not read from adapter at this time.\n"); | ||
1242 | return; | ||
1243 | } | ||
1244 | |||
1245 | /* event log header */ | ||
1246 | capacity = iwl_read_targ_mem(priv, base); | ||
1247 | mode = iwl_read_targ_mem(priv, base + (1 * sizeof(u32))); | ||
1248 | num_wraps = iwl_read_targ_mem(priv, base + (2 * sizeof(u32))); | ||
1249 | next_entry = iwl_read_targ_mem(priv, base + (3 * sizeof(u32))); | ||
1250 | |||
1251 | size = num_wraps ? capacity : next_entry; | ||
1252 | |||
1253 | /* bail out if nothing in log */ | ||
1254 | if (size == 0) { | ||
1255 | IWL_ERROR("Start IWL Event Log Dump: nothing in log\n"); | ||
1256 | iwl_release_nic_access(priv); | ||
1257 | return; | ||
1258 | } | ||
1259 | |||
1260 | IWL_ERROR("Start IWL Event Log Dump: display count %d, wraps %d\n", | ||
1261 | size, num_wraps); | ||
1262 | |||
1263 | /* if uCode has wrapped back to top of log, start at the oldest entry, | ||
1264 | * i.e the next one that uCode would fill. */ | ||
1265 | if (num_wraps) | ||
1266 | iwl_print_event_log(priv, next_entry, | ||
1267 | capacity - next_entry, mode); | ||
1268 | /* (then/else) start at top of log */ | ||
1269 | iwl_print_event_log(priv, 0, next_entry, mode); | ||
1270 | |||
1271 | iwl_release_nic_access(priv); | ||
1272 | } | ||
1273 | EXPORT_SYMBOL(iwl_dump_nic_event_log); | ||
1274 | |||
1275 | |||
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h index e139c8ffa9a2..6b5af7afbb25 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.h +++ b/drivers/net/wireless/iwlwifi/iwl-core.h | |||
@@ -86,7 +86,7 @@ struct iwl_hcmd_ops { | |||
86 | int (*rxon_assoc)(struct iwl_priv *priv); | 86 | int (*rxon_assoc)(struct iwl_priv *priv); |
87 | }; | 87 | }; |
88 | struct iwl_hcmd_utils_ops { | 88 | struct iwl_hcmd_utils_ops { |
89 | int (*enqueue_hcmd)(struct iwl_priv *priv, struct iwl_host_cmd *cmd); | 89 | u16 (*get_hcmd_size)(u8 cmd_id, u16 len); |
90 | u16 (*build_addsta_hcmd)(const struct iwl_addsta_cmd *cmd, u8 *data); | 90 | u16 (*build_addsta_hcmd)(const struct iwl_addsta_cmd *cmd, u8 *data); |
91 | #ifdef CONFIG_IWLWIFI_RUN_TIME_CALIB | 91 | #ifdef CONFIG_IWLWIFI_RUN_TIME_CALIB |
92 | void (*gain_computation)(struct iwl_priv *priv, | 92 | void (*gain_computation)(struct iwl_priv *priv, |
@@ -104,13 +104,22 @@ struct iwl_lib_ops { | |||
104 | int (*alloc_shared_mem)(struct iwl_priv *priv); | 104 | int (*alloc_shared_mem)(struct iwl_priv *priv); |
105 | void (*free_shared_mem)(struct iwl_priv *priv); | 105 | void (*free_shared_mem)(struct iwl_priv *priv); |
106 | int (*shared_mem_rx_idx)(struct iwl_priv *priv); | 106 | int (*shared_mem_rx_idx)(struct iwl_priv *priv); |
107 | /* Handling TX */ | ||
107 | void (*txq_update_byte_cnt_tbl)(struct iwl_priv *priv, | 108 | void (*txq_update_byte_cnt_tbl)(struct iwl_priv *priv, |
108 | struct iwl_tx_queue *txq, | 109 | struct iwl_tx_queue *txq, |
109 | u16 byte_cnt); | 110 | u16 byte_cnt); |
111 | void (*txq_inval_byte_cnt_tbl)(struct iwl_priv *priv, | ||
112 | struct iwl_tx_queue *txq); | ||
113 | void (*txq_set_sched)(struct iwl_priv *priv, u32 mask); | ||
114 | #ifdef CONFIG_IWL4965_HT | ||
115 | /* aggregations */ | ||
116 | int (*txq_agg_enable)(struct iwl_priv *priv, int txq_id, int tx_fifo, | ||
117 | int sta_id, int tid, u16 ssn_idx); | ||
118 | int (*txq_agg_disable)(struct iwl_priv *priv, u16 txq_id, u16 ssn_idx, | ||
119 | u8 tx_fifo); | ||
120 | #endif /* CONFIG_IWL4965_HT */ | ||
110 | /* setup Rx handler */ | 121 | /* setup Rx handler */ |
111 | void (*rx_handler_setup)(struct iwl_priv *priv); | 122 | void (*rx_handler_setup)(struct iwl_priv *priv); |
112 | /* nic Tx fifo handling */ | ||
113 | int (*disable_tx_fifo)(struct iwl_priv *priv); | ||
114 | /* alive notification after init uCode load */ | 123 | /* alive notification after init uCode load */ |
115 | void (*init_alive_start)(struct iwl_priv *priv); | 124 | void (*init_alive_start)(struct iwl_priv *priv); |
116 | /* alive notification */ | 125 | /* alive notification */ |
@@ -124,6 +133,8 @@ struct iwl_lib_ops { | |||
124 | /* power management */ | 133 | /* power management */ |
125 | struct { | 134 | struct { |
126 | int (*init)(struct iwl_priv *priv); | 135 | int (*init)(struct iwl_priv *priv); |
136 | int (*reset)(struct iwl_priv *priv); | ||
137 | void (*stop)(struct iwl_priv *priv); | ||
127 | void (*config)(struct iwl_priv *priv); | 138 | void (*config)(struct iwl_priv *priv); |
128 | int (*set_pwr_src)(struct iwl_priv *priv, enum iwl_pwr_src src); | 139 | int (*set_pwr_src)(struct iwl_priv *priv, enum iwl_pwr_src src); |
129 | } apm_ops; | 140 | } apm_ops; |
@@ -170,18 +181,19 @@ struct ieee80211_hw *iwl_alloc_all(struct iwl_cfg *cfg, | |||
170 | void iwl_hw_detect(struct iwl_priv *priv); | 181 | void iwl_hw_detect(struct iwl_priv *priv); |
171 | 182 | ||
172 | void iwlcore_clear_stations_table(struct iwl_priv *priv); | 183 | void iwlcore_clear_stations_table(struct iwl_priv *priv); |
184 | void iwl_free_calib_results(struct iwl_priv *priv); | ||
173 | void iwl_reset_qos(struct iwl_priv *priv); | 185 | void iwl_reset_qos(struct iwl_priv *priv); |
174 | void iwl_set_rxon_chain(struct iwl_priv *priv); | 186 | void iwl_set_rxon_chain(struct iwl_priv *priv); |
175 | int iwl_set_rxon_channel(struct iwl_priv *priv, | 187 | int iwl_set_rxon_channel(struct iwl_priv *priv, |
176 | enum ieee80211_band band, | 188 | enum ieee80211_band band, |
177 | u16 channel); | 189 | u16 channel); |
178 | void iwlcore_free_geos(struct iwl_priv *priv); | ||
179 | int iwl_setup(struct iwl_priv *priv); | ||
180 | void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_info *ht_info); | 190 | void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_info *ht_info); |
181 | u8 iwl_is_fat_tx_allowed(struct iwl_priv *priv, | 191 | u8 iwl_is_fat_tx_allowed(struct iwl_priv *priv, |
182 | struct ieee80211_ht_info *sta_ht_inf); | 192 | struct ieee80211_ht_info *sta_ht_inf); |
183 | int iwl_hw_nic_init(struct iwl_priv *priv); | 193 | int iwl_hw_nic_init(struct iwl_priv *priv); |
184 | 194 | int iwl_setup_mac(struct iwl_priv *priv); | |
195 | int iwl_init_drv(struct iwl_priv *priv); | ||
196 | void iwl_uninit_drv(struct iwl_priv *priv); | ||
185 | /* "keep warm" functions */ | 197 | /* "keep warm" functions */ |
186 | int iwl_kw_init(struct iwl_priv *priv); | 198 | int iwl_kw_init(struct iwl_priv *priv); |
187 | int iwl_kw_alloc(struct iwl_priv *priv); | 199 | int iwl_kw_alloc(struct iwl_priv *priv); |
@@ -202,14 +214,30 @@ int iwl_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq); | |||
202 | int iwl_rx_queue_restock(struct iwl_priv *priv); | 214 | int iwl_rx_queue_restock(struct iwl_priv *priv); |
203 | int iwl_rx_queue_space(const struct iwl_rx_queue *q); | 215 | int iwl_rx_queue_space(const struct iwl_rx_queue *q); |
204 | void iwl_rx_allocate(struct iwl_priv *priv); | 216 | void iwl_rx_allocate(struct iwl_priv *priv); |
217 | void iwl_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb); | ||
218 | int iwl_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index); | ||
219 | /* Handlers */ | ||
220 | void iwl_rx_missed_beacon_notif(struct iwl_priv *priv, | ||
221 | struct iwl_rx_mem_buffer *rxb); | ||
222 | |||
223 | /* TX helpers */ | ||
205 | 224 | ||
206 | /***************************************************** | 225 | /***************************************************** |
207 | * TX | 226 | * TX |
208 | ******************************************************/ | 227 | ******************************************************/ |
209 | int iwl_txq_ctx_reset(struct iwl_priv *priv); | 228 | int iwl_txq_ctx_reset(struct iwl_priv *priv); |
229 | int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb); | ||
210 | /* FIXME: remove when free Tx is fully merged into iwlcore */ | 230 | /* FIXME: remove when free Tx is fully merged into iwlcore */ |
211 | int iwl_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq); | 231 | int iwl_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq); |
212 | void iwl_hw_txq_ctx_free(struct iwl_priv *priv); | 232 | void iwl_hw_txq_ctx_free(struct iwl_priv *priv); |
233 | int iwl_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, void *tfd, | ||
234 | dma_addr_t addr, u16 len); | ||
235 | int iwl_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq); | ||
236 | #ifdef CONFIG_IWL4965_HT | ||
237 | int iwl_tx_agg_start(struct iwl_priv *priv, const u8 *ra, u16 tid, u16 *ssn); | ||
238 | int iwl_tx_agg_stop(struct iwl_priv *priv , const u8 *ra, u16 tid); | ||
239 | int iwl_txq_check_empty(struct iwl_priv *priv, int sta_id, u8 tid, int txq_id); | ||
240 | #endif | ||
213 | 241 | ||
214 | /***************************************************** | 242 | /***************************************************** |
215 | * S e n d i n g H o s t C o m m a n d s * | 243 | * S e n d i n g H o s t C o m m a n d s * |
@@ -226,6 +254,17 @@ int iwl_send_cmd_pdu_async(struct iwl_priv *priv, u8 id, u16 len, | |||
226 | int (*callback)(struct iwl_priv *priv, | 254 | int (*callback)(struct iwl_priv *priv, |
227 | struct iwl_cmd *cmd, | 255 | struct iwl_cmd *cmd, |
228 | struct sk_buff *skb)); | 256 | struct sk_buff *skb)); |
257 | |||
258 | int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd); | ||
259 | |||
260 | /***************************************************** | ||
261 | * Error Handling Debugging | ||
262 | ******************************************************/ | ||
263 | void iwl_print_event_log(struct iwl_priv *priv, u32 start_idx, | ||
264 | u32 num_events, u32 mode); | ||
265 | void iwl_dump_nic_error_log(struct iwl_priv *priv); | ||
266 | void iwl_dump_nic_event_log(struct iwl_priv *priv); | ||
267 | |||
229 | /*************** DRIVER STATUS FUNCTIONS *****/ | 268 | /*************** DRIVER STATUS FUNCTIONS *****/ |
230 | 269 | ||
231 | #define STATUS_HCMD_ACTIVE 0 /* host command in progress */ | 270 | #define STATUS_HCMD_ACTIVE 0 /* host command in progress */ |
@@ -303,5 +342,10 @@ static inline int iwl_send_rxon_assoc(struct iwl_priv *priv) | |||
303 | return priv->cfg->ops->hcmd->rxon_assoc(priv); | 342 | return priv->cfg->ops->hcmd->rxon_assoc(priv); |
304 | } | 343 | } |
305 | 344 | ||
345 | static inline const struct ieee80211_supported_band *iwl_get_hw_mode( | ||
346 | struct iwl_priv *priv, enum ieee80211_band band) | ||
347 | { | ||
348 | return priv->hw->wiphy->bands[band]; | ||
349 | } | ||
306 | 350 | ||
307 | #endif /* __iwl_core_h__ */ | 351 | #endif /* __iwl_core_h__ */ |
diff --git a/drivers/net/wireless/iwlwifi/iwl-csr.h b/drivers/net/wireless/iwlwifi/iwl-csr.h index 9d6e5d2072d2..545ed692d889 100644 --- a/drivers/net/wireless/iwlwifi/iwl-csr.h +++ b/drivers/net/wireless/iwlwifi/iwl-csr.h | |||
@@ -87,13 +87,14 @@ | |||
87 | /* EEPROM reads */ | 87 | /* EEPROM reads */ |
88 | #define CSR_EEPROM_REG (CSR_BASE+0x02c) | 88 | #define CSR_EEPROM_REG (CSR_BASE+0x02c) |
89 | #define CSR_EEPROM_GP (CSR_BASE+0x030) | 89 | #define CSR_EEPROM_GP (CSR_BASE+0x030) |
90 | #define CSR_GIO_REG (CSR_BASE+0x03C) | ||
90 | #define CSR_GP_UCODE (CSR_BASE+0x044) | 91 | #define CSR_GP_UCODE (CSR_BASE+0x044) |
91 | #define CSR_UCODE_DRV_GP1 (CSR_BASE+0x054) | 92 | #define CSR_UCODE_DRV_GP1 (CSR_BASE+0x054) |
92 | #define CSR_UCODE_DRV_GP1_SET (CSR_BASE+0x058) | 93 | #define CSR_UCODE_DRV_GP1_SET (CSR_BASE+0x058) |
93 | #define CSR_UCODE_DRV_GP1_CLR (CSR_BASE+0x05c) | 94 | #define CSR_UCODE_DRV_GP1_CLR (CSR_BASE+0x05c) |
94 | #define CSR_UCODE_DRV_GP2 (CSR_BASE+0x060) | 95 | #define CSR_UCODE_DRV_GP2 (CSR_BASE+0x060) |
95 | #define CSR_GIO_CHICKEN_BITS (CSR_BASE+0x100) | ||
96 | #define CSR_LED_REG (CSR_BASE+0x094) | 96 | #define CSR_LED_REG (CSR_BASE+0x094) |
97 | #define CSR_GIO_CHICKEN_BITS (CSR_BASE+0x100) | ||
97 | 98 | ||
98 | /* Analog phase-lock-loop configuration */ | 99 | /* Analog phase-lock-loop configuration */ |
99 | #define CSR_ANA_PLL_CFG (CSR_BASE+0x20c) | 100 | #define CSR_ANA_PLL_CFG (CSR_BASE+0x20c) |
@@ -213,6 +214,9 @@ | |||
213 | #define CSR_EEPROM_GP_BAD_SIGNATURE (0x00000000) | 214 | #define CSR_EEPROM_GP_BAD_SIGNATURE (0x00000000) |
214 | #define CSR_EEPROM_GP_IF_OWNER_MSK (0x00000180) | 215 | #define CSR_EEPROM_GP_IF_OWNER_MSK (0x00000180) |
215 | 216 | ||
217 | /* CSR GIO */ | ||
218 | #define CSR_GIO_REG_VAL_L0S_ENABLED (0x00000002) | ||
219 | |||
216 | /* UCODE DRV GP */ | 220 | /* UCODE DRV GP */ |
217 | #define CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP (0x00000001) | 221 | #define CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP (0x00000001) |
218 | #define CSR_UCODE_SW_BIT_RFKILL (0x00000002) | 222 | #define CSR_UCODE_SW_BIT_RFKILL (0x00000002) |
diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h index 2f24594c5fea..11de561c7bf8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debug.h +++ b/drivers/net/wireless/iwlwifi/iwl-debug.h | |||
@@ -45,13 +45,21 @@ struct iwl_debugfs { | |||
45 | const char *name; | 45 | const char *name; |
46 | struct dentry *dir_drv; | 46 | struct dentry *dir_drv; |
47 | struct dentry *dir_data; | 47 | struct dentry *dir_data; |
48 | struct dir_data_files{ | 48 | struct dentry *dir_rf; |
49 | struct dir_data_files { | ||
49 | struct dentry *file_sram; | 50 | struct dentry *file_sram; |
50 | struct dentry *file_eeprom; | 51 | struct dentry *file_eeprom; |
51 | struct dentry *file_stations; | 52 | struct dentry *file_stations; |
52 | struct dentry *file_rx_statistics; | 53 | struct dentry *file_rx_statistics; |
53 | struct dentry *file_tx_statistics; | 54 | struct dentry *file_tx_statistics; |
55 | struct dentry *file_log_event; | ||
54 | } dbgfs_data_files; | 56 | } dbgfs_data_files; |
57 | struct dir_rf_files { | ||
58 | #ifdef CONFIG_IWLWIFI_RUN_TIME_CALIB | ||
59 | struct dentry *file_disable_sensitivity; | ||
60 | struct dentry *file_disable_chain_noise; | ||
61 | #endif /* CONFIG_IWLWIFI_RUN_TIME_CALIB */ | ||
62 | } dbgfs_rf_files; | ||
55 | u32 sram_offset; | 63 | u32 sram_offset; |
56 | u32 sram_len; | 64 | u32 sram_len; |
57 | }; | 65 | }; |
diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c index ad25806dfaf1..29e16ba69cdb 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c +++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c | |||
@@ -55,6 +55,13 @@ | |||
55 | goto err; \ | 55 | goto err; \ |
56 | } while (0) | 56 | } while (0) |
57 | 57 | ||
58 | #define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \ | ||
59 | dbgfs->dbgfs_##parent##_files.file_##name = \ | ||
60 | debugfs_create_bool(#name, 0644, dbgfs->dir_##parent, ptr); \ | ||
61 | if (IS_ERR(dbgfs->dbgfs_##parent##_files.file_##name)) \ | ||
62 | goto err; \ | ||
63 | } while (0) | ||
64 | |||
58 | #define DEBUGFS_REMOVE(name) do { \ | 65 | #define DEBUGFS_REMOVE(name) do { \ |
59 | debugfs_remove(name); \ | 66 | debugfs_remove(name); \ |
60 | name = NULL; \ | 67 | name = NULL; \ |
@@ -85,6 +92,14 @@ static const struct file_operations iwl_dbgfs_##name##_ops = { \ | |||
85 | .open = iwl_dbgfs_open_file_generic, \ | 92 | .open = iwl_dbgfs_open_file_generic, \ |
86 | }; | 93 | }; |
87 | 94 | ||
95 | #define DEBUGFS_WRITE_FILE_OPS(name) \ | ||
96 | DEBUGFS_WRITE_FUNC(name); \ | ||
97 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ | ||
98 | .write = iwl_dbgfs_##name##_write, \ | ||
99 | .open = iwl_dbgfs_open_file_generic, \ | ||
100 | }; | ||
101 | |||
102 | |||
88 | #define DEBUGFS_READ_WRITE_FILE_OPS(name) \ | 103 | #define DEBUGFS_READ_WRITE_FILE_OPS(name) \ |
89 | DEBUGFS_READ_FUNC(name); \ | 104 | DEBUGFS_READ_FUNC(name); \ |
90 | DEBUGFS_WRITE_FUNC(name); \ | 105 | DEBUGFS_WRITE_FUNC(name); \ |
@@ -317,7 +332,29 @@ static ssize_t iwl_dbgfs_eeprom_read(struct file *file, | |||
317 | return ret; | 332 | return ret; |
318 | } | 333 | } |
319 | 334 | ||
335 | static ssize_t iwl_dbgfs_log_event_write(struct file *file, | ||
336 | const char __user *user_buf, | ||
337 | size_t count, loff_t *ppos) | ||
338 | { | ||
339 | struct iwl_priv *priv = file->private_data; | ||
340 | u32 event_log_flag; | ||
341 | char buf[8]; | ||
342 | int buf_size; | ||
343 | |||
344 | memset(buf, 0, sizeof(buf)); | ||
345 | buf_size = min(count, sizeof(buf) - 1); | ||
346 | if (copy_from_user(buf, user_buf, buf_size)) | ||
347 | return -EFAULT; | ||
348 | if (sscanf(buf, "%d", &event_log_flag) != 1) | ||
349 | return -EFAULT; | ||
350 | if (event_log_flag == 1) | ||
351 | iwl_dump_nic_event_log(priv); | ||
352 | |||
353 | return count; | ||
354 | } | ||
355 | |||
320 | DEBUGFS_READ_WRITE_FILE_OPS(sram); | 356 | DEBUGFS_READ_WRITE_FILE_OPS(sram); |
357 | DEBUGFS_WRITE_FILE_OPS(log_event); | ||
321 | DEBUGFS_READ_FILE_OPS(eeprom); | 358 | DEBUGFS_READ_FILE_OPS(eeprom); |
322 | DEBUGFS_READ_FILE_OPS(stations); | 359 | DEBUGFS_READ_FILE_OPS(stations); |
323 | DEBUGFS_READ_FILE_OPS(rx_statistics); | 360 | DEBUGFS_READ_FILE_OPS(rx_statistics); |
@@ -330,6 +367,7 @@ DEBUGFS_READ_FILE_OPS(tx_statistics); | |||
330 | int iwl_dbgfs_register(struct iwl_priv *priv, const char *name) | 367 | int iwl_dbgfs_register(struct iwl_priv *priv, const char *name) |
331 | { | 368 | { |
332 | struct iwl_debugfs *dbgfs; | 369 | struct iwl_debugfs *dbgfs; |
370 | struct dentry *phyd = priv->hw->wiphy->debugfsdir; | ||
333 | 371 | ||
334 | dbgfs = kzalloc(sizeof(struct iwl_debugfs), GFP_KERNEL); | 372 | dbgfs = kzalloc(sizeof(struct iwl_debugfs), GFP_KERNEL); |
335 | if (!dbgfs) { | 373 | if (!dbgfs) { |
@@ -338,18 +376,24 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name) | |||
338 | 376 | ||
339 | priv->dbgfs = dbgfs; | 377 | priv->dbgfs = dbgfs; |
340 | dbgfs->name = name; | 378 | dbgfs->name = name; |
341 | dbgfs->dir_drv = debugfs_create_dir(name, NULL); | 379 | dbgfs->dir_drv = debugfs_create_dir(name, phyd); |
342 | if (!dbgfs->dir_drv || IS_ERR(dbgfs->dir_drv)){ | 380 | if (!dbgfs->dir_drv || IS_ERR(dbgfs->dir_drv)){ |
343 | goto err; | 381 | goto err; |
344 | } | 382 | } |
345 | 383 | ||
346 | DEBUGFS_ADD_DIR(data, dbgfs->dir_drv); | 384 | DEBUGFS_ADD_DIR(data, dbgfs->dir_drv); |
385 | DEBUGFS_ADD_DIR(rf, dbgfs->dir_drv); | ||
347 | DEBUGFS_ADD_FILE(eeprom, data); | 386 | DEBUGFS_ADD_FILE(eeprom, data); |
348 | DEBUGFS_ADD_FILE(sram, data); | 387 | DEBUGFS_ADD_FILE(sram, data); |
388 | DEBUGFS_ADD_FILE(log_event, data); | ||
349 | DEBUGFS_ADD_FILE(stations, data); | 389 | DEBUGFS_ADD_FILE(stations, data); |
350 | DEBUGFS_ADD_FILE(rx_statistics, data); | 390 | DEBUGFS_ADD_FILE(rx_statistics, data); |
351 | DEBUGFS_ADD_FILE(tx_statistics, data); | 391 | DEBUGFS_ADD_FILE(tx_statistics, data); |
352 | 392 | #ifdef CONFIG_IWLWIFI_RUN_TIME_CALIB | |
393 | DEBUGFS_ADD_BOOL(disable_sensitivity, rf, &priv->disable_sens_cal); | ||
394 | DEBUGFS_ADD_BOOL(disable_chain_noise, rf, | ||
395 | &priv->disable_chain_noise_cal); | ||
396 | #endif /* CONFIG_IWLWIFI_RUN_TIME_CALIB */ | ||
353 | return 0; | 397 | return 0; |
354 | 398 | ||
355 | err: | 399 | err: |
@@ -372,8 +416,14 @@ void iwl_dbgfs_unregister(struct iwl_priv *priv) | |||
372 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_rx_statistics); | 416 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_rx_statistics); |
373 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_tx_statistics); | 417 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_tx_statistics); |
374 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_sram); | 418 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_sram); |
419 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_log_event); | ||
375 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_stations); | 420 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_stations); |
376 | DEBUGFS_REMOVE(priv->dbgfs->dir_data); | 421 | DEBUGFS_REMOVE(priv->dbgfs->dir_data); |
422 | #ifdef CONFIG_IWLWIFI_RUN_TIME_CALIB | ||
423 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_sensitivity); | ||
424 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_chain_noise); | ||
425 | #endif /* CONFIG_IWLWIFI_RUN_TIME_CALIB */ | ||
426 | DEBUGFS_REMOVE(priv->dbgfs->dir_rf); | ||
377 | DEBUGFS_REMOVE(priv->dbgfs->dir_drv); | 427 | DEBUGFS_REMOVE(priv->dbgfs->dir_drv); |
378 | kfree(priv->dbgfs); | 428 | kfree(priv->dbgfs); |
379 | priv->dbgfs = NULL; | 429 | priv->dbgfs = NULL; |
@@ -381,3 +431,4 @@ void iwl_dbgfs_unregister(struct iwl_priv *priv) | |||
381 | EXPORT_SYMBOL(iwl_dbgfs_unregister); | 431 | EXPORT_SYMBOL(iwl_dbgfs_unregister); |
382 | 432 | ||
383 | 433 | ||
434 | |||
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 5dccc5a8fa94..802f1a12b1aa 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h | |||
@@ -102,7 +102,7 @@ struct iwl_rx_mem_buffer { | |||
102 | * | 102 | * |
103 | * Contains common data for Rx and Tx queues | 103 | * Contains common data for Rx and Tx queues |
104 | */ | 104 | */ |
105 | struct iwl4965_queue { | 105 | struct iwl_queue { |
106 | int n_bd; /* number of BDs in this queue */ | 106 | int n_bd; /* number of BDs in this queue */ |
107 | int write_ptr; /* 1-st empty entry (index) host_w*/ | 107 | int write_ptr; /* 1-st empty entry (index) host_w*/ |
108 | int read_ptr; /* last used entry (index) host_r*/ | 108 | int read_ptr; /* last used entry (index) host_r*/ |
@@ -118,8 +118,7 @@ struct iwl4965_queue { | |||
118 | #define MAX_NUM_OF_TBS (20) | 118 | #define MAX_NUM_OF_TBS (20) |
119 | 119 | ||
120 | /* One for each TFD */ | 120 | /* One for each TFD */ |
121 | struct iwl4965_tx_info { | 121 | struct iwl_tx_info { |
122 | struct ieee80211_tx_status status; | ||
123 | struct sk_buff *skb[MAX_NUM_OF_TBS]; | 122 | struct sk_buff *skb[MAX_NUM_OF_TBS]; |
124 | }; | 123 | }; |
125 | 124 | ||
@@ -137,11 +136,11 @@ struct iwl4965_tx_info { | |||
137 | * descriptors) and required locking structures. | 136 | * descriptors) and required locking structures. |
138 | */ | 137 | */ |
139 | struct iwl_tx_queue { | 138 | struct iwl_tx_queue { |
140 | struct iwl4965_queue q; | 139 | struct iwl_queue q; |
141 | struct iwl_tfd_frame *bd; | 140 | struct iwl_tfd_frame *bd; |
142 | struct iwl_cmd *cmd; | 141 | struct iwl_cmd *cmd; |
143 | dma_addr_t dma_addr_cmd; | 142 | dma_addr_t dma_addr_cmd; |
144 | struct iwl4965_tx_info *txb; | 143 | struct iwl_tx_info *txb; |
145 | int need_update; | 144 | int need_update; |
146 | int sched_retry; | 145 | int sched_retry; |
147 | int active; | 146 | int active; |
@@ -262,7 +261,7 @@ enum iwl_pwr_src { | |||
262 | #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN) | 261 | #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN) |
263 | #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN) | 262 | #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN) |
264 | 263 | ||
265 | struct iwl4965_frame { | 264 | struct iwl_frame { |
266 | union { | 265 | union { |
267 | struct ieee80211_hdr frame; | 266 | struct ieee80211_hdr frame; |
268 | struct iwl4965_tx_beacon_cmd beacon; | 267 | struct iwl4965_tx_beacon_cmd beacon; |
@@ -308,6 +307,8 @@ struct iwl_cmd_meta { | |||
308 | 307 | ||
309 | } __attribute__ ((packed)); | 308 | } __attribute__ ((packed)); |
310 | 309 | ||
310 | #define IWL_CMD_MAX_PAYLOAD 320 | ||
311 | |||
311 | /** | 312 | /** |
312 | * struct iwl_cmd | 313 | * struct iwl_cmd |
313 | * | 314 | * |
@@ -329,11 +330,12 @@ struct iwl_cmd { | |||
329 | struct iwl4965_rxon_time_cmd rxon_time; | 330 | struct iwl4965_rxon_time_cmd rxon_time; |
330 | struct iwl4965_powertable_cmd powertable; | 331 | struct iwl4965_powertable_cmd powertable; |
331 | struct iwl4965_qosparam_cmd qosparam; | 332 | struct iwl4965_qosparam_cmd qosparam; |
332 | struct iwl4965_tx_cmd tx; | 333 | struct iwl_tx_cmd tx; |
333 | struct iwl4965_tx_beacon_cmd tx_beacon; | 334 | struct iwl4965_tx_beacon_cmd tx_beacon; |
334 | struct iwl4965_rxon_assoc_cmd rxon_assoc; | 335 | struct iwl4965_rxon_assoc_cmd rxon_assoc; |
336 | struct iwl_rem_sta_cmd rm_sta; | ||
335 | u8 *indirect; | 337 | u8 *indirect; |
336 | u8 payload[360]; | 338 | u8 payload[IWL_CMD_MAX_PAYLOAD]; |
337 | } __attribute__ ((packed)) cmd; | 339 | } __attribute__ ((packed)) cmd; |
338 | } __attribute__ ((packed)); | 340 | } __attribute__ ((packed)); |
339 | 341 | ||
@@ -442,7 +444,6 @@ struct iwl_hw_key { | |||
442 | enum ieee80211_key_alg alg; | 444 | enum ieee80211_key_alg alg; |
443 | int keylen; | 445 | int keylen; |
444 | u8 keyidx; | 446 | u8 keyidx; |
445 | struct ieee80211_key_conf *conf; | ||
446 | u8 key[32]; | 447 | u8 key[32]; |
447 | }; | 448 | }; |
448 | 449 | ||
@@ -573,7 +574,6 @@ struct iwl_sensitivity_ranges { | |||
573 | /** | 574 | /** |
574 | * struct iwl_hw_params | 575 | * struct iwl_hw_params |
575 | * @max_txq_num: Max # Tx queues supported | 576 | * @max_txq_num: Max # Tx queues supported |
576 | * @tx_cmd_len: Size of Tx command (but not including frame itself) | ||
577 | * @tx/rx_chains_num: Number of TX/RX chains | 577 | * @tx/rx_chains_num: Number of TX/RX chains |
578 | * @valid_tx/rx_ant: usable antennas | 578 | * @valid_tx/rx_ant: usable antennas |
579 | * @max_rxq_size: Max # Rx frames in Rx queue (must be power-of-2) | 579 | * @max_rxq_size: Max # Rx frames in Rx queue (must be power-of-2) |
@@ -590,7 +590,6 @@ struct iwl_sensitivity_ranges { | |||
590 | */ | 590 | */ |
591 | struct iwl_hw_params { | 591 | struct iwl_hw_params { |
592 | u16 max_txq_num; | 592 | u16 max_txq_num; |
593 | u16 tx_cmd_len; | ||
594 | u8 tx_chains_num; | 593 | u8 tx_chains_num; |
595 | u8 rx_chains_num; | 594 | u8 rx_chains_num; |
596 | u8 valid_tx_ant; | 595 | u8 valid_tx_ant; |
@@ -612,8 +611,8 @@ struct iwl_hw_params { | |||
612 | #endif | 611 | #endif |
613 | }; | 612 | }; |
614 | 613 | ||
615 | #define HT_SHORT_GI_20MHZ_ONLY (1 << 0) | 614 | #define HT_SHORT_GI_20MHZ (1 << 0) |
616 | #define HT_SHORT_GI_40MHZ_ONLY (1 << 1) | 615 | #define HT_SHORT_GI_40MHZ (1 << 1) |
617 | 616 | ||
618 | 617 | ||
619 | #define IWL_RX_HDR(x) ((struct iwl4965_rx_frame_hdr *)(\ | 618 | #define IWL_RX_HDR(x) ((struct iwl4965_rx_frame_hdr *)(\ |
@@ -635,8 +634,8 @@ struct iwl_hw_params { | |||
635 | struct iwl_addsta_cmd; | 634 | struct iwl_addsta_cmd; |
636 | extern int iwl_send_add_sta(struct iwl_priv *priv, | 635 | extern int iwl_send_add_sta(struct iwl_priv *priv, |
637 | struct iwl_addsta_cmd *sta, u8 flags); | 636 | struct iwl_addsta_cmd *sta, u8 flags); |
638 | extern u8 iwl4965_add_station_flags(struct iwl_priv *priv, const u8 *addr, | 637 | u8 iwl_add_station_flags(struct iwl_priv *priv, const u8 *addr, int is_ap, |
639 | int is_ap, u8 flags, void *ht_data); | 638 | u8 flags, struct ieee80211_ht_info *ht_info); |
640 | extern int iwl4965_is_network_packet(struct iwl_priv *priv, | 639 | extern int iwl4965_is_network_packet(struct iwl_priv *priv, |
641 | struct ieee80211_hdr *header); | 640 | struct ieee80211_hdr *header); |
642 | extern int iwl4965_power_init_handle(struct iwl_priv *priv); | 641 | extern int iwl4965_power_init_handle(struct iwl_priv *priv); |
@@ -652,14 +651,13 @@ extern int iwl4965_calc_sig_qual(int rssi_dbm, int noise_dbm); | |||
652 | extern unsigned int iwl4965_fill_beacon_frame(struct iwl_priv *priv, | 651 | extern unsigned int iwl4965_fill_beacon_frame(struct iwl_priv *priv, |
653 | struct ieee80211_hdr *hdr, | 652 | struct ieee80211_hdr *hdr, |
654 | const u8 *dest, int left); | 653 | const u8 *dest, int left); |
655 | extern __le16 *ieee80211_get_qos_ctrl(struct ieee80211_hdr *hdr); | ||
656 | extern void iwl4965_update_chain_flags(struct iwl_priv *priv); | 654 | extern void iwl4965_update_chain_flags(struct iwl_priv *priv); |
657 | int iwl4965_set_pwr_src(struct iwl_priv *priv, enum iwl_pwr_src src); | 655 | int iwl4965_set_pwr_src(struct iwl_priv *priv, enum iwl_pwr_src src); |
658 | 656 | ||
659 | int iwl4965_init_geos(struct iwl_priv *priv); | 657 | int iwl4965_init_geos(struct iwl_priv *priv); |
660 | void iwl4965_free_geos(struct iwl_priv *priv); | 658 | void iwl4965_free_geos(struct iwl_priv *priv); |
661 | 659 | ||
662 | extern const u8 iwl4965_broadcast_addr[ETH_ALEN]; | 660 | extern const u8 iwl_bcast_addr[ETH_ALEN]; |
663 | int iwl4965_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd); | 661 | int iwl4965_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd); |
664 | 662 | ||
665 | /* | 663 | /* |
@@ -687,19 +685,15 @@ extern u8 iwl4965_sync_station(struct iwl_priv *priv, int sta_id, | |||
687 | ****************************************************************************/ | 685 | ****************************************************************************/ |
688 | extern void iwl4965_hw_setup_deferred_work(struct iwl_priv *priv); | 686 | extern void iwl4965_hw_setup_deferred_work(struct iwl_priv *priv); |
689 | extern void iwl4965_hw_cancel_deferred_work(struct iwl_priv *priv); | 687 | extern void iwl4965_hw_cancel_deferred_work(struct iwl_priv *priv); |
690 | extern int iwl4965_hw_rxq_stop(struct iwl_priv *priv); | ||
691 | extern int iwl4965_hw_set_hw_params(struct iwl_priv *priv); | 688 | extern int iwl4965_hw_set_hw_params(struct iwl_priv *priv); |
692 | extern int iwl4965_hw_nic_stop_master(struct iwl_priv *priv); | 689 | extern int iwl_rxq_stop(struct iwl_priv *priv); |
693 | extern void iwl4965_hw_txq_ctx_stop(struct iwl_priv *priv); | 690 | extern void iwl_txq_ctx_stop(struct iwl_priv *priv); |
694 | extern int iwl4965_hw_nic_reset(struct iwl_priv *priv); | ||
695 | extern int iwl4965_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, void *tfd, | ||
696 | dma_addr_t addr, u16 len); | ||
697 | extern int iwl4965_hw_get_temperature(struct iwl_priv *priv); | 691 | extern int iwl4965_hw_get_temperature(struct iwl_priv *priv); |
698 | extern unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv, | 692 | extern unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv, |
699 | struct iwl4965_frame *frame, u8 rate); | 693 | struct iwl_frame *frame, u8 rate); |
700 | extern void iwl4965_hw_build_tx_cmd_rate(struct iwl_priv *priv, | 694 | extern void iwl4965_hw_build_tx_cmd_rate(struct iwl_priv *priv, |
701 | struct iwl_cmd *cmd, | 695 | struct iwl_cmd *cmd, |
702 | struct ieee80211_tx_control *ctrl, | 696 | struct ieee80211_tx_info *info, |
703 | struct ieee80211_hdr *hdr, | 697 | struct ieee80211_hdr *hdr, |
704 | int sta_id, int tx_id); | 698 | int sta_id, int tx_id); |
705 | extern int iwl4965_hw_reg_send_txpower(struct iwl_priv *priv); | 699 | extern int iwl4965_hw_reg_send_txpower(struct iwl_priv *priv); |
@@ -708,6 +702,8 @@ extern void iwl4965_hw_rx_statistics(struct iwl_priv *priv, | |||
708 | struct iwl_rx_mem_buffer *rxb); | 702 | struct iwl_rx_mem_buffer *rxb); |
709 | extern void iwl4965_disable_events(struct iwl_priv *priv); | 703 | extern void iwl4965_disable_events(struct iwl_priv *priv); |
710 | extern int iwl4965_get_temperature(const struct iwl_priv *priv); | 704 | extern int iwl4965_get_temperature(const struct iwl_priv *priv); |
705 | extern void iwl4965_rx_reply_rx(struct iwl_priv *priv, | ||
706 | struct iwl_rx_mem_buffer *rxb); | ||
711 | 707 | ||
712 | /** | 708 | /** |
713 | * iwl_find_station - Find station id for a given BSSID | 709 | * iwl_find_station - Find station id for a given BSSID |
@@ -720,8 +716,26 @@ extern int iwl4965_get_temperature(const struct iwl_priv *priv); | |||
720 | extern u8 iwl_find_station(struct iwl_priv *priv, const u8 *bssid); | 716 | extern u8 iwl_find_station(struct iwl_priv *priv, const u8 *bssid); |
721 | 717 | ||
722 | extern int iwl4965_hw_channel_switch(struct iwl_priv *priv, u16 channel); | 718 | extern int iwl4965_hw_channel_switch(struct iwl_priv *priv, u16 channel); |
723 | extern int iwl4965_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index); | 719 | extern int iwl_queue_space(const struct iwl_queue *q); |
724 | extern int iwl4965_queue_space(const struct iwl4965_queue *q); | 720 | static inline int iwl_queue_used(const struct iwl_queue *q, int i) |
721 | { | ||
722 | return q->write_ptr > q->read_ptr ? | ||
723 | (i >= q->read_ptr && i < q->write_ptr) : | ||
724 | !(i < q->read_ptr && i >= q->write_ptr); | ||
725 | } | ||
726 | |||
727 | |||
728 | static inline u8 get_cmd_index(struct iwl_queue *q, u32 index, int is_huge) | ||
729 | { | ||
730 | /* This is for scan command, the big buffer at end of command array */ | ||
731 | if (is_huge) | ||
732 | return q->n_window; /* must be power of 2 */ | ||
733 | |||
734 | /* Otherwise, use normal size buffers */ | ||
735 | return index & (q->n_window - 1); | ||
736 | } | ||
737 | |||
738 | |||
725 | struct iwl_priv; | 739 | struct iwl_priv; |
726 | 740 | ||
727 | extern void iwl4965_radio_kill_sw(struct iwl_priv *priv, int disable_radio); | 741 | extern void iwl4965_radio_kill_sw(struct iwl_priv *priv, int disable_radio); |
@@ -731,14 +745,12 @@ extern void iwl4965_radio_kill_sw(struct iwl_priv *priv, int disable_radio); | |||
731 | extern int iwl4965_tx_queue_update_wr_ptr(struct iwl_priv *priv, | 745 | extern int iwl4965_tx_queue_update_wr_ptr(struct iwl_priv *priv, |
732 | struct iwl_tx_queue *txq, | 746 | struct iwl_tx_queue *txq, |
733 | u16 byte_cnt); | 747 | u16 byte_cnt); |
734 | extern void iwl4965_add_station(struct iwl_priv *priv, const u8 *addr, | ||
735 | int is_ap); | ||
736 | extern int iwl4965_alive_notify(struct iwl_priv *priv); | 748 | extern int iwl4965_alive_notify(struct iwl_priv *priv); |
737 | extern void iwl4965_update_rate_scaling(struct iwl_priv *priv, u8 mode); | 749 | extern void iwl4965_update_rate_scaling(struct iwl_priv *priv, u8 mode); |
738 | extern void iwl4965_rf_kill_ct_config(struct iwl_priv *priv); | 750 | extern void iwl4965_rf_kill_ct_config(struct iwl_priv *priv); |
739 | extern void iwl4965_hwrate_to_tx_control(struct iwl_priv *priv, | 751 | extern void iwl4965_hwrate_to_tx_control(struct iwl_priv *priv, |
740 | u32 rate_n_flags, | 752 | u32 rate_n_flags, |
741 | struct ieee80211_tx_control *control); | 753 | struct ieee80211_tx_info *info); |
742 | 754 | ||
743 | #ifdef CONFIG_IWL4965_HT | 755 | #ifdef CONFIG_IWL4965_HT |
744 | extern void iwl4965_init_ht_hw_capab(const struct iwl_priv *priv, | 756 | extern void iwl4965_init_ht_hw_capab(const struct iwl_priv *priv, |
@@ -746,8 +758,6 @@ extern void iwl4965_init_ht_hw_capab(const struct iwl_priv *priv, | |||
746 | enum ieee80211_band band); | 758 | enum ieee80211_band band); |
747 | void iwl4965_set_rxon_ht(struct iwl_priv *priv, | 759 | void iwl4965_set_rxon_ht(struct iwl_priv *priv, |
748 | struct iwl_ht_info *ht_info); | 760 | struct iwl_ht_info *ht_info); |
749 | void iwl4965_set_ht_add_station(struct iwl_priv *priv, u8 index, | ||
750 | struct ieee80211_ht_info *sta_ht_inf); | ||
751 | int iwl4965_mac_ampdu_action(struct ieee80211_hw *hw, | 761 | int iwl4965_mac_ampdu_action(struct ieee80211_hw *hw, |
752 | enum ieee80211_ampdu_mlme_action action, | 762 | enum ieee80211_ampdu_mlme_action action, |
753 | const u8 *addr, u16 tid, u16 *ssn); | 763 | const u8 *addr, u16 tid, u16 *ssn); |
@@ -867,6 +877,21 @@ struct statistics_general_data { | |||
867 | u32 beacon_energy_c; | 877 | u32 beacon_energy_c; |
868 | }; | 878 | }; |
869 | 879 | ||
880 | struct iwl_calib_results { | ||
881 | void *tx_iq_res; | ||
882 | void *tx_iq_perd_res; | ||
883 | void *lo_res; | ||
884 | u32 tx_iq_res_len; | ||
885 | u32 tx_iq_perd_res_len; | ||
886 | u32 lo_res_len; | ||
887 | }; | ||
888 | |||
889 | enum ucode_type { | ||
890 | UCODE_NONE = 0, | ||
891 | UCODE_INIT, | ||
892 | UCODE_RT | ||
893 | }; | ||
894 | |||
870 | #ifdef CONFIG_IWLWIFI_RUN_TIME_CALIB | 895 | #ifdef CONFIG_IWLWIFI_RUN_TIME_CALIB |
871 | /* Sensitivity calib data */ | 896 | /* Sensitivity calib data */ |
872 | struct iwl_sensitivity_data { | 897 | struct iwl_sensitivity_data { |
@@ -968,6 +993,9 @@ struct iwl_priv { | |||
968 | s32 temperature; /* degrees Kelvin */ | 993 | s32 temperature; /* degrees Kelvin */ |
969 | s32 last_temperature; | 994 | s32 last_temperature; |
970 | 995 | ||
996 | /* init calibration results */ | ||
997 | struct iwl_calib_results calib_results; | ||
998 | |||
971 | /* Scan related variables */ | 999 | /* Scan related variables */ |
972 | unsigned long last_scan_jiffies; | 1000 | unsigned long last_scan_jiffies; |
973 | unsigned long next_scan_jiffies; | 1001 | unsigned long next_scan_jiffies; |
@@ -1001,6 +1029,8 @@ struct iwl_priv { | |||
1001 | struct fw_desc ucode_init; /* initialization inst */ | 1029 | struct fw_desc ucode_init; /* initialization inst */ |
1002 | struct fw_desc ucode_init_data; /* initialization data */ | 1030 | struct fw_desc ucode_init_data; /* initialization data */ |
1003 | struct fw_desc ucode_boot; /* bootstrap inst */ | 1031 | struct fw_desc ucode_boot; /* bootstrap inst */ |
1032 | enum ucode_type ucode_type; | ||
1033 | u8 ucode_write_complete; /* the image write is complete */ | ||
1004 | 1034 | ||
1005 | 1035 | ||
1006 | struct iwl4965_rxon_time_cmd rxon_timing; | 1036 | struct iwl4965_rxon_time_cmd rxon_timing; |
@@ -1009,16 +1039,16 @@ struct iwl_priv { | |||
1009 | * changed via explicit cast within the | 1039 | * changed via explicit cast within the |
1010 | * routines that actually update the physical | 1040 | * routines that actually update the physical |
1011 | * hardware */ | 1041 | * hardware */ |
1012 | const struct iwl4965_rxon_cmd active_rxon; | 1042 | const struct iwl_rxon_cmd active_rxon; |
1013 | struct iwl4965_rxon_cmd staging_rxon; | 1043 | struct iwl_rxon_cmd staging_rxon; |
1014 | 1044 | ||
1015 | int error_recovering; | 1045 | int error_recovering; |
1016 | struct iwl4965_rxon_cmd recovery_rxon; | 1046 | struct iwl_rxon_cmd recovery_rxon; |
1017 | 1047 | ||
1018 | /* 1st responses from initialize and runtime uCode images. | 1048 | /* 1st responses from initialize and runtime uCode images. |
1019 | * 4965's initialize alive response contains some calibration data. */ | 1049 | * 4965's initialize alive response contains some calibration data. */ |
1020 | struct iwl4965_init_alive_resp card_alive_init; | 1050 | struct iwl_init_alive_resp card_alive_init; |
1021 | struct iwl4965_alive_resp card_alive; | 1051 | struct iwl_alive_resp card_alive; |
1022 | #ifdef CONFIG_IWLWIFI_RFKILL | 1052 | #ifdef CONFIG_IWLWIFI_RFKILL |
1023 | struct iwl_rfkill_mngr rfkill_mngr; | 1053 | struct iwl_rfkill_mngr rfkill_mngr; |
1024 | #endif | 1054 | #endif |
@@ -1107,8 +1137,6 @@ struct iwl_priv { | |||
1107 | 1137 | ||
1108 | u8 mac80211_registered; | 1138 | u8 mac80211_registered; |
1109 | 1139 | ||
1110 | u32 notif_missed_beacons; | ||
1111 | |||
1112 | /* Rx'd packet timing information */ | 1140 | /* Rx'd packet timing information */ |
1113 | u32 last_beacon_time; | 1141 | u32 last_beacon_time; |
1114 | u64 last_tsf; | 1142 | u64 last_tsf; |
@@ -1195,12 +1223,56 @@ struct iwl_priv { | |||
1195 | #endif /* CONFIG_IWLWIFI_DEBUG */ | 1223 | #endif /* CONFIG_IWLWIFI_DEBUG */ |
1196 | 1224 | ||
1197 | struct work_struct txpower_work; | 1225 | struct work_struct txpower_work; |
1226 | #ifdef CONFIG_IWLWIFI_RUN_TIME_CALIB | ||
1227 | u32 disable_sens_cal; | ||
1228 | u32 disable_chain_noise_cal; | ||
1229 | #endif /* CONFIG_IWLWIFI_RUN_TIME_CALIB */ | ||
1198 | #ifdef CONFIG_IWL4965_RUN_TIME_CALIB | 1230 | #ifdef CONFIG_IWL4965_RUN_TIME_CALIB |
1199 | struct work_struct sensitivity_work; | 1231 | struct work_struct sensitivity_work; |
1200 | #endif | 1232 | #endif /* CONFIG_IWL4965_RUN_TIME_CALIB */ |
1201 | struct timer_list statistics_periodic; | 1233 | struct timer_list statistics_periodic; |
1202 | }; /*iwl_priv */ | 1234 | }; /*iwl_priv */ |
1203 | 1235 | ||
1236 | static inline void iwl_txq_ctx_activate(struct iwl_priv *priv, int txq_id) | ||
1237 | { | ||
1238 | set_bit(txq_id, &priv->txq_ctx_active_msk); | ||
1239 | } | ||
1240 | |||
1241 | static inline void iwl_txq_ctx_deactivate(struct iwl_priv *priv, int txq_id) | ||
1242 | { | ||
1243 | clear_bit(txq_id, &priv->txq_ctx_active_msk); | ||
1244 | } | ||
1245 | |||
1246 | #ifdef CONFIG_IWLWIF_DEBUG | ||
1247 | const char *iwl_get_tx_fail_reason(u32 status); | ||
1248 | #else | ||
1249 | static inline const char *iwl_get_tx_fail_reason(u32 status) { return ""; } | ||
1250 | #endif | ||
1251 | |||
1252 | |||
1253 | #ifdef CONFIG_IWL4965_HT | ||
1254 | static inline int iwl_get_ra_sta_id(struct iwl_priv *priv, | ||
1255 | struct ieee80211_hdr *hdr) | ||
1256 | { | ||
1257 | if (priv->iw_mode == IEEE80211_IF_TYPE_STA) { | ||
1258 | return IWL_AP_ID; | ||
1259 | } else { | ||
1260 | u8 *da = ieee80211_get_DA(hdr); | ||
1261 | return iwl_find_station(priv, da); | ||
1262 | } | ||
1263 | } | ||
1264 | |||
1265 | static inline struct ieee80211_hdr *iwl_tx_queue_get_hdr(struct iwl_priv *priv, | ||
1266 | int txq_id, int idx) | ||
1267 | { | ||
1268 | if (priv->txq[txq_id].txb[idx].skb[0]) | ||
1269 | return (struct ieee80211_hdr *)priv->txq[txq_id]. | ||
1270 | txb[idx].skb[0]->data; | ||
1271 | return NULL; | ||
1272 | } | ||
1273 | #endif | ||
1274 | |||
1275 | |||
1204 | static inline int iwl_is_associated(struct iwl_priv *priv) | 1276 | static inline int iwl_is_associated(struct iwl_priv *priv) |
1205 | { | 1277 | { |
1206 | return (priv->active_rxon.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; | 1278 | return (priv->active_rxon.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; |
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c index fa306601a550..11f9d9557a0e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c | |||
@@ -365,11 +365,11 @@ static void iwl_init_band_reference(const struct iwl_priv *priv, | |||
365 | ? # x " " : "") | 365 | ? # x " " : "") |
366 | 366 | ||
367 | /** | 367 | /** |
368 | * iwl4965_set_fat_chan_info - Copy fat channel info into driver's priv. | 368 | * iwl_set_fat_chan_info - Copy fat channel info into driver's priv. |
369 | * | 369 | * |
370 | * Does not set up a command, or touch hardware. | 370 | * Does not set up a command, or touch hardware. |
371 | */ | 371 | */ |
372 | static int iwl4965_set_fat_chan_info(struct iwl_priv *priv, | 372 | static int iwl_set_fat_chan_info(struct iwl_priv *priv, |
373 | enum ieee80211_band band, u16 channel, | 373 | enum ieee80211_band band, u16 channel, |
374 | const struct iwl_eeprom_channel *eeprom_ch, | 374 | const struct iwl_eeprom_channel *eeprom_ch, |
375 | u8 fat_extension_channel) | 375 | u8 fat_extension_channel) |
@@ -542,16 +542,16 @@ int iwl_init_channel_map(struct iwl_priv *priv) | |||
542 | fat_extension_chan = HT_IE_EXT_CHANNEL_ABOVE; | 542 | fat_extension_chan = HT_IE_EXT_CHANNEL_ABOVE; |
543 | 543 | ||
544 | /* Set up driver's info for lower half */ | 544 | /* Set up driver's info for lower half */ |
545 | iwl4965_set_fat_chan_info(priv, ieeeband, | 545 | iwl_set_fat_chan_info(priv, ieeeband, |
546 | eeprom_ch_index[ch], | 546 | eeprom_ch_index[ch], |
547 | &(eeprom_ch_info[ch]), | 547 | &(eeprom_ch_info[ch]), |
548 | fat_extension_chan); | 548 | fat_extension_chan); |
549 | 549 | ||
550 | /* Set up driver's info for upper half */ | 550 | /* Set up driver's info for upper half */ |
551 | iwl4965_set_fat_chan_info(priv, ieeeband, | 551 | iwl_set_fat_chan_info(priv, ieeeband, |
552 | (eeprom_ch_index[ch] + 4), | 552 | (eeprom_ch_index[ch] + 4), |
553 | &(eeprom_ch_info[ch]), | 553 | &(eeprom_ch_info[ch]), |
554 | HT_IE_EXT_CHANNEL_BELOW); | 554 | HT_IE_EXT_CHANNEL_BELOW); |
555 | } | 555 | } |
556 | } | 556 | } |
557 | 557 | ||
@@ -560,23 +560,21 @@ int iwl_init_channel_map(struct iwl_priv *priv) | |||
560 | EXPORT_SYMBOL(iwl_init_channel_map); | 560 | EXPORT_SYMBOL(iwl_init_channel_map); |
561 | 561 | ||
562 | /* | 562 | /* |
563 | * iwl_free_channel_map - undo allocations in iwl4965_init_channel_map | 563 | * iwl_free_channel_map - undo allocations in iwl_init_channel_map |
564 | */ | 564 | */ |
565 | void iwl_free_channel_map(struct iwl_priv *priv) | 565 | void iwl_free_channel_map(struct iwl_priv *priv) |
566 | { | 566 | { |
567 | kfree(priv->channel_info); | 567 | kfree(priv->channel_info); |
568 | priv->channel_count = 0; | 568 | priv->channel_count = 0; |
569 | } | 569 | } |
570 | EXPORT_SYMBOL(iwl_free_channel_map); | ||
571 | 570 | ||
572 | /** | 571 | /** |
573 | * iwl_get_channel_info - Find driver's private channel info | 572 | * iwl_get_channel_info - Find driver's private channel info |
574 | * | 573 | * |
575 | * Based on band and channel number. | 574 | * Based on band and channel number. |
576 | */ | 575 | */ |
577 | const struct iwl_channel_info *iwl_get_channel_info( | 576 | const struct iwl_channel_info *iwl_get_channel_info(const struct iwl_priv *priv, |
578 | const struct iwl_priv *priv, | 577 | enum ieee80211_band band, u16 channel) |
579 | enum ieee80211_band band, u16 channel) | ||
580 | { | 578 | { |
581 | int i; | 579 | int i; |
582 | 580 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.h b/drivers/net/wireless/iwlwifi/iwl-eeprom.h index dc1f027c66a0..d3a2a5b4ac56 100644 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.h +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.h | |||
@@ -146,6 +146,7 @@ struct iwl_eeprom_channel { | |||
146 | 146 | ||
147 | /*5000 calibrations */ | 147 | /*5000 calibrations */ |
148 | #define EEPROM_5000_CALIB_ALL (INDIRECT_ADDRESS | INDIRECT_CALIBRATION) | 148 | #define EEPROM_5000_CALIB_ALL (INDIRECT_ADDRESS | INDIRECT_CALIBRATION) |
149 | #define EEPROM_5000_XTAL ((2*0x128) | EEPROM_5000_CALIB_ALL) | ||
149 | 150 | ||
150 | /* 5000 links */ | 151 | /* 5000 links */ |
151 | #define EEPROM_5000_LINK_HOST (2*0x64) | 152 | #define EEPROM_5000_LINK_HOST (2*0x64) |
diff --git a/drivers/net/wireless/iwlwifi/iwl-hcmd.c b/drivers/net/wireless/iwlwifi/iwl-hcmd.c index 0412adf6ef8b..6c537360820b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-hcmd.c +++ b/drivers/net/wireless/iwlwifi/iwl-hcmd.c | |||
@@ -56,6 +56,7 @@ const char *get_cmd_string(u8 cmd) | |||
56 | IWL_CMD(REPLY_RATE_SCALE); | 56 | IWL_CMD(REPLY_RATE_SCALE); |
57 | IWL_CMD(REPLY_LEDS_CMD); | 57 | IWL_CMD(REPLY_LEDS_CMD); |
58 | IWL_CMD(REPLY_TX_LINK_QUALITY_CMD); | 58 | IWL_CMD(REPLY_TX_LINK_QUALITY_CMD); |
59 | IWL_CMD(COEX_PRIORITY_TABLE_CMD); | ||
59 | IWL_CMD(RADAR_NOTIFICATION); | 60 | IWL_CMD(RADAR_NOTIFICATION); |
60 | IWL_CMD(REPLY_QUIET_CMD); | 61 | IWL_CMD(REPLY_QUIET_CMD); |
61 | IWL_CMD(REPLY_CHANNEL_SWITCH); | 62 | IWL_CMD(REPLY_CHANNEL_SWITCH); |
@@ -89,6 +90,9 @@ const char *get_cmd_string(u8 cmd) | |||
89 | IWL_CMD(REPLY_RX_MPDU_CMD); | 90 | IWL_CMD(REPLY_RX_MPDU_CMD); |
90 | IWL_CMD(REPLY_RX); | 91 | IWL_CMD(REPLY_RX); |
91 | IWL_CMD(REPLY_COMPRESSED_BA); | 92 | IWL_CMD(REPLY_COMPRESSED_BA); |
93 | IWL_CMD(CALIBRATION_CFG_CMD); | ||
94 | IWL_CMD(CALIBRATION_RES_NOTIFICATION); | ||
95 | IWL_CMD(CALIBRATION_COMPLETE_NOTIFICATION); | ||
92 | default: | 96 | default: |
93 | return "UNKNOWN"; | 97 | return "UNKNOWN"; |
94 | 98 | ||
@@ -139,7 +143,7 @@ static int iwl_send_cmd_async(struct iwl_priv *priv, struct iwl_host_cmd *cmd) | |||
139 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) | 143 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) |
140 | return -EBUSY; | 144 | return -EBUSY; |
141 | 145 | ||
142 | ret = priv->cfg->ops->utils->enqueue_hcmd(priv, cmd); | 146 | ret = iwl_enqueue_hcmd(priv, cmd); |
143 | if (ret < 0) { | 147 | if (ret < 0) { |
144 | IWL_ERROR("Error sending %s: enqueue_hcmd failed: %d\n", | 148 | IWL_ERROR("Error sending %s: enqueue_hcmd failed: %d\n", |
145 | get_cmd_string(cmd->id), ret); | 149 | get_cmd_string(cmd->id), ret); |
@@ -170,7 +174,7 @@ int iwl_send_cmd_sync(struct iwl_priv *priv, struct iwl_host_cmd *cmd) | |||
170 | if (cmd->meta.flags & CMD_WANT_SKB) | 174 | if (cmd->meta.flags & CMD_WANT_SKB) |
171 | cmd->meta.source = &cmd->meta; | 175 | cmd->meta.source = &cmd->meta; |
172 | 176 | ||
173 | cmd_idx = priv->cfg->ops->utils->enqueue_hcmd(priv, cmd); | 177 | cmd_idx = iwl_enqueue_hcmd(priv, cmd); |
174 | if (cmd_idx < 0) { | 178 | if (cmd_idx < 0) { |
175 | ret = cmd_idx; | 179 | ret = cmd_idx; |
176 | IWL_ERROR("Error sending %s: enqueue_hcmd failed: %d\n", | 180 | IWL_ERROR("Error sending %s: enqueue_hcmd failed: %d\n", |
diff --git a/drivers/net/wireless/iwlwifi/iwl-helpers.h b/drivers/net/wireless/iwlwifi/iwl-helpers.h index a443472bea62..dedefa06ad8f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-helpers.h +++ b/drivers/net/wireless/iwlwifi/iwl-helpers.h | |||
@@ -136,6 +136,8 @@ static inline void iwl_set_bits16(__le16 *dst, u8 pos, u8 len, int val) | |||
136 | 136 | ||
137 | #define KELVIN_TO_CELSIUS(x) ((x)-273) | 137 | #define KELVIN_TO_CELSIUS(x) ((x)-273) |
138 | #define CELSIUS_TO_KELVIN(x) ((x)+273) | 138 | #define CELSIUS_TO_KELVIN(x) ((x)+273) |
139 | #define IWL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo)))) | ||
140 | |||
139 | 141 | ||
140 | #define IEEE80211_CHAN_W_RADAR_DETECT 0x00000010 | 142 | #define IEEE80211_CHAN_W_RADAR_DETECT 0x00000010 |
141 | 143 | ||
@@ -235,6 +237,25 @@ static inline int ieee80211_is_reassoc_response(u16 fc) | |||
235 | ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_REASSOC_RESP); | 237 | ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_REASSOC_RESP); |
236 | } | 238 | } |
237 | 239 | ||
240 | static inline int ieee80211_is_qos_data(u16 fc) | ||
241 | { | ||
242 | return ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) && | ||
243 | ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_QOS_DATA); | ||
244 | } | ||
245 | /** | ||
246 | * ieee80211_get_qos_ctrl - get pointer to the QoS control field | ||
247 | * | ||
248 | * This function returns the pointer to 802.11 header QoS field (2 bytes) | ||
249 | * This function doesn't check whether hdr is a QoS hdr, use with care | ||
250 | * @hdr: struct ieee80211_hdr *hdr | ||
251 | * @hdr_len: header length | ||
252 | */ | ||
253 | |||
254 | static inline u8 *ieee80211_get_qos_ctrl(struct ieee80211_hdr *hdr, int hdr_len) | ||
255 | { | ||
256 | return ((u8 *) hdr + hdr_len - QOS_CONTROL_LEN); | ||
257 | } | ||
258 | |||
238 | static inline int iwl_check_bits(unsigned long field, unsigned long mask) | 259 | static inline int iwl_check_bits(unsigned long field, unsigned long mask) |
239 | { | 260 | { |
240 | return ((field & mask) == mask) ? 1 : 0; | 261 | return ((field & mask) == mask) ? 1 : 0; |
diff --git a/drivers/net/wireless/iwlwifi/iwl-prph.h b/drivers/net/wireless/iwlwifi/iwl-prph.h index acac629386e0..70d9c7568b98 100644 --- a/drivers/net/wireless/iwlwifi/iwl-prph.h +++ b/drivers/net/wireless/iwlwifi/iwl-prph.h | |||
@@ -358,11 +358,6 @@ | |||
358 | * 7- 0: Enable (1), disable (0), one bit for each channel 0-7 | 358 | * 7- 0: Enable (1), disable (0), one bit for each channel 0-7 |
359 | */ | 359 | */ |
360 | #define IWL49_SCD_TXFACT (IWL49_SCD_START_OFFSET + 0x1c) | 360 | #define IWL49_SCD_TXFACT (IWL49_SCD_START_OFFSET + 0x1c) |
361 | |||
362 | /* Mask to enable contiguous Tx DMA/FIFO channels between "lo" and "hi". */ | ||
363 | #define SCD_TXFACT_REG_TXFIFO_MASK(lo, hi) \ | ||
364 | ((1 << (hi)) | ((1 << (hi)) - (1 << (lo)))) | ||
365 | |||
366 | /* | 361 | /* |
367 | * Queue (x) Write Pointers (indexes, really!), one for each Tx queue. | 362 | * Queue (x) Write Pointers (indexes, really!), one for each Tx queue. |
368 | * Initialized and updated by driver as new TFDs are added to queue. | 363 | * Initialized and updated by driver as new TFDs are added to queue. |
@@ -512,11 +507,39 @@ | |||
512 | #define IWL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(x) \ | 507 | #define IWL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(x) \ |
513 | ((IWL49_SCD_TRANSLATE_TBL_OFFSET + ((x) * 2)) & 0xfffffffc) | 508 | ((IWL49_SCD_TRANSLATE_TBL_OFFSET + ((x) * 2)) & 0xfffffffc) |
514 | 509 | ||
515 | #define IWL49_SCD_TXFIFO_POS_TID (0) | 510 | #define IWL_SCD_TXFIFO_POS_TID (0) |
516 | #define IWL49_SCD_TXFIFO_POS_RA (4) | 511 | #define IWL_SCD_TXFIFO_POS_RA (4) |
517 | #define IWL49_SCD_QUEUE_RA_TID_MAP_RATID_MSK (0x01FF) | 512 | #define IWL_SCD_QUEUE_RA_TID_MAP_RATID_MSK (0x01FF) |
518 | 513 | ||
519 | /* 5000 SCD */ | 514 | /* 5000 SCD */ |
515 | #define IWL50_SCD_QUEUE_STTS_REG_POS_TXF (0) | ||
516 | #define IWL50_SCD_QUEUE_STTS_REG_POS_ACTIVE (3) | ||
517 | #define IWL50_SCD_QUEUE_STTS_REG_POS_WSL (4) | ||
518 | #define IWL50_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN (19) | ||
519 | #define IWL50_SCD_QUEUE_STTS_REG_MSK (0x00FF0000) | ||
520 | |||
521 | #define IWL50_SCD_QUEUE_CTX_REG1_CREDIT_POS (8) | ||
522 | #define IWL50_SCD_QUEUE_CTX_REG1_CREDIT_MSK (0x00FFFF00) | ||
523 | #define IWL50_SCD_QUEUE_CTX_REG1_SUPER_CREDIT_POS (24) | ||
524 | #define IWL50_SCD_QUEUE_CTX_REG1_SUPER_CREDIT_MSK (0xFF000000) | ||
525 | #define IWL50_SCD_QUEUE_CTX_REG2_WIN_SIZE_POS (0) | ||
526 | #define IWL50_SCD_QUEUE_CTX_REG2_WIN_SIZE_MSK (0x0000007F) | ||
527 | #define IWL50_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS (16) | ||
528 | #define IWL50_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK (0x007F0000) | ||
529 | |||
530 | #define IWL50_SCD_CONTEXT_DATA_OFFSET (0x600) | ||
531 | #define IWL50_SCD_TX_STTS_BITMAP_OFFSET (0x7B1) | ||
532 | #define IWL50_SCD_TRANSLATE_TBL_OFFSET (0x7E0) | ||
533 | |||
534 | #define IWL50_SCD_CONTEXT_QUEUE_OFFSET(x)\ | ||
535 | (IWL50_SCD_CONTEXT_DATA_OFFSET + ((x) * 8)) | ||
536 | |||
537 | #define IWL50_SCD_TRANSLATE_TBL_OFFSET_QUEUE(x) \ | ||
538 | ((IWL50_SCD_TRANSLATE_TBL_OFFSET + ((x) * 2)) & 0xfffc) | ||
539 | |||
540 | #define IWL50_SCD_QUEUECHAIN_SEL_ALL(x) (((1<<(x)) - 1) &\ | ||
541 | (~(1<<IWL_CMD_QUEUE_NUM))) | ||
542 | |||
520 | #define IWL50_SCD_BASE (PRPH_BASE + 0xa02c00) | 543 | #define IWL50_SCD_BASE (PRPH_BASE + 0xa02c00) |
521 | 544 | ||
522 | #define IWL50_SCD_SRAM_BASE_ADDR (IWL50_SCD_BASE + 0x0) | 545 | #define IWL50_SCD_SRAM_BASE_ADDR (IWL50_SCD_BASE + 0x0) |
diff --git a/drivers/net/wireless/iwlwifi/iwl-rx.c b/drivers/net/wireless/iwlwifi/iwl-rx.c index a2eb90d40b7e..cc61c937320f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-rx.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include "iwl-core.h" | 33 | #include "iwl-core.h" |
34 | #include "iwl-sta.h" | 34 | #include "iwl-sta.h" |
35 | #include "iwl-io.h" | 35 | #include "iwl-io.h" |
36 | #include "iwl-calib.h" | ||
36 | #include "iwl-helpers.h" | 37 | #include "iwl-helpers.h" |
37 | /************************** RX-FUNCTIONS ****************************/ | 38 | /************************** RX-FUNCTIONS ****************************/ |
38 | /* | 39 | /* |
@@ -420,3 +421,50 @@ int iwl_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq) | |||
420 | return 0; | 421 | return 0; |
421 | } | 422 | } |
422 | 423 | ||
424 | int iwl_rxq_stop(struct iwl_priv *priv) | ||
425 | { | ||
426 | int ret; | ||
427 | unsigned long flags; | ||
428 | |||
429 | spin_lock_irqsave(&priv->lock, flags); | ||
430 | ret = iwl_grab_nic_access(priv); | ||
431 | if (unlikely(ret)) { | ||
432 | spin_unlock_irqrestore(&priv->lock, flags); | ||
433 | return ret; | ||
434 | } | ||
435 | |||
436 | /* stop Rx DMA */ | ||
437 | iwl_write_direct32(priv, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); | ||
438 | ret = iwl_poll_direct_bit(priv, FH_MEM_RSSR_RX_STATUS_REG, | ||
439 | (1 << 24), 1000); | ||
440 | if (ret < 0) | ||
441 | IWL_ERROR("Can't stop Rx DMA.\n"); | ||
442 | |||
443 | iwl_release_nic_access(priv); | ||
444 | spin_unlock_irqrestore(&priv->lock, flags); | ||
445 | |||
446 | return 0; | ||
447 | } | ||
448 | EXPORT_SYMBOL(iwl_rxq_stop); | ||
449 | |||
450 | void iwl_rx_missed_beacon_notif(struct iwl_priv *priv, | ||
451 | struct iwl_rx_mem_buffer *rxb) | ||
452 | |||
453 | { | ||
454 | #ifdef CONFIG_IWLWIFI_RUN_TIME_CALIB | ||
455 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; | ||
456 | struct iwl4965_missed_beacon_notif *missed_beacon; | ||
457 | |||
458 | missed_beacon = &pkt->u.missed_beacon; | ||
459 | if (le32_to_cpu(missed_beacon->consequtive_missed_beacons) > 5) { | ||
460 | IWL_DEBUG_CALIB("missed bcn cnsq %d totl %d rcd %d expctd %d\n", | ||
461 | le32_to_cpu(missed_beacon->consequtive_missed_beacons), | ||
462 | le32_to_cpu(missed_beacon->total_missed_becons), | ||
463 | le32_to_cpu(missed_beacon->num_recvd_beacons), | ||
464 | le32_to_cpu(missed_beacon->num_expected_beacons)); | ||
465 | if (!test_bit(STATUS_SCANNING, &priv->status)) | ||
466 | iwl_init_sensitivity(priv); | ||
467 | } | ||
468 | #endif /* CONFIG_IWLWIFI_RUN_TIME_CALIB */ | ||
469 | } | ||
470 | EXPORT_SYMBOL(iwl_rx_missed_beacon_notif); | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c index f2267047d102..983f10760fb0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-sta.c | |||
@@ -37,6 +37,10 @@ | |||
37 | #include "iwl-io.h" | 37 | #include "iwl-io.h" |
38 | #include "iwl-helpers.h" | 38 | #include "iwl-helpers.h" |
39 | 39 | ||
40 | |||
41 | #define IWL_STA_DRIVER_ACTIVE 0x1 /* ucode entry is active */ | ||
42 | #define IWL_STA_UCODE_ACTIVE 0x2 /* ucode entry is active */ | ||
43 | |||
40 | u8 iwl_find_station(struct iwl_priv *priv, const u8 *addr) | 44 | u8 iwl_find_station(struct iwl_priv *priv, const u8 *addr) |
41 | { | 45 | { |
42 | int i; | 46 | int i; |
@@ -70,6 +74,39 @@ u8 iwl_find_station(struct iwl_priv *priv, const u8 *addr) | |||
70 | } | 74 | } |
71 | EXPORT_SYMBOL(iwl_find_station); | 75 | EXPORT_SYMBOL(iwl_find_station); |
72 | 76 | ||
77 | static int iwl_add_sta_callback(struct iwl_priv *priv, | ||
78 | struct iwl_cmd *cmd, struct sk_buff *skb) | ||
79 | { | ||
80 | struct iwl_rx_packet *res = NULL; | ||
81 | |||
82 | if (!skb) { | ||
83 | IWL_ERROR("Error: Response NULL in REPLY_ADD_STA.\n"); | ||
84 | return 1; | ||
85 | } | ||
86 | |||
87 | res = (struct iwl_rx_packet *)skb->data; | ||
88 | if (res->hdr.flags & IWL_CMD_FAILED_MSK) { | ||
89 | IWL_ERROR("Bad return from REPLY_ADD_STA (0x%08X)\n", | ||
90 | res->hdr.flags); | ||
91 | return 1; | ||
92 | } | ||
93 | |||
94 | switch (res->u.add_sta.status) { | ||
95 | case ADD_STA_SUCCESS_MSK: | ||
96 | /* FIXME: implement iwl_sta_ucode_activate(priv, addr); */ | ||
97 | /* fail through */ | ||
98 | default: | ||
99 | IWL_DEBUG_HC("Received REPLY_ADD_STA:(0x%08X)\n", | ||
100 | res->u.add_sta.status); | ||
101 | break; | ||
102 | } | ||
103 | |||
104 | /* We didn't cache the SKB; let the caller free it */ | ||
105 | return 1; | ||
106 | } | ||
107 | |||
108 | |||
109 | |||
73 | int iwl_send_add_sta(struct iwl_priv *priv, | 110 | int iwl_send_add_sta(struct iwl_priv *priv, |
74 | struct iwl_addsta_cmd *sta, u8 flags) | 111 | struct iwl_addsta_cmd *sta, u8 flags) |
75 | { | 112 | { |
@@ -82,7 +119,9 @@ int iwl_send_add_sta(struct iwl_priv *priv, | |||
82 | .data = data, | 119 | .data = data, |
83 | }; | 120 | }; |
84 | 121 | ||
85 | if (!(flags & CMD_ASYNC)) | 122 | if (flags & CMD_ASYNC) |
123 | cmd.meta.u.callback = iwl_add_sta_callback; | ||
124 | else | ||
86 | cmd.meta.flags |= CMD_WANT_SKB; | 125 | cmd.meta.flags |= CMD_WANT_SKB; |
87 | 126 | ||
88 | cmd.len = priv->cfg->ops->utils->build_addsta_hcmd(sta, data); | 127 | cmd.len = priv->cfg->ops->utils->build_addsta_hcmd(sta, data); |
@@ -117,6 +156,276 @@ int iwl_send_add_sta(struct iwl_priv *priv, | |||
117 | } | 156 | } |
118 | EXPORT_SYMBOL(iwl_send_add_sta); | 157 | EXPORT_SYMBOL(iwl_send_add_sta); |
119 | 158 | ||
159 | #ifdef CONFIG_IWL4965_HT | ||
160 | |||
161 | static void iwl_set_ht_add_station(struct iwl_priv *priv, u8 index, | ||
162 | struct ieee80211_ht_info *sta_ht_inf) | ||
163 | { | ||
164 | __le32 sta_flags; | ||
165 | u8 mimo_ps_mode; | ||
166 | |||
167 | if (!sta_ht_inf || !sta_ht_inf->ht_supported) | ||
168 | goto done; | ||
169 | |||
170 | mimo_ps_mode = (sta_ht_inf->cap & IEEE80211_HT_CAP_MIMO_PS) >> 2; | ||
171 | |||
172 | sta_flags = priv->stations[index].sta.station_flags; | ||
173 | |||
174 | sta_flags &= ~(STA_FLG_RTS_MIMO_PROT_MSK | STA_FLG_MIMO_DIS_MSK); | ||
175 | |||
176 | switch (mimo_ps_mode) { | ||
177 | case WLAN_HT_CAP_MIMO_PS_STATIC: | ||
178 | sta_flags |= STA_FLG_MIMO_DIS_MSK; | ||
179 | break; | ||
180 | case WLAN_HT_CAP_MIMO_PS_DYNAMIC: | ||
181 | sta_flags |= STA_FLG_RTS_MIMO_PROT_MSK; | ||
182 | break; | ||
183 | case WLAN_HT_CAP_MIMO_PS_DISABLED: | ||
184 | break; | ||
185 | default: | ||
186 | IWL_WARNING("Invalid MIMO PS mode %d", mimo_ps_mode); | ||
187 | break; | ||
188 | } | ||
189 | |||
190 | sta_flags |= cpu_to_le32( | ||
191 | (u32)sta_ht_inf->ampdu_factor << STA_FLG_MAX_AGG_SIZE_POS); | ||
192 | |||
193 | sta_flags |= cpu_to_le32( | ||
194 | (u32)sta_ht_inf->ampdu_density << STA_FLG_AGG_MPDU_DENSITY_POS); | ||
195 | |||
196 | if (iwl_is_fat_tx_allowed(priv, sta_ht_inf)) | ||
197 | sta_flags |= STA_FLG_FAT_EN_MSK; | ||
198 | else | ||
199 | sta_flags &= ~STA_FLG_FAT_EN_MSK; | ||
200 | |||
201 | priv->stations[index].sta.station_flags = sta_flags; | ||
202 | done: | ||
203 | return; | ||
204 | } | ||
205 | #else | ||
206 | static inline void iwl_set_ht_add_station(struct iwl_priv *priv, u8 index, | ||
207 | struct ieee80211_ht_info *sta_ht_info) | ||
208 | { | ||
209 | } | ||
210 | #endif | ||
211 | |||
212 | /** | ||
213 | * iwl_add_station_flags - Add station to tables in driver and device | ||
214 | */ | ||
215 | u8 iwl_add_station_flags(struct iwl_priv *priv, const u8 *addr, int is_ap, | ||
216 | u8 flags, struct ieee80211_ht_info *ht_info) | ||
217 | { | ||
218 | int i; | ||
219 | int index = IWL_INVALID_STATION; | ||
220 | struct iwl_station_entry *station; | ||
221 | unsigned long flags_spin; | ||
222 | DECLARE_MAC_BUF(mac); | ||
223 | |||
224 | spin_lock_irqsave(&priv->sta_lock, flags_spin); | ||
225 | if (is_ap) | ||
226 | index = IWL_AP_ID; | ||
227 | else if (is_broadcast_ether_addr(addr)) | ||
228 | index = priv->hw_params.bcast_sta_id; | ||
229 | else | ||
230 | for (i = IWL_STA_ID; i < priv->hw_params.max_stations; i++) { | ||
231 | if (!compare_ether_addr(priv->stations[i].sta.sta.addr, | ||
232 | addr)) { | ||
233 | index = i; | ||
234 | break; | ||
235 | } | ||
236 | |||
237 | if (!priv->stations[i].used && | ||
238 | index == IWL_INVALID_STATION) | ||
239 | index = i; | ||
240 | } | ||
241 | |||
242 | |||
243 | /* These two conditions have the same outcome, but keep them separate | ||
244 | since they have different meanings */ | ||
245 | if (unlikely(index == IWL_INVALID_STATION)) { | ||
246 | spin_unlock_irqrestore(&priv->sta_lock, flags_spin); | ||
247 | return index; | ||
248 | } | ||
249 | |||
250 | if (priv->stations[index].used && | ||
251 | !compare_ether_addr(priv->stations[index].sta.sta.addr, addr)) { | ||
252 | spin_unlock_irqrestore(&priv->sta_lock, flags_spin); | ||
253 | return index; | ||
254 | } | ||
255 | |||
256 | |||
257 | IWL_DEBUG_ASSOC("Add STA ID %d: %s\n", index, print_mac(mac, addr)); | ||
258 | station = &priv->stations[index]; | ||
259 | station->used = 1; | ||
260 | priv->num_stations++; | ||
261 | |||
262 | /* Set up the REPLY_ADD_STA command to send to device */ | ||
263 | memset(&station->sta, 0, sizeof(struct iwl_addsta_cmd)); | ||
264 | memcpy(station->sta.sta.addr, addr, ETH_ALEN); | ||
265 | station->sta.mode = 0; | ||
266 | station->sta.sta.sta_id = index; | ||
267 | station->sta.station_flags = 0; | ||
268 | |||
269 | /* BCAST station and IBSS stations do not work in HT mode */ | ||
270 | if (index != priv->hw_params.bcast_sta_id && | ||
271 | priv->iw_mode != IEEE80211_IF_TYPE_IBSS) | ||
272 | iwl_set_ht_add_station(priv, index, ht_info); | ||
273 | |||
274 | spin_unlock_irqrestore(&priv->sta_lock, flags_spin); | ||
275 | |||
276 | /* Add station to device's station table */ | ||
277 | iwl_send_add_sta(priv, &station->sta, flags); | ||
278 | return index; | ||
279 | |||
280 | } | ||
281 | EXPORT_SYMBOL(iwl_add_station_flags); | ||
282 | |||
283 | |||
284 | static int iwl_sta_ucode_deactivate(struct iwl_priv *priv, const char *addr) | ||
285 | { | ||
286 | unsigned long flags; | ||
287 | u8 sta_id; | ||
288 | DECLARE_MAC_BUF(mac); | ||
289 | |||
290 | sta_id = iwl_find_station(priv, addr); | ||
291 | if (sta_id != IWL_INVALID_STATION) { | ||
292 | IWL_DEBUG_ASSOC("Removed STA from Ucode: %s\n", | ||
293 | print_mac(mac, addr)); | ||
294 | spin_lock_irqsave(&priv->sta_lock, flags); | ||
295 | priv->stations[sta_id].used &= ~IWL_STA_UCODE_ACTIVE; | ||
296 | memset(&priv->stations[sta_id], 0, | ||
297 | sizeof(struct iwl_station_entry)); | ||
298 | spin_unlock_irqrestore(&priv->sta_lock, flags); | ||
299 | return 0; | ||
300 | } | ||
301 | return -EINVAL; | ||
302 | } | ||
303 | |||
304 | static int iwl_remove_sta_callback(struct iwl_priv *priv, | ||
305 | struct iwl_cmd *cmd, struct sk_buff *skb) | ||
306 | { | ||
307 | struct iwl_rx_packet *res = NULL; | ||
308 | const char *addr = cmd->cmd.rm_sta.addr; | ||
309 | |||
310 | if (!skb) { | ||
311 | IWL_ERROR("Error: Response NULL in REPLY_REMOVE_STA.\n"); | ||
312 | return 1; | ||
313 | } | ||
314 | |||
315 | res = (struct iwl_rx_packet *)skb->data; | ||
316 | if (res->hdr.flags & IWL_CMD_FAILED_MSK) { | ||
317 | IWL_ERROR("Bad return from REPLY_REMOVE_STA (0x%08X)\n", | ||
318 | res->hdr.flags); | ||
319 | return 1; | ||
320 | } | ||
321 | |||
322 | switch (res->u.rem_sta.status) { | ||
323 | case REM_STA_SUCCESS_MSK: | ||
324 | iwl_sta_ucode_deactivate(priv, addr); | ||
325 | break; | ||
326 | default: | ||
327 | break; | ||
328 | } | ||
329 | |||
330 | /* We didn't cache the SKB; let the caller free it */ | ||
331 | return 1; | ||
332 | } | ||
333 | |||
334 | static int iwl_send_remove_station(struct iwl_priv *priv, const u8 *addr, | ||
335 | u8 flags) | ||
336 | { | ||
337 | struct iwl_rx_packet *res = NULL; | ||
338 | int ret; | ||
339 | |||
340 | struct iwl_rem_sta_cmd rm_sta_cmd; | ||
341 | |||
342 | struct iwl_host_cmd cmd = { | ||
343 | .id = REPLY_REMOVE_STA, | ||
344 | .len = sizeof(struct iwl_rem_sta_cmd), | ||
345 | .meta.flags = flags, | ||
346 | .data = &rm_sta_cmd, | ||
347 | }; | ||
348 | |||
349 | memset(&rm_sta_cmd, 0, sizeof(rm_sta_cmd)); | ||
350 | rm_sta_cmd.num_sta = 1; | ||
351 | memcpy(&rm_sta_cmd.addr, addr , ETH_ALEN); | ||
352 | |||
353 | if (flags & CMD_ASYNC) | ||
354 | cmd.meta.u.callback = iwl_remove_sta_callback; | ||
355 | else | ||
356 | cmd.meta.flags |= CMD_WANT_SKB; | ||
357 | ret = iwl_send_cmd(priv, &cmd); | ||
358 | |||
359 | if (ret || (flags & CMD_ASYNC)) | ||
360 | return ret; | ||
361 | |||
362 | res = (struct iwl_rx_packet *)cmd.meta.u.skb->data; | ||
363 | if (res->hdr.flags & IWL_CMD_FAILED_MSK) { | ||
364 | IWL_ERROR("Bad return from REPLY_REMOVE_STA (0x%08X)\n", | ||
365 | res->hdr.flags); | ||
366 | ret = -EIO; | ||
367 | } | ||
368 | |||
369 | if (!ret) { | ||
370 | switch (res->u.rem_sta.status) { | ||
371 | case REM_STA_SUCCESS_MSK: | ||
372 | iwl_sta_ucode_deactivate(priv, addr); | ||
373 | IWL_DEBUG_ASSOC("REPLY_REMOVE_STA PASSED\n"); | ||
374 | break; | ||
375 | default: | ||
376 | ret = -EIO; | ||
377 | IWL_ERROR("REPLY_REMOVE_STA failed\n"); | ||
378 | break; | ||
379 | } | ||
380 | } | ||
381 | |||
382 | priv->alloc_rxb_skb--; | ||
383 | dev_kfree_skb_any(cmd.meta.u.skb); | ||
384 | |||
385 | return ret; | ||
386 | } | ||
387 | /** | ||
388 | * iwl_remove_station - Remove driver's knowledge of station. | ||
389 | * | ||
390 | */ | ||
391 | u8 iwl_remove_station(struct iwl_priv *priv, const u8 *addr, int is_ap) | ||
392 | { | ||
393 | int index = IWL_INVALID_STATION; | ||
394 | int i; | ||
395 | unsigned long flags; | ||
396 | |||
397 | spin_lock_irqsave(&priv->sta_lock, flags); | ||
398 | |||
399 | if (is_ap) | ||
400 | index = IWL_AP_ID; | ||
401 | else if (is_broadcast_ether_addr(addr)) | ||
402 | index = priv->hw_params.bcast_sta_id; | ||
403 | else | ||
404 | for (i = IWL_STA_ID; i < priv->hw_params.max_stations; i++) | ||
405 | if (priv->stations[i].used && | ||
406 | !compare_ether_addr(priv->stations[i].sta.sta.addr, | ||
407 | addr)) { | ||
408 | index = i; | ||
409 | break; | ||
410 | } | ||
411 | |||
412 | if (unlikely(index == IWL_INVALID_STATION)) | ||
413 | goto out; | ||
414 | |||
415 | if (priv->stations[index].used) { | ||
416 | priv->stations[index].used = 0; | ||
417 | priv->num_stations--; | ||
418 | } | ||
419 | |||
420 | BUG_ON(priv->num_stations < 0); | ||
421 | spin_unlock_irqrestore(&priv->sta_lock, flags); | ||
422 | iwl_send_remove_station(priv, addr, CMD_ASYNC); | ||
423 | return index; | ||
424 | out: | ||
425 | spin_unlock_irqrestore(&priv->sta_lock, flags); | ||
426 | return 0; | ||
427 | } | ||
428 | EXPORT_SYMBOL(iwl_remove_station); | ||
120 | int iwl_get_free_ucode_key_index(struct iwl_priv *priv) | 429 | int iwl_get_free_ucode_key_index(struct iwl_priv *priv) |
121 | { | 430 | { |
122 | int i; | 431 | int i; |
@@ -200,7 +509,7 @@ int iwl_set_default_wep_key(struct iwl_priv *priv, | |||
200 | unsigned long flags; | 509 | unsigned long flags; |
201 | 510 | ||
202 | keyconf->flags &= ~IEEE80211_KEY_FLAG_GENERATE_IV; | 511 | keyconf->flags &= ~IEEE80211_KEY_FLAG_GENERATE_IV; |
203 | keyconf->hw_key_idx = keyconf->keyidx; | 512 | keyconf->hw_key_idx = HW_KEY_DEFAULT; |
204 | priv->stations[IWL_AP_ID].keyinfo.alg = ALG_WEP; | 513 | priv->stations[IWL_AP_ID].keyinfo.alg = ALG_WEP; |
205 | 514 | ||
206 | spin_lock_irqsave(&priv->sta_lock, flags); | 515 | spin_lock_irqsave(&priv->sta_lock, flags); |
@@ -230,7 +539,6 @@ static int iwl_set_wep_dynamic_key_info(struct iwl_priv *priv, | |||
230 | int ret; | 539 | int ret; |
231 | 540 | ||
232 | keyconf->flags &= ~IEEE80211_KEY_FLAG_GENERATE_IV; | 541 | keyconf->flags &= ~IEEE80211_KEY_FLAG_GENERATE_IV; |
233 | keyconf->hw_key_idx = keyconf->keyidx; | ||
234 | 542 | ||
235 | key_flags |= (STA_KEY_FLG_WEP | STA_KEY_FLG_MAP_KEY_MSK); | 543 | key_flags |= (STA_KEY_FLG_WEP | STA_KEY_FLG_MAP_KEY_MSK); |
236 | key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); | 544 | key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); |
@@ -287,7 +595,6 @@ static int iwl_set_ccmp_dynamic_key_info(struct iwl_priv *priv, | |||
287 | key_flags |= STA_KEY_MULTICAST_MSK; | 595 | key_flags |= STA_KEY_MULTICAST_MSK; |
288 | 596 | ||
289 | keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; | 597 | keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; |
290 | keyconf->hw_key_idx = keyconf->keyidx; | ||
291 | 598 | ||
292 | spin_lock_irqsave(&priv->sta_lock, flags); | 599 | spin_lock_irqsave(&priv->sta_lock, flags); |
293 | priv->stations[sta_id].keyinfo.alg = keyconf->alg; | 600 | priv->stations[sta_id].keyinfo.alg = keyconf->alg; |
@@ -325,12 +632,10 @@ static int iwl_set_tkip_dynamic_key_info(struct iwl_priv *priv, | |||
325 | 632 | ||
326 | keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; | 633 | keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; |
327 | keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; | 634 | keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; |
328 | keyconf->hw_key_idx = keyconf->keyidx; | ||
329 | 635 | ||
330 | spin_lock_irqsave(&priv->sta_lock, flags); | 636 | spin_lock_irqsave(&priv->sta_lock, flags); |
331 | 637 | ||
332 | priv->stations[sta_id].keyinfo.alg = keyconf->alg; | 638 | priv->stations[sta_id].keyinfo.alg = keyconf->alg; |
333 | priv->stations[sta_id].keyinfo.conf = keyconf; | ||
334 | priv->stations[sta_id].keyinfo.keylen = 16; | 639 | priv->stations[sta_id].keyinfo.keylen = 16; |
335 | 640 | ||
336 | if ((priv->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) | 641 | if ((priv->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) |
@@ -359,7 +664,7 @@ int iwl_remove_dynamic_key(struct iwl_priv *priv, | |||
359 | u16 key_flags; | 664 | u16 key_flags; |
360 | u8 keyidx; | 665 | u8 keyidx; |
361 | 666 | ||
362 | priv->key_mapping_key = 0; | 667 | priv->key_mapping_key--; |
363 | 668 | ||
364 | spin_lock_irqsave(&priv->sta_lock, flags); | 669 | spin_lock_irqsave(&priv->sta_lock, flags); |
365 | key_flags = le16_to_cpu(priv->stations[sta_id].sta.key.key_flags); | 670 | key_flags = le16_to_cpu(priv->stations[sta_id].sta.key.key_flags); |
@@ -390,31 +695,32 @@ int iwl_remove_dynamic_key(struct iwl_priv *priv, | |||
390 | priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; | 695 | priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; |
391 | 696 | ||
392 | IWL_DEBUG_INFO("hwcrypto: clear ucode station key info\n"); | 697 | IWL_DEBUG_INFO("hwcrypto: clear ucode station key info\n"); |
393 | ret = iwl_send_add_sta(priv, &priv->stations[sta_id].sta, 0); | 698 | ret = iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC); |
394 | spin_unlock_irqrestore(&priv->sta_lock, flags); | 699 | spin_unlock_irqrestore(&priv->sta_lock, flags); |
395 | return ret; | 700 | return ret; |
396 | } | 701 | } |
397 | EXPORT_SYMBOL(iwl_remove_dynamic_key); | 702 | EXPORT_SYMBOL(iwl_remove_dynamic_key); |
398 | 703 | ||
399 | int iwl_set_dynamic_key(struct iwl_priv *priv, | 704 | int iwl_set_dynamic_key(struct iwl_priv *priv, |
400 | struct ieee80211_key_conf *key, u8 sta_id) | 705 | struct ieee80211_key_conf *keyconf, u8 sta_id) |
401 | { | 706 | { |
402 | int ret; | 707 | int ret; |
403 | 708 | ||
404 | priv->key_mapping_key = 1; | 709 | priv->key_mapping_key++; |
710 | keyconf->hw_key_idx = HW_KEY_DYNAMIC; | ||
405 | 711 | ||
406 | switch (key->alg) { | 712 | switch (keyconf->alg) { |
407 | case ALG_CCMP: | 713 | case ALG_CCMP: |
408 | ret = iwl_set_ccmp_dynamic_key_info(priv, key, sta_id); | 714 | ret = iwl_set_ccmp_dynamic_key_info(priv, keyconf, sta_id); |
409 | break; | 715 | break; |
410 | case ALG_TKIP: | 716 | case ALG_TKIP: |
411 | ret = iwl_set_tkip_dynamic_key_info(priv, key, sta_id); | 717 | ret = iwl_set_tkip_dynamic_key_info(priv, keyconf, sta_id); |
412 | break; | 718 | break; |
413 | case ALG_WEP: | 719 | case ALG_WEP: |
414 | ret = iwl_set_wep_dynamic_key_info(priv, key, sta_id); | 720 | ret = iwl_set_wep_dynamic_key_info(priv, keyconf, sta_id); |
415 | break; | 721 | break; |
416 | default: | 722 | default: |
417 | IWL_ERROR("Unknown alg: %s alg = %d\n", __func__, key->alg); | 723 | IWL_ERROR("Unknown alg: %s alg = %d\n", __func__, keyconf->alg); |
418 | ret = -EINVAL; | 724 | ret = -EINVAL; |
419 | } | 725 | } |
420 | 726 | ||
@@ -470,3 +776,168 @@ int iwl_send_lq_cmd(struct iwl_priv *priv, | |||
470 | } | 776 | } |
471 | EXPORT_SYMBOL(iwl_send_lq_cmd); | 777 | EXPORT_SYMBOL(iwl_send_lq_cmd); |
472 | 778 | ||
779 | /** | ||
780 | * iwl_sta_init_lq - Initialize a station's hardware rate table | ||
781 | * | ||
782 | * The uCode's station table contains a table of fallback rates | ||
783 | * for automatic fallback during transmission. | ||
784 | * | ||
785 | * NOTE: This sets up a default set of values. These will be replaced later | ||
786 | * if the driver's iwl-4965-rs rate scaling algorithm is used, instead of | ||
787 | * rc80211_simple. | ||
788 | * | ||
789 | * NOTE: Run REPLY_ADD_STA command to set up station table entry, before | ||
790 | * calling this function (which runs REPLY_TX_LINK_QUALITY_CMD, | ||
791 | * which requires station table entry to exist). | ||
792 | */ | ||
793 | static void iwl_sta_init_lq(struct iwl_priv *priv, const u8 *addr, int is_ap) | ||
794 | { | ||
795 | int i, r; | ||
796 | struct iwl_link_quality_cmd link_cmd = { | ||
797 | .reserved1 = 0, | ||
798 | }; | ||
799 | u16 rate_flags; | ||
800 | |||
801 | /* Set up the rate scaling to start at selected rate, fall back | ||
802 | * all the way down to 1M in IEEE order, and then spin on 1M */ | ||
803 | if (is_ap) | ||
804 | r = IWL_RATE_54M_INDEX; | ||
805 | else if (priv->band == IEEE80211_BAND_5GHZ) | ||
806 | r = IWL_RATE_6M_INDEX; | ||
807 | else | ||
808 | r = IWL_RATE_1M_INDEX; | ||
809 | |||
810 | for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { | ||
811 | rate_flags = 0; | ||
812 | if (r >= IWL_FIRST_CCK_RATE && r <= IWL_LAST_CCK_RATE) | ||
813 | rate_flags |= RATE_MCS_CCK_MSK; | ||
814 | |||
815 | /* Use Tx antenna B only */ | ||
816 | rate_flags |= RATE_MCS_ANT_B_MSK; /*FIXME:RS*/ | ||
817 | |||
818 | link_cmd.rs_table[i].rate_n_flags = | ||
819 | iwl4965_hw_set_rate_n_flags(iwl_rates[r].plcp, rate_flags); | ||
820 | r = iwl4965_get_prev_ieee_rate(r); | ||
821 | } | ||
822 | |||
823 | link_cmd.general_params.single_stream_ant_msk = 2; | ||
824 | link_cmd.general_params.dual_stream_ant_msk = 3; | ||
825 | link_cmd.agg_params.agg_dis_start_th = 3; | ||
826 | link_cmd.agg_params.agg_time_limit = cpu_to_le16(4000); | ||
827 | |||
828 | /* Update the rate scaling for control frame Tx to AP */ | ||
829 | link_cmd.sta_id = is_ap ? IWL_AP_ID : priv->hw_params.bcast_sta_id; | ||
830 | |||
831 | iwl_send_cmd_pdu_async(priv, REPLY_TX_LINK_QUALITY_CMD, | ||
832 | sizeof(link_cmd), &link_cmd, NULL); | ||
833 | } | ||
834 | /** | ||
835 | * iwl_rxon_add_station - add station into station table. | ||
836 | * | ||
837 | * there is only one AP station with id= IWL_AP_ID | ||
838 | * NOTE: mutex must be held before calling this fnction | ||
839 | */ | ||
840 | int iwl_rxon_add_station(struct iwl_priv *priv, const u8 *addr, int is_ap) | ||
841 | { | ||
842 | u8 sta_id; | ||
843 | |||
844 | /* Add station to device's station table */ | ||
845 | #ifdef CONFIG_IWL4965_HT | ||
846 | struct ieee80211_conf *conf = &priv->hw->conf; | ||
847 | struct ieee80211_ht_info *cur_ht_config = &conf->ht_conf; | ||
848 | |||
849 | if ((is_ap) && | ||
850 | (conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) && | ||
851 | (priv->iw_mode == IEEE80211_IF_TYPE_STA)) | ||
852 | sta_id = iwl_add_station_flags(priv, addr, is_ap, | ||
853 | 0, cur_ht_config); | ||
854 | else | ||
855 | #endif /* CONFIG_IWL4965_HT */ | ||
856 | sta_id = iwl_add_station_flags(priv, addr, is_ap, | ||
857 | 0, NULL); | ||
858 | |||
859 | /* Set up default rate scaling table in device's station table */ | ||
860 | iwl_sta_init_lq(priv, addr, is_ap); | ||
861 | |||
862 | return sta_id; | ||
863 | } | ||
864 | EXPORT_SYMBOL(iwl_rxon_add_station); | ||
865 | |||
866 | |||
867 | /** | ||
868 | * iwl_get_sta_id - Find station's index within station table | ||
869 | * | ||
870 | * If new IBSS station, create new entry in station table | ||
871 | */ | ||
872 | int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr) | ||
873 | { | ||
874 | int sta_id; | ||
875 | u16 fc = le16_to_cpu(hdr->frame_control); | ||
876 | DECLARE_MAC_BUF(mac); | ||
877 | |||
878 | /* If this frame is broadcast or management, use broadcast station id */ | ||
879 | if (((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA) || | ||
880 | is_multicast_ether_addr(hdr->addr1)) | ||
881 | return priv->hw_params.bcast_sta_id; | ||
882 | |||
883 | switch (priv->iw_mode) { | ||
884 | |||
885 | /* If we are a client station in a BSS network, use the special | ||
886 | * AP station entry (that's the only station we communicate with) */ | ||
887 | case IEEE80211_IF_TYPE_STA: | ||
888 | return IWL_AP_ID; | ||
889 | |||
890 | /* If we are an AP, then find the station, or use BCAST */ | ||
891 | case IEEE80211_IF_TYPE_AP: | ||
892 | sta_id = iwl_find_station(priv, hdr->addr1); | ||
893 | if (sta_id != IWL_INVALID_STATION) | ||
894 | return sta_id; | ||
895 | return priv->hw_params.bcast_sta_id; | ||
896 | |||
897 | /* If this frame is going out to an IBSS network, find the station, | ||
898 | * or create a new station table entry */ | ||
899 | case IEEE80211_IF_TYPE_IBSS: | ||
900 | sta_id = iwl_find_station(priv, hdr->addr1); | ||
901 | if (sta_id != IWL_INVALID_STATION) | ||
902 | return sta_id; | ||
903 | |||
904 | /* Create new station table entry */ | ||
905 | sta_id = iwl_add_station_flags(priv, hdr->addr1, | ||
906 | 0, CMD_ASYNC, NULL); | ||
907 | |||
908 | if (sta_id != IWL_INVALID_STATION) | ||
909 | return sta_id; | ||
910 | |||
911 | IWL_DEBUG_DROP("Station %s not in station map. " | ||
912 | "Defaulting to broadcast...\n", | ||
913 | print_mac(mac, hdr->addr1)); | ||
914 | iwl_print_hex_dump(priv, IWL_DL_DROP, (u8 *) hdr, sizeof(*hdr)); | ||
915 | return priv->hw_params.bcast_sta_id; | ||
916 | |||
917 | default: | ||
918 | IWL_WARNING("Unknown mode of operation: %d", priv->iw_mode); | ||
919 | return priv->hw_params.bcast_sta_id; | ||
920 | } | ||
921 | } | ||
922 | EXPORT_SYMBOL(iwl_get_sta_id); | ||
923 | |||
924 | |||
925 | /** | ||
926 | * iwl_sta_modify_enable_tid_tx - Enable Tx for this TID in station table | ||
927 | */ | ||
928 | void iwl_sta_modify_enable_tid_tx(struct iwl_priv *priv, int sta_id, int tid) | ||
929 | { | ||
930 | unsigned long flags; | ||
931 | |||
932 | /* Remove "disable" flag, to enable Tx for this TID */ | ||
933 | spin_lock_irqsave(&priv->sta_lock, flags); | ||
934 | priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_TID_DISABLE_TX; | ||
935 | priv->stations[sta_id].sta.tid_disable_tx &= cpu_to_le16(~(1 << tid)); | ||
936 | priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; | ||
937 | spin_unlock_irqrestore(&priv->sta_lock, flags); | ||
938 | |||
939 | iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC); | ||
940 | } | ||
941 | EXPORT_SYMBOL(iwl_sta_modify_enable_tid_tx); | ||
942 | |||
943 | |||
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.h b/drivers/net/wireless/iwlwifi/iwl-sta.h index 38b1b0a98845..3d55716f5301 100644 --- a/drivers/net/wireless/iwlwifi/iwl-sta.h +++ b/drivers/net/wireless/iwlwifi/iwl-sta.h | |||
@@ -29,6 +29,9 @@ | |||
29 | #ifndef __iwl_sta_h__ | 29 | #ifndef __iwl_sta_h__ |
30 | #define __iwl_sta_h__ | 30 | #define __iwl_sta_h__ |
31 | 31 | ||
32 | #define HW_KEY_DYNAMIC 0 | ||
33 | #define HW_KEY_DEFAULT 1 | ||
34 | |||
32 | int iwl_get_free_ucode_key_index(struct iwl_priv *priv); | 35 | int iwl_get_free_ucode_key_index(struct iwl_priv *priv); |
33 | int iwl_send_static_wepkey_cmd(struct iwl_priv *priv, u8 send_if_empty); | 36 | int iwl_send_static_wepkey_cmd(struct iwl_priv *priv, u8 send_if_empty); |
34 | int iwl_remove_default_wep_key(struct iwl_priv *priv, | 37 | int iwl_remove_default_wep_key(struct iwl_priv *priv, |
@@ -39,4 +42,8 @@ int iwl_set_dynamic_key(struct iwl_priv *priv, | |||
39 | struct ieee80211_key_conf *key, u8 sta_id); | 42 | struct ieee80211_key_conf *key, u8 sta_id); |
40 | int iwl_remove_dynamic_key(struct iwl_priv *priv, | 43 | int iwl_remove_dynamic_key(struct iwl_priv *priv, |
41 | struct ieee80211_key_conf *key, u8 sta_id); | 44 | struct ieee80211_key_conf *key, u8 sta_id); |
45 | int iwl_rxon_add_station(struct iwl_priv *priv, const u8 *addr, int is_ap); | ||
46 | u8 iwl_remove_station(struct iwl_priv *priv, const u8 *addr, int is_ap); | ||
47 | int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr); | ||
48 | void iwl_sta_modify_enable_tid_tx(struct iwl_priv *priv, int sta_id, int tid); | ||
42 | #endif /* __iwl_sta_h__ */ | 49 | #endif /* __iwl_sta_h__ */ |
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c index a1e03ccd5147..cfe6f4b233dd 100644 --- a/drivers/net/wireless/iwlwifi/iwl-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-tx.c | |||
@@ -27,6 +27,7 @@ | |||
27 | * | 27 | * |
28 | *****************************************************************************/ | 28 | *****************************************************************************/ |
29 | 29 | ||
30 | #include <linux/etherdevice.h> | ||
30 | #include <net/mac80211.h> | 31 | #include <net/mac80211.h> |
31 | #include "iwl-eeprom.h" | 32 | #include "iwl-eeprom.h" |
32 | #include "iwl-dev.h" | 33 | #include "iwl-dev.h" |
@@ -35,6 +36,32 @@ | |||
35 | #include "iwl-io.h" | 36 | #include "iwl-io.h" |
36 | #include "iwl-helpers.h" | 37 | #include "iwl-helpers.h" |
37 | 38 | ||
39 | #ifdef CONFIG_IWL4965_HT | ||
40 | |||
41 | static const u16 default_tid_to_tx_fifo[] = { | ||
42 | IWL_TX_FIFO_AC1, | ||
43 | IWL_TX_FIFO_AC0, | ||
44 | IWL_TX_FIFO_AC0, | ||
45 | IWL_TX_FIFO_AC1, | ||
46 | IWL_TX_FIFO_AC2, | ||
47 | IWL_TX_FIFO_AC2, | ||
48 | IWL_TX_FIFO_AC3, | ||
49 | IWL_TX_FIFO_AC3, | ||
50 | IWL_TX_FIFO_NONE, | ||
51 | IWL_TX_FIFO_NONE, | ||
52 | IWL_TX_FIFO_NONE, | ||
53 | IWL_TX_FIFO_NONE, | ||
54 | IWL_TX_FIFO_NONE, | ||
55 | IWL_TX_FIFO_NONE, | ||
56 | IWL_TX_FIFO_NONE, | ||
57 | IWL_TX_FIFO_NONE, | ||
58 | IWL_TX_FIFO_AC3 | ||
59 | }; | ||
60 | |||
61 | #endif /*CONFIG_IWL4965_HT */ | ||
62 | |||
63 | |||
64 | |||
38 | /** | 65 | /** |
39 | * iwl_hw_txq_free_tfd - Free all chunks referenced by TFD [txq->q.read_ptr] | 66 | * iwl_hw_txq_free_tfd - Free all chunks referenced by TFD [txq->q.read_ptr] |
40 | * | 67 | * |
@@ -95,6 +122,89 @@ int iwl_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq) | |||
95 | } | 122 | } |
96 | EXPORT_SYMBOL(iwl_hw_txq_free_tfd); | 123 | EXPORT_SYMBOL(iwl_hw_txq_free_tfd); |
97 | 124 | ||
125 | |||
126 | int iwl_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, void *ptr, | ||
127 | dma_addr_t addr, u16 len) | ||
128 | { | ||
129 | int index, is_odd; | ||
130 | struct iwl_tfd_frame *tfd = ptr; | ||
131 | u32 num_tbs = IWL_GET_BITS(*tfd, num_tbs); | ||
132 | |||
133 | /* Each TFD can point to a maximum 20 Tx buffers */ | ||
134 | if ((num_tbs >= MAX_NUM_OF_TBS) || (num_tbs < 0)) { | ||
135 | IWL_ERROR("Error can not send more than %d chunks\n", | ||
136 | MAX_NUM_OF_TBS); | ||
137 | return -EINVAL; | ||
138 | } | ||
139 | |||
140 | index = num_tbs / 2; | ||
141 | is_odd = num_tbs & 0x1; | ||
142 | |||
143 | if (!is_odd) { | ||
144 | tfd->pa[index].tb1_addr = cpu_to_le32(addr); | ||
145 | IWL_SET_BITS(tfd->pa[index], tb1_addr_hi, | ||
146 | iwl_get_dma_hi_address(addr)); | ||
147 | IWL_SET_BITS(tfd->pa[index], tb1_len, len); | ||
148 | } else { | ||
149 | IWL_SET_BITS(tfd->pa[index], tb2_addr_lo16, | ||
150 | (u32) (addr & 0xffff)); | ||
151 | IWL_SET_BITS(tfd->pa[index], tb2_addr_hi20, addr >> 16); | ||
152 | IWL_SET_BITS(tfd->pa[index], tb2_len, len); | ||
153 | } | ||
154 | |||
155 | IWL_SET_BITS(*tfd, num_tbs, num_tbs + 1); | ||
156 | |||
157 | return 0; | ||
158 | } | ||
159 | EXPORT_SYMBOL(iwl_hw_txq_attach_buf_to_tfd); | ||
160 | |||
161 | /** | ||
162 | * iwl_txq_update_write_ptr - Send new write index to hardware | ||
163 | */ | ||
164 | int iwl_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq) | ||
165 | { | ||
166 | u32 reg = 0; | ||
167 | int ret = 0; | ||
168 | int txq_id = txq->q.id; | ||
169 | |||
170 | if (txq->need_update == 0) | ||
171 | return ret; | ||
172 | |||
173 | /* if we're trying to save power */ | ||
174 | if (test_bit(STATUS_POWER_PMI, &priv->status)) { | ||
175 | /* wake up nic if it's powered down ... | ||
176 | * uCode will wake up, and interrupt us again, so next | ||
177 | * time we'll skip this part. */ | ||
178 | reg = iwl_read32(priv, CSR_UCODE_DRV_GP1); | ||
179 | |||
180 | if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { | ||
181 | IWL_DEBUG_INFO("Requesting wakeup, GP1 = 0x%x\n", reg); | ||
182 | iwl_set_bit(priv, CSR_GP_CNTRL, | ||
183 | CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); | ||
184 | return ret; | ||
185 | } | ||
186 | |||
187 | /* restore this queue's parameters in nic hardware. */ | ||
188 | ret = iwl_grab_nic_access(priv); | ||
189 | if (ret) | ||
190 | return ret; | ||
191 | iwl_write_direct32(priv, HBUS_TARG_WRPTR, | ||
192 | txq->q.write_ptr | (txq_id << 8)); | ||
193 | iwl_release_nic_access(priv); | ||
194 | |||
195 | /* else not in power-save mode, uCode will never sleep when we're | ||
196 | * trying to tx (during RFKILL, we're not trying to tx). */ | ||
197 | } else | ||
198 | iwl_write32(priv, HBUS_TARG_WRPTR, | ||
199 | txq->q.write_ptr | (txq_id << 8)); | ||
200 | |||
201 | txq->need_update = 0; | ||
202 | |||
203 | return ret; | ||
204 | } | ||
205 | EXPORT_SYMBOL(iwl_txq_update_write_ptr); | ||
206 | |||
207 | |||
98 | /** | 208 | /** |
99 | * iwl_tx_queue_free - Deallocate DMA queue. | 209 | * iwl_tx_queue_free - Deallocate DMA queue. |
100 | * @txq: Transmit queue to deallocate. | 210 | * @txq: Transmit queue to deallocate. |
@@ -105,7 +215,7 @@ EXPORT_SYMBOL(iwl_hw_txq_free_tfd); | |||
105 | */ | 215 | */ |
106 | static void iwl_tx_queue_free(struct iwl_priv *priv, struct iwl_tx_queue *txq) | 216 | static void iwl_tx_queue_free(struct iwl_priv *priv, struct iwl_tx_queue *txq) |
107 | { | 217 | { |
108 | struct iwl4965_queue *q = &txq->q; | 218 | struct iwl_queue *q = &txq->q; |
109 | struct pci_dev *dev = priv->pci_dev; | 219 | struct pci_dev *dev = priv->pci_dev; |
110 | int len; | 220 | int len; |
111 | 221 | ||
@@ -137,28 +247,51 @@ static void iwl_tx_queue_free(struct iwl_priv *priv, struct iwl_tx_queue *txq) | |||
137 | memset(txq, 0, sizeof(*txq)); | 247 | memset(txq, 0, sizeof(*txq)); |
138 | } | 248 | } |
139 | 249 | ||
140 | /** | 250 | /*************** DMA-QUEUE-GENERAL-FUNCTIONS ***** |
141 | * iwl_hw_txq_ctx_free - Free TXQ Context | 251 | * DMA services |
142 | * | 252 | * |
143 | * Destroy all TX DMA queues and structures | 253 | * Theory of operation |
144 | */ | 254 | * |
145 | void iwl_hw_txq_ctx_free(struct iwl_priv *priv) | 255 | * A Tx or Rx queue resides in host DRAM, and is comprised of a circular buffer |
256 | * of buffer descriptors, each of which points to one or more data buffers for | ||
257 | * the device to read from or fill. Driver and device exchange status of each | ||
258 | * queue via "read" and "write" pointers. Driver keeps minimum of 2 empty | ||
259 | * entries in each circular buffer, to protect against confusing empty and full | ||
260 | * queue states. | ||
261 | * | ||
262 | * The device reads or writes the data in the queues via the device's several | ||
263 | * DMA/FIFO channels. Each queue is mapped to a single DMA channel. | ||
264 | * | ||
265 | * For Tx queue, there are low mark and high mark limits. If, after queuing | ||
266 | * the packet for Tx, free space become < low mark, Tx queue stopped. When | ||
267 | * reclaiming packets (on 'tx done IRQ), if free space become > high mark, | ||
268 | * Tx queue resumed. | ||
269 | * | ||
270 | * See more detailed info in iwl-4965-hw.h. | ||
271 | ***************************************************/ | ||
272 | |||
273 | int iwl_queue_space(const struct iwl_queue *q) | ||
146 | { | 274 | { |
147 | int txq_id; | 275 | int s = q->read_ptr - q->write_ptr; |
148 | 276 | ||
149 | /* Tx queues */ | 277 | if (q->read_ptr > q->write_ptr) |
150 | for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) | 278 | s -= q->n_bd; |
151 | iwl_tx_queue_free(priv, &priv->txq[txq_id]); | ||
152 | 279 | ||
153 | /* Keep-warm buffer */ | 280 | if (s <= 0) |
154 | iwl_kw_free(priv); | 281 | s += q->n_window; |
282 | /* keep some reserve to not confuse empty and full situations */ | ||
283 | s -= 2; | ||
284 | if (s < 0) | ||
285 | s = 0; | ||
286 | return s; | ||
155 | } | 287 | } |
156 | EXPORT_SYMBOL(iwl_hw_txq_ctx_free); | 288 | EXPORT_SYMBOL(iwl_queue_space); |
289 | |||
157 | 290 | ||
158 | /** | 291 | /** |
159 | * iwl_queue_init - Initialize queue's high/low-water and read/write indexes | 292 | * iwl_queue_init - Initialize queue's high/low-water and read/write indexes |
160 | */ | 293 | */ |
161 | static int iwl_queue_init(struct iwl_priv *priv, struct iwl4965_queue *q, | 294 | static int iwl_queue_init(struct iwl_priv *priv, struct iwl_queue *q, |
162 | int count, int slots_num, u32 id) | 295 | int count, int slots_num, u32 id) |
163 | { | 296 | { |
164 | q->n_bd = count; | 297 | q->n_bd = count; |
@@ -312,6 +445,24 @@ static int iwl_tx_queue_init(struct iwl_priv *priv, | |||
312 | 445 | ||
313 | return 0; | 446 | return 0; |
314 | } | 447 | } |
448 | /** | ||
449 | * iwl_hw_txq_ctx_free - Free TXQ Context | ||
450 | * | ||
451 | * Destroy all TX DMA queues and structures | ||
452 | */ | ||
453 | void iwl_hw_txq_ctx_free(struct iwl_priv *priv) | ||
454 | { | ||
455 | int txq_id; | ||
456 | |||
457 | /* Tx queues */ | ||
458 | for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) | ||
459 | iwl_tx_queue_free(priv, &priv->txq[txq_id]); | ||
460 | |||
461 | /* Keep-warm buffer */ | ||
462 | iwl_kw_free(priv); | ||
463 | } | ||
464 | EXPORT_SYMBOL(iwl_hw_txq_ctx_free); | ||
465 | |||
315 | 466 | ||
316 | /** | 467 | /** |
317 | * iwl_txq_ctx_reset - Reset TX queue context | 468 | * iwl_txq_ctx_reset - Reset TX queue context |
@@ -324,6 +475,7 @@ int iwl_txq_ctx_reset(struct iwl_priv *priv) | |||
324 | { | 475 | { |
325 | int ret = 0; | 476 | int ret = 0; |
326 | int txq_id, slots_num; | 477 | int txq_id, slots_num; |
478 | unsigned long flags; | ||
327 | 479 | ||
328 | iwl_kw_free(priv); | 480 | iwl_kw_free(priv); |
329 | 481 | ||
@@ -336,11 +488,19 @@ int iwl_txq_ctx_reset(struct iwl_priv *priv) | |||
336 | IWL_ERROR("Keep Warm allocation failed"); | 488 | IWL_ERROR("Keep Warm allocation failed"); |
337 | goto error_kw; | 489 | goto error_kw; |
338 | } | 490 | } |
491 | spin_lock_irqsave(&priv->lock, flags); | ||
492 | ret = iwl_grab_nic_access(priv); | ||
493 | if (unlikely(ret)) { | ||
494 | spin_unlock_irqrestore(&priv->lock, flags); | ||
495 | goto error_reset; | ||
496 | } | ||
339 | 497 | ||
340 | /* Turn off all Tx DMA fifos */ | 498 | /* Turn off all Tx DMA fifos */ |
341 | ret = priv->cfg->ops->lib->disable_tx_fifo(priv); | 499 | priv->cfg->ops->lib->txq_set_sched(priv, 0); |
342 | if (unlikely(ret)) | 500 | |
343 | goto error_reset; | 501 | iwl_release_nic_access(priv); |
502 | spin_unlock_irqrestore(&priv->lock, flags); | ||
503 | |||
344 | 504 | ||
345 | /* Tell nic where to find the keep-warm buffer */ | 505 | /* Tell nic where to find the keep-warm buffer */ |
346 | ret = iwl_kw_init(priv); | 506 | ret = iwl_kw_init(priv); |
@@ -349,8 +509,7 @@ int iwl_txq_ctx_reset(struct iwl_priv *priv) | |||
349 | goto error_reset; | 509 | goto error_reset; |
350 | } | 510 | } |
351 | 511 | ||
352 | /* Alloc and init all (default 16) Tx queues, | 512 | /* Alloc and init all Tx queues, including the command queue (#4) */ |
353 | * including the command queue (#4) */ | ||
354 | for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) { | 513 | for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) { |
355 | slots_num = (txq_id == IWL_CMD_QUEUE_NUM) ? | 514 | slots_num = (txq_id == IWL_CMD_QUEUE_NUM) ? |
356 | TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; | 515 | TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; |
@@ -371,3 +530,864 @@ int iwl_txq_ctx_reset(struct iwl_priv *priv) | |||
371 | error_kw: | 530 | error_kw: |
372 | return ret; | 531 | return ret; |
373 | } | 532 | } |
533 | /** | ||
534 | * iwl_txq_ctx_stop - Stop all Tx DMA channels, free Tx queue memory | ||
535 | */ | ||
536 | void iwl_txq_ctx_stop(struct iwl_priv *priv) | ||
537 | { | ||
538 | |||
539 | int txq_id; | ||
540 | unsigned long flags; | ||
541 | |||
542 | |||
543 | /* Turn off all Tx DMA fifos */ | ||
544 | spin_lock_irqsave(&priv->lock, flags); | ||
545 | if (iwl_grab_nic_access(priv)) { | ||
546 | spin_unlock_irqrestore(&priv->lock, flags); | ||
547 | return; | ||
548 | } | ||
549 | |||
550 | priv->cfg->ops->lib->txq_set_sched(priv, 0); | ||
551 | |||
552 | /* Stop each Tx DMA channel, and wait for it to be idle */ | ||
553 | for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) { | ||
554 | iwl_write_direct32(priv, | ||
555 | FH_TCSR_CHNL_TX_CONFIG_REG(txq_id), 0x0); | ||
556 | iwl_poll_direct_bit(priv, FH_TSSR_TX_STATUS_REG, | ||
557 | FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE | ||
558 | (txq_id), 200); | ||
559 | } | ||
560 | iwl_release_nic_access(priv); | ||
561 | spin_unlock_irqrestore(&priv->lock, flags); | ||
562 | |||
563 | /* Deallocate memory for all Tx queues */ | ||
564 | iwl_hw_txq_ctx_free(priv); | ||
565 | } | ||
566 | EXPORT_SYMBOL(iwl_txq_ctx_stop); | ||
567 | |||
568 | /* | ||
569 | * handle build REPLY_TX command notification. | ||
570 | */ | ||
571 | static void iwl_tx_cmd_build_basic(struct iwl_priv *priv, | ||
572 | struct iwl_tx_cmd *tx_cmd, | ||
573 | struct ieee80211_tx_info *info, | ||
574 | struct ieee80211_hdr *hdr, | ||
575 | int is_unicast, u8 std_id) | ||
576 | { | ||
577 | u16 fc = le16_to_cpu(hdr->frame_control); | ||
578 | __le32 tx_flags = tx_cmd->tx_flags; | ||
579 | |||
580 | tx_cmd->stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; | ||
581 | if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) { | ||
582 | tx_flags |= TX_CMD_FLG_ACK_MSK; | ||
583 | if ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) | ||
584 | tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; | ||
585 | if (ieee80211_is_probe_response(fc) && | ||
586 | !(le16_to_cpu(hdr->seq_ctrl) & 0xf)) | ||
587 | tx_flags |= TX_CMD_FLG_TSF_MSK; | ||
588 | } else { | ||
589 | tx_flags &= (~TX_CMD_FLG_ACK_MSK); | ||
590 | tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; | ||
591 | } | ||
592 | |||
593 | if (ieee80211_is_back_request(fc)) | ||
594 | tx_flags |= TX_CMD_FLG_ACK_MSK | TX_CMD_FLG_IMM_BA_RSP_MASK; | ||
595 | |||
596 | |||
597 | tx_cmd->sta_id = std_id; | ||
598 | if (ieee80211_get_morefrag(hdr)) | ||
599 | tx_flags |= TX_CMD_FLG_MORE_FRAG_MSK; | ||
600 | |||
601 | if (ieee80211_is_qos_data(fc)) { | ||
602 | u8 *qc = ieee80211_get_qos_ctrl(hdr, ieee80211_get_hdrlen(fc)); | ||
603 | tx_cmd->tid_tspec = qc[0] & 0xf; | ||
604 | tx_flags &= ~TX_CMD_FLG_SEQ_CTL_MSK; | ||
605 | } else { | ||
606 | tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; | ||
607 | } | ||
608 | |||
609 | if (info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) { | ||
610 | tx_flags |= TX_CMD_FLG_RTS_MSK; | ||
611 | tx_flags &= ~TX_CMD_FLG_CTS_MSK; | ||
612 | } else if (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) { | ||
613 | tx_flags &= ~TX_CMD_FLG_RTS_MSK; | ||
614 | tx_flags |= TX_CMD_FLG_CTS_MSK; | ||
615 | } | ||
616 | |||
617 | if ((tx_flags & TX_CMD_FLG_RTS_MSK) || (tx_flags & TX_CMD_FLG_CTS_MSK)) | ||
618 | tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK; | ||
619 | |||
620 | tx_flags &= ~(TX_CMD_FLG_ANT_SEL_MSK); | ||
621 | if ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) { | ||
622 | if ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_ASSOC_REQ || | ||
623 | (fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_REASSOC_REQ) | ||
624 | tx_cmd->timeout.pm_frame_timeout = cpu_to_le16(3); | ||
625 | else | ||
626 | tx_cmd->timeout.pm_frame_timeout = cpu_to_le16(2); | ||
627 | } else { | ||
628 | tx_cmd->timeout.pm_frame_timeout = 0; | ||
629 | } | ||
630 | |||
631 | tx_cmd->driver_txop = 0; | ||
632 | tx_cmd->tx_flags = tx_flags; | ||
633 | tx_cmd->next_frame_len = 0; | ||
634 | } | ||
635 | |||
636 | #define RTS_HCCA_RETRY_LIMIT 3 | ||
637 | #define RTS_DFAULT_RETRY_LIMIT 60 | ||
638 | |||
639 | static void iwl_tx_cmd_build_rate(struct iwl_priv *priv, | ||
640 | struct iwl_tx_cmd *tx_cmd, | ||
641 | struct ieee80211_tx_info *info, | ||
642 | u16 fc, int sta_id, | ||
643 | int is_hcca) | ||
644 | { | ||
645 | u8 rts_retry_limit = 0; | ||
646 | u8 data_retry_limit = 0; | ||
647 | u8 rate_plcp; | ||
648 | u16 rate_flags = 0; | ||
649 | int rate_idx; | ||
650 | |||
651 | rate_idx = min(ieee80211_get_tx_rate(priv->hw, info)->hw_value & 0xffff, | ||
652 | IWL_RATE_COUNT - 1); | ||
653 | |||
654 | rate_plcp = iwl_rates[rate_idx].plcp; | ||
655 | |||
656 | rts_retry_limit = (is_hcca) ? | ||
657 | RTS_HCCA_RETRY_LIMIT : RTS_DFAULT_RETRY_LIMIT; | ||
658 | |||
659 | if ((rate_idx >= IWL_FIRST_CCK_RATE) && (rate_idx <= IWL_LAST_CCK_RATE)) | ||
660 | rate_flags |= RATE_MCS_CCK_MSK; | ||
661 | |||
662 | |||
663 | if (ieee80211_is_probe_response(fc)) { | ||
664 | data_retry_limit = 3; | ||
665 | if (data_retry_limit < rts_retry_limit) | ||
666 | rts_retry_limit = data_retry_limit; | ||
667 | } else | ||
668 | data_retry_limit = IWL_DEFAULT_TX_RETRY; | ||
669 | |||
670 | if (priv->data_retry_limit != -1) | ||
671 | data_retry_limit = priv->data_retry_limit; | ||
672 | |||
673 | |||
674 | if (ieee80211_is_data(fc)) { | ||
675 | tx_cmd->initial_rate_index = 0; | ||
676 | tx_cmd->tx_flags |= TX_CMD_FLG_STA_RATE_MSK; | ||
677 | } else { | ||
678 | switch (fc & IEEE80211_FCTL_STYPE) { | ||
679 | case IEEE80211_STYPE_AUTH: | ||
680 | case IEEE80211_STYPE_DEAUTH: | ||
681 | case IEEE80211_STYPE_ASSOC_REQ: | ||
682 | case IEEE80211_STYPE_REASSOC_REQ: | ||
683 | if (tx_cmd->tx_flags & TX_CMD_FLG_RTS_MSK) { | ||
684 | tx_cmd->tx_flags &= ~TX_CMD_FLG_RTS_MSK; | ||
685 | tx_cmd->tx_flags |= TX_CMD_FLG_CTS_MSK; | ||
686 | } | ||
687 | break; | ||
688 | default: | ||
689 | break; | ||
690 | } | ||
691 | |||
692 | /* Alternate between antenna A and B for successive frames */ | ||
693 | if (priv->use_ant_b_for_management_frame) { | ||
694 | priv->use_ant_b_for_management_frame = 0; | ||
695 | rate_flags |= RATE_MCS_ANT_B_MSK; | ||
696 | } else { | ||
697 | priv->use_ant_b_for_management_frame = 1; | ||
698 | rate_flags |= RATE_MCS_ANT_A_MSK; | ||
699 | } | ||
700 | } | ||
701 | |||
702 | tx_cmd->rts_retry_limit = rts_retry_limit; | ||
703 | tx_cmd->data_retry_limit = data_retry_limit; | ||
704 | tx_cmd->rate_n_flags = iwl4965_hw_set_rate_n_flags(rate_plcp, rate_flags); | ||
705 | } | ||
706 | |||
707 | static void iwl_tx_cmd_build_hwcrypto(struct iwl_priv *priv, | ||
708 | struct ieee80211_tx_info *info, | ||
709 | struct iwl_tx_cmd *tx_cmd, | ||
710 | struct sk_buff *skb_frag, | ||
711 | int sta_id) | ||
712 | { | ||
713 | struct ieee80211_key_conf *keyconf = info->control.hw_key; | ||
714 | |||
715 | switch (keyconf->alg) { | ||
716 | case ALG_CCMP: | ||
717 | tx_cmd->sec_ctl = TX_CMD_SEC_CCM; | ||
718 | memcpy(tx_cmd->key, keyconf->key, keyconf->keylen); | ||
719 | if (info->flags & IEEE80211_TX_CTL_AMPDU) | ||
720 | tx_cmd->tx_flags |= TX_CMD_FLG_AGG_CCMP_MSK; | ||
721 | IWL_DEBUG_TX("tx_cmd with aes hwcrypto\n"); | ||
722 | break; | ||
723 | |||
724 | case ALG_TKIP: | ||
725 | tx_cmd->sec_ctl = TX_CMD_SEC_TKIP; | ||
726 | ieee80211_get_tkip_key(keyconf, skb_frag, | ||
727 | IEEE80211_TKIP_P2_KEY, tx_cmd->key); | ||
728 | IWL_DEBUG_TX("tx_cmd with tkip hwcrypto\n"); | ||
729 | break; | ||
730 | |||
731 | case ALG_WEP: | ||
732 | tx_cmd->sec_ctl |= (TX_CMD_SEC_WEP | | ||
733 | (keyconf->keyidx & TX_CMD_SEC_MSK) << TX_CMD_SEC_SHIFT); | ||
734 | |||
735 | if (keyconf->keylen == WEP_KEY_LEN_128) | ||
736 | tx_cmd->sec_ctl |= TX_CMD_SEC_KEY128; | ||
737 | |||
738 | memcpy(&tx_cmd->key[3], keyconf->key, keyconf->keylen); | ||
739 | |||
740 | IWL_DEBUG_TX("Configuring packet for WEP encryption " | ||
741 | "with key %d\n", keyconf->keyidx); | ||
742 | break; | ||
743 | |||
744 | default: | ||
745 | printk(KERN_ERR "Unknown encode alg %d\n", keyconf->alg); | ||
746 | break; | ||
747 | } | ||
748 | } | ||
749 | |||
750 | static void iwl_update_tx_stats(struct iwl_priv *priv, u16 fc, u16 len) | ||
751 | { | ||
752 | /* 0 - mgmt, 1 - cnt, 2 - data */ | ||
753 | int idx = (fc & IEEE80211_FCTL_FTYPE) >> 2; | ||
754 | priv->tx_stats[idx].cnt++; | ||
755 | priv->tx_stats[idx].bytes += len; | ||
756 | } | ||
757 | |||
758 | /* | ||
759 | * start REPLY_TX command process | ||
760 | */ | ||
761 | int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) | ||
762 | { | ||
763 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; | ||
764 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
765 | struct iwl_tfd_frame *tfd; | ||
766 | u32 *control_flags; | ||
767 | int txq_id = skb_get_queue_mapping(skb); | ||
768 | struct iwl_tx_queue *txq = NULL; | ||
769 | struct iwl_queue *q = NULL; | ||
770 | dma_addr_t phys_addr; | ||
771 | dma_addr_t txcmd_phys; | ||
772 | dma_addr_t scratch_phys; | ||
773 | struct iwl_cmd *out_cmd = NULL; | ||
774 | struct iwl_tx_cmd *tx_cmd; | ||
775 | u16 len, idx, len_org; | ||
776 | u16 seq_number = 0; | ||
777 | u8 id, hdr_len, unicast; | ||
778 | u8 sta_id; | ||
779 | u16 fc; | ||
780 | u8 wait_write_ptr = 0; | ||
781 | u8 tid = 0; | ||
782 | u8 *qc = NULL; | ||
783 | unsigned long flags; | ||
784 | int ret; | ||
785 | |||
786 | spin_lock_irqsave(&priv->lock, flags); | ||
787 | if (iwl_is_rfkill(priv)) { | ||
788 | IWL_DEBUG_DROP("Dropping - RF KILL\n"); | ||
789 | goto drop_unlock; | ||
790 | } | ||
791 | |||
792 | if (!priv->vif) { | ||
793 | IWL_DEBUG_DROP("Dropping - !priv->vif\n"); | ||
794 | goto drop_unlock; | ||
795 | } | ||
796 | |||
797 | if ((ieee80211_get_tx_rate(priv->hw, info)->hw_value & 0xFF) == | ||
798 | IWL_INVALID_RATE) { | ||
799 | IWL_ERROR("ERROR: No TX rate available.\n"); | ||
800 | goto drop_unlock; | ||
801 | } | ||
802 | |||
803 | unicast = !is_multicast_ether_addr(hdr->addr1); | ||
804 | id = 0; | ||
805 | |||
806 | fc = le16_to_cpu(hdr->frame_control); | ||
807 | |||
808 | #ifdef CONFIG_IWLWIFI_DEBUG | ||
809 | if (ieee80211_is_auth(fc)) | ||
810 | IWL_DEBUG_TX("Sending AUTH frame\n"); | ||
811 | else if (ieee80211_is_assoc_request(fc)) | ||
812 | IWL_DEBUG_TX("Sending ASSOC frame\n"); | ||
813 | else if (ieee80211_is_reassoc_request(fc)) | ||
814 | IWL_DEBUG_TX("Sending REASSOC frame\n"); | ||
815 | #endif | ||
816 | |||
817 | /* drop all data frame if we are not associated */ | ||
818 | if (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) && | ||
819 | (!iwl_is_associated(priv) || | ||
820 | ((priv->iw_mode == IEEE80211_IF_TYPE_STA) && !priv->assoc_id) || | ||
821 | !priv->assoc_station_added)) { | ||
822 | IWL_DEBUG_DROP("Dropping - !iwl_is_associated\n"); | ||
823 | goto drop_unlock; | ||
824 | } | ||
825 | |||
826 | spin_unlock_irqrestore(&priv->lock, flags); | ||
827 | |||
828 | hdr_len = ieee80211_get_hdrlen(fc); | ||
829 | |||
830 | /* Find (or create) index into station table for destination station */ | ||
831 | sta_id = iwl_get_sta_id(priv, hdr); | ||
832 | if (sta_id == IWL_INVALID_STATION) { | ||
833 | DECLARE_MAC_BUF(mac); | ||
834 | |||
835 | IWL_DEBUG_DROP("Dropping - INVALID STATION: %s\n", | ||
836 | print_mac(mac, hdr->addr1)); | ||
837 | goto drop; | ||
838 | } | ||
839 | |||
840 | IWL_DEBUG_TX("station Id %d\n", sta_id); | ||
841 | |||
842 | if (ieee80211_is_qos_data(fc)) { | ||
843 | qc = ieee80211_get_qos_ctrl(hdr, hdr_len); | ||
844 | tid = qc[0] & 0xf; | ||
845 | seq_number = priv->stations[sta_id].tid[tid].seq_number & | ||
846 | IEEE80211_SCTL_SEQ; | ||
847 | hdr->seq_ctrl = cpu_to_le16(seq_number) | | ||
848 | (hdr->seq_ctrl & | ||
849 | __constant_cpu_to_le16(IEEE80211_SCTL_FRAG)); | ||
850 | seq_number += 0x10; | ||
851 | #ifdef CONFIG_IWL4965_HT | ||
852 | /* aggregation is on for this <sta,tid> */ | ||
853 | if (info->flags & IEEE80211_TX_CTL_AMPDU) | ||
854 | txq_id = priv->stations[sta_id].tid[tid].agg.txq_id; | ||
855 | priv->stations[sta_id].tid[tid].tfds_in_queue++; | ||
856 | #endif /* CONFIG_IWL4965_HT */ | ||
857 | } | ||
858 | |||
859 | /* Descriptor for chosen Tx queue */ | ||
860 | txq = &priv->txq[txq_id]; | ||
861 | q = &txq->q; | ||
862 | |||
863 | spin_lock_irqsave(&priv->lock, flags); | ||
864 | |||
865 | /* Set up first empty TFD within this queue's circular TFD buffer */ | ||
866 | tfd = &txq->bd[q->write_ptr]; | ||
867 | memset(tfd, 0, sizeof(*tfd)); | ||
868 | control_flags = (u32 *) tfd; | ||
869 | idx = get_cmd_index(q, q->write_ptr, 0); | ||
870 | |||
871 | /* Set up driver data for this TFD */ | ||
872 | memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct iwl_tx_info)); | ||
873 | txq->txb[q->write_ptr].skb[0] = skb; | ||
874 | |||
875 | /* Set up first empty entry in queue's array of Tx/cmd buffers */ | ||
876 | out_cmd = &txq->cmd[idx]; | ||
877 | tx_cmd = &out_cmd->cmd.tx; | ||
878 | memset(&out_cmd->hdr, 0, sizeof(out_cmd->hdr)); | ||
879 | memset(tx_cmd, 0, sizeof(struct iwl_tx_cmd)); | ||
880 | |||
881 | /* | ||
882 | * Set up the Tx-command (not MAC!) header. | ||
883 | * Store the chosen Tx queue and TFD index within the sequence field; | ||
884 | * after Tx, uCode's Tx response will return this value so driver can | ||
885 | * locate the frame within the tx queue and do post-tx processing. | ||
886 | */ | ||
887 | out_cmd->hdr.cmd = REPLY_TX; | ||
888 | out_cmd->hdr.sequence = cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) | | ||
889 | INDEX_TO_SEQ(q->write_ptr))); | ||
890 | |||
891 | /* Copy MAC header from skb into command buffer */ | ||
892 | memcpy(tx_cmd->hdr, hdr, hdr_len); | ||
893 | |||
894 | /* | ||
895 | * Use the first empty entry in this queue's command buffer array | ||
896 | * to contain the Tx command and MAC header concatenated together | ||
897 | * (payload data will be in another buffer). | ||
898 | * Size of this varies, due to varying MAC header length. | ||
899 | * If end is not dword aligned, we'll have 2 extra bytes at the end | ||
900 | * of the MAC header (device reads on dword boundaries). | ||
901 | * We'll tell device about this padding later. | ||
902 | */ | ||
903 | len = sizeof(struct iwl_tx_cmd) + | ||
904 | sizeof(struct iwl_cmd_header) + hdr_len; | ||
905 | |||
906 | len_org = len; | ||
907 | len = (len + 3) & ~3; | ||
908 | |||
909 | if (len_org != len) | ||
910 | len_org = 1; | ||
911 | else | ||
912 | len_org = 0; | ||
913 | |||
914 | /* Physical address of this Tx command's header (not MAC header!), | ||
915 | * within command buffer array. */ | ||
916 | txcmd_phys = txq->dma_addr_cmd + sizeof(struct iwl_cmd) * idx + | ||
917 | offsetof(struct iwl_cmd, hdr); | ||
918 | |||
919 | /* Add buffer containing Tx command and MAC(!) header to TFD's | ||
920 | * first entry */ | ||
921 | iwl_hw_txq_attach_buf_to_tfd(priv, tfd, txcmd_phys, len); | ||
922 | |||
923 | if (!(info->flags & IEEE80211_TX_CTL_DO_NOT_ENCRYPT)) | ||
924 | iwl_tx_cmd_build_hwcrypto(priv, info, tx_cmd, skb, sta_id); | ||
925 | |||
926 | /* Set up TFD's 2nd entry to point directly to remainder of skb, | ||
927 | * if any (802.11 null frames have no payload). */ | ||
928 | len = skb->len - hdr_len; | ||
929 | if (len) { | ||
930 | phys_addr = pci_map_single(priv->pci_dev, skb->data + hdr_len, | ||
931 | len, PCI_DMA_TODEVICE); | ||
932 | iwl_hw_txq_attach_buf_to_tfd(priv, tfd, phys_addr, len); | ||
933 | } | ||
934 | |||
935 | /* Tell NIC about any 2-byte padding after MAC header */ | ||
936 | if (len_org) | ||
937 | tx_cmd->tx_flags |= TX_CMD_FLG_MH_PAD_MSK; | ||
938 | |||
939 | /* Total # bytes to be transmitted */ | ||
940 | len = (u16)skb->len; | ||
941 | tx_cmd->len = cpu_to_le16(len); | ||
942 | /* TODO need this for burst mode later on */ | ||
943 | iwl_tx_cmd_build_basic(priv, tx_cmd, info, hdr, unicast, sta_id); | ||
944 | |||
945 | /* set is_hcca to 0; it probably will never be implemented */ | ||
946 | iwl_tx_cmd_build_rate(priv, tx_cmd, info, fc, sta_id, 0); | ||
947 | |||
948 | iwl_update_tx_stats(priv, fc, len); | ||
949 | |||
950 | scratch_phys = txcmd_phys + sizeof(struct iwl_cmd_header) + | ||
951 | offsetof(struct iwl_tx_cmd, scratch); | ||
952 | tx_cmd->dram_lsb_ptr = cpu_to_le32(scratch_phys); | ||
953 | tx_cmd->dram_msb_ptr = iwl_get_dma_hi_address(scratch_phys); | ||
954 | |||
955 | if (!ieee80211_get_morefrag(hdr)) { | ||
956 | txq->need_update = 1; | ||
957 | if (qc) | ||
958 | priv->stations[sta_id].tid[tid].seq_number = seq_number; | ||
959 | } else { | ||
960 | wait_write_ptr = 1; | ||
961 | txq->need_update = 0; | ||
962 | } | ||
963 | |||
964 | iwl_print_hex_dump(priv, IWL_DL_TX, (u8 *)tx_cmd, sizeof(*tx_cmd)); | ||
965 | |||
966 | iwl_print_hex_dump(priv, IWL_DL_TX, (u8 *)tx_cmd->hdr, hdr_len); | ||
967 | |||
968 | /* Set up entry for this TFD in Tx byte-count array */ | ||
969 | priv->cfg->ops->lib->txq_update_byte_cnt_tbl(priv, txq, len); | ||
970 | |||
971 | /* Tell device the write index *just past* this latest filled TFD */ | ||
972 | q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd); | ||
973 | ret = iwl_txq_update_write_ptr(priv, txq); | ||
974 | spin_unlock_irqrestore(&priv->lock, flags); | ||
975 | |||
976 | if (ret) | ||
977 | return ret; | ||
978 | |||
979 | if ((iwl_queue_space(q) < q->high_mark) | ||
980 | && priv->mac80211_registered) { | ||
981 | if (wait_write_ptr) { | ||
982 | spin_lock_irqsave(&priv->lock, flags); | ||
983 | txq->need_update = 1; | ||
984 | iwl_txq_update_write_ptr(priv, txq); | ||
985 | spin_unlock_irqrestore(&priv->lock, flags); | ||
986 | } | ||
987 | |||
988 | ieee80211_stop_queue(priv->hw, skb_get_queue_mapping(skb)); | ||
989 | } | ||
990 | |||
991 | return 0; | ||
992 | |||
993 | drop_unlock: | ||
994 | spin_unlock_irqrestore(&priv->lock, flags); | ||
995 | drop: | ||
996 | return -1; | ||
997 | } | ||
998 | EXPORT_SYMBOL(iwl_tx_skb); | ||
999 | |||
1000 | /*************** HOST COMMAND QUEUE FUNCTIONS *****/ | ||
1001 | |||
1002 | /** | ||
1003 | * iwl_enqueue_hcmd - enqueue a uCode command | ||
1004 | * @priv: device private data point | ||
1005 | * @cmd: a point to the ucode command structure | ||
1006 | * | ||
1007 | * The function returns < 0 values to indicate the operation is | ||
1008 | * failed. On success, it turns the index (> 0) of command in the | ||
1009 | * command queue. | ||
1010 | */ | ||
1011 | int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd) | ||
1012 | { | ||
1013 | struct iwl_tx_queue *txq = &priv->txq[IWL_CMD_QUEUE_NUM]; | ||
1014 | struct iwl_queue *q = &txq->q; | ||
1015 | struct iwl_tfd_frame *tfd; | ||
1016 | u32 *control_flags; | ||
1017 | struct iwl_cmd *out_cmd; | ||
1018 | u32 idx; | ||
1019 | u16 fix_size; | ||
1020 | dma_addr_t phys_addr; | ||
1021 | int ret; | ||
1022 | unsigned long flags; | ||
1023 | |||
1024 | cmd->len = priv->cfg->ops->utils->get_hcmd_size(cmd->id, cmd->len); | ||
1025 | fix_size = (u16)(cmd->len + sizeof(out_cmd->hdr)); | ||
1026 | |||
1027 | /* If any of the command structures end up being larger than | ||
1028 | * the TFD_MAX_PAYLOAD_SIZE, and it sent as a 'small' command then | ||
1029 | * we will need to increase the size of the TFD entries */ | ||
1030 | BUG_ON((fix_size > TFD_MAX_PAYLOAD_SIZE) && | ||
1031 | !(cmd->meta.flags & CMD_SIZE_HUGE)); | ||
1032 | |||
1033 | if (iwl_is_rfkill(priv)) { | ||
1034 | IWL_DEBUG_INFO("Not sending command - RF KILL"); | ||
1035 | return -EIO; | ||
1036 | } | ||
1037 | |||
1038 | if (iwl_queue_space(q) < ((cmd->meta.flags & CMD_ASYNC) ? 2 : 1)) { | ||
1039 | IWL_ERROR("No space for Tx\n"); | ||
1040 | return -ENOSPC; | ||
1041 | } | ||
1042 | |||
1043 | spin_lock_irqsave(&priv->hcmd_lock, flags); | ||
1044 | |||
1045 | tfd = &txq->bd[q->write_ptr]; | ||
1046 | memset(tfd, 0, sizeof(*tfd)); | ||
1047 | |||
1048 | control_flags = (u32 *) tfd; | ||
1049 | |||
1050 | idx = get_cmd_index(q, q->write_ptr, cmd->meta.flags & CMD_SIZE_HUGE); | ||
1051 | out_cmd = &txq->cmd[idx]; | ||
1052 | |||
1053 | out_cmd->hdr.cmd = cmd->id; | ||
1054 | memcpy(&out_cmd->meta, &cmd->meta, sizeof(cmd->meta)); | ||
1055 | memcpy(&out_cmd->cmd.payload, cmd->data, cmd->len); | ||
1056 | |||
1057 | /* At this point, the out_cmd now has all of the incoming cmd | ||
1058 | * information */ | ||
1059 | |||
1060 | out_cmd->hdr.flags = 0; | ||
1061 | out_cmd->hdr.sequence = cpu_to_le16(QUEUE_TO_SEQ(IWL_CMD_QUEUE_NUM) | | ||
1062 | INDEX_TO_SEQ(q->write_ptr)); | ||
1063 | if (out_cmd->meta.flags & CMD_SIZE_HUGE) | ||
1064 | out_cmd->hdr.sequence |= cpu_to_le16(SEQ_HUGE_FRAME); | ||
1065 | |||
1066 | phys_addr = txq->dma_addr_cmd + sizeof(txq->cmd[0]) * idx + | ||
1067 | offsetof(struct iwl_cmd, hdr); | ||
1068 | iwl_hw_txq_attach_buf_to_tfd(priv, tfd, phys_addr, fix_size); | ||
1069 | |||
1070 | IWL_DEBUG_HC("Sending command %s (#%x), seq: 0x%04X, " | ||
1071 | "%d bytes at %d[%d]:%d\n", | ||
1072 | get_cmd_string(out_cmd->hdr.cmd), | ||
1073 | out_cmd->hdr.cmd, le16_to_cpu(out_cmd->hdr.sequence), | ||
1074 | fix_size, q->write_ptr, idx, IWL_CMD_QUEUE_NUM); | ||
1075 | |||
1076 | txq->need_update = 1; | ||
1077 | |||
1078 | /* Set up entry in queue's byte count circular buffer */ | ||
1079 | priv->cfg->ops->lib->txq_update_byte_cnt_tbl(priv, txq, 0); | ||
1080 | |||
1081 | /* Increment and update queue's write index */ | ||
1082 | q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd); | ||
1083 | ret = iwl_txq_update_write_ptr(priv, txq); | ||
1084 | |||
1085 | spin_unlock_irqrestore(&priv->hcmd_lock, flags); | ||
1086 | return ret ? ret : idx; | ||
1087 | } | ||
1088 | |||
1089 | int iwl_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index) | ||
1090 | { | ||
1091 | struct iwl_tx_queue *txq = &priv->txq[txq_id]; | ||
1092 | struct iwl_queue *q = &txq->q; | ||
1093 | struct iwl_tx_info *tx_info; | ||
1094 | int nfreed = 0; | ||
1095 | |||
1096 | if ((index >= q->n_bd) || (iwl_queue_used(q, index) == 0)) { | ||
1097 | IWL_ERROR("Read index for DMA queue txq id (%d), index %d, " | ||
1098 | "is out of range [0-%d] %d %d.\n", txq_id, | ||
1099 | index, q->n_bd, q->write_ptr, q->read_ptr); | ||
1100 | return 0; | ||
1101 | } | ||
1102 | |||
1103 | for (index = iwl_queue_inc_wrap(index, q->n_bd); q->read_ptr != index; | ||
1104 | q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) { | ||
1105 | |||
1106 | tx_info = &txq->txb[txq->q.read_ptr]; | ||
1107 | ieee80211_tx_status_irqsafe(priv->hw, tx_info->skb[0]); | ||
1108 | tx_info->skb[0] = NULL; | ||
1109 | |||
1110 | if (priv->cfg->ops->lib->txq_inval_byte_cnt_tbl) | ||
1111 | priv->cfg->ops->lib->txq_inval_byte_cnt_tbl(priv, txq); | ||
1112 | |||
1113 | iwl_hw_txq_free_tfd(priv, txq); | ||
1114 | nfreed++; | ||
1115 | } | ||
1116 | return nfreed; | ||
1117 | } | ||
1118 | EXPORT_SYMBOL(iwl_tx_queue_reclaim); | ||
1119 | |||
1120 | |||
1121 | /** | ||
1122 | * iwl_hcmd_queue_reclaim - Reclaim TX command queue entries already Tx'd | ||
1123 | * | ||
1124 | * When FW advances 'R' index, all entries between old and new 'R' index | ||
1125 | * need to be reclaimed. As result, some free space forms. If there is | ||
1126 | * enough free space (> low mark), wake the stack that feeds us. | ||
1127 | */ | ||
1128 | static void iwl_hcmd_queue_reclaim(struct iwl_priv *priv, int txq_id, int index) | ||
1129 | { | ||
1130 | struct iwl_tx_queue *txq = &priv->txq[txq_id]; | ||
1131 | struct iwl_queue *q = &txq->q; | ||
1132 | int nfreed = 0; | ||
1133 | |||
1134 | if ((index >= q->n_bd) || (iwl_queue_used(q, index) == 0)) { | ||
1135 | IWL_ERROR("Read index for DMA queue txq id (%d), index %d, " | ||
1136 | "is out of range [0-%d] %d %d.\n", txq_id, | ||
1137 | index, q->n_bd, q->write_ptr, q->read_ptr); | ||
1138 | return; | ||
1139 | } | ||
1140 | |||
1141 | for (index = iwl_queue_inc_wrap(index, q->n_bd); q->read_ptr != index; | ||
1142 | q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) { | ||
1143 | |||
1144 | if (nfreed > 1) { | ||
1145 | IWL_ERROR("HCMD skipped: index (%d) %d %d\n", index, | ||
1146 | q->write_ptr, q->read_ptr); | ||
1147 | queue_work(priv->workqueue, &priv->restart); | ||
1148 | } | ||
1149 | nfreed++; | ||
1150 | } | ||
1151 | } | ||
1152 | |||
1153 | /** | ||
1154 | * iwl_tx_cmd_complete - Pull unused buffers off the queue and reclaim them | ||
1155 | * @rxb: Rx buffer to reclaim | ||
1156 | * | ||
1157 | * If an Rx buffer has an async callback associated with it the callback | ||
1158 | * will be executed. The attached skb (if present) will only be freed | ||
1159 | * if the callback returns 1 | ||
1160 | */ | ||
1161 | void iwl_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) | ||
1162 | { | ||
1163 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; | ||
1164 | u16 sequence = le16_to_cpu(pkt->hdr.sequence); | ||
1165 | int txq_id = SEQ_TO_QUEUE(sequence); | ||
1166 | int index = SEQ_TO_INDEX(sequence); | ||
1167 | int huge = sequence & SEQ_HUGE_FRAME; | ||
1168 | int cmd_index; | ||
1169 | struct iwl_cmd *cmd; | ||
1170 | |||
1171 | /* If a Tx command is being handled and it isn't in the actual | ||
1172 | * command queue then there a command routing bug has been introduced | ||
1173 | * in the queue management code. */ | ||
1174 | if (txq_id != IWL_CMD_QUEUE_NUM) | ||
1175 | IWL_ERROR("Error wrong command queue %d command id 0x%X\n", | ||
1176 | txq_id, pkt->hdr.cmd); | ||
1177 | BUG_ON(txq_id != IWL_CMD_QUEUE_NUM); | ||
1178 | |||
1179 | cmd_index = get_cmd_index(&priv->txq[IWL_CMD_QUEUE_NUM].q, index, huge); | ||
1180 | cmd = &priv->txq[IWL_CMD_QUEUE_NUM].cmd[cmd_index]; | ||
1181 | |||
1182 | /* Input error checking is done when commands are added to queue. */ | ||
1183 | if (cmd->meta.flags & CMD_WANT_SKB) { | ||
1184 | cmd->meta.source->u.skb = rxb->skb; | ||
1185 | rxb->skb = NULL; | ||
1186 | } else if (cmd->meta.u.callback && | ||
1187 | !cmd->meta.u.callback(priv, cmd, rxb->skb)) | ||
1188 | rxb->skb = NULL; | ||
1189 | |||
1190 | iwl_hcmd_queue_reclaim(priv, txq_id, index); | ||
1191 | |||
1192 | if (!(cmd->meta.flags & CMD_ASYNC)) { | ||
1193 | clear_bit(STATUS_HCMD_ACTIVE, &priv->status); | ||
1194 | wake_up_interruptible(&priv->wait_command_queue); | ||
1195 | } | ||
1196 | } | ||
1197 | EXPORT_SYMBOL(iwl_tx_cmd_complete); | ||
1198 | |||
1199 | |||
1200 | #ifdef CONFIG_IWL4965_HT | ||
1201 | /* | ||
1202 | * Find first available (lowest unused) Tx Queue, mark it "active". | ||
1203 | * Called only when finding queue for aggregation. | ||
1204 | * Should never return anything < 7, because they should already | ||
1205 | * be in use as EDCA AC (0-3), Command (4), HCCA (5, 6). | ||
1206 | */ | ||
1207 | static int iwl_txq_ctx_activate_free(struct iwl_priv *priv) | ||
1208 | { | ||
1209 | int txq_id; | ||
1210 | |||
1211 | for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) | ||
1212 | if (!test_and_set_bit(txq_id, &priv->txq_ctx_active_msk)) | ||
1213 | return txq_id; | ||
1214 | return -1; | ||
1215 | } | ||
1216 | |||
1217 | int iwl_tx_agg_start(struct iwl_priv *priv, const u8 *ra, u16 tid, u16 *ssn) | ||
1218 | { | ||
1219 | int sta_id; | ||
1220 | int tx_fifo; | ||
1221 | int txq_id; | ||
1222 | int ret; | ||
1223 | unsigned long flags; | ||
1224 | struct iwl_tid_data *tid_data; | ||
1225 | DECLARE_MAC_BUF(mac); | ||
1226 | |||
1227 | if (likely(tid < ARRAY_SIZE(default_tid_to_tx_fifo))) | ||
1228 | tx_fifo = default_tid_to_tx_fifo[tid]; | ||
1229 | else | ||
1230 | return -EINVAL; | ||
1231 | |||
1232 | IWL_WARNING("%s on ra = %s tid = %d\n", | ||
1233 | __func__, print_mac(mac, ra), tid); | ||
1234 | |||
1235 | sta_id = iwl_find_station(priv, ra); | ||
1236 | if (sta_id == IWL_INVALID_STATION) | ||
1237 | return -ENXIO; | ||
1238 | |||
1239 | if (priv->stations[sta_id].tid[tid].agg.state != IWL_AGG_OFF) { | ||
1240 | IWL_ERROR("Start AGG when state is not IWL_AGG_OFF !\n"); | ||
1241 | return -ENXIO; | ||
1242 | } | ||
1243 | |||
1244 | txq_id = iwl_txq_ctx_activate_free(priv); | ||
1245 | if (txq_id == -1) | ||
1246 | return -ENXIO; | ||
1247 | |||
1248 | spin_lock_irqsave(&priv->sta_lock, flags); | ||
1249 | tid_data = &priv->stations[sta_id].tid[tid]; | ||
1250 | *ssn = SEQ_TO_SN(tid_data->seq_number); | ||
1251 | tid_data->agg.txq_id = txq_id; | ||
1252 | spin_unlock_irqrestore(&priv->sta_lock, flags); | ||
1253 | |||
1254 | ret = priv->cfg->ops->lib->txq_agg_enable(priv, txq_id, tx_fifo, | ||
1255 | sta_id, tid, *ssn); | ||
1256 | if (ret) | ||
1257 | return ret; | ||
1258 | |||
1259 | if (tid_data->tfds_in_queue == 0) { | ||
1260 | printk(KERN_ERR "HW queue is empty\n"); | ||
1261 | tid_data->agg.state = IWL_AGG_ON; | ||
1262 | ieee80211_start_tx_ba_cb_irqsafe(priv->hw, ra, tid); | ||
1263 | } else { | ||
1264 | IWL_DEBUG_HT("HW queue is NOT empty: %d packets in HW queue\n", | ||
1265 | tid_data->tfds_in_queue); | ||
1266 | tid_data->agg.state = IWL_EMPTYING_HW_QUEUE_ADDBA; | ||
1267 | } | ||
1268 | return ret; | ||
1269 | } | ||
1270 | EXPORT_SYMBOL(iwl_tx_agg_start); | ||
1271 | |||
1272 | int iwl_tx_agg_stop(struct iwl_priv *priv , const u8 *ra, u16 tid) | ||
1273 | { | ||
1274 | int tx_fifo_id, txq_id, sta_id, ssn = -1; | ||
1275 | struct iwl_tid_data *tid_data; | ||
1276 | int ret, write_ptr, read_ptr; | ||
1277 | unsigned long flags; | ||
1278 | DECLARE_MAC_BUF(mac); | ||
1279 | |||
1280 | if (!ra) { | ||
1281 | IWL_ERROR("ra = NULL\n"); | ||
1282 | return -EINVAL; | ||
1283 | } | ||
1284 | |||
1285 | if (likely(tid < ARRAY_SIZE(default_tid_to_tx_fifo))) | ||
1286 | tx_fifo_id = default_tid_to_tx_fifo[tid]; | ||
1287 | else | ||
1288 | return -EINVAL; | ||
1289 | |||
1290 | sta_id = iwl_find_station(priv, ra); | ||
1291 | |||
1292 | if (sta_id == IWL_INVALID_STATION) | ||
1293 | return -ENXIO; | ||
1294 | |||
1295 | if (priv->stations[sta_id].tid[tid].agg.state != IWL_AGG_ON) | ||
1296 | IWL_WARNING("Stopping AGG while state not IWL_AGG_ON\n"); | ||
1297 | |||
1298 | tid_data = &priv->stations[sta_id].tid[tid]; | ||
1299 | ssn = (tid_data->seq_number & IEEE80211_SCTL_SEQ) >> 4; | ||
1300 | txq_id = tid_data->agg.txq_id; | ||
1301 | write_ptr = priv->txq[txq_id].q.write_ptr; | ||
1302 | read_ptr = priv->txq[txq_id].q.read_ptr; | ||
1303 | |||
1304 | /* The queue is not empty */ | ||
1305 | if (write_ptr != read_ptr) { | ||
1306 | IWL_DEBUG_HT("Stopping a non empty AGG HW QUEUE\n"); | ||
1307 | priv->stations[sta_id].tid[tid].agg.state = | ||
1308 | IWL_EMPTYING_HW_QUEUE_DELBA; | ||
1309 | return 0; | ||
1310 | } | ||
1311 | |||
1312 | IWL_DEBUG_HT("HW queue is empty\n"); | ||
1313 | priv->stations[sta_id].tid[tid].agg.state = IWL_AGG_OFF; | ||
1314 | |||
1315 | spin_lock_irqsave(&priv->lock, flags); | ||
1316 | ret = priv->cfg->ops->lib->txq_agg_disable(priv, txq_id, ssn, | ||
1317 | tx_fifo_id); | ||
1318 | spin_unlock_irqrestore(&priv->lock, flags); | ||
1319 | |||
1320 | if (ret) | ||
1321 | return ret; | ||
1322 | |||
1323 | ieee80211_stop_tx_ba_cb_irqsafe(priv->hw, ra, tid); | ||
1324 | |||
1325 | return 0; | ||
1326 | } | ||
1327 | EXPORT_SYMBOL(iwl_tx_agg_stop); | ||
1328 | |||
1329 | int iwl_txq_check_empty(struct iwl_priv *priv, int sta_id, u8 tid, int txq_id) | ||
1330 | { | ||
1331 | struct iwl_queue *q = &priv->txq[txq_id].q; | ||
1332 | u8 *addr = priv->stations[sta_id].sta.sta.addr; | ||
1333 | struct iwl_tid_data *tid_data = &priv->stations[sta_id].tid[tid]; | ||
1334 | |||
1335 | switch (priv->stations[sta_id].tid[tid].agg.state) { | ||
1336 | case IWL_EMPTYING_HW_QUEUE_DELBA: | ||
1337 | /* We are reclaiming the last packet of the */ | ||
1338 | /* aggregated HW queue */ | ||
1339 | if (txq_id == tid_data->agg.txq_id && | ||
1340 | q->read_ptr == q->write_ptr) { | ||
1341 | u16 ssn = SEQ_TO_SN(tid_data->seq_number); | ||
1342 | int tx_fifo = default_tid_to_tx_fifo[tid]; | ||
1343 | IWL_DEBUG_HT("HW queue empty: continue DELBA flow\n"); | ||
1344 | priv->cfg->ops->lib->txq_agg_disable(priv, txq_id, | ||
1345 | ssn, tx_fifo); | ||
1346 | tid_data->agg.state = IWL_AGG_OFF; | ||
1347 | ieee80211_stop_tx_ba_cb_irqsafe(priv->hw, addr, tid); | ||
1348 | } | ||
1349 | break; | ||
1350 | case IWL_EMPTYING_HW_QUEUE_ADDBA: | ||
1351 | /* We are reclaiming the last packet of the queue */ | ||
1352 | if (tid_data->tfds_in_queue == 0) { | ||
1353 | IWL_DEBUG_HT("HW queue empty: continue ADDBA flow\n"); | ||
1354 | tid_data->agg.state = IWL_AGG_ON; | ||
1355 | ieee80211_start_tx_ba_cb_irqsafe(priv->hw, addr, tid); | ||
1356 | } | ||
1357 | break; | ||
1358 | } | ||
1359 | return 0; | ||
1360 | } | ||
1361 | EXPORT_SYMBOL(iwl_txq_check_empty); | ||
1362 | #endif /* CONFIG_IWL4965_HT */ | ||
1363 | |||
1364 | #ifdef CONFIG_IWLWIF_DEBUG | ||
1365 | #define TX_STATUS_ENTRY(x) case TX_STATUS_FAIL_ ## x: return #x | ||
1366 | |||
1367 | const char *iwl_get_tx_fail_reason(u32 status) | ||
1368 | { | ||
1369 | switch (status & TX_STATUS_MSK) { | ||
1370 | case TX_STATUS_SUCCESS: | ||
1371 | return "SUCCESS"; | ||
1372 | TX_STATUS_ENTRY(SHORT_LIMIT); | ||
1373 | TX_STATUS_ENTRY(LONG_LIMIT); | ||
1374 | TX_STATUS_ENTRY(FIFO_UNDERRUN); | ||
1375 | TX_STATUS_ENTRY(MGMNT_ABORT); | ||
1376 | TX_STATUS_ENTRY(NEXT_FRAG); | ||
1377 | TX_STATUS_ENTRY(LIFE_EXPIRE); | ||
1378 | TX_STATUS_ENTRY(DEST_PS); | ||
1379 | TX_STATUS_ENTRY(ABORTED); | ||
1380 | TX_STATUS_ENTRY(BT_RETRY); | ||
1381 | TX_STATUS_ENTRY(STA_INVALID); | ||
1382 | TX_STATUS_ENTRY(FRAG_DROPPED); | ||
1383 | TX_STATUS_ENTRY(TID_DISABLE); | ||
1384 | TX_STATUS_ENTRY(FRAME_FLUSHED); | ||
1385 | TX_STATUS_ENTRY(INSUFFICIENT_CF_POLL); | ||
1386 | TX_STATUS_ENTRY(TX_LOCKED); | ||
1387 | TX_STATUS_ENTRY(NO_BEACON_ON_RADAR); | ||
1388 | } | ||
1389 | |||
1390 | return "UNKNOWN"; | ||
1391 | } | ||
1392 | EXPORT_SYMBOL(iwl_get_tx_fail_reason); | ||
1393 | #endif /* CONFIG_IWLWIFI_DEBUG */ | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c index c1234ff4fc98..72279e07fe32 100644 --- a/drivers/net/wireless/iwlwifi/iwl3945-base.c +++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c | |||
@@ -102,16 +102,6 @@ MODULE_VERSION(DRV_VERSION); | |||
102 | MODULE_AUTHOR(DRV_COPYRIGHT); | 102 | MODULE_AUTHOR(DRV_COPYRIGHT); |
103 | MODULE_LICENSE("GPL"); | 103 | MODULE_LICENSE("GPL"); |
104 | 104 | ||
105 | static __le16 *ieee80211_get_qos_ctrl(struct ieee80211_hdr *hdr) | ||
106 | { | ||
107 | u16 fc = le16_to_cpu(hdr->frame_control); | ||
108 | int hdr_len = ieee80211_get_hdrlen(fc); | ||
109 | |||
110 | if ((fc & 0x00cc) == (IEEE80211_STYPE_QOS_DATA | IEEE80211_FTYPE_DATA)) | ||
111 | return (__le16 *) ((u8 *) hdr + hdr_len - QOS_CONTROL_LEN); | ||
112 | return NULL; | ||
113 | } | ||
114 | |||
115 | static const struct ieee80211_supported_band *iwl3945_get_band( | 105 | static const struct ieee80211_supported_band *iwl3945_get_band( |
116 | struct iwl3945_priv *priv, enum ieee80211_band band) | 106 | struct iwl3945_priv *priv, enum ieee80211_band band) |
117 | { | 107 | { |
@@ -2386,13 +2376,13 @@ static int iwl3945_set_mode(struct iwl3945_priv *priv, int mode) | |||
2386 | } | 2376 | } |
2387 | 2377 | ||
2388 | static void iwl3945_build_tx_cmd_hwcrypto(struct iwl3945_priv *priv, | 2378 | static void iwl3945_build_tx_cmd_hwcrypto(struct iwl3945_priv *priv, |
2389 | struct ieee80211_tx_control *ctl, | 2379 | struct ieee80211_tx_info *info, |
2390 | struct iwl3945_cmd *cmd, | 2380 | struct iwl3945_cmd *cmd, |
2391 | struct sk_buff *skb_frag, | 2381 | struct sk_buff *skb_frag, |
2392 | int last_frag) | 2382 | int last_frag) |
2393 | { | 2383 | { |
2394 | struct iwl3945_hw_key *keyinfo = | 2384 | struct iwl3945_hw_key *keyinfo = |
2395 | &priv->stations[ctl->hw_key->hw_key_idx].keyinfo; | 2385 | &priv->stations[info->control.hw_key->hw_key_idx].keyinfo; |
2396 | 2386 | ||
2397 | switch (keyinfo->alg) { | 2387 | switch (keyinfo->alg) { |
2398 | case ALG_CCMP: | 2388 | case ALG_CCMP: |
@@ -2415,7 +2405,7 @@ static void iwl3945_build_tx_cmd_hwcrypto(struct iwl3945_priv *priv, | |||
2415 | 2405 | ||
2416 | case ALG_WEP: | 2406 | case ALG_WEP: |
2417 | cmd->cmd.tx.sec_ctl = TX_CMD_SEC_WEP | | 2407 | cmd->cmd.tx.sec_ctl = TX_CMD_SEC_WEP | |
2418 | (ctl->hw_key->hw_key_idx & TX_CMD_SEC_MSK) << TX_CMD_SEC_SHIFT; | 2408 | (info->control.hw_key->hw_key_idx & TX_CMD_SEC_MSK) << TX_CMD_SEC_SHIFT; |
2419 | 2409 | ||
2420 | if (keyinfo->keylen == 13) | 2410 | if (keyinfo->keylen == 13) |
2421 | cmd->cmd.tx.sec_ctl |= TX_CMD_SEC_KEY128; | 2411 | cmd->cmd.tx.sec_ctl |= TX_CMD_SEC_KEY128; |
@@ -2423,7 +2413,7 @@ static void iwl3945_build_tx_cmd_hwcrypto(struct iwl3945_priv *priv, | |||
2423 | memcpy(&cmd->cmd.tx.key[3], keyinfo->key, keyinfo->keylen); | 2413 | memcpy(&cmd->cmd.tx.key[3], keyinfo->key, keyinfo->keylen); |
2424 | 2414 | ||
2425 | IWL_DEBUG_TX("Configuring packet for WEP encryption " | 2415 | IWL_DEBUG_TX("Configuring packet for WEP encryption " |
2426 | "with key %d\n", ctl->hw_key->hw_key_idx); | 2416 | "with key %d\n", info->control.hw_key->hw_key_idx); |
2427 | break; | 2417 | break; |
2428 | 2418 | ||
2429 | default: | 2419 | default: |
@@ -2437,16 +2427,15 @@ static void iwl3945_build_tx_cmd_hwcrypto(struct iwl3945_priv *priv, | |||
2437 | */ | 2427 | */ |
2438 | static void iwl3945_build_tx_cmd_basic(struct iwl3945_priv *priv, | 2428 | static void iwl3945_build_tx_cmd_basic(struct iwl3945_priv *priv, |
2439 | struct iwl3945_cmd *cmd, | 2429 | struct iwl3945_cmd *cmd, |
2440 | struct ieee80211_tx_control *ctrl, | 2430 | struct ieee80211_tx_info *info, |
2441 | struct ieee80211_hdr *hdr, | 2431 | struct ieee80211_hdr *hdr, |
2442 | int is_unicast, u8 std_id) | 2432 | int is_unicast, u8 std_id) |
2443 | { | 2433 | { |
2444 | __le16 *qc; | ||
2445 | u16 fc = le16_to_cpu(hdr->frame_control); | 2434 | u16 fc = le16_to_cpu(hdr->frame_control); |
2446 | __le32 tx_flags = cmd->cmd.tx.tx_flags; | 2435 | __le32 tx_flags = cmd->cmd.tx.tx_flags; |
2447 | 2436 | ||
2448 | cmd->cmd.tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; | 2437 | cmd->cmd.tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; |
2449 | if (!(ctrl->flags & IEEE80211_TXCTL_NO_ACK)) { | 2438 | if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) { |
2450 | tx_flags |= TX_CMD_FLG_ACK_MSK; | 2439 | tx_flags |= TX_CMD_FLG_ACK_MSK; |
2451 | if ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) | 2440 | if ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) |
2452 | tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; | 2441 | tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; |
@@ -2462,17 +2451,18 @@ static void iwl3945_build_tx_cmd_basic(struct iwl3945_priv *priv, | |||
2462 | if (ieee80211_get_morefrag(hdr)) | 2451 | if (ieee80211_get_morefrag(hdr)) |
2463 | tx_flags |= TX_CMD_FLG_MORE_FRAG_MSK; | 2452 | tx_flags |= TX_CMD_FLG_MORE_FRAG_MSK; |
2464 | 2453 | ||
2465 | qc = ieee80211_get_qos_ctrl(hdr); | 2454 | if (ieee80211_is_qos_data(fc)) { |
2466 | if (qc) { | 2455 | u8 *qc = ieee80211_get_qos_ctrl(hdr, ieee80211_get_hdrlen(fc)); |
2467 | cmd->cmd.tx.tid_tspec = (u8) (le16_to_cpu(*qc) & 0xf); | 2456 | cmd->cmd.tx.tid_tspec = qc[0] & 0xf; |
2468 | tx_flags &= ~TX_CMD_FLG_SEQ_CTL_MSK; | 2457 | tx_flags &= ~TX_CMD_FLG_SEQ_CTL_MSK; |
2469 | } else | 2458 | } else { |
2470 | tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; | 2459 | tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; |
2460 | } | ||
2471 | 2461 | ||
2472 | if (ctrl->flags & IEEE80211_TXCTL_USE_RTS_CTS) { | 2462 | if (info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) { |
2473 | tx_flags |= TX_CMD_FLG_RTS_MSK; | 2463 | tx_flags |= TX_CMD_FLG_RTS_MSK; |
2474 | tx_flags &= ~TX_CMD_FLG_CTS_MSK; | 2464 | tx_flags &= ~TX_CMD_FLG_CTS_MSK; |
2475 | } else if (ctrl->flags & IEEE80211_TXCTL_USE_CTS_PROTECT) { | 2465 | } else if (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) { |
2476 | tx_flags &= ~TX_CMD_FLG_RTS_MSK; | 2466 | tx_flags &= ~TX_CMD_FLG_RTS_MSK; |
2477 | tx_flags |= TX_CMD_FLG_CTS_MSK; | 2467 | tx_flags |= TX_CMD_FLG_CTS_MSK; |
2478 | } | 2468 | } |
@@ -2556,25 +2546,27 @@ static int iwl3945_get_sta_id(struct iwl3945_priv *priv, struct ieee80211_hdr *h | |||
2556 | /* | 2546 | /* |
2557 | * start REPLY_TX command process | 2547 | * start REPLY_TX command process |
2558 | */ | 2548 | */ |
2559 | static int iwl3945_tx_skb(struct iwl3945_priv *priv, | 2549 | static int iwl3945_tx_skb(struct iwl3945_priv *priv, struct sk_buff *skb) |
2560 | struct sk_buff *skb, struct ieee80211_tx_control *ctl) | ||
2561 | { | 2550 | { |
2562 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; | 2551 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; |
2552 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
2563 | struct iwl3945_tfd_frame *tfd; | 2553 | struct iwl3945_tfd_frame *tfd; |
2564 | u32 *control_flags; | 2554 | u32 *control_flags; |
2565 | int txq_id = ctl->queue; | 2555 | int txq_id = skb_get_queue_mapping(skb); |
2566 | struct iwl3945_tx_queue *txq = NULL; | 2556 | struct iwl3945_tx_queue *txq = NULL; |
2567 | struct iwl3945_queue *q = NULL; | 2557 | struct iwl3945_queue *q = NULL; |
2568 | dma_addr_t phys_addr; | 2558 | dma_addr_t phys_addr; |
2569 | dma_addr_t txcmd_phys; | 2559 | dma_addr_t txcmd_phys; |
2570 | struct iwl3945_cmd *out_cmd = NULL; | 2560 | struct iwl3945_cmd *out_cmd = NULL; |
2571 | u16 len, idx, len_org; | 2561 | u16 len, idx, len_org, hdr_len; |
2572 | u8 id, hdr_len, unicast; | 2562 | u8 id; |
2563 | u8 unicast; | ||
2573 | u8 sta_id; | 2564 | u8 sta_id; |
2565 | u8 tid = 0; | ||
2574 | u16 seq_number = 0; | 2566 | u16 seq_number = 0; |
2575 | u16 fc; | 2567 | u16 fc; |
2576 | __le16 *qc; | ||
2577 | u8 wait_write_ptr = 0; | 2568 | u8 wait_write_ptr = 0; |
2569 | u8 *qc = NULL; | ||
2578 | unsigned long flags; | 2570 | unsigned long flags; |
2579 | int rc; | 2571 | int rc; |
2580 | 2572 | ||
@@ -2589,7 +2581,7 @@ static int iwl3945_tx_skb(struct iwl3945_priv *priv, | |||
2589 | goto drop_unlock; | 2581 | goto drop_unlock; |
2590 | } | 2582 | } |
2591 | 2583 | ||
2592 | if ((ctl->tx_rate->hw_value & 0xFF) == IWL_INVALID_RATE) { | 2584 | if ((ieee80211_get_tx_rate(priv->hw, info)->hw_value & 0xFF) == IWL_INVALID_RATE) { |
2593 | IWL_ERROR("ERROR: No TX rate available.\n"); | 2585 | IWL_ERROR("ERROR: No TX rate available.\n"); |
2594 | goto drop_unlock; | 2586 | goto drop_unlock; |
2595 | } | 2587 | } |
@@ -2632,9 +2624,9 @@ static int iwl3945_tx_skb(struct iwl3945_priv *priv, | |||
2632 | 2624 | ||
2633 | IWL_DEBUG_RATE("station Id %d\n", sta_id); | 2625 | IWL_DEBUG_RATE("station Id %d\n", sta_id); |
2634 | 2626 | ||
2635 | qc = ieee80211_get_qos_ctrl(hdr); | 2627 | if (ieee80211_is_qos_data(fc)) { |
2636 | if (qc) { | 2628 | qc = ieee80211_get_qos_ctrl(hdr, hdr_len); |
2637 | u8 tid = (u8)(le16_to_cpu(*qc) & 0xf); | 2629 | tid = qc[0] & 0xf; |
2638 | seq_number = priv->stations[sta_id].tid[tid].seq_number & | 2630 | seq_number = priv->stations[sta_id].tid[tid].seq_number & |
2639 | IEEE80211_SCTL_SEQ; | 2631 | IEEE80211_SCTL_SEQ; |
2640 | hdr->seq_ctrl = cpu_to_le16(seq_number) | | 2632 | hdr->seq_ctrl = cpu_to_le16(seq_number) | |
@@ -2658,8 +2650,6 @@ static int iwl3945_tx_skb(struct iwl3945_priv *priv, | |||
2658 | /* Set up driver data for this TFD */ | 2650 | /* Set up driver data for this TFD */ |
2659 | memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct iwl3945_tx_info)); | 2651 | memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct iwl3945_tx_info)); |
2660 | txq->txb[q->write_ptr].skb[0] = skb; | 2652 | txq->txb[q->write_ptr].skb[0] = skb; |
2661 | memcpy(&(txq->txb[q->write_ptr].status.control), | ||
2662 | ctl, sizeof(struct ieee80211_tx_control)); | ||
2663 | 2653 | ||
2664 | /* Init first empty entry in queue's array of Tx/cmd buffers */ | 2654 | /* Init first empty entry in queue's array of Tx/cmd buffers */ |
2665 | out_cmd = &txq->cmd[idx]; | 2655 | out_cmd = &txq->cmd[idx]; |
@@ -2708,8 +2698,8 @@ static int iwl3945_tx_skb(struct iwl3945_priv *priv, | |||
2708 | * first entry */ | 2698 | * first entry */ |
2709 | iwl3945_hw_txq_attach_buf_to_tfd(priv, tfd, txcmd_phys, len); | 2699 | iwl3945_hw_txq_attach_buf_to_tfd(priv, tfd, txcmd_phys, len); |
2710 | 2700 | ||
2711 | if (!(ctl->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT)) | 2701 | if (!(info->flags & IEEE80211_TX_CTL_DO_NOT_ENCRYPT)) |
2712 | iwl3945_build_tx_cmd_hwcrypto(priv, ctl, out_cmd, skb, 0); | 2702 | iwl3945_build_tx_cmd_hwcrypto(priv, info, out_cmd, skb, 0); |
2713 | 2703 | ||
2714 | /* Set up TFD's 2nd entry to point directly to remainder of skb, | 2704 | /* Set up TFD's 2nd entry to point directly to remainder of skb, |
2715 | * if any (802.11 null frames have no payload). */ | 2705 | * if any (802.11 null frames have no payload). */ |
@@ -2734,10 +2724,10 @@ static int iwl3945_tx_skb(struct iwl3945_priv *priv, | |||
2734 | out_cmd->cmd.tx.len = cpu_to_le16(len); | 2724 | out_cmd->cmd.tx.len = cpu_to_le16(len); |
2735 | 2725 | ||
2736 | /* TODO need this for burst mode later on */ | 2726 | /* TODO need this for burst mode later on */ |
2737 | iwl3945_build_tx_cmd_basic(priv, out_cmd, ctl, hdr, unicast, sta_id); | 2727 | iwl3945_build_tx_cmd_basic(priv, out_cmd, info, hdr, unicast, sta_id); |
2738 | 2728 | ||
2739 | /* set is_hcca to 0; it probably will never be implemented */ | 2729 | /* set is_hcca to 0; it probably will never be implemented */ |
2740 | iwl3945_hw_build_tx_cmd_rate(priv, out_cmd, ctl, hdr, sta_id, 0); | 2730 | iwl3945_hw_build_tx_cmd_rate(priv, out_cmd, info, hdr, sta_id, 0); |
2741 | 2731 | ||
2742 | out_cmd->cmd.tx.tx_flags &= ~TX_CMD_FLG_ANT_A_MSK; | 2732 | out_cmd->cmd.tx.tx_flags &= ~TX_CMD_FLG_ANT_A_MSK; |
2743 | out_cmd->cmd.tx.tx_flags &= ~TX_CMD_FLG_ANT_B_MSK; | 2733 | out_cmd->cmd.tx.tx_flags &= ~TX_CMD_FLG_ANT_B_MSK; |
@@ -2745,7 +2735,6 @@ static int iwl3945_tx_skb(struct iwl3945_priv *priv, | |||
2745 | if (!ieee80211_get_morefrag(hdr)) { | 2735 | if (!ieee80211_get_morefrag(hdr)) { |
2746 | txq->need_update = 1; | 2736 | txq->need_update = 1; |
2747 | if (qc) { | 2737 | if (qc) { |
2748 | u8 tid = (u8)(le16_to_cpu(*qc) & 0xf); | ||
2749 | priv->stations[sta_id].tid[tid].seq_number = seq_number; | 2738 | priv->stations[sta_id].tid[tid].seq_number = seq_number; |
2750 | } | 2739 | } |
2751 | } else { | 2740 | } else { |
@@ -2776,7 +2765,7 @@ static int iwl3945_tx_skb(struct iwl3945_priv *priv, | |||
2776 | spin_unlock_irqrestore(&priv->lock, flags); | 2765 | spin_unlock_irqrestore(&priv->lock, flags); |
2777 | } | 2766 | } |
2778 | 2767 | ||
2779 | ieee80211_stop_queue(priv->hw, ctl->queue); | 2768 | ieee80211_stop_queue(priv->hw, skb_get_queue_mapping(skb)); |
2780 | } | 2769 | } |
2781 | 2770 | ||
2782 | return 0; | 2771 | return 0; |
@@ -3239,7 +3228,7 @@ static void iwl3945_bg_beacon_update(struct work_struct *work) | |||
3239 | struct sk_buff *beacon; | 3228 | struct sk_buff *beacon; |
3240 | 3229 | ||
3241 | /* Pull updated AP beacon from mac80211. will fail if not in AP mode */ | 3230 | /* Pull updated AP beacon from mac80211. will fail if not in AP mode */ |
3242 | beacon = ieee80211_beacon_get(priv->hw, priv->vif, NULL); | 3231 | beacon = ieee80211_beacon_get(priv->hw, priv->vif); |
3243 | 3232 | ||
3244 | if (!beacon) { | 3233 | if (!beacon) { |
3245 | IWL_ERROR("update beacon failed\n"); | 3234 | IWL_ERROR("update beacon failed\n"); |
@@ -5832,7 +5821,7 @@ static void iwl3945_alive_start(struct iwl3945_priv *priv) | |||
5832 | if (iwl3945_is_rfkill(priv)) | 5821 | if (iwl3945_is_rfkill(priv)) |
5833 | return; | 5822 | return; |
5834 | 5823 | ||
5835 | ieee80211_start_queues(priv->hw); | 5824 | ieee80211_wake_queues(priv->hw); |
5836 | 5825 | ||
5837 | priv->active_rate = priv->rates_mask; | 5826 | priv->active_rate = priv->rates_mask; |
5838 | priv->active_rate_basic = priv->rates_mask & IWL_BASIC_RATES_MASK; | 5827 | priv->active_rate_basic = priv->rates_mask & IWL_BASIC_RATES_MASK; |
@@ -5858,9 +5847,6 @@ static void iwl3945_alive_start(struct iwl3945_priv *priv) | |||
5858 | /* Configure the adapter for unassociated operation */ | 5847 | /* Configure the adapter for unassociated operation */ |
5859 | iwl3945_commit_rxon(priv); | 5848 | iwl3945_commit_rxon(priv); |
5860 | 5849 | ||
5861 | /* At this point, the NIC is initialized and operational */ | ||
5862 | priv->notif_missed_beacons = 0; | ||
5863 | |||
5864 | iwl3945_reg_txpower_periodic(priv); | 5850 | iwl3945_reg_txpower_periodic(priv); |
5865 | 5851 | ||
5866 | iwl3945_led_register(priv); | 5852 | iwl3945_led_register(priv); |
@@ -6690,8 +6676,7 @@ static void iwl3945_mac_stop(struct ieee80211_hw *hw) | |||
6690 | IWL_DEBUG_MAC80211("leave\n"); | 6676 | IWL_DEBUG_MAC80211("leave\n"); |
6691 | } | 6677 | } |
6692 | 6678 | ||
6693 | static int iwl3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb, | 6679 | static int iwl3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) |
6694 | struct ieee80211_tx_control *ctl) | ||
6695 | { | 6680 | { |
6696 | struct iwl3945_priv *priv = hw->priv; | 6681 | struct iwl3945_priv *priv = hw->priv; |
6697 | 6682 | ||
@@ -6703,9 +6688,9 @@ static int iwl3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
6703 | } | 6688 | } |
6704 | 6689 | ||
6705 | IWL_DEBUG_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, | 6690 | IWL_DEBUG_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, |
6706 | ctl->tx_rate->bitrate); | 6691 | ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); |
6707 | 6692 | ||
6708 | if (iwl3945_tx_skb(priv, skb, ctl)) | 6693 | if (iwl3945_tx_skb(priv, skb)) |
6709 | dev_kfree_skb_any(skb); | 6694 | dev_kfree_skb_any(skb); |
6710 | 6695 | ||
6711 | IWL_DEBUG_MAC80211("leave\n"); | 6696 | IWL_DEBUG_MAC80211("leave\n"); |
@@ -7342,8 +7327,7 @@ static void iwl3945_mac_reset_tsf(struct ieee80211_hw *hw) | |||
7342 | 7327 | ||
7343 | } | 7328 | } |
7344 | 7329 | ||
7345 | static int iwl3945_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb, | 7330 | static int iwl3945_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb) |
7346 | struct ieee80211_tx_control *control) | ||
7347 | { | 7331 | { |
7348 | struct iwl3945_priv *priv = hw->priv; | 7332 | struct iwl3945_priv *priv = hw->priv; |
7349 | unsigned long flags; | 7333 | unsigned long flags; |
@@ -8273,7 +8257,7 @@ static void __devexit iwl3945_pci_remove(struct pci_dev *pdev) | |||
8273 | 8257 | ||
8274 | iwl3945_free_channel_map(priv); | 8258 | iwl3945_free_channel_map(priv); |
8275 | iwl3945_free_geos(priv); | 8259 | iwl3945_free_geos(priv); |
8276 | 8260 | kfree(priv->scan); | |
8277 | if (priv->ibss_beacon) | 8261 | if (priv->ibss_beacon) |
8278 | dev_kfree_skb(priv->ibss_beacon); | 8262 | dev_kfree_skb(priv->ibss_beacon); |
8279 | 8263 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c index 55ca752ae9e6..c71daec8c746 100644 --- a/drivers/net/wireless/iwlwifi/iwl4965-base.c +++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c | |||
@@ -53,8 +53,6 @@ | |||
53 | #include "iwl-sta.h" | 53 | #include "iwl-sta.h" |
54 | #include "iwl-calib.h" | 54 | #include "iwl-calib.h" |
55 | 55 | ||
56 | static int iwl4965_tx_queue_update_write_ptr(struct iwl_priv *priv, | ||
57 | struct iwl_tx_queue *txq); | ||
58 | 56 | ||
59 | /****************************************************************************** | 57 | /****************************************************************************** |
60 | * | 58 | * |
@@ -89,22 +87,6 @@ MODULE_VERSION(DRV_VERSION); | |||
89 | MODULE_AUTHOR(DRV_COPYRIGHT); | 87 | MODULE_AUTHOR(DRV_COPYRIGHT); |
90 | MODULE_LICENSE("GPL"); | 88 | MODULE_LICENSE("GPL"); |
91 | 89 | ||
92 | __le16 *ieee80211_get_qos_ctrl(struct ieee80211_hdr *hdr) | ||
93 | { | ||
94 | u16 fc = le16_to_cpu(hdr->frame_control); | ||
95 | int hdr_len = ieee80211_get_hdrlen(fc); | ||
96 | |||
97 | if ((fc & 0x00cc) == (IEEE80211_STYPE_QOS_DATA | IEEE80211_FTYPE_DATA)) | ||
98 | return (__le16 *) ((u8 *) hdr + hdr_len - QOS_CONTROL_LEN); | ||
99 | return NULL; | ||
100 | } | ||
101 | |||
102 | static const struct ieee80211_supported_band *iwl_get_hw_mode( | ||
103 | struct iwl_priv *priv, enum ieee80211_band band) | ||
104 | { | ||
105 | return priv->hw->wiphy->bands[band]; | ||
106 | } | ||
107 | |||
108 | static int iwl4965_is_empty_essid(const char *essid, int essid_len) | 90 | static int iwl4965_is_empty_essid(const char *essid, int essid_len) |
109 | { | 91 | { |
110 | /* Single white space is for Linksys APs */ | 92 | /* Single white space is for Linksys APs */ |
@@ -145,70 +127,6 @@ static const char *iwl4965_escape_essid(const char *essid, u8 essid_len) | |||
145 | return escaped; | 127 | return escaped; |
146 | } | 128 | } |
147 | 129 | ||
148 | |||
149 | /*************** DMA-QUEUE-GENERAL-FUNCTIONS ***** | ||
150 | * DMA services | ||
151 | * | ||
152 | * Theory of operation | ||
153 | * | ||
154 | * A Tx or Rx queue resides in host DRAM, and is comprised of a circular buffer | ||
155 | * of buffer descriptors, each of which points to one or more data buffers for | ||
156 | * the device to read from or fill. Driver and device exchange status of each | ||
157 | * queue via "read" and "write" pointers. Driver keeps minimum of 2 empty | ||
158 | * entries in each circular buffer, to protect against confusing empty and full | ||
159 | * queue states. | ||
160 | * | ||
161 | * The device reads or writes the data in the queues via the device's several | ||
162 | * DMA/FIFO channels. Each queue is mapped to a single DMA channel. | ||
163 | * | ||
164 | * For Tx queue, there are low mark and high mark limits. If, after queuing | ||
165 | * the packet for Tx, free space become < low mark, Tx queue stopped. When | ||
166 | * reclaiming packets (on 'tx done IRQ), if free space become > high mark, | ||
167 | * Tx queue resumed. | ||
168 | * | ||
169 | * The 4965 operates with up to 17 queues: One receive queue, one transmit | ||
170 | * queue (#4) for sending commands to the device firmware, and 15 other | ||
171 | * Tx queues that may be mapped to prioritized Tx DMA/FIFO channels. | ||
172 | * | ||
173 | * See more detailed info in iwl-4965-hw.h. | ||
174 | ***************************************************/ | ||
175 | |||
176 | int iwl4965_queue_space(const struct iwl4965_queue *q) | ||
177 | { | ||
178 | int s = q->read_ptr - q->write_ptr; | ||
179 | |||
180 | if (q->read_ptr > q->write_ptr) | ||
181 | s -= q->n_bd; | ||
182 | |||
183 | if (s <= 0) | ||
184 | s += q->n_window; | ||
185 | /* keep some reserve to not confuse empty and full situations */ | ||
186 | s -= 2; | ||
187 | if (s < 0) | ||
188 | s = 0; | ||
189 | return s; | ||
190 | } | ||
191 | |||
192 | |||
193 | static inline int x2_queue_used(const struct iwl4965_queue *q, int i) | ||
194 | { | ||
195 | return q->write_ptr > q->read_ptr ? | ||
196 | (i >= q->read_ptr && i < q->write_ptr) : | ||
197 | !(i < q->read_ptr && i >= q->write_ptr); | ||
198 | } | ||
199 | |||
200 | static inline u8 get_cmd_index(struct iwl4965_queue *q, u32 index, int is_huge) | ||
201 | { | ||
202 | /* This is for scan command, the big buffer at end of command array */ | ||
203 | if (is_huge) | ||
204 | return q->n_window; /* must be power of 2 */ | ||
205 | |||
206 | /* Otherwise, use normal size buffers */ | ||
207 | return index & (q->n_window - 1); | ||
208 | } | ||
209 | |||
210 | const u8 iwl4965_broadcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; | ||
211 | |||
212 | /*************** STATION TABLE MANAGEMENT **** | 130 | /*************** STATION TABLE MANAGEMENT **** |
213 | * mac80211 should be examined to determine if sta_info is duplicating | 131 | * mac80211 should be examined to determine if sta_info is duplicating |
214 | * the functionality provided here | 132 | * the functionality provided here |
@@ -216,213 +134,11 @@ const u8 iwl4965_broadcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF | |||
216 | 134 | ||
217 | /**************************************************************/ | 135 | /**************************************************************/ |
218 | 136 | ||
219 | #if 0 /* temporary disable till we add real remove station */ | ||
220 | /** | ||
221 | * iwl4965_remove_station - Remove driver's knowledge of station. | ||
222 | * | ||
223 | * NOTE: This does not remove station from device's station table. | ||
224 | */ | ||
225 | static u8 iwl4965_remove_station(struct iwl_priv *priv, const u8 *addr, int is_ap) | ||
226 | { | ||
227 | int index = IWL_INVALID_STATION; | ||
228 | int i; | ||
229 | unsigned long flags; | ||
230 | |||
231 | spin_lock_irqsave(&priv->sta_lock, flags); | ||
232 | 137 | ||
233 | if (is_ap) | ||
234 | index = IWL_AP_ID; | ||
235 | else if (is_broadcast_ether_addr(addr)) | ||
236 | index = priv->hw_params.bcast_sta_id; | ||
237 | else | ||
238 | for (i = IWL_STA_ID; i < priv->hw_params.max_stations; i++) | ||
239 | if (priv->stations[i].used && | ||
240 | !compare_ether_addr(priv->stations[i].sta.sta.addr, | ||
241 | addr)) { | ||
242 | index = i; | ||
243 | break; | ||
244 | } | ||
245 | |||
246 | if (unlikely(index == IWL_INVALID_STATION)) | ||
247 | goto out; | ||
248 | |||
249 | if (priv->stations[index].used) { | ||
250 | priv->stations[index].used = 0; | ||
251 | priv->num_stations--; | ||
252 | } | ||
253 | |||
254 | BUG_ON(priv->num_stations < 0); | ||
255 | |||
256 | out: | ||
257 | spin_unlock_irqrestore(&priv->sta_lock, flags); | ||
258 | return 0; | ||
259 | } | ||
260 | #endif | ||
261 | |||
262 | /** | ||
263 | * iwl4965_add_station_flags - Add station to tables in driver and device | ||
264 | */ | ||
265 | u8 iwl4965_add_station_flags(struct iwl_priv *priv, const u8 *addr, | ||
266 | int is_ap, u8 flags, void *ht_data) | ||
267 | { | ||
268 | int i; | ||
269 | int index = IWL_INVALID_STATION; | ||
270 | struct iwl_station_entry *station; | ||
271 | unsigned long flags_spin; | ||
272 | DECLARE_MAC_BUF(mac); | ||
273 | |||
274 | spin_lock_irqsave(&priv->sta_lock, flags_spin); | ||
275 | if (is_ap) | ||
276 | index = IWL_AP_ID; | ||
277 | else if (is_broadcast_ether_addr(addr)) | ||
278 | index = priv->hw_params.bcast_sta_id; | ||
279 | else | ||
280 | for (i = IWL_STA_ID; i < priv->hw_params.max_stations; i++) { | ||
281 | if (!compare_ether_addr(priv->stations[i].sta.sta.addr, | ||
282 | addr)) { | ||
283 | index = i; | ||
284 | break; | ||
285 | } | ||
286 | |||
287 | if (!priv->stations[i].used && | ||
288 | index == IWL_INVALID_STATION) | ||
289 | index = i; | ||
290 | } | ||
291 | |||
292 | |||
293 | /* These two conditions have the same outcome, but keep them separate | ||
294 | since they have different meanings */ | ||
295 | if (unlikely(index == IWL_INVALID_STATION)) { | ||
296 | spin_unlock_irqrestore(&priv->sta_lock, flags_spin); | ||
297 | return index; | ||
298 | } | ||
299 | |||
300 | if (priv->stations[index].used && | ||
301 | !compare_ether_addr(priv->stations[index].sta.sta.addr, addr)) { | ||
302 | spin_unlock_irqrestore(&priv->sta_lock, flags_spin); | ||
303 | return index; | ||
304 | } | ||
305 | |||
306 | |||
307 | IWL_DEBUG_ASSOC("Add STA ID %d: %s\n", index, print_mac(mac, addr)); | ||
308 | station = &priv->stations[index]; | ||
309 | station->used = 1; | ||
310 | priv->num_stations++; | ||
311 | |||
312 | /* Set up the REPLY_ADD_STA command to send to device */ | ||
313 | memset(&station->sta, 0, sizeof(struct iwl_addsta_cmd)); | ||
314 | memcpy(station->sta.sta.addr, addr, ETH_ALEN); | ||
315 | station->sta.mode = 0; | ||
316 | station->sta.sta.sta_id = index; | ||
317 | station->sta.station_flags = 0; | ||
318 | |||
319 | #ifdef CONFIG_IWL4965_HT | ||
320 | /* BCAST station and IBSS stations do not work in HT mode */ | ||
321 | if (index != priv->hw_params.bcast_sta_id && | ||
322 | priv->iw_mode != IEEE80211_IF_TYPE_IBSS) | ||
323 | iwl4965_set_ht_add_station(priv, index, | ||
324 | (struct ieee80211_ht_info *) ht_data); | ||
325 | #endif /*CONFIG_IWL4965_HT*/ | ||
326 | |||
327 | spin_unlock_irqrestore(&priv->sta_lock, flags_spin); | ||
328 | |||
329 | /* Add station to device's station table */ | ||
330 | iwl_send_add_sta(priv, &station->sta, flags); | ||
331 | return index; | ||
332 | |||
333 | } | ||
334 | |||
335 | |||
336 | |||
337 | /*************** HOST COMMAND QUEUE FUNCTIONS *****/ | ||
338 | |||
339 | /** | ||
340 | * iwl4965_enqueue_hcmd - enqueue a uCode command | ||
341 | * @priv: device private data point | ||
342 | * @cmd: a point to the ucode command structure | ||
343 | * | ||
344 | * The function returns < 0 values to indicate the operation is | ||
345 | * failed. On success, it turns the index (> 0) of command in the | ||
346 | * command queue. | ||
347 | */ | ||
348 | int iwl4965_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd) | ||
349 | { | ||
350 | struct iwl_tx_queue *txq = &priv->txq[IWL_CMD_QUEUE_NUM]; | ||
351 | struct iwl4965_queue *q = &txq->q; | ||
352 | struct iwl_tfd_frame *tfd; | ||
353 | u32 *control_flags; | ||
354 | struct iwl_cmd *out_cmd; | ||
355 | u32 idx; | ||
356 | u16 fix_size = (u16)(cmd->len + sizeof(out_cmd->hdr)); | ||
357 | dma_addr_t phys_addr; | ||
358 | int ret; | ||
359 | unsigned long flags; | ||
360 | |||
361 | /* If any of the command structures end up being larger than | ||
362 | * the TFD_MAX_PAYLOAD_SIZE, and it sent as a 'small' command then | ||
363 | * we will need to increase the size of the TFD entries */ | ||
364 | BUG_ON((fix_size > TFD_MAX_PAYLOAD_SIZE) && | ||
365 | !(cmd->meta.flags & CMD_SIZE_HUGE)); | ||
366 | |||
367 | if (iwl_is_rfkill(priv)) { | ||
368 | IWL_DEBUG_INFO("Not sending command - RF KILL"); | ||
369 | return -EIO; | ||
370 | } | ||
371 | |||
372 | if (iwl4965_queue_space(q) < ((cmd->meta.flags & CMD_ASYNC) ? 2 : 1)) { | ||
373 | IWL_ERROR("No space for Tx\n"); | ||
374 | return -ENOSPC; | ||
375 | } | ||
376 | |||
377 | spin_lock_irqsave(&priv->hcmd_lock, flags); | ||
378 | |||
379 | tfd = &txq->bd[q->write_ptr]; | ||
380 | memset(tfd, 0, sizeof(*tfd)); | ||
381 | |||
382 | control_flags = (u32 *) tfd; | ||
383 | |||
384 | idx = get_cmd_index(q, q->write_ptr, cmd->meta.flags & CMD_SIZE_HUGE); | ||
385 | out_cmd = &txq->cmd[idx]; | ||
386 | |||
387 | out_cmd->hdr.cmd = cmd->id; | ||
388 | memcpy(&out_cmd->meta, &cmd->meta, sizeof(cmd->meta)); | ||
389 | memcpy(&out_cmd->cmd.payload, cmd->data, cmd->len); | ||
390 | |||
391 | /* At this point, the out_cmd now has all of the incoming cmd | ||
392 | * information */ | ||
393 | |||
394 | out_cmd->hdr.flags = 0; | ||
395 | out_cmd->hdr.sequence = cpu_to_le16(QUEUE_TO_SEQ(IWL_CMD_QUEUE_NUM) | | ||
396 | INDEX_TO_SEQ(q->write_ptr)); | ||
397 | if (out_cmd->meta.flags & CMD_SIZE_HUGE) | ||
398 | out_cmd->hdr.sequence |= cpu_to_le16(SEQ_HUGE_FRAME); | ||
399 | |||
400 | phys_addr = txq->dma_addr_cmd + sizeof(txq->cmd[0]) * idx + | ||
401 | offsetof(struct iwl_cmd, hdr); | ||
402 | iwl4965_hw_txq_attach_buf_to_tfd(priv, tfd, phys_addr, fix_size); | ||
403 | |||
404 | IWL_DEBUG_HC("Sending command %s (#%x), seq: 0x%04X, " | ||
405 | "%d bytes at %d[%d]:%d\n", | ||
406 | get_cmd_string(out_cmd->hdr.cmd), | ||
407 | out_cmd->hdr.cmd, le16_to_cpu(out_cmd->hdr.sequence), | ||
408 | fix_size, q->write_ptr, idx, IWL_CMD_QUEUE_NUM); | ||
409 | |||
410 | txq->need_update = 1; | ||
411 | |||
412 | /* Set up entry in queue's byte count circular buffer */ | ||
413 | priv->cfg->ops->lib->txq_update_byte_cnt_tbl(priv, txq, 0); | ||
414 | |||
415 | /* Increment and update queue's write index */ | ||
416 | q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd); | ||
417 | ret = iwl4965_tx_queue_update_write_ptr(priv, txq); | ||
418 | |||
419 | spin_unlock_irqrestore(&priv->hcmd_lock, flags); | ||
420 | return ret ? ret : idx; | ||
421 | } | ||
422 | 138 | ||
423 | static void iwl4965_set_rxon_hwcrypto(struct iwl_priv *priv, int hw_decrypt) | 139 | static void iwl4965_set_rxon_hwcrypto(struct iwl_priv *priv, int hw_decrypt) |
424 | { | 140 | { |
425 | struct iwl4965_rxon_cmd *rxon = &priv->staging_rxon; | 141 | struct iwl_rxon_cmd *rxon = &priv->staging_rxon; |
426 | 142 | ||
427 | if (hw_decrypt) | 143 | if (hw_decrypt) |
428 | rxon->filter_flags &= ~RXON_FILTER_DIS_DECRYPT_MSK; | 144 | rxon->filter_flags &= ~RXON_FILTER_DIS_DECRYPT_MSK; |
@@ -432,45 +148,13 @@ static void iwl4965_set_rxon_hwcrypto(struct iwl_priv *priv, int hw_decrypt) | |||
432 | } | 148 | } |
433 | 149 | ||
434 | /** | 150 | /** |
435 | * iwl4965_rxon_add_station - add station into station table. | ||
436 | * | ||
437 | * there is only one AP station with id= IWL_AP_ID | ||
438 | * NOTE: mutex must be held before calling this fnction | ||
439 | */ | ||
440 | static int iwl4965_rxon_add_station(struct iwl_priv *priv, | ||
441 | const u8 *addr, int is_ap) | ||
442 | { | ||
443 | u8 sta_id; | ||
444 | |||
445 | /* Add station to device's station table */ | ||
446 | #ifdef CONFIG_IWL4965_HT | ||
447 | struct ieee80211_conf *conf = &priv->hw->conf; | ||
448 | struct ieee80211_ht_info *cur_ht_config = &conf->ht_conf; | ||
449 | |||
450 | if ((is_ap) && | ||
451 | (conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) && | ||
452 | (priv->iw_mode == IEEE80211_IF_TYPE_STA)) | ||
453 | sta_id = iwl4965_add_station_flags(priv, addr, is_ap, | ||
454 | 0, cur_ht_config); | ||
455 | else | ||
456 | #endif /* CONFIG_IWL4965_HT */ | ||
457 | sta_id = iwl4965_add_station_flags(priv, addr, is_ap, | ||
458 | 0, NULL); | ||
459 | |||
460 | /* Set up default rate scaling table in device's station table */ | ||
461 | iwl4965_add_station(priv, addr, is_ap); | ||
462 | |||
463 | return sta_id; | ||
464 | } | ||
465 | |||
466 | /** | ||
467 | * iwl4965_check_rxon_cmd - validate RXON structure is valid | 151 | * iwl4965_check_rxon_cmd - validate RXON structure is valid |
468 | * | 152 | * |
469 | * NOTE: This is really only useful during development and can eventually | 153 | * NOTE: This is really only useful during development and can eventually |
470 | * be #ifdef'd out once the driver is stable and folks aren't actively | 154 | * be #ifdef'd out once the driver is stable and folks aren't actively |
471 | * making changes | 155 | * making changes |
472 | */ | 156 | */ |
473 | static int iwl4965_check_rxon_cmd(struct iwl4965_rxon_cmd *rxon) | 157 | static int iwl4965_check_rxon_cmd(struct iwl_rxon_cmd *rxon) |
474 | { | 158 | { |
475 | int error = 0; | 159 | int error = 0; |
476 | int counter = 1; | 160 | int counter = 1; |
@@ -595,7 +279,7 @@ static int iwl4965_full_rxon_required(struct iwl_priv *priv) | |||
595 | static int iwl4965_commit_rxon(struct iwl_priv *priv) | 279 | static int iwl4965_commit_rxon(struct iwl_priv *priv) |
596 | { | 280 | { |
597 | /* cast away the const for active_rxon in this function */ | 281 | /* cast away the const for active_rxon in this function */ |
598 | struct iwl4965_rxon_cmd *active_rxon = (void *)&priv->active_rxon; | 282 | struct iwl_rxon_cmd *active_rxon = (void *)&priv->active_rxon; |
599 | DECLARE_MAC_BUF(mac); | 283 | DECLARE_MAC_BUF(mac); |
600 | int rc = 0; | 284 | int rc = 0; |
601 | 285 | ||
@@ -640,7 +324,7 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv) | |||
640 | active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; | 324 | active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; |
641 | 325 | ||
642 | rc = iwl_send_cmd_pdu(priv, REPLY_RXON, | 326 | rc = iwl_send_cmd_pdu(priv, REPLY_RXON, |
643 | sizeof(struct iwl4965_rxon_cmd), | 327 | sizeof(struct iwl_rxon_cmd), |
644 | &priv->active_rxon); | 328 | &priv->active_rxon); |
645 | 329 | ||
646 | /* If the mask clearing failed then we set | 330 | /* If the mask clearing failed then we set |
@@ -665,12 +349,13 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv) | |||
665 | iwl4965_set_rxon_hwcrypto(priv, !priv->hw_params.sw_crypto); | 349 | iwl4965_set_rxon_hwcrypto(priv, !priv->hw_params.sw_crypto); |
666 | /* Apply the new configuration */ | 350 | /* Apply the new configuration */ |
667 | rc = iwl_send_cmd_pdu(priv, REPLY_RXON, | 351 | rc = iwl_send_cmd_pdu(priv, REPLY_RXON, |
668 | sizeof(struct iwl4965_rxon_cmd), &priv->staging_rxon); | 352 | sizeof(struct iwl_rxon_cmd), &priv->staging_rxon); |
669 | if (rc) { | 353 | if (rc) { |
670 | IWL_ERROR("Error setting new configuration (%d).\n", rc); | 354 | IWL_ERROR("Error setting new configuration (%d).\n", rc); |
671 | return rc; | 355 | return rc; |
672 | } | 356 | } |
673 | 357 | ||
358 | iwl_remove_station(priv, iwl_bcast_addr, 0); | ||
674 | iwlcore_clear_stations_table(priv); | 359 | iwlcore_clear_stations_table(priv); |
675 | 360 | ||
676 | if (!priv->error_recovering) | 361 | if (!priv->error_recovering) |
@@ -689,7 +374,7 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv) | |||
689 | } | 374 | } |
690 | 375 | ||
691 | /* Add the broadcast address so we can send broadcast frames */ | 376 | /* Add the broadcast address so we can send broadcast frames */ |
692 | if (iwl4965_rxon_add_station(priv, iwl4965_broadcast_addr, 0) == | 377 | if (iwl_rxon_add_station(priv, iwl_bcast_addr, 0) == |
693 | IWL_INVALID_STATION) { | 378 | IWL_INVALID_STATION) { |
694 | IWL_ERROR("Error adding BROADCAST address for transmit.\n"); | 379 | IWL_ERROR("Error adding BROADCAST address for transmit.\n"); |
695 | return -EIO; | 380 | return -EIO; |
@@ -699,7 +384,7 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv) | |||
699 | * add the IWL_AP_ID to the station rate table */ | 384 | * add the IWL_AP_ID to the station rate table */ |
700 | if (iwl_is_associated(priv) && | 385 | if (iwl_is_associated(priv) && |
701 | (priv->iw_mode == IEEE80211_IF_TYPE_STA)) { | 386 | (priv->iw_mode == IEEE80211_IF_TYPE_STA)) { |
702 | if (iwl4965_rxon_add_station(priv, priv->active_rxon.bssid_addr, 1) | 387 | if (iwl_rxon_add_station(priv, priv->active_rxon.bssid_addr, 1) |
703 | == IWL_INVALID_STATION) { | 388 | == IWL_INVALID_STATION) { |
704 | IWL_ERROR("Error adding AP address for transmit.\n"); | 389 | IWL_ERROR("Error adding AP address for transmit.\n"); |
705 | return -EIO; | 390 | return -EIO; |
@@ -797,7 +482,7 @@ static int iwl4965_send_card_state(struct iwl_priv *priv, u32 flags, u8 meta_fla | |||
797 | return iwl_send_cmd(priv, &cmd); | 482 | return iwl_send_cmd(priv, &cmd); |
798 | } | 483 | } |
799 | 484 | ||
800 | static void iwl4965_clear_free_frames(struct iwl_priv *priv) | 485 | static void iwl_clear_free_frames(struct iwl_priv *priv) |
801 | { | 486 | { |
802 | struct list_head *element; | 487 | struct list_head *element; |
803 | 488 | ||
@@ -807,7 +492,7 @@ static void iwl4965_clear_free_frames(struct iwl_priv *priv) | |||
807 | while (!list_empty(&priv->free_frames)) { | 492 | while (!list_empty(&priv->free_frames)) { |
808 | element = priv->free_frames.next; | 493 | element = priv->free_frames.next; |
809 | list_del(element); | 494 | list_del(element); |
810 | kfree(list_entry(element, struct iwl4965_frame, list)); | 495 | kfree(list_entry(element, struct iwl_frame, list)); |
811 | priv->frames_count--; | 496 | priv->frames_count--; |
812 | } | 497 | } |
813 | 498 | ||
@@ -818,9 +503,9 @@ static void iwl4965_clear_free_frames(struct iwl_priv *priv) | |||
818 | } | 503 | } |
819 | } | 504 | } |
820 | 505 | ||
821 | static struct iwl4965_frame *iwl4965_get_free_frame(struct iwl_priv *priv) | 506 | static struct iwl_frame *iwl_get_free_frame(struct iwl_priv *priv) |
822 | { | 507 | { |
823 | struct iwl4965_frame *frame; | 508 | struct iwl_frame *frame; |
824 | struct list_head *element; | 509 | struct list_head *element; |
825 | if (list_empty(&priv->free_frames)) { | 510 | if (list_empty(&priv->free_frames)) { |
826 | frame = kzalloc(sizeof(*frame), GFP_KERNEL); | 511 | frame = kzalloc(sizeof(*frame), GFP_KERNEL); |
@@ -835,10 +520,10 @@ static struct iwl4965_frame *iwl4965_get_free_frame(struct iwl_priv *priv) | |||
835 | 520 | ||
836 | element = priv->free_frames.next; | 521 | element = priv->free_frames.next; |
837 | list_del(element); | 522 | list_del(element); |
838 | return list_entry(element, struct iwl4965_frame, list); | 523 | return list_entry(element, struct iwl_frame, list); |
839 | } | 524 | } |
840 | 525 | ||
841 | static void iwl4965_free_frame(struct iwl_priv *priv, struct iwl4965_frame *frame) | 526 | static void iwl_free_frame(struct iwl_priv *priv, struct iwl_frame *frame) |
842 | { | 527 | { |
843 | memset(frame, 0, sizeof(*frame)); | 528 | memset(frame, 0, sizeof(*frame)); |
844 | list_add(&frame->list, &priv->free_frames); | 529 | list_add(&frame->list, &priv->free_frames); |
@@ -875,9 +560,9 @@ static u8 iwl4965_rate_get_lowest_plcp(struct iwl_priv *priv) | |||
875 | 560 | ||
876 | /* Find lowest valid rate */ | 561 | /* Find lowest valid rate */ |
877 | for (i = IWL_RATE_1M_INDEX; i != IWL_RATE_INVALID; | 562 | for (i = IWL_RATE_1M_INDEX; i != IWL_RATE_INVALID; |
878 | i = iwl4965_rates[i].next_ieee) { | 563 | i = iwl_rates[i].next_ieee) { |
879 | if (rate_mask & (1 << i)) | 564 | if (rate_mask & (1 << i)) |
880 | return iwl4965_rates[i].plcp; | 565 | return iwl_rates[i].plcp; |
881 | } | 566 | } |
882 | 567 | ||
883 | /* No valid rate was found. Assign the lowest one */ | 568 | /* No valid rate was found. Assign the lowest one */ |
@@ -889,12 +574,12 @@ static u8 iwl4965_rate_get_lowest_plcp(struct iwl_priv *priv) | |||
889 | 574 | ||
890 | static int iwl4965_send_beacon_cmd(struct iwl_priv *priv) | 575 | static int iwl4965_send_beacon_cmd(struct iwl_priv *priv) |
891 | { | 576 | { |
892 | struct iwl4965_frame *frame; | 577 | struct iwl_frame *frame; |
893 | unsigned int frame_size; | 578 | unsigned int frame_size; |
894 | int rc; | 579 | int rc; |
895 | u8 rate; | 580 | u8 rate; |
896 | 581 | ||
897 | frame = iwl4965_get_free_frame(priv); | 582 | frame = iwl_get_free_frame(priv); |
898 | 583 | ||
899 | if (!frame) { | 584 | if (!frame) { |
900 | IWL_ERROR("Could not obtain free frame buffer for beacon " | 585 | IWL_ERROR("Could not obtain free frame buffer for beacon " |
@@ -909,7 +594,7 @@ static int iwl4965_send_beacon_cmd(struct iwl_priv *priv) | |||
909 | rc = iwl_send_cmd_pdu(priv, REPLY_TX_BEACON, frame_size, | 594 | rc = iwl_send_cmd_pdu(priv, REPLY_TX_BEACON, frame_size, |
910 | &frame->u.cmd[0]); | 595 | &frame->u.cmd[0]); |
911 | 596 | ||
912 | iwl4965_free_frame(priv, frame); | 597 | iwl_free_frame(priv, frame); |
913 | 598 | ||
914 | return rc; | 599 | return rc; |
915 | } | 600 | } |
@@ -936,7 +621,7 @@ static u16 iwl4965_supported_rate_to_ie(u8 *ie, u16 supported_rate, | |||
936 | for (bit = 1, i = 0; i < IWL_RATE_COUNT; i++, bit <<= 1) { | 621 | for (bit = 1, i = 0; i < IWL_RATE_COUNT; i++, bit <<= 1) { |
937 | if (bit & supported_rate) { | 622 | if (bit & supported_rate) { |
938 | ret_rates |= bit; | 623 | ret_rates |= bit; |
939 | rates[*cnt] = iwl4965_rates[i].ieee | | 624 | rates[*cnt] = iwl_rates[i].ieee | |
940 | ((bit & basic_rate) ? 0x80 : 0x00); | 625 | ((bit & basic_rate) ? 0x80 : 0x00); |
941 | (*cnt)++; | 626 | (*cnt)++; |
942 | (*left)--; | 627 | (*left)--; |
@@ -967,9 +652,9 @@ static void iwl4965_ht_conf(struct iwl_priv *priv, | |||
967 | priv->ps_mode = (u8)((ht_conf->cap & IEEE80211_HT_CAP_MIMO_PS) >> 2); | 652 | priv->ps_mode = (u8)((ht_conf->cap & IEEE80211_HT_CAP_MIMO_PS) >> 2); |
968 | 653 | ||
969 | if (ht_conf->cap & IEEE80211_HT_CAP_SGI_20) | 654 | if (ht_conf->cap & IEEE80211_HT_CAP_SGI_20) |
970 | iwl_conf->sgf |= 0x1; | 655 | iwl_conf->sgf |= HT_SHORT_GI_20MHZ; |
971 | if (ht_conf->cap & IEEE80211_HT_CAP_SGI_40) | 656 | if (ht_conf->cap & IEEE80211_HT_CAP_SGI_40) |
972 | iwl_conf->sgf |= 0x2; | 657 | iwl_conf->sgf |= HT_SHORT_GI_40MHZ; |
973 | 658 | ||
974 | iwl_conf->is_green_field = !!(ht_conf->cap & IEEE80211_HT_CAP_GRN_FLD); | 659 | iwl_conf->is_green_field = !!(ht_conf->cap & IEEE80211_HT_CAP_GRN_FLD); |
975 | iwl_conf->max_amsdu_size = | 660 | iwl_conf->max_amsdu_size = |
@@ -1056,9 +741,9 @@ static u16 iwl4965_fill_probe_req(struct iwl_priv *priv, | |||
1056 | len += 24; | 741 | len += 24; |
1057 | 742 | ||
1058 | frame->frame_control = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ); | 743 | frame->frame_control = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ); |
1059 | memcpy(frame->da, iwl4965_broadcast_addr, ETH_ALEN); | 744 | memcpy(frame->da, iwl_bcast_addr, ETH_ALEN); |
1060 | memcpy(frame->sa, priv->mac_addr, ETH_ALEN); | 745 | memcpy(frame->sa, priv->mac_addr, ETH_ALEN); |
1061 | memcpy(frame->bssid, iwl4965_broadcast_addr, ETH_ALEN); | 746 | memcpy(frame->bssid, iwl_bcast_addr, ETH_ALEN); |
1062 | frame->seq_ctrl = 0; | 747 | frame->seq_ctrl = 0; |
1063 | 748 | ||
1064 | /* fill in our indirect SSID IE */ | 749 | /* fill in our indirect SSID IE */ |
@@ -1224,33 +909,7 @@ int iwl4965_is_network_packet(struct iwl_priv *priv, struct ieee80211_hdr *heade | |||
1224 | return 1; | 909 | return 1; |
1225 | } | 910 | } |
1226 | 911 | ||
1227 | #define TX_STATUS_ENTRY(x) case TX_STATUS_FAIL_ ## x: return #x | ||
1228 | |||
1229 | static const char *iwl4965_get_tx_fail_reason(u32 status) | ||
1230 | { | ||
1231 | switch (status & TX_STATUS_MSK) { | ||
1232 | case TX_STATUS_SUCCESS: | ||
1233 | return "SUCCESS"; | ||
1234 | TX_STATUS_ENTRY(SHORT_LIMIT); | ||
1235 | TX_STATUS_ENTRY(LONG_LIMIT); | ||
1236 | TX_STATUS_ENTRY(FIFO_UNDERRUN); | ||
1237 | TX_STATUS_ENTRY(MGMNT_ABORT); | ||
1238 | TX_STATUS_ENTRY(NEXT_FRAG); | ||
1239 | TX_STATUS_ENTRY(LIFE_EXPIRE); | ||
1240 | TX_STATUS_ENTRY(DEST_PS); | ||
1241 | TX_STATUS_ENTRY(ABORTED); | ||
1242 | TX_STATUS_ENTRY(BT_RETRY); | ||
1243 | TX_STATUS_ENTRY(STA_INVALID); | ||
1244 | TX_STATUS_ENTRY(FRAG_DROPPED); | ||
1245 | TX_STATUS_ENTRY(TID_DISABLE); | ||
1246 | TX_STATUS_ENTRY(FRAME_FLUSHED); | ||
1247 | TX_STATUS_ENTRY(INSUFFICIENT_CF_POLL); | ||
1248 | TX_STATUS_ENTRY(TX_LOCKED); | ||
1249 | TX_STATUS_ENTRY(NO_BEACON_ON_RADAR); | ||
1250 | } | ||
1251 | 912 | ||
1252 | return "UNKNOWN"; | ||
1253 | } | ||
1254 | 913 | ||
1255 | /** | 914 | /** |
1256 | * iwl4965_scan_cancel - Cancel any currently executing HW scan | 915 | * iwl4965_scan_cancel - Cancel any currently executing HW scan |
@@ -1425,8 +1084,8 @@ static int iwl4965_scan_initiate(struct iwl_priv *priv) | |||
1425 | } | 1084 | } |
1426 | 1085 | ||
1427 | 1086 | ||
1428 | static void iwl4965_set_flags_for_phymode(struct iwl_priv *priv, | 1087 | static void iwl_set_flags_for_band(struct iwl_priv *priv, |
1429 | enum ieee80211_band band) | 1088 | enum ieee80211_band band) |
1430 | { | 1089 | { |
1431 | if (band == IEEE80211_BAND_5GHZ) { | 1090 | if (band == IEEE80211_BAND_5GHZ) { |
1432 | priv->staging_rxon.flags &= | 1091 | priv->staging_rxon.flags &= |
@@ -1511,7 +1170,7 @@ static void iwl4965_connection_init_rx_config(struct iwl_priv *priv) | |||
1511 | priv->staging_rxon.channel = cpu_to_le16(ch_info->channel); | 1170 | priv->staging_rxon.channel = cpu_to_le16(ch_info->channel); |
1512 | priv->band = ch_info->band; | 1171 | priv->band = ch_info->band; |
1513 | 1172 | ||
1514 | iwl4965_set_flags_for_phymode(priv, priv->band); | 1173 | iwl_set_flags_for_band(priv, priv->band); |
1515 | 1174 | ||
1516 | priv->staging_rxon.ofdm_basic_rates = | 1175 | priv->staging_rxon.ofdm_basic_rates = |
1517 | (IWL_OFDM_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF; | 1176 | (IWL_OFDM_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF; |
@@ -1566,441 +1225,6 @@ static int iwl4965_set_mode(struct iwl_priv *priv, int mode) | |||
1566 | return 0; | 1225 | return 0; |
1567 | } | 1226 | } |
1568 | 1227 | ||
1569 | static void iwl4965_build_tx_cmd_hwcrypto(struct iwl_priv *priv, | ||
1570 | struct ieee80211_tx_control *ctl, | ||
1571 | struct iwl_cmd *cmd, | ||
1572 | struct sk_buff *skb_frag, | ||
1573 | int sta_id) | ||
1574 | { | ||
1575 | struct iwl_hw_key *keyinfo = &priv->stations[sta_id].keyinfo; | ||
1576 | struct iwl_wep_key *wepkey; | ||
1577 | int keyidx = 0; | ||
1578 | |||
1579 | BUG_ON(ctl->hw_key->hw_key_idx > 3); | ||
1580 | |||
1581 | switch (keyinfo->alg) { | ||
1582 | case ALG_CCMP: | ||
1583 | cmd->cmd.tx.sec_ctl = TX_CMD_SEC_CCM; | ||
1584 | memcpy(cmd->cmd.tx.key, keyinfo->key, keyinfo->keylen); | ||
1585 | if (ctl->flags & IEEE80211_TXCTL_AMPDU) | ||
1586 | cmd->cmd.tx.tx_flags |= TX_CMD_FLG_AGG_CCMP_MSK; | ||
1587 | IWL_DEBUG_TX("tx_cmd with aes hwcrypto\n"); | ||
1588 | break; | ||
1589 | |||
1590 | case ALG_TKIP: | ||
1591 | cmd->cmd.tx.sec_ctl = TX_CMD_SEC_TKIP; | ||
1592 | ieee80211_get_tkip_key(keyinfo->conf, skb_frag, | ||
1593 | IEEE80211_TKIP_P2_KEY, cmd->cmd.tx.key); | ||
1594 | IWL_DEBUG_TX("tx_cmd with tkip hwcrypto\n"); | ||
1595 | break; | ||
1596 | |||
1597 | case ALG_WEP: | ||
1598 | wepkey = &priv->wep_keys[ctl->hw_key->hw_key_idx]; | ||
1599 | cmd->cmd.tx.sec_ctl = 0; | ||
1600 | if (priv->default_wep_key) { | ||
1601 | /* the WEP key was sent as static */ | ||
1602 | keyidx = ctl->hw_key->hw_key_idx; | ||
1603 | memcpy(&cmd->cmd.tx.key[3], wepkey->key, | ||
1604 | wepkey->key_size); | ||
1605 | if (wepkey->key_size == WEP_KEY_LEN_128) | ||
1606 | cmd->cmd.tx.sec_ctl |= TX_CMD_SEC_KEY128; | ||
1607 | } else { | ||
1608 | /* the WEP key was sent as dynamic */ | ||
1609 | keyidx = keyinfo->keyidx; | ||
1610 | memcpy(&cmd->cmd.tx.key[3], keyinfo->key, | ||
1611 | keyinfo->keylen); | ||
1612 | if (keyinfo->keylen == WEP_KEY_LEN_128) | ||
1613 | cmd->cmd.tx.sec_ctl |= TX_CMD_SEC_KEY128; | ||
1614 | } | ||
1615 | |||
1616 | cmd->cmd.tx.sec_ctl |= (TX_CMD_SEC_WEP | | ||
1617 | (keyidx & TX_CMD_SEC_MSK) << TX_CMD_SEC_SHIFT); | ||
1618 | |||
1619 | IWL_DEBUG_TX("Configuring packet for WEP encryption " | ||
1620 | "with key %d\n", keyidx); | ||
1621 | break; | ||
1622 | |||
1623 | default: | ||
1624 | printk(KERN_ERR "Unknown encode alg %d\n", keyinfo->alg); | ||
1625 | break; | ||
1626 | } | ||
1627 | } | ||
1628 | |||
1629 | /* | ||
1630 | * handle build REPLY_TX command notification. | ||
1631 | */ | ||
1632 | static void iwl4965_build_tx_cmd_basic(struct iwl_priv *priv, | ||
1633 | struct iwl_cmd *cmd, | ||
1634 | struct ieee80211_tx_control *ctrl, | ||
1635 | struct ieee80211_hdr *hdr, | ||
1636 | int is_unicast, u8 std_id) | ||
1637 | { | ||
1638 | __le16 *qc; | ||
1639 | u16 fc = le16_to_cpu(hdr->frame_control); | ||
1640 | __le32 tx_flags = cmd->cmd.tx.tx_flags; | ||
1641 | |||
1642 | cmd->cmd.tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; | ||
1643 | if (!(ctrl->flags & IEEE80211_TXCTL_NO_ACK)) { | ||
1644 | tx_flags |= TX_CMD_FLG_ACK_MSK; | ||
1645 | if ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) | ||
1646 | tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; | ||
1647 | if (ieee80211_is_probe_response(fc) && | ||
1648 | !(le16_to_cpu(hdr->seq_ctrl) & 0xf)) | ||
1649 | tx_flags |= TX_CMD_FLG_TSF_MSK; | ||
1650 | } else { | ||
1651 | tx_flags &= (~TX_CMD_FLG_ACK_MSK); | ||
1652 | tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; | ||
1653 | } | ||
1654 | |||
1655 | if (ieee80211_is_back_request(fc)) | ||
1656 | tx_flags |= TX_CMD_FLG_ACK_MSK | TX_CMD_FLG_IMM_BA_RSP_MASK; | ||
1657 | |||
1658 | |||
1659 | cmd->cmd.tx.sta_id = std_id; | ||
1660 | if (ieee80211_get_morefrag(hdr)) | ||
1661 | tx_flags |= TX_CMD_FLG_MORE_FRAG_MSK; | ||
1662 | |||
1663 | qc = ieee80211_get_qos_ctrl(hdr); | ||
1664 | if (qc) { | ||
1665 | cmd->cmd.tx.tid_tspec = (u8) (le16_to_cpu(*qc) & 0xf); | ||
1666 | tx_flags &= ~TX_CMD_FLG_SEQ_CTL_MSK; | ||
1667 | } else | ||
1668 | tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; | ||
1669 | |||
1670 | if (ctrl->flags & IEEE80211_TXCTL_USE_RTS_CTS) { | ||
1671 | tx_flags |= TX_CMD_FLG_RTS_MSK; | ||
1672 | tx_flags &= ~TX_CMD_FLG_CTS_MSK; | ||
1673 | } else if (ctrl->flags & IEEE80211_TXCTL_USE_CTS_PROTECT) { | ||
1674 | tx_flags &= ~TX_CMD_FLG_RTS_MSK; | ||
1675 | tx_flags |= TX_CMD_FLG_CTS_MSK; | ||
1676 | } | ||
1677 | |||
1678 | if ((tx_flags & TX_CMD_FLG_RTS_MSK) || (tx_flags & TX_CMD_FLG_CTS_MSK)) | ||
1679 | tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK; | ||
1680 | |||
1681 | tx_flags &= ~(TX_CMD_FLG_ANT_SEL_MSK); | ||
1682 | if ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) { | ||
1683 | if ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_ASSOC_REQ || | ||
1684 | (fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_REASSOC_REQ) | ||
1685 | cmd->cmd.tx.timeout.pm_frame_timeout = cpu_to_le16(3); | ||
1686 | else | ||
1687 | cmd->cmd.tx.timeout.pm_frame_timeout = cpu_to_le16(2); | ||
1688 | } else { | ||
1689 | cmd->cmd.tx.timeout.pm_frame_timeout = 0; | ||
1690 | } | ||
1691 | |||
1692 | cmd->cmd.tx.driver_txop = 0; | ||
1693 | cmd->cmd.tx.tx_flags = tx_flags; | ||
1694 | cmd->cmd.tx.next_frame_len = 0; | ||
1695 | } | ||
1696 | static void iwl_update_tx_stats(struct iwl_priv *priv, u16 fc, u16 len) | ||
1697 | { | ||
1698 | /* 0 - mgmt, 1 - cnt, 2 - data */ | ||
1699 | int idx = (fc & IEEE80211_FCTL_FTYPE) >> 2; | ||
1700 | priv->tx_stats[idx].cnt++; | ||
1701 | priv->tx_stats[idx].bytes += len; | ||
1702 | } | ||
1703 | /** | ||
1704 | * iwl4965_get_sta_id - Find station's index within station table | ||
1705 | * | ||
1706 | * If new IBSS station, create new entry in station table | ||
1707 | */ | ||
1708 | static int iwl4965_get_sta_id(struct iwl_priv *priv, | ||
1709 | struct ieee80211_hdr *hdr) | ||
1710 | { | ||
1711 | int sta_id; | ||
1712 | u16 fc = le16_to_cpu(hdr->frame_control); | ||
1713 | DECLARE_MAC_BUF(mac); | ||
1714 | |||
1715 | /* If this frame is broadcast or management, use broadcast station id */ | ||
1716 | if (((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA) || | ||
1717 | is_multicast_ether_addr(hdr->addr1)) | ||
1718 | return priv->hw_params.bcast_sta_id; | ||
1719 | |||
1720 | switch (priv->iw_mode) { | ||
1721 | |||
1722 | /* If we are a client station in a BSS network, use the special | ||
1723 | * AP station entry (that's the only station we communicate with) */ | ||
1724 | case IEEE80211_IF_TYPE_STA: | ||
1725 | return IWL_AP_ID; | ||
1726 | |||
1727 | /* If we are an AP, then find the station, or use BCAST */ | ||
1728 | case IEEE80211_IF_TYPE_AP: | ||
1729 | sta_id = iwl_find_station(priv, hdr->addr1); | ||
1730 | if (sta_id != IWL_INVALID_STATION) | ||
1731 | return sta_id; | ||
1732 | return priv->hw_params.bcast_sta_id; | ||
1733 | |||
1734 | /* If this frame is going out to an IBSS network, find the station, | ||
1735 | * or create a new station table entry */ | ||
1736 | case IEEE80211_IF_TYPE_IBSS: | ||
1737 | sta_id = iwl_find_station(priv, hdr->addr1); | ||
1738 | if (sta_id != IWL_INVALID_STATION) | ||
1739 | return sta_id; | ||
1740 | |||
1741 | /* Create new station table entry */ | ||
1742 | sta_id = iwl4965_add_station_flags(priv, hdr->addr1, | ||
1743 | 0, CMD_ASYNC, NULL); | ||
1744 | |||
1745 | if (sta_id != IWL_INVALID_STATION) | ||
1746 | return sta_id; | ||
1747 | |||
1748 | IWL_DEBUG_DROP("Station %s not in station map. " | ||
1749 | "Defaulting to broadcast...\n", | ||
1750 | print_mac(mac, hdr->addr1)); | ||
1751 | iwl_print_hex_dump(priv, IWL_DL_DROP, (u8 *) hdr, sizeof(*hdr)); | ||
1752 | return priv->hw_params.bcast_sta_id; | ||
1753 | |||
1754 | default: | ||
1755 | IWL_WARNING("Unknown mode of operation: %d", priv->iw_mode); | ||
1756 | return priv->hw_params.bcast_sta_id; | ||
1757 | } | ||
1758 | } | ||
1759 | |||
1760 | /* | ||
1761 | * start REPLY_TX command process | ||
1762 | */ | ||
1763 | static int iwl4965_tx_skb(struct iwl_priv *priv, | ||
1764 | struct sk_buff *skb, struct ieee80211_tx_control *ctl) | ||
1765 | { | ||
1766 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; | ||
1767 | struct iwl_tfd_frame *tfd; | ||
1768 | u32 *control_flags; | ||
1769 | int txq_id = ctl->queue; | ||
1770 | struct iwl_tx_queue *txq = NULL; | ||
1771 | struct iwl4965_queue *q = NULL; | ||
1772 | dma_addr_t phys_addr; | ||
1773 | dma_addr_t txcmd_phys; | ||
1774 | dma_addr_t scratch_phys; | ||
1775 | struct iwl_cmd *out_cmd = NULL; | ||
1776 | u16 len, idx, len_org; | ||
1777 | u8 id, hdr_len, unicast; | ||
1778 | u8 sta_id; | ||
1779 | u16 seq_number = 0; | ||
1780 | u16 fc; | ||
1781 | __le16 *qc; | ||
1782 | u8 wait_write_ptr = 0; | ||
1783 | unsigned long flags; | ||
1784 | int rc; | ||
1785 | |||
1786 | spin_lock_irqsave(&priv->lock, flags); | ||
1787 | if (iwl_is_rfkill(priv)) { | ||
1788 | IWL_DEBUG_DROP("Dropping - RF KILL\n"); | ||
1789 | goto drop_unlock; | ||
1790 | } | ||
1791 | |||
1792 | if (!priv->vif) { | ||
1793 | IWL_DEBUG_DROP("Dropping - !priv->vif\n"); | ||
1794 | goto drop_unlock; | ||
1795 | } | ||
1796 | |||
1797 | if ((ctl->tx_rate->hw_value & 0xFF) == IWL_INVALID_RATE) { | ||
1798 | IWL_ERROR("ERROR: No TX rate available.\n"); | ||
1799 | goto drop_unlock; | ||
1800 | } | ||
1801 | |||
1802 | unicast = !is_multicast_ether_addr(hdr->addr1); | ||
1803 | id = 0; | ||
1804 | |||
1805 | fc = le16_to_cpu(hdr->frame_control); | ||
1806 | |||
1807 | #ifdef CONFIG_IWLWIFI_DEBUG | ||
1808 | if (ieee80211_is_auth(fc)) | ||
1809 | IWL_DEBUG_TX("Sending AUTH frame\n"); | ||
1810 | else if (ieee80211_is_assoc_request(fc)) | ||
1811 | IWL_DEBUG_TX("Sending ASSOC frame\n"); | ||
1812 | else if (ieee80211_is_reassoc_request(fc)) | ||
1813 | IWL_DEBUG_TX("Sending REASSOC frame\n"); | ||
1814 | #endif | ||
1815 | |||
1816 | /* drop all data frame if we are not associated */ | ||
1817 | if (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) && | ||
1818 | (!iwl_is_associated(priv) || | ||
1819 | ((priv->iw_mode == IEEE80211_IF_TYPE_STA) && !priv->assoc_id) || | ||
1820 | !priv->assoc_station_added)) { | ||
1821 | IWL_DEBUG_DROP("Dropping - !iwl_is_associated\n"); | ||
1822 | goto drop_unlock; | ||
1823 | } | ||
1824 | |||
1825 | spin_unlock_irqrestore(&priv->lock, flags); | ||
1826 | |||
1827 | hdr_len = ieee80211_get_hdrlen(fc); | ||
1828 | |||
1829 | /* Find (or create) index into station table for destination station */ | ||
1830 | sta_id = iwl4965_get_sta_id(priv, hdr); | ||
1831 | if (sta_id == IWL_INVALID_STATION) { | ||
1832 | DECLARE_MAC_BUF(mac); | ||
1833 | |||
1834 | IWL_DEBUG_DROP("Dropping - INVALID STATION: %s\n", | ||
1835 | print_mac(mac, hdr->addr1)); | ||
1836 | goto drop; | ||
1837 | } | ||
1838 | |||
1839 | IWL_DEBUG_TX("station Id %d\n", sta_id); | ||
1840 | |||
1841 | qc = ieee80211_get_qos_ctrl(hdr); | ||
1842 | if (qc) { | ||
1843 | u8 tid = (u8)(le16_to_cpu(*qc) & 0xf); | ||
1844 | seq_number = priv->stations[sta_id].tid[tid].seq_number & | ||
1845 | IEEE80211_SCTL_SEQ; | ||
1846 | hdr->seq_ctrl = cpu_to_le16(seq_number) | | ||
1847 | (hdr->seq_ctrl & | ||
1848 | __constant_cpu_to_le16(IEEE80211_SCTL_FRAG)); | ||
1849 | seq_number += 0x10; | ||
1850 | #ifdef CONFIG_IWL4965_HT | ||
1851 | /* aggregation is on for this <sta,tid> */ | ||
1852 | if (ctl->flags & IEEE80211_TXCTL_AMPDU) | ||
1853 | txq_id = priv->stations[sta_id].tid[tid].agg.txq_id; | ||
1854 | priv->stations[sta_id].tid[tid].tfds_in_queue++; | ||
1855 | #endif /* CONFIG_IWL4965_HT */ | ||
1856 | } | ||
1857 | |||
1858 | /* Descriptor for chosen Tx queue */ | ||
1859 | txq = &priv->txq[txq_id]; | ||
1860 | q = &txq->q; | ||
1861 | |||
1862 | spin_lock_irqsave(&priv->lock, flags); | ||
1863 | |||
1864 | /* Set up first empty TFD within this queue's circular TFD buffer */ | ||
1865 | tfd = &txq->bd[q->write_ptr]; | ||
1866 | memset(tfd, 0, sizeof(*tfd)); | ||
1867 | control_flags = (u32 *) tfd; | ||
1868 | idx = get_cmd_index(q, q->write_ptr, 0); | ||
1869 | |||
1870 | /* Set up driver data for this TFD */ | ||
1871 | memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct iwl4965_tx_info)); | ||
1872 | txq->txb[q->write_ptr].skb[0] = skb; | ||
1873 | memcpy(&(txq->txb[q->write_ptr].status.control), | ||
1874 | ctl, sizeof(struct ieee80211_tx_control)); | ||
1875 | |||
1876 | /* Set up first empty entry in queue's array of Tx/cmd buffers */ | ||
1877 | out_cmd = &txq->cmd[idx]; | ||
1878 | memset(&out_cmd->hdr, 0, sizeof(out_cmd->hdr)); | ||
1879 | memset(&out_cmd->cmd.tx, 0, sizeof(out_cmd->cmd.tx)); | ||
1880 | |||
1881 | /* | ||
1882 | * Set up the Tx-command (not MAC!) header. | ||
1883 | * Store the chosen Tx queue and TFD index within the sequence field; | ||
1884 | * after Tx, uCode's Tx response will return this value so driver can | ||
1885 | * locate the frame within the tx queue and do post-tx processing. | ||
1886 | */ | ||
1887 | out_cmd->hdr.cmd = REPLY_TX; | ||
1888 | out_cmd->hdr.sequence = cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) | | ||
1889 | INDEX_TO_SEQ(q->write_ptr))); | ||
1890 | |||
1891 | /* Copy MAC header from skb into command buffer */ | ||
1892 | memcpy(out_cmd->cmd.tx.hdr, hdr, hdr_len); | ||
1893 | |||
1894 | /* | ||
1895 | * Use the first empty entry in this queue's command buffer array | ||
1896 | * to contain the Tx command and MAC header concatenated together | ||
1897 | * (payload data will be in another buffer). | ||
1898 | * Size of this varies, due to varying MAC header length. | ||
1899 | * If end is not dword aligned, we'll have 2 extra bytes at the end | ||
1900 | * of the MAC header (device reads on dword boundaries). | ||
1901 | * We'll tell device about this padding later. | ||
1902 | */ | ||
1903 | len = priv->hw_params.tx_cmd_len + | ||
1904 | sizeof(struct iwl_cmd_header) + hdr_len; | ||
1905 | |||
1906 | len_org = len; | ||
1907 | len = (len + 3) & ~3; | ||
1908 | |||
1909 | if (len_org != len) | ||
1910 | len_org = 1; | ||
1911 | else | ||
1912 | len_org = 0; | ||
1913 | |||
1914 | /* Physical address of this Tx command's header (not MAC header!), | ||
1915 | * within command buffer array. */ | ||
1916 | txcmd_phys = txq->dma_addr_cmd + sizeof(struct iwl_cmd) * idx + | ||
1917 | offsetof(struct iwl_cmd, hdr); | ||
1918 | |||
1919 | /* Add buffer containing Tx command and MAC(!) header to TFD's | ||
1920 | * first entry */ | ||
1921 | iwl4965_hw_txq_attach_buf_to_tfd(priv, tfd, txcmd_phys, len); | ||
1922 | |||
1923 | if (!(ctl->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT)) | ||
1924 | iwl4965_build_tx_cmd_hwcrypto(priv, ctl, out_cmd, skb, sta_id); | ||
1925 | |||
1926 | /* Set up TFD's 2nd entry to point directly to remainder of skb, | ||
1927 | * if any (802.11 null frames have no payload). */ | ||
1928 | len = skb->len - hdr_len; | ||
1929 | if (len) { | ||
1930 | phys_addr = pci_map_single(priv->pci_dev, skb->data + hdr_len, | ||
1931 | len, PCI_DMA_TODEVICE); | ||
1932 | iwl4965_hw_txq_attach_buf_to_tfd(priv, tfd, phys_addr, len); | ||
1933 | } | ||
1934 | |||
1935 | /* Tell 4965 about any 2-byte padding after MAC header */ | ||
1936 | if (len_org) | ||
1937 | out_cmd->cmd.tx.tx_flags |= TX_CMD_FLG_MH_PAD_MSK; | ||
1938 | |||
1939 | /* Total # bytes to be transmitted */ | ||
1940 | len = (u16)skb->len; | ||
1941 | out_cmd->cmd.tx.len = cpu_to_le16(len); | ||
1942 | |||
1943 | /* TODO need this for burst mode later on */ | ||
1944 | iwl4965_build_tx_cmd_basic(priv, out_cmd, ctl, hdr, unicast, sta_id); | ||
1945 | |||
1946 | /* set is_hcca to 0; it probably will never be implemented */ | ||
1947 | iwl4965_hw_build_tx_cmd_rate(priv, out_cmd, ctl, hdr, sta_id, 0); | ||
1948 | |||
1949 | iwl_update_tx_stats(priv, fc, len); | ||
1950 | |||
1951 | scratch_phys = txcmd_phys + sizeof(struct iwl_cmd_header) + | ||
1952 | offsetof(struct iwl4965_tx_cmd, scratch); | ||
1953 | out_cmd->cmd.tx.dram_lsb_ptr = cpu_to_le32(scratch_phys); | ||
1954 | out_cmd->cmd.tx.dram_msb_ptr = iwl_get_dma_hi_address(scratch_phys); | ||
1955 | |||
1956 | if (!ieee80211_get_morefrag(hdr)) { | ||
1957 | txq->need_update = 1; | ||
1958 | if (qc) { | ||
1959 | u8 tid = (u8)(le16_to_cpu(*qc) & 0xf); | ||
1960 | priv->stations[sta_id].tid[tid].seq_number = seq_number; | ||
1961 | } | ||
1962 | } else { | ||
1963 | wait_write_ptr = 1; | ||
1964 | txq->need_update = 0; | ||
1965 | } | ||
1966 | |||
1967 | iwl_print_hex_dump(priv, IWL_DL_TX, out_cmd->cmd.payload, | ||
1968 | sizeof(out_cmd->cmd.tx)); | ||
1969 | |||
1970 | iwl_print_hex_dump(priv, IWL_DL_TX, (u8 *)out_cmd->cmd.tx.hdr, | ||
1971 | ieee80211_get_hdrlen(fc)); | ||
1972 | |||
1973 | /* Set up entry for this TFD in Tx byte-count array */ | ||
1974 | priv->cfg->ops->lib->txq_update_byte_cnt_tbl(priv, txq, len); | ||
1975 | |||
1976 | /* Tell device the write index *just past* this latest filled TFD */ | ||
1977 | q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd); | ||
1978 | rc = iwl4965_tx_queue_update_write_ptr(priv, txq); | ||
1979 | spin_unlock_irqrestore(&priv->lock, flags); | ||
1980 | |||
1981 | if (rc) | ||
1982 | return rc; | ||
1983 | |||
1984 | if ((iwl4965_queue_space(q) < q->high_mark) | ||
1985 | && priv->mac80211_registered) { | ||
1986 | if (wait_write_ptr) { | ||
1987 | spin_lock_irqsave(&priv->lock, flags); | ||
1988 | txq->need_update = 1; | ||
1989 | iwl4965_tx_queue_update_write_ptr(priv, txq); | ||
1990 | spin_unlock_irqrestore(&priv->lock, flags); | ||
1991 | } | ||
1992 | |||
1993 | ieee80211_stop_queue(priv->hw, ctl->queue); | ||
1994 | } | ||
1995 | |||
1996 | return 0; | ||
1997 | |||
1998 | drop_unlock: | ||
1999 | spin_unlock_irqrestore(&priv->lock, flags); | ||
2000 | drop: | ||
2001 | return -1; | ||
2002 | } | ||
2003 | |||
2004 | static void iwl4965_set_rate(struct iwl_priv *priv) | 1228 | static void iwl4965_set_rate(struct iwl_priv *priv) |
2005 | { | 1229 | { |
2006 | const struct ieee80211_supported_band *hw = NULL; | 1230 | const struct ieee80211_supported_band *hw = NULL; |
@@ -2305,341 +1529,16 @@ static int iwl4965_get_measurement(struct iwl_priv *priv, | |||
2305 | } | 1529 | } |
2306 | #endif | 1530 | #endif |
2307 | 1531 | ||
2308 | static void iwl4965_txstatus_to_ieee(struct iwl_priv *priv, | ||
2309 | struct iwl4965_tx_info *tx_sta) | ||
2310 | { | ||
2311 | |||
2312 | tx_sta->status.ack_signal = 0; | ||
2313 | tx_sta->status.excessive_retries = 0; | ||
2314 | |||
2315 | if (in_interrupt()) | ||
2316 | ieee80211_tx_status_irqsafe(priv->hw, | ||
2317 | tx_sta->skb[0], &(tx_sta->status)); | ||
2318 | else | ||
2319 | ieee80211_tx_status(priv->hw, | ||
2320 | tx_sta->skb[0], &(tx_sta->status)); | ||
2321 | |||
2322 | tx_sta->skb[0] = NULL; | ||
2323 | } | ||
2324 | |||
2325 | /** | ||
2326 | * iwl4965_tx_queue_reclaim - Reclaim Tx queue entries already Tx'd | ||
2327 | * | ||
2328 | * When FW advances 'R' index, all entries between old and new 'R' index | ||
2329 | * need to be reclaimed. As result, some free space forms. If there is | ||
2330 | * enough free space (> low mark), wake the stack that feeds us. | ||
2331 | */ | ||
2332 | int iwl4965_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index) | ||
2333 | { | ||
2334 | struct iwl_tx_queue *txq = &priv->txq[txq_id]; | ||
2335 | struct iwl4965_queue *q = &txq->q; | ||
2336 | int nfreed = 0; | ||
2337 | |||
2338 | if ((index >= q->n_bd) || (x2_queue_used(q, index) == 0)) { | ||
2339 | IWL_ERROR("Read index for DMA queue txq id (%d), index %d, " | ||
2340 | "is out of range [0-%d] %d %d.\n", txq_id, | ||
2341 | index, q->n_bd, q->write_ptr, q->read_ptr); | ||
2342 | return 0; | ||
2343 | } | ||
2344 | |||
2345 | for (index = iwl_queue_inc_wrap(index, q->n_bd); | ||
2346 | q->read_ptr != index; | ||
2347 | q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) { | ||
2348 | if (txq_id != IWL_CMD_QUEUE_NUM) { | ||
2349 | iwl4965_txstatus_to_ieee(priv, | ||
2350 | &(txq->txb[txq->q.read_ptr])); | ||
2351 | iwl_hw_txq_free_tfd(priv, txq); | ||
2352 | } else if (nfreed > 1) { | ||
2353 | IWL_ERROR("HCMD skipped: index (%d) %d %d\n", index, | ||
2354 | q->write_ptr, q->read_ptr); | ||
2355 | queue_work(priv->workqueue, &priv->restart); | ||
2356 | } | ||
2357 | nfreed++; | ||
2358 | } | ||
2359 | |||
2360 | return nfreed; | ||
2361 | } | ||
2362 | |||
2363 | static int iwl4965_is_tx_success(u32 status) | ||
2364 | { | ||
2365 | status &= TX_STATUS_MSK; | ||
2366 | return (status == TX_STATUS_SUCCESS) | ||
2367 | || (status == TX_STATUS_DIRECT_DONE); | ||
2368 | } | ||
2369 | |||
2370 | /****************************************************************************** | 1532 | /****************************************************************************** |
2371 | * | 1533 | * |
2372 | * Generic RX handler implementations | 1534 | * Generic RX handler implementations |
2373 | * | 1535 | * |
2374 | ******************************************************************************/ | 1536 | ******************************************************************************/ |
2375 | #ifdef CONFIG_IWL4965_HT | 1537 | static void iwl_rx_reply_alive(struct iwl_priv *priv, |
2376 | |||
2377 | static inline int iwl4965_get_ra_sta_id(struct iwl_priv *priv, | ||
2378 | struct ieee80211_hdr *hdr) | ||
2379 | { | ||
2380 | if (priv->iw_mode == IEEE80211_IF_TYPE_STA) | ||
2381 | return IWL_AP_ID; | ||
2382 | else { | ||
2383 | u8 *da = ieee80211_get_DA(hdr); | ||
2384 | return iwl_find_station(priv, da); | ||
2385 | } | ||
2386 | } | ||
2387 | |||
2388 | static struct ieee80211_hdr *iwl4965_tx_queue_get_hdr( | ||
2389 | struct iwl_priv *priv, int txq_id, int idx) | ||
2390 | { | ||
2391 | if (priv->txq[txq_id].txb[idx].skb[0]) | ||
2392 | return (struct ieee80211_hdr *)priv->txq[txq_id]. | ||
2393 | txb[idx].skb[0]->data; | ||
2394 | return NULL; | ||
2395 | } | ||
2396 | |||
2397 | static inline u32 iwl4965_get_scd_ssn(struct iwl4965_tx_resp *tx_resp) | ||
2398 | { | ||
2399 | __le32 *scd_ssn = (__le32 *)((u32 *)&tx_resp->status + | ||
2400 | tx_resp->frame_count); | ||
2401 | return le32_to_cpu(*scd_ssn) & MAX_SN; | ||
2402 | |||
2403 | } | ||
2404 | |||
2405 | /** | ||
2406 | * iwl4965_tx_status_reply_tx - Handle Tx rspnse for frames in aggregation queue | ||
2407 | */ | ||
2408 | static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv, | ||
2409 | struct iwl_ht_agg *agg, | ||
2410 | struct iwl4965_tx_resp_agg *tx_resp, | ||
2411 | u16 start_idx) | ||
2412 | { | ||
2413 | u16 status; | ||
2414 | struct agg_tx_status *frame_status = &tx_resp->status; | ||
2415 | struct ieee80211_tx_status *tx_status = NULL; | ||
2416 | struct ieee80211_hdr *hdr = NULL; | ||
2417 | int i, sh; | ||
2418 | int txq_id, idx; | ||
2419 | u16 seq; | ||
2420 | |||
2421 | if (agg->wait_for_ba) | ||
2422 | IWL_DEBUG_TX_REPLY("got tx response w/o block-ack\n"); | ||
2423 | |||
2424 | agg->frame_count = tx_resp->frame_count; | ||
2425 | agg->start_idx = start_idx; | ||
2426 | agg->rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags); | ||
2427 | agg->bitmap = 0; | ||
2428 | |||
2429 | /* # frames attempted by Tx command */ | ||
2430 | if (agg->frame_count == 1) { | ||
2431 | /* Only one frame was attempted; no block-ack will arrive */ | ||
2432 | status = le16_to_cpu(frame_status[0].status); | ||
2433 | seq = le16_to_cpu(frame_status[0].sequence); | ||
2434 | idx = SEQ_TO_INDEX(seq); | ||
2435 | txq_id = SEQ_TO_QUEUE(seq); | ||
2436 | |||
2437 | /* FIXME: code repetition */ | ||
2438 | IWL_DEBUG_TX_REPLY("FrameCnt = %d, StartIdx=%d idx=%d\n", | ||
2439 | agg->frame_count, agg->start_idx, idx); | ||
2440 | |||
2441 | tx_status = &(priv->txq[txq_id].txb[idx].status); | ||
2442 | tx_status->retry_count = tx_resp->failure_frame; | ||
2443 | tx_status->control.flags &= ~IEEE80211_TXCTL_AMPDU; | ||
2444 | tx_status->flags = iwl4965_is_tx_success(status)? | ||
2445 | IEEE80211_TX_STATUS_ACK : 0; | ||
2446 | iwl4965_hwrate_to_tx_control(priv, | ||
2447 | le32_to_cpu(tx_resp->rate_n_flags), | ||
2448 | &tx_status->control); | ||
2449 | /* FIXME: code repetition end */ | ||
2450 | |||
2451 | IWL_DEBUG_TX_REPLY("1 Frame 0x%x failure :%d\n", | ||
2452 | status & 0xff, tx_resp->failure_frame); | ||
2453 | IWL_DEBUG_TX_REPLY("Rate Info rate_n_flags=%x\n", | ||
2454 | iwl4965_hw_get_rate_n_flags(tx_resp->rate_n_flags)); | ||
2455 | |||
2456 | agg->wait_for_ba = 0; | ||
2457 | } else { | ||
2458 | /* Two or more frames were attempted; expect block-ack */ | ||
2459 | u64 bitmap = 0; | ||
2460 | int start = agg->start_idx; | ||
2461 | |||
2462 | /* Construct bit-map of pending frames within Tx window */ | ||
2463 | for (i = 0; i < agg->frame_count; i++) { | ||
2464 | u16 sc; | ||
2465 | status = le16_to_cpu(frame_status[i].status); | ||
2466 | seq = le16_to_cpu(frame_status[i].sequence); | ||
2467 | idx = SEQ_TO_INDEX(seq); | ||
2468 | txq_id = SEQ_TO_QUEUE(seq); | ||
2469 | |||
2470 | if (status & (AGG_TX_STATE_FEW_BYTES_MSK | | ||
2471 | AGG_TX_STATE_ABORT_MSK)) | ||
2472 | continue; | ||
2473 | |||
2474 | IWL_DEBUG_TX_REPLY("FrameCnt = %d, txq_id=%d idx=%d\n", | ||
2475 | agg->frame_count, txq_id, idx); | ||
2476 | |||
2477 | hdr = iwl4965_tx_queue_get_hdr(priv, txq_id, idx); | ||
2478 | |||
2479 | sc = le16_to_cpu(hdr->seq_ctrl); | ||
2480 | if (idx != (SEQ_TO_SN(sc) & 0xff)) { | ||
2481 | IWL_ERROR("BUG_ON idx doesn't match seq control" | ||
2482 | " idx=%d, seq_idx=%d, seq=%d\n", | ||
2483 | idx, SEQ_TO_SN(sc), | ||
2484 | hdr->seq_ctrl); | ||
2485 | return -1; | ||
2486 | } | ||
2487 | |||
2488 | IWL_DEBUG_TX_REPLY("AGG Frame i=%d idx %d seq=%d\n", | ||
2489 | i, idx, SEQ_TO_SN(sc)); | ||
2490 | |||
2491 | sh = idx - start; | ||
2492 | if (sh > 64) { | ||
2493 | sh = (start - idx) + 0xff; | ||
2494 | bitmap = bitmap << sh; | ||
2495 | sh = 0; | ||
2496 | start = idx; | ||
2497 | } else if (sh < -64) | ||
2498 | sh = 0xff - (start - idx); | ||
2499 | else if (sh < 0) { | ||
2500 | sh = start - idx; | ||
2501 | start = idx; | ||
2502 | bitmap = bitmap << sh; | ||
2503 | sh = 0; | ||
2504 | } | ||
2505 | bitmap |= (1 << sh); | ||
2506 | IWL_DEBUG_TX_REPLY("start=%d bitmap=0x%x\n", | ||
2507 | start, (u32)(bitmap & 0xFFFFFFFF)); | ||
2508 | } | ||
2509 | |||
2510 | agg->bitmap = bitmap; | ||
2511 | agg->start_idx = start; | ||
2512 | agg->rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags); | ||
2513 | IWL_DEBUG_TX_REPLY("Frames %d start_idx=%d bitmap=0x%llx\n", | ||
2514 | agg->frame_count, agg->start_idx, | ||
2515 | (unsigned long long)agg->bitmap); | ||
2516 | |||
2517 | if (bitmap) | ||
2518 | agg->wait_for_ba = 1; | ||
2519 | } | ||
2520 | return 0; | ||
2521 | } | ||
2522 | #endif | ||
2523 | |||
2524 | /** | ||
2525 | * iwl4965_rx_reply_tx - Handle standard (non-aggregation) Tx response | ||
2526 | */ | ||
2527 | static void iwl4965_rx_reply_tx(struct iwl_priv *priv, | ||
2528 | struct iwl_rx_mem_buffer *rxb) | 1538 | struct iwl_rx_mem_buffer *rxb) |
2529 | { | 1539 | { |
2530 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; | 1540 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; |
2531 | u16 sequence = le16_to_cpu(pkt->hdr.sequence); | 1541 | struct iwl_alive_resp *palive; |
2532 | int txq_id = SEQ_TO_QUEUE(sequence); | ||
2533 | int index = SEQ_TO_INDEX(sequence); | ||
2534 | struct iwl_tx_queue *txq = &priv->txq[txq_id]; | ||
2535 | struct ieee80211_tx_status *tx_status; | ||
2536 | struct iwl4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; | ||
2537 | u32 status = le32_to_cpu(tx_resp->status); | ||
2538 | #ifdef CONFIG_IWL4965_HT | ||
2539 | int tid = MAX_TID_COUNT, sta_id = IWL_INVALID_STATION; | ||
2540 | struct ieee80211_hdr *hdr; | ||
2541 | __le16 *qc; | ||
2542 | #endif | ||
2543 | |||
2544 | if ((index >= txq->q.n_bd) || (x2_queue_used(&txq->q, index) == 0)) { | ||
2545 | IWL_ERROR("Read index for DMA queue txq_id (%d) index %d " | ||
2546 | "is out of range [0-%d] %d %d\n", txq_id, | ||
2547 | index, txq->q.n_bd, txq->q.write_ptr, | ||
2548 | txq->q.read_ptr); | ||
2549 | return; | ||
2550 | } | ||
2551 | |||
2552 | #ifdef CONFIG_IWL4965_HT | ||
2553 | hdr = iwl4965_tx_queue_get_hdr(priv, txq_id, index); | ||
2554 | qc = ieee80211_get_qos_ctrl(hdr); | ||
2555 | |||
2556 | if (qc) | ||
2557 | tid = le16_to_cpu(*qc) & 0xf; | ||
2558 | |||
2559 | sta_id = iwl4965_get_ra_sta_id(priv, hdr); | ||
2560 | if (txq->sched_retry && unlikely(sta_id == IWL_INVALID_STATION)) { | ||
2561 | IWL_ERROR("Station not known\n"); | ||
2562 | return; | ||
2563 | } | ||
2564 | |||
2565 | if (txq->sched_retry) { | ||
2566 | const u32 scd_ssn = iwl4965_get_scd_ssn(tx_resp); | ||
2567 | struct iwl_ht_agg *agg = NULL; | ||
2568 | |||
2569 | if (!qc) | ||
2570 | return; | ||
2571 | |||
2572 | agg = &priv->stations[sta_id].tid[tid].agg; | ||
2573 | |||
2574 | iwl4965_tx_status_reply_tx(priv, agg, | ||
2575 | (struct iwl4965_tx_resp_agg *)tx_resp, index); | ||
2576 | |||
2577 | if ((tx_resp->frame_count == 1) && | ||
2578 | !iwl4965_is_tx_success(status)) { | ||
2579 | /* TODO: send BAR */ | ||
2580 | } | ||
2581 | |||
2582 | if (txq->q.read_ptr != (scd_ssn & 0xff)) { | ||
2583 | int freed, ampdu_q; | ||
2584 | index = iwl_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd); | ||
2585 | IWL_DEBUG_TX_REPLY("Retry scheduler reclaim scd_ssn " | ||
2586 | "%d index %d\n", scd_ssn , index); | ||
2587 | freed = iwl4965_tx_queue_reclaim(priv, txq_id, index); | ||
2588 | priv->stations[sta_id].tid[tid].tfds_in_queue -= freed; | ||
2589 | |||
2590 | if (iwl4965_queue_space(&txq->q) > txq->q.low_mark && | ||
2591 | txq_id >= 0 && priv->mac80211_registered && | ||
2592 | agg->state != IWL_EMPTYING_HW_QUEUE_DELBA) { | ||
2593 | /* calculate mac80211 ampdu sw queue to wake */ | ||
2594 | ampdu_q = txq_id - IWL_BACK_QUEUE_FIRST_ID + | ||
2595 | priv->hw->queues; | ||
2596 | if (agg->state == IWL_AGG_OFF) | ||
2597 | ieee80211_wake_queue(priv->hw, txq_id); | ||
2598 | else | ||
2599 | ieee80211_wake_queue(priv->hw, ampdu_q); | ||
2600 | } | ||
2601 | iwl4965_check_empty_hw_queue(priv, sta_id, tid, txq_id); | ||
2602 | } | ||
2603 | } else { | ||
2604 | #endif /* CONFIG_IWL4965_HT */ | ||
2605 | tx_status = &(txq->txb[txq->q.read_ptr].status); | ||
2606 | |||
2607 | tx_status->retry_count = tx_resp->failure_frame; | ||
2608 | tx_status->flags = | ||
2609 | iwl4965_is_tx_success(status) ? IEEE80211_TX_STATUS_ACK : 0; | ||
2610 | iwl4965_hwrate_to_tx_control(priv, le32_to_cpu(tx_resp->rate_n_flags), | ||
2611 | &tx_status->control); | ||
2612 | |||
2613 | IWL_DEBUG_TX("Tx queue %d Status %s (0x%08x) rate_n_flags 0x%x " | ||
2614 | "retries %d\n", txq_id, iwl4965_get_tx_fail_reason(status), | ||
2615 | status, le32_to_cpu(tx_resp->rate_n_flags), | ||
2616 | tx_resp->failure_frame); | ||
2617 | |||
2618 | IWL_DEBUG_TX_REPLY("Tx queue reclaim %d\n", index); | ||
2619 | #ifdef CONFIG_IWL4965_HT | ||
2620 | if (index != -1) { | ||
2621 | int freed = iwl4965_tx_queue_reclaim(priv, txq_id, index); | ||
2622 | if (tid != MAX_TID_COUNT) | ||
2623 | priv->stations[sta_id].tid[tid].tfds_in_queue -= freed; | ||
2624 | if (iwl4965_queue_space(&txq->q) > txq->q.low_mark && | ||
2625 | (txq_id >= 0) && priv->mac80211_registered) | ||
2626 | ieee80211_wake_queue(priv->hw, txq_id); | ||
2627 | if (tid != MAX_TID_COUNT) | ||
2628 | iwl4965_check_empty_hw_queue(priv, sta_id, tid, txq_id); | ||
2629 | } | ||
2630 | } | ||
2631 | #endif /* CONFIG_IWL4965_HT */ | ||
2632 | |||
2633 | if (iwl_check_bits(status, TX_ABORT_REQUIRED_MSK)) | ||
2634 | IWL_ERROR("TODO: Implement Tx ABORT REQUIRED!!!\n"); | ||
2635 | } | ||
2636 | |||
2637 | |||
2638 | static void iwl4965_rx_reply_alive(struct iwl_priv *priv, | ||
2639 | struct iwl_rx_mem_buffer *rxb) | ||
2640 | { | ||
2641 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; | ||
2642 | struct iwl4965_alive_resp *palive; | ||
2643 | struct delayed_work *pwork; | 1542 | struct delayed_work *pwork; |
2644 | 1543 | ||
2645 | palive = &pkt->u.alive_frame; | 1544 | palive = &pkt->u.alive_frame; |
@@ -2653,12 +1552,12 @@ static void iwl4965_rx_reply_alive(struct iwl_priv *priv, | |||
2653 | IWL_DEBUG_INFO("Initialization Alive received.\n"); | 1552 | IWL_DEBUG_INFO("Initialization Alive received.\n"); |
2654 | memcpy(&priv->card_alive_init, | 1553 | memcpy(&priv->card_alive_init, |
2655 | &pkt->u.alive_frame, | 1554 | &pkt->u.alive_frame, |
2656 | sizeof(struct iwl4965_init_alive_resp)); | 1555 | sizeof(struct iwl_init_alive_resp)); |
2657 | pwork = &priv->init_alive_start; | 1556 | pwork = &priv->init_alive_start; |
2658 | } else { | 1557 | } else { |
2659 | IWL_DEBUG_INFO("Runtime Alive received.\n"); | 1558 | IWL_DEBUG_INFO("Runtime Alive received.\n"); |
2660 | memcpy(&priv->card_alive, &pkt->u.alive_frame, | 1559 | memcpy(&priv->card_alive, &pkt->u.alive_frame, |
2661 | sizeof(struct iwl4965_alive_resp)); | 1560 | sizeof(struct iwl_alive_resp)); |
2662 | pwork = &priv->alive_start; | 1561 | pwork = &priv->alive_start; |
2663 | } | 1562 | } |
2664 | 1563 | ||
@@ -2671,15 +1570,6 @@ static void iwl4965_rx_reply_alive(struct iwl_priv *priv, | |||
2671 | IWL_WARNING("uCode did not respond OK.\n"); | 1570 | IWL_WARNING("uCode did not respond OK.\n"); |
2672 | } | 1571 | } |
2673 | 1572 | ||
2674 | static void iwl4965_rx_reply_add_sta(struct iwl_priv *priv, | ||
2675 | struct iwl_rx_mem_buffer *rxb) | ||
2676 | { | ||
2677 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; | ||
2678 | |||
2679 | IWL_DEBUG_RX("Received REPLY_ADD_STA: 0x%02X\n", pkt->u.status); | ||
2680 | return; | ||
2681 | } | ||
2682 | |||
2683 | static void iwl4965_rx_reply_error(struct iwl_priv *priv, | 1573 | static void iwl4965_rx_reply_error(struct iwl_priv *priv, |
2684 | struct iwl_rx_mem_buffer *rxb) | 1574 | struct iwl_rx_mem_buffer *rxb) |
2685 | { | 1575 | { |
@@ -2699,7 +1589,7 @@ static void iwl4965_rx_reply_error(struct iwl_priv *priv, | |||
2699 | static void iwl4965_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) | 1589 | static void iwl4965_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) |
2700 | { | 1590 | { |
2701 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; | 1591 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; |
2702 | struct iwl4965_rxon_cmd *rxon = (void *)&priv->active_rxon; | 1592 | struct iwl_rxon_cmd *rxon = (void *)&priv->active_rxon; |
2703 | struct iwl4965_csa_notification *csa = &(pkt->u.csa_notif); | 1593 | struct iwl4965_csa_notification *csa = &(pkt->u.csa_notif); |
2704 | IWL_DEBUG_11H("CSA notif: channel %d, status %d\n", | 1594 | IWL_DEBUG_11H("CSA notif: channel %d, status %d\n", |
2705 | le16_to_cpu(csa->channel), le32_to_cpu(csa->status)); | 1595 | le16_to_cpu(csa->channel), le32_to_cpu(csa->status)); |
@@ -2753,7 +1643,7 @@ static void iwl4965_bg_beacon_update(struct work_struct *work) | |||
2753 | struct sk_buff *beacon; | 1643 | struct sk_buff *beacon; |
2754 | 1644 | ||
2755 | /* Pull updated AP beacon from mac80211. will fail if not in AP mode */ | 1645 | /* Pull updated AP beacon from mac80211. will fail if not in AP mode */ |
2756 | beacon = ieee80211_beacon_get(priv->hw, priv->vif, NULL); | 1646 | beacon = ieee80211_beacon_get(priv->hw, priv->vif); |
2757 | 1647 | ||
2758 | if (!beacon) { | 1648 | if (!beacon) { |
2759 | IWL_ERROR("update beacon failed\n"); | 1649 | IWL_ERROR("update beacon failed\n"); |
@@ -2976,6 +1866,17 @@ static void iwl4965_rx_card_state_notif(struct iwl_priv *priv, | |||
2976 | wake_up_interruptible(&priv->wait_command_queue); | 1866 | wake_up_interruptible(&priv->wait_command_queue); |
2977 | } | 1867 | } |
2978 | 1868 | ||
1869 | /* Cache phy data (Rx signal strength, etc) for HT frame (REPLY_RX_PHY_CMD). | ||
1870 | * This will be used later in iwl4965_rx_reply_rx() for REPLY_RX_MPDU_CMD. */ | ||
1871 | static void iwl4965_rx_reply_rx_phy(struct iwl_priv *priv, | ||
1872 | struct iwl_rx_mem_buffer *rxb) | ||
1873 | { | ||
1874 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; | ||
1875 | priv->last_phy_res[0] = 1; | ||
1876 | memcpy(&priv->last_phy_res[1], &(pkt->u.raw[0]), | ||
1877 | sizeof(struct iwl4965_rx_phy_res)); | ||
1878 | } | ||
1879 | |||
2979 | /** | 1880 | /** |
2980 | * iwl4965_setup_rx_handlers - Initialize Rx handler callbacks | 1881 | * iwl4965_setup_rx_handlers - Initialize Rx handler callbacks |
2981 | * | 1882 | * |
@@ -2987,8 +1888,7 @@ static void iwl4965_rx_card_state_notif(struct iwl_priv *priv, | |||
2987 | */ | 1888 | */ |
2988 | static void iwl4965_setup_rx_handlers(struct iwl_priv *priv) | 1889 | static void iwl4965_setup_rx_handlers(struct iwl_priv *priv) |
2989 | { | 1890 | { |
2990 | priv->rx_handlers[REPLY_ALIVE] = iwl4965_rx_reply_alive; | 1891 | priv->rx_handlers[REPLY_ALIVE] = iwl_rx_reply_alive; |
2991 | priv->rx_handlers[REPLY_ADD_STA] = iwl4965_rx_reply_add_sta; | ||
2992 | priv->rx_handlers[REPLY_ERROR] = iwl4965_rx_reply_error; | 1892 | priv->rx_handlers[REPLY_ERROR] = iwl4965_rx_reply_error; |
2993 | priv->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = iwl4965_rx_csa; | 1893 | priv->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = iwl4965_rx_csa; |
2994 | priv->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] = | 1894 | priv->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] = |
@@ -3005,66 +1905,25 @@ static void iwl4965_setup_rx_handlers(struct iwl_priv *priv) | |||
3005 | */ | 1905 | */ |
3006 | priv->rx_handlers[REPLY_STATISTICS_CMD] = iwl4965_hw_rx_statistics; | 1906 | priv->rx_handlers[REPLY_STATISTICS_CMD] = iwl4965_hw_rx_statistics; |
3007 | priv->rx_handlers[STATISTICS_NOTIFICATION] = iwl4965_hw_rx_statistics; | 1907 | priv->rx_handlers[STATISTICS_NOTIFICATION] = iwl4965_hw_rx_statistics; |
3008 | 1908 | /* scan handlers */ | |
3009 | priv->rx_handlers[REPLY_SCAN_CMD] = iwl4965_rx_reply_scan; | 1909 | priv->rx_handlers[REPLY_SCAN_CMD] = iwl4965_rx_reply_scan; |
3010 | priv->rx_handlers[SCAN_START_NOTIFICATION] = iwl4965_rx_scan_start_notif; | 1910 | priv->rx_handlers[SCAN_START_NOTIFICATION] = iwl4965_rx_scan_start_notif; |
3011 | priv->rx_handlers[SCAN_RESULTS_NOTIFICATION] = | 1911 | priv->rx_handlers[SCAN_RESULTS_NOTIFICATION] = |
3012 | iwl4965_rx_scan_results_notif; | 1912 | iwl4965_rx_scan_results_notif; |
3013 | priv->rx_handlers[SCAN_COMPLETE_NOTIFICATION] = | 1913 | priv->rx_handlers[SCAN_COMPLETE_NOTIFICATION] = |
3014 | iwl4965_rx_scan_complete_notif; | 1914 | iwl4965_rx_scan_complete_notif; |
1915 | /* status change handler */ | ||
3015 | priv->rx_handlers[CARD_STATE_NOTIFICATION] = iwl4965_rx_card_state_notif; | 1916 | priv->rx_handlers[CARD_STATE_NOTIFICATION] = iwl4965_rx_card_state_notif; |
3016 | priv->rx_handlers[REPLY_TX] = iwl4965_rx_reply_tx; | ||
3017 | 1917 | ||
1918 | priv->rx_handlers[MISSED_BEACONS_NOTIFICATION] = | ||
1919 | iwl_rx_missed_beacon_notif; | ||
1920 | /* Rx handlers */ | ||
1921 | priv->rx_handlers[REPLY_RX_PHY_CMD] = iwl4965_rx_reply_rx_phy; | ||
1922 | priv->rx_handlers[REPLY_RX_MPDU_CMD] = iwl4965_rx_reply_rx; | ||
3018 | /* Set up hardware specific Rx handlers */ | 1923 | /* Set up hardware specific Rx handlers */ |
3019 | priv->cfg->ops->lib->rx_handler_setup(priv); | 1924 | priv->cfg->ops->lib->rx_handler_setup(priv); |
3020 | } | 1925 | } |
3021 | 1926 | ||
3022 | /** | ||
3023 | * iwl4965_tx_cmd_complete - Pull unused buffers off the queue and reclaim them | ||
3024 | * @rxb: Rx buffer to reclaim | ||
3025 | * | ||
3026 | * If an Rx buffer has an async callback associated with it the callback | ||
3027 | * will be executed. The attached skb (if present) will only be freed | ||
3028 | * if the callback returns 1 | ||
3029 | */ | ||
3030 | static void iwl4965_tx_cmd_complete(struct iwl_priv *priv, | ||
3031 | struct iwl_rx_mem_buffer *rxb) | ||
3032 | { | ||
3033 | struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; | ||
3034 | u16 sequence = le16_to_cpu(pkt->hdr.sequence); | ||
3035 | int txq_id = SEQ_TO_QUEUE(sequence); | ||
3036 | int index = SEQ_TO_INDEX(sequence); | ||
3037 | int huge = sequence & SEQ_HUGE_FRAME; | ||
3038 | int cmd_index; | ||
3039 | struct iwl_cmd *cmd; | ||
3040 | |||
3041 | /* If a Tx command is being handled and it isn't in the actual | ||
3042 | * command queue then there a command routing bug has been introduced | ||
3043 | * in the queue management code. */ | ||
3044 | if (txq_id != IWL_CMD_QUEUE_NUM) | ||
3045 | IWL_ERROR("Error wrong command queue %d command id 0x%X\n", | ||
3046 | txq_id, pkt->hdr.cmd); | ||
3047 | BUG_ON(txq_id != IWL_CMD_QUEUE_NUM); | ||
3048 | |||
3049 | cmd_index = get_cmd_index(&priv->txq[IWL_CMD_QUEUE_NUM].q, index, huge); | ||
3050 | cmd = &priv->txq[IWL_CMD_QUEUE_NUM].cmd[cmd_index]; | ||
3051 | |||
3052 | /* Input error checking is done when commands are added to queue. */ | ||
3053 | if (cmd->meta.flags & CMD_WANT_SKB) { | ||
3054 | cmd->meta.source->u.skb = rxb->skb; | ||
3055 | rxb->skb = NULL; | ||
3056 | } else if (cmd->meta.u.callback && | ||
3057 | !cmd->meta.u.callback(priv, cmd, rxb->skb)) | ||
3058 | rxb->skb = NULL; | ||
3059 | |||
3060 | iwl4965_tx_queue_reclaim(priv, txq_id, index); | ||
3061 | |||
3062 | if (!(cmd->meta.flags & CMD_ASYNC)) { | ||
3063 | clear_bit(STATUS_HCMD_ACTIVE, &priv->status); | ||
3064 | wake_up_interruptible(&priv->wait_command_queue); | ||
3065 | } | ||
3066 | } | ||
3067 | |||
3068 | /* | 1927 | /* |
3069 | * this should be called while priv->lock is locked | 1928 | * this should be called while priv->lock is locked |
3070 | */ | 1929 | */ |
@@ -3153,7 +2012,7 @@ void iwl_rx_handle(struct iwl_priv *priv) | |||
3153 | * fire off the (possibly) blocking iwl_send_cmd() | 2012 | * fire off the (possibly) blocking iwl_send_cmd() |
3154 | * as we reclaim the driver command queue */ | 2013 | * as we reclaim the driver command queue */ |
3155 | if (rxb && rxb->skb) | 2014 | if (rxb && rxb->skb) |
3156 | iwl4965_tx_cmd_complete(priv, rxb); | 2015 | iwl_tx_cmd_complete(priv, rxb); |
3157 | else | 2016 | else |
3158 | IWL_WARNING("Claim null rxb?\n"); | 2017 | IWL_WARNING("Claim null rxb?\n"); |
3159 | } | 2018 | } |
@@ -3268,56 +2127,10 @@ int iwl4965_calc_sig_qual(int rssi_dbm, int noise_dbm) | |||
3268 | return sig_qual; | 2127 | return sig_qual; |
3269 | } | 2128 | } |
3270 | 2129 | ||
3271 | /** | ||
3272 | * iwl4965_tx_queue_update_write_ptr - Send new write index to hardware | ||
3273 | */ | ||
3274 | static int iwl4965_tx_queue_update_write_ptr(struct iwl_priv *priv, | ||
3275 | struct iwl_tx_queue *txq) | ||
3276 | { | ||
3277 | u32 reg = 0; | ||
3278 | int rc = 0; | ||
3279 | int txq_id = txq->q.id; | ||
3280 | |||
3281 | if (txq->need_update == 0) | ||
3282 | return rc; | ||
3283 | |||
3284 | /* if we're trying to save power */ | ||
3285 | if (test_bit(STATUS_POWER_PMI, &priv->status)) { | ||
3286 | /* wake up nic if it's powered down ... | ||
3287 | * uCode will wake up, and interrupt us again, so next | ||
3288 | * time we'll skip this part. */ | ||
3289 | reg = iwl_read32(priv, CSR_UCODE_DRV_GP1); | ||
3290 | |||
3291 | if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { | ||
3292 | IWL_DEBUG_INFO("Requesting wakeup, GP1 = 0x%x\n", reg); | ||
3293 | iwl_set_bit(priv, CSR_GP_CNTRL, | ||
3294 | CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); | ||
3295 | return rc; | ||
3296 | } | ||
3297 | |||
3298 | /* restore this queue's parameters in nic hardware. */ | ||
3299 | rc = iwl_grab_nic_access(priv); | ||
3300 | if (rc) | ||
3301 | return rc; | ||
3302 | iwl_write_direct32(priv, HBUS_TARG_WRPTR, | ||
3303 | txq->q.write_ptr | (txq_id << 8)); | ||
3304 | iwl_release_nic_access(priv); | ||
3305 | |||
3306 | /* else not in power-save mode, uCode will never sleep when we're | ||
3307 | * trying to tx (during RFKILL, we're not trying to tx). */ | ||
3308 | } else | ||
3309 | iwl_write32(priv, HBUS_TARG_WRPTR, | ||
3310 | txq->q.write_ptr | (txq_id << 8)); | ||
3311 | |||
3312 | txq->need_update = 0; | ||
3313 | |||
3314 | return rc; | ||
3315 | } | ||
3316 | |||
3317 | #ifdef CONFIG_IWLWIFI_DEBUG | 2130 | #ifdef CONFIG_IWLWIFI_DEBUG |
3318 | static void iwl4965_print_rx_config_cmd(struct iwl_priv *priv) | 2131 | static void iwl4965_print_rx_config_cmd(struct iwl_priv *priv) |
3319 | { | 2132 | { |
3320 | struct iwl4965_rxon_cmd *rxon = &priv->staging_rxon; | 2133 | struct iwl_rxon_cmd *rxon = &priv->staging_rxon; |
3321 | DECLARE_MAC_BUF(mac); | 2134 | DECLARE_MAC_BUF(mac); |
3322 | 2135 | ||
3323 | IWL_DEBUG_RADIO("RX CONFIG:\n"); | 2136 | IWL_DEBUG_RADIO("RX CONFIG:\n"); |
@@ -3367,173 +2180,6 @@ static inline void iwl4965_disable_interrupts(struct iwl_priv *priv) | |||
3367 | IWL_DEBUG_ISR("Disabled interrupts\n"); | 2180 | IWL_DEBUG_ISR("Disabled interrupts\n"); |
3368 | } | 2181 | } |
3369 | 2182 | ||
3370 | static const char *desc_lookup(int i) | ||
3371 | { | ||
3372 | switch (i) { | ||
3373 | case 1: | ||
3374 | return "FAIL"; | ||
3375 | case 2: | ||
3376 | return "BAD_PARAM"; | ||
3377 | case 3: | ||
3378 | return "BAD_CHECKSUM"; | ||
3379 | case 4: | ||
3380 | return "NMI_INTERRUPT"; | ||
3381 | case 5: | ||
3382 | return "SYSASSERT"; | ||
3383 | case 6: | ||
3384 | return "FATAL_ERROR"; | ||
3385 | } | ||
3386 | |||
3387 | return "UNKNOWN"; | ||
3388 | } | ||
3389 | |||
3390 | #define ERROR_START_OFFSET (1 * sizeof(u32)) | ||
3391 | #define ERROR_ELEM_SIZE (7 * sizeof(u32)) | ||
3392 | |||
3393 | static void iwl4965_dump_nic_error_log(struct iwl_priv *priv) | ||
3394 | { | ||
3395 | u32 data2, line; | ||
3396 | u32 desc, time, count, base, data1; | ||
3397 | u32 blink1, blink2, ilink1, ilink2; | ||
3398 | int rc; | ||
3399 | |||
3400 | base = le32_to_cpu(priv->card_alive.error_event_table_ptr); | ||
3401 | |||
3402 | if (!priv->cfg->ops->lib->is_valid_rtc_data_addr(base)) { | ||
3403 | IWL_ERROR("Not valid error log pointer 0x%08X\n", base); | ||
3404 | return; | ||
3405 | } | ||
3406 | |||
3407 | rc = iwl_grab_nic_access(priv); | ||
3408 | if (rc) { | ||
3409 | IWL_WARNING("Can not read from adapter at this time.\n"); | ||
3410 | return; | ||
3411 | } | ||
3412 | |||
3413 | count = iwl_read_targ_mem(priv, base); | ||
3414 | |||
3415 | if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) { | ||
3416 | IWL_ERROR("Start IWL Error Log Dump:\n"); | ||
3417 | IWL_ERROR("Status: 0x%08lX, count: %d\n", priv->status, count); | ||
3418 | } | ||
3419 | |||
3420 | desc = iwl_read_targ_mem(priv, base + 1 * sizeof(u32)); | ||
3421 | blink1 = iwl_read_targ_mem(priv, base + 3 * sizeof(u32)); | ||
3422 | blink2 = iwl_read_targ_mem(priv, base + 4 * sizeof(u32)); | ||
3423 | ilink1 = iwl_read_targ_mem(priv, base + 5 * sizeof(u32)); | ||
3424 | ilink2 = iwl_read_targ_mem(priv, base + 6 * sizeof(u32)); | ||
3425 | data1 = iwl_read_targ_mem(priv, base + 7 * sizeof(u32)); | ||
3426 | data2 = iwl_read_targ_mem(priv, base + 8 * sizeof(u32)); | ||
3427 | line = iwl_read_targ_mem(priv, base + 9 * sizeof(u32)); | ||
3428 | time = iwl_read_targ_mem(priv, base + 11 * sizeof(u32)); | ||
3429 | |||
3430 | IWL_ERROR("Desc Time " | ||
3431 | "data1 data2 line\n"); | ||
3432 | IWL_ERROR("%-13s (#%d) %010u 0x%08X 0x%08X %u\n", | ||
3433 | desc_lookup(desc), desc, time, data1, data2, line); | ||
3434 | IWL_ERROR("blink1 blink2 ilink1 ilink2\n"); | ||
3435 | IWL_ERROR("0x%05X 0x%05X 0x%05X 0x%05X\n", blink1, blink2, | ||
3436 | ilink1, ilink2); | ||
3437 | |||
3438 | iwl_release_nic_access(priv); | ||
3439 | } | ||
3440 | |||
3441 | #define EVENT_START_OFFSET (4 * sizeof(u32)) | ||
3442 | |||
3443 | /** | ||
3444 | * iwl4965_print_event_log - Dump error event log to syslog | ||
3445 | * | ||
3446 | * NOTE: Must be called with iwl_grab_nic_access() already obtained! | ||
3447 | */ | ||
3448 | static void iwl4965_print_event_log(struct iwl_priv *priv, u32 start_idx, | ||
3449 | u32 num_events, u32 mode) | ||
3450 | { | ||
3451 | u32 i; | ||
3452 | u32 base; /* SRAM byte address of event log header */ | ||
3453 | u32 event_size; /* 2 u32s, or 3 u32s if timestamp recorded */ | ||
3454 | u32 ptr; /* SRAM byte address of log data */ | ||
3455 | u32 ev, time, data; /* event log data */ | ||
3456 | |||
3457 | if (num_events == 0) | ||
3458 | return; | ||
3459 | |||
3460 | base = le32_to_cpu(priv->card_alive.log_event_table_ptr); | ||
3461 | |||
3462 | if (mode == 0) | ||
3463 | event_size = 2 * sizeof(u32); | ||
3464 | else | ||
3465 | event_size = 3 * sizeof(u32); | ||
3466 | |||
3467 | ptr = base + EVENT_START_OFFSET + (start_idx * event_size); | ||
3468 | |||
3469 | /* "time" is actually "data" for mode 0 (no timestamp). | ||
3470 | * place event id # at far right for easier visual parsing. */ | ||
3471 | for (i = 0; i < num_events; i++) { | ||
3472 | ev = iwl_read_targ_mem(priv, ptr); | ||
3473 | ptr += sizeof(u32); | ||
3474 | time = iwl_read_targ_mem(priv, ptr); | ||
3475 | ptr += sizeof(u32); | ||
3476 | if (mode == 0) | ||
3477 | IWL_ERROR("0x%08x\t%04u\n", time, ev); /* data, ev */ | ||
3478 | else { | ||
3479 | data = iwl_read_targ_mem(priv, ptr); | ||
3480 | ptr += sizeof(u32); | ||
3481 | IWL_ERROR("%010u\t0x%08x\t%04u\n", time, data, ev); | ||
3482 | } | ||
3483 | } | ||
3484 | } | ||
3485 | |||
3486 | static void iwl4965_dump_nic_event_log(struct iwl_priv *priv) | ||
3487 | { | ||
3488 | int rc; | ||
3489 | u32 base; /* SRAM byte address of event log header */ | ||
3490 | u32 capacity; /* event log capacity in # entries */ | ||
3491 | u32 mode; /* 0 - no timestamp, 1 - timestamp recorded */ | ||
3492 | u32 num_wraps; /* # times uCode wrapped to top of log */ | ||
3493 | u32 next_entry; /* index of next entry to be written by uCode */ | ||
3494 | u32 size; /* # entries that we'll print */ | ||
3495 | |||
3496 | base = le32_to_cpu(priv->card_alive.log_event_table_ptr); | ||
3497 | if (!priv->cfg->ops->lib->is_valid_rtc_data_addr(base)) { | ||
3498 | IWL_ERROR("Invalid event log pointer 0x%08X\n", base); | ||
3499 | return; | ||
3500 | } | ||
3501 | |||
3502 | rc = iwl_grab_nic_access(priv); | ||
3503 | if (rc) { | ||
3504 | IWL_WARNING("Can not read from adapter at this time.\n"); | ||
3505 | return; | ||
3506 | } | ||
3507 | |||
3508 | /* event log header */ | ||
3509 | capacity = iwl_read_targ_mem(priv, base); | ||
3510 | mode = iwl_read_targ_mem(priv, base + (1 * sizeof(u32))); | ||
3511 | num_wraps = iwl_read_targ_mem(priv, base + (2 * sizeof(u32))); | ||
3512 | next_entry = iwl_read_targ_mem(priv, base + (3 * sizeof(u32))); | ||
3513 | |||
3514 | size = num_wraps ? capacity : next_entry; | ||
3515 | |||
3516 | /* bail out if nothing in log */ | ||
3517 | if (size == 0) { | ||
3518 | IWL_ERROR("Start IWL Event Log Dump: nothing in log\n"); | ||
3519 | iwl_release_nic_access(priv); | ||
3520 | return; | ||
3521 | } | ||
3522 | |||
3523 | IWL_ERROR("Start IWL Event Log Dump: display count %d, wraps %d\n", | ||
3524 | size, num_wraps); | ||
3525 | |||
3526 | /* if uCode has wrapped back to top of log, start at the oldest entry, | ||
3527 | * i.e the next one that uCode would fill. */ | ||
3528 | if (num_wraps) | ||
3529 | iwl4965_print_event_log(priv, next_entry, | ||
3530 | capacity - next_entry, mode); | ||
3531 | |||
3532 | /* (then/else) start at top of log */ | ||
3533 | iwl4965_print_event_log(priv, 0, next_entry, mode); | ||
3534 | |||
3535 | iwl_release_nic_access(priv); | ||
3536 | } | ||
3537 | 2183 | ||
3538 | /** | 2184 | /** |
3539 | * iwl4965_irq_handle_error - called for HW or SW error interrupt from card | 2185 | * iwl4965_irq_handle_error - called for HW or SW error interrupt from card |
@@ -3548,8 +2194,8 @@ static void iwl4965_irq_handle_error(struct iwl_priv *priv) | |||
3548 | 2194 | ||
3549 | #ifdef CONFIG_IWLWIFI_DEBUG | 2195 | #ifdef CONFIG_IWLWIFI_DEBUG |
3550 | if (priv->debug_level & IWL_DL_FW_ERRORS) { | 2196 | if (priv->debug_level & IWL_DL_FW_ERRORS) { |
3551 | iwl4965_dump_nic_error_log(priv); | 2197 | iwl_dump_nic_error_log(priv); |
3552 | iwl4965_dump_nic_event_log(priv); | 2198 | iwl_dump_nic_event_log(priv); |
3553 | iwl4965_print_rx_config_cmd(priv); | 2199 | iwl4965_print_rx_config_cmd(priv); |
3554 | } | 2200 | } |
3555 | #endif | 2201 | #endif |
@@ -3583,7 +2229,7 @@ static void iwl4965_error_recovery(struct iwl_priv *priv) | |||
3583 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; | 2229 | priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; |
3584 | iwl4965_commit_rxon(priv); | 2230 | iwl4965_commit_rxon(priv); |
3585 | 2231 | ||
3586 | iwl4965_rxon_add_station(priv, priv->bssid, 1); | 2232 | iwl_rxon_add_station(priv, priv->bssid, 1); |
3587 | 2233 | ||
3588 | spin_lock_irqsave(&priv->lock, flags); | 2234 | spin_lock_irqsave(&priv->lock, flags); |
3589 | priv->assoc_id = le16_to_cpu(priv->staging_rxon.assoc_id); | 2235 | priv->assoc_id = le16_to_cpu(priv->staging_rxon.assoc_id); |
@@ -3703,12 +2349,12 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv) | |||
3703 | if (inta & CSR_INT_BIT_WAKEUP) { | 2349 | if (inta & CSR_INT_BIT_WAKEUP) { |
3704 | IWL_DEBUG_ISR("Wakeup interrupt\n"); | 2350 | IWL_DEBUG_ISR("Wakeup interrupt\n"); |
3705 | iwl_rx_queue_update_write_ptr(priv, &priv->rxq); | 2351 | iwl_rx_queue_update_write_ptr(priv, &priv->rxq); |
3706 | iwl4965_tx_queue_update_write_ptr(priv, &priv->txq[0]); | 2352 | iwl_txq_update_write_ptr(priv, &priv->txq[0]); |
3707 | iwl4965_tx_queue_update_write_ptr(priv, &priv->txq[1]); | 2353 | iwl_txq_update_write_ptr(priv, &priv->txq[1]); |
3708 | iwl4965_tx_queue_update_write_ptr(priv, &priv->txq[2]); | 2354 | iwl_txq_update_write_ptr(priv, &priv->txq[2]); |
3709 | iwl4965_tx_queue_update_write_ptr(priv, &priv->txq[3]); | 2355 | iwl_txq_update_write_ptr(priv, &priv->txq[3]); |
3710 | iwl4965_tx_queue_update_write_ptr(priv, &priv->txq[4]); | 2356 | iwl_txq_update_write_ptr(priv, &priv->txq[4]); |
3711 | iwl4965_tx_queue_update_write_ptr(priv, &priv->txq[5]); | 2357 | iwl_txq_update_write_ptr(priv, &priv->txq[5]); |
3712 | 2358 | ||
3713 | handled |= CSR_INT_BIT_WAKEUP; | 2359 | handled |= CSR_INT_BIT_WAKEUP; |
3714 | } | 2360 | } |
@@ -3724,6 +2370,9 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv) | |||
3724 | if (inta & CSR_INT_BIT_FH_TX) { | 2370 | if (inta & CSR_INT_BIT_FH_TX) { |
3725 | IWL_DEBUG_ISR("Tx interrupt\n"); | 2371 | IWL_DEBUG_ISR("Tx interrupt\n"); |
3726 | handled |= CSR_INT_BIT_FH_TX; | 2372 | handled |= CSR_INT_BIT_FH_TX; |
2373 | /* FH finished to write, send event */ | ||
2374 | priv->ucode_write_complete = 1; | ||
2375 | wake_up_interruptible(&priv->wait_command_queue); | ||
3727 | } | 2376 | } |
3728 | 2377 | ||
3729 | if (inta & ~handled) | 2378 | if (inta & ~handled) |
@@ -4162,11 +2811,11 @@ static int iwl4965_read_ucode(struct iwl_priv *priv) | |||
4162 | } | 2811 | } |
4163 | 2812 | ||
4164 | /** | 2813 | /** |
4165 | * iwl4965_alive_start - called after REPLY_ALIVE notification received | 2814 | * iwl_alive_start - called after REPLY_ALIVE notification received |
4166 | * from protocol/runtime uCode (initialization uCode's | 2815 | * from protocol/runtime uCode (initialization uCode's |
4167 | * Alive gets handled by iwl4965_init_alive_start()). | 2816 | * Alive gets handled by iwl_init_alive_start()). |
4168 | */ | 2817 | */ |
4169 | static void iwl4965_alive_start(struct iwl_priv *priv) | 2818 | static void iwl_alive_start(struct iwl_priv *priv) |
4170 | { | 2819 | { |
4171 | int ret = 0; | 2820 | int ret = 0; |
4172 | 2821 | ||
@@ -4190,7 +2839,6 @@ static void iwl4965_alive_start(struct iwl_priv *priv) | |||
4190 | } | 2839 | } |
4191 | 2840 | ||
4192 | iwlcore_clear_stations_table(priv); | 2841 | iwlcore_clear_stations_table(priv); |
4193 | |||
4194 | ret = priv->cfg->ops->lib->alive_notify(priv); | 2842 | ret = priv->cfg->ops->lib->alive_notify(priv); |
4195 | if (ret) { | 2843 | if (ret) { |
4196 | IWL_WARNING("Could not complete ALIVE transition [ntf]: %d\n", | 2844 | IWL_WARNING("Could not complete ALIVE transition [ntf]: %d\n", |
@@ -4207,14 +2855,14 @@ static void iwl4965_alive_start(struct iwl_priv *priv) | |||
4207 | if (iwl_is_rfkill(priv)) | 2855 | if (iwl_is_rfkill(priv)) |
4208 | return; | 2856 | return; |
4209 | 2857 | ||
4210 | ieee80211_start_queues(priv->hw); | 2858 | ieee80211_wake_queues(priv->hw); |
4211 | 2859 | ||
4212 | priv->active_rate = priv->rates_mask; | 2860 | priv->active_rate = priv->rates_mask; |
4213 | priv->active_rate_basic = priv->rates_mask & IWL_BASIC_RATES_MASK; | 2861 | priv->active_rate_basic = priv->rates_mask & IWL_BASIC_RATES_MASK; |
4214 | 2862 | ||
4215 | if (iwl_is_associated(priv)) { | 2863 | if (iwl_is_associated(priv)) { |
4216 | struct iwl4965_rxon_cmd *active_rxon = | 2864 | struct iwl_rxon_cmd *active_rxon = |
4217 | (struct iwl4965_rxon_cmd *)(&priv->active_rxon); | 2865 | (struct iwl_rxon_cmd *)&priv->active_rxon; |
4218 | 2866 | ||
4219 | memcpy(&priv->staging_rxon, &priv->active_rxon, | 2867 | memcpy(&priv->staging_rxon, &priv->active_rxon, |
4220 | sizeof(priv->staging_rxon)); | 2868 | sizeof(priv->staging_rxon)); |
@@ -4228,12 +2876,12 @@ static void iwl4965_alive_start(struct iwl_priv *priv) | |||
4228 | /* Configure Bluetooth device coexistence support */ | 2876 | /* Configure Bluetooth device coexistence support */ |
4229 | iwl4965_send_bt_config(priv); | 2877 | iwl4965_send_bt_config(priv); |
4230 | 2878 | ||
2879 | iwl_reset_run_time_calib(priv); | ||
2880 | |||
4231 | /* Configure the adapter for unassociated operation */ | 2881 | /* Configure the adapter for unassociated operation */ |
4232 | iwl4965_commit_rxon(priv); | 2882 | iwl4965_commit_rxon(priv); |
4233 | 2883 | ||
4234 | /* At this point, the NIC is initialized and operational */ | 2884 | /* At this point, the NIC is initialized and operational */ |
4235 | priv->notif_missed_beacons = 0; | ||
4236 | |||
4237 | iwl4965_rf_kill_ct_config(priv); | 2885 | iwl4965_rf_kill_ct_config(priv); |
4238 | 2886 | ||
4239 | iwl_leds_register(priv); | 2887 | iwl_leds_register(priv); |
@@ -4259,12 +2907,9 @@ static void __iwl4965_down(struct iwl_priv *priv) | |||
4259 | { | 2907 | { |
4260 | unsigned long flags; | 2908 | unsigned long flags; |
4261 | int exit_pending = test_bit(STATUS_EXIT_PENDING, &priv->status); | 2909 | int exit_pending = test_bit(STATUS_EXIT_PENDING, &priv->status); |
4262 | struct ieee80211_conf *conf = NULL; | ||
4263 | 2910 | ||
4264 | IWL_DEBUG_INFO(DRV_NAME " is going down\n"); | 2911 | IWL_DEBUG_INFO(DRV_NAME " is going down\n"); |
4265 | 2912 | ||
4266 | conf = ieee80211_get_hw_conf(priv->hw); | ||
4267 | |||
4268 | if (!exit_pending) | 2913 | if (!exit_pending) |
4269 | set_bit(STATUS_EXIT_PENDING, &priv->status); | 2914 | set_bit(STATUS_EXIT_PENDING, &priv->status); |
4270 | 2915 | ||
@@ -4326,8 +2971,8 @@ static void __iwl4965_down(struct iwl_priv *priv) | |||
4326 | CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); | 2971 | CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); |
4327 | spin_unlock_irqrestore(&priv->lock, flags); | 2972 | spin_unlock_irqrestore(&priv->lock, flags); |
4328 | 2973 | ||
4329 | iwl4965_hw_txq_ctx_stop(priv); | 2974 | iwl_txq_ctx_stop(priv); |
4330 | iwl4965_hw_rxq_stop(priv); | 2975 | iwl_rxq_stop(priv); |
4331 | 2976 | ||
4332 | spin_lock_irqsave(&priv->lock, flags); | 2977 | spin_lock_irqsave(&priv->lock, flags); |
4333 | if (!iwl_grab_nic_access(priv)) { | 2978 | if (!iwl_grab_nic_access(priv)) { |
@@ -4339,20 +2984,19 @@ static void __iwl4965_down(struct iwl_priv *priv) | |||
4339 | 2984 | ||
4340 | udelay(5); | 2985 | udelay(5); |
4341 | 2986 | ||
4342 | iwl4965_hw_nic_stop_master(priv); | 2987 | /* FIXME: apm_ops.suspend(priv) */ |
4343 | iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); | 2988 | priv->cfg->ops->lib->apm_ops.reset(priv); |
4344 | iwl4965_hw_nic_reset(priv); | ||
4345 | priv->cfg->ops->lib->free_shared_mem(priv); | 2989 | priv->cfg->ops->lib->free_shared_mem(priv); |
4346 | 2990 | ||
4347 | exit: | 2991 | exit: |
4348 | memset(&priv->card_alive, 0, sizeof(struct iwl4965_alive_resp)); | 2992 | memset(&priv->card_alive, 0, sizeof(struct iwl_alive_resp)); |
4349 | 2993 | ||
4350 | if (priv->ibss_beacon) | 2994 | if (priv->ibss_beacon) |
4351 | dev_kfree_skb(priv->ibss_beacon); | 2995 | dev_kfree_skb(priv->ibss_beacon); |
4352 | priv->ibss_beacon = NULL; | 2996 | priv->ibss_beacon = NULL; |
4353 | 2997 | ||
4354 | /* clear out any free frames */ | 2998 | /* clear out any free frames */ |
4355 | iwl4965_clear_free_frames(priv); | 2999 | iwl_clear_free_frames(priv); |
4356 | } | 3000 | } |
4357 | 3001 | ||
4358 | static void iwl4965_down(struct iwl_priv *priv) | 3002 | static void iwl4965_down(struct iwl_priv *priv) |
@@ -4477,7 +3121,7 @@ static int __iwl4965_up(struct iwl_priv *priv) | |||
4477 | * | 3121 | * |
4478 | *****************************************************************************/ | 3122 | *****************************************************************************/ |
4479 | 3123 | ||
4480 | static void iwl4965_bg_init_alive_start(struct work_struct *data) | 3124 | static void iwl_bg_init_alive_start(struct work_struct *data) |
4481 | { | 3125 | { |
4482 | struct iwl_priv *priv = | 3126 | struct iwl_priv *priv = |
4483 | container_of(data, struct iwl_priv, init_alive_start.work); | 3127 | container_of(data, struct iwl_priv, init_alive_start.work); |
@@ -4490,7 +3134,7 @@ static void iwl4965_bg_init_alive_start(struct work_struct *data) | |||
4490 | mutex_unlock(&priv->mutex); | 3134 | mutex_unlock(&priv->mutex); |
4491 | } | 3135 | } |
4492 | 3136 | ||
4493 | static void iwl4965_bg_alive_start(struct work_struct *data) | 3137 | static void iwl_bg_alive_start(struct work_struct *data) |
4494 | { | 3138 | { |
4495 | struct iwl_priv *priv = | 3139 | struct iwl_priv *priv = |
4496 | container_of(data, struct iwl_priv, alive_start.work); | 3140 | container_of(data, struct iwl_priv, alive_start.work); |
@@ -4499,7 +3143,7 @@ static void iwl4965_bg_alive_start(struct work_struct *data) | |||
4499 | return; | 3143 | return; |
4500 | 3144 | ||
4501 | mutex_lock(&priv->mutex); | 3145 | mutex_lock(&priv->mutex); |
4502 | iwl4965_alive_start(priv); | 3146 | iwl_alive_start(priv); |
4503 | mutex_unlock(&priv->mutex); | 3147 | mutex_unlock(&priv->mutex); |
4504 | } | 3148 | } |
4505 | 3149 | ||
@@ -4909,8 +3553,8 @@ static void iwl4965_post_associate(struct iwl_priv *priv) | |||
4909 | /* clear out the station table */ | 3553 | /* clear out the station table */ |
4910 | iwlcore_clear_stations_table(priv); | 3554 | iwlcore_clear_stations_table(priv); |
4911 | 3555 | ||
4912 | iwl4965_rxon_add_station(priv, iwl4965_broadcast_addr, 0); | 3556 | iwl_rxon_add_station(priv, iwl_bcast_addr, 0); |
4913 | iwl4965_rxon_add_station(priv, priv->bssid, 0); | 3557 | iwl_rxon_add_station(priv, priv->bssid, 0); |
4914 | iwl4965_rate_scale_init(priv->hw, IWL_STA_ID); | 3558 | iwl4965_rate_scale_init(priv->hw, IWL_STA_ID); |
4915 | iwl4965_send_beacon_cmd(priv); | 3559 | iwl4965_send_beacon_cmd(priv); |
4916 | 3560 | ||
@@ -5021,7 +3665,7 @@ static int iwl4965_mac_start(struct ieee80211_hw *hw) | |||
5021 | /* we should be verifying the device is ready to be opened */ | 3665 | /* we should be verifying the device is ready to be opened */ |
5022 | mutex_lock(&priv->mutex); | 3666 | mutex_lock(&priv->mutex); |
5023 | 3667 | ||
5024 | memset(&priv->staging_rxon, 0, sizeof(struct iwl4965_rxon_cmd)); | 3668 | memset(&priv->staging_rxon, 0, sizeof(struct iwl_rxon_cmd)); |
5025 | /* fetch ucode file from disk, alloc and copy to bus-master buffers ... | 3669 | /* fetch ucode file from disk, alloc and copy to bus-master buffers ... |
5026 | * ucode filename and max sizes are card-specific. */ | 3670 | * ucode filename and max sizes are card-specific. */ |
5027 | 3671 | ||
@@ -5046,21 +3690,23 @@ static int iwl4965_mac_start(struct ieee80211_hw *hw) | |||
5046 | if (test_bit(STATUS_IN_SUSPEND, &priv->status)) | 3690 | if (test_bit(STATUS_IN_SUSPEND, &priv->status)) |
5047 | return 0; | 3691 | return 0; |
5048 | 3692 | ||
5049 | /* Wait for START_ALIVE from ucode. Otherwise callbacks from | 3693 | /* Wait for START_ALIVE from Run Time ucode. Otherwise callbacks from |
5050 | * mac80211 will not be run successfully. */ | 3694 | * mac80211 will not be run successfully. */ |
5051 | ret = wait_event_interruptible_timeout(priv->wait_command_queue, | 3695 | if (priv->ucode_type == UCODE_RT) { |
5052 | test_bit(STATUS_READY, &priv->status), | 3696 | ret = wait_event_interruptible_timeout(priv->wait_command_queue, |
5053 | UCODE_READY_TIMEOUT); | 3697 | test_bit(STATUS_READY, &priv->status), |
5054 | if (!ret) { | 3698 | UCODE_READY_TIMEOUT); |
5055 | if (!test_bit(STATUS_READY, &priv->status)) { | 3699 | if (!ret) { |
5056 | IWL_ERROR("Wait for START_ALIVE timeout after %dms.\n", | 3700 | if (!test_bit(STATUS_READY, &priv->status)) { |
5057 | jiffies_to_msecs(UCODE_READY_TIMEOUT)); | 3701 | IWL_ERROR("START_ALIVE timeout after %dms.\n", |
5058 | ret = -ETIMEDOUT; | 3702 | jiffies_to_msecs(UCODE_READY_TIMEOUT)); |
5059 | goto out_release_irq; | 3703 | ret = -ETIMEDOUT; |
3704 | goto out_release_irq; | ||
3705 | } | ||
5060 | } | 3706 | } |
5061 | } | ||
5062 | 3707 | ||
5063 | priv->is_open = 1; | 3708 | priv->is_open = 1; |
3709 | } | ||
5064 | IWL_DEBUG_MAC80211("leave\n"); | 3710 | IWL_DEBUG_MAC80211("leave\n"); |
5065 | return 0; | 3711 | return 0; |
5066 | 3712 | ||
@@ -5108,8 +3754,7 @@ static void iwl4965_mac_stop(struct ieee80211_hw *hw) | |||
5108 | IWL_DEBUG_MAC80211("leave\n"); | 3754 | IWL_DEBUG_MAC80211("leave\n"); |
5109 | } | 3755 | } |
5110 | 3756 | ||
5111 | static int iwl4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb, | 3757 | static int iwl4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) |
5112 | struct ieee80211_tx_control *ctl) | ||
5113 | { | 3758 | { |
5114 | struct iwl_priv *priv = hw->priv; | 3759 | struct iwl_priv *priv = hw->priv; |
5115 | 3760 | ||
@@ -5121,9 +3766,9 @@ static int iwl4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
5121 | } | 3766 | } |
5122 | 3767 | ||
5123 | IWL_DEBUG_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, | 3768 | IWL_DEBUG_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, |
5124 | ctl->tx_rate->bitrate); | 3769 | ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); |
5125 | 3770 | ||
5126 | if (iwl4965_tx_skb(priv, skb, ctl)) | 3771 | if (iwl_tx_skb(priv, skb)) |
5127 | dev_kfree_skb_any(skb); | 3772 | dev_kfree_skb_any(skb); |
5128 | 3773 | ||
5129 | IWL_DEBUG_MAC80211("leave\n"); | 3774 | IWL_DEBUG_MAC80211("leave\n"); |
@@ -5178,6 +3823,7 @@ static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *co | |||
5178 | const struct iwl_channel_info *ch_info; | 3823 | const struct iwl_channel_info *ch_info; |
5179 | unsigned long flags; | 3824 | unsigned long flags; |
5180 | int ret = 0; | 3825 | int ret = 0; |
3826 | u16 channel; | ||
5181 | 3827 | ||
5182 | mutex_lock(&priv->mutex); | 3828 | mutex_lock(&priv->mutex); |
5183 | IWL_DEBUG_MAC80211("enter to channel %d\n", conf->channel->hw_value); | 3829 | IWL_DEBUG_MAC80211("enter to channel %d\n", conf->channel->hw_value); |
@@ -5198,22 +3844,21 @@ static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *co | |||
5198 | return 0; | 3844 | return 0; |
5199 | } | 3845 | } |
5200 | 3846 | ||
5201 | spin_lock_irqsave(&priv->lock, flags); | 3847 | channel = ieee80211_frequency_to_channel(conf->channel->center_freq); |
5202 | 3848 | ch_info = iwl_get_channel_info(priv, conf->channel->band, channel); | |
5203 | ch_info = iwl_get_channel_info(priv, conf->channel->band, | ||
5204 | ieee80211_frequency_to_channel(conf->channel->center_freq)); | ||
5205 | if (!is_channel_valid(ch_info)) { | 3849 | if (!is_channel_valid(ch_info)) { |
5206 | IWL_DEBUG_MAC80211("leave - invalid channel\n"); | 3850 | IWL_DEBUG_MAC80211("leave - invalid channel\n"); |
5207 | spin_unlock_irqrestore(&priv->lock, flags); | ||
5208 | ret = -EINVAL; | 3851 | ret = -EINVAL; |
5209 | goto out; | 3852 | goto out; |
5210 | } | 3853 | } |
5211 | 3854 | ||
3855 | spin_lock_irqsave(&priv->lock, flags); | ||
3856 | |||
5212 | #ifdef CONFIG_IWL4965_HT | 3857 | #ifdef CONFIG_IWL4965_HT |
5213 | /* if we are switching from ht to 2.4 clear flags | 3858 | /* if we are switching from ht to 2.4 clear flags |
5214 | * from any ht related info since 2.4 does not | 3859 | * from any ht related info since 2.4 does not |
5215 | * support ht */ | 3860 | * support ht */ |
5216 | if ((le16_to_cpu(priv->staging_rxon.channel) != conf->channel->hw_value) | 3861 | if ((le16_to_cpu(priv->staging_rxon.channel) != channel) |
5217 | #ifdef IEEE80211_CONF_CHANNEL_SWITCH | 3862 | #ifdef IEEE80211_CONF_CHANNEL_SWITCH |
5218 | && !(conf->flags & IEEE80211_CONF_CHANNEL_SWITCH) | 3863 | && !(conf->flags & IEEE80211_CONF_CHANNEL_SWITCH) |
5219 | #endif | 3864 | #endif |
@@ -5221,10 +3866,9 @@ static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *co | |||
5221 | priv->staging_rxon.flags = 0; | 3866 | priv->staging_rxon.flags = 0; |
5222 | #endif /* CONFIG_IWL4965_HT */ | 3867 | #endif /* CONFIG_IWL4965_HT */ |
5223 | 3868 | ||
5224 | iwl_set_rxon_channel(priv, conf->channel->band, | 3869 | iwl_set_rxon_channel(priv, conf->channel->band, channel); |
5225 | ieee80211_frequency_to_channel(conf->channel->center_freq)); | ||
5226 | 3870 | ||
5227 | iwl4965_set_flags_for_phymode(priv, conf->channel->band); | 3871 | iwl_set_flags_for_band(priv, conf->channel->band); |
5228 | 3872 | ||
5229 | /* The list of supported rates and rate mask can be different | 3873 | /* The list of supported rates and rate mask can be different |
5230 | * for each band; since the band may have changed, reset | 3874 | * for each band; since the band may have changed, reset |
@@ -5321,7 +3965,7 @@ static void iwl4965_config_ap(struct iwl_priv *priv) | |||
5321 | priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK; | 3965 | priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK; |
5322 | iwl4965_commit_rxon(priv); | 3966 | iwl4965_commit_rxon(priv); |
5323 | iwl4965_activate_qos(priv, 1); | 3967 | iwl4965_activate_qos(priv, 1); |
5324 | iwl4965_rxon_add_station(priv, iwl4965_broadcast_addr, 0); | 3968 | iwl_rxon_add_station(priv, iwl_bcast_addr, 0); |
5325 | } | 3969 | } |
5326 | iwl4965_send_beacon_cmd(priv); | 3970 | iwl4965_send_beacon_cmd(priv); |
5327 | 3971 | ||
@@ -5410,7 +4054,7 @@ static int iwl4965_mac_config_interface(struct ieee80211_hw *hw, | |||
5410 | else { | 4054 | else { |
5411 | rc = iwl4965_commit_rxon(priv); | 4055 | rc = iwl4965_commit_rxon(priv); |
5412 | if ((priv->iw_mode == IEEE80211_IF_TYPE_STA) && rc) | 4056 | if ((priv->iw_mode == IEEE80211_IF_TYPE_STA) && rc) |
5413 | iwl4965_rxon_add_station( | 4057 | iwl_rxon_add_station( |
5414 | priv, priv->active_rxon.bssid_addr, 1); | 4058 | priv, priv->active_rxon.bssid_addr, 1); |
5415 | } | 4059 | } |
5416 | 4060 | ||
@@ -5697,7 +4341,8 @@ static int iwl4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, | |||
5697 | if (cmd == SET_KEY) | 4341 | if (cmd == SET_KEY) |
5698 | is_default_wep_key = !priv->key_mapping_key; | 4342 | is_default_wep_key = !priv->key_mapping_key; |
5699 | else | 4343 | else |
5700 | is_default_wep_key = priv->default_wep_key; | 4344 | is_default_wep_key = |
4345 | (key->hw_key_idx == HW_KEY_DEFAULT); | ||
5701 | } | 4346 | } |
5702 | 4347 | ||
5703 | switch (cmd) { | 4348 | switch (cmd) { |
@@ -5783,7 +4428,7 @@ static int iwl4965_mac_get_tx_stats(struct ieee80211_hw *hw, | |||
5783 | struct iwl_priv *priv = hw->priv; | 4428 | struct iwl_priv *priv = hw->priv; |
5784 | int i, avail; | 4429 | int i, avail; |
5785 | struct iwl_tx_queue *txq; | 4430 | struct iwl_tx_queue *txq; |
5786 | struct iwl4965_queue *q; | 4431 | struct iwl_queue *q; |
5787 | unsigned long flags; | 4432 | unsigned long flags; |
5788 | 4433 | ||
5789 | IWL_DEBUG_MAC80211("enter\n"); | 4434 | IWL_DEBUG_MAC80211("enter\n"); |
@@ -5798,7 +4443,7 @@ static int iwl4965_mac_get_tx_stats(struct ieee80211_hw *hw, | |||
5798 | for (i = 0; i < AC_NUM; i++) { | 4443 | for (i = 0; i < AC_NUM; i++) { |
5799 | txq = &priv->txq[i]; | 4444 | txq = &priv->txq[i]; |
5800 | q = &txq->q; | 4445 | q = &txq->q; |
5801 | avail = iwl4965_queue_space(q); | 4446 | avail = iwl_queue_space(q); |
5802 | 4447 | ||
5803 | stats[i].len = q->n_window - avail; | 4448 | stats[i].len = q->n_window - avail; |
5804 | stats[i].limit = q->n_window - q->high_mark; | 4449 | stats[i].limit = q->n_window - q->high_mark; |
@@ -5904,8 +4549,7 @@ static void iwl4965_mac_reset_tsf(struct ieee80211_hw *hw) | |||
5904 | IWL_DEBUG_MAC80211("leave\n"); | 4549 | IWL_DEBUG_MAC80211("leave\n"); |
5905 | } | 4550 | } |
5906 | 4551 | ||
5907 | static int iwl4965_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb, | 4552 | static int iwl4965_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb) |
5908 | struct ieee80211_tx_control *control) | ||
5909 | { | 4553 | { |
5910 | struct iwl_priv *priv = hw->priv; | 4554 | struct iwl_priv *priv = hw->priv; |
5911 | unsigned long flags; | 4555 | unsigned long flags; |
@@ -5998,7 +4642,7 @@ static ssize_t show_version(struct device *d, | |||
5998 | struct device_attribute *attr, char *buf) | 4642 | struct device_attribute *attr, char *buf) |
5999 | { | 4643 | { |
6000 | struct iwl_priv *priv = d->driver_data; | 4644 | struct iwl_priv *priv = d->driver_data; |
6001 | struct iwl4965_alive_resp *palive = &priv->card_alive; | 4645 | struct iwl_alive_resp *palive = &priv->card_alive; |
6002 | 4646 | ||
6003 | if (palive->is_valid) | 4647 | if (palive->is_valid) |
6004 | return sprintf(buf, "fw version: 0x%01X.0x%01X.0x%01X.0x%01X\n" | 4648 | return sprintf(buf, "fw version: 0x%01X.0x%01X.0x%01X.0x%01X\n" |
@@ -6368,34 +5012,6 @@ static ssize_t show_status(struct device *d, | |||
6368 | 5012 | ||
6369 | static DEVICE_ATTR(status, S_IRUGO, show_status, NULL); | 5013 | static DEVICE_ATTR(status, S_IRUGO, show_status, NULL); |
6370 | 5014 | ||
6371 | static ssize_t dump_error_log(struct device *d, | ||
6372 | struct device_attribute *attr, | ||
6373 | const char *buf, size_t count) | ||
6374 | { | ||
6375 | char *p = (char *)buf; | ||
6376 | |||
6377 | if (p[0] == '1') | ||
6378 | iwl4965_dump_nic_error_log((struct iwl_priv *)d->driver_data); | ||
6379 | |||
6380 | return strnlen(buf, count); | ||
6381 | } | ||
6382 | |||
6383 | static DEVICE_ATTR(dump_errors, S_IWUSR, NULL, dump_error_log); | ||
6384 | |||
6385 | static ssize_t dump_event_log(struct device *d, | ||
6386 | struct device_attribute *attr, | ||
6387 | const char *buf, size_t count) | ||
6388 | { | ||
6389 | char *p = (char *)buf; | ||
6390 | |||
6391 | if (p[0] == '1') | ||
6392 | iwl4965_dump_nic_event_log((struct iwl_priv *)d->driver_data); | ||
6393 | |||
6394 | return strnlen(buf, count); | ||
6395 | } | ||
6396 | |||
6397 | static DEVICE_ATTR(dump_events, S_IWUSR, NULL, dump_event_log); | ||
6398 | |||
6399 | /***************************************************************************** | 5015 | /***************************************************************************** |
6400 | * | 5016 | * |
6401 | * driver setup and teardown | 5017 | * driver setup and teardown |
@@ -6418,8 +5034,8 @@ static void iwl4965_setup_deferred_work(struct iwl_priv *priv) | |||
6418 | INIT_WORK(&priv->beacon_update, iwl4965_bg_beacon_update); | 5034 | INIT_WORK(&priv->beacon_update, iwl4965_bg_beacon_update); |
6419 | INIT_WORK(&priv->set_monitor, iwl4965_bg_set_monitor); | 5035 | INIT_WORK(&priv->set_monitor, iwl4965_bg_set_monitor); |
6420 | INIT_DELAYED_WORK(&priv->post_associate, iwl4965_bg_post_associate); | 5036 | INIT_DELAYED_WORK(&priv->post_associate, iwl4965_bg_post_associate); |
6421 | INIT_DELAYED_WORK(&priv->init_alive_start, iwl4965_bg_init_alive_start); | 5037 | INIT_DELAYED_WORK(&priv->init_alive_start, iwl_bg_init_alive_start); |
6422 | INIT_DELAYED_WORK(&priv->alive_start, iwl4965_bg_alive_start); | 5038 | INIT_DELAYED_WORK(&priv->alive_start, iwl_bg_alive_start); |
6423 | INIT_DELAYED_WORK(&priv->scan_check, iwl4965_bg_scan_check); | 5039 | INIT_DELAYED_WORK(&priv->scan_check, iwl4965_bg_scan_check); |
6424 | 5040 | ||
6425 | iwl4965_hw_setup_deferred_work(priv); | 5041 | iwl4965_hw_setup_deferred_work(priv); |
@@ -6441,8 +5057,6 @@ static void iwl4965_cancel_deferred_work(struct iwl_priv *priv) | |||
6441 | 5057 | ||
6442 | static struct attribute *iwl4965_sysfs_entries[] = { | 5058 | static struct attribute *iwl4965_sysfs_entries[] = { |
6443 | &dev_attr_channels.attr, | 5059 | &dev_attr_channels.attr, |
6444 | &dev_attr_dump_errors.attr, | ||
6445 | &dev_attr_dump_events.attr, | ||
6446 | &dev_attr_flags.attr, | 5060 | &dev_attr_flags.attr, |
6447 | &dev_attr_filter_flags.attr, | 5061 | &dev_attr_filter_flags.attr, |
6448 | #ifdef CONFIG_IWL4965_SPECTRUM_MEASUREMENT | 5062 | #ifdef CONFIG_IWL4965_SPECTRUM_MEASUREMENT |
@@ -6605,7 +5219,7 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
6605 | if (err) | 5219 | if (err) |
6606 | goto out_iounmap; | 5220 | goto out_iounmap; |
6607 | 5221 | ||
6608 | /* MAC Address location in EEPROM same for 3945/4965 */ | 5222 | /* extract MAC Address */ |
6609 | iwl_eeprom_get_mac(priv, priv->mac_addr); | 5223 | iwl_eeprom_get_mac(priv, priv->mac_addr); |
6610 | IWL_DEBUG_INFO("MAC address: %s\n", print_mac(mac, priv->mac_addr)); | 5224 | IWL_DEBUG_INFO("MAC address: %s\n", print_mac(mac, priv->mac_addr)); |
6611 | SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr); | 5225 | SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr); |
@@ -6620,10 +5234,10 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
6620 | } | 5234 | } |
6621 | 5235 | ||
6622 | /******************* | 5236 | /******************* |
6623 | * 6. Setup hw/priv | 5237 | * 6. Setup priv |
6624 | *******************/ | 5238 | *******************/ |
6625 | 5239 | ||
6626 | err = iwl_setup(priv); | 5240 | err = iwl_init_drv(priv); |
6627 | if (err) | 5241 | if (err) |
6628 | goto out_free_eeprom; | 5242 | goto out_free_eeprom; |
6629 | /* At this point both hw and priv are initialized. */ | 5243 | /* At this point both hw and priv are initialized. */ |
@@ -6638,9 +5252,6 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
6638 | IWL_DEBUG_INFO("Radio disabled.\n"); | 5252 | IWL_DEBUG_INFO("Radio disabled.\n"); |
6639 | } | 5253 | } |
6640 | 5254 | ||
6641 | if (priv->cfg->mod_params->enable_qos) | ||
6642 | priv->qos_data.qos_enable = 1; | ||
6643 | |||
6644 | /******************** | 5255 | /******************** |
6645 | * 8. Setup services | 5256 | * 8. Setup services |
6646 | ********************/ | 5257 | ********************/ |
@@ -6651,14 +5262,9 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
6651 | err = sysfs_create_group(&pdev->dev.kobj, &iwl4965_attribute_group); | 5262 | err = sysfs_create_group(&pdev->dev.kobj, &iwl4965_attribute_group); |
6652 | if (err) { | 5263 | if (err) { |
6653 | IWL_ERROR("failed to create sysfs device attributes\n"); | 5264 | IWL_ERROR("failed to create sysfs device attributes\n"); |
6654 | goto out_free_eeprom; | 5265 | goto out_uninit_drv; |
6655 | } | 5266 | } |
6656 | 5267 | ||
6657 | err = iwl_dbgfs_register(priv, DRV_NAME); | ||
6658 | if (err) { | ||
6659 | IWL_ERROR("failed to create debugfs files\n"); | ||
6660 | goto out_remove_sysfs; | ||
6661 | } | ||
6662 | 5268 | ||
6663 | iwl4965_setup_deferred_work(priv); | 5269 | iwl4965_setup_deferred_work(priv); |
6664 | iwl4965_setup_rx_handlers(priv); | 5270 | iwl4965_setup_rx_handlers(priv); |
@@ -6669,12 +5275,26 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
6669 | pci_save_state(pdev); | 5275 | pci_save_state(pdev); |
6670 | pci_disable_device(pdev); | 5276 | pci_disable_device(pdev); |
6671 | 5277 | ||
5278 | /********************************** | ||
5279 | * 10. Setup and register mac80211 | ||
5280 | **********************************/ | ||
5281 | |||
5282 | err = iwl_setup_mac(priv); | ||
5283 | if (err) | ||
5284 | goto out_remove_sysfs; | ||
5285 | |||
5286 | err = iwl_dbgfs_register(priv, DRV_NAME); | ||
5287 | if (err) | ||
5288 | IWL_ERROR("failed to create debugfs files\n"); | ||
5289 | |||
6672 | /* notify iwlcore to init */ | 5290 | /* notify iwlcore to init */ |
6673 | iwlcore_low_level_notify(priv, IWLCORE_INIT_EVT); | 5291 | iwlcore_low_level_notify(priv, IWLCORE_INIT_EVT); |
6674 | return 0; | 5292 | return 0; |
6675 | 5293 | ||
6676 | out_remove_sysfs: | 5294 | out_remove_sysfs: |
6677 | sysfs_remove_group(&pdev->dev.kobj, &iwl4965_attribute_group); | 5295 | sysfs_remove_group(&pdev->dev.kobj, &iwl4965_attribute_group); |
5296 | out_uninit_drv: | ||
5297 | iwl_uninit_drv(priv); | ||
6678 | out_free_eeprom: | 5298 | out_free_eeprom: |
6679 | iwl_eeprom_free(priv); | 5299 | iwl_eeprom_free(priv); |
6680 | out_iounmap: | 5300 | out_iounmap: |
@@ -6702,6 +5322,9 @@ static void __devexit iwl4965_pci_remove(struct pci_dev *pdev) | |||
6702 | 5322 | ||
6703 | IWL_DEBUG_INFO("*** UNLOAD DRIVER ***\n"); | 5323 | IWL_DEBUG_INFO("*** UNLOAD DRIVER ***\n"); |
6704 | 5324 | ||
5325 | iwl_dbgfs_unregister(priv); | ||
5326 | sysfs_remove_group(&pdev->dev.kobj, &iwl4965_attribute_group); | ||
5327 | |||
6705 | if (priv->mac80211_registered) { | 5328 | if (priv->mac80211_registered) { |
6706 | ieee80211_unregister_hw(priv->hw); | 5329 | ieee80211_unregister_hw(priv->hw); |
6707 | priv->mac80211_registered = 0; | 5330 | priv->mac80211_registered = 0; |
@@ -6729,8 +5352,6 @@ static void __devexit iwl4965_pci_remove(struct pci_dev *pdev) | |||
6729 | } | 5352 | } |
6730 | 5353 | ||
6731 | iwlcore_low_level_notify(priv, IWLCORE_REMOVE_EVT); | 5354 | iwlcore_low_level_notify(priv, IWLCORE_REMOVE_EVT); |
6732 | iwl_dbgfs_unregister(priv); | ||
6733 | sysfs_remove_group(&pdev->dev.kobj, &iwl4965_attribute_group); | ||
6734 | 5355 | ||
6735 | iwl4965_dealloc_ucode_pci(priv); | 5356 | iwl4965_dealloc_ucode_pci(priv); |
6736 | 5357 | ||
@@ -6756,8 +5377,7 @@ static void __devexit iwl4965_pci_remove(struct pci_dev *pdev) | |||
6756 | pci_disable_device(pdev); | 5377 | pci_disable_device(pdev); |
6757 | pci_set_drvdata(pdev, NULL); | 5378 | pci_set_drvdata(pdev, NULL); |
6758 | 5379 | ||
6759 | iwl_free_channel_map(priv); | 5380 | iwl_uninit_drv(priv); |
6760 | iwlcore_free_geos(priv); | ||
6761 | 5381 | ||
6762 | if (priv->ibss_beacon) | 5382 | if (priv->ibss_beacon) |
6763 | dev_kfree_skb(priv->ibss_beacon); | 5383 | dev_kfree_skb(priv->ibss_beacon); |
@@ -6848,10 +5468,6 @@ static int __init iwl4965_init(void) | |||
6848 | 5468 | ||
6849 | return ret; | 5469 | return ret; |
6850 | 5470 | ||
6851 | |||
6852 | #ifdef CONFIG_IWLWIFI_DEBUG | ||
6853 | pci_unregister_driver(&iwl_driver); | ||
6854 | #endif | ||
6855 | error_register: | 5471 | error_register: |
6856 | iwl4965_rate_control_unregister(); | 5472 | iwl4965_rate_control_unregister(); |
6857 | return ret; | 5473 | return ret; |
diff --git a/drivers/net/wireless/libertas/Makefile b/drivers/net/wireless/libertas/Makefile index f0724e31adfd..02080a3682a9 100644 --- a/drivers/net/wireless/libertas/Makefile +++ b/drivers/net/wireless/libertas/Makefile | |||
@@ -1,9 +1,5 @@ | |||
1 | libertas-objs := main.o wext.o \ | 1 | libertas-objs := main.o wext.o rx.o tx.o cmd.o cmdresp.o scan.o 11d.o \ |
2 | rx.o tx.o cmd.o \ | 2 | debugfs.o persistcfg.o ethtool.o assoc.o |
3 | cmdresp.o scan.o \ | ||
4 | 11d.o \ | ||
5 | debugfs.o \ | ||
6 | ethtool.o assoc.o | ||
7 | 3 | ||
8 | usb8xxx-objs += if_usb.o | 4 | usb8xxx-objs += if_usb.o |
9 | libertas_cs-objs += if_cs.o | 5 | libertas_cs-objs += if_cs.o |
diff --git a/drivers/net/wireless/libertas/assoc.c b/drivers/net/wireless/libertas/assoc.c index c9c3640ce9fb..a267d6e65f03 100644 --- a/drivers/net/wireless/libertas/assoc.c +++ b/drivers/net/wireless/libertas/assoc.c | |||
@@ -603,7 +603,8 @@ static int assoc_helper_channel(struct lbs_private *priv, | |||
603 | /* Change mesh channel first; 21.p21 firmware won't let | 603 | /* Change mesh channel first; 21.p21 firmware won't let |
604 | you change channel otherwise (even though it'll return | 604 | you change channel otherwise (even though it'll return |
605 | an error to this */ | 605 | an error to this */ |
606 | lbs_mesh_config(priv, 0, assoc_req->channel); | 606 | lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_STOP, |
607 | assoc_req->channel); | ||
607 | } | 608 | } |
608 | 609 | ||
609 | lbs_deb_assoc("ASSOC: channel: %d -> %d\n", | 610 | lbs_deb_assoc("ASSOC: channel: %d -> %d\n", |
@@ -642,7 +643,8 @@ static int assoc_helper_channel(struct lbs_private *priv, | |||
642 | 643 | ||
643 | restore_mesh: | 644 | restore_mesh: |
644 | if (priv->mesh_dev) | 645 | if (priv->mesh_dev) |
645 | lbs_mesh_config(priv, 1, priv->curbssparams.channel); | 646 | lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START, |
647 | priv->curbssparams.channel); | ||
646 | 648 | ||
647 | done: | 649 | done: |
648 | lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); | 650 | lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); |
@@ -1248,7 +1250,7 @@ static int get_common_rates(struct lbs_private *priv, | |||
1248 | lbs_deb_hex(LBS_DEB_JOIN, "common rates", tmp, tmp_size); | 1250 | lbs_deb_hex(LBS_DEB_JOIN, "common rates", tmp, tmp_size); |
1249 | lbs_deb_join("TX data rate 0x%02x\n", priv->cur_rate); | 1251 | lbs_deb_join("TX data rate 0x%02x\n", priv->cur_rate); |
1250 | 1252 | ||
1251 | if (!priv->auto_rate) { | 1253 | if (!priv->enablehwauto) { |
1252 | for (i = 0; i < tmp_size; i++) { | 1254 | for (i = 0; i < tmp_size; i++) { |
1253 | if (tmp[i] == priv->cur_rate) | 1255 | if (tmp[i] == priv->cur_rate) |
1254 | goto done; | 1256 | goto done; |
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c index c2dd43ece069..cf261d3487fd 100644 --- a/drivers/net/wireless/libertas/cmd.c +++ b/drivers/net/wireless/libertas/cmd.c | |||
@@ -4,6 +4,7 @@ | |||
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <net/iw_handler.h> | 6 | #include <net/iw_handler.h> |
7 | #include <net/ieee80211.h> | ||
7 | #include <linux/kfifo.h> | 8 | #include <linux/kfifo.h> |
8 | #include "host.h" | 9 | #include "host.h" |
9 | #include "hostcmd.h" | 10 | #include "hostcmd.h" |
@@ -109,7 +110,7 @@ int lbs_update_hw_spec(struct lbs_private *priv) | |||
109 | * CF card firmware 5.0.16p0: cap 0x00000303 | 110 | * CF card firmware 5.0.16p0: cap 0x00000303 |
110 | * USB dongle firmware 5.110.17p2: cap 0x00000303 | 111 | * USB dongle firmware 5.110.17p2: cap 0x00000303 |
111 | */ | 112 | */ |
112 | printk("libertas: %s, fw %u.%u.%up%u, cap 0x%08x\n", | 113 | lbs_pr_info("%s, fw %u.%u.%up%u, cap 0x%08x\n", |
113 | print_mac(mac, cmd.permanentaddr), | 114 | print_mac(mac, cmd.permanentaddr), |
114 | priv->fwrelease >> 24 & 0xff, | 115 | priv->fwrelease >> 24 & 0xff, |
115 | priv->fwrelease >> 16 & 0xff, | 116 | priv->fwrelease >> 16 & 0xff, |
@@ -675,26 +676,60 @@ static int lbs_cmd_802_11_monitor_mode(struct cmd_ds_command *cmd, | |||
675 | return 0; | 676 | return 0; |
676 | } | 677 | } |
677 | 678 | ||
678 | static int lbs_cmd_802_11_rate_adapt_rateset(struct lbs_private *priv, | 679 | static __le16 lbs_rate_to_fw_bitmap(int rate, int lower_rates_ok) |
679 | struct cmd_ds_command *cmd, | ||
680 | u16 cmd_action) | ||
681 | { | 680 | { |
682 | struct cmd_ds_802_11_rate_adapt_rateset | 681 | /* Bit Rate |
683 | *rateadapt = &cmd->params.rateset; | 682 | * 15:13 Reserved |
683 | * 12 54 Mbps | ||
684 | * 11 48 Mbps | ||
685 | * 10 36 Mbps | ||
686 | * 9 24 Mbps | ||
687 | * 8 18 Mbps | ||
688 | * 7 12 Mbps | ||
689 | * 6 9 Mbps | ||
690 | * 5 6 Mbps | ||
691 | * 4 Reserved | ||
692 | * 3 11 Mbps | ||
693 | * 2 5.5 Mbps | ||
694 | * 1 2 Mbps | ||
695 | * 0 1 Mbps | ||
696 | **/ | ||
697 | |||
698 | uint16_t ratemask; | ||
699 | int i = lbs_data_rate_to_fw_index(rate); | ||
700 | if (lower_rates_ok) | ||
701 | ratemask = (0x1fef >> (12 - i)); | ||
702 | else | ||
703 | ratemask = (1 << i); | ||
704 | return cpu_to_le16(ratemask); | ||
705 | } | ||
706 | |||
707 | int lbs_cmd_802_11_rate_adapt_rateset(struct lbs_private *priv, | ||
708 | uint16_t cmd_action) | ||
709 | { | ||
710 | struct cmd_ds_802_11_rate_adapt_rateset cmd; | ||
711 | int ret; | ||
684 | 712 | ||
685 | lbs_deb_enter(LBS_DEB_CMD); | 713 | lbs_deb_enter(LBS_DEB_CMD); |
686 | cmd->size = | ||
687 | cpu_to_le16(sizeof(struct cmd_ds_802_11_rate_adapt_rateset) | ||
688 | + S_DS_GEN); | ||
689 | cmd->command = cpu_to_le16(CMD_802_11_RATE_ADAPT_RATESET); | ||
690 | 714 | ||
691 | rateadapt->action = cpu_to_le16(cmd_action); | 715 | if (!priv->cur_rate && !priv->enablehwauto) |
692 | rateadapt->enablehwauto = cpu_to_le16(priv->enablehwauto); | 716 | return -EINVAL; |
693 | rateadapt->bitmap = cpu_to_le16(priv->ratebitmap); | ||
694 | 717 | ||
695 | lbs_deb_leave(LBS_DEB_CMD); | 718 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
696 | return 0; | 719 | |
720 | cmd.action = cpu_to_le16(cmd_action); | ||
721 | cmd.enablehwauto = cpu_to_le16(priv->enablehwauto); | ||
722 | cmd.bitmap = lbs_rate_to_fw_bitmap(priv->cur_rate, priv->enablehwauto); | ||
723 | ret = lbs_cmd_with_response(priv, CMD_802_11_RATE_ADAPT_RATESET, &cmd); | ||
724 | if (!ret && cmd_action == CMD_ACT_GET) { | ||
725 | priv->ratebitmap = le16_to_cpu(cmd.bitmap); | ||
726 | priv->enablehwauto = le16_to_cpu(cmd.enablehwauto); | ||
727 | } | ||
728 | |||
729 | lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); | ||
730 | return ret; | ||
697 | } | 731 | } |
732 | EXPORT_SYMBOL_GPL(lbs_cmd_802_11_rate_adapt_rateset); | ||
698 | 733 | ||
699 | /** | 734 | /** |
700 | * @brief Set the data rate | 735 | * @brief Set the data rate |
@@ -746,28 +781,6 @@ out: | |||
746 | return ret; | 781 | return ret; |
747 | } | 782 | } |
748 | 783 | ||
749 | static int lbs_cmd_mac_multicast_adr(struct lbs_private *priv, | ||
750 | struct cmd_ds_command *cmd, | ||
751 | u16 cmd_action) | ||
752 | { | ||
753 | struct cmd_ds_mac_multicast_adr *pMCastAdr = &cmd->params.madr; | ||
754 | |||
755 | lbs_deb_enter(LBS_DEB_CMD); | ||
756 | cmd->size = cpu_to_le16(sizeof(struct cmd_ds_mac_multicast_adr) + | ||
757 | S_DS_GEN); | ||
758 | cmd->command = cpu_to_le16(CMD_MAC_MULTICAST_ADR); | ||
759 | |||
760 | lbs_deb_cmd("MULTICAST_ADR: setting %d addresses\n", pMCastAdr->nr_of_adrs); | ||
761 | pMCastAdr->action = cpu_to_le16(cmd_action); | ||
762 | pMCastAdr->nr_of_adrs = | ||
763 | cpu_to_le16((u16) priv->nr_of_multicastmacaddr); | ||
764 | memcpy(pMCastAdr->maclist, priv->multicastlist, | ||
765 | priv->nr_of_multicastmacaddr * ETH_ALEN); | ||
766 | |||
767 | lbs_deb_leave(LBS_DEB_CMD); | ||
768 | return 0; | ||
769 | } | ||
770 | |||
771 | /** | 784 | /** |
772 | * @brief Get the radio channel | 785 | * @brief Get the radio channel |
773 | * | 786 | * |
@@ -1020,24 +1033,69 @@ int lbs_mesh_access(struct lbs_private *priv, uint16_t cmd_action, | |||
1020 | return ret; | 1033 | return ret; |
1021 | } | 1034 | } |
1022 | 1035 | ||
1023 | int lbs_mesh_config(struct lbs_private *priv, uint16_t enable, uint16_t chan) | 1036 | int lbs_mesh_config_send(struct lbs_private *priv, |
1037 | struct cmd_ds_mesh_config *cmd, | ||
1038 | uint16_t action, uint16_t type) | ||
1039 | { | ||
1040 | int ret; | ||
1041 | |||
1042 | lbs_deb_enter(LBS_DEB_CMD); | ||
1043 | |||
1044 | cmd->hdr.command = cpu_to_le16(CMD_MESH_CONFIG); | ||
1045 | cmd->hdr.size = cpu_to_le16(sizeof(struct cmd_ds_mesh_config)); | ||
1046 | cmd->hdr.result = 0; | ||
1047 | |||
1048 | cmd->type = cpu_to_le16(type); | ||
1049 | cmd->action = cpu_to_le16(action); | ||
1050 | |||
1051 | ret = lbs_cmd_with_response(priv, CMD_MESH_CONFIG, cmd); | ||
1052 | |||
1053 | lbs_deb_leave(LBS_DEB_CMD); | ||
1054 | return ret; | ||
1055 | } | ||
1056 | |||
1057 | /* This function is the CMD_MESH_CONFIG legacy function. It only handles the | ||
1058 | * START and STOP actions. The extended actions supported by CMD_MESH_CONFIG | ||
1059 | * are all handled by preparing a struct cmd_ds_mesh_config and passing it to | ||
1060 | * lbs_mesh_config_send. | ||
1061 | */ | ||
1062 | int lbs_mesh_config(struct lbs_private *priv, uint16_t action, uint16_t chan) | ||
1024 | { | 1063 | { |
1025 | struct cmd_ds_mesh_config cmd; | 1064 | struct cmd_ds_mesh_config cmd; |
1065 | struct mrvl_meshie *ie; | ||
1026 | 1066 | ||
1027 | memset(&cmd, 0, sizeof(cmd)); | 1067 | memset(&cmd, 0, sizeof(cmd)); |
1028 | cmd.action = cpu_to_le16(enable); | ||
1029 | cmd.channel = cpu_to_le16(chan); | 1068 | cmd.channel = cpu_to_le16(chan); |
1030 | cmd.type = cpu_to_le16(priv->mesh_tlv); | 1069 | ie = (struct mrvl_meshie *)cmd.data; |
1031 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); | 1070 | |
1032 | 1071 | switch (action) { | |
1033 | if (enable) { | 1072 | case CMD_ACT_MESH_CONFIG_START: |
1034 | cmd.length = cpu_to_le16(priv->mesh_ssid_len); | 1073 | ie->hdr.id = MFIE_TYPE_GENERIC; |
1035 | memcpy(cmd.data, priv->mesh_ssid, priv->mesh_ssid_len); | 1074 | ie->val.oui[0] = 0x00; |
1075 | ie->val.oui[1] = 0x50; | ||
1076 | ie->val.oui[2] = 0x43; | ||
1077 | ie->val.type = MARVELL_MESH_IE_TYPE; | ||
1078 | ie->val.subtype = MARVELL_MESH_IE_SUBTYPE; | ||
1079 | ie->val.version = MARVELL_MESH_IE_VERSION; | ||
1080 | ie->val.active_protocol_id = MARVELL_MESH_PROTO_ID_HWMP; | ||
1081 | ie->val.active_metric_id = MARVELL_MESH_METRIC_ID; | ||
1082 | ie->val.mesh_capability = MARVELL_MESH_CAPABILITY; | ||
1083 | ie->val.mesh_id_len = priv->mesh_ssid_len; | ||
1084 | memcpy(ie->val.mesh_id, priv->mesh_ssid, priv->mesh_ssid_len); | ||
1085 | ie->hdr.len = sizeof(struct mrvl_meshie_val) - | ||
1086 | IW_ESSID_MAX_SIZE + priv->mesh_ssid_len; | ||
1087 | cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie_val)); | ||
1088 | break; | ||
1089 | case CMD_ACT_MESH_CONFIG_STOP: | ||
1090 | break; | ||
1091 | default: | ||
1092 | return -1; | ||
1036 | } | 1093 | } |
1037 | lbs_deb_cmd("mesh config enable %d TLV %x channel %d SSID %s\n", | 1094 | lbs_deb_cmd("mesh config action %d type %x channel %d SSID %s\n", |
1038 | enable, priv->mesh_tlv, chan, | 1095 | action, priv->mesh_tlv, chan, |
1039 | escape_essid(priv->mesh_ssid, priv->mesh_ssid_len)); | 1096 | escape_essid(priv->mesh_ssid, priv->mesh_ssid_len)); |
1040 | return lbs_cmd_with_response(priv, CMD_MESH_CONFIG, &cmd); | 1097 | |
1098 | return lbs_mesh_config_send(priv, &cmd, action, priv->mesh_tlv); | ||
1041 | } | 1099 | } |
1042 | 1100 | ||
1043 | static int lbs_cmd_bcn_ctrl(struct lbs_private * priv, | 1101 | static int lbs_cmd_bcn_ctrl(struct lbs_private * priv, |
@@ -1112,7 +1170,7 @@ static void lbs_submit_command(struct lbs_private *priv, | |||
1112 | struct cmd_header *cmd; | 1170 | struct cmd_header *cmd; |
1113 | uint16_t cmdsize; | 1171 | uint16_t cmdsize; |
1114 | uint16_t command; | 1172 | uint16_t command; |
1115 | int timeo = 5 * HZ; | 1173 | int timeo = 3 * HZ; |
1116 | int ret; | 1174 | int ret; |
1117 | 1175 | ||
1118 | lbs_deb_enter(LBS_DEB_HOST); | 1176 | lbs_deb_enter(LBS_DEB_HOST); |
@@ -1130,7 +1188,7 @@ static void lbs_submit_command(struct lbs_private *priv, | |||
1130 | /* These commands take longer */ | 1188 | /* These commands take longer */ |
1131 | if (command == CMD_802_11_SCAN || command == CMD_802_11_ASSOCIATE || | 1189 | if (command == CMD_802_11_SCAN || command == CMD_802_11_ASSOCIATE || |
1132 | command == CMD_802_11_AUTHENTICATE) | 1190 | command == CMD_802_11_AUTHENTICATE) |
1133 | timeo = 10 * HZ; | 1191 | timeo = 5 * HZ; |
1134 | 1192 | ||
1135 | lbs_deb_cmd("DNLD_CMD: command 0x%04x, seq %d, size %d\n", | 1193 | lbs_deb_cmd("DNLD_CMD: command 0x%04x, seq %d, size %d\n", |
1136 | command, le16_to_cpu(cmd->seqnum), cmdsize); | 1194 | command, le16_to_cpu(cmd->seqnum), cmdsize); |
@@ -1142,7 +1200,7 @@ static void lbs_submit_command(struct lbs_private *priv, | |||
1142 | lbs_pr_info("DNLD_CMD: hw_host_to_card failed: %d\n", ret); | 1200 | lbs_pr_info("DNLD_CMD: hw_host_to_card failed: %d\n", ret); |
1143 | /* Let the timer kick in and retry, and potentially reset | 1201 | /* Let the timer kick in and retry, and potentially reset |
1144 | the whole thing if the condition persists */ | 1202 | the whole thing if the condition persists */ |
1145 | timeo = HZ; | 1203 | timeo = HZ/4; |
1146 | } | 1204 | } |
1147 | 1205 | ||
1148 | /* Setup the timer after transmit command */ | 1206 | /* Setup the timer after transmit command */ |
@@ -1247,8 +1305,7 @@ void lbs_set_mac_control(struct lbs_private *priv) | |||
1247 | cmd.action = cpu_to_le16(priv->mac_control); | 1305 | cmd.action = cpu_to_le16(priv->mac_control); |
1248 | cmd.reserved = 0; | 1306 | cmd.reserved = 0; |
1249 | 1307 | ||
1250 | lbs_cmd_async(priv, CMD_MAC_CONTROL, | 1308 | lbs_cmd_async(priv, CMD_MAC_CONTROL, &cmd.hdr, sizeof(cmd)); |
1251 | &cmd.hdr, sizeof(cmd)); | ||
1252 | 1309 | ||
1253 | lbs_deb_leave(LBS_DEB_CMD); | 1310 | lbs_deb_leave(LBS_DEB_CMD); |
1254 | } | 1311 | } |
@@ -1355,15 +1412,6 @@ int lbs_prepare_and_send_command(struct lbs_private *priv, | |||
1355 | cmd_action, pdata_buf); | 1412 | cmd_action, pdata_buf); |
1356 | break; | 1413 | break; |
1357 | 1414 | ||
1358 | case CMD_802_11_RATE_ADAPT_RATESET: | ||
1359 | ret = lbs_cmd_802_11_rate_adapt_rateset(priv, | ||
1360 | cmdptr, cmd_action); | ||
1361 | break; | ||
1362 | |||
1363 | case CMD_MAC_MULTICAST_ADR: | ||
1364 | ret = lbs_cmd_mac_multicast_adr(priv, cmdptr, cmd_action); | ||
1365 | break; | ||
1366 | |||
1367 | case CMD_802_11_MONITOR_MODE: | 1415 | case CMD_802_11_MONITOR_MODE: |
1368 | ret = lbs_cmd_802_11_monitor_mode(cmdptr, | 1416 | ret = lbs_cmd_802_11_monitor_mode(cmdptr, |
1369 | cmd_action, pdata_buf); | 1417 | cmd_action, pdata_buf); |
@@ -1452,7 +1500,7 @@ int lbs_prepare_and_send_command(struct lbs_private *priv, | |||
1452 | ret = lbs_cmd_bcn_ctrl(priv, cmdptr, cmd_action); | 1500 | ret = lbs_cmd_bcn_ctrl(priv, cmdptr, cmd_action); |
1453 | break; | 1501 | break; |
1454 | default: | 1502 | default: |
1455 | lbs_deb_host("PREP_CMD: unknown command 0x%04x\n", cmd_no); | 1503 | lbs_pr_err("PREP_CMD: unknown command 0x%04x\n", cmd_no); |
1456 | ret = -1; | 1504 | ret = -1; |
1457 | break; | 1505 | break; |
1458 | } | 1506 | } |
diff --git a/drivers/net/wireless/libertas/cmd.h b/drivers/net/wireless/libertas/cmd.h index f4019c22adfc..a53b51f8bdb4 100644 --- a/drivers/net/wireless/libertas/cmd.h +++ b/drivers/net/wireless/libertas/cmd.h | |||
@@ -39,12 +39,17 @@ int lbs_set_data_rate(struct lbs_private *priv, u8 rate); | |||
39 | int lbs_get_channel(struct lbs_private *priv); | 39 | int lbs_get_channel(struct lbs_private *priv); |
40 | int lbs_set_channel(struct lbs_private *priv, u8 channel); | 40 | int lbs_set_channel(struct lbs_private *priv, u8 channel); |
41 | 41 | ||
42 | int lbs_mesh_config_send(struct lbs_private *priv, | ||
43 | struct cmd_ds_mesh_config *cmd, | ||
44 | uint16_t action, uint16_t type); | ||
42 | int lbs_mesh_config(struct lbs_private *priv, uint16_t enable, uint16_t chan); | 45 | int lbs_mesh_config(struct lbs_private *priv, uint16_t enable, uint16_t chan); |
43 | 46 | ||
44 | int lbs_host_sleep_cfg(struct lbs_private *priv, uint32_t criteria); | 47 | int lbs_host_sleep_cfg(struct lbs_private *priv, uint32_t criteria); |
45 | int lbs_suspend(struct lbs_private *priv); | 48 | int lbs_suspend(struct lbs_private *priv); |
46 | void lbs_resume(struct lbs_private *priv); | 49 | void lbs_resume(struct lbs_private *priv); |
47 | 50 | ||
51 | int lbs_cmd_802_11_rate_adapt_rateset(struct lbs_private *priv, | ||
52 | uint16_t cmd_action); | ||
48 | int lbs_cmd_802_11_inactivity_timeout(struct lbs_private *priv, | 53 | int lbs_cmd_802_11_inactivity_timeout(struct lbs_private *priv, |
49 | uint16_t cmd_action, uint16_t *timeout); | 54 | uint16_t cmd_action, uint16_t *timeout); |
50 | int lbs_cmd_802_11_sleep_params(struct lbs_private *priv, uint16_t cmd_action, | 55 | int lbs_cmd_802_11_sleep_params(struct lbs_private *priv, uint16_t cmd_action, |
diff --git a/drivers/net/wireless/libertas/cmdresp.c b/drivers/net/wireless/libertas/cmdresp.c index 5abecb7673e6..24de3c3cf877 100644 --- a/drivers/net/wireless/libertas/cmdresp.c +++ b/drivers/net/wireless/libertas/cmdresp.c | |||
@@ -203,22 +203,6 @@ static int lbs_ret_802_11_rf_tx_power(struct lbs_private *priv, | |||
203 | return 0; | 203 | return 0; |
204 | } | 204 | } |
205 | 205 | ||
206 | static int lbs_ret_802_11_rate_adapt_rateset(struct lbs_private *priv, | ||
207 | struct cmd_ds_command *resp) | ||
208 | { | ||
209 | struct cmd_ds_802_11_rate_adapt_rateset *rates = &resp->params.rateset; | ||
210 | |||
211 | lbs_deb_enter(LBS_DEB_CMD); | ||
212 | |||
213 | if (rates->action == CMD_ACT_GET) { | ||
214 | priv->enablehwauto = le16_to_cpu(rates->enablehwauto); | ||
215 | priv->ratebitmap = le16_to_cpu(rates->bitmap); | ||
216 | } | ||
217 | |||
218 | lbs_deb_leave(LBS_DEB_CMD); | ||
219 | return 0; | ||
220 | } | ||
221 | |||
222 | static int lbs_ret_802_11_rssi(struct lbs_private *priv, | 206 | static int lbs_ret_802_11_rssi(struct lbs_private *priv, |
223 | struct cmd_ds_command *resp) | 207 | struct cmd_ds_command *resp) |
224 | { | 208 | { |
@@ -316,16 +300,11 @@ static inline int handle_cmd_response(struct lbs_private *priv, | |||
316 | 300 | ||
317 | break; | 301 | break; |
318 | 302 | ||
319 | case CMD_RET(CMD_MAC_MULTICAST_ADR): | ||
320 | case CMD_RET(CMD_802_11_RESET): | 303 | case CMD_RET(CMD_802_11_RESET): |
321 | case CMD_RET(CMD_802_11_AUTHENTICATE): | 304 | case CMD_RET(CMD_802_11_AUTHENTICATE): |
322 | case CMD_RET(CMD_802_11_BEACON_STOP): | 305 | case CMD_RET(CMD_802_11_BEACON_STOP): |
323 | break; | 306 | break; |
324 | 307 | ||
325 | case CMD_RET(CMD_802_11_RATE_ADAPT_RATESET): | ||
326 | ret = lbs_ret_802_11_rate_adapt_rateset(priv, resp); | ||
327 | break; | ||
328 | |||
329 | case CMD_RET(CMD_802_11_RSSI): | 308 | case CMD_RET(CMD_802_11_RSSI): |
330 | ret = lbs_ret_802_11_rssi(priv, resp); | 309 | ret = lbs_ret_802_11_rssi(priv, resp); |
331 | break; | 310 | break; |
@@ -376,8 +355,8 @@ static inline int handle_cmd_response(struct lbs_private *priv, | |||
376 | break; | 355 | break; |
377 | 356 | ||
378 | default: | 357 | default: |
379 | lbs_deb_host("CMD_RESP: unknown cmd response 0x%04x\n", | 358 | lbs_pr_err("CMD_RESP: unknown cmd response 0x%04x\n", |
380 | le16_to_cpu(resp->command)); | 359 | le16_to_cpu(resp->command)); |
381 | break; | 360 | break; |
382 | } | 361 | } |
383 | lbs_deb_leave(LBS_DEB_HOST); | 362 | lbs_deb_leave(LBS_DEB_HOST); |
diff --git a/drivers/net/wireless/libertas/decl.h b/drivers/net/wireless/libertas/decl.h index 0632b09655d2..a8ac974dacac 100644 --- a/drivers/net/wireless/libertas/decl.h +++ b/drivers/net/wireless/libertas/decl.h | |||
@@ -60,6 +60,10 @@ void lbs_mac_event_disconnected(struct lbs_private *priv); | |||
60 | 60 | ||
61 | void lbs_send_iwevcustom_event(struct lbs_private *priv, s8 *str); | 61 | void lbs_send_iwevcustom_event(struct lbs_private *priv, s8 *str); |
62 | 62 | ||
63 | /* persistcfg.c */ | ||
64 | void lbs_persist_config_init(struct net_device *net); | ||
65 | void lbs_persist_config_remove(struct net_device *net); | ||
66 | |||
63 | /* main.c */ | 67 | /* main.c */ |
64 | struct chan_freq_power *lbs_get_region_cfp_table(u8 region, | 68 | struct chan_freq_power *lbs_get_region_cfp_table(u8 region, |
65 | int *cfp_no); | 69 | int *cfp_no); |
diff --git a/drivers/net/wireless/libertas/defs.h b/drivers/net/wireless/libertas/defs.h index d39520111062..12e687550bce 100644 --- a/drivers/net/wireless/libertas/defs.h +++ b/drivers/net/wireless/libertas/defs.h | |||
@@ -40,6 +40,7 @@ | |||
40 | #define LBS_DEB_THREAD 0x00100000 | 40 | #define LBS_DEB_THREAD 0x00100000 |
41 | #define LBS_DEB_HEX 0x00200000 | 41 | #define LBS_DEB_HEX 0x00200000 |
42 | #define LBS_DEB_SDIO 0x00400000 | 42 | #define LBS_DEB_SDIO 0x00400000 |
43 | #define LBS_DEB_SYSFS 0x00800000 | ||
43 | 44 | ||
44 | extern unsigned int lbs_debug; | 45 | extern unsigned int lbs_debug; |
45 | 46 | ||
@@ -81,7 +82,8 @@ do { if ((lbs_debug & (grp)) == (grp)) \ | |||
81 | #define lbs_deb_usbd(dev, fmt, args...) LBS_DEB_LL(LBS_DEB_USB, " usbd", "%s:" fmt, (dev)->bus_id, ##args) | 82 | #define lbs_deb_usbd(dev, fmt, args...) LBS_DEB_LL(LBS_DEB_USB, " usbd", "%s:" fmt, (dev)->bus_id, ##args) |
82 | #define lbs_deb_cs(fmt, args...) LBS_DEB_LL(LBS_DEB_CS, " cs", fmt, ##args) | 83 | #define lbs_deb_cs(fmt, args...) LBS_DEB_LL(LBS_DEB_CS, " cs", fmt, ##args) |
83 | #define lbs_deb_thread(fmt, args...) LBS_DEB_LL(LBS_DEB_THREAD, " thread", fmt, ##args) | 84 | #define lbs_deb_thread(fmt, args...) LBS_DEB_LL(LBS_DEB_THREAD, " thread", fmt, ##args) |
84 | #define lbs_deb_sdio(fmt, args...) LBS_DEB_LL(LBS_DEB_SDIO, " thread", fmt, ##args) | 85 | #define lbs_deb_sdio(fmt, args...) LBS_DEB_LL(LBS_DEB_SDIO, " sdio", fmt, ##args) |
86 | #define lbs_deb_sysfs(fmt, args...) LBS_DEB_LL(LBS_DEB_SYSFS, " sysfs", fmt, ##args) | ||
85 | 87 | ||
86 | #define lbs_pr_info(format, args...) \ | 88 | #define lbs_pr_info(format, args...) \ |
87 | printk(KERN_INFO DRV_NAME": " format, ## args) | 89 | printk(KERN_INFO DRV_NAME": " format, ## args) |
@@ -170,6 +172,16 @@ static inline void lbs_deb_hex(unsigned int grp, const char *prompt, u8 *buf, in | |||
170 | 172 | ||
171 | #define MARVELL_MESH_IE_LENGTH 9 | 173 | #define MARVELL_MESH_IE_LENGTH 9 |
172 | 174 | ||
175 | /* Values used to populate the struct mrvl_mesh_ie. The only time you need this | ||
176 | * is when enabling the mesh using CMD_MESH_CONFIG. | ||
177 | */ | ||
178 | #define MARVELL_MESH_IE_TYPE 4 | ||
179 | #define MARVELL_MESH_IE_SUBTYPE 0 | ||
180 | #define MARVELL_MESH_IE_VERSION 0 | ||
181 | #define MARVELL_MESH_PROTO_ID_HWMP 0 | ||
182 | #define MARVELL_MESH_METRIC_ID 0 | ||
183 | #define MARVELL_MESH_CAPABILITY 0 | ||
184 | |||
173 | /** INT status Bit Definition*/ | 185 | /** INT status Bit Definition*/ |
174 | #define MRVDRV_TX_DNLD_RDY 0x0001 | 186 | #define MRVDRV_TX_DNLD_RDY 0x0001 |
175 | #define MRVDRV_RX_UPLD_RDY 0x0002 | 187 | #define MRVDRV_RX_UPLD_RDY 0x0002 |
diff --git a/drivers/net/wireless/libertas/dev.h b/drivers/net/wireless/libertas/dev.h index 0d9edb9b11f5..f5bb40c54d85 100644 --- a/drivers/net/wireless/libertas/dev.h +++ b/drivers/net/wireless/libertas/dev.h | |||
@@ -140,6 +140,8 @@ struct lbs_private { | |||
140 | wait_queue_head_t waitq; | 140 | wait_queue_head_t waitq; |
141 | struct workqueue_struct *work_thread; | 141 | struct workqueue_struct *work_thread; |
142 | 142 | ||
143 | struct work_struct mcast_work; | ||
144 | |||
143 | /** Scanning */ | 145 | /** Scanning */ |
144 | struct delayed_work scan_work; | 146 | struct delayed_work scan_work; |
145 | struct delayed_work assoc_work; | 147 | struct delayed_work assoc_work; |
@@ -151,6 +153,7 @@ struct lbs_private { | |||
151 | 153 | ||
152 | /** Hardware access */ | 154 | /** Hardware access */ |
153 | int (*hw_host_to_card) (struct lbs_private *priv, u8 type, u8 *payload, u16 nb); | 155 | int (*hw_host_to_card) (struct lbs_private *priv, u8 type, u8 *payload, u16 nb); |
156 | void (*reset_card) (struct lbs_private *priv); | ||
154 | 157 | ||
155 | /* Wake On LAN */ | 158 | /* Wake On LAN */ |
156 | uint32_t wol_criteria; | 159 | uint32_t wol_criteria; |
@@ -234,8 +237,8 @@ struct lbs_private { | |||
234 | /** 802.11 statistics */ | 237 | /** 802.11 statistics */ |
235 | // struct cmd_DS_802_11_GET_STAT wlan802_11Stat; | 238 | // struct cmd_DS_802_11_GET_STAT wlan802_11Stat; |
236 | 239 | ||
237 | u16 enablehwauto; | 240 | uint16_t enablehwauto; |
238 | u16 ratebitmap; | 241 | uint16_t ratebitmap; |
239 | 242 | ||
240 | u32 fragthsd; | 243 | u32 fragthsd; |
241 | u32 rtsthsd; | 244 | u32 rtsthsd; |
@@ -293,7 +296,6 @@ struct lbs_private { | |||
293 | 296 | ||
294 | /** data rate stuff */ | 297 | /** data rate stuff */ |
295 | u8 cur_rate; | 298 | u8 cur_rate; |
296 | u8 auto_rate; | ||
297 | 299 | ||
298 | /** RF calibration data */ | 300 | /** RF calibration data */ |
299 | 301 | ||
diff --git a/drivers/net/wireless/libertas/host.h b/drivers/net/wireless/libertas/host.h index 3915c3144fad..c92e41b4faf4 100644 --- a/drivers/net/wireless/libertas/host.h +++ b/drivers/net/wireless/libertas/host.h | |||
@@ -256,6 +256,23 @@ enum cmd_mesh_access_opts { | |||
256 | CMD_ACT_MESH_GET_AUTOSTART_ENABLED, | 256 | CMD_ACT_MESH_GET_AUTOSTART_ENABLED, |
257 | }; | 257 | }; |
258 | 258 | ||
259 | /* Define actions and types for CMD_MESH_CONFIG */ | ||
260 | enum cmd_mesh_config_actions { | ||
261 | CMD_ACT_MESH_CONFIG_STOP = 0, | ||
262 | CMD_ACT_MESH_CONFIG_START, | ||
263 | CMD_ACT_MESH_CONFIG_SET, | ||
264 | CMD_ACT_MESH_CONFIG_GET, | ||
265 | }; | ||
266 | |||
267 | enum cmd_mesh_config_types { | ||
268 | CMD_TYPE_MESH_SET_BOOTFLAG = 1, | ||
269 | CMD_TYPE_MESH_SET_BOOTTIME, | ||
270 | CMD_TYPE_MESH_SET_DEF_CHANNEL, | ||
271 | CMD_TYPE_MESH_SET_MESH_IE, | ||
272 | CMD_TYPE_MESH_GET_DEFAULTS, | ||
273 | CMD_TYPE_MESH_GET_MESH_IE, /* GET_DEFAULTS is superset of GET_MESHIE */ | ||
274 | }; | ||
275 | |||
259 | /** Card Event definition */ | 276 | /** Card Event definition */ |
260 | #define MACREG_INT_CODE_TX_PPA_FREE 0 | 277 | #define MACREG_INT_CODE_TX_PPA_FREE 0 |
261 | #define MACREG_INT_CODE_TX_DMA_DONE 1 | 278 | #define MACREG_INT_CODE_TX_DMA_DONE 1 |
diff --git a/drivers/net/wireless/libertas/hostcmd.h b/drivers/net/wireless/libertas/hostcmd.h index f29bc5bbda3e..913b480211a9 100644 --- a/drivers/net/wireless/libertas/hostcmd.h +++ b/drivers/net/wireless/libertas/hostcmd.h | |||
@@ -219,6 +219,7 @@ struct cmd_ds_mac_control { | |||
219 | }; | 219 | }; |
220 | 220 | ||
221 | struct cmd_ds_mac_multicast_adr { | 221 | struct cmd_ds_mac_multicast_adr { |
222 | struct cmd_header hdr; | ||
222 | __le16 action; | 223 | __le16 action; |
223 | __le16 nr_of_adrs; | 224 | __le16 nr_of_adrs; |
224 | u8 maclist[ETH_ALEN * MRVDRV_MAX_MULTICAST_LIST_SIZE]; | 225 | u8 maclist[ETH_ALEN * MRVDRV_MAX_MULTICAST_LIST_SIZE]; |
@@ -499,6 +500,7 @@ struct cmd_ds_802_11_data_rate { | |||
499 | }; | 500 | }; |
500 | 501 | ||
501 | struct cmd_ds_802_11_rate_adapt_rateset { | 502 | struct cmd_ds_802_11_rate_adapt_rateset { |
503 | struct cmd_header hdr; | ||
502 | __le16 action; | 504 | __le16 action; |
503 | __le16 enablehwauto; | 505 | __le16 enablehwauto; |
504 | __le16 bitmap; | 506 | __le16 bitmap; |
@@ -702,8 +704,6 @@ struct cmd_ds_command { | |||
702 | struct cmd_ds_802_11_rf_tx_power txp; | 704 | struct cmd_ds_802_11_rf_tx_power txp; |
703 | struct cmd_ds_802_11_rf_antenna rant; | 705 | struct cmd_ds_802_11_rf_antenna rant; |
704 | struct cmd_ds_802_11_monitor_mode monitor; | 706 | struct cmd_ds_802_11_monitor_mode monitor; |
705 | struct cmd_ds_802_11_rate_adapt_rateset rateset; | ||
706 | struct cmd_ds_mac_multicast_adr madr; | ||
707 | struct cmd_ds_802_11_ad_hoc_join adj; | 707 | struct cmd_ds_802_11_ad_hoc_join adj; |
708 | struct cmd_ds_802_11_rssi rssi; | 708 | struct cmd_ds_802_11_rssi rssi; |
709 | struct cmd_ds_802_11_rssi_rsp rssirsp; | 709 | struct cmd_ds_802_11_rssi_rsp rssirsp; |
diff --git a/drivers/net/wireless/libertas/if_cs.c b/drivers/net/wireless/libertas/if_cs.c index 54280e292ea5..873ab10a0786 100644 --- a/drivers/net/wireless/libertas/if_cs.c +++ b/drivers/net/wireless/libertas/if_cs.c | |||
@@ -148,76 +148,72 @@ static int if_cs_poll_while_fw_download(struct if_cs_card *card, uint addr, u8 r | |||
148 | { | 148 | { |
149 | int i; | 149 | int i; |
150 | 150 | ||
151 | for (i = 0; i < 1000; i++) { | 151 | for (i = 0; i < 100000; i++) { |
152 | u8 val = if_cs_read8(card, addr); | 152 | u8 val = if_cs_read8(card, addr); |
153 | if (val == reg) | 153 | if (val == reg) |
154 | return i; | 154 | return i; |
155 | udelay(500); | 155 | udelay(5); |
156 | } | 156 | } |
157 | return -ETIME; | 157 | return -ETIME; |
158 | } | 158 | } |
159 | 159 | ||
160 | 160 | ||
161 | 161 | ||
162 | /* Host control registers and their bit definitions */ | 162 | /* First the bitmasks for the host/card interrupt/status registers: */ |
163 | #define IF_CS_BIT_TX 0x0001 | ||
164 | #define IF_CS_BIT_RX 0x0002 | ||
165 | #define IF_CS_BIT_COMMAND 0x0004 | ||
166 | #define IF_CS_BIT_RESP 0x0008 | ||
167 | #define IF_CS_BIT_EVENT 0x0010 | ||
168 | #define IF_CS_BIT_MASK 0x001f | ||
163 | 169 | ||
164 | #define IF_CS_H_STATUS 0x00000000 | 170 | /* And now the individual registers and assorted masks */ |
165 | #define IF_CS_H_STATUS_TX_OVER 0x0001 | 171 | #define IF_CS_HOST_STATUS 0x00000000 |
166 | #define IF_CS_H_STATUS_RX_OVER 0x0002 | ||
167 | #define IF_CS_H_STATUS_DNLD_OVER 0x0004 | ||
168 | 172 | ||
169 | #define IF_CS_H_INT_CAUSE 0x00000002 | 173 | #define IF_CS_HOST_INT_CAUSE 0x00000002 |
170 | #define IF_CS_H_IC_TX_OVER 0x0001 | ||
171 | #define IF_CS_H_IC_RX_OVER 0x0002 | ||
172 | #define IF_CS_H_IC_DNLD_OVER 0x0004 | ||
173 | #define IF_CS_H_IC_POWER_DOWN 0x0008 | ||
174 | #define IF_CS_H_IC_HOST_EVENT 0x0010 | ||
175 | #define IF_CS_H_IC_MASK 0x001f | ||
176 | 174 | ||
177 | #define IF_CS_H_INT_MASK 0x00000004 | 175 | #define IF_CS_HOST_INT_MASK 0x00000004 |
178 | #define IF_CS_H_IM_MASK 0x001f | ||
179 | 176 | ||
180 | #define IF_CS_H_WRITE_LEN 0x00000014 | 177 | #define IF_CS_HOST_WRITE 0x00000016 |
178 | #define IF_CS_HOST_WRITE_LEN 0x00000014 | ||
181 | 179 | ||
182 | #define IF_CS_H_WRITE 0x00000016 | 180 | #define IF_CS_HOST_CMD 0x0000001A |
181 | #define IF_CS_HOST_CMD_LEN 0x00000018 | ||
183 | 182 | ||
184 | #define IF_CS_H_CMD_LEN 0x00000018 | 183 | #define IF_CS_READ 0x00000010 |
184 | #define IF_CS_READ_LEN 0x00000024 | ||
185 | 185 | ||
186 | #define IF_CS_H_CMD 0x0000001A | 186 | #define IF_CS_CARD_CMD 0x00000012 |
187 | #define IF_CS_CARD_CMD_LEN 0x00000030 | ||
187 | 188 | ||
188 | #define IF_CS_C_READ_LEN 0x00000024 | 189 | #define IF_CS_CARD_STATUS 0x00000020 |
190 | #define IF_CS_CARD_STATUS_MASK 0x7f00 | ||
189 | 191 | ||
190 | #define IF_CS_H_READ 0x00000010 | 192 | #define IF_CS_CARD_INT_CAUSE 0x00000022 |
191 | 193 | ||
192 | /* Card control registers and their bit definitions */ | 194 | #define IF_CS_CARD_SQ_READ_LOW 0x00000028 |
193 | 195 | #define IF_CS_CARD_SQ_HELPER_OK 0x10 | |
194 | #define IF_CS_C_STATUS 0x00000020 | ||
195 | #define IF_CS_C_S_TX_DNLD_RDY 0x0001 | ||
196 | #define IF_CS_C_S_RX_UPLD_RDY 0x0002 | ||
197 | #define IF_CS_C_S_CMD_DNLD_RDY 0x0004 | ||
198 | #define IF_CS_C_S_CMD_UPLD_RDY 0x0008 | ||
199 | #define IF_CS_C_S_CARDEVENT 0x0010 | ||
200 | #define IF_CS_C_S_MASK 0x001f | ||
201 | #define IF_CS_C_S_STATUS_MASK 0x7f00 | ||
202 | |||
203 | #define IF_CS_C_INT_CAUSE 0x00000022 | ||
204 | #define IF_CS_C_IC_MASK 0x001f | ||
205 | |||
206 | #define IF_CS_C_SQ_READ_LOW 0x00000028 | ||
207 | #define IF_CS_C_SQ_HELPER_OK 0x10 | ||
208 | |||
209 | #define IF_CS_C_CMD_LEN 0x00000030 | ||
210 | |||
211 | #define IF_CS_C_CMD 0x00000012 | ||
212 | 196 | ||
213 | #define IF_CS_SCRATCH 0x0000003F | 197 | #define IF_CS_SCRATCH 0x0000003F |
214 | 198 | ||
215 | 199 | ||
216 | 200 | ||
217 | /********************************************************************/ | 201 | /********************************************************************/ |
218 | /* I/O */ | 202 | /* I/O and interrupt handling */ |
219 | /********************************************************************/ | 203 | /********************************************************************/ |
220 | 204 | ||
205 | static inline void if_cs_enable_ints(struct if_cs_card *card) | ||
206 | { | ||
207 | lbs_deb_enter(LBS_DEB_CS); | ||
208 | if_cs_write16(card, IF_CS_HOST_INT_MASK, 0); | ||
209 | } | ||
210 | |||
211 | static inline void if_cs_disable_ints(struct if_cs_card *card) | ||
212 | { | ||
213 | lbs_deb_enter(LBS_DEB_CS); | ||
214 | if_cs_write16(card, IF_CS_HOST_INT_MASK, IF_CS_BIT_MASK); | ||
215 | } | ||
216 | |||
221 | /* | 217 | /* |
222 | * Called from if_cs_host_to_card to send a command to the hardware | 218 | * Called from if_cs_host_to_card to send a command to the hardware |
223 | */ | 219 | */ |
@@ -228,11 +224,12 @@ static int if_cs_send_cmd(struct lbs_private *priv, u8 *buf, u16 nb) | |||
228 | int loops = 0; | 224 | int loops = 0; |
229 | 225 | ||
230 | lbs_deb_enter(LBS_DEB_CS); | 226 | lbs_deb_enter(LBS_DEB_CS); |
227 | if_cs_disable_ints(card); | ||
231 | 228 | ||
232 | /* Is hardware ready? */ | 229 | /* Is hardware ready? */ |
233 | while (1) { | 230 | while (1) { |
234 | u16 val = if_cs_read16(card, IF_CS_C_STATUS); | 231 | u16 val = if_cs_read16(card, IF_CS_CARD_STATUS); |
235 | if (val & IF_CS_C_S_CMD_DNLD_RDY) | 232 | if (val & IF_CS_BIT_COMMAND) |
236 | break; | 233 | break; |
237 | if (++loops > 100) { | 234 | if (++loops > 100) { |
238 | lbs_pr_err("card not ready for commands\n"); | 235 | lbs_pr_err("card not ready for commands\n"); |
@@ -241,51 +238,56 @@ static int if_cs_send_cmd(struct lbs_private *priv, u8 *buf, u16 nb) | |||
241 | mdelay(1); | 238 | mdelay(1); |
242 | } | 239 | } |
243 | 240 | ||
244 | if_cs_write16(card, IF_CS_H_CMD_LEN, nb); | 241 | if_cs_write16(card, IF_CS_HOST_CMD_LEN, nb); |
245 | 242 | ||
246 | if_cs_write16_rep(card, IF_CS_H_CMD, buf, nb / 2); | 243 | if_cs_write16_rep(card, IF_CS_HOST_CMD, buf, nb / 2); |
247 | /* Are we supposed to transfer an odd amount of bytes? */ | 244 | /* Are we supposed to transfer an odd amount of bytes? */ |
248 | if (nb & 1) | 245 | if (nb & 1) |
249 | if_cs_write8(card, IF_CS_H_CMD, buf[nb-1]); | 246 | if_cs_write8(card, IF_CS_HOST_CMD, buf[nb-1]); |
250 | 247 | ||
251 | /* "Assert the download over interrupt command in the Host | 248 | /* "Assert the download over interrupt command in the Host |
252 | * status register" */ | 249 | * status register" */ |
253 | if_cs_write16(card, IF_CS_H_STATUS, IF_CS_H_STATUS_DNLD_OVER); | 250 | if_cs_write16(card, IF_CS_HOST_STATUS, IF_CS_BIT_COMMAND); |
254 | 251 | ||
255 | /* "Assert the download over interrupt command in the Card | 252 | /* "Assert the download over interrupt command in the Card |
256 | * interrupt case register" */ | 253 | * interrupt case register" */ |
257 | if_cs_write16(card, IF_CS_H_INT_CAUSE, IF_CS_H_IC_DNLD_OVER); | 254 | if_cs_write16(card, IF_CS_HOST_INT_CAUSE, IF_CS_BIT_COMMAND); |
258 | ret = 0; | 255 | ret = 0; |
259 | 256 | ||
260 | done: | 257 | done: |
258 | if_cs_enable_ints(card); | ||
261 | lbs_deb_leave_args(LBS_DEB_CS, "ret %d", ret); | 259 | lbs_deb_leave_args(LBS_DEB_CS, "ret %d", ret); |
262 | return ret; | 260 | return ret; |
263 | } | 261 | } |
264 | 262 | ||
265 | |||
266 | /* | 263 | /* |
267 | * Called from if_cs_host_to_card to send a data to the hardware | 264 | * Called from if_cs_host_to_card to send a data to the hardware |
268 | */ | 265 | */ |
269 | static void if_cs_send_data(struct lbs_private *priv, u8 *buf, u16 nb) | 266 | static void if_cs_send_data(struct lbs_private *priv, u8 *buf, u16 nb) |
270 | { | 267 | { |
271 | struct if_cs_card *card = (struct if_cs_card *)priv->card; | 268 | struct if_cs_card *card = (struct if_cs_card *)priv->card; |
269 | u16 status; | ||
272 | 270 | ||
273 | lbs_deb_enter(LBS_DEB_CS); | 271 | lbs_deb_enter(LBS_DEB_CS); |
272 | if_cs_disable_ints(card); | ||
273 | |||
274 | status = if_cs_read16(card, IF_CS_CARD_STATUS); | ||
275 | BUG_ON((status & IF_CS_BIT_TX) == 0); | ||
274 | 276 | ||
275 | if_cs_write16(card, IF_CS_H_WRITE_LEN, nb); | 277 | if_cs_write16(card, IF_CS_HOST_WRITE_LEN, nb); |
276 | 278 | ||
277 | /* write even number of bytes, then odd byte if necessary */ | 279 | /* write even number of bytes, then odd byte if necessary */ |
278 | if_cs_write16_rep(card, IF_CS_H_WRITE, buf, nb / 2); | 280 | if_cs_write16_rep(card, IF_CS_HOST_WRITE, buf, nb / 2); |
279 | if (nb & 1) | 281 | if (nb & 1) |
280 | if_cs_write8(card, IF_CS_H_WRITE, buf[nb-1]); | 282 | if_cs_write8(card, IF_CS_HOST_WRITE, buf[nb-1]); |
281 | 283 | ||
282 | if_cs_write16(card, IF_CS_H_STATUS, IF_CS_H_STATUS_TX_OVER); | 284 | if_cs_write16(card, IF_CS_HOST_STATUS, IF_CS_BIT_TX); |
283 | if_cs_write16(card, IF_CS_H_INT_CAUSE, IF_CS_H_STATUS_TX_OVER); | 285 | if_cs_write16(card, IF_CS_HOST_INT_CAUSE, IF_CS_BIT_TX); |
286 | if_cs_enable_ints(card); | ||
284 | 287 | ||
285 | lbs_deb_leave(LBS_DEB_CS); | 288 | lbs_deb_leave(LBS_DEB_CS); |
286 | } | 289 | } |
287 | 290 | ||
288 | |||
289 | /* | 291 | /* |
290 | * Get the command result out of the card. | 292 | * Get the command result out of the card. |
291 | */ | 293 | */ |
@@ -293,27 +295,28 @@ static int if_cs_receive_cmdres(struct lbs_private *priv, u8 *data, u32 *len) | |||
293 | { | 295 | { |
294 | unsigned long flags; | 296 | unsigned long flags; |
295 | int ret = -1; | 297 | int ret = -1; |
296 | u16 val; | 298 | u16 status; |
297 | 299 | ||
298 | lbs_deb_enter(LBS_DEB_CS); | 300 | lbs_deb_enter(LBS_DEB_CS); |
299 | 301 | ||
300 | /* is hardware ready? */ | 302 | /* is hardware ready? */ |
301 | val = if_cs_read16(priv->card, IF_CS_C_STATUS); | 303 | status = if_cs_read16(priv->card, IF_CS_CARD_STATUS); |
302 | if ((val & IF_CS_C_S_CMD_UPLD_RDY) == 0) { | 304 | if ((status & IF_CS_BIT_RESP) == 0) { |
303 | lbs_pr_err("card not ready for CMD\n"); | 305 | lbs_pr_err("no cmd response in card\n"); |
306 | *len = 0; | ||
304 | goto out; | 307 | goto out; |
305 | } | 308 | } |
306 | 309 | ||
307 | *len = if_cs_read16(priv->card, IF_CS_C_CMD_LEN); | 310 | *len = if_cs_read16(priv->card, IF_CS_CARD_CMD_LEN); |
308 | if ((*len == 0) || (*len > LBS_CMD_BUFFER_SIZE)) { | 311 | if ((*len == 0) || (*len > LBS_CMD_BUFFER_SIZE)) { |
309 | lbs_pr_err("card cmd buffer has invalid # of bytes (%d)\n", *len); | 312 | lbs_pr_err("card cmd buffer has invalid # of bytes (%d)\n", *len); |
310 | goto out; | 313 | goto out; |
311 | } | 314 | } |
312 | 315 | ||
313 | /* read even number of bytes, then odd byte if necessary */ | 316 | /* read even number of bytes, then odd byte if necessary */ |
314 | if_cs_read16_rep(priv->card, IF_CS_C_CMD, data, *len/sizeof(u16)); | 317 | if_cs_read16_rep(priv->card, IF_CS_CARD_CMD, data, *len/sizeof(u16)); |
315 | if (*len & 1) | 318 | if (*len & 1) |
316 | data[*len-1] = if_cs_read8(priv->card, IF_CS_C_CMD); | 319 | data[*len-1] = if_cs_read8(priv->card, IF_CS_CARD_CMD); |
317 | 320 | ||
318 | /* This is a workaround for a firmware that reports too much | 321 | /* This is a workaround for a firmware that reports too much |
319 | * bytes */ | 322 | * bytes */ |
@@ -330,7 +333,6 @@ out: | |||
330 | return ret; | 333 | return ret; |
331 | } | 334 | } |
332 | 335 | ||
333 | |||
334 | static struct sk_buff *if_cs_receive_data(struct lbs_private *priv) | 336 | static struct sk_buff *if_cs_receive_data(struct lbs_private *priv) |
335 | { | 337 | { |
336 | struct sk_buff *skb = NULL; | 338 | struct sk_buff *skb = NULL; |
@@ -339,7 +341,7 @@ static struct sk_buff *if_cs_receive_data(struct lbs_private *priv) | |||
339 | 341 | ||
340 | lbs_deb_enter(LBS_DEB_CS); | 342 | lbs_deb_enter(LBS_DEB_CS); |
341 | 343 | ||
342 | len = if_cs_read16(priv->card, IF_CS_C_READ_LEN); | 344 | len = if_cs_read16(priv->card, IF_CS_READ_LEN); |
343 | if (len == 0 || len > MRVDRV_ETH_RX_PACKET_BUFFER_SIZE) { | 345 | if (len == 0 || len > MRVDRV_ETH_RX_PACKET_BUFFER_SIZE) { |
344 | lbs_pr_err("card data buffer has invalid # of bytes (%d)\n", len); | 346 | lbs_pr_err("card data buffer has invalid # of bytes (%d)\n", len); |
345 | priv->stats.rx_dropped++; | 347 | priv->stats.rx_dropped++; |
@@ -354,38 +356,19 @@ static struct sk_buff *if_cs_receive_data(struct lbs_private *priv) | |||
354 | data = skb->data; | 356 | data = skb->data; |
355 | 357 | ||
356 | /* read even number of bytes, then odd byte if necessary */ | 358 | /* read even number of bytes, then odd byte if necessary */ |
357 | if_cs_read16_rep(priv->card, IF_CS_H_READ, data, len/sizeof(u16)); | 359 | if_cs_read16_rep(priv->card, IF_CS_READ, data, len/sizeof(u16)); |
358 | if (len & 1) | 360 | if (len & 1) |
359 | data[len-1] = if_cs_read8(priv->card, IF_CS_H_READ); | 361 | data[len-1] = if_cs_read8(priv->card, IF_CS_READ); |
360 | 362 | ||
361 | dat_err: | 363 | dat_err: |
362 | if_cs_write16(priv->card, IF_CS_H_STATUS, IF_CS_H_STATUS_RX_OVER); | 364 | if_cs_write16(priv->card, IF_CS_HOST_STATUS, IF_CS_BIT_RX); |
363 | if_cs_write16(priv->card, IF_CS_H_INT_CAUSE, IF_CS_H_IC_RX_OVER); | 365 | if_cs_write16(priv->card, IF_CS_HOST_INT_CAUSE, IF_CS_BIT_RX); |
364 | 366 | ||
365 | out: | 367 | out: |
366 | lbs_deb_leave_args(LBS_DEB_CS, "ret %p", skb); | 368 | lbs_deb_leave_args(LBS_DEB_CS, "ret %p", skb); |
367 | return skb; | 369 | return skb; |
368 | } | 370 | } |
369 | 371 | ||
370 | |||
371 | |||
372 | /********************************************************************/ | ||
373 | /* Interrupts */ | ||
374 | /********************************************************************/ | ||
375 | |||
376 | static inline void if_cs_enable_ints(struct if_cs_card *card) | ||
377 | { | ||
378 | lbs_deb_enter(LBS_DEB_CS); | ||
379 | if_cs_write16(card, IF_CS_H_INT_MASK, 0); | ||
380 | } | ||
381 | |||
382 | static inline void if_cs_disable_ints(struct if_cs_card *card) | ||
383 | { | ||
384 | lbs_deb_enter(LBS_DEB_CS); | ||
385 | if_cs_write16(card, IF_CS_H_INT_MASK, IF_CS_H_IM_MASK); | ||
386 | } | ||
387 | |||
388 | |||
389 | static irqreturn_t if_cs_interrupt(int irq, void *data) | 372 | static irqreturn_t if_cs_interrupt(int irq, void *data) |
390 | { | 373 | { |
391 | struct if_cs_card *card = data; | 374 | struct if_cs_card *card = data; |
@@ -394,10 +377,8 @@ static irqreturn_t if_cs_interrupt(int irq, void *data) | |||
394 | 377 | ||
395 | lbs_deb_enter(LBS_DEB_CS); | 378 | lbs_deb_enter(LBS_DEB_CS); |
396 | 379 | ||
397 | cause = if_cs_read16(card, IF_CS_C_INT_CAUSE); | 380 | /* Ask card interrupt cause register if there is something for us */ |
398 | if_cs_write16(card, IF_CS_C_INT_CAUSE, cause & IF_CS_C_IC_MASK); | 381 | cause = if_cs_read16(card, IF_CS_CARD_INT_CAUSE); |
399 | |||
400 | lbs_deb_cs("cause 0x%04x\n", cause); | ||
401 | if (cause == 0) { | 382 | if (cause == 0) { |
402 | /* Not for us */ | 383 | /* Not for us */ |
403 | return IRQ_NONE; | 384 | return IRQ_NONE; |
@@ -409,11 +390,11 @@ static irqreturn_t if_cs_interrupt(int irq, void *data) | |||
409 | return IRQ_HANDLED; | 390 | return IRQ_HANDLED; |
410 | } | 391 | } |
411 | 392 | ||
412 | /* TODO: I'm not sure what the best ordering is */ | 393 | /* Clear interrupt cause */ |
413 | 394 | if_cs_write16(card, IF_CS_CARD_INT_CAUSE, cause & IF_CS_BIT_MASK); | |
414 | cause = if_cs_read16(card, IF_CS_C_STATUS) & IF_CS_C_S_MASK; | 395 | lbs_deb_cs("cause 0x%04x\n", cause); |
415 | 396 | ||
416 | if (cause & IF_CS_C_S_RX_UPLD_RDY) { | 397 | if (cause & IF_CS_BIT_RX) { |
417 | struct sk_buff *skb; | 398 | struct sk_buff *skb; |
418 | lbs_deb_cs("rx packet\n"); | 399 | lbs_deb_cs("rx packet\n"); |
419 | skb = if_cs_receive_data(priv); | 400 | skb = if_cs_receive_data(priv); |
@@ -421,16 +402,16 @@ static irqreturn_t if_cs_interrupt(int irq, void *data) | |||
421 | lbs_process_rxed_packet(priv, skb); | 402 | lbs_process_rxed_packet(priv, skb); |
422 | } | 403 | } |
423 | 404 | ||
424 | if (cause & IF_CS_H_IC_TX_OVER) { | 405 | if (cause & IF_CS_BIT_TX) { |
425 | lbs_deb_cs("tx over\n"); | 406 | lbs_deb_cs("tx done\n"); |
426 | lbs_host_to_card_done(priv); | 407 | lbs_host_to_card_done(priv); |
427 | } | 408 | } |
428 | 409 | ||
429 | if (cause & IF_CS_C_S_CMD_UPLD_RDY) { | 410 | if (cause & IF_CS_BIT_RESP) { |
430 | unsigned long flags; | 411 | unsigned long flags; |
431 | u8 i; | 412 | u8 i; |
432 | 413 | ||
433 | lbs_deb_cs("cmd upload ready\n"); | 414 | lbs_deb_cs("cmd resp\n"); |
434 | spin_lock_irqsave(&priv->driver_lock, flags); | 415 | spin_lock_irqsave(&priv->driver_lock, flags); |
435 | i = (priv->resp_idx == 0) ? 1 : 0; | 416 | i = (priv->resp_idx == 0) ? 1 : 0; |
436 | spin_unlock_irqrestore(&priv->driver_lock, flags); | 417 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
@@ -444,15 +425,16 @@ static irqreturn_t if_cs_interrupt(int irq, void *data) | |||
444 | spin_unlock_irqrestore(&priv->driver_lock, flags); | 425 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
445 | } | 426 | } |
446 | 427 | ||
447 | if (cause & IF_CS_H_IC_HOST_EVENT) { | 428 | if (cause & IF_CS_BIT_EVENT) { |
448 | u16 event = if_cs_read16(priv->card, IF_CS_C_STATUS) | 429 | u16 event = if_cs_read16(priv->card, IF_CS_CARD_STATUS) |
449 | & IF_CS_C_S_STATUS_MASK; | 430 | & IF_CS_CARD_STATUS_MASK; |
450 | if_cs_write16(priv->card, IF_CS_H_INT_CAUSE, | 431 | if_cs_write16(priv->card, IF_CS_HOST_INT_CAUSE, |
451 | IF_CS_H_IC_HOST_EVENT); | 432 | IF_CS_BIT_EVENT); |
452 | lbs_deb_cs("eventcause 0x%04x\n", event); | 433 | lbs_deb_cs("host event 0x%04x\n", event); |
453 | lbs_queue_event(priv, event >> 8 & 0xff); | 434 | lbs_queue_event(priv, event >> 8 & 0xff); |
454 | } | 435 | } |
455 | 436 | ||
437 | lbs_deb_leave(LBS_DEB_CS); | ||
456 | return IRQ_HANDLED; | 438 | return IRQ_HANDLED; |
457 | } | 439 | } |
458 | 440 | ||
@@ -514,26 +496,26 @@ static int if_cs_prog_helper(struct if_cs_card *card) | |||
514 | 496 | ||
515 | /* "write the number of bytes to be sent to the I/O Command | 497 | /* "write the number of bytes to be sent to the I/O Command |
516 | * write length register" */ | 498 | * write length register" */ |
517 | if_cs_write16(card, IF_CS_H_CMD_LEN, count); | 499 | if_cs_write16(card, IF_CS_HOST_CMD_LEN, count); |
518 | 500 | ||
519 | /* "write this to I/O Command port register as 16 bit writes */ | 501 | /* "write this to I/O Command port register as 16 bit writes */ |
520 | if (count) | 502 | if (count) |
521 | if_cs_write16_rep(card, IF_CS_H_CMD, | 503 | if_cs_write16_rep(card, IF_CS_HOST_CMD, |
522 | &fw->data[sent], | 504 | &fw->data[sent], |
523 | count >> 1); | 505 | count >> 1); |
524 | 506 | ||
525 | /* "Assert the download over interrupt command in the Host | 507 | /* "Assert the download over interrupt command in the Host |
526 | * status register" */ | 508 | * status register" */ |
527 | if_cs_write8(card, IF_CS_H_STATUS, IF_CS_H_STATUS_DNLD_OVER); | 509 | if_cs_write8(card, IF_CS_HOST_STATUS, IF_CS_BIT_COMMAND); |
528 | 510 | ||
529 | /* "Assert the download over interrupt command in the Card | 511 | /* "Assert the download over interrupt command in the Card |
530 | * interrupt case register" */ | 512 | * interrupt case register" */ |
531 | if_cs_write16(card, IF_CS_H_INT_CAUSE, IF_CS_H_IC_DNLD_OVER); | 513 | if_cs_write16(card, IF_CS_HOST_INT_CAUSE, IF_CS_BIT_COMMAND); |
532 | 514 | ||
533 | /* "The host polls the Card Status register ... for 50 ms before | 515 | /* "The host polls the Card Status register ... for 50 ms before |
534 | declaring a failure */ | 516 | declaring a failure */ |
535 | ret = if_cs_poll_while_fw_download(card, IF_CS_C_STATUS, | 517 | ret = if_cs_poll_while_fw_download(card, IF_CS_CARD_STATUS, |
536 | IF_CS_C_S_CMD_DNLD_RDY); | 518 | IF_CS_BIT_COMMAND); |
537 | if (ret < 0) { | 519 | if (ret < 0) { |
538 | lbs_pr_err("can't download helper at 0x%x, ret %d\n", | 520 | lbs_pr_err("can't download helper at 0x%x, ret %d\n", |
539 | sent, ret); | 521 | sent, ret); |
@@ -575,14 +557,15 @@ static int if_cs_prog_real(struct if_cs_card *card) | |||
575 | } | 557 | } |
576 | lbs_deb_cs("fw size %td\n", fw->size); | 558 | lbs_deb_cs("fw size %td\n", fw->size); |
577 | 559 | ||
578 | ret = if_cs_poll_while_fw_download(card, IF_CS_C_SQ_READ_LOW, IF_CS_C_SQ_HELPER_OK); | 560 | ret = if_cs_poll_while_fw_download(card, IF_CS_CARD_SQ_READ_LOW, |
561 | IF_CS_CARD_SQ_HELPER_OK); | ||
579 | if (ret < 0) { | 562 | if (ret < 0) { |
580 | lbs_pr_err("helper firmware doesn't answer\n"); | 563 | lbs_pr_err("helper firmware doesn't answer\n"); |
581 | goto err_release; | 564 | goto err_release; |
582 | } | 565 | } |
583 | 566 | ||
584 | for (sent = 0; sent < fw->size; sent += len) { | 567 | for (sent = 0; sent < fw->size; sent += len) { |
585 | len = if_cs_read16(card, IF_CS_C_SQ_READ_LOW); | 568 | len = if_cs_read16(card, IF_CS_CARD_SQ_READ_LOW); |
586 | if (len & 1) { | 569 | if (len & 1) { |
587 | retry++; | 570 | retry++; |
588 | lbs_pr_info("odd, need to retry this firmware block\n"); | 571 | lbs_pr_info("odd, need to retry this firmware block\n"); |
@@ -600,16 +583,16 @@ static int if_cs_prog_real(struct if_cs_card *card) | |||
600 | } | 583 | } |
601 | 584 | ||
602 | 585 | ||
603 | if_cs_write16(card, IF_CS_H_CMD_LEN, len); | 586 | if_cs_write16(card, IF_CS_HOST_CMD_LEN, len); |
604 | 587 | ||
605 | if_cs_write16_rep(card, IF_CS_H_CMD, | 588 | if_cs_write16_rep(card, IF_CS_HOST_CMD, |
606 | &fw->data[sent], | 589 | &fw->data[sent], |
607 | (len+1) >> 1); | 590 | (len+1) >> 1); |
608 | if_cs_write8(card, IF_CS_H_STATUS, IF_CS_H_STATUS_DNLD_OVER); | 591 | if_cs_write8(card, IF_CS_HOST_STATUS, IF_CS_BIT_COMMAND); |
609 | if_cs_write16(card, IF_CS_H_INT_CAUSE, IF_CS_H_IC_DNLD_OVER); | 592 | if_cs_write16(card, IF_CS_HOST_INT_CAUSE, IF_CS_BIT_COMMAND); |
610 | 593 | ||
611 | ret = if_cs_poll_while_fw_download(card, IF_CS_C_STATUS, | 594 | ret = if_cs_poll_while_fw_download(card, IF_CS_CARD_STATUS, |
612 | IF_CS_C_S_CMD_DNLD_RDY); | 595 | IF_CS_BIT_COMMAND); |
613 | if (ret < 0) { | 596 | if (ret < 0) { |
614 | lbs_pr_err("can't download firmware at 0x%x\n", sent); | 597 | lbs_pr_err("can't download firmware at 0x%x\n", sent); |
615 | goto err_release; | 598 | goto err_release; |
@@ -837,7 +820,7 @@ static int if_cs_probe(struct pcmcia_device *p_dev) | |||
837 | 820 | ||
838 | /* Clear any interrupt cause that happend while sending | 821 | /* Clear any interrupt cause that happend while sending |
839 | * firmware/initializing card */ | 822 | * firmware/initializing card */ |
840 | if_cs_write16(card, IF_CS_C_INT_CAUSE, IF_CS_C_IC_MASK); | 823 | if_cs_write16(card, IF_CS_CARD_INT_CAUSE, IF_CS_BIT_MASK); |
841 | if_cs_enable_ints(card); | 824 | if_cs_enable_ints(card); |
842 | 825 | ||
843 | /* And finally bring the card up */ | 826 | /* And finally bring the card up */ |
diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c index 8032df72aaab..24783103a7dd 100644 --- a/drivers/net/wireless/libertas/if_usb.c +++ b/drivers/net/wireless/libertas/if_usb.c | |||
@@ -7,6 +7,10 @@ | |||
7 | #include <linux/netdevice.h> | 7 | #include <linux/netdevice.h> |
8 | #include <linux/usb.h> | 8 | #include <linux/usb.h> |
9 | 9 | ||
10 | #ifdef CONFIG_OLPC | ||
11 | #include <asm/olpc.h> | ||
12 | #endif | ||
13 | |||
10 | #define DRV_NAME "usb8xxx" | 14 | #define DRV_NAME "usb8xxx" |
11 | 15 | ||
12 | #include "host.h" | 16 | #include "host.h" |
@@ -146,6 +150,14 @@ static void if_usb_fw_timeo(unsigned long priv) | |||
146 | wake_up(&cardp->fw_wq); | 150 | wake_up(&cardp->fw_wq); |
147 | } | 151 | } |
148 | 152 | ||
153 | #ifdef CONFIG_OLPC | ||
154 | static void if_usb_reset_olpc_card(struct lbs_private *priv) | ||
155 | { | ||
156 | printk(KERN_CRIT "Resetting OLPC wireless via EC...\n"); | ||
157 | olpc_ec_cmd(0x25, NULL, 0, NULL, 0); | ||
158 | } | ||
159 | #endif | ||
160 | |||
149 | /** | 161 | /** |
150 | * @brief sets the configuration values | 162 | * @brief sets the configuration values |
151 | * @param ifnum interface number | 163 | * @param ifnum interface number |
@@ -231,6 +243,11 @@ static int if_usb_probe(struct usb_interface *intf, | |||
231 | cardp->priv->fw_ready = 1; | 243 | cardp->priv->fw_ready = 1; |
232 | 244 | ||
233 | priv->hw_host_to_card = if_usb_host_to_card; | 245 | priv->hw_host_to_card = if_usb_host_to_card; |
246 | #ifdef CONFIG_OLPC | ||
247 | if (machine_is_olpc()) | ||
248 | priv->reset_card = if_usb_reset_olpc_card; | ||
249 | #endif | ||
250 | |||
234 | cardp->boot2_version = udev->descriptor.bcdDevice; | 251 | cardp->boot2_version = udev->descriptor.bcdDevice; |
235 | 252 | ||
236 | if_usb_submit_rx_urb(cardp); | 253 | if_usb_submit_rx_urb(cardp); |
@@ -364,6 +381,11 @@ static int if_usb_reset_device(struct if_usb_card *cardp) | |||
364 | ret = usb_reset_device(cardp->udev); | 381 | ret = usb_reset_device(cardp->udev); |
365 | msleep(100); | 382 | msleep(100); |
366 | 383 | ||
384 | #ifdef CONFIG_OLPC | ||
385 | if (ret && machine_is_olpc()) | ||
386 | if_usb_reset_olpc_card(NULL); | ||
387 | #endif | ||
388 | |||
367 | lbs_deb_leave_args(LBS_DEB_USB, "ret %d", ret); | 389 | lbs_deb_leave_args(LBS_DEB_USB, "ret %d", ret); |
368 | 390 | ||
369 | return ret; | 391 | return ret; |
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c index 02e4fb639428..b7ab3590b586 100644 --- a/drivers/net/wireless/libertas/main.c +++ b/drivers/net/wireless/libertas/main.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/if_arp.h> | 11 | #include <linux/if_arp.h> |
12 | #include <linux/kthread.h> | 12 | #include <linux/kthread.h> |
13 | #include <linux/kfifo.h> | 13 | #include <linux/kfifo.h> |
14 | #include <linux/stddef.h> | ||
14 | 15 | ||
15 | #include <net/iw_handler.h> | 16 | #include <net/iw_handler.h> |
16 | #include <net/ieee80211.h> | 17 | #include <net/ieee80211.h> |
@@ -343,14 +344,15 @@ static ssize_t lbs_mesh_set(struct device *dev, | |||
343 | { | 344 | { |
344 | struct lbs_private *priv = to_net_dev(dev)->priv; | 345 | struct lbs_private *priv = to_net_dev(dev)->priv; |
345 | int enable; | 346 | int enable; |
346 | int ret; | 347 | int ret, action = CMD_ACT_MESH_CONFIG_STOP; |
347 | 348 | ||
348 | sscanf(buf, "%x", &enable); | 349 | sscanf(buf, "%x", &enable); |
349 | enable = !!enable; | 350 | enable = !!enable; |
350 | if (enable == !!priv->mesh_dev) | 351 | if (enable == !!priv->mesh_dev) |
351 | return count; | 352 | return count; |
352 | 353 | if (enable) | |
353 | ret = lbs_mesh_config(priv, enable, priv->curbssparams.channel); | 354 | action = CMD_ACT_MESH_CONFIG_START; |
355 | ret = lbs_mesh_config(priv, action, priv->curbssparams.channel); | ||
354 | if (ret) | 356 | if (ret) |
355 | return ret; | 357 | return ret; |
356 | 358 | ||
@@ -446,6 +448,8 @@ static int lbs_mesh_stop(struct net_device *dev) | |||
446 | 448 | ||
447 | spin_unlock_irq(&priv->driver_lock); | 449 | spin_unlock_irq(&priv->driver_lock); |
448 | 450 | ||
451 | schedule_work(&priv->mcast_work); | ||
452 | |||
449 | lbs_deb_leave(LBS_DEB_MESH); | 453 | lbs_deb_leave(LBS_DEB_MESH); |
450 | return 0; | 454 | return 0; |
451 | } | 455 | } |
@@ -467,6 +471,8 @@ static int lbs_eth_stop(struct net_device *dev) | |||
467 | netif_stop_queue(dev); | 471 | netif_stop_queue(dev); |
468 | spin_unlock_irq(&priv->driver_lock); | 472 | spin_unlock_irq(&priv->driver_lock); |
469 | 473 | ||
474 | schedule_work(&priv->mcast_work); | ||
475 | |||
470 | lbs_deb_leave(LBS_DEB_NET); | 476 | lbs_deb_leave(LBS_DEB_NET); |
471 | return 0; | 477 | return 0; |
472 | } | 478 | } |
@@ -563,89 +569,116 @@ done: | |||
563 | return ret; | 569 | return ret; |
564 | } | 570 | } |
565 | 571 | ||
566 | static int lbs_copy_multicast_address(struct lbs_private *priv, | 572 | |
567 | struct net_device *dev) | 573 | static inline int mac_in_list(unsigned char *list, int list_len, |
574 | unsigned char *mac) | ||
568 | { | 575 | { |
569 | int i = 0; | 576 | while (list_len) { |
570 | struct dev_mc_list *mcptr = dev->mc_list; | 577 | if (!memcmp(list, mac, ETH_ALEN)) |
578 | return 1; | ||
579 | list += ETH_ALEN; | ||
580 | list_len--; | ||
581 | } | ||
582 | return 0; | ||
583 | } | ||
584 | |||
585 | |||
586 | static int lbs_add_mcast_addrs(struct cmd_ds_mac_multicast_adr *cmd, | ||
587 | struct net_device *dev, int nr_addrs) | ||
588 | { | ||
589 | int i = nr_addrs; | ||
590 | struct dev_mc_list *mc_list; | ||
591 | DECLARE_MAC_BUF(mac); | ||
592 | |||
593 | if ((dev->flags & (IFF_UP|IFF_MULTICAST)) != (IFF_UP|IFF_MULTICAST)) | ||
594 | return nr_addrs; | ||
595 | |||
596 | netif_tx_lock_bh(dev); | ||
597 | for (mc_list = dev->mc_list; mc_list; mc_list = mc_list->next) { | ||
598 | if (mac_in_list(cmd->maclist, nr_addrs, mc_list->dmi_addr)) { | ||
599 | lbs_deb_net("mcast address %s:%s skipped\n", dev->name, | ||
600 | print_mac(mac, mc_list->dmi_addr)); | ||
601 | continue; | ||
602 | } | ||
571 | 603 | ||
572 | for (i = 0; i < dev->mc_count; i++) { | 604 | if (i == MRVDRV_MAX_MULTICAST_LIST_SIZE) |
573 | memcpy(&priv->multicastlist[i], mcptr->dmi_addr, ETH_ALEN); | 605 | break; |
574 | mcptr = mcptr->next; | 606 | memcpy(&cmd->maclist[6*i], mc_list->dmi_addr, ETH_ALEN); |
607 | lbs_deb_net("mcast address %s:%s added to filter\n", dev->name, | ||
608 | print_mac(mac, mc_list->dmi_addr)); | ||
609 | i++; | ||
575 | } | 610 | } |
611 | netif_tx_unlock_bh(dev); | ||
612 | if (mc_list) | ||
613 | return -EOVERFLOW; | ||
614 | |||
576 | return i; | 615 | return i; |
577 | } | 616 | } |
578 | 617 | ||
579 | static void lbs_set_multicast_list(struct net_device *dev) | 618 | static void lbs_set_mcast_worker(struct work_struct *work) |
580 | { | 619 | { |
581 | struct lbs_private *priv = dev->priv; | 620 | struct lbs_private *priv = container_of(work, struct lbs_private, mcast_work); |
582 | int old_mac_control; | 621 | struct cmd_ds_mac_multicast_adr mcast_cmd; |
583 | DECLARE_MAC_BUF(mac); | 622 | int dev_flags; |
623 | int nr_addrs; | ||
624 | int old_mac_control = priv->mac_control; | ||
584 | 625 | ||
585 | lbs_deb_enter(LBS_DEB_NET); | 626 | lbs_deb_enter(LBS_DEB_NET); |
586 | 627 | ||
587 | old_mac_control = priv->mac_control; | 628 | dev_flags = priv->dev->flags; |
588 | 629 | if (priv->mesh_dev) | |
589 | if (dev->flags & IFF_PROMISC) { | 630 | dev_flags |= priv->mesh_dev->flags; |
590 | lbs_deb_net("enable promiscuous mode\n"); | 631 | |
591 | priv->mac_control |= | 632 | if (dev_flags & IFF_PROMISC) { |
592 | CMD_ACT_MAC_PROMISCUOUS_ENABLE; | 633 | priv->mac_control |= CMD_ACT_MAC_PROMISCUOUS_ENABLE; |
593 | priv->mac_control &= | 634 | priv->mac_control &= ~(CMD_ACT_MAC_ALL_MULTICAST_ENABLE | |
594 | ~(CMD_ACT_MAC_ALL_MULTICAST_ENABLE | | 635 | CMD_ACT_MAC_MULTICAST_ENABLE); |
595 | CMD_ACT_MAC_MULTICAST_ENABLE); | 636 | goto out_set_mac_control; |
596 | } else { | 637 | } else if (dev_flags & IFF_ALLMULTI) { |
597 | /* Multicast */ | 638 | do_allmulti: |
598 | priv->mac_control &= | 639 | priv->mac_control |= CMD_ACT_MAC_ALL_MULTICAST_ENABLE; |
599 | ~CMD_ACT_MAC_PROMISCUOUS_ENABLE; | 640 | priv->mac_control &= ~(CMD_ACT_MAC_PROMISCUOUS_ENABLE | |
600 | 641 | CMD_ACT_MAC_MULTICAST_ENABLE); | |
601 | if (dev->flags & IFF_ALLMULTI || dev->mc_count > | 642 | goto out_set_mac_control; |
602 | MRVDRV_MAX_MULTICAST_LIST_SIZE) { | ||
603 | lbs_deb_net( "enabling all multicast\n"); | ||
604 | priv->mac_control |= | ||
605 | CMD_ACT_MAC_ALL_MULTICAST_ENABLE; | ||
606 | priv->mac_control &= | ||
607 | ~CMD_ACT_MAC_MULTICAST_ENABLE; | ||
608 | } else { | ||
609 | priv->mac_control &= | ||
610 | ~CMD_ACT_MAC_ALL_MULTICAST_ENABLE; | ||
611 | |||
612 | if (!dev->mc_count) { | ||
613 | lbs_deb_net("no multicast addresses, " | ||
614 | "disabling multicast\n"); | ||
615 | priv->mac_control &= | ||
616 | ~CMD_ACT_MAC_MULTICAST_ENABLE; | ||
617 | } else { | ||
618 | int i; | ||
619 | |||
620 | priv->mac_control |= | ||
621 | CMD_ACT_MAC_MULTICAST_ENABLE; | ||
622 | |||
623 | priv->nr_of_multicastmacaddr = | ||
624 | lbs_copy_multicast_address(priv, dev); | ||
625 | |||
626 | lbs_deb_net("multicast addresses: %d\n", | ||
627 | dev->mc_count); | ||
628 | |||
629 | for (i = 0; i < dev->mc_count; i++) { | ||
630 | lbs_deb_net("Multicast address %d: %s\n", | ||
631 | i, print_mac(mac, | ||
632 | priv->multicastlist[i])); | ||
633 | } | ||
634 | /* send multicast addresses to firmware */ | ||
635 | lbs_prepare_and_send_command(priv, | ||
636 | CMD_MAC_MULTICAST_ADR, | ||
637 | CMD_ACT_SET, 0, 0, | ||
638 | NULL); | ||
639 | } | ||
640 | } | ||
641 | } | 643 | } |
642 | 644 | ||
645 | /* Once for priv->dev, again for priv->mesh_dev if it exists */ | ||
646 | nr_addrs = lbs_add_mcast_addrs(&mcast_cmd, priv->dev, 0); | ||
647 | if (nr_addrs >= 0 && priv->mesh_dev) | ||
648 | nr_addrs = lbs_add_mcast_addrs(&mcast_cmd, priv->mesh_dev, nr_addrs); | ||
649 | if (nr_addrs < 0) | ||
650 | goto do_allmulti; | ||
651 | |||
652 | if (nr_addrs) { | ||
653 | int size = offsetof(struct cmd_ds_mac_multicast_adr, | ||
654 | maclist[6*nr_addrs]); | ||
655 | |||
656 | mcast_cmd.action = cpu_to_le16(CMD_ACT_SET); | ||
657 | mcast_cmd.hdr.size = cpu_to_le16(size); | ||
658 | mcast_cmd.nr_of_adrs = cpu_to_le16(nr_addrs); | ||
659 | |||
660 | lbs_cmd_async(priv, CMD_MAC_MULTICAST_ADR, &mcast_cmd.hdr, size); | ||
661 | |||
662 | priv->mac_control |= CMD_ACT_MAC_MULTICAST_ENABLE; | ||
663 | } else | ||
664 | priv->mac_control &= ~CMD_ACT_MAC_MULTICAST_ENABLE; | ||
665 | |||
666 | priv->mac_control &= ~(CMD_ACT_MAC_PROMISCUOUS_ENABLE | | ||
667 | CMD_ACT_MAC_ALL_MULTICAST_ENABLE); | ||
668 | out_set_mac_control: | ||
643 | if (priv->mac_control != old_mac_control) | 669 | if (priv->mac_control != old_mac_control) |
644 | lbs_set_mac_control(priv); | 670 | lbs_set_mac_control(priv); |
645 | 671 | ||
646 | lbs_deb_leave(LBS_DEB_NET); | 672 | lbs_deb_leave(LBS_DEB_NET); |
647 | } | 673 | } |
648 | 674 | ||
675 | static void lbs_set_multicast_list(struct net_device *dev) | ||
676 | { | ||
677 | struct lbs_private *priv = dev->priv; | ||
678 | |||
679 | schedule_work(&priv->mcast_work); | ||
680 | } | ||
681 | |||
649 | /** | 682 | /** |
650 | * @brief This function handles the major jobs in the LBS driver. | 683 | * @brief This function handles the major jobs in the LBS driver. |
651 | * It handles all events generated by firmware, RX data received | 684 | * It handles all events generated by firmware, RX data received |
@@ -689,14 +722,14 @@ static int lbs_thread(void *data) | |||
689 | shouldsleep = 1; /* Something is en route to the device already */ | 722 | shouldsleep = 1; /* Something is en route to the device already */ |
690 | else if (priv->tx_pending_len > 0) | 723 | else if (priv->tx_pending_len > 0) |
691 | shouldsleep = 0; /* We've a packet to send */ | 724 | shouldsleep = 0; /* We've a packet to send */ |
725 | else if (priv->resp_len[priv->resp_idx]) | ||
726 | shouldsleep = 0; /* We have a command response */ | ||
692 | else if (priv->cur_cmd) | 727 | else if (priv->cur_cmd) |
693 | shouldsleep = 1; /* Can't send a command; one already running */ | 728 | shouldsleep = 1; /* Can't send a command; one already running */ |
694 | else if (!list_empty(&priv->cmdpendingq)) | 729 | else if (!list_empty(&priv->cmdpendingq)) |
695 | shouldsleep = 0; /* We have a command to send */ | 730 | shouldsleep = 0; /* We have a command to send */ |
696 | else if (__kfifo_len(priv->event_fifo)) | 731 | else if (__kfifo_len(priv->event_fifo)) |
697 | shouldsleep = 0; /* We have an event to process */ | 732 | shouldsleep = 0; /* We have an event to process */ |
698 | else if (priv->resp_len[priv->resp_idx]) | ||
699 | shouldsleep = 0; /* We have a command response */ | ||
700 | else | 733 | else |
701 | shouldsleep = 1; /* No command */ | 734 | shouldsleep = 1; /* No command */ |
702 | 735 | ||
@@ -749,16 +782,21 @@ static int lbs_thread(void *data) | |||
749 | if (priv->cmd_timed_out && priv->cur_cmd) { | 782 | if (priv->cmd_timed_out && priv->cur_cmd) { |
750 | struct cmd_ctrl_node *cmdnode = priv->cur_cmd; | 783 | struct cmd_ctrl_node *cmdnode = priv->cur_cmd; |
751 | 784 | ||
752 | if (++priv->nr_retries > 10) { | 785 | if (++priv->nr_retries > 3) { |
753 | lbs_pr_info("Excessive timeouts submitting command %x\n", | 786 | lbs_pr_info("Excessive timeouts submitting " |
754 | le16_to_cpu(cmdnode->cmdbuf->command)); | 787 | "command 0x%04x\n", |
788 | le16_to_cpu(cmdnode->cmdbuf->command)); | ||
755 | lbs_complete_command(priv, cmdnode, -ETIMEDOUT); | 789 | lbs_complete_command(priv, cmdnode, -ETIMEDOUT); |
756 | priv->nr_retries = 0; | 790 | priv->nr_retries = 0; |
791 | if (priv->reset_card) | ||
792 | priv->reset_card(priv); | ||
757 | } else { | 793 | } else { |
758 | priv->cur_cmd = NULL; | 794 | priv->cur_cmd = NULL; |
759 | priv->dnld_sent = DNLD_RES_RECEIVED; | 795 | priv->dnld_sent = DNLD_RES_RECEIVED; |
760 | lbs_pr_info("requeueing command %x due to timeout (#%d)\n", | 796 | lbs_pr_info("requeueing command 0x%04x due " |
761 | le16_to_cpu(cmdnode->cmdbuf->command), priv->nr_retries); | 797 | "to timeout (#%d)\n", |
798 | le16_to_cpu(cmdnode->cmdbuf->command), | ||
799 | priv->nr_retries); | ||
762 | 800 | ||
763 | /* Stick it back at the _top_ of the pending queue | 801 | /* Stick it back at the _top_ of the pending queue |
764 | for immediate resubmission */ | 802 | for immediate resubmission */ |
@@ -949,12 +987,11 @@ static void command_timer_fn(unsigned long data) | |||
949 | lbs_deb_enter(LBS_DEB_CMD); | 987 | lbs_deb_enter(LBS_DEB_CMD); |
950 | spin_lock_irqsave(&priv->driver_lock, flags); | 988 | spin_lock_irqsave(&priv->driver_lock, flags); |
951 | 989 | ||
952 | if (!priv->cur_cmd) { | 990 | if (!priv->cur_cmd) |
953 | lbs_pr_info("Command timer expired; no pending command\n"); | ||
954 | goto out; | 991 | goto out; |
955 | } | ||
956 | 992 | ||
957 | lbs_pr_info("Command %x timed out\n", le16_to_cpu(priv->cur_cmd->cmdbuf->command)); | 993 | lbs_pr_info("command 0x%04x timed out\n", |
994 | le16_to_cpu(priv->cur_cmd->cmdbuf->command)); | ||
958 | 995 | ||
959 | priv->cmd_timed_out = 1; | 996 | priv->cmd_timed_out = 1; |
960 | wake_up_interruptible(&priv->waitq); | 997 | wake_up_interruptible(&priv->waitq); |
@@ -1008,7 +1045,7 @@ static int lbs_init_adapter(struct lbs_private *priv) | |||
1008 | priv->curbssparams.channel = DEFAULT_AD_HOC_CHANNEL; | 1045 | priv->curbssparams.channel = DEFAULT_AD_HOC_CHANNEL; |
1009 | priv->mac_control = CMD_ACT_MAC_RX_ON | CMD_ACT_MAC_TX_ON; | 1046 | priv->mac_control = CMD_ACT_MAC_RX_ON | CMD_ACT_MAC_TX_ON; |
1010 | priv->radioon = RADIO_ON; | 1047 | priv->radioon = RADIO_ON; |
1011 | priv->auto_rate = 1; | 1048 | priv->enablehwauto = 1; |
1012 | priv->capability = WLAN_CAPABILITY_SHORT_PREAMBLE; | 1049 | priv->capability = WLAN_CAPABILITY_SHORT_PREAMBLE; |
1013 | priv->psmode = LBS802_11POWERMODECAM; | 1050 | priv->psmode = LBS802_11POWERMODECAM; |
1014 | priv->psstate = PS_STATE_FULL_POWER; | 1051 | priv->psstate = PS_STATE_FULL_POWER; |
@@ -1123,6 +1160,7 @@ struct lbs_private *lbs_add_card(void *card, struct device *dmdev) | |||
1123 | priv->work_thread = create_singlethread_workqueue("lbs_worker"); | 1160 | priv->work_thread = create_singlethread_workqueue("lbs_worker"); |
1124 | INIT_DELAYED_WORK(&priv->assoc_work, lbs_association_worker); | 1161 | INIT_DELAYED_WORK(&priv->assoc_work, lbs_association_worker); |
1125 | INIT_DELAYED_WORK(&priv->scan_work, lbs_scan_worker); | 1162 | INIT_DELAYED_WORK(&priv->scan_work, lbs_scan_worker); |
1163 | INIT_WORK(&priv->mcast_work, lbs_set_mcast_worker); | ||
1126 | INIT_WORK(&priv->sync_channel, lbs_sync_channel_worker); | 1164 | INIT_WORK(&priv->sync_channel, lbs_sync_channel_worker); |
1127 | 1165 | ||
1128 | sprintf(priv->mesh_ssid, "mesh"); | 1166 | sprintf(priv->mesh_ssid, "mesh"); |
@@ -1159,6 +1197,7 @@ void lbs_remove_card(struct lbs_private *priv) | |||
1159 | 1197 | ||
1160 | cancel_delayed_work_sync(&priv->scan_work); | 1198 | cancel_delayed_work_sync(&priv->scan_work); |
1161 | cancel_delayed_work_sync(&priv->assoc_work); | 1199 | cancel_delayed_work_sync(&priv->assoc_work); |
1200 | cancel_work_sync(&priv->mcast_work); | ||
1162 | destroy_workqueue(priv->work_thread); | 1201 | destroy_workqueue(priv->work_thread); |
1163 | 1202 | ||
1164 | if (priv->psmode == LBS802_11POWERMODEMAX_PSP) { | 1203 | if (priv->psmode == LBS802_11POWERMODEMAX_PSP) { |
@@ -1224,9 +1263,11 @@ int lbs_start_card(struct lbs_private *priv) | |||
1224 | useful */ | 1263 | useful */ |
1225 | 1264 | ||
1226 | priv->mesh_tlv = 0x100 + 291; | 1265 | priv->mesh_tlv = 0x100 + 291; |
1227 | if (lbs_mesh_config(priv, 1, priv->curbssparams.channel)) { | 1266 | if (lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START, |
1267 | priv->curbssparams.channel)) { | ||
1228 | priv->mesh_tlv = 0x100 + 37; | 1268 | priv->mesh_tlv = 0x100 + 37; |
1229 | if (lbs_mesh_config(priv, 1, priv->curbssparams.channel)) | 1269 | if (lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START, |
1270 | priv->curbssparams.channel)) | ||
1230 | priv->mesh_tlv = 0; | 1271 | priv->mesh_tlv = 0; |
1231 | } | 1272 | } |
1232 | if (priv->mesh_tlv) { | 1273 | if (priv->mesh_tlv) { |
@@ -1266,8 +1307,9 @@ void lbs_stop_card(struct lbs_private *priv) | |||
1266 | 1307 | ||
1267 | lbs_debugfs_remove_one(priv); | 1308 | lbs_debugfs_remove_one(priv); |
1268 | device_remove_file(&dev->dev, &dev_attr_lbs_rtap); | 1309 | device_remove_file(&dev->dev, &dev_attr_lbs_rtap); |
1269 | if (priv->mesh_tlv) | 1310 | if (priv->mesh_tlv) { |
1270 | device_remove_file(&dev->dev, &dev_attr_lbs_mesh); | 1311 | device_remove_file(&dev->dev, &dev_attr_lbs_mesh); |
1312 | } | ||
1271 | 1313 | ||
1272 | /* Flush pending command nodes */ | 1314 | /* Flush pending command nodes */ |
1273 | del_timer_sync(&priv->command_timer); | 1315 | del_timer_sync(&priv->command_timer); |
@@ -1323,6 +1365,8 @@ static int lbs_add_mesh(struct lbs_private *priv) | |||
1323 | #ifdef WIRELESS_EXT | 1365 | #ifdef WIRELESS_EXT |
1324 | mesh_dev->wireless_handlers = (struct iw_handler_def *)&mesh_handler_def; | 1366 | mesh_dev->wireless_handlers = (struct iw_handler_def *)&mesh_handler_def; |
1325 | #endif | 1367 | #endif |
1368 | mesh_dev->flags |= IFF_BROADCAST | IFF_MULTICAST; | ||
1369 | mesh_dev->set_multicast_list = lbs_set_multicast_list; | ||
1326 | /* Register virtual mesh interface */ | 1370 | /* Register virtual mesh interface */ |
1327 | ret = register_netdev(mesh_dev); | 1371 | ret = register_netdev(mesh_dev); |
1328 | if (ret) { | 1372 | if (ret) { |
@@ -1334,6 +1378,8 @@ static int lbs_add_mesh(struct lbs_private *priv) | |||
1334 | if (ret) | 1378 | if (ret) |
1335 | goto err_unregister; | 1379 | goto err_unregister; |
1336 | 1380 | ||
1381 | lbs_persist_config_init(mesh_dev); | ||
1382 | |||
1337 | /* Everything successful */ | 1383 | /* Everything successful */ |
1338 | ret = 0; | 1384 | ret = 0; |
1339 | goto done; | 1385 | goto done; |
@@ -1360,8 +1406,9 @@ static void lbs_remove_mesh(struct lbs_private *priv) | |||
1360 | 1406 | ||
1361 | lbs_deb_enter(LBS_DEB_MESH); | 1407 | lbs_deb_enter(LBS_DEB_MESH); |
1362 | netif_stop_queue(mesh_dev); | 1408 | netif_stop_queue(mesh_dev); |
1363 | netif_carrier_off(priv->mesh_dev); | 1409 | netif_carrier_off(mesh_dev); |
1364 | sysfs_remove_group(&(mesh_dev->dev.kobj), &lbs_mesh_attr_group); | 1410 | sysfs_remove_group(&(mesh_dev->dev.kobj), &lbs_mesh_attr_group); |
1411 | lbs_persist_config_remove(mesh_dev); | ||
1365 | unregister_netdev(mesh_dev); | 1412 | unregister_netdev(mesh_dev); |
1366 | priv->mesh_dev = NULL; | 1413 | priv->mesh_dev = NULL; |
1367 | free_netdev(mesh_dev); | 1414 | free_netdev(mesh_dev); |
@@ -1555,7 +1602,6 @@ static int lbs_add_rtap(struct lbs_private *priv) | |||
1555 | rtap_dev->stop = lbs_rtap_stop; | 1602 | rtap_dev->stop = lbs_rtap_stop; |
1556 | rtap_dev->get_stats = lbs_rtap_get_stats; | 1603 | rtap_dev->get_stats = lbs_rtap_get_stats; |
1557 | rtap_dev->hard_start_xmit = lbs_rtap_hard_start_xmit; | 1604 | rtap_dev->hard_start_xmit = lbs_rtap_hard_start_xmit; |
1558 | rtap_dev->set_multicast_list = lbs_set_multicast_list; | ||
1559 | rtap_dev->priv = priv; | 1605 | rtap_dev->priv = priv; |
1560 | SET_NETDEV_DEV(rtap_dev, priv->dev->dev.parent); | 1606 | SET_NETDEV_DEV(rtap_dev, priv->dev->dev.parent); |
1561 | 1607 | ||
diff --git a/drivers/net/wireless/libertas/persistcfg.c b/drivers/net/wireless/libertas/persistcfg.c new file mode 100644 index 000000000000..6d0ff8decaf7 --- /dev/null +++ b/drivers/net/wireless/libertas/persistcfg.c | |||
@@ -0,0 +1,453 @@ | |||
1 | #include <linux/moduleparam.h> | ||
2 | #include <linux/delay.h> | ||
3 | #include <linux/etherdevice.h> | ||
4 | #include <linux/netdevice.h> | ||
5 | #include <linux/if_arp.h> | ||
6 | #include <linux/kthread.h> | ||
7 | #include <linux/kfifo.h> | ||
8 | |||
9 | #include "host.h" | ||
10 | #include "decl.h" | ||
11 | #include "dev.h" | ||
12 | #include "wext.h" | ||
13 | #include "debugfs.h" | ||
14 | #include "scan.h" | ||
15 | #include "assoc.h" | ||
16 | #include "cmd.h" | ||
17 | |||
18 | static int mesh_get_default_parameters(struct device *dev, | ||
19 | struct mrvl_mesh_defaults *defs) | ||
20 | { | ||
21 | struct lbs_private *priv = to_net_dev(dev)->priv; | ||
22 | struct cmd_ds_mesh_config cmd; | ||
23 | int ret; | ||
24 | |||
25 | memset(&cmd, 0, sizeof(struct cmd_ds_mesh_config)); | ||
26 | ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_GET, | ||
27 | CMD_TYPE_MESH_GET_DEFAULTS); | ||
28 | |||
29 | if (ret) | ||
30 | return -EOPNOTSUPP; | ||
31 | |||
32 | memcpy(defs, &cmd.data[0], sizeof(struct mrvl_mesh_defaults)); | ||
33 | |||
34 | return 0; | ||
35 | } | ||
36 | |||
37 | /** | ||
38 | * @brief Get function for sysfs attribute bootflag | ||
39 | */ | ||
40 | static ssize_t bootflag_get(struct device *dev, | ||
41 | struct device_attribute *attr, char *buf) | ||
42 | { | ||
43 | struct mrvl_mesh_defaults defs; | ||
44 | int ret; | ||
45 | |||
46 | ret = mesh_get_default_parameters(dev, &defs); | ||
47 | |||
48 | if (ret) | ||
49 | return ret; | ||
50 | |||
51 | return snprintf(buf, 12, "0x%x\n", le32_to_cpu(defs.bootflag)); | ||
52 | } | ||
53 | |||
54 | /** | ||
55 | * @brief Set function for sysfs attribute bootflag | ||
56 | */ | ||
57 | static ssize_t bootflag_set(struct device *dev, struct device_attribute *attr, | ||
58 | const char *buf, size_t count) | ||
59 | { | ||
60 | struct lbs_private *priv = to_net_dev(dev)->priv; | ||
61 | struct cmd_ds_mesh_config cmd; | ||
62 | uint32_t datum; | ||
63 | int ret; | ||
64 | |||
65 | memset(&cmd, 0, sizeof(cmd)); | ||
66 | ret = sscanf(buf, "%x", &datum); | ||
67 | if (ret != 1) | ||
68 | return -EINVAL; | ||
69 | |||
70 | *((__le32 *)&cmd.data[0]) = cpu_to_le32(!!datum); | ||
71 | cmd.length = cpu_to_le16(sizeof(uint32_t)); | ||
72 | ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET, | ||
73 | CMD_TYPE_MESH_SET_BOOTFLAG); | ||
74 | if (ret) | ||
75 | return ret; | ||
76 | |||
77 | return strlen(buf); | ||
78 | } | ||
79 | |||
80 | /** | ||
81 | * @brief Get function for sysfs attribute boottime | ||
82 | */ | ||
83 | static ssize_t boottime_get(struct device *dev, | ||
84 | struct device_attribute *attr, char *buf) | ||
85 | { | ||
86 | struct mrvl_mesh_defaults defs; | ||
87 | int ret; | ||
88 | |||
89 | ret = mesh_get_default_parameters(dev, &defs); | ||
90 | |||
91 | if (ret) | ||
92 | return ret; | ||
93 | |||
94 | return snprintf(buf, 12, "0x%x\n", defs.boottime); | ||
95 | } | ||
96 | |||
97 | /** | ||
98 | * @brief Set function for sysfs attribute boottime | ||
99 | */ | ||
100 | static ssize_t boottime_set(struct device *dev, | ||
101 | struct device_attribute *attr, const char *buf, size_t count) | ||
102 | { | ||
103 | struct lbs_private *priv = to_net_dev(dev)->priv; | ||
104 | struct cmd_ds_mesh_config cmd; | ||
105 | uint32_t datum; | ||
106 | int ret; | ||
107 | |||
108 | memset(&cmd, 0, sizeof(cmd)); | ||
109 | ret = sscanf(buf, "%x", &datum); | ||
110 | if (ret != 1) | ||
111 | return -EINVAL; | ||
112 | |||
113 | /* A too small boot time will result in the device booting into | ||
114 | * standalone (no-host) mode before the host can take control of it, | ||
115 | * so the change will be hard to revert. This may be a desired | ||
116 | * feature (e.g to configure a very fast boot time for devices that | ||
117 | * will not be attached to a host), but dangerous. So I'm enforcing a | ||
118 | * lower limit of 20 seconds: remove and recompile the driver if this | ||
119 | * does not work for you. | ||
120 | */ | ||
121 | datum = (datum < 20) ? 20 : datum; | ||
122 | cmd.data[0] = datum; | ||
123 | cmd.length = cpu_to_le16(sizeof(uint8_t)); | ||
124 | ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET, | ||
125 | CMD_TYPE_MESH_SET_BOOTTIME); | ||
126 | if (ret) | ||
127 | return ret; | ||
128 | |||
129 | return strlen(buf); | ||
130 | } | ||
131 | |||
132 | /** | ||
133 | * @brief Get function for sysfs attribute channel | ||
134 | */ | ||
135 | static ssize_t channel_get(struct device *dev, | ||
136 | struct device_attribute *attr, char *buf) | ||
137 | { | ||
138 | struct mrvl_mesh_defaults defs; | ||
139 | int ret; | ||
140 | |||
141 | ret = mesh_get_default_parameters(dev, &defs); | ||
142 | |||
143 | if (ret) | ||
144 | return ret; | ||
145 | |||
146 | return snprintf(buf, 12, "0x%x\n", le16_to_cpu(defs.channel)); | ||
147 | } | ||
148 | |||
149 | /** | ||
150 | * @brief Set function for sysfs attribute channel | ||
151 | */ | ||
152 | static ssize_t channel_set(struct device *dev, struct device_attribute *attr, | ||
153 | const char *buf, size_t count) | ||
154 | { | ||
155 | struct lbs_private *priv = to_net_dev(dev)->priv; | ||
156 | struct cmd_ds_mesh_config cmd; | ||
157 | uint16_t datum; | ||
158 | int ret; | ||
159 | |||
160 | memset(&cmd, 0, sizeof(cmd)); | ||
161 | ret = sscanf(buf, "%hx", &datum); | ||
162 | if (ret != 1 || datum < 1 || datum > 11) | ||
163 | return -EINVAL; | ||
164 | |||
165 | *((__le16 *)&cmd.data[0]) = cpu_to_le16(datum); | ||
166 | cmd.length = cpu_to_le16(sizeof(uint16_t)); | ||
167 | ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET, | ||
168 | CMD_TYPE_MESH_SET_DEF_CHANNEL); | ||
169 | if (ret) | ||
170 | return ret; | ||
171 | |||
172 | return strlen(buf); | ||
173 | } | ||
174 | |||
175 | /** | ||
176 | * @brief Get function for sysfs attribute mesh_id | ||
177 | */ | ||
178 | static ssize_t mesh_id_get(struct device *dev, struct device_attribute *attr, | ||
179 | char *buf) | ||
180 | { | ||
181 | struct mrvl_mesh_defaults defs; | ||
182 | int maxlen; | ||
183 | int ret; | ||
184 | |||
185 | ret = mesh_get_default_parameters(dev, &defs); | ||
186 | |||
187 | if (ret) | ||
188 | return ret; | ||
189 | |||
190 | if (defs.meshie.val.mesh_id_len > IW_ESSID_MAX_SIZE) { | ||
191 | lbs_pr_err("inconsistent mesh ID length"); | ||
192 | defs.meshie.val.mesh_id_len = IW_ESSID_MAX_SIZE; | ||
193 | } | ||
194 | |||
195 | /* SSID not null terminated: reserve room for \0 + \n */ | ||
196 | maxlen = defs.meshie.val.mesh_id_len + 2; | ||
197 | maxlen = (PAGE_SIZE > maxlen) ? maxlen : PAGE_SIZE; | ||
198 | |||
199 | defs.meshie.val.mesh_id[defs.meshie.val.mesh_id_len] = '\0'; | ||
200 | |||
201 | return snprintf(buf, maxlen, "%s\n", defs.meshie.val.mesh_id); | ||
202 | } | ||
203 | |||
204 | /** | ||
205 | * @brief Set function for sysfs attribute mesh_id | ||
206 | */ | ||
207 | static ssize_t mesh_id_set(struct device *dev, struct device_attribute *attr, | ||
208 | const char *buf, size_t count) | ||
209 | { | ||
210 | struct cmd_ds_mesh_config cmd; | ||
211 | struct mrvl_mesh_defaults defs; | ||
212 | struct mrvl_meshie *ie; | ||
213 | struct lbs_private *priv = to_net_dev(dev)->priv; | ||
214 | int len; | ||
215 | int ret; | ||
216 | |||
217 | if (count < 2 || count > IW_ESSID_MAX_SIZE + 1) | ||
218 | return -EINVAL; | ||
219 | |||
220 | memset(&cmd, 0, sizeof(struct cmd_ds_mesh_config)); | ||
221 | ie = (struct mrvl_meshie *) &cmd.data[0]; | ||
222 | |||
223 | /* fetch all other Information Element parameters */ | ||
224 | ret = mesh_get_default_parameters(dev, &defs); | ||
225 | |||
226 | cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie)); | ||
227 | |||
228 | /* transfer IE elements */ | ||
229 | memcpy(ie, &defs.meshie, sizeof(struct mrvl_meshie)); | ||
230 | |||
231 | len = count - 1; | ||
232 | memcpy(ie->val.mesh_id, buf, len); | ||
233 | /* SSID len */ | ||
234 | ie->val.mesh_id_len = len; | ||
235 | /* IE len */ | ||
236 | ie->hdr.len = sizeof(struct mrvl_meshie_val) - IW_ESSID_MAX_SIZE + len; | ||
237 | |||
238 | ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET, | ||
239 | CMD_TYPE_MESH_SET_MESH_IE); | ||
240 | if (ret) | ||
241 | return ret; | ||
242 | |||
243 | return strlen(buf); | ||
244 | } | ||
245 | |||
246 | /** | ||
247 | * @brief Get function for sysfs attribute protocol_id | ||
248 | */ | ||
249 | static ssize_t protocol_id_get(struct device *dev, | ||
250 | struct device_attribute *attr, char *buf) | ||
251 | { | ||
252 | struct mrvl_mesh_defaults defs; | ||
253 | int ret; | ||
254 | |||
255 | ret = mesh_get_default_parameters(dev, &defs); | ||
256 | |||
257 | if (ret) | ||
258 | return ret; | ||
259 | |||
260 | return snprintf(buf, 5, "%d\n", defs.meshie.val.active_protocol_id); | ||
261 | } | ||
262 | |||
263 | /** | ||
264 | * @brief Set function for sysfs attribute protocol_id | ||
265 | */ | ||
266 | static ssize_t protocol_id_set(struct device *dev, | ||
267 | struct device_attribute *attr, const char *buf, size_t count) | ||
268 | { | ||
269 | struct cmd_ds_mesh_config cmd; | ||
270 | struct mrvl_mesh_defaults defs; | ||
271 | struct mrvl_meshie *ie; | ||
272 | struct lbs_private *priv = to_net_dev(dev)->priv; | ||
273 | uint32_t datum; | ||
274 | int ret; | ||
275 | |||
276 | memset(&cmd, 0, sizeof(cmd)); | ||
277 | ret = sscanf(buf, "%x", &datum); | ||
278 | if (ret != 1) | ||
279 | return -EINVAL; | ||
280 | |||
281 | /* fetch all other Information Element parameters */ | ||
282 | ret = mesh_get_default_parameters(dev, &defs); | ||
283 | |||
284 | cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie)); | ||
285 | |||
286 | /* transfer IE elements */ | ||
287 | ie = (struct mrvl_meshie *) &cmd.data[0]; | ||
288 | memcpy(ie, &defs.meshie, sizeof(struct mrvl_meshie)); | ||
289 | /* update protocol id */ | ||
290 | ie->val.active_protocol_id = datum; | ||
291 | |||
292 | ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET, | ||
293 | CMD_TYPE_MESH_SET_MESH_IE); | ||
294 | if (ret) | ||
295 | return ret; | ||
296 | |||
297 | return strlen(buf); | ||
298 | } | ||
299 | |||
300 | /** | ||
301 | * @brief Get function for sysfs attribute metric_id | ||
302 | */ | ||
303 | static ssize_t metric_id_get(struct device *dev, | ||
304 | struct device_attribute *attr, char *buf) | ||
305 | { | ||
306 | struct mrvl_mesh_defaults defs; | ||
307 | int ret; | ||
308 | |||
309 | ret = mesh_get_default_parameters(dev, &defs); | ||
310 | |||
311 | if (ret) | ||
312 | return ret; | ||
313 | |||
314 | return snprintf(buf, 5, "%d\n", defs.meshie.val.active_metric_id); | ||
315 | } | ||
316 | |||
317 | /** | ||
318 | * @brief Set function for sysfs attribute metric_id | ||
319 | */ | ||
320 | static ssize_t metric_id_set(struct device *dev, struct device_attribute *attr, | ||
321 | const char *buf, size_t count) | ||
322 | { | ||
323 | struct cmd_ds_mesh_config cmd; | ||
324 | struct mrvl_mesh_defaults defs; | ||
325 | struct mrvl_meshie *ie; | ||
326 | struct lbs_private *priv = to_net_dev(dev)->priv; | ||
327 | uint32_t datum; | ||
328 | int ret; | ||
329 | |||
330 | memset(&cmd, 0, sizeof(cmd)); | ||
331 | ret = sscanf(buf, "%x", &datum); | ||
332 | if (ret != 1) | ||
333 | return -EINVAL; | ||
334 | |||
335 | /* fetch all other Information Element parameters */ | ||
336 | ret = mesh_get_default_parameters(dev, &defs); | ||
337 | |||
338 | cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie)); | ||
339 | |||
340 | /* transfer IE elements */ | ||
341 | ie = (struct mrvl_meshie *) &cmd.data[0]; | ||
342 | memcpy(ie, &defs.meshie, sizeof(struct mrvl_meshie)); | ||
343 | /* update metric id */ | ||
344 | ie->val.active_metric_id = datum; | ||
345 | |||
346 | ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET, | ||
347 | CMD_TYPE_MESH_SET_MESH_IE); | ||
348 | if (ret) | ||
349 | return ret; | ||
350 | |||
351 | return strlen(buf); | ||
352 | } | ||
353 | |||
354 | /** | ||
355 | * @brief Get function for sysfs attribute capability | ||
356 | */ | ||
357 | static ssize_t capability_get(struct device *dev, | ||
358 | struct device_attribute *attr, char *buf) | ||
359 | { | ||
360 | struct mrvl_mesh_defaults defs; | ||
361 | int ret; | ||
362 | |||
363 | ret = mesh_get_default_parameters(dev, &defs); | ||
364 | |||
365 | if (ret) | ||
366 | return ret; | ||
367 | |||
368 | return snprintf(buf, 5, "%d\n", defs.meshie.val.mesh_capability); | ||
369 | } | ||
370 | |||
371 | /** | ||
372 | * @brief Set function for sysfs attribute capability | ||
373 | */ | ||
374 | static ssize_t capability_set(struct device *dev, struct device_attribute *attr, | ||
375 | const char *buf, size_t count) | ||
376 | { | ||
377 | struct cmd_ds_mesh_config cmd; | ||
378 | struct mrvl_mesh_defaults defs; | ||
379 | struct mrvl_meshie *ie; | ||
380 | struct lbs_private *priv = to_net_dev(dev)->priv; | ||
381 | uint32_t datum; | ||
382 | int ret; | ||
383 | |||
384 | memset(&cmd, 0, sizeof(cmd)); | ||
385 | ret = sscanf(buf, "%x", &datum); | ||
386 | if (ret != 1) | ||
387 | return -EINVAL; | ||
388 | |||
389 | /* fetch all other Information Element parameters */ | ||
390 | ret = mesh_get_default_parameters(dev, &defs); | ||
391 | |||
392 | cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie)); | ||
393 | |||
394 | /* transfer IE elements */ | ||
395 | ie = (struct mrvl_meshie *) &cmd.data[0]; | ||
396 | memcpy(ie, &defs.meshie, sizeof(struct mrvl_meshie)); | ||
397 | /* update value */ | ||
398 | ie->val.mesh_capability = datum; | ||
399 | |||
400 | ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET, | ||
401 | CMD_TYPE_MESH_SET_MESH_IE); | ||
402 | if (ret) | ||
403 | return ret; | ||
404 | |||
405 | return strlen(buf); | ||
406 | } | ||
407 | |||
408 | |||
409 | static DEVICE_ATTR(bootflag, 0644, bootflag_get, bootflag_set); | ||
410 | static DEVICE_ATTR(boottime, 0644, boottime_get, boottime_set); | ||
411 | static DEVICE_ATTR(channel, 0644, channel_get, channel_set); | ||
412 | static DEVICE_ATTR(mesh_id, 0644, mesh_id_get, mesh_id_set); | ||
413 | static DEVICE_ATTR(protocol_id, 0644, protocol_id_get, protocol_id_set); | ||
414 | static DEVICE_ATTR(metric_id, 0644, metric_id_get, metric_id_set); | ||
415 | static DEVICE_ATTR(capability, 0644, capability_get, capability_set); | ||
416 | |||
417 | static struct attribute *boot_opts_attrs[] = { | ||
418 | &dev_attr_bootflag.attr, | ||
419 | &dev_attr_boottime.attr, | ||
420 | &dev_attr_channel.attr, | ||
421 | NULL | ||
422 | }; | ||
423 | |||
424 | static struct attribute_group boot_opts_group = { | ||
425 | .name = "boot_options", | ||
426 | .attrs = boot_opts_attrs, | ||
427 | }; | ||
428 | |||
429 | static struct attribute *mesh_ie_attrs[] = { | ||
430 | &dev_attr_mesh_id.attr, | ||
431 | &dev_attr_protocol_id.attr, | ||
432 | &dev_attr_metric_id.attr, | ||
433 | &dev_attr_capability.attr, | ||
434 | NULL | ||
435 | }; | ||
436 | |||
437 | static struct attribute_group mesh_ie_group = { | ||
438 | .name = "mesh_ie", | ||
439 | .attrs = mesh_ie_attrs, | ||
440 | }; | ||
441 | |||
442 | void lbs_persist_config_init(struct net_device *dev) | ||
443 | { | ||
444 | int ret; | ||
445 | ret = sysfs_create_group(&(dev->dev.kobj), &boot_opts_group); | ||
446 | ret = sysfs_create_group(&(dev->dev.kobj), &mesh_ie_group); | ||
447 | } | ||
448 | |||
449 | void lbs_persist_config_remove(struct net_device *dev) | ||
450 | { | ||
451 | sysfs_remove_group(&(dev->dev.kobj), &boot_opts_group); | ||
452 | sysfs_remove_group(&(dev->dev.kobj), &mesh_ie_group); | ||
453 | } | ||
diff --git a/drivers/net/wireless/libertas/rx.c b/drivers/net/wireless/libertas/rx.c index 05af7316f698..5749f22b296f 100644 --- a/drivers/net/wireless/libertas/rx.c +++ b/drivers/net/wireless/libertas/rx.c | |||
@@ -237,7 +237,7 @@ int lbs_process_rxed_packet(struct lbs_private *priv, struct sk_buff *skb) | |||
237 | /* Take the data rate from the rxpd structure | 237 | /* Take the data rate from the rxpd structure |
238 | * only if the rate is auto | 238 | * only if the rate is auto |
239 | */ | 239 | */ |
240 | if (priv->auto_rate) | 240 | if (priv->enablehwauto) |
241 | priv->cur_rate = lbs_fw_index_to_data_rate(p_rx_pd->rx_rate); | 241 | priv->cur_rate = lbs_fw_index_to_data_rate(p_rx_pd->rx_rate); |
242 | 242 | ||
243 | lbs_compute_rssi(priv, p_rx_pd); | 243 | lbs_compute_rssi(priv, p_rx_pd); |
@@ -383,7 +383,7 @@ static int process_rxed_802_11_packet(struct lbs_private *priv, | |||
383 | /* Take the data rate from the rxpd structure | 383 | /* Take the data rate from the rxpd structure |
384 | * only if the rate is auto | 384 | * only if the rate is auto |
385 | */ | 385 | */ |
386 | if (priv->auto_rate) | 386 | if (priv->enablehwauto) |
387 | priv->cur_rate = lbs_fw_index_to_data_rate(prxpd->rx_rate); | 387 | priv->cur_rate = lbs_fw_index_to_data_rate(prxpd->rx_rate); |
388 | 388 | ||
389 | lbs_compute_rssi(priv, prxpd); | 389 | lbs_compute_rssi(priv, prxpd); |
diff --git a/drivers/net/wireless/libertas/types.h b/drivers/net/wireless/libertas/types.h index 4031be420862..e0c2599da92f 100644 --- a/drivers/net/wireless/libertas/types.h +++ b/drivers/net/wireless/libertas/types.h | |||
@@ -6,6 +6,8 @@ | |||
6 | 6 | ||
7 | #include <linux/if_ether.h> | 7 | #include <linux/if_ether.h> |
8 | #include <asm/byteorder.h> | 8 | #include <asm/byteorder.h> |
9 | #include <linux/wireless.h> | ||
10 | #include <net/ieee80211.h> | ||
9 | 11 | ||
10 | struct ieeetypes_cfparamset { | 12 | struct ieeetypes_cfparamset { |
11 | u8 elementid; | 13 | u8 elementid; |
@@ -252,4 +254,32 @@ struct mrvlietypes_ledbhv { | |||
252 | struct led_bhv ledbhv[1]; | 254 | struct led_bhv ledbhv[1]; |
253 | } __attribute__ ((packed)); | 255 | } __attribute__ ((packed)); |
254 | 256 | ||
257 | /* Meant to be packed as the value member of a struct ieee80211_info_element. | ||
258 | * Note that the len member of the ieee80211_info_element varies depending on | ||
259 | * the mesh_id_len */ | ||
260 | struct mrvl_meshie_val { | ||
261 | uint8_t oui[P80211_OUI_LEN]; | ||
262 | uint8_t type; | ||
263 | uint8_t subtype; | ||
264 | uint8_t version; | ||
265 | uint8_t active_protocol_id; | ||
266 | uint8_t active_metric_id; | ||
267 | uint8_t mesh_capability; | ||
268 | uint8_t mesh_id_len; | ||
269 | uint8_t mesh_id[IW_ESSID_MAX_SIZE]; | ||
270 | } __attribute__ ((packed)); | ||
271 | |||
272 | struct mrvl_meshie { | ||
273 | struct ieee80211_info_element hdr; | ||
274 | struct mrvl_meshie_val val; | ||
275 | } __attribute__ ((packed)); | ||
276 | |||
277 | struct mrvl_mesh_defaults { | ||
278 | __le32 bootflag; | ||
279 | uint8_t boottime; | ||
280 | uint8_t reserved; | ||
281 | __le16 channel; | ||
282 | struct mrvl_meshie meshie; | ||
283 | } __attribute__ ((packed)); | ||
284 | |||
255 | #endif | 285 | #endif |
diff --git a/drivers/net/wireless/libertas/wext.c b/drivers/net/wireless/libertas/wext.c index 0973d015a520..8b3ed77860b3 100644 --- a/drivers/net/wireless/libertas/wext.c +++ b/drivers/net/wireless/libertas/wext.c | |||
@@ -1002,7 +1002,7 @@ static int lbs_mesh_set_freq(struct net_device *dev, | |||
1002 | else if (priv->mode == IW_MODE_ADHOC) | 1002 | else if (priv->mode == IW_MODE_ADHOC) |
1003 | lbs_stop_adhoc_network(priv); | 1003 | lbs_stop_adhoc_network(priv); |
1004 | } | 1004 | } |
1005 | lbs_mesh_config(priv, 1, fwrq->m); | 1005 | lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START, fwrq->m); |
1006 | lbs_update_channel(priv); | 1006 | lbs_update_channel(priv); |
1007 | ret = 0; | 1007 | ret = 0; |
1008 | 1008 | ||
@@ -1021,29 +1021,38 @@ static int lbs_set_rate(struct net_device *dev, struct iw_request_info *info, | |||
1021 | 1021 | ||
1022 | lbs_deb_enter(LBS_DEB_WEXT); | 1022 | lbs_deb_enter(LBS_DEB_WEXT); |
1023 | lbs_deb_wext("vwrq->value %d\n", vwrq->value); | 1023 | lbs_deb_wext("vwrq->value %d\n", vwrq->value); |
1024 | lbs_deb_wext("vwrq->fixed %d\n", vwrq->fixed); | ||
1025 | |||
1026 | if (vwrq->fixed && vwrq->value == -1) | ||
1027 | goto out; | ||
1024 | 1028 | ||
1025 | /* Auto rate? */ | 1029 | /* Auto rate? */ |
1026 | if (vwrq->value == -1) { | 1030 | priv->enablehwauto = !vwrq->fixed; |
1027 | priv->auto_rate = 1; | 1031 | |
1032 | if (vwrq->value == -1) | ||
1028 | priv->cur_rate = 0; | 1033 | priv->cur_rate = 0; |
1029 | } else { | 1034 | else { |
1030 | if (vwrq->value % 100000) | 1035 | if (vwrq->value % 100000) |
1031 | goto out; | 1036 | goto out; |
1032 | 1037 | ||
1038 | new_rate = vwrq->value / 500000; | ||
1039 | priv->cur_rate = new_rate; | ||
1040 | /* the rest is only needed for lbs_set_data_rate() */ | ||
1033 | memset(rates, 0, sizeof(rates)); | 1041 | memset(rates, 0, sizeof(rates)); |
1034 | copy_active_data_rates(priv, rates); | 1042 | copy_active_data_rates(priv, rates); |
1035 | new_rate = vwrq->value / 500000; | ||
1036 | if (!memchr(rates, new_rate, sizeof(rates))) { | 1043 | if (!memchr(rates, new_rate, sizeof(rates))) { |
1037 | lbs_pr_alert("fixed data rate 0x%X out of range\n", | 1044 | lbs_pr_alert("fixed data rate 0x%X out of range\n", |
1038 | new_rate); | 1045 | new_rate); |
1039 | goto out; | 1046 | goto out; |
1040 | } | 1047 | } |
1041 | |||
1042 | priv->cur_rate = new_rate; | ||
1043 | priv->auto_rate = 0; | ||
1044 | } | 1048 | } |
1045 | 1049 | ||
1046 | ret = lbs_set_data_rate(priv, new_rate); | 1050 | /* Try the newer command first (Firmware Spec 5.1 and above) */ |
1051 | ret = lbs_cmd_802_11_rate_adapt_rateset(priv, CMD_ACT_SET); | ||
1052 | |||
1053 | /* Fallback to older version */ | ||
1054 | if (ret) | ||
1055 | ret = lbs_set_data_rate(priv, new_rate); | ||
1047 | 1056 | ||
1048 | out: | 1057 | out: |
1049 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); | 1058 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
@@ -1060,7 +1069,7 @@ static int lbs_get_rate(struct net_device *dev, struct iw_request_info *info, | |||
1060 | if (priv->connect_status == LBS_CONNECTED) { | 1069 | if (priv->connect_status == LBS_CONNECTED) { |
1061 | vwrq->value = priv->cur_rate * 500000; | 1070 | vwrq->value = priv->cur_rate * 500000; |
1062 | 1071 | ||
1063 | if (priv->auto_rate) | 1072 | if (priv->enablehwauto) |
1064 | vwrq->fixed = 0; | 1073 | vwrq->fixed = 0; |
1065 | else | 1074 | else |
1066 | vwrq->fixed = 1; | 1075 | vwrq->fixed = 1; |
@@ -2011,7 +2020,8 @@ static int lbs_mesh_set_essid(struct net_device *dev, | |||
2011 | priv->mesh_ssid_len = dwrq->length; | 2020 | priv->mesh_ssid_len = dwrq->length; |
2012 | } | 2021 | } |
2013 | 2022 | ||
2014 | lbs_mesh_config(priv, 1, priv->curbssparams.channel); | 2023 | lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START, |
2024 | priv->curbssparams.channel); | ||
2015 | out: | 2025 | out: |
2016 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); | 2026 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |
2017 | return ret; | 2027 | return ret; |
diff --git a/drivers/net/wireless/p54/p54common.c b/drivers/net/wireless/p54/p54common.c index 9cbef5bce0f6..9f7224de6fd1 100644 --- a/drivers/net/wireless/p54/p54common.c +++ b/drivers/net/wireless/p54/p54common.c | |||
@@ -375,9 +375,6 @@ static void inline p54_wake_free_queues(struct ieee80211_hw *dev) | |||
375 | struct p54_common *priv = dev->priv; | 375 | struct p54_common *priv = dev->priv; |
376 | int i; | 376 | int i; |
377 | 377 | ||
378 | /* ieee80211_start_queues is great if all queues are really empty. | ||
379 | * But, what if some are full? */ | ||
380 | |||
381 | for (i = 0; i < dev->queues; i++) | 378 | for (i = 0; i < dev->queues; i++) |
382 | if (priv->tx_stats[i].len < priv->tx_stats[i].limit) | 379 | if (priv->tx_stats[i].len < priv->tx_stats[i].limit) |
383 | ieee80211_wake_queue(dev, i); | 380 | ieee80211_wake_queue(dev, i); |
@@ -395,44 +392,42 @@ static void p54_rx_frame_sent(struct ieee80211_hw *dev, struct sk_buff *skb) | |||
395 | u32 last_addr = priv->rx_start; | 392 | u32 last_addr = priv->rx_start; |
396 | 393 | ||
397 | while (entry != (struct sk_buff *)&priv->tx_queue) { | 394 | while (entry != (struct sk_buff *)&priv->tx_queue) { |
398 | range = (struct memrecord *)&entry->cb; | 395 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(entry); |
396 | range = (void *)info->driver_data; | ||
399 | if (range->start_addr == addr) { | 397 | if (range->start_addr == addr) { |
400 | struct ieee80211_tx_status status; | ||
401 | struct p54_control_hdr *entry_hdr; | 398 | struct p54_control_hdr *entry_hdr; |
402 | struct p54_tx_control_allocdata *entry_data; | 399 | struct p54_tx_control_allocdata *entry_data; |
403 | int pad = 0; | 400 | int pad = 0; |
404 | 401 | ||
405 | if (entry->next != (struct sk_buff *)&priv->tx_queue) | 402 | if (entry->next != (struct sk_buff *)&priv->tx_queue) { |
406 | freed = ((struct memrecord *)&entry->next->cb)->start_addr - last_addr; | 403 | struct ieee80211_tx_info *ni; |
407 | else | 404 | struct memrecord *mr; |
405 | |||
406 | ni = IEEE80211_SKB_CB(entry->next); | ||
407 | mr = (struct memrecord *)ni->driver_data; | ||
408 | freed = mr->start_addr - last_addr; | ||
409 | } else | ||
408 | freed = priv->rx_end - last_addr; | 410 | freed = priv->rx_end - last_addr; |
409 | 411 | ||
410 | last_addr = range->end_addr; | 412 | last_addr = range->end_addr; |
411 | __skb_unlink(entry, &priv->tx_queue); | 413 | __skb_unlink(entry, &priv->tx_queue); |
412 | if (!range->control) { | 414 | memset(&info->status, 0, sizeof(info->status)); |
413 | kfree_skb(entry); | 415 | priv->tx_stats[skb_get_queue_mapping(skb)].len--; |
414 | break; | ||
415 | } | ||
416 | memset(&status, 0, sizeof(status)); | ||
417 | memcpy(&status.control, range->control, | ||
418 | sizeof(status.control)); | ||
419 | kfree(range->control); | ||
420 | priv->tx_stats[status.control.queue].len--; | ||
421 | entry_hdr = (struct p54_control_hdr *) entry->data; | 416 | entry_hdr = (struct p54_control_hdr *) entry->data; |
422 | entry_data = (struct p54_tx_control_allocdata *) entry_hdr->data; | 417 | entry_data = (struct p54_tx_control_allocdata *) entry_hdr->data; |
423 | if ((entry_hdr->magic1 & cpu_to_le16(0x4000)) != 0) | 418 | if ((entry_hdr->magic1 & cpu_to_le16(0x4000)) != 0) |
424 | pad = entry_data->align[0]; | 419 | pad = entry_data->align[0]; |
425 | 420 | ||
426 | if (!(status.control.flags & IEEE80211_TXCTL_NO_ACK)) { | 421 | if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) { |
427 | if (!(payload->status & 0x01)) | 422 | if (!(payload->status & 0x01)) |
428 | status.flags |= IEEE80211_TX_STATUS_ACK; | 423 | info->flags |= IEEE80211_TX_STAT_ACK; |
429 | else | 424 | else |
430 | status.excessive_retries = 1; | 425 | info->status.excessive_retries = 1; |
431 | } | 426 | } |
432 | status.retry_count = payload->retries - 1; | 427 | info->status.retry_count = payload->retries - 1; |
433 | status.ack_signal = le16_to_cpu(payload->ack_rssi); | 428 | info->status.ack_signal = le16_to_cpu(payload->ack_rssi); |
434 | skb_pull(entry, sizeof(*hdr) + pad + sizeof(*entry_data)); | 429 | skb_pull(entry, sizeof(*hdr) + pad + sizeof(*entry_data)); |
435 | ieee80211_tx_status_irqsafe(dev, entry, &status); | 430 | ieee80211_tx_status_irqsafe(dev, entry); |
436 | break; | 431 | break; |
437 | } else | 432 | } else |
438 | last_addr = range->end_addr; | 433 | last_addr = range->end_addr; |
@@ -497,13 +492,11 @@ EXPORT_SYMBOL_GPL(p54_rx); | |||
497 | * allocated areas. | 492 | * allocated areas. |
498 | */ | 493 | */ |
499 | static void p54_assign_address(struct ieee80211_hw *dev, struct sk_buff *skb, | 494 | static void p54_assign_address(struct ieee80211_hw *dev, struct sk_buff *skb, |
500 | struct p54_control_hdr *data, u32 len, | 495 | struct p54_control_hdr *data, u32 len) |
501 | struct ieee80211_tx_control *control) | ||
502 | { | 496 | { |
503 | struct p54_common *priv = dev->priv; | 497 | struct p54_common *priv = dev->priv; |
504 | struct sk_buff *entry = priv->tx_queue.next; | 498 | struct sk_buff *entry = priv->tx_queue.next; |
505 | struct sk_buff *target_skb = NULL; | 499 | struct sk_buff *target_skb = NULL; |
506 | struct memrecord *range; | ||
507 | u32 last_addr = priv->rx_start; | 500 | u32 last_addr = priv->rx_start; |
508 | u32 largest_hole = 0; | 501 | u32 largest_hole = 0; |
509 | u32 target_addr = priv->rx_start; | 502 | u32 target_addr = priv->rx_start; |
@@ -515,7 +508,8 @@ static void p54_assign_address(struct ieee80211_hw *dev, struct sk_buff *skb, | |||
515 | left = skb_queue_len(&priv->tx_queue); | 508 | left = skb_queue_len(&priv->tx_queue); |
516 | while (left--) { | 509 | while (left--) { |
517 | u32 hole_size; | 510 | u32 hole_size; |
518 | range = (struct memrecord *)&entry->cb; | 511 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(entry); |
512 | struct memrecord *range = (void *)info->driver_data; | ||
519 | hole_size = range->start_addr - last_addr; | 513 | hole_size = range->start_addr - last_addr; |
520 | if (!target_skb && hole_size >= len) { | 514 | if (!target_skb && hole_size >= len) { |
521 | target_skb = entry->prev; | 515 | target_skb = entry->prev; |
@@ -530,17 +524,18 @@ static void p54_assign_address(struct ieee80211_hw *dev, struct sk_buff *skb, | |||
530 | target_skb = priv->tx_queue.prev; | 524 | target_skb = priv->tx_queue.prev; |
531 | largest_hole = max(largest_hole, priv->rx_end - last_addr - len); | 525 | largest_hole = max(largest_hole, priv->rx_end - last_addr - len); |
532 | if (!skb_queue_empty(&priv->tx_queue)) { | 526 | if (!skb_queue_empty(&priv->tx_queue)) { |
533 | range = (struct memrecord *)&target_skb->cb; | 527 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(target_skb); |
528 | struct memrecord *range = (void *)info->driver_data; | ||
534 | target_addr = range->end_addr; | 529 | target_addr = range->end_addr; |
535 | } | 530 | } |
536 | } else | 531 | } else |
537 | largest_hole = max(largest_hole, priv->rx_end - last_addr); | 532 | largest_hole = max(largest_hole, priv->rx_end - last_addr); |
538 | 533 | ||
539 | if (skb) { | 534 | if (skb) { |
540 | range = (struct memrecord *)&skb->cb; | 535 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
536 | struct memrecord *range = (void *)info->driver_data; | ||
541 | range->start_addr = target_addr; | 537 | range->start_addr = target_addr; |
542 | range->end_addr = target_addr + len; | 538 | range->end_addr = target_addr + len; |
543 | range->control = control; | ||
544 | __skb_queue_after(&priv->tx_queue, target_skb, skb); | 539 | __skb_queue_after(&priv->tx_queue, target_skb, skb); |
545 | if (largest_hole < IEEE80211_MAX_RTS_THRESHOLD + 0x170 + | 540 | if (largest_hole < IEEE80211_MAX_RTS_THRESHOLD + 0x170 + |
546 | sizeof(struct p54_control_hdr)) | 541 | sizeof(struct p54_control_hdr)) |
@@ -551,32 +546,27 @@ static void p54_assign_address(struct ieee80211_hw *dev, struct sk_buff *skb, | |||
551 | data->req_id = cpu_to_le32(target_addr + 0x70); | 546 | data->req_id = cpu_to_le32(target_addr + 0x70); |
552 | } | 547 | } |
553 | 548 | ||
554 | static int p54_tx(struct ieee80211_hw *dev, struct sk_buff *skb, | 549 | static int p54_tx(struct ieee80211_hw *dev, struct sk_buff *skb) |
555 | struct ieee80211_tx_control *control) | ||
556 | { | 550 | { |
551 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
557 | struct ieee80211_tx_queue_stats *current_queue; | 552 | struct ieee80211_tx_queue_stats *current_queue; |
558 | struct p54_common *priv = dev->priv; | 553 | struct p54_common *priv = dev->priv; |
559 | struct p54_control_hdr *hdr; | 554 | struct p54_control_hdr *hdr; |
560 | struct p54_tx_control_allocdata *txhdr; | 555 | struct p54_tx_control_allocdata *txhdr; |
561 | struct ieee80211_tx_control *control_copy; | ||
562 | size_t padding, len; | 556 | size_t padding, len; |
563 | u8 rate; | 557 | u8 rate; |
564 | 558 | ||
565 | current_queue = &priv->tx_stats[control->queue]; | 559 | current_queue = &priv->tx_stats[skb_get_queue_mapping(skb)]; |
566 | if (unlikely(current_queue->len > current_queue->limit)) | 560 | if (unlikely(current_queue->len > current_queue->limit)) |
567 | return NETDEV_TX_BUSY; | 561 | return NETDEV_TX_BUSY; |
568 | current_queue->len++; | 562 | current_queue->len++; |
569 | current_queue->count++; | 563 | current_queue->count++; |
570 | if (current_queue->len == current_queue->limit) | 564 | if (current_queue->len == current_queue->limit) |
571 | ieee80211_stop_queue(dev, control->queue); | 565 | ieee80211_stop_queue(dev, skb_get_queue_mapping(skb)); |
572 | 566 | ||
573 | padding = (unsigned long)(skb->data - (sizeof(*hdr) + sizeof(*txhdr))) & 3; | 567 | padding = (unsigned long)(skb->data - (sizeof(*hdr) + sizeof(*txhdr))) & 3; |
574 | len = skb->len; | 568 | len = skb->len; |
575 | 569 | ||
576 | control_copy = kmalloc(sizeof(*control), GFP_ATOMIC); | ||
577 | if (control_copy) | ||
578 | memcpy(control_copy, control, sizeof(*control)); | ||
579 | |||
580 | txhdr = (struct p54_tx_control_allocdata *) | 570 | txhdr = (struct p54_tx_control_allocdata *) |
581 | skb_push(skb, sizeof(*txhdr) + padding); | 571 | skb_push(skb, sizeof(*txhdr) + padding); |
582 | hdr = (struct p54_control_hdr *) skb_push(skb, sizeof(*hdr)); | 572 | hdr = (struct p54_control_hdr *) skb_push(skb, sizeof(*hdr)); |
@@ -586,35 +576,37 @@ static int p54_tx(struct ieee80211_hw *dev, struct sk_buff *skb, | |||
586 | else | 576 | else |
587 | hdr->magic1 = cpu_to_le16(0x0010); | 577 | hdr->magic1 = cpu_to_le16(0x0010); |
588 | hdr->len = cpu_to_le16(len); | 578 | hdr->len = cpu_to_le16(len); |
589 | hdr->type = (control->flags & IEEE80211_TXCTL_NO_ACK) ? 0 : cpu_to_le16(1); | 579 | hdr->type = (info->flags & IEEE80211_TX_CTL_NO_ACK) ? 0 : cpu_to_le16(1); |
590 | hdr->retry1 = hdr->retry2 = control->retry_limit; | 580 | hdr->retry1 = hdr->retry2 = info->control.retry_limit; |
591 | p54_assign_address(dev, skb, hdr, skb->len, control_copy); | ||
592 | 581 | ||
593 | memset(txhdr->wep_key, 0x0, 16); | 582 | memset(txhdr->wep_key, 0x0, 16); |
594 | txhdr->padding = 0; | 583 | txhdr->padding = 0; |
595 | txhdr->padding2 = 0; | 584 | txhdr->padding2 = 0; |
596 | 585 | ||
597 | /* TODO: add support for alternate retry TX rates */ | 586 | /* TODO: add support for alternate retry TX rates */ |
598 | rate = control->tx_rate->hw_value; | 587 | rate = ieee80211_get_tx_rate(dev, info)->hw_value; |
599 | if (control->flags & IEEE80211_TXCTL_SHORT_PREAMBLE) | 588 | if (info->flags & IEEE80211_TX_CTL_SHORT_PREAMBLE) |
600 | rate |= 0x10; | 589 | rate |= 0x10; |
601 | if (control->flags & IEEE80211_TXCTL_USE_RTS_CTS) | 590 | if (info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) |
602 | rate |= 0x40; | 591 | rate |= 0x40; |
603 | else if (control->flags & IEEE80211_TXCTL_USE_CTS_PROTECT) | 592 | else if (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) |
604 | rate |= 0x20; | 593 | rate |= 0x20; |
605 | memset(txhdr->rateset, rate, 8); | 594 | memset(txhdr->rateset, rate, 8); |
606 | txhdr->wep_key_present = 0; | 595 | txhdr->wep_key_present = 0; |
607 | txhdr->wep_key_len = 0; | 596 | txhdr->wep_key_len = 0; |
608 | txhdr->frame_type = cpu_to_le32(control->queue + 4); | 597 | txhdr->frame_type = cpu_to_le32(skb_get_queue_mapping(skb) + 4); |
609 | txhdr->magic4 = 0; | 598 | txhdr->magic4 = 0; |
610 | txhdr->antenna = (control->antenna_sel_tx == 0) ? | 599 | txhdr->antenna = (info->antenna_sel_tx == 0) ? |
611 | 2 : control->antenna_sel_tx - 1; | 600 | 2 : info->antenna_sel_tx - 1; |
612 | txhdr->output_power = 0x7f; // HW Maximum | 601 | txhdr->output_power = 0x7f; // HW Maximum |
613 | txhdr->magic5 = (control->flags & IEEE80211_TXCTL_NO_ACK) ? | 602 | txhdr->magic5 = (info->flags & IEEE80211_TX_CTL_NO_ACK) ? |
614 | 0 : ((rate > 0x3) ? cpu_to_le32(0x33) : cpu_to_le32(0x23)); | 603 | 0 : ((rate > 0x3) ? cpu_to_le32(0x33) : cpu_to_le32(0x23)); |
615 | if (padding) | 604 | if (padding) |
616 | txhdr->align[0] = padding; | 605 | txhdr->align[0] = padding; |
617 | 606 | ||
607 | /* modifies skb->cb and with it info, so must be last! */ | ||
608 | p54_assign_address(dev, skb, hdr, skb->len); | ||
609 | |||
618 | priv->tx(dev, hdr, skb->len, 0); | 610 | priv->tx(dev, hdr, skb->len, 0); |
619 | return 0; | 611 | return 0; |
620 | } | 612 | } |
@@ -637,7 +629,7 @@ static int p54_set_filter(struct ieee80211_hw *dev, u16 filter_type, | |||
637 | filter = (struct p54_tx_control_filter *) hdr->data; | 629 | filter = (struct p54_tx_control_filter *) hdr->data; |
638 | hdr->magic1 = cpu_to_le16(0x8001); | 630 | hdr->magic1 = cpu_to_le16(0x8001); |
639 | hdr->len = cpu_to_le16(sizeof(*filter)); | 631 | hdr->len = cpu_to_le16(sizeof(*filter)); |
640 | p54_assign_address(dev, NULL, hdr, sizeof(*hdr) + sizeof(*filter), NULL); | 632 | p54_assign_address(dev, NULL, hdr, sizeof(*hdr) + sizeof(*filter)); |
641 | hdr->type = cpu_to_le16(P54_CONTROL_TYPE_FILTER_SET); | 633 | hdr->type = cpu_to_le16(P54_CONTROL_TYPE_FILTER_SET); |
642 | 634 | ||
643 | filter->filter_type = cpu_to_le16(filter_type); | 635 | filter->filter_type = cpu_to_le16(filter_type); |
@@ -681,7 +673,7 @@ static int p54_set_freq(struct ieee80211_hw *dev, __le16 freq) | |||
681 | hdr->magic1 = cpu_to_le16(0x8001); | 673 | hdr->magic1 = cpu_to_le16(0x8001); |
682 | hdr->len = cpu_to_le16(sizeof(*chan)); | 674 | hdr->len = cpu_to_le16(sizeof(*chan)); |
683 | hdr->type = cpu_to_le16(P54_CONTROL_TYPE_CHANNEL_CHANGE); | 675 | hdr->type = cpu_to_le16(P54_CONTROL_TYPE_CHANNEL_CHANGE); |
684 | p54_assign_address(dev, NULL, hdr, sizeof(*hdr) + payload_len, NULL); | 676 | p54_assign_address(dev, NULL, hdr, sizeof(*hdr) + payload_len); |
685 | 677 | ||
686 | chan->magic1 = cpu_to_le16(0x1); | 678 | chan->magic1 = cpu_to_le16(0x1); |
687 | chan->magic2 = cpu_to_le16(0x0); | 679 | chan->magic2 = cpu_to_le16(0x0); |
@@ -754,7 +746,7 @@ static int p54_set_leds(struct ieee80211_hw *dev, int mode, int link, int act) | |||
754 | hdr->magic1 = cpu_to_le16(0x8001); | 746 | hdr->magic1 = cpu_to_le16(0x8001); |
755 | hdr->len = cpu_to_le16(sizeof(*led)); | 747 | hdr->len = cpu_to_le16(sizeof(*led)); |
756 | hdr->type = cpu_to_le16(P54_CONTROL_TYPE_LED); | 748 | hdr->type = cpu_to_le16(P54_CONTROL_TYPE_LED); |
757 | p54_assign_address(dev, NULL, hdr, sizeof(*hdr) + sizeof(*led), NULL); | 749 | p54_assign_address(dev, NULL, hdr, sizeof(*hdr) + sizeof(*led)); |
758 | 750 | ||
759 | led = (struct p54_tx_control_led *) hdr->data; | 751 | led = (struct p54_tx_control_led *) hdr->data; |
760 | led->mode = cpu_to_le16(mode); | 752 | led->mode = cpu_to_le16(mode); |
@@ -804,7 +796,7 @@ static void p54_set_vdcf(struct ieee80211_hw *dev) | |||
804 | 796 | ||
805 | hdr = (void *)priv->cached_vdcf + priv->tx_hdr_len; | 797 | hdr = (void *)priv->cached_vdcf + priv->tx_hdr_len; |
806 | 798 | ||
807 | p54_assign_address(dev, NULL, hdr, sizeof(*hdr) + sizeof(*vdcf), NULL); | 799 | p54_assign_address(dev, NULL, hdr, sizeof(*hdr) + sizeof(*vdcf)); |
808 | 800 | ||
809 | vdcf = (struct p54_tx_control_vdcf *) hdr->data; | 801 | vdcf = (struct p54_tx_control_vdcf *) hdr->data; |
810 | 802 | ||
@@ -840,12 +832,8 @@ static void p54_stop(struct ieee80211_hw *dev) | |||
840 | { | 832 | { |
841 | struct p54_common *priv = dev->priv; | 833 | struct p54_common *priv = dev->priv; |
842 | struct sk_buff *skb; | 834 | struct sk_buff *skb; |
843 | while ((skb = skb_dequeue(&priv->tx_queue))) { | 835 | while ((skb = skb_dequeue(&priv->tx_queue))) |
844 | struct memrecord *range = (struct memrecord *)&skb->cb; | ||
845 | if (range->control) | ||
846 | kfree(range->control); | ||
847 | kfree_skb(skb); | 836 | kfree_skb(skb); |
848 | } | ||
849 | priv->stop(dev); | 837 | priv->stop(dev); |
850 | priv->mode = IEEE80211_IF_TYPE_INVALID; | 838 | priv->mode = IEEE80211_IF_TYPE_INVALID; |
851 | } | 839 | } |
diff --git a/drivers/net/wireless/p54/p54common.h b/drivers/net/wireless/p54/p54common.h index c15b56e1d75e..2245fcce92dc 100644 --- a/drivers/net/wireless/p54/p54common.h +++ b/drivers/net/wireless/p54/p54common.h | |||
@@ -152,7 +152,6 @@ struct pda_pa_curve_data { | |||
152 | struct memrecord { | 152 | struct memrecord { |
153 | u32 start_addr; | 153 | u32 start_addr; |
154 | u32 end_addr; | 154 | u32 end_addr; |
155 | struct ieee80211_tx_control *control; | ||
156 | }; | 155 | }; |
157 | 156 | ||
158 | struct p54_eeprom_lm86 { | 157 | struct p54_eeprom_lm86 { |
diff --git a/drivers/net/wireless/p54/p54pci.c b/drivers/net/wireless/p54/p54pci.c index fa527723fbe0..7dd4add4bf4e 100644 --- a/drivers/net/wireless/p54/p54pci.c +++ b/drivers/net/wireless/p54/p54pci.c | |||
@@ -665,7 +665,7 @@ static int p54p_resume(struct pci_dev *pdev) | |||
665 | 665 | ||
666 | if (priv->common.mode != IEEE80211_IF_TYPE_INVALID) { | 666 | if (priv->common.mode != IEEE80211_IF_TYPE_INVALID) { |
667 | p54p_open(dev); | 667 | p54p_open(dev); |
668 | ieee80211_start_queues(dev); | 668 | ieee80211_wake_queues(dev); |
669 | } | 669 | } |
670 | 670 | ||
671 | return 0; | 671 | return 0; |
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c index d0b1fb15c709..ed310f84f28b 100644 --- a/drivers/net/wireless/rndis_wlan.c +++ b/drivers/net/wireless/rndis_wlan.c | |||
@@ -1108,7 +1108,7 @@ static int rndis_iw_get_range(struct net_device *dev, | |||
1108 | /* fill in 802.11g rates */ | 1108 | /* fill in 802.11g rates */ |
1109 | if (has_80211g_rates) { | 1109 | if (has_80211g_rates) { |
1110 | num = range->num_bitrates; | 1110 | num = range->num_bitrates; |
1111 | for (i = 0; i < sizeof(rates_80211g); i++) { | 1111 | for (i = 0; i < ARRAY_SIZE(rates_80211g); i++) { |
1112 | for (j = 0; j < num; j++) { | 1112 | for (j = 0; j < num; j++) { |
1113 | if (range->bitrate[j] == | 1113 | if (range->bitrate[j] == |
1114 | rates_80211g[i] * 1000000) | 1114 | rates_80211g[i] * 1000000) |
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c index afa565c63621..900140d3b304 100644 --- a/drivers/net/wireless/rt2x00/rt2400pci.c +++ b/drivers/net/wireless/rt2x00/rt2400pci.c | |||
@@ -620,48 +620,38 @@ static void rt2400pci_link_tuner(struct rt2x00_dev *rt2x00dev) | |||
620 | static void rt2400pci_init_rxentry(struct rt2x00_dev *rt2x00dev, | 620 | static void rt2400pci_init_rxentry(struct rt2x00_dev *rt2x00dev, |
621 | struct queue_entry *entry) | 621 | struct queue_entry *entry) |
622 | { | 622 | { |
623 | struct queue_entry_priv_pci_rx *priv_rx = entry->priv_data; | 623 | struct queue_entry_priv_pci *entry_priv = entry->priv_data; |
624 | u32 word; | 624 | u32 word; |
625 | 625 | ||
626 | rt2x00_desc_read(priv_rx->desc, 2, &word); | 626 | rt2x00_desc_read(entry_priv->desc, 2, &word); |
627 | rt2x00_set_field32(&word, RXD_W2_BUFFER_LENGTH, | 627 | rt2x00_set_field32(&word, RXD_W2_BUFFER_LENGTH, |
628 | entry->queue->data_size); | 628 | entry->queue->data_size); |
629 | rt2x00_desc_write(priv_rx->desc, 2, word); | 629 | rt2x00_desc_write(entry_priv->desc, 2, word); |
630 | 630 | ||
631 | rt2x00_desc_read(priv_rx->desc, 1, &word); | 631 | rt2x00_desc_read(entry_priv->desc, 1, &word); |
632 | rt2x00_set_field32(&word, RXD_W1_BUFFER_ADDRESS, priv_rx->data_dma); | 632 | rt2x00_set_field32(&word, RXD_W1_BUFFER_ADDRESS, entry_priv->data_dma); |
633 | rt2x00_desc_write(priv_rx->desc, 1, word); | 633 | rt2x00_desc_write(entry_priv->desc, 1, word); |
634 | 634 | ||
635 | rt2x00_desc_read(priv_rx->desc, 0, &word); | 635 | rt2x00_desc_read(entry_priv->desc, 0, &word); |
636 | rt2x00_set_field32(&word, RXD_W0_OWNER_NIC, 1); | 636 | rt2x00_set_field32(&word, RXD_W0_OWNER_NIC, 1); |
637 | rt2x00_desc_write(priv_rx->desc, 0, word); | 637 | rt2x00_desc_write(entry_priv->desc, 0, word); |
638 | } | 638 | } |
639 | 639 | ||
640 | static void rt2400pci_init_txentry(struct rt2x00_dev *rt2x00dev, | 640 | static void rt2400pci_init_txentry(struct rt2x00_dev *rt2x00dev, |
641 | struct queue_entry *entry) | 641 | struct queue_entry *entry) |
642 | { | 642 | { |
643 | struct queue_entry_priv_pci_tx *priv_tx = entry->priv_data; | 643 | struct queue_entry_priv_pci *entry_priv = entry->priv_data; |
644 | u32 word; | 644 | u32 word; |
645 | 645 | ||
646 | rt2x00_desc_read(priv_tx->desc, 1, &word); | 646 | rt2x00_desc_read(entry_priv->desc, 0, &word); |
647 | rt2x00_set_field32(&word, TXD_W1_BUFFER_ADDRESS, priv_tx->data_dma); | ||
648 | rt2x00_desc_write(priv_tx->desc, 1, word); | ||
649 | |||
650 | rt2x00_desc_read(priv_tx->desc, 2, &word); | ||
651 | rt2x00_set_field32(&word, TXD_W2_BUFFER_LENGTH, | ||
652 | entry->queue->data_size); | ||
653 | rt2x00_desc_write(priv_tx->desc, 2, word); | ||
654 | |||
655 | rt2x00_desc_read(priv_tx->desc, 0, &word); | ||
656 | rt2x00_set_field32(&word, TXD_W0_VALID, 0); | 647 | rt2x00_set_field32(&word, TXD_W0_VALID, 0); |
657 | rt2x00_set_field32(&word, TXD_W0_OWNER_NIC, 0); | 648 | rt2x00_set_field32(&word, TXD_W0_OWNER_NIC, 0); |
658 | rt2x00_desc_write(priv_tx->desc, 0, word); | 649 | rt2x00_desc_write(entry_priv->desc, 0, word); |
659 | } | 650 | } |
660 | 651 | ||
661 | static int rt2400pci_init_queues(struct rt2x00_dev *rt2x00dev) | 652 | static int rt2400pci_init_queues(struct rt2x00_dev *rt2x00dev) |
662 | { | 653 | { |
663 | struct queue_entry_priv_pci_rx *priv_rx; | 654 | struct queue_entry_priv_pci *entry_priv; |
664 | struct queue_entry_priv_pci_tx *priv_tx; | ||
665 | u32 reg; | 655 | u32 reg; |
666 | 656 | ||
667 | /* | 657 | /* |
@@ -674,28 +664,28 @@ static int rt2400pci_init_queues(struct rt2x00_dev *rt2x00dev) | |||
674 | rt2x00_set_field32(®, TXCSR2_NUM_PRIO, rt2x00dev->tx[0].limit); | 664 | rt2x00_set_field32(®, TXCSR2_NUM_PRIO, rt2x00dev->tx[0].limit); |
675 | rt2x00pci_register_write(rt2x00dev, TXCSR2, reg); | 665 | rt2x00pci_register_write(rt2x00dev, TXCSR2, reg); |
676 | 666 | ||
677 | priv_tx = rt2x00dev->tx[1].entries[0].priv_data; | 667 | entry_priv = rt2x00dev->tx[1].entries[0].priv_data; |
678 | rt2x00pci_register_read(rt2x00dev, TXCSR3, ®); | 668 | rt2x00pci_register_read(rt2x00dev, TXCSR3, ®); |
679 | rt2x00_set_field32(®, TXCSR3_TX_RING_REGISTER, | 669 | rt2x00_set_field32(®, TXCSR3_TX_RING_REGISTER, |
680 | priv_tx->desc_dma); | 670 | entry_priv->desc_dma); |
681 | rt2x00pci_register_write(rt2x00dev, TXCSR3, reg); | 671 | rt2x00pci_register_write(rt2x00dev, TXCSR3, reg); |
682 | 672 | ||
683 | priv_tx = rt2x00dev->tx[0].entries[0].priv_data; | 673 | entry_priv = rt2x00dev->tx[0].entries[0].priv_data; |
684 | rt2x00pci_register_read(rt2x00dev, TXCSR5, ®); | 674 | rt2x00pci_register_read(rt2x00dev, TXCSR5, ®); |
685 | rt2x00_set_field32(®, TXCSR5_PRIO_RING_REGISTER, | 675 | rt2x00_set_field32(®, TXCSR5_PRIO_RING_REGISTER, |
686 | priv_tx->desc_dma); | 676 | entry_priv->desc_dma); |
687 | rt2x00pci_register_write(rt2x00dev, TXCSR5, reg); | 677 | rt2x00pci_register_write(rt2x00dev, TXCSR5, reg); |
688 | 678 | ||
689 | priv_tx = rt2x00dev->bcn[1].entries[0].priv_data; | 679 | entry_priv = rt2x00dev->bcn[1].entries[0].priv_data; |
690 | rt2x00pci_register_read(rt2x00dev, TXCSR4, ®); | 680 | rt2x00pci_register_read(rt2x00dev, TXCSR4, ®); |
691 | rt2x00_set_field32(®, TXCSR4_ATIM_RING_REGISTER, | 681 | rt2x00_set_field32(®, TXCSR4_ATIM_RING_REGISTER, |
692 | priv_tx->desc_dma); | 682 | entry_priv->desc_dma); |
693 | rt2x00pci_register_write(rt2x00dev, TXCSR4, reg); | 683 | rt2x00pci_register_write(rt2x00dev, TXCSR4, reg); |
694 | 684 | ||
695 | priv_tx = rt2x00dev->bcn[0].entries[0].priv_data; | 685 | entry_priv = rt2x00dev->bcn[0].entries[0].priv_data; |
696 | rt2x00pci_register_read(rt2x00dev, TXCSR6, ®); | 686 | rt2x00pci_register_read(rt2x00dev, TXCSR6, ®); |
697 | rt2x00_set_field32(®, TXCSR6_BEACON_RING_REGISTER, | 687 | rt2x00_set_field32(®, TXCSR6_BEACON_RING_REGISTER, |
698 | priv_tx->desc_dma); | 688 | entry_priv->desc_dma); |
699 | rt2x00pci_register_write(rt2x00dev, TXCSR6, reg); | 689 | rt2x00pci_register_write(rt2x00dev, TXCSR6, reg); |
700 | 690 | ||
701 | rt2x00pci_register_read(rt2x00dev, RXCSR1, ®); | 691 | rt2x00pci_register_read(rt2x00dev, RXCSR1, ®); |
@@ -703,9 +693,10 @@ static int rt2400pci_init_queues(struct rt2x00_dev *rt2x00dev) | |||
703 | rt2x00_set_field32(®, RXCSR1_NUM_RXD, rt2x00dev->rx->limit); | 693 | rt2x00_set_field32(®, RXCSR1_NUM_RXD, rt2x00dev->rx->limit); |
704 | rt2x00pci_register_write(rt2x00dev, RXCSR1, reg); | 694 | rt2x00pci_register_write(rt2x00dev, RXCSR1, reg); |
705 | 695 | ||
706 | priv_rx = rt2x00dev->rx->entries[0].priv_data; | 696 | entry_priv = rt2x00dev->rx->entries[0].priv_data; |
707 | rt2x00pci_register_read(rt2x00dev, RXCSR2, ®); | 697 | rt2x00pci_register_read(rt2x00dev, RXCSR2, ®); |
708 | rt2x00_set_field32(®, RXCSR2_RX_RING_REGISTER, priv_rx->desc_dma); | 698 | rt2x00_set_field32(®, RXCSR2_RX_RING_REGISTER, |
699 | entry_priv->desc_dma); | ||
709 | rt2x00pci_register_write(rt2x00dev, RXCSR2, reg); | 700 | rt2x00pci_register_write(rt2x00dev, RXCSR2, reg); |
710 | 701 | ||
711 | return 0; | 702 | return 0; |
@@ -1001,17 +992,22 @@ static int rt2400pci_set_device_state(struct rt2x00_dev *rt2x00dev, | |||
1001 | */ | 992 | */ |
1002 | static void rt2400pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, | 993 | static void rt2400pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, |
1003 | struct sk_buff *skb, | 994 | struct sk_buff *skb, |
1004 | struct txentry_desc *txdesc, | 995 | struct txentry_desc *txdesc) |
1005 | struct ieee80211_tx_control *control) | ||
1006 | { | 996 | { |
1007 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb); | 997 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb); |
998 | struct queue_entry_priv_pci *entry_priv = skbdesc->entry->priv_data; | ||
1008 | __le32 *txd = skbdesc->desc; | 999 | __le32 *txd = skbdesc->desc; |
1009 | u32 word; | 1000 | u32 word; |
1010 | 1001 | ||
1011 | /* | 1002 | /* |
1012 | * Start writing the descriptor words. | 1003 | * Start writing the descriptor words. |
1013 | */ | 1004 | */ |
1005 | rt2x00_desc_read(entry_priv->desc, 1, &word); | ||
1006 | rt2x00_set_field32(&word, TXD_W1_BUFFER_ADDRESS, entry_priv->data_dma); | ||
1007 | rt2x00_desc_write(entry_priv->desc, 1, word); | ||
1008 | |||
1014 | rt2x00_desc_read(txd, 2, &word); | 1009 | rt2x00_desc_read(txd, 2, &word); |
1010 | rt2x00_set_field32(&word, TXD_W2_BUFFER_LENGTH, skbdesc->data_len); | ||
1015 | rt2x00_set_field32(&word, TXD_W2_DATABYTE_COUNT, skbdesc->data_len); | 1011 | rt2x00_set_field32(&word, TXD_W2_DATABYTE_COUNT, skbdesc->data_len); |
1016 | rt2x00_desc_write(txd, 2, word); | 1012 | rt2x00_desc_write(txd, 2, word); |
1017 | 1013 | ||
@@ -1046,8 +1042,7 @@ static void rt2400pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, | |||
1046 | test_bit(ENTRY_TXD_RTS_FRAME, &txdesc->flags)); | 1042 | test_bit(ENTRY_TXD_RTS_FRAME, &txdesc->flags)); |
1047 | rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs); | 1043 | rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs); |
1048 | rt2x00_set_field32(&word, TXD_W0_RETRY_MODE, | 1044 | rt2x00_set_field32(&word, TXD_W0_RETRY_MODE, |
1049 | !!(control->flags & | 1045 | test_bit(ENTRY_TXD_RETRY_MODE, &txdesc->flags)); |
1050 | IEEE80211_TXCTL_LONG_RETRY_LIMIT)); | ||
1051 | rt2x00_desc_write(txd, 0, word); | 1046 | rt2x00_desc_write(txd, 0, word); |
1052 | } | 1047 | } |
1053 | 1048 | ||
@@ -1083,16 +1078,15 @@ static void rt2400pci_kick_tx_queue(struct rt2x00_dev *rt2x00dev, | |||
1083 | static void rt2400pci_fill_rxdone(struct queue_entry *entry, | 1078 | static void rt2400pci_fill_rxdone(struct queue_entry *entry, |
1084 | struct rxdone_entry_desc *rxdesc) | 1079 | struct rxdone_entry_desc *rxdesc) |
1085 | { | 1080 | { |
1086 | struct queue_entry_priv_pci_rx *priv_rx = entry->priv_data; | 1081 | struct queue_entry_priv_pci *entry_priv = entry->priv_data; |
1087 | u32 word0; | 1082 | u32 word0; |
1088 | u32 word2; | 1083 | u32 word2; |
1089 | u32 word3; | 1084 | u32 word3; |
1090 | 1085 | ||
1091 | rt2x00_desc_read(priv_rx->desc, 0, &word0); | 1086 | rt2x00_desc_read(entry_priv->desc, 0, &word0); |
1092 | rt2x00_desc_read(priv_rx->desc, 2, &word2); | 1087 | rt2x00_desc_read(entry_priv->desc, 2, &word2); |
1093 | rt2x00_desc_read(priv_rx->desc, 3, &word3); | 1088 | rt2x00_desc_read(entry_priv->desc, 3, &word3); |
1094 | 1089 | ||
1095 | rxdesc->flags = 0; | ||
1096 | if (rt2x00_get_field32(word0, RXD_W0_CRC_ERROR)) | 1090 | if (rt2x00_get_field32(word0, RXD_W0_CRC_ERROR)) |
1097 | rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC; | 1091 | rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC; |
1098 | if (rt2x00_get_field32(word0, RXD_W0_PHYSICAL_ERROR)) | 1092 | if (rt2x00_get_field32(word0, RXD_W0_PHYSICAL_ERROR)) |
@@ -1108,7 +1102,7 @@ static void rt2400pci_fill_rxdone(struct queue_entry *entry, | |||
1108 | entry->queue->rt2x00dev->rssi_offset; | 1102 | entry->queue->rt2x00dev->rssi_offset; |
1109 | rxdesc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT); | 1103 | rxdesc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT); |
1110 | 1104 | ||
1111 | rxdesc->dev_flags = RXDONE_SIGNAL_PLCP; | 1105 | rxdesc->dev_flags |= RXDONE_SIGNAL_PLCP; |
1112 | if (rt2x00_get_field32(word0, RXD_W0_MY_BSS)) | 1106 | if (rt2x00_get_field32(word0, RXD_W0_MY_BSS)) |
1113 | rxdesc->dev_flags |= RXDONE_MY_BSS; | 1107 | rxdesc->dev_flags |= RXDONE_MY_BSS; |
1114 | } | 1108 | } |
@@ -1120,15 +1114,15 @@ static void rt2400pci_txdone(struct rt2x00_dev *rt2x00dev, | |||
1120 | const enum data_queue_qid queue_idx) | 1114 | const enum data_queue_qid queue_idx) |
1121 | { | 1115 | { |
1122 | struct data_queue *queue = rt2x00queue_get_queue(rt2x00dev, queue_idx); | 1116 | struct data_queue *queue = rt2x00queue_get_queue(rt2x00dev, queue_idx); |
1123 | struct queue_entry_priv_pci_tx *priv_tx; | 1117 | struct queue_entry_priv_pci *entry_priv; |
1124 | struct queue_entry *entry; | 1118 | struct queue_entry *entry; |
1125 | struct txdone_entry_desc txdesc; | 1119 | struct txdone_entry_desc txdesc; |
1126 | u32 word; | 1120 | u32 word; |
1127 | 1121 | ||
1128 | while (!rt2x00queue_empty(queue)) { | 1122 | while (!rt2x00queue_empty(queue)) { |
1129 | entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE); | 1123 | entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE); |
1130 | priv_tx = entry->priv_data; | 1124 | entry_priv = entry->priv_data; |
1131 | rt2x00_desc_read(priv_tx->desc, 0, &word); | 1125 | rt2x00_desc_read(entry_priv->desc, 0, &word); |
1132 | 1126 | ||
1133 | if (rt2x00_get_field32(word, TXD_W0_OWNER_NIC) || | 1127 | if (rt2x00_get_field32(word, TXD_W0_OWNER_NIC) || |
1134 | !rt2x00_get_field32(word, TXD_W0_VALID)) | 1128 | !rt2x00_get_field32(word, TXD_W0_VALID)) |
@@ -1137,7 +1131,18 @@ static void rt2400pci_txdone(struct rt2x00_dev *rt2x00dev, | |||
1137 | /* | 1131 | /* |
1138 | * Obtain the status about this packet. | 1132 | * Obtain the status about this packet. |
1139 | */ | 1133 | */ |
1140 | txdesc.status = rt2x00_get_field32(word, TXD_W0_RESULT); | 1134 | txdesc.flags = 0; |
1135 | switch (rt2x00_get_field32(word, TXD_W0_RESULT)) { | ||
1136 | case 0: /* Success */ | ||
1137 | case 1: /* Success with retry */ | ||
1138 | __set_bit(TXDONE_SUCCESS, &txdesc.flags); | ||
1139 | break; | ||
1140 | case 2: /* Failure, excessive retries */ | ||
1141 | __set_bit(TXDONE_EXCESSIVE_RETRY, &txdesc.flags); | ||
1142 | /* Don't break, this is a failed frame! */ | ||
1143 | default: /* Failure */ | ||
1144 | __set_bit(TXDONE_FAILURE, &txdesc.flags); | ||
1145 | } | ||
1141 | txdesc.retry = rt2x00_get_field32(word, TXD_W0_RETRY_COUNT); | 1146 | txdesc.retry = rt2x00_get_field32(word, TXD_W0_RETRY_COUNT); |
1142 | 1147 | ||
1143 | rt2x00pci_txdone(rt2x00dev, entry, &txdesc); | 1148 | rt2x00pci_txdone(rt2x00dev, entry, &txdesc); |
@@ -1364,7 +1369,6 @@ static void rt2400pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev) | |||
1364 | rt2x00dev->hw->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | | 1369 | rt2x00dev->hw->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | |
1365 | IEEE80211_HW_SIGNAL_DBM; | 1370 | IEEE80211_HW_SIGNAL_DBM; |
1366 | rt2x00dev->hw->extra_tx_headroom = 0; | 1371 | rt2x00dev->hw->extra_tx_headroom = 0; |
1367 | rt2x00dev->hw->queues = 2; | ||
1368 | 1372 | ||
1369 | SET_IEEE80211_DEV(rt2x00dev->hw, &rt2x00dev_pci(rt2x00dev)->dev); | 1373 | SET_IEEE80211_DEV(rt2x00dev->hw, &rt2x00dev_pci(rt2x00dev)->dev); |
1370 | SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, | 1374 | SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, |
@@ -1480,18 +1484,27 @@ static u64 rt2400pci_get_tsf(struct ieee80211_hw *hw) | |||
1480 | return tsf; | 1484 | return tsf; |
1481 | } | 1485 | } |
1482 | 1486 | ||
1483 | static int rt2400pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb, | 1487 | static int rt2400pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb) |
1484 | struct ieee80211_tx_control *control) | ||
1485 | { | 1488 | { |
1486 | struct rt2x00_dev *rt2x00dev = hw->priv; | 1489 | struct rt2x00_dev *rt2x00dev = hw->priv; |
1487 | struct rt2x00_intf *intf = vif_to_intf(control->vif); | 1490 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); |
1488 | struct queue_entry_priv_pci_tx *priv_tx; | 1491 | struct rt2x00_intf *intf = vif_to_intf(tx_info->control.vif); |
1492 | struct queue_entry_priv_pci *entry_priv; | ||
1489 | struct skb_frame_desc *skbdesc; | 1493 | struct skb_frame_desc *skbdesc; |
1494 | struct txentry_desc txdesc; | ||
1490 | u32 reg; | 1495 | u32 reg; |
1491 | 1496 | ||
1492 | if (unlikely(!intf->beacon)) | 1497 | if (unlikely(!intf->beacon)) |
1493 | return -ENOBUFS; | 1498 | return -ENOBUFS; |
1494 | priv_tx = intf->beacon->priv_data; | 1499 | entry_priv = intf->beacon->priv_data; |
1500 | |||
1501 | /* | ||
1502 | * Copy all TX descriptor information into txdesc, | ||
1503 | * after that we are free to use the skb->cb array | ||
1504 | * for our information. | ||
1505 | */ | ||
1506 | intf->beacon->skb = skb; | ||
1507 | rt2x00queue_create_tx_descriptor(intf->beacon, &txdesc); | ||
1495 | 1508 | ||
1496 | /* | 1509 | /* |
1497 | * Fill in skb descriptor | 1510 | * Fill in skb descriptor |
@@ -1501,7 +1514,7 @@ static int rt2400pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
1501 | skbdesc->flags |= FRAME_DESC_DRIVER_GENERATED; | 1514 | skbdesc->flags |= FRAME_DESC_DRIVER_GENERATED; |
1502 | skbdesc->data = skb->data; | 1515 | skbdesc->data = skb->data; |
1503 | skbdesc->data_len = skb->len; | 1516 | skbdesc->data_len = skb->len; |
1504 | skbdesc->desc = priv_tx->desc; | 1517 | skbdesc->desc = entry_priv->desc; |
1505 | skbdesc->desc_len = intf->beacon->queue->desc_size; | 1518 | skbdesc->desc_len = intf->beacon->queue->desc_size; |
1506 | skbdesc->entry = intf->beacon; | 1519 | skbdesc->entry = intf->beacon; |
1507 | 1520 | ||
@@ -1520,8 +1533,8 @@ static int rt2400pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
1520 | * Write entire beacon with descriptor to register, | 1533 | * Write entire beacon with descriptor to register, |
1521 | * and kick the beacon generator. | 1534 | * and kick the beacon generator. |
1522 | */ | 1535 | */ |
1523 | rt2x00lib_write_tx_desc(rt2x00dev, skb, control); | 1536 | memcpy(entry_priv->data, skb->data, skb->len); |
1524 | memcpy(priv_tx->data, skb->data, skb->len); | 1537 | rt2x00queue_write_tx_descriptor(intf->beacon, &txdesc); |
1525 | rt2x00dev->ops->lib->kick_tx_queue(rt2x00dev, QID_BEACON); | 1538 | rt2x00dev->ops->lib->kick_tx_queue(rt2x00dev, QID_BEACON); |
1526 | 1539 | ||
1527 | return 0; | 1540 | return 0; |
@@ -1581,28 +1594,28 @@ static const struct data_queue_desc rt2400pci_queue_rx = { | |||
1581 | .entry_num = RX_ENTRIES, | 1594 | .entry_num = RX_ENTRIES, |
1582 | .data_size = DATA_FRAME_SIZE, | 1595 | .data_size = DATA_FRAME_SIZE, |
1583 | .desc_size = RXD_DESC_SIZE, | 1596 | .desc_size = RXD_DESC_SIZE, |
1584 | .priv_size = sizeof(struct queue_entry_priv_pci_rx), | 1597 | .priv_size = sizeof(struct queue_entry_priv_pci), |
1585 | }; | 1598 | }; |
1586 | 1599 | ||
1587 | static const struct data_queue_desc rt2400pci_queue_tx = { | 1600 | static const struct data_queue_desc rt2400pci_queue_tx = { |
1588 | .entry_num = TX_ENTRIES, | 1601 | .entry_num = TX_ENTRIES, |
1589 | .data_size = DATA_FRAME_SIZE, | 1602 | .data_size = DATA_FRAME_SIZE, |
1590 | .desc_size = TXD_DESC_SIZE, | 1603 | .desc_size = TXD_DESC_SIZE, |
1591 | .priv_size = sizeof(struct queue_entry_priv_pci_tx), | 1604 | .priv_size = sizeof(struct queue_entry_priv_pci), |
1592 | }; | 1605 | }; |
1593 | 1606 | ||
1594 | static const struct data_queue_desc rt2400pci_queue_bcn = { | 1607 | static const struct data_queue_desc rt2400pci_queue_bcn = { |
1595 | .entry_num = BEACON_ENTRIES, | 1608 | .entry_num = BEACON_ENTRIES, |
1596 | .data_size = MGMT_FRAME_SIZE, | 1609 | .data_size = MGMT_FRAME_SIZE, |
1597 | .desc_size = TXD_DESC_SIZE, | 1610 | .desc_size = TXD_DESC_SIZE, |
1598 | .priv_size = sizeof(struct queue_entry_priv_pci_tx), | 1611 | .priv_size = sizeof(struct queue_entry_priv_pci), |
1599 | }; | 1612 | }; |
1600 | 1613 | ||
1601 | static const struct data_queue_desc rt2400pci_queue_atim = { | 1614 | static const struct data_queue_desc rt2400pci_queue_atim = { |
1602 | .entry_num = ATIM_ENTRIES, | 1615 | .entry_num = ATIM_ENTRIES, |
1603 | .data_size = DATA_FRAME_SIZE, | 1616 | .data_size = DATA_FRAME_SIZE, |
1604 | .desc_size = TXD_DESC_SIZE, | 1617 | .desc_size = TXD_DESC_SIZE, |
1605 | .priv_size = sizeof(struct queue_entry_priv_pci_tx), | 1618 | .priv_size = sizeof(struct queue_entry_priv_pci), |
1606 | }; | 1619 | }; |
1607 | 1620 | ||
1608 | static const struct rt2x00_ops rt2400pci_ops = { | 1621 | static const struct rt2x00_ops rt2400pci_ops = { |
@@ -1611,6 +1624,7 @@ static const struct rt2x00_ops rt2400pci_ops = { | |||
1611 | .max_ap_intf = 1, | 1624 | .max_ap_intf = 1, |
1612 | .eeprom_size = EEPROM_SIZE, | 1625 | .eeprom_size = EEPROM_SIZE, |
1613 | .rf_size = RF_SIZE, | 1626 | .rf_size = RF_SIZE, |
1627 | .tx_queues = NUM_TX_QUEUES, | ||
1614 | .rx = &rt2400pci_queue_rx, | 1628 | .rx = &rt2400pci_queue_rx, |
1615 | .tx = &rt2400pci_queue_tx, | 1629 | .tx = &rt2400pci_queue_tx, |
1616 | .bcn = &rt2400pci_queue_bcn, | 1630 | .bcn = &rt2400pci_queue_bcn, |
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.h b/drivers/net/wireless/rt2x00/rt2400pci.h index a5210f9a3360..e9aa326be9f6 100644 --- a/drivers/net/wireless/rt2x00/rt2400pci.h +++ b/drivers/net/wireless/rt2x00/rt2400pci.h | |||
@@ -52,6 +52,11 @@ | |||
52 | #define RF_SIZE 0x0010 | 52 | #define RF_SIZE 0x0010 |
53 | 53 | ||
54 | /* | 54 | /* |
55 | * Number of TX queues. | ||
56 | */ | ||
57 | #define NUM_TX_QUEUES 2 | ||
58 | |||
59 | /* | ||
55 | * Control/Status Registers(CSR). | 60 | * Control/Status Registers(CSR). |
56 | * Some values are set in TU, whereas 1 TU == 1024 us. | 61 | * Some values are set in TU, whereas 1 TU == 1024 us. |
57 | */ | 62 | */ |
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c index c06f1b5e5887..673350953b89 100644 --- a/drivers/net/wireless/rt2x00/rt2500pci.c +++ b/drivers/net/wireless/rt2x00/rt2500pci.c | |||
@@ -715,38 +715,33 @@ dynamic_cca_tune: | |||
715 | static void rt2500pci_init_rxentry(struct rt2x00_dev *rt2x00dev, | 715 | static void rt2500pci_init_rxentry(struct rt2x00_dev *rt2x00dev, |
716 | struct queue_entry *entry) | 716 | struct queue_entry *entry) |
717 | { | 717 | { |
718 | struct queue_entry_priv_pci_rx *priv_rx = entry->priv_data; | 718 | struct queue_entry_priv_pci *entry_priv = entry->priv_data; |
719 | u32 word; | 719 | u32 word; |
720 | 720 | ||
721 | rt2x00_desc_read(priv_rx->desc, 1, &word); | 721 | rt2x00_desc_read(entry_priv->desc, 1, &word); |
722 | rt2x00_set_field32(&word, RXD_W1_BUFFER_ADDRESS, priv_rx->data_dma); | 722 | rt2x00_set_field32(&word, RXD_W1_BUFFER_ADDRESS, entry_priv->data_dma); |
723 | rt2x00_desc_write(priv_rx->desc, 1, word); | 723 | rt2x00_desc_write(entry_priv->desc, 1, word); |
724 | 724 | ||
725 | rt2x00_desc_read(priv_rx->desc, 0, &word); | 725 | rt2x00_desc_read(entry_priv->desc, 0, &word); |
726 | rt2x00_set_field32(&word, RXD_W0_OWNER_NIC, 1); | 726 | rt2x00_set_field32(&word, RXD_W0_OWNER_NIC, 1); |
727 | rt2x00_desc_write(priv_rx->desc, 0, word); | 727 | rt2x00_desc_write(entry_priv->desc, 0, word); |
728 | } | 728 | } |
729 | 729 | ||
730 | static void rt2500pci_init_txentry(struct rt2x00_dev *rt2x00dev, | 730 | static void rt2500pci_init_txentry(struct rt2x00_dev *rt2x00dev, |
731 | struct queue_entry *entry) | 731 | struct queue_entry *entry) |
732 | { | 732 | { |
733 | struct queue_entry_priv_pci_tx *priv_tx = entry->priv_data; | 733 | struct queue_entry_priv_pci *entry_priv = entry->priv_data; |
734 | u32 word; | 734 | u32 word; |
735 | 735 | ||
736 | rt2x00_desc_read(priv_tx->desc, 1, &word); | 736 | rt2x00_desc_read(entry_priv->desc, 0, &word); |
737 | rt2x00_set_field32(&word, TXD_W1_BUFFER_ADDRESS, priv_tx->data_dma); | ||
738 | rt2x00_desc_write(priv_tx->desc, 1, word); | ||
739 | |||
740 | rt2x00_desc_read(priv_tx->desc, 0, &word); | ||
741 | rt2x00_set_field32(&word, TXD_W0_VALID, 0); | 737 | rt2x00_set_field32(&word, TXD_W0_VALID, 0); |
742 | rt2x00_set_field32(&word, TXD_W0_OWNER_NIC, 0); | 738 | rt2x00_set_field32(&word, TXD_W0_OWNER_NIC, 0); |
743 | rt2x00_desc_write(priv_tx->desc, 0, word); | 739 | rt2x00_desc_write(entry_priv->desc, 0, word); |
744 | } | 740 | } |
745 | 741 | ||
746 | static int rt2500pci_init_queues(struct rt2x00_dev *rt2x00dev) | 742 | static int rt2500pci_init_queues(struct rt2x00_dev *rt2x00dev) |
747 | { | 743 | { |
748 | struct queue_entry_priv_pci_rx *priv_rx; | 744 | struct queue_entry_priv_pci *entry_priv; |
749 | struct queue_entry_priv_pci_tx *priv_tx; | ||
750 | u32 reg; | 745 | u32 reg; |
751 | 746 | ||
752 | /* | 747 | /* |
@@ -759,28 +754,28 @@ static int rt2500pci_init_queues(struct rt2x00_dev *rt2x00dev) | |||
759 | rt2x00_set_field32(®, TXCSR2_NUM_PRIO, rt2x00dev->tx[0].limit); | 754 | rt2x00_set_field32(®, TXCSR2_NUM_PRIO, rt2x00dev->tx[0].limit); |
760 | rt2x00pci_register_write(rt2x00dev, TXCSR2, reg); | 755 | rt2x00pci_register_write(rt2x00dev, TXCSR2, reg); |
761 | 756 | ||
762 | priv_tx = rt2x00dev->tx[1].entries[0].priv_data; | 757 | entry_priv = rt2x00dev->tx[1].entries[0].priv_data; |
763 | rt2x00pci_register_read(rt2x00dev, TXCSR3, ®); | 758 | rt2x00pci_register_read(rt2x00dev, TXCSR3, ®); |
764 | rt2x00_set_field32(®, TXCSR3_TX_RING_REGISTER, | 759 | rt2x00_set_field32(®, TXCSR3_TX_RING_REGISTER, |
765 | priv_tx->desc_dma); | 760 | entry_priv->desc_dma); |
766 | rt2x00pci_register_write(rt2x00dev, TXCSR3, reg); | 761 | rt2x00pci_register_write(rt2x00dev, TXCSR3, reg); |
767 | 762 | ||
768 | priv_tx = rt2x00dev->tx[0].entries[0].priv_data; | 763 | entry_priv = rt2x00dev->tx[0].entries[0].priv_data; |
769 | rt2x00pci_register_read(rt2x00dev, TXCSR5, ®); | 764 | rt2x00pci_register_read(rt2x00dev, TXCSR5, ®); |
770 | rt2x00_set_field32(®, TXCSR5_PRIO_RING_REGISTER, | 765 | rt2x00_set_field32(®, TXCSR5_PRIO_RING_REGISTER, |
771 | priv_tx->desc_dma); | 766 | entry_priv->desc_dma); |
772 | rt2x00pci_register_write(rt2x00dev, TXCSR5, reg); | 767 | rt2x00pci_register_write(rt2x00dev, TXCSR5, reg); |
773 | 768 | ||
774 | priv_tx = rt2x00dev->bcn[1].entries[0].priv_data; | 769 | entry_priv = rt2x00dev->bcn[1].entries[0].priv_data; |
775 | rt2x00pci_register_read(rt2x00dev, TXCSR4, ®); | 770 | rt2x00pci_register_read(rt2x00dev, TXCSR4, ®); |
776 | rt2x00_set_field32(®, TXCSR4_ATIM_RING_REGISTER, | 771 | rt2x00_set_field32(®, TXCSR4_ATIM_RING_REGISTER, |
777 | priv_tx->desc_dma); | 772 | entry_priv->desc_dma); |
778 | rt2x00pci_register_write(rt2x00dev, TXCSR4, reg); | 773 | rt2x00pci_register_write(rt2x00dev, TXCSR4, reg); |
779 | 774 | ||
780 | priv_tx = rt2x00dev->bcn[0].entries[0].priv_data; | 775 | entry_priv = rt2x00dev->bcn[0].entries[0].priv_data; |
781 | rt2x00pci_register_read(rt2x00dev, TXCSR6, ®); | 776 | rt2x00pci_register_read(rt2x00dev, TXCSR6, ®); |
782 | rt2x00_set_field32(®, TXCSR6_BEACON_RING_REGISTER, | 777 | rt2x00_set_field32(®, TXCSR6_BEACON_RING_REGISTER, |
783 | priv_tx->desc_dma); | 778 | entry_priv->desc_dma); |
784 | rt2x00pci_register_write(rt2x00dev, TXCSR6, reg); | 779 | rt2x00pci_register_write(rt2x00dev, TXCSR6, reg); |
785 | 780 | ||
786 | rt2x00pci_register_read(rt2x00dev, RXCSR1, ®); | 781 | rt2x00pci_register_read(rt2x00dev, RXCSR1, ®); |
@@ -788,9 +783,10 @@ static int rt2500pci_init_queues(struct rt2x00_dev *rt2x00dev) | |||
788 | rt2x00_set_field32(®, RXCSR1_NUM_RXD, rt2x00dev->rx->limit); | 783 | rt2x00_set_field32(®, RXCSR1_NUM_RXD, rt2x00dev->rx->limit); |
789 | rt2x00pci_register_write(rt2x00dev, RXCSR1, reg); | 784 | rt2x00pci_register_write(rt2x00dev, RXCSR1, reg); |
790 | 785 | ||
791 | priv_rx = rt2x00dev->rx->entries[0].priv_data; | 786 | entry_priv = rt2x00dev->rx->entries[0].priv_data; |
792 | rt2x00pci_register_read(rt2x00dev, RXCSR2, ®); | 787 | rt2x00pci_register_read(rt2x00dev, RXCSR2, ®); |
793 | rt2x00_set_field32(®, RXCSR2_RX_RING_REGISTER, priv_rx->desc_dma); | 788 | rt2x00_set_field32(®, RXCSR2_RX_RING_REGISTER, |
789 | entry_priv->desc_dma); | ||
794 | rt2x00pci_register_write(rt2x00dev, RXCSR2, reg); | 790 | rt2x00pci_register_write(rt2x00dev, RXCSR2, reg); |
795 | 791 | ||
796 | return 0; | 792 | return 0; |
@@ -1155,16 +1151,20 @@ static int rt2500pci_set_device_state(struct rt2x00_dev *rt2x00dev, | |||
1155 | */ | 1151 | */ |
1156 | static void rt2500pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, | 1152 | static void rt2500pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, |
1157 | struct sk_buff *skb, | 1153 | struct sk_buff *skb, |
1158 | struct txentry_desc *txdesc, | 1154 | struct txentry_desc *txdesc) |
1159 | struct ieee80211_tx_control *control) | ||
1160 | { | 1155 | { |
1161 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb); | 1156 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb); |
1157 | struct queue_entry_priv_pci *entry_priv = skbdesc->entry->priv_data; | ||
1162 | __le32 *txd = skbdesc->desc; | 1158 | __le32 *txd = skbdesc->desc; |
1163 | u32 word; | 1159 | u32 word; |
1164 | 1160 | ||
1165 | /* | 1161 | /* |
1166 | * Start writing the descriptor words. | 1162 | * Start writing the descriptor words. |
1167 | */ | 1163 | */ |
1164 | rt2x00_desc_read(entry_priv->desc, 1, &word); | ||
1165 | rt2x00_set_field32(&word, TXD_W1_BUFFER_ADDRESS, entry_priv->data_dma); | ||
1166 | rt2x00_desc_write(entry_priv->desc, 1, word); | ||
1167 | |||
1168 | rt2x00_desc_read(txd, 2, &word); | 1168 | rt2x00_desc_read(txd, 2, &word); |
1169 | rt2x00_set_field32(&word, TXD_W2_IV_OFFSET, IEEE80211_HEADER); | 1169 | rt2x00_set_field32(&word, TXD_W2_IV_OFFSET, IEEE80211_HEADER); |
1170 | rt2x00_set_field32(&word, TXD_W2_AIFS, txdesc->aifs); | 1170 | rt2x00_set_field32(&word, TXD_W2_AIFS, txdesc->aifs); |
@@ -1198,9 +1198,7 @@ static void rt2500pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, | |||
1198 | rt2x00_set_field32(&word, TXD_W0_CIPHER_OWNER, 1); | 1198 | rt2x00_set_field32(&word, TXD_W0_CIPHER_OWNER, 1); |
1199 | rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs); | 1199 | rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs); |
1200 | rt2x00_set_field32(&word, TXD_W0_RETRY_MODE, | 1200 | rt2x00_set_field32(&word, TXD_W0_RETRY_MODE, |
1201 | !!(control->flags & | 1201 | test_bit(ENTRY_TXD_RETRY_MODE, &txdesc->flags)); |
1202 | IEEE80211_TXCTL_LONG_RETRY_LIMIT)); | ||
1203 | rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, skbdesc->data_len); | ||
1204 | rt2x00_set_field32(&word, TXD_W0_CIPHER_ALG, CIPHER_NONE); | 1202 | rt2x00_set_field32(&word, TXD_W0_CIPHER_ALG, CIPHER_NONE); |
1205 | rt2x00_desc_write(txd, 0, word); | 1203 | rt2x00_desc_write(txd, 0, word); |
1206 | } | 1204 | } |
@@ -1237,14 +1235,13 @@ static void rt2500pci_kick_tx_queue(struct rt2x00_dev *rt2x00dev, | |||
1237 | static void rt2500pci_fill_rxdone(struct queue_entry *entry, | 1235 | static void rt2500pci_fill_rxdone(struct queue_entry *entry, |
1238 | struct rxdone_entry_desc *rxdesc) | 1236 | struct rxdone_entry_desc *rxdesc) |
1239 | { | 1237 | { |
1240 | struct queue_entry_priv_pci_rx *priv_rx = entry->priv_data; | 1238 | struct queue_entry_priv_pci *entry_priv = entry->priv_data; |
1241 | u32 word0; | 1239 | u32 word0; |
1242 | u32 word2; | 1240 | u32 word2; |
1243 | 1241 | ||
1244 | rt2x00_desc_read(priv_rx->desc, 0, &word0); | 1242 | rt2x00_desc_read(entry_priv->desc, 0, &word0); |
1245 | rt2x00_desc_read(priv_rx->desc, 2, &word2); | 1243 | rt2x00_desc_read(entry_priv->desc, 2, &word2); |
1246 | 1244 | ||
1247 | rxdesc->flags = 0; | ||
1248 | if (rt2x00_get_field32(word0, RXD_W0_CRC_ERROR)) | 1245 | if (rt2x00_get_field32(word0, RXD_W0_CRC_ERROR)) |
1249 | rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC; | 1246 | rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC; |
1250 | if (rt2x00_get_field32(word0, RXD_W0_PHYSICAL_ERROR)) | 1247 | if (rt2x00_get_field32(word0, RXD_W0_PHYSICAL_ERROR)) |
@@ -1261,7 +1258,6 @@ static void rt2500pci_fill_rxdone(struct queue_entry *entry, | |||
1261 | entry->queue->rt2x00dev->rssi_offset; | 1258 | entry->queue->rt2x00dev->rssi_offset; |
1262 | rxdesc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT); | 1259 | rxdesc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT); |
1263 | 1260 | ||
1264 | rxdesc->dev_flags = 0; | ||
1265 | if (rt2x00_get_field32(word0, RXD_W0_OFDM)) | 1261 | if (rt2x00_get_field32(word0, RXD_W0_OFDM)) |
1266 | rxdesc->dev_flags |= RXDONE_SIGNAL_PLCP; | 1262 | rxdesc->dev_flags |= RXDONE_SIGNAL_PLCP; |
1267 | if (rt2x00_get_field32(word0, RXD_W0_MY_BSS)) | 1263 | if (rt2x00_get_field32(word0, RXD_W0_MY_BSS)) |
@@ -1275,15 +1271,15 @@ static void rt2500pci_txdone(struct rt2x00_dev *rt2x00dev, | |||
1275 | const enum data_queue_qid queue_idx) | 1271 | const enum data_queue_qid queue_idx) |
1276 | { | 1272 | { |
1277 | struct data_queue *queue = rt2x00queue_get_queue(rt2x00dev, queue_idx); | 1273 | struct data_queue *queue = rt2x00queue_get_queue(rt2x00dev, queue_idx); |
1278 | struct queue_entry_priv_pci_tx *priv_tx; | 1274 | struct queue_entry_priv_pci *entry_priv; |
1279 | struct queue_entry *entry; | 1275 | struct queue_entry *entry; |
1280 | struct txdone_entry_desc txdesc; | 1276 | struct txdone_entry_desc txdesc; |
1281 | u32 word; | 1277 | u32 word; |
1282 | 1278 | ||
1283 | while (!rt2x00queue_empty(queue)) { | 1279 | while (!rt2x00queue_empty(queue)) { |
1284 | entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE); | 1280 | entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE); |
1285 | priv_tx = entry->priv_data; | 1281 | entry_priv = entry->priv_data; |
1286 | rt2x00_desc_read(priv_tx->desc, 0, &word); | 1282 | rt2x00_desc_read(entry_priv->desc, 0, &word); |
1287 | 1283 | ||
1288 | if (rt2x00_get_field32(word, TXD_W0_OWNER_NIC) || | 1284 | if (rt2x00_get_field32(word, TXD_W0_OWNER_NIC) || |
1289 | !rt2x00_get_field32(word, TXD_W0_VALID)) | 1285 | !rt2x00_get_field32(word, TXD_W0_VALID)) |
@@ -1292,7 +1288,18 @@ static void rt2500pci_txdone(struct rt2x00_dev *rt2x00dev, | |||
1292 | /* | 1288 | /* |
1293 | * Obtain the status about this packet. | 1289 | * Obtain the status about this packet. |
1294 | */ | 1290 | */ |
1295 | txdesc.status = rt2x00_get_field32(word, TXD_W0_RESULT); | 1291 | txdesc.flags = 0; |
1292 | switch (rt2x00_get_field32(word, TXD_W0_RESULT)) { | ||
1293 | case 0: /* Success */ | ||
1294 | case 1: /* Success with retry */ | ||
1295 | __set_bit(TXDONE_SUCCESS, &txdesc.flags); | ||
1296 | break; | ||
1297 | case 2: /* Failure, excessive retries */ | ||
1298 | __set_bit(TXDONE_EXCESSIVE_RETRY, &txdesc.flags); | ||
1299 | /* Don't break, this is a failed frame! */ | ||
1300 | default: /* Failure */ | ||
1301 | __set_bit(TXDONE_FAILURE, &txdesc.flags); | ||
1302 | } | ||
1296 | txdesc.retry = rt2x00_get_field32(word, TXD_W0_RETRY_COUNT); | 1303 | txdesc.retry = rt2x00_get_field32(word, TXD_W0_RETRY_COUNT); |
1297 | 1304 | ||
1298 | rt2x00pci_txdone(rt2x00dev, entry, &txdesc); | 1305 | rt2x00pci_txdone(rt2x00dev, entry, &txdesc); |
@@ -1684,7 +1691,6 @@ static void rt2500pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev) | |||
1684 | IEEE80211_HW_SIGNAL_DBM; | 1691 | IEEE80211_HW_SIGNAL_DBM; |
1685 | 1692 | ||
1686 | rt2x00dev->hw->extra_tx_headroom = 0; | 1693 | rt2x00dev->hw->extra_tx_headroom = 0; |
1687 | rt2x00dev->hw->queues = 2; | ||
1688 | 1694 | ||
1689 | SET_IEEE80211_DEV(rt2x00dev->hw, &rt2x00dev_pci(rt2x00dev)->dev); | 1695 | SET_IEEE80211_DEV(rt2x00dev->hw, &rt2x00dev_pci(rt2x00dev)->dev); |
1690 | SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, | 1696 | SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, |
@@ -1793,19 +1799,28 @@ static u64 rt2500pci_get_tsf(struct ieee80211_hw *hw) | |||
1793 | return tsf; | 1799 | return tsf; |
1794 | } | 1800 | } |
1795 | 1801 | ||
1796 | static int rt2500pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb, | 1802 | static int rt2500pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb) |
1797 | struct ieee80211_tx_control *control) | ||
1798 | { | 1803 | { |
1799 | struct rt2x00_dev *rt2x00dev = hw->priv; | 1804 | struct rt2x00_dev *rt2x00dev = hw->priv; |
1800 | struct rt2x00_intf *intf = vif_to_intf(control->vif); | 1805 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); |
1801 | struct queue_entry_priv_pci_tx *priv_tx; | 1806 | struct rt2x00_intf *intf = vif_to_intf(tx_info->control.vif); |
1807 | struct queue_entry_priv_pci *entry_priv; | ||
1802 | struct skb_frame_desc *skbdesc; | 1808 | struct skb_frame_desc *skbdesc; |
1809 | struct txentry_desc txdesc; | ||
1803 | u32 reg; | 1810 | u32 reg; |
1804 | 1811 | ||
1805 | if (unlikely(!intf->beacon)) | 1812 | if (unlikely(!intf->beacon)) |
1806 | return -ENOBUFS; | 1813 | return -ENOBUFS; |
1807 | 1814 | ||
1808 | priv_tx = intf->beacon->priv_data; | 1815 | entry_priv = intf->beacon->priv_data; |
1816 | |||
1817 | /* | ||
1818 | * Copy all TX descriptor information into txdesc, | ||
1819 | * after that we are free to use the skb->cb array | ||
1820 | * for our information. | ||
1821 | */ | ||
1822 | intf->beacon->skb = skb; | ||
1823 | rt2x00queue_create_tx_descriptor(intf->beacon, &txdesc); | ||
1809 | 1824 | ||
1810 | /* | 1825 | /* |
1811 | * Fill in skb descriptor | 1826 | * Fill in skb descriptor |
@@ -1815,7 +1830,7 @@ static int rt2500pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
1815 | skbdesc->flags |= FRAME_DESC_DRIVER_GENERATED; | 1830 | skbdesc->flags |= FRAME_DESC_DRIVER_GENERATED; |
1816 | skbdesc->data = skb->data; | 1831 | skbdesc->data = skb->data; |
1817 | skbdesc->data_len = skb->len; | 1832 | skbdesc->data_len = skb->len; |
1818 | skbdesc->desc = priv_tx->desc; | 1833 | skbdesc->desc = entry_priv->desc; |
1819 | skbdesc->desc_len = intf->beacon->queue->desc_size; | 1834 | skbdesc->desc_len = intf->beacon->queue->desc_size; |
1820 | skbdesc->entry = intf->beacon; | 1835 | skbdesc->entry = intf->beacon; |
1821 | 1836 | ||
@@ -1834,8 +1849,8 @@ static int rt2500pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
1834 | * Write entire beacon with descriptor to register, | 1849 | * Write entire beacon with descriptor to register, |
1835 | * and kick the beacon generator. | 1850 | * and kick the beacon generator. |
1836 | */ | 1851 | */ |
1837 | rt2x00lib_write_tx_desc(rt2x00dev, skb, control); | 1852 | memcpy(entry_priv->data, skb->data, skb->len); |
1838 | memcpy(priv_tx->data, skb->data, skb->len); | 1853 | rt2x00queue_write_tx_descriptor(intf->beacon, &txdesc); |
1839 | rt2x00dev->ops->lib->kick_tx_queue(rt2x00dev, QID_BEACON); | 1854 | rt2x00dev->ops->lib->kick_tx_queue(rt2x00dev, QID_BEACON); |
1840 | 1855 | ||
1841 | return 0; | 1856 | return 0; |
@@ -1895,28 +1910,28 @@ static const struct data_queue_desc rt2500pci_queue_rx = { | |||
1895 | .entry_num = RX_ENTRIES, | 1910 | .entry_num = RX_ENTRIES, |
1896 | .data_size = DATA_FRAME_SIZE, | 1911 | .data_size = DATA_FRAME_SIZE, |
1897 | .desc_size = RXD_DESC_SIZE, | 1912 | .desc_size = RXD_DESC_SIZE, |
1898 | .priv_size = sizeof(struct queue_entry_priv_pci_rx), | 1913 | .priv_size = sizeof(struct queue_entry_priv_pci), |
1899 | }; | 1914 | }; |
1900 | 1915 | ||
1901 | static const struct data_queue_desc rt2500pci_queue_tx = { | 1916 | static const struct data_queue_desc rt2500pci_queue_tx = { |
1902 | .entry_num = TX_ENTRIES, | 1917 | .entry_num = TX_ENTRIES, |
1903 | .data_size = DATA_FRAME_SIZE, | 1918 | .data_size = DATA_FRAME_SIZE, |
1904 | .desc_size = TXD_DESC_SIZE, | 1919 | .desc_size = TXD_DESC_SIZE, |
1905 | .priv_size = sizeof(struct queue_entry_priv_pci_tx), | 1920 | .priv_size = sizeof(struct queue_entry_priv_pci), |
1906 | }; | 1921 | }; |
1907 | 1922 | ||
1908 | static const struct data_queue_desc rt2500pci_queue_bcn = { | 1923 | static const struct data_queue_desc rt2500pci_queue_bcn = { |
1909 | .entry_num = BEACON_ENTRIES, | 1924 | .entry_num = BEACON_ENTRIES, |
1910 | .data_size = MGMT_FRAME_SIZE, | 1925 | .data_size = MGMT_FRAME_SIZE, |
1911 | .desc_size = TXD_DESC_SIZE, | 1926 | .desc_size = TXD_DESC_SIZE, |
1912 | .priv_size = sizeof(struct queue_entry_priv_pci_tx), | 1927 | .priv_size = sizeof(struct queue_entry_priv_pci), |
1913 | }; | 1928 | }; |
1914 | 1929 | ||
1915 | static const struct data_queue_desc rt2500pci_queue_atim = { | 1930 | static const struct data_queue_desc rt2500pci_queue_atim = { |
1916 | .entry_num = ATIM_ENTRIES, | 1931 | .entry_num = ATIM_ENTRIES, |
1917 | .data_size = DATA_FRAME_SIZE, | 1932 | .data_size = DATA_FRAME_SIZE, |
1918 | .desc_size = TXD_DESC_SIZE, | 1933 | .desc_size = TXD_DESC_SIZE, |
1919 | .priv_size = sizeof(struct queue_entry_priv_pci_tx), | 1934 | .priv_size = sizeof(struct queue_entry_priv_pci), |
1920 | }; | 1935 | }; |
1921 | 1936 | ||
1922 | static const struct rt2x00_ops rt2500pci_ops = { | 1937 | static const struct rt2x00_ops rt2500pci_ops = { |
@@ -1925,6 +1940,7 @@ static const struct rt2x00_ops rt2500pci_ops = { | |||
1925 | .max_ap_intf = 1, | 1940 | .max_ap_intf = 1, |
1926 | .eeprom_size = EEPROM_SIZE, | 1941 | .eeprom_size = EEPROM_SIZE, |
1927 | .rf_size = RF_SIZE, | 1942 | .rf_size = RF_SIZE, |
1943 | .tx_queues = NUM_TX_QUEUES, | ||
1928 | .rx = &rt2500pci_queue_rx, | 1944 | .rx = &rt2500pci_queue_rx, |
1929 | .tx = &rt2500pci_queue_tx, | 1945 | .tx = &rt2500pci_queue_tx, |
1930 | .bcn = &rt2500pci_queue_bcn, | 1946 | .bcn = &rt2500pci_queue_bcn, |
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.h b/drivers/net/wireless/rt2x00/rt2500pci.h index 13899550465a..ea93b8f423a9 100644 --- a/drivers/net/wireless/rt2x00/rt2500pci.h +++ b/drivers/net/wireless/rt2x00/rt2500pci.h | |||
@@ -63,6 +63,11 @@ | |||
63 | #define RF_SIZE 0x0014 | 63 | #define RF_SIZE 0x0014 |
64 | 64 | ||
65 | /* | 65 | /* |
66 | * Number of TX queues. | ||
67 | */ | ||
68 | #define NUM_TX_QUEUES 2 | ||
69 | |||
70 | /* | ||
66 | * Control/Status Registers(CSR). | 71 | * Control/Status Registers(CSR). |
67 | * Some values are set in TU, whereas 1 TU == 1024 us. | 72 | * Some values are set in TU, whereas 1 TU == 1024 us. |
68 | */ | 73 | */ |
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c index 88bafdf8f0fa..cca1504550dc 100644 --- a/drivers/net/wireless/rt2x00/rt2500usb.c +++ b/drivers/net/wireless/rt2x00/rt2500usb.c | |||
@@ -1033,8 +1033,7 @@ static int rt2500usb_set_device_state(struct rt2x00_dev *rt2x00dev, | |||
1033 | */ | 1033 | */ |
1034 | static void rt2500usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, | 1034 | static void rt2500usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, |
1035 | struct sk_buff *skb, | 1035 | struct sk_buff *skb, |
1036 | struct txentry_desc *txdesc, | 1036 | struct txentry_desc *txdesc) |
1037 | struct ieee80211_tx_control *control) | ||
1038 | { | 1037 | { |
1039 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb); | 1038 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb); |
1040 | __le32 *txd = skbdesc->desc; | 1039 | __le32 *txd = skbdesc->desc; |
@@ -1058,7 +1057,7 @@ static void rt2500usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, | |||
1058 | rt2x00_desc_write(txd, 2, word); | 1057 | rt2x00_desc_write(txd, 2, word); |
1059 | 1058 | ||
1060 | rt2x00_desc_read(txd, 0, &word); | 1059 | rt2x00_desc_read(txd, 0, &word); |
1061 | rt2x00_set_field32(&word, TXD_W0_RETRY_LIMIT, control->retry_limit); | 1060 | rt2x00_set_field32(&word, TXD_W0_RETRY_LIMIT, txdesc->retry_limit); |
1062 | rt2x00_set_field32(&word, TXD_W0_MORE_FRAG, | 1061 | rt2x00_set_field32(&word, TXD_W0_MORE_FRAG, |
1063 | test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags)); | 1062 | test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags)); |
1064 | rt2x00_set_field32(&word, TXD_W0_ACK, | 1063 | rt2x00_set_field32(&word, TXD_W0_ACK, |
@@ -1068,7 +1067,7 @@ static void rt2500usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, | |||
1068 | rt2x00_set_field32(&word, TXD_W0_OFDM, | 1067 | rt2x00_set_field32(&word, TXD_W0_OFDM, |
1069 | test_bit(ENTRY_TXD_OFDM_RATE, &txdesc->flags)); | 1068 | test_bit(ENTRY_TXD_OFDM_RATE, &txdesc->flags)); |
1070 | rt2x00_set_field32(&word, TXD_W0_NEW_SEQ, | 1069 | rt2x00_set_field32(&word, TXD_W0_NEW_SEQ, |
1071 | !!(control->flags & IEEE80211_TXCTL_FIRST_FRAGMENT)); | 1070 | test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags)); |
1072 | rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs); | 1071 | rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs); |
1073 | rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, skbdesc->data_len); | 1072 | rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, skbdesc->data_len); |
1074 | rt2x00_set_field32(&word, TXD_W0_CIPHER, CIPHER_NONE); | 1073 | rt2x00_set_field32(&word, TXD_W0_CIPHER, CIPHER_NONE); |
@@ -1125,30 +1124,32 @@ static void rt2500usb_kick_tx_queue(struct rt2x00_dev *rt2x00dev, | |||
1125 | static void rt2500usb_fill_rxdone(struct queue_entry *entry, | 1124 | static void rt2500usb_fill_rxdone(struct queue_entry *entry, |
1126 | struct rxdone_entry_desc *rxdesc) | 1125 | struct rxdone_entry_desc *rxdesc) |
1127 | { | 1126 | { |
1128 | struct queue_entry_priv_usb_rx *priv_rx = entry->priv_data; | 1127 | struct queue_entry_priv_usb *entry_priv = entry->priv_data; |
1129 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); | 1128 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); |
1130 | __le32 *rxd = | 1129 | __le32 *rxd = |
1131 | (__le32 *)(entry->skb->data + | 1130 | (__le32 *)(entry->skb->data + |
1132 | (priv_rx->urb->actual_length - entry->queue->desc_size)); | 1131 | (entry_priv->urb->actual_length - |
1133 | unsigned int offset = entry->queue->desc_size + 2; | 1132 | entry->queue->desc_size)); |
1134 | u32 word0; | 1133 | u32 word0; |
1135 | u32 word1; | 1134 | u32 word1; |
1136 | 1135 | ||
1137 | /* | 1136 | /* |
1138 | * Copy descriptor to the available headroom inside the skbuffer. | 1137 | * Copy descriptor to the skb->cb array, this has 2 benefits: |
1138 | * 1) Each descriptor word is 4 byte aligned. | ||
1139 | * 2) Descriptor is safe from moving of frame data in rt2x00usb. | ||
1139 | */ | 1140 | */ |
1140 | skb_push(entry->skb, offset); | 1141 | skbdesc->desc_len = |
1141 | memcpy(entry->skb->data, rxd, entry->queue->desc_size); | 1142 | min_t(u16, entry->queue->desc_size, sizeof(entry->skb->cb)); |
1142 | rxd = (__le32 *)entry->skb->data; | 1143 | memcpy(entry->skb->cb, rxd, skbdesc->desc_len); |
1144 | skbdesc->desc = entry->skb->cb; | ||
1145 | rxd = (__le32 *)skbdesc->desc; | ||
1143 | 1146 | ||
1144 | /* | 1147 | /* |
1145 | * The descriptor is now aligned to 4 bytes and thus it is | 1148 | * It is now safe to read the descriptor on all architectures. |
1146 | * now safe to read it on all architectures. | ||
1147 | */ | 1149 | */ |
1148 | rt2x00_desc_read(rxd, 0, &word0); | 1150 | rt2x00_desc_read(rxd, 0, &word0); |
1149 | rt2x00_desc_read(rxd, 1, &word1); | 1151 | rt2x00_desc_read(rxd, 1, &word1); |
1150 | 1152 | ||
1151 | rxdesc->flags = 0; | ||
1152 | if (rt2x00_get_field32(word0, RXD_W0_CRC_ERROR)) | 1153 | if (rt2x00_get_field32(word0, RXD_W0_CRC_ERROR)) |
1153 | rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC; | 1154 | rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC; |
1154 | if (rt2x00_get_field32(word0, RXD_W0_PHYSICAL_ERROR)) | 1155 | if (rt2x00_get_field32(word0, RXD_W0_PHYSICAL_ERROR)) |
@@ -1165,7 +1166,6 @@ static void rt2500usb_fill_rxdone(struct queue_entry *entry, | |||
1165 | entry->queue->rt2x00dev->rssi_offset; | 1166 | entry->queue->rt2x00dev->rssi_offset; |
1166 | rxdesc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT); | 1167 | rxdesc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT); |
1167 | 1168 | ||
1168 | rxdesc->dev_flags = 0; | ||
1169 | if (rt2x00_get_field32(word0, RXD_W0_OFDM)) | 1169 | if (rt2x00_get_field32(word0, RXD_W0_OFDM)) |
1170 | rxdesc->dev_flags |= RXDONE_SIGNAL_PLCP; | 1170 | rxdesc->dev_flags |= RXDONE_SIGNAL_PLCP; |
1171 | if (rt2x00_get_field32(word0, RXD_W0_MY_BSS)) | 1171 | if (rt2x00_get_field32(word0, RXD_W0_MY_BSS)) |
@@ -1174,16 +1174,9 @@ static void rt2500usb_fill_rxdone(struct queue_entry *entry, | |||
1174 | /* | 1174 | /* |
1175 | * Adjust the skb memory window to the frame boundaries. | 1175 | * Adjust the skb memory window to the frame boundaries. |
1176 | */ | 1176 | */ |
1177 | skb_pull(entry->skb, offset); | ||
1178 | skb_trim(entry->skb, rxdesc->size); | 1177 | skb_trim(entry->skb, rxdesc->size); |
1179 | |||
1180 | /* | ||
1181 | * Set descriptor and data pointer. | ||
1182 | */ | ||
1183 | skbdesc->data = entry->skb->data; | 1178 | skbdesc->data = entry->skb->data; |
1184 | skbdesc->data_len = rxdesc->size; | 1179 | skbdesc->data_len = rxdesc->size; |
1185 | skbdesc->desc = rxd; | ||
1186 | skbdesc->desc_len = entry->queue->desc_size; | ||
1187 | } | 1180 | } |
1188 | 1181 | ||
1189 | /* | 1182 | /* |
@@ -1192,7 +1185,7 @@ static void rt2500usb_fill_rxdone(struct queue_entry *entry, | |||
1192 | static void rt2500usb_beacondone(struct urb *urb) | 1185 | static void rt2500usb_beacondone(struct urb *urb) |
1193 | { | 1186 | { |
1194 | struct queue_entry *entry = (struct queue_entry *)urb->context; | 1187 | struct queue_entry *entry = (struct queue_entry *)urb->context; |
1195 | struct queue_entry_priv_usb_bcn *priv_bcn = entry->priv_data; | 1188 | struct queue_entry_priv_usb_bcn *bcn_priv = entry->priv_data; |
1196 | 1189 | ||
1197 | if (!test_bit(DEVICE_ENABLED_RADIO, &entry->queue->rt2x00dev->flags)) | 1190 | if (!test_bit(DEVICE_ENABLED_RADIO, &entry->queue->rt2x00dev->flags)) |
1198 | return; | 1191 | return; |
@@ -1203,9 +1196,9 @@ static void rt2500usb_beacondone(struct urb *urb) | |||
1203 | * Otherwise we should free the sk_buffer, the device | 1196 | * Otherwise we should free the sk_buffer, the device |
1204 | * should be doing the rest of the work now. | 1197 | * should be doing the rest of the work now. |
1205 | */ | 1198 | */ |
1206 | if (priv_bcn->guardian_urb == urb) { | 1199 | if (bcn_priv->guardian_urb == urb) { |
1207 | usb_submit_urb(priv_bcn->urb, GFP_ATOMIC); | 1200 | usb_submit_urb(bcn_priv->urb, GFP_ATOMIC); |
1208 | } else if (priv_bcn->urb == urb) { | 1201 | } else if (bcn_priv->urb == urb) { |
1209 | dev_kfree_skb(entry->skb); | 1202 | dev_kfree_skb(entry->skb); |
1210 | entry->skb = NULL; | 1203 | entry->skb = NULL; |
1211 | } | 1204 | } |
@@ -1591,7 +1584,6 @@ static void rt2500usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev) | |||
1591 | IEEE80211_HW_SIGNAL_DBM; | 1584 | IEEE80211_HW_SIGNAL_DBM; |
1592 | 1585 | ||
1593 | rt2x00dev->hw->extra_tx_headroom = TXD_DESC_SIZE; | 1586 | rt2x00dev->hw->extra_tx_headroom = TXD_DESC_SIZE; |
1594 | rt2x00dev->hw->queues = 2; | ||
1595 | 1587 | ||
1596 | SET_IEEE80211_DEV(rt2x00dev->hw, &rt2x00dev_usb(rt2x00dev)->dev); | 1588 | SET_IEEE80211_DEV(rt2x00dev->hw, &rt2x00dev_usb(rt2x00dev)->dev); |
1597 | SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, | 1589 | SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, |
@@ -1674,15 +1666,15 @@ static int rt2500usb_probe_hw(struct rt2x00_dev *rt2x00dev) | |||
1674 | /* | 1666 | /* |
1675 | * IEEE80211 stack callback functions. | 1667 | * IEEE80211 stack callback functions. |
1676 | */ | 1668 | */ |
1677 | static int rt2500usb_beacon_update(struct ieee80211_hw *hw, | 1669 | static int rt2500usb_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb) |
1678 | struct sk_buff *skb, | ||
1679 | struct ieee80211_tx_control *control) | ||
1680 | { | 1670 | { |
1681 | struct rt2x00_dev *rt2x00dev = hw->priv; | 1671 | struct rt2x00_dev *rt2x00dev = hw->priv; |
1682 | struct usb_device *usb_dev = rt2x00dev_usb_dev(rt2x00dev); | 1672 | struct usb_device *usb_dev = rt2x00dev_usb_dev(rt2x00dev); |
1683 | struct rt2x00_intf *intf = vif_to_intf(control->vif); | 1673 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); |
1684 | struct queue_entry_priv_usb_bcn *priv_bcn; | 1674 | struct rt2x00_intf *intf = vif_to_intf(tx_info->control.vif); |
1675 | struct queue_entry_priv_usb_bcn *bcn_priv; | ||
1685 | struct skb_frame_desc *skbdesc; | 1676 | struct skb_frame_desc *skbdesc; |
1677 | struct txentry_desc txdesc; | ||
1686 | int pipe = usb_sndbulkpipe(usb_dev, 1); | 1678 | int pipe = usb_sndbulkpipe(usb_dev, 1); |
1687 | int length; | 1679 | int length; |
1688 | u16 reg; | 1680 | u16 reg; |
@@ -1690,7 +1682,15 @@ static int rt2500usb_beacon_update(struct ieee80211_hw *hw, | |||
1690 | if (unlikely(!intf->beacon)) | 1682 | if (unlikely(!intf->beacon)) |
1691 | return -ENOBUFS; | 1683 | return -ENOBUFS; |
1692 | 1684 | ||
1693 | priv_bcn = intf->beacon->priv_data; | 1685 | bcn_priv = intf->beacon->priv_data; |
1686 | |||
1687 | /* | ||
1688 | * Copy all TX descriptor information into txdesc, | ||
1689 | * after that we are free to use the skb->cb array | ||
1690 | * for our information. | ||
1691 | */ | ||
1692 | intf->beacon->skb = skb; | ||
1693 | rt2x00queue_create_tx_descriptor(intf->beacon, &txdesc); | ||
1694 | 1694 | ||
1695 | /* | 1695 | /* |
1696 | * Add the descriptor in front of the skb. | 1696 | * Add the descriptor in front of the skb. |
@@ -1720,7 +1720,7 @@ static int rt2500usb_beacon_update(struct ieee80211_hw *hw, | |||
1720 | rt2x00_set_field16(®, TXRX_CSR19_BEACON_GEN, 0); | 1720 | rt2x00_set_field16(®, TXRX_CSR19_BEACON_GEN, 0); |
1721 | rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg); | 1721 | rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg); |
1722 | 1722 | ||
1723 | rt2x00lib_write_tx_desc(rt2x00dev, skb, control); | 1723 | rt2x00queue_write_tx_descriptor(intf->beacon, &txdesc); |
1724 | 1724 | ||
1725 | /* | 1725 | /* |
1726 | * USB devices cannot blindly pass the skb->len as the | 1726 | * USB devices cannot blindly pass the skb->len as the |
@@ -1729,7 +1729,7 @@ static int rt2500usb_beacon_update(struct ieee80211_hw *hw, | |||
1729 | */ | 1729 | */ |
1730 | length = rt2500usb_get_tx_data_len(rt2x00dev, skb); | 1730 | length = rt2500usb_get_tx_data_len(rt2x00dev, skb); |
1731 | 1731 | ||
1732 | usb_fill_bulk_urb(priv_bcn->urb, usb_dev, pipe, | 1732 | usb_fill_bulk_urb(bcn_priv->urb, usb_dev, pipe, |
1733 | skb->data, length, rt2500usb_beacondone, | 1733 | skb->data, length, rt2500usb_beacondone, |
1734 | intf->beacon); | 1734 | intf->beacon); |
1735 | 1735 | ||
@@ -1738,15 +1738,15 @@ static int rt2500usb_beacon_update(struct ieee80211_hw *hw, | |||
1738 | * We only need a single byte, so lets recycle | 1738 | * We only need a single byte, so lets recycle |
1739 | * the 'flags' field we are not using for beacons. | 1739 | * the 'flags' field we are not using for beacons. |
1740 | */ | 1740 | */ |
1741 | priv_bcn->guardian_data = 0; | 1741 | bcn_priv->guardian_data = 0; |
1742 | usb_fill_bulk_urb(priv_bcn->guardian_urb, usb_dev, pipe, | 1742 | usb_fill_bulk_urb(bcn_priv->guardian_urb, usb_dev, pipe, |
1743 | &priv_bcn->guardian_data, 1, rt2500usb_beacondone, | 1743 | &bcn_priv->guardian_data, 1, rt2500usb_beacondone, |
1744 | intf->beacon); | 1744 | intf->beacon); |
1745 | 1745 | ||
1746 | /* | 1746 | /* |
1747 | * Send out the guardian byte. | 1747 | * Send out the guardian byte. |
1748 | */ | 1748 | */ |
1749 | usb_submit_urb(priv_bcn->guardian_urb, GFP_ATOMIC); | 1749 | usb_submit_urb(bcn_priv->guardian_urb, GFP_ATOMIC); |
1750 | 1750 | ||
1751 | /* | 1751 | /* |
1752 | * Enable beacon generation. | 1752 | * Enable beacon generation. |
@@ -1797,14 +1797,14 @@ static const struct data_queue_desc rt2500usb_queue_rx = { | |||
1797 | .entry_num = RX_ENTRIES, | 1797 | .entry_num = RX_ENTRIES, |
1798 | .data_size = DATA_FRAME_SIZE, | 1798 | .data_size = DATA_FRAME_SIZE, |
1799 | .desc_size = RXD_DESC_SIZE, | 1799 | .desc_size = RXD_DESC_SIZE, |
1800 | .priv_size = sizeof(struct queue_entry_priv_usb_rx), | 1800 | .priv_size = sizeof(struct queue_entry_priv_usb), |
1801 | }; | 1801 | }; |
1802 | 1802 | ||
1803 | static const struct data_queue_desc rt2500usb_queue_tx = { | 1803 | static const struct data_queue_desc rt2500usb_queue_tx = { |
1804 | .entry_num = TX_ENTRIES, | 1804 | .entry_num = TX_ENTRIES, |
1805 | .data_size = DATA_FRAME_SIZE, | 1805 | .data_size = DATA_FRAME_SIZE, |
1806 | .desc_size = TXD_DESC_SIZE, | 1806 | .desc_size = TXD_DESC_SIZE, |
1807 | .priv_size = sizeof(struct queue_entry_priv_usb_tx), | 1807 | .priv_size = sizeof(struct queue_entry_priv_usb), |
1808 | }; | 1808 | }; |
1809 | 1809 | ||
1810 | static const struct data_queue_desc rt2500usb_queue_bcn = { | 1810 | static const struct data_queue_desc rt2500usb_queue_bcn = { |
@@ -1818,7 +1818,7 @@ static const struct data_queue_desc rt2500usb_queue_atim = { | |||
1818 | .entry_num = ATIM_ENTRIES, | 1818 | .entry_num = ATIM_ENTRIES, |
1819 | .data_size = DATA_FRAME_SIZE, | 1819 | .data_size = DATA_FRAME_SIZE, |
1820 | .desc_size = TXD_DESC_SIZE, | 1820 | .desc_size = TXD_DESC_SIZE, |
1821 | .priv_size = sizeof(struct queue_entry_priv_usb_tx), | 1821 | .priv_size = sizeof(struct queue_entry_priv_usb), |
1822 | }; | 1822 | }; |
1823 | 1823 | ||
1824 | static const struct rt2x00_ops rt2500usb_ops = { | 1824 | static const struct rt2x00_ops rt2500usb_ops = { |
@@ -1827,6 +1827,7 @@ static const struct rt2x00_ops rt2500usb_ops = { | |||
1827 | .max_ap_intf = 1, | 1827 | .max_ap_intf = 1, |
1828 | .eeprom_size = EEPROM_SIZE, | 1828 | .eeprom_size = EEPROM_SIZE, |
1829 | .rf_size = RF_SIZE, | 1829 | .rf_size = RF_SIZE, |
1830 | .tx_queues = NUM_TX_QUEUES, | ||
1830 | .rx = &rt2500usb_queue_rx, | 1831 | .rx = &rt2500usb_queue_rx, |
1831 | .tx = &rt2500usb_queue_tx, | 1832 | .tx = &rt2500usb_queue_tx, |
1832 | .bcn = &rt2500usb_queue_bcn, | 1833 | .bcn = &rt2500usb_queue_bcn, |
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.h b/drivers/net/wireless/rt2x00/rt2500usb.h index a37a068d0c71..7d50098f0cc5 100644 --- a/drivers/net/wireless/rt2x00/rt2500usb.h +++ b/drivers/net/wireless/rt2x00/rt2500usb.h | |||
@@ -63,6 +63,11 @@ | |||
63 | #define RF_SIZE 0x0014 | 63 | #define RF_SIZE 0x0014 |
64 | 64 | ||
65 | /* | 65 | /* |
66 | * Number of TX queues. | ||
67 | */ | ||
68 | #define NUM_TX_QUEUES 2 | ||
69 | |||
70 | /* | ||
66 | * Control/Status Registers(CSR). | 71 | * Control/Status Registers(CSR). |
67 | * Some values are set in TU, whereas 1 TU == 1024 us. | 72 | * Some values are set in TU, whereas 1 TU == 1024 us. |
68 | */ | 73 | */ |
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h index 79bd9c9f8963..5c7220ea46e6 100644 --- a/drivers/net/wireless/rt2x00/rt2x00.h +++ b/drivers/net/wireless/rt2x00/rt2x00.h | |||
@@ -44,7 +44,7 @@ | |||
44 | /* | 44 | /* |
45 | * Module information. | 45 | * Module information. |
46 | */ | 46 | */ |
47 | #define DRV_VERSION "2.1.5" | 47 | #define DRV_VERSION "2.1.6" |
48 | #define DRV_PROJECT "http://rt2x00.serialmonkey.com" | 48 | #define DRV_PROJECT "http://rt2x00.serialmonkey.com" |
49 | 49 | ||
50 | /* | 50 | /* |
@@ -540,11 +540,9 @@ struct rt2x00lib_ops { | |||
540 | */ | 540 | */ |
541 | void (*write_tx_desc) (struct rt2x00_dev *rt2x00dev, | 541 | void (*write_tx_desc) (struct rt2x00_dev *rt2x00dev, |
542 | struct sk_buff *skb, | 542 | struct sk_buff *skb, |
543 | struct txentry_desc *txdesc, | 543 | struct txentry_desc *txdesc); |
544 | struct ieee80211_tx_control *control); | ||
545 | int (*write_tx_data) (struct rt2x00_dev *rt2x00dev, | 544 | int (*write_tx_data) (struct rt2x00_dev *rt2x00dev, |
546 | struct data_queue *queue, struct sk_buff *skb, | 545 | struct data_queue *queue, struct sk_buff *skb); |
547 | struct ieee80211_tx_control *control); | ||
548 | int (*get_tx_data_len) (struct rt2x00_dev *rt2x00dev, | 546 | int (*get_tx_data_len) (struct rt2x00_dev *rt2x00dev, |
549 | struct sk_buff *skb); | 547 | struct sk_buff *skb); |
550 | void (*kick_tx_queue) (struct rt2x00_dev *rt2x00dev, | 548 | void (*kick_tx_queue) (struct rt2x00_dev *rt2x00dev, |
@@ -592,6 +590,7 @@ struct rt2x00_ops { | |||
592 | const unsigned int max_ap_intf; | 590 | const unsigned int max_ap_intf; |
593 | const unsigned int eeprom_size; | 591 | const unsigned int eeprom_size; |
594 | const unsigned int rf_size; | 592 | const unsigned int rf_size; |
593 | const unsigned int tx_queues; | ||
595 | const struct data_queue_desc *rx; | 594 | const struct data_queue_desc *rx; |
596 | const struct data_queue_desc *tx; | 595 | const struct data_queue_desc *tx; |
597 | const struct data_queue_desc *bcn; | 596 | const struct data_queue_desc *bcn; |
@@ -927,6 +926,39 @@ static inline u16 get_duration_res(const unsigned int size, const u8 rate) | |||
927 | } | 926 | } |
928 | 927 | ||
929 | /** | 928 | /** |
929 | * rt2x00queue_create_tx_descriptor - Create TX descriptor from mac80211 input | ||
930 | * @entry: The entry which will be used to transfer the TX frame. | ||
931 | * @txdesc: rt2x00 TX descriptor which will be initialized by this function. | ||
932 | * | ||
933 | * This function will initialize the &struct txentry_desc based on information | ||
934 | * from mac80211. This descriptor can then be used by rt2x00lib and the drivers | ||
935 | * to correctly initialize the hardware descriptor. | ||
936 | * Note that before calling this function the skb->cb array must be untouched | ||
937 | * by rt2x00lib. Only after this function completes will it be save to | ||
938 | * overwrite the skb->cb information. | ||
939 | * The reason for this is that mac80211 writes its own tx information into | ||
940 | * the skb->cb array, and this function will use that information to initialize | ||
941 | * the &struct txentry_desc structure. | ||
942 | */ | ||
943 | void rt2x00queue_create_tx_descriptor(struct queue_entry *entry, | ||
944 | struct txentry_desc *txdesc); | ||
945 | |||
946 | /** | ||
947 | * rt2x00queue_write_tx_descriptor - Write TX descriptor to hardware | ||
948 | * @entry: The entry which will be used to transfer the TX frame. | ||
949 | * @txdesc: TX descriptor which will be used to write hardware descriptor | ||
950 | * | ||
951 | * This function will write a TX descriptor initialized by | ||
952 | * &rt2x00queue_create_tx_descriptor to the hardware. After this call | ||
953 | * has completed the frame is now owned by the hardware, the hardware | ||
954 | * queue will have automatically be kicked unless this frame was generated | ||
955 | * by rt2x00lib, in which case the frame is "special" and must be kicked | ||
956 | * by the caller. | ||
957 | */ | ||
958 | void rt2x00queue_write_tx_descriptor(struct queue_entry *entry, | ||
959 | struct txentry_desc *txdesc); | ||
960 | |||
961 | /** | ||
930 | * rt2x00queue_get_queue - Convert queue index to queue pointer | 962 | * rt2x00queue_get_queue - Convert queue index to queue pointer |
931 | * @rt2x00dev: Pointer to &struct rt2x00_dev. | 963 | * @rt2x00dev: Pointer to &struct rt2x00_dev. |
932 | * @queue: rt2x00 queue index (see &enum data_queue_qid). | 964 | * @queue: rt2x00 queue index (see &enum data_queue_qid). |
@@ -964,17 +996,9 @@ void rt2x00lib_rxdone(struct queue_entry *entry, | |||
964 | struct rxdone_entry_desc *rxdesc); | 996 | struct rxdone_entry_desc *rxdesc); |
965 | 997 | ||
966 | /* | 998 | /* |
967 | * TX descriptor initializer | ||
968 | */ | ||
969 | void rt2x00lib_write_tx_desc(struct rt2x00_dev *rt2x00dev, | ||
970 | struct sk_buff *skb, | ||
971 | struct ieee80211_tx_control *control); | ||
972 | |||
973 | /* | ||
974 | * mac80211 handlers. | 999 | * mac80211 handlers. |
975 | */ | 1000 | */ |
976 | int rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb, | 1001 | int rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb); |
977 | struct ieee80211_tx_control *control); | ||
978 | int rt2x00mac_start(struct ieee80211_hw *hw); | 1002 | int rt2x00mac_start(struct ieee80211_hw *hw); |
979 | void rt2x00mac_stop(struct ieee80211_hw *hw); | 1003 | void rt2x00mac_stop(struct ieee80211_hw *hw); |
980 | int rt2x00mac_add_interface(struct ieee80211_hw *hw, | 1004 | int rt2x00mac_add_interface(struct ieee80211_hw *hw, |
diff --git a/drivers/net/wireless/rt2x00/rt2x00debug.c b/drivers/net/wireless/rt2x00/rt2x00debug.c index bfab3b8780d6..bd92cb8e68e0 100644 --- a/drivers/net/wireless/rt2x00/rt2x00debug.c +++ b/drivers/net/wireless/rt2x00/rt2x00debug.c | |||
@@ -115,7 +115,7 @@ struct rt2x00debug_intf { | |||
115 | }; | 115 | }; |
116 | 116 | ||
117 | void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev, | 117 | void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev, |
118 | struct sk_buff *skb) | 118 | enum rt2x00_dump_type type, struct sk_buff *skb) |
119 | { | 119 | { |
120 | struct rt2x00debug_intf *intf = rt2x00dev->debugfs_intf; | 120 | struct rt2x00debug_intf *intf = rt2x00dev->debugfs_intf; |
121 | struct skb_frame_desc *desc = get_skb_frame_desc(skb); | 121 | struct skb_frame_desc *desc = get_skb_frame_desc(skb); |
@@ -148,7 +148,7 @@ void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev, | |||
148 | dump_hdr->chip_rt = cpu_to_le16(rt2x00dev->chip.rt); | 148 | dump_hdr->chip_rt = cpu_to_le16(rt2x00dev->chip.rt); |
149 | dump_hdr->chip_rf = cpu_to_le16(rt2x00dev->chip.rf); | 149 | dump_hdr->chip_rf = cpu_to_le16(rt2x00dev->chip.rf); |
150 | dump_hdr->chip_rev = cpu_to_le32(rt2x00dev->chip.rev); | 150 | dump_hdr->chip_rev = cpu_to_le32(rt2x00dev->chip.rev); |
151 | dump_hdr->type = cpu_to_le16(desc->frame_type); | 151 | dump_hdr->type = cpu_to_le16(type); |
152 | dump_hdr->queue_index = desc->entry->queue->qid; | 152 | dump_hdr->queue_index = desc->entry->queue->qid; |
153 | dump_hdr->entry_index = desc->entry->entry_idx; | 153 | dump_hdr->entry_index = desc->entry->entry_idx; |
154 | dump_hdr->timestamp_sec = cpu_to_le32(timestamp.tv_sec); | 154 | dump_hdr->timestamp_sec = cpu_to_le32(timestamp.tv_sec); |
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c index 3a49c256789f..69e233610c94 100644 --- a/drivers/net/wireless/rt2x00/rt2x00dev.c +++ b/drivers/net/wireless/rt2x00/rt2x00dev.c | |||
@@ -28,7 +28,6 @@ | |||
28 | 28 | ||
29 | #include "rt2x00.h" | 29 | #include "rt2x00.h" |
30 | #include "rt2x00lib.h" | 30 | #include "rt2x00lib.h" |
31 | #include "rt2x00dump.h" | ||
32 | 31 | ||
33 | /* | 32 | /* |
34 | * Link tuning handlers | 33 | * Link tuning handlers |
@@ -126,7 +125,7 @@ int rt2x00lib_enable_radio(struct rt2x00_dev *rt2x00dev) | |||
126 | /* | 125 | /* |
127 | * Start the TX queues. | 126 | * Start the TX queues. |
128 | */ | 127 | */ |
129 | ieee80211_start_queues(rt2x00dev->hw); | 128 | ieee80211_wake_queues(rt2x00dev->hw); |
130 | 129 | ||
131 | return 0; | 130 | return 0; |
132 | } | 131 | } |
@@ -416,7 +415,6 @@ static void rt2x00lib_intf_scheduled_iter(void *data, u8 *mac, | |||
416 | struct rt2x00_dev *rt2x00dev = data; | 415 | struct rt2x00_dev *rt2x00dev = data; |
417 | struct rt2x00_intf *intf = vif_to_intf(vif); | 416 | struct rt2x00_intf *intf = vif_to_intf(vif); |
418 | struct sk_buff *skb; | 417 | struct sk_buff *skb; |
419 | struct ieee80211_tx_control control; | ||
420 | struct ieee80211_bss_conf conf; | 418 | struct ieee80211_bss_conf conf; |
421 | int delayed_flags; | 419 | int delayed_flags; |
422 | 420 | ||
@@ -434,9 +432,9 @@ static void rt2x00lib_intf_scheduled_iter(void *data, u8 *mac, | |||
434 | spin_unlock(&intf->lock); | 432 | spin_unlock(&intf->lock); |
435 | 433 | ||
436 | if (delayed_flags & DELAYED_UPDATE_BEACON) { | 434 | if (delayed_flags & DELAYED_UPDATE_BEACON) { |
437 | skb = ieee80211_beacon_get(rt2x00dev->hw, vif, &control); | 435 | skb = ieee80211_beacon_get(rt2x00dev->hw, vif); |
438 | if (skb && rt2x00dev->ops->hw->beacon_update(rt2x00dev->hw, | 436 | if (skb && |
439 | skb, &control)) | 437 | rt2x00dev->ops->hw->beacon_update(rt2x00dev->hw, skb)) |
440 | dev_kfree_skb(skb); | 438 | dev_kfree_skb(skb); |
441 | } | 439 | } |
442 | 440 | ||
@@ -495,61 +493,55 @@ void rt2x00lib_txdone(struct queue_entry *entry, | |||
495 | struct txdone_entry_desc *txdesc) | 493 | struct txdone_entry_desc *txdesc) |
496 | { | 494 | { |
497 | struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; | 495 | struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; |
498 | struct skb_frame_desc *skbdesc; | 496 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(entry->skb); |
499 | struct ieee80211_tx_status tx_status; | 497 | |
500 | int success = !!(txdesc->status == TX_SUCCESS || | 498 | /* |
501 | txdesc->status == TX_SUCCESS_RETRY); | 499 | * Send frame to debugfs immediately, after this call is completed |
502 | int fail = !!(txdesc->status == TX_FAIL_RETRY || | 500 | * we are going to overwrite the skb->cb array. |
503 | txdesc->status == TX_FAIL_INVALID || | 501 | */ |
504 | txdesc->status == TX_FAIL_OTHER); | 502 | rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_TXDONE, entry->skb); |
505 | 503 | ||
506 | /* | 504 | /* |
507 | * Update TX statistics. | 505 | * Update TX statistics. |
508 | */ | 506 | */ |
509 | rt2x00dev->link.qual.tx_success += success; | 507 | rt2x00dev->link.qual.tx_success += |
510 | rt2x00dev->link.qual.tx_failed += txdesc->retry + fail; | 508 | test_bit(TXDONE_SUCCESS, &txdesc->flags); |
509 | rt2x00dev->link.qual.tx_failed += | ||
510 | txdesc->retry + !!test_bit(TXDONE_FAILURE, &txdesc->flags); | ||
511 | 511 | ||
512 | /* | 512 | /* |
513 | * Initialize TX status | 513 | * Initialize TX status |
514 | */ | 514 | */ |
515 | tx_status.flags = 0; | 515 | memset(&tx_info->status, 0, sizeof(tx_info->status)); |
516 | tx_status.ack_signal = 0; | 516 | tx_info->status.ack_signal = 0; |
517 | tx_status.excessive_retries = (txdesc->status == TX_FAIL_RETRY); | 517 | tx_info->status.excessive_retries = |
518 | tx_status.retry_count = txdesc->retry; | 518 | test_bit(TXDONE_EXCESSIVE_RETRY, &txdesc->flags); |
519 | memcpy(&tx_status.control, txdesc->control, sizeof(*txdesc->control)); | 519 | tx_info->status.retry_count = txdesc->retry; |
520 | 520 | ||
521 | if (!(tx_status.control.flags & IEEE80211_TXCTL_NO_ACK)) { | 521 | if (!(tx_info->flags & IEEE80211_TX_CTL_NO_ACK)) { |
522 | if (success) | 522 | if (test_bit(TXDONE_SUCCESS, &txdesc->flags)) |
523 | tx_status.flags |= IEEE80211_TX_STATUS_ACK; | 523 | tx_info->flags |= IEEE80211_TX_STAT_ACK; |
524 | else | 524 | else if (test_bit(TXDONE_FAILURE, &txdesc->flags)) |
525 | rt2x00dev->low_level_stats.dot11ACKFailureCount++; | 525 | rt2x00dev->low_level_stats.dot11ACKFailureCount++; |
526 | } | 526 | } |
527 | 527 | ||
528 | if (tx_status.control.flags & IEEE80211_TXCTL_USE_RTS_CTS) { | 528 | if (tx_info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) { |
529 | if (success) | 529 | if (test_bit(TXDONE_SUCCESS, &txdesc->flags)) |
530 | rt2x00dev->low_level_stats.dot11RTSSuccessCount++; | 530 | rt2x00dev->low_level_stats.dot11RTSSuccessCount++; |
531 | else | 531 | else if (test_bit(TXDONE_FAILURE, &txdesc->flags)) |
532 | rt2x00dev->low_level_stats.dot11RTSFailureCount++; | 532 | rt2x00dev->low_level_stats.dot11RTSFailureCount++; |
533 | } | 533 | } |
534 | 534 | ||
535 | /* | 535 | /* |
536 | * Send the tx_status to debugfs. Only send the status report | 536 | * Only send the status report to mac80211 when TX status was |
537 | * to mac80211 when the frame originated from there. If this was | 537 | * requested by it. If this was a extra frame coming through |
538 | * a extra frame coming through a mac80211 library call (RTS/CTS) | 538 | * a mac80211 library call (RTS/CTS) then we should not send the |
539 | * then we should not send the status report back. | 539 | * status report back. |
540 | * If send to mac80211, mac80211 will clean up the skb structure, | ||
541 | * otherwise we have to do it ourself. | ||
542 | */ | 540 | */ |
543 | skbdesc = get_skb_frame_desc(entry->skb); | 541 | if (tx_info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS) |
544 | skbdesc->frame_type = DUMP_FRAME_TXDONE; | 542 | ieee80211_tx_status_irqsafe(rt2x00dev->hw, entry->skb); |
545 | |||
546 | rt2x00debug_dump_frame(rt2x00dev, entry->skb); | ||
547 | |||
548 | if (!(skbdesc->flags & FRAME_DESC_DRIVER_GENERATED)) | ||
549 | ieee80211_tx_status_irqsafe(rt2x00dev->hw, | ||
550 | entry->skb, &tx_status); | ||
551 | else | 543 | else |
552 | dev_kfree_skb(entry->skb); | 544 | dev_kfree_skb_irq(entry->skb); |
553 | entry->skb = NULL; | 545 | entry->skb = NULL; |
554 | } | 546 | } |
555 | EXPORT_SYMBOL_GPL(rt2x00lib_txdone); | 547 | EXPORT_SYMBOL_GPL(rt2x00lib_txdone); |
@@ -610,154 +602,13 @@ void rt2x00lib_rxdone(struct queue_entry *entry, | |||
610 | * Send frame to mac80211 & debugfs. | 602 | * Send frame to mac80211 & debugfs. |
611 | * mac80211 will clean up the skb structure. | 603 | * mac80211 will clean up the skb structure. |
612 | */ | 604 | */ |
613 | get_skb_frame_desc(entry->skb)->frame_type = DUMP_FRAME_RXDONE; | 605 | rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_RXDONE, entry->skb); |
614 | rt2x00debug_dump_frame(rt2x00dev, entry->skb); | ||
615 | ieee80211_rx_irqsafe(rt2x00dev->hw, entry->skb, rx_status); | 606 | ieee80211_rx_irqsafe(rt2x00dev->hw, entry->skb, rx_status); |
616 | entry->skb = NULL; | 607 | entry->skb = NULL; |
617 | } | 608 | } |
618 | EXPORT_SYMBOL_GPL(rt2x00lib_rxdone); | 609 | EXPORT_SYMBOL_GPL(rt2x00lib_rxdone); |
619 | 610 | ||
620 | /* | 611 | /* |
621 | * TX descriptor initializer | ||
622 | */ | ||
623 | void rt2x00lib_write_tx_desc(struct rt2x00_dev *rt2x00dev, | ||
624 | struct sk_buff *skb, | ||
625 | struct ieee80211_tx_control *control) | ||
626 | { | ||
627 | struct txentry_desc txdesc; | ||
628 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb); | ||
629 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skbdesc->data; | ||
630 | const struct rt2x00_rate *rate; | ||
631 | int tx_rate; | ||
632 | int length; | ||
633 | int duration; | ||
634 | int residual; | ||
635 | u16 frame_control; | ||
636 | u16 seq_ctrl; | ||
637 | |||
638 | memset(&txdesc, 0, sizeof(txdesc)); | ||
639 | |||
640 | txdesc.queue = skbdesc->entry->queue->qid; | ||
641 | txdesc.cw_min = skbdesc->entry->queue->cw_min; | ||
642 | txdesc.cw_max = skbdesc->entry->queue->cw_max; | ||
643 | txdesc.aifs = skbdesc->entry->queue->aifs; | ||
644 | |||
645 | /* | ||
646 | * Read required fields from ieee80211 header. | ||
647 | */ | ||
648 | frame_control = le16_to_cpu(hdr->frame_control); | ||
649 | seq_ctrl = le16_to_cpu(hdr->seq_ctrl); | ||
650 | |||
651 | tx_rate = control->tx_rate->hw_value; | ||
652 | |||
653 | /* | ||
654 | * Check whether this frame is to be acked | ||
655 | */ | ||
656 | if (!(control->flags & IEEE80211_TXCTL_NO_ACK)) | ||
657 | __set_bit(ENTRY_TXD_ACK, &txdesc.flags); | ||
658 | |||
659 | /* | ||
660 | * Check if this is a RTS/CTS frame | ||
661 | */ | ||
662 | if (is_rts_frame(frame_control) || is_cts_frame(frame_control)) { | ||
663 | __set_bit(ENTRY_TXD_BURST, &txdesc.flags); | ||
664 | if (is_rts_frame(frame_control)) { | ||
665 | __set_bit(ENTRY_TXD_RTS_FRAME, &txdesc.flags); | ||
666 | __set_bit(ENTRY_TXD_ACK, &txdesc.flags); | ||
667 | } else | ||
668 | __clear_bit(ENTRY_TXD_ACK, &txdesc.flags); | ||
669 | if (control->rts_cts_rate) | ||
670 | tx_rate = control->rts_cts_rate->hw_value; | ||
671 | } | ||
672 | |||
673 | rate = rt2x00_get_rate(tx_rate); | ||
674 | |||
675 | /* | ||
676 | * Check if more fragments are pending | ||
677 | */ | ||
678 | if (ieee80211_get_morefrag(hdr)) { | ||
679 | __set_bit(ENTRY_TXD_BURST, &txdesc.flags); | ||
680 | __set_bit(ENTRY_TXD_MORE_FRAG, &txdesc.flags); | ||
681 | } | ||
682 | |||
683 | /* | ||
684 | * Beacons and probe responses require the tsf timestamp | ||
685 | * to be inserted into the frame. | ||
686 | */ | ||
687 | if (txdesc.queue == QID_BEACON || is_probe_resp(frame_control)) | ||
688 | __set_bit(ENTRY_TXD_REQ_TIMESTAMP, &txdesc.flags); | ||
689 | |||
690 | /* | ||
691 | * Determine with what IFS priority this frame should be send. | ||
692 | * Set ifs to IFS_SIFS when the this is not the first fragment, | ||
693 | * or this fragment came after RTS/CTS. | ||
694 | */ | ||
695 | if ((seq_ctrl & IEEE80211_SCTL_FRAG) > 0 || | ||
696 | test_bit(ENTRY_TXD_RTS_FRAME, &txdesc.flags)) | ||
697 | txdesc.ifs = IFS_SIFS; | ||
698 | else | ||
699 | txdesc.ifs = IFS_BACKOFF; | ||
700 | |||
701 | /* | ||
702 | * PLCP setup | ||
703 | * Length calculation depends on OFDM/CCK rate. | ||
704 | */ | ||
705 | txdesc.signal = rate->plcp; | ||
706 | txdesc.service = 0x04; | ||
707 | |||
708 | length = skbdesc->data_len + FCS_LEN; | ||
709 | if (rate->flags & DEV_RATE_OFDM) { | ||
710 | __set_bit(ENTRY_TXD_OFDM_RATE, &txdesc.flags); | ||
711 | |||
712 | txdesc.length_high = (length >> 6) & 0x3f; | ||
713 | txdesc.length_low = length & 0x3f; | ||
714 | } else { | ||
715 | /* | ||
716 | * Convert length to microseconds. | ||
717 | */ | ||
718 | residual = get_duration_res(length, rate->bitrate); | ||
719 | duration = get_duration(length, rate->bitrate); | ||
720 | |||
721 | if (residual != 0) { | ||
722 | duration++; | ||
723 | |||
724 | /* | ||
725 | * Check if we need to set the Length Extension | ||
726 | */ | ||
727 | if (rate->bitrate == 110 && residual <= 30) | ||
728 | txdesc.service |= 0x80; | ||
729 | } | ||
730 | |||
731 | txdesc.length_high = (duration >> 8) & 0xff; | ||
732 | txdesc.length_low = duration & 0xff; | ||
733 | |||
734 | /* | ||
735 | * When preamble is enabled we should set the | ||
736 | * preamble bit for the signal. | ||
737 | */ | ||
738 | if (rt2x00_get_rate_preamble(tx_rate)) | ||
739 | txdesc.signal |= 0x08; | ||
740 | } | ||
741 | |||
742 | rt2x00dev->ops->lib->write_tx_desc(rt2x00dev, skb, &txdesc, control); | ||
743 | |||
744 | /* | ||
745 | * Update queue entry. | ||
746 | */ | ||
747 | skbdesc->entry->skb = skb; | ||
748 | |||
749 | /* | ||
750 | * The frame has been completely initialized and ready | ||
751 | * for sending to the device. The caller will push the | ||
752 | * frame to the device, but we are going to push the | ||
753 | * frame to debugfs here. | ||
754 | */ | ||
755 | skbdesc->frame_type = DUMP_FRAME_TX; | ||
756 | rt2x00debug_dump_frame(rt2x00dev, skb); | ||
757 | } | ||
758 | EXPORT_SYMBOL_GPL(rt2x00lib_write_tx_desc); | ||
759 | |||
760 | /* | ||
761 | * Driver initialization handlers. | 612 | * Driver initialization handlers. |
762 | */ | 613 | */ |
763 | const struct rt2x00_rate rt2x00_supported_rates[12] = { | 614 | const struct rt2x00_rate rt2x00_supported_rates[12] = { |
@@ -973,6 +824,11 @@ static int rt2x00lib_probe_hw(struct rt2x00_dev *rt2x00dev) | |||
973 | return status; | 824 | return status; |
974 | 825 | ||
975 | /* | 826 | /* |
827 | * Initialize HW fields. | ||
828 | */ | ||
829 | rt2x00dev->hw->queues = rt2x00dev->ops->tx_queues; | ||
830 | |||
831 | /* | ||
976 | * Register HW. | 832 | * Register HW. |
977 | */ | 833 | */ |
978 | status = ieee80211_register_hw(rt2x00dev->hw); | 834 | status = ieee80211_register_hw(rt2x00dev->hw); |
@@ -1327,7 +1183,7 @@ int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev) | |||
1327 | * In that case we have disabled the TX queue and should | 1183 | * In that case we have disabled the TX queue and should |
1328 | * now enable it again | 1184 | * now enable it again |
1329 | */ | 1185 | */ |
1330 | ieee80211_start_queues(rt2x00dev->hw); | 1186 | ieee80211_wake_queues(rt2x00dev->hw); |
1331 | 1187 | ||
1332 | /* | 1188 | /* |
1333 | * During interface iteration we might have changed the | 1189 | * During interface iteration we might have changed the |
diff --git a/drivers/net/wireless/rt2x00/rt2x00lib.h b/drivers/net/wireless/rt2x00/rt2x00lib.h index 41ee02cd2825..c4ce534e3cdb 100644 --- a/drivers/net/wireless/rt2x00/rt2x00lib.h +++ b/drivers/net/wireless/rt2x00/rt2x00lib.h | |||
@@ -26,6 +26,8 @@ | |||
26 | #ifndef RT2X00LIB_H | 26 | #ifndef RT2X00LIB_H |
27 | #define RT2X00LIB_H | 27 | #define RT2X00LIB_H |
28 | 28 | ||
29 | #include "rt2x00dump.h" | ||
30 | |||
29 | /* | 31 | /* |
30 | * Interval defines | 32 | * Interval defines |
31 | * Both the link tuner as the rfkill will be called once per second. | 33 | * Both the link tuner as the rfkill will be called once per second. |
@@ -128,7 +130,8 @@ static inline void rt2x00lib_free_firmware(struct rt2x00_dev *rt2x00dev) | |||
128 | #ifdef CONFIG_RT2X00_LIB_DEBUGFS | 130 | #ifdef CONFIG_RT2X00_LIB_DEBUGFS |
129 | void rt2x00debug_register(struct rt2x00_dev *rt2x00dev); | 131 | void rt2x00debug_register(struct rt2x00_dev *rt2x00dev); |
130 | void rt2x00debug_deregister(struct rt2x00_dev *rt2x00dev); | 132 | void rt2x00debug_deregister(struct rt2x00_dev *rt2x00dev); |
131 | void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb); | 133 | void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev, |
134 | enum rt2x00_dump_type type, struct sk_buff *skb); | ||
132 | #else | 135 | #else |
133 | static inline void rt2x00debug_register(struct rt2x00_dev *rt2x00dev) | 136 | static inline void rt2x00debug_register(struct rt2x00_dev *rt2x00dev) |
134 | { | 137 | { |
@@ -139,6 +142,7 @@ static inline void rt2x00debug_deregister(struct rt2x00_dev *rt2x00dev) | |||
139 | } | 142 | } |
140 | 143 | ||
141 | static inline void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev, | 144 | static inline void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev, |
145 | enum rt2x00_dump_type type, | ||
142 | struct sk_buff *skb) | 146 | struct sk_buff *skb) |
143 | { | 147 | { |
144 | } | 148 | } |
diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c index 767e0ffce04e..c05e05b58887 100644 --- a/drivers/net/wireless/rt2x00/rt2x00mac.c +++ b/drivers/net/wireless/rt2x00/rt2x00mac.c | |||
@@ -31,14 +31,15 @@ | |||
31 | 31 | ||
32 | static int rt2x00mac_tx_rts_cts(struct rt2x00_dev *rt2x00dev, | 32 | static int rt2x00mac_tx_rts_cts(struct rt2x00_dev *rt2x00dev, |
33 | struct data_queue *queue, | 33 | struct data_queue *queue, |
34 | struct sk_buff *frag_skb, | 34 | struct sk_buff *frag_skb) |
35 | struct ieee80211_tx_control *control) | ||
36 | { | 35 | { |
36 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(frag_skb); | ||
37 | struct skb_frame_desc *skbdesc; | 37 | struct skb_frame_desc *skbdesc; |
38 | struct ieee80211_tx_info *rts_info; | ||
38 | struct sk_buff *skb; | 39 | struct sk_buff *skb; |
39 | int size; | 40 | int size; |
40 | 41 | ||
41 | if (control->flags & IEEE80211_TXCTL_USE_CTS_PROTECT) | 42 | if (tx_info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) |
42 | size = sizeof(struct ieee80211_cts); | 43 | size = sizeof(struct ieee80211_cts); |
43 | else | 44 | else |
44 | size = sizeof(struct ieee80211_rts); | 45 | size = sizeof(struct ieee80211_rts); |
@@ -52,13 +53,33 @@ static int rt2x00mac_tx_rts_cts(struct rt2x00_dev *rt2x00dev, | |||
52 | skb_reserve(skb, rt2x00dev->hw->extra_tx_headroom); | 53 | skb_reserve(skb, rt2x00dev->hw->extra_tx_headroom); |
53 | skb_put(skb, size); | 54 | skb_put(skb, size); |
54 | 55 | ||
55 | if (control->flags & IEEE80211_TXCTL_USE_CTS_PROTECT) | 56 | /* |
56 | ieee80211_ctstoself_get(rt2x00dev->hw, control->vif, | 57 | * Copy TX information over from original frame to |
57 | frag_skb->data, frag_skb->len, control, | 58 | * RTS/CTS frame. Note that we set the no encryption flag |
59 | * since we don't want this frame to be encrypted. | ||
60 | * RTS frames should be acked, while CTS-to-self frames | ||
61 | * should not. The ready for TX flag is cleared to prevent | ||
62 | * it being automatically send when the descriptor is | ||
63 | * written to the hardware. | ||
64 | */ | ||
65 | memcpy(skb->cb, frag_skb->cb, sizeof(skb->cb)); | ||
66 | rts_info = IEEE80211_SKB_CB(skb); | ||
67 | rts_info->flags |= IEEE80211_TX_CTL_DO_NOT_ENCRYPT; | ||
68 | rts_info->flags &= ~IEEE80211_TX_CTL_USE_CTS_PROTECT; | ||
69 | rts_info->flags &= ~IEEE80211_TX_CTL_REQ_TX_STATUS; | ||
70 | |||
71 | if (tx_info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) | ||
72 | rts_info->flags |= IEEE80211_TX_CTL_NO_ACK; | ||
73 | else | ||
74 | rts_info->flags &= ~IEEE80211_TX_CTL_NO_ACK; | ||
75 | |||
76 | if (tx_info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) | ||
77 | ieee80211_ctstoself_get(rt2x00dev->hw, tx_info->control.vif, | ||
78 | frag_skb->data, size, tx_info, | ||
58 | (struct ieee80211_cts *)(skb->data)); | 79 | (struct ieee80211_cts *)(skb->data)); |
59 | else | 80 | else |
60 | ieee80211_rts_get(rt2x00dev->hw, control->vif, | 81 | ieee80211_rts_get(rt2x00dev->hw, tx_info->control.vif, |
61 | frag_skb->data, frag_skb->len, control, | 82 | frag_skb->data, size, tx_info, |
62 | (struct ieee80211_rts *)(skb->data)); | 83 | (struct ieee80211_rts *)(skb->data)); |
63 | 84 | ||
64 | /* | 85 | /* |
@@ -68,7 +89,7 @@ static int rt2x00mac_tx_rts_cts(struct rt2x00_dev *rt2x00dev, | |||
68 | memset(skbdesc, 0, sizeof(*skbdesc)); | 89 | memset(skbdesc, 0, sizeof(*skbdesc)); |
69 | skbdesc->flags |= FRAME_DESC_DRIVER_GENERATED; | 90 | skbdesc->flags |= FRAME_DESC_DRIVER_GENERATED; |
70 | 91 | ||
71 | if (rt2x00dev->ops->lib->write_tx_data(rt2x00dev, queue, skb, control)) { | 92 | if (rt2x00dev->ops->lib->write_tx_data(rt2x00dev, queue, skb)) { |
72 | WARNING(rt2x00dev, "Failed to send RTS/CTS frame.\n"); | 93 | WARNING(rt2x00dev, "Failed to send RTS/CTS frame.\n"); |
73 | return NETDEV_TX_BUSY; | 94 | return NETDEV_TX_BUSY; |
74 | } | 95 | } |
@@ -76,14 +97,13 @@ static int rt2x00mac_tx_rts_cts(struct rt2x00_dev *rt2x00dev, | |||
76 | return NETDEV_TX_OK; | 97 | return NETDEV_TX_OK; |
77 | } | 98 | } |
78 | 99 | ||
79 | int rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb, | 100 | int rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) |
80 | struct ieee80211_tx_control *control) | ||
81 | { | 101 | { |
82 | struct rt2x00_dev *rt2x00dev = hw->priv; | 102 | struct rt2x00_dev *rt2x00dev = hw->priv; |
103 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); | ||
83 | struct ieee80211_hdr *ieee80211hdr = (struct ieee80211_hdr *)skb->data; | 104 | struct ieee80211_hdr *ieee80211hdr = (struct ieee80211_hdr *)skb->data; |
84 | enum data_queue_qid qid = mac80211_queue_to_qid(control->queue); | 105 | enum data_queue_qid qid = skb_get_queue_mapping(skb); |
85 | struct data_queue *queue; | 106 | struct data_queue *queue; |
86 | struct skb_frame_desc *skbdesc; | ||
87 | u16 frame_control; | 107 | u16 frame_control; |
88 | 108 | ||
89 | /* | 109 | /* |
@@ -100,7 +120,7 @@ int rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
100 | /* | 120 | /* |
101 | * Determine which queue to put packet on. | 121 | * Determine which queue to put packet on. |
102 | */ | 122 | */ |
103 | if (control->flags & IEEE80211_TXCTL_SEND_AFTER_DTIM && | 123 | if (tx_info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM && |
104 | test_bit(DRIVER_REQUIRE_ATIM_QUEUE, &rt2x00dev->flags)) | 124 | test_bit(DRIVER_REQUIRE_ATIM_QUEUE, &rt2x00dev->flags)) |
105 | queue = rt2x00queue_get_queue(rt2x00dev, QID_ATIM); | 125 | queue = rt2x00queue_get_queue(rt2x00dev, QID_ATIM); |
106 | else | 126 | else |
@@ -125,33 +145,27 @@ int rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
125 | */ | 145 | */ |
126 | frame_control = le16_to_cpu(ieee80211hdr->frame_control); | 146 | frame_control = le16_to_cpu(ieee80211hdr->frame_control); |
127 | if (!is_rts_frame(frame_control) && !is_cts_frame(frame_control) && | 147 | if (!is_rts_frame(frame_control) && !is_cts_frame(frame_control) && |
128 | (control->flags & (IEEE80211_TXCTL_USE_RTS_CTS | | 148 | (tx_info->flags & (IEEE80211_TX_CTL_USE_RTS_CTS | |
129 | IEEE80211_TXCTL_USE_CTS_PROTECT)) && | 149 | IEEE80211_TX_CTL_USE_CTS_PROTECT)) && |
130 | !rt2x00dev->ops->hw->set_rts_threshold) { | 150 | !rt2x00dev->ops->hw->set_rts_threshold) { |
131 | if (rt2x00queue_available(queue) <= 1) { | 151 | if (rt2x00queue_available(queue) <= 1) { |
132 | ieee80211_stop_queue(rt2x00dev->hw, control->queue); | 152 | ieee80211_stop_queue(rt2x00dev->hw, qid); |
133 | return NETDEV_TX_BUSY; | 153 | return NETDEV_TX_BUSY; |
134 | } | 154 | } |
135 | 155 | ||
136 | if (rt2x00mac_tx_rts_cts(rt2x00dev, queue, skb, control)) { | 156 | if (rt2x00mac_tx_rts_cts(rt2x00dev, queue, skb)) { |
137 | ieee80211_stop_queue(rt2x00dev->hw, control->queue); | 157 | ieee80211_stop_queue(rt2x00dev->hw, qid); |
138 | return NETDEV_TX_BUSY; | 158 | return NETDEV_TX_BUSY; |
139 | } | 159 | } |
140 | } | 160 | } |
141 | 161 | ||
142 | /* | 162 | if (rt2x00dev->ops->lib->write_tx_data(rt2x00dev, queue, skb)) { |
143 | * Initialize skb descriptor | 163 | ieee80211_stop_queue(rt2x00dev->hw, qid); |
144 | */ | ||
145 | skbdesc = get_skb_frame_desc(skb); | ||
146 | memset(skbdesc, 0, sizeof(*skbdesc)); | ||
147 | |||
148 | if (rt2x00dev->ops->lib->write_tx_data(rt2x00dev, queue, skb, control)) { | ||
149 | ieee80211_stop_queue(rt2x00dev->hw, control->queue); | ||
150 | return NETDEV_TX_BUSY; | 164 | return NETDEV_TX_BUSY; |
151 | } | 165 | } |
152 | 166 | ||
153 | if (rt2x00queue_full(queue)) | 167 | if (rt2x00queue_full(queue)) |
154 | ieee80211_stop_queue(rt2x00dev->hw, control->queue); | 168 | ieee80211_stop_queue(rt2x00dev->hw, qid); |
155 | 169 | ||
156 | if (rt2x00dev->ops->lib->kick_tx_queue) | 170 | if (rt2x00dev->ops->lib->kick_tx_queue) |
157 | rt2x00dev->ops->lib->kick_tx_queue(rt2x00dev, qid); | 171 | rt2x00dev->ops->lib->kick_tx_queue(rt2x00dev, qid); |
@@ -380,9 +394,7 @@ int rt2x00mac_config_interface(struct ieee80211_hw *hw, | |||
380 | if (conf->type != IEEE80211_IF_TYPE_AP || !conf->beacon) | 394 | if (conf->type != IEEE80211_IF_TYPE_AP || !conf->beacon) |
381 | return 0; | 395 | return 0; |
382 | 396 | ||
383 | status = rt2x00dev->ops->hw->beacon_update(rt2x00dev->hw, | 397 | status = rt2x00dev->ops->hw->beacon_update(rt2x00dev->hw, conf->beacon); |
384 | conf->beacon, | ||
385 | conf->beacon_control); | ||
386 | if (status) | 398 | if (status) |
387 | dev_kfree_skb(conf->beacon); | 399 | dev_kfree_skb(conf->beacon); |
388 | 400 | ||
@@ -456,7 +468,7 @@ int rt2x00mac_get_tx_stats(struct ieee80211_hw *hw, | |||
456 | struct rt2x00_dev *rt2x00dev = hw->priv; | 468 | struct rt2x00_dev *rt2x00dev = hw->priv; |
457 | unsigned int i; | 469 | unsigned int i; |
458 | 470 | ||
459 | for (i = 0; i < hw->queues; i++) { | 471 | for (i = 0; i < rt2x00dev->ops->tx_queues; i++) { |
460 | stats[i].len = rt2x00dev->tx[i].length; | 472 | stats[i].len = rt2x00dev->tx[i].length; |
461 | stats[i].limit = rt2x00dev->tx[i].limit; | 473 | stats[i].limit = rt2x00dev->tx[i].limit; |
462 | stats[i].count = rt2x00dev->tx[i].count; | 474 | stats[i].count = rt2x00dev->tx[i].count; |
diff --git a/drivers/net/wireless/rt2x00/rt2x00pci.c b/drivers/net/wireless/rt2x00/rt2x00pci.c index c17078eac197..70a3d135f64e 100644 --- a/drivers/net/wireless/rt2x00/rt2x00pci.c +++ b/drivers/net/wireless/rt2x00/rt2x00pci.c | |||
@@ -35,18 +35,18 @@ | |||
35 | * TX data handlers. | 35 | * TX data handlers. |
36 | */ | 36 | */ |
37 | int rt2x00pci_write_tx_data(struct rt2x00_dev *rt2x00dev, | 37 | int rt2x00pci_write_tx_data(struct rt2x00_dev *rt2x00dev, |
38 | struct data_queue *queue, struct sk_buff *skb, | 38 | struct data_queue *queue, struct sk_buff *skb) |
39 | struct ieee80211_tx_control *control) | ||
40 | { | 39 | { |
41 | struct queue_entry *entry = rt2x00queue_get_entry(queue, Q_INDEX); | 40 | struct queue_entry *entry = rt2x00queue_get_entry(queue, Q_INDEX); |
42 | struct queue_entry_priv_pci_tx *priv_tx = entry->priv_data; | 41 | struct queue_entry_priv_pci *entry_priv = entry->priv_data; |
43 | struct skb_frame_desc *skbdesc; | 42 | struct skb_frame_desc *skbdesc; |
43 | struct txentry_desc txdesc; | ||
44 | u32 word; | 44 | u32 word; |
45 | 45 | ||
46 | if (rt2x00queue_full(queue)) | 46 | if (rt2x00queue_full(queue)) |
47 | return -EINVAL; | 47 | return -EINVAL; |
48 | 48 | ||
49 | rt2x00_desc_read(priv_tx->desc, 0, &word); | 49 | rt2x00_desc_read(entry_priv->desc, 0, &word); |
50 | 50 | ||
51 | if (rt2x00_get_field32(word, TXD_ENTRY_OWNER_NIC) || | 51 | if (rt2x00_get_field32(word, TXD_ENTRY_OWNER_NIC) || |
52 | rt2x00_get_field32(word, TXD_ENTRY_VALID)) { | 52 | rt2x00_get_field32(word, TXD_ENTRY_VALID)) { |
@@ -58,19 +58,27 @@ int rt2x00pci_write_tx_data(struct rt2x00_dev *rt2x00dev, | |||
58 | } | 58 | } |
59 | 59 | ||
60 | /* | 60 | /* |
61 | * Copy all TX descriptor information into txdesc, | ||
62 | * after that we are free to use the skb->cb array | ||
63 | * for our information. | ||
64 | */ | ||
65 | entry->skb = skb; | ||
66 | rt2x00queue_create_tx_descriptor(entry, &txdesc); | ||
67 | |||
68 | /* | ||
61 | * Fill in skb descriptor | 69 | * Fill in skb descriptor |
62 | */ | 70 | */ |
63 | skbdesc = get_skb_frame_desc(skb); | 71 | skbdesc = get_skb_frame_desc(skb); |
72 | memset(skbdesc, 0, sizeof(*skbdesc)); | ||
64 | skbdesc->data = skb->data; | 73 | skbdesc->data = skb->data; |
65 | skbdesc->data_len = skb->len; | 74 | skbdesc->data_len = skb->len; |
66 | skbdesc->desc = priv_tx->desc; | 75 | skbdesc->desc = entry_priv->desc; |
67 | skbdesc->desc_len = queue->desc_size; | 76 | skbdesc->desc_len = queue->desc_size; |
68 | skbdesc->entry = entry; | 77 | skbdesc->entry = entry; |
69 | 78 | ||
70 | memcpy(&priv_tx->control, control, sizeof(priv_tx->control)); | 79 | memcpy(entry_priv->data, skb->data, skb->len); |
71 | memcpy(priv_tx->data, skb->data, skb->len); | ||
72 | rt2x00lib_write_tx_desc(rt2x00dev, skb, control); | ||
73 | 80 | ||
81 | rt2x00queue_write_tx_descriptor(entry, &txdesc); | ||
74 | rt2x00queue_index_inc(queue, Q_INDEX); | 82 | rt2x00queue_index_inc(queue, Q_INDEX); |
75 | 83 | ||
76 | return 0; | 84 | return 0; |
@@ -84,7 +92,7 @@ void rt2x00pci_rxdone(struct rt2x00_dev *rt2x00dev) | |||
84 | { | 92 | { |
85 | struct data_queue *queue = rt2x00dev->rx; | 93 | struct data_queue *queue = rt2x00dev->rx; |
86 | struct queue_entry *entry; | 94 | struct queue_entry *entry; |
87 | struct queue_entry_priv_pci_rx *priv_rx; | 95 | struct queue_entry_priv_pci *entry_priv; |
88 | struct ieee80211_hdr *hdr; | 96 | struct ieee80211_hdr *hdr; |
89 | struct skb_frame_desc *skbdesc; | 97 | struct skb_frame_desc *skbdesc; |
90 | struct rxdone_entry_desc rxdesc; | 98 | struct rxdone_entry_desc rxdesc; |
@@ -94,8 +102,8 @@ void rt2x00pci_rxdone(struct rt2x00_dev *rt2x00dev) | |||
94 | 102 | ||
95 | while (1) { | 103 | while (1) { |
96 | entry = rt2x00queue_get_entry(queue, Q_INDEX); | 104 | entry = rt2x00queue_get_entry(queue, Q_INDEX); |
97 | priv_rx = entry->priv_data; | 105 | entry_priv = entry->priv_data; |
98 | rt2x00_desc_read(priv_rx->desc, 0, &word); | 106 | rt2x00_desc_read(entry_priv->desc, 0, &word); |
99 | 107 | ||
100 | if (rt2x00_get_field32(word, RXD_ENTRY_OWNER_NIC)) | 108 | if (rt2x00_get_field32(word, RXD_ENTRY_OWNER_NIC)) |
101 | break; | 109 | break; |
@@ -103,7 +111,7 @@ void rt2x00pci_rxdone(struct rt2x00_dev *rt2x00dev) | |||
103 | memset(&rxdesc, 0, sizeof(rxdesc)); | 111 | memset(&rxdesc, 0, sizeof(rxdesc)); |
104 | rt2x00dev->ops->lib->fill_rxdone(entry, &rxdesc); | 112 | rt2x00dev->ops->lib->fill_rxdone(entry, &rxdesc); |
105 | 113 | ||
106 | hdr = (struct ieee80211_hdr *)priv_rx->data; | 114 | hdr = (struct ieee80211_hdr *)entry_priv->data; |
107 | header_size = | 115 | header_size = |
108 | ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control)); | 116 | ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control)); |
109 | 117 | ||
@@ -123,7 +131,7 @@ void rt2x00pci_rxdone(struct rt2x00_dev *rt2x00dev) | |||
123 | 131 | ||
124 | skb_reserve(entry->skb, align); | 132 | skb_reserve(entry->skb, align); |
125 | memcpy(skb_put(entry->skb, rxdesc.size), | 133 | memcpy(skb_put(entry->skb, rxdesc.size), |
126 | priv_rx->data, rxdesc.size); | 134 | entry_priv->data, rxdesc.size); |
127 | 135 | ||
128 | /* | 136 | /* |
129 | * Fill in skb descriptor | 137 | * Fill in skb descriptor |
@@ -132,7 +140,7 @@ void rt2x00pci_rxdone(struct rt2x00_dev *rt2x00dev) | |||
132 | memset(skbdesc, 0, sizeof(*skbdesc)); | 140 | memset(skbdesc, 0, sizeof(*skbdesc)); |
133 | skbdesc->data = entry->skb->data; | 141 | skbdesc->data = entry->skb->data; |
134 | skbdesc->data_len = entry->skb->len; | 142 | skbdesc->data_len = entry->skb->len; |
135 | skbdesc->desc = priv_rx->desc; | 143 | skbdesc->desc = entry_priv->desc; |
136 | skbdesc->desc_len = queue->desc_size; | 144 | skbdesc->desc_len = queue->desc_size; |
137 | skbdesc->entry = entry; | 145 | skbdesc->entry = entry; |
138 | 146 | ||
@@ -143,7 +151,7 @@ void rt2x00pci_rxdone(struct rt2x00_dev *rt2x00dev) | |||
143 | 151 | ||
144 | if (test_bit(DEVICE_ENABLED_RADIO, &queue->rt2x00dev->flags)) { | 152 | if (test_bit(DEVICE_ENABLED_RADIO, &queue->rt2x00dev->flags)) { |
145 | rt2x00_set_field32(&word, RXD_ENTRY_OWNER_NIC, 1); | 153 | rt2x00_set_field32(&word, RXD_ENTRY_OWNER_NIC, 1); |
146 | rt2x00_desc_write(priv_rx->desc, 0, word); | 154 | rt2x00_desc_write(entry_priv->desc, 0, word); |
147 | } | 155 | } |
148 | 156 | ||
149 | rt2x00queue_index_inc(queue, Q_INDEX); | 157 | rt2x00queue_index_inc(queue, Q_INDEX); |
@@ -154,10 +162,10 @@ EXPORT_SYMBOL_GPL(rt2x00pci_rxdone); | |||
154 | void rt2x00pci_txdone(struct rt2x00_dev *rt2x00dev, struct queue_entry *entry, | 162 | void rt2x00pci_txdone(struct rt2x00_dev *rt2x00dev, struct queue_entry *entry, |
155 | struct txdone_entry_desc *txdesc) | 163 | struct txdone_entry_desc *txdesc) |
156 | { | 164 | { |
157 | struct queue_entry_priv_pci_tx *priv_tx = entry->priv_data; | 165 | struct queue_entry_priv_pci *entry_priv = entry->priv_data; |
166 | enum data_queue_qid qid = skb_get_queue_mapping(entry->skb); | ||
158 | u32 word; | 167 | u32 word; |
159 | 168 | ||
160 | txdesc->control = &priv_tx->control; | ||
161 | rt2x00lib_txdone(entry, txdesc); | 169 | rt2x00lib_txdone(entry, txdesc); |
162 | 170 | ||
163 | /* | 171 | /* |
@@ -165,10 +173,10 @@ void rt2x00pci_txdone(struct rt2x00_dev *rt2x00dev, struct queue_entry *entry, | |||
165 | */ | 173 | */ |
166 | entry->flags = 0; | 174 | entry->flags = 0; |
167 | 175 | ||
168 | rt2x00_desc_read(priv_tx->desc, 0, &word); | 176 | rt2x00_desc_read(entry_priv->desc, 0, &word); |
169 | rt2x00_set_field32(&word, TXD_ENTRY_OWNER_NIC, 0); | 177 | rt2x00_set_field32(&word, TXD_ENTRY_OWNER_NIC, 0); |
170 | rt2x00_set_field32(&word, TXD_ENTRY_VALID, 0); | 178 | rt2x00_set_field32(&word, TXD_ENTRY_VALID, 0); |
171 | rt2x00_desc_write(priv_tx->desc, 0, word); | 179 | rt2x00_desc_write(entry_priv->desc, 0, word); |
172 | 180 | ||
173 | rt2x00queue_index_inc(entry->queue, Q_INDEX_DONE); | 181 | rt2x00queue_index_inc(entry->queue, Q_INDEX_DONE); |
174 | 182 | ||
@@ -178,7 +186,7 @@ void rt2x00pci_txdone(struct rt2x00_dev *rt2x00dev, struct queue_entry *entry, | |||
178 | * is reenabled when the txdone handler has finished. | 186 | * is reenabled when the txdone handler has finished. |
179 | */ | 187 | */ |
180 | if (!rt2x00queue_full(entry->queue)) | 188 | if (!rt2x00queue_full(entry->queue)) |
181 | ieee80211_wake_queue(rt2x00dev->hw, priv_tx->control.queue); | 189 | ieee80211_wake_queue(rt2x00dev->hw, qid); |
182 | 190 | ||
183 | } | 191 | } |
184 | EXPORT_SYMBOL_GPL(rt2x00pci_txdone); | 192 | EXPORT_SYMBOL_GPL(rt2x00pci_txdone); |
@@ -217,14 +225,9 @@ static int rt2x00pci_alloc_queue_dma(struct rt2x00_dev *rt2x00dev, | |||
217 | struct data_queue *queue) | 225 | struct data_queue *queue) |
218 | { | 226 | { |
219 | struct pci_dev *pci_dev = rt2x00dev_pci(rt2x00dev); | 227 | struct pci_dev *pci_dev = rt2x00dev_pci(rt2x00dev); |
220 | struct queue_entry_priv_pci_rx *priv_rx; | 228 | struct queue_entry_priv_pci *entry_priv; |
221 | struct queue_entry_priv_pci_tx *priv_tx; | ||
222 | void *addr; | 229 | void *addr; |
223 | dma_addr_t dma; | 230 | dma_addr_t dma; |
224 | void *desc_addr; | ||
225 | dma_addr_t desc_dma; | ||
226 | void *data_addr; | ||
227 | dma_addr_t data_dma; | ||
228 | unsigned int i; | 231 | unsigned int i; |
229 | 232 | ||
230 | /* | 233 | /* |
@@ -240,24 +243,11 @@ static int rt2x00pci_alloc_queue_dma(struct rt2x00_dev *rt2x00dev, | |||
240 | * Initialize all queue entries to contain valid addresses. | 243 | * Initialize all queue entries to contain valid addresses. |
241 | */ | 244 | */ |
242 | for (i = 0; i < queue->limit; i++) { | 245 | for (i = 0; i < queue->limit; i++) { |
243 | desc_addr = desc_offset(queue, addr, i); | 246 | entry_priv = queue->entries[i].priv_data; |
244 | desc_dma = desc_offset(queue, dma, i); | 247 | entry_priv->desc = desc_offset(queue, addr, i); |
245 | data_addr = data_offset(queue, addr, i); | 248 | entry_priv->desc_dma = desc_offset(queue, dma, i); |
246 | data_dma = data_offset(queue, dma, i); | 249 | entry_priv->data = data_offset(queue, addr, i); |
247 | 250 | entry_priv->data_dma = data_offset(queue, dma, i); | |
248 | if (queue->qid == QID_RX) { | ||
249 | priv_rx = queue->entries[i].priv_data; | ||
250 | priv_rx->desc = desc_addr; | ||
251 | priv_rx->desc_dma = desc_dma; | ||
252 | priv_rx->data = data_addr; | ||
253 | priv_rx->data_dma = data_dma; | ||
254 | } else { | ||
255 | priv_tx = queue->entries[i].priv_data; | ||
256 | priv_tx->desc = desc_addr; | ||
257 | priv_tx->desc_dma = desc_dma; | ||
258 | priv_tx->data = data_addr; | ||
259 | priv_tx->data_dma = data_dma; | ||
260 | } | ||
261 | } | 251 | } |
262 | 252 | ||
263 | return 0; | 253 | return 0; |
@@ -267,28 +257,13 @@ static void rt2x00pci_free_queue_dma(struct rt2x00_dev *rt2x00dev, | |||
267 | struct data_queue *queue) | 257 | struct data_queue *queue) |
268 | { | 258 | { |
269 | struct pci_dev *pci_dev = rt2x00dev_pci(rt2x00dev); | 259 | struct pci_dev *pci_dev = rt2x00dev_pci(rt2x00dev); |
270 | struct queue_entry_priv_pci_rx *priv_rx; | 260 | struct queue_entry_priv_pci *entry_priv = |
271 | struct queue_entry_priv_pci_tx *priv_tx; | 261 | queue->entries[0].priv_data; |
272 | void *data_addr; | ||
273 | dma_addr_t data_dma; | ||
274 | |||
275 | if (queue->qid == QID_RX) { | ||
276 | priv_rx = queue->entries[0].priv_data; | ||
277 | data_addr = priv_rx->data; | ||
278 | data_dma = priv_rx->data_dma; | ||
279 | |||
280 | priv_rx->data = NULL; | ||
281 | } else { | ||
282 | priv_tx = queue->entries[0].priv_data; | ||
283 | data_addr = priv_tx->data; | ||
284 | data_dma = priv_tx->data_dma; | ||
285 | |||
286 | priv_tx->data = NULL; | ||
287 | } | ||
288 | 262 | ||
289 | if (data_addr) | 263 | if (entry_priv->data) |
290 | pci_free_consistent(pci_dev, dma_size(queue), | 264 | pci_free_consistent(pci_dev, dma_size(queue), |
291 | data_addr, data_dma); | 265 | entry_priv->data, entry_priv->data_dma); |
266 | entry_priv->data = NULL; | ||
292 | } | 267 | } |
293 | 268 | ||
294 | int rt2x00pci_initialize(struct rt2x00_dev *rt2x00dev) | 269 | int rt2x00pci_initialize(struct rt2x00_dev *rt2x00dev) |
diff --git a/drivers/net/wireless/rt2x00/rt2x00pci.h b/drivers/net/wireless/rt2x00/rt2x00pci.h index 2b0ef17bba6e..37c851e442c1 100644 --- a/drivers/net/wireless/rt2x00/rt2x00pci.h +++ b/drivers/net/wireless/rt2x00/rt2x00pci.h | |||
@@ -91,42 +91,22 @@ rt2x00pci_register_multiwrite(struct rt2x00_dev *rt2x00dev, | |||
91 | * TX data handlers. | 91 | * TX data handlers. |
92 | */ | 92 | */ |
93 | int rt2x00pci_write_tx_data(struct rt2x00_dev *rt2x00dev, | 93 | int rt2x00pci_write_tx_data(struct rt2x00_dev *rt2x00dev, |
94 | struct data_queue *queue, struct sk_buff *skb, | 94 | struct data_queue *queue, struct sk_buff *skb); |
95 | struct ieee80211_tx_control *control); | ||
96 | 95 | ||
97 | /** | 96 | /** |
98 | * struct queue_entry_priv_pci_rx: Per RX entry PCI specific information | 97 | * struct queue_entry_priv_pci: Per entry PCI specific information |
99 | * | ||
100 | * @desc: Pointer to device descriptor. | ||
101 | * @desc_dma: DMA pointer to @desc. | ||
102 | * @data: Pointer to device's entry memory. | ||
103 | * @data_dma: DMA pointer to &data. | ||
104 | */ | ||
105 | struct queue_entry_priv_pci_rx { | ||
106 | __le32 *desc; | ||
107 | dma_addr_t desc_dma; | ||
108 | |||
109 | void *data; | ||
110 | dma_addr_t data_dma; | ||
111 | }; | ||
112 | |||
113 | /** | ||
114 | * struct queue_entry_priv_pci_tx: Per TX entry PCI specific information | ||
115 | * | 98 | * |
116 | * @desc: Pointer to device descriptor | 99 | * @desc: Pointer to device descriptor |
117 | * @desc_dma: DMA pointer to @desc. | 100 | * @desc_dma: DMA pointer to &desc. |
118 | * @data: Pointer to device's entry memory. | 101 | * @data: Pointer to device's entry memory. |
119 | * @data_dma: DMA pointer to &data. | 102 | * @data_dma: DMA pointer to &data. |
120 | * @control: mac80211 control structure used to transmit data. | ||
121 | */ | 103 | */ |
122 | struct queue_entry_priv_pci_tx { | 104 | struct queue_entry_priv_pci { |
123 | __le32 *desc; | 105 | __le32 *desc; |
124 | dma_addr_t desc_dma; | 106 | dma_addr_t desc_dma; |
125 | 107 | ||
126 | void *data; | 108 | void *data; |
127 | dma_addr_t data_dma; | 109 | dma_addr_t data_dma; |
128 | |||
129 | struct ieee80211_tx_control control; | ||
130 | }; | 110 | }; |
131 | 111 | ||
132 | /** | 112 | /** |
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c index e5b861f8416d..e69ef4b19239 100644 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c | |||
@@ -29,12 +29,171 @@ | |||
29 | #include "rt2x00.h" | 29 | #include "rt2x00.h" |
30 | #include "rt2x00lib.h" | 30 | #include "rt2x00lib.h" |
31 | 31 | ||
32 | void rt2x00queue_create_tx_descriptor(struct queue_entry *entry, | ||
33 | struct txentry_desc *txdesc) | ||
34 | { | ||
35 | struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; | ||
36 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(entry->skb); | ||
37 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)entry->skb->data; | ||
38 | struct ieee80211_rate *rate = | ||
39 | ieee80211_get_tx_rate(rt2x00dev->hw, tx_info); | ||
40 | const struct rt2x00_rate *hwrate; | ||
41 | unsigned int data_length; | ||
42 | unsigned int duration; | ||
43 | unsigned int residual; | ||
44 | u16 frame_control; | ||
45 | |||
46 | memset(txdesc, 0, sizeof(*txdesc)); | ||
47 | |||
48 | /* | ||
49 | * Initialize information from queue | ||
50 | */ | ||
51 | txdesc->queue = entry->queue->qid; | ||
52 | txdesc->cw_min = entry->queue->cw_min; | ||
53 | txdesc->cw_max = entry->queue->cw_max; | ||
54 | txdesc->aifs = entry->queue->aifs; | ||
55 | |||
56 | /* Data length should be extended with 4 bytes for CRC */ | ||
57 | data_length = entry->skb->len + 4; | ||
58 | |||
59 | /* | ||
60 | * Read required fields from ieee80211 header. | ||
61 | */ | ||
62 | frame_control = le16_to_cpu(hdr->frame_control); | ||
63 | |||
64 | /* | ||
65 | * Check whether this frame is to be acked. | ||
66 | */ | ||
67 | if (!(tx_info->flags & IEEE80211_TX_CTL_NO_ACK)) | ||
68 | __set_bit(ENTRY_TXD_ACK, &txdesc->flags); | ||
69 | |||
70 | /* | ||
71 | * Check if this is a RTS/CTS frame | ||
72 | */ | ||
73 | if (is_rts_frame(frame_control) || is_cts_frame(frame_control)) { | ||
74 | __set_bit(ENTRY_TXD_BURST, &txdesc->flags); | ||
75 | if (is_rts_frame(frame_control)) | ||
76 | __set_bit(ENTRY_TXD_RTS_FRAME, &txdesc->flags); | ||
77 | else | ||
78 | __set_bit(ENTRY_TXD_CTS_FRAME, &txdesc->flags); | ||
79 | if (tx_info->control.rts_cts_rate_idx >= 0) | ||
80 | rate = | ||
81 | ieee80211_get_rts_cts_rate(rt2x00dev->hw, tx_info); | ||
82 | } | ||
83 | |||
84 | /* | ||
85 | * Determine retry information. | ||
86 | */ | ||
87 | txdesc->retry_limit = tx_info->control.retry_limit; | ||
88 | if (tx_info->flags & IEEE80211_TX_CTL_LONG_RETRY_LIMIT) | ||
89 | __set_bit(ENTRY_TXD_RETRY_MODE, &txdesc->flags); | ||
90 | |||
91 | /* | ||
92 | * Check if more fragments are pending | ||
93 | */ | ||
94 | if (ieee80211_get_morefrag(hdr)) { | ||
95 | __set_bit(ENTRY_TXD_BURST, &txdesc->flags); | ||
96 | __set_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags); | ||
97 | } | ||
98 | |||
99 | /* | ||
100 | * Beacons and probe responses require the tsf timestamp | ||
101 | * to be inserted into the frame. | ||
102 | */ | ||
103 | if (txdesc->queue == QID_BEACON || is_probe_resp(frame_control)) | ||
104 | __set_bit(ENTRY_TXD_REQ_TIMESTAMP, &txdesc->flags); | ||
105 | |||
106 | /* | ||
107 | * Determine with what IFS priority this frame should be send. | ||
108 | * Set ifs to IFS_SIFS when the this is not the first fragment, | ||
109 | * or this fragment came after RTS/CTS. | ||
110 | */ | ||
111 | if (test_bit(ENTRY_TXD_RTS_FRAME, &txdesc->flags)) { | ||
112 | txdesc->ifs = IFS_SIFS; | ||
113 | } else if (tx_info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT) { | ||
114 | __set_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags); | ||
115 | txdesc->ifs = IFS_BACKOFF; | ||
116 | } else { | ||
117 | txdesc->ifs = IFS_SIFS; | ||
118 | } | ||
119 | |||
120 | /* | ||
121 | * PLCP setup | ||
122 | * Length calculation depends on OFDM/CCK rate. | ||
123 | */ | ||
124 | hwrate = rt2x00_get_rate(rate->hw_value); | ||
125 | txdesc->signal = hwrate->plcp; | ||
126 | txdesc->service = 0x04; | ||
127 | |||
128 | if (hwrate->flags & DEV_RATE_OFDM) { | ||
129 | __set_bit(ENTRY_TXD_OFDM_RATE, &txdesc->flags); | ||
130 | |||
131 | txdesc->length_high = (data_length >> 6) & 0x3f; | ||
132 | txdesc->length_low = data_length & 0x3f; | ||
133 | } else { | ||
134 | /* | ||
135 | * Convert length to microseconds. | ||
136 | */ | ||
137 | residual = get_duration_res(data_length, hwrate->bitrate); | ||
138 | duration = get_duration(data_length, hwrate->bitrate); | ||
139 | |||
140 | if (residual != 0) { | ||
141 | duration++; | ||
142 | |||
143 | /* | ||
144 | * Check if we need to set the Length Extension | ||
145 | */ | ||
146 | if (hwrate->bitrate == 110 && residual <= 30) | ||
147 | txdesc->service |= 0x80; | ||
148 | } | ||
149 | |||
150 | txdesc->length_high = (duration >> 8) & 0xff; | ||
151 | txdesc->length_low = duration & 0xff; | ||
152 | |||
153 | /* | ||
154 | * When preamble is enabled we should set the | ||
155 | * preamble bit for the signal. | ||
156 | */ | ||
157 | if (rt2x00_get_rate_preamble(rate->hw_value)) | ||
158 | txdesc->signal |= 0x08; | ||
159 | } | ||
160 | } | ||
161 | EXPORT_SYMBOL_GPL(rt2x00queue_create_tx_descriptor); | ||
162 | |||
163 | void rt2x00queue_write_tx_descriptor(struct queue_entry *entry, | ||
164 | struct txentry_desc *txdesc) | ||
165 | { | ||
166 | struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; | ||
167 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); | ||
168 | |||
169 | rt2x00dev->ops->lib->write_tx_desc(rt2x00dev, entry->skb, txdesc); | ||
170 | |||
171 | /* | ||
172 | * All processing on the frame has been completed, this means | ||
173 | * it is now ready to be dumped to userspace through debugfs. | ||
174 | */ | ||
175 | rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_TX, entry->skb); | ||
176 | |||
177 | /* | ||
178 | * We are done writing the frame to the queue entry, | ||
179 | * also kick the queue in case the correct flags are set, | ||
180 | * note that this will automatically filter beacons and | ||
181 | * RTS/CTS frames since those frames don't have this flag | ||
182 | * set. | ||
183 | */ | ||
184 | if (rt2x00dev->ops->lib->kick_tx_queue && | ||
185 | !(skbdesc->flags & FRAME_DESC_DRIVER_GENERATED)) | ||
186 | rt2x00dev->ops->lib->kick_tx_queue(rt2x00dev, | ||
187 | entry->queue->qid); | ||
188 | } | ||
189 | EXPORT_SYMBOL_GPL(rt2x00queue_write_tx_descriptor); | ||
190 | |||
32 | struct data_queue *rt2x00queue_get_queue(struct rt2x00_dev *rt2x00dev, | 191 | struct data_queue *rt2x00queue_get_queue(struct rt2x00_dev *rt2x00dev, |
33 | const enum data_queue_qid queue) | 192 | const enum data_queue_qid queue) |
34 | { | 193 | { |
35 | int atim = test_bit(DRIVER_REQUIRE_ATIM_QUEUE, &rt2x00dev->flags); | 194 | int atim = test_bit(DRIVER_REQUIRE_ATIM_QUEUE, &rt2x00dev->flags); |
36 | 195 | ||
37 | if (queue < rt2x00dev->hw->queues && rt2x00dev->tx) | 196 | if (queue < rt2x00dev->ops->tx_queues && rt2x00dev->tx) |
38 | return &rt2x00dev->tx[queue]; | 197 | return &rt2x00dev->tx[queue]; |
39 | 198 | ||
40 | if (!rt2x00dev->bcn) | 199 | if (!rt2x00dev->bcn) |
@@ -255,11 +414,11 @@ int rt2x00queue_allocate(struct rt2x00_dev *rt2x00dev) | |||
255 | /* | 414 | /* |
256 | * We need the following queues: | 415 | * We need the following queues: |
257 | * RX: 1 | 416 | * RX: 1 |
258 | * TX: hw->queues | 417 | * TX: ops->tx_queues |
259 | * Beacon: 1 | 418 | * Beacon: 1 |
260 | * Atim: 1 (if required) | 419 | * Atim: 1 (if required) |
261 | */ | 420 | */ |
262 | rt2x00dev->data_queues = 2 + rt2x00dev->hw->queues + req_atim; | 421 | rt2x00dev->data_queues = 2 + rt2x00dev->ops->tx_queues + req_atim; |
263 | 422 | ||
264 | queue = kzalloc(rt2x00dev->data_queues * sizeof(*queue), GFP_KERNEL); | 423 | queue = kzalloc(rt2x00dev->data_queues * sizeof(*queue), GFP_KERNEL); |
265 | if (!queue) { | 424 | if (!queue) { |
@@ -272,7 +431,7 @@ int rt2x00queue_allocate(struct rt2x00_dev *rt2x00dev) | |||
272 | */ | 431 | */ |
273 | rt2x00dev->rx = queue; | 432 | rt2x00dev->rx = queue; |
274 | rt2x00dev->tx = &queue[1]; | 433 | rt2x00dev->tx = &queue[1]; |
275 | rt2x00dev->bcn = &queue[1 + rt2x00dev->hw->queues]; | 434 | rt2x00dev->bcn = &queue[1 + rt2x00dev->ops->tx_queues]; |
276 | 435 | ||
277 | /* | 436 | /* |
278 | * Initialize queue parameters. | 437 | * Initialize queue parameters. |
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.h b/drivers/net/wireless/rt2x00/rt2x00queue.h index d1707a7ca41f..4d00ced14cc7 100644 --- a/drivers/net/wireless/rt2x00/rt2x00queue.h +++ b/drivers/net/wireless/rt2x00/rt2x00queue.h | |||
@@ -80,19 +80,6 @@ enum data_queue_qid { | |||
80 | }; | 80 | }; |
81 | 81 | ||
82 | /** | 82 | /** |
83 | * mac80211_queue_to_qid - Convert mac80211 queue to rt2x00 qid | ||
84 | * @queue: mac80211 queue. | ||
85 | */ | ||
86 | static inline enum data_queue_qid mac80211_queue_to_qid(unsigned int queue) | ||
87 | { | ||
88 | /* Regular TX queues are mapped directly */ | ||
89 | if (queue < 4) | ||
90 | return queue; | ||
91 | WARN_ON(1); | ||
92 | return QID_OTHER; | ||
93 | } | ||
94 | |||
95 | /** | ||
96 | * enum skb_frame_desc_flags: Flags for &struct skb_frame_desc | 83 | * enum skb_frame_desc_flags: Flags for &struct skb_frame_desc |
97 | * | 84 | * |
98 | * @FRAME_DESC_DRIVER_GENERATED: Frame was generated inside driver | 85 | * @FRAME_DESC_DRIVER_GENERATED: Frame was generated inside driver |
@@ -105,11 +92,10 @@ enum skb_frame_desc_flags { | |||
105 | /** | 92 | /** |
106 | * struct skb_frame_desc: Descriptor information for the skb buffer | 93 | * struct skb_frame_desc: Descriptor information for the skb buffer |
107 | * | 94 | * |
108 | * This structure is placed over the skb->cb array, this means that | 95 | * This structure is placed over the driver_data array, this means that |
109 | * this structure should not exceed the size of that array (48 bytes). | 96 | * this structure should not exceed the size of that array (40 bytes). |
110 | * | 97 | * |
111 | * @flags: Frame flags, see &enum skb_frame_desc_flags. | 98 | * @flags: Frame flags, see &enum skb_frame_desc_flags. |
112 | * @frame_type: Frame type, see &enum rt2x00_dump_type. | ||
113 | * @data: Pointer to data part of frame (Start of ieee80211 header). | 99 | * @data: Pointer to data part of frame (Start of ieee80211 header). |
114 | * @desc: Pointer to descriptor part of the frame. | 100 | * @desc: Pointer to descriptor part of the frame. |
115 | * Note that this pointer could point to something outside | 101 | * Note that this pointer could point to something outside |
@@ -121,21 +107,24 @@ enum skb_frame_desc_flags { | |||
121 | struct skb_frame_desc { | 107 | struct skb_frame_desc { |
122 | unsigned int flags; | 108 | unsigned int flags; |
123 | 109 | ||
124 | unsigned int frame_type; | 110 | unsigned short data_len; |
111 | unsigned short desc_len; | ||
125 | 112 | ||
126 | void *data; | 113 | void *data; |
127 | void *desc; | 114 | void *desc; |
128 | 115 | ||
129 | unsigned int data_len; | ||
130 | unsigned int desc_len; | ||
131 | |||
132 | struct queue_entry *entry; | 116 | struct queue_entry *entry; |
133 | }; | 117 | }; |
134 | 118 | ||
119 | /** | ||
120 | * get_skb_frame_desc - Obtain the rt2x00 frame descriptor from a sk_buff. | ||
121 | * @skb: &struct sk_buff from where we obtain the &struct skb_frame_desc | ||
122 | */ | ||
135 | static inline struct skb_frame_desc* get_skb_frame_desc(struct sk_buff *skb) | 123 | static inline struct skb_frame_desc* get_skb_frame_desc(struct sk_buff *skb) |
136 | { | 124 | { |
137 | BUILD_BUG_ON(sizeof(struct skb_frame_desc) > sizeof(skb->cb)); | 125 | BUILD_BUG_ON(sizeof(struct skb_frame_desc) > |
138 | return (struct skb_frame_desc *)&skb->cb[0]; | 126 | IEEE80211_TX_INFO_DRIVER_DATA_SIZE); |
127 | return (struct skb_frame_desc *)&IEEE80211_SKB_CB(skb)->driver_data; | ||
139 | } | 128 | } |
140 | 129 | ||
141 | /** | 130 | /** |
@@ -171,18 +160,32 @@ struct rxdone_entry_desc { | |||
171 | }; | 160 | }; |
172 | 161 | ||
173 | /** | 162 | /** |
163 | * enum txdone_entry_desc_flags: Flags for &struct txdone_entry_desc | ||
164 | * | ||
165 | * @TXDONE_UNKNOWN: Hardware could not determine success of transmission. | ||
166 | * @TXDONE_SUCCESS: Frame was successfully send | ||
167 | * @TXDONE_FAILURE: Frame was not successfully send | ||
168 | * @TXDONE_EXCESSIVE_RETRY: In addition to &TXDONE_FAILURE, the | ||
169 | * frame transmission failed due to excessive retries. | ||
170 | */ | ||
171 | enum txdone_entry_desc_flags { | ||
172 | TXDONE_UNKNOWN = 1 << 0, | ||
173 | TXDONE_SUCCESS = 1 << 1, | ||
174 | TXDONE_FAILURE = 1 << 2, | ||
175 | TXDONE_EXCESSIVE_RETRY = 1 << 3, | ||
176 | }; | ||
177 | |||
178 | /** | ||
174 | * struct txdone_entry_desc: TX done entry descriptor | 179 | * struct txdone_entry_desc: TX done entry descriptor |
175 | * | 180 | * |
176 | * Summary of information that has been read from the TX frame descriptor | 181 | * Summary of information that has been read from the TX frame descriptor |
177 | * after the device is done with transmission. | 182 | * after the device is done with transmission. |
178 | * | 183 | * |
179 | * @control: Control structure which was used to transmit the frame. | 184 | * @flags: TX done flags (See &enum txdone_entry_desc_flags). |
180 | * @status: TX status (See &enum tx_status). | ||
181 | * @retry: Retry count. | 185 | * @retry: Retry count. |
182 | */ | 186 | */ |
183 | struct txdone_entry_desc { | 187 | struct txdone_entry_desc { |
184 | struct ieee80211_tx_control *control; | 188 | unsigned long flags; |
185 | int status; | ||
186 | int retry; | 189 | int retry; |
187 | }; | 190 | }; |
188 | 191 | ||
@@ -190,19 +193,25 @@ struct txdone_entry_desc { | |||
190 | * enum txentry_desc_flags: Status flags for TX entry descriptor | 193 | * enum txentry_desc_flags: Status flags for TX entry descriptor |
191 | * | 194 | * |
192 | * @ENTRY_TXD_RTS_FRAME: This frame is a RTS frame. | 195 | * @ENTRY_TXD_RTS_FRAME: This frame is a RTS frame. |
196 | * @ENTRY_TXD_CTS_FRAME: This frame is a CTS-to-self frame. | ||
193 | * @ENTRY_TXD_OFDM_RATE: This frame is send out with an OFDM rate. | 197 | * @ENTRY_TXD_OFDM_RATE: This frame is send out with an OFDM rate. |
198 | * @ENTRY_TXD_FIRST_FRAGMENT: This is the first frame. | ||
194 | * @ENTRY_TXD_MORE_FRAG: This frame is followed by another fragment. | 199 | * @ENTRY_TXD_MORE_FRAG: This frame is followed by another fragment. |
195 | * @ENTRY_TXD_REQ_TIMESTAMP: Require timestamp to be inserted. | 200 | * @ENTRY_TXD_REQ_TIMESTAMP: Require timestamp to be inserted. |
196 | * @ENTRY_TXD_BURST: This frame belongs to the same burst event. | 201 | * @ENTRY_TXD_BURST: This frame belongs to the same burst event. |
197 | * @ENTRY_TXD_ACK: An ACK is required for this frame. | 202 | * @ENTRY_TXD_ACK: An ACK is required for this frame. |
203 | * @ENTRY_TXD_RETRY_MODE: When set, the long retry count is used. | ||
198 | */ | 204 | */ |
199 | enum txentry_desc_flags { | 205 | enum txentry_desc_flags { |
200 | ENTRY_TXD_RTS_FRAME, | 206 | ENTRY_TXD_RTS_FRAME, |
207 | ENTRY_TXD_CTS_FRAME, | ||
201 | ENTRY_TXD_OFDM_RATE, | 208 | ENTRY_TXD_OFDM_RATE, |
209 | ENTRY_TXD_FIRST_FRAGMENT, | ||
202 | ENTRY_TXD_MORE_FRAG, | 210 | ENTRY_TXD_MORE_FRAG, |
203 | ENTRY_TXD_REQ_TIMESTAMP, | 211 | ENTRY_TXD_REQ_TIMESTAMP, |
204 | ENTRY_TXD_BURST, | 212 | ENTRY_TXD_BURST, |
205 | ENTRY_TXD_ACK, | 213 | ENTRY_TXD_ACK, |
214 | ENTRY_TXD_RETRY_MODE, | ||
206 | }; | 215 | }; |
207 | 216 | ||
208 | /** | 217 | /** |
@@ -216,6 +225,7 @@ enum txentry_desc_flags { | |||
216 | * @length_low: PLCP length low word. | 225 | * @length_low: PLCP length low word. |
217 | * @signal: PLCP signal. | 226 | * @signal: PLCP signal. |
218 | * @service: PLCP service. | 227 | * @service: PLCP service. |
228 | * @retry_limit: Max number of retries. | ||
219 | * @aifs: AIFS value. | 229 | * @aifs: AIFS value. |
220 | * @ifs: IFS value. | 230 | * @ifs: IFS value. |
221 | * @cw_min: cwmin value. | 231 | * @cw_min: cwmin value. |
@@ -231,10 +241,11 @@ struct txentry_desc { | |||
231 | u16 signal; | 241 | u16 signal; |
232 | u16 service; | 242 | u16 service; |
233 | 243 | ||
234 | int aifs; | 244 | short retry_limit; |
235 | int ifs; | 245 | short aifs; |
236 | int cw_min; | 246 | short ifs; |
237 | int cw_max; | 247 | short cw_min; |
248 | short cw_max; | ||
238 | }; | 249 | }; |
239 | 250 | ||
240 | /** | 251 | /** |
@@ -378,7 +389,7 @@ struct data_queue_desc { | |||
378 | * the end of the TX queue array. | 389 | * the end of the TX queue array. |
379 | */ | 390 | */ |
380 | #define tx_queue_end(__dev) \ | 391 | #define tx_queue_end(__dev) \ |
381 | &(__dev)->tx[(__dev)->hw->queues] | 392 | &(__dev)->tx[(__dev)->ops->tx_queues] |
382 | 393 | ||
383 | /** | 394 | /** |
384 | * queue_loop - Loop through the queues within a specific range (HELPER MACRO). | 395 | * queue_loop - Loop through the queues within a specific range (HELPER MACRO). |
diff --git a/drivers/net/wireless/rt2x00/rt2x00reg.h b/drivers/net/wireless/rt2x00/rt2x00reg.h index 0325bed2fbf5..3f255df58b78 100644 --- a/drivers/net/wireless/rt2x00/rt2x00reg.h +++ b/drivers/net/wireless/rt2x00/rt2x00reg.h | |||
@@ -27,17 +27,6 @@ | |||
27 | #define RT2X00REG_H | 27 | #define RT2X00REG_H |
28 | 28 | ||
29 | /* | 29 | /* |
30 | * TX result flags. | ||
31 | */ | ||
32 | enum tx_status { | ||
33 | TX_SUCCESS = 0, | ||
34 | TX_SUCCESS_RETRY = 1, | ||
35 | TX_FAIL_RETRY = 2, | ||
36 | TX_FAIL_INVALID = 3, | ||
37 | TX_FAIL_OTHER = 4, | ||
38 | }; | ||
39 | |||
40 | /* | ||
41 | * Antenna values | 30 | * Antenna values |
42 | */ | 31 | */ |
43 | enum antenna { | 32 | enum antenna { |
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.c b/drivers/net/wireless/rt2x00/rt2x00usb.c index 98aafc2d584a..52d12fdc0ccf 100644 --- a/drivers/net/wireless/rt2x00/rt2x00usb.c +++ b/drivers/net/wireless/rt2x00/rt2x00usb.c | |||
@@ -129,9 +129,9 @@ static void rt2x00usb_interrupt_txdone(struct urb *urb) | |||
129 | { | 129 | { |
130 | struct queue_entry *entry = (struct queue_entry *)urb->context; | 130 | struct queue_entry *entry = (struct queue_entry *)urb->context; |
131 | struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; | 131 | struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; |
132 | struct queue_entry_priv_usb_tx *priv_tx = entry->priv_data; | ||
133 | struct txdone_entry_desc txdesc; | 132 | struct txdone_entry_desc txdesc; |
134 | __le32 *txd = (__le32 *)entry->skb->data; | 133 | __le32 *txd = (__le32 *)entry->skb->data; |
134 | enum data_queue_qid qid = skb_get_queue_mapping(entry->skb); | ||
135 | u32 word; | 135 | u32 word; |
136 | 136 | ||
137 | if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags) || | 137 | if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags) || |
@@ -147,10 +147,18 @@ static void rt2x00usb_interrupt_txdone(struct urb *urb) | |||
147 | 147 | ||
148 | /* | 148 | /* |
149 | * Obtain the status about this packet. | 149 | * Obtain the status about this packet. |
150 | * Note that when the status is 0 it does not mean the | ||
151 | * frame was send out correctly. It only means the frame | ||
152 | * was succesfully pushed to the hardware, we have no | ||
153 | * way to determine the transmission status right now. | ||
154 | * (Only indirectly by looking at the failed TX counters | ||
155 | * in the register). | ||
150 | */ | 156 | */ |
151 | txdesc.status = !urb->status ? TX_SUCCESS : TX_FAIL_RETRY; | 157 | if (!urb->status) |
158 | __set_bit(TXDONE_UNKNOWN, &txdesc.flags); | ||
159 | else | ||
160 | __set_bit(TXDONE_FAILURE, &txdesc.flags); | ||
152 | txdesc.retry = 0; | 161 | txdesc.retry = 0; |
153 | txdesc.control = &priv_tx->control; | ||
154 | 162 | ||
155 | rt2x00lib_txdone(entry, &txdesc); | 163 | rt2x00lib_txdone(entry, &txdesc); |
156 | 164 | ||
@@ -166,17 +174,17 @@ static void rt2x00usb_interrupt_txdone(struct urb *urb) | |||
166 | * is reenabled when the txdone handler has finished. | 174 | * is reenabled when the txdone handler has finished. |
167 | */ | 175 | */ |
168 | if (!rt2x00queue_full(entry->queue)) | 176 | if (!rt2x00queue_full(entry->queue)) |
169 | ieee80211_wake_queue(rt2x00dev->hw, priv_tx->control.queue); | 177 | ieee80211_wake_queue(rt2x00dev->hw, qid); |
170 | } | 178 | } |
171 | 179 | ||
172 | int rt2x00usb_write_tx_data(struct rt2x00_dev *rt2x00dev, | 180 | int rt2x00usb_write_tx_data(struct rt2x00_dev *rt2x00dev, |
173 | struct data_queue *queue, struct sk_buff *skb, | 181 | struct data_queue *queue, struct sk_buff *skb) |
174 | struct ieee80211_tx_control *control) | ||
175 | { | 182 | { |
176 | struct usb_device *usb_dev = rt2x00dev_usb_dev(rt2x00dev); | 183 | struct usb_device *usb_dev = rt2x00dev_usb_dev(rt2x00dev); |
177 | struct queue_entry *entry = rt2x00queue_get_entry(queue, Q_INDEX); | 184 | struct queue_entry *entry = rt2x00queue_get_entry(queue, Q_INDEX); |
178 | struct queue_entry_priv_usb_tx *priv_tx = entry->priv_data; | 185 | struct queue_entry_priv_usb *entry_priv = entry->priv_data; |
179 | struct skb_frame_desc *skbdesc; | 186 | struct skb_frame_desc *skbdesc; |
187 | struct txentry_desc txdesc; | ||
180 | u32 length; | 188 | u32 length; |
181 | 189 | ||
182 | if (rt2x00queue_full(queue)) | 190 | if (rt2x00queue_full(queue)) |
@@ -191,6 +199,14 @@ int rt2x00usb_write_tx_data(struct rt2x00_dev *rt2x00dev, | |||
191 | } | 199 | } |
192 | 200 | ||
193 | /* | 201 | /* |
202 | * Copy all TX descriptor information into txdesc, | ||
203 | * after that we are free to use the skb->cb array | ||
204 | * for our information. | ||
205 | */ | ||
206 | entry->skb = skb; | ||
207 | rt2x00queue_create_tx_descriptor(entry, &txdesc); | ||
208 | |||
209 | /* | ||
194 | * Add the descriptor in front of the skb. | 210 | * Add the descriptor in front of the skb. |
195 | */ | 211 | */ |
196 | skb_push(skb, queue->desc_size); | 212 | skb_push(skb, queue->desc_size); |
@@ -200,14 +216,14 @@ int rt2x00usb_write_tx_data(struct rt2x00_dev *rt2x00dev, | |||
200 | * Fill in skb descriptor | 216 | * Fill in skb descriptor |
201 | */ | 217 | */ |
202 | skbdesc = get_skb_frame_desc(skb); | 218 | skbdesc = get_skb_frame_desc(skb); |
219 | memset(skbdesc, 0, sizeof(*skbdesc)); | ||
203 | skbdesc->data = skb->data + queue->desc_size; | 220 | skbdesc->data = skb->data + queue->desc_size; |
204 | skbdesc->data_len = skb->len - queue->desc_size; | 221 | skbdesc->data_len = skb->len - queue->desc_size; |
205 | skbdesc->desc = skb->data; | 222 | skbdesc->desc = skb->data; |
206 | skbdesc->desc_len = queue->desc_size; | 223 | skbdesc->desc_len = queue->desc_size; |
207 | skbdesc->entry = entry; | 224 | skbdesc->entry = entry; |
208 | 225 | ||
209 | memcpy(&priv_tx->control, control, sizeof(priv_tx->control)); | 226 | rt2x00queue_write_tx_descriptor(entry, &txdesc); |
210 | rt2x00lib_write_tx_desc(rt2x00dev, skb, control); | ||
211 | 227 | ||
212 | /* | 228 | /* |
213 | * USB devices cannot blindly pass the skb->len as the | 229 | * USB devices cannot blindly pass the skb->len as the |
@@ -220,9 +236,9 @@ int rt2x00usb_write_tx_data(struct rt2x00_dev *rt2x00dev, | |||
220 | * Initialize URB and send the frame to the device. | 236 | * Initialize URB and send the frame to the device. |
221 | */ | 237 | */ |
222 | __set_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags); | 238 | __set_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags); |
223 | usb_fill_bulk_urb(priv_tx->urb, usb_dev, usb_sndbulkpipe(usb_dev, 1), | 239 | usb_fill_bulk_urb(entry_priv->urb, usb_dev, usb_sndbulkpipe(usb_dev, 1), |
224 | skb->data, length, rt2x00usb_interrupt_txdone, entry); | 240 | skb->data, length, rt2x00usb_interrupt_txdone, entry); |
225 | usb_submit_urb(priv_tx->urb, GFP_ATOMIC); | 241 | usb_submit_urb(entry_priv->urb, GFP_ATOMIC); |
226 | 242 | ||
227 | rt2x00queue_index_inc(queue, Q_INDEX); | 243 | rt2x00queue_index_inc(queue, Q_INDEX); |
228 | 244 | ||
@@ -237,22 +253,35 @@ static struct sk_buff* rt2x00usb_alloc_rxskb(struct data_queue *queue) | |||
237 | { | 253 | { |
238 | struct sk_buff *skb; | 254 | struct sk_buff *skb; |
239 | unsigned int frame_size; | 255 | unsigned int frame_size; |
256 | unsigned int reserved_size; | ||
240 | 257 | ||
241 | /* | 258 | /* |
242 | * As alignment we use 2 and not NET_IP_ALIGN because we need | 259 | * The frame size includes descriptor size, because the |
243 | * to be sure we have 2 bytes room in the head. (NET_IP_ALIGN | 260 | * hardware directly receive the frame into the skbuffer. |
244 | * can be 0 on some hardware). We use these 2 bytes for frame | ||
245 | * alignment later, we assume that the chance that | ||
246 | * header_size % 4 == 2 is bigger then header_size % 2 == 0 | ||
247 | * and thus optimize alignment by reserving the 2 bytes in | ||
248 | * advance. | ||
249 | */ | 261 | */ |
250 | frame_size = queue->data_size + queue->desc_size; | 262 | frame_size = queue->data_size + queue->desc_size; |
251 | skb = dev_alloc_skb(queue->desc_size + frame_size + 2); | 263 | |
264 | /* | ||
265 | * For the allocation we should keep a few things in mind: | ||
266 | * 1) 4byte alignment of 802.11 payload | ||
267 | * | ||
268 | * For (1) we need at most 4 bytes to guarentee the correct | ||
269 | * alignment. We are going to optimize the fact that the chance | ||
270 | * that the 802.11 header_size % 4 == 2 is much bigger then | ||
271 | * anything else. However since we need to move the frame up | ||
272 | * to 3 bytes to the front, which means we need to preallocate | ||
273 | * 6 bytes. | ||
274 | */ | ||
275 | reserved_size = 6; | ||
276 | |||
277 | /* | ||
278 | * Allocate skbuffer. | ||
279 | */ | ||
280 | skb = dev_alloc_skb(frame_size + reserved_size); | ||
252 | if (!skb) | 281 | if (!skb) |
253 | return NULL; | 282 | return NULL; |
254 | 283 | ||
255 | skb_reserve(skb, queue->desc_size + 2); | 284 | skb_reserve(skb, reserved_size); |
256 | skb_put(skb, frame_size); | 285 | skb_put(skb, frame_size); |
257 | 286 | ||
258 | return skb; | 287 | return skb; |
@@ -265,7 +294,8 @@ static void rt2x00usb_interrupt_rxdone(struct urb *urb) | |||
265 | struct sk_buff *skb; | 294 | struct sk_buff *skb; |
266 | struct skb_frame_desc *skbdesc; | 295 | struct skb_frame_desc *skbdesc; |
267 | struct rxdone_entry_desc rxdesc; | 296 | struct rxdone_entry_desc rxdesc; |
268 | int header_size; | 297 | unsigned int header_size; |
298 | unsigned int align; | ||
269 | 299 | ||
270 | if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags) || | 300 | if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags) || |
271 | !test_and_clear_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags)) | 301 | !test_and_clear_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags)) |
@@ -289,19 +319,29 @@ static void rt2x00usb_interrupt_rxdone(struct urb *urb) | |||
289 | memset(&rxdesc, 0, sizeof(rxdesc)); | 319 | memset(&rxdesc, 0, sizeof(rxdesc)); |
290 | rt2x00dev->ops->lib->fill_rxdone(entry, &rxdesc); | 320 | rt2x00dev->ops->lib->fill_rxdone(entry, &rxdesc); |
291 | 321 | ||
322 | header_size = ieee80211_get_hdrlen_from_skb(entry->skb); | ||
323 | |||
292 | /* | 324 | /* |
293 | * The data behind the ieee80211 header must be | 325 | * The data behind the ieee80211 header must be |
294 | * aligned on a 4 byte boundary. | 326 | * aligned on a 4 byte boundary. We already reserved |
327 | * 2 bytes for header_size % 4 == 2 optimization. | ||
328 | * To determine the number of bytes which the data | ||
329 | * should be moved to the left, we must add these | ||
330 | * 2 bytes to the header_size. | ||
295 | */ | 331 | */ |
296 | header_size = ieee80211_get_hdrlen_from_skb(entry->skb); | 332 | align = (header_size + 2) % 4; |
297 | if (header_size % 4 == 0) { | 333 | |
298 | skb_push(entry->skb, 2); | 334 | if (align) { |
299 | memmove(entry->skb->data, entry->skb->data + 2, | 335 | skb_push(entry->skb, align); |
300 | entry->skb->len - 2); | 336 | /* Move entire frame in 1 command */ |
301 | skbdesc->data = entry->skb->data; | 337 | memmove(entry->skb->data, entry->skb->data + align, |
302 | skb_trim(entry->skb,entry->skb->len - 2); | 338 | rxdesc.size); |
303 | } | 339 | } |
304 | 340 | ||
341 | /* Update data pointers, trim buffer to correct size */ | ||
342 | skbdesc->data = entry->skb->data; | ||
343 | skb_trim(entry->skb, rxdesc.size); | ||
344 | |||
305 | /* | 345 | /* |
306 | * Allocate a new sk buffer to replace the current one. | 346 | * Allocate a new sk buffer to replace the current one. |
307 | * If allocation fails, we should drop the current frame | 347 | * If allocation fails, we should drop the current frame |
@@ -338,10 +378,8 @@ skip_entry: | |||
338 | */ | 378 | */ |
339 | void rt2x00usb_disable_radio(struct rt2x00_dev *rt2x00dev) | 379 | void rt2x00usb_disable_radio(struct rt2x00_dev *rt2x00dev) |
340 | { | 380 | { |
341 | struct queue_entry_priv_usb_rx *priv_rx; | 381 | struct queue_entry_priv_usb *entry_priv; |
342 | struct queue_entry_priv_usb_tx *priv_tx; | 382 | struct queue_entry_priv_usb_bcn *bcn_priv; |
343 | struct queue_entry_priv_usb_bcn *priv_bcn; | ||
344 | struct data_queue *queue; | ||
345 | unsigned int i; | 383 | unsigned int i; |
346 | 384 | ||
347 | rt2x00usb_vendor_request_sw(rt2x00dev, USB_RX_CONTROL, 0, 0, | 385 | rt2x00usb_vendor_request_sw(rt2x00dev, USB_RX_CONTROL, 0, 0, |
@@ -351,31 +389,17 @@ void rt2x00usb_disable_radio(struct rt2x00_dev *rt2x00dev) | |||
351 | * Cancel all queues. | 389 | * Cancel all queues. |
352 | */ | 390 | */ |
353 | for (i = 0; i < rt2x00dev->rx->limit; i++) { | 391 | for (i = 0; i < rt2x00dev->rx->limit; i++) { |
354 | priv_rx = rt2x00dev->rx->entries[i].priv_data; | 392 | entry_priv = rt2x00dev->rx->entries[i].priv_data; |
355 | usb_kill_urb(priv_rx->urb); | 393 | usb_kill_urb(entry_priv->urb); |
356 | } | ||
357 | |||
358 | tx_queue_for_each(rt2x00dev, queue) { | ||
359 | for (i = 0; i < queue->limit; i++) { | ||
360 | priv_tx = queue->entries[i].priv_data; | ||
361 | usb_kill_urb(priv_tx->urb); | ||
362 | } | ||
363 | } | 394 | } |
364 | 395 | ||
396 | /* | ||
397 | * Kill guardian urb. | ||
398 | */ | ||
365 | for (i = 0; i < rt2x00dev->bcn->limit; i++) { | 399 | for (i = 0; i < rt2x00dev->bcn->limit; i++) { |
366 | priv_bcn = rt2x00dev->bcn->entries[i].priv_data; | 400 | bcn_priv = rt2x00dev->bcn->entries[i].priv_data; |
367 | usb_kill_urb(priv_bcn->urb); | 401 | if (bcn_priv->guardian_urb) |
368 | 402 | usb_kill_urb(bcn_priv->guardian_urb); | |
369 | if (priv_bcn->guardian_urb) | ||
370 | usb_kill_urb(priv_bcn->guardian_urb); | ||
371 | } | ||
372 | |||
373 | if (!test_bit(DRIVER_REQUIRE_ATIM_QUEUE, &rt2x00dev->flags)) | ||
374 | return; | ||
375 | |||
376 | for (i = 0; i < rt2x00dev->bcn[1].limit; i++) { | ||
377 | priv_tx = rt2x00dev->bcn[1].entries[i].priv_data; | ||
378 | usb_kill_urb(priv_tx->urb); | ||
379 | } | 403 | } |
380 | } | 404 | } |
381 | EXPORT_SYMBOL_GPL(rt2x00usb_disable_radio); | 405 | EXPORT_SYMBOL_GPL(rt2x00usb_disable_radio); |
@@ -387,15 +411,15 @@ void rt2x00usb_init_rxentry(struct rt2x00_dev *rt2x00dev, | |||
387 | struct queue_entry *entry) | 411 | struct queue_entry *entry) |
388 | { | 412 | { |
389 | struct usb_device *usb_dev = rt2x00dev_usb_dev(rt2x00dev); | 413 | struct usb_device *usb_dev = rt2x00dev_usb_dev(rt2x00dev); |
390 | struct queue_entry_priv_usb_rx *priv_rx = entry->priv_data; | 414 | struct queue_entry_priv_usb *entry_priv = entry->priv_data; |
391 | 415 | ||
392 | usb_fill_bulk_urb(priv_rx->urb, usb_dev, | 416 | usb_fill_bulk_urb(entry_priv->urb, usb_dev, |
393 | usb_rcvbulkpipe(usb_dev, 1), | 417 | usb_rcvbulkpipe(usb_dev, 1), |
394 | entry->skb->data, entry->skb->len, | 418 | entry->skb->data, entry->skb->len, |
395 | rt2x00usb_interrupt_rxdone, entry); | 419 | rt2x00usb_interrupt_rxdone, entry); |
396 | 420 | ||
397 | __set_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags); | 421 | __set_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags); |
398 | usb_submit_urb(priv_rx->urb, GFP_ATOMIC); | 422 | usb_submit_urb(entry_priv->urb, GFP_ATOMIC); |
399 | } | 423 | } |
400 | EXPORT_SYMBOL_GPL(rt2x00usb_init_rxentry); | 424 | EXPORT_SYMBOL_GPL(rt2x00usb_init_rxentry); |
401 | 425 | ||
@@ -409,38 +433,31 @@ EXPORT_SYMBOL_GPL(rt2x00usb_init_txentry); | |||
409 | static int rt2x00usb_alloc_urb(struct rt2x00_dev *rt2x00dev, | 433 | static int rt2x00usb_alloc_urb(struct rt2x00_dev *rt2x00dev, |
410 | struct data_queue *queue) | 434 | struct data_queue *queue) |
411 | { | 435 | { |
412 | struct queue_entry_priv_usb_rx *priv_rx; | 436 | struct queue_entry_priv_usb *entry_priv; |
413 | struct queue_entry_priv_usb_tx *priv_tx; | 437 | struct queue_entry_priv_usb_bcn *bcn_priv; |
414 | struct queue_entry_priv_usb_bcn *priv_bcn; | ||
415 | struct urb *urb; | ||
416 | unsigned int guardian = | ||
417 | test_bit(DRIVER_REQUIRE_BEACON_GUARD, &rt2x00dev->flags); | ||
418 | unsigned int i; | 438 | unsigned int i; |
419 | 439 | ||
440 | for (i = 0; i < queue->limit; i++) { | ||
441 | entry_priv = queue->entries[i].priv_data; | ||
442 | entry_priv->urb = usb_alloc_urb(0, GFP_KERNEL); | ||
443 | if (!entry_priv->urb) | ||
444 | return -ENOMEM; | ||
445 | } | ||
446 | |||
420 | /* | 447 | /* |
421 | * Allocate the URB's | 448 | * If this is not the beacon queue or |
449 | * no guardian byte was required for the beacon, | ||
450 | * then we are done. | ||
422 | */ | 451 | */ |
452 | if (rt2x00dev->bcn != queue || | ||
453 | !test_bit(DRIVER_REQUIRE_BEACON_GUARD, &rt2x00dev->flags)) | ||
454 | return 0; | ||
455 | |||
423 | for (i = 0; i < queue->limit; i++) { | 456 | for (i = 0; i < queue->limit; i++) { |
424 | urb = usb_alloc_urb(0, GFP_KERNEL); | 457 | bcn_priv = queue->entries[i].priv_data; |
425 | if (!urb) | 458 | bcn_priv->guardian_urb = usb_alloc_urb(0, GFP_KERNEL); |
459 | if (!bcn_priv->guardian_urb) | ||
426 | return -ENOMEM; | 460 | return -ENOMEM; |
427 | |||
428 | if (queue->qid == QID_RX) { | ||
429 | priv_rx = queue->entries[i].priv_data; | ||
430 | priv_rx->urb = urb; | ||
431 | } else if (queue->qid == QID_MGMT && guardian) { | ||
432 | priv_bcn = queue->entries[i].priv_data; | ||
433 | priv_bcn->urb = urb; | ||
434 | |||
435 | urb = usb_alloc_urb(0, GFP_KERNEL); | ||
436 | if (!urb) | ||
437 | return -ENOMEM; | ||
438 | |||
439 | priv_bcn->guardian_urb = urb; | ||
440 | } else { | ||
441 | priv_tx = queue->entries[i].priv_data; | ||
442 | priv_tx->urb = urb; | ||
443 | } | ||
444 | } | 461 | } |
445 | 462 | ||
446 | return 0; | 463 | return 0; |
@@ -449,38 +466,35 @@ static int rt2x00usb_alloc_urb(struct rt2x00_dev *rt2x00dev, | |||
449 | static void rt2x00usb_free_urb(struct rt2x00_dev *rt2x00dev, | 466 | static void rt2x00usb_free_urb(struct rt2x00_dev *rt2x00dev, |
450 | struct data_queue *queue) | 467 | struct data_queue *queue) |
451 | { | 468 | { |
452 | struct queue_entry_priv_usb_rx *priv_rx; | 469 | struct queue_entry_priv_usb *entry_priv; |
453 | struct queue_entry_priv_usb_tx *priv_tx; | 470 | struct queue_entry_priv_usb_bcn *bcn_priv; |
454 | struct queue_entry_priv_usb_bcn *priv_bcn; | ||
455 | struct urb *urb; | ||
456 | unsigned int guardian = | ||
457 | test_bit(DRIVER_REQUIRE_BEACON_GUARD, &rt2x00dev->flags); | ||
458 | unsigned int i; | 471 | unsigned int i; |
459 | 472 | ||
460 | if (!queue->entries) | 473 | if (!queue->entries) |
461 | return; | 474 | return; |
462 | 475 | ||
463 | for (i = 0; i < queue->limit; i++) { | 476 | for (i = 0; i < queue->limit; i++) { |
464 | if (queue->qid == QID_RX) { | 477 | entry_priv = queue->entries[i].priv_data; |
465 | priv_rx = queue->entries[i].priv_data; | 478 | usb_kill_urb(entry_priv->urb); |
466 | urb = priv_rx->urb; | 479 | usb_free_urb(entry_priv->urb); |
467 | } else if (queue->qid == QID_MGMT && guardian) { | ||
468 | priv_bcn = queue->entries[i].priv_data; | ||
469 | |||
470 | usb_kill_urb(priv_bcn->guardian_urb); | ||
471 | usb_free_urb(priv_bcn->guardian_urb); | ||
472 | |||
473 | urb = priv_bcn->urb; | ||
474 | } else { | ||
475 | priv_tx = queue->entries[i].priv_data; | ||
476 | urb = priv_tx->urb; | ||
477 | } | ||
478 | |||
479 | usb_kill_urb(urb); | ||
480 | usb_free_urb(urb); | ||
481 | if (queue->entries[i].skb) | 480 | if (queue->entries[i].skb) |
482 | kfree_skb(queue->entries[i].skb); | 481 | kfree_skb(queue->entries[i].skb); |
483 | } | 482 | } |
483 | |||
484 | /* | ||
485 | * If this is not the beacon queue or | ||
486 | * no guardian byte was required for the beacon, | ||
487 | * then we are done. | ||
488 | */ | ||
489 | if (rt2x00dev->bcn != queue || | ||
490 | !test_bit(DRIVER_REQUIRE_BEACON_GUARD, &rt2x00dev->flags)) | ||
491 | return; | ||
492 | |||
493 | for (i = 0; i < queue->limit; i++) { | ||
494 | bcn_priv = queue->entries[i].priv_data; | ||
495 | usb_kill_urb(bcn_priv->guardian_urb); | ||
496 | usb_free_urb(bcn_priv->guardian_urb); | ||
497 | } | ||
484 | } | 498 | } |
485 | 499 | ||
486 | int rt2x00usb_initialize(struct rt2x00_dev *rt2x00dev) | 500 | int rt2x00usb_initialize(struct rt2x00_dev *rt2x00dev) |
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.h b/drivers/net/wireless/rt2x00/rt2x00usb.h index 4da9eb376ebd..26f53f868af6 100644 --- a/drivers/net/wireless/rt2x00/rt2x00usb.h +++ b/drivers/net/wireless/rt2x00/rt2x00usb.h | |||
@@ -216,47 +216,31 @@ void rt2x00usb_disable_radio(struct rt2x00_dev *rt2x00dev); | |||
216 | * TX data handlers. | 216 | * TX data handlers. |
217 | */ | 217 | */ |
218 | int rt2x00usb_write_tx_data(struct rt2x00_dev *rt2x00dev, | 218 | int rt2x00usb_write_tx_data(struct rt2x00_dev *rt2x00dev, |
219 | struct data_queue *queue, struct sk_buff *skb, | 219 | struct data_queue *queue, struct sk_buff *skb); |
220 | struct ieee80211_tx_control *control); | ||
221 | 220 | ||
222 | /** | 221 | /** |
223 | * struct queue_entry_priv_usb_rx: Per RX entry USB specific information | 222 | * struct queue_entry_priv_usb: Per entry USB specific information |
224 | * | 223 | * |
225 | * @urb: Urb structure used for device communication. | 224 | * @urb: Urb structure used for device communication. |
226 | */ | 225 | */ |
227 | struct queue_entry_priv_usb_rx { | 226 | struct queue_entry_priv_usb { |
228 | struct urb *urb; | 227 | struct urb *urb; |
229 | }; | 228 | }; |
230 | 229 | ||
231 | /** | 230 | /** |
232 | * struct queue_entry_priv_usb_tx: Per TX entry USB specific information | 231 | * struct queue_entry_priv_usb_bcn: Per TX entry USB specific information |
233 | * | 232 | * |
234 | * @urb: Urb structure used for device communication. | 233 | * The first section should match &struct queue_entry_priv_usb exactly. |
235 | * @control: mac80211 control structure used to transmit data. | ||
236 | */ | ||
237 | struct queue_entry_priv_usb_tx { | ||
238 | struct urb *urb; | ||
239 | |||
240 | struct ieee80211_tx_control control; | ||
241 | }; | ||
242 | |||
243 | /** | ||
244 | * struct queue_entry_priv_usb_tx: Per TX entry USB specific information | ||
245 | * | ||
246 | * The first section should match &struct queue_entry_priv_usb_tx exactly. | ||
247 | * rt2500usb can use this structure to send a guardian byte when working | 234 | * rt2500usb can use this structure to send a guardian byte when working |
248 | * with beacons. | 235 | * with beacons. |
249 | * | 236 | * |
250 | * @urb: Urb structure used for device communication. | 237 | * @urb: Urb structure used for device communication. |
251 | * @control: mac80211 control structure used to transmit data. | ||
252 | * @guardian_data: Set to 0, used for sending the guardian data. | 238 | * @guardian_data: Set to 0, used for sending the guardian data. |
253 | * @guardian_urb: Urb structure used to send the guardian data. | 239 | * @guardian_urb: Urb structure used to send the guardian data. |
254 | */ | 240 | */ |
255 | struct queue_entry_priv_usb_bcn { | 241 | struct queue_entry_priv_usb_bcn { |
256 | struct urb *urb; | 242 | struct urb *urb; |
257 | 243 | ||
258 | struct ieee80211_tx_control control; | ||
259 | |||
260 | unsigned int guardian_data; | 244 | unsigned int guardian_data; |
261 | struct urb *guardian_urb; | 245 | struct urb *guardian_urb; |
262 | }; | 246 | }; |
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c index edddbf35bbab..e13ed5ced26e 100644 --- a/drivers/net/wireless/rt2x00/rt61pci.c +++ b/drivers/net/wireless/rt2x00/rt61pci.c | |||
@@ -1018,49 +1018,34 @@ static int rt61pci_load_firmware(struct rt2x00_dev *rt2x00dev, void *data, | |||
1018 | static void rt61pci_init_rxentry(struct rt2x00_dev *rt2x00dev, | 1018 | static void rt61pci_init_rxentry(struct rt2x00_dev *rt2x00dev, |
1019 | struct queue_entry *entry) | 1019 | struct queue_entry *entry) |
1020 | { | 1020 | { |
1021 | struct queue_entry_priv_pci_rx *priv_rx = entry->priv_data; | 1021 | struct queue_entry_priv_pci *entry_priv = entry->priv_data; |
1022 | u32 word; | 1022 | u32 word; |
1023 | 1023 | ||
1024 | rt2x00_desc_read(priv_rx->desc, 5, &word); | 1024 | rt2x00_desc_read(entry_priv->desc, 5, &word); |
1025 | rt2x00_set_field32(&word, RXD_W5_BUFFER_PHYSICAL_ADDRESS, | 1025 | rt2x00_set_field32(&word, RXD_W5_BUFFER_PHYSICAL_ADDRESS, |
1026 | priv_rx->data_dma); | 1026 | entry_priv->data_dma); |
1027 | rt2x00_desc_write(priv_rx->desc, 5, word); | 1027 | rt2x00_desc_write(entry_priv->desc, 5, word); |
1028 | 1028 | ||
1029 | rt2x00_desc_read(priv_rx->desc, 0, &word); | 1029 | rt2x00_desc_read(entry_priv->desc, 0, &word); |
1030 | rt2x00_set_field32(&word, RXD_W0_OWNER_NIC, 1); | 1030 | rt2x00_set_field32(&word, RXD_W0_OWNER_NIC, 1); |
1031 | rt2x00_desc_write(priv_rx->desc, 0, word); | 1031 | rt2x00_desc_write(entry_priv->desc, 0, word); |
1032 | } | 1032 | } |
1033 | 1033 | ||
1034 | static void rt61pci_init_txentry(struct rt2x00_dev *rt2x00dev, | 1034 | static void rt61pci_init_txentry(struct rt2x00_dev *rt2x00dev, |
1035 | struct queue_entry *entry) | 1035 | struct queue_entry *entry) |
1036 | { | 1036 | { |
1037 | struct queue_entry_priv_pci_tx *priv_tx = entry->priv_data; | 1037 | struct queue_entry_priv_pci *entry_priv = entry->priv_data; |
1038 | u32 word; | 1038 | u32 word; |
1039 | 1039 | ||
1040 | rt2x00_desc_read(priv_tx->desc, 1, &word); | 1040 | rt2x00_desc_read(entry_priv->desc, 0, &word); |
1041 | rt2x00_set_field32(&word, TXD_W1_BUFFER_COUNT, 1); | ||
1042 | rt2x00_desc_write(priv_tx->desc, 1, word); | ||
1043 | |||
1044 | rt2x00_desc_read(priv_tx->desc, 5, &word); | ||
1045 | rt2x00_set_field32(&word, TXD_W5_PID_TYPE, entry->queue->qid); | ||
1046 | rt2x00_set_field32(&word, TXD_W5_PID_SUBTYPE, entry->entry_idx); | ||
1047 | rt2x00_desc_write(priv_tx->desc, 5, word); | ||
1048 | |||
1049 | rt2x00_desc_read(priv_tx->desc, 6, &word); | ||
1050 | rt2x00_set_field32(&word, TXD_W6_BUFFER_PHYSICAL_ADDRESS, | ||
1051 | priv_tx->data_dma); | ||
1052 | rt2x00_desc_write(priv_tx->desc, 6, word); | ||
1053 | |||
1054 | rt2x00_desc_read(priv_tx->desc, 0, &word); | ||
1055 | rt2x00_set_field32(&word, TXD_W0_VALID, 0); | 1041 | rt2x00_set_field32(&word, TXD_W0_VALID, 0); |
1056 | rt2x00_set_field32(&word, TXD_W0_OWNER_NIC, 0); | 1042 | rt2x00_set_field32(&word, TXD_W0_OWNER_NIC, 0); |
1057 | rt2x00_desc_write(priv_tx->desc, 0, word); | 1043 | rt2x00_desc_write(entry_priv->desc, 0, word); |
1058 | } | 1044 | } |
1059 | 1045 | ||
1060 | static int rt61pci_init_queues(struct rt2x00_dev *rt2x00dev) | 1046 | static int rt61pci_init_queues(struct rt2x00_dev *rt2x00dev) |
1061 | { | 1047 | { |
1062 | struct queue_entry_priv_pci_rx *priv_rx; | 1048 | struct queue_entry_priv_pci *entry_priv; |
1063 | struct queue_entry_priv_pci_tx *priv_tx; | ||
1064 | u32 reg; | 1049 | u32 reg; |
1065 | 1050 | ||
1066 | /* | 1051 | /* |
@@ -1082,28 +1067,28 @@ static int rt61pci_init_queues(struct rt2x00_dev *rt2x00dev) | |||
1082 | rt2x00dev->tx[0].desc_size / 4); | 1067 | rt2x00dev->tx[0].desc_size / 4); |
1083 | rt2x00pci_register_write(rt2x00dev, TX_RING_CSR1, reg); | 1068 | rt2x00pci_register_write(rt2x00dev, TX_RING_CSR1, reg); |
1084 | 1069 | ||
1085 | priv_tx = rt2x00dev->tx[0].entries[0].priv_data; | 1070 | entry_priv = rt2x00dev->tx[0].entries[0].priv_data; |
1086 | rt2x00pci_register_read(rt2x00dev, AC0_BASE_CSR, ®); | 1071 | rt2x00pci_register_read(rt2x00dev, AC0_BASE_CSR, ®); |
1087 | rt2x00_set_field32(®, AC0_BASE_CSR_RING_REGISTER, | 1072 | rt2x00_set_field32(®, AC0_BASE_CSR_RING_REGISTER, |
1088 | priv_tx->desc_dma); | 1073 | entry_priv->desc_dma); |
1089 | rt2x00pci_register_write(rt2x00dev, AC0_BASE_CSR, reg); | 1074 | rt2x00pci_register_write(rt2x00dev, AC0_BASE_CSR, reg); |
1090 | 1075 | ||
1091 | priv_tx = rt2x00dev->tx[1].entries[0].priv_data; | 1076 | entry_priv = rt2x00dev->tx[1].entries[0].priv_data; |
1092 | rt2x00pci_register_read(rt2x00dev, AC1_BASE_CSR, ®); | 1077 | rt2x00pci_register_read(rt2x00dev, AC1_BASE_CSR, ®); |
1093 | rt2x00_set_field32(®, AC1_BASE_CSR_RING_REGISTER, | 1078 | rt2x00_set_field32(®, AC1_BASE_CSR_RING_REGISTER, |
1094 | priv_tx->desc_dma); | 1079 | entry_priv->desc_dma); |
1095 | rt2x00pci_register_write(rt2x00dev, AC1_BASE_CSR, reg); | 1080 | rt2x00pci_register_write(rt2x00dev, AC1_BASE_CSR, reg); |
1096 | 1081 | ||
1097 | priv_tx = rt2x00dev->tx[2].entries[0].priv_data; | 1082 | entry_priv = rt2x00dev->tx[2].entries[0].priv_data; |
1098 | rt2x00pci_register_read(rt2x00dev, AC2_BASE_CSR, ®); | 1083 | rt2x00pci_register_read(rt2x00dev, AC2_BASE_CSR, ®); |
1099 | rt2x00_set_field32(®, AC2_BASE_CSR_RING_REGISTER, | 1084 | rt2x00_set_field32(®, AC2_BASE_CSR_RING_REGISTER, |
1100 | priv_tx->desc_dma); | 1085 | entry_priv->desc_dma); |
1101 | rt2x00pci_register_write(rt2x00dev, AC2_BASE_CSR, reg); | 1086 | rt2x00pci_register_write(rt2x00dev, AC2_BASE_CSR, reg); |
1102 | 1087 | ||
1103 | priv_tx = rt2x00dev->tx[3].entries[0].priv_data; | 1088 | entry_priv = rt2x00dev->tx[3].entries[0].priv_data; |
1104 | rt2x00pci_register_read(rt2x00dev, AC3_BASE_CSR, ®); | 1089 | rt2x00pci_register_read(rt2x00dev, AC3_BASE_CSR, ®); |
1105 | rt2x00_set_field32(®, AC3_BASE_CSR_RING_REGISTER, | 1090 | rt2x00_set_field32(®, AC3_BASE_CSR_RING_REGISTER, |
1106 | priv_tx->desc_dma); | 1091 | entry_priv->desc_dma); |
1107 | rt2x00pci_register_write(rt2x00dev, AC3_BASE_CSR, reg); | 1092 | rt2x00pci_register_write(rt2x00dev, AC3_BASE_CSR, reg); |
1108 | 1093 | ||
1109 | rt2x00pci_register_read(rt2x00dev, RX_RING_CSR, ®); | 1094 | rt2x00pci_register_read(rt2x00dev, RX_RING_CSR, ®); |
@@ -1113,10 +1098,10 @@ static int rt61pci_init_queues(struct rt2x00_dev *rt2x00dev) | |||
1113 | rt2x00_set_field32(®, RX_RING_CSR_RXD_WRITEBACK_SIZE, 4); | 1098 | rt2x00_set_field32(®, RX_RING_CSR_RXD_WRITEBACK_SIZE, 4); |
1114 | rt2x00pci_register_write(rt2x00dev, RX_RING_CSR, reg); | 1099 | rt2x00pci_register_write(rt2x00dev, RX_RING_CSR, reg); |
1115 | 1100 | ||
1116 | priv_rx = rt2x00dev->rx->entries[0].priv_data; | 1101 | entry_priv = rt2x00dev->rx->entries[0].priv_data; |
1117 | rt2x00pci_register_read(rt2x00dev, RX_BASE_CSR, ®); | 1102 | rt2x00pci_register_read(rt2x00dev, RX_BASE_CSR, ®); |
1118 | rt2x00_set_field32(®, RX_BASE_CSR_RING_REGISTER, | 1103 | rt2x00_set_field32(®, RX_BASE_CSR_RING_REGISTER, |
1119 | priv_rx->desc_dma); | 1104 | entry_priv->desc_dma); |
1120 | rt2x00pci_register_write(rt2x00dev, RX_BASE_CSR, reg); | 1105 | rt2x00pci_register_write(rt2x00dev, RX_BASE_CSR, reg); |
1121 | 1106 | ||
1122 | rt2x00pci_register_read(rt2x00dev, TX_DMA_DST_CSR, ®); | 1107 | rt2x00pci_register_read(rt2x00dev, TX_DMA_DST_CSR, ®); |
@@ -1526,10 +1511,10 @@ static int rt61pci_set_device_state(struct rt2x00_dev *rt2x00dev, | |||
1526 | */ | 1511 | */ |
1527 | static void rt61pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, | 1512 | static void rt61pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, |
1528 | struct sk_buff *skb, | 1513 | struct sk_buff *skb, |
1529 | struct txentry_desc *txdesc, | 1514 | struct txentry_desc *txdesc) |
1530 | struct ieee80211_tx_control *control) | ||
1531 | { | 1515 | { |
1532 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb); | 1516 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb); |
1517 | struct queue_entry_priv_pci *entry_priv = skbdesc->entry->priv_data; | ||
1533 | __le32 *txd = skbdesc->desc; | 1518 | __le32 *txd = skbdesc->desc; |
1534 | u32 word; | 1519 | u32 word; |
1535 | 1520 | ||
@@ -1543,6 +1528,7 @@ static void rt61pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, | |||
1543 | rt2x00_set_field32(&word, TXD_W1_CWMAX, txdesc->cw_max); | 1528 | rt2x00_set_field32(&word, TXD_W1_CWMAX, txdesc->cw_max); |
1544 | rt2x00_set_field32(&word, TXD_W1_IV_OFFSET, IEEE80211_HEADER); | 1529 | rt2x00_set_field32(&word, TXD_W1_IV_OFFSET, IEEE80211_HEADER); |
1545 | rt2x00_set_field32(&word, TXD_W1_HW_SEQUENCE, 1); | 1530 | rt2x00_set_field32(&word, TXD_W1_HW_SEQUENCE, 1); |
1531 | rt2x00_set_field32(&word, TXD_W1_BUFFER_COUNT, 1); | ||
1546 | rt2x00_desc_write(txd, 1, word); | 1532 | rt2x00_desc_write(txd, 1, word); |
1547 | 1533 | ||
1548 | rt2x00_desc_read(txd, 2, &word); | 1534 | rt2x00_desc_read(txd, 2, &word); |
@@ -1553,11 +1539,19 @@ static void rt61pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, | |||
1553 | rt2x00_desc_write(txd, 2, word); | 1539 | rt2x00_desc_write(txd, 2, word); |
1554 | 1540 | ||
1555 | rt2x00_desc_read(txd, 5, &word); | 1541 | rt2x00_desc_read(txd, 5, &word); |
1542 | rt2x00_set_field32(&word, TXD_W5_PID_TYPE, skbdesc->entry->queue->qid); | ||
1543 | rt2x00_set_field32(&word, TXD_W5_PID_SUBTYPE, | ||
1544 | skbdesc->entry->entry_idx); | ||
1556 | rt2x00_set_field32(&word, TXD_W5_TX_POWER, | 1545 | rt2x00_set_field32(&word, TXD_W5_TX_POWER, |
1557 | TXPOWER_TO_DEV(rt2x00dev->tx_power)); | 1546 | TXPOWER_TO_DEV(rt2x00dev->tx_power)); |
1558 | rt2x00_set_field32(&word, TXD_W5_WAITING_DMA_DONE_INT, 1); | 1547 | rt2x00_set_field32(&word, TXD_W5_WAITING_DMA_DONE_INT, 1); |
1559 | rt2x00_desc_write(txd, 5, word); | 1548 | rt2x00_desc_write(txd, 5, word); |
1560 | 1549 | ||
1550 | rt2x00_desc_read(txd, 6, &word); | ||
1551 | rt2x00_set_field32(&word, TXD_W6_BUFFER_PHYSICAL_ADDRESS, | ||
1552 | entry_priv->data_dma); | ||
1553 | rt2x00_desc_write(txd, 6, word); | ||
1554 | |||
1561 | if (skbdesc->desc_len > TXINFO_SIZE) { | 1555 | if (skbdesc->desc_len > TXINFO_SIZE) { |
1562 | rt2x00_desc_read(txd, 11, &word); | 1556 | rt2x00_desc_read(txd, 11, &word); |
1563 | rt2x00_set_field32(&word, TXD_W11_BUFFER_LENGTH0, skbdesc->data_len); | 1557 | rt2x00_set_field32(&word, TXD_W11_BUFFER_LENGTH0, skbdesc->data_len); |
@@ -1577,8 +1571,7 @@ static void rt61pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, | |||
1577 | test_bit(ENTRY_TXD_OFDM_RATE, &txdesc->flags)); | 1571 | test_bit(ENTRY_TXD_OFDM_RATE, &txdesc->flags)); |
1578 | rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs); | 1572 | rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs); |
1579 | rt2x00_set_field32(&word, TXD_W0_RETRY_MODE, | 1573 | rt2x00_set_field32(&word, TXD_W0_RETRY_MODE, |
1580 | !!(control->flags & | 1574 | test_bit(ENTRY_TXD_RETRY_MODE, &txdesc->flags)); |
1581 | IEEE80211_TXCTL_LONG_RETRY_LIMIT)); | ||
1582 | rt2x00_set_field32(&word, TXD_W0_TKIP_MIC, 0); | 1575 | rt2x00_set_field32(&word, TXD_W0_TKIP_MIC, 0); |
1583 | rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, skbdesc->data_len); | 1576 | rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, skbdesc->data_len); |
1584 | rt2x00_set_field32(&word, TXD_W0_BURST, | 1577 | rt2x00_set_field32(&word, TXD_W0_BURST, |
@@ -1667,14 +1660,13 @@ static int rt61pci_agc_to_rssi(struct rt2x00_dev *rt2x00dev, int rxd_w1) | |||
1667 | static void rt61pci_fill_rxdone(struct queue_entry *entry, | 1660 | static void rt61pci_fill_rxdone(struct queue_entry *entry, |
1668 | struct rxdone_entry_desc *rxdesc) | 1661 | struct rxdone_entry_desc *rxdesc) |
1669 | { | 1662 | { |
1670 | struct queue_entry_priv_pci_rx *priv_rx = entry->priv_data; | 1663 | struct queue_entry_priv_pci *entry_priv = entry->priv_data; |
1671 | u32 word0; | 1664 | u32 word0; |
1672 | u32 word1; | 1665 | u32 word1; |
1673 | 1666 | ||
1674 | rt2x00_desc_read(priv_rx->desc, 0, &word0); | 1667 | rt2x00_desc_read(entry_priv->desc, 0, &word0); |
1675 | rt2x00_desc_read(priv_rx->desc, 1, &word1); | 1668 | rt2x00_desc_read(entry_priv->desc, 1, &word1); |
1676 | 1669 | ||
1677 | rxdesc->flags = 0; | ||
1678 | if (rt2x00_get_field32(word0, RXD_W0_CRC_ERROR)) | 1670 | if (rt2x00_get_field32(word0, RXD_W0_CRC_ERROR)) |
1679 | rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC; | 1671 | rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC; |
1680 | 1672 | ||
@@ -1688,7 +1680,6 @@ static void rt61pci_fill_rxdone(struct queue_entry *entry, | |||
1688 | rxdesc->rssi = rt61pci_agc_to_rssi(entry->queue->rt2x00dev, word1); | 1680 | rxdesc->rssi = rt61pci_agc_to_rssi(entry->queue->rt2x00dev, word1); |
1689 | rxdesc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT); | 1681 | rxdesc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT); |
1690 | 1682 | ||
1691 | rxdesc->dev_flags = 0; | ||
1692 | if (rt2x00_get_field32(word0, RXD_W0_OFDM)) | 1683 | if (rt2x00_get_field32(word0, RXD_W0_OFDM)) |
1693 | rxdesc->dev_flags |= RXDONE_SIGNAL_PLCP; | 1684 | rxdesc->dev_flags |= RXDONE_SIGNAL_PLCP; |
1694 | if (rt2x00_get_field32(word0, RXD_W0_MY_BSS)) | 1685 | if (rt2x00_get_field32(word0, RXD_W0_MY_BSS)) |
@@ -1703,7 +1694,7 @@ static void rt61pci_txdone(struct rt2x00_dev *rt2x00dev) | |||
1703 | struct data_queue *queue; | 1694 | struct data_queue *queue; |
1704 | struct queue_entry *entry; | 1695 | struct queue_entry *entry; |
1705 | struct queue_entry *entry_done; | 1696 | struct queue_entry *entry_done; |
1706 | struct queue_entry_priv_pci_tx *priv_tx; | 1697 | struct queue_entry_priv_pci *entry_priv; |
1707 | struct txdone_entry_desc txdesc; | 1698 | struct txdone_entry_desc txdesc; |
1708 | u32 word; | 1699 | u32 word; |
1709 | u32 reg; | 1700 | u32 reg; |
@@ -1748,8 +1739,8 @@ static void rt61pci_txdone(struct rt2x00_dev *rt2x00dev) | |||
1748 | continue; | 1739 | continue; |
1749 | 1740 | ||
1750 | entry = &queue->entries[index]; | 1741 | entry = &queue->entries[index]; |
1751 | priv_tx = entry->priv_data; | 1742 | entry_priv = entry->priv_data; |
1752 | rt2x00_desc_read(priv_tx->desc, 0, &word); | 1743 | rt2x00_desc_read(entry_priv->desc, 0, &word); |
1753 | 1744 | ||
1754 | if (rt2x00_get_field32(word, TXD_W0_OWNER_NIC) || | 1745 | if (rt2x00_get_field32(word, TXD_W0_OWNER_NIC) || |
1755 | !rt2x00_get_field32(word, TXD_W0_VALID)) | 1746 | !rt2x00_get_field32(word, TXD_W0_VALID)) |
@@ -1764,7 +1755,8 @@ static void rt61pci_txdone(struct rt2x00_dev *rt2x00dev) | |||
1764 | "TX status report missed for entry %d\n", | 1755 | "TX status report missed for entry %d\n", |
1765 | entry_done->entry_idx); | 1756 | entry_done->entry_idx); |
1766 | 1757 | ||
1767 | txdesc.status = TX_FAIL_OTHER; | 1758 | txdesc.flags = 0; |
1759 | __set_bit(TXDONE_UNKNOWN, &txdesc.flags); | ||
1768 | txdesc.retry = 0; | 1760 | txdesc.retry = 0; |
1769 | 1761 | ||
1770 | rt2x00pci_txdone(rt2x00dev, entry_done, &txdesc); | 1762 | rt2x00pci_txdone(rt2x00dev, entry_done, &txdesc); |
@@ -1774,7 +1766,17 @@ static void rt61pci_txdone(struct rt2x00_dev *rt2x00dev) | |||
1774 | /* | 1766 | /* |
1775 | * Obtain the status about this packet. | 1767 | * Obtain the status about this packet. |
1776 | */ | 1768 | */ |
1777 | txdesc.status = rt2x00_get_field32(reg, STA_CSR4_TX_RESULT); | 1769 | txdesc.flags = 0; |
1770 | switch (rt2x00_get_field32(reg, STA_CSR4_TX_RESULT)) { | ||
1771 | case 0: /* Success, maybe with retry */ | ||
1772 | __set_bit(TXDONE_SUCCESS, &txdesc.flags); | ||
1773 | break; | ||
1774 | case 6: /* Failure, excessive retries */ | ||
1775 | __set_bit(TXDONE_EXCESSIVE_RETRY, &txdesc.flags); | ||
1776 | /* Don't break, this is a failed frame! */ | ||
1777 | default: /* Failure */ | ||
1778 | __set_bit(TXDONE_FAILURE, &txdesc.flags); | ||
1779 | } | ||
1778 | txdesc.retry = rt2x00_get_field32(reg, STA_CSR4_RETRY_COUNT); | 1780 | txdesc.retry = rt2x00_get_field32(reg, STA_CSR4_RETRY_COUNT); |
1779 | 1781 | ||
1780 | rt2x00pci_txdone(rt2x00dev, entry, &txdesc); | 1782 | rt2x00pci_txdone(rt2x00dev, entry, &txdesc); |
@@ -2248,7 +2250,6 @@ static void rt61pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev) | |||
2248 | IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | | 2250 | IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | |
2249 | IEEE80211_HW_SIGNAL_DBM; | 2251 | IEEE80211_HW_SIGNAL_DBM; |
2250 | rt2x00dev->hw->extra_tx_headroom = 0; | 2252 | rt2x00dev->hw->extra_tx_headroom = 0; |
2251 | rt2x00dev->hw->queues = 4; | ||
2252 | 2253 | ||
2253 | SET_IEEE80211_DEV(rt2x00dev->hw, &rt2x00dev_pci(rt2x00dev)->dev); | 2254 | SET_IEEE80211_DEV(rt2x00dev->hw, &rt2x00dev_pci(rt2x00dev)->dev); |
2254 | SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, | 2255 | SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, |
@@ -2356,21 +2357,30 @@ static u64 rt61pci_get_tsf(struct ieee80211_hw *hw) | |||
2356 | return tsf; | 2357 | return tsf; |
2357 | } | 2358 | } |
2358 | 2359 | ||
2359 | static int rt61pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb, | 2360 | static int rt61pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb) |
2360 | struct ieee80211_tx_control *control) | ||
2361 | { | 2361 | { |
2362 | struct rt2x00_dev *rt2x00dev = hw->priv; | 2362 | struct rt2x00_dev *rt2x00dev = hw->priv; |
2363 | struct rt2x00_intf *intf = vif_to_intf(control->vif); | 2363 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); |
2364 | struct queue_entry_priv_pci_tx *priv_tx; | 2364 | struct rt2x00_intf *intf = vif_to_intf(tx_info->control.vif); |
2365 | struct queue_entry_priv_pci *entry_priv; | ||
2365 | struct skb_frame_desc *skbdesc; | 2366 | struct skb_frame_desc *skbdesc; |
2367 | struct txentry_desc txdesc; | ||
2366 | unsigned int beacon_base; | 2368 | unsigned int beacon_base; |
2367 | u32 reg; | 2369 | u32 reg; |
2368 | 2370 | ||
2369 | if (unlikely(!intf->beacon)) | 2371 | if (unlikely(!intf->beacon)) |
2370 | return -ENOBUFS; | 2372 | return -ENOBUFS; |
2371 | 2373 | ||
2372 | priv_tx = intf->beacon->priv_data; | 2374 | /* |
2373 | memset(priv_tx->desc, 0, intf->beacon->queue->desc_size); | 2375 | * Copy all TX descriptor information into txdesc, |
2376 | * after that we are free to use the skb->cb array | ||
2377 | * for our information. | ||
2378 | */ | ||
2379 | intf->beacon->skb = skb; | ||
2380 | rt2x00queue_create_tx_descriptor(intf->beacon, &txdesc); | ||
2381 | |||
2382 | entry_priv = intf->beacon->priv_data; | ||
2383 | memset(entry_priv->desc, 0, intf->beacon->queue->desc_size); | ||
2374 | 2384 | ||
2375 | /* | 2385 | /* |
2376 | * Fill in skb descriptor | 2386 | * Fill in skb descriptor |
@@ -2380,7 +2390,7 @@ static int rt61pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
2380 | skbdesc->flags |= FRAME_DESC_DRIVER_GENERATED; | 2390 | skbdesc->flags |= FRAME_DESC_DRIVER_GENERATED; |
2381 | skbdesc->data = skb->data; | 2391 | skbdesc->data = skb->data; |
2382 | skbdesc->data_len = skb->len; | 2392 | skbdesc->data_len = skb->len; |
2383 | skbdesc->desc = priv_tx->desc; | 2393 | skbdesc->desc = entry_priv->desc; |
2384 | skbdesc->desc_len = intf->beacon->queue->desc_size; | 2394 | skbdesc->desc_len = intf->beacon->queue->desc_size; |
2385 | skbdesc->entry = intf->beacon; | 2395 | skbdesc->entry = intf->beacon; |
2386 | 2396 | ||
@@ -2398,7 +2408,7 @@ static int rt61pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
2398 | * Write entire beacon with descriptor to register, | 2408 | * Write entire beacon with descriptor to register, |
2399 | * and kick the beacon generator. | 2409 | * and kick the beacon generator. |
2400 | */ | 2410 | */ |
2401 | rt2x00lib_write_tx_desc(rt2x00dev, skb, control); | 2411 | rt2x00queue_write_tx_descriptor(intf->beacon, &txdesc); |
2402 | beacon_base = HW_BEACON_OFFSET(intf->beacon->entry_idx); | 2412 | beacon_base = HW_BEACON_OFFSET(intf->beacon->entry_idx); |
2403 | rt2x00pci_register_multiwrite(rt2x00dev, beacon_base, | 2413 | rt2x00pci_register_multiwrite(rt2x00dev, beacon_base, |
2404 | skbdesc->desc, skbdesc->desc_len); | 2414 | skbdesc->desc, skbdesc->desc_len); |
@@ -2457,21 +2467,21 @@ static const struct data_queue_desc rt61pci_queue_rx = { | |||
2457 | .entry_num = RX_ENTRIES, | 2467 | .entry_num = RX_ENTRIES, |
2458 | .data_size = DATA_FRAME_SIZE, | 2468 | .data_size = DATA_FRAME_SIZE, |
2459 | .desc_size = RXD_DESC_SIZE, | 2469 | .desc_size = RXD_DESC_SIZE, |
2460 | .priv_size = sizeof(struct queue_entry_priv_pci_rx), | 2470 | .priv_size = sizeof(struct queue_entry_priv_pci), |
2461 | }; | 2471 | }; |
2462 | 2472 | ||
2463 | static const struct data_queue_desc rt61pci_queue_tx = { | 2473 | static const struct data_queue_desc rt61pci_queue_tx = { |
2464 | .entry_num = TX_ENTRIES, | 2474 | .entry_num = TX_ENTRIES, |
2465 | .data_size = DATA_FRAME_SIZE, | 2475 | .data_size = DATA_FRAME_SIZE, |
2466 | .desc_size = TXD_DESC_SIZE, | 2476 | .desc_size = TXD_DESC_SIZE, |
2467 | .priv_size = sizeof(struct queue_entry_priv_pci_tx), | 2477 | .priv_size = sizeof(struct queue_entry_priv_pci), |
2468 | }; | 2478 | }; |
2469 | 2479 | ||
2470 | static const struct data_queue_desc rt61pci_queue_bcn = { | 2480 | static const struct data_queue_desc rt61pci_queue_bcn = { |
2471 | .entry_num = 4 * BEACON_ENTRIES, | 2481 | .entry_num = 4 * BEACON_ENTRIES, |
2472 | .data_size = 0, /* No DMA required for beacons */ | 2482 | .data_size = 0, /* No DMA required for beacons */ |
2473 | .desc_size = TXINFO_SIZE, | 2483 | .desc_size = TXINFO_SIZE, |
2474 | .priv_size = sizeof(struct queue_entry_priv_pci_tx), | 2484 | .priv_size = sizeof(struct queue_entry_priv_pci), |
2475 | }; | 2485 | }; |
2476 | 2486 | ||
2477 | static const struct rt2x00_ops rt61pci_ops = { | 2487 | static const struct rt2x00_ops rt61pci_ops = { |
@@ -2480,6 +2490,7 @@ static const struct rt2x00_ops rt61pci_ops = { | |||
2480 | .max_ap_intf = 4, | 2490 | .max_ap_intf = 4, |
2481 | .eeprom_size = EEPROM_SIZE, | 2491 | .eeprom_size = EEPROM_SIZE, |
2482 | .rf_size = RF_SIZE, | 2492 | .rf_size = RF_SIZE, |
2493 | .tx_queues = NUM_TX_QUEUES, | ||
2483 | .rx = &rt61pci_queue_rx, | 2494 | .rx = &rt61pci_queue_rx, |
2484 | .tx = &rt61pci_queue_tx, | 2495 | .tx = &rt61pci_queue_tx, |
2485 | .bcn = &rt61pci_queue_bcn, | 2496 | .bcn = &rt61pci_queue_bcn, |
diff --git a/drivers/net/wireless/rt2x00/rt61pci.h b/drivers/net/wireless/rt2x00/rt61pci.h index 3511bba7ff65..c5a04b9329d2 100644 --- a/drivers/net/wireless/rt2x00/rt61pci.h +++ b/drivers/net/wireless/rt2x00/rt61pci.h | |||
@@ -54,6 +54,11 @@ | |||
54 | #define RF_SIZE 0x0014 | 54 | #define RF_SIZE 0x0014 |
55 | 55 | ||
56 | /* | 56 | /* |
57 | * Number of TX queues. | ||
58 | */ | ||
59 | #define NUM_TX_QUEUES 4 | ||
60 | |||
61 | /* | ||
57 | * PCI registers. | 62 | * PCI registers. |
58 | */ | 63 | */ |
59 | 64 | ||
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c index 51c5575ed02f..26c2e0a1a308 100644 --- a/drivers/net/wireless/rt2x00/rt73usb.c +++ b/drivers/net/wireless/rt2x00/rt73usb.c | |||
@@ -1255,8 +1255,7 @@ static int rt73usb_set_device_state(struct rt2x00_dev *rt2x00dev, | |||
1255 | */ | 1255 | */ |
1256 | static void rt73usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, | 1256 | static void rt73usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, |
1257 | struct sk_buff *skb, | 1257 | struct sk_buff *skb, |
1258 | struct txentry_desc *txdesc, | 1258 | struct txentry_desc *txdesc) |
1259 | struct ieee80211_tx_control *control) | ||
1260 | { | 1259 | { |
1261 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb); | 1260 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb); |
1262 | __le32 *txd = skbdesc->desc; | 1261 | __le32 *txd = skbdesc->desc; |
@@ -1301,8 +1300,7 @@ static void rt73usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, | |||
1301 | test_bit(ENTRY_TXD_OFDM_RATE, &txdesc->flags)); | 1300 | test_bit(ENTRY_TXD_OFDM_RATE, &txdesc->flags)); |
1302 | rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs); | 1301 | rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs); |
1303 | rt2x00_set_field32(&word, TXD_W0_RETRY_MODE, | 1302 | rt2x00_set_field32(&word, TXD_W0_RETRY_MODE, |
1304 | !!(control->flags & | 1303 | test_bit(ENTRY_TXD_RETRY_MODE, &txdesc->flags)); |
1305 | IEEE80211_TXCTL_LONG_RETRY_LIMIT)); | ||
1306 | rt2x00_set_field32(&word, TXD_W0_TKIP_MIC, 0); | 1304 | rt2x00_set_field32(&word, TXD_W0_TKIP_MIC, 0); |
1307 | rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, skbdesc->data_len); | 1305 | rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, skbdesc->data_len); |
1308 | rt2x00_set_field32(&word, TXD_W0_BURST2, | 1306 | rt2x00_set_field32(&word, TXD_W0_BURST2, |
@@ -1405,25 +1403,26 @@ static void rt73usb_fill_rxdone(struct queue_entry *entry, | |||
1405 | { | 1403 | { |
1406 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); | 1404 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); |
1407 | __le32 *rxd = (__le32 *)entry->skb->data; | 1405 | __le32 *rxd = (__le32 *)entry->skb->data; |
1408 | unsigned int offset = entry->queue->desc_size + 2; | ||
1409 | u32 word0; | 1406 | u32 word0; |
1410 | u32 word1; | 1407 | u32 word1; |
1411 | 1408 | ||
1412 | /* | 1409 | /* |
1413 | * Copy descriptor to the available headroom inside the skbuffer. | 1410 | * Copy descriptor to the skb->cb array, this has 2 benefits: |
1411 | * 1) Each descriptor word is 4 byte aligned. | ||
1412 | * 2) Descriptor is safe from moving of frame data in rt2x00usb. | ||
1414 | */ | 1413 | */ |
1415 | skb_push(entry->skb, offset); | 1414 | skbdesc->desc_len = |
1416 | memcpy(entry->skb->data, rxd, entry->queue->desc_size); | 1415 | min_t(u16, entry->queue->desc_size, sizeof(entry->skb->cb)); |
1417 | rxd = (__le32 *)entry->skb->data; | 1416 | memcpy(entry->skb->cb, rxd, skbdesc->desc_len); |
1417 | skbdesc->desc = entry->skb->cb; | ||
1418 | rxd = (__le32 *)skbdesc->desc; | ||
1418 | 1419 | ||
1419 | /* | 1420 | /* |
1420 | * The descriptor is now aligned to 4 bytes and thus it is | 1421 | * It is now safe to read the descriptor on all architectures. |
1421 | * now safe to read it on all architectures. | ||
1422 | */ | 1422 | */ |
1423 | rt2x00_desc_read(rxd, 0, &word0); | 1423 | rt2x00_desc_read(rxd, 0, &word0); |
1424 | rt2x00_desc_read(rxd, 1, &word1); | 1424 | rt2x00_desc_read(rxd, 1, &word1); |
1425 | 1425 | ||
1426 | rxdesc->flags = 0; | ||
1427 | if (rt2x00_get_field32(word0, RXD_W0_CRC_ERROR)) | 1426 | if (rt2x00_get_field32(word0, RXD_W0_CRC_ERROR)) |
1428 | rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC; | 1427 | rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC; |
1429 | 1428 | ||
@@ -1437,25 +1436,18 @@ static void rt73usb_fill_rxdone(struct queue_entry *entry, | |||
1437 | rxdesc->rssi = rt73usb_agc_to_rssi(entry->queue->rt2x00dev, word1); | 1436 | rxdesc->rssi = rt73usb_agc_to_rssi(entry->queue->rt2x00dev, word1); |
1438 | rxdesc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT); | 1437 | rxdesc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT); |
1439 | 1438 | ||
1440 | rxdesc->dev_flags = 0; | ||
1441 | if (rt2x00_get_field32(word0, RXD_W0_OFDM)) | 1439 | if (rt2x00_get_field32(word0, RXD_W0_OFDM)) |
1442 | rxdesc->dev_flags |= RXDONE_SIGNAL_PLCP; | 1440 | rxdesc->dev_flags |= RXDONE_SIGNAL_PLCP; |
1443 | if (rt2x00_get_field32(word0, RXD_W0_MY_BSS)) | 1441 | if (rt2x00_get_field32(word0, RXD_W0_MY_BSS)) |
1444 | rxdesc->dev_flags |= RXDONE_MY_BSS; | 1442 | rxdesc->dev_flags |= RXDONE_MY_BSS; |
1445 | 1443 | ||
1446 | /* | 1444 | /* |
1447 | * Adjust the skb memory window to the frame boundaries. | 1445 | * Set skb pointers, and update frame information. |
1448 | */ | 1446 | */ |
1449 | skb_pull(entry->skb, offset + entry->queue->desc_size); | 1447 | skb_pull(entry->skb, entry->queue->desc_size); |
1450 | skb_trim(entry->skb, rxdesc->size); | 1448 | skb_trim(entry->skb, rxdesc->size); |
1451 | |||
1452 | /* | ||
1453 | * Set descriptor and data pointer. | ||
1454 | */ | ||
1455 | skbdesc->data = entry->skb->data; | 1449 | skbdesc->data = entry->skb->data; |
1456 | skbdesc->data_len = rxdesc->size; | 1450 | skbdesc->data_len = rxdesc->size; |
1457 | skbdesc->desc = rxd; | ||
1458 | skbdesc->desc_len = entry->queue->desc_size; | ||
1459 | } | 1451 | } |
1460 | 1452 | ||
1461 | /* | 1453 | /* |
@@ -1833,7 +1825,6 @@ static void rt73usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev) | |||
1833 | IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | | 1825 | IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | |
1834 | IEEE80211_HW_SIGNAL_DBM; | 1826 | IEEE80211_HW_SIGNAL_DBM; |
1835 | rt2x00dev->hw->extra_tx_headroom = TXD_DESC_SIZE; | 1827 | rt2x00dev->hw->extra_tx_headroom = TXD_DESC_SIZE; |
1836 | rt2x00dev->hw->queues = 4; | ||
1837 | 1828 | ||
1838 | SET_IEEE80211_DEV(rt2x00dev->hw, &rt2x00dev_usb(rt2x00dev)->dev); | 1829 | SET_IEEE80211_DEV(rt2x00dev->hw, &rt2x00dev_usb(rt2x00dev)->dev); |
1839 | SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, | 1830 | SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, |
@@ -1957,12 +1948,13 @@ static u64 rt73usb_get_tsf(struct ieee80211_hw *hw) | |||
1957 | #define rt73usb_get_tsf NULL | 1948 | #define rt73usb_get_tsf NULL |
1958 | #endif | 1949 | #endif |
1959 | 1950 | ||
1960 | static int rt73usb_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb, | 1951 | static int rt73usb_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb) |
1961 | struct ieee80211_tx_control *control) | ||
1962 | { | 1952 | { |
1963 | struct rt2x00_dev *rt2x00dev = hw->priv; | 1953 | struct rt2x00_dev *rt2x00dev = hw->priv; |
1964 | struct rt2x00_intf *intf = vif_to_intf(control->vif); | 1954 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); |
1955 | struct rt2x00_intf *intf = vif_to_intf(tx_info->control.vif); | ||
1965 | struct skb_frame_desc *skbdesc; | 1956 | struct skb_frame_desc *skbdesc; |
1957 | struct txentry_desc txdesc; | ||
1966 | unsigned int beacon_base; | 1958 | unsigned int beacon_base; |
1967 | u32 reg; | 1959 | u32 reg; |
1968 | 1960 | ||
@@ -1970,6 +1962,14 @@ static int rt73usb_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
1970 | return -ENOBUFS; | 1962 | return -ENOBUFS; |
1971 | 1963 | ||
1972 | /* | 1964 | /* |
1965 | * Copy all TX descriptor information into txdesc, | ||
1966 | * after that we are free to use the skb->cb array | ||
1967 | * for our information. | ||
1968 | */ | ||
1969 | intf->beacon->skb = skb; | ||
1970 | rt2x00queue_create_tx_descriptor(intf->beacon, &txdesc); | ||
1971 | |||
1972 | /* | ||
1973 | * Add the descriptor in front of the skb. | 1973 | * Add the descriptor in front of the skb. |
1974 | */ | 1974 | */ |
1975 | skb_push(skb, intf->beacon->queue->desc_size); | 1975 | skb_push(skb, intf->beacon->queue->desc_size); |
@@ -2001,7 +2001,7 @@ static int rt73usb_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
2001 | * Write entire beacon with descriptor to register, | 2001 | * Write entire beacon with descriptor to register, |
2002 | * and kick the beacon generator. | 2002 | * and kick the beacon generator. |
2003 | */ | 2003 | */ |
2004 | rt2x00lib_write_tx_desc(rt2x00dev, skb, control); | 2004 | rt2x00queue_write_tx_descriptor(intf->beacon, &txdesc); |
2005 | beacon_base = HW_BEACON_OFFSET(intf->beacon->entry_idx); | 2005 | beacon_base = HW_BEACON_OFFSET(intf->beacon->entry_idx); |
2006 | rt2x00usb_vendor_request(rt2x00dev, USB_MULTI_WRITE, | 2006 | rt2x00usb_vendor_request(rt2x00dev, USB_MULTI_WRITE, |
2007 | USB_VENDOR_REQUEST_OUT, beacon_base, 0, | 2007 | USB_VENDOR_REQUEST_OUT, beacon_base, 0, |
@@ -2058,21 +2058,21 @@ static const struct data_queue_desc rt73usb_queue_rx = { | |||
2058 | .entry_num = RX_ENTRIES, | 2058 | .entry_num = RX_ENTRIES, |
2059 | .data_size = DATA_FRAME_SIZE, | 2059 | .data_size = DATA_FRAME_SIZE, |
2060 | .desc_size = RXD_DESC_SIZE, | 2060 | .desc_size = RXD_DESC_SIZE, |
2061 | .priv_size = sizeof(struct queue_entry_priv_usb_rx), | 2061 | .priv_size = sizeof(struct queue_entry_priv_usb), |
2062 | }; | 2062 | }; |
2063 | 2063 | ||
2064 | static const struct data_queue_desc rt73usb_queue_tx = { | 2064 | static const struct data_queue_desc rt73usb_queue_tx = { |
2065 | .entry_num = TX_ENTRIES, | 2065 | .entry_num = TX_ENTRIES, |
2066 | .data_size = DATA_FRAME_SIZE, | 2066 | .data_size = DATA_FRAME_SIZE, |
2067 | .desc_size = TXD_DESC_SIZE, | 2067 | .desc_size = TXD_DESC_SIZE, |
2068 | .priv_size = sizeof(struct queue_entry_priv_usb_tx), | 2068 | .priv_size = sizeof(struct queue_entry_priv_usb), |
2069 | }; | 2069 | }; |
2070 | 2070 | ||
2071 | static const struct data_queue_desc rt73usb_queue_bcn = { | 2071 | static const struct data_queue_desc rt73usb_queue_bcn = { |
2072 | .entry_num = 4 * BEACON_ENTRIES, | 2072 | .entry_num = 4 * BEACON_ENTRIES, |
2073 | .data_size = MGMT_FRAME_SIZE, | 2073 | .data_size = MGMT_FRAME_SIZE, |
2074 | .desc_size = TXINFO_SIZE, | 2074 | .desc_size = TXINFO_SIZE, |
2075 | .priv_size = sizeof(struct queue_entry_priv_usb_tx), | 2075 | .priv_size = sizeof(struct queue_entry_priv_usb), |
2076 | }; | 2076 | }; |
2077 | 2077 | ||
2078 | static const struct rt2x00_ops rt73usb_ops = { | 2078 | static const struct rt2x00_ops rt73usb_ops = { |
@@ -2081,6 +2081,7 @@ static const struct rt2x00_ops rt73usb_ops = { | |||
2081 | .max_ap_intf = 4, | 2081 | .max_ap_intf = 4, |
2082 | .eeprom_size = EEPROM_SIZE, | 2082 | .eeprom_size = EEPROM_SIZE, |
2083 | .rf_size = RF_SIZE, | 2083 | .rf_size = RF_SIZE, |
2084 | .tx_queues = NUM_TX_QUEUES, | ||
2084 | .rx = &rt73usb_queue_rx, | 2085 | .rx = &rt73usb_queue_rx, |
2085 | .tx = &rt73usb_queue_tx, | 2086 | .tx = &rt73usb_queue_tx, |
2086 | .bcn = &rt73usb_queue_bcn, | 2087 | .bcn = &rt73usb_queue_bcn, |
diff --git a/drivers/net/wireless/rt2x00/rt73usb.h b/drivers/net/wireless/rt2x00/rt73usb.h index 06d687425fef..25cdcc9bf7c4 100644 --- a/drivers/net/wireless/rt2x00/rt73usb.h +++ b/drivers/net/wireless/rt2x00/rt73usb.h | |||
@@ -54,6 +54,11 @@ | |||
54 | #define RF_SIZE 0x0014 | 54 | #define RF_SIZE 0x0014 |
55 | 55 | ||
56 | /* | 56 | /* |
57 | * Number of TX queues. | ||
58 | */ | ||
59 | #define NUM_TX_QUEUES 4 | ||
60 | |||
61 | /* | ||
57 | * USB registers. | 62 | * USB registers. |
58 | */ | 63 | */ |
59 | 64 | ||
diff --git a/drivers/net/wireless/rtl8180_dev.c b/drivers/net/wireless/rtl8180_dev.c index c220998cee65..b7172a12c057 100644 --- a/drivers/net/wireless/rtl8180_dev.c +++ b/drivers/net/wireless/rtl8180_dev.c | |||
@@ -170,34 +170,29 @@ static void rtl8180_handle_tx(struct ieee80211_hw *dev, unsigned int prio) | |||
170 | while (skb_queue_len(&ring->queue)) { | 170 | while (skb_queue_len(&ring->queue)) { |
171 | struct rtl8180_tx_desc *entry = &ring->desc[ring->idx]; | 171 | struct rtl8180_tx_desc *entry = &ring->desc[ring->idx]; |
172 | struct sk_buff *skb; | 172 | struct sk_buff *skb; |
173 | struct ieee80211_tx_status status; | 173 | struct ieee80211_tx_info *info; |
174 | struct ieee80211_tx_control *control; | ||
175 | u32 flags = le32_to_cpu(entry->flags); | 174 | u32 flags = le32_to_cpu(entry->flags); |
176 | 175 | ||
177 | if (flags & RTL8180_TX_DESC_FLAG_OWN) | 176 | if (flags & RTL8180_TX_DESC_FLAG_OWN) |
178 | return; | 177 | return; |
179 | 178 | ||
180 | memset(&status, 0, sizeof(status)); | ||
181 | |||
182 | ring->idx = (ring->idx + 1) % ring->entries; | 179 | ring->idx = (ring->idx + 1) % ring->entries; |
183 | skb = __skb_dequeue(&ring->queue); | 180 | skb = __skb_dequeue(&ring->queue); |
184 | pci_unmap_single(priv->pdev, le32_to_cpu(entry->tx_buf), | 181 | pci_unmap_single(priv->pdev, le32_to_cpu(entry->tx_buf), |
185 | skb->len, PCI_DMA_TODEVICE); | 182 | skb->len, PCI_DMA_TODEVICE); |
186 | 183 | ||
187 | control = *((struct ieee80211_tx_control **)skb->cb); | 184 | info = IEEE80211_SKB_CB(skb); |
188 | if (control) | 185 | memset(&info->status, 0, sizeof(info->status)); |
189 | memcpy(&status.control, control, sizeof(*control)); | ||
190 | kfree(control); | ||
191 | 186 | ||
192 | if (!(status.control.flags & IEEE80211_TXCTL_NO_ACK)) { | 187 | if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) { |
193 | if (flags & RTL8180_TX_DESC_FLAG_TX_OK) | 188 | if (flags & RTL8180_TX_DESC_FLAG_TX_OK) |
194 | status.flags = IEEE80211_TX_STATUS_ACK; | 189 | info->flags |= IEEE80211_TX_STAT_ACK; |
195 | else | 190 | else |
196 | status.excessive_retries = 1; | 191 | info->status.excessive_retries = 1; |
197 | } | 192 | } |
198 | status.retry_count = flags & 0xFF; | 193 | info->status.retry_count = flags & 0xFF; |
199 | 194 | ||
200 | ieee80211_tx_status_irqsafe(dev, skb, &status); | 195 | ieee80211_tx_status_irqsafe(dev, skb); |
201 | if (ring->entries - skb_queue_len(&ring->queue) == 2) | 196 | if (ring->entries - skb_queue_len(&ring->queue) == 2) |
202 | ieee80211_wake_queue(dev, prio); | 197 | ieee80211_wake_queue(dev, prio); |
203 | } | 198 | } |
@@ -238,9 +233,9 @@ static irqreturn_t rtl8180_interrupt(int irq, void *dev_id) | |||
238 | return IRQ_HANDLED; | 233 | return IRQ_HANDLED; |
239 | } | 234 | } |
240 | 235 | ||
241 | static int rtl8180_tx(struct ieee80211_hw *dev, struct sk_buff *skb, | 236 | static int rtl8180_tx(struct ieee80211_hw *dev, struct sk_buff *skb) |
242 | struct ieee80211_tx_control *control) | ||
243 | { | 237 | { |
238 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
244 | struct rtl8180_priv *priv = dev->priv; | 239 | struct rtl8180_priv *priv = dev->priv; |
245 | struct rtl8180_tx_ring *ring; | 240 | struct rtl8180_tx_ring *ring; |
246 | struct rtl8180_tx_desc *entry; | 241 | struct rtl8180_tx_desc *entry; |
@@ -251,46 +246,40 @@ static int rtl8180_tx(struct ieee80211_hw *dev, struct sk_buff *skb, | |||
251 | u16 plcp_len = 0; | 246 | u16 plcp_len = 0; |
252 | __le16 rts_duration = 0; | 247 | __le16 rts_duration = 0; |
253 | 248 | ||
254 | prio = control->queue; | 249 | prio = skb_get_queue_mapping(skb); |
255 | ring = &priv->tx_ring[prio]; | 250 | ring = &priv->tx_ring[prio]; |
256 | 251 | ||
257 | mapping = pci_map_single(priv->pdev, skb->data, | 252 | mapping = pci_map_single(priv->pdev, skb->data, |
258 | skb->len, PCI_DMA_TODEVICE); | 253 | skb->len, PCI_DMA_TODEVICE); |
259 | 254 | ||
260 | BUG_ON(!control->tx_rate); | ||
261 | |||
262 | tx_flags = RTL8180_TX_DESC_FLAG_OWN | RTL8180_TX_DESC_FLAG_FS | | 255 | tx_flags = RTL8180_TX_DESC_FLAG_OWN | RTL8180_TX_DESC_FLAG_FS | |
263 | RTL8180_TX_DESC_FLAG_LS | | 256 | RTL8180_TX_DESC_FLAG_LS | |
264 | (control->tx_rate->hw_value << 24) | skb->len; | 257 | (ieee80211_get_tx_rate(dev, info)->hw_value << 24) | |
258 | skb->len; | ||
265 | 259 | ||
266 | if (priv->r8185) | 260 | if (priv->r8185) |
267 | tx_flags |= RTL8180_TX_DESC_FLAG_DMA | | 261 | tx_flags |= RTL8180_TX_DESC_FLAG_DMA | |
268 | RTL8180_TX_DESC_FLAG_NO_ENC; | 262 | RTL8180_TX_DESC_FLAG_NO_ENC; |
269 | 263 | ||
270 | if (control->flags & IEEE80211_TXCTL_USE_RTS_CTS) { | 264 | if (info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) { |
271 | BUG_ON(!control->rts_cts_rate); | ||
272 | tx_flags |= RTL8180_TX_DESC_FLAG_RTS; | 265 | tx_flags |= RTL8180_TX_DESC_FLAG_RTS; |
273 | tx_flags |= control->rts_cts_rate->hw_value << 19; | 266 | tx_flags |= ieee80211_get_rts_cts_rate(dev, info)->hw_value << 19; |
274 | } else if (control->flags & IEEE80211_TXCTL_USE_CTS_PROTECT) { | 267 | } else if (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) { |
275 | BUG_ON(!control->rts_cts_rate); | ||
276 | tx_flags |= RTL8180_TX_DESC_FLAG_CTS; | 268 | tx_flags |= RTL8180_TX_DESC_FLAG_CTS; |
277 | tx_flags |= control->rts_cts_rate->hw_value << 19; | 269 | tx_flags |= ieee80211_get_rts_cts_rate(dev, info)->hw_value << 19; |
278 | } | 270 | } |
279 | 271 | ||
280 | *((struct ieee80211_tx_control **) skb->cb) = | 272 | if (info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) |
281 | kmemdup(control, sizeof(*control), GFP_ATOMIC); | ||
282 | |||
283 | if (control->flags & IEEE80211_TXCTL_USE_RTS_CTS) | ||
284 | rts_duration = ieee80211_rts_duration(dev, priv->vif, skb->len, | 273 | rts_duration = ieee80211_rts_duration(dev, priv->vif, skb->len, |
285 | control); | 274 | info); |
286 | 275 | ||
287 | if (!priv->r8185) { | 276 | if (!priv->r8185) { |
288 | unsigned int remainder; | 277 | unsigned int remainder; |
289 | 278 | ||
290 | plcp_len = DIV_ROUND_UP(16 * (skb->len + 4), | 279 | plcp_len = DIV_ROUND_UP(16 * (skb->len + 4), |
291 | (control->tx_rate->bitrate * 2) / 10); | 280 | (ieee80211_get_tx_rate(dev, info)->bitrate * 2) / 10); |
292 | remainder = (16 * (skb->len + 4)) % | 281 | remainder = (16 * (skb->len + 4)) % |
293 | ((control->tx_rate->bitrate * 2) / 10); | 282 | ((ieee80211_get_tx_rate(dev, info)->bitrate * 2) / 10); |
294 | if (remainder > 0 && remainder <= 6) | 283 | if (remainder > 0 && remainder <= 6) |
295 | plcp_len |= 1 << 15; | 284 | plcp_len |= 1 << 15; |
296 | } | 285 | } |
@@ -303,13 +292,13 @@ static int rtl8180_tx(struct ieee80211_hw *dev, struct sk_buff *skb, | |||
303 | entry->plcp_len = cpu_to_le16(plcp_len); | 292 | entry->plcp_len = cpu_to_le16(plcp_len); |
304 | entry->tx_buf = cpu_to_le32(mapping); | 293 | entry->tx_buf = cpu_to_le32(mapping); |
305 | entry->frame_len = cpu_to_le32(skb->len); | 294 | entry->frame_len = cpu_to_le32(skb->len); |
306 | entry->flags2 = control->alt_retry_rate != NULL ? | 295 | entry->flags2 = info->control.alt_retry_rate_idx >= 0 ? |
307 | control->alt_retry_rate->bitrate << 4 : 0; | 296 | ieee80211_get_alt_retry_rate(dev, info)->bitrate << 4 : 0; |
308 | entry->retry_limit = control->retry_limit; | 297 | entry->retry_limit = info->control.retry_limit; |
309 | entry->flags = cpu_to_le32(tx_flags); | 298 | entry->flags = cpu_to_le32(tx_flags); |
310 | __skb_queue_tail(&ring->queue, skb); | 299 | __skb_queue_tail(&ring->queue, skb); |
311 | if (ring->entries - skb_queue_len(&ring->queue) < 2) | 300 | if (ring->entries - skb_queue_len(&ring->queue) < 2) |
312 | ieee80211_stop_queue(dev, control->queue); | 301 | ieee80211_stop_queue(dev, skb_get_queue_mapping(skb)); |
313 | spin_unlock_irqrestore(&priv->lock, flags); | 302 | spin_unlock_irqrestore(&priv->lock, flags); |
314 | 303 | ||
315 | rtl818x_iowrite8(priv, &priv->map->TX_DMA_POLLING, (1 << (prio + 4))); | 304 | rtl818x_iowrite8(priv, &priv->map->TX_DMA_POLLING, (1 << (prio + 4))); |
@@ -525,7 +514,6 @@ static void rtl8180_free_tx_ring(struct ieee80211_hw *dev, unsigned int prio) | |||
525 | 514 | ||
526 | pci_unmap_single(priv->pdev, le32_to_cpu(entry->tx_buf), | 515 | pci_unmap_single(priv->pdev, le32_to_cpu(entry->tx_buf), |
527 | skb->len, PCI_DMA_TODEVICE); | 516 | skb->len, PCI_DMA_TODEVICE); |
528 | kfree(*((struct ieee80211_tx_control **) skb->cb)); | ||
529 | kfree_skb(skb); | 517 | kfree_skb(skb); |
530 | ring->idx = (ring->idx + 1) % ring->entries; | 518 | ring->idx = (ring->idx + 1) % ring->entries; |
531 | } | 519 | } |
diff --git a/drivers/net/wireless/rtl8187.h b/drivers/net/wireless/rtl8187.h index 076d88b6db0e..a0cfb666de0e 100644 --- a/drivers/net/wireless/rtl8187.h +++ b/drivers/net/wireless/rtl8187.h | |||
@@ -44,12 +44,6 @@ struct rtl8187_rx_hdr { | |||
44 | __le64 mac_time; | 44 | __le64 mac_time; |
45 | } __attribute__((packed)); | 45 | } __attribute__((packed)); |
46 | 46 | ||
47 | struct rtl8187_tx_info { | ||
48 | struct ieee80211_tx_control *control; | ||
49 | struct urb *urb; | ||
50 | struct ieee80211_hw *dev; | ||
51 | }; | ||
52 | |||
53 | struct rtl8187_tx_hdr { | 47 | struct rtl8187_tx_hdr { |
54 | __le32 flags; | 48 | __le32 flags; |
55 | #define RTL8187_TX_FLAG_NO_ENCRYPT (1 << 15) | 49 | #define RTL8187_TX_FLAG_NO_ENCRYPT (1 << 15) |
diff --git a/drivers/net/wireless/rtl8187_dev.c b/drivers/net/wireless/rtl8187_dev.c index 23514456d373..0078c7e9918c 100644 --- a/drivers/net/wireless/rtl8187_dev.c +++ b/drivers/net/wireless/rtl8187_dev.c | |||
@@ -150,27 +150,22 @@ void rtl8187_write_phy(struct ieee80211_hw *dev, u8 addr, u32 data) | |||
150 | 150 | ||
151 | static void rtl8187_tx_cb(struct urb *urb) | 151 | static void rtl8187_tx_cb(struct urb *urb) |
152 | { | 152 | { |
153 | struct ieee80211_tx_status status; | ||
154 | struct sk_buff *skb = (struct sk_buff *)urb->context; | 153 | struct sk_buff *skb = (struct sk_buff *)urb->context; |
155 | struct rtl8187_tx_info *info = (struct rtl8187_tx_info *)skb->cb; | 154 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
155 | struct ieee80211_hw *hw = info->driver_data[0]; | ||
156 | 156 | ||
157 | memset(&status, 0, sizeof(status)); | 157 | usb_free_urb(info->driver_data[1]); |
158 | |||
159 | usb_free_urb(info->urb); | ||
160 | if (info->control) | ||
161 | memcpy(&status.control, info->control, sizeof(status.control)); | ||
162 | kfree(info->control); | ||
163 | skb_pull(skb, sizeof(struct rtl8187_tx_hdr)); | 158 | skb_pull(skb, sizeof(struct rtl8187_tx_hdr)); |
164 | status.flags |= IEEE80211_TX_STATUS_ACK; | 159 | memset(&info->status, 0, sizeof(info->status)); |
165 | ieee80211_tx_status_irqsafe(info->dev, skb, &status); | 160 | info->flags |= IEEE80211_TX_STAT_ACK; |
161 | ieee80211_tx_status_irqsafe(hw, skb); | ||
166 | } | 162 | } |
167 | 163 | ||
168 | static int rtl8187_tx(struct ieee80211_hw *dev, struct sk_buff *skb, | 164 | static int rtl8187_tx(struct ieee80211_hw *dev, struct sk_buff *skb) |
169 | struct ieee80211_tx_control *control) | ||
170 | { | 165 | { |
171 | struct rtl8187_priv *priv = dev->priv; | 166 | struct rtl8187_priv *priv = dev->priv; |
167 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
172 | struct rtl8187_tx_hdr *hdr; | 168 | struct rtl8187_tx_hdr *hdr; |
173 | struct rtl8187_tx_info *info; | ||
174 | struct urb *urb; | 169 | struct urb *urb; |
175 | __le16 rts_dur = 0; | 170 | __le16 rts_dur = 0; |
176 | u32 flags; | 171 | u32 flags; |
@@ -185,33 +180,27 @@ static int rtl8187_tx(struct ieee80211_hw *dev, struct sk_buff *skb, | |||
185 | flags = skb->len; | 180 | flags = skb->len; |
186 | flags |= RTL8187_TX_FLAG_NO_ENCRYPT; | 181 | flags |= RTL8187_TX_FLAG_NO_ENCRYPT; |
187 | 182 | ||
188 | BUG_ON(!control->tx_rate); | 183 | flags |= ieee80211_get_tx_rate(dev, info)->hw_value << 24; |
189 | |||
190 | flags |= control->tx_rate->hw_value << 24; | ||
191 | if (ieee80211_get_morefrag((struct ieee80211_hdr *)skb->data)) | 184 | if (ieee80211_get_morefrag((struct ieee80211_hdr *)skb->data)) |
192 | flags |= RTL8187_TX_FLAG_MORE_FRAG; | 185 | flags |= RTL8187_TX_FLAG_MORE_FRAG; |
193 | if (control->flags & IEEE80211_TXCTL_USE_RTS_CTS) { | 186 | if (info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) { |
194 | BUG_ON(!control->rts_cts_rate); | ||
195 | flags |= RTL8187_TX_FLAG_RTS; | 187 | flags |= RTL8187_TX_FLAG_RTS; |
196 | flags |= control->rts_cts_rate->hw_value << 19; | 188 | flags |= ieee80211_get_rts_cts_rate(dev, info)->hw_value << 19; |
197 | rts_dur = ieee80211_rts_duration(dev, priv->vif, | 189 | rts_dur = ieee80211_rts_duration(dev, priv->vif, |
198 | skb->len, control); | 190 | skb->len, info); |
199 | } else if (control->flags & IEEE80211_TXCTL_USE_CTS_PROTECT) { | 191 | } else if (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) { |
200 | BUG_ON(!control->rts_cts_rate); | ||
201 | flags |= RTL8187_TX_FLAG_CTS; | 192 | flags |= RTL8187_TX_FLAG_CTS; |
202 | flags |= control->rts_cts_rate->hw_value << 19; | 193 | flags |= ieee80211_get_rts_cts_rate(dev, info)->hw_value << 19; |
203 | } | 194 | } |
204 | 195 | ||
205 | hdr = (struct rtl8187_tx_hdr *)skb_push(skb, sizeof(*hdr)); | 196 | hdr = (struct rtl8187_tx_hdr *)skb_push(skb, sizeof(*hdr)); |
206 | hdr->flags = cpu_to_le32(flags); | 197 | hdr->flags = cpu_to_le32(flags); |
207 | hdr->len = 0; | 198 | hdr->len = 0; |
208 | hdr->rts_duration = rts_dur; | 199 | hdr->rts_duration = rts_dur; |
209 | hdr->retry = cpu_to_le32(control->retry_limit << 8); | 200 | hdr->retry = cpu_to_le32(info->control.retry_limit << 8); |
210 | 201 | ||
211 | info = (struct rtl8187_tx_info *)skb->cb; | 202 | info->driver_data[0] = dev; |
212 | info->control = kmemdup(control, sizeof(*control), GFP_ATOMIC); | 203 | info->driver_data[1] = urb; |
213 | info->urb = urb; | ||
214 | info->dev = dev; | ||
215 | usb_fill_bulk_urb(urb, priv->udev, usb_sndbulkpipe(priv->udev, 2), | 204 | usb_fill_bulk_urb(urb, priv->udev, usb_sndbulkpipe(priv->udev, 2), |
216 | hdr, skb->len, rtl8187_tx_cb, skb); | 205 | hdr, skb->len, rtl8187_tx_cb, skb); |
217 | rc = usb_submit_urb(urb, GFP_ATOMIC); | 206 | rc = usb_submit_urb(urb, GFP_ATOMIC); |
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c index c99d4a4fde05..d2378d083a35 100644 --- a/drivers/net/wireless/zd1211rw/zd_mac.c +++ b/drivers/net/wireless/zd1211rw/zd_mac.c | |||
@@ -224,36 +224,6 @@ out: | |||
224 | return r; | 224 | return r; |
225 | } | 225 | } |
226 | 226 | ||
227 | /** | ||
228 | * clear_tx_skb_control_block - clears the control block of tx skbuffs | ||
229 | * @skb: a &struct sk_buff pointer | ||
230 | * | ||
231 | * This clears the control block of skbuff buffers, which were transmitted to | ||
232 | * the device. Notify that the function is not thread-safe, so prevent | ||
233 | * multiple calls. | ||
234 | */ | ||
235 | static void clear_tx_skb_control_block(struct sk_buff *skb) | ||
236 | { | ||
237 | struct zd_tx_skb_control_block *cb = | ||
238 | (struct zd_tx_skb_control_block *)skb->cb; | ||
239 | |||
240 | kfree(cb->control); | ||
241 | cb->control = NULL; | ||
242 | } | ||
243 | |||
244 | /** | ||
245 | * kfree_tx_skb - frees a tx skbuff | ||
246 | * @skb: a &struct sk_buff pointer | ||
247 | * | ||
248 | * Frees the tx skbuff. Frees also the allocated control structure in the | ||
249 | * control block if necessary. | ||
250 | */ | ||
251 | static void kfree_tx_skb(struct sk_buff *skb) | ||
252 | { | ||
253 | clear_tx_skb_control_block(skb); | ||
254 | dev_kfree_skb_any(skb); | ||
255 | } | ||
256 | |||
257 | static void zd_op_stop(struct ieee80211_hw *hw) | 227 | static void zd_op_stop(struct ieee80211_hw *hw) |
258 | { | 228 | { |
259 | struct zd_mac *mac = zd_hw_mac(hw); | 229 | struct zd_mac *mac = zd_hw_mac(hw); |
@@ -276,40 +246,15 @@ static void zd_op_stop(struct ieee80211_hw *hw) | |||
276 | 246 | ||
277 | 247 | ||
278 | while ((skb = skb_dequeue(ack_wait_queue))) | 248 | while ((skb = skb_dequeue(ack_wait_queue))) |
279 | kfree_tx_skb(skb); | 249 | dev_kfree_skb_any(skb); |
280 | } | ||
281 | |||
282 | /** | ||
283 | * init_tx_skb_control_block - initializes skb control block | ||
284 | * @skb: a &sk_buff pointer | ||
285 | * @dev: pointer to the mac80221 device | ||
286 | * @control: mac80211 tx control applying for the frame in @skb | ||
287 | * | ||
288 | * Initializes the control block of the skbuff to be transmitted. | ||
289 | */ | ||
290 | static int init_tx_skb_control_block(struct sk_buff *skb, | ||
291 | struct ieee80211_hw *hw, | ||
292 | struct ieee80211_tx_control *control) | ||
293 | { | ||
294 | struct zd_tx_skb_control_block *cb = | ||
295 | (struct zd_tx_skb_control_block *)skb->cb; | ||
296 | |||
297 | ZD_ASSERT(sizeof(*cb) <= sizeof(skb->cb)); | ||
298 | memset(cb, 0, sizeof(*cb)); | ||
299 | cb->hw= hw; | ||
300 | cb->control = kmalloc(sizeof(*control), GFP_ATOMIC); | ||
301 | if (cb->control == NULL) | ||
302 | return -ENOMEM; | ||
303 | memcpy(cb->control, control, sizeof(*control)); | ||
304 | |||
305 | return 0; | ||
306 | } | 250 | } |
307 | 251 | ||
308 | /** | 252 | /** |
309 | * tx_status - reports tx status of a packet if required | 253 | * tx_status - reports tx status of a packet if required |
310 | * @hw - a &struct ieee80211_hw pointer | 254 | * @hw - a &struct ieee80211_hw pointer |
311 | * @skb - a sk-buffer | 255 | * @skb - a sk-buffer |
312 | * @status - the tx status of the packet without control information | 256 | * @flags: extra flags to set in the TX status info |
257 | * @ackssi: ACK signal strength | ||
313 | * @success - True for successfull transmission of the frame | 258 | * @success - True for successfull transmission of the frame |
314 | * | 259 | * |
315 | * This information calls ieee80211_tx_status_irqsafe() if required by the | 260 | * This information calls ieee80211_tx_status_irqsafe() if required by the |
@@ -319,18 +264,17 @@ static int init_tx_skb_control_block(struct sk_buff *skb, | |||
319 | * If no status information has been requested, the skb is freed. | 264 | * If no status information has been requested, the skb is freed. |
320 | */ | 265 | */ |
321 | static void tx_status(struct ieee80211_hw *hw, struct sk_buff *skb, | 266 | static void tx_status(struct ieee80211_hw *hw, struct sk_buff *skb, |
322 | struct ieee80211_tx_status *status, | 267 | u32 flags, int ackssi, bool success) |
323 | bool success) | ||
324 | { | 268 | { |
325 | struct zd_tx_skb_control_block *cb = (struct zd_tx_skb_control_block *) | 269 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
326 | skb->cb; | 270 | |
271 | memset(&info->status, 0, sizeof(info->status)); | ||
327 | 272 | ||
328 | ZD_ASSERT(cb->control != NULL); | ||
329 | memcpy(&status->control, cb->control, sizeof(status->control)); | ||
330 | if (!success) | 273 | if (!success) |
331 | status->excessive_retries = 1; | 274 | info->status.excessive_retries = 1; |
332 | clear_tx_skb_control_block(skb); | 275 | info->flags |= flags; |
333 | ieee80211_tx_status_irqsafe(hw, skb, status); | 276 | info->status.ack_signal = ackssi; |
277 | ieee80211_tx_status_irqsafe(hw, skb); | ||
334 | } | 278 | } |
335 | 279 | ||
336 | /** | 280 | /** |
@@ -345,15 +289,12 @@ void zd_mac_tx_failed(struct ieee80211_hw *hw) | |||
345 | { | 289 | { |
346 | struct sk_buff_head *q = &zd_hw_mac(hw)->ack_wait_queue; | 290 | struct sk_buff_head *q = &zd_hw_mac(hw)->ack_wait_queue; |
347 | struct sk_buff *skb; | 291 | struct sk_buff *skb; |
348 | struct ieee80211_tx_status status; | ||
349 | 292 | ||
350 | skb = skb_dequeue(q); | 293 | skb = skb_dequeue(q); |
351 | if (skb == NULL) | 294 | if (skb == NULL) |
352 | return; | 295 | return; |
353 | 296 | ||
354 | memset(&status, 0, sizeof(status)); | 297 | tx_status(hw, skb, 0, 0, 0); |
355 | |||
356 | tx_status(hw, skb, &status, 0); | ||
357 | } | 298 | } |
358 | 299 | ||
359 | /** | 300 | /** |
@@ -368,28 +309,20 @@ void zd_mac_tx_failed(struct ieee80211_hw *hw) | |||
368 | */ | 309 | */ |
369 | void zd_mac_tx_to_dev(struct sk_buff *skb, int error) | 310 | void zd_mac_tx_to_dev(struct sk_buff *skb, int error) |
370 | { | 311 | { |
371 | struct zd_tx_skb_control_block *cb = | 312 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
372 | (struct zd_tx_skb_control_block *)skb->cb; | 313 | struct ieee80211_hw *hw = info->driver_data[0]; |
373 | struct ieee80211_hw *hw = cb->hw; | ||
374 | |||
375 | if (likely(cb->control)) { | ||
376 | skb_pull(skb, sizeof(struct zd_ctrlset)); | ||
377 | if (unlikely(error || | ||
378 | (cb->control->flags & IEEE80211_TXCTL_NO_ACK))) | ||
379 | { | ||
380 | struct ieee80211_tx_status status; | ||
381 | memset(&status, 0, sizeof(status)); | ||
382 | tx_status(hw, skb, &status, !error); | ||
383 | } else { | ||
384 | struct sk_buff_head *q = | ||
385 | &zd_hw_mac(hw)->ack_wait_queue; | ||
386 | 314 | ||
387 | skb_queue_tail(q, skb); | 315 | skb_pull(skb, sizeof(struct zd_ctrlset)); |
388 | while (skb_queue_len(q) > ZD_MAC_MAX_ACK_WAITERS) | 316 | if (unlikely(error || |
389 | zd_mac_tx_failed(hw); | 317 | (info->flags & IEEE80211_TX_CTL_NO_ACK))) { |
390 | } | 318 | tx_status(hw, skb, 0, 0, !error); |
391 | } else { | 319 | } else { |
392 | kfree_tx_skb(skb); | 320 | struct sk_buff_head *q = |
321 | &zd_hw_mac(hw)->ack_wait_queue; | ||
322 | |||
323 | skb_queue_tail(q, skb); | ||
324 | while (skb_queue_len(q) > ZD_MAC_MAX_ACK_WAITERS) | ||
325 | zd_mac_tx_failed(hw); | ||
393 | } | 326 | } |
394 | } | 327 | } |
395 | 328 | ||
@@ -454,7 +387,7 @@ static void cs_set_control(struct zd_mac *mac, struct zd_ctrlset *cs, | |||
454 | cs->control = 0; | 387 | cs->control = 0; |
455 | 388 | ||
456 | /* First fragment */ | 389 | /* First fragment */ |
457 | if (flags & IEEE80211_TXCTL_FIRST_FRAGMENT) | 390 | if (flags & IEEE80211_TX_CTL_FIRST_FRAGMENT) |
458 | cs->control |= ZD_CS_NEED_RANDOM_BACKOFF; | 391 | cs->control |= ZD_CS_NEED_RANDOM_BACKOFF; |
459 | 392 | ||
460 | /* Multicast */ | 393 | /* Multicast */ |
@@ -466,10 +399,10 @@ static void cs_set_control(struct zd_mac *mac, struct zd_ctrlset *cs, | |||
466 | (IEEE80211_FTYPE_CTL|IEEE80211_STYPE_PSPOLL)) | 399 | (IEEE80211_FTYPE_CTL|IEEE80211_STYPE_PSPOLL)) |
467 | cs->control |= ZD_CS_PS_POLL_FRAME; | 400 | cs->control |= ZD_CS_PS_POLL_FRAME; |
468 | 401 | ||
469 | if (flags & IEEE80211_TXCTL_USE_RTS_CTS) | 402 | if (flags & IEEE80211_TX_CTL_USE_RTS_CTS) |
470 | cs->control |= ZD_CS_RTS; | 403 | cs->control |= ZD_CS_RTS; |
471 | 404 | ||
472 | if (flags & IEEE80211_TXCTL_USE_CTS_PROTECT) | 405 | if (flags & IEEE80211_TX_CTL_USE_CTS_PROTECT) |
473 | cs->control |= ZD_CS_SELF_CTS; | 406 | cs->control |= ZD_CS_SELF_CTS; |
474 | 407 | ||
475 | /* FIXME: Management frame? */ | 408 | /* FIXME: Management frame? */ |
@@ -516,25 +449,28 @@ void zd_mac_config_beacon(struct ieee80211_hw *hw, struct sk_buff *beacon) | |||
516 | } | 449 | } |
517 | 450 | ||
518 | static int fill_ctrlset(struct zd_mac *mac, | 451 | static int fill_ctrlset(struct zd_mac *mac, |
519 | struct sk_buff *skb, | 452 | struct sk_buff *skb) |
520 | struct ieee80211_tx_control *control) | ||
521 | { | 453 | { |
522 | int r; | 454 | int r; |
523 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | 455 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; |
524 | unsigned int frag_len = skb->len + FCS_LEN; | 456 | unsigned int frag_len = skb->len + FCS_LEN; |
525 | unsigned int packet_length; | 457 | unsigned int packet_length; |
458 | struct ieee80211_rate *txrate; | ||
526 | struct zd_ctrlset *cs = (struct zd_ctrlset *) | 459 | struct zd_ctrlset *cs = (struct zd_ctrlset *) |
527 | skb_push(skb, sizeof(struct zd_ctrlset)); | 460 | skb_push(skb, sizeof(struct zd_ctrlset)); |
461 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
528 | 462 | ||
529 | ZD_ASSERT(frag_len <= 0xffff); | 463 | ZD_ASSERT(frag_len <= 0xffff); |
530 | 464 | ||
531 | cs->modulation = control->tx_rate->hw_value; | 465 | txrate = ieee80211_get_tx_rate(mac->hw, info); |
532 | if (control->flags & IEEE80211_TXCTL_SHORT_PREAMBLE) | 466 | |
533 | cs->modulation = control->tx_rate->hw_value_short; | 467 | cs->modulation = txrate->hw_value; |
468 | if (info->flags & IEEE80211_TX_CTL_SHORT_PREAMBLE) | ||
469 | cs->modulation = txrate->hw_value_short; | ||
534 | 470 | ||
535 | cs->tx_length = cpu_to_le16(frag_len); | 471 | cs->tx_length = cpu_to_le16(frag_len); |
536 | 472 | ||
537 | cs_set_control(mac, cs, hdr, control->flags); | 473 | cs_set_control(mac, cs, hdr, info->flags); |
538 | 474 | ||
539 | packet_length = frag_len + sizeof(struct zd_ctrlset) + 10; | 475 | packet_length = frag_len + sizeof(struct zd_ctrlset) + 10; |
540 | ZD_ASSERT(packet_length <= 0xffff); | 476 | ZD_ASSERT(packet_length <= 0xffff); |
@@ -579,24 +515,21 @@ static int fill_ctrlset(struct zd_mac *mac, | |||
579 | * control block of the skbuff will be initialized. If necessary the incoming | 515 | * control block of the skbuff will be initialized. If necessary the incoming |
580 | * mac80211 queues will be stopped. | 516 | * mac80211 queues will be stopped. |
581 | */ | 517 | */ |
582 | static int zd_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb, | 518 | static int zd_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) |
583 | struct ieee80211_tx_control *control) | ||
584 | { | 519 | { |
585 | struct zd_mac *mac = zd_hw_mac(hw); | 520 | struct zd_mac *mac = zd_hw_mac(hw); |
521 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
586 | int r; | 522 | int r; |
587 | 523 | ||
588 | r = fill_ctrlset(mac, skb, control); | 524 | r = fill_ctrlset(mac, skb); |
589 | if (r) | 525 | if (r) |
590 | return r; | 526 | return r; |
591 | 527 | ||
592 | r = init_tx_skb_control_block(skb, hw, control); | 528 | info->driver_data[0] = hw; |
593 | if (r) | 529 | |
594 | return r; | ||
595 | r = zd_usb_tx(&mac->chip.usb, skb); | 530 | r = zd_usb_tx(&mac->chip.usb, skb); |
596 | if (r) { | 531 | if (r) |
597 | clear_tx_skb_control_block(skb); | ||
598 | return r; | 532 | return r; |
599 | } | ||
600 | return 0; | 533 | return 0; |
601 | } | 534 | } |
602 | 535 | ||
@@ -634,13 +567,8 @@ static int filter_ack(struct ieee80211_hw *hw, struct ieee80211_hdr *rx_hdr, | |||
634 | tx_hdr = (struct ieee80211_hdr *)skb->data; | 567 | tx_hdr = (struct ieee80211_hdr *)skb->data; |
635 | if (likely(!compare_ether_addr(tx_hdr->addr2, rx_hdr->addr1))) | 568 | if (likely(!compare_ether_addr(tx_hdr->addr2, rx_hdr->addr1))) |
636 | { | 569 | { |
637 | struct ieee80211_tx_status status; | ||
638 | |||
639 | memset(&status, 0, sizeof(status)); | ||
640 | status.flags = IEEE80211_TX_STATUS_ACK; | ||
641 | status.ack_signal = stats->signal; | ||
642 | __skb_unlink(skb, q); | 570 | __skb_unlink(skb, q); |
643 | tx_status(hw, skb, &status, 1); | 571 | tx_status(hw, skb, IEEE80211_TX_STAT_ACK, stats->signal, 1); |
644 | goto out; | 572 | goto out; |
645 | } | 573 | } |
646 | } | 574 | } |
@@ -944,8 +872,7 @@ static void zd_op_bss_info_changed(struct ieee80211_hw *hw, | |||
944 | } | 872 | } |
945 | 873 | ||
946 | static int zd_op_beacon_update(struct ieee80211_hw *hw, | 874 | static int zd_op_beacon_update(struct ieee80211_hw *hw, |
947 | struct sk_buff *skb, | 875 | struct sk_buff *skb) |
948 | struct ieee80211_tx_control *ctl) | ||
949 | { | 876 | { |
950 | struct zd_mac *mac = zd_hw_mac(hw); | 877 | struct zd_mac *mac = zd_hw_mac(hw); |
951 | zd_mac_config_beacon(hw, skb); | 878 | zd_mac_config_beacon(hw, skb); |
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.h b/drivers/net/wireless/zd1211rw/zd_mac.h index 71170244d2c9..18c1d56d3dd7 100644 --- a/drivers/net/wireless/zd1211rw/zd_mac.h +++ b/drivers/net/wireless/zd1211rw/zd_mac.h | |||
@@ -149,22 +149,6 @@ struct housekeeping { | |||
149 | struct delayed_work link_led_work; | 149 | struct delayed_work link_led_work; |
150 | }; | 150 | }; |
151 | 151 | ||
152 | /** | ||
153 | * struct zd_tx_skb_control_block - control block for tx skbuffs | ||
154 | * @control: &struct ieee80211_tx_control pointer | ||
155 | * @context: context pointer | ||
156 | * | ||
157 | * This structure is used to fill the cb field in an &sk_buff to transmit. | ||
158 | * The control field is NULL, if there is no requirement from the mac80211 | ||
159 | * stack to report about the packet ACK. This is the case if the flag | ||
160 | * IEEE80211_TXCTL_NO_ACK is not set in &struct ieee80211_tx_control. | ||
161 | */ | ||
162 | struct zd_tx_skb_control_block { | ||
163 | struct ieee80211_tx_control *control; | ||
164 | struct ieee80211_hw *hw; | ||
165 | void *context; | ||
166 | }; | ||
167 | |||
168 | #define ZD_MAC_STATS_BUFFER_SIZE 16 | 152 | #define ZD_MAC_STATS_BUFFER_SIZE 16 |
169 | 153 | ||
170 | #define ZD_MAC_MAX_ACK_WAITERS 10 | 154 | #define ZD_MAC_MAX_ACK_WAITERS 10 |
diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c index 8941f5eb96c2..1ccff240bf97 100644 --- a/drivers/net/wireless/zd1211rw/zd_usb.c +++ b/drivers/net/wireless/zd1211rw/zd_usb.c | |||
@@ -169,10 +169,11 @@ static int upload_code(struct usb_device *udev, | |||
169 | if (flags & REBOOT) { | 169 | if (flags & REBOOT) { |
170 | u8 ret; | 170 | u8 ret; |
171 | 171 | ||
172 | /* Use "DMA-aware" buffer. */ | ||
172 | r = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), | 173 | r = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), |
173 | USB_REQ_FIRMWARE_CONFIRM, | 174 | USB_REQ_FIRMWARE_CONFIRM, |
174 | USB_DIR_IN | USB_TYPE_VENDOR, | 175 | USB_DIR_IN | USB_TYPE_VENDOR, |
175 | 0, 0, &ret, sizeof(ret), 5000 /* ms */); | 176 | 0, 0, p, sizeof(ret), 5000 /* ms */); |
176 | if (r != sizeof(ret)) { | 177 | if (r != sizeof(ret)) { |
177 | dev_err(&udev->dev, | 178 | dev_err(&udev->dev, |
178 | "control request firmeware confirmation failed." | 179 | "control request firmeware confirmation failed." |
@@ -181,6 +182,7 @@ static int upload_code(struct usb_device *udev, | |||
181 | r = -ENODEV; | 182 | r = -ENODEV; |
182 | goto error; | 183 | goto error; |
183 | } | 184 | } |
185 | ret = p[0]; | ||
184 | if (ret & 0x80) { | 186 | if (ret & 0x80) { |
185 | dev_err(&udev->dev, | 187 | dev_err(&udev->dev, |
186 | "Internal error while downloading." | 188 | "Internal error while downloading." |
@@ -312,22 +314,31 @@ int zd_usb_read_fw(struct zd_usb *usb, zd_addr_t addr, u8 *data, u16 len) | |||
312 | { | 314 | { |
313 | int r; | 315 | int r; |
314 | struct usb_device *udev = zd_usb_to_usbdev(usb); | 316 | struct usb_device *udev = zd_usb_to_usbdev(usb); |
317 | u8 *buf; | ||
315 | 318 | ||
319 | /* Use "DMA-aware" buffer. */ | ||
320 | buf = kmalloc(len, GFP_KERNEL); | ||
321 | if (!buf) | ||
322 | return -ENOMEM; | ||
316 | r = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), | 323 | r = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), |
317 | USB_REQ_FIRMWARE_READ_DATA, USB_DIR_IN | 0x40, addr, 0, | 324 | USB_REQ_FIRMWARE_READ_DATA, USB_DIR_IN | 0x40, addr, 0, |
318 | data, len, 5000); | 325 | buf, len, 5000); |
319 | if (r < 0) { | 326 | if (r < 0) { |
320 | dev_err(&udev->dev, | 327 | dev_err(&udev->dev, |
321 | "read over firmware interface failed: %d\n", r); | 328 | "read over firmware interface failed: %d\n", r); |
322 | return r; | 329 | goto exit; |
323 | } else if (r != len) { | 330 | } else if (r != len) { |
324 | dev_err(&udev->dev, | 331 | dev_err(&udev->dev, |
325 | "incomplete read over firmware interface: %d/%d\n", | 332 | "incomplete read over firmware interface: %d/%d\n", |
326 | r, len); | 333 | r, len); |
327 | return -EIO; | 334 | r = -EIO; |
335 | goto exit; | ||
328 | } | 336 | } |
329 | 337 | r = 0; | |
330 | return 0; | 338 | memcpy(data, buf, len); |
339 | exit: | ||
340 | kfree(buf); | ||
341 | return r; | ||
331 | } | 342 | } |
332 | 343 | ||
333 | #define urb_dev(urb) (&(urb)->dev->dev) | 344 | #define urb_dev(urb) (&(urb)->dev->dev) |
@@ -869,7 +880,7 @@ static void tx_urb_complete(struct urb *urb) | |||
869 | { | 880 | { |
870 | int r; | 881 | int r; |
871 | struct sk_buff *skb; | 882 | struct sk_buff *skb; |
872 | struct zd_tx_skb_control_block *cb; | 883 | struct ieee80211_tx_info *info; |
873 | struct zd_usb *usb; | 884 | struct zd_usb *usb; |
874 | 885 | ||
875 | switch (urb->status) { | 886 | switch (urb->status) { |
@@ -893,8 +904,8 @@ free_urb: | |||
893 | * grab 'usb' pointer before handing off the skb (since | 904 | * grab 'usb' pointer before handing off the skb (since |
894 | * it might be freed by zd_mac_tx_to_dev or mac80211) | 905 | * it might be freed by zd_mac_tx_to_dev or mac80211) |
895 | */ | 906 | */ |
896 | cb = (struct zd_tx_skb_control_block *)skb->cb; | 907 | info = IEEE80211_SKB_CB(skb); |
897 | usb = &zd_hw_mac(cb->hw)->chip.usb; | 908 | usb = &zd_hw_mac(info->driver_data[0])->chip.usb; |
898 | zd_mac_tx_to_dev(skb, urb->status); | 909 | zd_mac_tx_to_dev(skb, urb->status); |
899 | free_tx_urb(usb, urb); | 910 | free_tx_urb(usb, urb); |
900 | tx_dec_submitted_urbs(usb); | 911 | tx_dec_submitted_urbs(usb); |