Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Jul 2020 23:17:43 +0000 (UTC)
From:      Chuck Tuffli <chuck@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r363338 - stable/12/usr.sbin/bhyve
Message-ID:  <202007192317.06JNHhMZ052489@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: chuck
Date: Sun Jul 19 23:17:43 2020
New Revision: 363338
URL: https://svnweb.freebsd.org/changeset/base/363338

Log:
  MFC r362750 bhyve: implement NVMe Namespace Identification Descriptor

Modified:
  stable/12/usr.sbin/bhyve/pci_nvme.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/usr.sbin/bhyve/pci_nvme.c
==============================================================================
--- stable/12/usr.sbin/bhyve/pci_nvme.c	Sun Jul 19 22:58:11 2020	(r363337)
+++ stable/12/usr.sbin/bhyve/pci_nvme.c	Sun Jul 19 23:17:43 2020	(r363338)
@@ -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);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202007192317.06JNHhMZ052489>