From patchwork Tue Aug 3 15:27:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Hwang X-Patchwork-Id: 12416603 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0EB9FC4320A for ; Tue, 3 Aug 2021 15:27:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E6F5661029 for ; Tue, 3 Aug 2021 15:27:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236756AbhHCP1q (ORCPT ); Tue, 3 Aug 2021 11:27:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236745AbhHCP1o (ORCPT ); Tue, 3 Aug 2021 11:27:44 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62ECDC06179B for ; Tue, 3 Aug 2021 08:27:29 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id s22-20020a17090a1c16b0290177caeba067so4414341pjs.0 for ; Tue, 03 Aug 2021 08:27:29 -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:mime-version :content-transfer-encoding; bh=CbJpw/V4OPiAZHTSQ45FsW7F9yTlFc0tteK+tjxoFf0=; b=fff0IR+Nb/HujyLFvnTO1wNhj5aw1Bs7U90IwECsrFuj7sffG0jV1YreBDw/IaPtEu +MFW/Cqv8Z0Y6TTxm9w7aIk+2f0ExmAIFbFAu/+pixG1Nk+jMIuz4cOirorGHBvKJLyV wSx2KdaUGFaedgHfwV9jcw39KSQHVNNmwl3As= 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:mime-version :content-transfer-encoding; bh=CbJpw/V4OPiAZHTSQ45FsW7F9yTlFc0tteK+tjxoFf0=; b=sr/qi1zLnXQVQDuYduVmy7IcObKII1XEbhxHNBorPsxdAX5oHd2214WSysmemjkB3S uTzGWqDF6Knt1O1GC95XdZ/sRcdjL531MuFzXwbvq7tiA8/xdtjd3X6za/fuvzcc1gHg wY8golMywC044a9wFoxsGZZkXaLmMCY2egMvIDg4AVPWnWxxn4NNgJ3Ci1eo4bw2arbx z0PAMx94dRy5MzaBnKO6iBK+O4Jx8i/bHLQKVISeqX4qciD32tEZjgPmhTnXKfnB2VJ1 KesE+pfJQcqYmPnkiDohCqhI458QYpZvMGAwDKQEDWssKcmbbhkOzADtHl//rf0Nhgaa gf8g== X-Gm-Message-State: AOAM533zBmNXmWnes3yKM0OuRSS5PorhGJnObi/DR7/e5eDcn13mGSPe 2/3HkjOJT5bOoiji5tE7JH3XaKcBnTNH/w== X-Google-Smtp-Source: ABdhPJyvl5m5aSbxqpFMrNWiXHDpZmYxVI98R+Gqlc3QavK/tb5TXV4yjcSQ/j4/ABSDOSjHEibtrQ== X-Received: by 2002:a63:b4d:: with SMTP id a13mr110359pgl.404.1628004448345; Tue, 03 Aug 2021 08:27:28 -0700 (PDT) Received: from josephsih-z840.tpe.corp.google.com ([2401:fa00:1:10:7cf5:7e9:5266:c8ba]) by smtp.gmail.com with ESMTPSA id v30sm14922493pgk.25.2021.08.03.08.27.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Aug 2021 08:27:27 -0700 (PDT) From: Joseph Hwang To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com, pali@kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, josephsih@google.com, Joseph Hwang , Miao-chen Chou , Chethan T N , Kiran K , Johan Hedberg , linux-kernel@vger.kernel.org Subject: [PATCH v5 1/4] Bluetooth: btusb: disable Intel link statistics telemetry events Date: Tue, 3 Aug 2021 23:27:16 +0800 Message-Id: <20210803232539.v5.1.I41aec59e65ffd3226d368dabeb084af13cc133c8@changeid> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org To avoid the overhead on both the controller and the host, the Intel link statistics telemetry events are disabled by default. Reviewed-by: Miao-chen Chou Signed-off-by: Chethan T N Signed-off-by: Kiran K Signed-off-by: Joseph Hwang --- Changes in v5: - Rebase this patch 1/4 to resolve conflicts. - There are changes in patches 3/4 and 4/4. Changes in v4: - The original 2 patches in Series-version 3 are split into 2 patches from each patch per reviewers' comments. There are A total of 4 patches in this series now. - The callback function is renamed from hdev->set_vs_dbg_evt to hdev->set_quality_report. Note that there are two different specifications which will be integrated soon and enabled/disabled with the same callback. One is Android Bluetooth Quality Report (BQR), and the other Intel link statistics telemetry events here. While most Bluetooth controller vendors have supported or are supporting the Android specification in their controllers, it looks making sense to use set_quality_report as the callback name. - Similarly, the config option BT_FEATURE_VS_DBG_EVT is renamed as BT_FEATURE_QUALITY_REPORT which depends on BT now. - The BQR is controller specific. There needs to be a valid hdev in the first place. This is fixed in set_exp_feature(). - In set_exp_feature(), bluez will only set experimental feature to set BQR when the feature is supported. Please refer to bluez CLs. - Also refer to bluez patches for the decoding support of btmon. Changes in v3: - fix the long line in the commit message Changes in v2: - take care of intel_newgen as well as intel_new - fix the long lines in mgmt.c drivers/bluetooth/btusb.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index b1a05bb9f4bf..97414746c029 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -2865,7 +2865,6 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) u32 boot_param; char ddcname[64]; int err; - struct intel_debug_features features; BT_DBG("%s", hdev->name); @@ -2919,15 +2918,6 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) btintel_load_ddc_config(hdev, ddcname); } - /* Read the Intel supported features and if new exception formats - * supported, need to load the additional DDC config to enable. - */ - err = btintel_read_debug_features(hdev, &features); - if (!err) { - /* Set DDC mask for available debug features */ - btintel_set_debug_features(hdev, &features); - } - /* Read the Intel version information after loading the FW */ err = btintel_read_version(hdev, &ver); if (err) @@ -2966,7 +2956,6 @@ static int btusb_setup_intel_newgen(struct hci_dev *hdev) u32 boot_param; char ddcname[64]; int err; - struct intel_debug_features features; struct intel_version_tlv version; bt_dev_dbg(hdev, ""); @@ -3016,15 +3005,6 @@ static int btusb_setup_intel_newgen(struct hci_dev *hdev) */ btintel_load_ddc_config(hdev, ddcname); - /* Read the Intel supported features and if new exception formats - * supported, need to load the additional DDC config to enable. - */ - err = btintel_read_debug_features(hdev, &features); - if (!err) { - /* Set DDC mask for available debug features */ - btintel_set_debug_features(hdev, &features); - } - /* Read the Intel version information after loading the FW */ err = btintel_read_version_tlv(hdev, &version); if (err) From patchwork Tue Aug 3 15:27:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Hwang X-Patchwork-Id: 12416601 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6365C4338F for ; Tue, 3 Aug 2021 15:27:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9F82660F94 for ; Tue, 3 Aug 2021 15:27:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236749AbhHCP1p (ORCPT ); Tue, 3 Aug 2021 11:27:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236716AbhHCP1o (ORCPT ); Tue, 3 Aug 2021 11:27:44 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C257C061799 for ; Tue, 3 Aug 2021 08:27:31 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id j3so9059161plx.4 for ; Tue, 03 Aug 2021 08:27:31 -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=8XRuBGVk2TTwf9hGVxYImjah4Tr644Zkbwg4wofK/FY=; b=MQsgJNMfR+UCfzZoI3VN9d1zrZA9DLouL3DIB/inowYdG23QMuaAgMKtumqCbe60hU hfJrhY0YQ1N6DR4fseGUB/opus6JMgD2941bmDYk4RJv6Udt+vn6oDHGXJjmM6CYu743 En7wyZ2crsIcka5MgxJqoapjOOphI73cAQc0U= 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=8XRuBGVk2TTwf9hGVxYImjah4Tr644Zkbwg4wofK/FY=; b=cAToWKGSvZcTZ2rQR7coojXWe7IwQ73UBS52BvlK/8YfQa8LVDZWUAHaglSAU1cF6M uN43gRT/PAyYjlQsUbpJtwRwIn/EGpVAIbT2b+7pQ9XL00u7W2BvmXRo2azi552L1qJg xLMMX3Y/a8nNV3ILXux6cs3mtg2hgm1VUMBF9e2vlYLw5QmI3/qHN2YKNxBxT3UZ/TJe 9nIzG2PTLQZhK1ae33bp4o7ekEN4dpBdzWKHMzKi3UXcr2zENKOmJEr+C6WHAGxtCwxd ih4Yx9LK7RVfwXIKJabbSOb2y6hVboePZuCePs9mE4bq1crNKPHyJwzEUt7AtZOpF71B aRMA== X-Gm-Message-State: AOAM531zFDIc7m1ANStaFqJXs3qGTf5UHMoKjChDSKgJbFcepXFrL2wS Zxo49KmXj9MutNFhHZp3e9V4CUrr74M+oA== X-Google-Smtp-Source: ABdhPJy9VclF+eTNA91o9qVXsvOaHpY5kQ7ePpLs4p9ejb4RA0IUMI0a1MTIDdc48+r1k+Cerpz5SQ== X-Received: by 2002:a17:90a:558c:: with SMTP id c12mr24183440pji.124.1628004451025; Tue, 03 Aug 2021 08:27:31 -0700 (PDT) Received: from josephsih-z840.tpe.corp.google.com ([2401:fa00:1:10:7cf5:7e9:5266:c8ba]) by smtp.gmail.com with ESMTPSA id v30sm14922493pgk.25.2021.08.03.08.27.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Aug 2021 08:27:30 -0700 (PDT) From: Joseph Hwang To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com, pali@kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, josephsih@google.com, Chethan T N , Miao-chen Chou , Kiran K , Joseph Hwang , Johan Hedberg , linux-kernel@vger.kernel.org Subject: [PATCH v5 2/4] Bluetooth: btintel: support link statistics telemetry events Date: Tue, 3 Aug 2021 23:27:17 +0800 Message-Id: <20210803232539.v5.2.Ifb35feb49ec588106b256c508259500583582125@changeid> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog In-Reply-To: <20210803232539.v5.1.I41aec59e65ffd3226d368dabeb084af13cc133c8@changeid> References: <20210803232539.v5.1.I41aec59e65ffd3226d368dabeb084af13cc133c8@changeid> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Chethan T N This patch supports the link statistics telemetry events for intel controllers Reviewed-by: Miao-chen Chou Signed-off-by: Chethan T N Signed-off-by: Kiran K Signed-off-by: Joseph Hwang --- (no changes since v1) drivers/bluetooth/btintel.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c index e44b6993cf91..fd21ddb76928 100644 --- a/drivers/bluetooth/btintel.c +++ b/drivers/bluetooth/btintel.c @@ -1248,8 +1248,10 @@ EXPORT_SYMBOL_GPL(btintel_read_debug_features); int btintel_set_debug_features(struct hci_dev *hdev, const struct intel_debug_features *features) { - u8 mask[11] = { 0x0a, 0x92, 0x02, 0x07, 0x00, 0x00, 0x00, 0x00, + u8 mask[11] = { 0x0a, 0x92, 0x02, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + u8 period[5] = { 0x04, 0x91, 0x02, 0x05, 0x00 }; + u8 trace_enable = 0x02; struct sk_buff *skb; if (!features) @@ -1266,8 +1268,24 @@ int btintel_set_debug_features(struct hci_dev *hdev, PTR_ERR(skb)); return PTR_ERR(skb); } + kfree_skb(skb); + + skb = __hci_cmd_sync(hdev, 0xfc8b, 5, period, HCI_INIT_TIMEOUT); + if (IS_ERR(skb)) { + bt_dev_err(hdev, "Setting periodicity for link statistics traces failed (%ld)", + PTR_ERR(skb)); + return PTR_ERR(skb); + } + kfree_skb(skb); + skb = __hci_cmd_sync(hdev, 0xfca1, 1, &trace_enable, HCI_INIT_TIMEOUT); + if (IS_ERR(skb)) { + bt_dev_err(hdev, "Enable tracing of link statistics events failed (%ld)", + PTR_ERR(skb)); + return PTR_ERR(skb); + } kfree_skb(skb); + return 0; } EXPORT_SYMBOL_GPL(btintel_set_debug_features); From patchwork Tue Aug 3 15:27:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Hwang X-Patchwork-Id: 12416605 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9586C43214 for ; Tue, 3 Aug 2021 15:27:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A710F6103C for ; Tue, 3 Aug 2021 15:27:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236745AbhHCP1q (ORCPT ); Tue, 3 Aug 2021 11:27:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236730AbhHCP1p (ORCPT ); Tue, 3 Aug 2021 11:27:45 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE6CFC061764 for ; Tue, 3 Aug 2021 08:27:33 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id pj14-20020a17090b4f4eb029017786cf98f9so5191239pjb.2 for ; Tue, 03 Aug 2021 08:27: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=0NMDLRvCd8Q/Sr5vCBPPnUG/lOK2F47kcAWNHlgBnNo=; b=lf6lLXzT0+v5MPDgFLkljZAOcR52vQKJHTUUAW4AUs//Upt6/iYEpa8dPMTH6FOH1t Nt30zcrcpgM6X7P94U1bf7tyegZqnoF4t0hqtUTagSBRKHCIQz2DFUz0XQIKoeZk5nWG belIoiekv78wi+AjUewGnkWA6HOjrDAug/o7g= 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=0NMDLRvCd8Q/Sr5vCBPPnUG/lOK2F47kcAWNHlgBnNo=; b=K4oBC1fQMzgDH1XBQaT2PTQgMp970+ewArI2frPylwJHKqnMdS6xkP7oB1w+Pcg6lP p0/jZDxwXWhzOx5RoWYb5B2pbXVeYo2kWiCX2ON/yGVO48QL1BHfSBfruig6m391yBuV NKoRHVKbRGP1ofM11dzHdfSRRE44B/IJgsFCp5Ef2jKosje4efBdl2b0TOycuh515Hgy wGugyeabs2jhIEIG2FqRV/PADlofe4LgfhoGCp/N/PUbHhorI16tk6sTndEhqKln74hO M94nhuXZagqiFUuCmNjuKeAHpE9/ChtIUNT/rLYX5MVhCsyetEI/dHdl76V1sSamErS2 49Gw== X-Gm-Message-State: AOAM533rr+SjgJnEbj72T8z2C31RD7WkdnIW0dWKpJ3My0sHe2CltwSS bN8uOCFuAldnkcW1Z//nemD2EzJF0YWDog== X-Google-Smtp-Source: ABdhPJxcfI7a2tWXvVwm3JsMHUYHwLCtTDYBp2zo9xGJs/Aff8Uf6urdv9RaxQDWhoNUr/yF30dp+Q== X-Received: by 2002:a05:6a00:16d6:b029:32a:ffe9:76a with SMTP id l22-20020a056a0016d6b029032affe9076amr22990851pfc.60.1628004453262; Tue, 03 Aug 2021 08:27:33 -0700 (PDT) Received: from josephsih-z840.tpe.corp.google.com ([2401:fa00:1:10:7cf5:7e9:5266:c8ba]) by smtp.gmail.com with ESMTPSA id v30sm14922493pgk.25.2021.08.03.08.27.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Aug 2021 08:27:32 -0700 (PDT) From: Joseph Hwang To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com, pali@kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, josephsih@google.com, Joseph Hwang , Miao-chen Chou , Johan Hedberg , linux-kernel@vger.kernel.org Subject: [PATCH v5 3/4] Bluetooth: set quality report callback for Intel Date: Tue, 3 Aug 2021 23:27:18 +0800 Message-Id: <20210803232539.v5.3.I50ffa4cd0b3ab11669ff2541fc719fee00b4e244@changeid> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog In-Reply-To: <20210803232539.v5.1.I41aec59e65ffd3226d368dabeb084af13cc133c8@changeid> References: <20210803232539.v5.1.I41aec59e65ffd3226d368dabeb084af13cc133c8@changeid> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch sets up set_quality_report callback for Intel to set and reset the debug features. Reviewed-by: Miao-chen Chou Signed-off-by: Joseph Hwang --- Changes in v5: - Removed CONFIG_BT_FEATURE_QUALITY_REPORT since there was no large size impact. drivers/bluetooth/btintel.c | 73 ++++++++++++++++++++++++++++++++++++- drivers/bluetooth/btintel.h | 9 +++++ drivers/bluetooth/btusb.c | 8 ++++ 3 files changed, 89 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c index fd21ddb76928..28ca51227453 100644 --- a/drivers/bluetooth/btintel.c +++ b/drivers/bluetooth/btintel.c @@ -1254,8 +1254,10 @@ int btintel_set_debug_features(struct hci_dev *hdev, u8 trace_enable = 0x02; struct sk_buff *skb; - if (!features) + if (!features) { + bt_dev_warn(hdev, "Debug features not read"); return -EINVAL; + } if (!(features->page1[0] & 0x3f)) { bt_dev_info(hdev, "Telemetry exception format not supported"); @@ -1286,10 +1288,79 @@ int btintel_set_debug_features(struct hci_dev *hdev, } kfree_skb(skb); + bt_dev_info(hdev, "set debug features: trace_enable 0x%02x mask 0x%02x", + trace_enable, mask[3]); + return 0; } EXPORT_SYMBOL_GPL(btintel_set_debug_features); +int btintel_reset_debug_features(struct hci_dev *hdev, + const struct intel_debug_features *features) +{ + u8 mask[11] = { 0x0a, 0x92, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00 }; + u8 trace_enable = 0x00; + struct sk_buff *skb; + + if (!features) { + bt_dev_warn(hdev, "Debug features not read"); + return -EINVAL; + } + + if (!(features->page1[0] & 0x3f)) { + bt_dev_info(hdev, "Telemetry exception format not supported"); + return 0; + } + + /* Should stop the trace before writing ddc event mask. */ + skb = __hci_cmd_sync(hdev, 0xfca1, 1, &trace_enable, HCI_INIT_TIMEOUT); + if (IS_ERR(skb)) { + bt_dev_err(hdev, "Stop tracing of link statistics events failed (%ld)", + PTR_ERR(skb)); + return PTR_ERR(skb); + } + kfree_skb(skb); + + skb = __hci_cmd_sync(hdev, 0xfc8b, 11, mask, HCI_INIT_TIMEOUT); + if (IS_ERR(skb)) { + bt_dev_err(hdev, "Setting Intel telemetry ddc write event mask failed (%ld)", + PTR_ERR(skb)); + return PTR_ERR(skb); + } + kfree_skb(skb); + + bt_dev_info(hdev, "reset debug features: trace_enable 0x%02x mask 0x%02x", + trace_enable, mask[3]); + + return 0; +} +EXPORT_SYMBOL_GPL(btintel_reset_debug_features); + +int btintel_set_quality_report(struct hci_dev *hdev, bool enable) +{ + struct intel_debug_features features; + int err; + + bt_dev_dbg(hdev, "enable %d", enable); + + /* Read the Intel supported features and if new exception formats + * supported, need to load the additional DDC config to enable. + */ + err = btintel_read_debug_features(hdev, &features); + if (err) + return err; + + /* Set or reset the debug features. */ + if (enable) + err = btintel_set_debug_features(hdev, &features); + else + err = btintel_reset_debug_features(hdev, &features); + + return err; +} +EXPORT_SYMBOL_GPL(btintel_set_quality_report); + MODULE_AUTHOR("Marcel Holtmann "); MODULE_DESCRIPTION("Bluetooth support for Intel devices ver " VERSION); MODULE_VERSION(VERSION); diff --git a/drivers/bluetooth/btintel.h b/drivers/bluetooth/btintel.h index d184064a5e7c..0926b8196021 100644 --- a/drivers/bluetooth/btintel.h +++ b/drivers/bluetooth/btintel.h @@ -175,6 +175,9 @@ int btintel_read_debug_features(struct hci_dev *hdev, struct intel_debug_features *features); int btintel_set_debug_features(struct hci_dev *hdev, const struct intel_debug_features *features); +int btintel_reset_debug_features(struct hci_dev *hdev, + const struct intel_debug_features *features); +int btintel_set_quality_report(struct hci_dev *hdev, bool enable); #else static inline int btintel_check_bdaddr(struct hci_dev *hdev) @@ -307,4 +310,10 @@ static inline int btintel_set_debug_features(struct hci_dev *hdev, return -EOPNOTSUPP; } +static inline int btintel_reset_debug_features(struct hci_dev *hdev, + const struct intel_debug_features *features) +{ + return -EOPNOTSUPP; +} + #endif diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 97414746c029..9a860e4d8777 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -2918,6 +2918,9 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) btintel_load_ddc_config(hdev, ddcname); } + hci_dev_clear_flag(hdev, HCI_QUALITY_REPORT); + bt_dev_dbg(hdev, "HCI_QUALITY_REPORT cleared"); + /* Read the Intel version information after loading the FW */ err = btintel_read_version(hdev, &ver); if (err) @@ -3005,6 +3008,9 @@ static int btusb_setup_intel_newgen(struct hci_dev *hdev) */ btintel_load_ddc_config(hdev, ddcname); + hci_dev_clear_flag(hdev, HCI_QUALITY_REPORT); + bt_dev_dbg(hdev, "HCI_QUALITY_REPORT cleared"); + /* Read the Intel version information after loading the FW */ err = btintel_read_version_tlv(hdev, &version); if (err) @@ -4665,6 +4671,7 @@ static int btusb_probe(struct usb_interface *intf, hdev->set_diag = btintel_set_diag; hdev->set_bdaddr = btintel_set_bdaddr; hdev->cmd_timeout = btusb_intel_cmd_timeout; + hdev->set_quality_report = btintel_set_quality_report; 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); @@ -4679,6 +4686,7 @@ static int btusb_probe(struct usb_interface *intf, hdev->set_diag = btintel_set_diag; hdev->set_bdaddr = btintel_set_bdaddr; hdev->cmd_timeout = btusb_intel_cmd_timeout; + hdev->set_quality_report = btintel_set_quality_report; 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); From patchwork Tue Aug 3 15:27:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Hwang X-Patchwork-Id: 12416607 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5DBC6C4338F for ; Tue, 3 Aug 2021 15:27:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4A4AD60524 for ; Tue, 3 Aug 2021 15:27:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236807AbhHCP2F (ORCPT ); Tue, 3 Aug 2021 11:28:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236796AbhHCP16 (ORCPT ); Tue, 3 Aug 2021 11:27:58 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33D83C06179A for ; Tue, 3 Aug 2021 08:27:37 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id j18-20020a17090aeb12b029017737e6c349so3154140pjz.0 for ; Tue, 03 Aug 2021 08:27: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=BhqChEK30aWZ/Wvulh7cv7oSE9tKVj1Gn3MSKk1RcJk=; b=HcB7kFjYh2QNPCUYLNb/FNXkyDXp8QPqNymWq92aPF1aPo30ZwQkHE94ukSkRa44tp XKwk/mkULDPuTVMxR8VNnBAniDaGFL4YmT2BsDt1EkP7ZsRvkk0h5HmwLqIHJRsm4LrN 7fzpmns2cVVXxxJoQgjgKRrtNBS7aNX5HQqZ8= 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=BhqChEK30aWZ/Wvulh7cv7oSE9tKVj1Gn3MSKk1RcJk=; b=LTApK6O5xEf6RAUbhpH/2UhFi5VTjuzcVwAScR5TtzneX65IrHZrBRYTCVN5IFcr/+ M0nrN/yoz5GidVThGDrcAYGHZgVBQoAKLuq/k1RXyL+uhi6wTzMSc4XtskW0blKmCWjh GlLojGHZ/0AotTBSH51sSB6SBhXmE0/geiDji3JzZGpApedd/wcrcR1MxhDYFnOjsjeJ 1fgRKvf1Xhg4XiHaxyfIhOJ4djbZK+ajNm/Ncpq7qqN3WQto9y9BXi3ZM1DCDSq0zeAs NmPimfKHV/SdKQN/NJzO5dQqUh+IXpP195WNDM+5rsqzlGdj9BeJvBbW0ZhJu7eWxAo4 k8Dw== X-Gm-Message-State: AOAM532RcmQP8AYfy520Gn4p3XpU+QWfNe3yl/ZqBlnw98FjYOIWr7io DHAmn2cOCt3V+5x9yfLNAFcR85vKIO+McA== X-Google-Smtp-Source: ABdhPJxYl4i/CstW0b2daFlFXG6mNG46pbx5DxNFXnpEvvC5tMxq9figz8+RjDlixenDYDU2E7widQ== X-Received: by 2002:aa7:804f:0:b029:334:4951:da88 with SMTP id y15-20020aa7804f0000b02903344951da88mr22832724pfm.29.1628004456119; Tue, 03 Aug 2021 08:27:36 -0700 (PDT) Received: from josephsih-z840.tpe.corp.google.com ([2401:fa00:1:10:7cf5:7e9:5266:c8ba]) by smtp.gmail.com with ESMTPSA id v30sm14922493pgk.25.2021.08.03.08.27.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Aug 2021 08:27:35 -0700 (PDT) From: Joseph Hwang To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com, pali@kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, josephsih@google.com, Joseph Hwang , Miao-chen Chou , "David S. Miller" , Jakub Kicinski , Johan Hedberg , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v5 4/4] Bluetooth: Support the quality report events Date: Tue, 3 Aug 2021 23:27:19 +0800 Message-Id: <20210803232539.v5.4.I20c79eef4f36c4a3802e1068e59ec4a9f4ded940@changeid> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog In-Reply-To: <20210803232539.v5.1.I41aec59e65ffd3226d368dabeb084af13cc133c8@changeid> References: <20210803232539.v5.1.I41aec59e65ffd3226d368dabeb084af13cc133c8@changeid> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch allows a user space process to enable/disable the quality report events dynamically through the set experimental feature mgmt interface if CONFIG_BT_FEATURE_QUALITY_REPORT is enabled. Since the quality report feature needs to invoke the callback function provided by the driver, i.e., hdev->set_quality_report, a valid controller index is required. Reviewed-by: Miao-chen Chou Signed-off-by: Joseph Hwang --- Changes in v5: - Removed CONFIG_BT_FEATURE_QUALITY_REPORT since there was no large size impact. - Has checked hdev->set_quality_report is set. include/net/bluetooth/hci.h | 1 + include/net/bluetooth/hci_core.h | 2 + net/bluetooth/mgmt.c | 110 ++++++++++++++++++++++++++++++- 3 files changed, 112 insertions(+), 1 deletion(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index b80415011dcd..bb6b7398f490 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -330,6 +330,7 @@ enum { HCI_ENABLE_LL_PRIVACY, HCI_CMD_PENDING, HCI_FORCE_NO_MITM, + HCI_QUALITY_REPORT, __HCI_NUM_FLAGS, }; diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 4abe3c494002..171102a6b810 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -605,6 +605,7 @@ struct hci_dev { int (*set_bdaddr)(struct hci_dev *hdev, const bdaddr_t *bdaddr); void (*cmd_timeout)(struct hci_dev *hdev); bool (*prevent_wake)(struct hci_dev *hdev); + int (*set_quality_report)(struct hci_dev *hdev, bool enable); }; #define HCI_PHY_HANDLE(handle) (handle & 0xff) @@ -758,6 +759,7 @@ extern struct mutex hci_cb_list_lock; hci_dev_clear_flag(hdev, HCI_LE_ADV); \ hci_dev_clear_flag(hdev, HCI_LL_RPA_RESOLUTION);\ hci_dev_clear_flag(hdev, HCI_PERIODIC_INQ); \ + hci_dev_clear_flag(hdev, HCI_QUALITY_REPORT); \ } while (0) /* ----- HCI interface to upper protocols ----- */ diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 1e21e014efd2..358250862720 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -3791,6 +3791,12 @@ static const u8 debug_uuid[16] = { }; #endif +/* 330859bc-7506-492d-9370-9a6f0614037f */ +static const u8 quality_report_uuid[16] = { + 0x7f, 0x03, 0x14, 0x06, 0x6f, 0x9a, 0x70, 0x93, + 0x2d, 0x49, 0x06, 0x75, 0xbc, 0x59, 0x08, 0x33, +}; + /* 671b10b5-42c0-4696-9227-eb28d1b049d6 */ static const u8 simult_central_periph_uuid[16] = { 0xd6, 0x49, 0xb0, 0xd1, 0x28, 0xeb, 0x27, 0x92, @@ -3806,7 +3812,7 @@ static const u8 rpa_resolution_uuid[16] = { static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, void *data, u16 data_len) { - char buf[62]; /* Enough space for 3 features */ + char buf[82]; /* Enough space for 4 features: 2 + 20 * 4 */ struct mgmt_rp_read_exp_features_info *rp = (void *)buf; u16 idx = 0; u32 flags; @@ -3850,6 +3856,24 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, idx++; } + if (hdev) { + if (hdev->set_quality_report) { + /* BIT(0): indicating if set_quality_report is + * supported by controller. + */ + flags = BIT(0); + + /* BIT(1): indicating if the feature is enabled. */ + if (hci_dev_test_flag(hdev, HCI_QUALITY_REPORT)) + flags |= BIT(1); + } else { + flags = 0; + } + memcpy(rp->features[idx].uuid, quality_report_uuid, 16); + rp->features[idx].flags = cpu_to_le32(flags); + idx++; + } + rp->feature_count = cpu_to_le16(idx); /* After reading the experimental features information, enable @@ -3892,6 +3916,21 @@ static int exp_debug_feature_changed(bool enabled, struct sock *skip) } #endif +static int exp_quality_report_feature_changed(bool enabled, struct sock *skip) +{ + struct mgmt_ev_exp_feature_changed ev; + + BT_INFO("enabled %d", enabled); + + memset(&ev, 0, sizeof(ev)); + memcpy(ev.uuid, quality_report_uuid, 16); + ev.flags = cpu_to_le32(enabled ? BIT(0) : 0); + + return mgmt_limited_event(MGMT_EV_EXP_FEATURE_CHANGED, NULL, + &ev, sizeof(ev), + HCI_MGMT_EXP_FEATURE_EVENTS, skip); +} + static int set_exp_feature(struct sock *sk, struct hci_dev *hdev, void *data, u16 data_len) { @@ -4038,6 +4077,75 @@ static int set_exp_feature(struct sock *sk, struct hci_dev *hdev, return err; } + if (!memcmp(cp->uuid, quality_report_uuid, 16)) { + bool val, changed; + int err; + + /* Command requires to use a valid controller index */ + if (!hdev) + return mgmt_cmd_status(sk, MGMT_INDEX_NONE, + MGMT_OP_SET_EXP_FEATURE, + MGMT_STATUS_INVALID_INDEX); + + /* Parameters are limited to a single octet */ + if (data_len != MGMT_SET_EXP_FEATURE_SIZE + 1) + return mgmt_cmd_status(sk, hdev->id, + MGMT_OP_SET_EXP_FEATURE, + MGMT_STATUS_INVALID_PARAMS); + + /* Only boolean on/off is supported */ + if (cp->param[0] != 0x00 && cp->param[0] != 0x01) + return mgmt_cmd_status(sk, hdev->id, + MGMT_OP_SET_EXP_FEATURE, + MGMT_STATUS_INVALID_PARAMS); + + hci_req_sync_lock(hdev); + + val = !!cp->param[0]; + changed = (val != hci_dev_test_flag(hdev, HCI_QUALITY_REPORT)); + + if (!hdev->set_quality_report) { + BT_INFO("quality report not supported"); + err = mgmt_cmd_status(sk, hdev->id, + MGMT_OP_SET_EXP_FEATURE, + MGMT_STATUS_NOT_SUPPORTED); + goto unlock_quality_report; + } + + if (changed) { + err = hdev->set_quality_report(hdev, val); + if (err) { + BT_ERR("set_quality_report value %d err %d", + val, err); + err = mgmt_cmd_status(sk, hdev->id, + MGMT_OP_SET_EXP_FEATURE, + MGMT_STATUS_FAILED); + goto unlock_quality_report; + } + if (val) + hci_dev_set_flag(hdev, HCI_QUALITY_REPORT); + else + hci_dev_clear_flag(hdev, HCI_QUALITY_REPORT); + } + + BT_INFO("quality report enable %d changed %d", + val, changed); + + memcpy(rp.uuid, quality_report_uuid, 16); + rp.flags = cpu_to_le32(val ? BIT(0) : 0); + hci_sock_set_flag(sk, HCI_MGMT_EXP_FEATURE_EVENTS); + err = mgmt_cmd_complete(sk, hdev->id, + MGMT_OP_SET_EXP_FEATURE, 0, + &rp, sizeof(rp)); + + if (changed) + exp_quality_report_feature_changed(val, sk); + +unlock_quality_report: + hci_req_sync_unlock(hdev); + return err; + } + return mgmt_cmd_status(sk, hdev ? hdev->id : MGMT_INDEX_NONE, MGMT_OP_SET_EXP_FEATURE, MGMT_STATUS_NOT_SUPPORTED);