Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp393951pxb; Tue, 19 Oct 2021 05:13:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6JJYwkergbl2UB5XgKaE02QQUyqJaLo0Ou0LAAuTY+yrCJLlnI2M8dVRgntw+wp6TP1SJ X-Received: by 2002:a17:906:b311:: with SMTP id n17mr36119411ejz.571.1634645589490; Tue, 19 Oct 2021 05:13:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634645589; cv=none; d=google.com; s=arc-20160816; b=DJfNCNLu40rVxlRSaBcYXkPMT1PmSbtNwtiaitrQWkDqI/Z8JwpG3h3kIS2SZpmF6O J2HzSuOTEDEHjSwUVTxnDX7WKzxSdKahqaVIptsnXdyWShmP1Jpw8p1kAoU/lUJNjHbB WTcZPP8GIIWWFWX9UZjxdYnyLzzUMMfKCdRVxdxc+2xrTux8jV1o43MGRe3WKJ1L/Mh8 VR109lSukFLre8u1rXhgumX/1iVVnNf4YqmRcdW88R8eElhoR4Q1/ZQ4hQzYl0RWpsQL awhcwn1QE/6cje+6SVvjeIm7MrPfNVJX3qJzuxckTB6r1mj41A/Xeu7KmG2xA8hiVx6e kKEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=imTFDrWe85v4P6kkmQziiHJ0XlRBvngkTyOsy1ovX1A=; b=jROQVrTC1DLXpax/yxSPjgEs4OAJm5kQpH9wLGhRDDAm7Lk1Bg0sxz/r1vdLAox9tT QgXT6uISIPjhVKPWMkHtgSYRpGx2CVwgbLWKLyz2gIR0H3x1VMkgvA6A8tNhaum7go51 qjdPTd8Iq59JaDbRakEG/S/58T4zTQktnXmzgS3qIrhFveVDScCYHXNnslJJwLhdsKSy TH1YgXExJt13W9cWkVrDZzXCg2yp+XQzSUyPriY3F2/AF55ufdbxlrR0MmL2qDWSUfMG sy1sICS2UwlHzssEuLzKsp1BuZ4LHGdVi/D7PSrjvuM6tTRwHCBWaZmAm1iqt6yaWaKb q0XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=MHQ1lkou; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u21si25668691eda.507.2021.10.19.05.12.44; Tue, 19 Oct 2021 05:13:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=MHQ1lkou; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235515AbhJSMOC (ORCPT + 99 others); Tue, 19 Oct 2021 08:14:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230129AbhJSMOB (ORCPT ); Tue, 19 Oct 2021 08:14:01 -0400 Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com [IPv6:2607:f8b0:4864:20::b2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3214C06161C for ; Tue, 19 Oct 2021 05:11:48 -0700 (PDT) Received: by mail-yb1-xb2f.google.com with SMTP id l80so7086054ybf.4 for ; Tue, 19 Oct 2021 05:11:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=imTFDrWe85v4P6kkmQziiHJ0XlRBvngkTyOsy1ovX1A=; b=MHQ1lkouaegpQAmfQVB6poDsGHxVDgGqpCqsaU8e2cYImbn17EDdTRHxwb4Xoiw+fc xLUwt0nMvHga7UHcu5wGsAWDCmAg3IEjIBVx268YEEcqmBTo+NNB8HEdaCQLvHryMCgz hJvUxJ/zcDwpl9gMxLyKTWxqnQqEQwftQUks61MjH5UOaUGNr1ca/h0jv05ULEBtXZ1/ ZQrkZMfiHQ5+q8fvg2FwDy4jAslfWEu1eLybh3xVAa8Dh2pMg2SfH9lw2/Dmvf5Snfa9 zd8SoXV1lwajus2VU1648HU3srnLpgM6AfTEfybCRFicnXlC+K/hgFGQlBDIn4UVLO14 qyig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=imTFDrWe85v4P6kkmQziiHJ0XlRBvngkTyOsy1ovX1A=; b=iwivIQN8HkhL/sQqMMRUHnUkKGfZwGqh/pM/Nkj4eNIv3SMmtj7UTSOKVEkCqAaoRf AK+hHrggoH1xdJqBxQqmLfxvUl363CHXrVSy5X2CF9vu3XEaZ7mZbfqOWp3COVuKq0hc r3qC0Fv+3FGUEG31opAPZeHfCcnwTE1bekTvVzn9LPz6dQKjKW3vahb3jhn0FE8ld7n3 KnapOd0iCMOeASEjlsSwDuJU0En22ez3CoBHnurgdceDyPpAGkKIPfwFTYWZXwuqSGl+ P0REyJCS48Eg1lfTO7EGKaikoZpaf9SPUbd0euw93/BovnOPkZdI1XxFiv2QgEyT8SyJ TQQQ== X-Gm-Message-State: AOAM5301MyS1nFTtoaJFhgGLgIC/0kQK7z1MEmrEYonFZMsrOBmX9d79 3mKxvbS2k7O2XfAqeMLM7SyjaGXMVLlPPU3xDNrXhQ== X-Received: by 2002:a25:3817:: with SMTP id f23mr34089287yba.436.1634645507522; Tue, 19 Oct 2021 05:11:47 -0700 (PDT) MIME-Version: 1.0 References: <20210926150657.v4.1.Iaa4a0269e51d8e8d8784a6ac8e05899b49a1377d@changeid> <4A480983-CAF2-46B7-B462-9BC84E1783CC@holtmann.org> In-Reply-To: <4A480983-CAF2-46B7-B462-9BC84E1783CC@holtmann.org> From: Joseph Hwang Date: Tue, 19 Oct 2021 20:11:35 +0800 Message-ID: Subject: Re: [PATCH v4 1/4] Bluetooth: aosp: Support AOSP Bluetooth Quality Report To: Marcel Holtmann Cc: linux-bluetooth , Luiz Augusto von Dentz , =?UTF-8?Q?Pali_Roh=C3=A1r?= , CrosBT Upstreaming , Miao-chen Chou , "David S. Miller" , Jakub Kicinski , Johan Hedberg , open list , netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Marcel: Thanks for the RFC. I have fixed the patches per your request and submitted them for re-review. Thanks and regards! On Tue, Sep 28, 2021 at 6:45 PM Marcel Holtmann wrote= : > > Hi Joseph, > > > This patch adds the support of the AOSP Bluetooth Quality Report > > (BQR) events. > > > > Multiple vendors have supported the AOSP Bluetooth Quality Report. > > When a Bluetooth controller supports the capability, it can enable > > the capability through hci_set_aosp_capable. Then hci_core will > > set up the hdev->set_quality_report callback accordingly. > > > > Note that Intel also supports a distinct telemetry quality report > > specification. Intel sets up the hdev->set_quality_report callback > > in the btusb driver module. > > > > Reviewed-by: Miao-chen Chou > > Signed-off-by: Joseph Hwang > > > > --- > > > > Changes in v4: > > - Move the AOSP BQR support from the driver level to net/bluetooth/aosp= . > > - Fix the drivers to use hci_set_aosp_capable to enable aosp. > > - Add Mediatek to support the capability too. > > > > Changes in v3: > > - Fix the auto build test ERROR > > "undefined symbol: btandroid_set_quality_report" that occurred > > with some kernel configs. > > - Note that the mgmt-tester "Read Exp Feature - Success" failed. > > But on my test device, the same test passed. Please kindly let me > > know what may be going wrong. These patches do not actually > > modify read/set experimental features. > > - As to CheckPatch failed. No need to modify the MAINTAINERS file. > > Thanks. > > > > Changes in v2: > > - Fix the titles of patches 2/3 and 3/3 and reduce their lengths. > > > > net/bluetooth/aosp.c | 79 ++++++++++++++++++++++++++++++++++++++++ > > net/bluetooth/aosp.h | 7 ++++ > > net/bluetooth/hci_core.c | 17 +++++++++ > > 3 files changed, 103 insertions(+) > > > > diff --git a/net/bluetooth/aosp.c b/net/bluetooth/aosp.c > > index a1b7762335a5..c2b22bc83fb2 100644 > > --- a/net/bluetooth/aosp.c > > +++ b/net/bluetooth/aosp.c > > @@ -33,3 +33,82 @@ void aosp_do_close(struct hci_dev *hdev) > > > > bt_dev_dbg(hdev, "Cleanup of AOSP extension"); > > } > > + > > +/* BQR command */ > > +#define BQR_OPCODE hci_opcode_pack(0x3f, 0x015e) > > + > > +/* BQR report action */ > > +#define REPORT_ACTION_ADD 0x00 > > +#define REPORT_ACTION_DELETE 0x01 > > +#define REPORT_ACTION_CLEAR 0x02 > > + > > +/* BQR event masks */ > > +#define QUALITY_MONITORING BIT(0) > > +#define APPRAOCHING_LSTO BIT(1) > > +#define A2DP_AUDIO_CHOPPY BIT(2) > > +#define SCO_VOICE_CHOPPY BIT(3) > > + > > +#define DEFAULT_BQR_EVENT_MASK (QUALITY_MONITORING | APPRAOCHING= _LSTO | \ > > + A2DP_AUDIO_CHOPPY | SCO_VOICE_CHOPPY) > > + > > +/* Reporting at milliseconds so as not to stress the controller too mu= ch. > > + * Range: 0 ~ 65535 ms > > + */ > > +#define DEFALUT_REPORT_INTERVAL_MS 5000 > > + > > +struct aosp_bqr_cp { > > + __u8 report_action; > > + __u32 event_mask; > > + __u16 min_report_interval; > > +} __packed; > > + > > +static int enable_quality_report(struct hci_dev *hdev) > > +{ > > + struct sk_buff *skb; > > + struct aosp_bqr_cp cp; > > + > > + cp.report_action =3D REPORT_ACTION_ADD; > > + cp.event_mask =3D DEFAULT_BQR_EVENT_MASK; > > + cp.min_report_interval =3D DEFALUT_REPORT_INTERVAL_MS; > > + > > + skb =3D __hci_cmd_sync(hdev, BQR_OPCODE, sizeof(cp), &cp, > > + HCI_CMD_TIMEOUT); > > + if (IS_ERR(skb)) { > > + bt_dev_err(hdev, "Enabling Android BQR failed (%ld)", > > + PTR_ERR(skb)); > > + return PTR_ERR(skb); > > + } > > + > > + kfree_skb(skb); > > + return 0; > > +} > > + > > +static int disable_quality_report(struct hci_dev *hdev) > > +{ > > + struct sk_buff *skb; > > + struct aosp_bqr_cp cp =3D { 0 }; > > + > > + cp.report_action =3D REPORT_ACTION_CLEAR; > > + > > + skb =3D __hci_cmd_sync(hdev, BQR_OPCODE, sizeof(cp), &cp, > > + HCI_CMD_TIMEOUT); > > + if (IS_ERR(skb)) { > > + bt_dev_err(hdev, "Disabling Android BQR failed (%ld)", > > + PTR_ERR(skb)); > > + return PTR_ERR(skb); > > + } > > + > > + kfree_skb(skb); > > + return 0; > > +} > > + > > +int aosp_set_quality_report(struct hci_dev *hdev, bool enable) > > +{ > > + bt_dev_info(hdev, "quality report enable %d", enable); > > + > > + /* Enable or disable the quality report feature. */ > > + if (enable) > > + return enable_quality_report(hdev); > > + else > > + return disable_quality_report(hdev); > > +} > > diff --git a/net/bluetooth/aosp.h b/net/bluetooth/aosp.h > > index 328fc6d39f70..384e111c1260 100644 > > --- a/net/bluetooth/aosp.h > > +++ b/net/bluetooth/aosp.h > > @@ -8,9 +8,16 @@ > > void aosp_do_open(struct hci_dev *hdev); > > void aosp_do_close(struct hci_dev *hdev); > > > > +int aosp_set_quality_report(struct hci_dev *hdev, bool enable); > > + > > #else > > > > static inline void aosp_do_open(struct hci_dev *hdev) {} > > static inline void aosp_do_close(struct hci_dev *hdev) {} > > > > +static inline int aosp_set_quality_report(struct hci_dev *hdev, bool e= nable) > > +{ > > + return false; > > +} > > + > > #endif > > diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c > > index aeec5a3031a6..a2c22a4921d4 100644 > > --- a/net/bluetooth/hci_core.c > > +++ b/net/bluetooth/hci_core.c > > @@ -1315,6 +1315,21 @@ static void hci_dev_get_bd_addr_from_property(st= ruct hci_dev *hdev) > > bacpy(&hdev->public_addr, &ba); > > } > > > > +static void hci_set_quality_report(struct hci_dev *hdev) > > +{ > > +#ifdef CONFIG_BT_AOSPEXT > > + if (hdev->aosp_capable) { > > + /* The hdev->set_quality_report callback is setup here fo= r > > + * the vendors that support AOSP quality report specifica= tion. > > + * Note that Intel, while supporting a distinct telemetry > > + * quality report specification, sets up the > > + * hdev->set_quality_report callback in the btusb module. > > + */ > > + hdev->set_quality_report =3D aosp_set_quality_report; > > + } > > +#endif > > +} > > + > > I think that I wasn=E2=80=99t super clear in my review on how I wanted th= is feature. So hdev->set_quality_report should really only ever set by a tr= ansport driver. The core stack should never touch it. > > So I wanted something like this: > > if (hdev->set_quality_report) > err =3D hdev->set_quality_report(hdev, val); > else > err =3D aosp_set_quality_report(hdev, val); > > I send a RFC showing you how I think this should be done. > > An extra important step of course is to check if the Android extension ac= tually supports the quality report feature in the first place. > > And while writing that patch, I realized that your initial support has a = mistake. I send a patch for fixing it. The mgmt document is pretty clear on= how experimental flags are defined. > > Read Experimental Features Information Command > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > Command Code: 0x0049 > Controller Index: or > Command Parameters: > Return Parameters: Feature_Count (2 Octets) > Feature1 { > UUID (16 Octets) > Flags (4 Octets) > } > Feature2 { } > ... > > This command is used to retrieve the supported experimental featu= res > by the host stack. > > The UUID values are not defined here. They can change over time a= nd > are on purpose not stable. Features that mature will be removed a= t > some point. The mapping of feature UUID to the actual functionali= ty > of a given feature is out of scope here. > > The following bits are defined for the Flags parameter: > > 0 Feature active > 1 Causes change in supported settings > > So please don=E2=80=99t just make up things and exp UUID should only be p= resent if they are supported. If they are not supported because the hardwar= e is lacking support, they should not be reported. > > Regards > > Marcel > --=20 Joseph Shyh-In Hwang Email: josephsih@google.com