Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2654965rdg; Mon, 16 Oct 2023 10:34:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGpvDS4DPOyLBPjzJbLWXAe6iFlfbQCetxWKUn0p2u116MpGIeryvTv/MeRQIzx8lOPujsq X-Received: by 2002:a17:90a:b387:b0:274:4e9b:7a1a with SMTP id e7-20020a17090ab38700b002744e9b7a1amr29316679pjr.44.1697477667763; Mon, 16 Oct 2023 10:34:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697477667; cv=none; d=google.com; s=arc-20160816; b=tmZ7lTBzsrv+k+5Bf5QlF4ejLYFQoptmNgRfKmedTZm0MI5WfjWB+/4Eh6t1DOxllG Z9JDn50qKO2yIUSF2xIP3rRzam+1XBDO4UJW1yS6/cgsHDt8i5sKWOUQ4rBk4iZ0DSjy mjqUBA9j4HplS1rqCLwnrz6jyicvJOyXouRcNDxxa2r7AahB2ioiHJjVFeVQ8dkUjLd/ o6s3H918G3GPIO9EYVp7QIjwwmKHJDkDYPxqVQ0yJkKI1I9yDiJd4qbc7xOO+/XtmySI NjrRk03hWQsoIbHJCHAE2+dZbpPlNNNXm8a+QAJTgFFohjLCemGjo/KOlSrNGACXB5fO WYMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=PBt4ueYYlzL1IZJDM3R56oSh68/0VWM5tuNZpg5eLgc=; fh=65NL/mHMWFGgTABWU1uSodsrGqSddG+P4BsbtpMfabw=; b=MmYf9YfLRuvkakiPu4tIwU8WF78YPP/EEXvzRUwf+r02YPbcBtlfg4EUqmCwar68Mq tbSVDc8cXaRhI/G7ZP5SWEvvgMP6chCa4sFDD24iopD5LIpCLPP+KBp/kgEC4pwR1Z4b +km8sboUaEVVPSYTY/rxaczI83xHufFK+h6rOqR0jz21D0fWf9eGahR6Hq57QfIQOEGZ VR1WDFoTyBlRxc6PI8d/hviL9WLSwtPXT9zDDNQtksHbXc/fclzMXFHnaam4VJwYB47c oczWmxApwiZMCLd57/PJ1zWcq6E8aFkq9QDl5uZBMy+DWrTdkcHXS9/RZgAndILE223c 8bVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Ju0GdNgC; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id 20-20020a17090a199400b0027d113631f0si6392723pji.24.2023.10.16.10.34.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 10:34:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Ju0GdNgC; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 95848802A6EF; Mon, 16 Oct 2023 10:34:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231675AbjJPRe0 (ORCPT + 99 others); Mon, 16 Oct 2023 13:34:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229666AbjJPReZ (ORCPT ); Mon, 16 Oct 2023 13:34:25 -0400 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FBB683 for ; Mon, 16 Oct 2023 10:34:23 -0700 (PDT) Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2c1807f3400so56019061fa.1 for ; Mon, 16 Oct 2023 10:34:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697477661; x=1698082461; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=PBt4ueYYlzL1IZJDM3R56oSh68/0VWM5tuNZpg5eLgc=; b=Ju0GdNgCz4CV/38mXqHlC6gEHjZM4HxaxIe/coOqNQc9EgwRAdb7wYvvK6Ox1TY2O2 p2GzEWFpROyLijgWC+AZe1eCsLhXQ8ACJsFW/3VlZCp0K1q1ssaiO789xwsSUH+KXKin qR19TBH2SvZNYUxq6xO5MK20v9obSWgSBq+UNvX5w/uE2uGSkXAD07cF41wc/otqXUkS gOcvjnPzXoXKkJNL0KSWDhXIg6k3EYOQ/bFl1V/xPZgBl1J2eWvYOYDHpsNMb25CxCfH SzMQw/5E4bucHkHxK0ehX/kwpOUqhvpcekcOt1ywhE1VYFGcgsx3dQO7vYphaD1Pakv+ Afow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697477661; x=1698082461; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PBt4ueYYlzL1IZJDM3R56oSh68/0VWM5tuNZpg5eLgc=; b=t+QJntmA6oOX4v16iLfB9o8teDNfyf/LsHlzTmpmDy8jkG+8ETgeNQvTUBGD08zlwJ 6MWHEzSpLoSs3PSa6ZyYCbcQSRUwInMWtjiQonSiIWCcNey/b30Yia2Cx+9PRh/qW2Ca a4qx2uHiy7AssGHbPVvAqU1qDfpzJoQPxtNKo2EykQW94JO8LaCMnHIJOHfowluz77Pm 6WxzBYkUfCxp+uby+4kGNd4zKSG7u8FdifKl3HbEfD0aDXflYHR/V429+yJGBNXR1Oyw +C0O7Rvoj9voln5TWTZC7pG/9un+arJXgXXikELZoP6EnJfAlbknJ0DDsnKdgVUlyJcR 79Uw== X-Gm-Message-State: AOJu0YxI1E0t0cU0yqylhgarps9fNbjQX17HwPmqPh8SyJWLqxrFs6ii wdH7muQbnuovlapntSye7ydG+oWlyTSC0/P8VSk= X-Received: by 2002:a2e:bea1:0:b0:2c3:eed6:f4f with SMTP id a33-20020a2ebea1000000b002c3eed60f4fmr96923ljr.5.1697477661295; Mon, 16 Oct 2023 10:34:21 -0700 (PDT) MIME-Version: 1.0 References: <20231014074716.1866266-1-arkadiusz.bokowy@gmail.com> In-Reply-To: From: Luiz Augusto von Dentz Date: Mon, 16 Oct 2023 10:34:08 -0700 Message-ID: Subject: Re: [PATCH BlueZ] btdev: Broadcast EXT_ADV packets every 200 ms To: Arkadiusz Bokowy Cc: Paul Menzel , linux-bluetooth@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 16 Oct 2023 10:34:26 -0700 (PDT) Hi Arkadiusz, On Sat, Oct 14, 2023 at 11:58=E2=80=AFAM Arkadiusz Bokowy wrote: > > Hi Paul, > > > > Real BLE devices transmit LE advertisement report packages in given > > > intervals (typically in range between 20 ms and 10.24 s). With curren= t > > > kernel module Bluetooth stack implementation it is possible that the > > > first LE meta packet just after enabling scanning will be lost. It is > > > not an issue for real devices, because more advertisement reports wil= l > > > be delivered later (in given interval time). > > > > > > This patch changes optimistic implementation of sending only one LE > > > meta packets just after enabling scanning to sending LE meta packets > > > in 200 ms intervals. Such behavior will better emulate real HCI and > > > will workaround the issue of dropping the very first LE meta packet > > > by the kernel. > > > > Could you please describe your test setup? I guess you optimized the 20= 0 > > ms for your setup, and that is the reason you did not choose an even > > lower value like 100 ms? > > No, it's not an optimization for my particular setup, but more > generally for CPU load. I thought that it might be better not to run > advertisement code too frequently. But I guess that lower values > should also be OK, e.g. 100 ms or 50 ms. There is one "issue" with > that, though.... Now, the advertisement packet will be sent one > interval after the advertisement was enabled. If that's indeed an > issue, it can be fixed by calling the callback function in the moment > when the timer is armed. I'd keep the initial logic of sending the advertisement immediately since the likes of mgmt-tester, and other testers, do have a number of tests that connect so adding a delay can probably cause us to spend more time waiting. > > > -static void le_set_ext_adv_enable_complete(struct btdev *btdev, > > > - struct le_ext_adv *ext_= adv) > > > +static bool ext_adv_broadcast(void *user_data) > > > { > > > + struct le_ext_adv *ext_adv =3D user_data; > > > + struct btdev *btdev =3D ext_adv->dev; > > > > Are these used? > > > > Why rename the function? > > In the previous implementation, the le_set_ext_adv_enable_complete() > function was called after advertisement was enabled in order to send > LE meta packages to devices which have enabled scanning. But this code > was run only once. I thought that we can reuse this logic to send LE > meta packages every interval time. That's why I've renamed this > function, so the name will be more descriptive (it's not enable > complete callback anymore). And in order to provide compatibility with > new sygnature, I've added ext_adv and btdev variables. > > > > static void scan_pa(struct btdev *dev, struct btdev *remote) > > > { > > > if (dev->le_pa_sync_handle !=3D INV_HANDLE || !remote->le_pa_en= able) > > > @@ -5440,7 +5411,6 @@ static int cmd_set_ext_scan_enable_complete(str= uct btdev *dev, const void *data, > > > if (!btdev_list[i] || btdev_list[i] =3D=3D dev) > > > continue; > > > > > > - scan_ext_adv(dev, btdev_list[i]); > > > scan_pa(dev, btdev_list[i]); > > > } > > > > Excuse my ignorance, but the remove code is really not necessary anymor= e? > > Maybe I will briefly describe the previous implementation. There are > two possible cases for sending and receiving advertisements: a) device > A (B, C, ...) enables advertisement and then device Z enables > scanning; b) device Z enables scanning and then other devices enable > advertisement. So, in previous implementation, the LE meta packets > have been sent to devices with enabled scanning from devices which > have enabled advertisement either when the scan was enabled (in device > Z) or when the advertisement was enabled (in device A, B, C ...). The > removed code corresponds to the case of enabling scanning. It's not > required any more, because now advertising is governed by the devices > A, B, C by running advertisement logic every interval time (in the > original patch, every 200 ms, but that can be changed to lover > values). > > To be honest I'm not sure what about scan_pa(). Maybe that logic > should also be moved to some timer callback and should be governed by > the A, C, B, ... devices? I would have to read more about sync in the > BLE spec. Btw, make sure you run the testers to confirm you are not breaking any kernel testers. --=20 Luiz Augusto von Dentz