From patchwork Thu Jun 4 04:08:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sathish Narasimman X-Patchwork-Id: 11586895 X-Patchwork-Delegate: marcel@holtmann.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 57901913 for ; Thu, 4 Jun 2020 04:05:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3944420679 for ; Thu, 4 Jun 2020 04:05:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mXIQJGGY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726031AbgFDEFJ (ORCPT ); Thu, 4 Jun 2020 00:05:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725936AbgFDEFI (ORCPT ); Thu, 4 Jun 2020 00:05:08 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A0EDC03E96D for ; Wed, 3 Jun 2020 21:05:07 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id q16so1617648plr.2 for ; Wed, 03 Jun 2020 21:05:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=RqbNZdfUYH4SzFn+I4Y/bQsxB/0Uon3AtvdfFK17OOE=; b=mXIQJGGYDKoJoYB2Qm+B9pT/w6t6r3UxcwMj9m6UPl7Cpq8T0hPtnBJolbmzuMGYTP eWMVEQJdRSLOtA2l0RGfLO/a4NisVbbwRvdcz8j2j8A5Apo9OhLYxHrx3aoe0Rfouf9R 6JheofOnMg8718dCpIpZyIx8SgAl+m+CZP0jyaVADmrtW/zzdX5wF0+x9VD1ats20Mij 3d5vba3HB82Kj1NYMf2+Mp7uCi1YpTM6HL05k03/QlY9w4XgNgesBP5p6PBrycgIw/zf auSuXDpsIFLTZwP78tpK581doDD8W9n+oMjX+aVpj48qxoD4GrD9jV0uqSrhj8vu/i2E ++yA== 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; bh=RqbNZdfUYH4SzFn+I4Y/bQsxB/0Uon3AtvdfFK17OOE=; b=L2o6F+ERw3Dy1bokPiQpL1kGG8FxJpD/H1tmotu4opsxIAhnUnv7ivHb3MTXDOYKpg AB8FT1GX5EQliW0pHKTmUnJa53rafe5WjMHqmuQerapZWDTmWWbcK0VDGuTORPsArZE/ jjkwrMdnsYrNc8HuVbI6T05+Vm9Ldzx7cNtZPkyewkE8HrXu98WICU1RU8cQoEir6wTy rJdoN3TGQEQm+FJlQMXIiBXZDMZxhHmfyW4Bna+ENhfE/3M0Zd0uFm1Zz9ZNKM7KP4MW dZUF26rs7Qpm9rbhFHJ/PwH6CGh91Aumy8eTrO9mn4WC6jQVS9eZWnajhnNk5XvviQPT oQ0w== X-Gm-Message-State: AOAM531OBv2FvvrY2xjChvZuyG/Rl7w5Q8eEG2TbTkof16HD8T+30yFO W/U3q2A2h4B9vITH/HcZedbid9nEqpM= X-Google-Smtp-Source: ABdhPJxAReCSs4aM5970z/4PrXW7Mo3fgJd7XeTEaWefZWSCN51QTqoP9JDyEwi976Vh2YX4Atj/Rw== X-Received: by 2002:a17:90a:2070:: with SMTP id n103mr3695152pjc.109.1591243506770; Wed, 03 Jun 2020 21:05:06 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([134.134.137.77]) by smtp.gmail.com with ESMTPSA id j130sm3119393pfd.94.2020.06.03.21.05.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2020 21:05:06 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH v2 4/7] Bluetooth: Translate additional address type during le_conn Date: Thu, 4 Jun 2020 09:38:28 +0530 Message-Id: <20200604040828.13336-1-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org When using controller based address resolution, then the new address types 0x02 and 0x03 are used. These types need to be converted back into either public address or random address types. This patch is specially during LE_CREATE_CONN if using own_add_type as 0x02 or 0x03. Signed-off-by: Sathish Narasimman --- net/bluetooth/hci_event.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index cfeaee347db3..9c9c434844f2 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -2296,6 +2296,22 @@ static void cs_le_create_conn(struct hci_dev *hdev, bdaddr_t *peer_addr, if (!conn) return; + /* When using controller based address resolution, then the new + * address types 0x02 and 0x03 are used. These types need to be + * converted back into either public address or random address type + */ + if (use_ll_privacy(hdev) && + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) { + switch (own_address_type) { + case ADDR_LE_DEV_PUBLIC_RESOLVED: + own_address_type = ADDR_LE_DEV_PUBLIC; + break; + case ADDR_LE_DEV_RANDOM_RESOLVED: + own_address_type = ADDR_LE_DEV_RANDOM; + break; + } + } + /* Store the initiator and responder address information which * is needed for SMP. These values will not change during the * lifetime of the connection. From patchwork Thu Jun 4 04:08:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sathish Narasimman X-Patchwork-Id: 11586897 X-Patchwork-Delegate: marcel@holtmann.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9E840138C for ; Thu, 4 Jun 2020 04:05:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 83761206DC for ; Thu, 4 Jun 2020 04:05:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="G6z7LJXq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726104AbgFDEFY (ORCPT ); Thu, 4 Jun 2020 00:05:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725936AbgFDEFY (ORCPT ); Thu, 4 Jun 2020 00:05:24 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCA11C03E96D for ; Wed, 3 Jun 2020 21:05:22 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id 5so519643pjd.0 for ; Wed, 03 Jun 2020 21:05:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=6CBbZ9r4eSiZUUGFyvEEYED4UFptLRNF6sdTCpICb7Q=; b=G6z7LJXq1yMGvzasIcDqLhMRmS1B7Lt2UBo3R6TzlQYTaS8nw/C6mFjucuFGQhzBgK zkYQcfD7vgo3urDKr6P5+7fhPDGPTwXhaNvpeax9LtqpyuXhKKcoa8kVBtrXBBgDJEs3 9IleOAWQAgN/EVgbLCgUPn0xFon3pnNjR+UkG50C9xgu4O1bvyxHydGxMT7JMwnZZRzL SVRNsUJ+6xOOUH2XEhm9whFAKkEkENA7Q0zlDyd5h/lb1mSxsP1TA53/IP3wrC7E48tM c1/DcGihQQT1+o72MmMhzI4QHGyNVDdUXPIsZNjxcy1xc62NAy5QWkr0T2u91y3zUV+4 5syA== 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; bh=6CBbZ9r4eSiZUUGFyvEEYED4UFptLRNF6sdTCpICb7Q=; b=hTdz5Fe5zokQQC6oYJMusoDsft69coHCFFKCzus4hsLRS6NmxkkwXAjklQxi2nzhU4 xcU7a+NCwAPw6TDl9I9a3/Bd4CYgqKSb2vSwwhcnExctBio0ckOtJ9pudG4sDP5ZMuNp jkrB4Nz9DxvwItdTitBCD6J+MSM5TYDYCW8Sy1zimjvqQdaV8WZA7ruEd8HMhdneF7Ll XbI/2hwyLb7c+VksM0YdvmFyqw6SeJg5MMkl/D6PdWrckcqIVHiiMqRAS1nGhTIG6LDi G5QJqfMuAIeOIzXrQUwUnACIj+gYsqcynZ0h96gNaGaHiMVcz4LE0Bvx4sa/na1SD731 EdLQ== X-Gm-Message-State: AOAM530IjpOlCpB53041rE64jNMeABjdv09ZNfvzeUMFP3oEEVmQBlE2 2eUfYp2Br0q7WCDg0i59yblUFKdXqOI= X-Google-Smtp-Source: ABdhPJwhO8/xcwxFBN4HuqR5BkjFFP8mgMR0knnySqSmPe6cnId7wXVstfoShrZeOmx8/PmO5A+4LA== X-Received: by 2002:a17:902:eb03:: with SMTP id l3mr2912522plb.49.1591243522003; Wed, 03 Jun 2020 21:05:22 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([134.134.137.77]) by smtp.gmail.com with ESMTPSA id z9sm3700683pjr.39.2020.06.03.21.05.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2020 21:05:21 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH v2 5/7] Bluetooth: Let controller creates RPA during le create conn Date: Thu, 4 Jun 2020 09:38:44 +0530 Message-Id: <20200604040844.13386-1-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org When address resolution is enabled and set_privacy is enabled let's use own address type as 0x03 Signed-off-by: Sathish Narasimman --- net/bluetooth/hci_request.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index bcd64dec9989..6e1036cc8b1e 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -2183,7 +2183,13 @@ int hci_update_random_address(struct hci_request *req, bool require_privacy, if (use_rpa) { int to; - *own_addr_type = ADDR_LE_DEV_RANDOM; + /* If Controller supports LL Privacy use own address type is + * 0x03 + */ + if (use_ll_privacy(hdev)) + *own_addr_type = ADDR_LE_DEV_RANDOM_RESOLVED; + else + *own_addr_type = ADDR_LE_DEV_RANDOM; if (!hci_dev_test_and_clear_flag(hdev, HCI_RPA_EXPIRED) && !bacmp(&hdev->random_addr, &hdev->rpa)) From patchwork Thu Jun 4 04:09:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sathish Narasimman X-Patchwork-Id: 11586899 X-Patchwork-Delegate: marcel@holtmann.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6EB9317CA for ; Thu, 4 Jun 2020 04:05:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 526BB2072E for ; Thu, 4 Jun 2020 04:05:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="b/gevncW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726120AbgFDEFl (ORCPT ); Thu, 4 Jun 2020 00:05:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725767AbgFDEFk (ORCPT ); Thu, 4 Jun 2020 00:05:40 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD9AFC03E96D for ; Wed, 3 Jun 2020 21:05:39 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id s10so2989128pgm.0 for ; Wed, 03 Jun 2020 21:05:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=lEpu+mPwhcgszfPdr3BI0hBtv81HWV0SrnyrSIu5zdA=; b=b/gevncWZ8d9XHeBwJ+q25V/F8s0bhdNZ6h9iyEdxG9J1dlFa2HCrim69A1lt9OGFp GiiBnRrJR2x/WqMW//Z/gMGZh0Z/QyNLMfdgYcuhueIR2kx8DNEuJ/JvGTU4wDJqqww1 2var/k0g/gObPgH0lk0qSCKbciHgELAXXWlyKahWMMgKUKsU5bxCh4ra4dHsQcMXocvW UQS1Pax+1qyL3+2BcciozopGVErGRIYyajxAOPi0CjIGMGO+ZOMLKSAeXwiokIJj5A6t TIfK1HM4oqG5SrmZAlPPCYZsd4YDXz95E03gNcWis6/gf3FT117laVXimUQFMZ9/lzuv 21Og== 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; bh=lEpu+mPwhcgszfPdr3BI0hBtv81HWV0SrnyrSIu5zdA=; b=jcW7eNVYtQWzLC+Qbk27xTqGdv9lQOk2TWNEwwKLWzq55i5TQvYC68MMR/ZoUnZCWQ sGoSM9bdBbvosLCwdcHFpQQFniUD6DGo947koYNsH2EyxOHHiiauXHTu+NhpgI7wQOAp 3jGCI9j1NGa+OVB/SeY0SUBNO3SIisNWH4NXUPuyzTazpHZ27eVotEz9nqOl/mOXgQmx RYR6SHKTNYPLjBK00spB3l6AL1r574r51cREugTyyMCWbJ5zMduw0+XYADA54IzUUbW1 0UU1ZzzUdHQ5ApVehFf+bFonGkr4kZOf9+rEMPwSnknl5XM+aFx5kxhy4j5memctZzCu mohQ== X-Gm-Message-State: AOAM530SPoOndKRS1MNBOIEIuwyWOPi1gyrV1KIg50/nLosJeTvXxUJ2 pt96z2bwGlDlWoklJQs48ZOhvrg+J1M= X-Google-Smtp-Source: ABdhPJwX/6JF98725wRXb5v5nJZNeoVj3tLQoP5VEsIm2T1lby33tdoYXojGHFJ9dzECHvEohSnUjw== X-Received: by 2002:a63:78b:: with SMTP id 133mr2702944pgh.161.1591243538991; Wed, 03 Jun 2020 21:05:38 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([134.134.137.77]) by smtp.gmail.com with ESMTPSA id o18sm3265230pfu.138.2020.06.03.21.05.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2020 21:05:38 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH v2 6/7] Bluetooth: Enable/Disable address resolution during le create conn Date: Thu, 4 Jun 2020 09:39:00 +0530 Message-Id: <20200604040900.13436-1-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org In this patch if le_create_conn process is started restrict to disable address resolution and same is disabled during le_enh_connection_complete Signed-off-by: Sathish Narasimman --- net/bluetooth/hci_conn.c | 6 ++++- net/bluetooth/hci_event.c | 4 ++++ net/bluetooth/hci_request.c | 46 ++++++++++++++++++++++++++++--------- net/bluetooth/hci_request.h | 3 ++- net/bluetooth/mgmt.c | 2 +- 5 files changed, 47 insertions(+), 14 deletions(-) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 307800fd18e6..bbd6d06bc900 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -1008,6 +1008,10 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, struct smp_irk *irk; struct hci_request req; int err; + /* This ensures that during disable le_scan address resolution + * will not be disabled if it is followed by le_create_conn + */ + bool rpa_le_conn = true; /* Let's make sure that le is enabled.*/ if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED)) { @@ -1109,7 +1113,7 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, * state. */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { - hci_req_add_le_scan_disable(&req); + hci_req_add_le_scan_disable(&req, rpa_le_conn); hci_dev_set_flag(hdev, HCI_LE_SCAN_INTERRUPTED); } diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 9c9c434844f2..1866de712bb2 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5225,6 +5225,10 @@ static void hci_le_enh_conn_complete_evt(struct hci_dev *hdev, le16_to_cpu(ev->interval), le16_to_cpu(ev->latency), le16_to_cpu(ev->supervision_timeout)); + + if (use_ll_privacy(hdev) && + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) + hci_req_disable_address_resolution(hdev); } static void hci_le_ext_adv_term_evt(struct hci_dev *hdev, struct sk_buff *skb) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 6e1036cc8b1e..8552a37976ec 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -429,7 +429,7 @@ static void __hci_update_background_scan(struct hci_request *req) if (!hci_dev_test_flag(hdev, HCI_LE_SCAN)) return; - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); BT_DBG("%s stopping background scanning", hdev->name); } else { @@ -448,7 +448,7 @@ static void __hci_update_background_scan(struct hci_request *req) * don't miss any advertising (due to duplicates filter). */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); hci_req_add_le_passive_scan(req); @@ -653,7 +653,7 @@ void __hci_req_update_eir(struct hci_request *req) hci_req_add(req, HCI_OP_WRITE_EIR, sizeof(cp), &cp); } -void hci_req_add_le_scan_disable(struct hci_request *req) +void hci_req_add_le_scan_disable(struct hci_request *req, bool rpa_le_conn) { struct hci_dev *hdev = req->hdev; @@ -677,8 +677,9 @@ void hci_req_add_le_scan_disable(struct hci_request *req) hci_req_add(req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp); } + /* Disable address resolution */ if (use_ll_privacy(hdev) && - hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) { + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) && !rpa_le_conn) { __u8 enable = 0x00; hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); } @@ -1054,7 +1055,7 @@ static void hci_req_set_event_filter(struct hci_request *req) static void hci_req_config_le_suspend_scan(struct hci_request *req) { /* Can't change params without disabling first */ - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); /* Configure params and enable scanning */ hci_req_add_le_passive_scan(req); @@ -1121,7 +1122,7 @@ void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next) hci_req_add(&req, HCI_OP_WRITE_SCAN_ENABLE, 1, &page_scan); /* Disable LE passive scan */ - hci_req_add_le_scan_disable(&req); + hci_req_add_le_scan_disable(&req, false); /* Mark task needing completion */ set_bit(SUSPEND_SCAN_DISABLE, hdev->suspend_tasks); @@ -1682,6 +1683,29 @@ int hci_req_update_adv_data(struct hci_dev *hdev, u8 instance) return hci_req_run(&req, NULL); } +static void enable_addr_resolution_complete(struct hci_dev *hdev, u8 status, + u16 opcode) +{ + BT_DBG("%s status %u", hdev->name, status); +} + +void hci_req_disable_address_resolution(struct hci_dev *hdev) +{ + struct hci_request req; + __u8 enable = 0x00; + + if (!use_ll_privacy(hdev) && + !hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) + return; + + hci_req_init(&req, hdev); + + hci_req_add(&req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); + + hci_req_run(&req, enable_addr_resolution_complete); +} + static void adv_enable_complete(struct hci_dev *hdev, u8 status, u16 opcode) { BT_DBG("%s status %u", hdev->name, status); @@ -2608,7 +2632,7 @@ static void bg_scan_update(struct work_struct *work) static int le_scan_disable(struct hci_request *req, unsigned long opt) { - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); return 0; } @@ -2706,7 +2730,7 @@ static int le_scan_restart(struct hci_request *req, unsigned long opt) if (!hci_dev_test_flag(hdev, HCI_LE_SCAN)) return 0; - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); if (use_ext_scan(hdev)) { struct hci_cp_le_set_ext_scan_enable ext_enable_cp; @@ -2797,7 +2821,7 @@ static int active_scan(struct hci_request *req, unsigned long opt) * discovery scanning parameters. */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); /* All active scans will be done with either a resolvable private * address (when privacy feature has been enabled) or non-resolvable @@ -2911,14 +2935,14 @@ bool hci_req_stop_discovery(struct hci_request *req) if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { cancel_delayed_work(&hdev->le_scan_disable); - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); } ret = true; } else { /* Passive scanning */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); ret = true; } } diff --git a/net/bluetooth/hci_request.h b/net/bluetooth/hci_request.h index 0e81614d235e..12bea10e7d70 100644 --- a/net/bluetooth/hci_request.h +++ b/net/bluetooth/hci_request.h @@ -65,11 +65,12 @@ void __hci_req_write_fast_connectable(struct hci_request *req, bool enable); void __hci_req_update_name(struct hci_request *req); void __hci_req_update_eir(struct hci_request *req); -void hci_req_add_le_scan_disable(struct hci_request *req); +void hci_req_add_le_scan_disable(struct hci_request *req, bool rpa_le_conn); void hci_req_add_le_passive_scan(struct hci_request *req); void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next); +void hci_req_disable_address_resolution(struct hci_dev *hdev); void hci_req_reenable_advertising(struct hci_dev *hdev); void __hci_req_enable_advertising(struct hci_request *req); void __hci_req_disable_advertising(struct hci_request *req); diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 9e8a3cccc6ca..97eb4f3a160b 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -4848,7 +4848,7 @@ static int set_scan_params(struct sock *sk, struct hci_dev *hdev, hci_req_init(&req, hdev); - hci_req_add_le_scan_disable(&req); + hci_req_add_le_scan_disable(&req, false); hci_req_add_le_passive_scan(&req); hci_req_run(&req, NULL); From patchwork Thu Jun 4 04:09:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sathish Narasimman X-Patchwork-Id: 11586901 X-Patchwork-Delegate: marcel@holtmann.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5E0B717C9 for ; Thu, 4 Jun 2020 04:05:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 45D702072E for ; Thu, 4 Jun 2020 04:05:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gAS9QwEP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726164AbgFDEFz (ORCPT ); Thu, 4 Jun 2020 00:05:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725767AbgFDEFy (ORCPT ); Thu, 4 Jun 2020 00:05:54 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BA2AC03E96D for ; Wed, 3 Jun 2020 21:05:54 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id q16so1618312plr.2 for ; Wed, 03 Jun 2020 21:05:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=BU6ReF+CfuG1LTcepLVvODsTNk13vMQXVhPfvRTtwpU=; b=gAS9QwEPbm1XfGhdu+25w0d8AYeYGso/wq0qpJNDr5q5nYqBLoAXJ8JlF6FEb3Dziw DF9HlGThPZZZpuH0wd6CtiIcts0obs7EO91P0l79LdMp+ZwZFOUdzBFMfh/6XkWL8dGS gCoqy4mhXfXdutRF1ntD1Pw/m4y9DQprzFBjybSUOVCYz5ivGa4foNmzL35S1gj+2EMi riRXHzix0JJPxY9xGkVBfqYN4zxPCAK/DbzeIsVeOhhCJoTmiTz7rIVShV5UdL0wO8gz t4PiA1nx9g8s05qKRUKvdSS1eoZovCc23uXk4Qil3XYTSnhAwTIbmgdih10arIEdIBQx 6XLQ== 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; bh=BU6ReF+CfuG1LTcepLVvODsTNk13vMQXVhPfvRTtwpU=; b=l4MGbZyGLRVUlFzAe1NN426zb/IsDfwq3PZ3JF7TOpCqEE4BLjniYeBDc+fHlTci1K NwyxwOlF/+6D5cuvA8laIUIGExu1X07vw4IihALRg/TFr+pkYsR8R26nbqqxHrV/aPlv /0Q+o8s+PcINYkF8zkdyVcAQBoXyac9PF7jX/G+bfAAKkFJaC1gvdoICXvVOypi8eGuX 59JKv2eKh41DvIS7iB+CxBEk6g9Q8ncJh0Y+NKy4/teldSHpJhi5CG31Y34/YInLoxlG nSQa+L4C7NBDjjygnhnEPBZvyXI604iuGwH4s09n3Smn73cmawIaXMWh0fe13UV6nlDV gk9g== X-Gm-Message-State: AOAM531pxjQpgkVxfzkqb+IxBfP9zNwulB3Gkk4quq9k6QHhPN3StBE+ U/DDuoO4L5ZSH5S5lVw1FlZeU0Ck9mY= X-Google-Smtp-Source: ABdhPJxwtxJYkpDm7IvHuIK56uWwJ1m5h1AA0S5etB3MEQgKiN/oFcBeMW6R5P3qJVmZgnHb4X8olQ== X-Received: by 2002:a17:90a:b949:: with SMTP id f9mr3421630pjw.79.1591243553969; Wed, 03 Jun 2020 21:05:53 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([134.134.137.77]) by smtp.gmail.com with ESMTPSA id w190sm3098898pfw.35.2020.06.03.21.05.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2020 21:05:53 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH v2 7/7] Bluetooth: Enable RPA Timeout Date: Thu, 4 Jun 2020 09:39:16 +0530 Message-Id: <20200604040916.13495-1-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Enable RPA timeout during bluetooth initialization. The RPA timeout value is used from hdev, which initialized from debug_fs Signed-off-by: Sathish Narasimman --- include/net/bluetooth/hci.h | 2 ++ net/bluetooth/hci_core.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 1165dfea56a9..12005fbe6e09 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -1637,6 +1637,8 @@ struct hci_rp_le_read_resolv_list_size { #define HCI_OP_LE_SET_ADDR_RESOLV_ENABLE 0x202d +#define HCI_OP_LE_SET_RPA_TIMEOUT 0x202e + #define HCI_OP_LE_READ_MAX_DATA_LEN 0x202f struct hci_rp_le_read_max_data_len { __u8 status; diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index f4ceda1f1454..67e1434c3f31 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -763,6 +763,14 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt) hci_req_add(req, HCI_OP_LE_CLEAR_RESOLV_LIST, 0, NULL); } + if (hdev->commands[35] & 0x40) { + __le16 rpa_timeout = cpu_to_le16(hdev->rpa_timeout); + + /* Set RPA timeout */ + hci_req_add(req, HCI_OP_LE_SET_RPA_TIMEOUT, 2, + &rpa_timeout); + } + if (hdev->le_features[0] & HCI_LE_DATA_LEN_EXT) { /* Read LE Maximum Data Length */ hci_req_add(req, HCI_OP_LE_READ_MAX_DATA_LEN, 0, NULL);