diff mbox series

[BlueZ,3/5] hciemu: set bthost ACL MTU to match btdev

Message ID 258a6c7a911bd864ad15e81bd7155ddf47a1fa6f.1745750626.git.pav@iki.fi
State New
Headers show
Series [BlueZ,1/5] tools: add tests for RX timestamping | expand

Commit Message

Pauli Virtanen April 27, 2025, 10:44 a.m. UTC
Set the bthost ACL MTU to avoid generating larger packets than the btdev
ACL MTU.

This tests RX timestamping on ACL fragmentation.
---
 emulator/btdev.c  | 11 +++++++++++
 emulator/btdev.h  |  3 +++
 emulator/hciemu.c |  4 ++++
 3 files changed, 18 insertions(+)
diff mbox series

Patch

diff --git a/emulator/btdev.c b/emulator/btdev.c
index 76bae5ea1..cf5c36bb4 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
@@ -7460,6 +7460,17 @@  const uint8_t *btdev_get_adv_addr(struct btdev *btdev, uint8_t handle)
 	return ext_adv_addr(btdev, ext_adv);
 }
 
+void btdev_get_mtu(struct btdev *btdev, uint16_t *acl, uint16_t *sco,
+								uint16_t *iso)
+{
+	if (acl)
+		*acl = btdev->acl_mtu;
+	if (sco)
+		*acl = btdev->sco_mtu;
+	if (iso)
+		*iso = btdev->iso_mtu;
+}
+
 void btdev_set_le_states(struct btdev *btdev, const uint8_t *le_states)
 {
 	memcpy(btdev->le_states, le_states, sizeof(btdev->le_states));
diff --git a/emulator/btdev.h b/emulator/btdev.h
index a96c1a325..c7b3b468a 100644
--- a/emulator/btdev.h
+++ b/emulator/btdev.h
@@ -84,6 +84,9 @@  uint8_t btdev_get_le_scan_enable(struct btdev *btdev);
 
 const uint8_t *btdev_get_adv_addr(struct btdev *btdev, uint8_t handle);
 
+void btdev_get_mtu(struct btdev *btdev, uint16_t *acl, uint16_t *sco,
+								uint16_t *iso);
+
 void btdev_set_le_states(struct btdev *btdev, const uint8_t *le_states);
 
 void btdev_set_al_len(struct btdev *btdev, uint8_t len);
diff --git a/emulator/hciemu.c b/emulator/hciemu.c
index ccc57aada..8529caae8 100644
--- a/emulator/hciemu.c
+++ b/emulator/hciemu.c
@@ -308,6 +308,7 @@  static struct hciemu_client *hciemu_client_new(struct hciemu *hciemu,
 {
 	struct hciemu_client *client;
 	int sv[2];
+	uint16_t mtu;
 
 	client = new0(struct hciemu_client, 1);
 	if (!client)
@@ -342,6 +343,9 @@  static struct hciemu_client *hciemu_client_new(struct hciemu *hciemu,
 	client->host_source = create_source_bthost(sv[1], client->host);
 	client->start_source = g_idle_add(start_host, client);
 
+	btdev_get_mtu(client->dev, &mtu, NULL, NULL);
+	bthost_set_acl_mtu(client->host, mtu);
+
 	return client;
 }