Message ID | 20190607092232.83179-2-roger.pau@citrix.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | pci: expand usage of pci_sbdf_t | expand |
> -----Original Message----- > From: Roger Pau Monne [mailto:roger.pau@citrix.com] > Sent: 07 June 2019 10:22 > To: xen-devel@lists.xenproject.org > Cc: Roger Pau Monne <roger.pau@citrix.com>; Paul Durrant <Paul.Durrant@citrix.com>; Jan Beulich > <jbeulich@suse.com>; Andrew Cooper <Andrew.Cooper3@citrix.com>; George Dunlap > <George.Dunlap@citrix.com>; Ian Jackson <Ian.Jackson@citrix.com>; Julien Grall <julien.grall@arm.com>; > Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>; Stefano Stabellini <sstabellini@kernel.org>; Tim > (Xen.org) <tim@xen.org>; Wei Liu <wl@xen.org> > Subject: [PATCH v3 01/13] pci: rename func field to fn > > In preparation for adding a devfn field. This makes the naming more > consistent, as the devfn field encloses both the dev and the fn > fields. > > No functional change intended. > > Requested-by: Paul Durrant <paul.durrant@citrix.com> > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Reviewed-by: Paul Durrant <paul.durrant@citrix.com> > --- > Cc: Jan Beulich <jbeulich@suse.com> > Cc: Andrew Cooper <andrew.cooper3@citrix.com> > Cc: George Dunlap <George.Dunlap@eu.citrix.com> > Cc: Ian Jackson <ian.jackson@eu.citrix.com> > Cc: Julien Grall <julien.grall@arm.com> > Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> > Cc: Stefano Stabellini <sstabellini@kernel.org> > Cc: Tim Deegan <tim@xen.org> > Cc: Wei Liu <wl@xen.org> > --- > Changes since v2: > - New in this version. > --- > xen/drivers/passthrough/pci.c | 18 +++++++++--------- > xen/drivers/vpci/vpci.c | 28 ++++++++++++++-------------- > xen/include/xen/pci.h | 2 +- > 3 files changed, 24 insertions(+), 24 deletions(-) > > diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c > index 20bfa971a9..535c7e511b 100644 > --- a/xen/drivers/passthrough/pci.c > +++ b/xen/drivers/passthrough/pci.c > @@ -644,7 +644,7 @@ unsigned int pci_size_mem_bar(pci_sbdf_t sbdf, unsigned int pos, > unsigned int flags) > { > uint32_t hi = 0, bar = pci_conf_read32(sbdf.seg, sbdf.bus, sbdf.dev, > - sbdf.func, pos); > + sbdf.fn, pos); > uint64_t size; > bool is64bits = !(flags & PCI_BAR_ROM) && > (bar & PCI_BASE_ADDRESS_MEM_TYPE_MASK) == PCI_BASE_ADDRESS_MEM_TYPE_64; > @@ -654,7 +654,7 @@ unsigned int pci_size_mem_bar(pci_sbdf_t sbdf, unsigned int pos, > ASSERT(!((flags & PCI_BAR_VF) && (flags & PCI_BAR_ROM))); > ASSERT((flags & PCI_BAR_ROM) || > (bar & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_MEMORY); > - pci_conf_write32(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, pos, ~0); > + pci_conf_write32(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, pos, ~0); > if ( is64bits ) > { > if ( flags & PCI_BAR_LAST ) > @@ -662,24 +662,24 @@ unsigned int pci_size_mem_bar(pci_sbdf_t sbdf, unsigned int pos, > printk(XENLOG_WARNING > "%sdevice %04x:%02x:%02x.%u with 64-bit %sBAR in last slot\n", > (flags & PCI_BAR_VF) ? "SR-IOV " : "", sbdf.seg, sbdf.bus, > - sbdf.dev, sbdf.func, (flags & PCI_BAR_VF) ? "vf " : ""); > + sbdf.dev, sbdf.fn, (flags & PCI_BAR_VF) ? "vf " : ""); > *psize = 0; > return 1; > } > - hi = pci_conf_read32(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, pos + 4); > - pci_conf_write32(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, pos + 4, ~0); > + hi = pci_conf_read32(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, pos + 4); > + pci_conf_write32(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, pos + 4, ~0); > } > - size = pci_conf_read32(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, > + size = pci_conf_read32(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, > pos) & mask; > if ( is64bits ) > { > size |= (uint64_t)pci_conf_read32(sbdf.seg, sbdf.bus, sbdf.dev, > - sbdf.func, pos + 4) << 32; > - pci_conf_write32(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, pos + 4, hi); > + sbdf.fn, pos + 4) << 32; > + pci_conf_write32(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, pos + 4, hi); > } > else if ( size ) > size |= (uint64_t)~0 << 32; > - pci_conf_write32(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, pos, bar); > + pci_conf_write32(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, pos, bar); > size = -size; > > if ( paddr ) > diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c > index 82607bdb9a..b03232fe30 100644 > --- a/xen/drivers/vpci/vpci.c > +++ b/xen/drivers/vpci/vpci.c > @@ -212,7 +212,7 @@ static uint32_t vpci_read_hw(pci_sbdf_t sbdf, unsigned int reg, > switch ( size ) > { > case 4: > - data = pci_conf_read32(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, reg); > + data = pci_conf_read32(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, reg); > break; > > case 3: > @@ -222,26 +222,26 @@ static uint32_t vpci_read_hw(pci_sbdf_t sbdf, unsigned int reg, > */ > if ( reg & 1 ) > { > - data = pci_conf_read8(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, > + data = pci_conf_read8(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, > reg); > - data |= pci_conf_read16(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, > + data |= pci_conf_read16(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, > reg + 1) << 8; > } > else > { > - data = pci_conf_read16(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, > + data = pci_conf_read16(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, > reg); > - data |= pci_conf_read8(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, > + data |= pci_conf_read8(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, > reg + 2) << 16; > } > break; > > case 2: > - data = pci_conf_read16(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, reg); > + data = pci_conf_read16(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, reg); > break; > > case 1: > - data = pci_conf_read8(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, reg); > + data = pci_conf_read8(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, reg); > break; > > default: > @@ -259,7 +259,7 @@ static void vpci_write_hw(pci_sbdf_t sbdf, unsigned int reg, unsigned int size, > switch ( size ) > { > case 4: > - pci_conf_write32(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, reg, data); > + pci_conf_write32(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, reg, data); > break; > > case 3: > @@ -269,26 +269,26 @@ static void vpci_write_hw(pci_sbdf_t sbdf, unsigned int reg, unsigned int size, > */ > if ( reg & 1 ) > { > - pci_conf_write8(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, reg, > + pci_conf_write8(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, reg, > data); > - pci_conf_write16(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, reg + 1, > + pci_conf_write16(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, reg + 1, > data >> 8); > } > else > { > - pci_conf_write16(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, reg, > + pci_conf_write16(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, reg, > data); > - pci_conf_write8(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, reg + 2, > + pci_conf_write8(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, reg + 2, > data >> 16); > } > break; > > case 2: > - pci_conf_write16(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, reg, data); > + pci_conf_write16(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, reg, data); > break; > > case 1: > - pci_conf_write8(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, reg, data); > + pci_conf_write8(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, reg, data); > break; > > default: > diff --git a/xen/include/xen/pci.h b/xen/include/xen/pci.h > index 53f50d89e7..dab1a86dd4 100644 > --- a/xen/include/xen/pci.h > +++ b/xen/include/xen/pci.h > @@ -46,7 +46,7 @@ typedef union { > struct { > union { > struct { > - uint8_t func : 3, > + uint8_t fn : 3, > dev : 5; > }; > uint8_t extfunc; > -- > 2.20.1 (Apple Git-117)
>>> On 07.06.19 at 11:22, <roger.pau@citrix.com> wrote: > In preparation for adding a devfn field. This makes the naming more > consistent, as the devfn field encloses both the dev and the fn > fields. > > No functional change intended. > > Requested-by: Paul Durrant <paul.durrant@citrix.com> > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Acked-by: Jan Beulich <jbeulich@suse.com>
diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c index 20bfa971a9..535c7e511b 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -644,7 +644,7 @@ unsigned int pci_size_mem_bar(pci_sbdf_t sbdf, unsigned int pos, unsigned int flags) { uint32_t hi = 0, bar = pci_conf_read32(sbdf.seg, sbdf.bus, sbdf.dev, - sbdf.func, pos); + sbdf.fn, pos); uint64_t size; bool is64bits = !(flags & PCI_BAR_ROM) && (bar & PCI_BASE_ADDRESS_MEM_TYPE_MASK) == PCI_BASE_ADDRESS_MEM_TYPE_64; @@ -654,7 +654,7 @@ unsigned int pci_size_mem_bar(pci_sbdf_t sbdf, unsigned int pos, ASSERT(!((flags & PCI_BAR_VF) && (flags & PCI_BAR_ROM))); ASSERT((flags & PCI_BAR_ROM) || (bar & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_MEMORY); - pci_conf_write32(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, pos, ~0); + pci_conf_write32(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, pos, ~0); if ( is64bits ) { if ( flags & PCI_BAR_LAST ) @@ -662,24 +662,24 @@ unsigned int pci_size_mem_bar(pci_sbdf_t sbdf, unsigned int pos, printk(XENLOG_WARNING "%sdevice %04x:%02x:%02x.%u with 64-bit %sBAR in last slot\n", (flags & PCI_BAR_VF) ? "SR-IOV " : "", sbdf.seg, sbdf.bus, - sbdf.dev, sbdf.func, (flags & PCI_BAR_VF) ? "vf " : ""); + sbdf.dev, sbdf.fn, (flags & PCI_BAR_VF) ? "vf " : ""); *psize = 0; return 1; } - hi = pci_conf_read32(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, pos + 4); - pci_conf_write32(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, pos + 4, ~0); + hi = pci_conf_read32(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, pos + 4); + pci_conf_write32(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, pos + 4, ~0); } - size = pci_conf_read32(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, + size = pci_conf_read32(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, pos) & mask; if ( is64bits ) { size |= (uint64_t)pci_conf_read32(sbdf.seg, sbdf.bus, sbdf.dev, - sbdf.func, pos + 4) << 32; - pci_conf_write32(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, pos + 4, hi); + sbdf.fn, pos + 4) << 32; + pci_conf_write32(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, pos + 4, hi); } else if ( size ) size |= (uint64_t)~0 << 32; - pci_conf_write32(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, pos, bar); + pci_conf_write32(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, pos, bar); size = -size; if ( paddr ) diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c index 82607bdb9a..b03232fe30 100644 --- a/xen/drivers/vpci/vpci.c +++ b/xen/drivers/vpci/vpci.c @@ -212,7 +212,7 @@ static uint32_t vpci_read_hw(pci_sbdf_t sbdf, unsigned int reg, switch ( size ) { case 4: - data = pci_conf_read32(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, reg); + data = pci_conf_read32(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, reg); break; case 3: @@ -222,26 +222,26 @@ static uint32_t vpci_read_hw(pci_sbdf_t sbdf, unsigned int reg, */ if ( reg & 1 ) { - data = pci_conf_read8(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, + data = pci_conf_read8(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, reg); - data |= pci_conf_read16(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, + data |= pci_conf_read16(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, reg + 1) << 8; } else { - data = pci_conf_read16(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, + data = pci_conf_read16(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, reg); - data |= pci_conf_read8(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, + data |= pci_conf_read8(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, reg + 2) << 16; } break; case 2: - data = pci_conf_read16(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, reg); + data = pci_conf_read16(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, reg); break; case 1: - data = pci_conf_read8(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, reg); + data = pci_conf_read8(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, reg); break; default: @@ -259,7 +259,7 @@ static void vpci_write_hw(pci_sbdf_t sbdf, unsigned int reg, unsigned int size, switch ( size ) { case 4: - pci_conf_write32(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, reg, data); + pci_conf_write32(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, reg, data); break; case 3: @@ -269,26 +269,26 @@ static void vpci_write_hw(pci_sbdf_t sbdf, unsigned int reg, unsigned int size, */ if ( reg & 1 ) { - pci_conf_write8(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, reg, + pci_conf_write8(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, reg, data); - pci_conf_write16(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, reg + 1, + pci_conf_write16(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, reg + 1, data >> 8); } else { - pci_conf_write16(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, reg, + pci_conf_write16(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, reg, data); - pci_conf_write8(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, reg + 2, + pci_conf_write8(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, reg + 2, data >> 16); } break; case 2: - pci_conf_write16(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, reg, data); + pci_conf_write16(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, reg, data); break; case 1: - pci_conf_write8(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.func, reg, data); + pci_conf_write8(sbdf.seg, sbdf.bus, sbdf.dev, sbdf.fn, reg, data); break; default: diff --git a/xen/include/xen/pci.h b/xen/include/xen/pci.h index 53f50d89e7..dab1a86dd4 100644 --- a/xen/include/xen/pci.h +++ b/xen/include/xen/pci.h @@ -46,7 +46,7 @@ typedef union { struct { union { struct { - uint8_t func : 3, + uint8_t fn : 3, dev : 5; }; uint8_t extfunc;
In preparation for adding a devfn field. This makes the naming more consistent, as the devfn field encloses both the dev and the fn fields. No functional change intended. Requested-by: Paul Durrant <paul.durrant@citrix.com> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> --- Cc: Jan Beulich <jbeulich@suse.com> Cc: Andrew Cooper <andrew.cooper3@citrix.com> Cc: George Dunlap <George.Dunlap@eu.citrix.com> Cc: Ian Jackson <ian.jackson@eu.citrix.com> Cc: Julien Grall <julien.grall@arm.com> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Cc: Stefano Stabellini <sstabellini@kernel.org> Cc: Tim Deegan <tim@xen.org> Cc: Wei Liu <wl@xen.org> --- Changes since v2: - New in this version. --- xen/drivers/passthrough/pci.c | 18 +++++++++--------- xen/drivers/vpci/vpci.c | 28 ++++++++++++++-------------- xen/include/xen/pci.h | 2 +- 3 files changed, 24 insertions(+), 24 deletions(-)