From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0058.outbound.protection.outlook.com [104.47.41.58]) by dpdk.org (Postfix) with ESMTP id 9621B5684 for ; Thu, 17 Nov 2016 06:28:11 +0100 (CET) Received: from BN3PR0301CA0016.namprd03.prod.outlook.com (10.160.180.154) by CY1PR0301MB0746.namprd03.prod.outlook.com (10.160.159.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.734.8; Thu, 17 Nov 2016 05:28:09 +0000 Received: from BN1AFFO11FD033.protection.gbl (2a01:111:f400:7c10::100) by BN3PR0301CA0016.outlook.office365.com (2a01:111:e400:4000::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.734.8 via Frontend Transport; Thu, 17 Nov 2016 05:28:09 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com;nxp.com; dkim=none (message not signed) header.d=none; 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 BN1AFFO11FD033.mail.protection.outlook.com (10.58.52.246) 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 05:28:08 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:; UpperCasedChecksum:; SizeAsReceived:664; Count:10 Received: from Tophie.ap.freescale.net ([10.232.14.87]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id uAH5S1pr018741; Wed, 16 Nov 2016 22:28:07 -0700 From: Shreyansh Jain To: CC: , Shreyansh Jain Date: Thu, 17 Nov 2016 11:00:01 +0530 Message-ID: <1479360605-20558-3-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1479360605-20558-1-git-send-email-shreyansh.jain@nxp.com> References: <1479360605-20558-1-git-send-email-shreyansh.jain@nxp.com> X-IncomingHeaderCount: 10 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131238340888835395; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(979002)(6009001)(7916002)(2980300002)(1109001)(1110001)(339900001)(336004)(189002)(199003)(6666003)(5003940100001)(110136003)(6916009)(97736004)(76176999)(50986999)(5890100001)(2906002)(2950100002)(626004)(8936002)(189998001)(81166006)(81156014)(5660300001)(105606002)(2351001)(106466001)(33646002)(47776003)(48376002)(50466002)(104016004)(8666005)(92566002)(356003)(77096005)(85426001)(86362001)(305945005)(230783001)(87936001)(7846002)(36756003)(4326007)(68736007)(50226002)(8676002)(7059030)(21314002)(217873001)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB0746; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD033; 1:fcNkVw17GWQPoXYWvYFgBiwOKuX48fXKl6yv7sFmh3YSvv3JL17XvILb64afmWgyB5bLcGWpC4Tc98eOLElLYgVtuzk9lshKX9jtIE9/9RS9gnpmHpvWHObNeE4Ba0lrC7eTD7JvphEBsiFJYU9yse5hl9r2vXF75Ou3IB8/vO9ocbbpFsbKIuP8mbW/+rr5tHmzkqdP+YEe4Q3qmgQ4YA5+O7GjaKblxd+Pwm2bw/bkd9QwvUOjtQi/Olw1kaWgUjTsGmdmRX3jnj82oAc2THxCoOKk6oFqD4pVaf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DTg1iP1J+arnTDjqEq6KpeLcDJ1xtNXQWplheTKK34rG2RfWfVRrMZrFLJBqdIALrug6gHUew8iz2yHD4Zf6ITfhYjmg53eZNWFMnB6KhLwWK0ohr8KdZ7maoZqFtHig5wGD15n5GN9hU9/UWjuORnfVUcXue4L1zpK4daGg+vgOd2yeDC9yS6qEls3nDVygiB2rSsDxbNjUuwmtRAQ2xHThLK1jwkk6tr72xibkMj/8u4JHe9ihEQg73K3oOLbcz+5peKc9tIVpK19rhiW01e5GpWhOiCfzC2h7LDXUEgPOVE7D8ZmhIMSnOnbMRvMYfhZhp2bpHBAUcfhqZqH1L9CRcZa21k9w/nyMNbicNkg== X-MS-Office365-Filtering-Correlation-Id: 8843156e-f441-4918-d3e2-08d40eaa840b X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:CY1PR0301MB0746; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0746; 31:A+q2WTWEBTVRln9p4cPukYoUFBD65yPkayBiJezHA09QqdRzHnZ4T3Ns+c4KAJM7eaNco1GsSh9Wl9vFYf0PMMADAy1PJGjfyFgFcVsUOhbePJyaTDo5Cs9aiAUiJacXCuoZ9NVi3/fAm6pGK3xWPTvTf9V3LGruPHM6MXxOqK8+LDsekF8d8Aym71X2cdXujB4LBapyN3WhXZxoXl9HljqcMizadcGZNfOTYRiHQr/HMIk9pl49DJRUjYw36ESGYjecPNDeq7GmN1ZQ0O0A6g==; 4:h2VaeL+efjRL5Mle2RfA2CEXCdNYGqsOMSaHYhqqS0uZ5ltUFIrEZLw3MezqVAL2EGKO5FYWQp33Y97pSPn6F6E49HxuMDh4SrITe9Wl6umrxsnGTTl45nhZMFRuMKPJ203Z8pOeOia0cxmiXQpjuiRficUlcw3mTyqTvul6I2aGLDduVY2BLRbrHVzKJ0IQW64eiBewg1hCtvBTGHwEdC9XQY98QtSQALPc20FF64h5Ve7BrGvp+FJCtW30AaTO8/Yod7yliNXjo/pQulgde9kR6U2yLCxVocFbFJWzbPYswGujX6A3awWomz7AWf02Ax3BQjetQRjY1Bc/3ejoHVBRac8zTmnmuOtXhEwupfA0zmef9wF62WRf1MNcY8XAaGW3gMY319xC2sI0f+J1EsAcpFFxc+JKBIU65/ANcOaQq5WjlPpUVyDpOOQ+TWVhpS+pJgMa+wZx/9RZ9MjlVsymHLlASnJXP6jwIc5yV34oaXusBSWIcSCQHluX9ZzFlUs3T+ur4pxrqaZsiKqY12yY5ViUYqJzV5BaRWdtE/OG6l4etI3zidV1+rbuVW0p8/DSjPOC+FzV4Gda4V35vg== 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)(13024025)(13023025)(13015025)(13017025)(8121501046)(5005006)(13018025)(3002001)(10201501046)(6055026)(6096035); SRVR:CY1PR0301MB0746; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR0301MB0746; X-Forefront-PRVS: 01294F875B X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0301MB0746; 23:cPlsTxcwScvD9JcRM8Dsc+124DgvD3lLzobHHXS?= =?us-ascii?Q?4k+MLoVNqQzacRDWFKpCbRa+pNPjTKP1WXHUB2tR91z1ri7N8nGVlehvDI/9?= =?us-ascii?Q?94B2Pk0T1u0Eh0PaFQ4LOIc0PEbben/ALg5ZYCCk5DcrWAKvRh46X08Y4tSn?= =?us-ascii?Q?XSOpWTvKBzkZ1rU8ZCEx3E3e/N+dnV7xYvY29D3XkhH8diym/pSDn4SdE7ZP?= =?us-ascii?Q?za30WtOm6d+ffhW2DjDhdrumemLBi7EytSx3KJTrfcWtR8I+3ailHDA57dcW?= =?us-ascii?Q?Q/L6l1UwZ9PYbVjz5flIZz2jVEJgahwaH6IBwBFTgof3BQNbMqpVJ2FWLvcI?= =?us-ascii?Q?ns2FCdlkdCK5jQkrp5cp+vunmQsqwrhwYnfufNiacdrpCxhlGn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QqPg9XQkEsvXaWxYw22N+ZS9QaFfVAesl3jG4wEBYgJ28X1PWlkGE8hfhnC?= =?us-ascii?Q?zYA=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0746; 6:Ebze/4yI719twnp5EvQ2KC3+4mHTlcV6l0NqwL57FfVYVKXnv/Fx9Y9ofKVrnmc+ghCr+aiNdV4OaxH3Uh9atG4rTGwTOBLhy09u06vVlR9FaSmtWdbhSPVBe7USfWE3lFMktRF4REz3SSPmDNAcjAY80VkvnDA8eI06fWm+PKTSydI8FXji5SLA9JCtNmlJmf+/ZXbA3ZYzGPEfEx37x+a7KVJ7lczz5mOBjzk4D3jjZKmMmKFGG78lce4b36XbPy0X36wSC1idL4TymQrYmOdaQ1BfL54MZOjgGYD5rsaS3r3snsDRrSriQVCHoAOQ1DZ1NY9xeE+T85gaT+vxgA==; 5:4Vb9VDMjVq+a+4MdS+1OzxR5iU46nm2SD0YFr7/nt2flO27i64PCZc8v3r3friL/wrStCmeqIpBdp6frVeZ0/fEXlx8AI7ChOtecHvVKu7kN9ywK5PCBtlMVA0eq6cD/xHAFJAPIHE727mVm553xxjvUVvKXurMQc55cg1FgE5w1IJogMRGnmYNvYCxJPHyg; 24:BB7Z1lpXX59TxvBQmXcj7kAehWAGLJF2Yww7ZaCgJS9NHfA2Wz3jzH6hkThJmjt+e2KLeDOUuLO8vMcxW+3CyN44aPkka+UCA7c8LJbMOl8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0746; 7:e/MR0ThTtwpKRBtZGqKgCH6dLr6TYFtu4Q8A1ukRIZWwi90fhK1efC5rpe4qythbECvtq3PWPN2UhdXU+a4k3Xk4OFKO20J0AnYL8r4FRXb24ZUav0Juf3LfAMo13pY67EOEbLjYu+Ng/DaGNZC10akfJxOeXO1rI94/1ZKElC67gtxY06dFypAQya/vtbs2PDtAOgoWqnj1u3a77aqaJJE6wBRNHMe1Qs/72UWPJ+w6g0DV69fzEWgGsirTZZ/REvtYB0kWBJn5B7k5NsSuodOjyjbpVch9uzqcU0p5/Npd0KpxLIjRrYin0tJwzPtxNOxiJwWaf3CQtTsNo5RPNDvTVTjI7UT9AC6OaTiPSo8= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2016 05:28:08.6963 (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: CY1PR0301MB0746 Subject: [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 05:28:12 -0000 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. 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); + +/** + * 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); + +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 */ + struct rte_device_list device_list; /**< List of all devices on bus */ + 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); + +/** @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); + +/** @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 */ + const char *name; /**< Driver name. */ + const char *alias; /**< Driver alias. */ + driver_init_t *init; /**< Driver initialization */ + driver_uninit_t *uninit; /**< Driver uninitialization */ + unsigned int dev_private_size; /**< Size of device private data ??*/ +}; /** * Initalize all the registered drivers in this process -- 2.7.4