From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0071.outbound.protection.outlook.com [104.47.42.71]) by dpdk.org (Postfix) with ESMTP id EC17A2A5D for ; Tue, 13 Dec 2016 14:34:48 +0100 (CET) Received: from BN3PR0301CA0075.namprd03.prod.outlook.com (10.160.152.171) by BY2PR0301MB0742.namprd03.prod.outlook.com (10.160.63.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.747.13; Tue, 13 Dec 2016 13:34:47 +0000 Received: from BN1AFFO11FD018.protection.gbl (2a01:111:f400:7c10::138) by BN3PR0301CA0075.outlook.office365.com (2a01:111:e400:401e::43) 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; Tue, 13 Dec 2016 13:34:46 +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 BN1AFFO11FD018.mail.protection.outlook.com (10.58.52.78) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.761.6 via Frontend Transport; Tue, 13 Dec 2016 13:34:46 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:; UpperCasedChecksum:; SizeAsReceived:797; 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 uBDDYRw6005048; Tue, 13 Dec 2016 06:34:43 -0700 From: Shreyansh Jain To: , CC: , , , Shreyansh Jain Date: Tue, 13 Dec 2016 19:07:02 +0530 Message-ID: <1481636232-2300-3-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1481636232-2300-1-git-send-email-shreyansh.jain@nxp.com> References: <1480846288-2517-1-git-send-email-shreyansh.jain@nxp.com> <1481636232-2300-1-git-send-email-shreyansh.jain@nxp.com> X-IncomingHeaderCount: 10 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131261096865899439; (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)(336005)(7916002)(39410400002)(39860400002)(39850400002)(39840400002)(39380400002)(39450400003)(39400400002)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(86362001)(68736007)(8936002)(50466002)(50226002)(50986999)(76176999)(2906002)(48376002)(104016004)(5001770100001)(189998001)(97736004)(105606002)(106466001)(38730400001)(4326007)(5660300001)(92566002)(2950100002)(626004)(33646002)(5003940100001)(36756003)(305945005)(77096006)(6666003)(8666005)(356003)(81166006)(81156014)(47776003)(8676002)(85426001)(7059030)(21314002)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR0301MB0742; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD018; 1:30INKNee8JmqGG/W55UlV5m+g/HaOPXXEfEX9zcmsu7VuF++jTl/iJq4VfpRxYeahc0HVkJjrb9gHOXsORUaCF4ert9M7wkOIfSJxJWyNPg+32O2k80pWt3aVc4N4igWXFrNxtIKl06Y6FFPbRubez/HPhlxD1I3a2y+dWcN9558R0xqTwbCJS+Afuhr2fCVbvy+W45xLU5knfS1RfZA+hYW79BrpEaoj/1Khsn4lGe+ozzLZaVvBoPIwQ5MiA2oTXVHOh2276UzcstHjQ02FPy4xamL5nYpG79uPj0HMIrAdHAif+eE7qS7Qt28pBDbaLpwtOmLR13QPbXMQEo9XUH5bbd/77Ws3/xU+FR0jNqy/mBFc4L81MOAR5iy5RfNjzgcyXH6OB/0Y043g0XsYn9wueFMp3dHoxJCoMTtgj/X1B5EY3WJ2CjvUKfVNTVjCdepM9S5WIqorbEGZxIeAK160ReeVhUTcOHswj3OqEZWAPkQO46aPQEjBInHK0+kd1My1WflOjZFlAtwoM5saGb8fja/+bSK1rzeyItgWIscc0ybLRbTouHO7Lbr/Kua0p5UkUD9i3lNgSGaeuoJUrZ/QJ6265S8dZzSEmKdGdn4hioEZszNedaGxhzw6/BPjoZ6wTWp8lee8N/pvaOEyBEJAHDriv+6B46YLQEg6MklvDCEWvA5rPa6p9wyDzfB47g3XergfGId3ggTaMzXh7wJVZymiruXWlWYms+oQuHZwzeVZo/BrzQJRKawjHFkIjOt18GGYoSKVqoM2sLIWQ== MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 8ccbbb3f-a901-4c8b-18af-08d4235ccde9 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:BY2PR0301MB0742; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0742; 3:EFce/7sBlXCCU3gM2RFdjzYV5pC33NUEAOAjzI1TBmk0Dh4ppWYTmNiZwQBfLVKPJUOn/25VOR9uQUes5aN61wkBM2ozFgYTCFuMgfapqOEuSgl6XPRFPanTdSUJMCHtWYwdOw9vpf2cvrWknq1/8eYRBcoqKgEqsoyV7fL635CPHuuFFhqjVjue28S2wSwYGqpIu6jBYdleDQ8R/r5H4c0xF6HK6kPxwHWyF3WatCIhPcWXBeqDqPwMhhiCyIzWNIPsVZYZAKNtcCeYyUuaReAs0sJ3EUcAxE9z9aCUVWtrxMVsw1p8FJl54j9pFN85JioRuT9j/a8nPvTwWEneGA402H1SRnl91PNjORAKH0yz7/2DgI3MolAatr18eJrE X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0742; 25:CwDyOSi19tC6mZFBbpvW1bR9gjVNg6DW0WHnP4awm56NDtKumu7UBKV/F4FdGP9Mi1EdGqpVfr+iu5SV7clXVwlvPy2U2JuA6lDYULxOZyMD3PSeJcqK0Bo2D7l/X27SZ+9WaYv0Qcg7YYwEknd9egi0n+AJb3VvQei0RdEU/OSOQXfZUDpuvoSaLCDQk3XDWFpatw8BGrWrXtsuy3n6MS0+H/pm5UhAYnG9PljLLh0ILrH4pIwWOqj5KhIHaVTj1U2uyrduG+J0u+kwpjCNlO7SeJdHsODuC1yLYInTV2XdrU95jUt587PMCprnWMDc20tYHP2yqHXVr5jUodMVAQHhGb2BlZiyiUwuVJrymG1sQaEhOFn2cRM2S9v1NFjlPGcCkDfkg/1ZfvSr7CL5jdYnrsOxPe0olnrKADk+96Mpg1v+Nt5VYg/XBBY9JafsoKK02DAg+mApVRqybgDatYYeOmC4pK6ODAqNO5UyUeTeCej9/XmHN0KZbimAsoWOn1VedTUyBPGed71T6SAHhKiSz8k7kC5SLgtp/qjrOSqnviD4XlO152TkbinhuCNcDeHndd/t9E0FfU1bAcBDfZ8lZfQCTUn31rK/YcfGtpC54W1kqxQ7yzw4/8yi3sywOaoBOF73i7fPjRsIpxU+25XiQhUwiOHUwJCiCA8tw00UWyNknnvDNEDPpvcv7aSUfXygfacitg6o+gYIzo6PByhZ+MTxHcMUOfRzDJP/7iyh7gPkjV84dVM5ozkBcTqYPXLTCERaZwPPCKeVXyFl+qB2E+sBSeOD4A3V/QzM6zo= X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0742; 31:2cLr0EI4cRIfa2iyrX6Y15wS4jETuuIKTbbZw19SbL1WioovMM7D7e3wnkKxAwN/F2pc0TNAXk01ZCeeOEF4uBvpQS5wQNn4It+SrQmKkdeux017lGKTUG0KnXIWDB4fmL2+Juz93ivXDJ4vHgTGIFCMJjxG4GGbRK2CkjkRvz9MpumCfWvBQphMt27dNT4P9d2GAhuMgxgGa43DWzgQOt71HPBdbVyoHRrzrt6yymcdEC9fj3zyKTUQl6+q7B0N3P77PUaVBZneOhQZm0kx8Q== 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)(13018025)(8121501046)(5005006)(13017025)(13015025)(13024025)(13023025)(10201501046)(3002001)(6055026)(6096035)(20161123561025)(20161123565025)(20161123559025)(20161123556025)(20161123563025); SRVR:BY2PR0301MB0742; BCL:0; PCL:0; RULEID:(400006); SRVR:BY2PR0301MB0742; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0742; 4:KAssU0J3l3FnEl2kKz1Y9ry7GnZuXcNhk7x6gUoVcapzNr92s6nEQnJAbifxrd/Bi+EpfqzeBbHxdZwLzvut5EAdDAiMwbZLWLDMqDE3cSTzvzfDZEbX5p0z5xRK6I7C1lKLOsLfvBi9TD5CaUwKsJpxhASgyoZueupaqbY5s9B89uWPlcx8oI7YhMBjkQQwOYlgCfWCJJeWCB7/YPovVkodtx1vuhJJTe2uVStqPYkFqP6Jf8vg1h9zs9PYy7yjuGOhlJ3wM6zP46wIOBz38Y3jO8sTaoHIN864HXfvUDGueErMBntqRuXwuePIeo8ztYeya11GX5YmuXZwMlWpQfO46EP3ApOn0sqYPNy1ThzhdhAthH5BBsQQfs/7jT2mIuf9hgd/kBOBjlzImjst3wrHvfsRb5D2Hr/SEf1Hd1mKUxVd50lAcOukniyR1oHDmwn+hJK73FbdU7Yfw3sSO0AyYHYvQ2Ea7CrAqZgKCnazfcWsuIs2oSqvk/VPcKEFjrjyJYvFzj7lKzsI0S0D48jrqw7huhmo52HS58dK+X/kN5awBqNeeQzGTdjABHRrRqW3yO7mu3wOaxyJVwUM11ihdjlFdwyigPLk6K16u5suH+QKUUKlVjAffwRqsE/mg/SQeqe7zFeMqh9W5BhL5iG8TxzV+myToSgyBibacfgD3oUn+TOnD/8UpefP6KYPMpUyj4iHWKxbeYOcBXn2aGYnAnS2wlaQptxwR5K5c234igTpphCwnkAm0ADP+7OK X-Forefront-PRVS: 01559F388D X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR0301MB0742; 23:4EqOfvIwhlS4IKMBF2bX/7vcrSFOVyOaE4ApId4?= =?us-ascii?Q?wr0j/zHPMwhzlWI59GvgLbhBQWEsr5xurD+NSGDXdDseIcuQUUo5l6sSZOc8?= =?us-ascii?Q?VxaMUIF2he064qwphkJHWK3+Mbj7P3dvbHWk9yxJGXQ0XpBKqpDcJia55/3r?= =?us-ascii?Q?Xk/UrvUJpkXixIKDUM2Z4VGtd1es52cWXHxpL87T9fOk9W8Sl9fHYAjJoeaF?= =?us-ascii?Q?JuxHHAIulhH2sibIUdSb1DZujlrmgy/NDt2cZW21yRhSFttLWPNzduzbrhjQ?= =?us-ascii?Q?pwaEB5gnw9JTEzDAxLxYEs7ocC/mo7Iq7DKYTBbJwhhW1Giwq7mPQcn4p5by?= =?us-ascii?Q?9IayIwDD7/c1oELlnbX9dqrOaN3LIzhSQbtMZMUPROkSry2POIisxv+DOHKg?= =?us-ascii?Q?OvlSYX52LVTM1TXT2uLUt+Qup3tLKcp6f4cxuPdOBxkuhwSVdHx4Meyp/HQ4?= =?us-ascii?Q?ontebE4V3sK3/U+7E/uvyTnQphvaCx7wDlTWfxA7woJufZvl8xlJqmFOwV6f?= =?us-ascii?Q?yt4+ARcjonhqfakxBO6I2BmKmjBd5Y6XhajuxzJlQY+0b3pDGoPjXrs+l/a5?= =?us-ascii?Q?8G0BvYKtVPvKBzQ5Tivf8cy3KtCHGxTzqPGVbMa5cRGOEI4/ri+MMXT1TKqm?= =?us-ascii?Q?0OdAZMu8cpLQ3WFSX23GmIw5ewDL5kj8ai3yqeI4c6Hkw/Qh7GvRXx0BOdcS?= =?us-ascii?Q?8gedP9MT4dkO4smy0JpL+J+IyXxbr5pFzglw3Ugy1qxECDdPH+UId4GKiwhO?= =?us-ascii?Q?AVSqeaYDfwmQV8Uh4ggBL7vTjpPF7wvLuSrfmT8isBryd5n+BYgrjH4kIfgD?= =?us-ascii?Q?6JweBaRLkvaoWFn08hyo46X6cfQV086Yz4f7LhFBy/StpvgMWCHHuebcFzqb?= =?us-ascii?Q?Snxp1geY4l6viSceuw22qdDbvl1+ZhiFzovWYF48IHv+tPwL67KMI02hj7YY?= =?us-ascii?Q?HSvrZ3s4kxhNYtxS59FsWmDY0X4/KKvYAOMIcoH+AdzLkjStMiJKNoJn0xMI?= =?us-ascii?Q?PJJRxtfQGarc/FGYGacXfRZfhSSc2/SsDen06eLVIzLmLVHdDnHILs0LpFHb?= =?us-ascii?Q?R5EP2vFCuVqyUnJpxuseft+99ygLJ1MGFAQmnRrDsuPDfhehZVanv32dOziy?= =?us-ascii?Q?h0vHBpNb9LTYlrVOwaV5nm6Nx/UgPFN4IAzNl59HJ6+Dmza5dtLUf48uhP2W?= =?us-ascii?Q?RArqphTKspnmIj03fq05BNHe9PYnimuRuOzOsazNTm02i8pvJRabcTDAw61/?= =?us-ascii?Q?292RRxwE1qgutK0+i5k4h3Ty0Qahv4gojY72Sr/aiG6PnkdUqlDX2XxAlo8R?= =?us-ascii?Q?w8Q=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0742; 6:IpUlPFZJ7F7ZuoAIWXl2CKUbOIG4gPFSg79H0BmwRGW1Age+YOZViHnT93XC6775Xi62rquNwlVzjywsg8XZZvTw9aToR7KFlwo2TM0NRWBb58SOn9YBNynFLnXhaYK828COZyfJcBAXu6z1L5rAFBmNcJSIKzp8dx4BN+oj2oTdQlJNxr8H/HdACUq1H14vzDROMBqF+WRw+mAILCd62GU9cKeWFA1dQmzRF15hwzP+zjrRiJXH40a5dIxTFZVAXFZC67GKizaRWu2LWUBwI7sgyswYHyGykfeaDNUuJwpdTTx80Xw4lR8NQMIp6PgngGx0HbJYmU1p5cwCB+bPtgja8K5lL4cuUN/wq3AUJu/O21PIyNGS0r0AHBdGvLofxIuBMiw5AcAoWsAp1d2Hm+lsGsutvPwlq6vTHV7wnybLvjHAJITC+MhsJua8IPVy; 5:+/3QnwOcgWWJ4KyelqeSSrg15IcKoUgtG1evcak4A8vZAIwi7J7tizL7RunLvhX8OCOfkMOSQ0w/tT4Ljy/Oy2iIvl6JuR5LVfz+EbhPI/uw7POEzAB6+rfxugxm14SJFTSVJ6fwYQv86+n9C/wiDh7MMp6k5kQKwYrr+02tGJ/DBXsU7dGeWpbqqujmyC5f; 24:/Nc9IFDDZ3ihOa/i3nDTbG2FJkDOqWYrKs6z53iXe1F7wSeBjziFYQFgK3crT50btPjGOMQFZdLWgfA9Le8vRUHhMN/NuX+6nkujZ77U/qA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0742; 7:zPzb5FFNLtkfKLYHYb8fa8cXUwN/QBH/2yQjuXNblUD+osox6w4eiYsSvUW/ViK1kGAAybQUKPftnsuYPgTZr7xvib3IZtHWnkbcS5Z00QJ6h2dPGcT34sgGOT2N9iN5fA9novfzU/I1Rf2wRvcuc0ntHgEH8hkL/TocD/BNRk3KexdPVRc/FecmT4onCCsshINNLu+bgU6LrwhLNp0hnrkprBhhIUHvxJyL1z3jAA/4ARSfvy6wOX44uMHQZo6DBR0pIsAuqIkSr7IJz0FR3IF/31Ko6d9BZ0uiwmfrv+11odu6LzUD97Vi2b7YNipjgC0pT0QD/AcUbz5YNZV9nShWYpnRk41rYFs+WKhTvZ7W16ENBYQ+SrApaWjZGr9XcpREoftktLhk1lT9fseGgBPtTV4KEGdKGUhCbqv2zTB4k4FswtbBWhNkzqWQVOnMJg2aV4n1Qu3H/7dBazzFPw== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2016 13:34:46.2935 (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: BY2PR0301MB0742 Subject: [dpdk-dev] [PATCH v2 02/12] eal/bus: introduce bus abstraction 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: Tue, 13 Dec 2016 13:34:49 -0000 This patch introduces the rte_bus abstraction for devices and drivers in EAL framework. The model is: - One or more buses are connected to a CPU (or core) - One or more devices are conneted to a Bus - Drivers are running instances which manage one or more devices - Bus is responsible for identifying devices (and interrupt propogation) - Driver is responsible for initializing the device This patch adds a 'rte_bus' class which rte_driver and rte_device refer. This way, each device (rte_xxx_device) would have reference to the bus it is based on. As well as, each driver (rte_xxx_driver) would have link to the bus and devices on it for servicing. __ rte_bus_list / +----------'---+ |rte_bus | | driver_list------> List of rte_bus specific | device_list---- devices | | `-> List of rte_bus associated | | drivers +--|------|----+ _________/ \_________ +--------/----+ +-\---------------+ |rte_device | |rte_driver | | rte_bus | | rte_bus | | rte_driver | | ... | | ... | +---------...-----+ | | ||| +---||--------+ ||| || ||| | \ \\\ | \_____________ \\\ | \ ||| +------|---------+ +----|----------+ ||| |rte_pci_device | |rte_xxx_device | ||| | .... | | .... | ||| +----------------+ +---------------+ / | \ / | \ _____________________/ / \ / ___/ \ +-------------'--+ +------------'---+ +--'------------+ |rte_pci_driver | |rte_vdev_driver | |rte_xxx_driver | | .... | | .... | | .... | +----------------+ +----------------+ +---------------+ This patch only enables the bus references on rte_driver and rte_driver. EAL wide global device and driver list continue to exist until an instance of bus is added in subsequent patches. This patch also introduces RTE_REGISTER_BUS macro on the lines of RTE_PMD_REGISTER_XXX. Key difference is that the constructor priority has been explicitly set to 101 so as to execute bus registration before PMD. Signed-off-by: Shreyansh Jain -- v2: - fix bsdapp compilation issue because of missing export symbols in map file --- lib/librte_eal/bsdapp/eal/Makefile | 1 + lib/librte_eal/bsdapp/eal/rte_eal_version.map | 15 ++ lib/librte_eal/common/Makefile | 2 +- lib/librte_eal/common/eal_common_bus.c | 192 ++++++++++++++++++++++++ lib/librte_eal/common/include/rte_bus.h | 174 +++++++++++++++++++++ lib/librte_eal/common/include/rte_dev.h | 2 + lib/librte_eal/linuxapp/eal/Makefile | 1 + lib/librte_eal/linuxapp/eal/rte_eal_version.map | 15 ++ 8 files changed, 401 insertions(+), 1 deletion(-) create mode 100644 lib/librte_eal/common/eal_common_bus.c create mode 100644 lib/librte_eal/common/include/rte_bus.h diff --git a/lib/librte_eal/bsdapp/eal/Makefile b/lib/librte_eal/bsdapp/eal/Makefile index a15b762..cce99f7 100644 --- a/lib/librte_eal/bsdapp/eal/Makefile +++ b/lib/librte_eal/bsdapp/eal/Makefile @@ -78,6 +78,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_cpuflags.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_string_fns.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_hexdump.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_devargs.c +SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_bus.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_dev.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_options.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_thread.c diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index 2f81f7c..23fc1c1 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -174,3 +174,18 @@ DPDK_16.11 { rte_eal_vdrv_unregister; } DPDK_16.07; + +DPDK_17.02 { + global: + + rte_bus_list; + rte_eal_bus_add_device; + rte_eal_bus_add_driver; + rte_eal_get_bus; + rte_eal_bus_dump; + rte_eal_bus_register; + rte_eal_bus_remove_device; + rte_eal_bus_remove_driver; + rte_eal_bus_unregister; + +} DPDK_16.11; diff --git a/lib/librte_eal/common/Makefile b/lib/librte_eal/common/Makefile index a92c984..0c39414 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 rte_vdev.h +INC += rte_hexdump.h rte_devargs.h rte_bus.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_bus.c b/lib/librte_eal/common/eal_common_bus.c new file mode 100644 index 0000000..612f64e --- /dev/null +++ b/lib/librte_eal/common/eal_common_bus.c @@ -0,0 +1,192 @@ +/*- + * 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. + */ + +#include +#include +#include +#include + +#include +#include +#include + +#include "eal_private.h" + +struct rte_bus_list rte_bus_list = + TAILQ_HEAD_INITIALIZER(rte_bus_list); + +/** @internal + * Add a device to a bus. + */ +void +rte_eal_bus_add_device(struct rte_bus *bus, struct rte_device *dev) +{ + RTE_VERIFY(bus); + RTE_VERIFY(dev); + + TAILQ_INSERT_TAIL(&bus->device_list, dev, next); + dev->bus = bus; +} + +/** @internal + * Remove a device from its bus. + */ +void +rte_eal_bus_remove_device(struct rte_device *dev) +{ + struct rte_bus *bus; + + RTE_VERIFY(dev); + RTE_VERIFY(dev->bus); + + bus = dev->bus; + TAILQ_REMOVE(&bus->device_list, dev, next); + dev->bus = NULL; +} + +/** @internal + * Associate a driver with a bus. + */ +void +rte_eal_bus_add_driver(struct rte_bus *bus, struct rte_driver *drv) +{ + RTE_VERIFY(bus); + RTE_VERIFY(drv); + + TAILQ_INSERT_TAIL(&bus->driver_list, drv, next); + drv->bus = bus; +} + +/** @internal + * Disassociate a driver from bus. + */ +void +rte_eal_bus_remove_driver(struct rte_driver *drv) +{ + struct rte_bus *bus; + + RTE_VERIFY(drv); + RTE_VERIFY(drv->bus); + + bus = drv->bus; + TAILQ_REMOVE(&bus->driver_list, drv, next); + drv->bus = NULL; +} + +/** + * Get the bus handle using its name + */ +struct rte_bus * +rte_eal_get_bus(const char *bus_name) +{ + struct rte_bus *bus; + + RTE_VERIFY(bus_name); + + TAILQ_FOREACH(bus, &rte_bus_list, next) { + RTE_VERIFY(bus->name); + + if (!strcmp(bus_name, bus->name)) { + RTE_LOG(DEBUG, EAL, "Returning Bus object %p\n", bus); + return bus; + } + } + + /* Unable to find bus requested */ + return NULL; +} + +/* register a bus */ +void +rte_eal_bus_register(struct rte_bus *bus) +{ + RTE_VERIFY(bus); + RTE_VERIFY(bus->name && strlen(bus->name)); + + /* Initialize the driver and device list associated with the bus */ + TAILQ_INIT(&(bus->driver_list)); + TAILQ_INIT(&(bus->device_list)); + + TAILQ_INSERT_TAIL(&rte_bus_list, bus, next); + RTE_LOG(INFO, EAL, "Registered [%s] bus.\n", bus->name); +} + +/* unregister a bus */ +void +rte_eal_bus_unregister(struct rte_bus *bus) +{ + /* All devices and drivers associated with the bus should have been + * 'device->uninit' and 'driver->remove()' already. + */ + RTE_VERIFY(TAILQ_EMPTY(&(bus->driver_list))); + RTE_VERIFY(TAILQ_EMPTY(&(bus->device_list))); + + /* TODO: For each device, call its rte_device->driver->remove() + * and rte_eal_bus_remove_driver() + */ + + TAILQ_REMOVE(&rte_bus_list, bus, next); + RTE_LOG(INFO, EAL, "Unregistered [%s] bus.\n", bus->name); +} + +/* dump one bus info */ +static int +bus_dump_one(FILE *f, struct rte_bus *bus) +{ + int ret; + + /* For now, dump only the bus name */ + ret = fprintf(f, " %s\n", bus->name); + + /* Error in case of inability in writing to stream */ + if (ret < 0) + return ret; + + return 0; +} + +void +rte_eal_bus_dump(FILE *f) +{ + int ret; + struct rte_bus *bus; + + TAILQ_FOREACH(bus, &rte_bus_list, next) { + ret = bus_dump_one(f, bus); + if (ret) { + RTE_LOG(ERR, EAL, "Unable to write to stream (%d)\n", + ret); + break; + } + } +} 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..f0297a9 --- /dev/null +++ b/lib/librte_eal/common/include/rte_bus.h @@ -0,0 +1,174 @@ +/*- + * 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); + +/* Global Bus list */ +extern struct rte_bus_list rte_bus_list; + +struct rte_bus { + TAILQ_ENTRY(rte_bus) next; /**< Next bus object in linked list */ + struct rte_driver_list driver_list; + /**< List of all drivers on bus */ + struct rte_device_list device_list; + /**< List of all devices on bus */ + const char *name; /**< Name of the 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); + +/** + * Dump information of all the buses registered with EAL. + * + * @param f + * A valid and open output stream handle + * + * @return + * 0 in case of success + * !0 in case there is error in opening the output stream + */ +void rte_eal_bus_dump(FILE *f); + +/** Helper for Bus registration. The constructor has higher priority than + * PMD constructors + */ +#define RTE_REGISTER_BUS(nm, bus) \ +static void __attribute__((constructor(101), used)) 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..4004f9a 100644 --- a/lib/librte_eal/common/include/rte_dev.h +++ b/lib/librte_eal/common/include/rte_dev.h @@ -122,6 +122,7 @@ struct rte_driver; */ struct rte_device { TAILQ_ENTRY(rte_device) next; /**< Next device */ + struct rte_bus *bus; /**< Device connected to this bus */ struct rte_driver *driver; /**< Associated driver */ int numa_node; /**< NUMA node connection */ struct rte_devargs *devargs; /**< Device user arguments */ @@ -148,6 +149,7 @@ void rte_eal_device_remove(struct rte_device *dev); */ struct rte_driver { TAILQ_ENTRY(rte_driver) next; /**< Next in list. */ + struct rte_bus *bus; /**< Bus serviced by this driver */ const char *name; /**< Driver name. */ const char *alias; /**< Driver alias. */ }; diff --git a/lib/librte_eal/linuxapp/eal/Makefile b/lib/librte_eal/linuxapp/eal/Makefile index 4e206f0..aa874a5 100644 --- a/lib/librte_eal/linuxapp/eal/Makefile +++ b/lib/librte_eal/linuxapp/eal/Makefile @@ -87,6 +87,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_cpuflags.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_string_fns.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_hexdump.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_devargs.c +SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_bus.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_dev.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_options.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_thread.c diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map index 83721ba..c873a7f 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -178,3 +178,18 @@ DPDK_16.11 { rte_eal_vdrv_unregister; } DPDK_16.07; + +DPDK_17.02 { + global: + + rte_bus_list; + rte_eal_bus_add_device; + rte_eal_bus_add_driver; + rte_eal_get_bus; + rte_eal_bus_dump; + rte_eal_bus_register; + rte_eal_bus_remove_device; + rte_eal_bus_remove_driver; + rte_eal_bus_unregister; + +} DPDK_16.11; -- 2.7.4