Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp839280pxx; Thu, 29 Oct 2020 16:07:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwF7FSpe7WtnrbjJbOquL+fgISNDPCEsg9QlpyjAI/YSmzhq61/xzndagh1y1BBAvl48GtM X-Received: by 2002:a17:906:154c:: with SMTP id c12mr6749635ejd.427.1604012840475; Thu, 29 Oct 2020 16:07:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604012840; cv=none; d=google.com; s=arc-20160816; b=oaEagwCtU2mOa1ebIDZmBcAxCdzDvJBaw/ij7uUvP5L3amtiLaF8annKJi1yzFhCf8 cJuiwZRx1UtP3xycK2+3bn1Jkc19EGjRO45rStcQ7rzTUhw/TpnGP2/qPKvuATkbBwBJ HY9DnQLw526xhV+CTyQgmaV/uYEyhQBpO0Dnlvs5B6B40hxO76XzcDaqPsbQ/XkxYFk/ A4B7W6EXUZAbLy6/cfJOTndHr6IDG+7BG0OlUCcacBXDjnj0k0z0D0je2srGgv7jjU5D DPICo76ztCM8ph6YNks0vZtbtQeGdCT08WMXRkQEIKtIrACFaQaT6zl2MHSOUOvR5aFc euSQ== 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:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=Gf+F7yz3pMTj+KLx0gpbm0RJJgxj62/31jS9n0rFRmc=; b=yIf0vsR4e3s3BAzgCifOkjdA0BU/+MQLvCLwkJfW+H/TNNw4/NxryF+iN8wM68NQD8 wV2JgZaD3pToC6YNr7K1ni1/pWOzGdD239Qiva7Zw2lpE5t3rO/c3xraaa62FPBAbMv3 kdccC0KLeHw3K0fOvaI1M1+WlZp32ZVBT0SZrkdEXGSzJqczjx0Mum5SX9bQEQME8reF tEd40fhwXkMR22+VbhjLZa+OJYchQZCZq4OhBdr+DT+fHDaUuGIJkUlNZRL5bmYw8sY1 KBBMRz+lZogfBdYkpeP4qJmQ7vrgdoGIZIAvdivAlIX0GVn5rQjUDHoa3HSqvc4whXyL r2iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=GYZVbKB6; 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=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 p15si3172252edy.474.2020.10.29.16.06.51; Thu, 29 Oct 2020 16:07:20 -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=@google.com header.s=20161025 header.b=GYZVbKB6; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725856AbgJ2XGi (ORCPT + 99 others); Thu, 29 Oct 2020 19:06:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725379AbgJ2XGi (ORCPT ); Thu, 29 Oct 2020 19:06:38 -0400 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AFF7C0613CF for ; Thu, 29 Oct 2020 16:06:38 -0700 (PDT) Received: by mail-pf1-x449.google.com with SMTP id z125so3308425pfc.12 for ; Thu, 29 Oct 2020 16:06:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=Gf+F7yz3pMTj+KLx0gpbm0RJJgxj62/31jS9n0rFRmc=; b=GYZVbKB6FktK+aRbv/T54kPhf4DZ/6/AYpRT4qcM8Bk1a8lWgRvLY0cMo7Tlv8ScRu qM0Mt2+Rvc21U/vOYeKh0MZtOFt3paY583Dk9EJlpEmm3TIJ9PhQa9SRHCkAc0KAIyKI FBwh9h3aDNa5IHw0Ex/l8INVwjSrisap38cHb2Fp5nga8RbZZmPYCo3qfAYNH6ThcSJW 4p1LgEEf4X2rpiuz7Nv/J2zPU/nFF3Klrb/7qq8XJNBJYoyh25IM39Pjtb17HL67tKop d+2ZMIYDyF611sCVfbUU5PJh3xDvigVpc0SogkGCxl9Zw/hjRTTk0vkfV50GQ6X63s/R KrKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Gf+F7yz3pMTj+KLx0gpbm0RJJgxj62/31jS9n0rFRmc=; b=ss4Bjzi1dO7IuX0Kxr8I1JruIE6zegwni97TO453p0SxZHD4Wto9pDjiFlTIkkR35e vyCol7toHEWrb1csx2SCMTAZ+hX8P0qKd8WeMxAJv/tZNA8k4GCxX/XZsuqbxNRLz9+8 n6lOX6RAkBDwKgvD9W3AeJ4ajoTurrmwfTFK5I+sX0nPKyfDljJ2DGiCXhzPG5plPzcK aY+78ry4Y0ALXXgGdiM8i5BTKAyS3AfYje5uH/pfqjLuPbkexDIP+2q4EnnhEp3feL+M suaV7uRodI6YuM2Qcrlx7zG+Zj4Jwxz3NH3gndp9giDzAn0KmqNu3gWD8GxAwZsYgB6P NGqA== X-Gm-Message-State: AOAM5300l5bgg6xcPjY5etLpTINzCIMeEmtwlMactkKn7UUJNf7roEM8 9/8RU43jTbICItNIK2TQdIm2cuXL93B/O48rM8z9 Sender: "danielwinkler via sendgmr" X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:aa7:9a1b:0:b029:163:edfa:64a2 with SMTP id w27-20020aa79a1b0000b0290163edfa64a2mr6177344pfj.70.1604012797629; Thu, 29 Oct 2020 16:06:37 -0700 (PDT) Date: Thu, 29 Oct 2020 16:06:16 -0700 In-Reply-To: <20201029230623.3630069-1-danielwinkler@google.com> Message-Id: <20201029160317.Bluez.v6.4.I50d9faa25e9da6e71d77c83c7d47a5b135e88799@changeid> Mime-Version: 1.0 References: <20201029230623.3630069-1-danielwinkler@google.com> X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog Subject: [Bluez PATCH v6 04/10] advertising: Detect if extended advertising mgmt commands are supported From: Daniel Winkler To: luiz.von.dentz@intel.com Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler , Sonny Sasaka , Alain Michaud Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org We need to know if kernel supports the new MGMT interface. To do so, we check the return from adapter's MGMT_OP_READ_COMMANDS call for the new commands. This will later be used to route our requests for new advertisements. The change is tested by manually verifying that the correct MGMT commands are used when the feature is and is not available in kernel. Reviewed-by: Sonny Sasaka Reviewed-by: Alain Michaud --- Changes in v6: - Reserve new MGMT codes earlier in series to detect support Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: - Uses btd_has_kernel_features to detect kernel command support lib/mgmt.h | 4 ++++ src/adapter.c | 4 ++++ src/adapter.h | 1 + src/advertising.c | 3 +++ 4 files changed, 12 insertions(+) diff --git a/lib/mgmt.h b/lib/mgmt.h index 6aa0f5f88..59608e7ea 100644 --- a/lib/mgmt.h +++ b/lib/mgmt.h @@ -700,6 +700,10 @@ struct mgmt_rp_remove_adv_monitor { uint16_t monitor_handle; } __packed; +#define MGMT_OP_ADD_EXT_ADV_PARAMS 0x0054 + +#define MGMT_OP_ADD_EXT_ADV_DATA 0x0055 + #define MGMT_EV_CMD_COMPLETE 0x0001 struct mgmt_ev_cmd_complete { uint16_t opcode; diff --git a/src/adapter.c b/src/adapter.c index 1f075ef5f..90beb897f 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -9566,6 +9566,10 @@ static void read_commands_complete(uint8_t status, uint16_t length, DBG("kernel supports exp features"); kernel_features |= KERNEL_EXP_FEATURES; break; + case MGMT_OP_ADD_EXT_ADV_PARAMS: + DBG("kernel supports ext adv commands"); + kernel_features |= KERNEL_HAS_EXT_ADV_ADD_CMDS; + break; default: break; } diff --git a/src/adapter.h b/src/adapter.h index dcc574857..ace72affd 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -233,6 +233,7 @@ enum kernel_features { KERNEL_SET_SYSTEM_CONFIG = 1 << 2, KERNEL_EXP_FEATURES = 1 << 3, KERNEL_HAS_RESUME_EVT = 1 << 4, + KERNEL_HAS_EXT_ADV_ADD_CMDS = 1 << 5, }; bool btd_has_kernel_features(uint32_t feature); diff --git a/src/advertising.c b/src/advertising.c index c03869e50..7c7599552 100644 --- a/src/advertising.c +++ b/src/advertising.c @@ -48,6 +48,7 @@ struct btd_adv_manager { uint8_t max_ads; uint32_t supported_flags; unsigned int instance_bitmap; + bool extended_add_cmds; }; #define AD_TYPE_BROADCAST 0 @@ -1417,6 +1418,8 @@ static struct btd_adv_manager *manager_create(struct btd_adapter *adapter, manager->mgmt_index = btd_adapter_get_index(adapter); manager->clients = queue_new(); manager->supported_flags = MGMT_ADV_FLAG_LOCAL_NAME; + manager->extended_add_cmds = + btd_has_kernel_features(KERNEL_HAS_EXT_ADV_ADD_CMDS); if (!g_dbus_register_interface(btd_get_dbus_connection(), adapter_get_path(manager->adapter), -- 2.29.1.341.ge80a0c044ae-goog