Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH BlueZ v2 0/3] l2test: Several ECFC channels and sends on demand
@ 2026-12-01 19:52 Simon Mikuda
  2026-12-01 19:52 ` [PATCH BlueZ v2 1/3] l2test: Size frames to the channel's current MTU Simon Mikuda
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Simon Mikuda @ 2026-12-01 19:52 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Simon Mikuda

These let l2test drive the PTS L2CAP/ECFC cases that need several
channels in one request, or data sent after the tester reconfigured the
channel, which a single l2test channel with a fixed frame size cannot.

Changes in v2:
- l2test -k: the group's other channels are kept and closed with it
  (reconnect mode, a failed connect, the listener once the child has the
  group); each accepted group runs the mode on its last channel; -k
  takes 1 to 5
- l2test without -b: the send buffer grows with BT_SNDMTU instead of
  capping frames at the size at connection time

Simon Mikuda (3):
  l2test: Size frames to the channel's current MTU
  l2test: Add -j to send a burst for each line on stdin
  l2test: Add -k to open several enhanced credit based channels

 tools/l2test.c | 141 ++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 135 insertions(+), 6 deletions(-)


base-commit: eecfd959cf5ae9a24ee007975439747779804be1
-- 
2.43.0


^ permalink raw reply	[flat|nested] 7+ messages in thread
* [PATCH BlueZ 1/3] l2test: Size frames to the channel's current MTU
@ 2026-11-27 12:27 Simon Mikuda
  2026-11-27 15:47 ` l2test: Several ECFC channels and sends on demand bluez.test.bot
  0 siblings, 1 reply; 7+ messages in thread
From: Simon Mikuda @ 2026-11-27 12:27 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Simon Mikuda

Without -b, a frame was as large as the output MTU at connection time.
An enhanced credit based channel can be reconfigured to a larger MTU
later, so each frame is now as large as BT_SNDMTU says when it is sent.

Assisted-by: Claude:claude-opus-5-5
---
 tools/l2test.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/tools/l2test.c b/tools/l2test.c
index d7a52fe0d..dbfeae50a 100644
--- a/tools/l2test.c
+++ b/tools/l2test.c
@@ -1059,8 +1059,24 @@ static void recv_mode(int sk)
 	}
 }
 
+/* The channel's MTU now: the peer may have reconfigured it since connection
+ * (enhanced credit based mode).
+ */
+static int current_omtu(int sk)
+{
+	uint16_t mtu;
+	socklen_t len = sizeof(mtu);
+
+	if (getsockopt(sk, SOL_BLUETOOTH, BT_SNDMTU, &mtu, &len) < 0 || !mtu)
+		return omtu;
+
+	return mtu > buffer_size ? buffer_size : mtu;
+}
+
 static void do_send(int sk)
 {
+	/* Without -b each frame is as large as the channel's MTU */
+	bool follow_mtu = data_size < 0;
 	uint32_t seq;
 	int i, fd, len, buflen, size, sent;
 
@@ -1096,7 +1112,7 @@ static void do_send(int sk)
 		close(fd);
 		return;
 	} else {
-		for (i = 6; i < data_size; i++)
+		for (i = 6; i < buffer_size; i++)
 			buf[i] = 0x7f;
 	}
 
@@ -1105,6 +1121,9 @@ static void do_send(int sk)
 
 	seq = seq_start;
 	while ((num_frames == -1) || (num_frames-- > 0)) {
+		if (follow_mtu)
+			data_size = omtu = current_omtu(sk);
+
 		put_le32(seq, buf);
 		put_le16(data_size, buf + 4);
 
-- 
2.43.0


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

end of thread, other threads:[~2026-12-02 10:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 19:52 [PATCH BlueZ v2 0/3] l2test: Several ECFC channels and sends on demand Simon Mikuda
2026-12-01 19:52 ` [PATCH BlueZ v2 1/3] l2test: Size frames to the channel's current MTU Simon Mikuda
2026-12-02 10:06   ` l2test: Several ECFC channels and sends on demand bluez.test.bot
2026-12-01 19:52 ` [PATCH BlueZ v2 2/3] l2test: Add -j to send a burst for each line on stdin Simon Mikuda
2026-12-01 19:52 ` [PATCH BlueZ v2 3/3] l2test: Add -k to open several enhanced credit based channels Simon Mikuda
  -- strict thread matches above, loose matches on Subject: below --
2026-11-27 12:27 [PATCH BlueZ 1/3] l2test: Size frames to the channel's current MTU Simon Mikuda
2026-11-27 15:47 ` l2test: Several ECFC channels and sends on demand bluez.test.bot
2026-12-01 15:39   ` Luiz Augusto von Dentz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox