git: bf97446e34ab - main - ipmi(4): improve debugging for ioctl(IPMICTL_SEND_COMMAND)
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 08 Oct 2026 04:08:54 UTC
The branch main has been updated by rpokala:
URL: https://cgit.FreeBSD.org/src/commit/?id=bf97446e34abfe096d91d8c2bd49ea9a50d2227d
commit bf97446e34abfe096d91d8c2bd49ea9a50d2227d
Author: Ravi Pokala <rpokala@FreeBSD.org>
AuthorDate: 2026-10-08 04:01:12 +0000
Commit: Ravi Pokala <rpokala@FreeBSD.org>
CommitDate: 2026-10-08 04:08:22 +0000
ipmi(4): improve debugging for ioctl(IPMICTL_SEND_COMMAND)
Add a knob to debug ioctl(IPMICTL_SEND_COMMAND). Log the IPMI NetFn and
Cmd fields, followed by a hexdump of the request data. Upon completion,
log the hexdump of the response data.
Reviewed by: adrian, imp, ngie
Sponsored by: Vdura
Differential Revision: https://reviews.freebsd.org/D59514
---
share/man/man4/ipmi.4 | 34 +++++++++++++++++++++++++++++++++-
sys/dev/ipmi/ipmi.c | 18 ++++++++++++++++++
2 files changed, 51 insertions(+), 1 deletion(-)
diff --git a/share/man/man4/ipmi.4 b/share/man/man4/ipmi.4
index 0d2e32c01470..eb32edc8b6dd 100644
--- a/share/man/man4/ipmi.4
+++ b/share/man/man4/ipmi.4
@@ -23,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd October 25, 2017
+.Dd October 8, 2026
.Dt IPMI 4
.Os
.Sh NAME
@@ -99,6 +99,38 @@ power cycle subcomand of the chassis control command as described in section 28.
of the IPMI standard.
The length of time the system is off will be at least one second, but
may be longer if the power cycle interval has been set (see section 28.9).
+.Sh SYSCTL VARIABLES
+The following
+.Xr sysctl 8
+variables are available:
+.Bl -tag -width indent
+.It Va hw.ipmi.cycle_wait
+If an IPMI power-cycle reboot hook is configured, wait this long for
+power-down. (sec)
+.It Va hw.ipmi.hexdump_send
+When sending commands to the BMC, log the NetFn and Cmd, and the data sent
+to and received from the BMC.
+.It Va hw.ipmi.wd_init_enable
+Initialize the BMC watchdog during IPMI driver attachment.
+.It Va hw.ipmi.wd_pretimeout_countdown
+Trigger an interrupt before the BMC watchdog resets the system. (sec)
+.It Va hw.ipmi.wd_shutdown_countdown
+Set the BMC watchdog timer and countdown from here. (sec)
+.It Va hw.ipmi.wd_startup_countdown
+Initial BMC watchdog counter starting value. (sec)
+.It Va hw.ipmi.wd_timer_actions
+What action to take when the BMC watchdog timer expires:
+.Bl -tag -offset indent -compact -width 0x0
+.It 0
+NONE
+.It 1
+RESET
+.It 2
+POWER_DOWN
+.It 3
+POWER_CYCLE
+.El
+.El
.Sh IOCTLS
Sending and receiving messages through the
.Nm
diff --git a/sys/dev/ipmi/ipmi.c b/sys/dev/ipmi/ipmi.c
index 5f759017441c..abc432f1520e 100644
--- a/sys/dev/ipmi/ipmi.c
+++ b/sys/dev/ipmi/ipmi.c
@@ -89,6 +89,9 @@ static int wd_pretimeout_countdown = 120; /* sec */
static int cycle_wait = 10; /* sec */
static int wd_init_enable = 1;
+/* Log IPMICTL_SEND_COMMAND transactions */
+static int hexdump_send = 0;
+
static SYSCTL_NODE(_hw, OID_AUTO, ipmi, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
"IPMI driver parameters");
SYSCTL_INT(_hw_ipmi, OID_AUTO, on, CTLFLAG_RWTUN,
@@ -110,6 +113,9 @@ SYSCTL_INT(_hw_ipmi, OID_AUTO, wd_pretimeout_countdown, CTLFLAG_RWTUN,
SYSCTL_INT(_hw_ipmi, OID_AUTO, cycle_wait, CTLFLAG_RWTUN,
&cycle_wait, 0,
"IPMI power cycle on reboot delay time (seconds)");
+SYSCTL_INT(_hw_ipmi, OID_AUTO, hexdump_send, CTLFLAG_RWTUN,
+ &hexdump_send, 0,
+ "IPMI driver hexdump IPMICTL_SEND_COMMAND");
static struct cdevsw ipmi_cdevsw = {
.d_version = D_VERSION,
@@ -327,6 +333,12 @@ ipmi_ioctl(struct cdev *cdev, u_long cmd, caddr_t data,
ipmi_free_request(kreq);
return (error);
}
+ if (hexdump_send) {
+ printf("IPMI_REQ_MSG: netfn=%02x cmd=%02x\n",
+ req->msg.netfn, req->msg.cmd);
+ hexdump(kreq->ir_request, req->msg.data_len,
+ "SEND_COMMAND ->\n", 0);
+ }
IPMI_LOCK(sc);
dev->ipmi_requests++;
error = sc->ipmi_enqueue_request(sc, kreq);
@@ -442,6 +454,12 @@ ipmi_ioctl(struct cdev *cdev, u_long cmd, caddr_t data,
if (error == 0)
error = copyout(kreq->ir_reply, recv->msg.data + 1,
len - 1);
+ if (hexdump_send) {
+ printf("IPMI_RECV_MSG: netfn=%02x cmd=%02x\n",
+ recv->msg.netfn, recv->msg.cmd);
+ hexdump(kreq->ir_reply, len - 1,
+ "RECEIVE_MSG <-\n", 0);
+ }
ipmi_free_request(kreq);
if (error)
return (error);