All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ v2.. 1/3] lib: tools: remove POLL_ERRQUEUE
@ 2025-07-14 16:44 Pauli Virtanen
  2025-07-14 16:44 ` [PATCH BlueZ v2.. 2/3] lib: add BT_PKT_SEQNUM and BT_SCM_PKT_SEQNUM Pauli Virtanen
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Pauli Virtanen @ 2025-07-14 16:44 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Pauli Virtanen

This experimental feature did not land to mainline kernel, and probably
would need to be done differently.

Remove defines and tests for it.
---
 lib/bluetooth.h    |   2 -
 src/shared/util.c  |   2 -
 tools/iso-tester.c | 127 +--------------------------------------------
 3 files changed, 1 insertion(+), 130 deletions(-)

diff --git a/lib/bluetooth.h b/lib/bluetooth.h
index 9b6b54d5d..150679d72 100644
--- a/lib/bluetooth.h
+++ b/lib/bluetooth.h
@@ -253,8 +253,6 @@ enum {
 
 #define BT_ISO_BASE		20
 
-#define BT_POLL_ERRQUEUE	21
-
 /* Byte order conversions */
 #if __BYTE_ORDER == __LITTLE_ENDIAN
 #define htobs(d)  (d)
diff --git a/src/shared/util.c b/src/shared/util.c
index fa058170e..c2cf2bf72 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -1677,8 +1677,6 @@ static const struct {
 	{ "a6695ace-ee7f-4fb9-881a-5fac66c629af", "BlueZ Offload Codecs"},
 	{ "6fbaf188-05e0-496a-9885-d6ddfdb4e03e",
 		"BlueZ Experimental ISO Socket"},
-	{ "69518c4c-b69f-4679-8bc1-c021b47b5733",
-		"BlueZ Experimental Poll Errqueue"},
 	{ }
 };
 
diff --git a/tools/iso-tester.c b/tools/iso-tester.c
index 56550882e..2c674171d 100644
--- a/tools/iso-tester.c
+++ b/tools/iso-tester.c
@@ -515,9 +515,6 @@ struct iso_client_data {
 	 * Used for testing TX timestamping OPT_ID.
 	 */
 	unsigned int repeat_send;
-
-	/* Disable BT_POLL_ERRQUEUE before enabling TX timestamping */
-	bool no_poll_errqueue;
 };
 
 typedef bool (*iso_defer_accept_t)(struct test_data *data, GIOChannel *io,
@@ -654,18 +651,6 @@ static const uint8_t reset_iso_socket_param[] = {
 	0x00,						/* Action - disable */
 };
 
-static const uint8_t set_poll_errqueue_param[] = {
-	0x33, 0x57, 0x7b, 0xb4, 0x21, 0xc0, 0xc1, 0x8b, /* UUID */
-	0x79, 0x46, 0x9f, 0xb6, 0x4c, 0x8c, 0x51, 0x69,
-	0x01,						/* Action - enable */
-};
-
-static const uint8_t reset_poll_errqueue_param[] = {
-	0x33, 0x57, 0x7b, 0xb4, 0x21, 0xc0, 0xc1, 0x8b, /* UUID */
-	0x79, 0x46, 0x9f, 0xb6, 0x4c, 0x8c, 0x51, 0x69,
-	0x00,						/* Action - disable */
-};
-
 static void set_iso_socket_callback(uint8_t status, uint16_t length,
 					const void *param, void *user_data)
 {
@@ -677,26 +662,9 @@ static void set_iso_socket_callback(uint8_t status, uint16_t length,
 	tester_print("ISO socket feature is enabled");
 }
 
-static void set_poll_errqueue_callback(uint8_t status, uint16_t length,
-					const void *param, void *user_data)
-{
-	if (status != MGMT_STATUS_SUCCESS) {
-		tester_print("Poll Errqueue feature could not be enabled");
-		return;
-	}
-
-	tester_print("Poll Errqueue feature is enabled");
-}
-
 static void test_pre_setup(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
-	const struct iso_client_data *isodata = test_data;
-
-	if (isodata && isodata->no_poll_errqueue) {
-		if (tester_pre_setup_skip_by_default())
-			return;
-	}
 
 	data->mgmt = mgmt_new_default();
 	if (!data->mgmt) {
@@ -712,13 +680,6 @@ static void test_pre_setup(const void *test_data)
 		  sizeof(set_iso_socket_param), set_iso_socket_param,
 		  set_iso_socket_callback, NULL, NULL);
 
-	if (isodata && isodata->no_poll_errqueue) {
-		mgmt_send(data->mgmt, MGMT_OP_SET_EXP_FEATURE, MGMT_INDEX_NONE,
-			  sizeof(set_poll_errqueue_param),
-			  set_poll_errqueue_param,
-			  set_poll_errqueue_callback, NULL, NULL);
-	}
-
 	mgmt_send(data->mgmt, MGMT_OP_READ_INDEX_LIST, MGMT_INDEX_NONE, 0, NULL,
 					read_index_list_callback, NULL, NULL);
 }
@@ -726,19 +687,11 @@ static void test_pre_setup(const void *test_data)
 static void test_post_teardown(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
-	const struct iso_client_data *isodata = test_data;
 
 	mgmt_send(data->mgmt, MGMT_OP_SET_EXP_FEATURE, MGMT_INDEX_NONE,
 		  sizeof(reset_iso_socket_param), reset_iso_socket_param,
 		  NULL, NULL, NULL);
 
-	if (isodata && isodata->no_poll_errqueue) {
-		mgmt_send(data->mgmt, MGMT_OP_SET_EXP_FEATURE, MGMT_INDEX_NONE,
-			  sizeof(reset_poll_errqueue_param),
-			  reset_poll_errqueue_param,
-			  NULL, NULL, NULL);
-	}
-
 	hciemu_unref(data->hciemu);
 	data->hciemu = NULL;
 }
@@ -1085,16 +1038,6 @@ static const struct iso_client_data connect_send_tx_cmsg_timestamping = {
 	.cmsg_timestamping = true,
 };
 
-static const struct iso_client_data connect_send_tx_no_poll_timestamping = {
-	.qos = QOS_16_2_1,
-	.expect_err = 0,
-	.send = &send_16_2_1,
-	.so_timestamping = (SOF_TIMESTAMPING_SOFTWARE |
-					SOF_TIMESTAMPING_TX_COMPLETION),
-	.repeat_send = 1,
-	.no_poll_errqueue = true,
-};
-
 static const struct iso_client_data listen_16_2_1_recv = {
 	.qos = QOS_16_2_1,
 	.expect_err = 0,
@@ -2319,37 +2262,6 @@ static gboolean iso_recv_errqueue(GIOChannel *io, GIOCondition cond,
 	return FALSE;
 }
 
-static gboolean iso_fail_errqueue(GIOChannel *io, GIOCondition cond,
-							gpointer user_data)
-{
-	struct test_data *data = user_data;
-
-	tester_warn("Unexpected POLLERR");
-	tester_test_failed();
-
-	data->io_id[3] = 0;
-	return FALSE;
-}
-
-static gboolean iso_timer_errqueue(gpointer user_data)
-{
-	struct test_data *data = user_data;
-	GIOChannel *io;
-	gboolean ret;
-
-	io = queue_peek_head(data->io_queue);
-	g_assert(io);
-
-	ret = iso_recv_errqueue(io, G_IO_IN, data);
-	if (!ret) {
-		if (data->io_id[3])
-			g_source_remove(data->io_id[3]);
-		data->io_id[3] = 0;
-	}
-
-	return ret;
-}
-
 static void iso_tx_timestamping(struct test_data *data, GIOChannel *io)
 {
 	const struct iso_client_data *isodata = data->test_data;
@@ -2370,39 +2282,7 @@ static void iso_tx_timestamping(struct test_data *data, GIOChannel *io)
 
 	sk = g_io_channel_unix_get_fd(io);
 
-	if (isodata->no_poll_errqueue) {
-		uint32_t flag = 0;
-
-		err = setsockopt(sk, SOL_BLUETOOTH, BT_POLL_ERRQUEUE,
-							&flag, sizeof(flag));
-		if (err < 0) {
-			tester_warn("setsockopt BT_POLL_ERRQUEUE: %s (%d)",
-						strerror(errno), errno);
-			tester_test_failed();
-			return;
-		}
-
-		if (!data->io_queue)
-			data->io_queue = queue_new();
-		queue_push_head(data->io_queue, g_io_channel_ref(io));
-
-		data->io_id[2] = g_timeout_add(100, iso_timer_errqueue, data);
-		data->io_id[3] = g_io_add_watch(io, G_IO_ERR, iso_fail_errqueue,
-									data);
-	} else {
-		uint32_t flag = 1;
-
-		err = setsockopt(sk, SOL_BLUETOOTH, BT_POLL_ERRQUEUE,
-							&flag, sizeof(flag));
-		if (err >= 0) {
-			tester_warn("BT_POLL_ERRQUEUE available");
-			tester_test_failed();
-			return;
-		}
-
-		data->io_id[2] = g_io_add_watch(io, G_IO_ERR, iso_recv_errqueue,
-									data);
-	}
+	data->io_id[2] = g_io_add_watch(io, G_IO_ERR, iso_recv_errqueue, data);
 
 	if (isodata->cmsg_timestamping)
 		so &= ~TS_TX_RECORD_MASK;
@@ -3763,11 +3643,6 @@ int main(int argc, char *argv[])
 			&connect_send_tx_cmsg_timestamping, setup_powered,
 			test_connect);
 
-	/* Test TX timestamping and disabling POLLERR wakeup */
-	test_iso("ISO Send - TX No Poll Timestamping",
-			&connect_send_tx_no_poll_timestamping, setup_powered,
-			test_connect);
-
 	test_iso("ISO Receive - Success", &listen_16_2_1_recv, setup_powered,
 							test_listen);
 
-- 
2.50.1


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

* [PATCH BlueZ v2.. 2/3] lib: add BT_PKT_SEQNUM and BT_SCM_PKT_SEQNUM
  2025-07-14 16:44 [PATCH BlueZ v2.. 1/3] lib: tools: remove POLL_ERRQUEUE Pauli Virtanen
@ 2025-07-14 16:44 ` Pauli Virtanen
  2025-07-14 16:44 ` [PATCH BlueZ v2.. 3/3] iso-tester: add tests for BT_PKT_SEQNUM Pauli Virtanen
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Pauli Virtanen @ 2025-07-14 16:44 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Pauli Virtanen

Socket options and CMSG identifier for ISO packet sequence numbers.
---
 lib/bluetooth.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/bluetooth.h b/lib/bluetooth.h
index 150679d72..88a5d8b66 100644
--- a/lib/bluetooth.h
+++ b/lib/bluetooth.h
@@ -253,6 +253,10 @@ enum {
 
 #define BT_ISO_BASE		20
 
+#define BT_PKT_SEQNUM		22
+
+#define BT_SCM_PKT_SEQNUM	0x05
+
 /* Byte order conversions */
 #if __BYTE_ORDER == __LITTLE_ENDIAN
 #define htobs(d)  (d)
-- 
2.50.1


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

* [PATCH BlueZ v2.. 3/3] iso-tester: add tests for BT_PKT_SEQNUM
  2025-07-14 16:44 [PATCH BlueZ v2.. 1/3] lib: tools: remove POLL_ERRQUEUE Pauli Virtanen
  2025-07-14 16:44 ` [PATCH BlueZ v2.. 2/3] lib: add BT_PKT_SEQNUM and BT_SCM_PKT_SEQNUM Pauli Virtanen
