Skip to contentSkip to conversation

control Bluetooth coexistence

RFC In review Piotr Haber 2 participants 7 messages Feb 22, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover control Bluetooth coexistence

As 802.11 and Bluetooth devices can interfere with each other several coexistence techniques exist.
This is particularly important for devices that share antenna and analog front end between Wifi and Bluetooth.
There are situations when software control over the coexistence algorithm behavior would be beneficial - ex. giving EAPOL handshake or DHCP negotiation high priority.

This two patches add possibility to control Wifi-Bluetooth coexistence mode. First one extends wiphy params with coexistence mode setting. Second one implements coexistence control for brcmfmac.

[RFC] cfg80211: configuration of Bluetooth coexistence mode
brcmfmac: control BT coexistence parameters

Signature · 1 line
1.7.9.5
#1 lore raw

RFC PATCH 1/2 cfg80211: configuration of Bluetooth coexistence mode

Some devices share antenna/analog front end between Wifi and Bluetooth. The hardware coexistence interface allows them to do so, but there are situations when it would be beneficial if software had a way to have influence on it as well. It can be used to protect time sensitive traffic in presence of Bluetooth voice stream,
for an example EAPOL handshake or DHCP negotiation.

This patch adds new attribute to SET_WIPHY command and a new field in struct wiphy to allow control of the coexistence behavior. Devices that do not share resources with Bluetooth can ignore this parameter.

---
 include/net/cfg80211.h       |    4 ++++
 include/uapi/linux/nl80211.h |   20 ++++++++++++++++++++
 net/wireless/nl80211.c       |   22 +++++++++++++++++++++-
 3 files changed, 45 insertions(+), 1 deletion(-)
