2010-05-07 08:39:57

by Luciano Coelho

[permalink] [raw]
Subject: [PATCH 0/5] wl1271: patches for wk18

Hi John,

Here's our weekly patchset for the wl1271 driver.

Cheers,
Luca.


Juuso Oikarinen (4):
wl1271: Add sysfs file to retrieve HW PG-version and ROM-version
wl1271: Fix 32 bit register read related endiannes bug
wl1271: Fix to join and channel number handling
wl1271: Reduce PSM entry hang over period from 128 => 1 ms

Teemu Paasikivi (1):
wl1271: Increase timeout for command event waiting

drivers/net/wireless/wl12xx/wl1271.h | 4 +-
drivers/net/wireless/wl12xx/wl1271_boot.c | 12 +++++
drivers/net/wireless/wl12xx/wl1271_boot.h | 3 +
drivers/net/wireless/wl12xx/wl1271_cmd.c | 2 +-
drivers/net/wireless/wl12xx/wl1271_cmd.h | 2 +-
drivers/net/wireless/wl12xx/wl1271_io.h | 4 +-
drivers/net/wireless/wl12xx/wl1271_main.c | 63 ++++++++++++++++++++++++++---
7 files changed, 79 insertions(+), 11 deletions(-)



2010-05-07 08:39:37

by Luciano Coelho

[permalink] [raw]
Subject: [PATCH 5/5] wl1271: Reduce PSM entry hang over period from 128 => 1 ms

From: Juuso Oikarinen <[email protected]>

Currently, we configure a 128ms hang over period for the PSM entry
(the firmware will remain active for 128ms after sending the null func for
PSM and getting an ack for it.) This is a huge power consumption issue, and
appears unnecessary. So, configure the value to 1 ms.

Signed-off-by: Juuso Oikarinen <[email protected]>
Reviewed-by: Janne Ylalehto <[email protected]>
Signed-off-by: Luciano Coelho <[email protected]>
---
drivers/net/wireless/wl12xx/wl1271_cmd.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/wl12xx/wl1271_cmd.c b/drivers/net/wireless/wl12xx/wl1271_cmd.c
index 62c11af..19393e2 100644
--- a/drivers/net/wireless/wl12xx/wl1271_cmd.c
+++ b/drivers/net/wireless/wl12xx/wl1271_cmd.c
@@ -516,7 +516,7 @@ int wl1271_cmd_ps_mode(struct wl1271 *wl, u8 ps_mode, bool send)
ps_params->ps_mode = ps_mode;
ps_params->send_null_data = send;
ps_params->retries = 5;
- ps_params->hang_over_period = 128;
+ ps_params->hang_over_period = 1;
ps_params->null_data_rate = cpu_to_le32(1); /* 1 Mbps */

