From owner-svn-src-head@freebsd.org Fri Feb 7 12:15:41 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9851E24B4D1; Fri, 7 Feb 2020 12:15:41 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48DZ593Vlmz4TqP; Fri, 7 Feb 2020 12:15:41 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 55EC947B2; Fri, 7 Feb 2020 12:15:41 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 017CFfkO059170; Fri, 7 Feb 2020 12:15:41 GMT (envelope-from scottl@FreeBSD.org) Received: (from scottl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 017CFeRX059165; Fri, 7 Feb 2020 12:15:40 GMT (envelope-from scottl@FreeBSD.org) Message-Id: <202002071215.017CFeRX059165@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: scottl set sender to scottl@FreeBSD.org using -f From: Scott Long Date: Fri, 7 Feb 2020 12:15:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r357651 - in head: sys/dev/mpr sys/dev/mps usr.sbin/mpsutil X-SVN-Group: head X-SVN-Commit-Author: scottl X-SVN-Commit-Paths: in head: sys/dev/mpr sys/dev/mps usr.sbin/mpsutil X-SVN-Commit-Revision: 357651 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Feb 2020 12:15:41 -0000 Author: scottl Date: Fri Feb 7 12:15:39 2020 New Revision: 357651 URL: https://svnweb.freebsd.org/changeset/base/357651 Log: Advertise the MPI Message Version that's contained in the IOCFacts message in the sysctl block for the driver. mpsutil/mprutil needs this so it can know how big of a buffer to allocate when requesting the IOCFacts from the controller. This eliminates the kernel console messages about wrong allocation sizes. Reported by: imp Modified: head/sys/dev/mpr/mpr.c head/sys/dev/mpr/mprvar.h head/sys/dev/mps/mps.c head/sys/dev/mps/mpsvar.h head/usr.sbin/mpsutil/mps_cmd.c Modified: head/sys/dev/mpr/mpr.c ============================================================================== --- head/sys/dev/mpr/mpr.c Fri Feb 7 11:48:26 2020 (r357650) +++ head/sys/dev/mpr/mpr.c Fri Feb 7 12:15:39 2020 (r357651) @@ -520,6 +520,12 @@ mpr_iocfacts_allocate(struct mpr_softc *sc, uint8_t at 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,12 +1839,16 @@ 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, Modified: head/sys/dev/mpr/mprvar.h ============================================================================== --- head/sys/dev/mpr/mprvar.h Fri Feb 7 11:48:26 2020 (r357650) +++ head/sys/dev/mpr/mprvar.h Fri Feb 7 12:15:39 2020 (r357651) @@ -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; Modified: head/sys/dev/mps/mps.c ============================================================================== --- head/sys/dev/mps/mps.c Fri Feb 7 11:48:26 2020 (r357650) +++ head/sys/dev/mps/mps.c Fri Feb 7 12:15:39 2020 (r357651) @@ -498,6 +498,12 @@ mps_iocfacts_allocate(struct mps_softc *sc, uint8_t at 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,12 +1748,16 @@ 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, Modified: head/sys/dev/mps/mpsvar.h ============================================================================== --- head/sys/dev/mps/mpsvar.h Fri Feb 7 11:48:26 2020 (r357650) +++ head/sys/dev/mps/mpsvar.h Fri Feb 7 12:15:39 2020 (r357651) @@ -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; Modified: head/usr.sbin/mpsutil/mps_cmd.c ============================================================================== --- head/usr.sbin/mpsutil/mps_cmd.c Fri Feb 7 11:48:26 2020 (r357650) +++ head/usr.sbin/mpsutil/mps_cmd.c Fri Feb 7 12:15:39 2020 (r357651) @@ -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);