Skip to contentSkip to conversation

Bluetooth: Split bt_iso_qos into dedicated structures

PATCH Superseded Iulia Tanasescu 2 participants 3 messages Mar 28, 2023

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Bluetooth: Split bt_iso_qos into dedicated structures

This patch adds support for additional ISO broadcast QoS parameters, that the user can set before performing broadcast procedures using an ISO socket.

This patch splits the "bt_iso_qos" structure into dedicated unicast and broadcast structures, so that ISO sockets can be configured with dedicated QoS options depending on the type of ISO procedures to run.

This patch depends on the BlueZ patch [BlueZ,v2,1/1] Split bt_iso_qos into dedicated structures.

Iulia Tanasescu (1):
Split bt_iso_qos into dedicated structures

 include/net/bluetooth/bluetooth.h |  56 ++++++--
 include/net/bluetooth/hci_core.h  |  17 +--
 net/bluetooth/hci_conn.c          | 104 +++++++++------
 net/bluetooth/hci_event.c         |  38 +++---
 net/bluetooth/iso.c               | 205 ++++++++++++++++++++++++------
 5 files changed, 305 insertions(+), 115 deletions(-)

base-commit: db0fc80ec686774f1ca4606e752bf42af1f1cd97

Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/1 Bluetooth: Split bt_iso_qos into dedicated structures

Split bt_iso_qos into dedicated unicast and broadcast structures and add additional broadcast parameters.

---
 include/net/bluetooth/bluetooth.h |  56 ++++++--
 include/net/bluetooth/hci_core.h  |  17 +--
 net/bluetooth/hci_conn.c          | 104 +++++++++------
 net/bluetooth/hci_event.c         |  38 +++---
 net/bluetooth/iso.c               | 205 ++++++++++++++++++++++++------
 5 files changed, 305 insertions(+), 115 deletions(-)