ret = wl1271_cmd_send(wl, CMD_SET_PS_MODE, ps_params,
--
1.6.3.3


2010-05-07 08:39:19

by Luciano Coelho

[permalink] [raw]
Subject: [PATCH 4/5] wl1271: Increase timeout for command event waiting

From: Teemu Paasikivi <[email protected]>

Incresed the timeout value for command complete event waiting from 100
ms to 750 ms. In some rare cases it can take about 600 ms before
complete event for join command is received. This is most propably
caused by the firmware being busy with scanning related activities.

Signed-off-by: Teemu Paasikivi <[email protected]>
Reviewed-by: Juuso Oikarinen <[email protected]>
Signed-off-by: Luciano Coelho <[email protected]>
---
drivers/net/wireless/wl12xx/wl1271_cmd.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/wl12xx/wl1271_cmd.h b/drivers/net/wireless/wl12xx/wl1271_cmd.h
index 00f78b7..f2820b4 100644
--- a/drivers/net/wireless/wl12xx/wl1271_cmd.h
+++ b/drivers/net/wireless/wl12xx/wl1271_cmd.h
@@ -129,7 +129,7 @@ enum cmd_templ {
/* unit ms */
#define WL1271_COMMAND_TIMEOUT 2000
#define WL1271_CMD_TEMPL_MAX_SIZE 252
-#define WL1271_EVENT_TIMEOUT 100
+#define WL1271_EVENT_TIMEOUT 750

struct wl1271_cmd_header {
__le16 id;
--
1.6.3.3


2010-05-07 08:39:35

by Luciano Coelho

[permalink] [raw]
Subject: [PATCH 3/5] wl1271: Fix to join and channel number handling

From: Juuso Oikarinen <[email protected]>

This patch changes the way JOIN's are performed, and channel numbers updated.
The reason for this is that the firmware JOIN command clears WPA(2) key
material, and if done while associated to a WPA(2) secured AP, will render
the data-path unusable.

While the channel is not usually changed while associated (and currently we
could not even support something like that), after performing a scan operation
while associated, mac80211 will re-set the current channel to the driver. This
caused our problem.

Also, the mac80211 is assuming that the driver channel configuration remains
persistent over periods of IDLE. Therefore remove channel resetting to zero
from the unjoin function.

Signed-off-by: Juuso Oikarinen <[email protected]>
Reviewed-by: Teemu Paasikivi <[email protected]>
Signed-off-by: Luciano Coelho <[email protected]>
---
drivers/net/wireless/wl12xx/wl1271_main.c | 29 +++++++++++++++++++++++------
1 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/wl12xx/wl1271_main.c b/drivers/net/wireless/wl12xx/wl1271_main.c
index 5ad94fc..360daf8 100644
--- a/drivers/net/wireless/wl12xx/wl1271_main.c
+++ b/drivers/net/wireless/wl12xx/wl1271_main.c
@@ -1140,10 +1140,25 @@ out:
return ret;
}

-static int wl1271_join(struct wl1271 *wl)
+static int wl1271_join(struct wl1271 *wl, bool set_assoc)
{
int ret;

+ /*
+ * One of the side effects of the JOIN command is that is clears
+ * WPA/WPA2 keys from the chipset. Performing a JOIN while associated
+ * to a WPA/WPA2 access point will therefore kill the data-path.
+ * Currently there is no supported scenario for JOIN during
+ * association - if it becomes a supported scenario, the WPA/WPA2 keys
+ * must be handled somehow.
+ *
+ */
+ if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags))
+ wl1271_info("JOIN while associated.");
+
+ if (set_assoc)
+ set_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags);
+
ret = wl1271_cmd_join(wl, wl->set_bss_type);
if (ret < 0)
goto out;
@@ -1190,7 +1205,6 @@ static int wl1271_unjoin(struct wl1271 *wl)
goto out;

clear_bit(WL1271_FLAG_JOINED, &wl->flags);
- wl->channel = 0;
memset(wl->bssid, 0, ETH_ALEN);

/* stop filterting packets based on bssid */
@@ -1250,7 +1264,9 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed)
goto out;

/* if the channel changes while joined, join again */
- if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
+ if (changed & IEEE80211_CONF_CHANGE_CHANNEL &&
+ ((wl->band != conf->channel->band) ||
+ (wl->channel != channel))) {
wl->band = conf->channel->band;
wl->channel = channel;

@@ -1270,7 +1286,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed)
"failed %d", ret);

