Linux bluetooth development
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 4/4] avdtp: Enable MTU auto tunning
Date: Tue, 18 Feb 2020 16:36:12 -0800	[thread overview]
Message-ID: <20200219003612.14599-4-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20200219003612.14599-1-luiz.dentz@gmail.com>

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 --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);
-- 
2.21.1


  parent reply	other threads:[~2020-02-19  0:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-19  0:36 [PATCH BlueZ 1/4] lib: Add definition to BT_PHY Luiz Augusto von Dentz
2020-02-19  0:36 ` [PATCH BlueZ 2/4] btio: Add BT_IO_PHY option Luiz Augusto von Dentz
2020-02-19  0:36 ` [PATCH BlueZ 3/4] l2test: Add support to BT_PHY Luiz Augusto von Dentz
2020-02-19  0:36 ` Luiz Augusto von Dentz [this message]
2020-02-19 21:55 ` [PATCH BlueZ 1/4] lib: Add definition " Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200219003612.14599-4-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox