linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] Bluetooth: le_supported_roles experimental feature
@ 2020-07-01 22:08 Alain Michaud
  2020-07-02 13:18 ` Marcel Holtmann
  0 siblings, 1 reply; 6+ messages in thread
From: Alain Michaud @ 2020-07-01 22:08 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Alain Michaud

This patch adds an le_supported_roles features which allows a
clients to determine if the controller is able to support peripheral and
central connections separately and at the same time.

Signed-off-by: Alain Michaud <alainm@chromium.org>
---

Changes in v2:
 - Slight change of design based on offline feedback

 net/bluetooth/mgmt.c | 36 +++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 5e9b9728eeac..c13fcc21745f 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -3753,10 +3753,36 @@ static const u8 debug_uuid[16] = {
 };
 #endif
 
+/* 671b10b5-42c0-4696-9227-eb28d1b049d6 */
+static const u8 le_supported_roles[16] = {
+	0xd6, 0x49, 0xb0, 0xd1, 0x28, 0xeb, 0x27, 0x92,
+	0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67,
+};
+
+static u32 get_le_roles_flags(struct hci_dev *hdev)
+{
+	u32 flags = 0;
+
+	/* Central connections supported */
+	if (hdev->le_states[4] & 0x08)
+		flags |= BIT(0);
+
+	/* Peripheral connections supported */
+	if (hdev->le_states[4] & 0x40)
+		flags |= BIT(1);
+
+	/* Simult central and peripheral connections supported */
+	if (test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks) &&
+	    (hdev->le_states[3] & 0x10))
+		flags |= BIT(2);
+
+	return flags;
+}
+
 static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev,
 				  void *data, u16 data_len)
 {
-	char buf[42];
+	char buf[44];
 	struct mgmt_rp_read_exp_features_info *rp = (void *)buf;
 	u16 idx = 0;
 
@@ -3774,6 +3800,14 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev,
 	}
 #endif
 
+	if (hdev) {
+		memcpy(rp->features[idx].uuid, le_supported_roles,
+		       sizeof(le_supported_roles));
+
+		rp->features[idx].flags = cpu_to_le32(get_le_roles_flags(hdev));
+		++idx;
+	}
+
 	rp->feature_count = cpu_to_le16(idx);
 
 	/* After reading the experimental features information, enable
-- 
2.27.0.212.ge8ba1cc988-goog


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

end of thread, other threads:[~2020-07-03 13:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-01 22:08 [PATCH v2] Bluetooth: le_supported_roles experimental feature Alain Michaud
2020-07-02 13:18 ` Marcel Holtmann
     [not found]   ` <CALWDO_XT=O4NiqMur+_u1z4o0868ZzBr4gpUikgmgw2U4zqMzw@mail.gmail.com>
2020-07-02 15:01     ` Alain Michaud
2020-07-02 17:37       ` Alain Michaud
2020-07-03  7:24     ` Marcel Holtmann
2020-07-03 13:03       ` Marcel Holtmann

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).