Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Bluetooth: Add vendor-specific packet classification for ISO data

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 <yinghsu@chromium.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

authored by

Ying Hsu and committed by
Luiz Augusto von Dentz
f25b7fd3 d4cc4ee4

+40 -2
+23 -2
drivers/bluetooth/btintel.c
··· 2549 2549 data->acpi_reset_method = btintel_acpi_reset_method; 2550 2550 } 2551 2551 2552 + #define BTINTEL_ISODATA_HANDLE_BASE 0x900 2553 + 2554 + static u8 btintel_classify_pkt_type(struct hci_dev *hdev, struct sk_buff *skb) 2555 + { 2556 + /* 2557 + * Distinguish ISO data packets form ACL data packets 2558 + * based on their connection handle value range. 2559 + */ 2560 + if (hci_skb_pkt_type(skb) == HCI_ACLDATA_PKT) { 2561 + __u16 handle = __le16_to_cpu(hci_acl_hdr(skb)->handle); 2562 + 2563 + if (hci_handle(handle) >= BTINTEL_ISODATA_HANDLE_BASE) 2564 + return HCI_ISODATA_PKT; 2565 + } 2566 + 2567 + return hci_skb_pkt_type(skb); 2568 + } 2569 + 2552 2570 int btintel_bootloader_setup_tlv(struct hci_dev *hdev, 2553 2571 struct intel_version_tlv *ver) 2554 2572 { ··· 3007 2989 err = btintel_bootloader_setup(hdev, &ver); 3008 2990 btintel_register_devcoredump_support(hdev); 3009 2991 break; 2992 + case 0x18: /* GfP2 */ 2993 + case 0x1c: /* GaP */ 2994 + /* Re-classify packet type for controllers with LE audio */ 2995 + hdev->classify_pkt_type = btintel_classify_pkt_type; 2996 + fallthrough; 3010 2997 case 0x17: 3011 - case 0x18: 3012 2998 case 0x19: 3013 2999 case 0x1b: 3014 - case 0x1c: 3015 3000 case 0x1e: 3016 3001 /* Display version information of TLV type */ 3017 3002 btintel_version_info_tlv(hdev, &ver_tlv);
+1
include/net/bluetooth/hci_core.h
··· 649 649 int (*get_codec_config_data)(struct hci_dev *hdev, __u8 type, 650 650 struct bt_codec *codec, __u8 *vnd_len, 651 651 __u8 **vnd_data); 652 + u8 (*classify_pkt_type)(struct hci_dev *hdev, struct sk_buff *skb); 652 653 }; 653 654 654 655 #define HCI_PHY_HANDLE(handle) (handle & 0xff)
+16
net/bluetooth/hci_core.c
··· 2909 2909 } 2910 2910 EXPORT_SYMBOL(hci_reset_dev); 2911 2911 2912 + static u8 hci_dev_classify_pkt_type(struct hci_dev *hdev, struct sk_buff *skb) 2913 + { 2914 + if (hdev->classify_pkt_type) 2915 + return hdev->classify_pkt_type(hdev, skb); 2916 + 2917 + return hci_skb_pkt_type(skb); 2918 + } 2919 + 2912 2920 /* Receive frame from HCI drivers */ 2913 2921 int hci_recv_frame(struct hci_dev *hdev, struct sk_buff *skb) 2914 2922 { 2923 + u8 dev_pkt_type; 2924 + 2915 2925 if (!hdev || (!test_bit(HCI_UP, &hdev->flags) 2916 2926 && !test_bit(HCI_INIT, &hdev->flags))) { 2917 2927 kfree_skb(skb); 2918 2928 return -ENXIO; 2929 + } 2930 + 2931 + /* Check if the driver agree with packet type classification */ 2932 + dev_pkt_type = hci_dev_classify_pkt_type(hdev, skb); 2933 + if (hci_skb_pkt_type(skb) != dev_pkt_type) { 2934 + hci_skb_pkt_type(skb) = dev_pkt_type; 2919 2935 } 2920 2936 2921 2937 switch (hci_skb_pkt_type(skb)) {