From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: Pauli Virtanen <pav@iki.fi>
Cc: linux-bluetooth@vger.kernel.org, vlad.pruteanu@nxp.com
Subject: Re: [PATCH BlueZ] client: fix ISO send data rate
Date: Sat, 11 May 2024 11:22:41 -0400 [thread overview]
Message-ID: <CABBYNZ+zVn+GYG4sFubU4CMRkJBvhmjEX7UsAPROeQM1Pyjoqw@mail.gmail.com> (raw)
In-Reply-To: <9b88a0238679d24aa5d68a4c473483943a8ea2b6.1715427163.git.pav@iki.fi>
Hi Pauli,
On Sat, May 11, 2024 at 7:34 AM Pauli Virtanen <pav@iki.fi> wrote:
>
> We are sending data to controller at wrong average rate not equal to
> 1 packet / SDU interval, if Transport_Latency is not an integer multiple
> of SDU_Interval. The calculation currently may also give zero, so no
> data gets sent.
>
> We are sending data in bursts of num ~= Transport_Latency/SDU_Interval
> packets, in hopes that possibly larger timer interval makes things more
> efficient.
>
> Fix the data rate by sending num packets every num*SDU_Interval, so that
> the average data rate is correct.
>
> Also fix use of itimerspect.it_value with TFD_TIMER_ABSTIME. The value
> set previously is going to always be in the past in CLOCK_MONOTONIC so
> just set it to 1, and leave sending the initial packets to the main
> loop.
> ---
>
> Notes:
> This assumes kernel shall set qos.interval to SDU_Interval and not
> ISO_Interval.
>
> client/player.c | 20 ++++++++++++++------
> 1 file changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/client/player.c b/client/player.c
> index 7f67425aa..8d17022de 100644
> --- a/client/player.c
> +++ b/client/player.c
> @@ -5066,22 +5066,30 @@ static int transport_send(struct transport *transport, int fd,
> if (timer_fd < 0)
> return -errno;
>
> + /* Send data in bursts of
> + * num = ROUND_CLOSEST(Transport_Latency (ms) / SDU_Interval (us))
> + * with average data rate = 1 packet / SDU_Interval
> + */
> + transport->num = ROUND_CLOSEST(qos->latency * 1000, qos->interval);
> + if (!transport->num)
> + transport->num = 1;
> +
> memset(&ts, 0, sizeof(ts));
> - ts.it_value.tv_nsec = qos->latency * 1000000;
> - ts.it_interval.tv_nsec = qos->latency * 1000000;
> + ts.it_value.tv_nsec = 1;
> + ts.it_interval.tv_nsec = transport->num * qos->interval * 1000;
>
> - if (timerfd_settime(timer_fd, TFD_TIMER_ABSTIME, &ts, NULL) < 0)
> + if (timerfd_settime(timer_fd, TFD_TIMER_ABSTIME, &ts, NULL) < 0) {
> + close(timer_fd);
> return -errno;
> + }
>
> transport->fd = fd;
> - /* num of packets = ROUND_CLOSEST(latency (ms) / interval (us)) */
> - transport->num = ROUND_CLOSEST(qos->latency * 1000, qos->interval);
> transport->timer_io = io_new(timer_fd);
>
> io_set_read_handler(transport->timer_io, transport_timer_read,
> transport, NULL);
>
> - return transport_send_seq(transport, fd, 1);
The above was actually done on purpose so we are always one interval
ahead to keep controller buffer full as much as possible.
> + return 0;
> }
>
> static void cmd_send_transport(int argc, char *argv[])
> --
> 2.45.0
>
>
--
Luiz Augusto von Dentz
prev parent reply other threads:[~2024-05-11 15:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-11 11:34 [PATCH BlueZ] client: fix ISO send data rate Pauli Virtanen
2024-05-11 13:51 ` [BlueZ] " bluez.test.bot
2024-05-11 15:22 ` Luiz Augusto von Dentz [this message]
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=CABBYNZ+zVn+GYG4sFubU4CMRkJBvhmjEX7UsAPROeQM1Pyjoqw@mail.gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=pav@iki.fi \
--cc=vlad.pruteanu@nxp.com \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).