2024-05-23 13:18:33

by Simon Horman

[permalink] [raw]
Subject: Re: [PATCH v2] Bluetooth: Add vendor-specific packet classification for ISO data

On Thu, May 23, 2024 at 06:09:31AM +0000, Ying Hsu wrote:
> When HCI raw sockets are opened, the Bluetooth kernel module doesn't
> track CIS/BIS connections. User-space applications have to identify
> ISO data by maintaining connection information and look up the mapping
> for each ACL data packet received. Besides, btsnoop log captured in
> kernel couldn't tell ISO data from ACL data in this case.
>
> To avoid additional lookups, this patch introduces vendor-specific
> packet classification for Intel BT controllers to distinguish
> ISO data packets from ACL data packets.
>
> Signed-off-by: Ying Hsu <[email protected]>
> ---
> Tested LE audio unicast recording on a ChromeOS device with Intel AX211
>
> Changes in v2:
> - Adds vendor-specific packet classificaton in hci_dev.
> - Keeps reclassification in hci_recv_frame.
>
> drivers/bluetooth/btusb.c | 19 +++++++++++++++++++
> include/net/bluetooth/hci_core.h | 1 +
> net/bluetooth/hci_core.c | 16 ++++++++++++++++
> 3 files changed, 36 insertions(+)
>
> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
> index 79aefdb3324d..75561e749c50 100644
> --- a/drivers/bluetooth/btusb.c
> +++ b/drivers/bluetooth/btusb.c
> @@ -966,6 +966,24 @@ static void btusb_intel_cmd_timeout(struct hci_dev *hdev)
> gpiod_set_value_cansleep(reset_gpio, 0);
> }
>
> +#define BT_USB_INTEL_ISODATA_HANDLE_BASE 0x900
> +
> +static u8 btusb_intel_classify_pkt_type(struct hci_dev *hdev, struct sk_buff *skb)
> +{
> + /*
> + * Distinguish ISO data packets form ACL data packets
> + * based on their conneciton handle value range.

nit: connection

> + */
> + if (hci_skb_pkt_type(skb) == HCI_ACLDATA_PKT) {
> + __u16 handle = __le16_to_cpu(hci_acl_hdr(skb)->handle);
> +
> + if (hci_handle(handle) >= BT_USB_INTEL_ISODATA_HANDLE_BASE)
> + return HCI_ISODATA_PKT;
> + }
> +
> + return hci_skb_pkt_type(skb);
> +}
> +
> #define RTK_DEVCOREDUMP_CODE_MEMDUMP 0x01
> #define RTK_DEVCOREDUMP_CODE_HW_ERR 0x02
> #define RTK_DEVCOREDUMP_CODE_CMD_TIMEOUT 0x03

..