From owner-svn-src-head@freebsd.org Mon Jun 29 00:31:51 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 9878D3593E2; Mon, 29 Jun 2020 00:31:51 +0000 (UTC) (envelope-from chuck@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 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 49w7j22Xkrz435Z; Mon, 29 Jun 2020 00:31:50 +0000 (UTC) (envelope-from chuck@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 28C061ED8C; Mon, 29 Jun 2020 00:31:31 +0000 (UTC) (envelope-from chuck@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 05T0VVd3047155; Mon, 29 Jun 2020 00:31:31 GMT (envelope-from chuck@FreeBSD.org) Received: (from chuck@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 05T0VV0d047154; Mon, 29 Jun 2020 00:31:31 GMT (envelope-from chuck@FreeBSD.org) Message-Id: <202006290031.05T0VV0d047154@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: chuck set sender to chuck@FreeBSD.org using -f From: Chuck Tuffli Date: Mon, 29 Jun 2020 00:31:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r362750 - head/usr.sbin/bhyve X-SVN-Group: head X-SVN-Commit-Author: chuck X-SVN-Commit-Paths: head/usr.sbin/bhyve X-SVN-Commit-Revision: 362750 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.33 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: Mon, 29 Jun 2020 00:31:51 -0000 Author: chuck Date: Mon Jun 29 00:31:30 2020 New Revision: 362750 URL: https://svnweb.freebsd.org/changeset/base/362750 Log: bhyve: implement NVMe Namespace Identification Descriptor NVMe 1.3 compliant controllers must implement the Namespace Identification Descriptor structure (i.e. CNS=3). Previously this was unimplemented. Fixes UNH Test 1.1.4-0 Tested by: Jason Tubnor MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D24884 Modified: head/usr.sbin/bhyve/pci_nvme.c Modified: head/usr.sbin/bhyve/pci_nvme.c ============================================================================== --- head/usr.sbin/bhyve/pci_nvme.c Mon Jun 29 00:31:27 2020 (r362749) +++ head/usr.sbin/bhyve/pci_nvme.c Mon Jun 29 00:31:30 2020 (r362750) @@ -870,10 +870,13 @@ nvme_opc_identify(struct pci_nvme_softc* sc, struct nv struct nvme_completion* compl) { void *dest; + uint16_t status; DPRINTF("%s identify 0x%x nsid 0x%x", __func__, command->cdw10 & 0xFF, command->nsid); + pci_nvme_status_genc(&status, NVME_SC_SUCCESS); + switch (command->cdw10 & 0xFF) { case 0x00: /* return Identify Namespace data structure */ nvme_prp_memcpy(sc->nsc_pi->pi_vmctx, command->prp1, @@ -892,24 +895,30 @@ nvme_opc_identify(struct pci_nvme_softc* sc, struct nv ((uint32_t *)dest)[0] = 1; ((uint32_t *)dest)[1] = 0; break; - case 0x11: - pci_nvme_status_genc(&compl->status, - NVME_SC_INVALID_NAMESPACE_OR_FORMAT); - return (1); case 0x03: /* list of NSID structures in CDW1.NSID, 4096 bytes */ - case 0x10: - case 0x12: - case 0x13: - case 0x14: - case 0x15: + if (command->nsid != 1) { + pci_nvme_status_genc(&status, + NVME_SC_INVALID_NAMESPACE_OR_FORMAT); + break; + } + dest = vm_map_gpa(sc->nsc_pi->pi_vmctx, command->prp1, + sizeof(uint32_t) * 1024); + /* All bytes after the descriptor shall be zero */ + bzero(dest, sizeof(uint32_t) * 1024); + + /* Return NIDT=1 (i.e. EUI64) descriptor */ + ((uint8_t *)dest)[0] = 1; + ((uint8_t *)dest)[1] = sizeof(uint64_t); + bcopy(sc->nsdata.eui64, ((uint8_t *)dest) + 4, sizeof(uint64_t)); + break; default: DPRINTF("%s unsupported identify command requested 0x%x", __func__, command->cdw10 & 0xFF); - pci_nvme_status_genc(&compl->status, NVME_SC_INVALID_FIELD); + pci_nvme_status_genc(&status, NVME_SC_INVALID_FIELD); return (1); } - pci_nvme_status_genc(&compl->status, NVME_SC_SUCCESS); + compl->status = status; return (1); }