include/net/cfg80211.h +4 -0
index 36e076e..3db21be 100644
@@ -1526,6 +1526,7 @@ struct cfg80211_connect_params {
  * @WIPHY_PARAM_FRAG_THRESHOLD: wiphy->frag_threshold has changed
  * @WIPHY_PARAM_RTS_THRESHOLD: wiphy->rts_threshold has changed
  * @WIPHY_PARAM_COVERAGE_CLASS: coverage class changed
+ * @WIPHY_PARAM_BTCOEX: Bluetooth coexistence mode changed
  */
 enum wiphy_params_flags {
 	WIPHY_PARAM_RETRY_SHORT		= 1 << 0,
@@ -1533,6 +1534,7 @@ enum wiphy_params_flags {
 	WIPHY_PARAM_FRAG_THRESHOLD	= 1 << 2,
 	WIPHY_PARAM_RTS_THRESHOLD	= 1 << 3,
 	WIPHY_PARAM_COVERAGE_CLASS	= 1 << 4,
+	WIPHY_PARAM_BTCOEX_MODE		= 1 << 5,
 };
 
 /*
@@ -2322,6 +2324,7 @@ struct wiphy_wowlan_support {
  * @max_sched_scan_ie_len: same as max_scan_ie_len, but for scheduled
  *	scans
  * @coverage_class: current coverage class
+ * @btcoex_mode: Wifi-Bluetooth coexistence mode
  * @fw_version: firmware version for ethtool reporting
  * @hw_version: hardware version for ethtool reporting
  * @max_num_pmkids: maximum number of PMKIDs supported by device
@@ -2401,6 +2404,7 @@ struct wiphy {
 	u32 frag_threshold;
 	u32 rts_threshold;
 	u8 coverage_class;
+	enum nl80211_btcoex_mode btcoex_mode;
 
 	char fw_version[ETHTOOL_BUSINFO_LEN];
 	u32 hw_version;
include/uapi/linux/nl80211.h +20 -0
index 5b7dbc1..a96e1c9 100644
@@ -1336,6 +1336,9 @@ enum nl80211_commands {
  *	number of MAC addresses that a device can support for MAC
  *	ACL.
  *
+ * @NL80211_ATTR_WIPHY_BTCOEX_MODE: u8 attribute to control
+ *	Wifi - Bluetooth coexistence mode
+ *
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
  */
@@ -1614,6 +1617,8 @@ enum nl80211_attrs {
 
 	NL80211_ATTR_MAC_ACL_MAX,
 
+	NL80211_ATTR_WIPHY_BTCOEX_MODE,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
@@ -3323,4 +3328,19 @@ enum nl80211_acl_policy {
 	NL80211_ACL_POLICY_DENY_UNLESS_LISTED,
 };
 
+/**
+ * enum nl80211_btcoex_mode - Bluetooth coexistence mode
+ *
+ * Control Wifi - Bluetooth coexistence mode,
+ * to be used with %NL80211_ATTR_WIPHY_BTCOEX_MODE.
+ *
+ * @NL80211_BTCOEX_ENABLED: enable coexistence
+ * @NL80211_BTCOEX_DISABLED: disable coexistence, give Wifi
+ *	traffic priority over Bluetooth
+ */
+enum nl80211_btcoex_mode {
+	NL80211_BTCOEX_ENABLED,
+	NL80211_BTCOEX_DISABLED,
+};
+
 #endif /* __LINUX_NL80211_H */
net/wireless/nl80211.c +21 -1
index b5978ab..f8f99ef 100644
@@ -367,6 +367,7 @@ static const struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] = {
 	[NL80211_ATTR_P2P_OPPPS] = { .type = NLA_U8 },
 	[NL80211_ATTR_ACL_POLICY] = {. type = NLA_U32 },
 	[NL80211_ATTR_MAC_ADDRS] = { .type = NLA_NESTED },
+	[NL80211_ATTR_WIPHY_BTCOEX_MODE] = { .type = NLA_U8},
 };
 
 /* policy for the key attributes */
@@ -914,7 +915,9 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 portid, u32 seq, int flag
 	    nla_put_u16(msg, NL80211_ATTR_MAX_SCHED_SCAN_IE_LEN,
 			dev->wiphy.max_sched_scan_ie_len) ||
 	    nla_put_u8(msg, NL80211_ATTR_MAX_MATCH_SETS,
-		       dev->wiphy.max_match_sets))
+		       dev->wiphy.max_match_sets) ||
+	    nla_put_u8(msg, NL80211_ATTR_WIPHY_BTCOEX_MODE,
+		       dev->wiphy.btcoex_mode))
 		goto nla_put_failure;
 
 	if ((dev->wiphy.flags & WIPHY_FLAG_IBSS_RSN) &&
@@ -1528,6 +1531,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
 	u8 retry_short = 0, retry_long = 0;
 	u32 frag_threshold = 0, rts_threshold = 0;
 	u8 coverage_class = 0;
+	enum nl80211_btcoex_mode btcoex_mode = NL80211_BTCOEX_ENABLED;
 
 	/*
 	 * Try to find the wiphy and netdev. Normally this
@@ -1745,10 +1749,22 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
 		changed |= WIPHY_PARAM_COVERAGE_CLASS;
 	}
 
+	if (info->attrs[NL80211_ATTR_WIPHY_BTCOEX_MODE]) {
+		btcoex_mode = nla_get_u8(
+			info->attrs[NL80211_ATTR_WIPHY_BTCOEX_MODE]);
+		if (btcoex_mode != NL80211_BTCOEX_ENABLED &&
+		    btcoex_mode != NL80211_BTCOEX_DISABLED) {
+			result = -EINVAL;
+			goto bad_res;
+		}
+		changed |= WIPHY_PARAM_BTCOEX_MODE;
+	}
+
 	if (changed) {
 		u8 old_retry_short, old_retry_long;
 		u32 old_frag_threshold, old_rts_threshold;
 		u8 old_coverage_class;
+		enum nl80211_btcoex_mode old_btcoex_mode;
 
 		if (!rdev->ops->set_wiphy_params) {
 			result = -EOPNOTSUPP;
@@ -1760,6 +1776,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
 		old_frag_threshold = rdev->wiphy.frag_threshold;
 		old_rts_threshold = rdev->wiphy.rts_threshold;
 		old_coverage_class = rdev->wiphy.coverage_class;
+		old_btcoex_mode = rdev->wiphy.btcoex_mode;
 
 		if (changed & WIPHY_PARAM_RETRY_SHORT)
 			rdev->wiphy.retry_short = retry_short;
@@ -1771,6 +1788,8 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
 			rdev->wiphy.rts_threshold = rts_threshold;
 		if (changed & WIPHY_PARAM_COVERAGE_CLASS)
 			rdev->wiphy.coverage_class = coverage_class;
+		if (changed & WIPHY_PARAM_BTCOEX_MODE)
+			rdev->wiphy.btcoex_mode = btcoex_mode;
 
 		result = rdev_set_wiphy_params(rdev, changed);
 		if (result) {
@@ -1779,6 +1798,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
 			rdev->wiphy.frag_threshold = old_frag_threshold;
 			rdev->wiphy.rts_threshold = old_rts_threshold;
 			rdev->wiphy.coverage_class = old_coverage_class;
+			rdev->wiphy.btcoex_mode = old_btcoex_mode;
 		}
 	}
 
Signature · 1 line
1.7.9.5
maintainer
#2 lore raw

Re: [PATCH 1/2] [RFC] cfg80211: configuration of Bluetooth coexistence mode

Quoted 8 lines · Piotr Haber

Some devices share antenna/analog front end between Wifi and Bluetooth. The hardware coexistence interface allows them to do so, but there are situations when it would be beneficial if software had a way to have influence on it as well. It can be used to protect time sensitive traffic in presence of Bluetooth voice stream,
for an example EAPOL handshake or DHCP negotiation.

Quoted 4 lines

This patch adds new attribute to SET_WIPHY command and a new field in struct wiphy to allow control of the coexistence behavior. Devices that do not share resources with Bluetooth can ignore this parameter.

Apart from a few minor technical comments that I'll omit for now, I'm not sure what value this really has? EAPOL can already be "protected" by way of knowing when the station is marked authorized, and DHCP is pretty tricky because it could take "forever", might not be there at all, etc.

What application would actually call this? I don't really see how it could be integrated like that.

johannes

#3 lore raw

RE: [PATCH 1/2] [RFC] cfg80211: configuration of Bluetooth coexistence mode

Quoted 20 lines
Quoted 5 lines

From: Johannes Berg [[email protected]]
Sent: Friday, February 22, 2013 12:52 PM
To: Piotr Haber
Cc: [email protected]
Subject: Re: [PATCH 1/2] [RFC] cfg80211: configuration of Bluetooth coexistence mode

Quoted 8 lines · Piotr Haber

Some devices share antenna/analog front end between Wifi and Bluetooth. The hardware coexistence interface allows them to do so, but there are situations when it would be beneficial if software had a way to have influence on it as well. It can be used to protect time sensitive traffic in presence of Bluetooth voice stream,
for an example EAPOL handshake or DHCP negotiation.

Quoted 4 lines

This patch adds new attribute to SET_WIPHY command and a new field in struct wiphy to allow control of the coexistence behavior. Devices that do not share resources with Bluetooth can ignore this parameter.

Quoted 4 lines

Apart from a few minor technical comments that I'll omit for now, I'm not sure what value this really has? EAPOL can already be "protected" by way of knowing when the station is marked authorized, and DHCP is pretty tricky because it could take "forever", might not be there at all, etc.

By "protect" I meant give Wifi a priority over BT so these time sensitive things can finish quicker/on first try, limiting the possibility of dropping packets because of BT using the medium.
This is supposed to be temporary and time limited, so if say DHCP finishes in the window we give it - great, if not the coexistence goes back to default behavior and Wifi traffic is treated as usual.

Quoted 2 lines

What application would actually call this? I don't really see how it could be integrated like that.

For EAPOL wpa_supplicant might use it. For DHCP it could be used from enter/exit hooks via iw or some other utility able to send nl messages.

This feature is styled after Android one.
There a Wifi state machine tries to "protect" DHCP traffic.
It uses extra wpa_supplicant command (DRIVER) with linked driver specific library. Which means there can be only one wifi device and one needs to recompile wpa_supplicant to use another.
I wanted to make it more device independent.

Piotr

maintainer
#4 lore raw

Re: [PATCH 1/2] [RFC] cfg80211: configuration of Bluetooth coexistence mode

Quoted 8 lines · Piotr Haber
Quoted 4 lines

Apart from a few minor technical comments that I'll omit for now, I'm not sure what value this really has? EAPOL can already be "protected" by way of knowing when the station is marked authorized, and DHCP is pretty tricky because it could take "forever", might not be there at all, etc.

By "protect" I meant give Wifi a priority over BT so these time sensitive things can finish quicker/on first try, limiting the possibility of dropping packets because of BT using the medium.

I know :)

Quoted 3 lines

This is supposed to be temporary and time limited, so if say DHCP finishes in the window we give it - great, if not the coexistence goes back to default behavior and Wifi traffic is treated as usual.

That's not even documented/implemented, the way I read the patch you'd have to set it back manually.

Quoted 5 lines
Quoted 2 lines

What application would actually call this? I don't really see how it could be integrated like that.

For EAPOL wpa_supplicant might use it. For DHCP it could be used from enter/exit hooks via iw or some other utility able to send nl messages.

See that's the thing, I don't really see the point for EAPOL: you could just as well start protecting when the association is done, and end it when the station is marked authorized. That will have protected any EAPOL (or other protocols for that matter) traffic.

Similarly, you could give it a certain timeout to protect DHCP traffic. I guess the only thing that would seem necessary would be a notification of "DHCP done" that would allow you to drop the protection right away.

Quoted 1 line

This feature is styled after Android one.

I know, I'm (vaguely) familiar with that.

Quoted 1 line

There a Wifi state machine tries to "protect" DHCP traffic.

Is there any *reason* for it though? Would it ever call it after the connection is fully established?

To me this seems not very well thought out.

johannes

#5 lore raw

RE: [PATCH 1/2] [RFC] cfg80211: configuration of Bluetooth coexistence mode

Quoted 6 lines
Quoted 3 lines

This is supposed to be temporary and time limited, so if say DHCP finishes in the window we give it - great, if not the coexistence goes back to default behavior and Wifi traffic is treated as usual.

That's not even documented/implemented, the way I read the patch you'd have to set it back manually.

You are right, we implement it this way in brcmfmac but it is not documented in nl80211 change. I thought of DISABLED as a trigger (for timed boost) and ENABLED as a way to notify that whoever requested it is done. The interface could be made to reflect this "design"

Quoted 10 lines
Quoted 5 lines
Quoted 2 lines

What application would actually call this? I don't really see how it could be integrated like that.

For EAPOL wpa_supplicant might use it. For DHCP it could be used from enter/exit hooks via iw or some other utility able to send nl messages.

See that's the thing, I don't really see the point for EAPOL: you could just as well start protecting when the association is done, and end it when the station is marked authorized. That will have protected any EAPOL (or other protocols for that matter) traffic.

That is true, this could be totally automatic.

Quoted 3 lines

Similarly, you could give it a certain timeout to protect DHCP traffic. I guess the only thing that would seem necessary would be a notification of "DHCP done" that would allow you to drop the protection right away.

I guess that is the only reason we need this interface.
Still if we set the "protection" timeout to be reasonable it can do without it...

Quoted 8 lines
Quoted 1 line

This feature is styled after Android one.

I know, I'm (vaguely) familiar with that.

Quoted 1 line

There a Wifi state machine tries to "protect" DHCP traffic.

Is there any *reason* for it though? Would it ever call it after the connection is fully established?

As for reason I can't tell, someone found one to implement it in Android :) It is not used after connection is established.

Piotr

#6 lore raw

PATCH 2/2 brcmfmac: control BT coexistence parameters

In reply to Piotr Haber

Introduce feature to give Wifi traffic priority over Bluetooth.

---
 drivers/net/wireless/brcm80211/brcmfmac/Makefile   |    3 +-
 drivers/net/wireless/brcm80211/brcmfmac/btcoex.c   |  472 ++++++++++++++++++++
 drivers/net/wireless/brcm80211/brcmfmac/btcoex.h   |   24 +
 .../net/wireless/brcm80211/brcmfmac/wl_cfg80211.c  |   11 +
 .../net/wireless/brcm80211/brcmfmac/wl_cfg80211.h  |    3 +
 5 files changed, 512 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/wireless/brcm80211/brcmfmac/btcoex.c
 create mode 100644 drivers/net/wireless/brcm80211/brcmfmac/btcoex.h
drivers/net/wireless/brcm80211/brcmfmac/Makefile +2 -1
index 4d58aee..6421926 100644
@@ -30,7 +30,8 @@ brcmfmac-objs += \
 		p2p.o \
 		dhd_cdc.o \
 		dhd_common.o \
-		dhd_linux.o
+		dhd_linux.o \
+		btcoex.o
 brcmfmac-$(CONFIG_BRCMFMAC_SDIO) += \
 		dhd_sdio.o \
 		bcmsdh.o \
drivers/net/wireless/brcm80211/brcmfmac/btcoex.c new file +472 -0

472 lines not on this page · raw message

drivers/net/wireless/brcm80211/brcmfmac/btcoex.h new file +24 -0
new file mode 100644
index 0000000..5867123
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2013 Broadcom Corporation
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef WL_BTCOEX_H_
+#define WL_BTCOEX_H_
+
+int brcmf_btcoex_init(struct brcmf_cfg80211_info *cfg);
+void brcmf_btcoex_deinit(struct brcmf_cfg80211_info *cfg);
+int brcmf_btcoex_set_mode(struct brcmf_cfg80211_info *cfg,
+			  enum nl80211_btcoex_mode mode);
+
+#endif /* WL_BTCOEX_H_ */
drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c +11 -0
index a4f27f6..188d142 100644
@@ -28,6 +28,7 @@
 #include "dhd_dbg.h"
 #include "fwil_types.h"
 #include "p2p.h"
+#include "btcoex.h"
 #include "wl_cfg80211.h"
 #include "fwil.h"
 
@@ -1084,6 +1085,13 @@ static s32 brcmf_cfg80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
 		if (!err)
 			goto done;
 	}
