From patchwork Mon Mar 23 07:28:23 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: 11452419 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 3ECFB1392 for ; Mon, 23 Mar 2020 07:28:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1D77420732 for ; Mon, 23 Mar 2020 07:28:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="ODkKSuVJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727460AbgCWH2i (ORCPT ); Mon, 23 Mar 2020 03:28:38 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:38242 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727450AbgCWH2h (ORCPT ); Mon, 23 Mar 2020 03:28:37 -0400 Received: by mail-pg1-f195.google.com with SMTP id x7so6762101pgh.5 for ; Mon, 23 Mar 2020 00:28:36 -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=1WaFqY08yZDTNOOqFJJ4Ka9dG2R6CvdNBmfw+UsXwFw=; b=ODkKSuVJ6S52gPucNInkRRtmLi5CEwf3sUUvBlHuALvNerRafu3JZIPE//8XHMJcC+ Y0q0+nK9uhrEji65AzpxQv/UIT/ZXG0m+ynbKrKAl3Q5nyyj7MXmBArfQ/nAvEIsx/ea 24HV2oo0THO9Ki5w+CbrCEWerUT5NZLE1q9As= 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=1WaFqY08yZDTNOOqFJJ4Ka9dG2R6CvdNBmfw+UsXwFw=; b=A7cstqCWPJfPjyje1+53NWmBMuHpPyIZ4v1xVgoMpdO9vxtDJnl4RgCvaXGdu89mt8 MN1FMwRtOzT1GR3z3nU9SXbmLmLti/XLxhhUOBR+dIYSsD5D1a56UPw2Eke1GzFMncCl fewxabCtUbP/y5aajvFI+lMpxgYZHUtTApU8rD02/O93+ipAc2McghcDeTy6IViB7JX4 LJnxUVSx2EO820rDGrqLmFuY9LVKFEzPCL+vMP/t1x20GK3Z/XUa3NloP6pX84uzkvDO RAekN84isKMH3xqI1YCUsGCRtAiu/6uY+QmmGtr2tOsVVWefcB/f8tR1pp1pM/iHDzr6 qRdg== X-Gm-Message-State: ANhLgQ2mNXJgIgUJUY8tyimuiErlOZVYLrJAyvlR35lrvIbOaHn1ntr+ iadrZe+n3P632ZvwQq+zyBWkSfmgg+M= X-Google-Smtp-Source: ADFU+vuUDpsPfjd1HQWxTTC81WLH16iAkSLvmvkYp+NLO7JpHFuipUoXl00u8X8y9FJsnkBWcmeH0A== X-Received: by 2002:aa7:814c:: with SMTP id d12mr14344986pfn.70.1584948515681; Mon, 23 Mar 2020 00:28: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 z16sm12645399pfr.138.2020.03.23.00.28.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Mar 2020 00:28:34 -0700 (PDT) From: Miao-chen Chou To: Bluetooth Kernel Mailing List Cc: Luiz Augusto von Dentz , Marcel Holtmann , Alain Michaud , Miao-chen Chou , "David S. Miller" , Jakub Kicinski , Johan Hedberg , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v1 1/2] Bluetooth: btusb: Indicate Microsoft vendor extension for Intel 9460/9560 and 9160/9260 Date: Mon, 23 Mar 2020 00:28:23 -0700 Message-Id: <20200323002820.v1.1.I0e975833a6789e8acc74be7756cd54afde6ba98c@changeid> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200323072824.254495-1-mcchou@chromium.org> References: <20200323072824.254495-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 9460/9560 and 9160/9260. See https://docs.microsoft.com/en-us/windows-hardware/drivers/bluetooth/ microsoft-defined-bluetooth-hci-commands-and-events for more information about the extension. This was verified with Intel ThunderPeak BT controller where msft_vnd_ext_opcode is 0xFC1E. Signed-off-by: Miao-chen Chou --- Changes in v1: - Add a bit mask of driver_info for Microsoft vendor extension. - Indicates the support of Microsoft vendor extension for Intel 9460/9560 and 9160/9260. - Add fields to struct hci_dev to facilitate the support of Microsoft vendor extension. drivers/bluetooth/btusb.c | 18 ++++++++++++++++-- include/net/bluetooth/hci.h | 2 ++ include/net/bluetooth/hci_core.h | 4 ++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 3bdec42c9612..5eb27d1c4ac7 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -58,6 +58,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 +336,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 | @@ -348,7 +350,8 @@ static const struct usb_device_id blacklist_table[] = { { USB_DEVICE(0x8087, 0x0aa7), .driver_info = BTUSB_INTEL | BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x8087, 0x0aaa), .driver_info = BTUSB_INTEL_NEW | - BTUSB_WIDEBAND_SPEECH }, + BTUSB_WIDEBAND_SPEECH | + BTUSB_MSFT_VND_EXT }, /* Other Intel Bluetooth devices */ { USB_VENDOR_AND_INTERFACE_INFO(0x8087, 0xe0, 0x01, 0x01), @@ -3734,6 +3737,11 @@ static int btusb_probe(struct usb_interface *intf, hdev->send = btusb_send_frame; hdev->notify = btusb_notify; + hdev->msft_vnd_ext_opcode = HCI_OP_NOP; + hdev->msft_vnd_ext_features = 0; + hdev->msft_vnd_ext_evt_prefix_len = 0; + hdev->msft_vnd_ext_evt_prefix = NULL; + #ifdef CONFIG_PM err = btusb_config_oob_wake(hdev); if (err) @@ -3800,6 +3808,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); + + if (id->driver_info & BTUSB_MSFT_VND_EXT && + (id->idProduct == 0x0025 || id->idProduct == 0x0aaa)) { + hdev->msft_vnd_ext_opcode = + hci_opcode_pack(HCI_VND_DEBUG_CMD_OGF, 0x001E); + } } if (id->driver_info & BTUSB_MARVELL) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 5f60e135aeb6..b85e95454367 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -38,6 +38,8 @@ #define HCI_MAX_CSB_DATA_SIZE 252 +#define HCI_VND_DEBUG_CMD_OGF 0x3f + /* HCI dev events */ #define HCI_DEV_REG 1 #define HCI_DEV_UNREG 2 diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index d4e28773d378..15daf3b2d4f0 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -315,6 +315,10 @@ struct hci_dev { __u8 ssp_debug_mode; __u8 hw_error_code; __u32 clock; + __u16 msft_vnd_ext_opcode; + __u64 msft_vnd_ext_features; + __u8 msft_vnd_ext_evt_prefix_len; + void *msft_vnd_ext_evt_prefix; __u16 devid_source; __u16 devid_vendor; From patchwork Mon Mar 23 07:28:24 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: 11452417 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 D9D851392 for ; Mon, 23 Mar 2020 07:28:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A667820736 for ; Mon, 23 Mar 2020 07:28:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="gLnDgnE5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727393AbgCWH2p (ORCPT ); Mon, 23 Mar 2020 03:28:45 -0400 Received: from mail-pj1-f66.google.com ([209.85.216.66]:53032 "EHLO mail-pj1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727446AbgCWH2k (ORCPT ); Mon, 23 Mar 2020 03:28:40 -0400 Received: by mail-pj1-f66.google.com with SMTP id ng8so5764063pjb.2 for ; Mon, 23 Mar 2020 00:28:39 -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=peUcUJiWwH+jNWHv1XJjZ5RdsEPMfqXUmHLM2UZ+oGY=; b=gLnDgnE5axXZulHjrMwIKcMzI2z0jYs+ovG+RkBPPaHMnfDz8hyi3Ug3TYUXvOf2sk Jjxp3JN+gfykwgJp2859+PEUvlNywm/0Enznrra+RS20S2Ds08PykqxaT+Dv7sHcKIbU EHNelb/RxLV9ouR3oKbMbll6l1lkRM4G6M9SY= 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=peUcUJiWwH+jNWHv1XJjZ5RdsEPMfqXUmHLM2UZ+oGY=; b=VHSLWxPhF2+Mpds49JGSZ63csmlDFsy5HdK9esoPPUvdTA1QhnfYfeSDNcPUgQKlxf cMy1SPiGwjUURp2lKyhwcAbDWAGI+w/g/USgbAOPoR4mMw80KOm/FyUMuSE2pnyqmViM nonw9f5xX4QRF+36Uq96FkAPdk8UwTBszIdceU0Iqqo9O23ME+YnneU9J+kwkTs9cLJI 8NWqU16Kdm39AZ5lkufyl2MTFPH6P/P0Jj6M/gK+e5oitnskv1GaoJ6M5mh/5IJE6JSa JEBvD9VAzVQd7HOBMS0jeR4pz48JHv1oJcDWDPxM9Lz6BSah077coRrNKX+/xYYhLAGk y2Kw== X-Gm-Message-State: ANhLgQ1BO4byeYn6Ljjr8SGpjH1wlDz5utJw8S8orsvO6IfpkSoXnwXm TXWzNt5QNbsk38ToO0SRNdueSUwfjSE= X-Google-Smtp-Source: ADFU+vszQGhcp0OVnTmSb6ygcIVoxVz2AgsuoSKFCu6oASGs31eM2dg7Mt8vmMSGsH30Zai6ahgG5g== X-Received: by 2002:a17:902:a588:: with SMTP id az8mr20125265plb.163.1584948518415; Mon, 23 Mar 2020 00:28:38 -0700 (PDT) Received: from mcchou0.mtv.corp.google.com ([2620:15c:202:201:b46:ac84:1014:9555]) by smtp.gmail.com with ESMTPSA id z16sm12645399pfr.138.2020.03.23.00.28.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Mar 2020 00:28:37 -0700 (PDT) From: Miao-chen Chou To: Bluetooth Kernel Mailing List Cc: Luiz Augusto von Dentz , Marcel Holtmann , Alain Michaud , Miao-chen Chou , "David S. Miller" , Jakub Kicinski , Johan Hedberg , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v1 2/2] Bluetooth: btusb: Read the supported features of Microsoft vendor extension Date: Mon, 23 Mar 2020 00:28:24 -0700 Message-Id: <20200323002820.v1.2.I4e01733fa5b818028dc9188ca91438fc54aa5028@changeid> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200323072824.254495-1-mcchou@chromium.org> References: <20200323072824.254495-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 new header to facilitate the opcode and packet structures of vendor extension(s). For now, we add only the HCI_VS_MSFT_Read_Supported_Features command from Microsoft vendor extension. 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 ThhunderPeak BT controller where the Microsoft vendor extension features are 0x000000000000003f. Signed-off-by: Miao-chen Chou Reported-by: kbuild test robot --- Changes in v1: - Add vendor_hci.h to facilitate opcodes and packet structures of vendor extension(s). - Add opcode for the HCI_VS_MSFT_Read_Supported_Features command from Microsoft vendor extension. - Issue a HCI_VS_MSFT_Read_Supported_Features command upon hci_dev_do_open and save the return values. include/net/bluetooth/hci_core.h | 1 + include/net/bluetooth/vendor_hci.h | 51 ++++++++++++++++++++++++++++++ net/bluetooth/hci_core.c | 30 ++++++++++++++++++ net/bluetooth/hci_event.c | 49 +++++++++++++++++++++++++++- 4 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 include/net/bluetooth/vendor_hci.h diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 15daf3b2d4f0..941e71bdad42 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -30,6 +30,7 @@ #include #include +#include /* HCI priority */ #define HCI_PRIO_MAX 7 diff --git a/include/net/bluetooth/vendor_hci.h b/include/net/bluetooth/vendor_hci.h new file mode 100644 index 000000000000..bd374a7bf976 --- /dev/null +++ b/include/net/bluetooth/vendor_hci.h @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * BlueZ - Bluetooth protocol stack for Linux + * Copyright (C) 2020 Google Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY + * CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, + * COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS + * SOFTWARE IS DISCLAIMED. + */ + +#ifndef __VENDOR_HCI_H +#define __VENDOR_HCI_H + +#define MSFT_EVT_PREFIX_MAX_LEN 255 + +struct msft_cmd_cmp_info { + __u8 status; + __u8 sub_opcode; +} __packed; + +/* Microsoft Vendor HCI subcommands */ +#define MSFT_OP_READ_SUPPORTED_FEATURES 0x00 +#define MSFT_FEATURE_MASK_RSSI_MONITOR_BREDR_CONN 0x0000000000000001 +#define MSFT_FEATURE_MASK_RSSI_MONITOR_LE_CONN 0x0000000000000002 +#define MSFT_FEATURE_MASK_RSSI_MONITOR_LE_ADV 0x0000000000000004 +#define MSFT_FEATURE_MASK_ADV_MONITOR_LE_ADV 0x0000000000000008 +#define MSFT_FEATURE_MASK_VERIFY_CURVE_ 0x0000000000000010 +#define MSFT_FEATURE_MASK_CONCURRENT_ADV_MONITOR 0x0000000000000020 +struct msft_cp_read_supported_features { + __u8 sub_opcode; +} __packed; +struct msft_rp_read_supported_features { + __u64 features; + __u8 msft_evt_prefix_len; + __u8 msft_evt_prefix[0]; +} __packed; + +#endif /* __VENDOR_HCI_H */ diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index dbd2ad3a26ed..3cec58ca0047 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1407,6 +1407,32 @@ static void hci_dev_get_bd_addr_from_property(struct hci_dev *hdev) bacpy(&hdev->public_addr, &ba); } +static int hci_msft_read_supported_features_req(struct hci_request *req, + unsigned long opt) +{ + struct hci_dev *hdev = req->hdev; + struct msft_cp_read_supported_features cp; + + if (hdev->msft_vnd_ext_opcode == HCI_OP_NOP) + return -EOPNOTSUPP; + + cp.sub_opcode = MSFT_OP_READ_SUPPORTED_FEATURES; + hci_req_add(req, hdev->msft_vnd_ext_opcode, sizeof(cp), &cp); + return 0; +} + +static void read_vendor_extension_features(struct hci_dev *hdev) +{ + int err; + + if (hdev->msft_vnd_ext_opcode != HCI_OP_NOP) { + err = __hci_req_sync(hdev, hci_msft_read_supported_features_req, + 0, HCI_CMD_TIMEOUT, NULL); + if (err) + BT_ERR("HCI_VS_MSFT_Read_Supported_Feature failed"); + } +} + static int hci_dev_do_open(struct hci_dev *hdev) { int ret = 0; @@ -1572,6 +1598,10 @@ static int hci_dev_do_open(struct hci_dev *hdev) set_bit(HCI_UP, &hdev->flags); hci_sock_dev_event(hdev, HCI_DEV_UP); hci_leds_update_powered(hdev, true); + + /* Check features supported by HCI extensions. */ + read_vendor_extension_features(hdev); + if (!hci_dev_test_flag(hdev, HCI_SETUP) && !hci_dev_test_flag(hdev, HCI_CONFIG) && !hci_dev_test_flag(hdev, HCI_UNCONFIGURED) && diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 20408d386268..6a156167dfc9 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -23,7 +23,6 @@ */ /* Bluetooth HCI event handling. */ - #include #include @@ -1787,6 +1786,47 @@ static void hci_cc_write_ssp_debug_mode(struct hci_dev *hdev, struct sk_buff *sk hdev->ssp_debug_mode = *mode; } +static void hci_cc_msft_vnd_ext(struct hci_dev *hdev, struct sk_buff *skb) +{ + struct msft_cmd_cmp_info *info = (void *)skb->data; + const u8 status = info->status; + const u16 sub_opcode = __le16_to_cpu(info->sub_opcode); + + skb_pull(skb, sizeof(*info)); + + if (status) { + BT_ERR("Microsoft vendor extension sub command 0x%2.2x failed", + sub_opcode); + return; + } + + BT_DBG("%s status 0x%2.2x sub opcode 0x%2.2x", hdev->name, status, + sub_opcode); + + switch (sub_opcode) { + case MSFT_OP_READ_SUPPORTED_FEATURES: { + struct msft_rp_read_supported_features *rp = (void *)skb->data; + + hdev->msft_vnd_ext_features = __le64_to_cpu(rp->features); + hdev->msft_vnd_ext_evt_prefix_len = rp->msft_evt_prefix_len; + hdev->msft_vnd_ext_evt_prefix = + kmalloc(hdev->msft_vnd_ext_evt_prefix_len, GFP_ATOMIC); + if (!hdev->msft_vnd_ext_evt_prefix) + return; + + memcpy(hdev->msft_vnd_ext_evt_prefix, rp->msft_evt_prefix, + hdev->msft_vnd_ext_evt_prefix_len); + BT_DBG("%s Microsoft vendor extension features 0x%016llx", + hdev->name, hdev->msft_vnd_ext_features); + break; + } + default: + BT_ERR("%s unknown sub opcode 0x%2.2x", hdev->name, + sub_opcode); + break; + } +} + static void hci_cs_inquiry(struct hci_dev *hdev, __u8 status) { BT_DBG("%s status 0x%2.2x", hdev->name, status); @@ -3198,6 +3238,7 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb, hci_req_complete_skb_t *req_complete_skb) { struct hci_ev_cmd_complete *ev = (void *) skb->data; + const u16 msft_vnd_ext_opcode = hdev->msft_vnd_ext_opcode; *opcode = __le16_to_cpu(ev->opcode); *status = skb->data[sizeof(*ev)]; @@ -3538,6 +3579,12 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb, break; default: + /* Check if it's a Microsoft vendor extension opcode. */ + if (msft_vnd_ext_opcode != HCI_OP_NOP && + *opcode == msft_vnd_ext_opcode) { + hci_cc_msft_vnd_ext(hdev, skb); + break; + } BT_DBG("%s opcode 0x%4.4x", hdev->name, *opcode); break; }