From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0085.outbound.protection.outlook.com [104.47.36.85]) by dpdk.org (Postfix) with ESMTP id 129D45594 for ; Thu, 17 Nov 2016 13:57:49 +0100 (CET) Received: from BN6PR03CA0026.namprd03.prod.outlook.com (10.175.124.12) by CY4PR03MB2470.namprd03.prod.outlook.com (10.168.163.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.707.6; Thu, 17 Nov 2016 12:57:47 +0000 Received: from BY2FFO11FD013.protection.gbl (2a01:111:f400:7c0c::119) by BN6PR03CA0026.outlook.office365.com (2603:10b6:404:10c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.721.10 via Frontend Transport; Thu, 17 Nov 2016 12:57:47 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; infradead.org; dkim=none (message not signed) header.d=none;infradead.org; 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 BY2FFO11FD013.mail.protection.outlook.com (10.1.14.75) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.721.5 via Frontend Transport; Thu, 17 Nov 2016 12:57:47 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:; UpperCasedChecksum:; SizeAsReceived:967; Count:13 Received: from [10.232.14.87] ([10.232.14.87]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id uAHCvhd1020779; Thu, 17 Nov 2016 05:57:44 -0700 To: Jan Blunck References: <1479360605-20558-1-git-send-email-shreyansh.jain@nxp.com> <1479360605-20558-3-git-send-email-shreyansh.jain@nxp.com> CC: David Marchand , From: Shreyansh Jain Message-ID: <1dd1d34a-6e67-3e01-6d53-48222032cdb5@nxp.com> Date: Thu, 17 Nov 2016 18:30:00 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-IncomingHeaderCount: 13 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131238610673330244; (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)(1110001)(1109001)(339900001)(336004)(57704003)(377454003)(24454002)(189002)(199003)(7846002)(97736004)(64126003)(305945005)(92566002)(4001350100001)(189998001)(6666003)(2950100002)(4326007)(8676002)(5890100001)(626004)(2906002)(106466001)(110136003)(6916009)(68736007)(86362001)(31696002)(8936002)(5660300001)(105606002)(230700001)(50466002)(31686004)(36756003)(87936001)(356003)(33646002)(230783001)(23676002)(83506001)(81156014)(81166006)(85426001)(77096005)(65956001)(76176999)(54356999)(104016004)(65806001)(47776003)(229853002)(65826007)(50986999)(21314002)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR03MB2470; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD013; 1:TucfsLZ9cAAdKGgUHghoYtcNZgj0RO3mAdpIVYn8/IQQVf5dK41tFlLBQC3dMS0GRfqGb5tqhBhmntIIT7VLufAqdk74Us+DiipQxAQ2TW17g63LCxs8XkiQLB/bMHeUnpMSM6VGicU5y9S/1lx9GtuDFbATJCmriNhfAmHY7xQECvL9xCLeGD3Tp0JxLNYXmafCcMIahy2wopY+QLRalsh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b3AOuNicysvI8FoCKR/HXuqCmcc6EMg7WyDkjISLEdoN1s0gaeIqJe3vXbKsBG36zXeYzvsbclXCcwRGwRt6p7miNQzqBw+vILmTh4PVnJtCJzRpxLvoX4TbYo2SadCcVnOBstNRuyj8cylVXcXtOaAlArZz+3Af02KLWhAJn2WqktpXuXldFOmCT+rFiLolSQxm90QYWso07TOZePNeKsaHGucKe1J5czz4ERz0NBodUZMmLNE1xU52u3ts9w+OEG3kwC+ug+ZtKhUhf5Q== X-MS-Office365-Filtering-Correlation-Id: 9349d66c-2760-460f-dd3c-08d40ee95463 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:CY4PR03MB2470; X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2470; 31:HC6s0vnQF/whBNoD7gwK9qgJeX2i6ekC5Qr0Ip1+13cf4uF80sZmZdYd+7I+yphuJDlSRcH9ydfCH/1qn2MXSJ+BXdAPeBNVDsG/qh6AXVnrB9u+SjhnZ+zLei12EFiWntp6Lccb+jlLWrPSXGRZ7NyKODIOsYByx9aMRBxrKyl3SyMAkh9LwPnbtsuNuu87e8PeSMuzHcfQ4IXNCCNRKN+Nkl/udo4Fvh686BfGLjmHYCcjO7JzUwiCxJrxqiluTasjDRJ3DgxT8Ote2iS85g==; 4:docvOQkdmDugR2RRlNey701zgW7m8XQv617z91xYz48AQhmvsiJibaLnD7rVKpYWB7zbkaU+GBl81jLWiNKuKgjA6WRX5s81TXDJRXjzbW1I/bsXagFuAYd2y4ZeFlKzvovwhzoT0RE4o9tHx/l0ebY1YhS6mXh7DmvOBRDzPzzXIkaYKaiW5/2XPMLKAR1eYlRkBDKERn2IaMYr/86EXTQoEekjf2VdDKWXFGSG77za5Ew3DUF4HElD2WnmTLPhZ0xAdo9xWMRY/wP+v0qPOJZvDYigaTBqprVl9PGUa4L0iREeOBU9qTOPMmMmh75/AKcfKLURcVacHSjoybYb5gQgCaTM8aExa7qn4Ns91UGX07DrkzGFpR+s2TwQueVBT+yAqLwFv6hnBnCnkIfLr/LItyNDUAy6mXlXPc05wa4HYzdp36+00dg9VU3sy3DvoiqVsLLHSQwq6OE9kd56wZ11mxYqWZnS+rOi+5+GMEO3MeuT1NNEAE2t4wmnSJ9c8v/0Rp7ycPSWc/CQJ4IqVtcbFXE16xqIJUdojs4fAkWp8uJmDgPe1FnPrzBXCK3rLdvni7VV0nRBY5rVdM7fkg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095035)(601004)(2401047)(8121501046)(13015025)(13017025)(13024025)(13018025)(5005006)(13023025)(3002001)(10201501046)(6055026)(6096035); SRVR:CY4PR03MB2470; BCL:0; PCL:0; RULEID:(400006); SRVR:CY4PR03MB2470; X-Forefront-PRVS: 01294F875B X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTRQUjAzTUIyNDcwOzIzOnB4Wlp2N0ZHQmJ6L1JUZ0Ird2lCWWQxNGg5?= =?utf-8?B?QjZuSmVCd05UWE5xZUw5bUowSXFTNDhrajlrVHcrdCtKOC9acnovN1BmbTl4?= =?utf-8?B?by9FdVBJbmMyK0hkQy9WNnl6dXhBV21DRldmeUVRREswclh6Qm9UcTcwWXZT?= =?utf-8?B?ME1DeG9Yc24vSkNmdW51Q3h0QnFlRVRHbmRuZW96aVliVkpIS3dta0JHUEVq?= =?utf-8?B?c3NNbDMwZ2N3Ulk1aGV1VEszRkd2ZlpmRVE0QVQ2L2pIZkViYlVTSGxaRUZl?= =?utf-8?B?elFxNTd1K2JTdlRsQXJvK3R5MjBkdldrZnBxVzhaZ2dZbVBWenJHN2F1SnRi?= =?utf-8?B?ZVlhM1ROY3plWCszNEpVMEVHN1ZiYUFINTR6SHRvNGZqUStxMUNNbEYrdzVF?= =?utf-8?B?YVhSK0Y0SWtGSGhwbGVvMXBrbWt0djdmRmszNzdZOU9wWHp0S2toM0YwRFgz?= =?utf-8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+on2OEyoMr+OhT6m0mCqyuQkOPHZrIwAmiKyegOjS+ABfvH8FANy19vRB3AxmYZfF0giygBbiJhErQVoEJn/zUIp0pU3BFUDKct4YFQBKuEr2teD2SuDnltYovI0jF0G; 24:txnok/E07lLa1wNx6ZaTJ7fo3NZBxjA2ZgwdMH49qRU0OiGr1RfeUTAtUyoJl2iJdkIFtwK9cgvJQEmrI9O1zZe0vvbTz1p8GC0SKHlLPyE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2470; 7:KdNqpS+AZUBitTyHo3GjFPWgaDXYhzNgAnh9B89I+RlihM9HiOjd4oCfnYiIfbo7CKj1fH9Dz9PR6+I7v6+3stgnFnei9zhRNNFFx+s+4WV/+vsnmwwHXcBrdhiUsm2pMpqWlGOvyYu1CoXhpS3vFO8yHhsYiat7DbuXdwoNiI4B9mvYunIEMgmxre6coes+GLfkBJ70JVm7s918jHV+yz28UorahREcW1VnShUj3FsQPLqf6GJ/IrwU56NmRw8KdLf8MU7vlyNr4ZiDqVc7c9/DocWCqS5VU1rPk9Y+uErujvtm0t0CAYzH8lAw//D3+8G3rl6An7C+RWUIdFdFAOEXmOH0j+5b8xgoF7/iBH4= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2016 12:57:47.0210 (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: CY4PR03MB2470 Subject: Re: [dpdk-dev] [RFC PATCH 2/6] eal: introduce bus-device-driver structure 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: Thu, 17 Nov 2016 12:57:50 -0000 Hello Jan, Thanks for comments. Replies inline. On Thursday 17 November 2016 04:49 PM, Jan Blunck wrote: > On Thu, Nov 17, 2016 at 6:30 AM, Shreyansh Jain wrote: >> A device is connected to a bus and services by a driver associated with >> the bus. It is responsibility of the bus to identify the devices (scan) >> and then assign each device to a matching driver. >> >> A PMD would allocate a rte_xxx_driver and rte_xxx_device. >> rte_xxx_driver has rte_driver and rte_bus embedded. Similarly, rte_xxx_device >> has rte_device and rte_bus embedded. > > I don't think so: the rte_xxx_device embeds the generic rte_device and > references a the rte_bus > that it is attached to. You mean? struct rte_pci_device { struct rte_device device; struct rte_bus *bus; ... } If yes then I have a different view. 'device' is connected to a bus. pci_device is just a type of device. Only way it should know about the bus is through the parent rte_device. rte_device can reference the bus. > >> When a ethernet or crypto device (rte_eth_dev, rte_cryptodev) is allocated, >> it contains a reference of rte_device and rte_driver. >> Each ethernet device implementation would use container_of for finding the >> enclosing structure of rte_xxx_*. >> >> +-------------------+ >> +--------------+ |rte_pci_device | >> |rte_eth_dev | |+-----------------+| >> |+------------+| .-------->rte_device || >> ||rte_device*-----' |+-----------------+| >> |+------------+| ||rte_bus || >> | | |+-----------------+| >> / / +-------------------+ >> >> Signed-off-by: Shreyansh Jain >> --- >> lib/librte_eal/common/include/rte_bus.h | 243 ++++++++++++++++++++++++++++++++ >> lib/librte_eal/common/include/rte_dev.h | 36 ++--- >> 2 files changed, 261 insertions(+), 18 deletions(-) >> create mode 100644 lib/librte_eal/common/include/rte_bus.h >> >> diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h >> new file mode 100644 >> index 0000000..dc3aeb8 >> --- /dev/null >> +++ b/lib/librte_eal/common/include/rte_bus.h >> @@ -0,0 +1,243 @@ >> +/*- >> + * BSD LICENSE >> + * >> + * Copyright(c) 2016 NXP >> + * All rights reserved. >> + * >> + * Redistribution and use in source and binary forms, with or without >> + * modification, are permitted provided that the following conditions >> + * are met: >> + * >> + * * Redistributions of source code must retain the above copyright >> + * notice, this list of conditions and the following disclaimer. >> + * * Redistributions in binary form must reproduce the above copyright >> + * notice, this list of conditions and the following disclaimer in >> + * the documentation and/or other materials provided with the >> + * distribution. >> + * * Neither the name of NXP nor the names of its >> + * contributors may be used to endorse or promote products derived >> + * from this software without specific prior written permission. >> + * >> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >> + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >> + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >> + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >> + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >> + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >> + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >> + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >> + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >> + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >> + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >> + */ >> + >> +#ifndef _RTE_BUS_H_ >> +#define _RTE_BUS_H_ >> + >> +/** >> + * @file >> + * >> + * RTE PMD Bus Abstraction interfaces >> + * >> + * This file exposes APIs and Interfaces for Bus Abstraction over the devices >> + * drivers in EAL. >> + */ >> + >> +#ifdef __cplusplus >> +extern "C" { >> +#endif >> + >> +#include >> +#include >> + >> +#include >> +#include >> + >> + >> +/** Double linked list of buses */ >> +TAILQ_HEAD(rte_bus_list, rte_bus); >> + >> +/** >> + * Bus specific scan for devices attached on the bus. >> + * For each bus object, the scan would be reponsible for finding devices and >> + * adding them to its private device list. >> + * >> + * Successful detection of a device results in rte_device object which is >> + * embedded within the respective device type (rte_pci_device, for example). >> + * Thereafter, PCI specific bus would need to perform >> + * container_of(rte_pci_device) to obtain PCI device object. >> + * >> + * Scan failure of a bus is not treated as exit criteria for application. Scan >> + * for all other buses would still continue. >> + * >> + * @param void >> + * @return >> + * 0 for successful scan >> + * !0 (<0) for unsuccessful scan with error value >> + */ >> +typedef int (* bus_scan_t)(void); >> + >> +/** >> + * Bus specific match for devices and drivers which can service them. >> + * For each scanned device, during probe the match would link the devices with >> + * drivers which can service the device. >> + * >> + * It is the work of each bus handler to obtain the specific device object >> + * using container_of (or typecasting, as a less preferred way). >> + * >> + * @param drv >> + * Driver object attached to the bus >> + * @param dev >> + * Device object which is being probed. >> + * @return >> + * 0 for successful match >> + * !0 for unsuccessful match >> + */ >> +typedef int (* bus_match_t)(struct rte_driver *drv, struct rte_device *dev); > > Do you think this should do match & probe? It is only matching as of now. rte_eal_probe() from eal.c calls this function for the bus and probe for each device of that bus. (Look at 'pci_probe_all_drivers' called from rte_eal_pci_probe). > > I believe it is better to separate this into two functions to match() > and probe(). The > result of matching tells if the driver would want to claim the device > in general. But > probe()ing the device should only happen if the device isn't claimed > by a driver yet and > is not blacklisted. Agree. This is what rte_eal_pci_probe() is doing for PCI. Similar implementation would exists in bus specific area (this is a different debate where...) for probe on each driver (associated with that bus). > >> + >> +/** >> + * Dump the devices on the bus. >> + * Each bus type can define its own definition of information to dump. >> + * >> + * @param bus >> + * Handle for bus, device from which are to be dumped. >> + * @param f >> + * Handle to output device or file. >> + * @return void >> + */ >> +typedef void (* bus_dump_t)(struct rte_bus *bus, FILE *f); >> + >> +/** >> + * Search for a specific device in device list of the bus >> + * This would rely on the bus specific addressing. Each implementation would >> + * extract its specific device type and perform address compare. >> + * >> + * @param dev >> + * device handle to search for. >> + * @return >> + * rte_device handle for matched device, or NULL >> + */ >> +typedef struct rte_device * (* bus_device_get_t)(struct rte_device *dev); > > From my experience it is better to delegate this to a helper: > > int bus_for_each_dev(struct rte_bus *bus, struct rte_device *start, > int (*match)(struct rte_device *dev, void *data), void *data); > > Based on that you can easily implement all kinds of functions like > bus_find_dev(), bus_find_dev_by_name(), bus_dump(), ... Interesting idea. Thanks. I will have a look on this. > >> + >> +struct rte_bus { >> + TAILQ_ENTRY(rte_bus) next; /**< Next bus object in linked list */ >> + struct rte_driver_list driver_list; /**< List of all drivers of bus */ > > TAILQ_HEAD? Yes. That should be TAILQ_HEAD. I just reused the definition create in rte_dev.h using TAILQ_HEAD. I will change this. > >> + struct rte_device_list device_list; /**< List of all devices on bus */ > > TAILQ_HEAD? Same as above. I will change this. > >> + const char *name; /**< Name of the bus */ >> + /* Mandatory hooks */ >> + bus_scan_t *scan; /**< Hook for scanning for devices */ >> + bus_match_t *match; /**< Hook for matching device & driver */ >> + /* Optional hooks */ >> + bus_dump_t *dump_dev; /**< Hook for dumping devices on bus */ >> + bus_device_get_t *find_dev; /**< Search for a device on bus */ >> +}; >> + >> +/** @internal >> + * Add a device to a bus. >> + * >> + * @param bus >> + * Bus on which device is to be added >> + * @param dev >> + * Device handle >> + * @return >> + * None >> + */ >> +void >> +rte_eal_bus_add_device(struct rte_bus *bus, struct rte_device *dev); > > Why do we need this? From my understanding the rte_bus->scan() is > adding the devices to the rte_bus->device_list. Plugging a device *after* scan has been completed. Hotplugging. Specially for vdev, this would be required, in my opinion. > >> +/** @internal >> + * Remove a device from its bus. >> + * >> + * @param dev >> + * Device handle to remove >> + * @return >> + * None >> + */ >> +void >> +rte_eal_bus_remove_device(struct rte_device *dev); >> + >> +/** @internal >> + * Associate a driver with a bus. >> + * >> + * @param bus >> + * Bus on which driver is to be added >> + * @param dev >> + * Driver handle >> + * @return >> + * None >> + */ >> +void >> +rte_eal_bus_add_driver(struct rte_bus *bus, struct rte_driver *drv); >> + > > What happens if a driver is added at runtime to a bus? Does that immediately > trigger a match & probe of unclaimed devices? My take: - scan the bus for any newly plugged devices. Might be required in case a device is logical entity represented by multiple entries in sysfs. -- add only those which are not already added - maybe address/id match - Trigger driver probe for all devices which don't have a driver assigned to them (unclaimed, as you stated). (This is part of my further changes - I think I forgot to put them as note in cover letter). > >> +/** @internal >> + * Disassociate a driver from its bus. >> + * >> + * @param dev >> + * Driver handle to remove >> + * @return >> + * None >> + */ >> +void >> +rte_eal_bus_remove_driver(struct rte_driver *drv); >> + >> +/** >> + * Register a Bus handler. >> + * >> + * @param driver >> + * A pointer to a rte_bus structure describing the bus >> + * to be registered. >> + */ >> +void rte_eal_bus_register(struct rte_bus *bus); >> + >> +/** >> + * Unregister a Bus handler. >> + * >> + * @param driver >> + * A pointer to a rte_bus structure describing the bus >> + * to be unregistered. >> + */ >> +void rte_eal_bus_unregister(struct rte_bus *bus); >> + >> +/** >> + * Obtain handle for bus given its name. >> + * >> + * @param bus_name >> + * Name of the bus handle to search >> + * @return >> + * Pointer to Bus object if name matches any registered bus object >> + * NULL, if no matching bus found >> + */ >> +struct rte_bus * rte_eal_get_bus(const char *bus_name); >> + >> +/** >> + * Register a device driver. >> + * >> + * @param driver >> + * A pointer to a rte_dev structure describing the driver >> + * to be registered. >> + */ >> +void rte_eal_driver_register(struct rte_driver *driver); >> + >> +/** >> + * Unregister a device driver. >> + * >> + * @param driver >> + * A pointer to a rte_dev structure describing the driver >> + * to be unregistered. >> + */ >> +void rte_eal_driver_unregister(struct rte_driver *driver); >> + >> +/** Helper for Bus registration */ >> +#define RTE_PMD_REGISTER_BUS(nm, bus) \ >> +RTE_INIT(businitfn_ ##nm); \ >> +static void businitfn_ ##nm(void) \ >> +{\ >> + (bus).name = RTE_STR(nm);\ >> + rte_eal_bus_register(&bus); \ >> +} >> + >> +#ifdef __cplusplus >> +} >> +#endif >> + >> +#endif /* _RTE_BUS_H */ >> diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h >> index 8840380..b08bab5 100644 >> --- a/lib/librte_eal/common/include/rte_dev.h >> +++ b/lib/librte_eal/common/include/rte_dev.h >> @@ -116,12 +116,14 @@ TAILQ_HEAD(rte_device_list, rte_device); >> >> /* Forward declaration */ >> struct rte_driver; >> +struct rte_bus; >> >> /** >> * A structure describing a generic device. >> */ >> struct rte_device { >> TAILQ_ENTRY(rte_device) next; /**< Next device */ >> + struct rte_bus *bus; /**< Bus on which device is placed */ >> struct rte_driver *driver; /**< Associated driver */ >> int numa_node; /**< NUMA node connection */ >> struct rte_devargs *devargs; /**< Device user arguments */ >> @@ -144,31 +146,29 @@ void rte_eal_device_insert(struct rte_device *dev); >> void rte_eal_device_remove(struct rte_device *dev); >> >> /** >> - * A structure describing a device driver. >> + * @internal >> + * TODO >> */ >> -struct rte_driver { >> - TAILQ_ENTRY(rte_driver) next; /**< Next in list. */ >> - const char *name; /**< Driver name. */ >> - const char *alias; /**< Driver alias. */ >> -}; >> +typedef int (*driver_init_t)(struct rte_device *eth_dev); >> >> /** >> - * Register a device driver. >> - * >> - * @param driver >> - * A pointer to a rte_dev structure describing the driver >> - * to be registered. >> + * @internal >> + * TODO >> */ >> -void rte_eal_driver_register(struct rte_driver *driver); >> +typedef int (*driver_uninit_t)(struct rte_device *eth_dev); >> >> /** >> - * Unregister a device driver. >> - * >> - * @param driver >> - * A pointer to a rte_dev structure describing the driver >> - * to be unregistered. >> + * A structure describing a device driver. >> */ >> -void rte_eal_driver_unregister(struct rte_driver *driver); >> +struct rte_driver { >> + TAILQ_ENTRY(rte_driver) next; /**< Next in list. */ >> + struct rte_bus *bus; /**< Bus which drivers services */ > > I think this should be TAILQ_ENTRY instead. rte_bus `-> device_list-. <- TAILQ_HEAD (rte_device) | rte_pci_device:TAILQ_ENTRY(rte_device) rte_device just references the bus it belong to. Am I missing something? > >> + const char *name; /**< Driver name. */ >> + const char *alias; /**< Driver alias. */ >> + driver_init_t *init; /**< Driver initialization */ >> + driver_uninit_t *uninit; /**< Driver uninitialization */ > > Shouldn't this be probe() and remove()? rte_xxx_driver already includes probe and remove. Mandate for init is to allocate the ethernet or cryptodev (or some other functional unit). Whereas, probe is responsible for driver specific intialization - PCI specific, in case of PCI driver. Initially I had thought of moving rte_pci_driver->probe() to rte_driver. But, I couldn't understand where would functional device initialization exist. It cannot be rte_xxx_driver. It should be generic place. Such functional device initialization is in path of the probe function, but so does driver specific information. If we remove rte_pci_driver->probe and move to rte_driver->probe(), it would only mean rte_driver calling a hook within the PCI driver specific domain. > >> + unsigned int dev_private_size; /**< Size of device private data ??*/ > > I don't think that dev_private_size is really required at this level. > First of all this is related to the rte_eth_dev structure and > therefore it really depends on the driver_init_t (aka probe()) if it > is actually allocating an rte_eth_dev or not. Anyway that is up to the > drivers probe() function. I moved it based on input through ML (or IRC, I don't remember). My understanding: if this is common for all rte_xxx_driver instances (for allocating their ethernet/crypto structure), it would actually make sense to keep at this level so that init() can use it for allocating necessary space before handling over the rte_xxx_driver. But again, I am OK keeping it in the underlying layer - as you have rightly pointed out, it would only be used at rte_xxx_driver layer. > >> +}; >> >> /** >> * Initalize all the registered drivers in this process >> -- >> 2.7.4 >> > - Shreyansh