From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <shreyansh.jain@nxp.com>
Received: from NAM03-CO1-obe.outbound.protection.outlook.com
 (mail-co1nam03on0072.outbound.protection.outlook.com [104.47.40.72])
 by dpdk.org (Postfix) with ESMTP id D46F7D4E0
 for <dev@dpdk.org>; Thu, 29 Dec 2016 06:14:38 +0100 (CET)
Received: from CY4PR03CA0023.namprd03.prod.outlook.com (10.168.162.33) by
 BY2PR0301MB0741.namprd03.prod.outlook.com (10.160.63.19) with Microsoft SMTP
 Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id
 15.1.817.10; Thu, 29 Dec 2016 05:14:37 +0000
Received: from BN1AFFO11FD005.protection.gbl (2a01:111:f400:7c10::103) by
 CY4PR03CA0023.outlook.office365.com (2603:10b6:903:33::33) with Microsoft
 SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.817.10 via
 Frontend Transport; Thu, 29 Dec 2016 05:14:36 +0000
Authentication-Results: spf=fail (sender IP is 192.88.158.2)
 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.158.2 as permitted sender) receiver=protection.outlook.com;
 client-ip=192.88.158.2; helo=az84smr01.freescale.net;
Received: from az84smr01.freescale.net (192.88.158.2) by
 BN1AFFO11FD005.mail.protection.outlook.com (10.58.52.65) with Microsoft SMTP
 Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.789.10
 via Frontend Transport; Thu, 29 Dec 2016 05:14:36 +0000
Received: from Tophie.ap.freescale.net ([10.232.14.87])
 by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id uBT5DOHm010218;
 Wed, 28 Dec 2016 22:14:32 -0700
From: Shreyansh Jain <shreyansh.jain@nxp.com>
To: <dev@dpdk.org>
CC: <thomas.monjalon@6wind.com>, <bruce.richardson@intel.com>,
 <john.mcnamara@intel.com>, <ferruh.yigit@intel.com>,
 <jerin.jacob@caviumnetworks.com>, Hemant Agrawal <hemant.agrawal@nxp.com>,
 Cristian Sovaiala <cristian.sovaiala@nxp.com>
Date: Thu, 29 Dec 2016 10:46:25 +0530
Message-ID: <1482988612-6638-7-git-send-email-shreyansh.jain@nxp.com>
X-Mailer: git-send-email 2.7.4
In-Reply-To: <1482988612-6638-1-git-send-email-shreyansh.jain@nxp.com>
References: <1482180853-18823-1-git-send-email-hemant.agrawal@nxp.com>
 <1482988612-6638-1-git-send-email-shreyansh.jain@nxp.com>
X-EOPAttributedMessage: 0
X-Matching-Connectors: 131274620763921620;
 (91ab9b29-cfa4-454e-5278-08d120cd25b8); ()
X-Forefront-Antispam-Report: CIP:192.88.158.2; IPV:NLI; CTRY:US; EFV:NLI;
 SFV:NSPM;
 SFS:(10009020)(6009001)(7916002)(336005)(39450400003)(39840400002)(39380400002)(39850400002)(39400400002)(39410400002)(39860400002)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(77096006)(47776003)(8656002)(2950100002)(69596002)(6666003)(6916009)(5660300001)(36756003)(4326007)(626004)(104016004)(85426001)(2906002)(305945005)(48376002)(86362001)(50466002)(50986999)(76176999)(5003940100001)(92566002)(356003)(33646002)(97736004)(38730400001)(8936002)(189998001)(2351001)(105606002)(110136003)(106466001)(68736007)(81166006)(8676002)(81156014)(50226002)(7059030)(2004002);
 DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR0301MB0741; H:az84smr01.freescale.net;
 FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; 
