LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v8 1/5] Bluetooth: btusb: disable Intel link statistics telemetry events
@ 2021-08-13 16:51 Joseph Hwang
  2021-08-13 16:51 ` [PATCH v8 2/5] Bluetooth: btintel: support " Joseph Hwang
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Joseph Hwang @ 2021-08-13 16:51 UTC (permalink / raw)
  To: linux-bluetooth, marcel, luiz.dentz, pali
  Cc: chromeos-bluetooth-upstreaming, josephsih, Joseph Hwang,
	Miao-chen Chou, Chethan T N, Kiran K, Johan Hedberg,
	linux-kernel

To avoid the overhead on both the controller and the host, the
Intel link statistics telemetry events are disabled by default.

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
Signed-off-by: Chethan T N <chethan.tumkur.narayan@intel.com>
Signed-off-by: Kiran K <kiran.k@intel.com>
Signed-off-by: Joseph Hwang <josephsih@chromium.org>
---

Changes in v8:
- This version adds a new patch which refactors the set_exp_feature
  function with a feature table.
- Swap the patches per the comments on v7.
- Remove the unsuitable debug messages.
- This patch is not changed in this version.

Changes in v7:
- Rebase on Tedd's patches that moved functionality from btusb to
  btintel.

Changes in v6:
- Rebase on the latest commit.

Changes in v5:
- Rebase this patch 1/4 to resolve conflicts.
- There are changes in patches 3/4 and 4/4.

Changes in v4:
- The original 2 patches in Series-version 3 are split into
  2 patches from each patch per reviewers' comments. There are
  A total of 4 patches in this series now.
- The callback function is renamed from hdev->set_vs_dbg_evt to
  hdev->set_quality_report. Note that there are two different
  specifications which will be integrated soon and enabled/disabled
  with the same callback. One is Android Bluetooth Quality Report
  (BQR), and the other Intel link statistics telemetry events here.
  While most Bluetooth controller vendors have supported or are
  supporting the Android specification in their controllers, it looks
  making sense to use set_quality_report as the callback name.
- Similarly, the config option BT_FEATURE_VS_DBG_EVT is renamed as
  BT_FEATURE_QUALITY_REPORT which depends on BT now.
- The BQR is controller specific. There needs to be a valid hdev in the
  first place. This is fixed in set_exp_feature().
- In set_exp_feature(), bluez will only set experimental feature to set
  BQR when the feature is supported. Please refer to bluez CLs.
- Also refer to bluez patches for the decoding support of btmon.

Changes in v3:
- fix the long line in the commit message

Changes in v2:
- take care of intel_newgen as well as intel_new
- fix the long lines in mgmt.c

 drivers/bluetooth/btintel.c | 20 --------------------
 1 file changed, 20 deletions(-)

diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c
index f1705b46fc88..0fe093fa5158 100644
--- a/drivers/bluetooth/btintel.c
+++ b/drivers/bluetooth/btintel.c
@@ -1893,7 +1893,6 @@ static int btintel_bootloader_setup(struct hci_dev *hdev,
 	u32 boot_param;
 	char ddcname[64];
 	int err;
-	struct intel_debug_features features;
 
 	BT_DBG("%s", hdev->name);
 
@@ -1934,15 +1933,6 @@ static int btintel_bootloader_setup(struct hci_dev *hdev,
 		btintel_load_ddc_config(hdev, ddcname);
 	}
 
-	/* Read the Intel supported features and if new exception formats
-	 * supported, need to load the additional DDC config to enable.
-	 */
-	err = btintel_read_debug_features(hdev, &features);
-	if (!err) {
-		/* Set DDC mask for available debug features */
-		btintel_set_debug_features(hdev, &features);
-	}
-
 	/* Read the Intel version information after loading the FW  */
 	err = btintel_read_version(hdev, &new_ver);
 	if (err)
@@ -2089,7 +2079,6 @@ static int btintel_bootloader_setup_tlv(struct hci_dev *hdev,
 	u32 boot_param;
 	char ddcname[64];
 	int err;
-	struct intel_debug_features features;
 	struct intel_version_tlv new_ver;
 
 	bt_dev_dbg(hdev, "");
@@ -2125,15 +2114,6 @@ static int btintel_bootloader_setup_tlv(struct hci_dev *hdev,
 	 */
 	btintel_load_ddc_config(hdev, ddcname);
 
-	/* Read the Intel supported features and if new exception formats
-	 * supported, need to load the additional DDC config to enable.
-	 */
-	err = btintel_read_debug_features(hdev, &features);
-	if (!err) {
-		/* Set DDC mask for available debug features */
-		btintel_set_debug_features(hdev, &features);
-	}
-
 	/* Read the Intel version information after loading the FW  */
 	err = btintel_read_version_tlv(hdev, &new_ver);
 	if (err)
-- 
2.33.0.rc1.237.g0d66db33f3-goog


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v8 2/5] Bluetooth: btintel: support link statistics telemetry events
  2021-08-13 16:51 [PATCH v8 1/5] Bluetooth: btusb: disable Intel link statistics telemetry events Joseph Hwang
@ 2021-08-13 16:51 ` Joseph Hwang
  2021-08-13 16:51 ` [PATCH v8 3/5] Bluetooth: refactor set_exp_feature with a feature table Joseph Hwang
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Joseph Hwang @ 2021-08-13 16:51 UTC (permalink / raw)
  To: linux-bluetooth, marcel, luiz.dentz, pali
  Cc: chromeos-bluetooth-upstreaming, josephsih, Chethan T N,
	Miao-chen Chou, Kiran K, Joseph Hwang, Johan Hedberg,
	linux-kernel

From: Chethan T N <chethan.tumkur.narayan@intel.com>

This patch supports the link statistics telemetry events for
intel controllers

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
Signed-off-by: Chethan T N <chethan.tumkur.narayan@intel.com>
Signed-off-by: Kiran K <kiran.k@intel.com>
Signed-off-by: Joseph Hwang <josephsih@chromium.org>
---

(no changes since v7)

Changes in v7:
- Rebase on Tedd's patches that moved functionality from btusb to
  btintel.

 drivers/bluetooth/btintel.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c
index 0fe093fa5158..643e2194ca01 100644
--- a/drivers/bluetooth/btintel.c
+++ b/drivers/bluetooth/btintel.c
@@ -1285,8 +1285,10 @@ static int btintel_read_debug_features(struct hci_dev *hdev,
 static int btintel_set_debug_features(struct hci_dev *hdev,
 			       const struct intel_debug_features *features)
 {
-	u8 mask[11] = { 0x0a, 0x92, 0x02, 0x07, 0x00, 0x00, 0x00, 0x00,
+	u8 mask[11] = { 0x0a, 0x92, 0x02, 0x7f, 0x00, 0x00, 0x00, 0x00,
 			0x00, 0x00, 0x00 };
+	u8 period[5] = { 0x04, 0x91, 0x02, 0x05, 0x00 };
+	u8 trace_enable = 0x02;
 	struct sk_buff *skb;
 
 	if (!features)
@@ -1303,8 +1305,24 @@ static int btintel_set_debug_features(struct hci_dev *hdev,
 			   PTR_ERR(skb));
 		return PTR_ERR(skb);
 	}
+	kfree_skb(skb);
+
+	skb = __hci_cmd_sync(hdev, 0xfc8b, 5, period, HCI_INIT_TIMEOUT);
+	if (IS_ERR(skb)) {
+		bt_dev_err(hdev, "Setting periodicity for link statistics traces failed (%ld)",
+			   PTR_ERR(skb));
+		return PTR_ERR(skb);
+	}
+	kfree_skb(skb);
 
+	skb = __hci_cmd_sync(hdev, 0xfca1, 1, &trace_enable, HCI_INIT_TIMEOUT);
+	if (IS_ERR(skb)) {
+		bt_dev_err(hdev, "Enable tracing of link statistics events failed (%ld)",
+			   PTR_ERR(skb));
+		return PTR_ERR(skb);
+	}
 	kfree_skb(skb);
+
 	return 0;
 }
 
-- 
2.33.0.rc1.237.g0d66db33f3-goog


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v8 3/5] Bluetooth: refactor set_exp_feature with a feature table
  2021-08-13 16:51 [PATCH v8 1/5] Bluetooth: btusb: disable Intel link statistics telemetry events Joseph Hwang
  2021-08-13 16:51 ` [PATCH v8 2/5] Bluetooth: btintel: support " Joseph Hwang
