diff mbox series

[BlueZ,4/4] avdtp: Enable MTU auto tunning

Message ID 20200219003612.14599-4-luiz.dentz@gmail.com (mailing list archive)
State Accepted
Delegated to: Luiz Von Dentz
Headers show
Series [BlueZ,1/4] lib: Add definition to BT_PHY | expand

Commit Message

Luiz Augusto von Dentz Feb. 19, 2020, 12:36 a.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This uses BT_PHY to check if kernel is able to do MTU auto tunning
which is enabled by forcing the input MTU to 0.
---
 profiles/audio/avdtp.c | 32 ++++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index f42f21bbb..0e075f9ff 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -401,6 +401,7 @@  struct avdtp {
 
 	struct avdtp_stream *pending_open;
 
+	uint32_t phy;
 	uint16_t imtu;
 	uint16_t omtu;
 
@@ -2291,6 +2292,9 @@  static void avdtp_connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
 	if (!session->io)
 		session->io = g_io_channel_ref(chan);
 
+	/* Check if kernel supports reading packet types */
+	bt_io_get(chan, NULL, BT_IO_OPT_PHY, &session->phy, BT_IO_OPT_INVALID);
+
 	bt_io_get(chan, &err,
 			BT_IO_OPT_OMTU, &session->omtu,
 			BT_IO_OPT_IMTU, &session->imtu,
@@ -2399,14 +2403,26 @@  static GIOChannel *l2cap_connect(struct avdtp *session)
 
 	src = btd_adapter_get_address(device_get_adapter(session->device));
 
-	io = bt_io_connect(avdtp_connect_cb, session,
-				NULL, &err,
-				BT_IO_OPT_SOURCE_BDADDR, src,
-				BT_IO_OPT_DEST_BDADDR,
-				device_get_address(session->device),
-				BT_IO_OPT_PSM, AVDTP_PSM,
-				BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_MEDIUM,
-				BT_IO_OPT_INVALID);
+	if (session->phy)
+		io = bt_io_connect(avdtp_connect_cb, session,
+					NULL, &err,
+					BT_IO_OPT_SOURCE_BDADDR, src,
+					BT_IO_OPT_DEST_BDADDR,
+					device_get_address(session->device),
+					BT_IO_OPT_PSM, AVDTP_PSM,
+					BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_MEDIUM,
+					/* Set Input MTU to 0 to auto-tune */
+					BT_IO_OPT_IMTU, 0,
+					BT_IO_OPT_INVALID);
+	else
+		io = bt_io_connect(avdtp_connect_cb, session,
+					NULL, &err,
+					BT_IO_OPT_SOURCE_BDADDR, src,
+					BT_IO_OPT_DEST_BDADDR,
+					device_get_address(session->device),
+					BT_IO_OPT_PSM, AVDTP_PSM,
+					BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_MEDIUM,
+					BT_IO_OPT_INVALID);
 	if (!io) {
 		error("%s", err->message);
 		g_error_free(err);