From patchwork Mon Jul 13 06:22:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sathish Narasimman X-Patchwork-Id: 11658823 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 4C23913B1 for ; Mon, 13 Jul 2020 06:18:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 345AF2075F for ; Mon, 13 Jul 2020 06:18:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hUtjcKtg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729013AbgGMGSj (ORCPT ); Mon, 13 Jul 2020 02:18:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725804AbgGMGSj (ORCPT ); Mon, 13 Jul 2020 02:18:39 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96AB1C061794 for ; Sun, 12 Jul 2020 23:18:39 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id f16so5729875pjt.0 for ; Sun, 12 Jul 2020 23:18: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:in-reply-to:references; bh=0uDYaKG7efI3+NfcjCvxS1+KgIa76fmhv33RI9RFLbw=; b=hUtjcKtgoBapahxkdmERTduk04+ofTqj2xNcTSMk5qW2ivR/AIl59W9/v5Co1Yxh9O Dhd0WSJnUc7opL0EeEDVgG3XO+r4LwLM08bDTuFhChIElShcLVinBFAUDXGybgGg7+ER agSrHrS/xhHJrkV0YWT/p270AcUUQDH9EaSoorbaTDIcO6RBTGva5PUtVuZOAlWUPfsU AVtNNTryoNn7GcvJJHa/BaanIOCqaWKSQW0TowMYDQfebYfSB92bLy4FCXY1RvYx4pGo kHu6ClK4zfqQ0pT1BrECmGtINU0vkyMqN01YJ74TQP1HN8isfzwIYRsSUnNdgPHN8NrO Rjug== 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:in-reply-to :references; bh=0uDYaKG7efI3+NfcjCvxS1+KgIa76fmhv33RI9RFLbw=; b=sJb8SkzzNkPjwzs21AlGXx64LwcowYLsc2hRdJ3CfCJFfgkoouoLWWcfYn1JFDSAu5 1VNYuRd52dykLZcEBVuqKNksQ56ZyJJ/9HXQ58hDtPTY26yBu3v9EgYAXEJItVl3zcv1 x9RwFGDA1TDLcFqy4dbiEewXfml91oO+EhyDAyWzN0d3twC5IdTP+Gxj31VtMh0glfEv Q+ge9gl9D9SglEJQQ9RsmYYH61nC2sbnnhuMmZ/3oKRjvD7rcoRjZrUfc/X93aSeP6Yb itXtotqBHx4Zi0sbbF6PYOWvr3j5Pl0V4ZggjTqb3eEm1YibDO+TjOcKbMry8mUpybGV lpVQ== X-Gm-Message-State: AOAM530hL/VhSNLB3vZnteelHK2ZqHqtj8/+RfaLbmQGtZfQ+weBvGyn lz9dFdpHl6QzQJnz+kKed/Ebb5131OcpmA== X-Google-Smtp-Source: ABdhPJx8P3oxwtEo0ns2ScQu4IKDUTrgpWu/hD6SWZtM7YMg2zCU3ZDHaH8MJybO016/eVhWiFIZ3Q== X-Received: by 2002:a17:902:654e:: with SMTP id d14mr26325038pln.60.1594621118885; Sun, 12 Jul 2020 23:18:38 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com (jfdmzpr04-ext.jf.intel.com. [134.134.137.73]) by smtp.gmail.com with ESMTPSA id 204sm13096371pfx.3.2020.07.12.23.18.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2020 23:18:38 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Marcel Holtmann , Sathish Narsimman Subject: [PATCH v4 2/8] Bluetooth: Configure controller address resolution if available Date: Mon, 13 Jul 2020 11:52:07 +0530 Message-Id: <20200713062213.3692-3-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200713062213.3692-1-sathish.narasimman@intel.com> References: <20200713062213.3692-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Marcel Holtmann When the LL Privacy support is available, then as part of enabling or disabling passive background scanning, it is required to set up the controller based address resolution as well. Since only passive background scanning is utilizing the whitelist, the address resolution is now bound to the whitelist and passive background scanning. All other resolution can be easily done by the host stack. Signed-off-by: Marcel Holtmann Signed-off-by: Sathish Narsimman --- include/net/bluetooth/hci_core.h | 3 +++ net/bluetooth/hci_request.c | 26 +++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 34ad5b207598..065250242a1b 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1359,6 +1359,9 @@ void hci_conn_del_sysfs(struct hci_conn *conn); #define scan_coded(dev) (((dev)->le_tx_def_phys & HCI_LE_SET_PHY_CODED) || \ ((dev)->le_rx_def_phys & HCI_LE_SET_PHY_CODED)) +/* Use LL Privacy based address resolution if supported */ +#define use_ll_privacy(dev) ((dev)->le_features[0] & HCI_LE_LL_PRIVACY) + /* Use ext scanning if set ext scan param and ext scan enable is supported */ #define use_ext_scan(dev) (((dev)->commands[37] & 0x20) && \ ((dev)->commands[37] & 0x40)) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 770b93758112..d3c7ddbcff33 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -675,6 +675,12 @@ void hci_req_add_le_scan_disable(struct hci_request *req) cp.enable = LE_SCAN_DISABLE; hci_req_add(req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp); } + + if (use_ll_privacy(hdev) && + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) { + __u8 enable = 0x00; + hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); + } } static void del_from_white_list(struct hci_request *req, bdaddr_t *bdaddr, @@ -816,7 +822,8 @@ static bool scan_use_rpa(struct hci_dev *hdev) } static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, - u16 window, u8 own_addr_type, u8 filter_policy) + u16 window, u8 own_addr_type, u8 filter_policy, + bool addr_resolv) { struct hci_dev *hdev = req->hdev; @@ -825,6 +832,11 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, return; } + if (use_ll_privacy(hdev) && addr_resolv) { + u8 enable = 0x01; + hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); + } + /* Use ext scanning if set ext scan param and ext scan enable is * supported */ @@ -898,12 +910,18 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, } } +/* Ensure to call hci_req_add_le_scan_disable() first to disable the + * controller based address resolution to be able to reconfigure + * resolving list. + */ void hci_req_add_le_passive_scan(struct hci_request *req) { struct hci_dev *hdev = req->hdev; u8 own_addr_type; u8 filter_policy; u16 window, interval; + /* Background scanning should run with address resolution */ + bool addr_resolv = true; if (hdev->scanning_paused) { bt_dev_dbg(hdev, "Scanning is paused for suspend"); @@ -949,7 +967,7 @@ void hci_req_add_le_passive_scan(struct hci_request *req) bt_dev_dbg(hdev, "LE passive scan with whitelist = %d", filter_policy); hci_req_start_scan(req, LE_SCAN_PASSIVE, interval, window, - own_addr_type, filter_policy); + own_addr_type, filter_policy, addr_resolv); } static u8 get_adv_instance_scan_rsp_len(struct hci_dev *hdev, u8 instance) @@ -2748,6 +2766,8 @@ static int active_scan(struct hci_request *req, unsigned long opt) u8 own_addr_type; /* White list is not used for discovery */ u8 filter_policy = 0x00; + /* Discovery doesn't require controller address resolution */ + bool addr_resolv = false; int err; BT_DBG("%s", hdev->name); @@ -2770,7 +2790,7 @@ static int active_scan(struct hci_request *req, unsigned long opt) hci_req_start_scan(req, LE_SCAN_ACTIVE, interval, hdev->le_scan_window_discovery, own_addr_type, - filter_policy); + filter_policy, addr_resolv); return 0; }