@ 2021-08-13 16:51 ` Joseph Hwang
  2021-08-13 19:22   ` kernel test robot
  2021-08-13 19:34   ` kernel test robot
  2021-08-13 16:51 ` [PATCH v8 4/5] Bluetooth: Support the quality report events Joseph Hwang
  2021-08-13 16:51 ` [PATCH v8 5/5] Bluetooth: set quality report callback for Intel Joseph Hwang
  3 siblings, 2 replies; 7+ messages in thread
From: Joseph Hwang @ 2021-08-13 16:51 UTC (permalink / raw)
  To: linux-bluetooth, marcel, luiz.dentz, pali
  Cc: chromeos-bluetooth-upstreaming, josephsih, Joseph Hwang,
	David S. Miller, Jakub Kicinski, Johan Hedberg, linux-kernel,
	netdev

This patch refactors the set_exp_feature with a feature table
consisting of UUIDs and the corresponding callback functions.
In this way, a new experimental feature setting function can be
simply added with its UUID and callback function.

Signed-off-by: Joseph Hwang <josephsih@chromium.org>
---

Changes in v8:
- Refactor the set_exp_feature function with a feature table.
- This is a new patch added in v8.

 net/bluetooth/mgmt.c | 248 +++++++++++++++++++++++++------------------
 1 file changed, 142 insertions(+), 106 deletions(-)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 1e21e014efd2..ffd526b2beab 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -3806,7 +3806,7 @@ static const u8 rpa_resolution_uuid[16] = {
 static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev,
 				  void *data, u16 data_len)
 {
-	char buf[62];	/* Enough space for 3 features */
+	char buf[62];   /* Enough space for 3 features */
 	struct mgmt_rp_read_exp_features_info *rp = (void *)buf;
 	u16 idx = 0;
 	u32 flags;
@@ -3892,150 +3892,186 @@ static int exp_debug_feature_changed(bool enabled, struct sock *skip)
 }
 #endif
 
-static int set_exp_feature(struct sock *sk, struct hci_dev *hdev,
-			   void *data, u16 data_len)
+#define EXP_FEAT(_uuid, _set_func)	\
+{					\
+	.uuid = _uuid,			\
+	.set_func = _set_func,		\
+}
+
+/* The zero key uuid is special. Multiple exp features are set through it. */
+static int set_zero_key_func(struct sock *sk, struct hci_dev *hdev,
+			     struct mgmt_cp_set_exp_feature *cp, u16 data_len)
 {
-	struct mgmt_cp_set_exp_feature *cp = data;
 	struct mgmt_rp_set_exp_feature rp;
 
-	bt_dev_dbg(hdev, "sock %p", sk);
-
-	if (!memcmp(cp->uuid, ZERO_KEY, 16)) {
-		memset(rp.uuid, 0, 16);
-		rp.flags = cpu_to_le32(0);
+	memset(rp.uuid, 0, 16);
+	rp.flags = cpu_to_le32(0);
 
 #ifdef CONFIG_BT_FEATURE_DEBUG
-		if (!hdev) {
-			bool changed = bt_dbg_get();
+	if (!hdev) {
+		bool changed = bt_dbg_get();
 
-			bt_dbg_set(false);
+		bt_dbg_set(false);
 
-			if (changed)
-				exp_debug_feature_changed(false, sk);
-		}
+		if (changed)
+			exp_debug_feature_changed(false, sk);
+	}
 #endif
 
-		if (hdev && use_ll_privacy(hdev) && !hdev_is_powered(hdev)) {
-			bool changed = hci_dev_test_flag(hdev,
-							 HCI_ENABLE_LL_PRIVACY);
+	if (hdev && use_ll_privacy(hdev) && !hdev_is_powered(hdev)) {
+		bool changed = hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY);
 
-			hci_dev_clear_flag(hdev, HCI_ENABLE_LL_PRIVACY);
+		hci_dev_clear_flag(hdev, HCI_ENABLE_LL_PRIVACY);
 
-			if (changed)
-				exp_ll_privacy_feature_changed(false, hdev, sk);
-		}
+		if (changed)
+			exp_ll_privacy_feature_changed(false, hdev, sk);
+	}
 
-		hci_sock_set_flag(sk, HCI_MGMT_EXP_FEATURE_EVENTS);
+	hci_sock_set_flag(sk, HCI_MGMT_EXP_FEATURE_EVENTS);
 
-		return mgmt_cmd_complete(sk, hdev ? hdev->id : MGMT_INDEX_NONE,
-					 MGMT_OP_SET_EXP_FEATURE, 0,
-					 &rp, sizeof(rp));
-	}
+	return mgmt_cmd_complete(sk, hdev ? hdev->id : MGMT_INDEX_NONE,
+				 MGMT_OP_SET_EXP_FEATURE, 0,
+				 &rp, sizeof(rp));
+}
 
 #ifdef CONFIG_BT_FEATURE_DEBUG
-	if (!memcmp(cp->uuid, debug_uuid, 16)) {
-		bool val, changed;
-		int err;
+static int set_debug_func(struct sock *sk, struct hci_dev *hdev,
+			  struct mgmt_cp_set_exp_feature *cp, u16 data_len)
+{
+	struct mgmt_rp_set_exp_feature rp;
 
-		/* Command requires to use the non-controller index */
-		if (hdev)
-			return mgmt_cmd_status(sk, hdev->id,
-					       MGMT_OP_SET_EXP_FEATURE,
-					       MGMT_STATUS_INVALID_INDEX);
+	bool val, changed;
+	int err;
 
-		/* Parameters are limited to a single octet */
-		if (data_len != MGMT_SET_EXP_FEATURE_SIZE + 1)
-			return mgmt_cmd_status(sk, MGMT_INDEX_NONE,
-					       MGMT_OP_SET_EXP_FEATURE,
-					       MGMT_STATUS_INVALID_PARAMS);
+	/* Command requires to use the non-controller index */
+	if (hdev)
+		return mgmt_cmd_status(sk, hdev->id,
+				       MGMT_OP_SET_EXP_FEATURE,
+				       MGMT_STATUS_INVALID_INDEX);
 
-		/* Only boolean on/off is supported */
-		if (cp->param[0] != 0x00 && cp->param[0] != 0x01)
-			return mgmt_cmd_status(sk, MGMT_INDEX_NONE,
-					       MGMT_OP_SET_EXP_FEATURE,
-					       MGMT_STATUS_INVALID_PARAMS);
+	/* Parameters are limited to a single octet */
+	if (data_len != MGMT_SET_EXP_FEATURE_SIZE + 1)
+		return mgmt_cmd_status(sk, MGMT_INDEX_NONE,
+				       MGMT_OP_SET_EXP_FEATURE,
+				       MGMT_STATUS_INVALID_PARAMS);
 
-		val = !!cp->param[0];
-		changed = val ? !bt_dbg_get() : bt_dbg_get();
-		bt_dbg_set(val);
+	/* Only boolean on/off is supported */
+	if (cp->param[0] != 0x00 && cp->param[0] != 0x01)
+		return mgmt_cmd_status(sk, MGMT_INDEX_NONE,
+				       MGMT_OP_SET_EXP_FEATURE,
+				       MGMT_STATUS_INVALID_PARAMS);
 
-		memcpy(rp.uuid, debug_uuid, 16);
-		rp.flags = cpu_to_le32(val ? BIT(0) : 0);
+	val = !!cp->param[0];
+	changed = val ? !bt_dbg_get() : bt_dbg_get();
+	bt_dbg_set(val);
 
-		hci_sock_set_flag(sk, HCI_MGMT_EXP_FEATURE_EVENTS);
+	memcpy(rp.uuid, debug_uuid, 16);
+	rp.flags = cpu_to_le32(val ? BIT(0) : 0);
 
-		err = mgmt_cmd_complete(sk, MGMT_INDEX_NONE,
-					MGMT_OP_SET_EXP_FEATURE, 0,
-					&rp, sizeof(rp));
+	hci_sock_set_flag(sk, HCI_MGMT_EXP_FEATURE_EVENTS);
 
-		if (changed)
-			exp_debug_feature_changed(val, sk);
+	err = mgmt_cmd_complete(sk, MGMT_INDEX_NONE,
+				MGMT_OP_SET_EXP_FEATURE, 0,
+				&rp, sizeof(rp));
 
-		return err;
-	}
+	if (changed)
+		exp_debug_feature_changed(val, sk);
+
+	return err;
+}
 #endif
 
-	if (!memcmp(cp->uuid, rpa_resolution_uuid, 16)) {
-		bool val, changed;
-		int err;
-		u32 flags;
+static int set_rpa_resolution_func(struct sock *sk, struct hci_dev *hdev,
+				   struct mgmt_cp_set_exp_feature *cp,
+				   u16 data_len)
+{
+	struct mgmt_rp_set_exp_feature rp;
+	bool val, changed;
+	int err;
+	u32 flags;
+
+	/* Command requires to use the controller index */
+	if (!hdev)
+		return mgmt_cmd_status(sk, MGMT_INDEX_NONE,
+				       MGMT_OP_SET_EXP_FEATURE,
+				       MGMT_STATUS_INVALID_INDEX);
 
-		/* Command requires to use the controller index */
-		if (!hdev)
-			return mgmt_cmd_status(sk, MGMT_INDEX_NONE,
-					       MGMT_OP_SET_EXP_FEATURE,
-					       MGMT_STATUS_INVALID_INDEX);
+	/* Changes can only be made when controller is powered down */
+	if (hdev_is_powered(hdev))
+		return mgmt_cmd_status(sk, hdev->id,
+				       MGMT_OP_SET_EXP_FEATURE,
+				       MGMT_STATUS_REJECTED);
 
-		/* Changes can only be made when controller is powered down */
-		if (hdev_is_powered(hdev))
-			return mgmt_cmd_status(sk, hdev->id,
-					       MGMT_OP_SET_EXP_FEATURE,
-					       MGMT_STATUS_REJECTED);
+	/* Parameters are limited to a single octet */
+	if (data_len != MGMT_SET_EXP_FEATURE_SIZE + 1)
+		return mgmt_cmd_status(sk, hdev->id,
+				       MGMT_OP_SET_EXP_FEATURE,
+				       MGMT_STATUS_INVALID_PARAMS);
 
-		/* Parameters are limited to a single octet */
-		if (data_len != MGMT_SET_EXP_FEATURE_SIZE + 1)
-			return mgmt_cmd_status(sk, hdev->id,
-					       MGMT_OP_SET_EXP_FEATURE,
-					       MGMT_STATUS_INVALID_PARAMS);
+	/* Only boolean on/off is supported */
+	if (cp->param[0] != 0x00 && cp->param[0] != 0x01)
+		return mgmt_cmd_status(sk, hdev->id,
+				       MGMT_OP_SET_EXP_FEATURE,
+				       MGMT_STATUS_INVALID_PARAMS);
 
-		/* Only boolean on/off is supported */
-		if (cp->param[0] != 0x00 && cp->param[0] != 0x01)
-			return mgmt_cmd_status(sk, hdev->id,
-					       MGMT_OP_SET_EXP_FEATURE,
-					       MGMT_STATUS_INVALID_PARAMS);
+	val = !!cp->param[0];
 
-		val = !!cp->param[0];
+	if (val) {
+		changed = !hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY);
+		hci_dev_set_flag(hdev, HCI_ENABLE_LL_PRIVACY);
+		hci_dev_clear_flag(hdev, HCI_ADVERTISING);
 
-		if (val) {
-			changed = !hci_dev_test_flag(hdev,
-						     HCI_ENABLE_LL_PRIVACY);
-			hci_dev_set_flag(hdev, HCI_ENABLE_LL_PRIVACY);
-			hci_dev_clear_flag(hdev, HCI_ADVERTISING);
+		/* Enable LL privacy + supported settings changed */
+		flags = BIT(0) | BIT(1);
+	} else {
+		changed = hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY);
+		hci_dev_clear_flag(hdev, HCI_ENABLE_LL_PRIVACY);
 
-			/* Enable LL privacy + supported settings changed */
-			flags = BIT(0) | BIT(1);
-		} else {
-			changed = hci_dev_test_flag(hdev,
-						    HCI_ENABLE_LL_PRIVACY);
-			hci_dev_clear_flag(hdev, HCI_ENABLE_LL_PRIVACY);
+		/* Disable LL privacy + supported settings changed */
+		flags = BIT(1);
+	}
 
-			/* Disable LL privacy + supported settings changed */
-			flags = BIT(1);
-		}
+	memcpy(rp.uuid, rpa_resolution_uuid, 16);
+	rp.flags = cpu_to_le32(flags);
 
-		memcpy(rp.uuid, rpa_resolution_uuid, 16);
-		rp.flags = cpu_to_le32(flags);
+	hci_sock_set_flag(sk, HCI_MGMT_EXP_FEATURE_EVENTS);
 
-		hci_sock_set_flag(sk, HCI_MGMT_EXP_FEATURE_EVENTS);
+	err = mgmt_cmd_complete(sk, hdev->id,
+				MGMT_OP_SET_EXP_FEATURE, 0,
+				&rp, sizeof(rp));
 
-		err = mgmt_cmd_complete(sk, hdev->id,
-					MGMT_OP_SET_EXP_FEATURE, 0,
-					&rp, sizeof(rp));
+	if (changed)
+		exp_ll_privacy_feature_changed(val, hdev, sk);
 
-		if (changed)
-			exp_ll_privacy_feature_changed(val, hdev, sk);
+	return err;
+}
 
-		return err;
+static const struct mgmt_exp_feature {
+	const u8 *uuid;
+	int (*set_func)(struct sock *sk, struct hci_dev *hdev,
+			struct mgmt_cp_set_exp_feature *cp, u16 data_len);
+} exp_features[] = {
+	EXP_FEAT(ZERO_KEY, set_zero_key_func),
+#ifdef CONFIG_BT_FEATURE_DEBUG
+	EXP_FEAT(debug_uuid, set_debug_func),
+#endif
+	EXP_FEAT(rpa_resolution_uuid, set_rpa_resolution_func),
+
+	/* end with a null feature */
+	EXP_FEAT(NULL, NULL)
+};
+
+static int set_exp_feature(struct sock *sk, struct hci_dev *hdev,
+			   void *data, u16 data_len)
+{
+	struct mgmt_cp_set_exp_feature *cp = data;
+	size_t i = 0;
+
+	bt_dev_dbg(hdev, "sock %p", sk);
+
+	for (i = 0; exp_features[i].uuid; i++) {
+		if (!memcmp(cp->uuid, exp_features[i].uuid, 16)) {
+			return exp_features[i].set_func(sk, hdev, cp, data_len);
 	}
 
 	return mgmt_cmd_status(sk, hdev ? hdev->id : MGMT_INDEX_NONE,
-- 
2.33.0.rc1.237.g0d66db33f3-goog


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v8 4/5] Bluetooth: Support the quality report events
  2021-08-13 16:51 [PATCH v8 1/5] Bluetooth: btusb: disable Intel link statistics telemetry events Joseph Hwang
  2021-08-13 16:51 ` [PATCH v8 2/5] Bluetooth: btintel: support " Joseph Hwang
  2021-08-13 16:51 ` [PATCH v8 3/5] Bluetooth: refactor set_exp_feature with a feature table Joseph Hwang
@ 2021-08-13 16:51 ` Joseph Hwang
  2021-08-13 16:51 ` [PATCH v8 5/5] Bluetooth: set quality report callback for Intel Joseph Hwang
  3 siblings, 0 replies; 7+ messages in thread
From: Joseph Hwang @ 2021-08-13 16:51 UTC (permalink / raw)
  To: linux-bluetooth, marcel, luiz.dentz, pali
  Cc: chromeos-bluetooth-upstreaming, josephsih, Joseph Hwang,
	Miao-chen Chou, David S. Miller, Jakub Kicinski, Johan Hedberg,
	linux-kernel, netdev

This patch allows a user space process to enable/disable the quality
report events dynamically through the set experimental feature mgmt
interface if CONFIG_BT_FEATURE_QUALITY_REPORT is enabled.

Since the quality report feature needs to invoke the callback function
provided by the driver, i.e., hdev->set_quality_report, a valid
controller index is required.

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
Signed-off-by: Joseph Hwang <josephsih@chromium.org>
---

Changes in v8:
- Rebase on the previous patch about refactoring set_exp_feature with
  a feature table. A standalone set_quality_report_func is implemented
  instead of adding the logic into set_exp_feature.

Changes in v7:
- Rebase on Tedd's patches that moved functionality from btusb to
  btintel.

Changes in v5:
- Removed CONFIG_BT_FEATURE_QUALITY_REPORT since there was no
  large size impact.

 include/net/bluetooth/hci.h      |   1 +
 include/net/bluetooth/hci_core.h |   2 +
 net/bluetooth/mgmt.c             | 113 ++++++++++++++++++++++++++++++-
 3 files changed, 115 insertions(+), 1 deletion(-)

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index b80415011dcd..bb6b7398f490 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -330,6 +330,7 @@ enum {
 	HCI_ENABLE_LL_PRIVACY,
 	HCI_CMD_PENDING,
 	HCI_FORCE_NO_MITM,
+	HCI_QUALITY_REPORT,
 
 	__HCI_NUM_FLAGS,
 };
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index a7d06d7da602..7e9ae36b2582 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -606,6 +606,7 @@ struct hci_dev {
 	int (*set_bdaddr)(struct hci_dev *hdev, const bdaddr_t *bdaddr);
 	void (*cmd_timeout)(struct hci_dev *hdev);
 	bool (*prevent_wake)(struct hci_dev *hdev);
+	int (*set_quality_report)(struct hci_dev *hdev, bool enable);
 };
 
 #define HCI_PHY_HANDLE(handle)	(handle & 0xff)
@@ -759,6 +760,7 @@ extern struct mutex hci_cb_list_lock;
 		hci_dev_clear_flag(hdev, HCI_LE_ADV);		\
 		hci_dev_clear_flag(hdev, HCI_LL_RPA_RESOLUTION);\
 		hci_dev_clear_flag(hdev, HCI_PERIODIC_INQ);	\
+		hci_dev_clear_flag(hdev, HCI_QUALITY_REPORT);	\
 	} while (0)
 
 /* ----- HCI interface to upper protocols ----- */
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index ffd526b2beab..f0d586515a65 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -3791,6 +3791,12 @@ static const u8 debug_uuid[16] = {
 };
 #endif
 
+/* 330859bc-7506-492d-9370-9a6f0614037f */
+static const u8 quality_report_uuid[16] = {
+	0x7f, 0x03, 0x14, 0x06, 0x6f, 0x9a, 0x70, 0x93,
+	0x2d, 0x49, 0x06, 0x75, 0xbc, 0x59, 0x08, 0x33,
+};
+
 /* 671b10b5-42c0-4696-9227-eb28d1b049d6 */
 static const u8 simult_central_periph_uuid[16] = {
 	0xd6, 0x49, 0xb0, 0xd1, 0x28, 0xeb, 0x27, 0x92,
@@ -3806,7 +3812,7 @@ static const u8 rpa_resolution_uuid[16] = {
 static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev,
 				  void *data, u16 data_len)
 {
-	char buf[62];   /* Enough space for 3 features */
+	char buf[82];   /* Enough space for 4 features: 2 + 20 * 4 */
 	struct mgmt_rp_read_exp_features_info *rp = (void *)buf;
 	u16 idx = 0;
 	u32 flags;
@@ -3850,6 +3856,24 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev,
 		idx++;
 	}
 
+	if (hdev) {
+		if (hdev->set_quality_report) {
+			/* BIT(0): indicating if set_quality_report is
+			 * supported by controller.
+			 */
+			flags = BIT(0);
+
+			/* BIT(1): indicating if the feature is enabled. */
+			if (hci_dev_test_flag(hdev, HCI_QUALITY_REPORT))
+				flags |= BIT(1);
+		} else {
+			flags = 0;
+		}
+		memcpy(rp->features[idx].uuid, quality_report_uuid, 16);
+		rp->features[idx].flags = cpu_to_le32(flags);
+		idx++;
+	}
+
 	rp->feature_count = cpu_to_le16(idx);
 
 	/* After reading the experimental features information, enable
@@ -3892,6 +3916,21 @@ static int exp_debug_feature_changed(bool enabled, struct sock *skip)
 }
 #endif
 
+static int exp_quality_report_feature_changed(bool enabled, struct sock *skip)
+{
+	struct mgmt_ev_exp_feature_changed ev;
+
+	BT_INFO("enabled %d", enabled);
+
+	memset(&ev, 0, sizeof(ev));
+	memcpy(ev.uuid, quality_report_uuid, 16);
+	ev.flags = cpu_to_le32(enabled ? BIT(0) : 0);
+
+	return mgmt_limited_event(MGMT_EV_EXP_FEATURE_CHANGED, NULL,
+				  &ev, sizeof(ev),
+				  HCI_MGMT_EXP_FEATURE_EVENTS, skip);
+}
+
 #define EXP_FEAT(_uuid, _set_func)	\
 {					\
 	.uuid = _uuid,			\
@@ -4046,6 +4085,77 @@ static int set_rpa_resolution_func(struct sock *sk, struct hci_dev *hdev,
 	return err;
 }
 
+static int set_quality_report_func(struct sock *sk, struct hci_dev *hdev,
+				   struct mgmt_cp_set_exp_feature *cp,
+				   u16 data_len)
+{
+	struct mgmt_rp_set_exp_feature rp;
+	bool val, changed;
+	int err;
+
+	/* Command requires to use a valid controller index */
+	if (!hdev)
+		return mgmt_cmd_status(sk, MGMT_INDEX_NONE,
+				       MGMT_OP_SET_EXP_FEATURE,
+				       MGMT_STATUS_INVALID_INDEX);
+
+	/* Parameters are limited to a single octet */
+	if (data_len != MGMT_SET_EXP_FEATURE_SIZE + 1)
+		return mgmt_cmd_status(sk, hdev->id,
+				       MGMT_OP_SET_EXP_FEATURE,
+				       MGMT_STATUS_INVALID_PARAMS);
+
+	/* Only boolean on/off is supported */
+	if (cp->param[0] != 0x00 && cp->param[0] != 0x01)
+		return mgmt_cmd_status(sk, hdev->id,
+				       MGMT_OP_SET_EXP_FEATURE,
+				       MGMT_STATUS_INVALID_PARAMS);
+
+	hci_req_sync_lock(hdev);
+
+	val = !!cp->param[0];
+	changed = (val != hci_dev_test_flag(hdev, HCI_QUALITY_REPORT));
+
+	if (!hdev->set_quality_report) {
+		BT_INFO("quality report not supported");
+		err = mgmt_cmd_status(sk, hdev->id,
+				      MGMT_OP_SET_EXP_FEATURE,
+				      MGMT_STATUS_NOT_SUPPORTED);
+		goto unlock_quality_report;
+	}
+
+	if (changed) {
+		err = hdev->set_quality_report(hdev, val);
+		if (err) {
+			BT_ERR("set_quality_report value %d err %d", val, err);
+			err = mgmt_cmd_status(sk, hdev->id,
+					      MGMT_OP_SET_EXP_FEATURE,
+					      MGMT_STATUS_FAILED);
+			goto unlock_quality_report;
+		}
+		if (val)
+			hci_dev_set_flag(hdev, HCI_QUALITY_REPORT);
+		else
+			hci_dev_clear_flag(hdev, HCI_QUALITY_REPORT);
+	}
+
+	BT_INFO("quality report enable %d changed %d", val, changed);
+
+	memcpy(rp.uuid, quality_report_uuid, 16);
+	rp.flags = cpu_to_le32(val ? BIT(0) : 0);
+	hci_sock_set_flag(sk, HCI_MGMT_EXP_FEATURE_EVENTS);
+	err = mgmt_cmd_complete(sk, hdev->id,
+				MGMT_OP_SET_EXP_FEATURE, 0,
+				&rp, sizeof(rp));
+
+	if (changed)
+		exp_quality_report_feature_changed(val, sk);
+
+unlock_quality_report:
+	hci_req_sync_unlock(hdev);
+	return err;
+}
+
 static const struct mgmt_exp_feature {
 	const u8 *uuid;
 	int (*set_func)(struct sock *sk, struct hci_dev *hdev,
@@ -4056,6 +4166,7 @@ static const struct mgmt_exp_feature {
 	EXP_FEAT(debug_uuid, set_debug_func),
 #endif
 	EXP_FEAT(rpa_resolution_uuid, set_rpa_resolution_func),
+	EXP_FEAT(quality_report_uuid, set_quality_report_func),
 
 	/* end with a null feature */
 	EXP_FEAT(NULL, NULL)
-- 
2.33.0.rc1.237.g0d66db33f3-goog


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v8 5/5] Bluetooth: set quality report callback for Intel
  2021-08-13 16:51 [PATCH v8 1/5] Bluetooth: btusb: disable Intel link statistics telemetry events Joseph Hwang
                   ` (2 preceding siblings ...)
  2021-08-13 16:51 ` [PATCH v8 4/5] Bluetooth: Support the quality report events Joseph Hwang
@ 2021-08-13 16:51 ` Joseph Hwang
  3 siblings, 0 replies; 7+ messages in thread
