From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0056.outbound.protection.outlook.com [104.47.33.56]) by dpdk.org (Postfix) with ESMTP id 1CC448D9C for ; Tue, 20 Sep 2016 14:42:52 +0200 (CEST) Received: from DM2PR03CA0028.namprd03.prod.outlook.com (10.141.96.27) by CY4PR03MB2438.namprd03.prod.outlook.com (10.168.163.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.619.10; Tue, 20 Sep 2016 12:42:50 +0000 Received: from BL2FFO11FD013.protection.gbl (2a01:111:f400:7c09::188) by DM2PR03CA0028.outlook.office365.com (2a01:111:e400:2428::27) 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; Tue, 20 Sep 2016 12:42:50 +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 BL2FFO11FD013.mail.protection.outlook.com (10.173.160.221) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.629.5 via Frontend Transport; Tue, 20 Sep 2016 12:42:49 +0000 Received: from Tophie.ap.freescale.net ([10.232.14.87]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id u8KCexsh006559; Tue, 20 Sep 2016 05:42:46 -0700 From: Shreyansh Jain To: CC: , David Marchand , , Thomas Monjalon , Shreyansh Jain Date: Tue, 20 Sep 2016 18:11:27 +0530 Message-ID: <1474375296-26078-16-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1474375296-26078-1-git-send-email-shreyansh.jain@nxp.com> References: <1466510566-9240-1-git-send-email-shreyansh.jain@nxp.com> <1474375296-26078-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131188489698521148; (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)(189002)(199003)(7846002)(5003940100001)(92566002)(305945005)(626004)(356003)(8666005)(36756003)(5660300001)(50466002)(189998001)(48376002)(33646002)(85426001)(19580395003)(19580405001)(87936001)(105606002)(2906002)(76176999)(97736004)(50226002)(106466001)(575784001)(86362001)(50986999)(8676002)(5890100001)(68736007)(47776003)(110136003)(81156014)(104016004)(586003)(8936002)(4326007)(11100500001)(77096005)(2950100001)(229853001)(81166006)(2351001)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR03MB2438; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD013; 1:9v6us/ljnUPbUHb/d2r3lbR++SO432ed+cuAmQIndMLhfAx9nJXoReDWZVI0i55unkgZ/M5/BXqbCiCNmQPl5cN27k5HGtQKPOlGAmrxn3zv6R8Fn6YhS5IAsIMqbM5iO+aKwe1H5x7rcGUHiLXdR+IXFihjloI/4OTy4kxnA7L1ARLJ4NBzaPfGmOe21pKkY9N2eQV1uXakzfiopI3Y2WwFAj9PTGaYbJB8BodSL7grwRmS4SmzYUJcMSwt3LRJYVtEGb/vqxGg35HdcB64wPUuWtjpXVSsRN+0Evzi8ONIrZJP34etjwn2YDhNCd7z8am+R9E34/mYLprotmTkI19+dznkG+5bK1xygjXhJHaQ3szjhnM6otuGXGfXtlUU9D0S4lLayDvnI5d9cYCbHIzDAQsw7MBazYxq20TWw4cjXZn1ydj/59EUAbsb33kxX79BU68esD2CLFGdfyxtOWUY1dwux+iU0DeYr4z4HSFXOlDby4cJJmGPPg0RCAA+qane8RzhqgM93g2x1HVpIfnCnjo7mVtho3fdBqgvynoWV2fhNvKadUljrl5mW5tt3+ye2kraXIOUUblvgZ4LOl+lu4+FSTFWZoxntlfpE/P+nup1BGyNKcwVaPI78PjIWpxTNjzDaBavYBszeozKQeSNPSaq35xnNUAlxIXeRekGV9xtkfcFIZiarbei+KSrFz8qgVcUt+5wODNG/FS2YtqlUiXjS/B4T2iwXvSpNgE= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 11c8599e-843a-4f53-4edb-08d3e153a18e X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2438; 2:kmVf3HcuaUe5RU7NEvfnuupxTEY3hU8YyRR+YWIjrPbi7/osV4KZJh8wxZIui/yzfnfE5JDW0GzJ+H0vqhT9dJ5WE1EljtnKgE4drm6ci3l6M1nK7/EttNTwUEOWg7O9oapTDXlBkXBU1mqmH8C7TNKM4dtUttXsY0m+G2viUjmUJmbPbOUF1Dl1riD06TGt; 3:igOV2Fbr34uQ2haxdHx/WUqw8zJeh1hwl01Kw60z5F7ZeGK+r3PIKzG+O5SPoixi30lYdIBuN5O9CbPjbHUJZP/Yxqkt2meXJbbi4xtDo9/sFbAiKoMZdwhJQueN6oNSNXwVSwaEs596cfnuiWj9GClw5BGtf6/QWgGMZPv2xT3QCbUrmEHjvJepWh/zp1AwmZ0tGrlDoogHmaF8X4aYwUv6rzl2bUySp/mhZ02MeqU=; 25:t0MpvTOGvJ53EH4wF8kqpAP9hTktSN1fKEGB779tJVNJSazIsIf8uG8UhaIyY9x4Ge3M9hWOttCy/0bVZnC7aPENMz1Ct+/0e8mgNeLjEOYkypmU7WxDylbH4NHBOPmX656vDsTRkDEyX63HCb2oLRmyOjqaM2AeFMZPxzT3Zu4FwvNEEt1pJjk/FdgEGXtwkKKSaxiL+w+tlMPoRojuGHRdvbtpWp7sYO4u1oIEBQDtv+LUBjy91RDfCoeM9TpfSRkHCcLinXRxfsGgjYwo43h3wFZ/dlgupwT346nu6GrfEk4MmSoBJ7qC5/BTCOWDITN6DuMtfF2+ZX0gJdv5HgJLBjdCgyv3PyLbhnHsaU8gDB8vDqjOc2FVoPIFjSv8aSwEZLRLqIuoOwF0rlrCF+0/xrKYLeNDn9xayBJjcy4= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY4PR03MB2438; X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2438; 31:p43COvm4U7WnGIAJ2keilIHEBwV4sMNVi769SDMwRgIM62OCeCNm/qPgsLngRa303wfAL63i5yLvcHuvDqNphj2QNXQMLEddmv8epP1GI2/K6gY+0wfClVqU20NqqgihEWUoH7Jv5Q0LCXDWldocPUZKiUENDcxf7+gg+IhHmuLnfDBQWkaGiNJNAMoI9rT8a333gJcbFi1yZBffqDf5aFcvIJFB2bp2Vv635/A/Qtk=; 4:cWZg+Fa3Freg98mQKR+NJzbF4ElUE7OZiY4sfnHLrnd5oLIYdBV6j4lT6u/lFl9tOhv8TY64SwzA8SJuyCxxc2y9yM8f2mn/8Mx7tPtd0leQ8AGHgAQWe/WGJ0vorxzsMGu8ZXUItCadFnADP8SIDOIQGhJL9F07QyNzGU1nxO2EBSUzoTbRhlpyVzWH7fh6jtiCxuE4mAvkOO8QOJWlVY+cRxrX8WeRHz+Bf9Y/nBH7O0ge7NiHz+aTl97oJgfvgojmSssZ6491kKIjQbRYQG1bEK+Oo/OAVU4wT6CLMdUxVVJvPzeQaoQr8+qLxmu43U8xOrsXN+vtZr7ErB1TJCs+pYD6uyiHIs3kNjxod9y3hAvSiDt3sd+8Qtide0sGlt7ltGQaTiPcajWLWg4O+RbH5FTv4l+clb4SPtuhvkUnIRmT1g0BWj/4j5f3aBAMB+vu5ejWvftxr1eUIb+CVltAxkb38GX+o1S42rCVXahWb4Q01QgJBfi5Kp8hHpTKCnJK0SAGsOpVcGNN33hAm9WIi+MOYe+zErKjNL0kR709fJXIvR3XjNPjib4vMO/sdg3rWja8fH9nFQYi2WSXdA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(17755550239193); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(13017025)(13015025)(8121501046)(13023025)(13018025)(13024025)(5005006)(10201501046)(3002001)(6055026); SRVR:CY4PR03MB2438; BCL:0; PCL:0; RULEID:(400006); SRVR:CY4PR03MB2438; X-Forefront-PRVS: 0071BFA85B X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR03MB2438; 23:OYuS4TGoFq9dJpJy/pUEJPW3LUpH+33NZB0EaFHBx?= =?us-ascii?Q?mrhTOpgiIRJwdvI+Blq3e1RVeZ10crvgN69smwWYoXM8bkazO5NZzkj6bWP4?= =?us-ascii?Q?Oh6GCOXqRK5ZTYBW80zxqjUk2Vq1BV5FkK41/+9q4ZW+iUHtCo2UygFQ11h4?= =?us-ascii?Q?iFCJx5HRf2yrC8CVqTRvpg6frsalX/ItAlHS9Q0sNEa1CWfcWv8GTEWoe/p0?= =?us-ascii?Q?AyKZgHZSHV6cnLMEHX7pzKjhvrybfVssjvs914ufSiIyiaNPJhZx7xCHcZqI?= =?us-ascii?Q?gjxbyblrUewwo2a0eskUUic7psDb6jbgZtwYs+uzs7mnOhRotBShgCZXkf3Y?= =?us-ascii?Q?aaM3Kw0pgaajgwzSyPWAtPPhqduqJENRem3YgEdEoUftwi30MVGWiSmnCo6l?= =?us-ascii?Q?kEKqzjvSacoVNecm4kCv8cj4nK0493leupm3C95+mDiAkVv7qypkug/HAjkP?= =?us-ascii?Q?6aJwlNJRIVzGZdaU50Un7cHoRGTj/6V/vgUoF9Cmdnl/ezeNOVhMAhvGp5VW?= =?us-ascii?Q?46qM+1LJFetUfJMGSVqnhN0pNdpRI+Egnd2huIuAK38GMMnQQXFgXJ9XePnR?= =?us-ascii?Q?FsT8hQkizaiEIxVQ+4DiVPMFkTdnr0II+TpOTEM7csPiLDk8RJh0ibnUU7Jc?= =?us-ascii?Q?MPKocACOBQK89gNfQaRSC9wkOemDfwy3NXZe/QT9g6n9coCBphBfr3Yw6OTw?= =?us-ascii?Q?xXFwJdE5ifEGNOt1s4azeWimXuRxfMONaSOXCAdc3S0sMFJttIiCY4DdS7rp?= =?us-ascii?Q?KmFB4YtHgWkEtihbTTQY0++qJfa7TnwbYz9hEsiyv2rGqu8nyHhqQ3x0muy8?= =?us-ascii?Q?eWKUVA6idpmofms4AMPWcZnSbP84Gh21RJNmUDnTE3VUpqqUFPpwKfL5JU7R?= =?us-ascii?Q?brKzt52EstvHeuorAaNsHgC7v7RiYRT9DO3HkXZ5sBSeAEQUhzoi3WTb4wle?= =?us-ascii?Q?3xZTFNCWjKPV5JgCpzYMbc0eTVsie5E5yCpeQlBQIj25gADidt6f1iparMLv?= =?us-ascii?Q?qjrmeoEeB0IW73ubC1lckKCvmB2/Uav+jSzOevyQtxFVyXA/ENvZ5qmaSKLh?= =?us-ascii?Q?PVFyGJebcAsxw9Ui3pm5lj6GfaAh4hyCbiBs6NcSrD62tkns0T/pkMndcBXM?= =?us-ascii?Q?C/yUTamW1YJuvYoY81WSmcb/dyN7PCEpW7C6JVQQdZXQHNSO4+QeGxdxWaZt?= =?us-ascii?Q?z6pQiU1GOrgBKsJkNya93JjoQM2LogIi3oSOGuuAz/PA9RSjFzs8nzUBw=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2438; 6:c0GnOsC1R1OPMTWfsdNGMPtltd02dCvib2suncnkXVICIcQi52gfYs9FjK3ivs0s+ZhP33DbjeVHpRaqEVPIXREdPt+z8raOiH9jBV2G9tJM7Gvj5Yv8OtVkXa2hNOM53LDmZXsITd4jR8D3MRUEXTdLjRIxUt5xzNu934UCBFfKpY0GTOz/1fgxwJeAZMiEawZHK6NQxHOJ94lzfbZEuAoz0i/yiDpXJp9bw2q36lu1/giTU9fv+SRChnlGxJ5HlWuyZmy+amCLyEQOZ8ejhE6dUNfi4NLN5HRsn55yNbk=; 5:UwH5SDKZ/HzCSVEP/ctKC53TkoeYtxEaJkLip2v1aF3tpEuhM2Gjad0sQhmnxLl26LBqHfxxlYgWPYzGsu0THzxJOROxBbvA5c/EnS9y31hKop931fe34w9hjS7XeDAW4LfIxq0+jdfp4dTd4YqmEcDXWv4coYmbaJU9+b9BdDY=; 24:BFFJD0tDfH4kaz9e1hKzOOlyhINgfy42eiBFLloDwkmmNkSF/SANPU6r55Wd34nxBow+Buy8YYGdIG7Xvg5cDesKZrFOe9YHE/OyU+mCZ38=; 7:actVyzPosVNjLr6HB2cTf3tnRkZ/bn2ST/F/0RQl1oYOaW0JBhitybW9oBfDAcIJX23rSZ7mPFV5oRs8sMlMjlUWH72xUlvkFHxXmjS4XqLHNbZ/lefaFA+kiR4NRqx4xe/rKj4jn9qGdWKXHStHvcWGaN97eLaUHZSpr5RttactBCFIPFoTFxydYnsHQ9Sw2/NYDJZIEaEmh4ZrO9wbckRHIv1wuFtZxL3BnzyJpM9IdSAamQo7yXCowFaAYd07MG3FfmFqJtqpOU8uccVq9zzEYs5ciLU9eNV0wUyi2KgH0Ya0lS9mOZpVtOh2i04W SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2016 12:42:49.6649 (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: CY4PR03MB2438 Subject: [dpdk-dev] [PATCH v11 15/24] eal: extract vdev infra 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: Tue, 20 Sep 2016 12:42:52 -0000 From: Jan Viktorin Move all PMD_VDEV-specific code into a separate module and header file to not polute the generic code anymore. There is now a list of virtual devices available. The rte_vdev_driver integrates the original rte_driver inside (C inheritance). The rte_driver will be however change in the future to serve as a common base for all other types of drivers. The existing PMDs (PMD_VDEV) are to be modified later (there is no change for them at the moment). Signed-off-by: Jan Viktorin Signed-off-by: Shreyansh Jain --- lib/librte_eal/bsdapp/eal/Makefile | 1 + lib/librte_eal/bsdapp/eal/rte_eal_version.map | 3 + lib/librte_eal/common/Makefile | 2 +- lib/librte_eal/common/eal_common_dev.c | 54 +----------- lib/librte_eal/common/eal_common_vdev.c | 112 ++++++++++++++++++++++++ lib/librte_eal/common/include/rte_vdev.h | 85 ++++++++++++++++++ lib/librte_eal/linuxapp/eal/Makefile | 1 + lib/librte_eal/linuxapp/eal/rte_eal_version.map | 3 + 8 files changed, 207 insertions(+), 54 deletions(-) create mode 100644 lib/librte_eal/common/eal_common_vdev.c create mode 100644 lib/librte_eal/common/include/rte_vdev.h diff --git a/lib/librte_eal/bsdapp/eal/Makefile b/lib/librte_eal/bsdapp/eal/Makefile index 7a0fea5..5a3fc1d 100644 --- a/lib/librte_eal/bsdapp/eal/Makefile +++ b/lib/librte_eal/bsdapp/eal/Makefile @@ -69,6 +69,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_timer.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_memzone.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_log.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_launch.c +SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_vdev.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_pci.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_pci_uio.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_memory.c diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index 7b3d409..ec61017 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -168,4 +168,7 @@ DPDK_16.11 { rte_eal_dev_attach; rte_eal_dev_detach; + rte_eal_vdrv_register; + rte_eal_vdrv_unregister; + } DPDK_16.07; diff --git a/lib/librte_eal/common/Makefile b/lib/librte_eal/common/Makefile index bb9810d..dfd64aa 100644 --- a/lib/librte_eal/common/Makefile +++ b/lib/librte_eal/common/Makefile @@ -38,7 +38,7 @@ INC += rte_per_lcore.h rte_random.h INC += rte_tailq.h rte_interrupts.h rte_alarm.h INC += rte_string_fns.h rte_version.h INC += rte_eal_memconfig.h rte_malloc_heap.h -INC += rte_hexdump.h rte_devargs.h rte_dev.h +INC += rte_hexdump.h rte_devargs.h rte_dev.h rte_vdev.h INC += rte_pci_dev_feature_defs.h rte_pci_dev_features.h INC += rte_malloc.h rte_keepalive.h rte_time.h diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index 88f9d3f..555e0d9 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -64,32 +64,6 @@ rte_eal_driver_unregister(struct rte_driver *driver) } int -rte_eal_vdev_init(const char *name, const char *args) -{ - struct rte_driver *driver; - - if (name == NULL) - return -EINVAL; - - TAILQ_FOREACH(driver, &dev_driver_list, next) { - if (driver->type != PMD_VDEV) - continue; - - /* - * search a driver prefix in virtual device name. - * For example, if the driver is pcap PMD, driver->name - * will be "eth_pcap", but "name" will be "eth_pcapN". - * So use strncmp to compare. - */ - if (!strncmp(driver->name, name, strlen(driver->name))) - return driver->init(name, args); - } - - RTE_LOG(ERR, EAL, "no driver found for %s\n", name); - return -EINVAL; -} - -int rte_eal_dev_init(void) { struct rte_devargs *devargs; @@ -98,7 +72,7 @@ rte_eal_dev_init(void) /* * Note that the dev_driver_list is populated here * from calls made to rte_eal_driver_register from constructor functions - * embedded into PMD modules via the PMD_REGISTER_DRIVER macro + * embedded into PMD modules via the DRIVER_REGISTER_VDEV macro */ /* call the init function for each virtual device */ @@ -125,32 +99,6 @@ rte_eal_dev_init(void) return 0; } -int -rte_eal_vdev_uninit(const char *name) -{ - struct rte_driver *driver; - - if (name == NULL) - return -EINVAL; - - TAILQ_FOREACH(driver, &dev_driver_list, next) { - if (driver->type != PMD_VDEV) - continue; - - /* - * search a driver prefix in virtual device name. - * For example, if the driver is pcap PMD, driver->name - * will be "eth_pcap", but "name" will be "eth_pcapN". - * So use strncmp to compare. - */ - if (!strncmp(driver->name, name, strlen(driver->name))) - return driver->uninit(name); - } - - RTE_LOG(ERR, EAL, "no driver found for %s\n", name); - return -EINVAL; -} - int rte_eal_dev_attach(const char *name, const char *devargs) { struct rte_pci_addr addr; diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c new file mode 100644 index 0000000..462517f --- /dev/null +++ b/lib/librte_eal/common/eal_common_vdev.c @@ -0,0 +1,112 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2016 RehiveTech. 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 RehiveTech 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. + */ + +#include +#include +#include +#include +#include +#include + +#include +#include + +struct vdev_driver_list vdev_driver_list = + TAILQ_HEAD_INITIALIZER(vdev_driver_list); + +/* register a driver */ +void +rte_eal_vdrv_register(struct rte_vdev_driver *driver) +{ + TAILQ_INSERT_TAIL(&vdev_driver_list, driver, next); +} + +/* unregister a driver */ +void +rte_eal_vdrv_unregister(struct rte_vdev_driver *driver) +{ + TAILQ_REMOVE(&vdev_driver_list, driver, next); +} + +int +rte_eal_vdev_init(const char *name, const char *args) +{ + struct rte_vdev_driver *driver; + + if (name == NULL) + return -EINVAL; + + TAILQ_FOREACH(driver, &vdev_driver_list, next) { + if (driver->driver.type != PMD_VDEV) + continue; + + /* + * search a driver prefix in virtual device name. + * For example, if the driver is pcap PMD, driver->name + * will be "eth_pcap", but "name" will be "eth_pcapN". + * So use strncmp to compare. + */ + if (!strncmp(driver->driver.name, name, + strlen(driver->driver.name))) + return driver->driver.init(name, args); + } + + RTE_LOG(ERR, EAL, "no driver found for %s\n", name); + return -EINVAL; +} + +int +rte_eal_vdev_uninit(const char *name) +{ + struct rte_vdev_driver *driver; + + if (name == NULL) + return -EINVAL; + + TAILQ_FOREACH(driver, &vdev_driver_list, next) { + if (driver->driver.type != PMD_VDEV) + continue; + + /* + * search a driver prefix in virtual device name. + * For example, if the driver is pcap PMD, driver->name + * will be "eth_pcap", but "name" will be "eth_pcapN". + * So use strncmp to compare. + */ + if (!strncmp(driver->driver.name, name, + strlen(driver->driver.name))) + return driver->driver.uninit(name); + } + + RTE_LOG(ERR, EAL, "no driver found for %s\n", name); + return -EINVAL; +} diff --git a/lib/librte_eal/common/include/rte_vdev.h b/lib/librte_eal/common/include/rte_vdev.h new file mode 100644 index 0000000..9c5cc54 --- /dev/null +++ b/lib/librte_eal/common/include/rte_vdev.h @@ -0,0 +1,85 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2016 RehiveTech. 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 RehiveTech 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_VDEV_H +#define RTE_VDEV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/** Double linked list of virtual device drivers. */ +TAILQ_HEAD(vdev_driver_list, rte_vdev_driver); + +/** + * A virtual device driver abstraction. + */ +struct rte_vdev_driver { + TAILQ_ENTRY(rte_vdev_driver) next; /**< Next in list. */ + struct rte_driver driver; /**< Inherited general driver. */ +}; + +/** + * Register a virtual device driver. + * + * @param driver + * A pointer to a rte_vdev_driver structure describing the driver + * to be registered. + */ +void rte_eal_vdrv_register(struct rte_vdev_driver *driver); + +/** + * Unregister a virtual device driver. + * + * @param driver + * A pointer to a rte_vdev_driver structure describing the driver + * to be unregistered. + */ +void rte_eal_vdrv_unregister(struct rte_vdev_driver *driver); + +#define DRIVER_REGISTER_VDEV(nm, vdrv)\ +RTE_INIT(vdrvinitfn_ ##vdrv);\ +static void vdrvinitfn_ ##vdrv(void)\ +{\ + (vdrv).driver.name = RTE_STR(nm);\ + rte_eal_vdrv_register(&vdrv);\ +} \ +DRIVER_EXPORT_NAME(nm, __COUNTER__) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lib/librte_eal/linuxapp/eal/Makefile b/lib/librte_eal/linuxapp/eal/Makefile index 193957f..4e206f0 100644 --- a/lib/librte_eal/linuxapp/eal/Makefile +++ b/lib/librte_eal/linuxapp/eal/Makefile @@ -77,6 +77,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_timer.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_memzone.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_log.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_launch.c +SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_vdev.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_pci.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_pci_uio.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_memory.c diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map index c0bd391..b8bfd4b 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -172,4 +172,7 @@ DPDK_16.11 { rte_eal_dev_attach; rte_eal_dev_detach; + rte_eal_vdrv_register; + rte_eal_vdrv_unregister; + } DPDK_16.07; -- 2.7.4