include/net/bluetooth/bluetooth.h +43 -13
index bcc5a4cd2c17..bc2503d9c3cd 100644
@@ -1,6 +1,7 @@
 /*
    BlueZ - Bluetooth protocol stack for Linux
    Copyright (C) 2000-2001 Qualcomm Incorporated
+   Copyright 2023 NXP
 
    Written 2000,2001 by Maxim Krasnyansky <[email protected]>
 
@@ -171,25 +172,54 @@ struct bt_iso_io_qos {
 	__u8  rtn;
 };
 
-struct bt_iso_qos {
-	union {
-		__u8  cig;
-		__u8  big;
-	};
-	union {
-		__u8  cis;
-		__u8  bis;
-	};
-	union {
-		__u8  sca;
-		__u8  sync_interval;
-	};
+struct bt_iso_ucast_qos {
+	__u8  cig;
+	__u8  cis;
+	__u8  sca;
 	__u8  packing;
 	__u8  framing;
 	struct bt_iso_io_qos in;
 	struct bt_iso_io_qos out;
 };
 
+struct bt_iso_bcast_src_qos {
+	__u8  sync_interval;
+	__u8  big;
+	__u8  bis;
+	__u8  packing;
+	__u8  framing;
+	__u8  encryption;
+	__u8  bcode[16];
+	struct bt_iso_io_qos out;
+};
+
+struct bt_iso_bcast_snk_qos {
+	__u8  options;
+	__u16 skip;
+	__u16 sync_timeout;
+	__u8  sync_cte_type;
+	__u8  big;
+	__u8  encryption;
+	__u8  bcode[16];
+	__u8  mse;
+	__u16 timeout;
+	struct bt_iso_io_qos in;
+};
+
+struct bt_iso_bcast_qos {
+union {
+		struct bt_iso_bcast_src_qos bsrc;
+		struct bt_iso_bcast_snk_qos bsnk;
+	};
+};
+
+struct bt_iso_qos {
+	union {
+		struct bt_iso_ucast_qos ucast;
+		struct bt_iso_bcast_qos bcast;
+	};
+};
+
 #define BT_ISO_PHY_1M		0x01
 #define BT_ISO_PHY_2M		0x02
 #define BT_ISO_PHY_CODED	0x04
include/net/bluetooth/hci_core.h +9 -8
index 53d3328c2b8b..e6e6217a4509 100644
@@ -1,6 +1,7 @@
 /*
    BlueZ - Bluetooth protocol stack for Linux
    Copyright (c) 2000-2001, 2010, Code Aurora Forum. All rights reserved.
+   Copyright 2023 NXP
 
    Written 2000,2001 by Maxim Krasnyansky <[email protected]>
 
@@ -1090,7 +1091,7 @@ static inline struct hci_conn *hci_conn_hash_lookup_bis(struct hci_dev *hdev,
 		if (bacmp(&c->dst, ba) || c->type != ISO_LINK)
 			continue;
 
-		if (c->iso_qos.big == big && c->iso_qos.bis == bis) {
+		if (c->iso_qos.bcast.bsrc.big == big && c->iso_qos.bcast.bsrc.bis == bis) {
 			rcu_read_unlock();
 			return c;
 		}
@@ -1199,7 +1200,7 @@ static inline struct hci_conn *hci_conn_hash_lookup_cig(struct hci_dev *hdev,
 		if (c->type != ISO_LINK)
 			continue;
 
-		if (handle == c->iso_qos.cig) {
+		if (handle == c->iso_qos.ucast.cig) {
 			rcu_read_unlock();
 			return c;
 		}
@@ -1222,7 +1223,7 @@ static inline struct hci_conn *hci_conn_hash_lookup_big(struct hci_dev *hdev,
 		if (bacmp(&c->dst, BDADDR_ANY) || c->type != ISO_LINK)
 			continue;
 
-		if (handle == c->iso_qos.big) {
+		if (handle == c->iso_qos.bcast.bsrc.big) {
 			rcu_read_unlock();
 			return c;
 		}
@@ -1324,15 +1325,15 @@ struct hci_conn *hci_connect_acl(struct hci_dev *hdev, bdaddr_t *dst,
 struct hci_conn *hci_connect_sco(struct hci_dev *hdev, int type, bdaddr_t *dst,
 				 __u16 setting, struct bt_codec *codec);
 struct hci_conn *hci_bind_cis(struct hci_dev *hdev, bdaddr_t *dst,
-			      __u8 dst_type, struct bt_iso_qos *qos);
+			      __u8 dst_type, struct bt_iso_ucast_qos *qos);
 struct hci_conn *hci_connect_cis(struct hci_dev *hdev, bdaddr_t *dst,
-				 __u8 dst_type, struct bt_iso_qos *qos);
+				 __u8 dst_type, struct bt_iso_ucast_qos *qos);
 struct hci_conn *hci_connect_bis(struct hci_dev *hdev, bdaddr_t *dst,
-				 __u8 dst_type, struct bt_iso_qos *qos,
+				 __u8 dst_type, struct bt_iso_bcast_src_qos *qos,
 				 __u8 data_len, __u8 *data);
 int hci_pa_create_sync(struct hci_dev *hdev, bdaddr_t *dst, __u8 dst_type,
-		       __u8 sid);
-int hci_le_big_create_sync(struct hci_dev *hdev, struct bt_iso_qos *qos,
+		       __u8 sid, struct bt_iso_bcast_snk_qos *qos);
+int hci_le_big_create_sync(struct hci_dev *hdev, struct bt_iso_bcast_snk_qos *qos,
 			   __u16 sync_handle, __u8 num_bis, __u8 bis[]);
 int hci_conn_check_link_mode(struct hci_conn *conn);
 int hci_conn_check_secure(struct hci_conn *conn, __u8 sec_level);
net/bluetooth/hci_conn.c +67 -37

314 lines not on this page · raw message

net/bluetooth/hci_event.c +21 -17
index 8d8547fa9032..0a7c2c759ac8 100644
@@ -1,6 +1,7 @@
 /*
    BlueZ - Bluetooth protocol stack for Linux
    Copyright (c) 2000-2001, 2010, Code Aurora Forum. All rights reserved.
+   Copyright 2023 NXP
 
    Written 2000,2001 by Maxim Krasnyansky <[email protected]>
 
@@ -3843,7 +3844,7 @@ static u8 hci_cc_le_set_cig_params(struct hci_dev *hdev, void *data,
 	rcu_read_lock();
 
 	list_for_each_entry_rcu(conn, &hdev->conn_hash.list, list) {
-		if (conn->type != ISO_LINK || conn->iso_qos.cig != rp->cig_id ||
+		if (conn->type != ISO_LINK || conn->iso_qos.ucast.cig != rp->cig_id ||
 		    conn->state == BT_CONNECTED)
 			continue;
 
@@ -3877,6 +3878,7 @@ static u8 hci_cc_le_setup_iso_path(struct hci_dev *hdev, void *data,
 	struct hci_rp_le_setup_iso_path *rp = data;
 	struct hci_cp_le_setup_iso_path *cp;
 	struct hci_conn *conn;
+	bool cfm;
 
 	bt_dev_dbg(hdev, "status 0x%2.2x", rp->status);
 
@@ -3900,12 +3902,14 @@ static u8 hci_cc_le_setup_iso_path(struct hci_dev *hdev, void *data,
 	/* Input (Host to Controller) */
 	case 0x00:
 		/* Only confirm connection if output only */
