Lee, Chun-Yi e5849d
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Lee, Chun-Yi e5849d
Date: Mon, 28 Oct 2019 20:25:02 +0200
Lee, Chun-Yi e5849d
Subject: Bluetooth: btusb: Detect if an ACL packet is in fact an ISO packet
Lee, Chun-Yi e5849d
Patch-mainline: v6.0-rc1
Lee, Chun-Yi e5849d
Git-commit: 14202eff214e1e941fefa0366d4c3bc4b1a0d500
Lee, Chun-Yi e5849d
References: jsc#PED-1407
Lee, Chun-Yi e5849d
Lee, Chun-Yi e5849d
Fix up the packet type if ISO packets are sent over the bulk endpoint.
Lee, Chun-Yi e5849d
Lee, Chun-Yi e5849d
Note: This is a stopgap since the Bluetooth specification currently
Lee, Chun-Yi e5849d
doesn't define any endpoint to transport ISO packets.
Lee, Chun-Yi e5849d
Lee, Chun-Yi e5849d
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Lee, Chun-Yi e5849d
Acked-by: Lee, Chun-Yi <jlee@suse.com>
Lee, Chun-Yi e5849d
---
Lee, Chun-Yi e5849d
 drivers/bluetooth/btusb.c |   10 ++++++++++
Lee, Chun-Yi e5849d
 1 file changed, 10 insertions(+)
Lee, Chun-Yi e5849d
Lee, Chun-Yi e5849d
--- a/drivers/bluetooth/btusb.c
Lee, Chun-Yi e5849d
+++ b/drivers/bluetooth/btusb.c
Lee, Chun-Yi e5849d
@@ -911,11 +911,21 @@ static int btusb_recv_bulk(struct btusb_
Lee, Chun-Yi e5849d
 		hci_skb_expect(skb) -= len;
Lee, Chun-Yi e5849d
 
Lee, Chun-Yi e5849d
 		if (skb->len == HCI_ACL_HDR_SIZE) {
Lee, Chun-Yi e5849d
+			__u16 handle = __le16_to_cpu(hci_acl_hdr(skb)->handle);
Lee, Chun-Yi e5849d
 			__le16 dlen = hci_acl_hdr(skb)->dlen;
Lee, Chun-Yi e5849d
+			__u8 type;
Lee, Chun-Yi e5849d
 
Lee, Chun-Yi e5849d
 			/* Complete ACL header */
Lee, Chun-Yi e5849d
 			hci_skb_expect(skb) = __le16_to_cpu(dlen);
Lee, Chun-Yi e5849d
 
Lee, Chun-Yi e5849d
+			/* Detect if ISO packet has been sent over bulk */
Lee, Chun-Yi e5849d
+			if (hci_conn_num(data->hdev, ISO_LINK)) {
Lee, Chun-Yi e5849d
+				type = hci_conn_lookup_type(data->hdev,
Lee, Chun-Yi e5849d
+							    hci_handle(handle));
Lee, Chun-Yi e5849d
+				if (type == ISO_LINK)
Lee, Chun-Yi e5849d
+					hci_skb_pkt_type(skb) = HCI_ISODATA_PKT;
Lee, Chun-Yi e5849d
+			}
Lee, Chun-Yi e5849d
+
Lee, Chun-Yi e5849d
 			if (skb_tailroom(skb) < hci_skb_expect(skb)) {
Lee, Chun-Yi e5849d
 				kfree_skb(skb);
Lee, Chun-Yi e5849d
 				skb = NULL;