From patchwork Wed Feb 9 09:24:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Hwang X-Patchwork-Id: 12739913 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 6361DC433FE for ; Wed, 9 Feb 2022 09:25:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232467AbiBIJZW (ORCPT ); Wed, 9 Feb 2022 04:25:22 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:45260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232234AbiBIJZV (ORCPT ); Wed, 9 Feb 2022 04:25:21 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3C9BC1DF807 for ; Wed, 9 Feb 2022 01:25:17 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id a11-20020a17090a740b00b001b8b506c42fso4623826pjg.0 for ; Wed, 09 Feb 2022 01:25:17 -0800 (PST) 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=Zj9lmaqr1ILhWR4H8tl30NHz4jXQUSH7MNOMbElh7EM=; b=encWBATk5KKsq/cKWCBTkFPSqVC1Fb+cgRI+6kV4gwsQo7wx6ejdekNakqAwZauWKa vmZYimM8F7OGgKE3Nu16j2QQVVwxBIbtzA+34DdLtRMGECWySTvfUzQoZJzRDTzdHmVr bZNFfhAjlWmrHFb0/kGTcZWyOGIu+o5PZKUbw= 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=Zj9lmaqr1ILhWR4H8tl30NHz4jXQUSH7MNOMbElh7EM=; b=zdGsdf6es2fiqCty1FR+yeqfuFbG3lOddFVbo4yjpyKsqr/wSb5VNz7EYB27SLebLK 2w6B+ouBCSB5VfqnQuj+Mnf7EnnLsQOwllQ7UiRkhjtUc4z+1t/sFu3gq7BuEtW/uZ9q z4yGFTww74cI3pUDPjANTEI4IUwc6rRxwWNSg/Nz5vjEMKX5ikZJtO7Zmiz4aNdhgBkg TZX5aetOzNF0fqv9Wnzf8A3goxCVC2q41yDcsQIa6Q+NZxotx5JTpg9KMZAZ3AuA/f99 8/UB995aIVRXaj9YqdID+7LJUvvjIJwC+r1WPWkkK/VYAlbcGGaBzKAlB+i7wr76l9Am 7hng== X-Gm-Message-State: AOAM533SXkIV2SlmPF28BFVWg0pAI4JaoG8hP/IeZ9SN4BMxx//7KZQX Zy4cudq/78LFc1Zj23sL8IRwGZcB86BWVA== X-Google-Smtp-Source: ABdhPJzppLhFvM4SIHQmmkdncEDhmQrPI3+e+YEMWuoxtv78d611RlezJc3jJNNgTNuXK/CUd+H6mA== X-Received: by 2002:a17:90b:4c43:: with SMTP id np3mr2407475pjb.88.1644398661595; Wed, 09 Feb 2022 01:24:21 -0800 (PST) Received: from localhost (174.71.80.34.bc.googleusercontent.com. [34.80.71.174]) by smtp.gmail.com with UTF8SMTPSA id q17sm18938271pfu.160.2022.02.09.01.24.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 09 Feb 2022 01:24:21 -0800 (PST) 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 v3 1/9] doc: Add Bluetooth quality report event Date: Wed, 9 Feb 2022 17:24:06 +0800 Message-Id: <20220209092414.751642-1-josephsih@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Add the Bluetooth quality report event in doc/mgmt-api.txt. Signed-off-by: Joseph Hwang --- 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 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt index ebe56afa4..5a32091fa 100644 --- a/doc/mgmt-api.txt +++ b/doc/mgmt-api.txt @@ -4978,3 +4978,22 @@ Advertisement Monitor Device Lost Event 2 LE Random This event will be sent to all management sockets. + + +Bluetooth 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 Feb 9 09:24:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Hwang X-Patchwork-Id: 12739914 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 4DEA1C433F5 for ; Wed, 9 Feb 2022 09:25:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232234AbiBIJZc (ORCPT ); Wed, 9 Feb 2022 04:25:32 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:45796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229695AbiBIJZb (ORCPT ); Wed, 9 Feb 2022 04:25:31 -0500 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D118C094CAA for ; Wed, 9 Feb 2022 01:25:26 -0800 (PST) Received: by mail-pf1-x42c.google.com with SMTP id d187so3191205pfa.10 for ; Wed, 09 Feb 2022 01:25:26 -0800 (PST) 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=qW1SUmdDnvNIzHcgBGusXb1sIBN2gf/ZGCzEYdsEAfc=; b=MWmD2AfhTv3A9VTNplgDSqlug7tyqFypWaK7cntCV/fcPL2fxT8GTklLl6I64rgn/5 hlzZPrj7u53g4PJAQ3QSMj5KASh5El1nam1uMlF9UkBjh/SAI4RZNTLRw1rp9I/I/cOY yZXZDR0Jyx+jHDkpKoRqWZDFy2jGbNpLimRqE= 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=qW1SUmdDnvNIzHcgBGusXb1sIBN2gf/ZGCzEYdsEAfc=; b=RnhGKxuMSaSyuVQeo0+UOo23wAoPUJX9DzxsY9xRtg8BHrkCQirRLhhDIIrH2HmC4M cX3gZLHwar50Y/Mofv0zl/4EH9kBdNB3xPU3tWqq8x/XWfwlGr8Yttu8mQXMhpkPSHhK 3z0RYpoNi0sO8iRSTy5/hm0mhEIkwgp+Xqsh2/u0Sdc7iFO4U4uK9hRnJpjLycti3SAC ZhUmbiTeIgt6mDU7fOHRGQEQaoOMZLVfNvqzjDIpLBejFoxuW/4g4JS9vH5Sp6TbgGr3 M/pLSVBFewpzyYLEcadbBIaRR2wgWUn4uEuOEzkouxwXeQkaJyo1xNKjl2HpVHKHD+vt 7LBQ== X-Gm-Message-State: AOAM5302ecPbs4FMgJKTpwf+Z7Y6epaxrFS/m+v3OogV9gpSf6T5uGMq PkfPPEk4z8D5kKv5ecKF0yA1zTYJynLgZg== X-Google-Smtp-Source: ABdhPJwT03DkEFOouYisawmJK/39DlzXmBtZC2FM5AAol+wZFu9q2UAtx2jKuASZgBNppB2hg4gU0w== X-Received: by 2002:a63:8ac2:: with SMTP id y185mr1181395pgd.608.1644398664316; Wed, 09 Feb 2022 01:24:24 -0800 (PST) Received: from localhost (174.71.80.34.bc.googleusercontent.com. [34.80.71.174]) by smtp.gmail.com with UTF8SMTPSA id 16sm5437731pje.34.2022.02.09.01.24.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 09 Feb 2022 01:24:23 -0800 (PST) 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 v3 2/9] lib: Add structures and constants for quality report event Date: Wed, 9 Feb 2022 17:24:07 +0800 Message-Id: <20220209092414.751642-2-josephsih@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220209092414.751642-1-josephsih@chromium.org> References: <20220209092414.751642-1-josephsih@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Add the new struct and constants to lib/mgmt.h. Signed-off-by: Joseph Hwang --- 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 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/mgmt.h b/lib/mgmt.h index 922a24367..db9a24cd6 100644 --- a/lib/mgmt.h +++ b/lib/mgmt.h @@ -1032,6 +1032,15 @@ struct mgmt_ev_adv_monitor_device_lost { struct mgmt_addr_info addr; } __packed; +#define MGMT_EV_QUALITY_REPORT 0x0031 +#define QUALITY_SPEC_AOSP_BQR 0x0 +#define QUALITY_SPEC_INTEL_TELEMETRY 0x1 +struct mgmt_ev_quality_report { + uint8_t quality_spec; + uint32_t data_len; + uint8_t data[]; +} __packed; + static const char *mgmt_op[] = { "<0x0000>", "Read Version", @@ -1172,6 +1181,7 @@ static const char *mgmt_ev[] = { "Controller Resume", "Advertisement Monitor Device Found", /* 0x002f */ "Advertisement Monitor Device Lost", + "Bluetooth Quality Report", /* 0x0031 */ }; static const char *mgmt_status[] = { From patchwork Wed Feb 9 09:24: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: 12739915 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 E5442C433EF for ; Wed, 9 Feb 2022 09:25:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232475AbiBIJZl (ORCPT ); Wed, 9 Feb 2022 04:25:41 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:46292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229695AbiBIJZj (ORCPT ); Wed, 9 Feb 2022 04:25:39 -0500 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E179E0AFABD for ; Wed, 9 Feb 2022 01:25:34 -0800 (PST) Received: by mail-pf1-x42a.google.com with SMTP id d187so3191388pfa.10 for ; Wed, 09 Feb 2022 01:25:34 -0800 (PST) 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=vPPhLL1Y+5vlVmq9MDz6NaYxXuKrQj6x7ivKO7F9Q0E=; b=cT1i5PN+Ih/xYpIKX+SNjKeFCK3JSrlJqy3V3VAYK+s5c9jNzVRxg3uc2/YvwRmMbX 6rcxD7HKbk7BJXIXr1+NEtDLnDauR5vTlv0WWfq7nPeapxC0fLV4ek7fzdoxL91mBvbw zn2MPadp8aqyqtlPI+dM/Sbjn4nzCX4Qnb3mw= 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=vPPhLL1Y+5vlVmq9MDz6NaYxXuKrQj6x7ivKO7F9Q0E=; b=3v6wLm0HhVk9OXdM43rjQSawwlf4l4+1ZsUzD9azVdi04IgElbhtlsojAqN1sfB7m1 MNO0gJBnYp3V3S3rNHAdoRWaZFIK7a17mMglvjVwREWjwi1IKrvumldYE/YuYSWahmbR RhGhIx6SOV925yXX1jrhIQY0R5jeKpQm5XSeozdkasf0++TsQ/3u13qvfC1px6dIAKh1 sA4ovdjRV70xoaaTyFFgsZ2/Qx3e12dZGA/YJ0j19UYMzqIm/AEBfP2KnQwVx61crZiM h7VFhbZDbulVPYYUaV+ABiWckaf8fmRbjxSjOfOOJObwX8BIT07tblwfrWlc+vmbkBab oTEA== X-Gm-Message-State: AOAM533l5+xNkLem+sdRCWSi/UCb34dJg567KUlclkTatAxBONHdu2EN NY5X43jVa97wEKMB7zW0yEo5ND1q7JHHHw== X-Google-Smtp-Source: ABdhPJwHcJnCRmwCMp20pOJiz3919ZdRzTja+NqC7cPelqneic1zKoYvn5B8dciOrqjk51HIl3v8Fg== X-Received: by 2002:a63:2a86:: with SMTP id q128mr1179143pgq.53.1644398667110; Wed, 09 Feb 2022 01:24:27 -0800 (PST) Received: from localhost (174.71.80.34.bc.googleusercontent.com. [34.80.71.174]) by smtp.gmail.com with UTF8SMTPSA id b12sm18192936pfm.154.2022.02.09.01.24.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 09 Feb 2022 01:24:26 -0800 (PST) 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 v3 3/9] adapter: support AOSP MGMT_EV_QUALITY_REPORT Date: Wed, 9 Feb 2022 17:24:08 +0800 Message-Id: <20220209172328.BlueZ.v3.3.Ie4d1be8ced51f0aa92ee6d8eacf9666a121a1292@changeid> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220209092414.751642-1-josephsih@chromium.org> References: <20220209092414.751642-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 Signed-off-by: Joseph Hwang --- (no changes since v2) 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 | 56 +++++++++++++++++++++++++++++ src/adapter.h | 2 ++ src/shared/aosp.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++ src/shared/aosp.h | 58 ++++++++++++++++++++++++++++++ 5 files changed, 208 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 e391d7ae8..baab40369 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 9772e843a..58f8c0298 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" @@ -9312,6 +9313,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_BQR) { + 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) { @@ -9727,6 +9750,19 @@ static void le_simult_central_peripheral_func(struct btd_adapter *adapter, (void *)le_simult_central_peripheral_uuid.val); } +static bool is_exp_feature_uuid_the_same(const void *data, + const void *match_data) +{ + return memcmp(data, match_data, + sizeof(((struct mgmt_exp_uuid *)NULL)->val)) == 0; +} + +bool is_quality_report_supported(struct btd_adapter *adapter) +{ + return queue_find(adapter->exps, is_exp_feature_uuid_the_same, + (void *)quality_report_uuid.val) != NULL; +} + static void quality_report_func(struct btd_adapter *adapter, uint8_t action) { if (action) @@ -9882,6 +9918,18 @@ static void read_exp_features(struct btd_adapter *adapter) btd_error(adapter->dev_id, "Failed to read exp features info"); } +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) { @@ -10110,6 +10158,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)); @@ -10137,6 +10190,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/adapter.h b/src/adapter.h index 35deb1d11..c199e358a 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -266,6 +266,8 @@ enum kernel_features { bool btd_has_kernel_features(uint32_t feature); +bool is_quality_report_supported(struct btd_adapter *adapter); + bool btd_adapter_set_allowed_uuids(struct btd_adapter *adapter, struct queue *uuids); bool btd_adapter_is_uuid_allowed(struct btd_adapter *adapter, 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..b58aa5e3a --- /dev/null +++ b/src/shared/aosp.h @@ -0,0 +1,58 @@ +/* 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. + * + */ + +#ifndef __AOSP_H +#define __AOSP_H + +#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); + +#endif /* __AOSP_H */ From patchwork Wed Feb 9 09:24: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: 12739916 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 B909CC433FE for ; Wed, 9 Feb 2022 09:25:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232685AbiBIJZm (ORCPT ); Wed, 9 Feb 2022 04:25:42 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:46368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230273AbiBIJZk (ORCPT ); Wed, 9 Feb 2022 04:25:40 -0500 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFD63C094CAA for ; Wed, 9 Feb 2022 01:25:35 -0800 (PST) Received: by mail-pj1-x1036.google.com with SMTP id g15-20020a17090a67cf00b001b7d5b6bedaso1651202pjm.4 for ; Wed, 09 Feb 2022 01:25:35 -0800 (PST) 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=B6SveYj5aVD2P+O4jsROHbMSI2TioYoQ0aIVRSWCY94=; b=dN870vZgyvKV5EWmTFT3hw54f/VRKyNJBCiAMwCWcUSizRcDypDD2wFi0qjfopaD7d TrRnt5fkkrTmA5ENnAyXVBj+z8WdZX3Ubzk9x4TMmbaVqBmiFpiFvAOQPR5LwRR0qsFv R5G8pgaptR2EEMTdaLru1ToHt4BLFrIzhFpyc= 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=B6SveYj5aVD2P+O4jsROHbMSI2TioYoQ0aIVRSWCY94=; b=Gip1Y/VmMrv4IZK3/3NLdfNSwmTdCCEJFFV+ZuYypdTwmUT8z+/JJup+XkpknYG+nX XZXParwJfGFK11PU+5iEp3wDtxOW0+xJD508PQNUM+jDrgZasH7HvpYUNOek33q1YOD9 QmIsTe59APAkCl8L+kdXML6D+cLH/CJco9wRf8ll4NqqO18j5kumu0kLdqMK4SYIt17V KYnLLHotl+/uaYd9hbTLRDgXeiXvfXjRQvAqJ0GN5tE7B0Es1XK490zHNpOXZuyVCEhR ra/jd3gXdcjsXakTOyvq7E6kHj9olXNmKorUj2LAP+24SIkYWFnxNhJLaNjDQj6gKdqc yfHg== X-Gm-Message-State: AOAM5300yy5FTPxMm7MvDee/oSfvoco6dDFIkLxR+H8mqI7helagiidX yf5gQ+i9ym/8fo6speoSsdZRIeSGoGa8uA== X-Google-Smtp-Source: ABdhPJw5QpF2ooT7re4+0jjE+BgVEUX4I7zf8XwJECA9s2WRXya2eMURovaFc6biuIf+s/xOFJRPVA== X-Received: by 2002:a17:902:6502:: with SMTP id b2mr1484828plk.43.1644398669937; Wed, 09 Feb 2022 01:24:29 -0800 (PST) Received: from localhost (174.71.80.34.bc.googleusercontent.com. [34.80.71.174]) by smtp.gmail.com with UTF8SMTPSA id o125sm14924784pfb.116.2022.02.09.01.24.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 09 Feb 2022 01:24:29 -0800 (PST) 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 v3 4/9] adapter: support Intel MGMT_EV_QUALITY_REPORT Date: Wed, 9 Feb 2022 17:24:09 +0800 Message-Id: <20220209172328.BlueZ.v3.4.Ifdf5cf89a14b4f293d868910c6cb85e802f7eb9e@changeid> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220209092414.751642-1-josephsih@chromium.org> References: <20220209092414.751642-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 Signed-off-by: Joseph Hwang --- (no changes since v2) 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 | 9 +- src/shared/intel.c | 243 +++++++++++++++++++++++++++++++++++++++++++++ src/shared/intel.h | 155 +++++++++++++++++++++++++++++ 4 files changed, 408 insertions(+), 2 deletions(-) create mode 100644 src/shared/intel.c create mode 100644 src/shared/intel.h diff --git a/Makefile.am b/Makefile.am index baab40369..abbe3897b 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 58f8c0298..9816235ec 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" @@ -9329,6 +9330,9 @@ static void quality_report_callback(uint16_t index, uint16_t length, if (ev->quality_spec == QUALITY_SPEC_AOSP_BQR) { if (!process_aosp_quality_report(ev)) error("processing aosp quality report"); + } else if (ev->quality_spec == QUALITY_SPEC_INTEL_TELEMETRY) { + if (!process_intel_telemetry_report(ev)) + error("processing intel telemetry report"); } else { error("quality report spec %u not supported.", ev->quality_spec); @@ -9927,7 +9931,10 @@ static void quality_report_debug(const char *str, void *user_data) static void quality_set_debug(struct btd_adapter *adapter) { - aosp_set_debug(quality_report_debug, "quality: "); + if (is_manufacturer_intel(adapter->manufacturer)) + intel_set_debug(quality_report_debug, "quality: "); + else + aosp_set_debug(quality_report_debug, "quality: "); } static void read_info_complete(uint8_t status, uint16_t length, 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..2b20f803e --- /dev/null +++ b/src/shared/intel.h @@ -0,0 +1,155 @@ +/* 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. + * + */ + +#ifndef __INTEL_H +#define __INTEL_H + +#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); + +#endif /* __INTEL_H */ From patchwork Wed Feb 9 09:24: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: 12739917 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 CC311C433EF for ; Wed, 9 Feb 2022 09:25:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234430AbiBIJZv (ORCPT ); Wed, 9 Feb 2022 04:25:51 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:46794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233473AbiBIJZs (ORCPT ); Wed, 9 Feb 2022 04:25:48 -0500 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 65F57E0B2A8D for ; Wed, 9 Feb 2022 01:25:44 -0800 (PST) Received: by mail-pj1-x102a.google.com with SMTP id c5-20020a17090a1d0500b001b904a7046dso2992714pjd.1 for ; Wed, 09 Feb 2022 01:25:44 -0800 (PST) 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=0Ezf2K87PY88yQLZVVdIdZGxXgxLe9pcYiYstWtu8lU=; b=Jvd8VZiKyaHs39Wjs7e9iLCcU+EkjI9kr+EtrwiUR3Z5P9l2yLFjlPxEP/gYMUWGa0 lLuD+Mm7ll5h/FcgxAbRxfwHuS2C1tCwXhbLds5VHGuoq/CsSBWSO7P02+fISmZIH/Pc 9yY68P/kqkVA7P0cEIFzhrqg3VDNnlRNsCBVY= 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=0Ezf2K87PY88yQLZVVdIdZGxXgxLe9pcYiYstWtu8lU=; b=j+7rDbSu+xLf2hss/Md2B2EeCOLNTpKP8OA9yujQ4qmfPyXUxCX++Ko1Q6AT+6SCJd yHd+sHMaiB1s3vVhvfyJC3vYLmip9GOWXqazO3syJCwmct227UzU0J0hWfYFa6ydWDuX UVqYezb7hTkbTFJgd0KAEeLQAlR9nMx1wYsVweRH7PxxVGjW39KQBk1lGjMr7JvzGV1g AXIyL5+4+N5Ppa42J2La0c8dlbOqqTI8O3QaPRdHmu98wToAbUi0dsZAtsWrto/7LuOS RZPrA9mwxKXnwqBttBn8necIFaAG/cu0dbzpxlzBF1q88s2PXo8lTyQk0/2ZMjula9Mq a77Q== X-Gm-Message-State: AOAM532rOif5ZwQ8MM4SYBNPygMBTDp9ClNXS0UeFvU8aa+59WFrQNg9 8snTkjkE5NtTPjHOpadeG5cSm7aOdorzRw== X-Google-Smtp-Source: ABdhPJzC+mBF8NDjH1P32ICsaDV/p7PuoySduAN2ZJkepj4YwuYUQpU9na64LJU/4syyN8JfqrvuHw== X-Received: by 2002:a17:903:28c:: with SMTP id j12mr599500plr.78.1644398672687; Wed, 09 Feb 2022 01:24:32 -0800 (PST) Received: from localhost (174.71.80.34.bc.googleusercontent.com. [34.80.71.174]) by smtp.gmail.com with UTF8SMTPSA id t9sm5253516pjg.44.2022.02.09.01.24.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 09 Feb 2022 01:24:32 -0800 (PST) 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 v3 5/9] doc: Introduce the Set Quality Report Command Date: Wed, 9 Feb 2022 17:24:10 +0800 Message-Id: <20220209092414.751642-3-josephsih@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220209092414.751642-1-josephsih@chromium.org> References: <20220209092414.751642-1-josephsih@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Add the Set Quality Report Command in doc/mgmt-api.txt. Signed-off-by: Joseph Hwang --- Changes in v3: - This is a new patch that introduces the Set Quality Report Command. doc/mgmt-api.txt | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt index 5a32091fa..4ac84d41b 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,37 @@ Add Advertisement Patterns Monitor With RSSI Threshold Command Invalid Parameters +Set Quality Report Command +========================== + + Command Code: 0x0057 + Controller Index: + Command Parameters: Action (1 Octet) + Return Parameters: + + This command is used to enable and disable the controller's quality + report feature. + + This command requires to use a valid controller index. Otherwise, + an "invalid index" status will be returned. + + The parameter "action" can be either 0 to disable the feature or + 1 to enable the feature. For any values other than 0 and 1, an + "invalid parameters" status will be returned. + + If the driver does not indicate that the controller supports the + quality report feature, a "not supported" status will be returned. + + The command is sent to the controller to enable/disable the quality + report feature. If the controller failed to execute the action, a + "failed" status will be returned. + + Possible errors: Failed + Invalid Index + Invalid Parameters + Not Supported + + Command Complete Event ====================== From patchwork Wed Feb 9 09:24: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: 12739918 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 95CF7C433F5 for ; Wed, 9 Feb 2022 09:25:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234483AbiBIJZw (ORCPT ); Wed, 9 Feb 2022 04:25:52 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:46872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234335AbiBIJZt (ORCPT ); Wed, 9 Feb 2022 04:25:49 -0500 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FFD4E0B2A96 for ; Wed, 9 Feb 2022 01:25:45 -0800 (PST) Received: by mail-pj1-x102c.google.com with SMTP id ki18-20020a17090ae91200b001b8be87e9abso3440979pjb.1 for ; Wed, 09 Feb 2022 01:25:45 -0800 (PST) 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=dbGl2g+xSsgoPigjMOhOL2LjoIGxCaud1t0GsUmz8Ic=; b=SUBqX8PdHolVXO9Ec0CTGckqgeuirioszUEVCkjId/QIt4rx8V+Er9MVp9+AWZcOEt vXV9lO9DoREsfv9gLAZzOh9gYTMGH5JNoXuZ2O9sAXR4Tldq+Lk1jYlB98JUP60zHjAw tGwf/611fI8mxqM2pFY12hCgqLOn0+NU1e0Is= 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=dbGl2g+xSsgoPigjMOhOL2LjoIGxCaud1t0GsUmz8Ic=; b=Y8iz5flk2VX6/5o3gPmImyomHbUkMPq9yTDy96CQGk639hJm3+eVuwcYv1lnSW0NUt ScmSNVz/U5ZHx3aEjcebdukyJGPNBKliU/gfrdmNXv8EnXjhSBMMoLqo3n/Ar4ikWl7I DKEg+PskhIaZZajfK+zkPjywe5ZxMBJRwcmzjjI86bh8ub+c0Byk/4OgpqyFZEwMMftg uHORWJSKtipXC/KPmSFlPq1EJOFPuVw7mp55q7qylQEuBTksU4C7GUUQE7+ikiM8HVni 51u3gNaouEOsf3arN3Njd4bT9RnN0EfgFTmzM1lr8aXC2dMZGYCH5hCQ+fej3o+5Y60v /eVA== X-Gm-Message-State: AOAM531gA5pi0f26coXuYGEwugeulIIjUBajb0n6+zH+Th8INyFIEyQd 0sCUigXQzKtLduDtQCb7PWAaopQgHp2kVQ== X-Google-Smtp-Source: ABdhPJx71x5puUV4TU5bwl89O4+GlrcVcrfPpwAN2pJ7pWHM+P1hYOsCo4LTbc2qhUu/ynIWoB6rRw== X-Received: by 2002:a17:902:b286:: with SMTP id u6mr1205141plr.155.1644398675467; Wed, 09 Feb 2022 01:24:35 -0800 (PST) Received: from localhost (174.71.80.34.bc.googleusercontent.com. [34.80.71.174]) by smtp.gmail.com with UTF8SMTPSA id f8sm19261995pfe.204.2022.02.09.01.24.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 09 Feb 2022 01:24:35 -0800 (PST) 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 v3 6/9] lib: Add structure and constant for MGMT_OP_SET_QUALITY_REPORT Date: Wed, 9 Feb 2022 17:24:11 +0800 Message-Id: <20220209092414.751642-4-josephsih@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220209092414.751642-1-josephsih@chromium.org> References: <20220209092414.751642-1-josephsih@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch adds the struct and constant for MGMT_OP_SET_QUALITY_REPORT. Signed-off-by: Joseph Hwang --- Changes in v3: - This is a new patch that adds the structure and constant for MGMT_OP_SET_QUALITY_REPORT. lib/mgmt.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/mgmt.h b/lib/mgmt.h index db9a24cd6..2741d5d66 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,11 @@ 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 action; +} __packed; + #define MGMT_EV_CMD_COMPLETE 0x0001 struct mgmt_ev_cmd_complete { uint16_t opcode; From patchwork Wed Feb 9 09:24: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: 12739919 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 89EDBC433EF for ; Wed, 9 Feb 2022 09:26:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234487AbiBIJZ7 (ORCPT ); Wed, 9 Feb 2022 04:25:59 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:47330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229544AbiBIJZ4 (ORCPT ); Wed, 9 Feb 2022 04:25:56 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B567FE03E21E for ; Wed, 9 Feb 2022 01:25:52 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id a11-20020a17090a740b00b001b8b506c42fso4624389pjg.0 for ; Wed, 09 Feb 2022 01:25:52 -0800 (PST) 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=lZ7VTq83RLOJ0uaKrHIzjaJZ39aUOWoyZ3tyZJGSuJU=; b=Q8F6O7dEG2GmVqhWUePA72aKjaibZFeijXFsC1Bf32F/sm6KdfoPdt7Z2JUIP4ayKJ +YYJFFdxBkzEQ8B/i1pQxNhh4nkLY2jlK++Gh5fNElZlt/NDGCGSMCm7yL9K46AP0472 YrxskiyxBWJoq5e+fZv5+VQ5AUPymvivuiAOk= 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=lZ7VTq83RLOJ0uaKrHIzjaJZ39aUOWoyZ3tyZJGSuJU=; b=U2umLXDVgStvvTek2recXR8+u4mxP464OGHVsZs99ciV5ap4HkTesxb2/WNLKWNZmQ PCubGy3JCfx5nWG3jDh8V8rH0hrQ6ch3lGbQb0M/PIgx7aaK3iCDvr3ziwkzyFrrO5tn /CLQPA9zEwkXx/6Qrp91+R3dcIoaS4lG+6dkRNi01mNmi60Z7o5nFORq1iCcdiGTV17E JqnKYltGEhSvsLgotTFjxASB8MHSTivlCKqbDNzrxo/Yb784rdkjVXMtoccLp/+sPWgG qIXVMHwk4EHCVlqbRLX1TCVYkjhtqyhmGr0YTeyVzxe/Vem0OQamrE5dcTa6JuLZU8R3 H55w== X-Gm-Message-State: AOAM532x3SrmozcimEI4hyPKfQjQQM9UeYlSPwsX9WQmIs9GwVikmUo7 GDARAay2llk0qkrxw92bTcTnDoxlZUFNiw== X-Google-Smtp-Source: ABdhPJzcwi4WfVrKuzHeNTX5DiKKi/0SBFV1n0bFRbOxFKOQ3J5zV0PfPvhAy/lv3MkU5+mNto7PXw== X-Received: by 2002:a17:902:ec82:: with SMTP id x2mr1301453plg.139.1644398678214; Wed, 09 Feb 2022 01:24:38 -0800 (PST) Received: from localhost (174.71.80.34.bc.googleusercontent.com. [34.80.71.174]) by smtp.gmail.com with UTF8SMTPSA id nu7sm6076006pjb.30.2022.02.09.01.24.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 09 Feb 2022 01:24:37 -0800 (PST) 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 v3 7/9] adapter: enable quality report via MGMT_OP_SET_QUALITY_REPORT Date: Wed, 9 Feb 2022 17:24:12 +0800 Message-Id: <20220209092414.751642-5-josephsih@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220209092414.751642-1-josephsih@chromium.org> References: <20220209092414.751642-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. Signed-off-by: Joseph Hwang --- Changes in v3: - This is a new patch that enables the quality report feature via MGMT_OP_SET_QUALITY_REPORT. src/adapter.c | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index 9816235ec..9cb684345 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -122,13 +122,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, @@ -9754,25 +9747,6 @@ static void le_simult_central_peripheral_func(struct btd_adapter *adapter, (void *)le_simult_central_peripheral_uuid.val); } -static bool is_exp_feature_uuid_the_same(const void *data, - const void *match_data) -{ - return memcmp(data, match_data, - sizeof(((struct mgmt_exp_uuid *)NULL)->val)) == 0; -} - -bool is_quality_report_supported(struct btd_adapter *adapter) -{ - return queue_find(adapter->exps, is_exp_feature_uuid_the_same, - (void *)quality_report_uuid.val) != NULL; -} - -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) { @@ -9848,7 +9822,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), }; @@ -9922,6 +9895,11 @@ static void read_exp_features(struct btd_adapter *adapter) btd_error(adapter->dev_id, "Failed to read exp features info"); } +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; From patchwork Wed Feb 9 09:24: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: 12739920 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 B8FC6C433EF for ; Wed, 9 Feb 2022 09:26:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233744AbiBIJ0I (ORCPT ); Wed, 9 Feb 2022 04:26:08 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:47982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229544AbiBIJ0H (ORCPT ); Wed, 9 Feb 2022 04:26:07 -0500 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF36AE058254 for ; Wed, 9 Feb 2022 01:26:01 -0800 (PST) Received: by mail-pl1-x62d.google.com with SMTP id y17so1691019plg.7 for ; Wed, 09 Feb 2022 01:26:01 -0800 (PST) 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=vZUO0cqlNRIJarZJPiafFiE07Tp9QCPY4gWT3QTXXvQ=; b=MuP0BGrWdMzNenvaMZIVRsd7fdvLFy+WKwRFeYpCEQR3pedG07OBNa03n3XKM2UoX4 /jmjbqvWlxIvP74qXsU0ZH9VmYRzmExVHKvn2F5a4fFw3r3H9c6ctIzzBTpsH6a/zMLZ xqlaSN0U/3UiW1bGy9Ewy+dxl5zNXE47dFwx4= 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=vZUO0cqlNRIJarZJPiafFiE07Tp9QCPY4gWT3QTXXvQ=; b=NHoUBcs5qwwDchZHdo6VMUzuXCmECm2c7CG/dfiWxo5LDYErPi1LHTul9n9oJcdE9H LgXKSCMg4i8U6d8IfNXUb6FrG3oCT+GvU1wcW4EuNhwnUuDm4Vt/+sGEHC9KDFGXpdgM cbhDLJuR8upnBhXiK0TLVJ+0Ut0vL2q7059hJDAqNUBTaAXXEblDIX0lOp4VjwlVgKDv C5RbBIASjc5BqnYKYXaXyl+4uz74pfrUDZD6icTrQ3obIdrQhjToxJTE1i3e3ibXgzhz XudEjf6XKchDUmdlPu5qyLEv4tymUoXcc6yFZYIFG899V2nF2IO+2OkagheFlTCSYTf4 e6NA== X-Gm-Message-State: AOAM532nBUVWyOZtHjPhiZfkxL7BVhNUlFd2VHp62o0d6QVSYpUprvdZ 4HHcwNKXZAsg3X5/YtWtigy9SH64r9QUjw== X-Google-Smtp-Source: ABdhPJymZi6xfZg5ANX0bNcNcrr+a/ey0sWRCVKDH1VMNkZR4JMgczTsZKwu2trJ6cSsM0JMD92K4g== X-Received: by 2002:a17:903:2d2:: with SMTP id s18mr1519335plk.56.1644398680996; Wed, 09 Feb 2022 01:24:40 -0800 (PST) Received: from localhost (174.71.80.34.bc.googleusercontent.com. [34.80.71.174]) by smtp.gmail.com with UTF8SMTPSA id g12sm18050158pfm.119.2022.02.09.01.24.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 09 Feb 2022 01:24:40 -0800 (PST) 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 v3 8/9] tools/btmgmt: fix quality report command Date: Wed, 9 Feb 2022 17:24:13 +0800 Message-Id: <20220209092414.751642-6-josephsih@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220209092414.751642-1-josephsih@chromium.org> References: <20220209092414.751642-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. Signed-off-by: Joseph Hwang --- Changes in v3: - This is a new patch that fixes the quality on/off command in btmgmt. tools/btmgmt.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/tools/btmgmt.c b/tools/btmgmt.c index 42ef9acef..4f215b4af 100644 --- a/tools/btmgmt.c +++ b/tools/btmgmt.c @@ -1842,7 +1842,7 @@ 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) @@ -1856,12 +1856,7 @@ static void exp_quality_rsp(uint8_t status, uint16_t len, const void *param, 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 +1873,10 @@ static void cmd_exp_quality(int argc, char **argv) } memset(&cp, 0, sizeof(cp)); - memcpy(cp.uuid, uuid, 16); cp.action = 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 +5630,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 Feb 9 09:24: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: 12739921 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 340F4C433EF for ; Wed, 9 Feb 2022 09:26:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234576AbiBIJ0P (ORCPT ); Wed, 9 Feb 2022 04:26:15 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:48226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229544AbiBIJ0M (ORCPT ); Wed, 9 Feb 2022 04:26:12 -0500 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EA85E058269 for ; Wed, 9 Feb 2022 01:26:07 -0800 (PST) Received: by mail-pf1-x434.google.com with SMTP id a39so2386592pfx.7 for ; Wed, 09 Feb 2022 01:26:07 -0800 (PST) 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=fQtjyJhWV3SBhpr27SqHKqSu/xFu20sVB+tlUFLL+GM=; b=QQJnt/oQEwVXWXGZVVaW52Jcnnd9OyAPxC5eO7uP/BpcyNNxjZtzWE0ZNOCFkQ5zgy P5RwDdQ54U/maO3VMmT+DTYD03jIaMFvOlObjYmdxNprWVgn5YTFTJZA4B51W0p7yhTN HTYO4ibA+7q/FIR7DbxFfKWdUoq/VDTLR7plE= 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=fQtjyJhWV3SBhpr27SqHKqSu/xFu20sVB+tlUFLL+GM=; b=RcUu/ueXDkXoET1o3GGi820CiTFEoWNoBDIv6x15nHkYWColIfpB2FFH49AhtWLun+ hRrjTCfgqYJWyGtLRucxe3BkR+CQb1yWItwxQMXEq9xcr2u5SbUNGcxhSFgGpGgv9Rwv SJMPp5kRBT58QBFHTXXe50XR10rYCGEvwbGXg+CJsRaS7u6oO8WJA+szIGHa5jZMAEeC VcPw3zoHduTlrItQ7ovPtKkLM8pqn7U6WC4Prsc449JIvxlFQTL4p7qbGWkbdQ6FXlkT mGCsC6OHwa/wCv8m67nr5hkBX3qD/PDnnCrPAXQSMWWAHBqO6jP+dnub7PND0NmI9PEa 70qg== X-Gm-Message-State: AOAM530jHvwY6avSbn1FCwKVCSgHBbRT/NeQYtIeRojvV8MXc9IB12l7 KUCB2GNI7+ReYuADsc8p7UlcxAw4ahmR3g== X-Google-Smtp-Source: ABdhPJw63VL5m7wpsMo2kepLc0deDKTlIXCjWnExhON66s2pDXwnDtdldz63QRuyiNdNtz10ppHZzw== X-Received: by 2002:a63:6a87:: with SMTP id f129mr1210501pgc.0.1644398683645; Wed, 09 Feb 2022 01:24:43 -0800 (PST) Received: from localhost (174.71.80.34.bc.googleusercontent.com. [34.80.71.174]) by smtp.gmail.com with UTF8SMTPSA id j14sm19611086pfj.218.2022.02.09.01.24.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 09 Feb 2022 01:24:43 -0800 (PST) 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 v3 9/9] monitor: print quality report cmd Date: Wed, 9 Feb 2022 17:24:14 +0800 Message-Id: <20220209092414.751642-7-josephsih@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220209092414.751642-1-josephsih@chromium.org> References: <20220209092414.751642-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. Signed-off-by: Joseph Hwang --- 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 397000644..4dce2f681 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -12011,6 +12011,7 @@ static const struct bitfield_data mgmt_settings_table[] = { { 15, "Static Address" }, { 16, "PHY Configuration" }, { 17, "Wideband Speech" }, + { 18, "Quality Report" }, { } }; @@ -13607,6 +13608,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 = *(uint8_t *)data; + + print_field("Set Quality Report %u", action); +} + struct mgmt_data { uint16_t opcode; const char *str; @@ -13864,6 +13872,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_null_rsp, 0, true }, { } };