aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn W. Linville <linville@tuxdriver.com>2013-11-05 15:51:34 -0500
committerJohn W. Linville <linville@tuxdriver.com>2013-11-05 15:51:34 -0500
commitdce1ebabcb0ac12113487221663c2aba648dd244 (patch)
treeedcf745d82290450b794acc61f4b98616d639883
parent33b443422eda3828814e8c4b17cf4202ec6ac529 (diff)
parent8d3c1fd8c3a4a4a1a319491cdd09bd7eca23ba3b (diff)
Merge branch 'for-linville' of git://git.kernel.org/pub/scm/linux/kernel/git/luca/wl12xx
-rw-r--r--drivers/net/wireless/ti/wl12xx/main.c16
-rw-r--r--drivers/net/wireless/ti/wl18xx/main.c32
-rw-r--r--drivers/net/wireless/ti/wlcore/acx.c10
-rw-r--r--drivers/net/wireless/ti/wlcore/cmd.c12
-rw-r--r--drivers/net/wireless/ti/wlcore/cmd.h3
-rw-r--r--drivers/net/wireless/ti/wlcore/conf.h5
-rw-r--r--drivers/net/wireless/ti/wlcore/debugfs.c18
-rw-r--r--drivers/net/wireless/ti/wlcore/event.c1
-rw-r--r--drivers/net/wireless/ti/wlcore/hw_ops.h9
-rw-r--r--drivers/net/wireless/ti/wlcore/init.c6
-rw-r--r--drivers/net/wireless/ti/wlcore/io.h4
-rw-r--r--drivers/net/wireless/ti/wlcore/main.c74
-rw-r--r--drivers/net/wireless/ti/wlcore/scan.c24
-rw-r--r--drivers/net/wireless/ti/wlcore/testmode.c3
-rw-r--r--drivers/net/wireless/ti/wlcore/wlcore.h9
-rw-r--r--drivers/net/wireless/ti/wlcore/wlcore_i.h2
16 files changed, 175 insertions, 53 deletions
diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
index 591526b99154..be7129ba16ad 100644
--- a/drivers/net/wireless/ti/wl12xx/main.c
+++ b/drivers/net/wireless/ti/wl12xx/main.c
@@ -333,11 +333,11 @@ static struct wlcore_conf wl12xx_conf = {
333 .always = 0, 333 .always = 0,
334 }, 334 },
335 .fwlog = { 335 .fwlog = {
336 .mode = WL12XX_FWLOG_ON_DEMAND, 336 .mode = WL12XX_FWLOG_CONTINUOUS,
337 .mem_blocks = 2, 337 .mem_blocks = 2,
338 .severity = 0, 338 .severity = 0,
339 .timestamp = WL12XX_FWLOG_TIMESTAMP_DISABLED, 339 .timestamp = WL12XX_FWLOG_TIMESTAMP_DISABLED,
340 .output = WL12XX_FWLOG_OUTPUT_HOST, 340 .output = WL12XX_FWLOG_OUTPUT_DBG_PINS,
341 .threshold = 0, 341 .threshold = 0,
342 }, 342 },
343 .rate = { 343 .rate = {
@@ -717,6 +717,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
717 goto out; 717 goto out;
718 } 718 }
719 719
720 wl->fw_mem_block_size = 256;
721 wl->fwlog_end = 0x2000000;
722
720 /* common settings */ 723 /* common settings */
721 wl->scan_templ_id_2_4 = CMD_TEMPL_APP_PROBE_REQ_2_4_LEGACY; 724 wl->scan_templ_id_2_4 = CMD_TEMPL_APP_PROBE_REQ_2_4_LEGACY;
722 wl->scan_templ_id_5 = CMD_TEMPL_APP_PROBE_REQ_5_LEGACY; 725 wl->scan_templ_id_5 = CMD_TEMPL_APP_PROBE_REQ_5_LEGACY;
@@ -1262,9 +1265,10 @@ static int wl12xx_boot(struct wl1271 *wl)
1262 BA_SESSION_RX_CONSTRAINT_EVENT_ID | 1265 BA_SESSION_RX_CONSTRAINT_EVENT_ID |
1263 REMAIN_ON_CHANNEL_COMPLETE_EVENT_ID | 1266 REMAIN_ON_CHANNEL_COMPLETE_EVENT_ID |
1264 INACTIVE_STA_EVENT_ID | 1267 INACTIVE_STA_EVENT_ID |
1265 MAX_TX_RETRY_EVENT_ID |
1266 CHANNEL_SWITCH_COMPLETE_EVENT_ID; 1268 CHANNEL_SWITCH_COMPLETE_EVENT_ID;
1267 1269
1270 wl->ap_event_mask = MAX_TX_RETRY_EVENT_ID;
1271
1268 ret = wlcore_boot_run_firmware(wl); 1272 ret = wlcore_boot_run_firmware(wl);
1269 if (ret < 0) 1273 if (ret < 0)
1270 goto out; 1274 goto out;
@@ -1648,6 +1652,11 @@ static bool wl12xx_lnk_low_prio(struct wl1271 *wl, u8 hlid,
1648 return true; 1652 return true;
1649} 1653}
1650 1654
1655static u32 wl12xx_convert_hwaddr(struct wl1271 *wl, u32 hwaddr)
1656{
1657 return hwaddr << 5;
1658}
1659
1651static int wl12xx_setup(struct wl1271 *wl); 1660static int wl12xx_setup(struct wl1271 *wl);
1652 1661
1653static struct wlcore_ops wl12xx_ops = { 1662static struct wlcore_ops wl12xx_ops = {
@@ -1684,6 +1693,7 @@ static struct wlcore_ops wl12xx_ops = {
1684 .channel_switch = wl12xx_cmd_channel_switch, 1693 .channel_switch = wl12xx_cmd_channel_switch,
1685 .pre_pkt_send = NULL, 1694 .pre_pkt_send = NULL,
1686 .set_peer_cap = wl12xx_set_peer_cap, 1695 .set_peer_cap = wl12xx_set_peer_cap,
1696 .convert_hwaddr = wl12xx_convert_hwaddr,
1687 .lnk_high_prio = wl12xx_lnk_high_prio, 1697 .lnk_high_prio = wl12xx_lnk_high_prio,
1688 .lnk_low_prio = wl12xx_lnk_low_prio, 1698 .lnk_low_prio = wl12xx_lnk_low_prio,
1689}; 1699};
diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
index d0daca1d23bc..ec37b16585df 100644
--- a/drivers/net/wireless/ti/wl18xx/main.c
+++ b/drivers/net/wireless/ti/wl18xx/main.c
@@ -456,11 +456,11 @@ static struct wlcore_conf wl18xx_conf = {
456 .always = 0, 456 .always = 0,
457 }, 457 },
458 .fwlog = { 458 .fwlog = {
459 .mode = WL12XX_FWLOG_ON_DEMAND, 459 .mode = WL12XX_FWLOG_CONTINUOUS,
460 .mem_blocks = 2, 460 .mem_blocks = 2,
461 .severity = 0, 461 .severity = 0,
462 .timestamp = WL12XX_FWLOG_TIMESTAMP_DISABLED, 462 .timestamp = WL12XX_FWLOG_TIMESTAMP_DISABLED,
463 .output = WL12XX_FWLOG_OUTPUT_HOST, 463 .output = WL12XX_FWLOG_OUTPUT_DBG_PINS,
464 .threshold = 0, 464 .threshold = 0,
465 }, 465 },
466 .rate = { 466 .rate = {
@@ -505,7 +505,7 @@ static struct wlcore_conf wl18xx_conf = {
505 505
506static struct wl18xx_priv_conf wl18xx_default_priv_conf = { 506static struct wl18xx_priv_conf wl18xx_default_priv_conf = {
507 .ht = { 507 .ht = {
508 .mode = HT_MODE_DEFAULT, 508 .mode = HT_MODE_WIDE,
509 }, 509 },
510 .phy = { 510 .phy = {
511 .phy_standalone = 0x00, 511 .phy_standalone = 0x00,
@@ -516,7 +516,7 @@ static struct wl18xx_priv_conf wl18xx_default_priv_conf = {
516 .auto_detect = 0x00, 516 .auto_detect = 0x00,
517 .dedicated_fem = FEM_NONE, 517 .dedicated_fem = FEM_NONE,
518 .low_band_component = COMPONENT_3_WAY_SWITCH, 518 .low_band_component = COMPONENT_3_WAY_SWITCH,
519 .low_band_component_type = 0x04, 519 .low_band_component_type = 0x05,
520 .high_band_component = COMPONENT_2_WAY_SWITCH, 520 .high_band_component = COMPONENT_2_WAY_SWITCH,
521 .high_band_component_type = 0x09, 521 .high_band_component_type = 0x09,
522 .tcxo_ldo_voltage = 0x00, 522 .tcxo_ldo_voltage = 0x00,
@@ -556,15 +556,15 @@ static struct wl18xx_priv_conf wl18xx_default_priv_conf = {
556 .per_chan_pwr_limit_arr_11p = { 0xff, 0xff, 0xff, 0xff, 556 .per_chan_pwr_limit_arr_11p = { 0xff, 0xff, 0xff, 0xff,
557 0xff, 0xff, 0xff }, 557 0xff, 0xff, 0xff },
558 .psat = 0, 558 .psat = 0,
559 .low_power_val = 0x08,
560 .med_power_val = 0x12,
561 .high_power_val = 0x18,
562 .low_power_val_2nd = 0x05,
563 .med_power_val_2nd = 0x0a,
564 .high_power_val_2nd = 0x14,
565 .external_pa_dc2dc = 0, 559 .external_pa_dc2dc = 0,
566 .number_of_assembled_ant2_4 = 2, 560 .number_of_assembled_ant2_4 = 2,
567 .number_of_assembled_ant5 = 1, 561 .number_of_assembled_ant5 = 1,
562 .low_power_val = 0xff,
563 .med_power_val = 0xff,
564 .high_power_val = 0xff,
565 .low_power_val_2nd = 0xff,
566 .med_power_val_2nd = 0xff,
567 .high_power_val_2nd = 0xff,
568 .tx_rf_margin = 1, 568 .tx_rf_margin = 1,
569 }, 569 },
570}; 570};
@@ -686,6 +686,9 @@ static int wl18xx_identify_chip(struct wl1271 *wl)
686 goto out; 686 goto out;
687 } 687 }
688 688
689 wl->fw_mem_block_size = 272;
690 wl->fwlog_end = 0x40000000;
691
689 wl->scan_templ_id_2_4 = CMD_TEMPL_CFG_PROBE_REQ_2_4; 692 wl->scan_templ_id_2_4 = CMD_TEMPL_CFG_PROBE_REQ_2_4;
690 wl->scan_templ_id_5 = CMD_TEMPL_CFG_PROBE_REQ_5; 693 wl->scan_templ_id_5 = CMD_TEMPL_CFG_PROBE_REQ_5;
691 wl->sched_scan_templ_id_2_4 = CMD_TEMPL_PROBE_REQ_2_4_PERIODIC; 694 wl->sched_scan_templ_id_2_4 = CMD_TEMPL_PROBE_REQ_2_4_PERIODIC;
@@ -988,10 +991,11 @@ static int wl18xx_boot(struct wl1271 *wl)
988 BA_SESSION_RX_CONSTRAINT_EVENT_ID | 991 BA_SESSION_RX_CONSTRAINT_EVENT_ID |
989 REMAIN_ON_CHANNEL_COMPLETE_EVENT_ID | 992 REMAIN_ON_CHANNEL_COMPLETE_EVENT_ID |
990 INACTIVE_STA_EVENT_ID | 993 INACTIVE_STA_EVENT_ID |
991 MAX_TX_FAILURE_EVENT_ID |
992 CHANNEL_SWITCH_COMPLETE_EVENT_ID | 994 CHANNEL_SWITCH_COMPLETE_EVENT_ID |
993 DFS_CHANNELS_CONFIG_COMPLETE_EVENT; 995 DFS_CHANNELS_CONFIG_COMPLETE_EVENT;
994 996
997 wl->ap_event_mask = MAX_TX_FAILURE_EVENT_ID;
998
995 ret = wlcore_boot_run_firmware(wl); 999 ret = wlcore_boot_run_firmware(wl);
996 if (ret < 0) 1000 if (ret < 0)
997 goto out; 1001 goto out;
@@ -1604,6 +1608,11 @@ static bool wl18xx_lnk_low_prio(struct wl1271 *wl, u8 hlid,
1604 return lnk->allocated_pkts < thold; 1608 return lnk->allocated_pkts < thold;
1605} 1609}
1606 1610
1611static u32 wl18xx_convert_hwaddr(struct wl1271 *wl, u32 hwaddr)
1612{
1613 return hwaddr & ~0x80000000;
1614}
1615
1607static int wl18xx_setup(struct wl1271 *wl); 1616static int wl18xx_setup(struct wl1271 *wl);
1608 1617
1609static struct wlcore_ops wl18xx_ops = { 1618static struct wlcore_ops wl18xx_ops = {
@@ -1641,6 +1650,7 @@ static struct wlcore_ops wl18xx_ops = {
1641 .pre_pkt_send = wl18xx_pre_pkt_send, 1650 .pre_pkt_send = wl18xx_pre_pkt_send,
1642 .sta_rc_update = wl18xx_sta_rc_update, 1651 .sta_rc_update = wl18xx_sta_rc_update,
1643 .set_peer_cap = wl18xx_set_peer_cap, 1652 .set_peer_cap = wl18xx_set_peer_cap,
1653 .convert_hwaddr = wl18xx_convert_hwaddr,
1644 .lnk_high_prio = wl18xx_lnk_high_prio, 1654 .lnk_high_prio = wl18xx_lnk_high_prio,
1645 .lnk_low_prio = wl18xx_lnk_low_prio, 1655 .lnk_low_prio = wl18xx_lnk_low_prio,
1646}; 1656};
diff --git a/drivers/net/wireless/ti/wlcore/acx.c b/drivers/net/wireless/ti/wlcore/acx.c
index 7a970cd9c555..ec83675a2446 100644
--- a/drivers/net/wireless/ti/wlcore/acx.c
+++ b/drivers/net/wireless/ti/wlcore/acx.c
@@ -162,7 +162,8 @@ int wl1271_acx_mem_map(struct wl1271 *wl, struct acx_header *mem_map,
162 162
163 wl1271_debug(DEBUG_ACX, "acx mem map"); 163 wl1271_debug(DEBUG_ACX, "acx mem map");
164 164
165 ret = wl1271_cmd_interrogate(wl, ACX_MEM_MAP, mem_map, len); 165 ret = wl1271_cmd_interrogate(wl, ACX_MEM_MAP, mem_map,
166 sizeof(struct acx_header), len);
166 if (ret < 0) 167 if (ret < 0)
167 return ret; 168 return ret;
168 169
@@ -722,6 +723,7 @@ int wl1271_acx_statistics(struct wl1271 *wl, void *stats)
722 wl1271_debug(DEBUG_ACX, "acx statistics"); 723 wl1271_debug(DEBUG_ACX, "acx statistics");
723 724
724 ret = wl1271_cmd_interrogate(wl, ACX_STATISTICS, stats, 725 ret = wl1271_cmd_interrogate(wl, ACX_STATISTICS, stats,
726 sizeof(struct acx_header),
725 wl->stats.fw_stats_len); 727 wl->stats.fw_stats_len);
726 if (ret < 0) { 728 if (ret < 0) {
727 wl1271_warning("acx statistics failed: %d", ret); 729 wl1271_warning("acx statistics failed: %d", ret);
@@ -1470,8 +1472,8 @@ int wl12xx_acx_tsf_info(struct wl1271 *wl, struct wl12xx_vif *wlvif,
1470 1472
1471 tsf_info->role_id = wlvif->role_id; 1473 tsf_info->role_id = wlvif->role_id;
1472 1474
1473 ret = wl1271_cmd_interrogate(wl, ACX_TSF_INFO, 1475 ret = wl1271_cmd_interrogate(wl, ACX_TSF_INFO, tsf_info,
1474 tsf_info, sizeof(*tsf_info)); 1476 sizeof(struct acx_header), sizeof(*tsf_info));
1475 if (ret < 0) { 1477 if (ret < 0) {
1476 wl1271_warning("acx tsf info interrogate failed"); 1478 wl1271_warning("acx tsf info interrogate failed");
1477 goto out; 1479 goto out;
@@ -1752,7 +1754,7 @@ int wlcore_acx_average_rssi(struct wl1271 *wl, struct wl12xx_vif *wlvif,
1752 1754
1753 acx->role_id = wlvif->role_id; 1755 acx->role_id = wlvif->role_id;
1754 ret = wl1271_cmd_interrogate(wl, ACX_ROAMING_STATISTICS_TBL, 1756 ret = wl1271_cmd_interrogate(wl, ACX_ROAMING_STATISTICS_TBL,
1755 acx, sizeof(*acx)); 1757 acx, sizeof(*acx), sizeof(*acx));
1756 if (ret < 0) { 1758 if (ret < 0) {
1757 wl1271_warning("acx roaming statistics failed: %d", ret); 1759 wl1271_warning("acx roaming statistics failed: %d", ret);
1758 ret = -ENOMEM; 1760 ret = -ENOMEM;
diff --git a/drivers/net/wireless/ti/wlcore/cmd.c b/drivers/net/wireless/ti/wlcore/cmd.c
index 9e5416f8764d..34d9dfff2ad3 100644
--- a/drivers/net/wireless/ti/wlcore/cmd.c
+++ b/drivers/net/wireless/ti/wlcore/cmd.c
@@ -60,7 +60,8 @@ static int __wlcore_cmd_send(struct wl1271 *wl, u16 id, void *buf,
60 u16 status; 60 u16 status;
61 u16 poll_count = 0; 61 u16 poll_count = 0;
62 62
63 if (WARN_ON(unlikely(wl->state == WLCORE_STATE_RESTARTING))) 63 if (WARN_ON(wl->state == WLCORE_STATE_RESTARTING &&
64 id != CMD_STOP_FWLOGGER))
64 return -EIO; 65 return -EIO;
65 66
66 cmd = buf; 67 cmd = buf;
@@ -845,7 +846,8 @@ EXPORT_SYMBOL_GPL(wl1271_cmd_test);
845 * @buf: buffer for the response, including all headers, must work with dma 846 * @buf: buffer for the response, including all headers, must work with dma
846 * @len: length of buf 847 * @len: length of buf
847 */ 848 */
848int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf, size_t len) 849int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf,
850 size_t cmd_len, size_t res_len)
849{ 851{
850 struct acx_header *acx = buf; 852 struct acx_header *acx = buf;
851 int ret; 853 int ret;
@@ -854,10 +856,10 @@ int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf, size_t len)
854 856
855 acx->id = cpu_to_le16(id); 857 acx->id = cpu_to_le16(id);
856 858
857 /* payload length, does not include any headers */ 859 /* response payload length, does not include any headers */
858 acx->len = cpu_to_le16(len - sizeof(*acx)); 860 acx->len = cpu_to_le16(res_len - sizeof(*acx));
859 861
860 ret = wl1271_cmd_send(wl, CMD_INTERROGATE, acx, sizeof(*acx), len); 862 ret = wl1271_cmd_send(wl, CMD_INTERROGATE, acx, cmd_len, res_len);
861 if (ret < 0) 863 if (ret < 0)
862 wl1271_error("INTERROGATE command failed"); 864 wl1271_error("INTERROGATE command failed");
863 865
diff --git a/drivers/net/wireless/ti/wlcore/cmd.h b/drivers/net/wireless/ti/wlcore/cmd.h
index fd34123047cd..323d4a856e4b 100644
--- a/drivers/net/wireless/ti/wlcore/cmd.h
+++ b/drivers/net/wireless/ti/wlcore/cmd.h
@@ -45,7 +45,8 @@ int wl12xx_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif,
45 enum ieee80211_band band, int channel); 45 enum ieee80211_band band, int channel);
46int wl12xx_stop_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif); 46int wl12xx_stop_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif);
47int wl1271_cmd_test(struct wl1271 *wl, void *buf, size_t buf_len, u8 answer); 47int wl1271_cmd_test(struct wl1271 *wl, void *buf, size_t buf_len, u8 answer);
48int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf, size_t len); 48int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf,
49 size_t cmd_len, size_t res_len);
49int wl1271_cmd_configure(struct wl1271 *wl, u16 id, void *buf, size_t len); 50int wl1271_cmd_configure(struct wl1271 *wl, u16 id, void *buf, size_t len);
50int wlcore_cmd_configure_failsafe(struct wl1271 *wl, u16 id, void *buf, 51int wlcore_cmd_configure_failsafe(struct wl1271 *wl, u16 id, void *buf,
51 size_t len, unsigned long valid_rets); 52 size_t len, unsigned long valid_rets);
diff --git a/drivers/net/wireless/ti/wlcore/conf.h b/drivers/net/wireless/ti/wlcore/conf.h
index 2b96ff821341..40995c42bef8 100644
--- a/drivers/net/wireless/ti/wlcore/conf.h
+++ b/drivers/net/wireless/ti/wlcore/conf.h
@@ -1274,6 +1274,9 @@ struct conf_rx_streaming_settings {
1274 u8 always; 1274 u8 always;
1275} __packed; 1275} __packed;
1276 1276
1277#define CONF_FWLOG_MIN_MEM_BLOCKS 2
1278#define CONF_FWLOG_MAX_MEM_BLOCKS 16
1279
1277struct conf_fwlog { 1280struct conf_fwlog {
1278 /* Continuous or on-demand */ 1281 /* Continuous or on-demand */
1279 u8 mode; 1282 u8 mode;
@@ -1281,7 +1284,7 @@ struct conf_fwlog {
1281 /* 1284 /*
1282 * Number of memory blocks dedicated for the FW logger 1285 * Number of memory blocks dedicated for the FW logger
1283 * 1286 *
1284 * Range: 1-3, or 0 to disable the FW logger 1287 * Range: 2-16, or 0 to disable the FW logger
1285 */ 1288 */
1286 u8 mem_blocks; 1289 u8 mem_blocks;
1287 1290
diff --git a/drivers/net/wireless/ti/wlcore/debugfs.c b/drivers/net/wireless/ti/wlcore/debugfs.c
index e17630c2a849..89893c717025 100644
--- a/drivers/net/wireless/ti/wlcore/debugfs.c
+++ b/drivers/net/wireless/ti/wlcore/debugfs.c
@@ -437,6 +437,7 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf,
437 int res = 0; 437 int res = 0;
438 ssize_t ret; 438 ssize_t ret;
439 char *buf; 439 char *buf;
440 struct wl12xx_vif *wlvif;
440 441
441#define DRIVER_STATE_BUF_LEN 1024 442#define DRIVER_STATE_BUF_LEN 1024
442 443
@@ -450,12 +451,28 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf,
450 (res += scnprintf(buf + res, DRIVER_STATE_BUF_LEN - res,\ 451 (res += scnprintf(buf + res, DRIVER_STATE_BUF_LEN - res,\
451 #x " = " fmt "\n", wl->x)) 452 #x " = " fmt "\n", wl->x))
452 453
454#define DRIVER_STATE_PRINT_GENERIC(x, fmt, args...) \
455 (res += scnprintf(buf + res, DRIVER_STATE_BUF_LEN - res,\
456 #x " = " fmt "\n", args))
457
453#define DRIVER_STATE_PRINT_LONG(x) DRIVER_STATE_PRINT(x, "%ld") 458#define DRIVER_STATE_PRINT_LONG(x) DRIVER_STATE_PRINT(x, "%ld")
454#define DRIVER_STATE_PRINT_INT(x) DRIVER_STATE_PRINT(x, "%d") 459#define DRIVER_STATE_PRINT_INT(x) DRIVER_STATE_PRINT(x, "%d")
455#define DRIVER_STATE_PRINT_STR(x) DRIVER_STATE_PRINT(x, "%s") 460#define DRIVER_STATE_PRINT_STR(x) DRIVER_STATE_PRINT(x, "%s")
456#define DRIVER_STATE_PRINT_LHEX(x) DRIVER_STATE_PRINT(x, "0x%lx") 461#define DRIVER_STATE_PRINT_LHEX(x) DRIVER_STATE_PRINT(x, "0x%lx")
457#define DRIVER_STATE_PRINT_HEX(x) DRIVER_STATE_PRINT(x, "0x%x") 462#define DRIVER_STATE_PRINT_HEX(x) DRIVER_STATE_PRINT(x, "0x%x")
458 463
464 wl12xx_for_each_wlvif_sta(wl, wlvif) {
465 if (!test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags))
466 continue;
467
468 DRIVER_STATE_PRINT_GENERIC(channel, "%d (%s)", wlvif->channel,
469 wlvif->p2p ? "P2P-CL" : "STA");
470 }
471
472 wl12xx_for_each_wlvif_ap(wl, wlvif)
473 DRIVER_STATE_PRINT_GENERIC(channel, "%d (%s)", wlvif->channel,
474 wlvif->p2p ? "P2P-GO" : "AP");
475
459 DRIVER_STATE_PRINT_INT(tx_blocks_available); 476 DRIVER_STATE_PRINT_INT(tx_blocks_available);
460 DRIVER_STATE_PRINT_INT(tx_allocated_blocks); 477 DRIVER_STATE_PRINT_INT(tx_allocated_blocks);
461 DRIVER_STATE_PRINT_INT(tx_allocated_pkts[0]); 478 DRIVER_STATE_PRINT_INT(tx_allocated_pkts[0]);
@@ -474,7 +491,6 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf,
474 DRIVER_STATE_PRINT_INT(tx_blocks_freed); 491 DRIVER_STATE_PRINT_INT(tx_blocks_freed);
475 DRIVER_STATE_PRINT_INT(rx_counter); 492 DRIVER_STATE_PRINT_INT(rx_counter);
476 DRIVER_STATE_PRINT_INT(state); 493 DRIVER_STATE_PRINT_INT(state);
477 DRIVER_STATE_PRINT_INT(channel);
478 DRIVER_STATE_PRINT_INT(band); 494 DRIVER_STATE_PRINT_INT(band);
479 DRIVER_STATE_PRINT_INT(power_level); 495 DRIVER_STATE_PRINT_INT(power_level);
480 DRIVER_STATE_PRINT_INT(sg_enabled); 496 DRIVER_STATE_PRINT_INT(sg_enabled);
diff --git a/drivers/net/wireless/ti/wlcore/event.c b/drivers/net/wireless/ti/wlcore/event.c
index 67f61689b49e..8d3b34965db3 100644
--- a/drivers/net/wireless/ti/wlcore/event.c
+++ b/drivers/net/wireless/ti/wlcore/event.c
@@ -266,6 +266,7 @@ int wl1271_event_unmask(struct wl1271 *wl)
266{ 266{
267 int ret; 267 int ret;
268 268
269 wl1271_debug(DEBUG_EVENT, "unmasking event_mask 0x%x", wl->event_mask);
269 ret = wl1271_acx_event_mbox_mask(wl, ~(wl->event_mask)); 270 ret = wl1271_acx_event_mbox_mask(wl, ~(wl->event_mask));
270 if (ret < 0) 271 if (ret < 0)
271 return ret; 272 return ret;
diff --git a/drivers/net/wireless/ti/wlcore/hw_ops.h b/drivers/net/wireless/ti/wlcore/hw_ops.h
index 7fd260c02a0a..51f8d634d32f 100644
--- a/drivers/net/wireless/ti/wlcore/hw_ops.h
+++ b/drivers/net/wireless/ti/wlcore/hw_ops.h
@@ -222,6 +222,15 @@ wlcore_hw_set_peer_cap(struct wl1271 *wl,
222 return 0; 222 return 0;
223} 223}
224 224
225static inline u32
226wlcore_hw_convert_hwaddr(struct wl1271 *wl, u32 hwaddr)
227{
228 if (!wl->ops->convert_hwaddr)
229 BUG_ON(1);
230
231 return wl->ops->convert_hwaddr(wl, hwaddr);
232}
233
225static inline bool 234static inline bool
226wlcore_hw_lnk_high_prio(struct wl1271 *wl, u8 hlid, 235wlcore_hw_lnk_high_prio(struct wl1271 *wl, u8 hlid,
227 struct wl1271_link *lnk) 236 struct wl1271_link *lnk)
diff --git a/drivers/net/wireless/ti/wlcore/init.c b/drivers/net/wireless/ti/wlcore/init.c
index 5c6f11e157d9..7699f9d07e26 100644
--- a/drivers/net/wireless/ti/wlcore/init.c
+++ b/drivers/net/wireless/ti/wlcore/init.c
@@ -571,6 +571,12 @@ int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif)
571 ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_CAM); 571 ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_CAM);
572 if (ret < 0) 572 if (ret < 0)
573 return ret; 573 return ret;
574
575 /* unmask ap events */
576 wl->event_mask |= wl->ap_event_mask;
577 ret = wl1271_event_unmask(wl);
578 if (ret < 0)
579 return ret;
574 /* first STA, no APs */ 580 /* first STA, no APs */
575 } else if (wl->sta_count == 0 && wl->ap_count == 0 && !is_ap) { 581 } else if (wl->sta_count == 0 && wl->ap_count == 0 && !is_ap) {
576 u8 sta_auth = wl->conf.conn.sta_sleep_auth; 582 u8 sta_auth = wl->conf.conn.sta_sleep_auth;
diff --git a/drivers/net/wireless/ti/wlcore/io.h b/drivers/net/wireless/ti/wlcore/io.h
index af7d9f9b3b4d..07e3d6a049ad 100644
--- a/drivers/net/wireless/ti/wlcore/io.h
+++ b/drivers/net/wireless/ti/wlcore/io.h
@@ -165,8 +165,8 @@ static inline int __must_check wlcore_read_hwaddr(struct wl1271 *wl, int hwaddr,
165 int physical; 165 int physical;
166 int addr; 166 int addr;
167 167
168 /* Addresses are stored internally as addresses to 32 bytes blocks */ 168 /* Convert from FW internal address which is chip arch dependent */
169 addr = hwaddr << 5; 169 addr = wl->ops->convert_hwaddr(wl, hwaddr);
170 170
171 physical = wlcore_translate_addr(wl, addr); 171 physical = wlcore_translate_addr(wl, addr);
172 172
diff --git a/drivers/net/wireless/ti/wlcore/main.c b/drivers/net/wireless/ti/wlcore/main.c
index bbdd10632373..0368b9cbfb89 100644
--- a/drivers/net/wireless/ti/wlcore/main.c
+++ b/drivers/net/wireless/ti/wlcore/main.c
@@ -44,6 +44,7 @@
44#define WL1271_BOOT_RETRIES 3 44#define WL1271_BOOT_RETRIES 3
45 45
46static char *fwlog_param; 46static char *fwlog_param;
47static int fwlog_mem_blocks = -1;
47static int bug_on_recovery = -1; 48static int bug_on_recovery = -1;
48static int no_recovery = -1; 49static int no_recovery = -1;
49 50
@@ -291,6 +292,18 @@ static void wlcore_adjust_conf(struct wl1271 *wl)
291{ 292{
292 /* Adjust settings according to optional module parameters */ 293 /* Adjust settings according to optional module parameters */
293 294
295 /* Firmware Logger params */
296 if (fwlog_mem_blocks != -1) {
297 if (fwlog_mem_blocks >= CONF_FWLOG_MIN_MEM_BLOCKS &&
298 fwlog_mem_blocks <= CONF_FWLOG_MAX_MEM_BLOCKS) {
299 wl->conf.fwlog.mem_blocks = fwlog_mem_blocks;
300 } else {
301 wl1271_error(
302 "Illegal fwlog_mem_blocks=%d using default %d",
303 fwlog_mem_blocks, wl->conf.fwlog.mem_blocks);
304 }
305 }
306
294 if (fwlog_param) { 307 if (fwlog_param) {
295 if (!strcmp(fwlog_param, "continuous")) { 308 if (!strcmp(fwlog_param, "continuous")) {
296 wl->conf.fwlog.mode = WL12XX_FWLOG_CONTINUOUS; 309 wl->conf.fwlog.mode = WL12XX_FWLOG_CONTINUOUS;
@@ -780,6 +793,7 @@ void wl12xx_queue_recovery_work(struct wl1271 *wl)
780 if (wl->state == WLCORE_STATE_ON) { 793 if (wl->state == WLCORE_STATE_ON) {
781 wl->state = WLCORE_STATE_RESTARTING; 794 wl->state = WLCORE_STATE_RESTARTING;
782 set_bit(WL1271_FLAG_RECOVERY_IN_PROGRESS, &wl->flags); 795 set_bit(WL1271_FLAG_RECOVERY_IN_PROGRESS, &wl->flags);
796 wl1271_ps_elp_wakeup(wl);
783 wlcore_disable_interrupts_nosync(wl); 797 wlcore_disable_interrupts_nosync(wl);
784 ieee80211_queue_work(wl->hw, &wl->recovery_work); 798 ieee80211_queue_work(wl->hw, &wl->recovery_work);
785 } 799 }
@@ -787,19 +801,10 @@ void wl12xx_queue_recovery_work(struct wl1271 *wl)
787 801
788size_t wl12xx_copy_fwlog(struct wl1271 *wl, u8 *memblock, size_t maxlen) 802size_t wl12xx_copy_fwlog(struct wl1271 *wl, u8 *memblock, size_t maxlen)
789{ 803{
790 size_t len = 0; 804 size_t len;
791
792 /* The FW log is a length-value list, find where the log end */
793 while (len < maxlen) {
794 if (memblock[len] == 0)
795 break;
796 if (len + memblock[len] + 1 > maxlen)
797 break;
798 len += memblock[len] + 1;
799 }
800 805
801 /* Make sure we have enough room */ 806 /* Make sure we have enough room */
802 len = min(len, (size_t)(PAGE_SIZE - wl->fwlog_size)); 807 len = min(maxlen, (size_t)(PAGE_SIZE - wl->fwlog_size));
803 808
804 /* Fill the FW log file, consumed by the sysfs fwlog entry */ 809 /* Fill the FW log file, consumed by the sysfs fwlog entry */
805 memcpy(wl->fwlog + wl->fwlog_size, memblock, len); 810 memcpy(wl->fwlog + wl->fwlog_size, memblock, len);
@@ -808,10 +813,9 @@ size_t wl12xx_copy_fwlog(struct wl1271 *wl, u8 *memblock, size_t maxlen)
808 return len; 813 return len;
809} 814}
810 815
811#define WLCORE_FW_LOG_END 0x2000000
812
813static void wl12xx_read_fwlog_panic(struct wl1271 *wl) 816static void wl12xx_read_fwlog_panic(struct wl1271 *wl)
814{ 817{
818 struct wlcore_partition_set part, old_part;
815 u32 addr; 819 u32 addr;
816 u32 offset; 820 u32 offset;
817 u32 end_of_log; 821 u32 end_of_log;
@@ -824,7 +828,7 @@ static void wl12xx_read_fwlog_panic(struct wl1271 *wl)
824 828
825 wl1271_info("Reading FW panic log"); 829 wl1271_info("Reading FW panic log");
826 830
827 block = kmalloc(WL12XX_HW_BLOCK_SIZE, GFP_KERNEL); 831 block = kmalloc(wl->fw_mem_block_size, GFP_KERNEL);
828 if (!block) 832 if (!block)
829 return; 833 return;
830 834
@@ -850,17 +854,31 @@ static void wl12xx_read_fwlog_panic(struct wl1271 *wl)
850 854
851 if (wl->conf.fwlog.mode == WL12XX_FWLOG_CONTINUOUS) { 855 if (wl->conf.fwlog.mode == WL12XX_FWLOG_CONTINUOUS) {
852 offset = sizeof(addr) + sizeof(struct wl1271_rx_descriptor); 856 offset = sizeof(addr) + sizeof(struct wl1271_rx_descriptor);
853 end_of_log = WLCORE_FW_LOG_END; 857 end_of_log = wl->fwlog_end;
854 } else { 858 } else {
855 offset = sizeof(addr); 859 offset = sizeof(addr);
856 end_of_log = addr; 860 end_of_log = addr;
857 } 861 }
858 862
863 old_part = wl->curr_part;
864 memset(&part, 0, sizeof(part));
865
859 /* Traverse the memory blocks linked list */ 866 /* Traverse the memory blocks linked list */
860 do { 867 do {
861 memset(block, 0, WL12XX_HW_BLOCK_SIZE); 868 part.mem.start = wlcore_hw_convert_hwaddr(wl, addr);
862 ret = wlcore_read_hwaddr(wl, addr, block, WL12XX_HW_BLOCK_SIZE, 869 part.mem.size = PAGE_SIZE;
863 false); 870
871 ret = wlcore_set_partition(wl, &part);
872 if (ret < 0) {
873 wl1271_error("%s: set_partition start=0x%X size=%d",
874 __func__, part.mem.start, part.mem.size);
875 goto out;
876 }
877
878 memset(block, 0, wl->fw_mem_block_size);
879 ret = wlcore_read_hwaddr(wl, addr, block,
880 wl->fw_mem_block_size, false);
881
864 if (ret < 0) 882 if (ret < 0)
865 goto out; 883 goto out;
866 884
@@ -871,8 +889,9 @@ static void wl12xx_read_fwlog_panic(struct wl1271 *wl)
871 * on demand mode and is equal to 0x2000000 in continuous mode. 889 * on demand mode and is equal to 0x2000000 in continuous mode.
872 */ 890 */
873 addr = le32_to_cpup((__le32 *)block); 891 addr = le32_to_cpup((__le32 *)block);
892
874 if (!wl12xx_copy_fwlog(wl, block + offset, 893 if (!wl12xx_copy_fwlog(wl, block + offset,
875 WL12XX_HW_BLOCK_SIZE - offset)) 894 wl->fw_mem_block_size - offset))
876 break; 895 break;
877 } while (addr && (addr != end_of_log)); 896 } while (addr && (addr != end_of_log));
878 897
@@ -880,6 +899,7 @@ static void wl12xx_read_fwlog_panic(struct wl1271 *wl)
880 899
881out: 900out:
882 kfree(block); 901 kfree(block);
902 wlcore_set_partition(wl, &old_part);
883} 903}
884 904
885static void wlcore_print_recovery(struct wl1271 *wl) 905static void wlcore_print_recovery(struct wl1271 *wl)
@@ -924,7 +944,8 @@ static void wl1271_recovery_work(struct work_struct *work)
924 goto out_unlock; 944 goto out_unlock;
925 945
926 if (!test_bit(WL1271_FLAG_INTENDED_FW_RECOVERY, &wl->flags)) { 946 if (!test_bit(WL1271_FLAG_INTENDED_FW_RECOVERY, &wl->flags)) {
927 wl12xx_read_fwlog_panic(wl); 947 if (wl->conf.fwlog.output == WL12XX_FWLOG_OUTPUT_HOST)
948 wl12xx_read_fwlog_panic(wl);
928 wlcore_print_recovery(wl); 949 wlcore_print_recovery(wl);
929 } 950 }
930 951
@@ -1928,8 +1949,10 @@ static void wlcore_op_stop_locked(struct wl1271 *wl)
1928 1949
1929 /* 1950 /*
1930 * FW channels must be re-calibrated after recovery, 1951 * FW channels must be re-calibrated after recovery,
1931 * clear the last Reg-Domain channel configuration. 1952 * save current Reg-Domain channel configuration and clear it.
1932 */ 1953 */
1954 memcpy(wl->reg_ch_conf_pending, wl->reg_ch_conf_last,
1955 sizeof(wl->reg_ch_conf_pending));
1933 memset(wl->reg_ch_conf_last, 0, sizeof(wl->reg_ch_conf_last)); 1956 memset(wl->reg_ch_conf_last, 0, sizeof(wl->reg_ch_conf_last));
1934} 1957}
1935 1958
@@ -2623,6 +2646,12 @@ deinit:
2623 !test_bit(WL1271_FLAG_INTENDED_FW_RECOVERY, &wl->flags)) 2646 !test_bit(WL1271_FLAG_INTENDED_FW_RECOVERY, &wl->flags))
2624 goto unlock; 2647 goto unlock;
2625 2648
2649 if (wl->ap_count == 0 && is_ap) {
2650 /* mask ap events */
2651 wl->event_mask &= ~wl->ap_event_mask;
2652 wl1271_event_unmask(wl);
2653 }
2654
2626 if (wl->ap_count == 0 && is_ap && wl->sta_count) { 2655 if (wl->ap_count == 0 && is_ap && wl->sta_count) {
2627 u8 sta_auth = wl->conf.conn.sta_sleep_auth; 2656 u8 sta_auth = wl->conf.conn.sta_sleep_auth;
2628 /* Configure for power according to debugfs */ 2657 /* Configure for power according to debugfs */
@@ -6152,6 +6181,9 @@ module_param_named(fwlog, fwlog_param, charp, 0);
6152MODULE_PARM_DESC(fwlog, 6181MODULE_PARM_DESC(fwlog,
6153 "FW logger options: continuous, ondemand, dbgpins or disable"); 6182 "FW logger options: continuous, ondemand, dbgpins or disable");
6154 6183
6184module_param(fwlog_mem_blocks, int, S_IRUSR | S_IWUSR);
6185MODULE_PARM_DESC(fwlog_mem_blocks, "fwlog mem_blocks");
6186
6155module_param(bug_on_recovery, int, S_IRUSR | S_IWUSR); 6187module_param(bug_on_recovery, int, S_IRUSR | S_IWUSR);
6156MODULE_PARM_DESC(bug_on_recovery, "BUG() on fw recovery"); 6188MODULE_PARM_DESC(bug_on_recovery, "BUG() on fw recovery");
6157 6189
diff --git a/drivers/net/wireless/ti/wlcore/scan.c b/drivers/net/wireless/ti/wlcore/scan.c
index 13e743df2e31..7ed86203304b 100644
--- a/drivers/net/wireless/ti/wlcore/scan.c
+++ b/drivers/net/wireless/ti/wlcore/scan.c
@@ -92,9 +92,31 @@ out:
92static void wlcore_started_vifs_iter(void *data, u8 *mac, 92static void wlcore_started_vifs_iter(void *data, u8 *mac,
93 struct ieee80211_vif *vif) 93 struct ieee80211_vif *vif)
94{ 94{
95 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
96 bool active = false;
95 int *count = (int *)data; 97 int *count = (int *)data;
96 98
97 if (!vif->bss_conf.idle) 99 /*
100 * count active interfaces according to interface type.
101 * checking only bss_conf.idle is bad for some cases, e.g.
102 * we don't want to count sta in p2p_find as active interface.
103 */
104 switch (wlvif->bss_type) {
105 case BSS_TYPE_STA_BSS:
106 if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags))
107 active = true;
108 break;
109
110 case BSS_TYPE_AP_BSS:
111 if (wlvif->wl->active_sta_count > 0)
112 active = true;
113 break;
114
115 default:
116 break;
117 }
118
119 if (active)
98 (*count)++; 120 (*count)++;
99} 121}
100 122
diff --git a/drivers/net/wireless/ti/wlcore/testmode.c b/drivers/net/wireless/ti/wlcore/testmode.c
index a3b7d950d8e9..ddad58f614da 100644
--- a/drivers/net/wireless/ti/wlcore/testmode.c
+++ b/drivers/net/wireless/ti/wlcore/testmode.c
@@ -179,7 +179,8 @@ static int wl1271_tm_cmd_interrogate(struct wl1271 *wl, struct nlattr *tb[])
179 goto out_sleep; 179 goto out_sleep;
180 } 180 }
181 181
182 ret = wl1271_cmd_interrogate(wl, ie_id, cmd, sizeof(*cmd)); 182 ret = wl1271_cmd_interrogate(wl, ie_id, cmd,
183 sizeof(struct acx_header), sizeof(*cmd));
183 if (ret < 0) { 184 if (ret < 0) {
184 wl1271_warning("testmode cmd interrogate failed: %d", ret); 185 wl1271_warning("testmode cmd interrogate failed: %d", ret);
185 goto out_free; 186 goto out_free;
diff --git a/drivers/net/wireless/ti/wlcore/wlcore.h b/drivers/net/wireless/ti/wlcore/wlcore.h
index 54ce5d5e84db..06efc12a39e5 100644
--- a/drivers/net/wireless/ti/wlcore/wlcore.h
+++ b/drivers/net/wireless/ti/wlcore/wlcore.h
@@ -110,6 +110,7 @@ struct wlcore_ops {
110 struct ieee80211_sta_ht_cap *ht_cap, 110 struct ieee80211_sta_ht_cap *ht_cap,
111 bool allow_ht_operation, 111 bool allow_ht_operation,
112 u32 rate_set, u8 hlid); 112 u32 rate_set, u8 hlid);
113 u32 (*convert_hwaddr)(struct wl1271 *wl, u32 hwaddr);
113 bool (*lnk_high_prio)(struct wl1271 *wl, u8 hlid, 114 bool (*lnk_high_prio)(struct wl1271 *wl, u8 hlid,
114 struct wl1271_link *lnk); 115 struct wl1271_link *lnk);
115 bool (*lnk_low_prio)(struct wl1271 *wl, u8 hlid, 116 bool (*lnk_low_prio)(struct wl1271 *wl, u8 hlid,
@@ -290,6 +291,12 @@ struct wl1271 {
290 /* Number of valid bytes in the FW log buffer */ 291 /* Number of valid bytes in the FW log buffer */
291 ssize_t fwlog_size; 292 ssize_t fwlog_size;
292 293
294 /* FW log end marker */
295 u32 fwlog_end;
296
297 /* FW memory block size */
298 u32 fw_mem_block_size;
299
293 /* Sysfs FW log entry readers wait queue */ 300 /* Sysfs FW log entry readers wait queue */
294 wait_queue_head_t fwlog_waitq; 301 wait_queue_head_t fwlog_waitq;
295 302
@@ -307,6 +314,8 @@ struct wl1271 {
307 314
308 /* The mbox event mask */ 315 /* The mbox event mask */
309 u32 event_mask; 316 u32 event_mask;
317 /* events to unmask only when ap interface is up */
318 u32 ap_event_mask;
310 319
311 /* Mailbox pointers */ 320 /* Mailbox pointers */
312 u32 mbox_size; 321 u32 mbox_size;
diff --git a/drivers/net/wireless/ti/wlcore/wlcore_i.h b/drivers/net/wireless/ti/wlcore/wlcore_i.h
index 2a50e089b0e7..ce7261ce8b59 100644
--- a/drivers/net/wireless/ti/wlcore/wlcore_i.h
+++ b/drivers/net/wireless/ti/wlcore/wlcore_i.h
@@ -550,6 +550,4 @@ void wl1271_rx_filter_flatten_fields(struct wl12xx_rx_filter *filter,
550#define HW_HT_RATES_OFFSET 16 550#define HW_HT_RATES_OFFSET 16
551#define HW_MIMO_RATES_OFFSET 24 551#define HW_MIMO_RATES_OFFSET 24
552 552
553#define WL12XX_HW_BLOCK_SIZE 256
554
555#endif /* __WLCORE_I_H__ */ 553#endif /* __WLCORE_I_H__ */