Skip to content

monitor: Reference request frames on responses

Luiz Augusto von Dentz linux-bluetooth 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest10 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/10monitor: Reference the request frame on command responsesmonitor/packet.c+104 -41 reply
2/10doc/btmon: Document the request reference on command responsesdoc/btmon.rst+13 -10 replies
3/10monitor: Resolve commands completed by a later eventmonitor/packet.c+266 -370 replies
4/10doc/btmon: Document the deferred command referencesdoc/btmon.rst+23 -00 replies
5/10monitor: Report command latency in analyze modemonitor/analyze.c+99 -00 replies
6/10doc/btmon: Document the command latency statisticsdoc/btmon.rst+27 -00 replies
7/10monitor: Add request tracking for the protocols above HCImonitor/l2cap.c monitor/l2cap.h monitor/packet.c +1 more+214 -80 replies
8/10monitor/att: Reference the request frame on responsesmonitor/att.c+68 -10 replies
9/10monitor: Reference the request frame on SDP, AVDTP and AVCTP responsesmonitor/avctp.c monitor/avdtp.c monitor/sdp.c+64 -50 replies
10/10doc/btmon: Document the protocol request referencesdoc/btmon.rst+47 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH BlueZ v1 00/10] monitor: Reference request frames on responses

From: Luiz Augusto von Dentz <[email protected]>

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)
Quoted 1 line

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:

Quoted 1 line

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(-)
Signature · 1 line
2.55.0