From patchwork Sat Apr 4 03:31:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miao-chen Chou X-Patchwork-Id: 11474023 X-Patchwork-Delegate: marcel@holtmann.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F2C621392 for ; Sat, 4 Apr 2020 03:31:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D1FBE20737 for ; Sat, 4 Apr 2020 03:31:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="hdtjJZvY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726442AbgDDDbe (ORCPT ); Fri, 3 Apr 2020 23:31:34 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:41522 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726373AbgDDDbb (ORCPT ); Fri, 3 Apr 2020 23:31:31 -0400 Received: by mail-pg1-f193.google.com with SMTP id m13so568689pgd.8 for ; Fri, 03 Apr 2020 20:31:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=v1mdWcuwskC5xCxFq+Qddy86SO72Bw+uYH+YeQZGcNE=; b=hdtjJZvYVOQsb3dVzkBalbaBdiHxGcZAApVW04rr3BcEzsea3w0jFkiUten1Wq0d7J 8NXzcwSTadalpNtoqjqwmaaW1SIwQ4W+MPFH37wQEnjWgZ+K95lkiIw5hOujctIJ4P/S QIoVpuHz1MVJmZ+OA2Lm0lfxbj0gkchH7dxCY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=v1mdWcuwskC5xCxFq+Qddy86SO72Bw+uYH+YeQZGcNE=; b=BRi5LnwUyCKP8XLFWwx+8/cfVr6ySYknf7AP4mvAau45/a1/AriISKEYhTcvy4r9yk Iuu5TMRrKMqFqw/3fu1of3IjFtql1hygvTTyY7JCjQp/I+tTmERNy2IXQa9F9lUvXYcQ jyffMhNLch6Eoe9pfM10fUNGsRVlRxctcbBtiuR+PJ0PEgs/RW5qeJjaKZ/vHioR6c8G D5wnHL/c4sBf5XagVpxrf2nGkoUS3a126esxZ2b+C1uE6eeZQfIBjNhdSwZn6c6Sqe5G fOl7XHvTyW193mJDstpe++pLDUYYbZo5UBOb9l+DqrqMFYGf0k55fNi7YzpQ/Z7WSFjl E0pQ== X-Gm-Message-State: AGi0PuaIaM01cJaFWegTOReJpz4iuXU/tWlAePDYlvGJE14XfpKfB/ij In/wy4VU4uLNJoyhqyM9d+fLTgcmruk= X-Google-Smtp-Source: APiQypJ77ulOxjh+3lJmzBP70688j+/yZ+EXq9Z0QmGYQf8wqv4ALEIxck7H5Vy2ku+i/vAZcPAu2A== X-Received: by 2002:a63:be49:: with SMTP id g9mr11194340pgo.30.1585971089286; Fri, 03 Apr 2020 20:31:29 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:b46:ac84:1014:9555]) by smtp.gmail.com with ESMTPSA id o184sm6800599pfg.149.2020.04.03.20.31.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Apr 2020 20:31:28 -0700 (PDT) From: Miao-chen Chou To: Bluetooth Kernel Mailing List Cc: Marcel Holtmann , Alain Michaud , Luiz Augusto von Dentz , Miao-chen Chou , "David S. Miller" , Jakub Kicinski , Johan Hedberg , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v5 1/3] Bluetooth: Add the framework of using Microsoft vendor extension Date: Fri, 3 Apr 2020 20:31:16 -0700 Message-Id: <20200403203058.v5.1.I04214d389ccfe933f1056a17c0e0ecdacb0395b5@changeid> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200404033118.22135-1-mcchou@chromium.org> References: <20200404033118.22135-1-mcchou@chromium.org> MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This adds the framework of using Microsoft vendor extension by introducing a kernel config, BT_MSFTEXT, and a source file to facilitate Microsoft vendor extension functions. This was verified with Intel ThunderPeak BT controller where msft_opcode is 0xFC1E. See https://docs.microsoft.com/en-us/windows- hardware/drivers/bluetooth/microsoft-defined-bluetooth-hci-commands-and- events for more information about the extension. Signed-off-by: Marcel Holtmann (cherry picked from commit dadae5cfbf84abb7b5465e82a7aae801a2a4f163) Signed-off-by: Miao-chen Chou --- Changes in v5: - Extract the changes on btusb as a different commit. Changes in v4: - Introduce CONFIG_BT_MSFTEXT as a starting point of providing a framework to use Microsoft extension - Create include/net/bluetooth/msft.h and net/bluetooth/msft.c to facilitate functions of Microsoft extension. Changes in v3: - Create net/bluetooth/msft.c with struct msft_vnd_ext defined internally and change the hdev->msft_ext field to void*. - Define and expose msft_vnd_ext_set_opcode() for btusb use. - Init hdev->msft_ext in hci_alloc_dev() and deinit it in hci_free_dev(). Changes in v2: - Define struct msft_vnd_ext and add a field of this type to struct hci_dev to facilitate the support of Microsoft vendor extension. include/net/bluetooth/hci_core.h | 4 ++++ include/net/bluetooth/msft.h | 19 +++++++++++++++++++ net/bluetooth/Kconfig | 7 +++++++ net/bluetooth/Makefile | 1 + net/bluetooth/msft.c | 15 +++++++++++++++ 5 files changed, 46 insertions(+) create mode 100644 include/net/bluetooth/msft.h create mode 100644 net/bluetooth/msft.c diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index d4e28773d3781..239cae2d99986 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -484,6 +484,10 @@ struct hci_dev { struct led_trigger *power_led; #endif +#if IS_ENABLED(CONFIG_BT_MSFTEXT) + __u16 msft_opcode; +#endif + int (*open)(struct hci_dev *hdev); int (*close)(struct hci_dev *hdev); int (*flush)(struct hci_dev *hdev); diff --git a/include/net/bluetooth/msft.h b/include/net/bluetooth/msft.h new file mode 100644 index 0000000000000..7218ea759dde4 --- /dev/null +++ b/include/net/bluetooth/msft.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* Copyright (C) 2020 Google Corporation */ + +#ifndef __MSFT_H +#define __MSFT_H + +#include + +#if IS_ENABLED(CONFIG_BT_MSFTEXT) + +void msft_set_opcode(struct hci_dev *hdev, __u16 opcode); + +#else + +static inline void msft_set_opcode(struct hci_dev *hdev, __u16 opcode) {} + +#endif + +#endif /* __MSFT_H*/ diff --git a/net/bluetooth/Kconfig b/net/bluetooth/Kconfig index 165148c7c4ce5..d439be5c534e7 100644 --- a/net/bluetooth/Kconfig +++ b/net/bluetooth/Kconfig @@ -93,6 +93,13 @@ config BT_LEDS This option selects a few LED triggers for different Bluetooth events. +config BT_MSFTEXT + bool "Enable Microsoft extensions" + depends on BT + help + This options enables support for the Microsoft defined HCI + vendor extensions. + config BT_SELFTEST bool "Bluetooth self testing support" depends on BT && DEBUG_KERNEL diff --git a/net/bluetooth/Makefile b/net/bluetooth/Makefile index fda41c0b47818..41dd541a44a52 100644 --- a/net/bluetooth/Makefile +++ b/net/bluetooth/Makefile @@ -19,5 +19,6 @@ bluetooth-y := af_bluetooth.o hci_core.o hci_conn.o hci_event.o mgmt.o \ bluetooth-$(CONFIG_BT_BREDR) += sco.o bluetooth-$(CONFIG_BT_HS) += a2mp.o amp.o bluetooth-$(CONFIG_BT_LEDS) += leds.o +bluetooth-$(CONFIG_BT_MSFTEXT) += msft.o bluetooth-$(CONFIG_BT_DEBUGFS) += hci_debugfs.o bluetooth-$(CONFIG_BT_SELFTEST) += selftest.o diff --git a/net/bluetooth/msft.c b/net/bluetooth/msft.c new file mode 100644 index 0000000000000..04dad4ac7bf78 --- /dev/null +++ b/net/bluetooth/msft.c @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* Copyright (C) 2020 Google Corporation */ + +#include +#include +#include + +void msft_set_opcode(struct hci_dev *hdev, __u16 opcode) +{ + hdev->msft_opcode = opcode; + + bt_dev_info(hdev, "Enabling MSFT extensions with opcode 0x%2.2x", + hdev->msft_opcode); +} +EXPORT_SYMBOL(msft_set_opcode); From patchwork Sat Apr 4 03:31:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miao-chen Chou X-Patchwork-Id: 11474027 X-Patchwork-Delegate: marcel@holtmann.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C96BD92A for ; Sat, 4 Apr 2020 03:31:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8E12F212CC for ; Sat, 4 Apr 2020 03:31:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="MHGvGKhd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726520AbgDDDbj (ORCPT ); Fri, 3 Apr 2020 23:31:39 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:39336 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726373AbgDDDbf (ORCPT ); Fri, 3 Apr 2020 23:31:35 -0400 Received: by mail-pf1-f193.google.com with SMTP id k15so4609865pfh.6 for ; Fri, 03 Apr 2020 20:31:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MywSYTxMvz+c+DUairYMPtaig3rFkiIAbKCB3sT2phA=; b=MHGvGKhd/3J77UtdPgNIETApL3dzQzcBrP4+ClU29FiyhzQGWkqMQ2fyFdPobh4n8B OWIFU93Xs/PhakQo1ImDMPDzhvqDczAxeV5X8bIgXA9TWURYs2FlAbsuTwRyAhsrnuda ed/+MaQqGiUOIGg2MkO0vArmsMuZHZXi5MVgw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MywSYTxMvz+c+DUairYMPtaig3rFkiIAbKCB3sT2phA=; b=VfHgGRzfWywnm6u4wY7p1f+uyEqLmW30HKwa5Qq4cCv2xW0sEXmm1FEM4MLYPmVbyq 69XbRirK5udPxGZyHMqFvh+ajO7Iwvs9e2RK8c9XUCDnTYYFV5AF+SknY/szVaUaS+fZ +lfxA7pyy3Qng1thyZqM5rtPkIWBjY78g3we7KgQo/SZsyoety76/PIZpIn8z0uk6bUL YALtHrGvoo0cJzaKqTHp0S7SUh9YNvgbNeQG94GuDdkMTY+4sKFO3EGcQ5P+OVS2gnAx q03rbqbKtezUIVGNtkbpbsqYgtwQK8/CrfNgA0BZoWDN2mm6N7/GHS7seEk3SZX+b1Y7 bE9Q== X-Gm-Message-State: AGi0PubnblZMrY95J+jh/quZtSJvlGdjwXCGKD/4lLYe8WLAweR+J7GI /F7vgcYEGyznxXLKt2X8mFOJu0nKDPk= X-Google-Smtp-Source: APiQypJnrT8PD4zx1fCAbpAQWk0eVDXKSGUaO+7XrXJbg/w5coyLj+brfkV67/V96dYJ4kjqrZrrOw== X-Received: by 2002:a63:8c13:: with SMTP id m19mr10669543pgd.44.1585971092193; Fri, 03 Apr 2020 20:31:32 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:b46:ac84:1014:9555]) by smtp.gmail.com with ESMTPSA id o184sm6800599pfg.149.2020.04.03.20.31.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Apr 2020 20:31:31 -0700 (PDT) From: Miao-chen Chou To: Bluetooth Kernel Mailing List Cc: Marcel Holtmann , Alain Michaud , Luiz Augusto von Dentz , Miao-chen Chou , "David S. Miller" , Jakub Kicinski , Johan Hedberg , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v5 2/3] Bluetooth: Read the supported features of Microsoft vendor extension Date: Fri, 3 Apr 2020 20:31:17 -0700 Message-Id: <20200403203058.v5.2.Ic59b637deef8e646f6599a80c9a2aa554f919e55@changeid> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200404033118.22135-1-mcchou@chromium.org> References: <20200404033118.22135-1-mcchou@chromium.org> MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This defines an opcode and packet structures of Microsoft vendor extension. For now, we add only the HCI_VS_MSFT_Read_Supported_Features command. See https://docs.microsoft.com/en-us/windows-hardware/drivers/bluetooth/ microsoft-defined-bluetooth-hci-commands-and-events#microsoft-defined- bluetooth-hci-events for more details. Upon initialization of a hci_dev, we issue a HCI_VS_MSFT_Read_Supported_Features command to read the supported features of Microsoft vendor extension if the opcode of Microsoft vendor extension is valid. See https://docs.microsoft.com/en-us/windows-hardware/drivers/ bluetooth/microsoft-defined-bluetooth-hci-commands-and-events# hci_vs_msft_read_supported_features for more details. This was verified on a device with Intel ThunderPeak BT controller where the Microsoft vendor extension features are 0x000000000000003f. Signed-off-by: Marcel Holtmann Signed-off-by: Miao-chen Chou --- Changes in v5: - Update the include line of msft.h. Changes in v4: - Move MSFT's do_open() and do_close() from net/bluetooth/hci_core.c to net/bluetooth/msft.c. - Other than msft opcode, define struct msft_data to host the rest of information of Microsoft extension and leave a void* pointing to a msft_data in struct hci_dev. Changes in v3: - Introduce msft_vnd_ext_do_open() and msft_vnd_ext_do_close(). Changes in v2: - Issue a HCI_VS_MSFT_Read_Supported_Features command with __hci_cmd_sync() instead of constructing a request. include/net/bluetooth/hci_core.h | 1 + include/net/bluetooth/msft.h | 7 ++ net/bluetooth/hci_core.c | 5 ++ net/bluetooth/hci_event.c | 5 ++ net/bluetooth/msft.c | 125 +++++++++++++++++++++++++++++++ 5 files changed, 143 insertions(+) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 239cae2d99986..59ddcd3a52ccd 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -486,6 +486,7 @@ struct hci_dev { #if IS_ENABLED(CONFIG_BT_MSFTEXT) __u16 msft_opcode; + void *msft_data; #endif int (*open)(struct hci_dev *hdev); diff --git a/include/net/bluetooth/msft.h b/include/net/bluetooth/msft.h index 7218ea759dde4..6cd5e6b3fb784 100644 --- a/include/net/bluetooth/msft.h +++ b/include/net/bluetooth/msft.h @@ -4,15 +4,22 @@ #ifndef __MSFT_H #define __MSFT_H +#include #include #if IS_ENABLED(CONFIG_BT_MSFTEXT) void msft_set_opcode(struct hci_dev *hdev, __u16 opcode); +void msft_do_open(struct hci_dev *hdev); +void msft_do_close(struct hci_dev *hdev); +void msft_vendor_evt(struct hci_dev *hdev, struct sk_buff *skb); #else static inline void msft_set_opcode(struct hci_dev *hdev, __u16 opcode) {} +static inline void msft_do_open(struct hci_dev *hdev) {} +static inline void msft_do_close(struct hci_dev *hdev) {} +static inline void msft_vendor_evt(struct hci_dev *hdev, struct sk_buff *skb) {} #endif diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index dbd2ad3a26eda..738b20a731a79 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -39,6 +39,7 @@ #include #include #include +#include #include "hci_request.h" #include "hci_debugfs.h" @@ -1563,6 +1564,8 @@ static int hci_dev_do_open(struct hci_dev *hdev) hci_dev_test_flag(hdev, HCI_VENDOR_DIAG) && hdev->set_diag) ret = hdev->set_diag(hdev, true); + msft_do_open(hdev); + clear_bit(HCI_INIT, &hdev->flags); if (!ret) { @@ -1758,6 +1761,8 @@ int hci_dev_do_close(struct hci_dev *hdev) hci_sock_dev_event(hdev, HCI_DEV_DOWN); + msft_do_close(hdev); + if (hdev->flush) hdev->flush(hdev); diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 20408d3862683..da42e7f6bcef3 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "hci_request.h" #include "hci_debugfs.h" @@ -6144,6 +6145,10 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) hci_num_comp_blocks_evt(hdev, skb); break; + case HCI_EV_VENDOR: + msft_vendor_evt(hdev, skb); + break; + default: BT_DBG("%s event 0x%2.2x", hdev->name, event); break; diff --git a/net/bluetooth/msft.c b/net/bluetooth/msft.c index 04dad4ac7bf78..b1f476ec3fcc5 100644 --- a/net/bluetooth/msft.c +++ b/net/bluetooth/msft.c @@ -5,6 +5,24 @@ #include #include +#define MSFT_OP_READ_SUPPORTED_FEATURES 0x00 +struct msft_cp_read_supported_features { + __u8 sub_opcode; +} __packed; +struct msft_rp_read_supported_features { + __u8 status; + __u8 sub_opcode; + __le64 features; + __u8 evt_prefix_len; + __u8 evt_prefix[0]; +} __packed; + +struct msft_data { + __u64 features; + __u8 evt_prefix_len; + __u8 *evt_prefix; +}; + void msft_set_opcode(struct hci_dev *hdev, __u16 opcode) { hdev->msft_opcode = opcode; @@ -13,3 +31,110 @@ void msft_set_opcode(struct hci_dev *hdev, __u16 opcode) hdev->msft_opcode); } EXPORT_SYMBOL(msft_set_opcode); + +static struct msft_data *read_supported_features(struct hci_dev *hdev) +{ + struct msft_data *msft; + struct msft_cp_read_supported_features cp; + struct msft_rp_read_supported_features *rp; + struct sk_buff *skb; + + cp.sub_opcode = MSFT_OP_READ_SUPPORTED_FEATURES; + + skb = __hci_cmd_sync(hdev, hdev->msft_opcode, sizeof(cp), &cp, + HCI_CMD_TIMEOUT); + if (IS_ERR(skb)) { + bt_dev_err(hdev, "Failed to read MSFT supported features (%ld)", + PTR_ERR(skb)); + return NULL; + } + + if (skb->len < sizeof(*rp)) { + bt_dev_err(hdev, "MSFT supported features length mismatch"); + goto failed; + } + + rp = (struct msft_rp_read_supported_features *)skb->data; + + if (rp->sub_opcode != MSFT_OP_READ_SUPPORTED_FEATURES) + goto failed; + + msft = kzalloc(sizeof(*msft), GFP_KERNEL); + if (!msft) + goto failed; + + if (rp->evt_prefix_len > 0) { + msft->evt_prefix = kmemdup(rp->evt_prefix, rp->evt_prefix_len, + GFP_KERNEL); + if (!msft->evt_prefix) + goto failed; + } + + msft->evt_prefix_len = rp->evt_prefix_len; + msft->features = __le64_to_cpu(rp->features); + kfree_skb(skb); + + bt_dev_info(hdev, "MSFT supported features %llx", msft->features); + return msft; + +failed: + kfree_skb(skb); + return NULL; +} + +void msft_do_open(struct hci_dev *hdev) +{ + if (hdev->msft_opcode == HCI_OP_NOP) + return; + + bt_dev_dbg(hdev, "Initialize MSFT extension"); + hdev->msft_data = read_supported_features(hdev); +} + +void msft_do_close(struct hci_dev *hdev) +{ + struct msft_data *msft = hdev->msft_data; + + if (!msft) + return; + + bt_dev_dbg(hdev, "Cleanup of MSFT extension"); + + hdev->msft_data = NULL; + + kfree(msft->evt_prefix); + kfree(msft); +} + +void msft_vendor_evt(struct hci_dev *hdev, struct sk_buff *skb) +{ + struct msft_data *msft = hdev->msft_data; + u8 event; + + if (!msft) + return; + + /* When the extension has defined an event prefix, check that it + * matches, and otherwise just return. + */ + if (msft->evt_prefix_len > 0) { + if (skb->len < msft->evt_prefix_len) + return; + + if (memcmp(skb->data, msft->evt_prefix, msft->evt_prefix_len)) + return; + + skb_pull(skb, msft->evt_prefix_len); + } + + /* Every event starts at least with an event code and the rest of + * the data is variable and depends on the event code. Returns true + */ + if (skb->len < 1) + return; + + event = *skb->data; + skb_pull(skb, 1); + + bt_dev_dbg(hdev, "MSFT vendor event %u", event); +} From patchwork Sat Apr 4 03:31:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miao-chen Chou X-Patchwork-Id: 11474025 X-Patchwork-Delegate: marcel@holtmann.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9CD2A92A for ; Sat, 4 Apr 2020 03:31:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7B81320737 for ; Sat, 4 Apr 2020 03:31:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="XgEWKJcb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726508AbgDDDbi (ORCPT ); Fri, 3 Apr 2020 23:31:38 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:37249 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726377AbgDDDbh (ORCPT ); Fri, 3 Apr 2020 23:31:37 -0400 Received: by mail-pg1-f196.google.com with SMTP id r4so3101358pgg.4 for ; Fri, 03 Apr 2020 20:31:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0rL0Rm/lQAGdaWAZMBOVIG8W3bOy5kskSwoybEKdYAI=; b=XgEWKJcbVYb7TmhweibqD0bkM2iPPwCNk2hOBqDTGRWd4/EhFLvZ3R8jIUTS6/RKN0 yqImpO0HDSB5bc4odVnYWUlBWU3Xs07RxSuC8YF/65KjiU3mtAez/a3QndAY8W4FQ7JJ dGaT+OpFQ9uQCxCcqwbY3i4xJbEXcmrHrGj/s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0rL0Rm/lQAGdaWAZMBOVIG8W3bOy5kskSwoybEKdYAI=; b=lUxvN1hk9xhsfMfQ9P1aLETBRbr20D/HNhL/NGtrD3o5QXBgyyz7RjXR+vbBqJP8Zs nklzBZkLvEAIY4dnAwTesTj1KxeGhCbvxOVlGkA8aAL+7B3mOH2yFhyGjaVwPNBJwm8P k71g7MXUxbQWt/Y0q6GAQhEPGkbQwgTLL/Tnaavl9T0hNhz75z3yYFrdKVHTrlXUri3A WavL5f7joJzm8SA/UIAfnX+sjKmd7O7z0ja6QMQmux0dgrcVjc6baH5sAwT1dY+yE6yw vK1mCjT1lMQOp0Lg93dZu68m3v5cF9j8qIzJPQR90Bc2hyOtzKZUAF7GTmThOORsxNFF NIsA== X-Gm-Message-State: AGi0PubRYjQBBRLSDK7D1TgJ8MvWOHq1xWjM6MdX8tq8hrY6JOmn9GVn jElXsOfbsCFc4VcHTzpHBV38adf3MNc= X-Google-Smtp-Source: APiQypKPhQwTlSAv0HKYk7HrJSfvfdKMVLrCM060ETottRWgNo6xvvPB1ihIrqMJlOuKM9iRmsrrXA== X-Received: by 2002:a63:a361:: with SMTP id v33mr10906958pgn.324.1585971095462; Fri, 03 Apr 2020 20:31:35 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:b46:ac84:1014:9555]) by smtp.gmail.com with ESMTPSA id o184sm6800599pfg.149.2020.04.03.20.31.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Apr 2020 20:31:34 -0700 (PDT) From: Miao-chen Chou To: Bluetooth Kernel Mailing List Cc: Marcel Holtmann , Alain Michaud , Luiz Augusto von Dentz , Miao-chen Chou , Johan Hedberg , linux-kernel@vger.kernel.org Subject: [PATCH v5 3/3] Bluetooth: btusb: Indicate Microsoft vendor extension for Intel 9160/9260 Date: Fri, 3 Apr 2020 20:31:18 -0700 Message-Id: <20200403203058.v5.3.I56c3ba2ec2bcfaadf57575c5c74a03dd4f8487d0@changeid> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200404033118.22135-1-mcchou@chromium.org> References: <20200404033118.22135-1-mcchou@chromium.org> MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This adds a bit mask of driver_info for Microsoft vendor extension and indicates the support for Intel 9160/9260. This was verified with Intel ThunderPeak BT controller where msft_opcode is 0xFC1E. Signed-off-by: Marcel Holtmann Signed-off-by: Miao-chen Chou --- Changes in v5: - Extract the changes on btusb as a different commit. Changes in v4: - Introduce CONFIG_BT_MSFTEXT as a starting point of providing a framework to use Microsoft extension - Create include/net/bluetooth/msft.h and net/bluetooth/msft.c to facilitate functions of Microsoft extension. Changes in v3: - Create net/bluetooth/msft.c with struct msft_vnd_ext defined internally and change the hdev->msft_ext field to void*. - Define and expose msft_vnd_ext_set_opcode() for btusb use. - Init hdev->msft_ext in hci_alloc_dev() and deinit it in hci_free_dev(). Changes in v2: - Define struct msft_vnd_ext and add a field of this type to struct hci_dev to facilitate the support of Microsoft vendor extension. drivers/bluetooth/btusb.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 3bdec42c96123..f73ad18c04559 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -20,6 +20,7 @@ #include #include +#include #include "btintel.h" #include "btbcm.h" @@ -58,6 +59,7 @@ static struct usb_driver btusb_driver; #define BTUSB_CW6622 0x100000 #define BTUSB_MEDIATEK 0x200000 #define BTUSB_WIDEBAND_SPEECH 0x400000 +#define BTUSB_MSFT_VND_EXT 0x800000 static const struct usb_device_id btusb_table[] = { /* Generic Bluetooth USB device */ @@ -335,7 +337,8 @@ static const struct usb_device_id blacklist_table[] = { /* Intel Bluetooth devices */ { USB_DEVICE(0x8087, 0x0025), .driver_info = BTUSB_INTEL_NEW | - BTUSB_WIDEBAND_SPEECH }, + BTUSB_WIDEBAND_SPEECH | + BTUSB_MSFT_VND_EXT }, { USB_DEVICE(0x8087, 0x0026), .driver_info = BTUSB_INTEL_NEW | BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x8087, 0x0029), .driver_info = BTUSB_INTEL_NEW | @@ -3800,6 +3803,12 @@ static int btusb_probe(struct usb_interface *intf, set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks); set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); set_bit(HCI_QUIRK_NON_PERSISTENT_DIAG, &hdev->quirks); + + /* All Intel controllers that support the Microsoft + * vendor extension are using 0xFC1E for VsMsftOpCode. + */ + if (id->driver_info & BTUSB_MSFT_VND_EXT) + msft_set_opcode(hdev, 0xFC1E); } if (id->driver_info & BTUSB_MARVELL)