Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4444456ybz; Tue, 21 Apr 2020 00:16:43 -0700 (PDT) X-Google-Smtp-Source: APiQypKcdbJZSpcgZiwJ2+qr7qnaYTE00bKcl3ZMpXmzSzppHEzfzktUI1aZuHMewRBI1aiFeAfB X-Received: by 2002:a17:906:4553:: with SMTP id s19mr19394361ejq.295.1587453403156; Tue, 21 Apr 2020 00:16:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587453403; cv=none; d=google.com; s=arc-20160816; b=VU2wfQ8fqMcrn/WWBsprECAXp5KaY1SHZ+UULUQ904rA01tjczZhXAVnUNrz+vPuR4 VC4zpOg1kHajeE6dgjAuN4cteFIwIB9YgeR37di8eTS1/Gg2aaFvlQxEph13BYo1uPAW 2rtQKt1gRtVEV5kehSZwXgC9F7vN7fmo3Y2RZgZ/X+raR4Vk/KKVPcYGUYzz6YvD+j+4 fLLm9WBJJ9NJaMERlQP/s8u1vWvGG1lOOV8ra5JH+C6e0rUPmbPrV+ZeTtT99Cv249eu wvXh8Z8kO4ojau56DODzpzI9opmYvqPCYOrm7NBMMsnEpridoIyKh3HukUwYOz/I8sCG mFUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Q2lV2zVviFx429eDDhLhQTtJt5drYidx2JsoYO3FjeU=; b=dPuVCs1XwFMqmaPm8XzGiMZUStaqoHwiT+uEL1PImaajdRA/UIuJJsfTDXOi3pWMkz uX285IaWwPTSwcwVzqdOuwRDh2RxvEtkDfsGJrnz6moMaI3RhOPkH75ZV8mMlk13rkjs izA2tvrJXs5a6pxxTAs9CVP5nIhqw0WlmavP3J39oM3DG5aYzI9w0Pnhr4MtghdXbS89 XMIR0bljoVXPgXNzW/fzQW/4U6RRSQnWqTe4hG9sbJKJf4QUVdUJ/BLyF8ab14RofpZy /VUyXSXDZzPl3ChIPCac8S/C/36hVmFjMJsmEyykGh89NbxtlwRhSZwpp29TOe7+m8ve j4TA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=W3r4Q0IN; 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=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h13si1080571edw.475.2020.04.21.00.16.05; Tue, 21 Apr 2020 00:16:43 -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=@chromium.org header.s=google header.b=W3r4Q0IN; 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=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726013AbgDUHPz (ORCPT + 99 others); Tue, 21 Apr 2020 03:15:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725926AbgDUHPz (ORCPT ); Tue, 21 Apr 2020 03:15:55 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D7AEC061A0F for ; Tue, 21 Apr 2020 00:15:53 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id w20so6562434ljj.0 for ; Tue, 21 Apr 2020 00:15:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Q2lV2zVviFx429eDDhLhQTtJt5drYidx2JsoYO3FjeU=; b=W3r4Q0INrLwOSbkoxj8LTTvdDuLbz+S4gfP23cTWYZhhRghNkw1atZ09jfebq3pyq4 FDVc/4Xtua712bzWyEykIFvzxPNdXRXzYuk/4QE74piiy0BP+6hRXDcgTiwDsTCXwyUV 3xetlljqfIpdus9HQjWo7nCrjOHfCB37xORrY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Q2lV2zVviFx429eDDhLhQTtJt5drYidx2JsoYO3FjeU=; b=dyrnKXnjPNomkFj5/p+EIyfO/ZTdJEjGnQyaDAPFELHMEvUXmu0jQEiL/8O1MqbO+J GhVgqBwOhIEeu4kxXOqYyP00E9hl8sHwWjypTuwP18VkZ8U/UEmCqhxy4ECUL16u1Zhc kRtKwGaf2BukXDEseA4GGxOg01oMxWqGJsDAdQEj0I9vNdUKZi9wpie/6z4qmA6OAJ/S 8tGzzLDCMORPO8IP3PGcgRQkp9sBroF+HQPVfy/G1UYj282g3g3ZcZ9MRm9F+RtBVNdb 62sRNSSZCG0oFJ29ZPJoNUnpbWXnQcrmjrzHvS590NEQAz8hbPZZNUn0ZSyDZa27xbSO i7kg== X-Gm-Message-State: AGi0PuauBip70dLYKH8lF/truLn2NZmjNoVPmLJoq+XSDbBwKbuLM6CB 4tS7iRibbucYknLVRwdNnYclYRUhVkWwdYECp5w5x5Wu X-Received: by 2002:a2e:a37b:: with SMTP id i27mr11594870ljn.36.1587453351642; Tue, 21 Apr 2020 00:15:51 -0700 (PDT) MIME-Version: 1.0 References: <20200417200903.BlueZ.v1.1.If9f6be992cbaeaa35423de29da6db28675b35fcc@changeid> In-Reply-To: From: Miao-chen Chou Date: Tue, 21 Apr 2020 00:15:40 -0700 Message-ID: Subject: Re: [BlueZ PATCH v1] doc: Describe the new Advertisement Monitor support To: Luiz Augusto von Dentz Cc: Bluetooth Kernel Mailing List , Alain Michaud , Luiz Augusto von Dentz , Marcel Holtmann , Michael Sun , Yoni Shavit Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org On Mon, Apr 20, 2020 at 3:53 PM Luiz Augusto von Dentz wrote: > > Hi Miao, > > On Fri, Apr 17, 2020 at 8:13 PM Miao-chen Chou wrote: > > > > This describes the following commands. > > - Add Advertisement Patterns Monitor > > - Remove Advertisement Monitor > > - Remove All Advertisement Monitors > > Note that the content of a monitor can differ based on its type. For now we > > introduce only pattern-based monitor, so you may find that unlike commands > > for removing monitor(s), the Add command is tied to a specific type. > > > > Signed-off-by: Miao-chen Chou > > For userspace we don't require signed-of-by line. Ack, it was added by patman tool, I will remove it before sending. > > > --- > > > > doc/mgmt-api.txt | 68 ++++++++++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 68 insertions(+) > > > > diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt > > index 39f23c456..fcd281a35 100644 > > --- a/doc/mgmt-api.txt > > +++ b/doc/mgmt-api.txt > > @@ -3138,6 +3138,74 @@ Read Security Information Command > > Invalid Index > > > > > > +Add Advertisement Patterns Monitor Command > > +========================================= > > + > > + Command Code: 0x0049 > > + Controller Index: > > + Command Parameters: Pattern_count (1 Octets) > > + Pattern1 { > > + AD_Data_Type (1 Octet) > > + Index (1 Octet) > > What is this index for, it is not very clear why would we need it here > since we are going to return a index already. This is the starting position of the given pattern. For instance, if we'd like to look for the pattern within a Manufacturer Data field with value {0x01, 0x02, 0x03} starting from index 2. Given the Manufacturer Data field is {0x00, 0xFF, 0x01, 0x02, 0x03, 0x04}, the matching would start from octet 0x01, and the result would be a match. Perhaps I should rename "Index" to "Start_Position" or rename "Monitor_index" to "Monitor_handle" to avoid confusion. > > > + Length (1 Octet) > > + Value (variable length) > > + } > > + Pattern2 { } > > + ... > > + Return Parameters: Monitor_Index (8 Octets) > > I guess we could call this a handle if the is assigned by the > controller not the host stack, also it might be more a good idea to > put some example on how to build the parameter list, etc, to make it > easier to visualize how these parameters are put together. "Monitor_Handle" sounds good to me. I will add some examples. > > > + > > + This command is used to add an advertisement monitor whose filtering > > + conditions are patterns. The kernel would track the number of registered > > + monitors to determine whether to perform LE scanning while there is > > + ongoing LE scanning for other intentions, such as auto-reconnection and > > + discovery session. If the controller supports Microsoft HCI extension, > > + the kernel would offload the content filtering to the controller in > > + order to reduce power consumption; otherwise the kernel ignore the > > + content of the monitor. > > + > > + Possible errors: Failed > > + Busy > > + Invalid Parameters > > + > > + > > +Remove Advertisement Monitor Command > > +==================================== > > + > > + Command Code: 0x004A > > + Controller Index: > > + Command Parameters: Monitor_Index (8 Octets) > > + Return Parameters: Monitor_Index (8 Octets) > > + > > + This command is used to remove an advertisement monitor. The kernel > > + would remove the monitor with Monitor_Index and update the LE scanning. > > + If the controller supports Microsoft HCI extension and the monitor has > > + been offloaded, the kernel would cancel the offloading; otherwise the > > + kernel takes no further actions other than removing it from the list. > > + > > + Possible errors: Failed > > + Busy > > + Invalid Index > > + > > + > > +Remove All Advertisement Monitors Command > > +========================================= > > + > > + Command Code: 0x004B > > + Controller Index: > > + Command Parameters: > > + Return Parameters: Num_removed_Monitors (2 Octets) > > + Monitor_Index[i] (2 Octets) > > + > > + This command is used to remove all advertisement monitors. The kernel > > + would remove all monitors and update the LE scanning if needed. If the > > + controller supports Microsoft HCI extension the monitors have been > > + offloaded, the kernel would cancel all offloadings; otherwise the kernel > > + takes no further actions other than removing all monitors from the list. > > + > > + Possible errors: Failed > > + Busy > > I wonder if we could keep this simple and just have a special value > passed to Remove that would be consider remove all e.g. > 0x0000000000000000, that way we don't have to allocate yet another > opcode for removing all, though Im not sure how the values are managed > in that namespace so it may not be possible allocate one for use with > remote all logic, the other option would be to have a num_monitors and > then in case none is provided do the remove all, that actually might > be useful since if there are multiple application/monitors we can > remove all monitors from one application without afting the others > leaving remove all logic just for when bluetoothd is restarted which > is basically a cleanup. The intention of this command is indeed to handle the restart of bluetoothd. It's a good point that we may want to remove all monitors of an application. Let me try to combine remove and remove all commands in my next patch. Thanks, Miao