-		if (conn->iso_qos.out.sdu && !conn->iso_qos.in.sdu)
+		cfm = !bacmp(&conn->dst, BDADDR_ANY) ||
+			(conn->iso_qos.ucast.out.sdu && !conn->iso_qos.ucast.in.sdu);
+		if (cfm)
 			hci_connect_cfm(conn, rp->status);
 		break;
 	/* Output (Controller to Host) */
 	case 0x01:
-		/* Confirm connection since conn->iso_qos is always configured
+		/* Confirm connection since Output is always configured
 		 * last.
 		 */
 		hci_connect_cfm(conn, rp->status);
@@ -6822,15 +6826,15 @@ static void hci_le_cis_estabilished_evt(struct hci_dev *hdev, void *data,
 		memset(&interval, 0, sizeof(interval));
 
 		memcpy(&interval, ev->c_latency, sizeof(ev->c_latency));
-		conn->iso_qos.in.interval = le32_to_cpu(interval);
+		conn->iso_qos.ucast.in.interval = le32_to_cpu(interval);
 		memcpy(&interval, ev->p_latency, sizeof(ev->p_latency));
-		conn->iso_qos.out.interval = le32_to_cpu(interval);
-		conn->iso_qos.in.latency = le16_to_cpu(ev->interval);
-		conn->iso_qos.out.latency = le16_to_cpu(ev->interval);
-		conn->iso_qos.in.sdu = le16_to_cpu(ev->c_mtu);
-		conn->iso_qos.out.sdu = le16_to_cpu(ev->p_mtu);
-		conn->iso_qos.in.phy = ev->c_phy;
-		conn->iso_qos.out.phy = ev->p_phy;
+		conn->iso_qos.ucast.out.interval = le32_to_cpu(interval);
+		conn->iso_qos.ucast.in.latency = le16_to_cpu(ev->interval);
+		conn->iso_qos.ucast.out.latency = le16_to_cpu(ev->interval);
+		conn->iso_qos.ucast.in.sdu = le16_to_cpu(ev->c_mtu);
+		conn->iso_qos.ucast.out.sdu = le16_to_cpu(ev->p_mtu);
+		conn->iso_qos.ucast.in.phy = ev->c_phy;
+		conn->iso_qos.ucast.out.phy = ev->p_phy;
 	}
 
 	if (!ev->status) {
@@ -6904,8 +6908,8 @@ static void hci_le_cis_req_evt(struct hci_dev *hdev, void *data,
 		cis->handle = cis_handle;
 	}
 
-	cis->iso_qos.cig = ev->cig_id;
-	cis->iso_qos.cis = ev->cis_id;
+	cis->iso_qos.ucast.cig = ev->cig_id;
+	cis->iso_qos.ucast.cis = ev->cis_id;
 
 	if (!(flags & HCI_PROTO_DEFER)) {
 		hci_le_accept_cis(hdev, ev->cis_handle);
@@ -6992,13 +6996,13 @@ static void hci_le_big_sync_established_evt(struct hci_dev *hdev, void *data,
 			bis->handle = handle;
 		}
 
-		bis->iso_qos.big = ev->handle;
+		bis->iso_qos.bcast.bsnk.big = ev->handle;
 		memset(&interval, 0, sizeof(interval));
 		memcpy(&interval, ev->latency, sizeof(ev->latency));
-		bis->iso_qos.in.interval = le32_to_cpu(interval);
+		bis->iso_qos.bcast.bsnk.in.interval = le32_to_cpu(interval);
 		/* Convert ISO Interval (1.25 ms slots) to latency (ms) */
-		bis->iso_qos.in.latency = le16_to_cpu(ev->interval) * 125 / 100;
-		bis->iso_qos.in.sdu = le16_to_cpu(ev->max_pdu);
+		bis->iso_qos.bcast.bsnk.in.latency = le16_to_cpu(ev->interval) * 125 / 100;
+		bis->iso_qos.bcast.bsnk.in.sdu = le16_to_cpu(ev->max_pdu);
 
 		hci_connect_cfm(bis, ev->status);
 	}
net/bluetooth/iso.c +165 -40

350 lines not on this page · raw message

Signature · 1 line
2.34.1
#2 lore raw

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=734491

---Test result---

Test Summary:

CheckPatch                    PASS      1.94 seconds
GitLint                       PASS      0.24 seconds
SubjectPrefix                 PASS      0.06 seconds
BuildKernel                   PASS      44.08 seconds
CheckAllWarning               PASS      48.31 seconds
CheckSparse                   WARNING   53.70 seconds
CheckSmatch                   WARNING   144.02 seconds
BuildKernel32                 PASS      42.76 seconds
TestRunnerSetup               PASS      607.28 seconds
TestRunner_l2cap-tester       PASS      20.13 seconds
TestRunner_iso-tester         FAIL      19.69 seconds
TestRunner_bnep-tester        PASS      7.10 seconds
TestRunner_mgmt-tester        PASS      132.33 seconds
TestRunner_rfcomm-tester      PASS      11.07 seconds
TestRunner_sco-tester         PASS      10.00 seconds
TestRunner_ioctl-tester       PASS      11.91 seconds
TestRunner_mesh-tester        PASS      8.81 seconds
TestRunner_smp-tester         PASS      9.92 seconds
TestRunner_userchan-tester    PASS      7.40 seconds
IncrementalBuild              PASS      39.77 seconds

Details
##############################
Test: CheckSparse - WARNING
Desc: Run sparse tool with linux kernel
Output:
net/bluetooth/hci_conn.c:2095:18: warning: incorrect type in assignment (different base types)net/bluetooth/hci_conn.c:2095:18: expected restricted __le16 [usertype] skipnet/bluetooth/hci_conn.c:2095:18: got unsigned short [usertype] skipnet/bluetooth/hci_conn.c:2096:26: warning: incorrect type in assignment (different base types)net/bluetooth/hci_conn.c:2096:26: expected restricted __le16 [usertype] sync_timeoutnet/bluetooth/hci_conn.c:2096:26: got unsigned short [usertype] sync_timeoutnet/bluetooth/hci_conn.c:2126:24: warning: incorrect type in assignment (different base types)net/bluetooth/hci_conn.c:2126:24: expected restricted __le16 [addressable] [assigned] [usertype] timeoutnet/bluetooth/hci_conn.c:2126:24: got unsigned short [usertype] timeoutnet/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):
##############################
Test: TestRunner_iso-tester - FAIL
Desc: Run iso-tester with test-runner
Output:
Total: 57, Passed: 10 (17.5%), Failed: 47, Not Run: 0

Failed Test Cases

Basic ISO Set Socket Option - Success                Failed       0.184 seconds
ISO QoS 8_1_1 - Success                              Failed       0.188 seconds
ISO QoS 8_2_1 - Success                              Failed       0.176 seconds
ISO QoS 16_1_1 - Success                             Failed       0.184 seconds
ISO QoS 16_2_1 - Success                             Failed       0.184 seconds
ISO QoS 16_2_1 CIG 0x01 - Success                    Failed       0.192 seconds
ISO QoS 16_2_1 CIG 0x01 CIS 0x01 - Success           Failed       0.184 seconds
ISO QoS 24_1_1 - Success                             Failed       0.196 seconds
ISO QoS 24_2_1 - Success                             Failed       0.180 seconds
ISO QoS 32_1_1 - Success                             Failed       0.176 seconds
ISO QoS 32_2_1 - Success                             Failed       0.188 seconds
ISO QoS 44_1_1 - Success                             Failed       0.188 seconds
ISO QoS 44_2_1 - Success                             Failed       0.184 seconds
ISO QoS 48_1_1 - Success                             Failed       0.184 seconds
ISO QoS 48_2_1 - Success                             Failed       0.180 seconds
ISO QoS 48_3_1 - Success                             Failed       0.176 seconds
ISO QoS 48_4_1 - Success                             Failed       0.184 seconds
ISO QoS 48_5_1 - Success                             Failed       0.184 seconds
ISO QoS 48_6_1 - Success                             Failed       0.200 seconds
ISO QoS 8_1_2 - Success                              Failed       0.192 seconds
ISO QoS 8_2_2 - Success                              Failed       0.184 seconds
ISO QoS 16_1_2 - Success                             Failed       0.176 seconds
ISO QoS 16_2_2 - Success                             Failed       0.188 seconds
ISO QoS 24_1_2 - Success                             Failed       0.176 seconds
ISO QoS 24_2_2 - Success                             Failed       0.192 seconds
ISO QoS 32_1_2 - Success                             Failed       0.184 seconds
ISO QoS 32_2_2 - Success                             Failed       0.188 seconds
ISO QoS 44_1_2 - Success                             Failed       0.184 seconds
ISO QoS 44_2_2 - Success                             Failed       0.184 seconds
ISO QoS 48_1_2 - Success                             Failed       0.192 seconds
ISO QoS 48_2_2 - Success                             Failed       0.188 seconds
ISO QoS 48_3_2 - Success                             Failed       0.188 seconds
ISO QoS 48_4_2 - Success                             Failed       0.176 seconds
ISO QoS 48_5_2 - Success                             Failed       0.192 seconds
ISO QoS 48_6_2 - Success                             Failed       0.180 seconds
ISO Connect - Reject                                 Failed       0.180 seconds
ISO Connect2 CIG 0x01 - Success                      Failed       0.188 seconds
ISO Send - Success                                   Failed       0.176 seconds
ISO Defer - Success                                  Failed       0.180 seconds
ISO Defer Send - Success                             Failed       0.184 seconds
ISO 48_2_1 Defer Send - Success                      Failed       0.188 seconds
ISO Send and Receive - Success                       Failed       0.176 seconds
ISO Disconnect - Success                             Failed       0.172 seconds
ISO Reconnect - Success                              Failed       0.172 seconds
ISO Broadcaster - Success                            Failed       0.180 seconds
ISO Broadcaster BIG 0x01 - Success                   Failed       0.184 seconds
ISO Broadcaster BIG 0x01 BIS 0x01 - Success          Failed       0.188 seconds

---
Regards,
Linux Bluetooth