diff options
author | Scott Long <scottl@FreeBSD.org> | 2020-02-07 12:15:39 +0000 |
---|---|---|
committer | Scott Long <scottl@FreeBSD.org> | 2020-02-07 12:15:39 +0000 |
commit | 69e85eb8ae4919e0806bc2957cbc4a33f9138b54 (patch) | |
tree | 64816da24d956fe9e0834d618c8957f3c43a44af | |
parent | b041593ae7a45e1b1f2144c2b946d92abf242c65 (diff) |
Notes
-rw-r--r-- | sys/dev/mpr/mpr.c | 14 | ||||
-rw-r--r-- | sys/dev/mpr/mprvar.h | 1 | ||||
-rw-r--r-- | sys/dev/mps/mps.c | 14 | ||||
-rw-r--r-- | sys/dev/mps/mpsvar.h | 1 | ||||
-rw-r--r-- | usr.sbin/mpsutil/mps_cmd.c | 21 |
5 files changed, 43 insertions, 8 deletions
diff --git a/sys/dev/mpr/mpr.c b/sys/dev/mpr/mpr.c index 4ef502d8c760..c5b1a9c01811 100644 --- a/sys/dev/mpr/mpr.c +++ b/sys/dev/mpr/mpr.c @@ -520,6 +520,12 @@ mpr_iocfacts_allocate(struct mpr_softc *sc, uint8_t attaching) sc->facts->FWVersion.Struct.Unit, sc->facts->FWVersion.Struct.Dev); + snprintf(sc->msg_version, sizeof(sc->msg_version), "%d.%d", + (sc->facts->MsgVersion & MPI2_IOCFACTS_MSGVERSION_MAJOR_MASK) >> + MPI2_IOCFACTS_MSGVERSION_MAJOR_SHIFT, + (sc->facts->MsgVersion & MPI2_IOCFACTS_MSGVERSION_MINOR_MASK) >> + MPI2_IOCFACTS_MSGVERSION_MINOR_SHIFT); + mpr_dprint(sc, MPR_INFO, "Firmware: %s, Driver: %s\n", sc->fw_version, MPR_DRIVER_VERSION); mpr_dprint(sc, MPR_INFO, @@ -1833,13 +1839,17 @@ mpr_setup_sysctl(struct mpr_softc *sc) "Total number of event frames allocated"); SYSCTL_ADD_STRING(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), - OID_AUTO, "firmware_version", CTLFLAG_RW, sc->fw_version, + OID_AUTO, "firmware_version", CTLFLAG_RD, sc->fw_version, strlen(sc->fw_version), "firmware version"); SYSCTL_ADD_STRING(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), - OID_AUTO, "driver_version", CTLFLAG_RW, MPR_DRIVER_VERSION, + OID_AUTO, "driver_version", CTLFLAG_RD, MPR_DRIVER_VERSION, strlen(MPR_DRIVER_VERSION), "driver version"); + SYSCTL_ADD_STRING(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), + OID_AUTO, "msg_version", CTLFLAG_RD, sc->msg_version, + strlen(sc->msg_version), "message interface version"); + SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, "io_cmds_active", CTLFLAG_RD, &sc->io_cmds_active, 0, "number of currently active commands"); diff --git a/sys/dev/mpr/mprvar.h b/sys/dev/mpr/mprvar.h index 8f1f7a385c72..c18460085f56 100644 --- a/sys/dev/mpr/mprvar.h +++ b/sys/dev/mpr/mprvar.h @@ -372,6 +372,7 @@ struct mpr_softc { struct sysctl_ctx_list sysctl_ctx; struct sysctl_oid *sysctl_tree; char fw_version[16]; + char msg_version[8]; struct mpr_command *commands; struct mpr_chain *chains; struct mpr_prp_page *prps; diff --git a/sys/dev/mps/mps.c b/sys/dev/mps/mps.c index 046beda137fc..cff2e2aa080d 100644 --- a/sys/dev/mps/mps.c +++ b/sys/dev/mps/mps.c @@ -498,6 +498,12 @@ mps_iocfacts_allocate(struct mps_softc *sc, uint8_t attaching) sc->facts->FWVersion.Struct.Unit, sc->facts->FWVersion.Struct.Dev); + snprintf(sc->msg_version, sizeof(sc->msg_version), "%d.%d", + (sc->facts->MsgVersion & MPI2_IOCFACTS_MSGVERSION_MAJOR_MASK) >> + MPI2_IOCFACTS_MSGVERSION_MAJOR_SHIFT, + (sc->facts->MsgVersion & MPI2_IOCFACTS_MSGVERSION_MINOR_MASK) >> + MPI2_IOCFACTS_MSGVERSION_MINOR_SHIFT); + mps_dprint(sc, MPS_INFO, "Firmware: %s, Driver: %s\n", sc->fw_version, MPS_DRIVER_VERSION); mps_dprint(sc, MPS_INFO, "IOCCapabilities: %b\n", @@ -1742,13 +1748,17 @@ mps_setup_sysctl(struct mps_softc *sc) "Total number of event frames allocated"); SYSCTL_ADD_STRING(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), - OID_AUTO, "firmware_version", CTLFLAG_RW, sc->fw_version, + OID_AUTO, "firmware_version", CTLFLAG_RD, sc->fw_version, strlen(sc->fw_version), "firmware version"); SYSCTL_ADD_STRING(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), - OID_AUTO, "driver_version", CTLFLAG_RW, MPS_DRIVER_VERSION, + OID_AUTO, "driver_version", CTLFLAG_RD, MPS_DRIVER_VERSION, strlen(MPS_DRIVER_VERSION), "driver version"); + SYSCTL_ADD_STRING(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), + OID_AUTO, "msg_version", CTLFLAG_RD, sc->msg_version, + strlen(sc->msg_version), "message interface version"); + SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, "io_cmds_active", CTLFLAG_RD, &sc->io_cmds_active, 0, "number of currently active commands"); diff --git a/sys/dev/mps/mpsvar.h b/sys/dev/mps/mpsvar.h index 3193198c6cbd..442ada4221bf 100644 --- a/sys/dev/mps/mpsvar.h +++ b/sys/dev/mps/mpsvar.h @@ -330,6 +330,7 @@ struct mps_softc { struct sysctl_ctx_list sysctl_ctx; struct sysctl_oid *sysctl_tree; char fw_version[16]; + char msg_version[8]; struct mps_command *commands; struct mps_chain *chains; struct callout periodic; diff --git a/usr.sbin/mpsutil/mps_cmd.c b/usr.sbin/mpsutil/mps_cmd.c index edde180bf99d..527ce4db41d6 100644 --- a/usr.sbin/mpsutil/mps_cmd.c +++ b/usr.sbin/mpsutil/mps_cmd.c @@ -724,23 +724,36 @@ mps_get_iocfacts(int fd) { MPI2_IOC_FACTS_REPLY *facts; MPI2_IOC_FACTS_REQUEST req; + char msgver[8], sysctlname[128]; + size_t len, factslen; int error; - facts = malloc(sizeof(MPI2_IOC_FACTS_REPLY)); + snprintf(sysctlname, sizeof(sysctlname), "dev.%s.%d.msg_version", + is_mps ? "mps" : "mpr", mps_unit); + + factslen = sizeof(MPI2_IOC_FACTS_REPLY); + len = sizeof(msgver); + error = sysctlbyname(sysctlname, msgver, &len, NULL, 0); + if (error == 0) { + if (strncmp(msgver, "2.6", sizeof(msgver)) == 0) + factslen += 4; + } + + facts = malloc(factslen); if (facts == NULL) { errno = ENOMEM; return (NULL); } - bzero(&req, sizeof(MPI2_IOC_FACTS_REQUEST)); + bzero(&req, factslen); req.Function = MPI2_FUNCTION_IOC_FACTS; #if 1 error = mps_pass_command(fd, &req, sizeof(MPI2_IOC_FACTS_REQUEST), - facts, sizeof(MPI2_IOC_FACTS_REPLY), NULL, 0, NULL, 0, 10); + facts, factslen, NULL, 0, NULL, 0, 10); #else error = mps_user_command(fd, &req, sizeof(MPI2_IOC_FACTS_REQUEST), - facts, sizeof(MPI2_IOC_FACTS_REPLY), NULL, 0, 0); + facts, factslen, NULL, 0, 0); #endif if (error) { free(facts); |