if (test_bit(WL1271_FLAG_JOINED, &wl->flags)) {
- ret = wl1271_join(wl);
+ ret = wl1271_join(wl, false);
if (ret < 0)
wl1271_warning("cmd join to update channel "
"failed %d", ret);
@@ -1652,6 +1668,7 @@ static void wl1271_op_bss_info_changed(struct ieee80211_hw *hw,
enum wl1271_cmd_ps_mode mode;
struct wl1271 *wl = hw->priv;
bool do_join = false;
+ bool set_assoc = false;
int ret;

wl1271_debug(DEBUG_MAC80211, "mac80211 bss info changed");
@@ -1761,7 +1778,7 @@ static void wl1271_op_bss_info_changed(struct ieee80211_hw *hw,
if (bss_conf->assoc) {
u32 rates;
wl->aid = bss_conf->aid;
- set_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags);
+ set_assoc = true;

/*
* use basic rates from AP, and determine lowest rate
@@ -1861,7 +1878,7 @@ static void wl1271_op_bss_info_changed(struct ieee80211_hw *hw,
}

if (do_join) {
- ret = wl1271_join(wl);
+ ret = wl1271_join(wl, set_assoc);
if (ret < 0) {
wl1271_warning("cmd join failed %d", ret);
goto out_sleep;
--
1.6.3.3


2010-05-07 08:39:18

by Luciano Coelho

[permalink] [raw]
Subject: [PATCH 2/5] wl1271: Fix 32 bit register read related endiannes bug

From: Juuso Oikarinen <[email protected]>

Reading single registers did not pay attention to data endianness. This patch
fix that.

Signed-off-by: Juuso Oikarinen <[email protected]>
Reviewed-by: Luciano Coelho <[email protected]>
Signed-off-by: Luciano Coelho <[email protected]>
---
drivers/net/wireless/wl12xx/wl1271.h | 2 +-
drivers/net/wireless/wl12xx/wl1271_io.h | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/wl12xx/wl1271.h b/drivers/net/wireless/wl12xx/wl1271.h
index 3e1769d..6f1b6b5 100644
--- a/drivers/net/wireless/wl12xx/wl1271.h
+++ b/drivers/net/wireless/wl12xx/wl1271.h
@@ -481,7 +481,7 @@ struct wl1271 {
struct wl1271_stats stats;
struct wl1271_debugfs debugfs;

- u32 buffer_32;
+ __le32 buffer_32;
u32 buffer_cmd;
u32 buffer_busyword[WL1271_BUSY_WORD_CNT];

diff --git a/drivers/net/wireless/wl12xx/wl1271_io.h b/drivers/net/wireless/wl12xx/wl1271_io.h
index d8837ef..bc806c7 100644
--- a/drivers/net/wireless/wl12xx/wl1271_io.h
+++ b/drivers/net/wireless/wl12xx/wl1271_io.h
@@ -74,12 +74,12 @@ static inline u32 wl1271_raw_read32(struct wl1271 *wl, int addr)
wl1271_raw_read(wl, addr, &wl->buffer_32,
sizeof(wl->buffer_32), false);

- return wl->buffer_32;
+ return le32_to_cpu(wl->buffer_32);
}

static inline void wl1271_raw_write32(struct wl1271 *wl, int addr, u32 val)
{
- wl->buffer_32 = val;
+ wl->buffer_32 = cpu_to_le32(val);
wl1271_raw_write(wl, addr, &wl->buffer_32,
sizeof(wl->buffer_32), false);
}
--
1.6.3.3


2010-05-07 08:39:41

by Luciano Coelho

[permalink] [raw]
Subject: [PATCH 1/5] wl1271: Add sysfs file to retrieve HW PG-version and ROM-version

From: Juuso Oikarinen <[email protected]>

This patch reads the HW PG version (along with a ROM-version, embedded in the
same value) from the wl1271 hardware and publishes the value in a sysfs -file.

Signed-off-by: Juuso Oikarinen <[email protected]>
Reviewed-by: Luciano Coelho <[email protected]>
Signed-off-by: Luciano Coelho <[email protected]>
---
drivers/net/wireless/wl12xx/wl1271.h | 2 +
drivers/net/wireless/wl12xx/wl1271_boot.c | 12 ++++++++++
drivers/net/wireless/wl12xx/wl1271_boot.h | 3 ++
drivers/net/wireless/wl12xx/wl1271_main.c | 34 +++++++++++++++++++++++++++++
4 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/drivers/net/wireless/wl12xx/wl1271.h b/drivers/net/wireless/wl12xx/wl1271.h
index 75887e7..3e1769d 100644
--- a/drivers/net/wireless/wl12xx/wl1271.h
+++ b/drivers/net/wireless/wl12xx/wl1271.h
@@ -388,6 +388,8 @@ struct wl1271 {
size_t fw_len;
struct wl1271_nvs_file *nvs;

+ s8 hw_pg_ver;
+
u8 bssid[ETH_ALEN];
u8 mac_addr[ETH_ALEN];
u8 bss_type;
diff --git a/drivers/net/wireless/wl12xx/wl1271_boot.c b/drivers/net/wireless/wl12xx/wl1271_boot.c
index acb1d9e..1a36d8a 100644
--- a/drivers/net/wireless/wl12xx/wl1271_boot.c
+++ b/drivers/net/wireless/wl12xx/wl1271_boot.c
@@ -441,11 +441,23 @@ static int wl1271_boot_write_irq_polarity(struct wl1271 *wl)
return 0;
}

+static void wl1271_boot_hw_version(struct wl1271 *wl)
+{
+ u32 fuse;
+
+ fuse = wl1271_top_reg_read(wl, REG_FUSE_DATA_2_1);
+ fuse = (fuse & PG_VER_MASK) >> PG_VER_OFFSET;
+
+ wl->hw_pg_ver = (s8)fuse;
+}
+
int wl1271_boot(struct wl1271 *wl)
{
int ret = 0;
u32 tmp, clk, pause;

+ wl1271_boot_hw_version(wl);
+
if (REF_CLOCK == 0 || REF_CLOCK == 2 || REF_CLOCK == 4)
/* ref clk: 19.2/38.4/38.4-XTAL */
clk = 0x3;
diff --git a/drivers/net/wireless/wl12xx/wl1271_boot.h b/drivers/net/wireless/wl12xx/wl1271_boot.h
index 95ecc52..f829699 100644
--- a/drivers/net/wireless/wl12xx/wl1271_boot.h
+++ b/drivers/net/wireless/wl12xx/wl1271_boot.h
@@ -55,6 +55,9 @@ struct wl1271_static_data {
#define OCP_REG_CLK_POLARITY 0x0cb2
#define OCP_REG_CLK_PULL 0x0cb4

+#define REG_FUSE_DATA_2_1 0x050a
+#define PG_VER_MASK 0x3c
+#define PG_VER_OFFSET 2

#define CMD_MBOX_ADDRESS 0x407B4

diff --git a/drivers/net/wireless/wl12xx/wl1271_main.c b/drivers/net/wireless/wl12xx/wl1271_main.c
index b167248..5ad94fc 100644
--- a/drivers/net/wireless/wl12xx/wl1271_main.c
+++ b/drivers/net/wireless/wl12xx/wl1271_main.c
@@ -2233,6 +2233,29 @@ static DEVICE_ATTR(bt_coex_state, S_IRUGO | S_IWUSR,
wl1271_sysfs_show_bt_coex_state,
wl1271_sysfs_store_bt_coex_state);

+static ssize_t wl1271_sysfs_show_hw_pg_ver(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct wl1271 *wl = dev_get_drvdata(dev);
+ ssize_t len;
+
+ /* FIXME: what's the maximum length of buf? page size?*/
+ len = 500;
+
+ mutex_lock(&wl->mutex);
+ if (wl->hw_pg_ver >= 0)
+ len = snprintf(buf, len, "%d\n", wl->hw_pg_ver);
+ else
+ len = snprintf(buf, len, "n/a\n");
+ mutex_unlock(&wl->mutex);
+
+ return len;
+}
+
+static DEVICE_ATTR(hw_pg_ver, S_IRUGO | S_IWUSR,
+ wl1271_sysfs_show_hw_pg_ver, NULL);
+
int wl1271_register_hw(struct wl1271 *wl)
{
int ret;
@@ -2352,6 +2375,7 @@ struct ieee80211_hw *wl1271_alloc_hw(void)
wl->vif = NULL;
wl->flags = 0;
wl->sg_enabled = true;
+ wl->hw_pg_ver = -1;

for (i = 0; i < ACX_TX_DESCRIPTORS; i++)
wl->tx_frames[i] = NULL;
@@ -2381,8 +2405,18 @@ struct ieee80211_hw *wl1271_alloc_hw(void)
goto err_platform;
}

+ /* Create sysfs file to get HW PG version */
+ ret = device_create_file(&wl->plat_dev->dev, &dev_attr_hw_pg_ver);
+ if (ret < 0) {
+ wl1271_error("failed to create sysfs file hw_pg_ver");
+ goto err_bt_coex_state;
+ }
+
return hw;

+err_bt_coex_state:
+ device_remove_file(&wl->plat_dev->dev, &dev_attr_bt_coex_state);
+
err_platform:
platform_device_unregister(wl->plat_dev);

--
1.6.3.3