Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2967674ybt; Mon, 29 Jun 2020 11:42:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymxEFxEXU9S9l7ygwapDIy4lWoJ9vZ0x+fU0w9OYedxCOOmLHgZVqfwE1H8qP2/fuPGVfY X-Received: by 2002:a05:6402:1494:: with SMTP id e20mr7499560edv.2.1593456133277; Mon, 29 Jun 2020 11:42:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593456133; cv=none; d=google.com; s=arc-20160816; b=ZjpF7Z9dJwb+LH5I0Nh9baxljFXaZ8cWF0BEGjVBjixX+Z0Xpgsqb9A+eLVPzV/TXg eC7ya0TodIN3fJKszuw/LQgoibbXbqn/VZ8ASQgMyCSuCSXRR/kwaswZ1bW5g2CwDEMW W5g9raGRfu1NW6dS6D2I8p7fhiaNk2cw+LaLoaUT5SjBOrK12wF9P5vQlnbco6Rmljp4 InCLOkS00JOeSdFoceHRMj0Oc78KncMl9md6wltNzQZPCWHr8aiCJ7FwOx0j5Tke+G5r hGjY0YhEXi8nZXzrznfmV61cwcl2R8TQgGWm71n1mBRqxL/4cq3J8xt9BlpiS3FJE99e HQlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=6Kr0CfwM9aKJbWc9C5EQDAp5E5fQURuKqXKmcPgCKRE=; b=VjpYmQKIbFuQ1njAiMgXfeftGwwmlF7FTNZUr/uhmzl1W9lxvShZC7xJZBMVewtElN xUYdY47mMn+y43tPrilpXce38PQd/WEuWNsNmaz2yfO3moIMp9uKaL3Bl1ac0iPGkLfx 3Hexp9UMfVSD6bqkveMs+wnfrrFpKXfd3jJb4BLiMjiZrl3gPXBqjj/+i1pwxFTUkqaR /7yUQ8gFn9ncyLjNnb/8eRqcZEmJkZvFbImBGkn4dlx7P4aGiU4W9nGHazDJNBxNgXfi MxVSwt5nD4VM79yzGpo84summ3WHnpuVbVht6GDI8/zrnz9EvTbULeE7/AZrZ38znFVC KP/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=oZRC9H1G; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dr9si413020ejc.147.2020.06.29.11.41.28; Mon, 29 Jun 2020 11:42:13 -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=@chromium.org header.s=google header.b=oZRC9H1G; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726114AbgF2SiI (ORCPT + 99 others); Mon, 29 Jun 2020 14:38:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727977AbgF2SiC (ORCPT ); Mon, 29 Jun 2020 14:38:02 -0400 Received: from mail-ua1-x941.google.com (mail-ua1-x941.google.com [IPv6:2607:f8b0:4864:20::941]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F00DCC030F00 for ; Mon, 29 Jun 2020 09:11:04 -0700 (PDT) Received: by mail-ua1-x941.google.com with SMTP id c7so4031293uap.0 for ; Mon, 29 Jun 2020 09:11:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6Kr0CfwM9aKJbWc9C5EQDAp5E5fQURuKqXKmcPgCKRE=; b=oZRC9H1Gd6zyRqmzg72zYw5eW3ddmJZTEDKJ5539KLntSeq9byAnfsEBOYFIEBnP9p L3Dza1wr8wbcFMdyZeGjdL1a+Bob1GsWt8Khjzh5XXtdWm6dczCzqULwfv2JAVkTs7IE IVy8mEkswZubHMbrE2Z2aWmEd3mmQIkTB1YO8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6Kr0CfwM9aKJbWc9C5EQDAp5E5fQURuKqXKmcPgCKRE=; b=N60+uALgDn1opV5T5SdU/A9pbrcG6UHosXSdUv6t9/2yjKHlZARWBa1AxT78DJczX5 pqfy3PiwUe/rne72euhZwBROzA4fTpw9uqUnXGIwWca2kfsJc4APUl0me1uH1a/VQRYq U/NtE87gsJImbaHlxPjgPT0fgF+UmQ0ie9NmVnQLywhFjyObrLILBfqQS51mmZKDHnwl 5Kk367btSJL1PpERepFcJDgk+a7EYHLURKQzm3A7WtjmvyD9bHe9iuMbOX+zpkwjL6w3 OvgmNX/L3EpsdGr7ReGxYQ1vFFU6MXavWsiBtnwvBzmeFA9G5Dmha9MZO+ALfSi4X9Fp T5sA== X-Gm-Message-State: AOAM533vbIeJlZchKbhDdpu25HFJq7lWiEt+6Y5RcM2nJLo4kx0728VZ I78TzYg9pCmXUbvtkAU45hvxX/jaHlY= X-Received: by 2002:ab0:7849:: with SMTP id y9mr11180790uaq.56.1593447063791; Mon, 29 Jun 2020 09:11:03 -0700 (PDT) Received: from alain.c.googlers.com.com (252.177.243.35.bc.googleusercontent.com. [35.243.177.252]) by smtp.gmail.com with ESMTPSA id 123sm5633vsu.17.2020.06.29.09.11.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 09:11:03 -0700 (PDT) From: Alain Michaud To: linux-bluetooth@vger.kernel.org Cc: Alain Michaud Subject: [PATCH v3] Bluetooth: Adding a configurable autoconnect timeout Date: Mon, 29 Jun 2020 16:11:00 +0000 Message-Id: <20200629161100.3070288-1-alainm@chromium.org> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch adds a configurable LE autoconnect timeout. Signed-off-by: Alain Michaud --- Changes in v3: - Rebase onto master Changes in v2: Fixing longer than 80 char line. include/net/bluetooth/hci_core.h | 1 + net/bluetooth/hci_core.c | 1 + net/bluetooth/hci_event.c | 2 +- net/bluetooth/mgmt_config.c | 13 +++++++++++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 836dc997ff94..34ad5b207598 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -376,6 +376,7 @@ struct hci_dev { __u16 def_br_lsto; __u16 def_page_timeout; __u16 def_multi_adv_rotation_duration; + __u16 def_le_autoconnect_timeout; __u16 pkt_type; __u16 esco_type; diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 5577cf9e2c7c..1920e3c5c6f6 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3569,6 +3569,7 @@ struct hci_dev *hci_alloc_dev(void) hdev->le_rx_def_phys = HCI_LE_SET_PHY_1M; hdev->le_num_of_adv_sets = HCI_MAX_ADV_INSTANCES; hdev->def_multi_adv_rotation_duration = HCI_DEFAULT_ADV_DURATION; + hdev->def_le_autoconnect_timeout = HCI_LE_AUTOCONN_TIMEOUT; hdev->rpa_timeout = HCI_DEFAULT_RPA_TIMEOUT; hdev->discov_interleaved_timeout = DISCOV_INTERLEAVED_TIMEOUT; diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index e060fc9ebb18..03a0759f2fc2 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5315,7 +5315,7 @@ static struct hci_conn *check_pending_le_conn(struct hci_dev *hdev, } conn = hci_connect_le(hdev, addr, addr_type, BT_SECURITY_LOW, - HCI_LE_AUTOCONN_TIMEOUT, HCI_ROLE_MASTER, + hdev->def_le_autoconnect_timeout, HCI_ROLE_MASTER, direct_rpa); if (!IS_ERR(conn)) { /* If HCI_AUTO_CONN_EXPLICIT is set, conn is already owned diff --git a/net/bluetooth/mgmt_config.c b/net/bluetooth/mgmt_config.c index 8d01a8ff85e9..b30b571f8caf 100644 --- a/net/bluetooth/mgmt_config.c +++ b/net/bluetooth/mgmt_config.c @@ -17,6 +17,12 @@ { cpu_to_le16(hdev->_param_name_) } \ } +#define HDEV_PARAM_U16_JIFFIES_TO_MSECS(_param_code_, _param_name_) \ +{ \ + { cpu_to_le16(_param_code_), sizeof(__u16) }, \ + { cpu_to_le16(jiffies_to_msecs(hdev->_param_name_)) } \ +} + int read_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, u16 data_len) { @@ -59,6 +65,8 @@ int read_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, HDEV_PARAM_U16(0x0018, le_conn_max_interval), HDEV_PARAM_U16(0x0019, le_conn_latency), HDEV_PARAM_U16(0x001a, le_supv_timeout), + HDEV_PARAM_U16_JIFFIES_TO_MSECS(0x001b, + def_le_autoconnect_timeout), }; struct mgmt_rp_read_def_system_config *rp = (void *)params; @@ -129,6 +137,7 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, case 0x0018: case 0x0019: case 0x001a: + case 0x001b: if (len != sizeof(u16)) { bt_dev_warn(hdev, "invalid length %d, exp %zu for type %d", len, sizeof(u16), type); @@ -238,6 +247,10 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data, case 0x0001a: hdev->le_supv_timeout = TLV_GET_LE16(buffer); break; + case 0x0001b: + hdev->def_le_autoconnect_timeout = + msecs_to_jiffies(TLV_GET_LE16(buffer)); + break; default: bt_dev_warn(hdev, "unsupported parameter %u", type); break; -- 2.27.0.212.ge8ba1cc988-goog