X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD005;
 1:+UBiIRrzmTH+DPNgW3an7CNUwLM7JRZivrBE+lQcShir6lA6ur2QrXgkYHgQCipX3YODvtIUf1Gilrkrzldzp0mT5Iu/8gFgn7nLBM2cPlouKSyx3FPB7+YxNkG9ahYJPjvZh9aSHh7lARHJ/PxEbQfPOoVRxjcx1FhplxiZXlJElnGqMrpyVyjlnge8NKRZrGTdYV7td9kZGMR10PWeo6oMUJrviHKVkBgysWs7J3GRcbQMe63UoJdFFzhlwQFL+ROpRZpWqYcKjgpYc2/V/iEwF8QH61YSVdnWBhbvGc9dvnBrr/GCKImOMK8cMMaaapMEuQk4FwOR+nfWVAFRGXL1bY6gzhBNdVLdbcAcOttiIOlO7Sg8O2zHP+6FO2CGyjQzBBb4suUK+FGY1u6VlnjVRXOFdlpBc4ZporZ4iDwWdW3/INr9BWYdqqYmBEOq+OPVyIjZ3ylvbKzyDTebxaeV4coxg0tJ7zEdO9xzj8+rBlgQFvK+9FI30/SK1JEcRJYc0JYk9Zh/ILD44LrehcNKCW0YJ9tRiaXOb6WfmNiEsogaHvHtAmcgVZNWZnTahDUs4I7ZBQ7I+qHNQcZ75pCSy1zC20RBg1IVZHDyO3gjYc5vVqR3RTN66CQzVdkXKyEpfbjuct18Od6x/TKxUjuJDVgl9IMkvAVCkCP4DXDUhnG7pS4EJEbXxvdSNscgjj/CXDoes4lRSTK3PTYXcT6twR5/+L0vKbsxZLX4VVctnlYAUr9O3INirQELf0SKVw3IAmNhe2D0YE86n876Ew==
MIME-Version: 1.0
Content-Type: text/plain
X-MS-Office365-Filtering-Correlation-Id: 8ae2f2ad-4c0e-4ec1-51cc-08d42fa9950c
X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001);
 SRVR:BY2PR0301MB0741; 
X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0741;
 3:6kz/wgZ1jqNHwh083w1+cYcowx5Jj5rKo3QqPVn8qPmuuzxR89SAGEAZBKedx0rkLwOe92uTW7Z8jn3nsi/yT9p3vG7oZTeujGLc3O0n1FnjUcahwOIMsAhEUXgx+p8fNihRcFCZxWOIf5M9A2v+3CyIZ6qrRzxBBiIXTH9/B2s5rwlTrpYrU7rwnGCx0WzSqoH0VWcZWAqQLtsHY/fYo2cvy4Kqe6sCTrLg47iAkoiogZZ8aLpu2PtFqyKybVdrfgXAZ/yEyEPpA6TyZ8wtbaZQgFGmG2BnzRBitmElfDZD6/dX4/nTNv3efxNo2j2hP/EcvOJAFdzS/8wcH6o7r3+flmdJ2Beawvjhb7DhTr4=;
 25:TbBOUaVyIwQ6dTapbZNdA1awxEsoeY8mcGQ0sq2hSWX7U1oJo2clH9jCD9m8n9VuujZJD3wd/aUJ/vmyAE+EsSoycA0TkryUIE2YvUag/ScmGNboNOvJs677TZmw3LVkn6+zxzvbZXHxyYMe2i7okHD47ClHeB6clyGpc0jXGJccnuWsxH0ba2d1AJfK3cy4/NAQpC6Z4REAwgmHZaGBAHC2yx1pnZ19YvYeWuAP4m/vj2Tv9BQvkqivezEkouBbOUqLzwhzBMfgsm3Tt7DUHesPStxVbRPrigW1tWgEQRljV9XS1aT/hhR/ID4FQRSuUmRz+S7oloIWomtk9mM02n8U0x1CTysjT0BevE0kJJMZagiYC7/688saklSl2e0Oa7ktyiXvUatRvLxl9re/eG0QCn+WWE72fADIFj+YIAoS9OHSMSDOjPzEpHHlBUaSNbYvNG/Ds17RtwM2lRueBA==
X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0741;
 31:2fvUDPuAuDhXLI6pPJFpBg5qHYMeGhSWlhODlKJtN87qi9QvJNUs+TqwLJPl3PY6Hzg8+shkV0FyGrtJt7RUaXDdU5lIvjCivEf97WbpbTbfx6oHTTn/WX0W/xU1RsdvalFjtDi45loBe9qEibSdzdjfWDP8hYZ0E13OTZ/wQu4gOj5J2PC+WSCQlWW+Rw7JIjIsO9E+7khbjVeWmK7hCJ5MykF+5uXrxdYBxkKBYmW/EnTrwVtRteo2x9uNyN8cHWkUScmm1KpF3PNX/WazGw==
