Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1144201pxb; Thu, 4 Mar 2021 04:37:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJzmhHs9EANviUoyWczaOOzYDrWx4y2fjc4W60zbwNb09Ybg6RohHmFXo7ZBdSXa2XErmrRt X-Received: by 2002:aa7:c7c8:: with SMTP id o8mr4027856eds.176.1614861469540; Thu, 04 Mar 2021 04:37:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614861469; cv=none; d=google.com; s=arc-20160816; b=jdL0cC/xn0wr2GHxw2uxa0BIYYy7wAiDCRqGRR+VtEMr6haqR3j1wKTLPEucUU4REV n2rTM7F2kfwwkz0AvAkcnVJqF2tMvgYr9lKeYE/XTZy47OZ7H/wyTFtbrNZ8vCDZaWvp LpWyk3octgmmIBfwqvZ3gSRHaUiqFARCIazAU4BGirZSKKn7I5s6Mggpwd3YjzsPGLUS YgUsKGsZAO22dpNC6HNCucYG+sgi+ihUoZK6vFzRr4okjvG6lxr3e8nW1yIu6dCtyCEe fE6icvPWvrqNBPtoZ5ybTAzBgzvouDjakwVVrsf+GPR/r6gMq2uLSk4HPzBOaLfHjkcn ODBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :sender:dkim-signature; bh=N8PCfwZicPjsnptNF7G2E2FEEsEc1qJ+kpbU5CqawP4=; b=FSARLKLN/dEXGXmjV/jvXf+jlFxRIkTY60d8Q2AEYTTudHF+4HTTbSthNi33hSriGA HChIc1K9h1fb+cc7a/uwdw8wJgaYZmsq4zXcdib2R1i8eMgSM4q+IhIzrKrWnCStfvza hVDjeQk5XrRr8ngIK+5Cw6i/bQoBXjoaVQ41b/VAVrBPVLN9xrSJtjka7vA6Fn0Nj40U RE3G6uV+CnKh3ny5XFHFnOBBhRSbeyZ1Yjh1f9AddaYh2urkK/CZDqEpR6yC5drfr8Bz PzC7D60NvbJ/QJQsY/sHM4VL925khMLN353h+mK84dVxsFWoOy/NqITOf8C5C4FLHxcd wVhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=SiqOub67; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y1si17010408ejm.229.2021.03.04.04.37.26; Thu, 04 Mar 2021 04:37:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=@google.com header.s=20161025 header.b=SiqOub67; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387745AbhCCTdW (ORCPT + 99 others); Wed, 3 Mar 2021 14:33:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1387125AbhCCTQN (ORCPT ); Wed, 3 Mar 2021 14:16:13 -0500 Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00606C061761 for ; Wed, 3 Mar 2021 11:15:32 -0800 (PST) Received: by mail-qt1-x849.google.com with SMTP id 4so13375200qtc.13 for ; Wed, 03 Mar 2021 11:15:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=N8PCfwZicPjsnptNF7G2E2FEEsEc1qJ+kpbU5CqawP4=; b=SiqOub67DbuT7DposIVvjRTO5q6bbjEYPp2lv1j+m1Fc+fdHLnq5h2pIQWBmODeHAa 3wo7u5CoSmMLYGcT3oouHik8GTpdL+NM6YC5ZX6ulHa1QJhSWAEYqdqETmOBpWLe0/px FNGoIWcpECCqmMMpTApmatf2xo7Xs6b+t4/DSU4DJiBDbTYdDv1B8utLYMiWXFRXIeCi a0Aqi1vTY+P8QypncQG1WY0T7N3CFAZxQihnDTt54xOYiqXFaQFuKLQpbRjdKJFGXy9R Np1exSKW/If5gBbUoqqKhaViJNfq8ZWo4qcV5ZA3Q+qaj6HDhghLusZIeMNglzq+quo4 27yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=N8PCfwZicPjsnptNF7G2E2FEEsEc1qJ+kpbU5CqawP4=; b=joW/qj4P98G8tCwEAQdgeWj/uF3bv4lPvGOvTsIbI7vtdIkgTRnJrK3KBMniHOF/I9 CkUDlGnbpIcIzjOWoCHKVyLciS1pevwIXLFPoqtnVwBe9fh1dGLr+OXoS2LdEN0t8+vF xVYYuCmOBQ05XcrPElfTjgMnoyUuISVvRIicQxYj65vxNigUZcXQTGphBTaWzKqtYHmV qKhh8ZPitvESpj6ABjnYGUC5PDwTjlWSxYzMplfxu2E9PwKF/ch6k+mtZBVtWFScDaLU R04xBMIuXSvwbXZreizRYU6SSWohcoCC2Eg9Qo3KS7MFIKXWhrwiwMkeHb2Rs91s61Uw n/Bw== X-Gm-Message-State: AOAM533jqtyAtwavtTo/XtVwaNh3zOQeWRJgf4pgLQEzM4LRb+3duKeK aVX+N3qLNLfl243jCnY8UCRQYTb/gThzSbbgqNOl Sender: "danielwinkler via sendgmr" X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:45cc:69de:aba1:a948]) (user=danielwinkler job=sendgmr) by 2002:ad4:5b86:: with SMTP id 6mr669445qvp.15.1614798932019; Wed, 03 Mar 2021 11:15:32 -0800 (PST) Date: Wed, 3 Mar 2021 11:15:23 -0800 Message-Id: <20210303111505.1.I3108b046a478cb4f1b85aeb84edb0f127cff81a8@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog Subject: [PATCH] Bluetooth: Allow scannable adv with extended MGMT APIs From: Daniel Winkler To: linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler , Alain Michaud , Sonny Sasaka , Miao-chen Chou , "David S. Miller" , Jakub Kicinski , Johan Hedberg , Luiz Augusto von Dentz , Marcel Holtmann , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org An issue was found, where if a bluetooth client requests a broadcast advertisement with scan response data, it will not be properly registered with the controller. This is because at the time that the hci_cp_le_set_scan_param structure is created, the scan response will not yet have been received since it comes in a second MGMT call. With empty scan response, the request defaults to a non-scannable PDU type. On some controllers, the subsequent scan response request will fail due to incorrect PDU type, and others will succeed and not use the scan response. This fix allows the advertising parameters MGMT call to include a flag to let the kernel know whether a scan response will be coming, so that the correct PDU type is used in the first place. A bluetoothd change is also incoming to take advantage of it. To test this, I created a broadcast advertisement with scan response data and registered it on the hatch chromebook. Without this change, the request fails, and with it will succeed. Reviewed-by: Alain Michaud Reviewed-by: Sonny Sasaka Reviewed-by: Miao-chen Chou Signed-off-by: Daniel Winkler --- include/net/bluetooth/mgmt.h | 1 + net/bluetooth/hci_request.c | 3 ++- net/bluetooth/mgmt.c | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 839a2028009ea1..a7cffb06956517 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -578,6 +578,7 @@ struct mgmt_rp_add_advertising { #define MGMT_ADV_PARAM_TIMEOUT BIT(13) #define MGMT_ADV_PARAM_INTERVALS BIT(14) #define MGMT_ADV_PARAM_TX_POWER BIT(15) +#define MGMT_ADV_PARAM_SCAN_RSP BIT(16) #define MGMT_ADV_FLAG_SEC_MASK (MGMT_ADV_FLAG_SEC_1M | MGMT_ADV_FLAG_SEC_2M | \ MGMT_ADV_FLAG_SEC_CODED) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 75a42178c82d9b..d7ee11ef70d3e1 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -2180,7 +2180,8 @@ int __hci_req_setup_ext_adv_instance(struct hci_request *req, u8 instance) cp.evt_properties = cpu_to_le16(LE_EXT_ADV_CONN_IND); else cp.evt_properties = cpu_to_le16(LE_LEGACY_ADV_IND); - } else if (adv_instance_is_scannable(hdev, instance)) { + } else if (adv_instance_is_scannable(hdev, instance) || + (flags & MGMT_ADV_PARAM_SCAN_RSP)) { if (secondary_adv) cp.evt_properties = cpu_to_le16(LE_EXT_ADV_SCAN_IND); else diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 74971b4bd4570d..90334ac4a13589 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -7432,6 +7432,7 @@ static u32 get_supported_adv_flags(struct hci_dev *hdev) flags |= MGMT_ADV_PARAM_TIMEOUT; flags |= MGMT_ADV_PARAM_INTERVALS; flags |= MGMT_ADV_PARAM_TX_POWER; + flags |= MGMT_ADV_PARAM_SCAN_RSP; /* In extended adv TX_POWER returned from Set Adv Param * will be always valid. -- 2.30.1.766.gb4fecdf3b7-goog