bus/pci: use Linux PCI sysfs to get PIO address
authorHuawei Xie <huawei.xhw@alibaba-inc.com>
Wed, 10 Mar 2021 17:36:29 +0000 (01:36 +0800)
committerDavid Marchand <david.marchand@redhat.com>
Mon, 15 Mar 2021 14:13:29 +0000 (15:13 +0100)
commit46dcbccd3a2715fb2059c51544722aabd2fe40f7
tree4a0305a9d9396bde8bb90fcf118818f6d209f1a8
parentc8238116ece889fe356c54930bca791091ab1938
bus/pci: use Linux PCI sysfs to get PIO address

Currently virtio PMD assumes legacy device uses PIO bar.
There are three ways to get PIO (port-mapped I/O) address for virtio
legacy device.
1) under igb_uio
   - get PIO address from uio/uio# sysfs attribute, for instance:
     /sys/bus/pci/devices/0000:00:09.0/uio/uio0/portio/port0/start
2) under uio_pci_generic
   - for X86, get PIO address from /proc/ioport
   - for other ARCH, get PIO address from standard PCI sysfs attribute,
     for instance: /sys/bus/pci/devices/0000:00:09.0/resource

Actually, "port0/start" in igb_uio and "resource" point to exactly the
same thing, i.e, pci_dev->resource[0] in kernel source code.

This patch refactors these messy things, and uses standard PCI sysfs
attribute "resource".

Signed-off-by: Huawei Xie <huawei.xhw@alibaba-inc.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Tested-by: Yinan Wang <yinan.wang@intel.com>
drivers/bus/pci/linux/pci.c
drivers/bus/pci/linux/pci_uio.c