X-Microsoft-Antispam-PRVS: <BY2PR0301MB07418E26C3F5FA58C7A260C8906B0@BY2PR0301MB0741.namprd03.prod.outlook.com>
X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(275809806118684);
X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0;
 RULEID:(6095060)(601004)(2401047)(13023025)(13024025)(13015025)(13017025)(13018025)(8121501046)(5005006)(3002001)(10201501046)(6055026)(6096035)(20161123563025)(20161123565025)(20161123561025)(20161123559025)(20161123556025);
 SRVR:BY2PR0301MB0741; BCL:0; PCL:0; RULEID:(400006); SRVR:BY2PR0301MB0741; 
X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0741;
 4:VtO+roN/yU4br42QKnl0I5OeCo5rZ0u6bZh6VV+gNXHs2PKyWn1PWMr9xGujXyFX5jKA619tEixuk1dE8EhFwPjLab6z9Y74XNW9e/o6rkLwfaWqWAEVxhELxX5AYVwRM+8R6022zWBUhhnE2t38SBP+2/ozf0TGs/SpRhJMc8SI0kukUyumnpxe7dZZvQYnqQg1M3IhH1vJ739PAdFQueTJwMJcSdc+lqty/zKhyyj75kSPKrnESSJA4CAOjrNTiWIgvLCgSg4XiA27G8qu15l2QlUQ6VAhWslECjOZGVaEz5e2obLNSZnevhujFTSgH+6XqZDdd2311Tb5UxHJEyQK2IuTumiI2cW+E2isN1CZvG3reLr5ylmA3gtAtM2Lb5xz+Lz6izZkXbGyZdx0/tiHvEmGDgIHfpYoczgCKjsiLaN1OK8UkR1xdawlMreb4OMPkXr+LYDug726HsHdYVxyHF+sibMUFiIPlt7nyVqPB53UEXwOaV+lzhLuUdV3g98PlLGr6qBhtusc77L1VjaDLTxVFmwr9ES2GesOm+hPJUSwjm0knYDclh2AffzZfxTUTTdd3YzLjptYIGSoUM6Ny9ZVRUv44XdVNMNDBIg8n7tAIeWTC83Sso+EK/iDf5AWDyn3pM+pD70dDiKrmT/SLmkFPjG8FF23mSobC5GBCKIHnwmfvD/5grNRuEJBOq8fl7bG4bIlcWJg9bGan+ut+hGQ3u0wYpOM/tHSzKHKdsb86aa6574k/eWD+lvcNxbzufcD2Sbgl+Hx88CBoA==
X-Forefront-PRV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COYExhAqnIMIBqEz+EoIRxyioeqKMk5y5JsbSjtC3K7daxY7b/ng6npLL69rsbnk4VOhOQBe4x9zeruDDOEzf6;
 5:9G/2jgP8eCGGYtVwNlr4uXeTK5WnQUv7suad+CXDhHYCa7Ghsl0eo6OMawrewf0JL3jOGuRjYGBETSbfj0AevnMXWUB3y0PquQBgg9JTtLgMfEXlLdNWk9UJhdkQ/vjTJH0Rkc2Cbt69+BX8+19rWivL50zhbcl3HKPlvI0t59oAOAmRARM7u7k8V+D4eUtT;
 24:bWE0sGZ/3Ke9cDtLugeCMVF/YI32Qz2i4U02hvxjZM75iBx6bJRQ+Rfy7ERMmw2vXbygG5Wg/ROEcJdX0MsIXyPircevfECFMx4saB1TiqE=
SpamDiagnosticOutput: 1:99
SpamDiagnosticMetadata: NSPM
X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0741;
 7:YHeDhYTT9xjNXdS6RPBB4yCVGZcmsrvEKl70a2wR+W6ZF8QPXsjsW3/RuWQgWAg150yrofHuDmf11pNYBo91/KWMNYLiZsFTQ9hUmBzC9fIsRR7tdAKQ/6u1CZ6RwBS/3OJ9vMgpjSu/8Q6QceGlNVALyVCRs1hcDn6sKzv2hLfLh5mIi/DOh6ac9IjAZijfogzEy7PHHVs3TSRTDokpvoUl4skLDdKkfwTYMAo7o8lo9VuBNu3RbjRWhj50I5ZoN8jyd0BmNjGaEgqU47jcjUErNJXsdfEc26h4WTSBzg67P8DzNRhG88H62bpZCoB4nGtIfan1KZt8RSKhRmOL0dQmS7dGK0CbegsmDRoDS8cjF34FgVDtm/g7EZlyBXVUqrRkhMGcKL8X1o9bprS7H4qfsYC4S7o9I2mTIDuPea/xpYZekBEgs/QQgYYNHxswwJ1JCvMJNPmFZer2n/EABA==
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Dec 2016 05:14:36.0333 (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.158.2];
 Helo=[az84smr01.freescale.net]
