From owner-svn-src-stable@freebsd.org Sun Apr 12 19:02:35 2020 Return-Path: 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 708212C5EAA; Sun, 12 Apr 2020 19:02:35 +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 490h2g1JqNz4VlF; Sun, 12 Apr 2020 19:02:35 +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 24C8D6631; Sun, 12 Apr 2020 19:02:35 +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 03CJ2Z6f085766; Sun, 12 Apr 2020 19:02:35 GMT (envelope-from chuck@FreeBSD.org) Received: (from chuck@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 03CJ2ZGG085765; Sun, 12 Apr 2020 19:02:35 GMT (envelope-from chuck@FreeBSD.org) Message-Id: <202004121902.03CJ2ZGG085765@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: chuck set sender to chuck@FreeBSD.org using -f From: Chuck Tuffli Date: Sun, 12 Apr 2020 19:02:35 +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: r359830 - 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: 359830 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Apr 2020 19:02:35 -0000 Author: chuck Date: Sun Apr 12 19:02:34 2020 New Revision: 359830 URL: https://svnweb.freebsd.org/changeset/base/359830 Log: MFC r359363 bhyve: refactor NVMe namespace initialization 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 Apr 12 18:04:20 2020 (r359829) +++ stable/12/usr.sbin/bhyve/pci_nvme.c Sun Apr 12 19:02:34 2020 (r359830) @@ -421,20 +421,21 @@ crc16(uint16_t crc, const void *buffer, unsigned int l static void pci_nvme_init_nsdata(struct pci_nvme_softc *sc, struct nvme_namespace_data *nd, uint32_t nsid, - uint64_t eui64) + struct pci_nvme_blockstore *nvstore) { - nd->nsze = sc->nvstore.size / sc->nvstore.sectsz; + /* Get capacity and block size information from backing store */ + nd->nsze = nvstore->size / nvstore->sectsz; nd->ncap = nd->nsze; nd->nuse = nd->nsze; - /* Get LBA and backstore information from backing store */ nd->nlbaf = 0; /* NLBAF is a 0's based value (i.e. 1 LBA Format) */ nd->flbas = 0; /* Create an EUI-64 if user did not provide one */ - if (eui64 == 0) { + if (nvstore->eui64 == 0) { char *data = NULL; + uint64_t eui64 = nvstore->eui64; asprintf(&data, "%s%u%u%u", vmname, sc->nsc_pi->pi_bus, sc->nsc_pi->pi_slot, sc->nsc_pi->pi_func); @@ -443,12 +444,12 @@ pci_nvme_init_nsdata(struct pci_nvme_softc *sc, eui64 = OUI_FREEBSD_NVME_LOW | crc16(0, data, strlen(data)); free(data); } - eui64 = (eui64 << 16) | (nsid & 0xffff); + nvstore->eui64 = (eui64 << 16) | (nsid & 0xffff); } - be64enc(nd->eui64, eui64); + be64enc(nd->eui64, nvstore->eui64); /* LBA data-sz = 2^lbads */ - nd->lbaf[0] = sc->nvstore.sectsz_bits << NVME_NS_DATA_LBAF_LBADS_SHIFT; + nd->lbaf[0] = nvstore->sectsz_bits << NVME_NS_DATA_LBAF_LBADS_SHIFT; } static void @@ -2031,7 +2032,7 @@ pci_nvme_init(struct vmctx *ctx, struct pci_devinst *p pci_nvme_reset(sc); pci_nvme_init_ctrldata(sc); - pci_nvme_init_nsdata(sc, &sc->nsdata, 1, sc->nvstore.eui64); + pci_nvme_init_nsdata(sc, &sc->nsdata, 1, &sc->nvstore); pci_nvme_init_logpages(sc); pci_lintr_request(pi);