Bluetooth: Prioritize SCO traffic
authorAbhishek Pandit-Subedi <abhishekpandit@chromium.org>
Mon, 23 Mar 2020 19:45:07 +0000 (12:45 -0700)
committerMarcel Holtmann <marcel@holtmann.org>
Fri, 3 Apr 2020 06:47:09 +0000 (08:47 +0200)
commit7fedd3bb6b77f9b6eefb0e4dcd8f79d0d00b86d7
treeb6a480a472e8233544e2abe5b71e16f2d39d7a6a
parent81bd5d0c62437c02caac6b3f942fcda874063cb0
Bluetooth: Prioritize SCO traffic

When scheduling TX packets, send all SCO/eSCO packets first, check for
pending SCO/eSCO packets after every ACL/LE packet and send them if any
are pending.  This is done to make sure that we can meet SCO deadlines
on slow interfaces like UART.

If we were to queue up multiple ACL packets without checking for a SCO
packet, we might miss the SCO timing. For example:

The time it takes to send a maximum size ACL packet (1024 bytes):
t = 10/8 * 1024 bytes * 8 bits/byte * 1 packet / baudrate
        where 10/8 is uart overhead due to start/stop bits per byte

Replace t = 3.75ms (SCO deadline), which gives us a baudrate of 2730666.

At a baudrate of 3000000, if we didn't check for SCO packets within 1024
bytes, we would miss the 3.75ms timing window.

Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
net/bluetooth/hci_core.c