* [PATCH RFC v1] monitor: Add support for logging host packets
@ 2025-07-31 19:56 Luiz Augusto von Dentz
2025-07-31 21:33 ` [RFC,v1] " bluez.test.bot
0 siblings, 1 reply; 2+ messages in thread
From: Luiz Augusto von Dentz @ 2025-07-31 19:56 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds support for logging host packets so their timing is
visible in the logs:
l2cap-tester[41]: < HOST Data TX: len 12 [hci0] 15:50:02.974141
l2cap-tester[41]: < ACL Data T.. flags 0x00 dlen 12 #83 [hci0] 15:50:02.974199
Channel: 64 len 8 [PSM 4097 mode Basic (0x00)] {chan 0}
01 02 03 04 05 06 07 08 ........
> ACL Data RX: Handle 42 flags 0x02 dlen 12 #170 [hci0] 15:51:43.269961
Channel: 64 len 8 [PSM 4097 mode Basic (0x00)] {chan 0}
01 02 03 04 05 06 07 08 ........
[45]: > HOST Data RX: len 8 [hci0] 15:51:43.269976
---
monitor/display.h | 1 +
monitor/main.c | 7 ++++++-
monitor/packet.c | 29 +++++++++++++++++++++++++++++
monitor/packet.h | 3 +++
src/shared/btsnoop.h | 2 ++
5 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/monitor/display.h b/monitor/display.h
index ee076448cc31..189c518a0ce7 100644
--- a/monitor/display.h
+++ b/monitor/display.h
@@ -29,6 +29,7 @@ void set_monitor_color(enum monitor_color);
#define COLOR_WHITE_BG "\x1B[0;47;30m"
#define COLOR_HIGHLIGHT "\x1B[1;39m"
+#define COLOR_GRAY_BOLD "\x1B[1;30m"
#define COLOR_RED_BOLD "\x1B[1;31m"
#define COLOR_GREEN_BOLD "\x1B[1;32m"
#define COLOR_BLUE_BOLD "\x1B[1;34m"
diff --git a/monitor/main.c b/monitor/main.c
index fa56fcb29f38..11d6c9cd1655 100644
--- a/monitor/main.c
+++ b/monitor/main.c
@@ -66,6 +66,7 @@ static void usage(void)
"\t-S, --sco Dump SCO traffic\n"
"\t-A, --a2dp Dump A2DP stream traffic\n"
"\t-I, --iso Dump ISO traffic\n"
+ "\t-H, --host Dump HOST traffic\n"
"\t-E, --ellisys [ip] Send Ellisys HCI Injection\n"
"\t-P, --no-pager Disable pager usage\n"
"\t-J --jlink <device>,[<serialno>],[<interface>],[<speed>]\n"
@@ -94,6 +95,7 @@ static const struct option main_options[] = {
{ "sco", no_argument, NULL, 'S' },
{ "a2dp", no_argument, NULL, 'A' },
{ "iso", no_argument, NULL, 'I' },
+ { "host", no_argument, NULL, 'H' },
{ "ellisys", required_argument, NULL, 'E' },
{ "no-pager", no_argument, NULL, 'P' },
{ "jlink", required_argument, NULL, 'J' },
@@ -131,7 +133,7 @@ int main(int argc, char *argv[])
struct sockaddr_un addr;
opt = getopt_long(argc, argv,
- "r:w:a:s:p:i:d:B:V:MNtTSAIE:PJ:R:C:c:vh",
+ "r:w:a:s:p:i:d:B:V:MNtTSAIHE:PJ:R:C:c:vh",
main_options, NULL);
if (opt < 0)
break;
@@ -205,6 +207,9 @@ int main(int argc, char *argv[])
case 'I':
filter_mask |= PACKET_FILTER_SHOW_ISO_DATA;
break;
+ case 'H':
+ filter_mask |= PACKET_FILTER_SHOW_HOST_DATA;
+ break;
case 'E':
ellisys_server = optarg;
ellisys_port = 24352;
diff --git a/monitor/packet.c b/monitor/packet.c
index 90a82b1af4ff..288b7630c059 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -70,6 +70,7 @@
#define COLOR_HCI_ACLDATA COLOR_CYAN
#define COLOR_HCI_SCODATA COLOR_YELLOW
#define COLOR_HCI_ISODATA COLOR_YELLOW
+#define COLOR_HOSTDATA COLOR_GRAY_BOLD
#define COLOR_UNKNOWN_ERROR COLOR_WHITE_BG
#define COLOR_UNKNOWN_FEATURE_BIT COLOR_WHITE_BG
@@ -4316,6 +4317,12 @@ void packet_monitor(struct timeval *tv, struct ucred *cred,
case BTSNOOP_OPCODE_ISO_RX_PKT:
packet_hci_isodata(tv, cred, index, true, data, size);
break;
+ case BTSNOOP_OPCODE_HOST_TX_PKT:
+ packet_host_data(tv, cred, index, false, data, size);
+ break;
+ case BTSNOOP_OPCODE_HOST_RX_PKT:
+ packet_host_data(tv, cred, index, true, data, size);
+ break;
case BTSNOOP_OPCODE_OPEN_INDEX:
if (index < MAX_INDEX)
addr2str(index_list[index].bdaddr, str);
@@ -14120,6 +14127,28 @@ malformed:
packet_hexdump(data, size);
}
+void packet_host_data(struct timeval *tv, struct ucred *cred, uint16_t index,
+ bool in, const void *data, uint16_t size)
+{
+ char str[10];
+
+ if (index >= MAX_INDEX) {
+ print_field("Invalid index (%d).", index);
+ return;
+ }
+
+ sprintf(str, "len %u", size);
+
+ print_packet(tv, cred, in ? '>' : '<', index, NULL, COLOR_HOSTDATA,
+ in ? "HOST Data RX" : "HOST Data TX",
+ str, NULL);
+
+ if (filter_mask & PACKET_FILTER_SHOW_HOST_DATA)
+ packet_hexdump(data, size);
+
+ return;
+}
+
void packet_ctrl_open(struct timeval *tv, struct ucred *cred, uint16_t index,
const void *data, uint16_t size)
{
diff --git a/monitor/packet.h b/monitor/packet.h
index 964b9a7219fa..d2a0b53aee78 100644
--- a/monitor/packet.h
+++ b/monitor/packet.h
@@ -23,6 +23,7 @@
#define PACKET_FILTER_SHOW_A2DP_STREAM (1 << 6)
#define PACKET_FILTER_SHOW_MGMT_SOCKET (1 << 7)
#define PACKET_FILTER_SHOW_ISO_DATA (1 << 8)
+#define PACKET_FILTER_SHOW_HOST_DATA (1 << 9)
#define TV_MSEC(_tv) (long long)((_tv).tv_sec * 1000 + (_tv).tv_usec / 1000)
struct packet_latency {
@@ -120,6 +121,8 @@ void packet_hci_scodata(struct timeval *tv, struct ucred *cred, uint16_t index,
bool in, const void *data, uint16_t size);
void packet_hci_isodata(struct timeval *tv, struct ucred *cred, uint16_t index,
bool in, const void *data, uint16_t size);
+void packet_host_data(struct timeval *tv, struct ucred *cred, uint16_t index,
+ bool in, const void *data, uint16_t size);
void packet_ctrl_open(struct timeval *tv, struct ucred *cred, uint16_t index,
const void *data, uint16_t size);
diff --git a/src/shared/btsnoop.h b/src/shared/btsnoop.h
index c24755d56729..b54ebc50ded7 100644
--- a/src/shared/btsnoop.h
+++ b/src/shared/btsnoop.h
@@ -42,6 +42,8 @@
#define BTSNOOP_OPCODE_CTRL_EVENT 17
#define BTSNOOP_OPCODE_ISO_TX_PKT 18
#define BTSNOOP_OPCODE_ISO_RX_PKT 19
+#define BTSNOOP_OPCODE_HOST_TX_PKT 22
+#define BTSNOOP_OPCODE_HOST_RX_PKT 23
#define BTSNOOP_MAX_PACKET_SIZE (1486 + 4)
--
2.50.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* RE: [RFC,v1] monitor: Add support for logging host packets
2025-07-31 19:56 [PATCH RFC v1] monitor: Add support for logging host packets Luiz Augusto von Dentz
@ 2025-07-31 21:33 ` bluez.test.bot
0 siblings, 0 replies; 2+ messages in thread
From: bluez.test.bot @ 2025-07-31 21:33 UTC (permalink / raw)
To: linux-bluetooth, luiz.dentz
[-- Attachment #1: Type: text/plain, Size: 1633 bytes --]
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=987469
---Test result---
Test Summary:
CheckPatch PENDING 0.36 seconds
GitLint PENDING 0.45 seconds
BuildEll PASS 20.21 seconds
BluezMake PASS 2673.43 seconds
MakeCheck PASS 21.02 seconds
MakeDistcheck PASS 184.12 seconds
CheckValgrind PASS 233.05 seconds
CheckSmatch WARNING 302.89 seconds
bluezmakeextell PASS 126.91 seconds
IncrementalBuild PENDING 0.38 seconds
ScanBuild PASS 906.98 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
monitor/packet.c: note: in included file:monitor/display.h:83:26: warning: Variable length array is used.monitor/packet.c:1919:26: warning: Variable length array is used.monitor/packet.c: note: in included file:monitor/bt.h:3822:52: warning: array of flexible structures
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-07-31 21:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-31 19:56 [PATCH RFC v1] monitor: Add support for logging host packets Luiz Augusto von Dentz
2025-07-31 21:33 ` [RFC,v1] " bluez.test.bot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.