From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0052.outbound.protection.outlook.com [104.47.33.52]) by dpdk.org (Postfix) with ESMTP id CE9BE559C for ; Sun, 4 Dec 2016 13:43:44 +0100 (CET) Received: from BN6PR03CA0068.namprd03.prod.outlook.com (10.173.137.30) by BN1PR0301MB0739.namprd03.prod.outlook.com (10.160.78.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.747.13; Sun, 4 Dec 2016 12:43:43 +0000 Received: from BN1AFFO11FD025.protection.gbl (2a01:111:f400:7c10::140) by BN6PR03CA0068.outlook.office365.com (2603:10b6:404:4c::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.747.13 via Frontend Transport; Sun, 4 Dec 2016 12:43:43 +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 BN1AFFO11FD025.mail.protection.outlook.com (10.58.52.85) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.734.4 via Frontend Transport; Sun, 4 Dec 2016 12:43:42 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:; UpperCasedChecksum:; SizeAsReceived:773; Count:10 Received: from bf-netperf1.idc ([10.232.134.28]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id uB4ChXb5032240; Sun, 4 Dec 2016 05:43:39 -0700 From: Hemant Agrawal To: CC: , , , Cristian Sovaiala , Hemant Agrawal Date: Sun, 4 Dec 2016 23:46:57 +0530 Message-ID: <1480875447-23680-3-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1480875447-23680-1-git-send-email-hemant.agrawal@nxp.com> References: <1480875447-23680-1-git-send-email-hemant.agrawal@nxp.com> X-IncomingHeaderCount: 10 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131253290230423080; (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)(189002)(199003)(305945005)(2906002)(81156014)(97736004)(68736007)(626004)(50226002)(5660300001)(85426001)(8676002)(76176999)(50986999)(105606002)(110136003)(8936002)(104016004)(2351001)(38730400001)(106466001)(39400400001)(6666003)(189998001)(2950100002)(77096006)(6916009)(356003)(39450400002)(4326007)(33646002)(47776003)(36756003)(5003940100001)(92566002)(39410400001)(39380400001)(50466002)(48376002)(7846002)(8666005)(86362001)(81166006)(7059030)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN1PR0301MB0739; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD025; 1:uK/aoH2qZnqdEFEaKPy3PJMVbGqgJaUGbA5XyFtw+NQhd2PGJZWCP4A8riQSzw0FgO4Hv7Y7MJ2U3qJjqZClh9QVM0gur5eNn/hCo7nED2y7+2EUMPdzDuAFJROqZvFkooDC4jAlk/TUpvPCqX1Yk3kAs2jM8eaJmyOGwYHNN4jFKGDnlrQu9Px9XaaNVvf9V+/fseHQz1k82qkCCUYs1CU4jpBAcB8QDi1ISPRSfUttEpa0JsMGR6X8vnwJUaTv0U/juCPKvr+kKmQUvjpxaMf8FbdrzzAtl383re9Ow8kqCYV+UVpvX3uzmcV+u1i96z1rDAf69z9eeKeg1jUraZB/eBcU9oBLXAD+AAzP5OAA9zmt45ZPrdb1Ooki8sE4ADc2VBxKVt/s7MxAZxeeBvIrsWi4ceGX1DEdcLr/wMaFNu0PAWy5BeXfMmt4n/zGB/hcDabgFOIYeKHKQp9Euma2zBu8ux7BQ6A3KsbjKTl9hD8OQlMbP8Uns/c4Bwh787CTbmaLCq56xb+jTLjcFGT0UUpn4pqDixQY+G9old0Lvyg6cXvgOO/lbj5tt54Xyt5VMLe5VAbyvRQcsWLYSpe5ouKXseoy8oq75kx2N+ha//dKiTelgIsszUN6kbLWZAQpk8mTqUyUPpwwWnBg6OyfZ5COAb/yXdCuWEdJdnDTBBaQeaW8nOeRrfqE001vCe90niOTdlATeFtwi87WoVGwtiZ0JWfNhdtUnJUE4qDfeOKpvWr7q6UiIHqvwp+W8p92eBD6RRylSrka43eDZQ== MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: fbcafb69-3413-44d3-b1d1-08d41c432e2a X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:BN1PR0301MB0739; X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0739; 3:0k4cQaR0yWFY7M2J2sV2KVX0IIADEzbjM4ysP9dIGpKckiLsfPHBb6Wzma5JmIziDAkWW62DytbkPegT67fDz2XqumqaYRwzpjFKkyfRoMq+th/fpVXLgvPBxa4TmE9NH69mM/ET/I5F3ruZGbgwqx57g8RjH/uxbMPdFNEbCe0KIyWpQcGWbgcuk+frZI/hZL0f7r0NUD6TGeIN1+19nVfEiPL6LXiRhFAYI4pCrBBU9RDn4sWv+plM7dvb8eX8Hgou1MQIs3ju1MiQn4zVFqTNbe3BPV/lqBEZMIToPvTpVkqvWmWYeMRq42gZeRzGAU+GoYLeeBX4DvgH8TkDGhuBAkRyddKP//ipDun8dA0b3XBvXfY+Seb9qDol5S89 X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0739; 25:V36vOr17BCJigQIELwOW56CFhGUDsR6cd0tRwuqMfeBq/bcwn8oG+NC/gDHu7s/f9ALG/7Apr6gnkEOfnzO5JqhTsSTqqcOtc/U99gwUSuKFZjv1hr9VBEL6wzb+pgRnRKT3cjCY0937iaFCGo0wCwlu2PJk1Z8ouHEtUogCJ9W+yAkeNO+RGj/tj+P8Zw9gp9ucEm9PSu9P1LNeTvPv0bP4PH5L6y6y4NcG0VOCJfmC/dUm8SLTbqAsful3KblOg8/FjQffmjWStkszHdLvNJCup5B4c+uJDncBAgmhRN4UwJbbZpKmSHMytHtqWBoq2o1ZaDjCUpx62++Xl88aL0SGIwrjOfwmIHbiMezFjO95rl+8l5OMc73zKwoQ3iIzUoJce/ymM6qFS1RyZi1ytEKQlkc98J8Ca19Ie0KmKbmgUPoA6vhwZAZNl+1bSwr+27bXJ+ZHpoBsxG0AKwdIap+fg+4H3Ej4W1+F+KmkiSbgBv3PbPtbTqh1+pn2MMm6mFTwprO3NjoQeSJrb+f35OHsimQJ7E7HEh+D01FoysKXFWcGrj1OuZPXPzuZFVpMCn0iGT7P0VMvSV1PvZjZ0Srw9oyNSHKKBE+cmRLpPQCzUMRFuqBiXZlNuYkTVX4RomXiWXbFRJINqJnImqwSJ+gyuFV/Xp51HTyraoVjZXyE2cpCekBXCjdkFrrkqr5nx1yYzjAyB8LKvsGEhRNhrwGJIegxHLQm8IDt1sOU6oFBZkzbZABEkYfvCiG3LI9m/yCG05+binvOumJTJdVYZA== X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0739; 31:iA4L2ZyOP1vYe2Lx275NUK2ajCcFCC7bV4hm1lFdZAk4U71X47CocnZhMknePOwoLhoY+gP3Pg2JYBwi5knzBoBQ5XNZdFQ1drqFVl6S+8bjISQDeBoOFShUDbzXBJVySY3I/1uuzOr94RZ1mLkKcJZMvE8sfDKtYwGSq6tuderB2a33o5+pp76oVEGeNDxRv99HN9JwweMgFSNNcH6IlXBc3j6mGM1XNv4UFUKhwMgvCTOQpvTBBo0YUqOKwK5qpqPJEFrVWT2TK51cQpBl8w== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(275809806118684); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095060)(601004)(2401047)(13017025)(13023025)(13015025)(13024025)(13018025)(8121501046)(5005006)(10201501046)(3002001)(6055026)(6096035)(20161123563025)(20161123565025)(20161123559025)(20161123556025)(20161123561025); SRVR:BN1PR0301MB0739; BCL:0; PCL:0; RULEID:(400006); SRVR:BN1PR0301MB0739; X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0739; 4:NORfJ1l3uCMgD+a9ik9fXa1RgfPcgo1SXDUTJ+6VupZuD3oTr5aL+UPiCOaRN4/DaU0FgzLiDqOD+Xng7zK1jA8/tJcutOOcM+PntDd7/kslweLq9I4NgcJyPFn7rIBxdRUYiuqP6UygLN78Bd1svttp4yjtfyNEKln308DALXZF0b9IQowVPHiU4xiN7yX2ooZSnD+UHf/wHT8D4L4CMWMrm/I2g9IcG3K7t2cmtxeGf7mvXkkaM4jyZLFeN+nwn9ufWpA6z9yVjV1oSq4tLkRl+uVyzIdG2+5vVbmPs14AP/YTb/XyR3XNm1gp6pI/r6j4pZF2K5X+ZWpi/4SZZeyYsJf3gXO4MOQNEVuCiVcpNxdvak3Lp5VHcRtpPU4VRy026vtarmX2sgHNIOtzPLmiC78BZvjNfnGTQznANA8BihQUctsWKwiYSXHlwTW3um97vtCq7iu1EKVZRK1mp8mdzB1Vt7AjQNIoMuwiZaxeR1mS6w+Lkfh3YNs2fyaNkwZQ6wtExNtUOkmncX1QshsD4dCiTRhFnANxMJtu3jlCMNBS9j8LwvXCxi+0f/d+KzUFtbLZKtE7L8JhgUbByEygXnaKKkQgFOTFQFQPsS99JVaxxFQ05qnbiosLQvDoXlTlKwUF8H/JR4T2CsjeKGxoGKswrUXoowF/NBmelP0xss2vfWfabW1uELm0MhT3cMBgo2Bx9Y5TLntatGzGbmVUm3Lrm7JIqnfyzG3318japzSVtIBoh92UBS3RzvcJIa88vtu37AJl//Cb365lBw== X-Forefront-PRVS: 014617085B X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN1PR0301MB0739; 23:96o1J8OMmSM2RnbD6xlSa/GZmqYxtlC2CtNX3Fv?= =?us-ascii?Q?qO83wM+8TVTjAYaZI5xWpuDD1IovZpjsL5R7QAlRt3HAxKL3B6rIUTgXlYWn?= =?us-ascii?Q?iqtpagn7CZ+BbWItQPG7HZiT5XXfN9t8x9CTcmBmHPErVbdQ/qcvir2z043d?= =?us-ascii?Q?IWMIDPCND9L+u09jgeHzyUpV/UJDQsHJHiScliigPmoWprT1gJOZPute9xXA?= =?us-ascii?Q?TbCLvb7wwjHZqQC3O3SZtBSr2Z1VnMIBcQ9ZsW6swM0RHNAGC57OxdrQdKIR?= =?us-ascii?Q?3VwK4gCRUgjkWxErrnj+09nQWPxjmaMLQrnAGTmZYGpkdzSArBUKqWFSPEah?= =?us-ascii?Q?aoffD5yN5aBai/iqTzWiKrOds3UargiEgk4e5655WBSNs/J3QTAAqs4o0OVf?= =?us-ascii?Q?RjMjle+Q8s8RjMyjkjv9yEM0DtJv6CxodAkkLk+TPAlF4CVd6QEx5f50DOvN?= =?us-ascii?Q?/j0t+XoMYzip5e584on8W6Mt0oMsYvQHRqKqdAhcShmmP8N5js0AzQ75GjmE?= =?us-ascii?Q?q+Lwe7PJ5ekadYElH7HpoCP3VIr07abdtBbIdq2BzTjO4ME5tkcMPZm/lkD4?= =?us-ascii?Q?iO+7HTAOPNM8awE5FgY2Eu+hqXmppDiafwGr8k51tO869CiBn1aOeQts51M3?= =?us-ascii?Q?jCh47e0Neu9a/+S2gPjwO/SAurT4KTISLB5EbqaNzXjJd51tph18JI3490G5?= =?us-ascii?Q?aWPKpsjXlEEadcwsLWnu45YWTIGSgH8s0jouXVY052LzmBY/PYMSyIbAI3YI?= =?us-ascii?Q?YF+D2svMVvSUUWDnbc0PsQb0CjSkMhmfn+R9ZkO+X8WzEt+x2bfS/72TjYe3?= =?us-ascii?Q?nX+/cP3Eut4RXxjSoNggx3EobxU+1IDlciD5zYwCB8c3ljXZNt1qEGr/7/Zg?= =?us-ascii?Q?+AEIimD2K8CuVSkyNszrpt8ffFQTI6woXk6UYzflMgpgbTQ/jJlWoHfNHVXD?= =?us-ascii?Q?bYBryMeUJx/lwwpJ2QbtE2IMJEGJuI6JmL0YOIvU0JVfFyH89BdLHEf55HCQ?= =?us-ascii?Q?/oHMOcKK4/+nMyTf7K+FNK++UZickj3bejOz7DYziMPkMq60fu/UvbjeUuVB?= =?us-ascii?Q?efwzGAS95rUJ2sxZ4pt4gpYDHjD4txkK4I9Bae+ykvK27dNqqjiy6OunLV6D?= =?us-ascii?Q?PPonPbPmE8xKyouOiJH0csxYBwJEMS5JC+25qq9tsulV2kAwvZMv4dqm8W1X?= =?us-ascii?Q?qj4uOzZvumChg6bv6v3B9bcWLBKOhiO42D87L8WLnWZ/JqqnLbgQ9FKR3hQa?= =?us-ascii?Q?gzVPG2fnahNkInIGY+Rc=3D?= X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0739; 6:EKWXTDZdxadqFd3NIgxf0UGQjMYRFMHMZngOMq9TLb9O8tLPD+noVMmNZo/442CdF7v354gRqWCoqhvjfF+9fyNv4KzeQ/5fl3C+34jyM5MBGIiF+kys8RiPLqYXkQz37qDvHlfCl/plkDOi/SqrBQRwf4ixfP8jzuh2ecdZ1GDKLdrZKyiQGk7B9Scgggxbeu1pPvq7oowis0EG6KE0gfxIcjtM9dDutIgGwd2gAnJEflwU7EZKo4jjbR3cJatJ7TP3HI1abe1MPmoyiskRB7h0vnCCFTpidqiVOzxahJ1inzZpwRiJM5rF5HNnW/ws91BBOgarKnCKrDFM5e/SG0ecCF8p+64Nb3uA1+Yn84fIOZiehuQJC4cgsDnXUApi6pdEbMwOYsi5VEsQZrvHchYCDP22E9CW4cOYAw/IQeh+8W2eBNDzJ+4XSaVYXUUP; 5:VihsWmEPxb2dOWxA1YyCS+XZPmyl0mRv0V7IBD+qyf72ki8b0cgSnjSUzzJfyAP6OxijbWTI5cQtJArwkg4UrwYlmHJeJZS+FzF0XcIldXERavfJsLIWsKRp5zp6I1/gViM6ILWQla0CcErngdeJFAu73atRWyoYiabBbRhuCbJePM8l4OUrOSxerFzHvIQb; 24:tIv9hOSQY/gpX3MAwlPtFNgjLdDwF98TRal3alD1GZ2/i2tf5BnxEyI6goxvnBx89Ixfry3s61V3jaIQY1pj/5UHzV3D3jF44QwkLzfP8ZE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0739; 7:MMnSv26a7eswI0RnR21qMl4eyVNNQLYJXtj950MNBbDnNYqP9XJ+5WhxVrLdQHwkcvXm2qqnPhAhxXM1qldESNcJUXHgdG9sxCxlNLDvActtuCk/GoYYseML5/UU3yQroIXMkDDdva++OXtKDcqXDrdDmBWr9mKCkQt0K8YGk+K3irbKk+Fd37ldY/q6YnQ0tq1X/vVbJ7wPS8B3WHyq6grk2289f9hBCdKD8wWJt3OJvxjinqtm7RfthJzhd+1C+VVUpcestcDC6bcKbbLjAcu5iGGk6LCxNbqn9XsPAO3P3pdsj2jsWGY+varjzfRL9/CHq18dLX7Z/4Yf4PWBUD5IjWWoRGTl1amsmHH7a2lB2NgiBq+me6WyL1siXEp3RIn3KZPh0bYz6uX3kyHcwPr4XzpodfUaOpi01m4JyC8QQoh1btCxjKpYP0BGM0+89UFd+WmLzyLUrFBXClIIcA== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2016 12:43:42.7147 (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: BN1PR0301MB0739 Subject: [dpdk-dev] [PATCH 02/32] drivers/common: introducing dpaa2 mc driver 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: Sun, 04 Dec 2016 12:43:45 -0000 This patch intoduces the DPAA2 MC(Management complex Driver) This driver is common to be used by various DPAA2 net, crypto and other drivers Signed-off-by: Cristian Sovaiala [Hemant:rebase and conversion to library for DPDK] Signed-off-by: Hemant Agrawal --- config/defconfig_arm64-dpaa2-linuxapp-gcc | 7 +- drivers/Makefile | 1 + drivers/common/Makefile | 36 +++++ drivers/common/dpaa2/Makefile | 36 +++++ drivers/common/dpaa2/mc/Makefile | 53 ++++++ drivers/common/dpaa2/mc/dpaa2_mc_version.map | 4 + drivers/common/dpaa2/mc/fsl_mc_cmd.h | 231 +++++++++++++++++++++++++++ drivers/common/dpaa2/mc/fsl_mc_sys.h | 98 ++++++++++++ drivers/common/dpaa2/mc/mc_sys.c | 126 +++++++++++++++ 9 files changed, 591 insertions(+), 1 deletion(-) create mode 100644 drivers/common/Makefile create mode 100644 drivers/common/dpaa2/Makefile create mode 100644 drivers/common/dpaa2/mc/Makefile create mode 100644 drivers/common/dpaa2/mc/dpaa2_mc_version.map create mode 100644 drivers/common/dpaa2/mc/fsl_mc_cmd.h create mode 100644 drivers/common/dpaa2/mc/fsl_mc_sys.h create mode 100644 drivers/common/dpaa2/mc/mc_sys.c diff --git a/config/defconfig_arm64-dpaa2-linuxapp-gcc b/config/defconfig_arm64-dpaa2-linuxapp-gcc index 66df54c..00f207e 100644 --- a/config/defconfig_arm64-dpaa2-linuxapp-gcc +++ b/config/defconfig_arm64-dpaa2-linuxapp-gcc @@ -1,6 +1,7 @@ # BSD LICENSE # -# Copyright(c) 2016 Freescale Semiconductor, Inc. All rights reserved. +# Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved. +# 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 @@ -40,3 +41,7 @@ CONFIG_RTE_ARCH_ARM_TUNE="cortex-a57+fp+simd" # CONFIG_RTE_MAX_LCORE=8 CONFIG_RTE_MAX_NUMA_NODES=1 + +# Compile software PMD backed by NXP DPAA2 files +# +CONFIG_RTE_LIBRTE_DPAA2_PMD=y diff --git a/drivers/Makefile b/drivers/Makefile index 81c03a8..d5580f6 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -31,6 +31,7 @@ include $(RTE_SDK)/mk/rte.vars.mk +DIRS-y += common DIRS-y += net DIRS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += crypto diff --git a/drivers/common/Makefile b/drivers/common/Makefile new file mode 100644 index 0000000..0c3f35f --- /dev/null +++ b/drivers/common/Makefile @@ -0,0 +1,36 @@ +# BSD LICENSE +# +# Copyright(c) 2016 NXP. All rights reserved. +# 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 $(RTE_SDK)/mk/rte.vars.mk + +DIRS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += dpaa2 + +include $(RTE_SDK)/mk/rte.subdir.mk diff --git a/drivers/common/dpaa2/Makefile b/drivers/common/dpaa2/Makefile new file mode 100644 index 0000000..a4f80c1 --- /dev/null +++ b/drivers/common/dpaa2/Makefile @@ -0,0 +1,36 @@ +# BSD LICENSE +# +# Copyright(c) 2016 NXP. All rights reserved. +# 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 $(RTE_SDK)/mk/rte.vars.mk + +DIRS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += mc + +include $(RTE_SDK)/mk/rte.subdir.mk diff --git a/drivers/common/dpaa2/mc/Makefile b/drivers/common/dpaa2/mc/Makefile new file mode 100644 index 0000000..9632168 --- /dev/null +++ b/drivers/common/dpaa2/mc/Makefile @@ -0,0 +1,53 @@ +# BSD LICENSE +# +# Copyright(c) 2016 NXP. All rights reserved. +# 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 $(RTE_SDK)/mk/rte.vars.mk +RTE_SDK_MC=$(RTE_SDK)/drivers/common/dpaa2 + +# +# library name +# +LIB = libdpaa2_mc.a + +CFLAGS += -O3 +CFLAGS += $(WERROR_FLAGS) +CFLAGS +=-Wno-strict-aliasing + +CFLAGS += -I$(RTE_SDK_MC)/mc +EXPORT_MAP := dpaa2_mc_version.map + +LIBABIVER := 1 + +SRCS-y += \ + mc_sys.c + + +include $(RTE_SDK)/mk/rte.lib.mk diff --git a/drivers/common/dpaa2/mc/dpaa2_mc_version.map b/drivers/common/dpaa2/mc/dpaa2_mc_version.map new file mode 100644 index 0000000..31eca32 --- /dev/null +++ b/drivers/common/dpaa2/mc/dpaa2_mc_version.map @@ -0,0 +1,4 @@ +DPDK_17.02 { + + local: *; +}; diff --git a/drivers/common/dpaa2/mc/fsl_mc_cmd.h b/drivers/common/dpaa2/mc/fsl_mc_cmd.h new file mode 100644 index 0000000..cbd3995 --- /dev/null +++ b/drivers/common/dpaa2/mc/fsl_mc_cmd.h @@ -0,0 +1,231 @@ +/* Copyright 2013-2016 Freescale Semiconductor Inc. + * Copyright (c) 2016 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 the above-listed copyright holders nor the + * names of any contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * + * ALTERNATIVELY, this software may be distributed under the terms of the + * GNU General Public License ("GPL") as published by the Free Software + * Foundation, either version 2 of that License or (at your option) any + * later version. + * + * 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 HOLDERS 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 __FSL_MC_CMD_H +#define __FSL_MC_CMD_H + +#define MC_CMD_NUM_OF_PARAMS 7 + +#define MAKE_UMASK64(_width) \ + ((uint64_t)((_width) < 64 ? ((uint64_t)1 << (_width)) - 1 : \ + (uint64_t)-1)) + +static inline uint64_t mc_enc(int lsoffset, int width, uint64_t val) +{ + return (uint64_t)(((uint64_t)val & MAKE_UMASK64(width)) << lsoffset); +} + +static inline uint64_t mc_dec(uint64_t val, int lsoffset, int width) +{ + return (uint64_t)((val >> lsoffset) & MAKE_UMASK64(width)); +} + +struct mc_command { + uint64_t header; + uint64_t params[MC_CMD_NUM_OF_PARAMS]; +}; + +/** + * enum mc_cmd_status - indicates MC status at command response + * @MC_CMD_STATUS_OK: Completed successfully + * @MC_CMD_STATUS_READY: Ready to be processed + * @MC_CMD_STATUS_AUTH_ERR: Authentication error + * @MC_CMD_STATUS_NO_PRIVILEGE: No privilege + * @MC_CMD_STATUS_DMA_ERR: DMA or I/O error + * @MC_CMD_STATUS_CONFIG_ERR: Configuration error + * @MC_CMD_STATUS_TIMEOUT: Operation timed out + * @MC_CMD_STATUS_NO_RESOURCE: No resources + * @MC_CMD_STATUS_NO_MEMORY: No memory available + * @MC_CMD_STATUS_BUSY: Device is busy + * @MC_CMD_STATUS_UNSUPPORTED_OP: Unsupported operation + * @MC_CMD_STATUS_INVALID_STATE: Invalid state + */ +enum mc_cmd_status { + MC_CMD_STATUS_OK = 0x0, + MC_CMD_STATUS_READY = 0x1, + MC_CMD_STATUS_AUTH_ERR = 0x3, + MC_CMD_STATUS_NO_PRIVILEGE = 0x4, + MC_CMD_STATUS_DMA_ERR = 0x5, + MC_CMD_STATUS_CONFIG_ERR = 0x6, + MC_CMD_STATUS_TIMEOUT = 0x7, + MC_CMD_STATUS_NO_RESOURCE = 0x8, + MC_CMD_STATUS_NO_MEMORY = 0x9, + MC_CMD_STATUS_BUSY = 0xA, + MC_CMD_STATUS_UNSUPPORTED_OP = 0xB, + MC_CMD_STATUS_INVALID_STATE = 0xC +}; + +/* MC command flags */ + +/** + * High priority flag + */ +#define MC_CMD_FLAG_PRI 0x00008000 +/** + * Command completion flag + */ +#define MC_CMD_FLAG_INTR_DIS 0x01000000 + +/** + * Command ID field offset + */ +#define MC_CMD_HDR_CMDID_O 48 +/** + * Command ID field size + */ +#define MC_CMD_HDR_CMDID_S 16 +/** + * Token field offset + */ +#define MC_CMD_HDR_TOKEN_O 32 +/** + * Token field size + */ +#define MC_CMD_HDR_TOKEN_S 16 +/** + * Status field offset + */ +#define MC_CMD_HDR_STATUS_O 16 +/** + * Status field size + */ +#define MC_CMD_HDR_STATUS_S 8 +/** + * Flags field offset + */ +#define MC_CMD_HDR_FLAGS_O 0 +/** + * Flags field size + */ +#define MC_CMD_HDR_FLAGS_S 32 +/** + * Command flags mask + */ +#define MC_CMD_HDR_FLAGS_MASK 0xFF00FF00 + +#define MC_CMD_HDR_READ_STATUS(_hdr) \ + ((enum mc_cmd_status)mc_dec((_hdr), \ + MC_CMD_HDR_STATUS_O, MC_CMD_HDR_STATUS_S)) + +#define MC_CMD_HDR_READ_TOKEN(_hdr) \ + ((uint16_t)mc_dec((_hdr), MC_CMD_HDR_TOKEN_O, MC_CMD_HDR_TOKEN_S)) + +#define MC_PREP_OP(_ext, _param, _offset, _width, _type, _arg) \ + ((_ext)[_param] |= cpu_to_le64(mc_enc((_offset), (_width), _arg))) + +#define MC_EXT_OP(_ext, _param, _offset, _width, _type, _arg) \ + (_arg = (_type)mc_dec(cpu_to_le64(_ext[_param]), (_offset), (_width))) + +#define MC_CMD_OP(_cmd, _param, _offset, _width, _type, _arg) \ + ((_cmd).params[_param] |= mc_enc((_offset), (_width), _arg)) + +#define MC_RSP_OP(_cmd, _param, _offset, _width, _type, _arg) \ + (_arg = (_type)mc_dec(_cmd.params[_param], (_offset), (_width))) + +/* cmd, param, offset, width, type, arg_name */ +#define CMD_CREATE_RSP_GET_OBJ_ID_PARAM0(cmd, object_id) \ + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, object_id) + +/* cmd, param, offset, width, type, arg_name */ +#define CMD_DESTROY_SET_OBJ_ID_PARAM0(cmd, object_id) \ + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, object_id) + +static inline uint64_t mc_encode_cmd_header(uint16_t cmd_id, + uint32_t cmd_flags, + uint16_t token) +{ + uint64_t hdr; + + hdr = mc_enc(MC_CMD_HDR_CMDID_O, MC_CMD_HDR_CMDID_S, cmd_id); + hdr |= mc_enc(MC_CMD_HDR_FLAGS_O, MC_CMD_HDR_FLAGS_S, + (cmd_flags & MC_CMD_HDR_FLAGS_MASK)); + hdr |= mc_enc(MC_CMD_HDR_TOKEN_O, MC_CMD_HDR_TOKEN_S, token); + hdr |= mc_enc(MC_CMD_HDR_STATUS_O, MC_CMD_HDR_STATUS_S, + MC_CMD_STATUS_READY); + + return hdr; +} + +/** + * mc_write_command - writes a command to a Management Complex (MC) portal + * + * @portal: pointer to an MC portal + * @cmd: pointer to a filled command + */ +static inline void mc_write_command(struct mc_command __iomem *portal, + struct mc_command *cmd) +{ + int i; + uint32_t word; + + /* copy command parameters into the portal */ + for (i = 0; i < MC_CMD_NUM_OF_PARAMS; i++) + iowrite64(cmd->params[i], &portal->params[i]); + + /* submit the command by writing the header */ + word = (uint32_t)mc_dec(cmd->header, 32, 32); + iowrite32(word, (((uint32_t *)&portal->header) + 1)); + + word = (uint32_t)mc_dec(cmd->header, 0, 32); + iowrite32(word, (uint32_t *)&portal->header); +} + +/** + * mc_read_response - reads the response for the last MC command from a + * Management Complex (MC) portal + * + * @portal: pointer to an MC portal + * @resp: pointer to command response buffer + * + * Returns MC_CMD_STATUS_OK on Success; Error code otherwise. + */ +static inline enum mc_cmd_status mc_read_response( + struct mc_command __iomem *portal, + struct mc_command *resp) +{ + int i; + enum mc_cmd_status status; + + /* Copy command response header from MC portal: */ + resp->header = ioread64(&portal->header); + status = MC_CMD_HDR_READ_STATUS(resp->header); + if (status != MC_CMD_STATUS_OK) + return status; + + /* Copy command response data from MC portal: */ + for (i = 0; i < MC_CMD_NUM_OF_PARAMS; i++) + resp->params[i] = ioread64(&portal->params[i]); + + return status; +} + +#endif /* __FSL_MC_CMD_H */ diff --git a/drivers/common/dpaa2/mc/fsl_mc_sys.h b/drivers/common/dpaa2/mc/fsl_mc_sys.h new file mode 100644 index 0000000..d9d43e5 --- /dev/null +++ b/drivers/common/dpaa2/mc/fsl_mc_sys.h @@ -0,0 +1,98 @@ +/* Copyright 2013-2015 Freescale Semiconductor Inc. + * + * 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 the above-listed copyright holders nor the + * names of any contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * + * ALTERNATIVELY, this software may be distributed under the terms of the + * GNU General Public License ("GPL") as published by the Free Software + * Foundation, either version 2 of that License or (at your option) any + * later version. + * + * 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 HOLDERS 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 _FSL_MC_SYS_H +#define _FSL_MC_SYS_H + +#ifdef __linux_driver__ + +#include +#include +#include + +struct fsl_mc_io { + void *regs; +}; + +#ifndef ENOTSUP +#define ENOTSUP 95 +#endif + +#define ioread64(_p) readq(_p) +#define iowrite64(_v, _p) writeq(_v, _p) + +#else /* __linux_driver__ */ + +#include +#include +#include +#include +#include +#include + +#define cpu_to_le64(x) __cpu_to_le64(x) +#ifndef dmb +#define dmb() {__asm__ __volatile__("" : : : "memory"); } +#endif +#define __iormb() dmb() +#define __iowmb() dmb() +#define __arch_getq(a) (*(volatile unsigned long *)(a)) +#define __arch_putq(v, a) (*(volatile unsigned long *)(a) = (v)) +#define __arch_putq32(v, a) (*(volatile unsigned int *)(a) = (v)) +#define readq(c) \ + ({ uint64_t __v = __arch_getq(c); __iormb(); __v; }) +#define writeq(v, c) \ + ({ uint64_t __v = v; __iowmb(); __arch_putq(__v, c); __v; }) +#define writeq32(v, c) \ + ({ uint32_t __v = v; __iowmb(); __arch_putq32(__v, c); __v; }) +#define ioread64(_p) readq(_p) +#define iowrite64(_v, _p) writeq(_v, _p) +#define iowrite32(_v, _p) writeq32(_v, _p) +#define __iomem + +struct fsl_mc_io { + void *regs; +}; + +#ifndef ENOTSUP +#define ENOTSUP 95 +#endif + +/*GPP is supposed to use MC commands with low priority*/ +#define CMD_PRI_LOW 0 /*!< Low Priority command indication */ + +struct mc_command; + +int mc_send_command(struct fsl_mc_io *mc_io, struct mc_command *cmd); + +#endif /* __linux_driver__ */ + +#endif /* _FSL_MC_SYS_H */ diff --git a/drivers/common/dpaa2/mc/mc_sys.c b/drivers/common/dpaa2/mc/mc_sys.c new file mode 100644 index 0000000..e12a18b --- /dev/null +++ b/drivers/common/dpaa2/mc/mc_sys.c @@ -0,0 +1,126 @@ +/* Copyright 2013-2015 Freescale Semiconductor Inc. + * + * 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 the above-listed copyright holders nor the + * names of any contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * + * ALTERNATIVELY, this software may be distributed under the terms of the + * GNU General Public License ("GPL") as published by the Free Software + * Foundation, either version 2 of that License or (at your option) any + * later version. + * + * 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 HOLDERS 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 + +/** User space framework uses MC Portal in shared mode. Following change +* introduces lock in MC FLIB +*/ + +/** +* The mc_spinlock_t type. +*/ +typedef struct { + volatile int locked; /**< lock status 0 = unlocked, 1 = locked */ +} mc_spinlock_t; + +/** +* A static spinlock initializer. +*/ +static mc_spinlock_t mc_portal_lock = { 0 }; + +static inline void mc_pause(void) {} + +static inline void mc_spinlock_lock(mc_spinlock_t *sl) +{ + while (__sync_lock_test_and_set(&sl->locked, 1)) + while (sl->locked) + mc_pause(); +} + +static inline void mc_spinlock_unlock(mc_spinlock_t *sl) +{ + __sync_lock_release(&sl->locked); +} + +static int mc_status_to_error(enum mc_cmd_status status) +{ + switch (status) { + case MC_CMD_STATUS_OK: + return 0; + case MC_CMD_STATUS_AUTH_ERR: + return -EACCES; /* Token error */ + case MC_CMD_STATUS_NO_PRIVILEGE: + return -EPERM; /* Permission denied */ + case MC_CMD_STATUS_DMA_ERR: + return -EIO; /* Input/Output error */ + case MC_CMD_STATUS_CONFIG_ERR: + return -EINVAL; /* Device not configured */ + case MC_CMD_STATUS_TIMEOUT: + return -ETIMEDOUT; /* Operation timed out */ + case MC_CMD_STATUS_NO_RESOURCE: + return -ENAVAIL; /* Resource temporarily unavailable */ + case MC_CMD_STATUS_NO_MEMORY: + return -ENOMEM; /* Cannot allocate memory */ + case MC_CMD_STATUS_BUSY: + return -EBUSY; /* Device busy */ + case MC_CMD_STATUS_UNSUPPORTED_OP: + return -ENOTSUP; /* Operation not supported by device */ + case MC_CMD_STATUS_INVALID_STATE: + return -ENODEV; /* Invalid device state */ + default: + break; + } + + /* Not expected to reach here */ + return -EINVAL; +} + +int mc_send_command(struct fsl_mc_io *mc_io, struct mc_command *cmd) +{ + enum mc_cmd_status status; + + if (!mc_io || !mc_io->regs) + return -EACCES; + + /* --- Call lock function here in case portal is shared --- */ + mc_spinlock_lock(&mc_portal_lock); + + mc_write_command(mc_io->regs, cmd); + + /* Spin until status changes */ + do { + status = MC_CMD_HDR_READ_STATUS(ioread64(mc_io->regs)); + + /* --- Call wait function here to prevent blocking --- + * Change the loop condition accordingly to exit on timeout. + */ + } while (status == MC_CMD_STATUS_READY); + + /* Read the response back into the command buffer */ + mc_read_response(mc_io->regs, cmd); + + /* --- Call unlock function here in case portal is shared --- */ + mc_spinlock_unlock(&mc_portal_lock); + + return mc_status_to_error(status); +} -- 1.9.1