From 57ec39a5b3e6fd23ee8c34937cfe3e6ba83be6ef Mon Sep 17 00:00:00 2001 From: Alexander Bluhm Date: Thu, 5 Sep 2024 08:52:28 +0000 Subject: In ddb(4) print mbuf chain and packet list. For debugging hardware offloading, DMA requirements, bounce buffers, and performance optimizations, knowing the memory layout of mbuf content helps. Implement /c and /p modifiers in ddb show mbuf. It traverses the pointer m_next for mbuf chain or m_nextpkt for packet list. Show mbuf type, data offset, mbuf length, packet length, cluster size, and total number of elements, length and size. OK claudio@ mvs@ --- sys/ddb/db_command.c | 12 ++++++++++-- sys/ddb/db_interface.h | 4 +++- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'sys/ddb') diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c index 562053d112a..1e129c2e03c 100644 --- a/sys/ddb/db_command.c +++ b/sys/ddb/db_command.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_command.c,v 1.101 2024/05/13 01:15:50 jsg Exp $ */ +/* $OpenBSD: db_command.c,v 1.102 2024/09/05 08:52:27 bluhm Exp $ */ /* $NetBSD: db_command.c,v 1.20 1996/03/30 22:30:05 christos Exp $ */ /* @@ -340,7 +340,15 @@ db_malloc_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) void db_mbuf_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) { - m_print((void *)addr, db_printf); + if ((modif[0] == 'c' && modif[1] == 'p') || + (modif[0] == 'p' && modif[1] == 'c')) + m_print_packet((void *)addr, 1, db_printf); + else if (modif[0] == 'c') + m_print_chain((void *)addr, 0, db_printf); + else if (modif[0] == 'p') + m_print_packet((void *)addr, 0, db_printf); + else + m_print((void *)addr, db_printf); } void diff --git a/sys/ddb/db_interface.h b/sys/ddb/db_interface.h index cccec9ed69c..bdde7ae345f 100644 --- a/sys/ddb/db_interface.h +++ b/sys/ddb/db_interface.h @@ -1,4 +1,4 @@ -/* $OpenBSD: db_interface.h,v 1.27 2024/02/03 18:51:58 beck Exp $ */ +/* $OpenBSD: db_interface.h,v 1.28 2024/09/05 08:52:27 bluhm Exp $ */ /* $NetBSD: db_interface.h,v 1.1 1996/02/05 01:57:03 christos Exp $ */ /* @@ -61,6 +61,8 @@ void db_show_all_pools(db_expr_t, int, db_expr_t, char *); /* kern/uipc_mbuf.c */ void m_print(void *, int (*)(const char *, ...)); +void m_print_chain(void *, int, int (*)(const char *, ...)); +void m_print_packet(void *, int, int (*)(const char *, ...)); /* kern/uipc_socket.c */ void so_print(void *, int (*)(const char *, ...)); -- cgit v1.2.3