From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0065.outbound.protection.outlook.com [104.47.34.65]) by dpdk.org (Postfix) with ESMTP id A6C0A2BB4 for ; Mon, 19 Sep 2016 08:47:10 +0200 (CEST) Received: from DM2PR03CA0044.namprd03.prod.outlook.com (10.141.96.43) by CY1PR0301MB2011.namprd03.prod.outlook.com (10.164.2.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.629.8; Mon, 19 Sep 2016 06:47:08 +0000 Received: from BL2FFO11FD047.protection.gbl (2a01:111:f400:7c09::130) by DM2PR03CA0044.outlook.office365.com (2a01:111:e400:2428::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.629.8 via Frontend Transport; Mon, 19 Sep 2016 06:47:08 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; rehivetech.com; dkim=none (message not signed) header.d=none;rehivetech.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11FD047.mail.protection.outlook.com (10.173.161.209) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.629.5 via Frontend Transport; Mon, 19 Sep 2016 06:47:07 +0000 Received: from [10.232.14.87] ([10.232.14.87]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id u8J6l4BD022329; Sun, 18 Sep 2016 23:47:05 -0700 To: Jan Viktorin References: <1451682326-5834-1-git-send-email-viktorin@rehivetech.com> <1473410639-10367-1-git-send-email-shreyansh.jain@nxp.com> <1473410639-10367-7-git-send-email-shreyansh.jain@nxp.com> <20160916142703.607722e7@pcviktorin.fit.vutbr.cz> CC: , From: Shreyansh Jain Message-ID: Date: Mon, 19 Sep 2016 12:17:53 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <20160916142703.607722e7@pcviktorin.fit.vutbr.cz> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-EOPAttributedMessage: 0 X-Matching-Connectors: 131187412281418856; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(24454002)(76104003)(377454003)(92566002)(36756003)(85426001)(31686004)(47776003)(19580395003)(65956001)(104016004)(19580405001)(626004)(77096005)(65806001)(105606002)(87936001)(4326007)(106466001)(23746002)(2950100001)(2906002)(64126003)(8676002)(5660300001)(68736007)(8666005)(356003)(50466002)(305945005)(31696002)(65826007)(54356999)(189998001)(586003)(4001350100001)(97736004)(81156014)(93886004)(230700001)(86362001)(11100500001)(76176999)(81166006)(33646002)(110136003)(7846002)(8936002)(50986999)(83506001)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB2011; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD047; 1:E7hHjaI+Y/f6GzY39FiLF3k9WxFS3FiCYJ4Iz6e2avC1ft3OFxLR+imJBsDcCKbGE+h9xfFMaC2SjIPN+sk0wenliwLZ38j8rCcLkRqHfVCMfhknf0S0+BvO7n1Z1tBbRd9OGlhmzPkIX6STic09BM/mwGo63RzyLeyGCxgf9ZF5oM71190LLlAAuIMKGcQ2o1ol0qrZDv7UY1OTtIaso/aJQinvLzRrGtiXxLMhjY1NvqCOelfVvIAcmeNYWySRCiz9tDF5aY26A6In3C6BOWYthL448YYljG+Ez0JvtIjXYQdgCUXxBdBjPZKBfE20O8sRO9OTrNdIpIvsxqm2zr2nuFXACNgPWi7OgIXz0hioFGm+ZCPA8FwO7vCxwK9GfjOUDObLgGczXFd9Oh6WwXJCo9TbRz38OePqsG35YSd8v5XkJNBMAfaSq4Ykt7U91rnCgoXsq9+sHz3GVrFmzdZI62q6xDJl5yNczKShCOH1OGMwr2hsbSqzwkjlKvEwCwQeda3JPtEJ8DrDgtpd9Ui9WLDiWN5Auo8cSPSAD5uhYHmx1AoAPVLOQy3MM3SLu7MewSfXiC1zZ6kZ/tzhHg== X-MS-Office365-Filtering-Correlation-Id: cfaa96aa-4d56-47ad-6468-08d3e058c680 X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB2011; 2:ZS+Qz1cMsvYY5pjhzcf16ZonhCz9FbVp1+DfrMQEzlVssCW+hGQN8EDUouKB4o9jUvuNSzKK7dQn63cwnDbzSrSmfBR2ycHsheC/NfJCtQueA9EnPzJwa4umIDJq5mYMmD7OGfb5pJh850DBdQvF3UbSxm/BA26TxPZVSZJ83Q8kPLci47EKlDGFCghOOSV0; 3:60nqbktHWK1M5zK0UvwxlxLAh0YdNhLxGM0frwCQjcOjtXlmjTXlGLCazrqg+Y8NNWgwCanSEj6oSQ40iGTRnLmrC3LZy4gEXh3kg5U9TOacSrK3CHpxwIORtW8nd1g+9Yisa+SRi5IYbbCC2w074BFbB+b5ulqtGkbeSvUDBkOIfbY9rXop9ExWy01Mf7EXuqC+Tcp/JVDPmSvZNFZ6822neYnCqIVzcbmmVs2snk8= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB2011; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB2011; 25:THbnIiumGt9kciWtzC1TLuJXynKcz7Hte6i1GRAoy5Uy7DHyk12BJ2LcWgeaXpoW8ge4WhE975V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c0xEyC82BWox5GKjHWPCTwIRLXXOWx2kQ8LbRZqU1RVrAoJ1hfOcJ8wyyk5iu3rCy5g0gmwJNznCxZ/MVXTyC0Oq4igUlqGqXm+3e0I2kYKeZTrNe8q9R1ciKfI3kOwnEARV+6QLHuJzdTql02YWPw/KwCpeWHjSO4OLFEGcYojwC/Z2XIBb+kKsR0yV0RdqFGhMIFTwE3kCGlzJaBgzU+uci7llJiD99qLb+i0ONlh4gOVBoUJI8PdUo+mC88/zUQKp5Vi2fGTHrbwLEteX/eYUMlIIyQbamizb4oS7niyyVq53echlvJ2ADOZXQn6+njOnUtEyi2PRMDEPVJZswaBZ4FFoEOQwi15JQlM8J04U43vBZBc+DLQUaCjddj46yRuJHZCXzzyNGAVdfWUt/HXF2A9K2WPdBodr4hEiiun60DjvoKHrY= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(13015025)(13017025)(13023025)(13024025)(13018025)(8121501046)(5005006)(3002001)(10201501046)(6055026); SRVR:CY1PR0301MB2011; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR0301MB2011; X-Forefront-PRVS: 0070A8666B X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1; CY1PR0301MB2011; 23:FViZ3/wbCnSdAmS1DtL88e6as6Jg0HEa0+5?= =?Windows-1252?Q?Es56dqWhpE7lqs/dBZJfE+xym+zyJdLuNOLU3rhfKA3UfTeqBi20nTgB?= =?Windows-1252?Q?cuZIKtTBxcKHHytotbuotC2EdV87R0WLYm3u/OOyR7yCQS7gk0fUxQSj?= =?Windows-1252?Q?6MVJK6Pb1AgCxy8ixj6waJzW7vvcBP8EeUWw2/z2VaC2BzAp/toeX6CL?= =?Windows-1252?Q?PpXkKwqIPA1vz3ebT/pc0FAlH7LvnogEQzB+ECtTKCPycGMer1x/BcvB?= =?Windows-1252?Q?p0HDqKpYP3lM7QmKNs5Y69KnBSF2rN+pJvL4MnokPWCqwBaQzOq+GafS?= =?Windows-1252?Q?5/ZYpbYotW2gp/6USmBpMYQA5THpZuO1tqMQiobyPEhq7QqbrqmX4v0f?= =?Windows-1252?Q?5XdJsNsZGtZMao5UoUpqqGDxMauYvEhCKpgiHrkZM+GFWQWpI9ZnFDTs?= =?Windows-1252?Q?tqasyotKSqKU23zGwUovwzN7/WnF5P6M7xqSA2uLyXnX95oMTMXeJCfL?= =?Windows-1252?Q?tGtCY67D2p8oAJN8a63wn4HwXd/qq6xogoIpoiW3YASlU5sfrT6glgRS?= =?Windows-1252?Q?cuTG75UwuWpB8T5EMF8UgLx4HWc7GgxW9cLw97XtA8hAgtD1KwYqbXUK?= =?Windows-1252?Q?8LvFnM0G9x1RHkMlq7Kusu9zREmMO1I3Q87kfUhEyixvyEHEAJhTTKgV?= =?Windows-1252?Q?szAyKGlFf3jLEbzng/ZyZkUbOQJ1qLZgkx8kAhOy70aOexlJvUlO8jfd?= =?Windows-1252?Q?IdN3wWkACXZvTWT/1LE6ASu7PTHhi1c53/LR5VZIJCLd7Nfv+um/BRY0?= =?Windows-1252?Q?f/DPlDyIFhLA1k6/A6ib6cPI2WZU3foZab4WvmRY6D2njZxWnRVXXoBH?= =?Windows-1252?Q?U2Ihi2dmGicf/qOn+qExlQk/RuNX+uwvF8auGhRQk/UwBBXhPS744ByB?= =?Windows-1252?Q?cYGlRpWAZAN2M3C98js7q2joxtYtV/9doHErVOXDUgF92UtQUDteEDVs?= =?Windows-1252?Q?c+jUeMbo1BfR1wkcjWvCaEyr4EjTY3vfSvA5acgTFraDK77OaUDk6M3h?= =?Windows-1252?Q?1dwdvE1OCN6rbWIbWgmE3L56YtO97Oi/BuboiygehsEY9eKFXbpy4+P7?= =?Windows-1252?Q?FJIVMXvGs4pN6yHqXfnx6WIa1JJJA/dQjSVhzeZzhW9YTkdO7rFGaF7P?= =?Windows-1252?Q?11D/fGxn+bFrZGdrZB8cg5As0AIwz80+vdT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m1uFBEVbR43zYOkL1aCNlrbQ5DXT7NnGhVycbb0j2HoM1V1r6+Rm7S4X8RGAvZYt9VNwj5kDj1YHQDBW2PGmiSzbFmQa5k7Pk++zeKPCQtm45X4gwiW6ivaWSaNSFBaiyNt3+lIUpFQ4gQQgOFnGNO1EP9akRHmQL/8nPyvCfaRo+uE7rnhyHqWrzJTWBkG8wHK/Y+N4OH2/rRIl4hO1ZAyROMXYEVCUl5n SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2016 06:47:07.9546 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB2011 Subject: Re: [dpdk-dev] [PATCH v3 06/15] eal/soc: implement probing of drivers X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Sep 2016 06:47:11 -0000 Hi Jan, On Friday 16 September 2016 05:57 PM, Jan Viktorin wrote: > On Fri, 9 Sep 2016 14:13:50 +0530 > Shreyansh Jain wrote: > >> Each SoC PMD registers a set of callback for scanning its own bus/infra and >> matching devices to drivers when probe is called. >> This patch introduces the infra for calls to SoC scan on rte_eal_soc_init() >> and match on rte_eal_soc_probe(). >> >> Patch also adds test case for scan and probe. >> >> Signed-off-by: Jan Viktorin >> Signed-off-by: Shreyansh Jain >> Signed-off-by: Hemant Agrawal >> --- >> app/test/test_soc.c | 138 ++++++++++++++- >> lib/librte_eal/bsdapp/eal/rte_eal_version.map | 4 + >> lib/librte_eal/common/eal_common_soc.c | 215 ++++++++++++++++++++++++ >> lib/librte_eal/common/include/rte_soc.h | 51 ++++++ >> lib/librte_eal/linuxapp/eal/eal.c | 5 + >> lib/librte_eal/linuxapp/eal/eal_soc.c | 16 ++ >> lib/librte_eal/linuxapp/eal/rte_eal_version.map | 4 + >> 7 files changed, 432 insertions(+), 1 deletion(-) >> >> diff --git a/app/test/test_soc.c b/app/test/test_soc.c >> index ac03e64..d2b9462 100644 >> --- a/app/test/test_soc.c >> +++ b/app/test/test_soc.c >> @@ -87,14 +87,45 @@ static int test_compare_addr(void) >> */ >> struct test_wrapper { >> struct rte_soc_driver soc_drv; >> + struct rte_soc_device soc_dev; >> }; >> >> +static int empty_pmd0_devinit(struct rte_soc_driver *drv, >> + struct rte_soc_device *dev); >> +static int empty_pmd0_devuninit(struct rte_soc_device *dev); > > I prefer an empty line here. Ok. I will add that. > > > What is the prupose of the scan here? What device does it provide > to the test? I'd prefer to call it e.g. "allways_find_device0" or > something describing the purpose and explaining what is the goal > of the related test. I understand what you are hinting at. Purpose of scan is obviously to 'always add a device0'. I will update the code. > > Probably a comment explaining "provide a device named 'empty_pmd0_dev' > would be helpful. Ok. > >> +static void test_soc_scan_dev0_cb(void); > > Similar here, something like "match_by_name". > >> +static int test_soc_match_dev0_cb(struct rte_soc_driver *drv, >> + struct rte_soc_device *dev); > > I prefer an empty line here. Do we really place newlines in function declarations? That doesn't really help anything, until and unless some comments are added to those. Anyways, rather than added blank lines, I will add some comments - those are indeed misssing. > > > ditto... Will add comments. > >> +static void test_soc_scan_dev1_cb(void); > > ditto... Same here, I prefer comment rather than blank line. > >> +static int test_soc_match_dev1_cb(struct rte_soc_driver *drv, >> + struct rte_soc_device *dev); >> + >> +static int >> +empty_pmd0_devinit(struct rte_soc_driver *drv __rte_unused, >> + struct rte_soc_device *dev __rte_unused) >> +{ >> + return 0; >> +} >> + >> +static int >> +empty_pmd0_devuninit(struct rte_soc_device *dev) >> +{ >> + /* Release the memory associated with dev->addr.name */ >> + free(dev->addr.name); >> + >> + return 0; >> +} >> + >> struct test_wrapper empty_pmd0 = { >> .soc_drv = { >> .driver = { >> .name = "empty_pmd0" >> }, >> - }, >> + .devinit = empty_pmd0_devinit, >> + .devuninit = empty_pmd0_devuninit, >> + .scan_fn = test_soc_scan_dev0_cb, >> + .match_fn = test_soc_match_dev0_cb, >> + } >> }; >> >> struct test_wrapper empty_pmd1 = { >> @@ -102,9 +133,54 @@ struct test_wrapper empty_pmd1 = { >> .driver = { >> .name = "empty_pmd1" >> }, >> + .scan_fn = test_soc_scan_dev1_cb, >> + .match_fn = test_soc_match_dev1_cb, >> }, >> }; >> >> +static void >> +test_soc_scan_dev0_cb(void) >> +{ >> + /* SoC's scan would scan devices on its bus and add to >> + * soc_device_list >> + */ >> + empty_pmd0.soc_dev.addr.name = strdup("empty_pmd0_dev"); >> + >> + TAILQ_INSERT_TAIL(&soc_device_list, &empty_pmd0.soc_dev, next); >> +} >> + >> +static int >> +test_soc_match_dev0_cb(struct rte_soc_driver *drv __rte_unused, >> + struct rte_soc_device *dev) >> +{ >> + if (!dev->addr.name || strcmp(dev->addr.name, "empty_pmd0_dev")) >> + return 0; >> + >> + return 1; >> +} >> + >> + >> +static void >> +test_soc_scan_dev1_cb(void) >> +{ >> + /* SoC's scan would scan devices on its bus and add to >> + * soc_device_list >> + */ >> + empty_pmd0.soc_dev.addr.name = strdup("empty_pmd1_dev"); >> + >> + TAILQ_INSERT_TAIL(&soc_device_list, &empty_pmd1.soc_dev, next); >> +} >> + >> +static int >> +test_soc_match_dev1_cb(struct rte_soc_driver *drv __rte_unused, >> + struct rte_soc_device *dev) >> +{ >> + if (!dev->addr.name || strcmp(dev->addr.name, "empty_pmd1_dev")) >> + return 0; >> + >> + return 1; >> +} >> + >> static int >> count_registered_socdrvs(void) >> { >> @@ -148,13 +224,54 @@ test_register_unregister(void) >> return 0; >> } >> >> +/* Test Probe (scan and match) functionality */ >> +static int >> +test_soc_init_and_probe(void) > > You say to test scan and match. I'd prefer to reflect this in the name > of the test. Otherwise, it seems you are testing init and probe which > is not true, I think. I agree. I will update the name of the function. > > Do you test that "match principle works" or that "match functions are OK" > or "match functions are called as expected", ...? "match functions are called as expected" The model for the patchset was to allow PMDs to write their own match and hence, verifying a particular match is not definitive. Rather, the test case simply confirms that a SoC based PMD would be able to implement its own match/scan and these would be called from EAL as expected. > >> +{ >> + struct rte_soc_driver *drv; >> + >> + /* Registering dummy drivers */ >> + rte_eal_soc_register(&empty_pmd0.soc_drv); >> + rte_eal_soc_register(&empty_pmd1.soc_drv); >> + /* Assuming that test_register_unregister is working, not verifying >> + * that drivers are indeed registered >> + */ >> + >> + /* rte_eal_soc_init is called by rte_eal_init, which in turn calls the >> + * scan_fn of each driver. >> + */ >> + TAILQ_FOREACH(drv, &soc_driver_list, next) { >> + if (drv && drv->scan_fn) >> + drv->scan_fn(); >> + } > > Here, I suppose you mimic the rte_eal_soc_init? Yes. > >> + >> + /* rte_eal_init() would perform other inits here */ >> + >> + /* Probe would link the SoC devices<=>drivers */ >> + rte_eal_soc_probe(); >> + >> + /* Unregistering dummy drivers */ >> + rte_eal_soc_unregister(&empty_pmd0.soc_drv); >> + rte_eal_soc_unregister(&empty_pmd1.soc_drv); >> + >> + free(empty_pmd0.soc_dev.addr.name); >> + >> + printf("%s has been successful\n", __func__); > > How you detect it is unsuccessful? Is it possible to fail in this test? > A test that can never fail is in fact not a test :). The design assumption for SoC patcheset was: A PMDs scan is called to find devices on its bus (PMD ~ bus). Whether devices are found or not, is irrelevant to EAL - whether that is because of error or actually no devices were available. With the above logic, no 'success/failure' is checked in the test. It is simply a verification of EAL's ability to link the PMD with it (scan/match function pointers). > >> + return 0; >> +} >> + >> /* save real devices and drivers until the tests finishes */ >> struct soc_driver_list real_soc_driver_list = >> TAILQ_HEAD_INITIALIZER(real_soc_driver_list); >> >> +/* save real devices and drivers until the tests finishes */ >> +struct soc_device_list real_soc_device_list = >> + TAILQ_HEAD_INITIALIZER(real_soc_device_list); >> + >> static int test_soc_setup(void) >> { >> struct rte_soc_driver *drv; >> + struct rte_soc_device *dev; >> >> /* no real drivers for the test */ >> while (!TAILQ_EMPTY(&soc_driver_list)) { >> @@ -163,12 +280,20 @@ static int test_soc_setup(void) >> TAILQ_INSERT_TAIL(&real_soc_driver_list, drv, next); >> } >> >> + /* And, no real devices for the test */ >> + while (!TAILQ_EMPTY(&soc_device_list)) { >> + dev = TAILQ_FIRST(&soc_device_list); >> + TAILQ_REMOVE(&soc_device_list, dev, next); >> + TAILQ_INSERT_TAIL(&real_soc_device_list, dev, next); >> + } >> + >> return 0; >> } >> >> static int test_soc_cleanup(void) >> { >> struct rte_soc_driver *drv; >> + struct rte_soc_device *dev; >> >> /* bring back real drivers after the test */ >> while (!TAILQ_EMPTY(&real_soc_driver_list)) { >> @@ -177,6 +302,13 @@ static int test_soc_cleanup(void) >> rte_eal_soc_register(drv); >> } >> >> + /* And, bring back real devices after the test */ >> + while (!TAILQ_EMPTY(&real_soc_device_list)) { >> + dev = TAILQ_FIRST(&real_soc_device_list); >> + TAILQ_REMOVE(&real_soc_device_list, dev, next); >> + TAILQ_INSERT_TAIL(&soc_device_list, dev, next); >> + } >> + >> return 0; >> } >> >> @@ -192,6 +324,10 @@ test_soc(void) >> if (test_register_unregister()) >> return -1; >> >> + /* Assuming test_register_unregister has succeeded */ >> + if (test_soc_init_and_probe()) >> + return -1; >> + >> if (test_soc_cleanup()) >> return -1; >> >> diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map >> index de38848..3c407be 100644 >> --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map >> +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map >> @@ -173,5 +173,9 @@ DPDK_16.11 { >> rte_eal_soc_register; >> rte_eal_soc_unregister; >> rte_eal_soc_dump; >> + rte_eal_soc_match; >> + rte_eal_soc_detach; >> + rte_eal_soc_probe; >> + rte_eal_soc_probe_one; >> >> } DPDK_16.07; >> diff --git a/lib/librte_eal/common/eal_common_soc.c b/lib/librte_eal/common/eal_common_soc.c >> index 5dcddc5..bb87a67 100644 >> --- a/lib/librte_eal/common/eal_common_soc.c >> +++ b/lib/librte_eal/common/eal_common_soc.c >> @@ -36,6 +36,8 @@ >> #include >> >> #include >> +#include >> +#include >> >> #include "eal_private.h" >> >> @@ -45,6 +47,213 @@ struct soc_driver_list soc_driver_list = >> struct soc_device_list soc_device_list = >> TAILQ_HEAD_INITIALIZER(soc_device_list); >> >> +/* Default SoC device<->Driver match handler function */ > > I think this comment is redundant. All this is already said in the rte_soc.h. Ok. I will remove it from here and if need be, update the rte_soc.h to have elaborate comments. > >> +int >> +rte_eal_soc_match(struct rte_soc_driver *drv, struct rte_soc_device *dev) >> +{ >> + int i, j; >> + >> + RTE_VERIFY(drv != NULL && drv->id_table != NULL); >> + RTE_VERIFY(dev != NULL && dev->id != NULL); >> + >> + for (i = 0; drv->id_table[i].compatible; ++i) { >> + const char *drv_compat = drv->id_table[i].compatible; >> + >> + for (j = 0; dev->id[j].compatible; ++j) { >> + const char *dev_compat = dev->id[j].compatible; >> + >> + if (!strcmp(drv_compat, dev_compat)) >> + return 0; >> + } >> + } >> + >> + return 1; >> +} >> + >> + >> +static int >> +rte_eal_soc_probe_one_driver(struct rte_soc_driver *drv, >> + struct rte_soc_device *dev) >> +{ >> + int ret = 1; >> + > > I think, the RTE_VERIFY(dev->match_fn) might be good here. > It avoids any doubts about the validity of the pointer. That has already been done in rte_eal_soc_register which is called when PMDs are registering themselves through DRIVER_REGISTER_SOC. That would prevent any PMD leaking through to this stage without a proper match_fn/scan_fn. > >> + ret = drv->match_fn(drv, dev); >> + if (ret) { >> + RTE_LOG(DEBUG, EAL, >> + " match function failed, skipping\n"); > > Is this a failure? I think it is not. Failure would be if the match > function cannot execute correctly. This is more like "no-match". The log message is misleading. This is _not_ a failure but simply a 'no-match'. I will update this. > > When debugging, I'd like to see more a message like "driver does not match". Problem would be about '' of a driver. There is already another discussion about SoC capability/platform bus definitions - probably I will wait for that so as to define what a '' for a driver and device is. In this case, the key reason for not adding such a message was because it was assumed PMDs are black boxes with EAL not even assuming what '' means. Anyways, it is better to discuss these things in that other email. > >> + return ret; >> + } >> + >> + dev->driver = drv; >> + RTE_VERIFY(drv->devinit != NULL); >> + return drv->devinit(drv, dev); >> +} >> + >> +static int >> +soc_probe_all_drivers(struct rte_soc_device *dev) >> +{ >> + struct rte_soc_driver *drv = NULL; >> + int rc = 0; >> + >> + if (dev == NULL) >> + return -1; >> + >> + TAILQ_FOREACH(drv, &soc_driver_list, next) { >> + rc = rte_eal_soc_probe_one_driver(drv, dev); >> + if (rc < 0) >> + /* negative value is an error */ >> + return -1; >> + if (rc > 0) >> + /* positive value means driver doesn't support it */ >> + continue; >> + return 0; >> + } >> + return 1; >> +} >> + >> +/* If the IDs match, call the devuninit() function of the driver. */ > > Again, I think this comment is redudant. I'd leave it if it explains some > implementation-specific detail but it does not seem to... Ok. > >> +static int >> +rte_eal_soc_detach_dev(struct rte_soc_driver *drv, >> + struct rte_soc_device *dev) >> +{ >> + int ret; >> + >> + if ((drv == NULL) || (dev == NULL)) >> + return -EINVAL; >> + >> + ret = drv->match_fn(drv, dev); >> + if (ret) { >> + RTE_LOG(DEBUG, EAL, >> + " match function failed, skipping\n"); > > When debugging, I'd like to see more "driver does not match". My reply is same as above - I will like to wait and see what we conclude from the other discussion on SoC scan/match. > >> + return ret; >> + } >> + >> + RTE_LOG(DEBUG, EAL, "SoC device %s\n", >> + dev->addr.name); >> + >> + RTE_LOG(DEBUG, EAL, " remove driver: %s\n", drv->driver.name); >> + >> + if (drv->devuninit && (drv->devuninit(dev) < 0)) >> + return -1; /* negative value is an error */ >> + >> + /* clear driver structure */ >> + dev->driver = NULL; >> + >> + return 0; >> +} >> + >> +/* >> + * Call the devuninit() function of all registered drivers for the given >> + * device if their IDs match. > > I think, the "IDs match" is obsolete becase the match_fn may work in a different way now. Yes, I will remove this comment. > >> + * >> + * @return >> + * 0 when successful >> + * -1 if deinitialization fails >> + * 1 if no driver is found for this device. >> + */ >> +static int >> +soc_detach_all_drivers(struct rte_soc_device *dev) >> +{ >> + struct rte_soc_driver *dr = NULL; >> + int rc = 0; >> + >> + if (dev == NULL) >> + return -1; >> + >> + TAILQ_FOREACH(dr, &soc_driver_list, next) { >> + rc = rte_eal_soc_detach_dev(dr, dev); >> + if (rc < 0) >> + /* negative value is an error */ >> + return -1; >> + if (rc > 0) >> + /* positive value means driver doesn't support it */ >> + continue; >> + return 0; >> + } >> + return 1; >> +} >> + >> +/* >> + * Detach device specified by its SoC address. >> + */ >> +int >> +rte_eal_soc_detach(const struct rte_soc_addr *addr) >> +{ >> + struct rte_soc_device *dev = NULL; >> + int ret = 0; >> + >> + if (addr == NULL) >> + return -1; >> + >> + TAILQ_FOREACH(dev, &soc_device_list, next) { >> + if (rte_eal_compare_soc_addr(&dev->addr, addr)) >> + continue; >> + >> + ret = soc_detach_all_drivers(dev); >> + if (ret < 0) >> + goto err_return; >> + >> + TAILQ_REMOVE(&soc_device_list, dev, next); >> + return 0; >> + } >> + return -1; >> + >> +err_return: >> + RTE_LOG(WARNING, EAL, "Requested device %s cannot be used\n", >> + dev->addr.name); >> + return -1; >> +} >> + >> +int >> +rte_eal_soc_probe_one(const struct rte_soc_addr *addr) >> +{ >> + struct rte_soc_device *dev = NULL; >> + int ret = 0; >> + >> + if (addr == NULL) >> + return -1; >> + >> + /* unlike pci, in case of soc, it the responsibility of the soc driver >> + * to check during init whether device has been updated since last add. > > Why? Can you give a more detailed explanation? For this patch, I have _not_ assumed anything for a SoC's bus/driver/device model. In absence of a proper standard, each SoC is unique - categorizing all SoC under a platform bus, for example, would only mean assuming platform bus is a standard. Best judge for the layout of SoC devices is the SoC PMD (which is also like a bus driver, other than being a device driver). Once again, if the discussion in other thread comes to a logical conclusion, this would get updated. > >> + */ >> + >> + TAILQ_FOREACH(dev, &soc_device_list, next) { >> + if (rte_eal_compare_soc_addr(&dev->addr, addr)) >> + continue; >> + >> + ret = soc_probe_all_drivers(dev); >> + if (ret < 0) >> + goto err_return; >> + return 0; >> + } >> + return -1; >> + >> +err_return: >> + RTE_LOG(WARNING, EAL, >> + "Requested device %s cannot be used\n", addr->name); >> + return -1; >> +} >> + >> +/* >> + * Scan the SoC devices and call the devinit() function for all registered >> + * drivers that have a matching entry in its id_table for discovered devices. >> + */ > > Should be in header. Here it is redundant. Ok. I will move to rte_soc.h. > >> +int >> +rte_eal_soc_probe(void) >> +{ >> + struct rte_soc_device *dev = NULL; >> + int ret = 0; >> + >> + TAILQ_FOREACH(dev, &soc_device_list, next) { >> + ret = soc_probe_all_drivers(dev); >> + if (ret < 0) >> + rte_exit(EXIT_FAILURE, "Requested device %s" >> + " cannot be used\n", dev->addr.name); >> + } >> + >> + return 0; >> +} >> + >> /* dump one device */ >> static int >> soc_dump_one_device(FILE *f, struct rte_soc_device *dev) >> @@ -79,6 +288,12 @@ rte_eal_soc_dump(FILE *f) >> void >> rte_eal_soc_register(struct rte_soc_driver *driver) >> { >> + /* For a valid soc driver, match and scan function >> + * should be provided. >> + */ > > This comment should be in the header file. Actually there is no valueable addition made by this comment. RTE_VERIFY is self explanatory. I will remove the comment all together. > >> + RTE_VERIFY(driver != NULL); >> + RTE_VERIFY(driver->match_fn != NULL); >> + RTE_VERIFY(driver->scan_fn != NULL); >> TAILQ_INSERT_TAIL(&soc_driver_list, driver, next); >> } >> >> diff --git a/lib/librte_eal/common/include/rte_soc.h b/lib/librte_eal/common/include/rte_soc.h >> index c6f98eb..bfb49a2 100644 >> --- a/lib/librte_eal/common/include/rte_soc.h >> +++ b/lib/librte_eal/common/include/rte_soc.h >> @@ -97,6 +97,16 @@ typedef int (soc_devinit_t)(struct rte_soc_driver *, struct rte_soc_device *); >> typedef int (soc_devuninit_t)(struct rte_soc_device *); >> >> /** >> + * SoC device scan callback, called from rte_eal_soc_init. > > Can you explain what is the goal of the callback? > What is the expected behaviour. EAL would call the scan of each registered SoC PMD (DRIVER_REGISTER_SOC). This scan is responsible for finding devices on SoC's specific bus and add them to SoC device_list. This is a callback because SoC don't have a generalization like PCI. A SoC is not necessarily a platform bus either (what original patch series assumed). > > It returns void so it seems it can never fail. Is this correct? > I can image that to scan for devices, I need to check some file-system > structure which can be unavailable... This is what I had in mind: That is true, it never fails. It is expected that scan function simply ignores (logs error) and moves ahead. A local error for a particular SoC (I agree, there might not be more than one SoC) doesn't necessarily mean that complete DPDK Application should quit. It only means that application user should get some error/warning/message about failure. > >> + */ >> +typedef void (soc_scan_t)(void); > > You are missing the '*' in (*soc_scan_t). That was put in the definition in the rte_soc_driver - but, I see you have already commented there. I will add the '*' here and remove from there. > >> + >> +/** >> + * Custom device<=>driver match callback for SoC > > Can you explain the semantics (return values), please? rte_soc.h already has explanation on the expected semantics over rte_eal_soc_match - the default implementation. But, I agree, it should be above this declaration. > >> + */ >> +typedef int (soc_match_t)(struct rte_soc_driver *, struct rte_soc_device *); > > You are missing the '*' in (*soc_match_t). Same as above - I will add '*' and remove from rte_soc_driver. > >> + >> +/** >> * A structure describing a SoC driver. >> */ >> struct rte_soc_driver { >> @@ -104,6 +114,8 @@ struct rte_soc_driver { >> struct rte_driver driver; /**< Inherit core driver. */ >> soc_devinit_t *devinit; /**< Device initialization */ >> soc_devuninit_t *devuninit; /**< Device uninitialization */ > > Those should be renamed to probe/remove. Yes, agree with that. > >> + soc_scan_t *scan_fn; /**< Callback for scanning SoC bus*/ >> + soc_match_t *match_fn; /**< Callback to match dev<->drv */ > > Here the '*' would be redundant if you add them to the typedefs. As stated above, I will remove from there and add to typedefs. > > I think, we should tell the users that scan_fn and match_fn must be always set > to something. How? I think it would be part of documentation, isn't it? Also, rte_eal_soc_init() already enforces this check with RTE_VERIFY. > >> const struct rte_soc_id *id_table; /**< ID table, NULL terminated */ >> }; >> >> @@ -146,6 +158,45 @@ rte_eal_compare_soc_addr(const struct rte_soc_addr *a0, >> } >> >> /** >> + * Default function for matching the Soc driver with device. Each driver can >> + * either use this function or define their own soc matching function. >> + * This function relies on the compatible string extracted from sysfs. But, >> + * a SoC might have different way of identifying its devices. Such SoC can >> + * override match_fn. >> + * >> + * @return >> + * 0 on success >> + * -1 when no match found >> + */ >> +int >> +rte_eal_soc_match(struct rte_soc_driver *drv, struct rte_soc_device *dev); > > What about naming it > > rte_eal_soc_match_default Ok. > > or maybe better > > rte_eal_soc_match_compatible > > what do you think? From what I had in mind - the discussion about SoC not necessarily being a Platform bus - 'compatible' doesn't look fine to me. But again, it is still open debate so - I will wait until that is conlcuded. > >> + >> +/** >> + * Probe SoC devices for registered drivers. >> + */ >> +int rte_eal_soc_probe(void); >> + >> +/** >> + * Probe the single SoC device. >> + */ >> +int rte_eal_soc_probe_one(const struct rte_soc_addr *addr); >> + >> +/** >> + * Close the single SoC device. >> + * >> + * Scan the SoC devices and find the SoC device specified by the SoC >> + * address, then call the devuninit() function for registered driver >> + * that has a matching entry in its id_table for discovered device. >> + * >> + * @param addr >> + * The SoC address to close. >> + * @return >> + * - 0 on success. >> + * - Negative on error. >> + */ >> +int rte_eal_soc_detach(const struct rte_soc_addr *addr); >> + >> +/** >> * Dump discovered SoC devices. >> */ >> void rte_eal_soc_dump(FILE *f); >> diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c >> index 15c8c3d..147b601 100644 >> --- a/lib/librte_eal/linuxapp/eal/eal.c >> +++ b/lib/librte_eal/linuxapp/eal/eal.c >> @@ -70,6 +70,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -881,6 +882,10 @@ rte_eal_init(int argc, char **argv) >> if (rte_eal_pci_probe()) >> rte_panic("Cannot probe PCI\n"); >> >> + /* Probe & Initialize SoC devices */ >> + if (rte_eal_soc_probe()) >> + rte_panic("Cannot probe SoC\n"); >> + >> rte_eal_mcfg_complete(); >> >> return fctret; >> diff --git a/lib/librte_eal/linuxapp/eal/eal_soc.c b/lib/librte_eal/linuxapp/eal/eal_soc.c >> index 04848b9..5f961c4 100644 >> --- a/lib/librte_eal/linuxapp/eal/eal_soc.c >> +++ b/lib/librte_eal/linuxapp/eal/eal_soc.c >> @@ -52,5 +52,21 @@ >> int >> rte_eal_soc_init(void) >> { >> + struct rte_soc_driver *drv; >> + >> + /* for debug purposes, SoC can be disabled */ >> + if (internal_config.no_soc) >> + return 0; >> + >> + /* For each registered driver, call their scan routine to perform any >> + * custom scan for devices (for example, custom buses) >> + */ >> + TAILQ_FOREACH(drv, &soc_driver_list, next) { > > Is it possible to have drv->scan_fn == NULL? I suppose, this is invalid. > I'd prefer to have RTE_VERIFY for this check. rte_eal_soc_init() has this check already. Driver wouldn't even be registered in case scan/match are not implemented. > >> + if (drv && drv->scan_fn) { >> + drv->scan_fn(); >> + /* Ignore all errors from this */ >> + } > >> + } >> + >> return 0; >> } >> diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map >> index b9d1932..adcfe7d 100644 >> --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map >> +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map >> @@ -179,5 +179,9 @@ DPDK_16.11 { >> rte_eal_soc_register; >> rte_eal_soc_unregister; >> rte_eal_soc_dump; >> + rte_eal_soc_match; >> + rte_eal_soc_detach; >> + rte_eal_soc_probe; >> + rte_eal_soc_probe_one; >> >> } DPDK_16.07; > > Regards > Jan > I hope I have covered all your comments. That was an exhaustive review. Thanks a lot for your time. Lets work to resolve the architectural issues revolving around SoC scan/match. - Shreyansh