Linux bluetooth development
 help / color / mirror / Atom feed
From: Roland Schober <rolandschober1968@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: luiz.dentz@gmail.com, Roland Schober <rolandschober1968@gmail.com>
Subject: [RFC PATCH v2 0/6] Bluetooth: Periodic advertising and PAwR over MGMT
Date: Thu,  3 Dec 2026 23:13:59 +0100	[thread overview]
Message-ID: <20261203221405.682222-1-rolandschober1968@gmail.com> (raw)

Hi Luiz,

v2 of the RFC for periodic advertising and the advertiser side of
Periodic Advertising with Responses (PAwR) over MGMT. The interface
is the one of v1, and the questions on it are still open; v2 fixes
one more case in the kernel, which the review of the BlueZ series
brought up, and is rebased onto bluetooth-next.

Changes in v2:
 - New patch 3: an instance with a timeout and periodic advertising.
   When the timeout ends the controller stops the advertising of the
   set, and the kernel freed its instance. The periodic advertising
   went on in the controller, and nothing stopped it any more. The
   kernel now disables it and removes the set.
 - Patch 2 is the fix I sent on its own after v1 ("Bluetooth:
   hci_sync: Disable PA before removing an advertising set"), with
   that commit message. The code is the one of v1.
 - Rebased onto bluetooth-next. Patches 1 and 4 to 6 are unchanged.

v1: "[RFC PATCH 0/5] Bluetooth: Periodic advertising and PAwR over
MGMT"

The interface (patches 4 to 6):

  Add Periodic Advertising Parameters (0x005d)
      Makes an instance created with Add Extended Advertising Parameters
      periodic, before Add Extended Advertising Data enables it. With a
      number of subevents it is PAwR, without it is plain periodic
      advertising.
  Add Periodic Advertising Data (0x005e)
      The data of a plain periodic advertising train.
  Periodic Advertising Subevent Data Request event (0x0035)
      The controller asks for the data of a range of subevents.
  Set Periodic Advertising Subevent Data (0x005f)
      The answer: the data of one or more subevents, in one HCI command.
  Periodic Advertising Response Report event (0x0036)
      The responses received in the response slots of a subevent.

The parameters and the entries are those of the HCI commands and
events, in their units; the advertising handle is replaced by the
instance.

Questions:

1. New commands, or flags and parameters added to Add Extended
   Advertising Parameters and Add Extended Advertising Data? I chose
   commands of their own because the existing ones have no room for
   the parameters, and an instance can then become periodic without a
   second way to create it.

2. Set Periodic Advertising Subevent Data is sent with hci_send_cmd()
   and answered from the Command Complete handler, as the PIN code and
   user confirmation replies are. Queued with hci_cmd_sync_queue() it
   waited behind the connection setup, and the controller refused the
   data as too late: it wants the data within its lead time, 40 to 50 ms
   on the controller I tested with. Is this acceptable, or is there a
   better way to send a command which must not wait?

3. The kernel does not check that the subevents of the answer are the
   requested ones, and does not split an answer over several HCI
   commands; the controller refuses what is wrong, and user space gets
   the error. Should the kernel do more here?

4. The controller's Too Late error (0x46) reaches user space as the
   generic Failed. Is a MGMT status of its own wanted?

5. The two events go to all MGMT sockets. Should they go only to the
   socket which added the instance?

6. New in v2: an instance with a timeout which is periodic is removed
   as a whole when the timeout ends, train included (patch 3). The
   other way would be to refuse periodic advertising parameters for an
   instance with a timeout. Is removing it what you would expect?

Not in this series:

 - periodic advertising data of more than one HCI command (252 octets);
 - Periodic Advertising Sync Transfer over MGMT (the tests send
   LE Periodic Advertising Set Info Transfer with HCI Cmd Sync);
 - connecting to a synchronised device through a subevent
   (LE Extended Create Connection [v2]);
 - the scanner side.

A known gap: if the controller never answers LE Set Periodic
Advertising Subevent Data, its MGMT command stays pending, and the
answer to the next one is taken for it. The PIN code replies have the
same weakness; I have not solved it here.

Patches 2 and 3 are needed by the others but stand on their own.
Patch 2: the controller refuses to remove an advertising set while
periodic advertising is enabled on it. Patch 3 changes nothing for an
instance without periodic advertising.

Tested in two ways.

With the BlueZ emulator: the BlueZ series (v3) adds the PAwR
advertiser to btdev and 33 mgmt-tester cases for the three commands,
among them a second instance, controllers without the features,
Remove Advertising and Set Powered off with a train running, an
instance whose timeout ends with a train running, and subevent data
which is too early, too late or sent in two commands at once.
mgmt-tester passes 562 of 562. Without patch 2 the removal and the
power off cases fail, without patch 3 the timeout case. The other
testers pass: iso 213, l2cap 152, sco 30, ioctl 28, mesh 10, smp 8,
userchan 4. No KASAN or lockdep reports.

With a real controller, in QEMU: the Nordic SoftDevice Controller on a
simulated nRF52 (BabbleSim), with Zephyr's periodic_sync_rsp sample as
the responder. Plain periodic advertising: the train starts, its data
is set and changed while it runs, the instance is removed. PAwR: the
train starts, the responder is connected and synchronised by PAST,
95 data requests in 8 s are all answered in time and the responses
arrive. An instance with a timeout and a PAwR train: when the timeout
ends the controller sends LE Advertising Set Terminated and goes on
with the train. Without patch 3 the data requests continue, and Add
Periodic Advertising Parameters for the instance fails with Busy
when it is added again. With it the train is disabled, the set is
removed, and the instance can be added again. An earlier state of the
PAwR patches, ported to 6.6, runs the PAwR exchange on an i.MX93
board.

The Bluetooth code builds with W=1 without warnings. I could not run
sparse, a 32-bit build or an LLVM build here.

The BlueZ side (doc/mgmt-protocol.rst, btmon decoding, btmgmt
commands, emulator and tests) is posted as
"[RFC PATCH BlueZ v3 00/12] Periodic advertising and PAwR over MGMT".

Roland Schober (6):
  Bluetooth: hci: Add Periodic Advertising with Responses definitions
  Bluetooth: hci_sync: Disable PA before removing an advertising set
  Bluetooth: hci_event: Stop PA when an advertising set times out
  Bluetooth: MGMT: Add Add Periodic Advertising Parameters command
  Bluetooth: MGMT: Add Add Periodic Advertising Data command
  Bluetooth: MGMT: Add PAwR subevent data and response reports

 include/net/bluetooth/hci.h      |  59 +++++
 include/net/bluetooth/hci_core.h |  20 ++
 include/net/bluetooth/hci_sync.h |   2 +
 include/net/bluetooth/mgmt.h     |  89 +++++++
 net/bluetooth/hci_event.c        | 115 +++++++++-
 net/bluetooth/hci_sync.c         | 104 ++++++++-
 net/bluetooth/mgmt.c             | 382 +++++++++++++++++++++++++++++++
 7 files changed, 767 insertions(+), 4 deletions(-)


base-commit: 738af1958d2e7205008ca818352199ae8e454509
-- 
2.47.3


             reply	other threads:[~2026-12-03 22:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 22:13 Roland Schober [this message]
2026-12-03 22:14 ` [RFC PATCH v2 1/6] Bluetooth: hci: Add Periodic Advertising with Responses definitions Roland Schober
2026-12-04  2:11   ` Bluetooth: Periodic advertising and PAwR over MGMT bluez.test.bot
2026-12-03 22:14 ` [RFC PATCH v2 2/6] Bluetooth: hci_sync: Disable PA before removing an advertising set Roland Schober
2026-12-03 22:14 ` [RFC PATCH v2 3/6] Bluetooth: hci_event: Stop PA when an advertising set times out Roland Schober
2026-12-03 22:14 ` [RFC PATCH v2 4/6] Bluetooth: MGMT: Add Add Periodic Advertising Parameters command Roland Schober
2026-12-03 22:14 ` [RFC PATCH v2 5/6] Bluetooth: MGMT: Add Add Periodic Advertising Data command Roland Schober
2026-12-03 22:14 ` [RFC PATCH v2 6/6] Bluetooth: MGMT: Add PAwR subevent data and response reports Roland Schober

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261203221405.682222-1-rolandschober1968@gmail.com \
    --to=rolandschober1968@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox