@@ -73,6 +73,7 @@ SRCS-y += test_resource.c
$(eval $(call linked_resource,test_resource_c,resource.c))
$(eval $(call linked_tar_resource,test_resource_tar,test_resource.c))
SRCS-y += test_pci.c
+$(eval $(call linked_tar_resource,test_pci_sysfs,test_pci_sysfs))
SRCS-y += test_prefetch.c
SRCS-y += test_byteorder.c
SRCS-y += test_per_lcore.c
@@ -43,6 +43,7 @@
#include <rte_devargs.h>
#include "test.h"
+#include "resource.h"
/* Generic maximum number of drivers to have room to allocate all drivers */
#define NUM_MAX_DRIVERS 256
@@ -215,37 +216,88 @@ static int test_pci_sysfs(void)
return 0;
}
-/* real drivers (not used for testing) */
+/* real devices & drivers (not used for testing) */
struct pci_driver_list real_pci_driver_list =
TAILQ_HEAD_INITIALIZER(real_pci_driver_list);
+struct pci_device_list real_pci_device_list =
+ TAILQ_HEAD_INITIALIZER(real_pci_device_list);
+
+REGISTER_LINKED_RESOURCE(test_pci_sysfs);
static int
test_pci_setup(void)
{
+ struct rte_pci_device *dev;
struct rte_pci_driver *dr;
+ const struct resource *r;
+ int ret;
+
+ r = resource_find("test_pci_sysfs");
+ TEST_ASSERT_NOT_NULL(r, "missing resource test_pci_sysfs");
+
+ ret = resource_untar(r);
+ TEST_ASSERT_SUCCESS(ret, "failed to untar %s", r->name);
+
+ ret = setenv("SYSFS_PCI_DEVICES", "test_pci_sysfs/bus/pci/devices", 1);
+ TEST_ASSERT_SUCCESS(ret, "failed to setenv");
- /* Unregister original driver list */
+ /* Unregister original devices & drivers lists */
while (!TAILQ_EMPTY(&pci_driver_list)) {
dr = TAILQ_FIRST(&pci_driver_list);
rte_eal_pci_unregister(dr);
TAILQ_INSERT_TAIL(&real_pci_driver_list, dr, next);
}
+ while (!TAILQ_EMPTY(&pci_device_list)) {
+ dev = TAILQ_FIRST(&pci_device_list);
+ TAILQ_REMOVE(&pci_device_list, dev, next);
+ TAILQ_INSERT_TAIL(&real_pci_device_list, dev, next);
+ }
+
+ ret = rte_eal_pci_scan();
+ TEST_ASSERT_SUCCESS(ret, "failed to scan PCI bus");
+ rte_eal_pci_dump(stdout);
+
return 0;
}
static int
test_pci_cleanup(void)
{
+ struct rte_pci_device *dev;
struct rte_pci_driver *dr;
+ const struct resource *r;
+ int ret;
+
+ unsetenv("SYSFS_PCI_DEVICES");
+
+ r = resource_find("test_pci_sysfs");
+ TEST_ASSERT_NOT_NULL(r, "missing resource test_pci_sysfs");
+
+ ret = resource_rm_by_tar(r);
+ TEST_ASSERT_SUCCESS(ret, "Failed to delete resource %s", r->name);
- /* Restore original driver list */
+ /* FIXME: there is no API in DPDK to free a rte_pci_device so we
+ cannot free the devices in the right way. Let's assume that we
+ don't care for tests. */
+ while (!TAILQ_EMPTY(&pci_device_list)) {
+ dev = TAILQ_FIRST(&pci_device_list);
+ TAILQ_REMOVE(&pci_device_list, dev, next);
+ }
+
+ /* Restore original devices & drivers lists */
while (!TAILQ_EMPTY(&real_pci_driver_list)) {
dr = TAILQ_FIRST(&real_pci_driver_list);
TAILQ_REMOVE(&real_pci_driver_list, dr, next);
rte_eal_pci_register(dr);
}
+ while (!TAILQ_EMPTY(&real_pci_device_list)) {
+ dev = TAILQ_FIRST(&real_pci_device_list);
+ TAILQ_REMOVE(&real_pci_device_list, dev, next);
+ TAILQ_INSERT_TAIL(&pci_device_list, dev, next);
+ }
+
return 0;
}
new file mode 100644
@@ -0,0 +1 @@
+0x020000
new file mode 100644
GIT binary patch
literal 64
zcmZo`_$|QBBEZ1Nz`(@7(7?dMz;S^A2oxWHNCpNT2LUi2#BOU~22l(SV3L7>8>k5Y
DD^Ld(
literal 0
HcmV?d00001
new file mode 100644
@@ -0,0 +1 @@
+64
new file mode 100644
@@ -0,0 +1 @@
+0x10fb
new file mode 100644
@@ -0,0 +1 @@
+64
new file mode 100644
@@ -0,0 +1 @@
+1
new file mode 100644
@@ -0,0 +1 @@
+0
new file mode 100644
@@ -0,0 +1 @@
+pci:v00008086d000010FBsv00008086sd00000003bc02sc00i00
new file mode 100644
@@ -0,0 +1 @@
+1
new file mode 100644
@@ -0,0 +1 @@
+-1
new file mode 100644
@@ -0,0 +1,13 @@
+0x00000000d0080000 0x00000000d00fffff 0x000000000014220c
+0x0000000000000000 0x0000000000000000 0x0000000000000000
+0x000000000000e020 0x000000000000e03f 0x0000000000040101
+0x0000000000000000 0x0000000000000000 0x0000000000000000
+0x00000000d0104000 0x00000000d0107fff 0x000000000014220c
+0x0000000000000000 0x0000000000000000 0x0000000000000000
+0x0000000000000000 0x0000000000000000 0x0000000000000000
+0x00000000ab000000 0x00000000ab0fffff 0x0000000000140204
+0x0000000000000000 0x0000000000000000 0x0000000000000000
+0x0000000000000000 0x0000000000000000 0x0000000000000000
+0x00000000ab100000 0x00000000ab1fffff 0x0000000000140204
+0x0000000000000000 0x0000000000000000 0x0000000000000000
+0x0000000000000000 0x0000000000000000 0x0000000000000000
new file mode 100644
@@ -0,0 +1 @@
+0
new file mode 100644
@@ -0,0 +1 @@
+63
new file mode 100644
@@ -0,0 +1 @@
+0x0003
new file mode 100644
@@ -0,0 +1 @@
+0x8086
new file mode 100644
@@ -0,0 +1,6 @@
+DRIVER=ixgbe
+PCI_CLASS=20000
+PCI_ID=8086:10FB
+PCI_SUBSYS_ID=8086:0003
+PCI_SLOT_NAME=0000:01:00.0
+MODALIAS=pci:v00008086d000010FBsv00008086sd00000003bc02sc00i00
new file mode 100644
@@ -0,0 +1 @@
+0x8086