Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp236871ybl; Thu, 30 Jan 2020 21:08:39 -0800 (PST) X-Google-Smtp-Source: APXvYqzp255eYp+T83f47pfYszhUVoQ8GegTkP+iF+475zHpzKM6519XKSOCIkUyZH5Xarun5Ma4 X-Received: by 2002:a9d:6510:: with SMTP id i16mr6040939otl.142.1580447319033; Thu, 30 Jan 2020 21:08:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580447319; cv=none; d=google.com; s=arc-20160816; b=iGfDFW5Wq561a1paq9tdgBrIF4O9EOMupSIhFMr6JSrSAWjQy0+2ZBooyJBG8ivak5 S2PDBvXDYFQPAPjf2rJ6lI33LWMhGUPlU879BQM1YLmArjk7m3FbcqPwSZ5qF5HyxPBr ykNH6SnzD9tM4HSQGysRJtnJRDtuYKKKCFI3XjU+D1TIk4FitIvMJ2/DsHYdZ5rLN9lE sziMXpo3sFkmGrCQusGzMwSJh30sQ2iWucxFB02pthS20LMPRmiTZOdfimfTNEiBCFG/ PfiCCeHPq8XbvV8WCfLF0SzI5jAZDFYaicroIKxU0IFtk7TA8oWru67FgVBt/4TTwD0i aZKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=owFpUSGzMLt+ilIrhwEvul+H64pU1vs/nJcrZ/5Y6oc=; b=HQeJ7RxEe1nxJe2v3cjSdlcNWtgvyJlumtLpht/ov4cPtfF1UBnaKCoDvmBvx1V0Yu Lw0WfamAhuPlo7uySEznxDbLr73kXBap+9vR5F+6RyRr+AKpw/n9jpxeBMDlxmZVwKcr Tq+SDtpByKbID5x1Vt7vkOOuc40vlpSfRLb38CkQcFkbC1cOoqj+qDlP9EbuAYzD+Qgp uXb2TVmEhWs/abrTjS+7KQm0mOjtR+eCq8+1a/glk9HmHJQ3NmPWKrThyu29sPUR5BeA LvXVORF5J36dNBCfiOmY/x64X5pWDqzVFvgLyKODDmG+ENqswulkxvBvPqhq9rJD+eEB XgtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dpP6bbiF; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s143si2467714oih.251.2020.01.30.21.08.10; Thu, 30 Jan 2020 21:08:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dpP6bbiF; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726109AbgAaFHl (ORCPT + 99 others); Fri, 31 Jan 2020 00:07:41 -0500 Received: from mail-io1-f68.google.com ([209.85.166.68]:46874 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725263AbgAaFHl (ORCPT ); Fri, 31 Jan 2020 00:07:41 -0500 Received: by mail-io1-f68.google.com with SMTP id t26so6730672ioi.13 for ; Thu, 30 Jan 2020 21:07:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=owFpUSGzMLt+ilIrhwEvul+H64pU1vs/nJcrZ/5Y6oc=; b=dpP6bbiFOmMWOcsM1lWQbPmH8B+/2WDWKxsnvZUwyYBEbVKeom9eT+ZZFUVa4jqzJ6 WPKNC5pPBX45so2Qrp7lpbK/dyz5gJ/omjUN8Gi0khpEkoxr3CbZofocoy1UEKF9Hgd+ hZOD/AR1m+GTWMPXtRx6MfKIXp3/FaCXFm5q0yyatsej4kTrhJdvL70669N6IWr1RxUz hINHg48XuXbPJxXkBw9EZz51CjAqRTzlBzRW/DR9CnnrJcg0HyRLMNgJfTZVxDA5bQt2 0O4yPdyUxrZNtuMJsKpcx84cSV81SfU3b95rXRz5NIsxkv+7scn6ULcPUbYZNoxV1ZW0 Ge4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=owFpUSGzMLt+ilIrhwEvul+H64pU1vs/nJcrZ/5Y6oc=; b=GVt1uU1FXjC6Oxz4hOtQUnG8P3gcDGFk0ihvOAM9zONjKBJy+nFsKTkX4RIQnEsIHH 3vG30KPDUUQqm0AwuYyJ8chl6hJQiUpMytGbOw3vWNZBhre8fvZrXLXeV1tysw0OlKX3 XDeeLIH/XQBB+9+JjxhPMxe0sTmyduyB/SzZCLTcoUnx9i+jG0H9dZX/6y8qwxm/OIVS 4ahfXK2DSmdjbcPUuGx/lozXIav5F8mRnW6TugrJcLIFK7ZiavOk0jA1AyqfTyjG6PdG zjn++XwaVFeFSW7Jv/S66LZxOXc1fF2rlblrP+RWcCOb2pCiWFbbTH6u5ZgXO5nEHxgx z+iw== X-Gm-Message-State: APjAAAWgtwFS514xXyaOIePu+rCyWDpxuJUsZagBRWvgoUiCvgdH2oIy +QZaK+2sshkm9xPdP8TcwwJCj9nzDNrItFND799S2Kg9 X-Received: by 2002:a6b:dc09:: with SMTP id s9mr6756238ioc.185.1580447260239; Thu, 30 Jan 2020 21:07:40 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Sathish Narasimman Date: Fri, 31 Jan 2020 10:37:29 +0530 Message-ID: Subject: Re: L2CAP mtu preference set by user space clarification To: Luiz Augusto von Dentz Cc: chethan tn , Bluez mailing list , Chethan T N , Sathish Narasimman Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Luiz Thanks for the suggestion. On Fri, Jan 31, 2020 at 12:42 AM Luiz Augusto von Dentz wrote: > > Hi Sathish, > > On Mon, Jan 27, 2020 at 11:02 PM Sathish Narasimman > wrote: > > > > Hi Luiz, > > > > There are some headsets that configure the MTU to 850(3M PHY) and then > > under some situation(noisy), it switches to 2M PHY packets for A2DP > > playback. The reason behind this is their receiver's capability for > > better demodulation with QDPSK(2M PHY) when compared to 8DPSK(3M PHY). > > > > From Bluetooth specification, the remote device can request the > > LMP_preferred_rate with the LMP command to switch to 2M. When Baseband > > PHY is 2M, the maximum possible packet type is 2DH5 which can hold > > 679 bytes ( 672 bytes of L2CAP MTU excluding the baseband headers). > > > > When L2CAP MTU for an A2DP packet is larger than 672 bytes, it happens > > to use 2 Baseband packets to deliver the L2CAP packet ie., like 1 > > 2DH5(679 bytes) and 1 2DH3(171 bytes) packet to deliver 850 bytes of > > AVDTP Media. The is not efficient baseband utilization when the number > > of baseband ACL buffers used 2 no.s or even less that may lead to the > > delivery of one L2CAP packet that may take 4 slots more ( 2.5 ms > > more). > > > > When the remote device ( headset) has less number of baseband ACL > > buffers and Host(source) is aggressively delivering the audio data to > > render, it shall end up in a condition where the remote device does > > Flow OFF that shall make the Source device to wait until next FLOW ON > > send from the headset device. This kind of situation shall end up > > accumulating more buffers and FLOW ON/OFF become cyclic and leads to > > an audio break. > > > > Is there a better solution to overcome this issue? > > > > We considered changing the HOST MTU to 672bytes to overcome this issue > > that makes the remote headset device to use 2M. And found that the > > test results are positive. > > But we only control the RX/input MTU not the TX/output MTU, so the > headset is at fault here it should have reconfigured the MTU > accordingly. For the RX/input there is a patch already adjusting the > MTU automatically when the socket MTU is set to 0: > > commit 4b6e228e297b73451f3a4b12fb7d0b24d9d32e6f > Author: Luiz Augusto von Dentz > Date: Thu Jan 2 15:00:57 2020 -0800 > > Bluetooth: Auto tune if input MTU is set to 0 > > This enables the code to set the input MTU using the underline link > packet types when set to 0, previously this would likely be rejected by > the remote peer since it would be bellow the minimal of 48 for BR/EDR > or 23 for LE, that way it shall be safe to use 0 without causing any > side effects. > > This is convenient for the likes of A2DP transport, see: > > https://habr.com/en/post/456182/ > > Without the remote side updating the MTU the host has no idea of the > changes to the packet type, also we would have to notify the upper > layer of the change if that happens mid stream, this relation between > packet type is not very clear to the L2CAP layer since it doesn't > distinct what data the upper layer is sending so we cannot just do the > MTU change locally and limit the output MTU based on the underline > link, expect perhaps if we would be willing to do that when MTU is set > to 0 in which we would artificially limit the packet length based on > the supported packet types, but does the controller notifies this sort > of change to the host at all? > > > > > On Wed, Dec 18, 2019 at 5:49 AM Luiz Augusto von Dentz > > wrote: > > > > > > Hi Chethan, > > > > > > On Mon, Dec 16, 2019 at 10:40 PM chethan tn wrote: > > > > > > > > Hi, > > > > > > > > I would like to understand why the Source device L2CAP mtu is always > > > > set to the remote device mtu during L2CAP connection? > > > > > > > > https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth.git/tree/net/bluetooth/l2cap_core.c#n3370 > > > > https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth.git/tree/net/bluetooth/l2cap_core.c#n3474 > > > > > > > > > > > > > > > > I tried to set the specific MTU for specific profile connection( For > > > > Ex: A2DP connection - PSM 25) patch mentioned below, but the same is > > > > not reflected because of the below code. > > > > > > > > https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth.git/tree/net/bluetooth/l2cap_core.c#n3474 > > > > > > The answer is pretty simple, we don't control the remote/output MTU, > > > so we cannot force the remote to use some arbitrary MTU if it doesn't > > > agree with. > > > > > > > Here the patch to set the MTU from the use space bluez. > > > > > > > > diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c > > > > index 58e1534a4..7d8a718c0 100644 > > > > --- a/profiles/audio/a2dp.c > > > > +++ b/profiles/audio/a2dp.c > > > > @@ -1573,6 +1573,7 @@ static bool a2dp_server_listen(struct a2dp_server *server) > > > > BT_IO_OPT_SOURCE_BDADDR, > > > > btd_adapter_get_address(server->adapter), > > > > BT_IO_OPT_PSM, AVDTP_PSM, > > > > + BT_IO_OPT_OMTU, AVDTP_MTU, > > > > BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_MEDIUM, > > > > BT_IO_OPT_MASTER, true, > > > > BT_IO_OPT_INVALID); > > > > diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c > > > > index 51ead684a..786702cec 100644 > > > > --- a/profiles/audio/avdtp.c > > > > +++ b/profiles/audio/avdtp.c > > > > @@ -2394,6 +2394,7 @@ static GIOChannel *l2cap_connect(struct avdtp *session) > > > > BT_IO_OPT_DEST_BDADDR, > > > > device_get_address(session->device), > > > > BT_IO_OPT_PSM, AVDTP_PSM, > > > > + BT_IO_OPT_OMTU, AVDTP_MTU, > > > > BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_MEDIUM, > > > > BT_IO_OPT_INVALID); > > > > if (!io) { > > > > diff --git a/profiles/audio/avdtp.h b/profiles/audio/avdtp.h > > > > index 621a6e3cf..372b2579d 100644 > > > > --- a/profiles/audio/avdtp.h > > > > +++ b/profiles/audio/avdtp.h > > > > > > > > > > > > > > > > Can you please suggest what is the best way to set the L2CAP mtu as > > > > user defined. > > > > > > > > > > > > Thanks > > > > > > > > Chethan > > > > > > > > > > > > -- > > > Luiz Augusto von Dentz > > > > Regards > > Sathish N > > > > -- > Luiz Augusto von Dentz