From yasuoka@yasuoka.net Sat Nov 29 12:20:52 2014 Delivered-To: david@gwynne.id.au Received: by 10.152.18.11 with SMTP id s11csp172399lad; Fri, 28 Nov 2014 18:20:53 -0800 (PST) X-Received: by 10.66.66.40 with SMTP id c8mr79473887pat.66.1417227653242; Fri, 28 Nov 2014 18:20:53 -0800 (PST) Return-Path: Received: from cvs.openbsd.org (cvs.openbsd.org. [199.185.137.3]) by mx.google.com with ESMTPS id bh17si18758269pdb.81.2014.11.28.18.20.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Nov 2014 18:20:52 -0800 (PST) Received-SPF: fail (google.com: domain of yasuoka@yasuoka.net does not designate 199.185.137.3 as permitted sender) client-ip=199.185.137.3; Authentication-Results: mx.google.com; spf=fail (google.com: domain of yasuoka@yasuoka.net does not designate 199.185.137.3 as permitted sender) smtp.mail=yasuoka@yasuoka.net Received: from shear.ucar.edu (lists.openbsd.org [192.43.244.163]); by cvs.openbsd.org (OpenSMTPD) with ESMTPS id 85f311f6; TLS version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=FAIL; Fri, 28 Nov 2014 19:20:51 -0700 (MST) Received: from mail.2ndsoft.com (s247156.ppp.asahi-net.or.jp [220.157.247.156]) by shear.ucar.edu (8.14.8/8.14.8) with ESMTP id sAT2Xfh5017667; Fri, 28 Nov 2014 19:33:42 -0700 (MST) Received: from localhost (fe80::20c:29ff:fe63:1e7c [IPv6:fe80::20c:29ff:fe63:1e7c]); by mail.2ndsoft.com (OpenSMTPD) with ESMTP id 478339ef; Sat, 29 Nov 2014 11:19:07 +0900 (JST) Date: Sat, 29 Nov 2014 11:20:41 +0900 (JST) Message-Id: <20141129.112041.2165587335602150376.yasuoka@yasuoka.net> To: tech@openbsd.org, dlg@openbsd.org, jmatthew@openbsd.org, jsg@openbsd.org Subject: Fix mfi to set drive state (offline, rebuild..) properly From: YASUOKA Masahiko X-Mailer: Mew version 6.4 on Emacs 24.3 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Status: RO Content-Length: 2146 Lines: 82 I'm using NEC Express5800 with its optional RAID contoller, but I could not set the drive state into rebuild or offline by bioctl(8). Tsubai found mfi(4) needs to be fixed to operate the firmware interface properly. I'd like to commit below diff from him. test? ok? Fix mfi ioctl to set drive state properly. diff from Tsubai Masanari Index: sys/dev/ic/mfi.c =================================================================== RCS file: /disk/cvs/openbsd/src/sys/dev/ic/mfi.c,v retrieving revision 1.157 diff -u -p -r1.157 mfi.c --- sys/dev/ic/mfi.c 14 Sep 2014 14:17:24 -0000 1.157 +++ sys/dev/ic/mfi.c 29 Nov 2014 02:01:18 -0000 @@ -1900,6 +1900,7 @@ int mfi_ioctl_setstate(struct mfi_softc *sc, struct bioc_setstate *bs) { struct mfi_pd_list *pd; + struct mfi_pd_details *info; int i, found, rv = EINVAL; uint8_t mbox[MFI_MBOX_SIZE]; @@ -1907,6 +1908,7 @@ mfi_ioctl_setstate(struct mfi_softc *sc, bs->bs_status); pd = malloc(sizeof(*pd), M_DEVBUF, M_WAITOK); + info = malloc(sizeof *info, M_DEVBUF, M_WAITOK); if (mfi_mgmt(sc, MR_DCMD_PD_GET_LIST, MFI_DATA_IN, sizeof(*pd), pd, NULL)) @@ -1925,23 +1927,30 @@ mfi_ioctl_setstate(struct mfi_softc *sc, memset(mbox, 0, sizeof mbox); *((uint16_t *)&mbox) = pd->mpl_address[i].mpa_pd_id; + if (mfi_mgmt(sc, MR_DCMD_PD_GET_INFO, MFI_DATA_IN, + sizeof *info, info, mbox)) + goto done; + + *((uint16_t *)&mbox[0]) = pd->mpl_address[i].mpa_pd_id; + *((uint16_t *)&mbox[2]) = info->mpd_pd.mfp_seq; switch (bs->bs_status) { case BIOC_SSONLINE: - mbox[2] = MFI_PD_ONLINE; + mbox[4] = MFI_PD_ONLINE; break; case BIOC_SSOFFLINE: - mbox[2] = MFI_PD_OFFLINE; + mbox[4] = MFI_PD_OFFLINE; break; case BIOC_SSHOTSPARE: - mbox[2] = MFI_PD_HOTSPARE; + mbox[4] = MFI_PD_HOTSPARE; break; -/* + case BIOC_SSREBUILD: + mbox[4] = MFI_PD_REBUILD; break; -*/ + default: DNPRINTF(MFI_D_IOCTL, "%s: mfi_ioctl_setstate invalid " "opcode %x\n", DEVNAME(sc), bs->bs_status); @@ -1955,6 +1964,7 @@ mfi_ioctl_setstate(struct mfi_softc *sc, rv = 0; done: free(pd, M_DEVBUF, 0); + free(info, M_DEVBUF, 0); return (rv); }