[PATCH v1 07/11] tests/functional/test_arm_aspeed_ast2600: Add PCIe test via root port and e1000e

Jamin Lin via posted 11 patches 2 months, 3 weeks ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, "Cédric Le Goater" <clg@kaod.org>, Steven Lee <steven_lee@aspeedtech.com>, Troy Lee <leetroy@gmail.com>, Jamin Lin <jamin_lin@aspeedtech.com>, Andrew Jeffery <andrew@codeconstruct.com.au>, Joel Stanley <joel@jms.id.au>, "Michael S. Tsirkin" <mst@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
There is a newer version of this series
[PATCH v1 07/11] tests/functional/test_arm_aspeed_ast2600: Add PCIe test via root port and e1000e
Posted by Jamin Lin via 2 months, 3 weeks ago
Add a functional test that exercises the AST2600 PCIe RC_H by creating a
root port and an e1000e endpoint behind it. The AST2600/ASPEED driver
treats root bus 0x80 specially: only two device addresses are usable on
the root bus, addr 0 (ASPEED host bridge) and addr 8. To attach endpoints
without code changes, the test places a QEMU PCIe root port at 0x80:08.0
and hangs e1000e behind it so the endpoint enumerates on bus 0x81.

The test appends:
-device pcie-root-port,id=root_port0,slot=1,addr=8,bus=pcie.0
-device e1000e,netdev=net0,bus=root_port0
-netdev user,id=net0

It then verifies enumeration with lspci:
0001:80:00.0 Host bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge
0001:80:08.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
0001:81:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network
Connection

This is a temporary solution that allows attaching multiple PCIe
devices while the ASPEED drivers does not support placing endpoints directly
on bus numbers 0x80.

Reference:
https://github.com/AspeedTech-BMC/linux/blob/aspeed-master-v6.6/drivers/pci/controller/pcie-aspeed.c#L309

Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
---
 tests/functional/test_arm_aspeed_ast2600.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/tests/functional/test_arm_aspeed_ast2600.py b/tests/functional/test_arm_aspeed_ast2600.py
index fdae4c939d..9ffcef513d 100755
--- a/tests/functional/test_arm_aspeed_ast2600.py
+++ b/tests/functional/test_arm_aspeed_ast2600.py
@@ -110,6 +110,10 @@ def test_arm_ast2600_evb_sdk(self):
             'tmp105,bus=aspeed.i2c.bus.5,address=0x4d,id=tmp-test')
         self.vm.add_args('-device',
             'ds1338,bus=aspeed.i2c.bus.5,address=0x32')
+        self.vm.add_args('-device',
+            'pcie-root-port,id=root_port0,slot=1,addr=8,bus=pcie.0')
+        self.vm.add_args('-device', 'e1000e,netdev=net0,bus=root_port0')
+        self.vm.add_args('-netdev', 'user,id=net0')
         self.do_test_arm_aspeed_sdk_start(
             self.scratch_file("ast2600-default", "image-bmc"))
 
@@ -136,5 +140,15 @@ def test_arm_ast2600_evb_sdk(self):
         exec_command_and_wait_for_pattern(self,
              '/sbin/hwclock -f /dev/rtc1', year)
 
+        exec_command_and_wait_for_pattern(self,
+            'lspci -s 0001:80:00.0',
+            '0001:80:00.0 Host bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge')
+        exec_command_and_wait_for_pattern(self,
+            'lspci -s 0001:80:08.0',
+            '0001:80:08.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port')
+        exec_command_and_wait_for_pattern(self,
+            'lspci -s 0001:81:00.0',
+            '0001:81:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection')
+
 if __name__ == '__main__':
     AspeedTest.main()
-- 
2.43.0