From 5750092edd0958adc875d6012f6e656a430e71c6 Mon Sep 17 00:00:00 2001 From: np Date: Fri, 2 Aug 2013 18:05:42 +0000 Subject: [PATCH] Display temperature sensor data. Shows -1 if sensor not available on the card. # sysctl dev.t4nex.0.temperature # sysctl dev.t5nex.0.temperature --- sys/dev/cxgbe/t4_main.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 1bdb4dfe3ac..3ff068f8c89 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -379,6 +379,7 @@ static int sysctl_holdoff_pktc_idx(SYSCTL_HANDLER_ARGS); static int sysctl_qsize_rxq(SYSCTL_HANDLER_ARGS); static int sysctl_qsize_txq(SYSCTL_HANDLER_ARGS); static int sysctl_handle_t4_reg64(SYSCTL_HANDLER_ARGS); +static int sysctl_temperature(SYSCTL_HANDLER_ARGS); #ifdef SBUF_DRAIN static int sysctl_cctrl(SYSCTL_HANDLER_ARGS); static int sysctl_cim_ibq_obq(SYSCTL_HANDLER_ARGS); @@ -4223,6 +4224,10 @@ t4_sysctls(struct adapter *sc) SYSCTL_ADD_INT(ctx, children, OID_AUTO, "nfilters", CTLFLAG_RD, NULL, sc->tids.nftids, "number of filters"); + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "temperature", CTLTYPE_INT | + CTLFLAG_RD, sc, 0, sysctl_temperature, "A", + "chip temperature (in Celsius)"); + t4_sge_sysctls(sc, ctx, children); #ifdef SBUF_DRAIN @@ -4865,6 +4870,31 @@ sysctl_handle_t4_reg64(SYSCTL_HANDLER_ARGS) return (sysctl_handle_64(oidp, &val, 0, req)); } +static int +sysctl_temperature(SYSCTL_HANDLER_ARGS) +{ + struct adapter *sc = arg1; + int rc, t; + uint32_t param, val; + + rc = begin_synchronized_op(sc, NULL, SLEEP_OK | INTR_OK, "t4temp"); + if (rc) + return (rc); + param = V_FW_PARAMS_MNEM(FW_PARAMS_MNEM_DEV) | + V_FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DEV_DIAG) | + V_FW_PARAMS_PARAM_Y(FW_PARAM_DEV_DIAG_TMP); + rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, ¶m, &val); + end_synchronized_op(sc, 0); + if (rc) + return (rc); + + /* unknown is returned as 0 but we display -1 in that case */ + t = val == 0 ? -1 : val; + + rc = sysctl_handle_int(oidp, &t, 0, req); + return (rc); +} + #ifdef SBUF_DRAIN static int sysctl_cctrl(SYSCTL_HANDLER_ARGS) -- 2.45.0