From nobody Fri Apr 26 06:12:48 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557504809; cv=none; d=zoho.com; s=zohoarc; b=duXVUGjne0CvTj7u94UILAGN2ysoChEVmHwsUOTFJfOhoo/tmacAMLR047vPjO7S18fT40FcsVqbfUDyUDRPShfLyvhS/yACi/vsanHXqCpaaa8NgMECdXtWXVZoY8HNw/yGTuzyLUa+6XbT26hwxYuuJ0Asx9Oyyv0NngHER1A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557504809; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=uyPyQHfnFRAztEvebhZ4iQ5diCieuYHPq/l1RSNRw5g=; b=ndYCSeYNXGuL9MjGFriQDrR2/n6DGuXu74RmxzC4ZPXoepB335jptpxyX5JJ4di484fr+EDZZjN74FSaEqpnGv9MD6tmp3Aqx3/5xxNeozxvBZdNntGkzQU5y3/KEcbfUoqYRHaxo3217/TUJuUejZtc+hSpqLJ7iI+nA0WxUII= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 155750480988968.84806980435201; Fri, 10 May 2019 09:13:29 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hP87z-0004fh-7J; Fri, 10 May 2019 16:12:07 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hP87x-0004f8-BA for xen-devel@lists.xenproject.org; Fri, 10 May 2019 16:12:05 +0000 Received: from SMTP03.CITRIX.COM (unknown [162.221.156.55]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 585e520a-733e-11e9-8edb-efea701647df; Fri, 10 May 2019 16:12:02 +0000 (UTC) X-Inumbo-ID: 585e520a-733e-11e9-8edb-efea701647df X-IronPort-AV: E=Sophos;i="5.60,453,1549929600"; d="scan'208";a="85330726" From: Roger Pau Monne To: Date: Fri, 10 May 2019 18:10:56 +0200 Message-ID: <20190510161056.48648-6-roger.pau@citrix.com> X-Mailer: git-send-email 2.17.2 (Apple Git-113) In-Reply-To: <20190510161056.48648-1-roger.pau@citrix.com> References: <20190510161056.48648-1-roger.pau@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 5/5] pci: switch PCI capabilities related functions to use pci_sbdf_t X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Kevin Tian , Stefano Stabellini , Wei Liu , Suravee Suthikulpanit , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , Brian Woods , Roger Pau Monne Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Since pci_dev already has a pci_sbdf_t field switch the capability related functions SBDF parameters to a single pci_sbdf_t parameter. No functional change expected. Signed-off-by: Roger Pau Monn=C3=A9 --- Cc: Jan Beulich Cc: Andrew Cooper Cc: Wei Liu Cc: George Dunlap Cc: Ian Jackson Cc: Julien Grall Cc: Konrad Rzeszutek Wilk Cc: Stefano Stabellini Cc: Tim Deegan Cc: Suravee Suthikulpanit Cc: Brian Woods Cc: Kevin Tian --- xen/arch/x86/msi.c | 42 ++++++---------------- xen/drivers/char/ehci-dbgp.c | 3 +- xen/drivers/passthrough/amd/iommu_detect.c | 2 +- xen/drivers/passthrough/ats.h | 12 +++++-- xen/drivers/passthrough/pci.c | 22 +++++------- xen/drivers/passthrough/vtd/quirks.c | 12 +++---- xen/drivers/passthrough/vtd/x86/ats.c | 3 +- xen/drivers/passthrough/x86/ats.c | 4 +-- xen/drivers/pci/pci.c | 31 +++++----------- xen/drivers/vpci/msi.c | 4 +-- xen/drivers/vpci/msix.c | 4 +-- xen/include/xen/pci.h | 9 ++--- 12 files changed, 52 insertions(+), 96 deletions(-) diff --git a/xen/arch/x86/msi.c b/xen/arch/x86/msi.c index 6832211772..27ea11b769 100644 --- a/xen/arch/x86/msi.c +++ b/xen/arch/x86/msi.c @@ -339,7 +339,7 @@ static void msi_set_enable(struct pci_dev *dev, int ena= ble) uint8_t slot =3D dev->sbdf.dev; uint8_t func =3D dev->sbdf.func; =20 - pos =3D pci_find_cap_offset(seg, bus, slot, func, PCI_CAP_ID_MSI); + pos =3D pci_find_cap_offset(dev->sbdf, PCI_CAP_ID_MSI); if ( pos ) __msi_set_enable(seg, bus, slot, func, pos, enable); } @@ -347,12 +347,9 @@ static void msi_set_enable(struct pci_dev *dev, int en= able) static void msix_set_enable(struct pci_dev *dev, int enable) { int pos; - uint16_t control, seg =3D dev->sbdf.seg; - uint8_t bus =3D dev->sbdf.bus; - uint8_t slot =3D dev->sbdf.dev; - uint8_t func =3D dev->sbdf.func; + uint16_t control; =20 - pos =3D pci_find_cap_offset(seg, bus, slot, func, PCI_CAP_ID_MSIX); + pos =3D pci_find_cap_offset(dev->sbdf, PCI_CAP_ID_MSIX); if ( pos ) { control =3D pci_conf_read16(dev->sbdf, msix_control_reg(pos)); @@ -669,13 +666,10 @@ static int msi_capability_init(struct pci_dev *dev, struct msi_desc *entry; int pos; unsigned int i, maxvec, mpos; - uint16_t control, seg =3D dev->sbdf.seg; - uint8_t bus =3D dev->sbdf.bus; - uint8_t slot =3D dev->sbdf.dev; - uint8_t func =3D dev->sbdf.func; + uint16_t control; =20 ASSERT(pcidevs_locked()); - pos =3D pci_find_cap_offset(seg, bus, slot, func, PCI_CAP_ID_MSI); + pos =3D pci_find_cap_offset(dev->sbdf, PCI_CAP_ID_MSI); if ( !pos ) return -ENODEV; control =3D pci_conf_read16(dev->sbdf, msi_control_reg(pos)); @@ -752,9 +746,7 @@ static u64 read_pci_mem_bar(u16 seg, u8 bus, u8 slot, u= 8 func, u8 bir, int vf) if ( vf >=3D 0 ) { struct pci_dev *pdev =3D pci_get_pdev(seg, bus, PCI_DEVFN(slot, fu= nc)); - unsigned int pos =3D pci_find_ext_capability(seg, bus, - PCI_DEVFN(slot, func), - PCI_EXT_CAP_ID_SRIOV); + unsigned int pos =3D pci_find_ext_capability(sbdf, PCI_EXT_CAP_ID_= SRIOV); u16 ctrl =3D pci_conf_read16(sbdf, pos + PCI_SRIOV_CTRL); u16 num_vf =3D pci_conf_read16(sbdf, pos + PCI_SRIOV_NUM_VF); u16 offset =3D pci_conf_read16(sbdf, pos + PCI_SRIOV_VF_OFFSET); @@ -1096,13 +1088,12 @@ static int __pci_enable_msix(struct msi_info *msi, = struct msi_desc **desc) int pos, nr_entries; struct pci_dev *pdev; u16 control; - u8 slot =3D PCI_SLOT(msi->devfn); - u8 func =3D PCI_FUNC(msi->devfn); struct msi_desc *old_desc; =20 ASSERT(pcidevs_locked()); pdev =3D pci_get_pdev(msi->seg, msi->bus, msi->devfn); - pos =3D pci_find_cap_offset(msi->seg, msi->bus, slot, func, PCI_CAP_ID= _MSIX); + pos =3D pci_find_cap_offset(PCI_SBDF3_T(msi->seg, msi->bus, msi->devfn= ), + PCI_CAP_ID_MSIX); if ( !pdev || !pos ) return -ENODEV; =20 @@ -1145,12 +1136,7 @@ static void _pci_cleanup_msix(struct arch_msix *msix) static void __pci_disable_msix(struct msi_desc *entry) { struct pci_dev *dev =3D entry->dev; - uint16_t seg =3D dev->sbdf.seg; - uint8_t bus =3D dev->sbdf.bus; - uint8_t slot =3D dev->sbdf.dev; - uint8_t func =3D dev->sbdf.func; - unsigned int pos =3D pci_find_cap_offset(seg, bus, slot, func, - PCI_CAP_ID_MSIX); + unsigned int pos =3D pci_find_cap_offset(dev->sbdf, PCI_CAP_ID_MSIX); uint16_t control =3D pci_conf_read16(dev->sbdf, msix_control_reg(entry->msi_attrib.= pos)); bool maskall =3D dev->msix->host_maskall; @@ -1186,8 +1172,7 @@ int pci_prepare_msix(u16 seg, u8 bus, u8 devfn, bool = off) { int rc; struct pci_dev *pdev; - u8 slot =3D PCI_SLOT(devfn), func =3D PCI_FUNC(devfn); - unsigned int pos =3D pci_find_cap_offset(seg, bus, slot, func, + unsigned int pos =3D pci_find_cap_offset(PCI_SBDF3_T(seg, bus, devfn), PCI_CAP_ID_MSIX); =20 if ( !use_msi ) @@ -1267,10 +1252,6 @@ void pci_cleanup_msi(struct pci_dev *pdev) int pci_msi_conf_write_intercept(struct pci_dev *pdev, unsigned int reg, unsigned int size, uint32_t *data) { - uint16_t seg =3D pdev->sbdf.seg; - uint8_t bus =3D pdev->sbdf.bus; - uint8_t slot =3D pdev->sbdf.dev; - uint8_t func =3D pdev->sbdf.func; struct msi_desc *entry; unsigned int pos; =20 @@ -1278,8 +1259,7 @@ int pci_msi_conf_write_intercept(struct pci_dev *pdev= , unsigned int reg, { entry =3D find_msi_entry(pdev, -1, PCI_CAP_ID_MSIX); pos =3D entry ? entry->msi_attrib.pos - : pci_find_cap_offset(seg, bus, slot, func, - PCI_CAP_ID_MSIX); + : pci_find_cap_offset(pdev->sbdf, PCI_CAP_ID_MSIX); ASSERT(pos); =20 if ( reg >=3D pos && reg < msix_pba_offset_reg(pos) + 4 ) diff --git a/xen/drivers/char/ehci-dbgp.c b/xen/drivers/char/ehci-dbgp.c index 4cd4157353..27bd4b935d 100644 --- a/xen/drivers/char/ehci-dbgp.c +++ b/xen/drivers/char/ehci-dbgp.c @@ -688,7 +688,8 @@ static unsigned int __init __find_dbgp(u8 bus, u8 slot,= u8 func) if ( (class >> 8) !=3D PCI_CLASS_SERIAL_USB_EHCI ) return 0; =20 - return pci_find_cap_offset(0, bus, slot, func, PCI_CAP_ID_EHCI_DEBUG); + return pci_find_cap_offset(PCI_SBDF_T(0, bus, slot, func), + PCI_CAP_ID_EHCI_DEBUG); } =20 static unsigned int __init find_dbgp(struct ehci_dbgp *dbgp, diff --git a/xen/drivers/passthrough/amd/iommu_detect.c b/xen/drivers/passt= hrough/amd/iommu_detect.c index 91f5ea6bff..3b36827c14 100644 --- a/xen/drivers/passthrough/amd/iommu_detect.c +++ b/xen/drivers/passthrough/amd/iommu_detect.c @@ -30,7 +30,7 @@ static int __init get_iommu_msi_capabilities( { int pos; =20 - pos =3D pci_find_cap_offset(seg, bus, dev, func, PCI_CAP_ID_MSI); + pos =3D pci_find_cap_offset(PCI_SBDF_T(seg, bus, dev, func), PCI_CAP_I= D_MSI); =20 if ( !pos ) return -ENODEV; diff --git a/xen/drivers/passthrough/ats.h b/xen/drivers/passthrough/ats.h index e83a45d16e..3b996c748a 100644 --- a/xen/drivers/passthrough/ats.h +++ b/xen/drivers/passthrough/ats.h @@ -31,11 +31,16 @@ static inline int pci_ats_enabled(int seg, int bus, int= devfn) { u32 value; int pos; + const pci_sbdf_t sbdf =3D { + .seg =3D seg, + .bus =3D bus, + .extfunc =3D devfn, + }; =20 - pos =3D pci_find_ext_capability(seg, bus, devfn, PCI_EXT_CAP_ID_ATS); + pos =3D pci_find_ext_capability(sbdf, PCI_EXT_CAP_ID_ATS); BUG_ON(!pos); =20 - value =3D pci_conf_read16(PCI_SBDF3_T(seg, bus, devfn), pos + ATS_REG_= CTL); + value =3D pci_conf_read16(sbdf, pos + ATS_REG_CTL); =20 return value & ATS_ENABLE; } @@ -45,7 +50,8 @@ static inline int pci_ats_device(int seg, int bus, int de= vfn) if ( !ats_enabled ) return 0; =20 - return pci_find_ext_capability(seg, bus, devfn, PCI_EXT_CAP_ID_ATS); + return pci_find_ext_capability(PCI_SBDF3_T(seg, bus, devfn), + PCI_EXT_CAP_ID_ATS); } =20 #endif /* _ATS_H_ */ diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c index a9667ca21c..cfe2dda733 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -332,8 +332,7 @@ static struct pci_dev *alloc_pdev(struct pci_seg *pseg,= u8 bus, u8 devfn) pdev->domain =3D NULL; INIT_LIST_HEAD(&pdev->msi_list); =20 - if ( pci_find_cap_offset(pseg->nr, bus, PCI_SLOT(devfn), PCI_FUNC(devf= n), - PCI_CAP_ID_MSIX) ) + if ( pci_find_cap_offset(pdev->sbdf, PCI_CAP_ID_MSIX) ) { struct arch_msix *msix =3D xzalloc(struct arch_msix); =20 @@ -371,8 +370,7 @@ static struct pci_dev *alloc_pdev(struct pci_seg *pseg,= u8 bus, u8 devfn) break; =20 case DEV_TYPE_PCIe_ENDPOINT: - pos =3D pci_find_cap_offset(pseg->nr, bus, PCI_SLOT(devfn), - PCI_FUNC(devfn), PCI_CAP_ID_EXP); + pos =3D pci_find_cap_offset(pdev->sbdf, PCI_CAP_ID_EXP); BUG_ON(!pos); cap =3D pci_conf_read16(pdev->sbdf, pos + PCI_EXP_DEVCAP); if ( cap & PCI_EXP_DEVCAP_PHANTOM ) @@ -585,13 +583,12 @@ struct pci_dev *pci_get_pdev_by_domain(const struct d= omain *d, int seg, static void pci_enable_acs(struct pci_dev *pdev) { int pos; - uint16_t cap, ctrl, seg =3D pdev->sbdf.seg; - uint8_t bus =3D pdev->sbdf.bus; + uint16_t cap, ctrl; =20 if ( !iommu_enabled ) return; =20 - pos =3D pci_find_ext_capability(seg, bus, pdev->sbdf.extfunc, PCI_EXT_= CAP_ID_ACS); + pos =3D pci_find_ext_capability(pdev->sbdf, PCI_EXT_CAP_ID_ACS); if (!pos) return; =20 @@ -722,7 +719,7 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn, =20 if ( !pdev->info.is_virtfn && !pdev->vf_rlen[0] ) { - unsigned int pos =3D pci_find_ext_capability(seg, bus, devfn, + unsigned int pos =3D pci_find_ext_capability(pdev->sbdf, PCI_EXT_CAP_ID_SRIOV); u16 ctrl =3D pci_conf_read16(pdev->sbdf, pos + PCI_SRIOV_CTRL); =20 @@ -907,13 +904,13 @@ enum pdev_type pdev_type(u16 seg, u8 bus, u8 devfn) { u16 class_device, creg; u8 d =3D PCI_SLOT(devfn), f =3D PCI_FUNC(devfn); - int pos =3D pci_find_cap_offset(seg, bus, d, f, PCI_CAP_ID_EXP); const pci_sbdf_t sbdf =3D { .seg =3D seg, .bus =3D bus, .dev =3D d, .func =3D f, }; + int pos =3D pci_find_cap_offset(sbdf, PCI_CAP_ID_EXP); =20 class_device =3D pci_conf_read16(sbdf, PCI_CLASS_DEVICE); switch ( class_device ) @@ -1177,9 +1174,7 @@ static int hest_match_pci(const struct acpi_hest_aer_= common *p, static bool_t hest_match_type(const struct acpi_hest_header *hest_hdr, const struct pci_dev *pdev) { - unsigned int pos =3D pci_find_cap_offset(pdev->sbdf.seg, pdev->sbdf.bu= s, - pdev->sbdf.dev, pdev->sbdf.func, - PCI_CAP_ID_EXP); + unsigned int pos =3D pci_find_cap_offset(pdev->sbdf, PCI_CAP_ID_EXP); uint8_t pcie =3D MASK_EXTR(pci_conf_read16(pdev->sbdf, pos + PCI_EXP_F= LAGS), PCI_EXP_FLAGS_TYPE); =20 @@ -1249,8 +1244,7 @@ bool_t pcie_aer_get_firmware_first(const struct pci_d= ev *pdev) { struct aer_hest_parse_info info =3D { .pdev =3D pdev }; =20 - return pci_find_cap_offset(pdev->sbdf.seg, pdev->sbdf.bus, pdev->sbdf.= dev, - pdev->sbdf.func, PCI_CAP_ID_EXP) && + return pci_find_cap_offset(pdev->sbdf, PCI_CAP_ID_EXP) && apei_hest_parse(aer_hest_parse, &info) >=3D 0 && info.firmware_first; } diff --git a/xen/drivers/passthrough/vtd/quirks.c b/xen/drivers/passthrough= /vtd/quirks.c index 0302c503fb..289d43f0fe 100644 --- a/xen/drivers/passthrough/vtd/quirks.c +++ b/xen/drivers/passthrough/vtd/quirks.c @@ -426,8 +426,6 @@ int me_wifi_quirk(struct domain *domain, u8 bus, u8 dev= fn, int map) =20 void pci_vtd_quirk(const struct pci_dev *pdev) { - int seg =3D pdev->sbdf.seg; - int bus =3D pdev->sbdf.bus; int pos; bool_t ff; u32 val, val2; @@ -464,12 +462,10 @@ void pci_vtd_quirk(const struct pci_dev *pdev) /* Sandybridge-EP (Romley) */ case 0x3c00: /* host bridge */ case 0x3c01 ... 0x3c0b: /* root ports */ - pos =3D pci_find_ext_capability(seg, bus, pdev->sbdf.extfunc, - PCI_EXT_CAP_ID_ERR); + pos =3D pci_find_ext_capability(pdev->sbdf, PCI_EXT_CAP_ID_ERR); if ( !pos ) { - pos =3D pci_find_ext_capability(seg, bus, pdev->sbdf.extfunc, - PCI_EXT_CAP_ID_VNDR); + pos =3D pci_find_ext_capability(pdev->sbdf, PCI_EXT_CAP_ID_VND= R); while ( pos ) { val =3D pci_conf_read32(pdev->sbdf, pos + PCI_VNDR_HEADER); @@ -478,8 +474,8 @@ void pci_vtd_quirk(const struct pci_dev *pdev) pos +=3D PCI_VNDR_HEADER; break; } - pos =3D pci_find_next_ext_capability(seg, bus, pdev->sbdf.= extfunc, - pos, PCI_EXT_CAP_ID_VND= R); + pos =3D pci_find_next_ext_capability(pdev->sbdf, pos, + PCI_EXT_CAP_ID_VNDR); } ff =3D 0; } diff --git a/xen/drivers/passthrough/vtd/x86/ats.c b/xen/drivers/passthroug= h/vtd/x86/ats.c index e0904df5b6..260b06a856 100644 --- a/xen/drivers/passthrough/vtd/x86/ats.c +++ b/xen/drivers/passthrough/vtd/x86/ats.c @@ -57,8 +57,7 @@ int ats_device(const struct pci_dev *pdev, const struct a= cpi_drhd_unit *drhd) return 0; =20 ats_drhd =3D find_ats_dev_drhd(drhd->iommu); - pos =3D pci_find_ext_capability(pdev->sbdf.seg, pdev->sbdf.bus, - pdev->sbdf.extfunc, PCI_EXT_CAP_ID_ATS); + pos =3D pci_find_ext_capability(pdev->sbdf, PCI_EXT_CAP_ID_ATS); =20 if ( pos && (ats_drhd =3D=3D NULL) ) { diff --git a/xen/drivers/passthrough/x86/ats.c b/xen/drivers/passthrough/x8= 6/ats.c index cfd610229d..bfbd50100a 100644 --- a/xen/drivers/passthrough/x86/ats.c +++ b/xen/drivers/passthrough/x86/ats.c @@ -23,11 +23,9 @@ boolean_param("ats", ats_enabled); int enable_ats_device(struct pci_dev *pdev, struct list_head *ats_list) { u32 value; - uint16_t seg =3D pdev->sbdf.seg; - uint16_t bus =3D pdev->sbdf.bus, devfn =3D pdev->sbdf.extfunc; int pos; =20 - pos =3D pci_find_ext_capability(seg, bus, devfn, PCI_EXT_CAP_ID_ATS); + pos =3D pci_find_ext_capability(pdev->sbdf, PCI_EXT_CAP_ID_ATS); BUG_ON(!pos); =20 if ( iommu_verbose ) diff --git a/xen/drivers/pci/pci.c b/xen/drivers/pci/pci.c index 3d2acf6f77..e902a0aace 100644 --- a/xen/drivers/pci/pci.c +++ b/xen/drivers/pci/pci.c @@ -8,18 +8,12 @@ #include #include =20 -int pci_find_cap_offset(u16 seg, u8 bus, u8 dev, u8 func, u8 cap) +int pci_find_cap_offset(pci_sbdf_t sbdf, unsigned int cap) { u8 id; int max_cap =3D 48; u8 pos =3D PCI_CAPABILITY_LIST; u16 status; - const pci_sbdf_t sbdf =3D { - .seg =3D seg, - .bus =3D bus, - .dev =3D dev, - .func =3D func, - }; =20 status =3D pci_conf_read16(sbdf, PCI_STATUS); if ( (status & PCI_STATUS_CAP_LIST) =3D=3D 0 ) @@ -45,15 +39,10 @@ int pci_find_cap_offset(u16 seg, u8 bus, u8 dev, u8 fun= c, u8 cap) return 0; } =20 -int pci_find_next_cap(u16 seg, u8 bus, unsigned int devfn, u8 pos, int cap) +int pci_find_next_cap(pci_sbdf_t sbdf, unsigned int pos, unsigned int cap) { u8 id; int ttl =3D 48; - const pci_sbdf_t sbdf =3D { - .seg =3D seg, - .bus =3D bus, - .extfunc =3D devfn, - }; =20 while ( ttl-- ) { @@ -83,9 +72,9 @@ int pci_find_next_cap(u16 seg, u8 bus, unsigned int devfn= , u8 pos, int cap) * within the device's PCI configuration space or 0 if the device does * not support it. */ -int pci_find_ext_capability(int seg, int bus, int devfn, int cap) +int pci_find_ext_capability(pci_sbdf_t sbdf, unsigned int cap) { - return pci_find_next_ext_capability(seg, bus, devfn, 0, cap); + return pci_find_next_ext_capability(sbdf, 0, cap); } =20 /** @@ -98,15 +87,11 @@ int pci_find_ext_capability(int seg, int bus, int devfn= , int cap) * within the device's PCI configuration space or 0 if the device does * not support it. */ -int pci_find_next_ext_capability(int seg, int bus, int devfn, int start, i= nt cap) +int pci_find_next_ext_capability(pci_sbdf_t sbdf, unsigned int start, + unsigned int cap) { - int ttl =3D 480; /* 3840 bytes, minimum 8 bytes per capability */ - int pos =3D max(start, 0x100); - const pci_sbdf_t sbdf =3D { - .seg =3D seg, - .bus =3D bus, - .extfunc =3D devfn, - }; + unsigned int ttl =3D 480; /* 3840 bytes, minimum 8 bytes per capabilit= y */ + unsigned int pos =3D max(start, 0x100u); uint32_t header =3D pci_conf_read32(sbdf, pos); =20 /* diff --git a/xen/drivers/vpci/msi.c b/xen/drivers/vpci/msi.c index 2bdae48edf..2a366828a1 100644 --- a/xen/drivers/vpci/msi.c +++ b/xen/drivers/vpci/msi.c @@ -185,9 +185,7 @@ static void mask_write(const struct pci_dev *pdev, unsi= gned int reg, =20 static int init_msi(struct pci_dev *pdev) { - unsigned int pos =3D pci_find_cap_offset(pdev->sbdf.seg, pdev->sbdf.bu= s, - pdev->sbdf.dev, pdev->sbdf.func, - PCI_CAP_ID_MSI); + unsigned int pos =3D pci_find_cap_offset(pdev->sbdf, PCI_CAP_ID_MSI); uint16_t control; int ret; =20 diff --git a/xen/drivers/vpci/msix.c b/xen/drivers/vpci/msix.c index 1006b01f4b..44dbb086fd 100644 --- a/xen/drivers/vpci/msix.c +++ b/xen/drivers/vpci/msix.c @@ -445,9 +445,7 @@ static int init_msix(struct pci_dev *pdev) uint16_t control; int rc; =20 - msix_offset =3D pci_find_cap_offset(pdev->sbdf.seg, pdev->sbdf.bus, - pdev->sbdf.dev, pdev->sbdf.func, - PCI_CAP_ID_MSIX); + msix_offset =3D pci_find_cap_offset(pdev->sbdf, PCI_CAP_ID_MSIX); if ( !msix_offset ) return 0; =20 diff --git a/xen/include/xen/pci.h b/xen/include/xen/pci.h index 5e345c417f..937465f5b5 100644 --- a/xen/include/xen/pci.h +++ b/xen/include/xen/pci.h @@ -178,10 +178,11 @@ int pci_mmcfg_read(unsigned int seg, unsigned int bus, unsigned int devfn, int reg, int len, u32 *value); int pci_mmcfg_write(unsigned int seg, unsigned int bus, unsigned int devfn, int reg, int len, u32 value); -int pci_find_cap_offset(u16 seg, u8 bus, u8 dev, u8 func, u8 cap); -int pci_find_next_cap(u16 seg, u8 bus, unsigned int devfn, u8 pos, int cap= ); -int pci_find_ext_capability(int seg, int bus, int devfn, int cap); -int pci_find_next_ext_capability(int seg, int bus, int devfn, int pos, int= cap); +int pci_find_cap_offset(pci_sbdf_t sbdf, unsigned int cap); +int pci_find_next_cap(pci_sbdf_t sbdf, unsigned int pos, unsigned int cap); +int pci_find_ext_capability(pci_sbdf_t sbdf, unsigned int cap); +int pci_find_next_ext_capability(pci_sbdf_t sbdf, unsigned int pos, + unsigned int cap); const char *parse_pci(const char *, unsigned int *seg, unsigned int *bus, unsigned int *dev, unsigned int *func); const char *parse_pci_seg(const char *, unsigned int *seg, unsigned int *b= us, --=20 2.17.2 (Apple Git-113) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel