public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ v1] adapter: Fix setting index in MGMT_OP_SET_EXP_FEATURE with debug_uuid
@ 2025-08-20 20:41 Luiz Augusto von Dentz
  2025-08-20 20:41 ` [PATCH BlueZ v1] monitor: Add support for -K/--kernel Luiz Augusto von Dentz
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2025-08-20 20:41 UTC (permalink / raw)
  To: linux-bluetooth

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

Experimental debug feature requires use of MGMT_INDEX_NONE since it is
not an adapter specific feature.
---
 src/adapter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/adapter.c b/src/adapter.c
index b771cf66ade3..549a6c0b8324 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -10019,7 +10019,7 @@ static void exp_debug_func(struct btd_adapter *adapter, uint8_t action)
 	cp.action = action;
 
 	if (exp_mgmt_send(adapter, MGMT_OP_SET_EXP_FEATURE,
-			adapter->dev_id, sizeof(cp), &cp,
+			MGMT_INDEX_NONE, sizeof(cp), &cp,
 			set_exp_debug_complete))
 		return;
 
-- 
2.50.1


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

* [PATCH BlueZ v1] monitor: Add support for -K/--kernel
  2025-08-20 20:41 [PATCH BlueZ v1] adapter: Fix setting index in MGMT_OP_SET_EXP_FEATURE with debug_uuid Luiz Augusto von Dentz
@ 2025-08-20 20:41 ` Luiz Augusto von Dentz
  2025-08-20 22:00   ` [BlueZ,v1] " bluez.test.bot
  2025-08-20 21:59 ` [BlueZ,v1] adapter: Fix setting index in MGMT_OP_SET_EXP_FEATURE with debug_uuid bluez.test.bot
  2025-08-21 14:00 ` [PATCH BlueZ v1] " patchwork-bot+bluetooth
  2 siblings, 1 reply; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2025-08-20 20:41 UTC (permalink / raw)
  To: linux-bluetooth

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

This adds support for -K/--kernel that open /proc/kmsg and attempts
to print messages starting with 'Bluetooth:':

> monitor/btmon -K
= Note: Bluetooth: BNEP (Ethernet Emulation) ver 1.3
= Note: Bluetooth: BNEP filters: protocol multicast
= Note: Bluetooth: BNEP socket layer initialized
= Note: Bluetooth: MGMT ver 1.23
= Note: Bluetooth: RFCOMM TTY layer initialized
= Note: Bluetooth: RFCOMM socket layer initialized
= Note: Bluetooth: RFCOMM ver 1.11
---
 monitor/btmon.rst |  2 ++
 monitor/control.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++
 monitor/main.c    |  7 +++++-
 monitor/packet.h  |  1 +
 4 files changed, 68 insertions(+), 1 deletion(-)

diff --git a/monitor/btmon.rst b/monitor/btmon.rst
index eb5e25182f0f..39c185fd5e41 100644
--- a/monitor/btmon.rst
+++ b/monitor/btmon.rst
@@ -77,6 +77,8 @@ OPTIONS
 
 -M, --mgmt                  Open channel for mgmt events.
 
+-K, --kernel                Open kmsg for kernel messages.
+
 -t, --time                  Show a time instead of time offset.
 
 -T, --date                  Show a time and date information instead of
diff --git a/monitor/control.c b/monitor/control.c
index cb8e9fe731fb..83347d5dbc3e 100644
--- a/monitor/control.c
+++ b/monitor/control.c
@@ -1081,6 +1081,62 @@ static int open_channel(uint16_t channel)
 	return 0;
 }
 
+static void kmsg_callback(int fd, uint32_t events, void *user_data)
+{
+	char buf[1024], *msg;
+	ssize_t len;
+	struct timeval tv;
+
+	if (events & (EPOLLERR | EPOLLHUP)) {
+		mainloop_remove_fd(fd);
+		return;
+	}
+
+	memset(buf, 0, sizeof(buf));
+
+	len = read(fd, buf, sizeof(buf));
+	if (len < 0)
+		return;
+
+	/* Check if the kernel message is from Bluetooth */
+	msg = strcasestr(buf, "Bluetooth:");
+	if (!msg)
+		return;
+
+	/* Replace Bluetooth with Kernel to avoid possible confusions */
+	msg += 3;
+	memcpy(msg, "Kernel", 6);
+
+	/* Adjust the actual length since part of the message is skipped and
+	 * replace the \n with \0 at the end.
+	 */
+	len = len - (msg - buf);
+	msg[len - 1] = '\0';
+
+	gettimeofday(&tv, NULL);
+
+	btsnoop_write_hci(btsnoop_file, &tv, HCI_DEV_NONE,
+				BTSNOOP_OPCODE_SYSTEM_NOTE, 0, msg, len);
+	packet_monitor(&tv, NULL, HCI_DEV_NONE,
+				BTSNOOP_OPCODE_SYSTEM_NOTE, msg, len);
+}
+
+static int open_kmsg(void)
+{
+	int fd;
+
+	fd = open("/dev/kmsg", O_RDONLY);
+	if (fd < 0)
+		return -1;
+
+	if (mainloop_add_fd(fd, EPOLLIN, kmsg_callback, NULL, NULL) < 0) {
+		close(fd);
+		return -1;
+	}
+
+	return 0;
+}
+
 static void client_callback(int fd, uint32_t events, void *user_data)
 {
 	struct control_data *data = user_data;
@@ -1556,6 +1612,9 @@ int control_tracing(void)
 	if (packet_has_filter(PACKET_FILTER_SHOW_MGMT_SOCKET))
 		open_channel(HCI_CHANNEL_CONTROL);
 
+	if (packet_has_filter(PACKET_FILTER_SHOW_KMSG))
+		open_kmsg();
+
 	return 0;
 }
 
diff --git a/monitor/main.c b/monitor/main.c
index fa56fcb29f38..cc947af1ffc4 100644
--- a/monitor/main.c
+++ b/monitor/main.c
@@ -61,6 +61,7 @@ static void usage(void)
 		"\t-B, --tty-speed <rate> Set TTY speed (default 115200)\n"
 		"\t-V, --vendor <compid>  Set default company identifier\n"
 		"\t-M, --mgmt             Open channel for mgmt events\n"
+		"\t-K, --kernel           Open kmsg for kernel messages\n"
 		"\t-t, --time             Show time instead of time offset\n"
 		"\t-T, --date             Show time and date information\n"
 		"\t-S, --sco              Dump SCO traffic\n"
@@ -88,6 +89,7 @@ static const struct option main_options[] = {
 	{ "tty-speed", required_argument, NULL, 'B' },
 	{ "vendor",    required_argument, NULL, 'V' },
 	{ "mgmt",      no_argument,       NULL, 'M' },
+	{ "kernel",    no_argument,       NULL, 'K' },
 	{ "no-time",   no_argument,       NULL, 'N' },
 	{ "time",      no_argument,       NULL, 't' },
 	{ "date",      no_argument,       NULL, 'T' },
@@ -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:MKNtTSAIE:PJ:R:C:c:vh",
 				main_options, NULL);
 		if (opt < 0)
 			break;
@@ -184,6 +186,9 @@ int main(int argc, char *argv[])
 		case 'M':
 			filter_mask |= PACKET_FILTER_SHOW_MGMT_SOCKET;
 			break;
+		case 'K':
+			filter_mask |= PACKET_FILTER_SHOW_KMSG;
+			break;
 		case 'N':
 			filter_mask &= ~PACKET_FILTER_SHOW_TIME_OFFSET;
 			break;
diff --git a/monitor/packet.h b/monitor/packet.h
index 964b9a7219fa..154a08efacc5 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_KMSG		(1 << 9)
 #define TV_MSEC(_tv) (long long)((_tv).tv_sec * 1000 + (_tv).tv_usec / 1000)
 
 struct packet_latency {
-- 
2.50.1


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

* RE: [BlueZ,v1] adapter: Fix setting index in MGMT_OP_SET_EXP_FEATURE with debug_uuid
  2025-08-20 20:41 [PATCH BlueZ v1] adapter: Fix setting index in MGMT_OP_SET_EXP_FEATURE with debug_uuid Luiz Augusto von Dentz
  2025-08-20 20:41 ` [PATCH BlueZ v1] monitor: Add support for -K/--kernel Luiz Augusto von Dentz
@ 2025-08-20 21:59 ` bluez.test.bot
  2025-08-21 14:00 ` [PATCH BlueZ v1] " patchwork-bot+bluetooth
  2 siblings, 0 replies; 5+ messages in thread
From: bluez.test.bot @ 2025-08-20 21:59 UTC (permalink / raw)
  To: linux-bluetooth, luiz.dentz

[-- Attachment #1: Type: text/plain, Size: 1261 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=993678

---Test result---

Test Summary:
CheckPatch                    PENDING   0.29 seconds
GitLint                       PENDING   0.32 seconds
BuildEll                      PASS      19.79 seconds
BluezMake                     PASS      2545.68 seconds
MakeCheck                     PASS      20.37 seconds
MakeDistcheck                 PASS      182.77 seconds
CheckValgrind                 PASS      234.19 seconds
CheckSmatch                   PASS      304.92 seconds
bluezmakeextell               PASS      127.70 seconds
IncrementalBuild              PENDING   0.24 seconds
ScanBuild                     PASS      900.50 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth


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

* RE: [BlueZ,v1] monitor: Add support for -K/--kernel
  2025-08-20 20:41 ` [PATCH BlueZ v1] monitor: Add support for -K/--kernel Luiz Augusto von Dentz
@ 2025-08-20 22:00   ` bluez.test.bot
  0 siblings, 0 replies; 5+ messages in thread
From: bluez.test.bot @ 2025-08-20 22:00 UTC (permalink / raw)
  To: linux-bluetooth, luiz.dentz

[-- Attachment #1: Type: text/plain, Size: 1261 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=993679

---Test result---

Test Summary:
CheckPatch                    PENDING   0.33 seconds
GitLint                       PENDING   0.30 seconds
BuildEll                      PASS      20.13 seconds
BluezMake                     PASS      2582.12 seconds
MakeCheck                     PASS      20.54 seconds
MakeDistcheck                 PASS      184.59 seconds
CheckValgrind                 PASS      235.83 seconds
CheckSmatch                   PASS      306.31 seconds
bluezmakeextell               PASS      128.33 seconds
IncrementalBuild              PENDING   0.29 seconds
ScanBuild                     PASS      911.89 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth


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

* Re: [PATCH BlueZ v1] adapter: Fix setting index in MGMT_OP_SET_EXP_FEATURE with debug_uuid
  2025-08-20 20:41 [PATCH BlueZ v1] adapter: Fix setting index in MGMT_OP_SET_EXP_FEATURE with debug_uuid Luiz Augusto von Dentz
  2025-08-20 20:41 ` [PATCH BlueZ v1] monitor: Add support for -K/--kernel Luiz Augusto von Dentz
  2025-08-20 21:59 ` [BlueZ,v1] adapter: Fix setting index in MGMT_OP_SET_EXP_FEATURE with debug_uuid bluez.test.bot
@ 2025-08-21 14:00 ` patchwork-bot+bluetooth
  2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+bluetooth @ 2025-08-21 14:00 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hello:

This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Wed, 20 Aug 2025 16:41:16 -0400 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> Experimental debug feature requires use of MGMT_INDEX_NONE since it is
> not an adapter specific feature.
> ---
>  src/adapter.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Here is the summary with links:
  - [BlueZ,v1] adapter: Fix setting index in MGMT_OP_SET_EXP_FEATURE with debug_uuid
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=5f38ea159ea8

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2025-08-21 13:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-20 20:41 [PATCH BlueZ v1] adapter: Fix setting index in MGMT_OP_SET_EXP_FEATURE with debug_uuid Luiz Augusto von Dentz
2025-08-20 20:41 ` [PATCH BlueZ v1] monitor: Add support for -K/--kernel Luiz Augusto von Dentz
2025-08-20 22:00   ` [BlueZ,v1] " bluez.test.bot
2025-08-20 21:59 ` [BlueZ,v1] adapter: Fix setting index in MGMT_OP_SET_EXP_FEATURE with debug_uuid bluez.test.bot
2025-08-21 14:00 ` [PATCH BlueZ v1] " patchwork-bot+bluetooth

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