Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH BlueZ v1 00/10] monitor: Reference request frames on responses
@ 2026-09-09 18:28 Luiz Augusto von Dentz
  2026-09-09 18:28 ` [PATCH BlueZ v1 01/10] monitor: Reference the request frame on command responses Luiz Augusto von Dentz
                   ` (9 more replies)
  0 siblings, 10 replies; 12+ messages in thread
From: Luiz Augusto von Dentz @ 2026-09-09 18:28 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

A trace shows every request and every response, but nothing ties the two
together. Finding the request a response belongs to means scrolling back
through the trace matching identifiers by eye, and the time the other side
took to answer is only visible by comparing timestamps by hand.

This series makes a response name the frame that carried its request, and
how long the response took to arrive:

  < HCI Command: LE Set Random Address (0x08|0x0005) plen 6 #76 [hci0] 3.175055
          Address: 00:11:22:33:44:55 (Non-Resolvable)
  > HCI Event: Command Complete (0x0e) plen 4               #77 [hci0] 3.175394
        LE Set Random Address (0x08|0x0005) ncmd 1 #76 (0.339 msec)
          Status: Success (0x00)

Patches 1 and 2 cover the commands answered by a Command Complete or a
Command Status.

Patches 3 and 4 cover the commands that are only acknowledged by a Command
Status and complete much later through a separate event, which is where
the delay is often seconds rather than microseconds:

  > HCI Event: Connect Complete (0x03) plen 11              #27 [hci0] 6.178055
          Request: #12 (3003.000 msec)
          Status: Success (0x00)

Several of these may be outstanding towards different devices at once and
need not complete in order, so they are matched on the connection handle
or the remote address rather than on the opcode alone.

Patches 5 and 6 report command latency in analyze mode, along with the
number of commands that were never answered at all:

  Command latency: 0-215 msec (~55 msec +/- 70 msec)
  Commands without response: 3

Commands completing through a later event are measured up to their
acknowledgement only, since a Create Connection waiting three seconds for
its Connect Complete is waiting on the remote device rather than on the
controller, and folding that in would swamp both the average and the
deviation.

Patches 7 to 10 extend the same idea to the protocols carried over ACL,
each of which pairs a request with its response through an identifier of
its own:

  L2CAP: Connection Response (0x03) ident 1 len 8 #2 (1.000 msec)
  ATT: Error Response (0x01) len 4 #6 (45.500 msec)
  SDP: Service Search Response (0x03) tid 5 len 5 #8 (12.400 msec)
  AVCTP Control: Response: type 0x00 label 7 PID 0x110e #12 (23.100 msec)

None of these layers had access to a timestamp or a frame number, as
neither is passed down from the HCI decoding. Rather than thread both
through every protocol handler, the packet being decoded is recorded and
picked up in l2cap_frame_init(), which every frame passes through.

Requests there are keyed on the channel rather than on the CID, because a
CID names the receiving end and so differs between the two directions of
the same channel.

Nothing is printed when the request was not captured, so attaching to a
system that is already running produces no extra output until a complete
transaction has been seen. No existing line is removed or reordered, and
only the deferred case adds a line of its own.

Setup Synchronous Connection, LE Create CIS and SMP are deliberately left
out. The first reports the ACL handle in the command but the new
synchronous handle in the event, the second produces one event per CIS,
and the third has no transaction identifier, so none of them can be
matched this way without being wrong.

Luiz Augusto von Dentz (10):
  monitor: Reference the request frame on command responses
  doc/btmon: Document the request reference on command responses
  monitor: Resolve commands completed by a later event
  doc/btmon: Document the deferred command references
  monitor: Report command latency in analyze mode
  doc/btmon: Document the command latency statistics
  monitor: Add request tracking for the protocols above HCI
  monitor/att: Reference the request frame on responses
  monitor: Reference the request frame on SDP, AVDTP and AVCTP responses
  doc/btmon: Document the protocol request references

 doc/btmon.rst     | 111 ++++++++++-
 monitor/analyze.c |  99 ++++++++++
 monitor/att.c     |  69 ++++++-
 monitor/avctp.c   |  24 ++-
 monitor/avdtp.c   |  24 ++-
 monitor/l2cap.c   |  76 +++++++-
 monitor/l2cap.h   |   8 +
 monitor/packet.c  | 467 +++++++++++++++++++++++++++++++++++++++++++++-
 monitor/packet.h  |  14 ++
 monitor/sdp.c     |  21 ++-
 10 files changed, 891 insertions(+), 22 deletions(-)

-- 
2.55.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-09-10 17:43 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-09 18:28 [PATCH BlueZ v1 00/10] monitor: Reference request frames on responses Luiz Augusto von Dentz
2026-09-09 18:28 ` [PATCH BlueZ v1 01/10] monitor: Reference the request frame on command responses Luiz Augusto von Dentz
2026-09-10 17:43   ` monitor: Reference request frames on responses bluez.test.bot
2026-09-09 18:28 ` [PATCH BlueZ v1 02/10] doc/btmon: Document the request reference on command responses Luiz Augusto von Dentz
2026-09-09 18:28 ` [PATCH BlueZ v1 03/10] monitor: Resolve commands completed by a later event Luiz Augusto von Dentz
2026-09-09 18:28 ` [PATCH BlueZ v1 04/10] doc/btmon: Document the deferred command references Luiz Augusto von Dentz
2026-09-09 18:28 ` [PATCH BlueZ v1 05/10] monitor: Report command latency in analyze mode Luiz Augusto von Dentz
2026-09-09 18:28 ` [PATCH BlueZ v1 06/10] doc/btmon: Document the command latency statistics Luiz Augusto von Dentz
2026-09-09 18:28 ` [PATCH BlueZ v1 07/10] monitor: Add request tracking for the protocols above HCI Luiz Augusto von Dentz
2026-09-09 18:28 ` [PATCH BlueZ v1 08/10] monitor/att: Reference the request frame on responses Luiz Augusto von Dentz
2026-09-09 18:28 ` [PATCH BlueZ v1 09/10] monitor: Reference the request frame on SDP, AVDTP and AVCTP responses Luiz Augusto von Dentz
2026-09-09 18:28 ` [PATCH BlueZ v1 10/10] doc/btmon: Document the protocol request references Luiz Augusto von Dentz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox