Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp472722ybt; Wed, 1 Jul 2020 03:01:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSY+z6W/THB3glhMkD33IYnmTM2bApEfjamGjV/ebEbrHc2oacqb/irxJCJ3cPUQu5inmi X-Received: by 2002:a05:6402:1a4b:: with SMTP id bf11mr14296110edb.191.1593597701994; Wed, 01 Jul 2020 03:01:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593597701; cv=none; d=google.com; s=arc-20160816; b=aRXIAG6Ffm1mfq1rJxtHDo3Y6Yltcauf94Xue/u1kApFUj2L8pVt/nBQHIiNIFmlso MX2csvK8uykceDIKziKD5SoHJjUWmjpvg7j16SgQTBDZ3PiMAsI7o68T0zNPYGefM/a5 ZffKDSQ5kh6WG6nzg+qfH2M4uia7/da9/ejnhOxDBUig91AlcpKbQgrIzl5fjG/zcDtZ XDomZMLz+ur0KCZsqiEwN6YKwQ2WxJI8Zx5QUe4fPZLShYLtqabaFhjTx+sLMDEQ5TNk n5K+RaQ5F/mP8607FRVV33dg1hAF7DYjC07dgjqwwO3DVZUFt66WAIVxrECJWkaPebnT PtIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=yhFm8iVS8rF216LAKKaefGhuvOqn0g+HGfEb++sXEKQ=; b=PYLqFGEuvVZbK52r9I6m8kghZBdWe3U8T9BLdEq/tEBlv+aajMIxHUQSb3v7XYpP1V 9SQbtLHJFTXDeCImptYdQMuvGoA2ZzsTrdOqN7LWZ8zn1rJxOZiPpjL2F+QIm8olC6hF DQ36wZuwHoY+w7Rk2alA5EDx8zPNlQDlklFZ6krsFbIAf5GNcDheAdSVpT9Dml5UbIQJ Hu6+E7ftR0c+QCCanpNrmX5ma1OSUosB4LpnYmowdrjZzjBs0I/kDomKP3Yks5ZiCCmG 5Wwanu57ciYaYFk/EA4ZQsQ9PR1ZVyRVyrdH4Nv/CTydIyLRdDaHCvWSdevDv1WnQUAR 8yPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hdiqcRc6; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a9si3747573ejf.124.2020.07.01.03.01.14; Wed, 01 Jul 2020 03:01:41 -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=@gmail.com header.s=20161025 header.b=hdiqcRc6; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729633AbgGAKBL (ORCPT + 99 others); Wed, 1 Jul 2020 06:01:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725440AbgGAKBK (ORCPT ); Wed, 1 Jul 2020 06:01:10 -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 77D7AC061755 for ; Wed, 1 Jul 2020 03:01:10 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id bf7so395861plb.2 for ; Wed, 01 Jul 2020 03:01:10 -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=yhFm8iVS8rF216LAKKaefGhuvOqn0g+HGfEb++sXEKQ=; b=hdiqcRc63sJZg87JBlBrYqCN/EuvRLRr0Q4xTHYcPEY9fft8NYzC2mYjSkPb0Qckuo Y0JTvEVd8gCB/G5u2kjcb2UuGtX1RIt6wKbw4JsPlFUig1okeouA/Xeo21DMwZrqg48C dh104Na4SW6oTFpa+TbntOVTraqSRcpvtGQ8TF/ffnA9qYg2wN+gpHo9U6D0UV4KnWk9 USuRhIWhUewFnDewVPLfnjEOe5s+tWWl1kjel0RDZrViNkR0ib6toF/9/qCZGUNWdSAX akfIJcyu4KqDEgRA4kYBuEmpXXGrUPL6YrIZ8NfPvkbQWNc0rk08bgqrXM+JcWq5Jy8G dg6Q== 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=yhFm8iVS8rF216LAKKaefGhuvOqn0g+HGfEb++sXEKQ=; b=pC++NKP8GJ+iDGTLawS5aq4t3Ze7NW+/mOqX9qJK5zqk4cbi2w82UZnIlJIW7pmJ3g gJGezxI50bYIMiqEGGqy+W0gqWvl45zbf4dRDwi1MxYNTR/DX/4PF3inMeL0BfUkXNTl 6MiBJw8csA91zObaU0VQXpvRcnLQjlQNbtvUqJ0FNOFhGXkd6vmTSYQjfFgAw76DDK60 wS0kwKuIte5+OsTQDtkcqxv7Z+q4aIMqI635ZIwLzPusFdshKsGdhNpwln4CKCjaf3yT WO1POidvXh/GCEqgfwjnn85o9i0so7d35kiPxft0g5XLkRnhwVZt6A7enSkib91vp677 fRfg== X-Gm-Message-State: AOAM53027R8/PEELBJj/UJiBK9ujHlpW+l8TV2Atl7cN6U2/59PCjjbs +d0OuHczDsCs/cTgDiO6s5OLSm2zHQYvCw== X-Received: by 2002:a17:902:7204:: with SMTP id ba4mr20563799plb.250.1593597669730; Wed, 01 Jul 2020 03:01:09 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.55.43]) by smtp.gmail.com with ESMTPSA id d37sm5381961pgd.18.2020.07.01.03.01.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 03:01:09 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Marcel Holtmann , Sathish Narsimman Subject: [PATCH v2 2/8] Bluetooth: Configure controller address resolution if available Date: Wed, 1 Jul 2020 15:34:26 +0530 Message-Id: <20200701100432.28038-3-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200701100432.28038-1-sathish.narasimman@intel.com> References: <20200701100432.28038-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 836dc997ff94..915f7a48bfaa 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1358,6 +1358,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 116207009dde..5978f9177b3d 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, @@ -815,7 +821,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; @@ -824,6 +831,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 */ @@ -897,12 +909,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"); @@ -948,7 +966,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) @@ -2747,6 +2765,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); @@ -2768,7 +2788,7 @@ static int active_scan(struct hci_request *req, unsigned long opt) own_addr_type = ADDR_LE_DEV_PUBLIC; hci_req_start_scan(req, LE_SCAN_ACTIVE, interval, DISCOV_LE_SCAN_WIN, - own_addr_type, filter_policy); + own_addr_type, filter_policy, addr_resolv); return 0; } -- 2.17.1