@ 2025-07-14 16:44 ` Pauli Virtanen
  2025-07-14 18:14 ` [BlueZ,v2..,1/3] lib: tools: remove POLL_ERRQUEUE bluez.test.bot
  2025-07-14 21:00 ` [PATCH BlueZ v2.. 1/3] " patchwork-bot+bluetooth
  3 siblings, 0 replies; 5+ messages in thread
From: Pauli Virtanen @ 2025-07-14 16:44 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Pauli Virtanen

Add test

ISO Receive Packet Seqnum - Success
---
 tools/iso-tester.c | 80 ++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 78 insertions(+), 2 deletions(-)

diff --git a/tools/iso-tester.c b/tools/iso-tester.c
index 2c674171d..6aefb5196 100644
--- a/tools/iso-tester.c
+++ b/tools/iso-tester.c
@@ -477,6 +477,7 @@ struct test_data {
 	bool reconnect;
 	bool suspending;
 	struct tx_tstamp_data tx_ts;
+	int seqnum;
 };
 
 struct iso_client_data {
@@ -500,6 +501,9 @@ struct iso_client_data {
 	bool pa_bind;
 	bool big;
 
+	/* Enable BT_PKT_SEQNUM for RX packet sequence numbers */
+	bool pkt_seqnum;
+
 	/* Enable SO_TIMESTAMPING with these flags */
 	uint32_t so_timestamping;
 
@@ -1061,6 +1065,14 @@ static const struct iso_client_data listen_16_2_1_recv_pkt_status = {
 	.pkt_status = 0x02,
 };
 
+static const struct iso_client_data listen_16_2_1_recv_pkt_seqnum = {
+	.qos = QOS_16_2_1,
+	.expect_err = 0,
+	.recv = &send_16_2_1,
+	.server = true,
+	.pkt_seqnum = true,
+};
+
 static const struct iso_client_data listen_16_2_1_recv_rx_timestamping = {
 	.qos = QOS_16_2_1,
 	.expect_err = 0,
@@ -2204,11 +2216,51 @@ static gboolean iso_recv_data(GIOChannel *io, GIOCondition cond,
 		return FALSE;
 	}
 
+	if (isodata->pkt_seqnum) {
+		struct cmsghdr *cmsg;
+		uint16_t pkt_seqnum = 0;
+
+		for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL;
+					cmsg = CMSG_NXTHDR(&msg, cmsg)) {
+			if (cmsg->cmsg_level != SOL_BLUETOOTH)
+				continue;
+
+			if (cmsg->cmsg_type == BT_SCM_PKT_SEQNUM) {
+				memcpy(&pkt_seqnum, CMSG_DATA(cmsg),
+						sizeof(pkt_seqnum));
+				tester_debug("BT_SCM_PKT_SEQNUM = 0x%2.2x",
+							pkt_seqnum);
+				break;
+			}
+		}
+
+		if (data->seqnum < 0)
+			data->seqnum = pkt_seqnum;
+		else
+			data->seqnum++;
+
+		if (pkt_seqnum != data->seqnum) {
+			tester_warn("isodata->pkt_seqnum 0x%2.2x != 0x%2.2x "
+					"pkt_seqnum", pkt_seqnum, data->seqnum);
+			tester_test_failed();
+			return FALSE;
+		}
+	}
+
 	if (isodata->so_timestamping & SOF_TIMESTAMPING_RX_SOFTWARE)
 		rx_timestamp_check(&msg);
 
+	if (data->step) {
+		data->step--;
+	} else {
+		tester_test_failed();
+		return FALSE;
+	}
+
 	if (memcmp(buf, isodata->recv->iov_base, ret))
 		tester_test_failed();
+	else if (data->step)
+		return TRUE;
 	else
 		tester_test_passed();
 
@@ -2220,6 +2272,7 @@ static void iso_recv(struct test_data *data, GIOChannel *io)
 	const struct iso_client_data *isodata = data->test_data;
 	struct bthost *host;
 	static uint16_t sn;
+	int j, count;
 
 	tester_print("Receive %zu bytes of data", isodata->recv->iov_len);
 
@@ -2234,8 +2287,13 @@ static void iso_recv(struct test_data *data, GIOChannel *io)
 		return;
 
 	host = hciemu_client_get_host(data->hciemu);
-	bthost_send_iso(host, data->handle, isodata->ts, sn++, 0,
-				isodata->pkt_status, isodata->recv, 1);
+
+	count = isodata->pkt_seqnum ? 2 : 1;
+	for (j = 0; j < count; ++j) {
+		bthost_send_iso(host, data->handle, isodata->ts, sn++, 0,
+					isodata->pkt_status, isodata->recv, 1);
+		data->step++;
+	}
 
 	data->io_id[0] = g_io_add_watch(io, G_IO_IN, iso_recv_data, data);
 }
@@ -3093,6 +3151,20 @@ static gboolean iso_accept(GIOChannel *io, GIOCondition cond,
 		}
 	}
 
+	if (isodata->pkt_seqnum) {
+		int opt = 1;
+
+		data->seqnum = -1;
+
+		if (setsockopt(new_sk, SOL_BLUETOOTH, BT_PKT_SEQNUM, &opt,
+							sizeof(opt)) < 0) {
+			tester_print("Can't set socket BT_PKT_SEQNUM option: "
+					"%s (%d)", strerror(errno), errno);
+			tester_test_failed();
+			return false;
+		}
+	}
+
 	ret = iso_connect(new_io, cond, user_data);
 
 	g_io_channel_unref(new_io);
@@ -3654,6 +3726,10 @@ int main(int argc, char *argv[])
 						&listen_16_2_1_recv_pkt_status,
 						setup_powered, test_listen);
 
+	test_iso("ISO Receive Packet Seqnum - Success",
+						&listen_16_2_1_recv_pkt_seqnum,
+						setup_powered, test_listen);
+
 	test_iso("ISO Receive - RX Timestamping",
 					&listen_16_2_1_recv_rx_timestamping,
 					setup_powered, test_listen);
-- 
2.50.1


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

* RE: [BlueZ,v2..,1/3] lib: tools: remove POLL_ERRQUEUE
  2025-07-14 16:44 [PATCH BlueZ v2.. 1/3] lib: tools: remove POLL_ERRQUEUE Pauli Virtanen
  2025-07-14 16:44 ` [PATCH BlueZ v2.. 2/3] lib: add BT_PKT_SEQNUM and BT_SCM_PKT_SEQNUM Pauli Virtanen
  2025-07-14 16:44 ` [PATCH BlueZ v2.. 3/3] iso-tester: add tests for BT_PKT_SEQNUM Pauli Virtanen
@ 2025-07-14 18:14 ` bluez.test.bot
  2025-07-14 21:00 ` [PATCH BlueZ v2.. 1/3] " patchwork-bot+bluetooth
  3 siblings, 0 replies; 5+ messages in thread
From: bluez.test.bot @ 2025-07-14 18:14 UTC (permalink / raw)
  To: linux-bluetooth, pav

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

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

---Test result---

Test Summary:
CheckPatch                    PENDING   0.34 seconds
GitLint                       PENDING   0.28 seconds
BuildEll                      PASS      20.47 seconds
BluezMake                     PASS      2663.57 seconds
MakeCheck                     PASS      20.16 seconds
MakeDistcheck                 PASS      186.55 seconds
CheckValgrind                 PASS      235.33 seconds
CheckSmatch                   PASS      308.40 seconds
bluezmakeextell               PASS      129.17 seconds
IncrementalBuild              PENDING   0.22 seconds
ScanBuild                     PASS      932.27 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth


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

* Re: [PATCH BlueZ v2.. 1/3] lib: tools: remove POLL_ERRQUEUE
  2025-07-14 16:44 [PATCH BlueZ v2.. 1/3] lib: tools: remove POLL_ERRQUEUE Pauli Virtanen
                   ` (2 preceding siblings ...)
  2025-07-14 18:14 ` [BlueZ,v2..,1/3] lib: tools: remove POLL_ERRQUEUE bluez.test.bot
@ 2025-07-14 21:00 ` patchwork-bot+bluetooth
  3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+bluetooth @ 2025-07-14 21:00 UTC (permalink / raw)
  To: Pauli Virtanen; +Cc: linux-bluetooth

