Skip to contentSkip to conversation

wl1251: add sysfs interface for bluetooth coexistence mode configuration

PATCH In review David Gnedt 2 participants 4 messages Jan 30, 2011 – Jan 31, 2011 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 4/18 wl1251: add sysfs interface for bluetooth coexistence mode configuration

Port the bt_coex_mode sysfs interface from wl1251 driver version included in the Maemo Fremantle kernel to allow bt-coexistence mode configuration. This enables userspace applications to set one of the modes WL1251_BT_COEX_OFF, WL1251_BT_COEX_ENABLE and WL1251_BT_COEX_MONOAUDIO. The default mode is WL1251_BT_COEX_OFF.
It should be noted that this driver always enabled bt-coexistence before and enabled bt-coexistence directly affects the receiving performance, rendering it unusable in some low-signal situations. Especially monitor mode is affected very badly with bt-coexistence enabled.

---
 drivers/net/wireless/wl1251/acx.c    |   43 ++++++++++++-
 drivers/net/wireless/wl1251/acx.h    |    8 ++-
 drivers/net/wireless/wl1251/init.c   |    6 +--
 drivers/net/wireless/wl1251/main.c   |  108 ++++++++++++++++++++++++++++++++++
 drivers/net/wireless/wl1251/wl1251.h |    8 +++
 5 files changed, 161 insertions(+), 12 deletions(-)
drivers/net/wireless/wl1251/acx.c +38 -1
index 64a0214..960149e 100644
@@ -583,7 +583,7 @@ out:
 	return ret;
 }
 -int wl1251_acx_sg_enable(struct wl1251 *wl)
+int wl1251_acx_sg_enable(struct wl1251 *wl, u8 mode)
 {
 	struct acx_bt_wlan_coex *pta;
 	int ret;
@@ -596,7 +596,7 @@ int wl1251_acx_sg_enable(struct wl1251 *wl)
 		goto out;
 	}
 -	pta->enable = SG_ENABLE;
+	pta->enable = mode;
  	ret = wl1251_cmd_configure(wl, ACX_SG_ENABLE, pta, sizeof(*pta));
 	if (ret < 0) {
@@ -609,7 +609,7 @@ out:
 	return ret;
 }
 -int wl1251_acx_sg_cfg(struct wl1251 *wl)
+int wl1251_acx_sg_cfg(struct wl1251 *wl, u16 wake_up_beacon)
 {
 	struct acx_bt_wlan_coex_param *param;
 	int ret;
@@ -634,7 +634,7 @@ int wl1251_acx_sg_cfg(struct wl1251 *wl)
 	param->wlan_cycle_fast = PTA_CYCLE_TIME_FAST_DEF;
 	param->bt_anti_starvation_period = PTA_ANTI_STARVE_PERIOD_DEF;
 	param->next_bt_lp_packet = PTA_TIMEOUT_NEXT_BT_LP_PACKET_DEF;
-	param->wake_up_beacon = PTA_TIME_BEFORE_BEACON_DEF;
+	param->wake_up_beacon = wake_up_beacon;
 	param->hp_dm_max_guard_time = PTA_HPDM_MAX_TIME_DEF;
 	param->next_wlan_packet = PTA_TIME_OUT_NEXT_WLAN_DEF;
 	param->antenna_type = PTA_ANTENNA_TYPE_DEF;
@@ -663,6 +663,41 @@ out:
 	return ret;
 }
 +int wl1251_acx_sg_configure(struct wl1251 *wl, bool force)
