Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp748751ybh; Sun, 12 Jul 2020 23:19:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8BO6MSJ3mtnq4B0uYX3pem0h5sJ71vuV+QzLTD2un/65tnUV+rz8AlownpIJiGGDJv/0M X-Received: by 2002:a17:906:958f:: with SMTP id r15mr62748109ejx.77.1594621147206; Sun, 12 Jul 2020 23:19:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594621147; cv=none; d=google.com; s=arc-20160816; b=ReyZKHreYv9WAHd6q0YQy8RpWPzMaNG4WEtDC9cBgucJIPbpVoHHJJghgc2rZnk3e/ VAHVAsH2S41qFGrOwoqJBhMbloX3an9AwG2XU3ScqQt1U7Ngc2OuvjaQiaL2aCLTnEFs iOlYGsdqx4iPRYV+JwXVEFZQ2EvWt23n9XhECVdJZIwfcpaSw5dsOmPS00WImjopG8n1 U7sVuJMwJr0HbUZYJwCQSUOn+/CQLkgm7eBMnAaXYpLUzczUsfDko3gZhIJbeGkcARgE K2svfHdKKGD10Mv/2YbfIG2Nzl+wpyEvCZSHygGrZYDtHhMGPPaNyYIR/5CyEIITxkHz bQQg== 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=0uDYaKG7efI3+NfcjCvxS1+KgIa76fmhv33RI9RFLbw=; b=x4scWUzXfeBhose48Wj3AGvJqlUcR981c6d61CL0fSB0wURMe8WyO+zbuKEA1Zi+HK PYy2c6mAhsTePUskoftQJIITTtSb/8+dMG0hlbTdJi418o6yltEZFifwVcR+xiHUVPRk /Uqm52uDxNp/hMxTkOkC851WdxwKnooPnQceKk/VWXfZHjY6mdJA21wUWdQdltWCL+yS oJr5EXUBjII3DMhckzNjWAHaGakhMk6nktsifZqn4SSwDY0BCzhzEkHXDQByl4mE7M82 EHgWWW8ZGhF4WbH2H3CfGpZK0KR6a+fSlgIXlWyX8/9UyCvObyWcDNcQZBrV9+64Zsfh XvBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hUtjcKtg; 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 c10si8411609ejs.1.2020.07.12.23.18.43; Sun, 12 Jul 2020 23:19:07 -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=hUtjcKtg; 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 S1729003AbgGMGSj (ORCPT + 99 others); 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-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; } -- 2.17.1