Skip to contentSkip to conversation

Bluetooth: hci_conn: Add support for linking multiple hcon

PATCH Superseded Luiz Augusto von Dentz 2 participants 4 messages Apr 13, 2023

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/3 Bluetooth: hci_conn: Add support for linking multiple hcon

From: Luiz Augusto von Dentz <[email protected]>

Since it is required for some configurations to have multiple CIS with the same peer (e.g. BAP - 4.4.6. Audio Configuration 6(i)).

---
 include/net/bluetooth/hci_core.h |  14 ++-
 net/bluetooth/hci_conn.c         | 155 ++++++++++++++++++++++---------
 net/bluetooth/hci_event.c        |  94 +++++++++----------
 net/bluetooth/iso.c              |   8 +-
 4 files changed, 173 insertions(+), 98 deletions(-)
include/net/bluetooth/hci_core.h +12 -2
index 827e67159523..4fe1e71cb9d8 100644
@@ -770,7 +770,10 @@ struct hci_conn {
 	void		*iso_data;
 	struct amp_mgr	*amp_mgr;
 
-	struct hci_conn	*link;
+	struct list_head link_list;
+	struct hci_conn	*parent;
+	struct hci_link *link;
+
 	struct bt_codec codec;
 
 	void (*connect_cfm_cb)	(struct hci_conn *conn, u8 status);
@@ -780,6 +783,11 @@ struct hci_conn {
 	void (*cleanup)(struct hci_conn *conn);
 };
 
+struct hci_link {
+	struct list_head list;
+	struct hci_conn *conn;
+};
+
 struct hci_chan {
 	struct list_head list;
 	__u16 handle;
@@ -1383,12 +1391,14 @@ static inline void hci_conn_put(struct hci_conn *conn)
 	put_device(&conn->dev);
 }
 
-static inline void hci_conn_hold(struct hci_conn *conn)
+static inline struct hci_conn *hci_conn_hold(struct hci_conn *conn)
 {
 	BT_DBG("hcon %p orig refcnt %d", conn, atomic_read(&conn->refcnt));
 
 	atomic_inc(&conn->refcnt);
 	cancel_delayed_work(&conn->disc_work);
+
+	return conn;
 }
 
 static inline void hci_conn_drop(struct hci_conn *conn)
net/bluetooth/hci_conn.c +113 -42

284 lines not on this page · raw message

net/bluetooth/hci_event.c +42 -52

153 lines not on this page · raw message

net/bluetooth/iso.c +6 -2
index 74117df03a3f..34d55a85d8f6 100644
@@ -1657,8 +1657,12 @@ static void iso_connect_cfm(struct hci_conn *hcon, __u8 status)
 
 		/* Check if LE link has failed */
 		if (status) {
-			if (hcon->link)
-				iso_conn_del(hcon->link, bt_to_errno(status));
+			struct hci_link *link, *t;
+
+			list_for_each_entry_safe(link, t, &hcon->link_list,
+						 list)
+				iso_conn_del(link->conn, bt_to_errno(status));
+
 			return;
 		}
 
Signature · 1 line
2.39.2
author maintainer
#1 lore raw

PATCH 2/3 Bluetooth: hci_conn: Fix not matching by CIS ID

From: Luiz Augusto von Dentz <[email protected]>

This fixes only matching CIS by address which prevents creating new hcon if upper layer is requesting a specific CIS ID.

---
 include/net/bluetooth/hci_core.h | 7 ++++++-
 net/bluetooth/hci_conn.c         | 2 +-
 2 files changed, 7 insertions(+), 2 deletions(-)
include/net/bluetooth/hci_core.h +6 -1
index 4fe1e71cb9d8..6f5e8594ff2d 100644
@@ -1180,7 +1180,8 @@ static inline struct hci_conn *hci_conn_hash_lookup_le(struct hci_dev *hdev,
 
 static inline struct hci_conn *hci_conn_hash_lookup_cis(struct hci_dev *hdev,
 							bdaddr_t *ba,
-							__u8 ba_type)
+							__u8 ba_type,
+							__u8 id)
 {
 	struct hci_conn_hash *h = &hdev->conn_hash;
 	struct hci_conn  *c;
@@ -1191,6 +1192,10 @@ static inline struct hci_conn *hci_conn_hash_lookup_cis(struct hci_dev *hdev,
 		if (c->type != ISO_LINK)
 			continue;
 
+		/* Match CIS ID if set */
+		if (id != BT_ISO_QOS_CIS_UNSET && id != c->iso_qos.ucast.cis)
+			continue;
+
 		if (ba_type == c->dst_type && !bacmp(&c->dst, ba)) {
 			rcu_read_unlock();
 			return c;
net/bluetooth/hci_conn.c +1 -1
index 8b8ebd3e2585..5524f08b91ae 100644
@@ -1842,7 +1842,7 @@ struct hci_conn *hci_bind_cis(struct hci_dev *hdev, bdaddr_t *dst,
 {
 	struct hci_conn *cis;
 
-	cis = hci_conn_hash_lookup_cis(hdev, dst, dst_type);
+	cis = hci_conn_hash_lookup_cis(hdev, dst, dst_type, qos->ucast.cis);
 	if (!cis) {
 		cis = hci_conn_add(hdev, ISO_LINK, dst, HCI_ROLE_MASTER);
 		if (!cis)
Signature · 1 line
2.39.2
author maintainer
#2 lore raw

PATCH 3/3 Bluetooth: hci_conn: Fix not waiting for HCI_EVT_LE_CIS_ESTABLISHED

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

When submitting HCI_OP_LE_CREATE_CIS the code shall wait for HCI_EVT_LE_CIS_ESTABLISHED thus enforcing the serialization of HCI_OP_LE_CREATE_CIS as the Core spec does not allow to send them in parallel:

BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 4, Part E page 2566:

If the Host issues this command before all the HCI_LE_CIS_Established events from the previous use of the command have been generated, the Controller shall return the error code Command Disallowed (0x0C).

---
 include/net/bluetooth/hci_sync.h |  2 +
 net/bluetooth/hci_conn.c         | 68 +++-----------------------------
 net/bluetooth/hci_sync.c         | 65 ++++++++++++++++++++++++++++++
 3 files changed, 73 insertions(+), 62 deletions(-)
include/net/bluetooth/hci_sync.h +2 -0
index 17f5a4c32f36..f61b249787fc 100644
@@ -122,6 +122,8 @@ int hci_abort_conn_sync(struct hci_dev *hdev, struct hci_conn *conn, u8 reason);
 
 int hci_le_create_conn_sync(struct hci_dev *hdev, struct hci_conn *conn);
 
+int hci_le_create_cis_sync(struct hci_dev *hdev, struct hci_conn *conn);
+
 int hci_le_remove_cig_sync(struct hci_dev *hdev, u8 handle);
 
 int hci_le_terminate_big_sync(struct hci_dev *hdev, u8 handle, u8 reason);
net/bluetooth/hci_conn.c +6 -62

84 lines not on this page · raw message

net/bluetooth/hci_sync.c +65 -0

71 lines not on this page · raw message

Signature · 1 line
2.39.2
#3 lore raw
In reply to Luiz Augusto von Dentz

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=739317

---Test result---

Test Summary:

CheckPatch                    PASS      3.52 seconds
GitLint                       PASS      1.06 seconds
SubjectPrefix                 PASS      0.37 seconds
BuildKernel                   PASS      38.01 seconds
CheckAllWarning               PASS      41.68 seconds
CheckSparse                   WARNING   47.73 seconds
CheckSmatch                   WARNING   123.69 seconds
BuildKernel32                 PASS      37.14 seconds
TestRunnerSetup               PASS      519.08 seconds
TestRunner_l2cap-tester       PASS      18.08 seconds
TestRunner_iso-tester         PASS      19.00 seconds
TestRunner_bnep-tester        PASS      6.11 seconds
TestRunner_mgmt-tester        PASS      125.24 seconds
TestRunner_rfcomm-tester      PASS      10.05 seconds
TestRunner_sco-tester         PASS      9.03 seconds
TestRunner_ioctl-tester       PASS      10.53 seconds
TestRunner_mesh-tester        PASS      7.74 seconds
TestRunner_smp-tester         PASS      8.84 seconds
TestRunner_userchan-tester    PASS      6.62 seconds
IncrementalBuild              PASS      98.31 seconds

Details
##############################
Test: CheckSparse - WARNING
Desc: Run sparse tool with linux kernel
Output:
net/bluetooth/hci_event.c: note: in included file (through include/net/bluetooth/hci_core.h):
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
net/bluetooth/hci_event.c: note: in included file (through include/net/bluetooth/hci_core.h):

---
Regards,
Linux Bluetooth