From owner-svn-src-stable@freebsd.org  Mon Sep  9 14:16:58 2019
Return-Path: <owner-svn-src-stable@freebsd.org>
Delivered-To: svn-src-stable@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 67E0FD3A63;
 Mon,  9 Sep 2019 14:16:58 +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)
 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 46Rqwp25Bjz42cG;
 Mon,  9 Sep 2019 14:16:58 +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 2B57BED73;
 Mon,  9 Sep 2019 14:16:58 +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 x89EGw3B062669;
 Mon, 9 Sep 2019 14:16:58 GMT (envelope-from chuck@FreeBSD.org)
Received: (from chuck@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id x89EGwM2062668;
 Mon, 9 Sep 2019 14:16:58 GMT (envelope-from chuck@FreeBSD.org)
Message-Id: <201909091416.x89EGwM2062668@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: chuck set sender to
 chuck@FreeBSD.org using -f
From: Chuck Tuffli <chuck@FreeBSD.org>
Date: Mon, 9 Sep 2019 14:16:58 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject: svn commit: r352061 - stable/12/usr.sbin/bhyve
X-SVN-Group: stable-12
X-SVN-Commit-Author: chuck
X-SVN-Commit-Paths: stable/12/usr.sbin/bhyve
X-SVN-Commit-Revision: 352061
X-SVN-Commit-Repository: base
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
 <svn-src-stable.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/svn-src-stable>, 
 <mailto:svn-src-stable-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-stable/>
List-Post: <mailto:svn-src-stable@freebsd.org>
List-Help: <mailto:svn-src-stable-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/svn-src-stable>,
 <mailto:svn-src-stable-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Mon, 09 Sep 2019 14:16:58 -0000

Author: chuck
Date: Mon Sep  9 14:16:57 2019
New Revision: 352061
URL: https://svnweb.freebsd.org/changeset/base/352061

Log:
  MFC r350077
  
  bhyve: update the NVMe CQ based on the status
  
  Approved by:	imp (mentor)

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	Mon Sep  9 12:42:48 2019	(r352060)
+++ stable/12/usr.sbin/bhyve/pci_nvme.c	Mon Sep  9 14:16:57 2019	(r352061)
@@ -99,6 +99,10 @@ static int nvme_debug = 0;
 #define	NVME_PRP2_ITEMS		(PAGE_SIZE/sizeof(uint64_t))
 #define	NVME_MAX_BLOCKIOVS	512
 
+/* This is a synthetic status code to indicate there is no status */
+#define NVME_NO_STATUS		0xffff
+#define NVME_COMPLETION_VALID(c)	((c).status != NVME_NO_STATUS)
+
 /* helpers */
 
 /* Convert a zero-based value into a one-based value */
@@ -1092,14 +1096,16 @@ pci_nvme_handle_admin_cmd(struct pci_nvme_softc* sc, u
 			/* XXX dont care, unhandled for now
 			do_intr |= nvme_opc_async_event_req(sc, cmd, &compl);
 			*/
+			compl.status = NVME_NO_STATUS;
 			break;
 		default:
 			WPRINTF(("0x%x command is not implemented\r\n",
 			    cmd->opc));
+			pci_nvme_status_genc(&compl.status, NVME_SC_INVALID_OPCODE);
+			do_intr |= 1;
 		}
 	
-		/* for now skip async event generation */
-		if (cmd->opc != NVME_OPC_ASYNC_EVENT_REQUEST) {
+		if (NVME_COMPLETION_VALID(compl)) {
 			struct nvme_completion *cp;
 			int phase;