X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR0301MB0741
Subject: [dpdk-dev] [PATCH v3 06/33] bus/fslmc: introduce mc object functions
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Thu, 29 Dec 2016 05:14:39 -0000

From: Hemant Agrawal <hemant.agrawal@nxp.com>

This patch intoduces the DPAA2 MC(Management complex Driver).

This is a minimal set of low level functions to send and
receive commands to the fsl-mc. It includes support for basic
management commands and commands to manipulate MC objects.

This is common to be used by various DPAA2 PMDs. e.g.net, crypto
and other drivers.

This is a low level library also used in kernel.

Signed-off-by: Cristian Sovaiala <cristian.sovaiala@nxp.com>
Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/bus/fslmc/Makefile        |   7 ++
 drivers/bus/fslmc/mc/fsl_mc_cmd.h | 231 ++++++++++++++++++++++++++++++++++++++
 drivers/bus/fslmc/mc/fsl_mc_sys.h |  98 ++++++++++++++++
 drivers/bus/fslmc/mc/mc_sys.c     | 107 ++++++++++++++++++
 4 files changed, 443 insertions(+)
 create mode 100644 drivers/bus/fslmc/mc/fsl_mc_cmd.h
 create mode 100644 drivers/bus/fslmc/mc/fsl_mc_sys.h
 create mode 100644 drivers/bus/fslmc/mc/mc_sys.c

diff --git a/drivers/bus/fslmc/Makefile b/drivers/bus/fslmc/Makefile
index c4f22ed..21e9f17 100644
--- a/drivers/bus/fslmc/Makefile
+++ b/drivers/bus/fslmc/Makefile
@@ -37,6 +37,10 @@ LIB = librte_pmd_fslmcbus.a
 
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += "-Wno-strict-aliasing"
+
+CFLAGS += -I$(RTE_SDK)/drivers/bus/fslmc
+CFLAGS += -I$(RTE_SDK)/drivers/bus/fslmc/mc
 
 # versioning export map
 EXPORT_MAP := rte_pmd_fslmcbus_version.map
@@ -44,6 +48,9 @@ EXPORT_MAP := rte_pmd_fslmcbus_version.map
 # library version
 LIBABIVER := 1
 
+SRCS-$(CONFIG_RTE_LIBRTE_FSLMC_BUS) += \
+        mc/mc_sys.c
+
 SRCS-$(CONFIG_RTE_LIBRTE_FSLMC_BUS) += fslmc_bus.c
 
 # library dependencies
diff --git a/drivers/bus/fslmc/mc/fsl_mc_cmd.h b/drivers/bus/fslmc/mc/fsl_mc_cmd.h
new file mode 100644
index 0000000..cbd3995
--- /dev/null
+++ b/drivers/bus/fslmc/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/bus/fslmc/mc/fsl_mc_sys.h b/drivers/bus/fslmc/mc/fsl_mc_sys.h
new file mode 100644
index 0000000..d9d43e5
--- /dev/null
+++ b/drivers/bus/fslmc/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 <linux/errno.h>
+#include <asm/io.h>
+#include <linux/slab.h>
+
+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 <stdio.h>
+#include <libio.h>
+#include <stdint.h>
+#include <errno.h>
+#include <sys/uio.h>
+#include <linux/byteorder/little_endian.h>
+
+#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/bus/fslmc/mc/mc_sys.c b/drivers/bus/fslmc/mc/mc_sys.c
new file mode 100644
index 0000000..c428624
--- /dev/null
+++ b/drivers/bus/fslmc/mc/mc_sys.c
@@ -0,0 +1,107 @@
+/* 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 <fsl_mc_sys.h>
+#include <fsl_mc_cmd.h>
+
+#include <rte_spinlock.h>
+
+/** User space framework uses MC Portal in shared mode. Following change
+ * introduces lock in MC FLIB
+ */
+
+/**
+ * A static spinlock initializer.
+ */
+static rte_spinlock_t mc_portal_lock = RTE_SPINLOCK_INITIALIZER;
+
+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 --- */
+	rte_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 --- */
+	rte_spinlock_unlock(&mc_portal_lock);
+
+	return mc_status_to_error(status);
+}
-- 
2.7.4