+{
+	int ret;
+
+	if (wl->state == WL1251_STATE_OFF && !force)
+		return 0;
+
+	switch (wl->bt_coex_mode) {
+	case WL1251_BT_COEX_OFF:
+		ret = wl1251_acx_sg_enable(wl, SG_DISABLE);
+		if (ret)
+			break;
+		ret = wl1251_acx_sg_cfg(wl, 0);
+		break;
+	case WL1251_BT_COEX_ENABLE:
+		ret = wl1251_acx_sg_enable(wl, SG_ENABLE);
+		if (ret)
+			break;
+		ret = wl1251_acx_sg_cfg(wl, PTA_TIME_BEFORE_BEACON_DEF);
+		break;
+	case WL1251_BT_COEX_MONOAUDIO:
+		ret = wl1251_acx_sg_enable(wl, SG_ENABLE);
+		if (ret)
+			break;
+		ret = wl1251_acx_sg_cfg(wl, PTA_TIME_BEFORE_BEACON_MONO_AUDIO);
+		break;
+	default:
+		wl1251_error("Invalid BT co-ex mode!");
+		ret = -EOPNOTSUPP;
+		break;
+	}
+
+	return ret;
+}
+
 int wl1251_acx_cca_threshold(struct wl1251 *wl)
 {
 	struct acx_energy_detection *detection;
drivers/net/wireless/wl1251/acx.h +2 -1
index efcc3aa..04d4073 100644
@@ -515,7 +515,8 @@ struct acx_bt_wlan_coex {
 #define PTA_ANTI_STARVE_PERIOD_DEF	  (500)
 #define PTA_ANTI_STARVE_NUM_CYCLE_DEF	  (4)
 #define PTA_ALLOW_PA_SD_DEF		  (1)
-#define PTA_TIME_BEFORE_BEACON_DEF	  (6300)
+#define PTA_TIME_BEFORE_BEACON_DEF	  (500)
+#define PTA_TIME_BEFORE_BEACON_MONO_AUDIO (6300)
 #define PTA_HPDM_MAX_TIME_DEF		  (1600)
 #define PTA_TIME_OUT_NEXT_WLAN_DEF	  (2550)
 #define PTA_AUTO_MODE_NO_CTS_DEF	  (0)
@@ -1387,8 +1388,9 @@ int wl1251_acx_rts_threshold(struct wl1251 *wl, u16

rts_threshold);
int wl1251_acx_beacon_filter_opt(struct wl1251 *wl, bool enable_filter); int wl1251_acx_beacon_filter_table(struct wl1251 *wl);
int wl1251_acx_conn_monit_params(struct wl1251 *wl);
-int wl1251_acx_sg_enable(struct wl1251 *wl);
-int wl1251_acx_sg_cfg(struct wl1251 *wl);
+int wl1251_acx_sg_enable(struct wl1251 *wl, u8 mode);
+int wl1251_acx_sg_cfg(struct wl1251 *wl, u16 wake_up_beacon); +int wl1251_acx_sg_configure(struct wl1251 *wl, bool force);
int wl1251_acx_cca_threshold(struct wl1251 *wl);
int wl1251_acx_bcn_dtim_options(struct wl1251 *wl);
int wl1251_acx_aid(struct wl1251 *wl, u16 aid);

drivers/net/wireless/wl1251/init.c +1 -4
index 89b43d3..a6ad223 100644
@@ -162,11 +162,7 @@ int wl1251_hw_init_pta(struct wl1251 *wl)
 {
 	int ret;
 -	ret = wl1251_acx_sg_enable(wl);
-	if (ret < 0)
-		return ret;
-
-	ret = wl1251_acx_sg_cfg(wl);
+	ret = wl1251_acx_sg_configure(wl, true);
 	if (ret < 0)
 		return ret;
 diff --git a/drivers/net/wireless/wl1251/main.c

b/drivers/net/wireless/wl1251/main.c
index 2c95b90..86f3136 100644

drivers/net/wireless/wl1251/main.c +103 -0

120 lines not on this page · raw message

wl->beacon_int = WL1251_DEFAULT_BEACON_INT; wl->dtim_period = WL1251_DEFAULT_DTIM_PERIOD; wl->vif = NULL;
+ wl->bt_coex_mode = WL1251_BT_COEX_OFF;
for (i = 0; i < FW_TX_CMPLT_BLOCK_SIZE; i++)
wl->tx_frames[i] = NULL;
@@ -1417,6 +1523,8 @@ int wl1251_free_hw(struct wl1251 *wl)
wl1251_debugfs_exit(wl);
+ platform_device_unregister(&wl1251_device);
+
kfree(wl->target_mem_map); kfree(wl->data_path);
vfree(wl->fw);

(quoted diff) +0 -0

b/drivers/net/wireless/wl1251/wl1251.h
index c0ce2c8..2877023 100644

drivers/net/wireless/wl1251/wl1251.h +6 -0
@@ -251,6 +251,12 @@ struct wl1251_debugfs {
 	struct dentry *excessive_retries;
 };
 +enum wl1251_bt_coex_mode {
+	WL1251_BT_COEX_OFF,
+	WL1251_BT_COEX_ENABLE,
+	WL1251_BT_COEX_MONOAUDIO
+};
+
 struct wl1251_if_operations {
 	void (*read)(struct wl1251 *wl, int addr, void *buf, size_t len);
 	void (*write)(struct wl1251 *wl, int addr, void *buf, size_t len);
@@ -380,6 +386,8 @@ struct wl1251 {
  	struct ieee80211_vif *vif;
 +	enum wl1251_bt_coex_mode bt_coex_mode;
+
 	u32 chip_id;
 	char fw_ver[21];
 -- 1.7.0.4
 
#1 lore raw

PATCH 4/18 wl1251: add sysfs interface for bluetooth coexistence mode configuration

Port the bt_coex_mode sysfs interface from wl1251 driver version included in the Maemo Fremantle kernel to allow bt-coexistence mode configuration. This enables userspace applications to set one of the modes WL1251_BT_COEX_OFF, WL1251_BT_COEX_ENABLE and WL1251_BT_COEX_MONOAUDIO. The default mode is WL1251_BT_COEX_OFF.
It should be noted that this driver always enabled bt-coexistence before and enabled bt-coexistence directly affects the receiving performance, rendering it unusable in some low-signal situations. Especially monitor mode is affected very badly with bt-coexistence enabled.

---
Sorry for the partly broken patches, I thought I configured my client the right way. I tried to stop the mails at my mailserver, but it was mostly already too late.

---
 drivers/net/wireless/wl1251/acx.c    |   43 ++++++++++++-
 drivers/net/wireless/wl1251/acx.h    |    8 ++-
 drivers/net/wireless/wl1251/init.c   |    6 +--
 drivers/net/wireless/wl1251/main.c   |  108 ++++++++++++++++++++++++++++++++++
 drivers/net/wireless/wl1251/wl1251.h |    8 +++
 5 files changed, 161 insertions(+), 12 deletions(-)
drivers/net/wireless/wl1251/acx.c +39 -4
index 64a0214..960149e 100644
@@ -583,7 +583,7 @@ out:
 	return ret;
 }
 
-int wl1251_acx_sg_enable(struct wl1251 *wl)
+int wl1251_acx_sg_enable(struct wl1251 *wl, u8 mode)
 {
 	struct acx_bt_wlan_coex *pta;
 	int ret;
@@ -596,7 +596,7 @@ int wl1251_acx_sg_enable(struct wl1251 *wl)
 		goto out;
 	}
 
-	pta->enable = SG_ENABLE;
+	pta->enable = mode;
 
 	ret = wl1251_cmd_configure(wl, ACX_SG_ENABLE, pta, sizeof(*pta));
 	if (ret < 0) {
@@ -609,7 +609,7 @@ out:
 	return ret;
 }
 
-int wl1251_acx_sg_cfg(struct wl1251 *wl)
+int wl1251_acx_sg_cfg(struct wl1251 *wl, u16 wake_up_beacon)
 {
 	struct acx_bt_wlan_coex_param *param;
 	int ret;
@@ -634,7 +634,7 @@ int wl1251_acx_sg_cfg(struct wl1251 *wl)
 	param->wlan_cycle_fast = PTA_CYCLE_TIME_FAST_DEF;
 	param->bt_anti_starvation_period = PTA_ANTI_STARVE_PERIOD_DEF;
 	param->next_bt_lp_packet = PTA_TIMEOUT_NEXT_BT_LP_PACKET_DEF;
-	param->wake_up_beacon = PTA_TIME_BEFORE_BEACON_DEF;
+	param->wake_up_beacon = wake_up_beacon;
 	param->hp_dm_max_guard_time = PTA_HPDM_MAX_TIME_DEF;
 	param->next_wlan_packet = PTA_TIME_OUT_NEXT_WLAN_DEF;
 	param->antenna_type = PTA_ANTENNA_TYPE_DEF;
@@ -663,6 +663,41 @@ out:
 	return ret;
 }
 
+int wl1251_acx_sg_configure(struct wl1251 *wl, bool force)
+{
+	int ret;
+
+	if (wl->state == WL1251_STATE_OFF && !force)
+		return 0;
+
+	switch (wl->bt_coex_mode) {
+	case WL1251_BT_COEX_OFF:
+		ret = wl1251_acx_sg_enable(wl, SG_DISABLE);
+		if (ret)
+			break;
+		ret = wl1251_acx_sg_cfg(wl, 0);
+		break;
+	case WL1251_BT_COEX_ENABLE:
+		ret = wl1251_acx_sg_enable(wl, SG_ENABLE);
+		if (ret)
+			break;
+		ret = wl1251_acx_sg_cfg(wl, PTA_TIME_BEFORE_BEACON_DEF);
+		break;
+	case WL1251_BT_COEX_MONOAUDIO:
+		ret = wl1251_acx_sg_enable(wl, SG_ENABLE);
+		if (ret)
+			break;
+		ret = wl1251_acx_sg_cfg(wl, PTA_TIME_BEFORE_BEACON_MONO_AUDIO);
+		break;
+	default:
+		wl1251_error("Invalid BT co-ex mode!");
+		ret = -EOPNOTSUPP;
+		break;
+	}
+
+	return ret;
+}
+
 int wl1251_acx_cca_threshold(struct wl1251 *wl)
 {
 	struct acx_energy_detection *detection;
drivers/net/wireless/wl1251/acx.h +5 -3
index efcc3aa..04d4073 100644
@@ -515,7 +515,8 @@ struct acx_bt_wlan_coex {
 #define PTA_ANTI_STARVE_PERIOD_DEF	  (500)
 #define PTA_ANTI_STARVE_NUM_CYCLE_DEF	  (4)
 #define PTA_ALLOW_PA_SD_DEF		  (1)
-#define PTA_TIME_BEFORE_BEACON_DEF	  (6300)
+#define PTA_TIME_BEFORE_BEACON_DEF	  (500)
+#define PTA_TIME_BEFORE_BEACON_MONO_AUDIO (6300)
 #define PTA_HPDM_MAX_TIME_DEF		  (1600)
 #define PTA_TIME_OUT_NEXT_WLAN_DEF	  (2550)
 #define PTA_AUTO_MODE_NO_CTS_DEF	  (0)
@@ -1387,8 +1388,9 @@ int wl1251_acx_rts_threshold(struct wl1251 *wl, u16 rts_threshold);
 int wl1251_acx_beacon_filter_opt(struct wl1251 *wl, bool enable_filter);
 int wl1251_acx_beacon_filter_table(struct wl1251 *wl);
 int wl1251_acx_conn_monit_params(struct wl1251 *wl);
-int wl1251_acx_sg_enable(struct wl1251 *wl);
-int wl1251_acx_sg_cfg(struct wl1251 *wl);
+int wl1251_acx_sg_enable(struct wl1251 *wl, u8 mode);
+int wl1251_acx_sg_cfg(struct wl1251 *wl, u16 wake_up_beacon);
+int wl1251_acx_sg_configure(struct wl1251 *wl, bool force);
 int wl1251_acx_cca_threshold(struct wl1251 *wl);
 int wl1251_acx_bcn_dtim_options(struct wl1251 *wl);
 int wl1251_acx_aid(struct wl1251 *wl, u16 aid);
drivers/net/wireless/wl1251/init.c +1 -5
index 89b43d3..a6ad223 100644
@@ -162,11 +162,7 @@ int wl1251_hw_init_pta(struct wl1251 *wl)
 {
 	int ret;
 
-	ret = wl1251_acx_sg_enable(wl);
-	if (ret < 0)
-		return ret;
-
-	ret = wl1251_acx_sg_cfg(wl);
+	ret = wl1251_acx_sg_configure(wl, true);
 	if (ret < 0)
 		return ret;
 
drivers/net/wireless/wl1251/main.c +108 -0

138 lines not on this page · raw message

drivers/net/wireless/wl1251/wl1251.h +8 -0
index c0ce2c8..2877023 100644
@@ -251,6 +251,12 @@ struct wl1251_debugfs {
 	struct dentry *excessive_retries;
 };
 
+enum wl1251_bt_coex_mode {
+	WL1251_BT_COEX_OFF,
+	WL1251_BT_COEX_ENABLE,
+	WL1251_BT_COEX_MONOAUDIO
+};
+
 struct wl1251_if_operations {
 	void (*read)(struct wl1251 *wl, int addr, void *buf, size_t len);
 	void (*write)(struct wl1251 *wl, int addr, void *buf, size_t len);
@@ -380,6 +386,8 @@ struct wl1251 {
 
 	struct ieee80211_vif *vif;
 
+	enum wl1251_bt_coex_mode bt_coex_mode;
+
 	u32 chip_id;
 	char fw_ver[21];
 
Signature · 1 line
1.7.0.4
#2 lore raw
In reply to David Gnedt
Quoted 5 lines · David Gnedt

Port the bt_coex_mode sysfs interface from wl1251 driver version included in the Maemo Fremantle kernel to allow bt-coexistence mode configuration. This enables userspace applications to set one of the modes WL1251_BT_COEX_OFF, WL1251_BT_COEX_ENABLE and WL1251_BT_COEX_MONOAUDIO. The default mode is WL1251_BT_COEX_OFF.

Sorry, but this was an awful hack in the fremantle kernel and I really would not like to see this in the upstream driver. We should do better than that :) And besides, who would use it? The only user I know is maemo's wlancond and maemo is dead and buried anyway. RIP

I'm not saying that we don't need this, I just want to understand where we need this. And also sysfs is not the best choise imho, maybe debugfs is better?

Quoted 4 lines

It should be noted that this driver always enabled bt-coexistence before and enabled bt-coexistence directly affects the receiving performance, rendering it unusable in some low-signal situations. Especially monitor mode is affected very badly with bt-coexistence enabled.

Yes, btcoex is very tricky to get right. Also one problem is that wl1251's btcoex implementation significantly increases power consumption.

Signature · 1 line
Kalle Valo
#3 lore raw

Am 2011-01-31 16:28, schrieb Kalle Valo:

Quoted 8 lines

Sorry, but this was an awful hack in the fremantle kernel and I really would not like to see this in the upstream driver. We should do better than that :) And besides, who would use it? The only user I know is maemo's wlancond and maemo is dead and buried anyway. RIP

I'm not saying that we don't need this, I just want to understand where we need this. And also sysfs is not the best choise imho, maybe debugfs is better?

I understand that you don't like this patch upstream, but I also think that it is a very useful feature to switch btcoex on/off. Moreover I think 3 states aren't needed at all, but we should at least be able to disable it completely. Maybe we could also detect if bt is enabled/disabled in kernel and switch the btcoex automatically?
By the way, how is this problem solved in other drivers?

Quoted 8 lines
Quoted 4 lines

It should be noted that this driver always enabled bt-coexistence before and enabled bt-coexistence directly affects the receiving performance, rendering it unusable in some low-signal situations. Especially monitor mode is affected very badly with bt-coexistence enabled.

Yes, btcoex is very tricky to get right. Also one problem is that wl1251's btcoex implementation significantly increases power consumption.

One more point to make it switchable.