From patchwork Wed May 25 10:50:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Hwang X-Patchwork-Id: 576039 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CB51C433F5 for ; Wed, 25 May 2022 10:50:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229736AbiEYKub (ORCPT ); Wed, 25 May 2022 06:50:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229604AbiEYKua (ORCPT ); Wed, 25 May 2022 06:50:30 -0400 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 596FC1C6 for ; Wed, 25 May 2022 03:50:29 -0700 (PDT) Received: by mail-pj1-x102a.google.com with SMTP id gk22so922237pjb.1 for ; Wed, 25 May 2022 03:50: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=/S9U3Gf8VokdT11z/FTy2YkWPpZtI3hDdvP6QmYOARw=; b=kAAkzLjGVsaTeOmvN4qaWDZxsyzTbN6+/fJ2VbXIm7HBUjxtomGjv87eFXypj7GB/m DUHGdaj0uK4yOsPP6HwTXL6XoTThWcfmR3qQLzERH9rNeW6+8k0LK5wmg8LIXEugKJ0/ yPQwEin6hCqvVd10Ei8lqjXPxJzfL4JNHEsYo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=/S9U3Gf8VokdT11z/FTy2YkWPpZtI3hDdvP6QmYOARw=; b=7gNhTYOQcA4iT1CQoLmx3sR7Kx86RVxgSiaAj3uhS0UYu92eTL2oZgjHJCOeAWgUXN +k+vw6DvcEP7RGrk1BUfHPOA+BybXwRCVl1fTUJPOV5bs1no+FL06ntEZfOKeC3UZ7CX 5JCi0X1oCPyRL6aC7OLFjmupppkMJtT+UJqalRbCv0j5X7VcBKQ12Gr3xvdHiaU3mliT DS1DR30RqQPCO+YtdGHkudo/OSafABQ6lnLW7hp+jPfFL8VjVZY6fw35o2O+DRsY1JaR KYwAwxxa4BIk9+SC6T25SigHJFaJ8As6emzDnkzcJ+EqYXW3Om76+A2L8j92kd2yIsaD l/lw== X-Gm-Message-State: AOAM530aX5JLBGg1cZG+cqkt96F6ZRE3G8/a2fwCottOVjno3TaxPt5l Mjy9qftOC1rMmX8cvgOgx7nyaGpuWbpZ5g== X-Google-Smtp-Source: ABdhPJy6aQ7UjkSlbeV/TNGavDFllf6QGicJ5wDbD1QRqDuihIkMWWBE+2j7oJSysCT1jwz8IDDsOQ== X-Received: by 2002:a17:90b:3ecd:b0:1dc:945e:41b1 with SMTP id rm13-20020a17090b3ecd00b001dc945e41b1mr9815653pjb.208.1653475828702; Wed, 25 May 2022 03:50:28 -0700 (PDT) Received: from localhost (174.71.80.34.bc.googleusercontent.com. [34.80.71.174]) by smtp.gmail.com with UTF8SMTPSA id z13-20020a056a00240d00b0050dc762819bsm11217510pfh.117.2022.05.25.03.50.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 25 May 2022 03:50:28 -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 Subject: [BlueZ PATCH v5 1/8] doc: Introduce the quality report command and event Date: Wed, 25 May 2022 18:50:08 +0800 Message-Id: <20220525105015.2315987-1-josephsih@chromium.org> X-Mailer: git-send-email 2.36.1.124.g0e6072fb45-goog MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Add the MGMT quality report command and event in doc/mgmt-api.txt. --- Changes in v5: - Use Quality_Report instead of Action in mgmt-api.txt. - Modify the description of Set Quality Report Command. Changes in v4: - Use "Quality Report Event" without the prefix "Bluetooth" word. - Combine both MGMT quality report command and event changes in a single patch. Changes in v3: - Swap AOSP Bluetooth Quality Report Event and Intel Telemetry Event. - Add 5 new patches (5/9 - 9/9) to enable the quality report feature via MGMT_OP_SET_QUALITY_REPORT instead of through the experimental features. Changes in v2: - This is a new patch for adding the event in doc/mgmt-api.txt doc/mgmt-api.txt | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt index ebe56afa4..a429f0ef3 100644 --- a/doc/mgmt-api.txt +++ b/doc/mgmt-api.txt @@ -332,6 +332,7 @@ Read Controller Information Command 15 Static Address 16 PHY Configuration 17 Wideband Speech + 18 Quality Report This command generates a Command Complete event on success or a Command Status event on failure. @@ -2924,6 +2925,7 @@ Read Extended Controller Information Command 15 Static Address 16 PHY Configuration 17 Wideband Speech + 18 Quality Report The EIR_Data field contains information about class of device, local name and other values. Not all of them might be present. For @@ -3858,6 +3860,45 @@ Add Advertisement Patterns Monitor With RSSI Threshold Command Invalid Parameters +Set Quality Report Command +========================== + + Command Code: 0x0057 + Controller Index: + Command Parameters: Quality_Report (1 Octet) + Return Parameters: Current_Settings (4 Octets) + + This command is used to enable and disable the controller's quality + report feature. The allowed values for the Quality_Report command + parameter are 0x00 and 0x01. All other values will return Invalid + Parameters. + + The value 0x00 disables the Quality Report, and the value 0x01 + enables the Quality Report feature. + + This command is only available for the controllers that support + either AOSP Bluetooth quality report or Intel telemetry event. + It is supported if the supported_settings indicate support for it. + + This command requires to use a valid controller index. Otherwise, + an Invalid Index status will be returned. + + The command is sent to the controller to enable/disable the quality + report feature, and generates a Command Complete event on success. + If the controller failed to execute the action, a Failed status will + be returned. + + The quality report state is maintained by the kernel over the adapter + power cycle. When the adapter is powered off, the quality report + feature is disabled by the kernel. When the adapter is powered on, it + is enabled again by the kernel if it was enabled before. + + Possible errors: Failed + Invalid Index + Invalid Parameters + Not Supported + + Command Complete Event ====================== @@ -4978,3 +5019,22 @@ Advertisement Monitor Device Lost Event 2 LE Random This event will be sent to all management sockets. + + +Quality Report Event +==================== + + Event code: 0x0031 + Controller Index: + Event Parameters: Quality_Spec (1 Octet) + Report_Len (2 Octets) + Report (0-65535 Octets) + + This event carries the Bluetooth quality report sent by the + controller. + + Possible values for the Quality_Spec parameter: + 0 AOSP Bluetooth Quality Report Event + 1 Intel Telemetry Event + + This event will be sent to all management sockets. From patchwork Wed May 25 10:50:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Hwang X-Patchwork-Id: 577009 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9FC0C433F5 for ; Wed, 25 May 2022 10:50:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230326AbiEYKuf (ORCPT ); Wed, 25 May 2022 06:50:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229604AbiEYKue (ORCPT ); Wed, 25 May 2022 06:50:34 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39F029588 for ; Wed, 25 May 2022 03:50:32 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id w3so11604366plp.13 for ; Wed, 25 May 2022 03:50:32 -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=onOqx5Fpa2xZe+G9sIa3BkOaz4cWIfCQZPOA6oQs8qQ=; b=IXjmgcxbc3bJEpVVSy61Wg++pKXd1UxYPK5nb3b32bZr0DdFpECl/JlkkUrXVaqphj bQgqIp5tJzyKepiEvh4Z46KDO50ksv0+6M7dtWO5dpMRQ9CGE+Ia4hhQ5TvTWlLRPUGA 0PFAR/egqCHVisyZEmKiMEPfh9h/cGoPOST3s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=onOqx5Fpa2xZe+G9sIa3BkOaz4cWIfCQZPOA6oQs8qQ=; b=RT43/dOhWoT8CW6D5YNmtYNOzSx8wECAvg0XzYATLN7lQAg1qI28c40vlWssqFLBZZ rRW8LdqUVEBjVamcJ0avWFcUOPTPO+6FG4tYlLe0VqUd6nhCYgvAceZOPa4Lo023muh+ DMuRuxyxxkUAsAuW4v/Pktvq7GB24GrbyRzDUAjiy+E9Hc//UYa5wjZ3QfCtGMc+Ir+n yTmxdJctH4ofuLO6jf9mV7zO3Ds70e/eUaEmB6G3opjmuCZ5o+N2znSsPBIcvxickIl2 8LEMrWCgmbMGMmL7h9JZdbqxLU5hnIPuN4yR+z8MN1JxTDkq54rQ+bfmC8XisYeAwNpj yLdg== X-Gm-Message-State: AOAM530M28N2bJEu64HVoazd1fuCTQlIb36UVky/Xp2STPEpVAeH7f4m UFRz0JzX/Z5vn53a6koCbQXHu8g04HdJqQ== X-Google-Smtp-Source: ABdhPJyIuPbuEoAuj7fuILItknDj/1+k5q1PUwS2a/lAfjI5EMPsIFo5iazQOcE2BizlKs3WfI8MLA== X-Received: by 2002:a17:902:ec8a:b0:161:7ca5:eced with SMTP id x10-20020a170902ec8a00b001617ca5ecedmr32292930plg.17.1653475831440; Wed, 25 May 2022 03:50:31 -0700 (PDT) Received: from localhost (174.71.80.34.bc.googleusercontent.com. [34.80.71.174]) by smtp.gmail.com with UTF8SMTPSA id a13-20020a17090abe0d00b001cd4989feebsm1203709pjs.55.2022.05.25.03.50.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 25 May 2022 03:50:31 -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 Subject: [BlueZ PATCH v5 2/8] lib: Add structures and constants for quality report command and event Date: Wed, 25 May 2022 18:50:09 +0800 Message-Id: <20220525105015.2315987-2-josephsih@chromium.org> X-Mailer: git-send-email 2.36.1.124.g0e6072fb45-goog In-Reply-To: <20220525105015.2315987-1-josephsih@chromium.org> References: <20220525105015.2315987-1-josephsih@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Add the new MGMT struct and constants to lib/mgmt.h. --- Changes in v5: - Use quality_report instead of action in struct mgmt_cp_set_quality_report. - Declare "const uint8_t data[];" Changes in v4: - Combine both MGMT command and event changes in a single patch. - Fix namings of QUALITY_SPEC_AOSP and QUALITY_SPEC_INTEL. - Use "Quality Report" without the prefix "Bluetooth". Changes in v3: - Swap AOSP Bluetooth Quality Report Event and Intel Telemetry Event. Changes in v2: - This is a new patch for adding the new struct and constants. lib/mgmt.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/mgmt.h b/lib/mgmt.h index 922a24367..fd59ef6fa 100644 --- a/lib/mgmt.h +++ b/lib/mgmt.h @@ -96,6 +96,7 @@ struct mgmt_rp_read_index_list { #define MGMT_SETTING_STATIC_ADDRESS 0x00008000 #define MGMT_SETTING_PHY_CONFIGURATION 0x00010000 #define MGMT_SETTING_WIDEBAND_SPEECH 0x00020000 +#define MGMT_SETTING_QUALITY_REPORT 0x00040000 #define MGMT_OP_READ_INFO 0x0004 struct mgmt_rp_read_info { @@ -757,6 +758,14 @@ struct mgmt_cp_add_adv_patterns_monitor_rssi { struct mgmt_adv_pattern patterns[0]; } __packed; +#define MGMT_OP_SET_QUALITY_REPORT 0x0057 +struct mgmt_cp_set_quality_report { + uint8_t quality_report; +} __packed; +struct mgmt_rp_set_quality_report { + uint32_t current_settings; +} __packed; + #define MGMT_EV_CMD_COMPLETE 0x0001 struct mgmt_ev_cmd_complete { uint16_t opcode; @@ -1032,6 +1041,15 @@ struct mgmt_ev_adv_monitor_device_lost { struct mgmt_addr_info addr; } __packed; +#define MGMT_EV_QUALITY_REPORT 0x0031 +#define QUALITY_SPEC_AOSP 0x0 +#define QUALITY_SPEC_INTEL 0x1 +struct mgmt_ev_quality_report { + uint8_t quality_spec; + uint32_t data_len; + const uint8_t data[]; +} __packed; + static const char *mgmt_op[] = { "<0x0000>", "Read Version", @@ -1172,6 +1190,7 @@ static const char *mgmt_ev[] = { "Controller Resume", "Advertisement Monitor Device Found", /* 0x002f */ "Advertisement Monitor Device Lost", + "Quality Report", /* 0x0031 */ }; static const char *mgmt_status[] = { From patchwork Wed May 25 10:50:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Hwang X-Patchwork-Id: 576038 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B02EC433F5 for ; Wed, 25 May 2022 10:50:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231163AbiEYKuh (ORCPT ); Wed, 25 May 2022 06:50:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229604AbiEYKuf (ORCPT ); Wed, 25 May 2022 06:50:35 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC73A1C6 for ; Wed, 25 May 2022 03:50:34 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id v5-20020a17090a7c0500b001df84fa82f8so4677712pjf.5 for ; Wed, 25 May 2022 03:50:34 -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=/+P/7k1LChvI26DD9TDcF/h4mBlWn8AMjL3OetW7svw=; b=U0BkY3nCf0ZKzy/JlzQaWxci40PBuP+83Fi6cZlkI/E0mRuMx5ves07vSOyFmtBFpZ 8MPfGjw0QxU6GG+RbQcEU1PP2v8v7earmVvspYRWMkxUWYDFnsgLxNI79gVcQpWxK36f zqoR7lDXzGGBrtR/DdVgkPyRHciuoStnB4c+8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/+P/7k1LChvI26DD9TDcF/h4mBlWn8AMjL3OetW7svw=; b=ixjtXhePsRio0TFidSIGDhXt3ly8zv4b2HN4T9hMbxwPctuT+0OhpUACO0T1DkBvnm JFDj5v6h+0BNlNe85uzJcrHjgLdfFPIOMOS/e4dkSuht2zfaO6Z7iB2hfjsGufE/0XIQ VWQRNro5r1+BIHhEwvv+h9TyxK0X31v/8K1L9yBVrEeV7wIFGGLj1eTv5rUKmp/IQySO T+Trx/MMPKP+eDKa28XapG2CbHHwf1pXPDaSaAAabWXYBdHm83wVHdGATdEsEL+/LrC3 ekpNMvKtUAd/h2HtBWIOxyGkNBGLIcw+aItuTwHIVoTnGets5OK9UHZEi8XqFhPn5Zuc zxFw== X-Gm-Message-State: AOAM531l+IurZJgFgDOdJQqtIxCoWd+A0zWLxsI7D39g0PVxCygM/Wot ovS6NFAESy1o1DqnJGDSkTBE4xbFhjNL3Q== X-Google-Smtp-Source: ABdhPJzxi1p/BIeQg+gEd16KVGKSgEMmTz4wwokyMY0bWnH71F/Loeocg4W23B/WCiXi6KI55w3c5g== X-Received: by 2002:a17:902:c752:b0:161:7cb4:78b1 with SMTP id q18-20020a170902c75200b001617cb478b1mr31801632plq.166.1653475834023; Wed, 25 May 2022 03:50:34 -0700 (PDT) Received: from localhost (174.71.80.34.bc.googleusercontent.com. [34.80.71.174]) by smtp.gmail.com with UTF8SMTPSA id v4-20020a17090a458400b001d9780b7779sm1282983pjg.15.2022.05.25.03.50.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 25 May 2022 03:50:33 -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 Subject: [BlueZ PATCH v5 3/8] adapter: remove quality report from experimental features Date: Wed, 25 May 2022 18:50:10 +0800 Message-Id: <20220525105015.2315987-3-josephsih@chromium.org> X-Mailer: git-send-email 2.36.1.124.g0e6072fb45-goog In-Reply-To: <20220525105015.2315987-1-josephsih@chromium.org> References: <20220525105015.2315987-1-josephsih@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org The quality report feature is now enabled through MGMT_OP_SET_QUALITY_REPORT instead of through the experimental features. --- Changes in v5: - Move is_quality_report_supported() implementation to next patch. The function does not belong to this patch. Changes in v4: - Move forward this patch in the patch series so that this command patch is prior to the quality report event patches. Changes in v3: - This is a new patch that enables the quality report feature via MGMT_OP_SET_QUALITY_REPORT. src/adapter.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index db2624c60..d0abb2a3c 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -120,13 +120,6 @@ static const struct mgmt_exp_uuid le_simult_central_peripheral_uuid = { .str = "671b10b5-42c0-4696-9227-eb28d1b049d6" }; -/* 330859bc-7506-492d-9370-9a6f0614037f */ -static const struct mgmt_exp_uuid quality_report_uuid = { - .val = { 0x7f, 0x03, 0x14, 0x06, 0x6f, 0x9a, 0x70, 0x93, - 0x2d, 0x49, 0x06, 0x75, 0xbc, 0x59, 0x08, 0x33 }, - .str = "330859bc-7506-492d-9370-9a6f0614037f" -}; - /* 15c0a148-c273-11ea-b3de-0242ac130004 */ static const struct mgmt_exp_uuid rpa_resolution_uuid = { .val = { 0x04, 0x00, 0x13, 0xac, 0x42, 0x02, 0xde, 0xb3, @@ -9617,12 +9610,6 @@ static void le_simult_central_peripheral_func(struct btd_adapter *adapter, (void *)le_simult_central_peripheral_uuid.val); } -static void quality_report_func(struct btd_adapter *adapter, uint8_t action) -{ - if (action) - queue_push_tail(adapter->exps, (void *)quality_report_uuid.val); -} - static void set_rpa_resolution_complete(uint8_t status, uint16_t len, const void *param, void *user_data) { @@ -9698,7 +9685,6 @@ static const struct exp_feat { EXP_FEAT(&debug_uuid, exp_debug_func), EXP_FEAT(&le_simult_central_peripheral_uuid, le_simult_central_peripheral_func), - EXP_FEAT(&quality_report_uuid, quality_report_func), EXP_FEAT(&rpa_resolution_uuid, rpa_resolution_func), EXP_FEAT(&codec_offload_uuid, codec_offload_func), }; From patchwork Wed May 25 10:50:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Hwang X-Patchwork-Id: 577008 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 761B3C433EF for ; Wed, 25 May 2022 10:50:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231607AbiEYKul (ORCPT ); Wed, 25 May 2022 06:50:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231229AbiEYKuj (ORCPT ); Wed, 25 May 2022 06:50:39 -0400 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D24F140AD for ; Wed, 25 May 2022 03:50:38 -0700 (PDT) Received: by mail-pg1-x534.google.com with SMTP id 137so18610841pgb.5 for ; Wed, 25 May 2022 03:50:38 -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=HfDRSkq5af+3lqek6h75Ep8d3Xl1FWuhUOBxKYneEs4=; b=fe9lWb4HKsyTY9jxTTtDU/4Vx1y7ht0MLWPOviBc1yDpEfzZwOXNiCezYxd3w9KDwM 7VHe2p6cPWbrIu04S8dAv3ikXNfKASwTMtvzCCnQgyHxF8jVIWw5rcTDq3t4V8+I/oQr yNelE5YOkBUlcjmduTxEzh3kJeDS4Uw3TbVTo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HfDRSkq5af+3lqek6h75Ep8d3Xl1FWuhUOBxKYneEs4=; b=JsUb+yEbfX6KkptU7nRwIgpvYOs+NrFpVwPsemUdn6AleNCwaqq6ki2PUC8yoC2Z3s fOKPOIOh7jUS7t88KsnZRcwoY5+P9t0gmF/nVnVT7MmZx1O2igF8DX9Tmdfz4Oyo8Uec wQk+07kjg/0zWg9YYkg/auebmLnmT27LprkEj7bM76Batw/RTl6r6h0MwIRR/zsKB1uy K57pjgz3AfBfdc7prKqMX3SH8kCJaG+K+KvcH3SV1+lQfJ9EtUFtTjOTqZju/xR0/Szm KaqJJ/9/hfod/MkyMMMBkSsF/0zop1mynFRRBqv/kG8fek5CPGmCsvcx+COUod2xNR+r /Lgg== X-Gm-Message-State: AOAM531ZQOy3EFU+Eau1UYIIkbDn2sYYLfTxQM5nLT1GmgiKM2LNZRAx m/osRHzvhJB5Uj50J8zko2/rhWDEH8qLHQ== X-Google-Smtp-Source: ABdhPJzKDNcmdNTqG2wFFVFPkr+qtbFGlBlajWTeW/V/MDqqnHc7AT7l0nCrURQiXn7ccSXHdPDvpg== X-Received: by 2002:a05:6a00:140c:b0:4e1:530c:edc0 with SMTP id l12-20020a056a00140c00b004e1530cedc0mr33379477pfu.18.1653475837368; Wed, 25 May 2022 03:50:37 -0700 (PDT) Received: from localhost (174.71.80.34.bc.googleusercontent.com. [34.80.71.174]) by smtp.gmail.com with UTF8SMTPSA id u22-20020a17090ae01600b001df666ebddesm1290753pjy.6.2022.05.25.03.50.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 25 May 2022 03:50:37 -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 , Archie Pusaka Subject: [BlueZ PATCH v5 4/8] adapter: support AOSP MGMT_EV_QUALITY_REPORT Date: Wed, 25 May 2022 18:50:11 +0800 Message-Id: <20220525184842.BlueZ.v5.4.Ie4d1be8ced51f0aa92ee6d8eacf9666a121a1292@changeid> X-Mailer: git-send-email 2.36.1.124.g0e6072fb45-goog In-Reply-To: <20220525105015.2315987-1-josephsih@chromium.org> References: <20220525105015.2315987-1-josephsih@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch supports a new MGMT event of AOSP bluetooth quality report. Reviewed-by: Archie Pusaka --- Changes in v5: - Do not use the circular inclusion protection for src/shared/aosp.h - Move the is_quality_report_supported() implementation from previous patch to this patch. And make it static. Changes in v4: - Change QUALITY_SPEC_AOSP_BQR to QUALITY_SPEC_AOSP. Changes in v2: - The new structs and constants are moved to separate patches: * doc: Add Bluetooth quality report event * lib: Add structures and constants for quality report - The btmon decoding patches, about 500 lines of code, are ready and will be submitted immediately after these patches are accepted. - Use util_debug instead of defining a new debug function. - Remove the event printing function. - The plan about the BQR events is to further expose them to other daemons, e.g., an audio daemon to make some smart control, or to an UI daemon to display alerts to users. Makefile.am | 3 +- src/adapter.c | 48 +++++++++++++++++++++++++ src/shared/aosp.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++ src/shared/aosp.h | 54 ++++++++++++++++++++++++++++ 4 files changed, 194 insertions(+), 1 deletion(-) create mode 100644 src/shared/aosp.c create mode 100644 src/shared/aosp.h diff --git a/Makefile.am b/Makefile.am index 82125c482..600d85354 100644 --- a/Makefile.am +++ b/Makefile.am @@ -230,7 +230,8 @@ shared_sources = src/shared/io.h src/shared/timeout.h \ src/shared/gatt-db.h src/shared/gatt-db.c \ src/shared/gap.h src/shared/gap.c \ src/shared/log.h src/shared/log.c \ - src/shared/tty.h + src/shared/tty.h \ + src/shared/aosp.h src/shared/aosp.c if READLINE shared_sources += src/shared/shell.c src/shared/shell.h diff --git a/src/adapter.c b/src/adapter.c index d0abb2a3c..537ec3a11 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -47,6 +47,7 @@ #include "src/shared/att.h" #include "src/shared/gatt-db.h" #include "src/shared/timeout.h" +#include "src/shared/aosp.h" #include "btio/btio.h" #include "btd.h" @@ -9192,6 +9193,28 @@ static void controller_resume_callback(uint16_t index, uint16_t length, controller_resume_notify(adapter); } +static void quality_report_callback(uint16_t index, uint16_t length, + const void *param, void *user_data) +{ + const struct mgmt_ev_quality_report *ev = param; + + if (!ev) + return; + + if (length < sizeof(*ev)) { + error("MGMT_EV_QUALITY_REPORT event too small"); + return; + } + + if (ev->quality_spec == QUALITY_SPEC_AOSP) { + if (!process_aosp_quality_report(ev)) + error("processing aosp quality report"); + } else { + error("quality report spec %u not supported.", + ev->quality_spec); + } +} + static void device_blocked_callback(uint16_t index, uint16_t length, const void *param, void *user_data) { @@ -9758,6 +9781,23 @@ static void read_exp_features(struct btd_adapter *adapter) btd_error(adapter->dev_id, "Failed to read exp features info"); } +static bool is_quality_report_supported(struct btd_adapter *adapter) +{ + return !!(adapter->supported_settings & MGMT_SETTING_QUALITY_REPORT); +} + +static void quality_report_debug(const char *str, void *user_data) +{ + const char *prefix = user_data; + + info("%s%s", prefix, str); +} + +static void quality_set_debug(struct btd_adapter *adapter) +{ + aosp_set_debug(quality_report_debug, "quality: "); +} + static void read_info_complete(uint8_t status, uint16_t length, const void *param, void *user_data) { @@ -9996,6 +10036,11 @@ static void read_info_complete(uint8_t status, uint16_t length, controller_resume_callback, adapter, NULL); + mgmt_register(adapter->mgmt, MGMT_EV_QUALITY_REPORT, + adapter->dev_id, + quality_report_callback, + adapter, NULL); + set_dev_class(adapter); set_name(adapter, btd_adapter_get_name(adapter)); @@ -10023,6 +10068,9 @@ static void read_info_complete(uint8_t status, uint16_t length, if (btd_adapter_get_powered(adapter)) adapter_start(adapter); + if (is_quality_report_supported(adapter) && getenv("QUALITY_DEBUG")) + quality_set_debug(adapter); + return; failed: diff --git a/src/shared/aosp.c b/src/shared/aosp.c new file mode 100644 index 000000000..838babea4 --- /dev/null +++ b/src/shared/aosp.c @@ -0,0 +1,90 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2021 Google LLC + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + +#include +#include +#include +#include + +#include "lib/bluetooth.h" +#include "lib/mgmt.h" + +#include "src/shared/aosp.h" +#include "src/shared/util.h" + +static struct { + aosp_debug_func_t callback; + void *data; +} aosp_debug; + +void aosp_set_debug(aosp_debug_func_t callback, void *user_data) +{ + aosp_debug.callback = callback; + aosp_debug.data = user_data; +} + +bool process_aosp_quality_report(const struct mgmt_ev_quality_report *ev) +{ + const struct aosp_bqr *edata = (struct aosp_bqr *)ev->data; + struct aosp_bqr bqr; + + if (edata->subevent_code != 0x58) { + util_debug(aosp_debug.callback, aosp_debug.data, + "error: %u not AOSP Bluetooth quality report subevent", + edata->subevent_code); + return false; + } + + if (ev->data_len < sizeof(struct aosp_bqr)) { + util_debug(aosp_debug.callback, aosp_debug.data, + "error: AOSP report size %u too small (expect >= %lu).", + ev->data_len, sizeof(struct aosp_bqr)); + return false; + } + + /* Ignore the Vendor Specific Parameter (VSP) field for now + * due to the lack of standard way of reading it. + */ + bqr.quality_report_id = edata->quality_report_id; + bqr.packet_type = edata->packet_type; + bqr.conn_handle = btohs(edata->conn_handle); + bqr.conn_role = edata->conn_role; + bqr.tx_power_level = edata->tx_power_level; + bqr.rssi = edata->rssi; + bqr.snr = edata->snr; + bqr.unused_afh_channel_count = edata->unused_afh_channel_count; + bqr.afh_select_unideal_channel_count = + edata->afh_select_unideal_channel_count; + bqr.lsto = btohs(edata->lsto); + bqr.conn_piconet_clock = btohl(edata->conn_piconet_clock); + bqr.retransmission_count = btohl(edata->retransmission_count); + bqr.no_rx_count = btohl(edata->no_rx_count); + bqr.nak_count = btohl(edata->nak_count); + bqr.last_tx_ack_timestamp = btohl(edata->last_tx_ack_timestamp); + bqr.flow_off_count = btohl(edata->flow_off_count); + bqr.last_flow_on_timestamp = btohl(edata->last_flow_on_timestamp); + bqr.buffer_overflow_bytes = btohl(edata->buffer_overflow_bytes); + bqr.buffer_underflow_bytes = btohl(edata->buffer_underflow_bytes); + + util_debug(aosp_debug.callback, aosp_debug.data, + "AOSP report of connection hanle %u received", bqr.conn_handle); + + return true; +} diff --git a/src/shared/aosp.h b/src/shared/aosp.h new file mode 100644 index 000000000..39b3adcc8 --- /dev/null +++ b/src/shared/aosp.h @@ -0,0 +1,54 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2021 Google LLC + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + +#include +#include + +struct mgmt_ev_quality_report; + +struct aosp_bqr { + uint8_t subevent_code; + uint8_t quality_report_id; + uint8_t packet_type; + uint16_t conn_handle; + uint8_t conn_role; + int8_t tx_power_level; /* -30 to 20 dbm */ + int8_t rssi; /* -127 to 20 dbm */ + uint8_t snr; /* db */ + uint8_t unused_afh_channel_count; + uint8_t afh_select_unideal_channel_count; + uint16_t lsto; + uint32_t conn_piconet_clock; + uint32_t retransmission_count; + uint32_t no_rx_count; + uint32_t nak_count; + uint32_t last_tx_ack_timestamp; + uint32_t flow_off_count; + uint32_t last_flow_on_timestamp; + uint32_t buffer_overflow_bytes; + uint32_t buffer_underflow_bytes; + + uint8_t vsp[0]; /* Vendor Specific Parameter */ +} __packed; + +typedef void (*aosp_debug_func_t)(const char *str, void *user_data); +void aosp_set_debug(aosp_debug_func_t callback, void *user_data); + +bool process_aosp_quality_report(const struct mgmt_ev_quality_report *ev); From patchwork Wed May 25 10:50:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Hwang X-Patchwork-Id: 576036 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57269C433FE for ; Wed, 25 May 2022 10:50:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232894AbiEYKus (ORCPT ); Wed, 25 May 2022 06:50:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231229AbiEYKun (ORCPT ); Wed, 25 May 2022 06:50:43 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14D241C6 for ; Wed, 25 May 2022 03:50:41 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id v5-20020a17090a7c0500b001df84fa82f8so4677712pjf.5 for ; Wed, 25 May 2022 03:50:41 -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=Jp9tpcW0C2dQUt4wvwkJxbSRqM6ZA2dPiRKIr6RxLwE=; b=LoThnp4EXOjarnuZ5lKrHelE2qGF1wXlOsr6WL7ZkNScJOFhbEjk/QvyoP8E0+Af3H cOf+Sri9fjzkljlfkLbPgyIYR38ZFaJX90Rh1aS91VPvGqDJRYHeBk3sUceD15tvq6Z2 Q6mv1qvYR5Q56cUPAfBuFL58lB7tKmQUFe5G0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Jp9tpcW0C2dQUt4wvwkJxbSRqM6ZA2dPiRKIr6RxLwE=; b=FVL1zf2iQvO0N58vL2uMSXb0HQU4uP4XpAvkYAwFtYJIizqLGx4UtXhhujUtg2Xuho TydEeVuWf+HwFlKEnOJVn5Ye1r/k+T9/AzvLQR8SuWmnGBedLhWW9TEBBYrlAcDL2ZR0 lucGVppBNotbHq8h9RJklHkAphLYuHROy38TLVDI02JU6rXVgyFaXM7Zgglu048Bz2Qk 5eBlJBDvA3xYcKrXPAoYhE0OfigWn9rcAihrE655a+4VOAaHLxE/7EPG4Ieubi5LBm21 FTZ43WzVmCHv5A5DPmg5xaqcvKYs6yU2/B4gBHM1ot2I/7PCZDBjNYpNcGP2sLdV2WAQ Bw0g== X-Gm-Message-State: AOAM531Rf+XlPW07uRY5X4nrUe0AmkYo4Tt+apqueYXpbolr82ykVHVv pxISYMHOaSw/3zVJdaklu5w5mFzeoB4RAg== X-Google-Smtp-Source: ABdhPJySz6plU4+3ElYEn722MTVOGFv4TXYvvL34jDsaLBM8g0eELu+aJxpXsUQAGpOkvlttWUaY6Q== X-Received: by 2002:a17:90b:3b4c:b0:1e0:2c34:fbe8 with SMTP id ot12-20020a17090b3b4c00b001e02c34fbe8mr9843292pjb.70.1653475840254; Wed, 25 May 2022 03:50:40 -0700 (PDT) Received: from localhost (174.71.80.34.bc.googleusercontent.com. [34.80.71.174]) by smtp.gmail.com with UTF8SMTPSA id w66-20020a628245000000b0050dc7628179sm11012895pfd.83.2022.05.25.03.50.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 25 May 2022 03:50:40 -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 , Archie Pusaka Subject: [BlueZ PATCH v5 5/8] adapter: support Intel MGMT_EV_QUALITY_REPORT Date: Wed, 25 May 2022 18:50:12 +0800 Message-Id: <20220525184842.BlueZ.v5.5.Ifdf5cf89a14b4f293d868910c6cb85e802f7eb9e@changeid> X-Mailer: git-send-email 2.36.1.124.g0e6072fb45-goog In-Reply-To: <20220525105015.2315987-1-josephsih@chromium.org> References: <20220525105015.2315987-1-josephsih@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch supports a new MGMT event of Intel telemetry report. Reviewed-by: Archie Pusaka --- Changes in v5: - Remove signed-off-by for user space. - Re: "I wonder why you do not use subevent->attr as an union?" My reply: The subevent->attr is a pointer that points to the actual target attribute in either intel_acl_event or intel_sco_event (both of which are combined as a union in intel_ext_telemetry_event). In this way, we do not need to define the subevent functions for the subevents and save lots of code. - Re: "Is the cast really needed here?" My reply: Yes, it is needed. Otherwise, we got a warning: "incompatible pointer types [-Wincompatible-pointer-types]" - Declare "const uint8_t data[];" in struct mgmt_ev_quality_report for ev->data in lib/mgmt.h. - In quality_set_debug(), call intel_set_debug() and aosp_set_debug() for both specifications. - Do not use the circular inclusion protection for src/shared/intel.h Changes in v4: - Change QUALITY_SPEC_INTEL_TELEMETRY to QUALITY_SPEC_INTEL. Changes in v2: - Remove the event printing function. The btmon decoding patches are ready and will be submitted after these are accepted. Makefile.am | 3 +- src/adapter.c | 5 + src/shared/intel.c | 243 +++++++++++++++++++++++++++++++++++++++++++++ src/shared/intel.h | 150 ++++++++++++++++++++++++++++ 4 files changed, 400 insertions(+), 1 deletion(-) create mode 100644 src/shared/intel.c create mode 100644 src/shared/intel.h diff --git a/Makefile.am b/Makefile.am index 600d85354..6dc16f226 100644 --- a/Makefile.am +++ b/Makefile.am @@ -231,7 +231,8 @@ shared_sources = src/shared/io.h src/shared/timeout.h \ src/shared/gap.h src/shared/gap.c \ src/shared/log.h src/shared/log.c \ src/shared/tty.h \ - src/shared/aosp.h src/shared/aosp.c + src/shared/aosp.h src/shared/aosp.c \ + src/shared/intel.h src/shared/intel.c if READLINE shared_sources += src/shared/shell.c src/shared/shell.h diff --git a/src/adapter.c b/src/adapter.c index 537ec3a11..9020f44e6 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -48,6 +48,7 @@ #include "src/shared/gatt-db.h" #include "src/shared/timeout.h" #include "src/shared/aosp.h" +#include "src/shared/intel.h" #include "btio/btio.h" #include "btd.h" @@ -9209,6 +9210,9 @@ static void quality_report_callback(uint16_t index, uint16_t length, if (ev->quality_spec == QUALITY_SPEC_AOSP) { if (!process_aosp_quality_report(ev)) error("processing aosp quality report"); + } else if (ev->quality_spec == QUALITY_SPEC_INTEL) { + if (!process_intel_telemetry_report(ev)) + error("processing intel telemetry report"); } else { error("quality report spec %u not supported.", ev->quality_spec); @@ -9795,6 +9799,7 @@ static void quality_report_debug(const char *str, void *user_data) static void quality_set_debug(struct btd_adapter *adapter) { + intel_set_debug(quality_report_debug, "quality: "); aosp_set_debug(quality_report_debug, "quality: "); } diff --git a/src/shared/intel.c b/src/shared/intel.c new file mode 100644 index 000000000..5d7c0d0ad --- /dev/null +++ b/src/shared/intel.c @@ -0,0 +1,243 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2021 Google LLC + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + +#include +#include +#include +#include + +#include "lib/bluetooth.h" +#include "lib/mgmt.h" + +#include "src/shared/intel.h" +#include "src/shared/util.h" + +#define COMPANY_ID_INTEL 0x0002 + +struct intel_ext_telemetry_event tev; + +static struct { + intel_debug_func_t callback; + void *data; +} intel_debug; + +/* Use offsetof to access the attributes of structures. This makes + * simple traversing and assigning values to the attributes. + */ +#define TELEM_OFFSET(a) offsetof(struct intel_ext_telemetry_event, a) +#define TELEM_ATTR(a) (((uint8_t *)&tev) + TELEM_OFFSET(a)) + +#define ACL_OFFSET(a) offsetof(struct intel_acl_event, a) +#define ACL_ATTR(a) (((uint8_t *)&tev.conn.acl) + ACL_OFFSET(a)) +#define ACL_ATTR_ARRAY(a, i) (ACL_ATTR(a) + i * sizeof(tev.conn.acl.a[0])) + +#define SCO_OFFSET(a) offsetof(struct intel_sco_event, a) +#define SCO_ATTR(a) (((uint8_t *)&tev.conn.sco) + SCO_OFFSET(a)) + +static const struct intel_ext_subevent { + uint8_t id; + uint8_t size; + uint8_t elements; + uint8_t *attr; /* address of the attribute in tev */ +} intel_ext_subevent_table[] = { + { 0x01, 1, 1, TELEM_ATTR(telemetry_ev_type) }, + + /* ACL audio link quality subevents */ + { 0x4a, 2, 1, ACL_ATTR(conn_handle) }, + { 0x4b, 4, 1, ACL_ATTR(rx_hec_error) }, + { 0x4c, 4, 1, ACL_ATTR(rx_crc_error) }, + { 0x4d, 4, 1, ACL_ATTR(packets_from_host) }, + { 0x4e, 4, 1, ACL_ATTR(tx_packets) }, + { 0x4f, 4, 1, ACL_ATTR_ARRAY(tx_packets_retry, 0) }, + { 0x50, 4, 1, ACL_ATTR_ARRAY(tx_packets_retry, 1) }, + { 0x51, 4, 1, ACL_ATTR_ARRAY(tx_packets_retry, 2) }, + { 0x52, 4, 1, ACL_ATTR_ARRAY(tx_packets_retry, 3) }, + { 0x53, 4, 1, ACL_ATTR_ARRAY(tx_packets_retry, 4) }, + { 0x54, 4, 1, ACL_ATTR_ARRAY(tx_packets_by_type, 0) }, + { 0x55, 4, 1, ACL_ATTR_ARRAY(tx_packets_by_type, 1) }, + { 0x56, 4, 1, ACL_ATTR_ARRAY(tx_packets_by_type, 2) }, + { 0x57, 4, 1, ACL_ATTR_ARRAY(tx_packets_by_type, 3) }, + { 0x58, 4, 1, ACL_ATTR_ARRAY(tx_packets_by_type, 4) }, + { 0x59, 4, 1, ACL_ATTR_ARRAY(tx_packets_by_type, 5) }, + { 0x5a, 4, 1, ACL_ATTR_ARRAY(tx_packets_by_type, 6) }, + { 0x5b, 4, 1, ACL_ATTR_ARRAY(tx_packets_by_type, 7) }, + { 0x5c, 4, 1, ACL_ATTR_ARRAY(tx_packets_by_type, 8) }, + { 0x5d, 4, 1, ACL_ATTR(rx_packets) }, + { 0x5e, 4, 1, ACL_ATTR(link_throughput) }, + { 0x5f, 4, 1, ACL_ATTR(max_packet_letency) }, + { 0x60, 4, 1, ACL_ATTR(avg_packet_letency) }, + + /* SCO/eSCO audio link quality subevents */ + { 0x6a, 2, 1, SCO_ATTR(conn_handle) }, + { 0x6b, 4, 1, SCO_ATTR(packets_from_host) }, + { 0x6c, 4, 1, SCO_ATTR(tx_packets) }, + { 0x6d, 4, 1, SCO_ATTR(rx_payload_lost) }, + { 0x6e, 4, 1, SCO_ATTR(tx_payload_lost) }, + { 0x6f, 4, 5, SCO_ATTR(rx_no_sync_error) }, + { 0x70, 4, 5, SCO_ATTR(rx_hec_error) }, + { 0x71, 4, 5, SCO_ATTR(rx_crc_error) }, + { 0x72, 4, 5, SCO_ATTR(rx_nak_error) }, + { 0x73, 4, 5, SCO_ATTR(tx_failed_wifi_coex) }, + { 0x74, 4, 5, SCO_ATTR(rx_failed_wifi_coex) }, + { 0x75, 4, 1, SCO_ATTR(samples_inserted_by_CDC) }, + { 0x76, 4, 1, SCO_ATTR(samples_dropped) }, + { 0x77, 4, 1, SCO_ATTR(mute_samples) }, + { 0x78, 4, 1, SCO_ATTR(plc_injection) }, + + /* end */ + { 0x0, 0, 0 } +}; + +bool is_manufacturer_intel(uint16_t manufacturer) +{ + return manufacturer == COMPANY_ID_INTEL; +} + +void intel_set_debug(intel_debug_func_t callback, void *user_data) +{ + intel_debug.callback = callback; + intel_debug.data = user_data; +} + +static const struct intel_tlv *process_ext_subevent( + struct intel_ext_telemetry_event *tev, + const struct intel_tlv *tlv, + const struct intel_tlv *last_tlv) +{ + const struct intel_tlv *next_tlv = NEXT_TLV(tlv); + const struct intel_ext_subevent *subevent = NULL; + int i; + + for (i = 0; intel_ext_subevent_table[i].size > 0; i++) { + if (intel_ext_subevent_table[i].id == tlv->id) { + subevent = &intel_ext_subevent_table[i]; + break; + } + } + + if (!subevent) { + util_debug(intel_debug.callback, intel_debug.data, + "error: unknown Intel telemetry subevent 0x%2.2x", + tlv->id); + return NULL; + } + + if (tlv->length != subevent->size * subevent->elements) { + util_debug(intel_debug.callback, intel_debug.data, + "error: invalid length %d of subevent 0x%2.2x", + tlv->length, tlv->id); + return NULL; + } + + if (next_tlv > last_tlv) { + util_debug(intel_debug.callback, intel_debug.data, + "error: subevent 0x%2.2x exceeds the buffer size.", + tlv->id); + return NULL; + } + + /* Assign tlv value to the corresponding attribute of acl/sco struct. */ + switch (subevent->size) { + case 1: + *subevent->attr = get_u8(tlv->value); + break; + + case 2: + *((uint16_t *)subevent->attr) = get_le16(tlv->value); + break; + + case 4: + if (subevent->elements == 1) { + *((uint32_t *)subevent->attr) = get_le32(tlv->value); + break; + } + + for (i = 0; i < subevent->elements; i++) { + /* Both acl and sco structs are __packed such that + * the addresses of array elements can be calculated. + */ + *((uint32_t *)(subevent->attr + i * subevent->size)) = + get_le32((uint32_t *)tlv->value + i); + } + break; + + default: + util_debug(intel_debug.callback, intel_debug.data, + "error: subevent id %u: size %u not supported", + subevent->id, subevent->size); + break; + + } + + switch (subevent->id) { + case EXT_EVT_TYPE: + /* Only interested in the LINK_QUALITY_REPORT type for now. */ + if (*subevent->attr != LINK_QUALITY_REPORT) + return NULL; + break; + + case ACL_CONNECTION_HANDLE: + tev->link_type = TELEMETRY_ACL_LINK; + break; + + case SCO_CONNECTION_HANDLE: + tev->link_type = TELEMETRY_SCO_LINK; + break; + + default: + break; + } + + return next_tlv; +} + +struct intel_telemetry_data { + uint16_t vendor_prefix; + uint8_t code; + uint8_t data[]; /* a number of struct intel_tlv subevents */ +} __packed; + +bool process_intel_telemetry_report(const struct mgmt_ev_quality_report *ev) +{ + struct intel_telemetry_data *telemetry = + (struct intel_telemetry_data *)ev->data; + + /* The telemetry->data points to a number of consecutive tlv.*/ + const struct intel_tlv *tlv = (const struct intel_tlv *)telemetry->data; + const struct intel_tlv *last_tlv = + (const struct intel_tlv *)(ev->data + ev->data_len); + + if (telemetry->code != 0x03) { + util_debug(intel_debug.callback, intel_debug.data, + "error: %u not Intel telemetry sub-opcode", + telemetry->code); + return false; + } + + /* Read every tlv subevent into tev. + * The decoding process terminates normally when tlv == last_tlv. + */ + memset(&tev, 0, sizeof(tev)); + while (tlv && tlv < last_tlv) + tlv = process_ext_subevent(&tev, tlv, last_tlv); + + /* If the decoding completes successfully, tlv would be non-NULL */ + return !!tlv; +} diff --git a/src/shared/intel.h b/src/shared/intel.h new file mode 100644 index 000000000..f1c5729ef --- /dev/null +++ b/src/shared/intel.h @@ -0,0 +1,150 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2021 Google LLC + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + +#include + +struct mgmt_ev_quality_report; + +enum intel_telemetry_event_type { + SYSTEM_EXCEPTION, + FATAL_EXCEPTION, + DEBUG_EXCEPTION, + CONNECTION_EVENT, + DISCONNECTION_EVENT, + LINK_QUALITY_REPORT, +}; + +enum intel_telemetry_link_type { + TELEMETRY_UNKNOWN_LINK, + TELEMETRY_ACL_LINK, + TELEMETRY_SCO_LINK, +}; + +/* The subevent indices of the complete list of Intel telemetry subevents. */ +enum intel_subevt_list { + EXT_EVT_TYPE = 0x01, + + ACL_CONNECTION_HANDLE = 0x4a, + ACL_HEC_ERRORS, + ACL_CRC_ERRORS, + ACL_PACKETS_FROM_HOST, + ACL_TX_PACKETS_TO_AIR, + ACL_TX_PACKETS_0_RETRY, + ACL_TX_PACKETS_1_RETRY, + ACL_TX_PACKETS_2_RETRY, + ACL_TX_PACKETS_3_RETRY, + ACL_TX_PACKETS_MORE_RETRY, + ACL_TX_PACKETS_DH1, + ACL_TX_PACKETS_DH3, + ACL_TX_PACKETS_DH5, + ACL_TX_PACKETS_2DH1, + ACL_TX_PACKETS_2DH3, + ACL_TX_PACKETS_2DH5, + ACL_TX_PACKETS_3DH1, + ACL_TX_PACKETS_3DH3, + ACL_TX_PACKETS_3DH5, + ACL_RX_PACKETS, + ACL_LINK_THROUGHPUT, + ACL_MAX_PACKET_LATENCY, + ACL_AVG_PACKET_LATENCY, + + SCO_CONNECTION_HANDLE = 0x6a, + SCO_RX_PACKETS, + SCO_TX_PACKETS, + SCO_RX_PACKETS_LOST, + SCO_TX_PACKETS_LOST, + SCO_RX_NO_SYNC_ERROR, + SCO_RX_HEC_ERROR, + SCO_RX_CRC_ERROR, + SCO_RX_NAK_ERROR, + SCO_TX_FAILED_BY_WIFI, + SCO_RX_FAILED_BY_WIFI, + SCO_SAMPLES_INSERTED, + SCO_SAMPLES_DROPPED, + SCO_MUTE_SAMPLES, + SCO_PLC_INJECTION_DATA, +}; + +#define INTEL_NUM_SLOTS 5 +#define INTEL_NUM_RETRIES 5 +#define INTEL_NUM_PACKET_TYPES 9 + +/* An Intel telemetry subevent is of the TLV format. + * - id: takes 1 byte. This is the subevent id. + * - length: takes 1 byte. + * - value: takes |length| bytes. + */ +struct intel_tlv { + uint8_t id; + uint8_t length; + uint8_t value[0]; +}; + +#define TLV_SIZE(tlv) (*((const uint8_t *) tlv + 1) + 2 * sizeof(uint8_t)) +#define NEXT_TLV(tlv) ((const struct intel_tlv *)\ + ((const uint8_t *)tlv + TLV_SIZE(tlv))) + +struct intel_acl_event { + uint16_t conn_handle; + uint32_t rx_hec_error; + uint32_t rx_crc_error; + uint32_t packets_from_host; + uint32_t tx_packets; + uint32_t tx_packets_retry[INTEL_NUM_RETRIES]; + uint32_t tx_packets_by_type[INTEL_NUM_PACKET_TYPES]; + uint32_t rx_packets; + uint32_t link_throughput; + uint32_t max_packet_letency; + uint32_t avg_packet_letency; +} __packed; + +struct intel_sco_event { + uint16_t conn_handle; + uint32_t packets_from_host; + uint32_t tx_packets; + uint32_t rx_payload_lost; + uint32_t tx_payload_lost; + uint32_t rx_no_sync_error[INTEL_NUM_SLOTS]; + uint32_t rx_hec_error[INTEL_NUM_SLOTS]; + uint32_t rx_crc_error[INTEL_NUM_SLOTS]; + uint32_t rx_nak_error[INTEL_NUM_SLOTS]; + uint32_t tx_failed_wifi_coex[INTEL_NUM_SLOTS]; + uint32_t rx_failed_wifi_coex[INTEL_NUM_SLOTS]; + uint32_t samples_inserted_by_CDC; + uint32_t samples_dropped; + uint32_t mute_samples; + uint32_t plc_injection; +} __packed; + +struct intel_ext_telemetry_event { + uint8_t telemetry_ev_type; /* one in enum intel_telemetry_event_type */ + uint8_t link_type; + union { + struct intel_sco_event sco; + struct intel_acl_event acl; + } conn; +} __packed; + +typedef void (*intel_debug_func_t)(const char *str, void *user_data); + +bool is_manufacturer_intel(uint16_t manufacturer); +void intel_set_debug(intel_debug_func_t callback, void *user_data); + +bool process_intel_telemetry_report(const struct mgmt_ev_quality_report *ev); From patchwork Wed May 25 10:50:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Hwang X-Patchwork-Id: 576037 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 819FBC433F5 for ; Wed, 25 May 2022 10:50:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231492AbiEYKur (ORCPT ); Wed, 25 May 2022 06:50:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233017AbiEYKuo (ORCPT ); Wed, 25 May 2022 06:50:44 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97F4F9588 for ; Wed, 25 May 2022 03:50:43 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id n8so18243326plh.1 for ; Wed, 25 May 2022 03:50:43 -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=/WgMfVFnH8jyFYZO3ukTuQ7o6AcL+561H2M0Rv8Ez+U=; b=ALxfFLlMcnd0XUiLYxhfqxG7+2r5kbxxca58hdl5c1U0l4hEiYIqtAowFOuv3+ZSTw E6KS2jxg7VWTzOuX+31ZxbM4/wmrtxodtTus4h3MvI0ohl2R58y1BcTdt1puDVZe7t/B qWqlNXfZsx5u+05GVceDcfv7Ovri9uHn8MOpg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/WgMfVFnH8jyFYZO3ukTuQ7o6AcL+561H2M0Rv8Ez+U=; b=7LUwfQSZ2xk6KWHqykpS634zRtiB9UjF/S76OkEaxFkHCi8nu84bMj5Xltu0VyHQOI E7oW4Qho4gMqNWuh9M2BJUKeqyiAE77CXKyihkEpK5547gpuR9akLYnJudIY9rc75UZv bqCEAdcBTa1E8h9Hia5NBaFfY/ZQDQrUDmqBKHhsgenciwo3pQjNYaigKb7uoH2IZHd9 bSigweMgJ4Jn9TbVIckNC4DOwEHUBkEJ+RCQCxDK0ey+xgBk5AKgHpVzOIBSTNAm+RJm 5RwnHW95iXefAsOkKgqXwtXuYEvYpIVGiVrXfhOmaCrbhlq7uMydnK4cWdEIP1KN/2Oa QS2w== X-Gm-Message-State: AOAM5315OMU0IcAUiN0TKOVVJZLwGopnTQCaY1UWrg7s2639EAu5EMKl pvpjk55EUBK1Y1qJ3mvFlRIYh8PZMYre3g== X-Google-Smtp-Source: ABdhPJw1TXXatUenZw29f1sc8cRqDMbq/7K1TUYqfHhoUN91+BzpwIietTsIbckbo9BF8ynfULX9oQ== X-Received: by 2002:a17:90b:4a0f:b0:1e0:edc:c1f with SMTP id kk15-20020a17090b4a0f00b001e00edc0c1fmr9710691pjb.93.1653475842842; Wed, 25 May 2022 03:50:42 -0700 (PDT) Received: from localhost (174.71.80.34.bc.googleusercontent.com. [34.80.71.174]) by smtp.gmail.com with UTF8SMTPSA id h9-20020aa786c9000000b0050dc7628196sm10955036pfo.112.2022.05.25.03.50.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 25 May 2022 03:50:42 -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 Subject: [BlueZ PATCH v5 6/8] tools/btmgmt: fix quality report command Date: Wed, 25 May 2022 18:50:13 +0800 Message-Id: <20220525105015.2315987-4-josephsih@chromium.org> X-Mailer: git-send-email 2.36.1.124.g0e6072fb45-goog In-Reply-To: <20220525105015.2315987-1-josephsih@chromium.org> References: <20220525105015.2315987-1-josephsih@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org The set quality report feature becomes a mgmt command and is not included in the experimental features any more. --- Changes in v5: - Use quality_report instead of action in cmd_exp_quality(). Changes in v4: - Add "quality-report" in settings_str. - Print current_settings in quality_rsp. Changes in v3: - This is a new patch that fixes the quality on/off command in btmgmt. tools/btmgmt.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/tools/btmgmt.c b/tools/btmgmt.c index 8f63f12ba..bab67e63b 100644 --- a/tools/btmgmt.c +++ b/tools/btmgmt.c @@ -353,6 +353,7 @@ static const char *settings_str[] = { "static-addr", "phy-configuration", "wide-band-speech", + "quality-report", }; static const char *settings2str(uint32_t settings) @@ -1842,26 +1843,28 @@ static void cmd_exp_privacy(int argc, char **argv) } } -static void exp_quality_rsp(uint8_t status, uint16_t len, const void *param, +static void quality_rsp(uint8_t status, uint16_t len, const void *param, void *user_data) { - if (status != 0) + const struct mgmt_rp_set_quality_report *rp = param; + uint32_t current_settings; + + if (status != 0) { error("Set Quality Report feature failed: 0x%02x (%s)", status, mgmt_errstr(status)); - else - print("Quality Report feature successfully set"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + current_settings = le32_to_cpu(rp->current_settings); + print("Quality Report feature successfully set"); + print("\tcurrent settings: %s", settings2str(current_settings)); bt_shell_noninteractive_quit(EXIT_SUCCESS); } static void cmd_exp_quality(int argc, char **argv) { - /* 330859bc-7506-492d-9370-9a6f0614037f */ - static const uint8_t uuid[16] = { - 0x7f, 0x03, 0x14, 0x06, 0x6f, 0x9a, 0x70, 0x93, - 0x2d, 0x49, 0x06, 0x75, 0xbc, 0x59, 0x08, 0x33, - }; - struct mgmt_cp_set_exp_feature cp; + struct mgmt_cp_set_quality_report cp; uint8_t val; if (mgmt_index == MGMT_INDEX_NONE) { @@ -1878,11 +1881,10 @@ static void cmd_exp_quality(int argc, char **argv) } memset(&cp, 0, sizeof(cp)); - memcpy(cp.uuid, uuid, 16); - cp.action = val; + cp.quality_report = val; - if (mgmt_send(mgmt, MGMT_OP_SET_EXP_FEATURE, mgmt_index, - sizeof(cp), &cp, exp_quality_rsp, NULL, NULL) == 0) { + if (mgmt_send(mgmt, MGMT_OP_SET_QUALITY_REPORT, mgmt_index, + sizeof(cp), &cp, quality_rsp, NULL, NULL) == 0) { error("Unable to send quality report feature cmd"); return bt_shell_noninteractive_quit(EXIT_FAILURE); } @@ -5636,10 +5638,10 @@ static const struct bt_shell_menu main_menu = { cmd_exp_debug, "Set debug feature" }, { "exp-privacy", "", cmd_exp_privacy, "Set LL privacy feature" }, - { "exp-quality", "", cmd_exp_quality, - "Set bluetooth quality report feature" }, { "exp-offload", "", cmd_exp_offload_codecs, "Toggle codec support" }, + { "quality", "", + cmd_exp_quality, "Set bluetooth quality report feature" }, { "read-sysconfig", NULL, cmd_read_sysconfig, "Read System Configuration" }, { "set-sysconfig", "<-v|-h> [options...]", From patchwork Wed May 25 10:50:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Hwang X-Patchwork-Id: 577007 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1068EC4332F for ; Wed, 25 May 2022 10:50:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233125AbiEYKut (ORCPT ); Wed, 25 May 2022 06:50:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229736AbiEYKur (ORCPT ); Wed, 25 May 2022 06:50:47 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86CE4D1 for ; Wed, 25 May 2022 03:50:46 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id gz24so1387524pjb.2 for ; Wed, 25 May 2022 03:50: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:in-reply-to:references :mime-version:content-transfer-encoding; bh=miJIvESjAK0ZOteRzXcxVnOWKJVfLsHBHQwdmkHOyoo=; b=dFfY/OPLLBmvoTIVkxDFhvi00dkeD3fl2Wrwhys9icoCeeNiyqMHZIlg0wVjGuxkJY 9ATJX62gR9snV/hs4T3QIDfucXKnYv4csP8JSTIbOmcYhSjrtHeI6BvgIresxjFPDheq qcRINzWJCRvVvYLPpz/3nORvItsuC0v3QQwRY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=miJIvESjAK0ZOteRzXcxVnOWKJVfLsHBHQwdmkHOyoo=; b=kJ6MG6CqhFGRaZFiW5ife96M7w9iFFXX40j7viLNHThT/nAzwgb9T0aesQD083K/d0 z5umODSnjtYjhza+OjH4TW5U2N+ZjpMaRrimnXO/OkIU4JM8uMZQS9zeWEOtcJChCTFk sDkKruSWEM5wCBFrBjwf6dDjkUYb71IG9gg3EgGK6gg8dk9r6frbCC+TXYUTBL4nBp7G dBIIyljtv1s0R1Cnpd3m3O3WBTnDy4CgAv2OET1MbHqbw5VSCaQmh5nh2yxoJXvo1SOW ZoVNqrkaizrHHYVDSRsBpR5Uz4X/+fNk3qjyR0mweqvhtga43Pb5E3LNAeKOOLOhNLPv nXYw== X-Gm-Message-State: AOAM533iS+XUvlkfhYy53Jx/KppRs8ogz/9ZxbLHvCIL+veVpeCGvduK 4WhUA99mdyS7Ou4jbxjQes1D08av3jBC4A== X-Google-Smtp-Source: ABdhPJz8pBiIBYx216PLdTiyBKrnqh4fz+PF8sP6eJOqHEXHVylbfCT5/PuzB80MiLHP8lZPInot9w== X-Received: by 2002:a17:903:181:b0:161:d2d2:751d with SMTP id z1-20020a170903018100b00161d2d2751dmr31954920plg.91.1653475845921; Wed, 25 May 2022 03:50:45 -0700 (PDT) Received: from localhost (174.71.80.34.bc.googleusercontent.com. [34.80.71.174]) by smtp.gmail.com with UTF8SMTPSA id k2-20020a170902c40200b0016240bbe893sm3600857plk.302.2022.05.25.03.50.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 25 May 2022 03:50:45 -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 Subject: [BlueZ PATCH v5 7/8] monitor: print quality report cmd Date: Wed, 25 May 2022 18:50:14 +0800 Message-Id: <20220525105015.2315987-5-josephsih@chromium.org> X-Mailer: git-send-email 2.36.1.124.g0e6072fb45-goog In-Reply-To: <20220525105015.2315987-1-josephsih@chromium.org> References: <20220525105015.2315987-1-josephsih@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch prints the set quality command properly. --- (no changes since v4) Changes in v4: - Use get_u8() to replace *(uint8_t *). - Use mgmt_new_settings_rsp as the rsp_func in mgmt_command_table for Set Quality Report. Changes in v3: - This is a new patch that prints the set quality command. monitor/packet.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/monitor/packet.c b/monitor/packet.c index d80735a06..33b1f2fea 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -12216,6 +12216,7 @@ static const struct bitfield_data mgmt_settings_table[] = { { 15, "Static Address" }, { 16, "PHY Configuration" }, { 17, "Wideband Speech" }, + { 18, "Quality Report" }, { } }; @@ -13812,6 +13813,13 @@ static void mgmt_remove_adv_monitor_patterns_rsp(const void *data, print_field("Handle: %d", handle); } +static void mgmt_set_quality_report_cmd(const void *data, uint16_t size) +{ + uint8_t action = get_u8(data); + + print_field("Set Quality Report %u", action); +} + struct mgmt_data { uint16_t opcode; const char *str; @@ -14069,6 +14077,9 @@ static const struct mgmt_data mgmt_command_table[] = { mgmt_add_adv_monitor_patterns_rssi_cmd, 8, false, mgmt_add_adv_monitor_patterns_rsp, 2, true}, + { 0x0057, "Set Quality Report", + mgmt_set_quality_report_cmd, 1, true, + mgmt_new_settings_rsp, 4, true }, { } }; From patchwork Wed May 25 10:50:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Hwang X-Patchwork-Id: 577006 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94647C433F5 for ; Wed, 25 May 2022 10:50:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233818AbiEYKuv (ORCPT ); Wed, 25 May 2022 06:50:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231229AbiEYKut (ORCPT ); Wed, 25 May 2022 06:50:49 -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 26C101C6 for ; Wed, 25 May 2022 03:50:49 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id n10so19353157pjh.5 for ; Wed, 25 May 2022 03:50:49 -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=FIvnf+ov8MINP5sCQTpSgaYLBw6/bRB93NDP8cKBAHQ=; b=bxcT8rV9P0szfNen8/JZzsY2GRz13YcGxDatlSkoG7nwB6QBxfKUUI0TSnPEhhI1Ms MCQH1OCDcxtWCQwad35ezBWwTkADsEAn8JLhf8H7TNddUpd8KiJ8oup3k06xNFAzUP5B Y6kZS3MDU219Hd1ztcTCM/iGtrqOEYk3qUPNI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FIvnf+ov8MINP5sCQTpSgaYLBw6/bRB93NDP8cKBAHQ=; b=8LacLHB8RxSR4IlJb3ICyOE4IjkeG8cJ44+fhGVy6GJPrY9iu2mX/2HkpQMe6bkqsX I0jEeXYH0fdrDSd8GNzYmzY8Uwt2ysLjPOe7zeSeKl3e+7g8l7/r4fSwOzl9NmIhKvEL OQoZCfO9UwYSne3fTpIKftKzZnUqCpQFKxVRUy+YhI+2A5jdMAsOXz0x5nQL2HCNyVXw JczrZWHUyLN/+sRTQxUxZ8tj36HzGyUM4lEBWYgV74mlFQlsJ+Yj2yMLFM6qcGuodZ5n OCBtoTm+rvTmnKrkvzK8r33zjQ7g8MiAYP3U8JhVDyEwXVc0zpG67Sxp7AHQypLK0oq7 qLBw== X-Gm-Message-State: AOAM532YR+MPY2TfzFX50jqBtUFPmVrFud6LQFCEh10hwGvFSmWbhzVE rXscMKwXKS1o3SmKpHDTCwLON3yvzpTiTA== X-Google-Smtp-Source: ABdhPJwgziPS+PgkkFC/bjmFZ+VE0a90Bb9bcb1/ggDkuzCqjJIlT4glLgLQ/lobIR1btt85+xqPqA== X-Received: by 2002:a17:90a:1c02:b0:1e0:df7:31f2 with SMTP id s2-20020a17090a1c0200b001e00df731f2mr9964289pjs.222.1653475848502; Wed, 25 May 2022 03:50:48 -0700 (PDT) Received: from localhost (174.71.80.34.bc.googleusercontent.com. [34.80.71.174]) by smtp.gmail.com with UTF8SMTPSA id f1-20020a170902f38100b001635dc81415sm1072132ple.289.2022.05.25.03.50.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 25 May 2022 03:50:48 -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 Subject: [BlueZ PATCH v5 8/8] monitor: packet: add missing decodings of MGMT commands to todo Date: Wed, 25 May 2022 18:50:15 +0800 Message-Id: <20220525105015.2315987-6-josephsih@chromium.org> X-Mailer: git-send-email 2.36.1.124.g0e6072fb45-goog In-Reply-To: <20220525105015.2315987-1-josephsih@chromium.org> References: <20220525105015.2315987-1-josephsih@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch adds the missing decodings of MGMT commands to btmon --todo. --- (no changes since v4) Changes in v4: - This is a new patch that adds the missing decodings of MGMT commands. monitor/packet.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/monitor/packet.c b/monitor/packet.c index 33b1f2fea..11f7fe87f 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -14901,4 +14901,13 @@ void packet_todo(void) printf("\t%s\n", le_meta_event_table[i].str); } + + printf("MGMT commands with missing decodings:\n"); + + for (i = 0; mgmt_command_table[i].str; i++) { + if (mgmt_command_table[i].func) + continue; + + printf("\t%s\n", mgmt_command_table[i].str); + } }