From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0070.outbound.protection.outlook.com [104.47.40.70]) by dpdk.org (Postfix) with ESMTP id 4147399E8 for ; Thu, 25 May 2017 20:09:04 +0200 (CEST) Received: from DM2PR03CA0053.namprd03.prod.outlook.com (2a01:111:e400:2428::52) by BL2PR03MB164.namprd03.prod.outlook.com (2a01:111:e400:c0d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1124.9; Thu, 25 May 2017 18:09:02 +0000 Received: from BN1BFFO11FD046.protection.gbl (2a01:111:f400:7c10::1:157) by DM2PR03CA0053.outlook.office365.com (2a01:111:e400:2428::52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1124.9 via Frontend Transport; Thu, 25 May 2017 18:09:02 +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; 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 BN1BFFO11FD046.mail.protection.outlook.com (10.58.145.1) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1075.5 via Frontend Transport; Thu, 25 May 2017 18:09:01 +0000 Received: from b27504-OptiPlex-790.ap.freescale.net (b27504-OptiPlex-790.ap.freescale.net [10.232.132.60]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v4PI84WH022340; Thu, 25 May 2017 11:08:58 -0700 From: Nipun Gupta To: CC: , , , , , , Nipun Gupta Date: Thu, 25 May 2017 23:37:37 +0530 Message-ID: <1495735671-4917-7-git-send-email-nipun.gupta@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1495735671-4917-1-git-send-email-nipun.gupta@nxp.com> References: <1495735671-4917-1-git-send-email-nipun.gupta@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131402093420438832; (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)(39380400002)(39400400002)(39860400002)(39850400002)(39840400002)(39410400002)(39450400003)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(9170700003)(86362001)(76176999)(50986999)(8676002)(106466001)(33646002)(104016004)(2906002)(305945005)(5660300001)(77096006)(110136004)(2351001)(38730400002)(189998001)(47776003)(50226002)(81166006)(54906002)(53936002)(8936002)(8656002)(85426001)(5003940100001)(4326008)(48376002)(36756003)(498600001)(356003)(50466002)(105606002)(6666003)(6916009)(2950100002); DIR:OUT; SFP:1101; SCL:1; SRVR:BL2PR03MB164; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; A:1; MX:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD046; 1:lbt4q6XGGjiMSFdZtJ9P2HbQGRUGp1GsUEaLzmzs/yZSKgDbzFGbBlXn0Pe0qNgFe8yS+BPJr8TbcShTTcLxyk6OnBOLmlhLVO0g+79P8OZcWXpR0Yewz0NJvd0woA+lsL1JRQuXQMPvgfbb9AU2HiQOQic9GclikjVBMTBtKT0khfkntciLMtKLy11qk4oSGdYHki7ZWEVfHmfTwGHiETfg/SxD3/cHbpzJ7NRUd02ejdCKnrgavDR9oaxJ6oawyKb06ewN/PjVEn/g9oCmXBx51G90z+f2zDREGqZbkJ/2P1TdyWAvaYAM2GOH1EMScBm15YPxg8hoohA93k5WWSh7x4Tit5M/1/7L2EzTBcM9Dv5gPx47knizJoT+/AgRbmJ3Ztb2g1MCaMAQSJWfN0OBUfqNlKuzi65M/31jozUl76grgf3AXVI/It4vvJzuHBlqbY77DCurL2WyN81eDctaTyDLQHC7CfB1KPuaEdPVBWemsEv7IdTQohgiG6AyjPnMA6e1RBskZpbUlTk6RUf+Ua5z/t1lXwlOexp5vcRY72noDtBA289XAUHGBp2rBBTRtAC0N34oMghXowkFQg1m7ZjiUkchyIwJHUwqPZrKxtN9KhqvwB0LU3r0wxPvcbTRY9hOdCS+DdirvBuFKAJaKxg6iccgGNJZ/qNJM78jHe7RyfcI5BNCQiIIpbMNN0OOuxa2J3S2fscl8vjgi8XozlkIyruxQsQVQHhmiSulSRUSIbwFDrWSDM0UXrdCifE/vQ4OkB8SqDRDw78ZrA== MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL2PR03MB164: X-MS-Office365-Filtering-Correlation-Id: 039bced1-dca3-4045-a278-08d4a3991f83 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131430075)(201703131517081); SRVR:BL2PR03MB164; X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB164; 3:L2bLKrYcaW0mJqnVuSyX5yc/uiE8ncH97KsHXwvoOftNBW6QVVNcF7rOseCItOpa7gODTv11yR4CCKlzcDH43t4muLD7ECvZ1FsrNYCr9vdON57zZtDdkIL9VeHpPYAkZULWbbn2ZFrEtYjwFPLYudp8GE4omql4jggK/bh3TTCA1Ij1osZvNJERoVZH7WTy3AjK+bRsxtskBzCsEcSiYZILxZs2z7e9yvn9j8hZ0TFnAohP+tFt1R6ZhDcjlOghA4qzHGA1C9oAoeVOi0j4QovIe7C98ZujSK060f7IZzo1lf2hLjdsbgO38hfnkZ6wyNXUjybOAqxCK6jjqD0yVdzvYfT0749CuCH+L16Krqqw3T0gQK5MAee8TL/gFexcJq4sPtjACK+f+HKiXieXq2cI6GA+NadSJTxeTcJvhvc+gH7PatzE1x2iBnnnyaOP; 25:8U2VYgtK+IFsiIVv7P0mNFJcmdRHSOZUWwzZiuH3ljO4EX3D6rvsQd6jnEuEQ9Zj/Bfv5iydph270yHTgTZ9z0crVlkqTrY0pwrQdAhH35v8/Q9jg+mpbO1QKKWHhv87g+EXCevOREKelVLDEcN47wnlSeaus1zlng5FST2Kjh2yMENsU7kLlp5U5NIF8XxgDnMkQCpEUM+to6FWTPqvmNmUTl4/BsSS2jB42NrGlgsZL4KLh+ycK8eb+UDZg+rw3HNkTfAoZhHINRIUBfZ1mKeUzsLcuAbGrRbk5XlFu6Rffd9V7bNXYh3iOwPQXm64PhyTB3yxCJ0zhD5ztmXipDYc+AneD/CmjlWs8y7PUdAYYSCbU4vbzaEjtHDB3u/HcFBT3+cVN8uJ63IP5skW+FfcY8xlLw7p0RLTquCR+mr7wwoNO2BVt6fOqrptKEdLqjB14wlcvucsPEi7jAx4N3mlRMtF7/JyqLjPSh6WSwQ= X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB164; 31:KavtqEigCgdiLKlmi+zPawezRbG/IMx4iDGA/PYn3dAuc2ZuXoCacruEOmrzSvEgjqeKeSohBgnByMD6TS0hOkJ8QTedkTZjd//LNoWToBQdmG3CPOfSH1BkXPFjnnM7CQoo0o29JhABZDwLJXwKMFbUS81VdpTWiLr9Z6Fqk2dP6ceY8V7U2Xc3MJBPA4en5NY+uE1p9OP7c1mUT6QJfdmepM2gDRnv04XdOaLETGWGRuEaz9xE4hoUpu+89i7wKSDki8572M3cqArWuO7bNg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(275809806118684); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(601004)(2401047)(13018025)(13023025)(13024025)(8121501046)(5005006)(13015025)(13017025)(10201501046)(3002001)(93006095)(93001095)(6055026)(6096035)(20161123565025)(201703131430075)(201703131433075)(201703131441075)(201703131448075)(201703161259150)(20161123559100)(20161123556025)(20161123561025)(20161123563025); SRVR:BL2PR03MB164; BCL:0; PCL:0; RULEID:(400006); SRVR:BL2PR03MB164; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BL2PR03MB164; 4:wryitQRJZWXCCx6KG4Jo7P6+AZejOm5eDUqL8wyAzSW?= =?us-ascii?Q?AknTDWIuWUSPDvUnogVyzx6nXmge2DfRa6DXiZCqze47zAobaUf7H7/ZKNnS?= =?us-ascii?Q?xCoeVQQk6Mg77CoFpG0xiz93bZqGnnoNYtEjemYkU3fXZYSB7AFGXF5hYZkf?= =?us-ascii?Q?uZuJM9t/3A9t4BPyVY92OO0mn74+guDJjjehJW+P2NIqEUaHyPbID7CRbEY2?= =?us-ascii?Q?+dcSZkYziwq6w2ABvEBpcxFcl4hw6Nf9BBkN2GPmdKt9Ex+4qi71MgintKP8?= =?us-ascii?Q?8s1d2RwuKfLxzszLiVQhCsEkRDtgBE+SnhqVW1+1PGUaMCVjsG6ttLjIKR4C?= =?us-ascii?Q?JeOFOYtQ2BGn+9em2UM9OJxx2YEcE3LiGuOfUCjSjxAENXgdHyxxMy36mkmK?= =?us-ascii?Q?uc71AMdEgwGgtqX32c3RUGfp6YQVrq7HAv5qMDM6EittsY+pQIdWqPaiLhg0?= =?us-ascii?Q?tT65QVqIUute+Pgf692sBo27tus/pBM4hAqlSgy64/CcWnQ3EvuC4tKziocI?= =?us-ascii?Q?IH8QB92H2OYlpOl7mQrs3QIw1yB6+gFosKPywVXyGgHBME3+EBoPTGytQ714?= =?us-ascii?Q?krF873LPQzA2RrdKF8Fmd33/peMU41bUvsRps7KAKURkT62UcFCDqOLPWrIc?= =?us-ascii?Q?PiZMo1iB5JR9ZJY88JsA/wh/iXj6qYeWj2yFnznFILOeKQsGC5Lj3Jfy/7t+?= =?us-ascii?Q?nMJkkvZxc8da09CZAvziINypducOOoClW9qhTF5NHkbaHLGeBkBkgUtvKNjh?= =?us-ascii?Q?aCDfSbJuIP2cJ5Ci4sHBi4XPNGU+9hL9CSZyDyuzTgwn3Yuuz95jRNx3r+jZ?= =?us-ascii?Q?+N0poPO3bw5zgyNlcBgJYgq5uWORf7LYEG3IAjk0lFZXsVE78RYYajkSpk+g?= =?us-ascii?Q?Ez8agc6x9vZaBb4fJg4UH9W957G0B42rlzBbR7DAjAQiCEIjNfR4FSs+PuK1?= =?us-ascii?Q?E/Y2c1iDNcF/rNUnVO+CrvNE2N7cTg2b4/Yteh/boLFWk4dKF0bpBxpKshS1?= =?us-ascii?Q?JY7QO9jS8AIqVcXftS06c?= X-Forefront-PRVS: 0318501FAE X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BL2PR03MB164; 23:TSeUXOIX+azkbue5BYSZ4R3aiaMTpaZMsWR9EtdlY0?= =?us-ascii?Q?4X4LGoo+E5u/Oc999pOjBwjDF/H+Fjeu8S+eXFvz6L/AwDep0PB1x9lx1qNG?= =?us-ascii?Q?b52kcKp3oZ5TAk+xAJ5LC+t2yNuP8myEb2hhNMLMKWJUKNycGyKXuwjrV9m2?= =?us-ascii?Q?zjnt3owiias/Te5IPxiYJEPL+Jr6kBRpiuwoELUrp66acH5fix9Euvvrn6oj?= =?us-ascii?Q?cnZBfvKolTuvN2dzunCcgkgcVVUp3cLXhFT9THnunhsTXS8I+xBzDUApZPeH?= =?us-ascii?Q?RlQHSfPWCBxdMU8up8SmzwuWdOCoWPateXXAKYVjKab8SYvcXWpRTWZHcL4p?= =?us-ascii?Q?jwIuXiGDtKHReHr4aTLPOb//eME1bFhqTNBw0jpBV8UAfgJp118U/XozGatV?= =?us-ascii?Q?a11m/kxKqxh95XCx1lHrlnl/Lk2sjxiBsp6HBBUikS3SXLBnuPvLJ19jr9pq?= =?us-ascii?Q?jRipPRtw9Kv5GIlPRTBlGToo4dr52ixmuQ4I+PmYcMQoByDNTfROXXBdCbJ1?= =?us-ascii?Q?hQhi+9Qt3kjYiOfSJZ1gbDbIscn5w4tm98k/26CRsMUwM+AySHgy645NRqF/?= =?us-ascii?Q?mp4ZBO05ijBaRDKCmicCygL0I5wk7sj6fLKO5mijB+PYTDMyKK3wd2sqCZ7i?= =?us-ascii?Q?T5lHINoD/YpVjO0JNbcau/efzrUnWHqPN7UJV6OPl9zAzlb0i71Rk+m5d+Jx?= =?us-ascii?Q?IRueAtgsHU0x8c7iC3W7RIuWptQXfLFnJu0QgTtTfkZ7vZN8N0iJiqtYtAbz?= =?us-ascii?Q?hAlq+AKSmgHZu8UjUk62kh86fuJH+ia0ryxNDMxjrV3WawFFfDRP8kJqDWBQ?= =?us-ascii?Q?qDKPR158ZEw8sHnwXwfVtd4glBvHNHD6giChGxXoN8E3lh9+9ia1t20RLBco?= =?us-ascii?Q?UEztOKIebQYkgJlqAmehJ1wG3z3+Idngdc1cNzucxD+2j2mFupd/zduRYUHG?= =?us-ascii?Q?JwQC5/+vxjSefdk1sd5DYMY/FzH9XF4SQK1BIQ3DlBeP1T0yUHXtlcjp3nOs?= =?us-ascii?Q?L3iqebkEGwhB3uG0fJoAtGGyLip0dAW9K97uK7/Uf7SkvLLupqcw1MJ4kLv3?= =?us-ascii?Q?e+JId3qNOXfcWvM4FkSZ1JNv17nvvTrOtkHl7GWcRHQExRy3wW3MKktciBCG?= =?us-ascii?Q?uqC58xQtkaxYkB7AOotKBVcAkMs0iOUpypYNJD1HzJXj0ZCEj/z+Hb0H/dkH?= =?us-ascii?Q?tbla3E1ftgyv3416P+HmHhOLU7mV6qlvsMroG8MW1BDW0KPbj51qb2JjT0wr?= =?us-ascii?Q?nxVMn1aY2NsNROngM=3D?= X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB164; 6:w8+ImIpGf7BI0VQFxqqm39FwGcQE453DpYFCsrWpgdaM85MTVI9mUkOMYKiihasCVLxQkQs1KE6N5BG3x1Gs+TGJVn1TerTBIGXsTsfrzqtAEcsop6ZT9XTbT5zWQ6DFugL7LdmzhLNvnltRWuwI4ZRxjq0KxMs48w1LbUnJtCnKSaZ9249I3CxodW0pHkmx6ESaYcw+bwWs9dKaFE6BLduT+qBeOpW0Tk+Rre9hJPA1v+Pzo07YjFHpNLto4zB4cElu/GyA7nnawI2TQDgNIIY+cRnOIw6idBRCmzYB4fpcV89HzA7zCivPxTLKJdmVW8TkNLvbtTmzT7X9VBYgytmUspKgO+MRmaWb6kXjmaj8ousBYLHZLY/QBC4hAU9CDOdO2ygCytble1TFFoMys2kIfyJ1A/8ZCO+L9Lq2XqmHviMq1WjxLs9Qi8jjSZliVmgMGxROBrLP/nzezSwQ7wASmCSpvE+FxmYypDaHF0lNzC9aAMEXpl/iTsaKA9fez7dVmRSuIcgiviH/DSx/6Q==; 5:aGv8DCQVmdIPJEl6HmQnTIS92V3Agh77fMwPLPkeqUda9wPXgTXOdxZkTpatnpjLVY9CMnR8Lmmqds8atVjazfKaAZ6gz2d5tX1z34tbIhp1C/KlIXBE2L5djRYlgwK8cCKuQ16kmAGMJL/4GZFePWNdNakiVR8jFYzvaJGhv0xYY5BmgshzTs1alOdZOeyy; 24:ArwOlY47P2FaJstR+OzLUTWyNyC8by3jqe4UEmrj+mS5HaCTQh6SvcEGBtXH10orxyzTX8SoGeh2ugg5B94WB+w/0JxMz/bbOvERk1A8/10= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB164; 7:ilMNcJkLHFD64GcJHRzTBZwOuk0PrPp7kbC4fZZEliK3xJj67O//VM4ngPeoyfX6hbM6XrQythOPVrb4MqdcuI6WWBAqdchmC4Lej27CBNwaIAA161FdKh/UUP8mj2ST/qYOnC5/AYCpFJBXsq/L0d9owsUH7Y64FhdxaSGIZIW4yzMgSeZZlhENNL8sNcGo/K+92DabB/pwdZo1nwxFBm36oukRMyxdrH6m2Anfc1AnnChFgy2uuY9TNFNj9fkQXMmllfhXQXoOJNwzXqVNkxltzAwXyGbEVXKW9Ax4i3G30j1iASFV/uQpDBDxxVttkp10yBj/Rhgx2HInoLS3kg== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 May 2017 18:09:01.8410 (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: BL2PR03MB164 Subject: [dpdk-dev] [PATCH 06/20] event/dpaa2: register dpcon as dpaa2 device for bus scan 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: Thu, 25 May 2017 18:09:05 -0000 Registering dpcon as dpaa2 type device handling initialization, allocation and freeing of the device Signed-off-by: Nipun Gupta --- drivers/event/dpaa2/Makefile | 8 ++ drivers/event/dpaa2/dpaa2_eventdev.h | 18 +++++ drivers/event/dpaa2/dpaa2_hw_dpcon.c | 139 +++++++++++++++++++++++++++++++++++ 3 files changed, 165 insertions(+) create mode 100644 drivers/event/dpaa2/dpaa2_hw_dpcon.c diff --git a/drivers/event/dpaa2/Makefile b/drivers/event/dpaa2/Makefile index b76cf58..001904a 100644 --- a/drivers/event/dpaa2/Makefile +++ b/drivers/event/dpaa2/Makefile @@ -38,7 +38,14 @@ LIB = librte_pmd_dpaa2_event.a CFLAGS += $(WERROR_FLAGS) +CFLAGS += -I$(RTE_SDK)/drivers/bus/fslmc +CFLAGS += -I$(RTE_SDK)/drivers/bus/fslmc/qbman/include +CFLAGS += -I$(RTE_SDK)/drivers/bus/fslmc/mc +CFLAGS += -I$(RTE_SDK)/drivers/bus/fslmc/portal +CFLAGS += -I$(RTE_SDK)/drivers/mempool/dpaa2 CFLAGS += -I$(RTE_SDK)/drivers/event/dpaa2 +CFLAGS += -I$(RTE_SDK)/lib/librte_eal/linuxapp/eal + # versioning export map EXPORT_MAP := rte_pmd_dpaa2_event_version.map @@ -47,6 +54,7 @@ LIBABIVER := 1 # # all source are stored in SRCS-y # +SRCS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_EVENTDEV) += dpaa2_hw_dpcon.c SRCS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_EVENTDEV) += dpaa2_eventdev.c # this lib depends upon: diff --git a/drivers/event/dpaa2/dpaa2_eventdev.h b/drivers/event/dpaa2/dpaa2_eventdev.h index 959f443..b151502 100644 --- a/drivers/event/dpaa2/dpaa2_eventdev.h +++ b/drivers/event/dpaa2/dpaa2_eventdev.h @@ -34,6 +34,10 @@ #define __DPAA2_EVENTDEV_H__ #include +#include +#include +#include + #define EVENTDEV_NAME_DPAA2_PMD event_dpaa2 #ifdef RTE_LIBRTE_PMD_DPAA2_EVENTDEV_DEBUG @@ -48,4 +52,18 @@ #define PMD_DRV_ERR(fmt, args...) \ RTE_LOG(ERR, PMD, "%s(): " fmt "\n", __func__, ## args) +struct dpaa2_dpcon_dev { + TAILQ_ENTRY(dpaa2_dpcon_dev) next; + struct fsl_mc_io dpcon; + uint16_t token; + rte_atomic16_t in_use; + uint32_t dpcon_id; + uint16_t qbman_ch_id; + uint8_t num_priorities; + uint8_t channel_index; +}; + +struct dpaa2_dpcon_dev *rte_dpaa2_alloc_dpcon_dev(void); +void rte_dpaa2_free_dpcon_dev(struct dpaa2_dpcon_dev *dpcon); + #endif /* __DPAA2_EVENTDEV_H__ */ diff --git a/drivers/event/dpaa2/dpaa2_hw_dpcon.c b/drivers/event/dpaa2/dpaa2_hw_dpcon.c new file mode 100644 index 0000000..27f5bcb --- /dev/null +++ b/drivers/event/dpaa2/dpaa2_hw_dpcon.c @@ -0,0 +1,139 @@ +/*- + * BSD LICENSE + * + * Copyright 2017 NXP. + * + * 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 +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include "dpaa2_eventdev.h" + +TAILQ_HEAD(dpcon_dev_list, dpaa2_dpcon_dev); +static struct dpcon_dev_list dpcon_dev_list + = TAILQ_HEAD_INITIALIZER(dpcon_dev_list); /*!< DPCON device list */ + +static int +rte_dpaa2_create_dpcon_device(struct fslmc_vfio_device *vdev __rte_unused, + struct vfio_device_info *obj_info __rte_unused, + int dpcon_id) +{ + struct dpaa2_dpcon_dev *dpcon_node; + struct dpcon_attr attr; + int ret; + + /* Allocate DPAA2 dpcon handle */ + dpcon_node = rte_malloc(NULL, sizeof(struct dpaa2_dpcon_dev), 0); + if (!dpcon_node) { + PMD_DRV_LOG(ERR, "Memory allocation failed for DPCON Device"); + return -1; + } + + /* Open the dpcon object */ + dpcon_node->dpcon.regs = rte_mcp_ptr_list[MC_PORTAL_INDEX]; + ret = dpcon_open(&dpcon_node->dpcon, + CMD_PRI_LOW, dpcon_id, &dpcon_node->token); + if (ret) { + PMD_DRV_LOG(ERR, "Resource alloc failure with err code: %d", + ret); + rte_free(dpcon_node); + return -1; + } + + /* Get the device attributes */ + ret = dpcon_get_attributes(&dpcon_node->dpcon, + CMD_PRI_LOW, dpcon_node->token, &attr); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Reading device failed with err code: %d", + ret); + rte_free(dpcon_node); + return -1; + } + + /* Updating device specific private information*/ + dpcon_node->qbman_ch_id = attr.qbman_ch_id; + dpcon_node->num_priorities = attr.num_priorities; + dpcon_node->dpcon_id = dpcon_id; + rte_atomic16_init(&dpcon_node->in_use); + + TAILQ_INSERT_TAIL(&dpcon_dev_list, dpcon_node, next); + + PMD_DRV_LOG(DEBUG, "DPAA2: Added [dpcon-%d]", dpcon_id); + + return 0; +} + +struct dpaa2_dpcon_dev *rte_dpaa2_alloc_dpcon_dev(void) +{ + struct dpaa2_dpcon_dev *dpcon_dev = NULL; + + /* Get DPCON dev handle from list using index */ + TAILQ_FOREACH(dpcon_dev, &dpcon_dev_list, next) { + if (dpcon_dev && rte_atomic16_test_and_set(&dpcon_dev->in_use)) + break; + } + + return dpcon_dev; +} + +void rte_dpaa2_free_dpcon_dev(struct dpaa2_dpcon_dev *dpcon) +{ + struct dpaa2_dpcon_dev *dpcon_dev = NULL; + + /* Match DPCON handle and mark it free */ + TAILQ_FOREACH(dpcon_dev, &dpcon_dev_list, next) { + if (dpcon_dev == dpcon) { + rte_atomic16_dec(&dpcon_dev->in_use); + return; + } + } +} + +static struct rte_dpaa2_object rte_dpaa2_dpcon_obj = { + .object_id = DPAA2_MC_DPCON_DEVID, + .create = rte_dpaa2_create_dpcon_device, +}; + +RTE_PMD_REGISTER_DPAA2_OBJECT(dpcon, rte_dpaa2_dpcon_obj); -- 1.9.1