From nobody Wed Oct 04 16:53:54 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4S11423vS2z4wGhJ; Wed, 4 Oct 2023 16:53:54 +0000 (UTC) (envelope-from git@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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4S11422zGcz3C83; Wed, 4 Oct 2023 16:53:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696438434; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+rk9gEU/9hTUQwoONc1JSVzrhiiQzTakriA8FBndsgw=; b=IoDPfjJHv4XY2QsW6aeGnAxveWraxrAEuXBBDRLh1Stz3rUfgeAM5Lo/bJ32Ef/AhuTsVn lBMfxwL/zkuQn3/BPHwXIqX4RBrkzci48x/Q7vRxMY8HV3AGXl+HbWJy7UZvu2JZr7gpqN XZ8YdG2HfZNUs9BG+4AEMyzpMgo7iipTkv6yj67U1iA5EgJsNCuzvDvjE4WzsDXVVfkI7T zol8L6pzuIo5UV1xTdtEjHP4Ie9f/83KzgS/SVx21CLxz6KbLtr2AYhU3nSENFE63lO0Ou XP+myaD+KBqPREg5Mql3xWrjoVZTFDqCu1g9mOxJBIKs/X6+vRhQPoKpaOXGxQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1696438434; a=rsa-sha256; cv=none; b=ex3omsPF38EXDktX0XmQuwis2SNQBPBeRCbj7SKbqDToQFcskNff1ZIegPyramCjO7gDKJ T1NDlg92hvlAvvgrC2CRFJgFbvAFGUEBdm/iJCftvfR105Zgaq50CNYy0u/BHyYdFd4owS b3eXQWNFnmgRTpzV8xGckyzqLWVl/aBu5W5T6YVWmYMfZ9yltC/Iykg9AUmjfF3OCqNkEe uFLzSasL9AxSJN71X41NmTkLGkz72f4nARVWBAo5zs3apOSVIJ7VjNN9ucKa4C89+QpCJt smS1MjIrfmDSaXtzxPhDdTDmidj/yXcDSQ8mwY1pE6pHcdKzdEhv0jDyrY9Lmg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696438434; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+rk9gEU/9hTUQwoONc1JSVzrhiiQzTakriA8FBndsgw=; b=VmkqxCI1kOsuQdLkCKKI+7gNKhPp8/8n9lQHDz1sH9OpV/mkx7Lw/TGYVvfiGZcU2nXY2U qfhY2NNJRZgG9n34pyHLzh1yb+zQnRpccFDiwrG52zm6s1CgTF9GZWrVPBB8umkrOM+tSY Cckx4h+S2IL+/5deHmP7EwOyxx7Ox3t57+aF5VRqOoidPMhZqnioGfd4V72AOkq0xgFNIy N0FMwhRYnplLFT8b809Ygxv9YDtoYmgSAfjUea/Um0y+J2WE41aoQZU3NCuMibKwWJCoH0 pQptfuMUDqq7veT4FZJoCT0AWI/GBiV1NOsTB4qyWjFDEml8SOv4I1F2FLVbGw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4S1142221SzlRS; Wed, 4 Oct 2023 16:53:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 394Grshs037385; Wed, 4 Oct 2023 16:53:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 394Grsae037381; Wed, 4 Oct 2023 16:53:54 GMT (envelope-from git) Date: Wed, 4 Oct 2023 16:53:54 GMT Message-Id: <202310041653.394Grsae037381@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 01d53c34e79a - main - bhyve: Improve pcifd function naming List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 01d53c34e79afaad757088e5fbb4846f02a8beca Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=01d53c34e79afaad757088e5fbb4846f02a8beca commit 01d53c34e79afaad757088e5fbb4846f02a8beca Author: Mark Johnston AuthorDate: 2023-10-04 16:19:58 +0000 Commit: Mark Johnston CommitDate: 2023-10-04 16:53:16 +0000 bhyve: Improve pcifd function naming read_config() and write_config() are externally visible, so give them more descriptive names. No functional change intended. MFC after: 1 week Sponsored by: Innovate UK --- usr.sbin/bhyve/pci_emul.c | 2 +- usr.sbin/bhyve/pci_gvt-d.c | 8 ++++---- usr.sbin/bhyve/pci_lpc.c | 9 +++++---- usr.sbin/bhyve/pci_passthru.c | 40 +++++++++++++++++++++++----------------- usr.sbin/bhyve/pci_passthru.h | 6 ++++-- 5 files changed, 37 insertions(+), 28 deletions(-) diff --git a/usr.sbin/bhyve/pci_emul.c b/usr.sbin/bhyve/pci_emul.c index 3c34d0e22478..5fb25dbfe9c7 100644 --- a/usr.sbin/bhyve/pci_emul.c +++ b/usr.sbin/bhyve/pci_emul.c @@ -375,7 +375,7 @@ pci_config_read_reg(const struct pcisel *const host_sel, nvlist_t *nvl, if (config == NULL) { return def; } else if (host_sel != NULL && strcmp(config, "host") == 0) { - return read_config(host_sel, reg, size); + return pci_host_read_config(host_sel, reg, size); } else { return strtol(config, NULL, 16); } diff --git a/usr.sbin/bhyve/pci_gvt-d.c b/usr.sbin/bhyve/pci_gvt-d.c index 35c7f30dd292..78fa9878358e 100644 --- a/usr.sbin/bhyve/pci_gvt-d.c +++ b/usr.sbin/bhyve/pci_gvt-d.c @@ -49,11 +49,11 @@ gvt_d_probe(struct pci_devinst *const pi) sc = pi->pi_arg; - vendor = read_config(passthru_get_sel(sc), PCIR_VENDOR, 0x02); + vendor = pci_host_read_config(passthru_get_sel(sc), PCIR_VENDOR, 0x02); if (vendor != PCI_VENDOR_INTEL) return (ENXIO); - class = read_config(passthru_get_sel(sc), PCIR_CLASS, 0x01); + class = pci_host_read_config(passthru_get_sel(sc), PCIR_CLASS, 0x01); if (class != PCIC_DISPLAY) return (ENXIO); @@ -169,7 +169,7 @@ gvt_d_setup_gsm(struct pci_devinst *const pi) "Warning: Unable to reuse host address of Graphics Stolen Memory. GPU passthrough might not work properly."); } - bdsm = read_config(passthru_get_sel(sc), PCIR_BDSM, 4); + bdsm = pci_host_read_config(passthru_get_sel(sc), PCIR_BDSM, 4); pci_set_cfgdata32(pi, PCIR_BDSM, gsm->gpa | (bdsm & (PCIM_BDSM_GSM_ALIGNMENT - 1))); @@ -201,7 +201,7 @@ gvt_d_setup_opregion(struct pci_devinst *const pi) return (-1); } - asls = read_config(passthru_get_sel(sc), PCIR_ASLS_CTL, 4); + asls = pci_host_read_config(passthru_get_sel(sc), PCIR_ASLS_CTL, 4); header = mmap(NULL, sizeof(*header), PROT_READ, MAP_SHARED, memfd, asls); diff --git a/usr.sbin/bhyve/pci_lpc.c b/usr.sbin/bhyve/pci_lpc.c index 2ff9bbc27774..5c2a2a7965b0 100644 --- a/usr.sbin/bhyve/pci_lpc.c +++ b/usr.sbin/bhyve/pci_lpc.c @@ -485,15 +485,16 @@ pci_lpc_get_sel(struct pcisel *const sel) sel->pc_dev = slot; sel->pc_func = 0; - if (read_config(sel, PCIR_HDRTYPE, 1) & PCIM_MFDEV) + if (pci_host_read_config(sel, PCIR_HDRTYPE, 1) & PCIM_MFDEV) max_func = PCI_FUNCMAX; for (uint8_t func = 0; func <= max_func; ++func) { sel->pc_func = func; - if ((read_config(sel, PCIR_CLASS, 1) == PCIC_BRIDGE) && - (read_config(sel, PCIR_SUBCLASS, 1) == - PCIS_BRIDGE_ISA)) { + if (pci_host_read_config(sel, PCIR_CLASS, 1) == + PCIC_BRIDGE && + pci_host_read_config(sel, PCIR_SUBCLASS, 1) == + PCIS_BRIDGE_ISA) { return (0); } } diff --git a/usr.sbin/bhyve/pci_passthru.c b/usr.sbin/bhyve/pci_passthru.c index fa23358c07a2..0a80ee649689 100644 --- a/usr.sbin/bhyve/pci_passthru.c +++ b/usr.sbin/bhyve/pci_passthru.c @@ -145,7 +145,7 @@ pcifd_init(void) } uint32_t -read_config(const struct pcisel *sel, long reg, int width) +pci_host_read_config(const struct pcisel *sel, long reg, int width) { struct pci_io pi; @@ -165,7 +165,8 @@ read_config(const struct pcisel *sel, long reg, int width) } void -write_config(const struct pcisel *sel, long reg, int width, uint32_t data) +pci_host_write_config(const struct pcisel *sel, long reg, int width, + uint32_t data) { struct pci_io pi; @@ -224,24 +225,25 @@ cfginitmsi(struct passthru_softc *sc) * Parse the capabilities and cache the location of the MSI * and MSI-X capabilities. */ - sts = read_config(&sel, PCIR_STATUS, 2); + sts = pci_host_read_config(&sel, PCIR_STATUS, 2); if (sts & PCIM_STATUS_CAPPRESENT) { - ptr = read_config(&sel, PCIR_CAP_PTR, 1); + ptr = pci_host_read_config(&sel, PCIR_CAP_PTR, 1); while (ptr != 0 && ptr != 0xff) { - cap = read_config(&sel, ptr + PCICAP_ID, 1); + cap = pci_host_read_config(&sel, ptr + PCICAP_ID, 1); if (cap == PCIY_MSI) { /* * Copy the MSI capability into the config * space of the emulated pci device */ sc->psc_msi.capoff = ptr; - sc->psc_msi.msgctrl = read_config(&sel, - ptr + 2, 2); + sc->psc_msi.msgctrl = pci_host_read_config(&sel, + ptr + 2, 2); sc->psc_msi.emulated = 0; caplen = msi_caplen(sc->psc_msi.msgctrl); capptr = ptr; while (caplen > 0) { - u32 = read_config(&sel, capptr, 4); + u32 = pci_host_read_config(&sel, capptr, + 4); pci_set_cfgdata32(pi, capptr, u32); caplen -= 4; capptr += 4; @@ -255,7 +257,8 @@ cfginitmsi(struct passthru_softc *sc) msixcap_ptr = (char *)&msixcap; capptr = ptr; while (caplen > 0) { - u32 = read_config(&sel, capptr, 4); + u32 = pci_host_read_config(&sel, capptr, + 4); memcpy(msixcap_ptr, &u32, 4); pci_set_cfgdata32(pi, capptr, u32); caplen -= 4; @@ -263,7 +266,8 @@ cfginitmsi(struct passthru_softc *sc) msixcap_ptr += 4; } } - ptr = read_config(&sel, ptr + PCICAP_NEXTPTR, 1); + ptr = pci_host_read_config(&sel, ptr + PCICAP_NEXTPTR, + 1); } } @@ -298,7 +302,7 @@ cfginitmsi(struct passthru_softc *sc) */ if ((sts & PCIM_STATUS_CAPPRESENT) != 0 && sc->psc_msi.capoff == 0) { int origptr, msiptr; - origptr = read_config(&sel, PCIR_CAP_PTR, 1); + origptr = pci_host_read_config(&sel, PCIR_CAP_PTR, 1); msiptr = passthru_add_msicap(pi, 1, origptr); sc->psc_msi.capoff = msiptr; sc->psc_msi.msgctrl = pci_get_cfgdata16(pi, msiptr + 2); @@ -577,7 +581,8 @@ cfginitbar(struct passthru_softc *sc) return (-1); /* Use same lobits as physical bar */ - uint8_t lobits = read_config(&sc->psc_sel, PCIR_BAR(i), 0x01); + uint8_t lobits = pci_host_read_config(&sc->psc_sel, PCIR_BAR(i), + 0x01); if (bartype == PCIBAR_MEM32 || bartype == PCIBAR_MEM64) { lobits &= ~PCIM_BAR_MEM_BASE; } else { @@ -621,7 +626,8 @@ cfginit(struct pci_devinst *pi, int bus, int slot, int func) intline = pci_get_cfgdata8(pi, PCIR_INTLINE); intpin = pci_get_cfgdata8(pi, PCIR_INTPIN); for (int i = 0; i <= PCIR_MAXLAT; i += 4) { - pci_set_cfgdata32(pi, i, read_config(&sc->psc_sel, i, 4)); + pci_set_cfgdata32(pi, i, + pci_host_read_config(&sc->psc_sel, i, 4)); } pci_set_cfgdata8(pi, PCIR_INTLINE, intline); pci_set_cfgdata8(pi, PCIR_INTPIN, intpin); @@ -638,7 +644,7 @@ cfginit(struct pci_devinst *pi, int bus, int slot, int func) goto done; } - write_config(&sc->psc_sel, PCIR_COMMAND, 2, + pci_host_write_config(&sc->psc_sel, PCIR_COMMAND, 2, pci_get_cfgdata16(pi, PCIR_COMMAND)); /* @@ -988,13 +994,13 @@ passthru_cfgread_default(struct passthru_softc *sc, if (coff == PCIR_COMMAND) { if (bytes <= 2) return (-1); - *rv = read_config(&sc->psc_sel, PCIR_STATUS, 2) << 16 | + *rv = pci_host_read_config(&sc->psc_sel, PCIR_STATUS, 2) << 16 | pci_get_cfgdata16(pi, PCIR_COMMAND); return (0); } /* Everything else just read from the device's config space */ - *rv = read_config(&sc->psc_sel, coff, bytes); + *rv = pci_host_read_config(&sc->psc_sel, coff, bytes); return (0); } @@ -1080,7 +1086,7 @@ passthru_cfgwrite_default(struct passthru_softc *sc, struct pci_devinst *pi, } #endif - write_config(&sc->psc_sel, coff, bytes, val); + pci_host_write_config(&sc->psc_sel, coff, bytes, val); if (coff == PCIR_COMMAND) { cmd_old = pci_get_cfgdata16(pi, PCIR_COMMAND); if (bytes == 1) diff --git a/usr.sbin/bhyve/pci_passthru.h b/usr.sbin/bhyve/pci_passthru.h index 49d2bb309f71..a89ad287cbc5 100644 --- a/usr.sbin/bhyve/pci_passthru.h +++ b/usr.sbin/bhyve/pci_passthru.h @@ -36,8 +36,10 @@ typedef int (*cfgread_handler)(struct passthru_softc *sc, typedef int (*cfgwrite_handler)(struct passthru_softc *sc, struct pci_devinst *pi, int coff, int bytes, uint32_t val); -uint32_t read_config(const struct pcisel *sel, long reg, int width); -void write_config(const struct pcisel *sel, long reg, int width, uint32_t data); +uint32_t pci_host_read_config(const struct pcisel *sel, long reg, int width); +void pci_host_write_config(const struct pcisel *sel, long reg, int width, + uint32_t data); + int passthru_cfgread_emulate(struct passthru_softc *sc, struct pci_devinst *pi, int coff, int bytes, uint32_t *rv); int passthru_cfgwrite_emulate(struct passthru_softc *sc, struct pci_devinst *pi,