+	if (changed & WIPHY_PARAM_BTCOEX_MODE &&
+	    (cfg->conf->btcoex_mode != wiphy->btcoex_mode)) {
+		cfg->conf->btcoex_mode = wiphy->btcoex_mode;
+		err = brcmf_btcoex_set_mode(cfg, cfg->conf->btcoex_mode);
+		if (!err)
+			goto done;
+	}
 
 done:
 	brcmf_dbg(TRACE, "Exit\n");
@@ -4657,6 +4665,7 @@ static void brcmf_init_conf(struct brcmf_cfg80211_conf *conf)
 	conf->retry_short = (u32)-1;
 	conf->retry_long = (u32)-1;
 	conf->tx_power = -1;
+	conf->btcoex_mode = NL80211_BTCOEX_ENABLED;
 }
 
 static void brcmf_register_event_handlers(struct brcmf_cfg80211_info *cfg)
@@ -4814,6 +4823,7 @@ struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr,
 		brcmf_err("P2P initilisation failed (%d)\n", err);
 		goto cfg80211_p2p_attach_out;
 	}
+	brcmf_btcoex_init(cfg);
 
 	return cfg;
 
@@ -4832,6 +4842,7 @@ void brcmf_cfg80211_detach(struct brcmf_cfg80211_info *cfg)
 	struct brcmf_cfg80211_vif *tmp;
 
 	wl_deinit_priv(cfg);
