Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3691315pxk; Tue, 29 Sep 2020 03:56:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytgXCA3LZat85jbnMWmVH85aXbtMlMQuYX8aBJKGN0Xbd/i+BO0BIreRjFdcID8z63P4eE X-Received: by 2002:a17:906:1b11:: with SMTP id o17mr3375575ejg.67.1601377011669; Tue, 29 Sep 2020 03:56:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601377011; cv=none; d=google.com; s=arc-20160816; b=0R+jw9BjQlNwAWqzHYoVrPFBVJutfiIV4uGR2b5rjG97QUF8CnBK9uvQ63qn+jDsr1 mzQqum/zEIp6utsY13fsd9IlRT5YD6fJquzLsbnBlYXmNaX317hYBjClgaxwf0l25QHu k97hnTxIyi39SNMEXxGD7i9rmaNmXikmAQXTAjAQ9T7Xx4HB3Al3e0ISoH9Th1fcN6YM dCjklkY9+baMoZQzfdEbhDlZqrJUphpI8XecNWRw6zL6KOAACWuvO5NH5NkJiQVfo2BS Eu/Tbuy0FEE8CipUAftPH3SLcfe/m8M//XYKQup9DH/zCtPxK6SBTiXN7EilHrKh3puO autA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=GnzdACP512zgJlZNer+AWXbyoPMk47HIJPVn+VkAO1U=; b=gYZJ1iwroXlyqdl3hdPFYVcEHvZNUgUG9YAKvCIcCvVqxSeLxC8/RLwTgzxhPRySB9 Gxo7K40LlQNzA4Dh6RXePlH4JUlnqWHxrktDGnwFqudXFtrmFBdQQp/BtjdWhMS5YuE4 zidZmBPBaV4UpVAOJ5qTDwiadiyXF8UkVp56OP+JSSKYAG2xd2hh4YSIS+/i3ZJGCKfI 1ItGQ3N9mM2OOA57/umnGfUIwkNQO1q1N6iOJ4tCARe40LLInf+4s6y0jeJZfwvKs7ck Qo/lK3UvRo4GkNOlo2pXqPrMWK8MtIPZIWfpbuHIjYVINZ35RSrxQLxf2RNBFG8F23A4 Y0KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=jE4ugx5j; 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 c10si2569703edw.68.2020.09.29.03.56.17; Tue, 29 Sep 2020 03:56:51 -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=20161025 header.b=jE4ugx5j; 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 S1725554AbgI2K4Q (ORCPT + 99 others); Tue, 29 Sep 2020 06:56:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725306AbgI2K4Q (ORCPT ); Tue, 29 Sep 2020 06:56:16 -0400 Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA398C061755 for ; Tue, 29 Sep 2020 03:56:14 -0700 (PDT) Received: by mail-qt1-x849.google.com with SMTP id a16so2647119qtj.7 for ; Tue, 29 Sep 2020 03:56:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=GnzdACP512zgJlZNer+AWXbyoPMk47HIJPVn+VkAO1U=; b=jE4ugx5jScfBHZv2LYCYdO2ihvTPgOSodmCUr2Pct4X3tabrNoblDPSwTyHKCVc/w8 UgareC4ZVPu/RN1gPUV2FoJKiFXQsBU+Iht3b7XViS/XSP2gmIMq1SRAssZjx30u0mNd GlCT/+EVArXmp2oZk/hlIDnaLGN4wk4FPOQnEci7TB6wi4/L6u3W4S8LxoOoiEKZUWy+ RXungaDKodDX9+wptiDUtvbNV3/ut1dz0U2mWxgQLjGP68d+dcMzoSYPCsJ29uRVp0uZ meE7njYg6afr/6NORdFfWs6DpcAZzfK7yHkdf+bXx/uDvipksn7jWDiJHfTKE+EnIrge SWrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=GnzdACP512zgJlZNer+AWXbyoPMk47HIJPVn+VkAO1U=; b=pyg1XXVDcxgcNyBAJEPa0Jrla/Xa36zUaPj+ikddBcax1joEkWE5o//eY86DdtLXIs alPEqWPjYetDBzj1yGzq203XAIv7YpSlo/tHHRes+R9q3TNDbX0OBBkfbcKk1jk+H0Oa Rh6zyepEF/uHDswJ4Hju/JNg5GciPHOgkK3X9n9QEwac6O5XQDKf7tSMrJcYt5K7RoQj BsisNE/30GRV0Uo7rv6h9+azYf8SpDR6wIUv1DNcL879OHfHxmqx/lgt6RafYo1YGRCe hLra2MXFwnC0HNzKu4wfMS/TTfm87pdvml/84kTlMs+VmG7piy8Cg/dMMIEM7nukg6dk 1Cmg== X-Gm-Message-State: AOAM530cZYXwUq6OFjWxIGlqwVQ/wjDL+y3m4Rwg3Y47OadxTfucOxbv 0fFt3s2VyEwYu5Ujmsy3y0jK7+XFKMZeplxzNI9AiHVoEx1xhY3qShRdBgXJCTcEaIlMrs1zb7O DD4KeIpD5E1091S4jmcXVJSbJ2B7MsgbbnaySDlR+YiHF2aKAt+HBHJzdzykiL8xfY3uEKySlpf GVmnFJLFDAs4o= Sender: "howardchung via sendgmr" X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:ad4:41c4:: with SMTP id a4mr3670216qvq.60.1601376973698; Tue, 29 Sep 2020 03:56:13 -0700 (PDT) Date: Tue, 29 Sep 2020 18:56:03 +0800 In-Reply-To: <20200929185522.BlueZ.v5.1.I1f083629d41c747a33a3937fbc199ea37dccde12@changeid> Message-Id: <20200929185522.BlueZ.v5.2.Iac5207375d22fb7b96ae4ef73b49ae4ab457219c@changeid> Mime-Version: 1.0 References: <20200929185522.BlueZ.v5.1.I1f083629d41c747a33a3937fbc199ea37dccde12@changeid> X-Mailer: git-send-email 2.28.0.709.gb0816b6eb0-goog Subject: [BlueZ PATCH v5 2/3] core: Add param to disable interleave scan From: Howard Chung To: linux-bluetooth@vger.kernel.org Cc: mmandlik@chromium.org, luiz.dentz@gmail.com, alainm@chromium.org, mcchou@chromium.org, Howard Chung Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch adds parameter to enable/disable the interleave scan feature. --- Changes in v5: - Fix compile warning Changes in v4: - Set type of EnableAdvMonInterleaveScan to u8 - Add support of different sizes of parameters Changes in v3: - Set EnableAdvMonInterleaveScan default to Disable src/adapter.c | 10 ++++++++++ src/hcid.h | 1 + src/main.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- src/main.conf | 6 ++++++ 4 files changed, 60 insertions(+), 2 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index f072541aad35..553db4aa8b1f 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -4169,6 +4169,7 @@ static void load_default_system_params(struct btd_adapter *adapter) struct mgmt_tlv entry; union { uint16_t u16; + uint8_t u8; }; } __packed *params; uint16_t i = 0; @@ -4436,6 +4437,15 @@ static void load_default_system_params(struct btd_adapter *adapter) len += sizeof(params[i].u16); } + if (main_opts.default_params.enable_advmon_interleave_scan != 0xFF) { + params[i].entry.type = 0x001f; + params[i].entry.length = sizeof(params[i].u8); + params[i].u8 = + main_opts.default_params.enable_advmon_interleave_scan; + ++i; + len += sizeof(params[i].u8); + } + err = mgmt_send(adapter->mgmt, MGMT_OP_SET_DEF_SYSTEM_CONFIG, adapter->dev_id, len, params, NULL, NULL, NULL); if (!err) diff --git a/src/hcid.h b/src/hcid.h index 713eab8e03ae..34d22b3470f9 100644 --- a/src/hcid.h +++ b/src/hcid.h @@ -83,6 +83,7 @@ struct main_opts { uint16_t advmon_allowlist_scan_duration; uint16_t advmon_no_filter_scan_duration; + uint8_t enable_advmon_interleave_scan; } default_params; diff --git a/src/main.c b/src/main.c index 38f193a093df..274af6bdcc0f 100644 --- a/src/main.c +++ b/src/main.c @@ -112,6 +112,7 @@ static const char *controller_options[] = { "LEAutoconnecttimeout", "AdvMonAllowlistScanDuration", "AdvMonNoFilterScanDuration", + "EnableAdvMonInterleaveScan", NULL }; @@ -307,130 +308,169 @@ static void parse_controller_config(GKeyFile *config) { static const struct { const char * const val_name; - uint16_t * const val; + void * const val; + const size_t size; const uint16_t min; const uint16_t max; } params[] = { { "BRPageScanType", &main_opts.default_params.br_page_scan_type, + sizeof(main_opts.default_params.br_page_scan_type), 0, 1}, { "BRPageScanInterval", &main_opts.default_params.br_page_scan_interval, + sizeof(main_opts.default_params.br_page_scan_interval), 0x0012, 0x1000}, { "BRPageScanWindow", &main_opts.default_params.br_page_scan_win, + sizeof(main_opts.default_params.br_page_scan_win), 0x0011, 0x1000}, { "BRInquiryScanType", &main_opts.default_params.br_scan_type, + sizeof(main_opts.default_params.br_scan_type), 0, 1}, { "BRInquiryScanInterval", &main_opts.default_params.br_scan_interval, + sizeof(main_opts.default_params.br_scan_interval), 0x0012, 0x1000}, { "BRInquiryScanWindow", &main_opts.default_params.br_scan_win, + sizeof(main_opts.default_params.br_scan_win), 0x0011, 0x1000}, { "BRLinkSupervisionTimeout", &main_opts.default_params.br_link_supervision_timeout, + sizeof(main_opts.default_params.br_link_supervision_timeout), 0x0001, 0xFFFF}, { "BRPageTimeout", &main_opts.default_params.br_page_timeout, + sizeof(main_opts.default_params.br_page_scan_win), 0x0001, 0xFFFF}, { "BRMinSniffInterval", &main_opts.default_params.br_min_sniff_interval, + sizeof(main_opts.default_params.br_min_sniff_interval), 0x0001, 0xFFFE}, { "BRMaxSniffInterval", &main_opts.default_params.br_max_sniff_interval, + sizeof(main_opts.default_params.br_max_sniff_interval), 0x0001, 0xFFFE}, { "LEMinAdvertisementInterval", &main_opts.default_params.le_min_adv_interval, + sizeof(main_opts.default_params.le_min_adv_interval), 0x0020, 0x4000}, { "LEMaxAdvertisementInterval", &main_opts.default_params.le_max_adv_interval, + sizeof(main_opts.default_params.le_max_adv_interval), 0x0020, 0x4000}, { "LEMultiAdvertisementRotationInterval", &main_opts.default_params.le_multi_adv_rotation_interval, + sizeof(main_opts.default_params. + le_multi_adv_rotation_interval), 0x0001, 0xFFFF}, { "LEScanIntervalAutoConnect", &main_opts.default_params.le_scan_interval_autoconnect, + sizeof(main_opts.default_params.le_scan_interval_autoconnect), 0x0004, 0x4000}, { "LEScanWindowAutoConnect", &main_opts.default_params.le_scan_win_autoconnect, + sizeof(main_opts.default_params.le_scan_win_autoconnect), 0x0004, 0x4000}, { "LEScanIntervalSuspend", &main_opts.default_params.le_scan_interval_suspend, + sizeof(main_opts.default_params.le_scan_interval_suspend), 0x0004, 0x4000}, { "LEScanWindowSuspend", &main_opts.default_params.le_scan_win_suspend, + sizeof(main_opts.default_params.le_scan_win_suspend), 0x0004, 0x4000}, { "LEScanIntervalDiscovery", &main_opts.default_params.le_scan_interval_discovery, + sizeof(main_opts.default_params.le_scan_interval_discovery), 0x0004, 0x4000}, { "LEScanWindowDiscovery", &main_opts.default_params.le_scan_win_discovery, + sizeof(main_opts.default_params.le_scan_win_discovery), 0x0004, 0x4000}, { "LEScanIntervalAdvMonitor", &main_opts.default_params.le_scan_interval_adv_monitor, + sizeof(main_opts.default_params.le_scan_interval_adv_monitor), 0x0004, 0x4000}, { "LEScanWindowAdvMonitor", &main_opts.default_params.le_scan_win_adv_monitor, + sizeof(main_opts.default_params.le_scan_win_adv_monitor), 0x0004, 0x4000}, { "LEScanIntervalConnect", &main_opts.default_params.le_scan_interval_connect, + sizeof(main_opts.default_params.le_scan_interval_connect), 0x0004, 0x4000}, { "LEScanWindowConnect", &main_opts.default_params.le_scan_win_connect, + sizeof(main_opts.default_params.le_scan_win_connect), 0x0004, 0x4000}, { "LEMinConnectionInterval", &main_opts.default_params.le_min_conn_interval, + sizeof(main_opts.default_params.le_min_conn_interval), 0x0006, 0x0C80}, { "LEMaxConnectionInterval", &main_opts.default_params.le_max_conn_interval, + sizeof(main_opts.default_params.le_max_conn_interval), 0x0006, 0x0C80}, { "LEConnectionLatency", &main_opts.default_params.le_conn_latency, + sizeof(main_opts.default_params.le_conn_latency), 0x0000, 0x01F3}, { "LEConnectionSupervisionTimeout", &main_opts.default_params.le_conn_lsto, + sizeof(main_opts.default_params.le_conn_lsto), 0x000A, 0x0C80}, { "LEAutoconnecttimeout", &main_opts.default_params.le_autoconnect_timeout, + sizeof(main_opts.default_params.le_autoconnect_timeout), 0x0001, 0x4000}, { "AdvMonAllowlistScanDuration", &main_opts.default_params.advmon_allowlist_scan_duration, + sizeof(main_opts.default_params. + advmon_allowlist_scan_duration), 1, 10000}, { "AdvMonNoFilterScanDuration", &main_opts.default_params.advmon_no_filter_scan_duration, + sizeof(main_opts.default_params.br_page_scan_win), 1, 10000}, + { "EnableAdvMonInterleaveScan", + &main_opts.default_params.enable_advmon_interleave_scan, + sizeof(main_opts.default_params. + enable_advmon_interleave_scan), + 0, + 1}, }; uint16_t i; @@ -449,7 +489,7 @@ static void parse_controller_config(GKeyFile *config) val = MAX(val, params[i].min); val = MIN(val, params[i].max); - *params[i].val = val; + memcpy(params[i].val, &val, params[i].size); ++main_opts.default_params.num_entries; } } @@ -698,6 +738,7 @@ static void init_defaults(void) main_opts.default_params.num_entries = 0; main_opts.default_params.br_page_scan_type = 0xFFFF; main_opts.default_params.br_scan_type = 0xFFFF; + main_opts.default_params.enable_advmon_interleave_scan = 0xFF; if (sscanf(VERSION, "%hhu.%hhu", &major, &minor) != 2) return; diff --git a/src/main.conf b/src/main.conf index 3b341f44c9cf..82ffc5813204 100644 --- a/src/main.conf +++ b/src/main.conf @@ -159,6 +159,12 @@ # Default: 500 #AdvMonNoFilterScanDuration= +# Enable/Disable Advertisement Monitor interleave scan for power saving. +# 0: disable +# 1: enable +# Defaults to 0 +#EnableAdvMonInterleaveScan= + [GATT] # GATT attribute cache. # Possible values: -- 2.28.0.709.gb0816b6eb0-goog