From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0076.outbound.protection.outlook.com [104.47.34.76]) by dpdk.org (Postfix) with ESMTP id 60FBC3990 for ; Fri, 16 Dec 2016 14:22:41 +0100 (CET) Received: from BN3PR0301CA0084.namprd03.prod.outlook.com (10.160.152.180) by BN1PR0301MB0737.namprd03.prod.outlook.com (10.160.78.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.771.8; Fri, 16 Dec 2016 13:22:40 +0000 Received: from BY2FFO11OLC015.protection.gbl (2a01:111:f400:7c0c::103) by BN3PR0301CA0084.outlook.office365.com (2a01:111:e400:401e::52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.771.8 via Frontend Transport; Fri, 16 Dec 2016 13:22:39 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=nxp.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BY2FFO11OLC015.mail.protection.outlook.com (10.1.15.59) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.771.7 via Frontend Transport; Fri, 16 Dec 2016 13:22:39 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:; UpperCasedChecksum:; SizeAsReceived:982; Count:13 Received: from [10.232.14.87] ([10.232.14.87]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id uBGDMZao001588; Fri, 16 Dec 2016 06:22:36 -0700 To: References: <1481636232-2300-1-git-send-email-shreyansh.jain@nxp.com> <1481893853-31790-1-git-send-email-shreyansh.jain@nxp.com> <1481893853-31790-5-git-send-email-shreyansh.jain@nxp.com> CC: , , , From: Shreyansh Jain Message-ID: <8c576d0f-cac5-2a0e-8e33-fccbc6c90787@nxp.com> Date: Fri, 16 Dec 2016 18:55:21 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <1481893853-31790-5-git-send-email-shreyansh.jain@nxp.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-IncomingHeaderCount: 13 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131263681594450727; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.158.2; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(336005)(39840400002)(39450400003)(39400400002)(39380400002)(39410400002)(39860400002)(39850400002)(2980300002)(1109001)(1110001)(339900001)(24454002)(377454003)(189002)(199003)(356003)(76176999)(189998001)(33646002)(47776003)(23746002)(230700001)(626004)(8936002)(4001350100001)(81156014)(31696002)(81166006)(86362001)(50466002)(65956001)(5890100001)(65806001)(97736004)(31686004)(64126003)(8676002)(85426001)(2906002)(65826007)(68736007)(83506001)(69596002)(92566002)(110136003)(5660300001)(77096006)(105606002)(305945005)(229853002)(104016004)(36756003)(6916009)(2351001)(6666003)(2950100002)(54356999)(106466001)(4326007)(38730400001)(50986999); DIR:OUT; SFP:1101; SCL:1; SRVR:BN1PR0301MB0737; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11OLC015; 1:RlaHy2YGTRV+bQJ4EDe7xwt/A98a1yy+WL87l5N3TqF71uKuphg9VMmobHG+zOlTaA3VUF5cGsQm3ovXsgpNOkrzsxSWOwAKxCXBXX8jjkqsfIevEJ1RqEV6wQe3dvo0eEhj+xE87sr33vtPa6KknqhzkZqjsuY/kgvIsmXYM9rDcOLIR17xLH/G2lcGB9Uv+bnLzQlFyFzO9DYcKZp+bhMuyB8uySRlxCKOnbBM0QfXyeAF1gG21P5H5dB0MsxqjyqBBDUfvApkSYrdkJop4ZZ9X6PjjzW0VrFWAqrW73kP4LAMVPV2Pd+WZ5QRJnSOqxQ2/uSo5yDRkf1bC15R5RylfWPR/jzSihHzsqOoLzKIKtLxx/wFP/3P1lidUwwNvWhfS8MPu/OOAQlfl1bpJvgUG4j3CNIOnaHFaqizo1aXbR3lZUmbQXTqzBZz0Q99/luG1b8GbL9+mdP36POITTmurtvGuQl46oHysn/wM39L2x0NiRIUR25Uv+XNsQM4JRsf4msxdZsvkrgTjxB+Dr29arOCdzGfmuUjXYIRPhMHxBiazda9eZflanOykvljBXXcAB1ctJjWlczdABP1tozTXPmTeHjxwRSe15zn1ymudrAlnmYhOQ8urnzCyDcFPhsIs4RdRm9TORwOYhXtsw== X-MS-Office365-Filtering-Correlation-Id: f7deecd6-8cbd-4e95-e327-08d425b69bcf X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:BN1PR0301MB0737; X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0737; 3:55hoh5L6mtPq/nK8BwFIFNot9xLHn3M2HHuShZ9aGqYp6cl/xmsdf9+tmroOSKm/N1c5dKK7OaJsIwFWNnwL/hfUSba/JD0qhvIZY2o9Fy2+9euiwtbdWTaoOuNcsjpRCinF2KG//hDKYtaoeLHvTptiQnLeFF4ME7aUgCzQns5lvZYImY6dnoubMJi0zcT+Bmm1Zn/JB+b1HF502SY5THB8vX+StOk7Wz5kPMej+PkDA+itlmD6gJlQanSFqHKM7y397KfuMjf4vmnbVSkXbWTZIJGc/WsJyzmfWir9U6gMp6Mr4liTmnYAaaulnF6zcZw5xxPIoYB7sLCAAIiVwR8FH+gdTYzdN0wmmOnA9O4= X-Microsoft-Exchange-Diagnostics: 1; B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z4vFnaYe7Nr69VZuckMnWo5Y/qBKzG8qmKwqoEaNdkWAwUVnqShaP6/dWhduRw4tqzJ6suehF5NgUxNh9g== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095060)(601004)(2401047)(13023025)(8121501046)(5005006)(13024025)(13017025)(13018025)(13015025)(10201501046)(3002001)(6055026)(6096035)(20161123561025)(20161123565025)(20161123556025)(20161123559025)(20161123563025); SRVR:BN1PR0301MB0737; BCL:0; PCL:0; RULEID:(400006); SRVR:BN1PR0301MB0737; X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0737; 4:L7bgosec9AM0bquKacGTa+czWc36UuepQRLSjNsApJfOxer+HbI3JuIqApDYR+6grnbCYhcRNY92ya6FXqoqJ1A7slsh3bv5VYh0gEkky9SRF5MTpYyiSEm7VOjdNECV7mRbd6MWKpQXH1YJwcy9esjL67DIewpBasOuWkijFlxHuidU/Wc0wIWhPLHzxlkSQdrnMCgM2EuSXJLc5tG7FDHFwksndEdHjwqCpcS+ugo+v6P7WGvPLsabJwhG2EkUX/WWGB6BQlBbrSS+8M8e120MGKjE0JBk69I5OeY4RPiuAxbHrrTOU/m6YrqzaRVEg1CyPcL0VW5g1GJw97XhcYCB1ik4j0YX7LIrE1URk8Z0N1Xd8HWKRK+dXDyTy67iqZKiMMNntSuWDmbooiN35KAfSK6fI2yFNkKYKFyDTgNX7E22lpUpdkaoW6Lu7UAS/c28qTbw6hXXwU64ktRNRqoFjAPx0bq6ta0ZZPAxSCNAkNt3AvMYX/idN+jANUJZGORqlBKpE613YbeIbwL4mdiPomUnGvCQEe0y43DY0/xZkAhEAqlpXNR3us/w7EiNroR70X7TcoXbrWNQn7dbxCswhdzlt+hOeGXZX8XwO2i88qhmIOqCraNaKNJQvowQ19D/+ZiTcFgYzVL62fNVxqmksuZTQXipwlEIFPo4WOWTnjpEVx0g3cxE23iNx5DZbI+Wp3qa7jJOv2FJRBatBSt/LsUQCm17q9/PQH38uQYVrjGaxfq0g9iVNrk756Zt X-Forefront-PRVS: 01583E185C X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1; BN1PR0301MB0737; 23:a0Z96JpQTZI7vd3jfTrO42cKglIqOJYpTy8?= =?Windows-1252?Q?jG8W55W6fna/Q19yjWBCmN8K8G8yhgrbFzB62/tAhe83cSeD25Lg3rED?= =?Windows-1252?Q?6OGoq9QHBE4qCBbrqv5TYNkchDh+y7wTGAxshmHEE0BkfJceeiyDoptA?= =?Windows-1252?Q?/Q0UI7CRXmhBfGUxxNiiCRzwlaKiUZd+m5leck62bKyO9QorIa9eWwTf?= =?Windows-1252?Q?FPoqsBXG5pCga6vYnxLMRE++3jw4lORaDw7cOjXqfofGYdpb1iz3SBw1?= =?Windows-1252?Q?EFTiw9j+SZMJzWheWjfbazcM5uYsD8+RbkL/BVSUKhGiofso6nmcV1gH?= =?Windows-1252?Q?0kPNXovRgJn4prVygVtGZ96KPM8zrMJ+KL2DhUOZLyWfrPWnfbAenkM6?= =?Windows-1252?Q?6qpNxEnft70RDx9DrnJtsm+0twGDFiQY+uepuAbbGjPQ7SmlWY5DwroM?= =?Windows-1252?Q?Ah2EEdCfbi27S+pARUwhw6sNleRA+ncsOYle/JFom+EhNRadm6VDA1lC?= =?Windows-1252?Q?Jc9kw+uAZ2xURsth2eU2orVfNodPo7znABYFvmM0scXmkaK20YZxamx/?= =?Windows-1252?Q?6eejEY/HdglZfFDK4YRmK8MnmHSWFXt0kpYqrmWXMG5UBWe1NKqJfffE?= =?Windows-1252?Q?4v+wclsMWg4UAoQcAvdTVZ4Nw5JqAyIvcFuWYKEws/fB4St4OiDMjSAP?= =?Windows-1252?Q?phq0UA59RIKCYfY9oEq9AYOAQ5gY2zihyI2nuNrLBnfJxcUfU8o/rOvJ?= =?Windows-1252?Q?nL/6sa9szWUuD1i1IeWpEhGFJsox6WoIeuZvQHzwgPf9C5/j63ceLPmL?= =?Windows-1252?Q?ODj2eAYfV7MGYEQTGy0VjVD2DwzhAPTkNdS4vlS72XlcCzGpD09/zNQM?= =?Windows-1252?Q?D5WmYi+OByWAiBgqdy/feg+LyEl+OlTF+xNGEARdp4H+CsnMBis61jdZ?= =?Windows-1252?Q?YO8ohPlgt/MS9uEJTNcVc/hGGktyP4Mm1HsiHUXGj+MbcRM1jbYpjk8o?= =?Windows-1252?Q?SC5xcXbQe0gfjU2yzI9xVcGTnIgH/Rfyi/6p9ioYp1Jw/Fi6ouw8LNLa?= =?Windows-1252?Q?h6avz0XtHnZd4tQtbJZKjH2R/Nq0rRBWBmUDcj4vKRRFLcBe9Qh2wOD6?= =?Windows-1252?Q?aG374eJio9HMcNx2owiMSGac27U5GtYV1DMoJwTR5ZRuthbE33zIvYO3?= =?Windows-1252?Q?Ivv1uD1O2DXLHUsmduy01WWXWSvQReZt3ycOmz0Rnycft/Le0M14tRFB?= =?Windows-1252?Q?HQTPqvD5y8u3jXq5qa+HDkJaHkkv6+DDZ/SDog5u6HKMUUyODKR0QYg8?= =?Windows-1252?Q?G7+mCiun3/rmlL8wuJulkKEL+XEGCB/V2VEK5939Op2kZf+9Fvm/6gmI?= =?Windows-1252?Q?0bY5eNYjNxFHsDCBYqIWVxy6goCclOuMNVtN+U6i532JZkHGmC9WQBhW?= =?Windows-1252?Q?mjzkAh7Lum6p6602t+fLzZ0uuNWh56FIjBdas64COsckOWvNMmHaic3r?= =?Windows-1252?Q?UyeRQz3jHcpZRZCVet3sECv/SAiBfmxekKoDOg0C3aOzLvTn6H+FSiC5?= =?Windows-1252?Q?bJ0zDGG1EDNHYHtNUF2AeSd3Pk2MDUa8A82uTq3Qgqciai2GSavu0BVe?= =?Windows-1252?Q?U9+Fr3zmLzcWmL6uWfdM11XFvK7BW+e2o6jTvoh66dLHa?= X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0737; 6:6iEzem3SuB2H4VF/PG2Zm6xl3xyEgUTSWWfCaqBf8O+JZz/6+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nOC9KECW5XGKqg3K9klbS2doIzypVIjhCSWFicK+QQSxRaSZRUA4rY+1tmBv4kyjUG1dW7iD8fRPcwYymd3oX0pxJsbVCd9DJ16sTGkrULEn8y0cWojQ+cFu3Swt9NajKN+DL1cVRgj2zdBvytSNLbRuQKRI7KH2Og4d9H8DSrEsA== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Dec 2016 13:22:39.0395 (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.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN1PR0301MB0737 Subject: Re: [dpdk-dev] [PATCH v3 04/12] eal/bus: add scan, match and insert support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Dec 2016 13:22:42 -0000 On Friday 16 December 2016 06:40 PM, Shreyansh Jain wrote: > When a PMD is registred, it will associate itself with a bus. > > A bus is responsible for 'scan' of all the devices attached to it. > All the scanned devices are attached to bus specific device_list. > During the probe operation, 'match' of the drivers and devices would > be done. > > Also, rather than adding a device to tail, a new device might be added to > the list (pivoted on bus) at a predefined position, for example, adding it > in order of addressing. Support for this is added as '*bus_insert'. > > This patch also adds necessary test framework to test the scan and > match callbacks. > > Signed-off-by: Shreyansh Jain > --- > app/test/test_bus.c | 265 ++++++++++++++++++++++++++++++++ > lib/librte_eal/common/eal_common_bus.c | 15 ++ > lib/librte_eal/common/include/rte_bus.h | 64 ++++++++ > 3 files changed, 344 insertions(+) > > diff --git a/app/test/test_bus.c b/app/test/test_bus.c > index 760d40a..ed95479 100644 > --- a/app/test/test_bus.c > +++ b/app/test/test_bus.c > @@ -80,12 +80,32 @@ struct dummy_bus { > struct rte_bus_list orig_bus_list = > TAILQ_HEAD_INITIALIZER(orig_bus_list); > > +/* Forward declarations for callbacks from bus */ > + > +/* Bus A > + * Scan would register devA1 and devA2 to bus > + */ > +int scan_fn_for_busA(struct rte_bus *bus); > + > +/* Bus B > + * Scan would register devB1 and devB2 to bus > + */ > +int scan_fn_for_busB(struct rte_bus *bus); > + > +/* generic implementations wrapped around by above declarations */ > +static int generic_scan_fn(struct rte_bus *bus); > +static int generic_match_fn(struct rte_driver *drv, struct rte_device *dev); > + > struct rte_bus busA = { > .name = "busA", /* "busA" */ > + .scan = scan_fn_for_busA, > + .match = generic_match_fn, > }; > > struct rte_bus busB = { > .name = "busB", /* "busB */ > + .scan = scan_fn_for_busB, > + .match = generic_match_fn, > }; > > struct rte_driver driverA = { > @@ -184,6 +204,92 @@ dump_device_tree(void) > printf("------>8-------\n"); > } > > +/* @internal > + * Move over the dummy_buses and find the entry matching the bus object > + * passed as argument. > + * For each device in that dummy_buses list, register. > + * > + * @param bus > + * bus to scan againt test entry > + * @return > + * 0 for successful scan, even if no devices are found > + * !0 for any error in scanning (like, invalid bus) > + */ > +static int > +generic_scan_fn(struct rte_bus *bus) > +{ > + int i = 0; > + struct rte_device *dev = NULL; > + struct dummy_bus *db = NULL; > + > + if (!bus) > + return -1; > + > + /* Extract the device tree node using the bus passed */ > + for (i = 0; dummy_buses[i].name; i++) { > + if (!strcmp(dummy_buses[i].name, bus->name)) { > + db = &dummy_buses[i]; > + break; > + } > + } > + > + if (!db) > + return -1; > + > + /* For all the devices in the device tree (dummy_buses), add device */ > + for (i = 0; db->devices[i]; i++) { > + dev = &(db->devices[i]->dev); > + rte_eal_bus_add_device(bus, dev); > + } > + > + return 0; > +} > + > +/* @internal > + * Obtain bus from driver object. Match the address of rte_device object > + * with all the devices associated with that bus. > + * > + * Being a test function, all this does is validate that device object > + * provided is available on the same bus to which driver is registered. > + * > + * @param drv > + * driver to which matching is to be performed > + * @param dev > + * device object to match with driver > + * @return > + * 0 for successful match > + * !0 for failed match > + */ > +static int > +generic_match_fn(struct rte_driver *drv, struct rte_device *dev) > +{ > + struct rte_bus *bus; > + struct rte_device *dev_p = NULL; > + > + /* Match is based entirely on address of 'dev' and 'dev_p' extracted > + * from bus->device_list. > + */ > + > + /* a driver is registered with the bus *before* the scan. */ > + bus = drv->bus; > + TAILQ_FOREACH(dev_p, &bus->device_list, next) { > + if (dev == dev_p) > + return 0; > + } > + > + return 1; > +} > + > +int > +scan_fn_for_busA(struct rte_bus *bus) { > + return generic_scan_fn(bus); > +} > + > +int > +scan_fn_for_busB(struct rte_bus *bus) { > + return generic_scan_fn(bus); > +} > + > static int > test_bus_setup(void) > { > @@ -391,6 +497,155 @@ test_driver_unregistration_on_bus(void) > > } > > +static int > +test_device_unregistration_on_bus(void) > +{ > + int i; > + struct rte_bus *bus = NULL; > + struct rte_device *dev; > + > + for (i = 0; dummy_buses[i].name; i++) { > + bus = rte_eal_get_bus(dummy_buses[i].name); > + if (!bus) { > + printf("Unable to find bus (%s)\n", > + dummy_buses[i].name); > + return -1; > + } > + > + /* For bus 'bus', unregister all devices */ > + TAILQ_FOREACH(dev, &bus->device_list, next) { > + rte_eal_bus_remove_device(dev); > + } > + } > + > + for (i = 0; dummy_buses[i].name; i++) { > + bus = rte_eal_get_bus(dummy_buses[i].name); > + > + if (!TAILQ_EMPTY(&bus->device_list)) { > + printf("Unable to remove all devices on bus (%s)\n", > + bus->name); > + return -1; > + } > + } > + > + /* All devices from all buses have been removed */ > + printf("All devices on all buses unregistered.\n"); > + dump_device_tree(); > + > + return 0; > +} > + > +/* @internal > + * For each bus registered, call the scan function to identify devices > + * on the bus. > + * > + * @param void > + * @return > + * 0 for successful scan > + * !0 for unsuccessful scan > + * > + */ > +static int > +test_bus_scan(void) > +{ > + int ret; > + struct rte_bus *bus; > + > + TAILQ_FOREACH(bus, &rte_bus_list, next) { > + /* Call the scan function for each bus */ > + ret = bus->scan(bus); > + if (ret) { > + printf("Scan of buses failed.\n"); > + return -1; > + } > + } > + > + printf("Scan of all buses completed.\n"); > + dump_device_tree(); > + > + return 0; > +} > + > +/* @internal > + * Function to perform 'probe' and link devices and drivers on a bus. > + * This would work over all the buses registered, and all devices and drivers > + * registered with it - call match on each pair. > + * Aim is to test the match_fn for each bus. > + * > + * @param void > + * @return > + * 0 for successful probe > + * !0 for failure in probe > + * > + */ > +static int > +test_probe_on_bus(void) > +{ > + int ret = 0; > + int i, j; > + struct rte_bus *bus = NULL; > + struct rte_device *dev = NULL; > + struct rte_driver *drv = NULL; > + > + /* In case of this test: > + * 1. for each bus in rte_bus_list > + * 2. for each device in bus->device_list > + * 3. for each driver in bus->driver_list > + * 4. call match > + * 5. link driver and device > + * 6. Verify the linkage. > + */ This comment style is indeed in a warning from checkpatch. My bad - somehow I missed fixing this before sending out. v4, along with any other major comments/reviews. - Shreyansh