+	brcmf_btcoex_deinit(cfg);
 	list_for_each_entry_safe(vif, tmp, &cfg->vif_list, list) {
 		brcmf_free_vif(vif);
 	}
drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h +3 -0
index 8b5d498..f764925 100644
@@ -107,6 +107,7 @@ struct brcmf_cfg80211_conf {
 	u32 retry_long;
 	s32 tx_power;
 	struct ieee80211_channel channel;
+	enum nl80211_btcoex_mode btcoex_mode;
 };
 
 /* basic structure of scan request */
@@ -347,6 +348,7 @@ struct brcmf_cfg80211_vif_event {
  * @wiphy: wiphy object for cfg80211 interface.
  * @conf: dongle configuration.
  * @p2p: peer-to-peer specific information.
+ * @btcoex: Bluetooth coexistence information.
  * @scan_request: cfg80211 scan request object.
  * @usr_sync: mainly for dongle up/down synchronization.
  * @bss_list: bss_list holding scanned ap information.
@@ -380,6 +382,7 @@ struct brcmf_cfg80211_info {
 	struct wiphy *wiphy;
 	struct brcmf_cfg80211_conf *conf;
 	struct brcmf_p2p_info p2p;
+	struct brcmf_btcoex_info *btcoex;
 	struct cfg80211_scan_request *scan_request;
 	struct mutex usr_sync;
 	struct brcmf_scan_results *bss_list;
Signature · 1 line
1.7.9.5