Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1298260ybh; Thu, 23 Jul 2020 05:36:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydxvnihM7DbRLSe9CmfWXcYkINmPKR5ovPxcG3Y1cPzGEYF9ONE/hXlOihHVDSqQMbRfUo X-Received: by 2002:aa7:c609:: with SMTP id h9mr4039740edq.43.1595507765383; Thu, 23 Jul 2020 05:36:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595507765; cv=none; d=google.com; s=arc-20160816; b=P9RADVRaKReoOWmDIBOi2GmPv/EHSrfD9jM/yGuT8sHMjuBcRjiJosqK5ukNtI04Dh VSbDIDLhi7biJ624qcZM0fAKc9xRKkU4Tz9U+DAGs18Mjk+ki9VqgYi5oKGTmb8X7fzl YVtzCqElsKsDNCIC2q1eWTSWcJ3Pz2NlqeVTzEGu11jDxsl35m+R/01EekISxu1UZnVA hSbyGnQD+1yvRFuTGfpqFi8N2yQJgQ+9mXZRFLkJAtmBwtgW90eaouqUHtNpmWPAcMew ckSfaytbl61EeOmOFl7yeuu9ZV4D7IWcWhdRA+58EtGEyQRTNTLifP81Kwlh+napFiFo WWLg== 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=VUqS07gPBeyv2W2P3TCEcoo0Bx0MtNnbq5B59KDRGS0=; b=VpSaSJQ0rPLWs3Xkt0n9F4EMUjKFcYBgN+H8ED1GqMnFw1BatfqWT325s8HdG/wPU5 DHJcBZJby1Ch2aF+7mdcy+b3TlK5igXn4cmHrAauz9tqHxohoFAV7L9y0Sln5HYSM8+x WtpNasHoKgqLc5BqWK9wLcH2Sk7H7JG/Bs3nJGrMejrd5oY77lZb5BSt4W/54X0C/Md4 tQV+efwmuU0Fkze6asxY+ieQvTaQbLGZTpUtzOGAWRzRYGxEidW81gSTwsJWz44OKbA0 CB8MzR9Y+jJzxVbkL3F8M6WNna3Mna2tE6R8fa87nhd+i4Vh6ow8Tnp4qCik84TOGNiF W6IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Z1wM4Dfv; 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 p2si1957952eju.192.2020.07.23.05.35.33; Thu, 23 Jul 2020 05:36:05 -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=Z1wM4Dfv; 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 S1726521AbgGWMfU (ORCPT + 99 others); Thu, 23 Jul 2020 08:35:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726109AbgGWMfU (ORCPT ); Thu, 23 Jul 2020 08:35:20 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DE89C0619DC for ; Thu, 23 Jul 2020 05:35:20 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id g67so3030272pgc.8 for ; Thu, 23 Jul 2020 05:35:20 -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=VUqS07gPBeyv2W2P3TCEcoo0Bx0MtNnbq5B59KDRGS0=; b=Z1wM4DfvsvCcG6fWY8jGCPVJsVfd2JgZ+Tcw1MTcd1kYzfgVrWzNJUgjsV+jTYZ5nY Ky8UvuOTf6uCB+oKnM9UCGVWxDvrS6xZWLqMcLFn+0OSR/AH9iLcD8H5EEnPbffWPuGD 2Ephum5uOS1pDfxZmSjeKS4K8KADNAWqT5hxPBK+AddN6mRVbSrgGAAqFx4T3VxYbh9D +twN9nxnfthtLSs4nYQNXCLZVHDSjU3T0o6TdNlsSlmcccEX6Te+SaA+zWT5TizlOZe2 jhXw3bOFZxkTpy7kX/ktQjFB06wn19l9mYUNqOJtBHk7uyP93P7svUySWKSHoCTkLzl0 zM7w== 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=VUqS07gPBeyv2W2P3TCEcoo0Bx0MtNnbq5B59KDRGS0=; b=HezUaCw1ABVh+/X1ndHiN3Ljru/jeGf6IV+E2npTRpl4W33RWQIA20+C0QO/ZY6b8q W/hCoVm5HOQWkycKN2b+hjmvCaOzpqjetcw/718E4mKMjysqAAwcn/BxCvq1ryOi2W2C /Cq62/wcmKO9Unu6jWxyPEZyZPgjuJ+D/WkVwgGs6fUY0ewgdHZpgQ0yw3Gtb1SBLxF8 n0EW2NtYKh4Xcf5NNWsao4z1wucPI5TzBOMj+2EvU+qQYcwcux3KDRNdy1p1ILoRWPrz xQ6BSr3Ha8ZssJSrJ9x4aH0DhG0W15LJ1xNRG5YxmDzrPp/uArNO1DbOiwa4Urs7Bn9A KRzg== X-Gm-Message-State: AOAM532aK7nNQ713NnLkGpTVplNXRX7qSIBrwK7ic4Cy/hyDDdO9h/Me RBZ6JIMRB0hfXOSc9uiOE3WPaI8UKtrCZA== X-Received: by 2002:a63:6ca:: with SMTP id 193mr4036706pgg.269.1595507719475; Thu, 23 Jul 2020 05:35:19 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.54.42]) by smtp.gmail.com with ESMTPSA id z11sm2849823pfr.71.2020.07.23.05.35.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2020 05:35:19 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Marcel Holtmann , Sathish Narsimman Subject: [PATCH v5 2/8] Bluetooth: Configure controller address resolution if available Date: Thu, 23 Jul 2020 18:08:57 +0530 Message-Id: <20200723123903.29337-2-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200723123903.29337-1-sathish.narasimman@intel.com> References: <20200723123903.29337-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 bee1b4778ccc..8caac20556b4 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 7c0c2fda04ad..7d0ba53ffed0 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) @@ -2789,6 +2807,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); @@ -2811,7 +2831,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; } -- 2.17.1