Hello:

This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Mon, 14 Jul 2025 19:44:48 +0300 you wrote:
> This experimental feature did not land to mainline kernel, and probably
> would need to be done differently.
> 
> Remove defines and tests for it.
> ---
>  lib/bluetooth.h    |   2 -
>  src/shared/util.c  |   2 -
>  tools/iso-tester.c | 127 +--------------------------------------------
>  3 files changed, 1 insertion(+), 130 deletions(-)

Here is the summary with links:
  - [BlueZ,v2..,1/3] lib: tools: remove POLL_ERRQUEUE
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=db061936394d
  - [BlueZ,v2..,2/3] lib: add BT_PKT_SEQNUM and BT_SCM_PKT_SEQNUM
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=9e117ebee13f
  - [BlueZ,v2..,3/3] iso-tester: add tests for BT_PKT_SEQNUM
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=b0a1386f98c2

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2025-07-14 20:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-14 16:44 [PATCH BlueZ v2.. 1/3] lib: tools: remove POLL_ERRQUEUE Pauli Virtanen
2025-07-14 16:44 ` [PATCH BlueZ v2.. 2/3] lib: add BT_PKT_SEQNUM and BT_SCM_PKT_SEQNUM Pauli Virtanen
2025-07-14 16:44 ` [PATCH BlueZ v2.. 3/3] iso-tester: add tests for BT_PKT_SEQNUM Pauli Virtanen
2025-07-14 18:14 ` [BlueZ,v2..,1/3] lib: tools: remove POLL_ERRQUEUE bluez.test.bot
2025-07-14 21:00 ` [PATCH BlueZ v2.. 1/3] " patchwork-bot+bluetooth

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.