Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/19766/?format=api
http://patches.dpdk.org/api/patches/19766/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/1484801117-779-11-git-send-email-thomas.monjalon@6wind.com/", "project": { "id": 1, "url": "http://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<1484801117-779-11-git-send-email-thomas.monjalon@6wind.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1484801117-779-11-git-send-email-thomas.monjalon@6wind.com", "date": "2017-01-19T04:45:14", "name": "[dpdk-dev,v11,10/13] app/test: add PCI bus driver", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "68259b2eea6db9d9a2f129bcb35182c8b7cef15f", "submitter": { "id": 1, "url": "http://patches.dpdk.org/api/people/1/?format=api", "name": "Thomas Monjalon", "email": "thomas.monjalon@6wind.com" }, "delegate": { "id": 1, "url": "http://patches.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/1484801117-779-11-git-send-email-thomas.monjalon@6wind.com/mbox/", "series": [], "comments": "http://patches.dpdk.org/api/patches/19766/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/19766/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@dpdk.org", "Delivered-To": "patchwork@dpdk.org", "Received": [ "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 1B308FB4A;\n\tThu, 19 Jan 2017 05:45:56 +0100 (CET)", "from mail-wm0-f44.google.com (mail-wm0-f44.google.com\n\t[74.125.82.44]) by dpdk.org (Postfix) with ESMTP id A941DFB35\n\tfor <dev@dpdk.org>; Thu, 19 Jan 2017 05:45:32 +0100 (CET)", "by mail-wm0-f44.google.com with SMTP id c85so272772453wmi.1\n\tfor <dev@dpdk.org>; Wed, 18 Jan 2017 20:45:32 -0800 (PST)", "from XPS13.localdomain (184.203.134.77.rev.sfr.net.\n\t[77.134.203.184]) by smtp.gmail.com with ESMTPSA id\n\tt194sm2568586wmd.1.2017.01.18.20.45.31\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tWed, 18 Jan 2017 20:45:31 -0800 (PST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=6wind-com.20150623.gappssmtp.com; s=20150623;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=70soUCPcea+hWcXG+sE4imeci8xPI+K/51Rbh5cqJxo=;\n\tb=KgQt7ug8Ka+PpKFA4g0VT79lOGMHZhJWSDJNanbsSoEpqt90EYhFSZbtt4QJdruWP1\n\tZZbB9zIj6sWUTW8Rg72QOz3ORXGHThDIwobZ3KBmyVrDVSzjN1GezjyNuy5tcXaaPUe7\n\t2zGdwfcX4Be8jgK6GwbMkSBK8Oiy+DFyTi9MGk9eIiY+JkbrUcipaA+P7UsT6zEV7cHa\n\tUV6wPx/OpeXJIJ11IePkP7pdJqgdyk3BfmfezNwl1sEgnankVsAaJqTV4fis8xne9Ezu\n\tZkX6gZxzplaN9kEPDWCUx7Y74qsIt1VjwyhXGzdFwzljM+8P31YPIO4enrnKbvyO1dcz\n\t+Prg==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=70soUCPcea+hWcXG+sE4imeci8xPI+K/51Rbh5cqJxo=;\n\tb=CRyxmESzPTtUBNVMjii6yrlqs5A8K6iD+Car9jA2I18ykDwbf8I9POn80SmyDlhUJ4\n\tV6tWhwmDc3S9tTSOgv+t8VqmqpxS5meMQhQkaEEK8BzIX0t/kVDwLtNfgJZlhEGXCT+E\n\t7rJoz3KcNlfiBBHXCGIrcuwZLTbv+S3lC3ZZ3NzVxFUqKunvhosJ7F4Jj26LOcRac3eM\n\tdOivZLWnksHr0PlSy/R5ilVb0kYA5lSB9wpxvIc1Q82Rh9imebdM0++RVa9p5haiMw0c\n\tlDTFQNKgThGUnfUGew/lCW5IpWOmWjOLUkx6mrd6ezKiVQyNpsEkENrosCgoWBbe3LmH\n\tHGOA==", "X-Gm-Message-State": "AIkVDXKu0AwgbnqhH4A9WWclWT68Qg2h0Dm/b43gSscJSWj26AbvidsUkRRVDhJmpJaKrjMF", "X-Received": "by 10.28.21.84 with SMTP id 81mr24346416wmv.106.1484801132322;\n\tWed, 18 Jan 2017 20:45:32 -0800 (PST)", "From": "Thomas Monjalon <thomas.monjalon@6wind.com>", "To": "Shreyansh Jain <shreyansh.jain@nxp.com>", "Cc": "dev@dpdk.org", "Date": "Thu, 19 Jan 2017 05:45:14 +0100", "Message-Id": "<1484801117-779-11-git-send-email-thomas.monjalon@6wind.com>", "X-Mailer": "git-send-email 2.7.0", "In-Reply-To": "<1484801117-779-1-git-send-email-thomas.monjalon@6wind.com>", "References": "<1484748329-5418-1-git-send-email-shreyansh.jain@nxp.com>\n\t<1484801117-779-1-git-send-email-thomas.monjalon@6wind.com>", "Subject": "[dpdk-dev] [PATCH v11 10/13] app/test: add PCI bus driver", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://dpdk.org/ml/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "From: Shreyansh Jain <shreyansh.jain@nxp.com>\n\nSigned-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>\nReviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>\n---\n app/test/test_pci.c | 164 ++++++++++++++++++++++++++++++++++++----------------\n 1 file changed, 114 insertions(+), 50 deletions(-)", "diff": "diff --git a/app/test/test_pci.c b/app/test/test_pci.c\nindex cda186d..09261cc 100644\n--- a/app/test/test_pci.c\n+++ b/app/test/test_pci.c\n@@ -38,9 +38,11 @@\n #include <sys/queue.h>\n \n #include <rte_interrupts.h>\n+#include <rte_bus.h>\n #include <rte_pci.h>\n #include <rte_ethdev.h>\n #include <rte_devargs.h>\n+#include <rte_tailq.h>\n \n #include \"test.h\"\n #include \"resource.h\"\n@@ -61,10 +63,31 @@\n \n int test_pci_run = 0; /* value checked by the multiprocess test */\n static unsigned pci_dev_count;\n+struct test_pci_bus;\n+static struct test_pci_bus *pci_bus; /* global reference to a Test PCI bus */\n+\n+/** List of PCI devices */\n+TAILQ_HEAD(test_pci_device_list, rte_pci_device);\n+/** List of PCI drivers */\n+TAILQ_HEAD(test_pci_driver_list, rte_pci_driver);\n \n static int my_driver_init(struct rte_pci_driver *dr,\n \t\t\t struct rte_pci_device *dev);\n \n+struct test_pci_bus {\n+\tstruct rte_bus bus;\n+\tstruct test_pci_device_list test_device_list;\n+\tstruct test_pci_driver_list test_driver_list;\n+};\n+\n+struct test_pci_bus test_pci_bus = {\n+\t.bus = {\n+\t\t.name = \"test_pci_bus\",\n+\t\t.scan = rte_eal_pci_scan,\n+\t\t.probe = rte_eal_pci_probe,\n+\t},\n+};\n+\n /* IXGBE NICS */\n struct rte_pci_id my_driver_id[] = {\n \t{RTE_PCI_DEVICE(0x0001, 0x1234)},\n@@ -79,7 +102,7 @@ struct rte_pci_id my_driver_id2[] = {\n \n struct rte_pci_driver my_driver = {\n \t.driver = {\n-\t\t.name = \"test_driver\"\n+\t\t.name = \"test_driver\",\n \t},\n \t.probe = my_driver_init,\n \t.id_table = my_driver_id,\n@@ -88,7 +111,7 @@ struct rte_pci_driver my_driver = {\n \n struct rte_pci_driver my_driver2 = {\n \t.driver = {\n-\t\t.name = \"test_driver2\"\n+\t\t.name = \"test_driver2\",\n \t},\n \t.probe = my_driver_init,\n \t.id_table = my_driver_id2,\n@@ -108,6 +131,55 @@ my_driver_init(__attribute__((unused)) struct rte_pci_driver *dr,\n \treturn 0;\n }\n \n+/* dump devices on the bus */\n+static void\n+do_pci_device_dump(FILE *f)\n+{\n+\tint i;\n+\tstruct rte_pci_device *dev = NULL;\n+\n+\tTAILQ_FOREACH(dev, &test_pci_bus.test_device_list, next) {\n+\n+\t\tfprintf(f, PCI_PRI_FMT, dev->addr.domain, dev->addr.bus,\n+\t\t dev->addr.devid, dev->addr.function);\n+\t\tfprintf(f, \" - vendor:%x device:%x\\n\", dev->id.vendor_id,\n+\t\t dev->id.device_id);\n+\n+\t\tfor (i = 0; i != sizeof(dev->mem_resource) /\n+\t\t\tsizeof(dev->mem_resource[0]); i++) {\n+\t\t\tfprintf(f, \" %16.16\"PRIx64\" %16.16\"PRIx64\"\\n\",\n+\t\t\t\tdev->mem_resource[i].phys_addr,\n+\t\t\t\tdev->mem_resource[i].len);\n+\t\t}\n+\t}\n+}\n+\n+/* Dummy implementation for rte_eal_pci_probe() over test_pci_bus */\n+static int\n+do_pci_bus_probe(void)\n+{\n+\tint ret;\n+\tstruct rte_pci_device *device;\n+\tstruct rte_pci_driver *driver;\n+\n+\tTAILQ_FOREACH(device, &test_pci_bus.test_device_list, next) {\n+\t\tTAILQ_FOREACH(driver, &test_pci_bus.test_driver_list, next) {\n+\t\t\tret = rte_pci_match(driver, device);\n+\t\t\tif (!ret) {\n+\t\t\t\tif (!driver->probe)\n+\t\t\t\t\tcontinue;\n+\n+\t\t\t\tdevice->driver = driver;\n+\t\t\t\tret = driver->probe(driver, device);\n+\t\t\t\tif (ret != 0)\n+\t\t\t\t\treturn ret;\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\treturn 0;\n+}\n+\n static void\n blacklist_all_devices(void)\n {\n@@ -115,7 +187,7 @@ blacklist_all_devices(void)\n \tunsigned i = 0;\n \tchar pci_addr_str[16];\n \n-\tTAILQ_FOREACH(dev, &pci_device_list, next) {\n+\tTAILQ_FOREACH(dev, &(test_pci_bus.test_device_list), next) {\n \t\tsnprintf(pci_addr_str, sizeof(pci_addr_str), PCI_PRI_FMT,\n \t\t\tdev->addr.domain, dev->addr.bus, dev->addr.devid,\n \t\t\tdev->addr.function);\n@@ -142,19 +214,11 @@ static void free_devargs_list(void)\n \t}\n }\n \n-/* backup real devices & drivers (not used for testing) */\n-struct pci_driver_list real_pci_driver_list =\n-\tTAILQ_HEAD_INITIALIZER(real_pci_driver_list);\n-struct pci_device_list real_pci_device_list =\n-\tTAILQ_HEAD_INITIALIZER(real_pci_device_list);\n-\n REGISTER_LINKED_RESOURCE(test_pci_sysfs);\n \n static int\n test_pci_setup(void)\n {\n-\tstruct rte_pci_device *dev;\n-\tstruct rte_pci_driver *dr;\n \tconst struct resource *r;\n \tint ret;\n \n@@ -167,22 +231,22 @@ test_pci_setup(void)\n \tret = setenv(\"SYSFS_PCI_DEVICES\", \"test_pci_sysfs/bus/pci/devices\", 1);\n \tTEST_ASSERT_SUCCESS(ret, \"failed to setenv\");\n \n-\t/* Unregister original devices & drivers lists */\n-\twhile (!TAILQ_EMPTY(&pci_driver_list)) {\n-\t\tdr = TAILQ_FIRST(&pci_driver_list);\n-\t\trte_eal_pci_unregister(dr);\n-\t\tTAILQ_INSERT_TAIL(&real_pci_driver_list, dr, next);\n-\t}\n+\tTAILQ_INIT(&test_pci_bus.test_device_list);\n+\tTAILQ_INIT(&test_pci_bus.test_driver_list);\n \n-\twhile (!TAILQ_EMPTY(&pci_device_list)) {\n-\t\tdev = TAILQ_FIRST(&pci_device_list);\n-\t\tTAILQ_REMOVE(&pci_device_list, dev, next);\n-\t\tTAILQ_INSERT_TAIL(&real_pci_device_list, dev, next);\n-\t}\n+\t/* Create a new Bus called 'test_pci_bus' */\n+\t/* Bus doesn't exist; Create the test bus */\n+\tprintf(\"Creating a Test PCI bus\\n\");\n+\trte_bus_register(&test_pci_bus.bus);\n+\tpci_bus = &test_pci_bus;\n+\n+\tprintf(\"Scan for Test devices and add to bus\\n\");\n+\tret = pci_bus->bus.scan();\n \n-\tret = rte_eal_pci_scan();\n \tTEST_ASSERT_SUCCESS(ret, \"failed to scan PCI bus\");\n-\trte_eal_pci_dump(stdout);\n+\n+\tprintf(\"Dump of all devices scanned:\\n\");\n+\tdo_pci_device_dump(stdout);\n \n \treturn 0;\n }\n@@ -190,10 +254,11 @@ test_pci_setup(void)\n static int\n test_pci_cleanup(void)\n {\n-\tstruct rte_pci_device *dev;\n-\tstruct rte_pci_driver *dr;\n+\tstruct rte_pci_device *dev = NULL;\n+\tstruct rte_pci_driver *dr = NULL;\n \tconst struct resource *r;\n \tint ret;\n+\tvoid *temp;\n \n \tunsetenv(\"SYSFS_PCI_DEVICES\");\n \n@@ -203,28 +268,23 @@ test_pci_cleanup(void)\n \tret = resource_rm_by_tar(r);\n \tTEST_ASSERT_SUCCESS(ret, \"Failed to delete resource %s\", r->name);\n \n+\tTEST_ASSERT_NOT_NULL(pci_bus, \"Invalid bus specified\");\n+\n \t/*\n \t * FIXME: there is no API in DPDK to free a rte_pci_device so we\n \t * cannot free the devices in the right way. Let's assume that we\n \t * don't care for tests.\n \t */\n-\twhile (!TAILQ_EMPTY(&pci_device_list)) {\n-\t\tdev = TAILQ_FIRST(&pci_device_list);\n-\t\tTAILQ_REMOVE(&pci_device_list, dev, next);\n+\tTAILQ_FOREACH_SAFE(dev, &(test_pci_bus.test_device_list), next, temp) {\n+\t\tTAILQ_REMOVE(&(test_pci_bus.test_device_list), dev, next);\n+\t\tdev->driver = NULL;\n \t}\n \n-\t/* Restore original devices & drivers lists */\n-\twhile (!TAILQ_EMPTY(&real_pci_driver_list)) {\n-\t\tdr = TAILQ_FIRST(&real_pci_driver_list);\n-\t\tTAILQ_REMOVE(&real_pci_driver_list, dr, next);\n-\t\trte_eal_pci_register(dr);\n+\tTAILQ_FOREACH_SAFE(dr, &(test_pci_bus.test_driver_list), next, temp) {\n+\t\tTAILQ_REMOVE(&(test_pci_bus.test_driver_list), dr, next);\n \t}\n \n-\twhile (!TAILQ_EMPTY(&real_pci_device_list)) {\n-\t\tdev = TAILQ_FIRST(&real_pci_device_list);\n-\t\tTAILQ_REMOVE(&real_pci_device_list, dev, next);\n-\t\tTAILQ_INSERT_TAIL(&pci_device_list, dev, next);\n-\t}\n+\trte_bus_unregister(&pci_bus->bus);\n \n \treturn 0;\n }\n@@ -234,16 +294,19 @@ test_pci_blacklist(void)\n {\n \tstruct rte_devargs_list save_devargs_list;\n \n-\tprintf(\"Dump all devices\\n\");\n-\tTEST_ASSERT(TAILQ_EMPTY(&pci_driver_list),\n-\t\t\t\"pci_driver_list not empty\");\n+\tTEST_ASSERT_NOT_NULL(pci_bus, \"Invalid bus specified\");\n \n-\trte_eal_pci_register(&my_driver);\n-\trte_eal_pci_register(&my_driver2);\n+\tTEST_ASSERT(TAILQ_EMPTY(&test_pci_bus.test_driver_list),\n+\t\t \"PCI Driver list not empty\");\n+\n+\t/* Add test drivers to Bus */\n+\tTAILQ_INSERT_TAIL(&test_pci_bus.test_driver_list, &my_driver, next);\n+\tTAILQ_INSERT_TAIL(&test_pci_bus.test_driver_list, &my_driver2, next);\n \n \tpci_dev_count = 0;\n-\tprintf(\"Scan bus\\n\");\n-\trte_eal_pci_probe();\n+\n+\tprintf(\"Probe the Test Bus\\n\");\n+\tdo_pci_bus_probe();\n \n \tif (pci_dev_count == 0) {\n \t\tprintf(\"no device detected\\n\");\n@@ -257,8 +320,8 @@ test_pci_blacklist(void)\n \tblacklist_all_devices();\n \n \tpci_dev_count = 0;\n-\tprintf(\"Scan bus with all devices blacklisted\\n\");\n-\trte_eal_pci_probe();\n+\tprintf(\"Probe bus with all devices blacklisted\\n\");\n+\tdo_pci_bus_probe();\n \n \tfree_devargs_list();\n \tdevargs_list = save_devargs_list;\n@@ -270,8 +333,9 @@ test_pci_blacklist(void)\n \n \ttest_pci_run = 1;\n \n-\trte_eal_pci_unregister(&my_driver);\n-\trte_eal_pci_unregister(&my_driver2);\n+\t/* Clear the test drivers added to Test Bus */\n+\tTAILQ_REMOVE(&(test_pci_bus.test_driver_list), &my_driver, next);\n+\tTAILQ_REMOVE(&(test_pci_bus.test_driver_list), &my_driver2, next);\n \n \treturn 0;\n }\n", "prefixes": [ "dpdk-dev", "v11", "10/13" ] }{ "id": 19766, "url": "