Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1808976pxb; Wed, 9 Feb 2022 05:06:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJyhOoRTN2HZHBHUJTbAqsUZOnF+VNd7/fXmEL4QPYqIb819as/+xG/4RL8WAPWlx8eJx5IG X-Received: by 2002:a62:bd0e:: with SMTP id a14mr2317027pff.32.1644411963934; Wed, 09 Feb 2022 05:06:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644411963; cv=none; d=google.com; s=arc-20160816; b=rfNrXWfZp628aStjiWGGwSsj9kU7+pfDQ/DN7yyTFZhimmBjjfFI6GP3rflWV4TiRk /qOIZu9TjvaqNLG5p0Z6lc2HWl9GtCdsFz71bIrC9px+3soOHPFjf7EBjgThQ+VIVbqA fEqYiOZchYkCDYA/KXkLr6tW4qG16LDyYh35Nqx/qZXSHx/I5aZmkH0dSap9HT4cUgsB TjO68XxKaDvBKfoZkeQzgh5uYFlJRMycHaACst28HFyvTCd9X+U8mJBA/pQwHSbIKpcD XNmxeFElcVMSMX76B187zrOyurj0ZN1tTOdFlOdCtwg55h+n+xNXNjTg62c6YTW1meVH ChbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JK/vxlNdT7JFNpKXya4qcBlyZK3+Mgah0JCZD6Vpyng=; b=Jnn5YgUW9Ro/RHp9kwl8i2DRl8Y38iYcjMpUob85iJAjSvcIo5+vZZsEjbYpBXoiDM QI8YiqlAdiK7N5uXMoG/MURO7z9jwPdT3fUdKwiz6JlSxl1byEtjkGKocPZ3KmRObsCl pHzafgBnojgIicgOI0tFAON9np2uFiYTN4gYOkqliq74kxh7xRYj+KtXe8vxw6y1aNex cCYktKN55uB0tBY1I0U+ikb7IW5Q+5n1q1cKJelSxFpQMay9mV4WDgKWWml8A6jmqkwP EV7ndPnuHPzOYk8YzrSHxUZ/tDwHSgl/B6x6ZJB6o6FJmZDTRscz7PYYHyklcHcg+MoC /apA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Dd9ehfWl; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id x189si15287765pgd.263.2022.02.09.05.06.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 05:06:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Dd9ehfWl; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 25D47E054AF4; Wed, 9 Feb 2022 02:34:59 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229538AbiBIJX5 (ORCPT + 99 others); Wed, 9 Feb 2022 04:23:57 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:40096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233169AbiBIJXz (ORCPT ); Wed, 9 Feb 2022 04:23:55 -0500 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 A4725E01C3A9 for ; Wed, 9 Feb 2022 01:23:50 -0800 (PST) Received: by mail-pj1-x1032.google.com with SMTP id c5-20020a17090a1d0500b001b904a7046dso2989884pjd.1 for ; Wed, 09 Feb 2022 01:23:50 -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=JK/vxlNdT7JFNpKXya4qcBlyZK3+Mgah0JCZD6Vpyng=; b=Dd9ehfWl2Y6WKNAFgrGKr9CVtZ1St2YwveTIwLh40r2xNqNNv4hfP3lIxok/CJbpbb lCBQFXHhalZXWsgQG6emIqVTccv8VkQDyQUD1cq5hdYemUNtFvdmQZ2/1Mm5M5aUD0nP 9mV3/4iQPPLOGCrGIFGt8yp9wDPcybqlFoKKQ= 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=JK/vxlNdT7JFNpKXya4qcBlyZK3+Mgah0JCZD6Vpyng=; b=WUd6gQubayOM2bL0NIBtxn/ikKY+eCz+Sq/VXSt9UIV4LZt+IAF33/gti4NPIIjSne 9xkoB9paCiVr6jcE7lBwGO6zo1LpxSk0zZCCx0kfWt1mAw1G67dSEtxIm4AUTJa93ULp 3j7gaBschgT76bMj/7zKVPQmVFzM+YKpIG58FJx+BgdMZ7ZAOOnwtbvppGBK2C4SMZSg RSEJqDSMpBwm1WQvoMoFo93hWDwp+jCLBLtRhQMBW43FeRZg63KQVI3GOSmzkfBm3YFE VqkDUsAHoopg1ff6tt+KUjw/iLI6opcjxhEnWNxkoL6lEK0ku140KzzKvJgUr7vtWkH6 7fyg== X-Gm-Message-State: AOAM533W7ppwzLWHeHftaqbEbaYHfjc9sImf+ic/tEbOybLLcouZjelK jhy7o/I5SGb2p3YHkJCURHBV2+Bg2t89WA== X-Received: by 2002:a17:90a:3:: with SMTP id 3mr335438pja.211.1644398595054; Wed, 09 Feb 2022 01:23:15 -0800 (PST) Received: from localhost (174.71.80.34.bc.googleusercontent.com. [34.80.71.174]) by smtp.gmail.com with UTF8SMTPSA id k14sm19262194pff.25.2022.02.09.01.23.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 09 Feb 2022 01:23:14 -0800 (PST) From: Joseph Hwang To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com, pali@kernel.org Cc: josephsih@google.com, chromeos-bluetooth-upstreaming@chromium.org, Joseph Hwang , "David S. Miller" , Jakub Kicinski , Johan Hedberg , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v3 3/3] Bluetooth: mgmt: add set_quality_report for MGMT_OP_SET_QUALITY_REPORT Date: Wed, 9 Feb 2022 17:23:00 +0800 Message-Id: <20220209092312.751426-1-josephsih@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220209172233.v3.1.I2015b42d2d0a502334c9c3a2983438b89716d4f0@changeid> References: <20220209172233.v3.1.I2015b42d2d0a502334c9c3a2983438b89716d4f0@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch adds a new set_quality_report mgmt handler to set the quality report feature. The feature is removed from the experimental features at the same time. Signed-off-by: Joseph Hwang --- Changes in v3: - This is a new patch to enable the quality report feature. The reading and setting of the quality report feature are removed from the experimental features. include/net/bluetooth/mgmt.h | 7 ++ net/bluetooth/mgmt.c | 164 +++++++++++++++-------------------- 2 files changed, 77 insertions(+), 94 deletions(-) diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 03204b4ba641..236e042fbc1c 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -109,6 +109,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 #define MGMT_READ_INFO_SIZE 0 @@ -838,6 +839,12 @@ struct mgmt_cp_add_adv_patterns_monitor_rssi { } __packed; #define MGMT_ADD_ADV_PATTERNS_MONITOR_RSSI_SIZE 8 +#define MGMT_OP_SET_QUALITY_REPORT 0x0057 +struct mgmt_cp_set_quality_report { + __u8 action; +} __packed; +#define MGMT_SET_QUALITY_REPORT_SIZE 1 + #define MGMT_EV_CMD_COMPLETE 0x0001 struct mgmt_ev_cmd_complete { __le16 opcode; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index cab79f480a21..92de8e669897 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -857,6 +857,10 @@ static u32 get_supported_settings(struct hci_dev *hdev) settings |= MGMT_SETTING_PHY_CONFIGURATION; + if (hdev && (aosp_has_quality_report(hdev) || + hdev->set_quality_report)) + settings |= MGMT_SETTING_QUALITY_REPORT; + return settings; } @@ -928,6 +932,9 @@ static u32 get_current_settings(struct hci_dev *hdev) if (hci_dev_test_flag(hdev, HCI_WIDEBAND_SPEECH_ENABLED)) settings |= MGMT_SETTING_WIDEBAND_SPEECH; + if (hci_dev_test_flag(hdev, HCI_QUALITY_REPORT)) + settings |= MGMT_SETTING_QUALITY_REPORT; + return settings; } @@ -3871,12 +3878,6 @@ static const u8 debug_uuid[16] = { }; #endif -/* 330859bc-7506-492d-9370-9a6f0614037f */ -static const u8 quality_report_uuid[16] = { - 0x7f, 0x03, 0x14, 0x06, 0x6f, 0x9a, 0x70, 0x93, - 0x2d, 0x49, 0x06, 0x75, 0xbc, 0x59, 0x08, 0x33, -}; - /* a6695ace-ee7f-4fb9-881a-5fac66c629af */ static const u8 offload_codecs_uuid[16] = { 0xaf, 0x29, 0xc6, 0x66, 0xac, 0x5f, 0x1a, 0x88, @@ -3898,7 +3899,7 @@ static const u8 rpa_resolution_uuid[16] = { static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, void *data, u16 data_len) { - char buf[102]; /* Enough space for 5 features: 2 + 20 * 5 */ + char buf[82]; /* Enough space for 4 features: 2 + 20 * 4 */ struct mgmt_rp_read_exp_features_info *rp = (void *)buf; u16 idx = 0; u32 flags; @@ -3939,18 +3940,6 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, idx++; } - if (hdev && (aosp_has_quality_report(hdev) || - hdev->set_quality_report)) { - if (hci_dev_test_flag(hdev, HCI_QUALITY_REPORT)) - flags = BIT(0); - else - flags = 0; - - memcpy(rp->features[idx].uuid, quality_report_uuid, 16); - rp->features[idx].flags = cpu_to_le32(flags); - idx++; - } - if (hdev && hdev->get_data_path_id) { if (hci_dev_test_flag(hdev, HCI_OFFLOAD_CODECS_ENABLED)) flags = BIT(0); @@ -4163,80 +4152,6 @@ static int set_rpa_resolution_func(struct sock *sk, struct hci_dev *hdev, return err; } -static int set_quality_report_func(struct sock *sk, struct hci_dev *hdev, - struct mgmt_cp_set_exp_feature *cp, - u16 data_len) -{ - struct mgmt_rp_set_exp_feature rp; - bool val, changed; - int err; - - /* Command requires to use a valid controller index */ - if (!hdev) - return mgmt_cmd_status(sk, MGMT_INDEX_NONE, - MGMT_OP_SET_EXP_FEATURE, - MGMT_STATUS_INVALID_INDEX); - - /* Parameters are limited to a single octet */ - if (data_len != MGMT_SET_EXP_FEATURE_SIZE + 1) - return mgmt_cmd_status(sk, hdev->id, - MGMT_OP_SET_EXP_FEATURE, - MGMT_STATUS_INVALID_PARAMS); - - /* Only boolean on/off is supported */ - if (cp->param[0] != 0x00 && cp->param[0] != 0x01) - return mgmt_cmd_status(sk, hdev->id, - MGMT_OP_SET_EXP_FEATURE, - MGMT_STATUS_INVALID_PARAMS); - - hci_req_sync_lock(hdev); - - val = !!cp->param[0]; - changed = (val != hci_dev_test_flag(hdev, HCI_QUALITY_REPORT)); - - if (!aosp_has_quality_report(hdev) && !hdev->set_quality_report) { - err = mgmt_cmd_status(sk, hdev->id, - MGMT_OP_SET_EXP_FEATURE, - MGMT_STATUS_NOT_SUPPORTED); - goto unlock_quality_report; - } - - if (changed) { - if (hdev->set_quality_report) - err = hdev->set_quality_report(hdev, val); - else - err = aosp_set_quality_report(hdev, val); - - if (err) { - err = mgmt_cmd_status(sk, hdev->id, - MGMT_OP_SET_EXP_FEATURE, - MGMT_STATUS_FAILED); - goto unlock_quality_report; - } - - if (val) - hci_dev_set_flag(hdev, HCI_QUALITY_REPORT); - else - hci_dev_clear_flag(hdev, HCI_QUALITY_REPORT); - } - - bt_dev_dbg(hdev, "quality report enable %d changed %d", val, changed); - - memcpy(rp.uuid, quality_report_uuid, 16); - rp.flags = cpu_to_le32(val ? BIT(0) : 0); - hci_sock_set_flag(sk, HCI_MGMT_EXP_FEATURE_EVENTS); - - err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_SET_EXP_FEATURE, 0, - &rp, sizeof(rp)); - - if (changed) - exp_feature_changed(hdev, quality_report_uuid, val, sk); - -unlock_quality_report: - hci_req_sync_unlock(hdev); - return err; -} - static int set_offload_codec_func(struct sock *sk, struct hci_dev *hdev, struct mgmt_cp_set_exp_feature *cp, u16 data_len) @@ -4363,7 +4278,6 @@ static const struct mgmt_exp_feature { EXP_FEAT(debug_uuid, set_debug_func), #endif EXP_FEAT(rpa_resolution_uuid, set_rpa_resolution_func), - EXP_FEAT(quality_report_uuid, set_quality_report_func), EXP_FEAT(offload_codecs_uuid, set_offload_codec_func), EXP_FEAT(le_simultaneous_roles_uuid, set_le_simultaneous_roles_func), @@ -8656,6 +8570,67 @@ static int get_adv_size_info(struct sock *sk, struct hci_dev *hdev, return err; } +static int set_quality_report(struct sock *sk, struct hci_dev *hdev, + void *data, u16 data_len) +{ + struct mgmt_cp_set_quality_report *cp = data; + bool enable, changed; + int err; + + /* Command requires to use a valid controller index */ + if (!hdev) + return mgmt_cmd_status(sk, MGMT_INDEX_NONE, + MGMT_OP_SET_QUALITY_REPORT, + MGMT_STATUS_INVALID_INDEX); + + /* Only 0 (off) and 1 (on) is supported */ + if (cp->action != 0x00 && cp->action != 0x01) + return mgmt_cmd_status(sk, hdev->id, + MGMT_OP_SET_QUALITY_REPORT, + MGMT_STATUS_INVALID_PARAMS); + + hci_req_sync_lock(hdev); + + enable = !!cp->action; + changed = (enable != hci_dev_test_flag(hdev, HCI_QUALITY_REPORT)); + + if (!aosp_has_quality_report(hdev) && !hdev->set_quality_report) { + err = mgmt_cmd_status(sk, hdev->id, + MGMT_OP_SET_QUALITY_REPORT, + MGMT_STATUS_NOT_SUPPORTED); + goto unlock_quality_report; + } + + if (changed) { + if (hdev->set_quality_report) + err = hdev->set_quality_report(hdev, enable); + else + err = aosp_set_quality_report(hdev, enable); + + if (err) { + err = mgmt_cmd_status(sk, hdev->id, + MGMT_OP_SET_QUALITY_REPORT, + MGMT_STATUS_FAILED); + goto unlock_quality_report; + } + + if (enable) + hci_dev_set_flag(hdev, HCI_QUALITY_REPORT); + else + hci_dev_clear_flag(hdev, HCI_QUALITY_REPORT); + } + + bt_dev_dbg(hdev, "quality report enable %d changed %d", + enable, changed); + + err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_SET_QUALITY_REPORT, 0, + NULL, 0); + +unlock_quality_report: + hci_req_sync_unlock(hdev); + return err; +} + static const struct hci_mgmt_handler mgmt_handlers[] = { { NULL }, /* 0x0000 (no command) */ { read_version, MGMT_READ_VERSION_SIZE, @@ -8782,6 +8757,7 @@ static const struct hci_mgmt_handler mgmt_handlers[] = { { add_adv_patterns_monitor_rssi, MGMT_ADD_ADV_PATTERNS_MONITOR_RSSI_SIZE, HCI_MGMT_VAR_LEN }, + { set_quality_report, MGMT_SET_QUALITY_REPORT_SIZE }, }; void mgmt_index_added(struct hci_dev *hdev) -- 2.35.0.263.gb82422642f-goog