Skip to content

Commit f25b7fd

Browse files
Ying HsuVudentz
authored andcommitted
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>
1 parent d4cc4ee commit f25b7fd

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

drivers/bluetooth/btintel.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2549,6 +2549,24 @@ static void btintel_set_dsm_reset_method(struct hci_dev *hdev,
25492549
data->acpi_reset_method = btintel_acpi_reset_method;
25502550
}
25512551

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+
25522570
int btintel_bootloader_setup_tlv(struct hci_dev *hdev,
25532571
struct intel_version_tlv *ver)
25542572
{
@@ -2989,11 +3007,14 @@ static int btintel_setup_combined(struct hci_dev *hdev)
29893007
err = btintel_bootloader_setup(hdev, &ver);
29903008
btintel_register_devcoredump_support(hdev);
29913009
break;
3010+
case 0x18: /* GfP2 */
3011+
case 0x1c: /* GaP */
3012+
/* Re-classify packet type for controllers with LE audio */
3013+
hdev->classify_pkt_type = btintel_classify_pkt_type;
3014+
fallthrough;
29923015
case 0x17:
2993-
case 0x18:
29943016
case 0x19:
29953017
case 0x1b:
2996-
case 0x1c:
29973018
case 0x1e:
29983019
/* Display version information of TLV type */
29993020
btintel_version_info_tlv(hdev, &ver_tlv);

include/net/bluetooth/hci_core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ struct hci_dev {
649649
int (*get_codec_config_data)(struct hci_dev *hdev, __u8 type,
650650
struct bt_codec *codec, __u8 *vnd_len,
651651
__u8 **vnd_data);
652+
u8 (*classify_pkt_type)(struct hci_dev *hdev, struct sk_buff *skb);
652653
};
653654

654655
#define HCI_PHY_HANDLE(handle) (handle & 0xff)

net/bluetooth/hci_core.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2909,15 +2909,31 @@ int hci_reset_dev(struct hci_dev *hdev)
29092909
}
29102910
EXPORT_SYMBOL(hci_reset_dev);
29112911

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+
29122920
/* Receive frame from HCI drivers */
29132921
int hci_recv_frame(struct hci_dev *hdev, struct sk_buff *skb)
29142922
{
2923+
u8 dev_pkt_type;
2924+
29152925
if (!hdev || (!test_bit(HCI_UP, &hdev->flags)
29162926
&& !test_bit(HCI_INIT, &hdev->flags))) {
29172927
kfree_skb(skb);
29182928
return -ENXIO;
29192929
}
29202930

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;
2935+
}
2936+
29212937
switch (hci_skb_pkt_type(skb)) {
29222938
case HCI_EVENT_PKT:
29232939
break;

0 commit comments

Comments
 (0)