From patchwork Fri Jun 18 08:00:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Hwang X-Patchwork-Id: 12330535 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=-18.9 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, URIBL_BLOCKED,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 A1B0BC48BE8 for ; Fri, 18 Jun 2021 08:01:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8CED0613B9 for ; Fri, 18 Jun 2021 08:01:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232695AbhFRIDT (ORCPT ); Fri, 18 Jun 2021 04:03:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232453AbhFRIDD (ORCPT ); Fri, 18 Jun 2021 04:03:03 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2695EC06175F for ; Fri, 18 Jun 2021 01:00:46 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id t19-20020a17090ae513b029016f66a73701so272126pjy.3 for ; Fri, 18 Jun 2021 01:00:46 -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=PNadQEIR3cQzWjVHVl6U6Trj5czCwGU5K/9fEbS0IFU=; b=NU8H2cHGLU8WEZ5cFDQ1P4KyBmnlbSWQ3asS8zTU2HWSpaLBo1Qq1YgqMQRniXV215 zsPaU4Lv+/GkMn8szM2Mww/8H9FOeSNPT5cYd6zx9YJLYb/JNUn67jGYBeRn/ydFG8/A 8ZN88h6ngwT4VeZmiHLk+IpA8YnqvoW6VkLFQ= 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=PNadQEIR3cQzWjVHVl6U6Trj5czCwGU5K/9fEbS0IFU=; b=qZEzWoD71HuHSS0qkSKIC0Gtlj3BfrrKVIN3hRSGxZYPBGetv4F9eRsCBdUIrVsm2S A2DiIA7WsakacQjsIRM036S3RWDmX0WYinyREOTKQIU6kGTLJRpPjWyASals8LGDE0bo Kc3gIzYGFfV3U9Fq6G7pjxN7J5kapgBssBqcZGrCa+6DzCFhDnwNn9wXVlQuNuSt5n+d CUxBqfX/gGflEO37dMaeEhoMBMn6nTPyoRClE6mx/cXtCEG75Z6V8uPQaF2UDTxdTF40 0kFwBkPgIwcko8FJZ9ts5jAKQzCRM4i+c6H/YnxqBbyTE986oNyryzga5BKmHllOUEFR 0T3w== X-Gm-Message-State: AOAM532g89xyanAkbnwuwVPNM3IbHh8kIEkWHmJCUncerMFSlV7UZKlu 8qfkC2DrShwqR+AagprEji/gWtAx3gEkuQ== X-Google-Smtp-Source: ABdhPJxzdqGEUb0JVxCzggTlO/YE2Y915WsH0HOI45DOrpgw0nqBKotR038Ddo1QhF7u299lTMRg4Q== X-Received: by 2002:a17:90a:4e02:: with SMTP id n2mr5852194pjh.80.1624003245264; Fri, 18 Jun 2021 01:00:45 -0700 (PDT) Received: from josephsih-z840.tpe.corp.google.com ([2401:fa00:1:10:6cbb:95eb:e2ae:8479]) by smtp.gmail.com with ESMTPSA id v21sm7341671pfu.77.2021.06.18.01.00.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 01:00:44 -0700 (PDT) From: Joseph Hwang To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com, pali@kernel.org Cc: josephsih@google.com, chromeos-bluetooth-upstreaming@chromium.org, Joseph Hwang , Miao-chen Chou , Chethan T N , Kiran K , Johan Hedberg , linux-kernel@vger.kernel.org Subject: [PATCH v4 1/4] Bluetooth: btusb: disable Intel link statistics telemetry events Date: Fri, 18 Jun 2021 16:00:36 +0800 Message-Id: <20210618160016.v4.1.I41aec59e65ffd3226d368dabeb084af13cc133c8@changeid> X-Mailer: git-send-email 2.32.0.288.g62a8d224e6-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 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 | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index a9855a2dd561..4c3b26c5e507 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -2850,7 +2850,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); @@ -2904,14 +2903,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. - */ - btintel_read_debug_features(hdev, &features); - - /* 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) @@ -2950,7 +2941,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, ""); @@ -3000,14 +2990,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. - */ - btintel_read_debug_features(hdev, &features); - - /* 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 Fri Jun 18 08:00:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Hwang X-Patchwork-Id: 12330537 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=-18.9 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, URIBL_BLOCKED,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 CE66BC49361 for ; Fri, 18 Jun 2021 08:01:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B2A5C613B9 for ; Fri, 18 Jun 2021 08:01:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232358AbhFRID1 (ORCPT ); Fri, 18 Jun 2021 04:03:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232654AbhFRIDH (ORCPT ); Fri, 18 Jun 2021 04:03:07 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BED74C061767 for ; Fri, 18 Jun 2021 01:00:48 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id i4so568645plt.12 for ; Fri, 18 Jun 2021 01:00:48 -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=InZhYqpv8m1+7VVhTH77wgZ+W95Cha0AWCB0EvIdTXY=; b=l83ZIor3bdYFAsNOHzp84GWE6gE7BJQCkA7D5v97xxbKaYtL51nEoYZuwqMhSSCqlK aiSeOv4a+G+Mi1fDk+3zeb7eTOvgofYzoGznWAMxMuhgKCftUdRBBIfLexFg/cCvys9x YYIonzEqgaQulejtTIB8L2qrcffRlL8NRrIps= 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=InZhYqpv8m1+7VVhTH77wgZ+W95Cha0AWCB0EvIdTXY=; b=XBmywroHIXXR5wwJPahzwADu8bLWCwwRLG7KykZeidVzfw0tPyWzlr0Ppxncw4sFSy im0fe9S688+zYUlBnjM5VkSeJ29ml0rwMOHJSjU5th2VABt+8wZL0/w/AbpIxL3jszI3 BancXX1Z9uFyOSAEWtWhKkENSJZxgJrsNrDeSrKFwGAuqsdvtZIBD0NIXVLjaNntJErj hyrJb5ql//RvveHe/81/75AejHFKtUAZwVRpAP0cViK9d45EMfd9yD2pPgqFWUYGEDbf HQvXz0LPs1KweLet0nDVPVUGMuR0a5yEknz3PukiF2QKfd4h/rQ6PjJzEcoS7Otei2K+ 2ycw== X-Gm-Message-State: AOAM530v3hXp9gMhBjMaJIrtr1Bqg+JJCEhds9luXXdpmSyCDOy9PjCM xBecw+eBLffFS30CyCnbc3O4jNh0Qf3YJA== X-Google-Smtp-Source: ABdhPJwEOwojVPfMDqPw6N+jQgIklXCslZ1wyeDFGuamDh2i+cfIgN6tDoZqI6KRL6tWX1uBfViXAw== X-Received: by 2002:a17:90a:4e4a:: with SMTP id t10mr9845003pjl.173.1624003247772; Fri, 18 Jun 2021 01:00:47 -0700 (PDT) Received: from josephsih-z840.tpe.corp.google.com ([2401:fa00:1:10:6cbb:95eb:e2ae:8479]) by smtp.gmail.com with ESMTPSA id v21sm7341671pfu.77.2021.06.18.01.00.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 01:00:47 -0700 (PDT) From: Joseph Hwang To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com, pali@kernel.org Cc: josephsih@google.com, chromeos-bluetooth-upstreaming@chromium.org, Chethan T N , Miao-chen Chou , Kiran K , Joseph Hwang , Johan Hedberg , linux-kernel@vger.kernel.org Subject: [PATCH v4 2/4] Bluetooth: btintel: support link statistics telemetry events Date: Fri, 18 Jun 2021 16:00:37 +0800 Message-Id: <20210618160016.v4.2.Ifb35feb49ec588106b256c508259500583582125@changeid> X-Mailer: git-send-email 2.32.0.288.g62a8d224e6-goog In-Reply-To: <20210618160016.v4.1.I41aec59e65ffd3226d368dabeb084af13cc133c8@changeid> References: <20210618160016.v4.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 Fri Jun 18 08:00:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Hwang X-Patchwork-Id: 12330541 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=-18.9 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, URIBL_BLOCKED,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 60D9EC48BDF for ; Fri, 18 Jun 2021 08:01:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4B7946117A for ; Fri, 18 Jun 2021 08:01:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233463AbhFRIDm (ORCPT ); Fri, 18 Jun 2021 04:03:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232665AbhFRIDL (ORCPT ); Fri, 18 Jun 2021 04:03:11 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6DB8C0617A6 for ; Fri, 18 Jun 2021 01:00:50 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id w31so7148130pga.6 for ; Fri, 18 Jun 2021 01:00:50 -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=UHRUoNKTXDhWOWWn3W311+njF5lywCh5AdKKO+L8q00=; b=iAsz0DdU4MEkawdRoyeBDUzcxfxX0FcKg+cjohP0ukmtUl/NtpwfLK8asbKSn89oUS +hJ7ZqKrfep0JINdjbD/C1GVT8E9+TGk47da+WrIuseRoV7naxAWLHUt3EL3B+B/5iEZ 54xAoTfr21SYY21EYilsbqQxnMIktqM01WJiI= 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=UHRUoNKTXDhWOWWn3W311+njF5lywCh5AdKKO+L8q00=; b=GiUGaJxamDJMcqgU42EpS7Q6P4hvyhHP48VY0cF5yySdcGO9bPgAud42cZ2WAPw4WD DoFEj8ztdle7ceJqOvOSu8E+ZYVWFAe0MjBBG4r7w4jtnATtvvYMYNNpykpjiOJ2EnD4 uDgP60fvb2eje9D5IfJt8FcIeKDdYgEhYyHNmqilAik/t9HMawfEFL4vwgq5zZIQ3FOX lmo/vJqALOsh3Sw++nZx4HriImqFcBAqV/6uVBbKs/6BWKjK8MKGuXiPnlipUuK1LlkA 9PmzqSebQUsY0tHXEyUkH7zV9RINfUINcrlehfF+03cSrhTg2KTqRTAzWFTYiWk4Utq1 jCmw== X-Gm-Message-State: AOAM5313AqWJPlsi8CDqZtTYVWFItvy3hIroDcgnGXaRsXTu4Pc0E5GN nfmamgH9x3h73vc7nZE0Pf8G0waPwLGsUw== X-Google-Smtp-Source: ABdhPJxwDdQM44hS+Ddhw7JWdEvTNdfDf51bw41GEHCOmZ1GRxVY5nBPak5SI2QbcEJ4zbiS3mD/KA== X-Received: by 2002:a63:e14:: with SMTP id d20mr9056017pgl.35.1624003249994; Fri, 18 Jun 2021 01:00:49 -0700 (PDT) Received: from josephsih-z840.tpe.corp.google.com ([2401:fa00:1:10:6cbb:95eb:e2ae:8479]) by smtp.gmail.com with ESMTPSA id v21sm7341671pfu.77.2021.06.18.01.00.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 01:00:49 -0700 (PDT) From: Joseph Hwang To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com, pali@kernel.org Cc: josephsih@google.com, chromeos-bluetooth-upstreaming@chromium.org, Joseph Hwang , Miao-chen Chou , Johan Hedberg , linux-kernel@vger.kernel.org Subject: [PATCH v4 3/4] Bluetooth: set quality report callback for Intel Date: Fri, 18 Jun 2021 16:00:38 +0800 Message-Id: <20210618160016.v4.3.I50ffa4cd0b3ab11669ff2541fc719fee00b4e244@changeid> X-Mailer: git-send-email 2.32.0.288.g62a8d224e6-goog In-Reply-To: <20210618160016.v4.1.I41aec59e65ffd3226d368dabeb084af13cc133c8@changeid> References: <20210618160016.v4.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 --- (no changes since v1) drivers/bluetooth/btintel.c | 75 ++++++++++++++++++++++++++++++++++++- drivers/bluetooth/btintel.h | 13 +++++++ drivers/bluetooth/btusb.c | 16 ++++++++ 3 files changed, 103 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c index fd21ddb76928..7b32141b555f 100644 --- a/drivers/bluetooth/btintel.c +++ b/drivers/bluetooth/btintel.c @@ -1213,6 +1213,7 @@ void btintel_reset_to_bootloader(struct hci_dev *hdev) } EXPORT_SYMBOL_GPL(btintel_reset_to_bootloader); +#ifdef CONFIG_BT_FEATURE_QUALITY_REPORT int btintel_read_debug_features(struct hci_dev *hdev, struct intel_debug_features *features) { @@ -1254,8 +1255,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 +1289,80 @@ 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); +#endif + 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..618d3736599f 100644 --- a/drivers/bluetooth/btintel.h +++ b/drivers/bluetooth/btintel.h @@ -171,10 +171,15 @@ int btintel_download_firmware_newgen(struct hci_dev *hdev, u32 *boot_param, u8 hw_variant, u8 sbe_type); void btintel_reset_to_bootloader(struct hci_dev *hdev); +#ifdef CONFIG_BT_FEATURE_QUALITY_REPORT 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); +#endif #else static inline int btintel_check_bdaddr(struct hci_dev *hdev) @@ -301,10 +306,18 @@ static inline int btintel_read_debug_features(struct hci_dev *hdev, return -EOPNOTSUPP; } +#ifdef CONFIG_BT_FEATURE_QUALITY_REPORT static inline int btintel_set_debug_features(struct hci_dev *hdev, const struct intel_debug_features *features) { return -EOPNOTSUPP; } +static inline int btintel_reset_debug_features(struct hci_dev *hdev, + const struct intel_debug_features *features) +{ + return -EOPNOTSUPP; +} +#endif + #endif diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 4c3b26c5e507..a3d5c520b55e 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -2903,6 +2903,11 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) btintel_load_ddc_config(hdev, ddcname); } +#ifdef CONFIG_BT_FEATURE_QUALITY_REPORT + hci_dev_clear_flag(hdev, HCI_QUALITY_REPORT); + bt_dev_dbg(hdev, "HCI_QUALITY_REPORT cleared"); +#endif + /* Read the Intel version information after loading the FW */ err = btintel_read_version(hdev, &ver); if (err) @@ -2990,6 +2995,11 @@ static int btusb_setup_intel_newgen(struct hci_dev *hdev) */ btintel_load_ddc_config(hdev, ddcname); +#ifdef CONFIG_BT_FEATURE_QUALITY_REPORT + hci_dev_clear_flag(hdev, HCI_QUALITY_REPORT); + bt_dev_dbg(hdev, "HCI_QUALITY_REPORT cleared"); +#endif + /* Read the Intel version information after loading the FW */ err = btintel_read_version_tlv(hdev, &version); if (err) @@ -4637,6 +4647,9 @@ 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; +#ifdef CONFIG_BT_FEATURE_QUALITY_REPORT + hdev->set_quality_report = btintel_set_quality_report; +#endif 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); @@ -4651,6 +4664,9 @@ 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; +#ifdef CONFIG_BT_FEATURE_QUALITY_REPORT + hdev->set_quality_report = btintel_set_quality_report; +#endif 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 Fri Jun 18 08:00:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Hwang X-Patchwork-Id: 12330539 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=-18.9 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, URIBL_BLOCKED,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 ADD89C48BE8 for ; Fri, 18 Jun 2021 08:01:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8C43261184 for ; Fri, 18 Jun 2021 08:01:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232724AbhFRIDb (ORCPT ); Fri, 18 Jun 2021 04:03:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232046AbhFRIDM (ORCPT ); Fri, 18 Jun 2021 04:03:12 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 802A2C0617AE for ; Fri, 18 Jun 2021 01:00:53 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id k6so7061443pfk.12 for ; Fri, 18 Jun 2021 01:00:53 -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=5HAONQPZe7/SR1yiilCYPmjw7Y/Yqrfapy71bu7s5Gk=; b=gqBgo5FtV2BrQiAKmxq8eBZbSZ9cprcFx89DZxsGsOJD4ELAzDm7qRpr4ccqXh3jw7 HbDBJvC2/d5WNSDLwo6W+RmvoB6VIWXI1LZD0MQqF2fntWXhuLXOnp2V4S4BrglM7XLu FX3PQo/RCBbBE3OxM5Ma/hupXfQMjDwOMsJNs= 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=5HAONQPZe7/SR1yiilCYPmjw7Y/Yqrfapy71bu7s5Gk=; b=jOUSw7B3Q4bTDXHnt5WVfuhbFPgyq9rmSIDdOtSVRmF3CJIKyDA4IssQxfpsI/UnHX vjZ9Toi+zM43fSwWzKbp5QdRRWnXC2QJEjKyfTBlkZ9n7U3S0Wa3A6dujVw9xsWc4jvD ZYhkPqVYv+ND9Cs9cEBjs1FA7qSJIdFMT2IT51m97Z9OxNd6hK5gfYhHsi2FsHiMa/le opgnk47jzMfY5ubrwl9fB5LyYrZtJmIYaukYwB2L6EqETGA16+KefTK/74+Gw17pzTjS 8Ui3DRLO2jtwplOEa18M7MSyJa/iMDmfu6/ILlTUHvOPtqxzEIXK1hTnbRU8r5yI9nWm ZNSw== X-Gm-Message-State: AOAM530ArN5OPkSFybhLzIuQty42kqm2z1M6VCDWjpiGPMj+vM6siC4E HBm/ymbCxxGd3/F24gV1Sl4XEGqP/JUIbA== X-Google-Smtp-Source: ABdhPJw7xUC/J4bt0UufwKr0rt03Po2lflZ68+7D2LCtbrD07yOb2doD5xUbq2bbliHgYytmbCtCNw== X-Received: by 2002:aa7:8bd6:0:b029:2ec:7dc9:77e3 with SMTP id s22-20020aa78bd60000b02902ec7dc977e3mr3937801pfd.62.1624003252595; Fri, 18 Jun 2021 01:00:52 -0700 (PDT) Received: from josephsih-z840.tpe.corp.google.com ([2401:fa00:1:10:6cbb:95eb:e2ae:8479]) by smtp.gmail.com with ESMTPSA id v21sm7341671pfu.77.2021.06.18.01.00.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 01:00:52 -0700 (PDT) From: Joseph Hwang To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com, pali@kernel.org Cc: josephsih@google.com, chromeos-bluetooth-upstreaming@chromium.org, Joseph Hwang , Miao-chen Chou , "David S. Miller" , Jakub Kicinski , Johan Hedberg , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v4 4/4] Bluetooth: Support the quality report events Date: Fri, 18 Jun 2021 16:00:39 +0800 Message-Id: <20210618160016.v4.4.I20c79eef4f36c4a3802e1068e59ec4a9f4ded940@changeid> X-Mailer: git-send-email 2.32.0.288.g62a8d224e6-goog In-Reply-To: <20210618160016.v4.1.I41aec59e65ffd3226d368dabeb084af13cc133c8@changeid> References: <20210618160016.v4.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 --- (no changes since v1) include/net/bluetooth/hci.h | 4 ++ include/net/bluetooth/hci_core.h | 22 ++++-- net/bluetooth/Kconfig | 11 +++ net/bluetooth/mgmt.c | 118 ++++++++++++++++++++++++++++++- 4 files changed, 148 insertions(+), 7 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index b80415011dcd..2811b60e1acc 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -331,6 +331,10 @@ enum { HCI_CMD_PENDING, HCI_FORCE_NO_MITM, +#ifdef CONFIG_BT_FEATURE_QUALITY_REPORT + HCI_QUALITY_REPORT, +#endif + __HCI_NUM_FLAGS, }; diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index a53e94459ecd..c25de25a7036 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -605,6 +605,9 @@ 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); +#ifdef CONFIG_BT_FEATURE_QUALITY_REPORT + int (*set_quality_report)(struct hci_dev *hdev, bool enable); +#endif }; #define HCI_PHY_HANDLE(handle) (handle & 0xff) @@ -752,12 +755,19 @@ extern struct mutex hci_cb_list_lock; #define hci_dev_test_and_clear_flag(hdev, nr) test_and_clear_bit((nr), (hdev)->dev_flags) #define hci_dev_test_and_change_flag(hdev, nr) test_and_change_bit((nr), (hdev)->dev_flags) -#define hci_dev_clear_volatile_flags(hdev) \ - do { \ - hci_dev_clear_flag(hdev, HCI_LE_SCAN); \ - 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); \ +#ifdef CONFIG_BT_FEATURE_QUALITY_REPORT +#define hci_dev_clear_flag_quality_report(x) { hci_dev_clear_flag(hdev, x); } +#else +#define hci_dev_clear_flag_quality_report(x) {} +#endif + +#define hci_dev_clear_volatile_flags(hdev) \ + do { \ + hci_dev_clear_flag(hdev, HCI_LE_SCAN); \ + 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_quality_report(HCI_QUALITY_REPORT) \ } while (0) /* ----- HCI interface to upper protocols ----- */ diff --git a/net/bluetooth/Kconfig b/net/bluetooth/Kconfig index e0ab4cd7afc3..d63c3cdf2d6f 100644 --- a/net/bluetooth/Kconfig +++ b/net/bluetooth/Kconfig @@ -148,4 +148,15 @@ config BT_FEATURE_DEBUG This provides an option to enable/disable debugging statements at runtime via the experimental features interface. +config BT_FEATURE_QUALITY_REPORT + bool "Runtime option for logging controller quality report events" + depends on BT + default n + help + This provides an option to enable/disable controller quality report + events logging at runtime via the experimental features interface. + The quality report events may include the categories of system + exceptions, connections/disconnection, the link quality statistics, + etc. + source "drivers/bluetooth/Kconfig" diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index d1bf5a55ff85..0de089524d74 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -3791,6 +3791,14 @@ static const u8 debug_uuid[16] = { }; #endif +#ifdef CONFIG_BT_FEATURE_QUALITY_REPORT +/* 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, +}; +#endif + /* 671b10b5-42c0-4696-9227-eb28d1b049d6 */ static const u8 simult_central_periph_uuid[16] = { 0xd6, 0x49, 0xb0, 0xd1, 0x28, 0xeb, 0x27, 0x92, @@ -3806,7 +3814,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 +3858,26 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, idx++; } +#ifdef CONFIG_BT_FEATURE_QUALITY_REPORT + 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++; + } +#endif + rp->feature_count = cpu_to_le16(idx); /* After reading the experimental features information, enable @@ -3892,6 +3920,23 @@ static int exp_debug_feature_changed(bool enabled, struct sock *skip) } #endif +#ifdef CONFIG_BT_FEATURE_QUALITY_REPORT +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); +} +#endif + static int set_exp_feature(struct sock *sk, struct hci_dev *hdev, void *data, u16 data_len) { @@ -4038,6 +4083,77 @@ static int set_exp_feature(struct sock *sk, struct hci_dev *hdev, return err; } +#ifdef CONFIG_BT_FEATURE_QUALITY_REPORT + 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; + } +#endif + return mgmt_cmd_status(sk, hdev ? hdev->id : MGMT_INDEX_NONE, MGMT_OP_SET_EXP_FEATURE, MGMT_STATUS_NOT_SUPPORTED);