From: Joseph Hwang @ 2021-08-13 16:51 UTC (permalink / raw)
  To: linux-bluetooth, marcel, luiz.dentz, pali
  Cc: chromeos-bluetooth-upstreaming, josephsih, Joseph Hwang,
	Miao-chen Chou, Johan Hedberg, linux-kernel

This patch sets up set_quality_report callback for Intel to
set and reset the debug features.

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
Signed-off-by: Joseph Hwang <josephsih@chromium.org>
---

Changes in v8:
- Removed the unsuitable debug messages.

Changes in v7:
- Rebase on Tedd's patches that moved functionality from btusb to
  btintel.

Changes in v5:
- Removed CONFIG_BT_FEATURE_QUALITY_REPORT since there was no
  large size impact.

 drivers/bluetooth/btintel.c | 79 ++++++++++++++++++++++++++++++++++++-
 drivers/bluetooth/btintel.h |  6 +++
 2 files changed, 84 insertions(+), 1 deletion(-)

diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c
index 643e2194ca01..778d803159f3 100644
--- a/drivers/bluetooth/btintel.c
+++ b/drivers/bluetooth/btintel.c
@@ -1291,8 +1291,10 @@ static int btintel_set_debug_features(struct hci_dev *hdev,
 	u8 trace_enable = 0x02;
 	struct sk_buff *skb;
 
-	if (!features)
+	if (!features) {
+		bt_dev_warn(hdev, "Debug features not read");
 		return -EINVAL;
+	}
 
 	if (!(features->page1[0] & 0x3f)) {
 		bt_dev_info(hdev, "Telemetry exception format not supported");
@@ -1323,9 +1325,77 @@ static int btintel_set_debug_features(struct hci_dev *hdev,
 	}
 	kfree_skb(skb);
 
+	bt_dev_info(hdev, "set debug features: trace_enable 0x%02x mask 0x%02x",
+		    trace_enable, mask[3]);
+
 	return 0;
 }
 
+static int btintel_reset_debug_features(struct hci_dev *hdev,
+				 const struct intel_debug_features *features)
+{
+	u8 mask[11] = { 0x0a, 0x92, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00 };
+	u8 trace_enable = 0x00;
+	struct sk_buff *skb;
+
+	if (!features) {
+		bt_dev_warn(hdev, "Debug features not read");
+		return -EINVAL;
+	}
+
+	if (!(features->page1[0] & 0x3f)) {
+		bt_dev_info(hdev, "Telemetry exception format not supported");
+		return 0;
+	}
+
+	/* Should stop the trace before writing ddc event mask. */
+	skb = __hci_cmd_sync(hdev, 0xfca1, 1, &trace_enable, HCI_INIT_TIMEOUT);
+	if (IS_ERR(skb)) {
+		bt_dev_err(hdev, "Stop tracing of link statistics events failed (%ld)",
+			   PTR_ERR(skb));
+		return PTR_ERR(skb);
+	}
+	kfree_skb(skb);
+
+	skb = __hci_cmd_sync(hdev, 0xfc8b, 11, mask, HCI_INIT_TIMEOUT);
+	if (IS_ERR(skb)) {
+		bt_dev_err(hdev, "Setting Intel telemetry ddc write event mask failed (%ld)",
+			   PTR_ERR(skb));
+		return PTR_ERR(skb);
+	}
+	kfree_skb(skb);
+
+	bt_dev_info(hdev, "reset debug features: trace_enable 0x%02x mask 0x%02x",
+		    trace_enable, mask[3]);
+
+	return 0;
+}
+
+int btintel_set_quality_report(struct hci_dev *hdev, bool enable)
+{
+	struct intel_debug_features features;
+	int err;
+
+	bt_dev_dbg(hdev, "enable %d", enable);
+
+	/* Read the Intel supported features and if new exception formats
+	 * supported, need to load the additional DDC config to enable.
+	 */
+	err = btintel_read_debug_features(hdev, &features);
+	if (err)
+		return err;
+
+	/* Set or reset the debug features. */
+	if (enable)
+		err = btintel_set_debug_features(hdev, &features);
+	else
+		err = btintel_reset_debug_features(hdev, &features);
+
+	return err;
+}
+EXPORT_SYMBOL_GPL(btintel_set_quality_report);
+
 static const struct firmware *btintel_legacy_rom_get_fw(struct hci_dev *hdev,
 					       struct intel_version *ver)
 {
@@ -1951,6 +2021,8 @@ static int btintel_bootloader_setup(struct hci_dev *hdev,
 		btintel_load_ddc_config(hdev, ddcname);
 	}
 
+	hci_dev_clear_flag(hdev, HCI_QUALITY_REPORT);
+
 	/* Read the Intel version information after loading the FW  */
 	err = btintel_read_version(hdev, &new_ver);
 	if (err)
@@ -2132,6 +2204,8 @@ static int btintel_bootloader_setup_tlv(struct hci_dev *hdev,
 	 */
 	btintel_load_ddc_config(hdev, ddcname);
 
+	hci_dev_clear_flag(hdev, HCI_QUALITY_REPORT);
+
 	/* Read the Intel version information after loading the FW  */
 	err = btintel_read_version_tlv(hdev, &new_ver);
 	if (err)
@@ -2230,6 +2304,9 @@ static int btintel_setup_combined(struct hci_dev *hdev)
 	set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks);
 	set_bit(HCI_QUIRK_NON_PERSISTENT_DIAG, &hdev->quirks);
 
+	/* Set up the quality report callback for Intel devices */
+	hdev->set_quality_report = btintel_set_quality_report;
+
 	/* For Legacy device, check the HW platform value and size */
 	if (skb->len == sizeof(ver) && skb->data[1] == 0x37) {
 		bt_dev_dbg(hdev, "Read the legacy Intel version information");
diff --git a/drivers/bluetooth/btintel.h b/drivers/bluetooth/btintel.h
index aa64072bbe68..fe02cb9ac96c 100644
--- a/drivers/bluetooth/btintel.h
+++ b/drivers/bluetooth/btintel.h
@@ -204,6 +204,7 @@ int btintel_configure_setup(struct hci_dev *hdev);
 void btintel_bootup(struct hci_dev *hdev, const void *ptr, unsigned int len);
 void btintel_secure_send_result(struct hci_dev *hdev,
 				const void *ptr, unsigned int len);
+int btintel_set_quality_report(struct hci_dev *hdev, bool enable);
 #else
 
 static inline int btintel_check_bdaddr(struct hci_dev *hdev)
@@ -294,4 +295,9 @@ static inline void btintel_secure_send_result(struct hci_dev *hdev,
 				const void *ptr, unsigned int len)
 {
 }
+
+static inline int btintel_set_quality_report(struct hci_dev *hdev, bool enable)
+{
+	return -ENODEV;
+}
 #endif
-- 
2.33.0.rc1.237.g0d66db33f3-goog


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v8 3/5] Bluetooth: refactor set_exp_feature with a feature table
  2021-08-13 16:51 ` [PATCH v8 3/5] Bluetooth: refactor set_exp_feature with a feature table Joseph Hwang
@ 2021-08-13 19:22   ` kernel test robot
  2021-08-13 19:34   ` kernel test robot
  1 sibling, 0 replies; 7+ messages in thread
From: kernel test robot @ 2021-08-13 19:22 UTC (permalink / raw)
  To: Joseph Hwang, linux-bluetooth, marcel, luiz.dentz, pali
  Cc: kbuild-all, chromeos-bluetooth-upstreaming, josephsih,
	Joseph Hwang, Jakub Kicinski, Johan Hedberg, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 30338 bytes --]

Hi Joseph,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on bluetooth-next/master]
[also build test ERROR on next-20210813]
[cannot apply to bluetooth/master v5.14-rc5]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Joseph-Hwang/Bluetooth-btusb-disable-Intel-link-statistics-telemetry-events/20210814-005423
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git master
config: m68k-allmodconfig (attached as .config)
compiler: m68k-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/7a3d3d918d33f8f8796cb27e1f137c56c2afaeac
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Joseph-Hwang/Bluetooth-btusb-disable-Intel-link-statistics-telemetry-events/20210814-005423
        git checkout 7a3d3d918d33f8f8796cb27e1f137c56c2afaeac
        # save the attached .config to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=m68k SHELL=/bin/bash net/bluetooth/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   net/bluetooth/mgmt.c: In function 'set_exp_feature':
>> net/bluetooth/mgmt.c:4084:12: error: invalid storage class for function 'get_device_flags'
    4084 | static int get_device_flags(struct sock *sk, struct hci_dev *hdev, void *data,
         |            ^~~~~~~~~~~~~~~~
>> net/bluetooth/mgmt.c:4084:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
    4084 | static int get_device_flags(struct sock *sk, struct hci_dev *hdev, void *data,
         | ^~~~~~
>> net/bluetooth/mgmt.c:4134:13: error: invalid storage class for function 'device_flags_changed'
    4134 | static void device_flags_changed(struct sock *sk, struct hci_dev *hdev,
         |             ^~~~~~~~~~~~~~~~~~~~
>> net/bluetooth/mgmt.c:4148:12: error: invalid storage class for function 'set_device_flags'
    4148 | static int set_device_flags(struct sock *sk, struct hci_dev *hdev, void *data,
         |            ^~~~~~~~~~~~~~~~
>> net/bluetooth/mgmt.c:4206:13: error: invalid storage class for function 'mgmt_adv_monitor_added'
    4206 | static void mgmt_adv_monitor_added(struct sock *sk, struct hci_dev *hdev,
         |             ^~~~~~~~~~~~~~~~~~~~~~
>> net/bluetooth/mgmt.c:4236:12: error: invalid storage class for function 'read_adv_mon_features'
    4236 | static int read_adv_mon_features(struct sock *sk, struct hci_dev *hdev,
         |            ^~~~~~~~~~~~~~~~~~~~~
>> net/bluetooth/mgmt.c:4324:12: error: invalid storage class for function '__add_adv_patterns_monitor'
    4324 | static int __add_adv_patterns_monitor(struct sock *sk, struct hci_dev *hdev,
         |            ^~~~~~~~~~~~~~~~~~~~~~~~~~
>> net/bluetooth/mgmt.c:4388:13: error: invalid storage class for function 'parse_adv_monitor_rssi'
    4388 | static void parse_adv_monitor_rssi(struct adv_monitor *m,
         |             ^~~~~~~~~~~~~~~~~~~~~~
>> net/bluetooth/mgmt.c:4413:11: error: invalid storage class for function 'parse_adv_monitor_pattern'
    4413 | static u8 parse_adv_monitor_pattern(struct adv_monitor *m, u8 pattern_count,
         |           ^~~~~~~~~~~~~~~~~~~~~~~~~
>> net/bluetooth/mgmt.c:4444:12: error: invalid storage class for function 'add_adv_patterns_monitor'
    4444 | static int add_adv_patterns_monitor(struct sock *sk, struct hci_dev *hdev,
         |            ^~~~~~~~~~~~~~~~~~~~~~~~
>> net/bluetooth/mgmt.c:4481:12: error: invalid storage class for function 'add_adv_patterns_monitor_rssi'
    4481 | static int add_adv_patterns_monitor_rssi(struct sock *sk, struct hci_dev *hdev,
         |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> net/bluetooth/mgmt.c:4549:12: error: invalid storage class for function 'remove_adv_monitor'
    4549 | static int remove_adv_monitor(struct sock *sk, struct hci_dev *hdev,
         |            ^~~~~~~~~~~~~~~~~~
>> net/bluetooth/mgmt.c:4614:13: error: invalid storage class for function 'read_local_oob_data_complete'
    4614 | static void read_local_oob_data_complete(struct hci_dev *hdev, u8 status,
         |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> net/bluetooth/mgmt.c:4673:12: error: invalid storage class for function 'read_local_oob_data'
    4673 | static int read_local_oob_data(struct sock *sk, struct hci_dev *hdev,
         |            ^~~~~~~~~~~~~~~~~~~
>> net/bluetooth/mgmt.c:4724:12: error: invalid storage class for function 'add_remote_oob_data'
    4724 | static int add_remote_oob_data(struct sock *sk, struct hci_dev *hdev,
         |            ^~~~~~~~~~~~~~~~~~~
>> net/bluetooth/mgmt.c:4832:12: error: invalid storage class for function 'remove_remote_oob_data'
    4832 | static int remove_remote_oob_data(struct sock *sk, struct hci_dev *hdev,
         |            ^~~~~~~~~~~~~~~~~~~~~~
>> net/bluetooth/mgmt.c:4899:13: error: invalid storage class for function 'discovery_type_is_valid'
    4899 | static bool discovery_type_is_valid(struct hci_dev *hdev, uint8_t type,
         |             ^~~~~~~~~~~~~~~~~~~~~~~
>> net/bluetooth/mgmt.c:4926:12: error: invalid storage class for function 'start_discovery_internal'
    4926 | static int start_discovery_internal(struct sock *sk, struct hci_dev *hdev,
         |            ^~~~~~~~~~~~~~~~~~~~~~~~
>> net/bluetooth/mgmt.c:4994:12: error: invalid storage class for function 'start_discovery'
    4994 | static int start_discovery(struct sock *sk, struct hci_dev *hdev,
         |            ^~~~~~~~~~~~~~~
>> net/bluetooth/mgmt.c:5001:12: error: invalid storage class for function 'start_limited_discovery'
    5001 | static int start_limited_discovery(struct sock *sk, struct hci_dev *hdev,
         |            ^~~~~~~~~~~~~~~~~~~~~~~
   net/bluetooth/mgmt.c:5009:12: error: invalid storage class for function 'service_discovery_cmd_complete'
    5009 | static int service_discovery_cmd_complete(struct mgmt_pending_cmd *cmd,
         |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/bluetooth/mgmt.c:5016:12: error: invalid storage class for function 'start_service_discovery'
    5016 | static int start_service_discovery(struct sock *sk, struct hci_dev *hdev,
         |            ^~~~~~~~~~~~~~~~~~~~~~~
   net/bluetooth/mgmt.c:5148:12: error: invalid storage class for function 'stop_discovery'
    5148 | static int stop_discovery(struct sock *sk, struct hci_dev *hdev, void *data,
         |            ^~~~~~~~~~~~~~
   net/bluetooth/mgmt.c:5190:12: error: invalid storage class for function 'confirm_name'
    5190 | static int confirm_name(struct sock *sk, struct hci_dev *hdev, void *data,
         |            ^~~~~~~~~~~~
   net/bluetooth/mgmt.c:5232:12: error: invalid storage class for function 'block_device'
    5232 | static int block_device(struct sock *sk, struct hci_dev *hdev, void *data,
         |            ^~~~~~~~~~~~
   net/bluetooth/mgmt.c:5268:12: error: invalid storage class for function 'unblock_device'
    5268 | static int unblock_device(struct sock *sk, struct hci_dev *hdev, void *data,
         |            ^~~~~~~~~~~~~~
   net/bluetooth/mgmt.c:5304:12: error: invalid storage class for function 'set_device_id'
    5304 | static int set_device_id(struct sock *sk, struct hci_dev *hdev, void *data,
         |            ^~~~~~~~~~~~~
   net/bluetooth/mgmt.c:5339:13: error: invalid storage class for function 'enable_advertising_instance'
    5339 | static void enable_advertising_instance(struct hci_dev *hdev, u8 status,
         |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/bluetooth/mgmt.c:5345:13: error: invalid storage class for function 'set_advertising_complete'
    5345 | static void set_advertising_complete(struct hci_dev *hdev, u8 status,
         |             ^~~~~~~~~~~~~~~~~~~~~~~~
   net/bluetooth/mgmt.c:5419:12: error: invalid storage class for function 'set_advertising'
    5419 | static int set_advertising(struct sock *sk, struct hci_dev *hdev, void *data,
         |            ^~~~~~~~~~~~~~~
   net/bluetooth/mgmt.c:5538:12: error: invalid storage class for function 'set_static_address'
    5538 | static int set_static_address(struct sock *sk, struct hci_dev *hdev,
         |            ^~~~~~~~~~~~~~~~~~
   net/bluetooth/mgmt.c:5582:12: error: invalid storage class for function 'set_scan_params'
    5582 | static int set_scan_params(struct sock *sk, struct hci_dev *hdev,
         |            ^~~~~~~~~~~~~~~
   net/bluetooth/mgmt.c:5639:13: error: invalid storage class for function 'fast_connectable_complete'
    5639 | static void fast_connectable_complete(struct hci_dev *hdev, u8 status,
         |             ^~~~~~~~~~~~~~~~~~~~~~~~~
   net/bluetooth/mgmt.c:5673:12: error: invalid storage class for function 'set_fast_connectable'
    5673 | static int set_fast_connectable(struct sock *sk, struct hci_dev *hdev,
         |            ^~~~~~~~~~~~~~~~~~~~
   net/bluetooth/mgmt.c:5738:13: error: invalid storage class for function 'set_bredr_complete'
    5738 | static void set_bredr_complete(struct hci_dev *hdev, u8 status, u16 opcode)
         |             ^~~~~~~~~~~~~~~~~~
   net/bluetooth/mgmt.c:5770:12: error: invalid storage class for function 'set_bredr'
    5770 | static int set_bredr(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
         |            ^~~~~~~~~
   net/bluetooth/mgmt.c:5882:13: error: invalid storage class for function 'sc_enable_complete'
    5882 | static void sc_enable_complete(struct hci_dev *hdev, u8 status, u16 opcode)
         |             ^~~~~~~~~~~~~~~~~~
   net/bluetooth/mgmt.c:5927:12: error: invalid storage class for function 'set_secure_conn'
    5927 | static int set_secure_conn(struct sock *sk, struct hci_dev *hdev,
         |            ^~~~~~~~~~~~~~~
   net/bluetooth/mgmt.c:6015:12: error: invalid storage class for function 'set_debug_keys'
    6015 | static int set_debug_keys(struct sock *sk, struct hci_dev *hdev,
         |            ^~~~~~~~~~~~~~
   net/bluetooth/mgmt.c:6062:12: error: invalid storage class for function 'set_privacy'
    6062 | static int set_privacy(struct sock *sk, struct hci_dev *hdev, void *cp_data,
         |            ^~~~~~~~~~~
   net/bluetooth/mgmt.c:6119:13: error: invalid storage class for function 'irk_is_valid'
    6119 | static bool irk_is_valid(struct mgmt_irk_info *irk)
         |             ^~~~~~~~~~~~
   net/bluetooth/mgmt.c:6135:12: error: invalid storage class for function 'load_irks'
    6135 | static int load_irks(struct sock *sk, struct hci_dev *hdev, void *cp_data,
         |            ^~~~~~~~~
   net/bluetooth/mgmt.c:6206:13: error: invalid storage class for function 'ltk_is_valid'
    6206 | static bool ltk_is_valid(struct mgmt_ltk_info *key)
         |             ^~~~~~~~~~~~
   net/bluetooth/mgmt.c:6225:12: error: invalid storage class for function 'load_long_term_keys'
    6225 | static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
         |            ^~~~~~~~~~~~~~~~~~~
   net/bluetooth/mgmt.c:6321:12: error: invalid storage class for function 'conn_info_cmd_complete'
    6321 | static int conn_info_cmd_complete(struct mgmt_pending_cmd *cmd, u8 status)
         |            ^~~~~~~~~~~~~~~~~~~~~~
   net/bluetooth/mgmt.c:6348:13: error: invalid storage class for function 'conn_info_refresh_complete'
    6348 | static void conn_info_refresh_complete(struct hci_dev *hdev, u8 hci_status,
         |             ^~~~~~~~~~~~~~~~~~~~~~~~~~
   net/bluetooth/mgmt.c:6402:12: error: invalid storage class for function 'get_conn_info'
    6402 | static int get_conn_info(struct sock *sk, struct hci_dev *hdev, void *data,
         |            ^~~~~~~~~~~~~
   net/bluetooth/mgmt.c:6523:12: error: invalid storage class for function 'clock_info_cmd_complete'
    6523 | static int clock_info_cmd_complete(struct mgmt_pending_cmd *cmd, u8 status)
         |            ^~~~~~~~~~~~~~~~~~~~~~~
   net/bluetooth/mgmt.c:6559:13: error: invalid storage class for function 'get_clock_info_complete'
    6559 | static void get_clock_info_complete(struct hci_dev *hdev, u8 status, u16 opcode)
         |             ^~~~~~~~~~~~~~~~~~~~~~~
   net/bluetooth/mgmt.c:6591:12: error: invalid storage class for function 'get_clock_info'
    6591 | static int get_clock_info(struct sock *sk, struct hci_dev *hdev, void *data,
         |            ^~~~~~~~~~~~~~
   net/bluetooth/mgmt.c:6667:13: error: invalid storage class for function 'is_connected'
    6667 | static bool is_connected(struct hci_dev *hdev, bdaddr_t *addr, u8 type)
         |             ^~~~~~~~~~~~
   net/bluetooth/mgmt.c:6685:12: error: invalid storage class for function 'hci_conn_params_set'
    6685 | static int hci_conn_params_set(struct hci_dev *hdev, bdaddr_t *addr,
         |            ^~~~~~~~~~~~~~~~~~~
   net/bluetooth/mgmt.c:6729:13: error: invalid storage class for function 'device_added'
    6729 | static void device_added(struct sock *sk, struct hci_dev *hdev,


vim +/get_device_flags +4084 net/bluetooth/mgmt.c

4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4083  
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17 @4084  static int get_device_flags(struct sock *sk, struct hci_dev *hdev, void *data,
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4085  			    u16 data_len)
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4086  {
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4087  	struct mgmt_cp_get_device_flags *cp = data;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4088  	struct mgmt_rp_get_device_flags rp;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4089  	struct bdaddr_list_with_flags *br_params;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4090  	struct hci_conn_params *params;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4091  	u32 supported_flags = SUPPORTED_DEVICE_FLAGS();
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4092  	u32 current_flags = 0;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4093  	u8 status = MGMT_STATUS_INVALID_PARAMS;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4094  
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4095  	bt_dev_dbg(hdev, "Get device flags %pMR (type 0x%x)\n",
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4096  		   &cp->addr.bdaddr, cp->addr.type);
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4097  
3ca33e3fb4f919 Abhishek Pandit-Subedi 2020-06-19  4098  	hci_dev_lock(hdev);
3ca33e3fb4f919 Abhishek Pandit-Subedi 2020-06-19  4099  
02ce2c2c24024a Tedd Ho-Jeong An       2021-05-26  4100  	memset(&rp, 0, sizeof(rp));
02ce2c2c24024a Tedd Ho-Jeong An       2021-05-26  4101  
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4102  	if (cp->addr.type == BDADDR_BREDR) {
3d4f9c00492b4e Archie Pusaka          2021-06-04  4103  		br_params = hci_bdaddr_list_lookup_with_flags(&hdev->accept_list,
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4104  							      &cp->addr.bdaddr,
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4105  							      cp->addr.type);
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4106  		if (!br_params)
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4107  			goto done;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4108  
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4109  		current_flags = br_params->current_flags;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4110  	} else {
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4111  		params = hci_conn_params_lookup(hdev, &cp->addr.bdaddr,
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4112  						le_addr_type(cp->addr.type));
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4113  
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4114  		if (!params)
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4115  			goto done;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4116  
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4117  		current_flags = params->current_flags;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4118  	}
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4119  
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4120  	bacpy(&rp.addr.bdaddr, &cp->addr.bdaddr);
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4121  	rp.addr.type = cp->addr.type;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4122  	rp.supported_flags = cpu_to_le32(supported_flags);
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4123  	rp.current_flags = cpu_to_le32(current_flags);
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4124  
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4125  	status = MGMT_STATUS_SUCCESS;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4126  
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4127  done:
3ca33e3fb4f919 Abhishek Pandit-Subedi 2020-06-19  4128  	hci_dev_unlock(hdev);
3ca33e3fb4f919 Abhishek Pandit-Subedi 2020-06-19  4129  
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4130  	return mgmt_cmd_complete(sk, hdev->id, MGMT_OP_GET_DEVICE_FLAGS, status,
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4131  				&rp, sizeof(rp));
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4132  }
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4133  
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17 @4134  static void device_flags_changed(struct sock *sk, struct hci_dev *hdev,
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4135  				 bdaddr_t *bdaddr, u8 bdaddr_type,
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4136  				 u32 supported_flags, u32 current_flags)
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4137  {
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4138  	struct mgmt_ev_device_flags_changed ev;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4139  
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4140  	bacpy(&ev.addr.bdaddr, bdaddr);
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4141  	ev.addr.type = bdaddr_type;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4142  	ev.supported_flags = cpu_to_le32(supported_flags);
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4143  	ev.current_flags = cpu_to_le32(current_flags);
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4144  
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4145  	mgmt_event(MGMT_EV_DEVICE_FLAGS_CHANGED, hdev, &ev, sizeof(ev), sk);
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4146  }
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4147  
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17 @4148  static int set_device_flags(struct sock *sk, struct hci_dev *hdev, void *data,
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4149  			    u16 len)
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4150  {
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4151  	struct mgmt_cp_set_device_flags *cp = data;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4152  	struct bdaddr_list_with_flags *br_params;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4153  	struct hci_conn_params *params;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4154  	u8 status = MGMT_STATUS_INVALID_PARAMS;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4155  	u32 supported_flags = SUPPORTED_DEVICE_FLAGS();
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4156  	u32 current_flags = __le32_to_cpu(cp->current_flags);
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4157  
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4158  	bt_dev_dbg(hdev, "Set device flags %pMR (type 0x%x) = 0x%x",
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4159  		   &cp->addr.bdaddr, cp->addr.type,
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4160  		   __le32_to_cpu(current_flags));
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4161  
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4162  	if ((supported_flags | current_flags) != supported_flags) {
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4163  		bt_dev_warn(hdev, "Bad flag given (0x%x) vs supported (0x%0x)",
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4164  			    current_flags, supported_flags);
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4165  		goto done;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4166  	}
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4167  
3ca33e3fb4f919 Abhishek Pandit-Subedi 2020-06-19  4168  	hci_dev_lock(hdev);
3ca33e3fb4f919 Abhishek Pandit-Subedi 2020-06-19  4169  
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4170  	if (cp->addr.type == BDADDR_BREDR) {
3d4f9c00492b4e Archie Pusaka          2021-06-04  4171  		br_params = hci_bdaddr_list_lookup_with_flags(&hdev->accept_list,
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4172  							      &cp->addr.bdaddr,
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4173  							      cp->addr.type);
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4174  
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4175  		if (br_params) {
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4176  			br_params->current_flags = current_flags;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4177  			status = MGMT_STATUS_SUCCESS;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4178  		} else {
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4179  			bt_dev_warn(hdev, "No such BR/EDR device %pMR (0x%x)",
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4180  				    &cp->addr.bdaddr, cp->addr.type);
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4181  		}
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4182  	} else {
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4183  		params = hci_conn_params_lookup(hdev, &cp->addr.bdaddr,
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4184  						le_addr_type(cp->addr.type));
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4185  		if (params) {
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4186  			params->current_flags = current_flags;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4187  			status = MGMT_STATUS_SUCCESS;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4188  		} else {
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4189  			bt_dev_warn(hdev, "No such LE device %pMR (0x%x)",
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4190  				    &cp->addr.bdaddr,
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4191  				    le_addr_type(cp->addr.type));
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4192  		}
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4193  	}
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4194  
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4195  done:
3ca33e3fb4f919 Abhishek Pandit-Subedi 2020-06-19  4196  	hci_dev_unlock(hdev);
3ca33e3fb4f919 Abhishek Pandit-Subedi 2020-06-19  4197  
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4198  	if (status == MGMT_STATUS_SUCCESS)
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4199  		device_flags_changed(sk, hdev, &cp->addr.bdaddr, cp->addr.type,
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4200  				     supported_flags, current_flags);
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4201  
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4202  	return mgmt_cmd_complete(sk, hdev->id, MGMT_OP_SET_DEVICE_FLAGS, status,
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4203  				 &cp->addr, sizeof(cp->addr));
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4204  }
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4205  
b52729f27b1e39 Miao-chen Chou         2020-06-17 @4206  static void mgmt_adv_monitor_added(struct sock *sk, struct hci_dev *hdev,
b52729f27b1e39 Miao-chen Chou         2020-06-17  4207  				   u16 handle)
b52729f27b1e39 Miao-chen Chou         2020-06-17  4208  {
b52729f27b1e39 Miao-chen Chou         2020-06-17  4209  	struct mgmt_ev_adv_monitor_added ev;
b52729f27b1e39 Miao-chen Chou         2020-06-17  4210  
b52729f27b1e39 Miao-chen Chou         2020-06-17  4211  	ev.monitor_handle = cpu_to_le16(handle);
b52729f27b1e39 Miao-chen Chou         2020-06-17  4212  
b52729f27b1e39 Miao-chen Chou         2020-06-17  4213  	mgmt_event(MGMT_EV_ADV_MONITOR_ADDED, hdev, &ev, sizeof(ev), sk);
b52729f27b1e39 Miao-chen Chou         2020-06-17  4214  }
b52729f27b1e39 Miao-chen Chou         2020-06-17  4215  
66bd095ab5d408 Archie Pusaka          2021-01-22  4216  void mgmt_adv_monitor_removed(struct hci_dev *hdev, u16 handle)
cdde92e230719f Miao-chen Chou         2020-06-17  4217  {
66bd095ab5d408 Archie Pusaka          2021-01-22  4218  	struct mgmt_ev_adv_monitor_removed ev;
66bd095ab5d408 Archie Pusaka          2021-01-22  4219  	struct mgmt_pending_cmd *cmd;
66bd095ab5d408 Archie Pusaka          2021-01-22  4220  	struct sock *sk_skip = NULL;
66bd095ab5d408 Archie Pusaka          2021-01-22  4221  	struct mgmt_cp_remove_adv_monitor *cp;
66bd095ab5d408 Archie Pusaka          2021-01-22  4222  
66bd095ab5d408 Archie Pusaka          2021-01-22  4223  	cmd = pending_find(MGMT_OP_REMOVE_ADV_MONITOR, hdev);
66bd095ab5d408 Archie Pusaka          2021-01-22  4224  	if (cmd) {
66bd095ab5d408 Archie Pusaka          2021-01-22  4225  		cp = cmd->param;
66bd095ab5d408 Archie Pusaka          2021-01-22  4226  
66bd095ab5d408 Archie Pusaka          2021-01-22  4227  		if (cp->monitor_handle)
66bd095ab5d408 Archie Pusaka          2021-01-22  4228  			sk_skip = cmd->sk;
66bd095ab5d408 Archie Pusaka          2021-01-22  4229  	}
cdde92e230719f Miao-chen Chou         2020-06-17  4230  
cdde92e230719f Miao-chen Chou         2020-06-17  4231  	ev.monitor_handle = cpu_to_le16(handle);
cdde92e230719f Miao-chen Chou         2020-06-17  4232  
66bd095ab5d408 Archie Pusaka          2021-01-22  4233  	mgmt_event(MGMT_EV_ADV_MONITOR_REMOVED, hdev, &ev, sizeof(ev), sk_skip);
cdde92e230719f Miao-chen Chou         2020-06-17  4234  }
cdde92e230719f Miao-chen Chou         2020-06-17  4235  
e5e1e7fd470ccf Miao-chen Chou         2020-06-17 @4236  static int read_adv_mon_features(struct sock *sk, struct hci_dev *hdev,
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4237  				 void *data, u16 len)
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4238  {
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4239  	struct adv_monitor *monitor = NULL;
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4240  	struct mgmt_rp_read_adv_monitor_features *rp = NULL;
cafd472a10ff3b Peilin Ye              2020-09-09  4241  	int handle, err;
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4242  	size_t rp_size = 0;
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4243  	__u32 supported = 0;
a2a4dedf88ab2f Archie Pusaka          2021-01-22  4244  	__u32 enabled = 0;
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4245  	__u16 num_handles = 0;
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4246  	__u16 handles[HCI_MAX_ADV_MONITOR_NUM_HANDLES];
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4247  
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4248  	BT_DBG("request for %s", hdev->name);
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4249  
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4250  	hci_dev_lock(hdev);
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4251  
a2a4dedf88ab2f Archie Pusaka          2021-01-22  4252  	if (msft_monitor_supported(hdev))
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4253  		supported |= MGMT_ADV_MONITOR_FEATURE_MASK_OR_PATTERNS;
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4254  
a2a4dedf88ab2f Archie Pusaka          2021-01-22  4255  	idr_for_each_entry(&hdev->adv_monitors_idr, monitor, handle)
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4256  		handles[num_handles++] = monitor->handle;
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4257  
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4258  	hci_dev_unlock(hdev);
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4259  
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4260  	rp_size = sizeof(*rp) + (num_handles * sizeof(u16));
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4261  	rp = kmalloc(rp_size, GFP_KERNEL);
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4262  	if (!rp)
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4263  		return -ENOMEM;
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4264  
a2a4dedf88ab2f Archie Pusaka          2021-01-22  4265  	/* All supported features are currently enabled */
a2a4dedf88ab2f Archie Pusaka          2021-01-22  4266  	enabled = supported;
a2a4dedf88ab2f Archie Pusaka          2021-01-22  4267  
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4268  	rp->supported_features = cpu_to_le32(supported);
a2a4dedf88ab2f Archie Pusaka          2021-01-22  4269  	rp->enabled_features = cpu_to_le32(enabled);
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4270  	rp->max_num_handles = cpu_to_le16(HCI_MAX_ADV_MONITOR_NUM_HANDLES);
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4271  	rp->max_num_patterns = HCI_MAX_ADV_MONITOR_NUM_PATTERNS;
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4272  	rp->num_handles = cpu_to_le16(num_handles);
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4273  	if (num_handles)
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4274  		memcpy(&rp->handles, &handles, (num_handles * sizeof(u16)));
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4275  
cafd472a10ff3b Peilin Ye              2020-09-09  4276  	err = mgmt_cmd_complete(sk, hdev->id,
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4277  				MGMT_OP_READ_ADV_MONITOR_FEATURES,
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4278  				MGMT_STATUS_SUCCESS, rp, rp_size);
cafd472a10ff3b Peilin Ye              2020-09-09  4279  
cafd472a10ff3b Peilin Ye              2020-09-09  4280  	kfree(rp);
cafd472a10ff3b Peilin Ye              2020-09-09  4281  
cafd472a10ff3b Peilin Ye              2020-09-09  4282  	return err;
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4283  }
e5e1e7fd470ccf Miao-chen Chou         2020-06-17  4284  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 60715 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v8 3/5] Bluetooth: refactor set_exp_feature with a feature table
  2021-08-13 16:51 ` [PATCH v8 3/5] Bluetooth: refactor set_exp_feature with a feature table Joseph Hwang
  2021-08-13 19:22   ` kernel test robot
@ 2021-08-13 19:34   ` kernel test robot
  1 sibling, 0 replies; 7+ messages in thread
From: kernel test robot @ 2021-08-13 19:34 UTC (permalink / raw)
  To: Joseph Hwang, linux-bluetooth, marcel, luiz.dentz, pali
  Cc: clang-built-linux, kbuild-all, chromeos-bluetooth-upstreaming,
	josephsih, Joseph Hwang, Jakub Kicinski, Johan Hedberg,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 7668 bytes --]

Hi Joseph,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on bluetooth-next/master]
[also build test ERROR on next-20210813]
[cannot apply to bluetooth/master v5.14-rc5]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Joseph-Hwang/Bluetooth-btusb-disable-Intel-link-statistics-telemetry-events/20210814-005423
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git master
config: hexagon-randconfig-r041-20210814 (attached as .config)
compiler: clang version 12.0.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/7a3d3d918d33f8f8796cb27e1f137c56c2afaeac
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Joseph-Hwang/Bluetooth-btusb-disable-Intel-link-statistics-telemetry-events/20210814-005423
        git checkout 7a3d3d918d33f8f8796cb27e1f137c56c2afaeac
        # save the attached .config to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross O=build_dir ARCH=hexagon SHELL=/bin/bash net/bluetooth/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> net/bluetooth/mgmt.c:4086:1: error: function definition is not allowed here
   {
   ^
   net/bluetooth/mgmt.c:4137:1: error: function definition is not allowed here
   {
   ^
   net/bluetooth/mgmt.c:4150:1: error: function definition is not allowed here
   {
   ^
   net/bluetooth/mgmt.c:4208:1: error: function definition is not allowed here
   {
   ^
   net/bluetooth/mgmt.c:4217:1: error: function definition is not allowed here
   {
   ^
   net/bluetooth/mgmt.c:4238:1: error: function definition is not allowed here
   {
   ^
   net/bluetooth/mgmt.c:4286:1: error: function definition is not allowed here
   {
   ^
   net/bluetooth/mgmt.c:4327:1: error: function definition is not allowed here
   {
   ^
   net/bluetooth/mgmt.c:4390:1: error: function definition is not allowed here
   {
   ^
   net/bluetooth/mgmt.c:4415:1: error: function definition is not allowed here
   {
   ^
   net/bluetooth/mgmt.c:4446:1: error: function definition is not allowed here
   {
   ^
   net/bluetooth/mgmt.c:4483:1: error: function definition is not allowed here
   {
   ^
   net/bluetooth/mgmt.c:4519:1: error: function definition is not allowed here
   {
   ^
   net/bluetooth/mgmt.c:4551:1: error: function definition is not allowed here
   {
   ^
   net/bluetooth/mgmt.c:4616:1: error: function definition is not allowed here
   {
   ^
   net/bluetooth/mgmt.c:4675:1: error: function definition is not allowed here
   {
   ^
   net/bluetooth/mgmt.c:4726:1: error: function definition is not allowed here
   {
   ^
   net/bluetooth/mgmt.c:4834:1: error: function definition is not allowed here
   {
   ^
   net/bluetooth/mgmt.c:4870:1: error: function definition is not allowed here
   {
   ^
   fatal error: too many errors emitted, stopping now [-ferror-limit=]
   20 errors generated.


vim +4086 net/bluetooth/mgmt.c

4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4083  
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4084  static int get_device_flags(struct sock *sk, struct hci_dev *hdev, void *data,
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4085  			    u16 data_len)
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17 @4086  {
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4087  	struct mgmt_cp_get_device_flags *cp = data;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4088  	struct mgmt_rp_get_device_flags rp;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4089  	struct bdaddr_list_with_flags *br_params;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4090  	struct hci_conn_params *params;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4091  	u32 supported_flags = SUPPORTED_DEVICE_FLAGS();
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4092  	u32 current_flags = 0;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4093  	u8 status = MGMT_STATUS_INVALID_PARAMS;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4094  
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4095  	bt_dev_dbg(hdev, "Get device flags %pMR (type 0x%x)\n",
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4096  		   &cp->addr.bdaddr, cp->addr.type);
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4097  
3ca33e3fb4f919 Abhishek Pandit-Subedi 2020-06-19  4098  	hci_dev_lock(hdev);
3ca33e3fb4f919 Abhishek Pandit-Subedi 2020-06-19  4099  
02ce2c2c24024a Tedd Ho-Jeong An       2021-05-26  4100  	memset(&rp, 0, sizeof(rp));
02ce2c2c24024a Tedd Ho-Jeong An       2021-05-26  4101  
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4102  	if (cp->addr.type == BDADDR_BREDR) {
3d4f9c00492b4e Archie Pusaka          2021-06-04  4103  		br_params = hci_bdaddr_list_lookup_with_flags(&hdev->accept_list,
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4104  							      &cp->addr.bdaddr,
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4105  							      cp->addr.type);
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4106  		if (!br_params)
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4107  			goto done;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4108  
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4109  		current_flags = br_params->current_flags;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4110  	} else {
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4111  		params = hci_conn_params_lookup(hdev, &cp->addr.bdaddr,
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4112  						le_addr_type(cp->addr.type));
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4113  
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4114  		if (!params)
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4115  			goto done;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4116  
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4117  		current_flags = params->current_flags;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4118  	}
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4119  
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4120  	bacpy(&rp.addr.bdaddr, &cp->addr.bdaddr);
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4121  	rp.addr.type = cp->addr.type;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4122  	rp.supported_flags = cpu_to_le32(supported_flags);
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4123  	rp.current_flags = cpu_to_le32(current_flags);
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4124  
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4125  	status = MGMT_STATUS_SUCCESS;
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4126  
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4127  done:
3ca33e3fb4f919 Abhishek Pandit-Subedi 2020-06-19  4128  	hci_dev_unlock(hdev);
3ca33e3fb4f919 Abhishek Pandit-Subedi 2020-06-19  4129  
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4130  	return mgmt_cmd_complete(sk, hdev->id, MGMT_OP_GET_DEVICE_FLAGS, status,
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4131  				&rp, sizeof(rp));
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4132  }
4c54bf2b093bb2 Abhishek Pandit-Subedi 2020-06-17  4133  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 25370 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-08-13 19:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-13 16:51 [PATCH v8 1/5] Bluetooth: btusb: disable Intel link statistics telemetry events Joseph Hwang
2021-08-13 16:51 ` [PATCH v8 2/5] Bluetooth: btintel: support " Joseph Hwang
2021-08-13 16:51 ` [PATCH v8 3/5] Bluetooth: refactor set_exp_feature with a feature table Joseph Hwang
2021-08-13 19:22   ` kernel test robot
2021-08-13 19:34   ` kernel test robot
2021-08-13 16:51 ` [PATCH v8 4/5] Bluetooth: Support the quality report events Joseph Hwang
2021-08-13 16:51 ` [PATCH v8 5/5] Bluetooth: set quality report callback for Intel Joseph Hwang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).