git: e6d0edd2fe8c - main - scmi: Add sysctl transport properties

From: Andrew Turner <andrew_at_FreeBSD.org>
Date: Thu, 23 Jan 2025 17:27:40 UTC
The branch main has been updated by andrew:

URL: https://cgit.FreeBSD.org/src/commit/?id=e6d0edd2fe8c3c15faa7c9c66703efa007a5fbe1

commit e6d0edd2fe8c3c15faa7c9c66703efa007a5fbe1
Author:     Cristian Marussi <cristian.marussi@arm.com>
AuthorDate: 2025-01-23 13:27:08 +0000
Commit:     Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2025-01-23 17:26:27 +0000

    scmi: Add sysctl transport properties
    
    Expose as read-only the configured transport properties.
    
    Tested on:      Arm Morello Board
    Reviewed by:    andrew
    Sponsored by:   Arm Ltd
    Differential Revision:  https://reviews.freebsd.org/D47428
    Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---
 sys/dev/firmware/arm/scmi.c | 13 +++++++++++++
 sys/dev/firmware/arm/scmi.h |  3 +++
 2 files changed, 16 insertions(+)

diff --git a/sys/dev/firmware/arm/scmi.c b/sys/dev/firmware/arm/scmi.c
index 2d9f6fa89d4b..b27f7211201e 100644
--- a/sys/dev/firmware/arm/scmi.c
+++ b/sys/dev/firmware/arm/scmi.c
@@ -44,6 +44,7 @@
 #include <sys/queue.h>
 #include <sys/refcount.h>
 #include <sys/sdt.h>
+#include <sys/sysctl.h>
 #include <sys/taskqueue.h>
 
 #include <dev/clk/clk.h>
@@ -189,6 +190,7 @@ static void		scmi_process_response(struct scmi_softc *, uint32_t,
 int
 scmi_attach(device_t dev)
 {
+	struct sysctl_oid *sysctl_trans;
 	struct scmi_softc *sc;
 	phandle_t node;
 	int error;
@@ -209,6 +211,17 @@ scmi_attach(device_t dev)
 	device_printf(dev, "Transport - max_msg:%d  max_payld_sz:%lu  reply_timo_ms:%d\n",
 	    SCMI_MAX_MSG(sc), SCMI_MAX_MSG_PAYLD_SIZE(sc), SCMI_MAX_MSG_TIMEOUT_MS(sc));
 
+	sc->sysctl_root = SYSCTL_ADD_NODE(NULL, SYSCTL_STATIC_CHILDREN(_hw),
+	    OID_AUTO, "scmi", CTLFLAG_RD, 0, "SCMI root");
+	sysctl_trans = SYSCTL_ADD_NODE(NULL, SYSCTL_CHILDREN(sc->sysctl_root),
+	    OID_AUTO, "transport", CTLFLAG_RD, 0, "SCMI Transport properties");
+	SYSCTL_ADD_INT(NULL, SYSCTL_CHILDREN(sysctl_trans), OID_AUTO, "max_msg",
+	    CTLFLAG_RD, &sc->trs_desc.max_msg, 0, "SCMI Max number of inflight messages");
+	SYSCTL_ADD_INT(NULL, SYSCTL_CHILDREN(sysctl_trans), OID_AUTO, "max_msg_size",
+	    CTLFLAG_RD, &sc->trs_desc.max_payld_sz, 0, "SCMI Max message payload size");
+	SYSCTL_ADD_INT(NULL, SYSCTL_CHILDREN(sysctl_trans), OID_AUTO, "max_rx_timeout_ms",
+	    CTLFLAG_RD, &sc->trs_desc.reply_timo_ms, 0, "SCMI Max message RX timeout ms");
+
 	/*
 	 * Allow devices to identify.
 	 */
diff --git a/sys/dev/firmware/arm/scmi.h b/sys/dev/firmware/arm/scmi.h
index 990759237964..fc52732bd503 100644
--- a/sys/dev/firmware/arm/scmi.h
+++ b/sys/dev/firmware/arm/scmi.h
@@ -32,6 +32,8 @@
 #ifndef	_ARM64_SCMI_SCMI_H_
 #define	_ARM64_SCMI_SCMI_H_
 
+#include <sys/sysctl.h>
+
 #include "scmi_if.h"
 
 #define SCMI_DEF_MAX_MSG		32
@@ -64,6 +66,7 @@ struct scmi_softc {
 	struct mtx			mtx;
 	struct scmi_transport_desc	trs_desc;
 	struct scmi_transport		*trs;
+	struct sysctl_oid		*sysctl_root;
 };
 
 struct scmi_msg {