Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp268153lqp; Wed, 22 May 2024 04:15:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW5Al7StmrWdashdzwoaUPm7QUVqDY0IqSg3lh+Qo+kpd23DCuWeT4hS5dfPdeQFvuCOBrtJG8vm/uUUXfcAgiZDQ4sYKSzwzCoQXtN5Q== X-Google-Smtp-Source: AGHT+IFfTVNWUTAsRmHpSIhhGWw9oCvg0iIjO1t7oGZV6miws1lcq6jsILEUKboMUNI4w612ERqr X-Received: by 2002:a25:7405:0:b0:df4:d8b7:1843 with SMTP id 3f1490d57ef6-df4e0e18bf6mr1567637276.61.1716376515742; Wed, 22 May 2024 04:15:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716376515; cv=pass; d=google.com; s=arc-20160816; b=j5s6JZU6G0C4VaKYaraMgsGf4n3cxvZ7HL11U7s8nCzHGOM9eXF5nyeZSpqaPIwOy7 m5uvOZowJgqGOS9LwMoxx8NHwfT2VEq+Hs6kU49AQCxiD7L6M4kfEb87tP/wl3SIbZYR D4Luk/e2/6rkV0C/4+kEwYuEb3Wa72JkfyGzkJtH0tHPOfs1//ms/ori621irifNmmGp +vMKWXvBXH7AXUldsOD/Ngp1LYv7Cp4nTqunShSpUWgp69WwQ7RTUW3iik6Of9npX2Qg HcdD0kZqHGF38tBMxr3Eu+lXj0q4plzU6tJxmTbPbUEMQbiqxy2ZVQTqbR9YOLmjKQKa 9JKg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=HGIbu+ypr2d0LLOENVoxzZcXEUbFgFGUeiK4yxl8U00=; fh=WDE8B6rIq4SLifG3n/P8tXn9ybIoy9KZSc4xX8B32Sc=; b=mcK49NTkiGV0cvZ56PpoDhC4LPjeiJFGjIM3ZMzkWTL/m3Th2qLLVC/b7G/b+Bi/AC 2eJJTYfOXRDQ4Zqt3ohrCeQostYrKmM85HkgbdEvE39JjBgp4PEHRIGFAhsvuglUz8ck IqaOc9AOJtyUGKBrGzB6PKQe0VXkSCaPTVOfqHuHfp20pTcenVX1Hjw+XqTcxfMujKgX PcqO8Fa/42giCurbCa3RcV2FhNQXJMQHYjc2ce3BaLZ6OatohqT2VlWj4aR+QgEE3IAp YD7RPiPAex3CLAGUQYGoYj/2ZDVJiiufFQM5NS46hji/iC1XgRRN1s1l3VbAqHa8kHxJ qj9g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=dUYe7QLH; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-bluetooth+bounces-4861-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4861-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6ab6bd54d76si58904816d6.251.2024.05.22.04.15.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 04:15:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-4861-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=dUYe7QLH; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-bluetooth+bounces-4861-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4861-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 771261C21E10 for ; Wed, 22 May 2024 11:15:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ABB3D84A3F; Wed, 22 May 2024 11:11:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="dUYe7QLH" X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail-io1-f51.google.com (mail-io1-f51.google.com [209.85.166.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D5BB82C88 for ; Wed, 22 May 2024 11:11:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716376308; cv=none; b=FG8iX/6E9dT2RsPspnocLScB37dI3tCnz3sW/8LGyCAXy02ggElAmqx62LNTVhEVnJDdKSdScoFnLcnqoJk0xtFHruYE8TCVyHEo5ChxOnkKGpbZlK6J9dOvgktJ+ZIYbeVg9xQ64qibvOEUyqDbHR/PUN/qJouzR8TSxMN28H8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716376308; c=relaxed/simple; bh=Ow3Tprf5J79b5FpVc2oISMYxIiNACP/jJXhyCs7qoh8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=gwRJIznyP4QrhEkirOQIUlVc3bXBEiXPfWLdBKOS+IpNlGGcDGEC37YbW1dXsPv8Ic15kbJ8O6ywDE0C7tpIMkYHg1KYlhnnJuEHIrsskZoWU7Dq+wc0Dn99eJHp42dYSV4di0ia9TIqxiW5c1zSlfLEGrLsl4u3RID7YRHQSj4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=dUYe7QLH; arc=none smtp.client-ip=209.85.166.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-io1-f51.google.com with SMTP id ca18e2360f4ac-7e201ab539eso301657839f.1 for ; Wed, 22 May 2024 04:11:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1716376305; x=1716981105; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=HGIbu+ypr2d0LLOENVoxzZcXEUbFgFGUeiK4yxl8U00=; b=dUYe7QLH5abdjotnhf7Or3sbvFrG0V+mcfblmSJ/1voWuzRVdRzRcDu9NLKehJ2dJf L2K9uA423Hfekul6+zhyeNL9ZP96lNchp6V57P9SBD9jcDtDTpKazd6CH2Ewt1smXfR+ IzH4dVP5LZFk7JDA5PMwvo+fQFj0p1MIAAe7k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716376305; x=1716981105; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=HGIbu+ypr2d0LLOENVoxzZcXEUbFgFGUeiK4yxl8U00=; b=Rsp22B8QCicA1Zjd0r6HPrm/M9bLEkpeyCNMZwS8Fn2JMx141znREaXq5vQBV1tZ3y NwDdULb1iS0rQrc+dKwB99oS+XLIVcBETrgm4w4X6R9LBuOWFSMAE//Td5aNMPeLFHPo DPyxPrErrVKyWG+TrKiGOIqdr8Vhue/BPFsKBDMbQtbasL3jtihmfIy5Njqbm/Ku3ufI JjphzC6PT3mXhzazaBoBvYhOzRN/jt9oq1Pzxl5k7FQ+D38w2EaZj8NtTu6bGHORuGIX LOGx2O48RDlM6qjK6LntS/G0wYvpYPGeFKS1S9tBiyyh/fTsaALtmWdd1WvS2440zWXL oNkw== X-Gm-Message-State: AOJu0YxPlCYnBwYZMtuED9S67UNhjunr+nNRW//OdrEnAwotmR7z4L5m YNwtj0fC85zjaU0xqXO4mleElG9HPGHZuYh3YiludAkVNP83Dh75QypqWG6xe9R5GEizn0ln1BM = X-Received: by 2002:a05:6602:4b86:b0:7e1:542d:7b09 with SMTP id ca18e2360f4ac-7e360c1566amr175674139f.0.1716376305249; Wed, 22 May 2024 04:11:45 -0700 (PDT) Received: from localhost (60.252.199.104.bc.googleusercontent.com. [104.199.252.60]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-6f4d2b2de1csm23189037b3a.204.2024.05.22.04.11.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 May 2024 04:11:44 -0700 (PDT) From: Ying Hsu To: linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Ying Hsu , Luiz Augusto von Dentz , Marcel Holtmann , linux-kernel@vger.kernel.org Subject: [PATCH] Bluetooth: vendor specific ISO data packet identification by handle Date: Wed, 22 May 2024 11:11:37 +0000 Message-ID: <20240522111139.2612601-1-yinghsu@chromium.org> X-Mailer: git-send-email 2.45.1.288.g0e0cd299f1-goog Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 catpured in kernel would couldn't tell ISO data from ACL data in this case. By differentiating ISO data from ACL data earlier in btusb, we can eliminate unnecessary lookups and improve btsnoop log clarity. This patch enables vendor-specific differentiation between ISO and ACL data packets. Signed-off-by: Ying Hsu --- Tested LE unicast recording on a ChromeOS device with Intel AX211 drivers/bluetooth/btusb.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 79aefdb3324d..543961b6c671 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -889,6 +889,8 @@ struct btusb_data { int (*recv_acl)(struct hci_dev *hdev, struct sk_buff *skb); int (*recv_bulk)(struct btusb_data *data, void *buffer, int count); + int (*is_iso_data_pkt)(struct sk_buff *skb); + int (*setup_on_usb)(struct hci_dev *hdev); int oob_wake_irq; /* irq for out-of-band wake-on-bt */ @@ -1229,6 +1231,8 @@ static int btusb_recv_bulk(struct btusb_data *data, void *buffer, int count) if (!hci_skb_expect(skb)) { /* Complete frame */ + if (data->is_iso_data_pkt && data->is_iso_data_pkt(skb)) + hci_skb_pkt_type(skb) = HCI_ISODATA_PKT; btusb_recv_acl(data, skb); skb = NULL; } @@ -2539,6 +2543,13 @@ static int btusb_recv_bulk_intel(struct btusb_data *data, void *buffer, return btusb_recv_bulk(data, buffer, count); } +static int btusb_is_iso_data_pkt_intel(struct sk_buff *skb) +{ + __u16 handle = (__le16_to_cpu(hci_acl_hdr(skb)->handle) & 0xfff); + + return (handle >= 0x900); +} + static int btusb_send_frame_intel(struct hci_dev *hdev, struct sk_buff *skb) { struct urb *urb; @@ -4361,6 +4372,9 @@ static int btusb_probe(struct usb_interface *intf, /* Override the rx handlers */ data->recv_event = btintel_recv_event; data->recv_bulk = btusb_recv_bulk_intel; + + /* Override for ISO data packet*/ + data->is_iso_data_pkt = btusb_is_iso_data_pkt_intel; } else if (id->driver_info & BTUSB_REALTEK) { /* Allocate extra space for Realtek device */ priv_size += sizeof(struct btrealtek_data); -- 2.45.1.288.g0e0cd299f1-goog