From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0082.outbound.protection.outlook.com [104.47.42.82]) by dpdk.org (Postfix) with ESMTP id 00AB069C5 for ; Fri, 24 Mar 2017 13:42:01 +0100 (CET) Received: from BN3PR03CA0077.namprd03.prod.outlook.com (10.167.1.165) by CY1PR03MB2266.namprd03.prod.outlook.com (10.166.207.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.947.12; Fri, 24 Mar 2017 12:41:57 +0000 Received: from BN1AFFO11FD032.protection.gbl (2a01:111:f400:7c10::107) by BN3PR03CA0077.outlook.office365.com (2a01:111:e400:7a4d::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.991.14 via Frontend Transport; Fri, 24 Mar 2017 12:41:57 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; caviumnetworks.com; dkim=none (message not signed) header.d=none; caviumnetworks.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 BN1AFFO11FD032.mail.protection.outlook.com (10.58.52.186) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.977.7 via Frontend Transport; Fri, 24 Mar 2017 12:41:56 +0000 Received: from bf-netperf1.idc ([10.232.134.28]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v2OCfacC031007; Fri, 24 Mar 2017 05:41:53 -0700 From: Hemant Agrawal To: CC: , , , , , Date: Fri, 24 Mar 2017 18:11:15 +0530 Message-ID: <1490359292-18773-6-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1490359292-18773-1-git-send-email-hemant.agrawal@nxp.com> References: <1489754201-1027-1-git-send-email-hemant.agrawal@nxp.com> <1490359292-18773-1-git-send-email-hemant.agrawal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131348329171524479; (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)(39840400002)(39850400002)(39400400002)(39860400002)(39380400002)(39450400003)(39410400002)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(9170700003)(104016004)(48376002)(54906002)(50226002)(86362001)(110136004)(4326008)(36756003)(189998001)(2906002)(8656002)(47776003)(575784001)(53936002)(85426001)(76176999)(105606002)(33646002)(50986999)(77096006)(6666003)(356003)(6916009)(81166006)(2351001)(38730400002)(305945005)(5003940100001)(106466001)(8676002)(8936002)(50466002)(5660300001)(2950100002)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR03MB2266; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; MX:1; A:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD032; 1:ZFKiTxRG1uJBUseu73IzoBbBXe9qEIWPSu7HQInM8liVTSfPSSGt3QL1MhhNy0+LaZTOey/95ThOoWKX77tYf8/inf9X8FxG1QQAe2hydzqVdK19bRSQ4J+Ako1rY17ma1+kGI4q00SZBfaUU8aYaOzk+HhzrW2aDg4x0YVpK8Z3fZgSevShOAR1gnUiOAbXIFkbt7f1/bUBnsidJ5pP3F76blIVQSgyoonZaCOgO2ZsCyj+iQpcxabcTbx6jva1LTUo442RlnFjo0vM17vlWqEEfeRgXa4Ftcytd/d+vtjirWbNoWyBUvftR1Jcj+bERpVLbDtPv16urrlh624Yr9+bPBWuvlkPOBVbB2kCU7MJBCdPL6HW2wO2uF12vwSP+SkTdAwsApxMSJFX4SOlZvb8903w6FdVJOJy7GsMTjCns5Si9/0MXzLSnv5lBOXya1K53DkOZaXaJG0UrLLSma29KHzA4KbTkKGMUnmmz2XFVv8FBeK3H/9yYQpD/m6QPOfgHiocFdJUtRIHTKKRENMWhRIJa3lab9YKys4PFT/4uJKOFViRq45jXRD43tz/FE0n1PExAtCpeTVaU0maVdcSldgtkEWmZ2baUEFADuSZF6Xjm+/qe2qNuHkWLi1in0W1JJ++1crVhXSjYvRKqw== MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 2e3ff37b-87b7-4f2b-58bd-08d472b3288e X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:CY1PR03MB2266; X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB2266; 3:F5pO8UJFEnfDoR34ELXNrT2Ak88n1JOsXgVR/Bc/JT2tREn0o710aAun25svY8+nHpHA4DKIUAdxVoXXHb/Og+tjlUR0YCPgX3uE4p0msUchwUXAlvmC3pXwlUG7X6CL/FKIxTe43Vk3dWKcgyPgAbwdTwqnCwmXnCeQACaJOv4cGSvsk3c3IHJLRs2N+rc66FRxRdB3LXGBcsuC+AFyqEAEQF1xA6dxEc467L07E1n075iVskGkfLfY/K2XXP6R3WEVqBRN9NBN+lg3+WpIapjvbqVB6GWzzk3LhPchDSJ7pi0Q4nQdrDauwLLh6c8+DhEVEJwrnqOX+E4ow0f8I5kXYuozRMIKziJrrqm3/GSFwVOmKxVrDov7en+jt8ba; 25:cBGILF4/nDPbe6l+F3Z8XBRTEbsXIehtngDaZYcZfOMw9bVJwUhcHpjclpXtTyGYAGBtB5MGyOr+NXba+0wt8A2ExGzBm5lekP9px5liRLRPrXptOkBsGvL5ZOpo8Gw8SvX/l0oF/xLz5ha1Ze8wwbbF3BJkFy64vkKvIa1b9KmSxmVJMCdQECVWrefVZZw9tKnFZgHSxMY6GeqLN+IZRzMBw/kBVPBexgn5q8YY4IxpMD49eKQ6Jb8k/uDGLr9LQIqBijqTJDAyjl4A8AdF33kUGrbE3XAclqxMiuGpeCiSCTq7Yw+Ox/dETg4WCLYcVhv8jWiYFOAQ2Z3JIx/+t2LA82YpKdJoqJSOzPSZZaP8f8lMUF+zbOoJsUtrT/jIFvDf4NeuaCrxqErXsEJzuUxuWkeF9MJafa14sIes7RJuI+brrd9blOYLs9pmI9NLALknPAD0X+ufFftpDflNkQ== X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB2266; 31:gN/z1yuRQGwlYeYL2aFyH6ZPYpWP4A+23XEi8CAHKhEvLVcyOO1G8CwcI66VF/n6GQ0muLElpLW8kC+lPZrwIhSMlqCHSFSU28BD3J5KeXtZhhy3bjVnYt7E/vKbjUygAwt0O4/CO8uJ25KShfIoUIdxdQgBe1y3VymCpIRSCcHKU6ly2GkwV94lp02FMAKHhGdBtvrQkhNuDPtp1ANNnYb89nv2MshDZijwgQSgo7iKB62o6d2ZqBuqpQjZoIVExAX/0UuLeN1R7UKLWXEL/5W1RMfq8oRn5jDQLR4pzB8= 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)(13018025)(13017025)(8121501046)(5005006)(13024025)(13023025)(13015025)(3002001)(10201501046)(6055026)(6096035)(20161123565025)(20161123559025)(20161123556025)(20161123561025)(20161123563025); SRVR:CY1PR03MB2266; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR03MB2266; X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB2266; 4:QQiqOTp1JtB/EEnGI1tW82KbumWT81G3VEbQsPFhMAQxSlWZ6JuyN4U8RS86qGQJDIoh2HudYnxggenh35DduFrwy6JIzsKQM8SfeVpNjwVuxB0Fsuu1qTR9FStthP1Dc7L0CewKuBPAuq5ZA1Gjqbyy+KdZ8iWZhpnikTqacvF8B6tMwt65IgZ9XugzFlC4y9a+QBOc9lnuACmF+6WAXQ/TV13SnMsDc48B+RVr1dXNhRfnVCXRd5EYgxScUWIO7jDGKi6D7ifBJjYR8AtGi5cndGxDetLJik1taczde+DwOGJhneiJbGNs65L84+9EgAKZoIAX3ow6j9JoKsGgWCAywRHT9t4j7lHhXrKXbu+0IF+v7qqTO6iphv/FTiiZD4ATK0RwYXowYI8joUAqkoCmzc6L6qPu5+yu6Rdqk7HFwaUTDhFRF3UTIErb66rml3JQ9w/xCfAi08MbvwQrIzWTMjqvfswpMA31AA5pX2xXZv9cCNic+H2E2K/axwphE/aKyorIUvBfF2k1HuAiCUmkdKSLjkO4XTvdDjzMdh+3BVwukjwLHTz+jRcDDit0++hvWnLqegcU/qOt5D3igUAk5emGc34LlmO/a9/VvPWYV5T9Qa4ZdUNBke50XX8JgdZMcWTP2OmEVJcKcd0/1XpAOGMlqC2pYETKohAFXmzY0tUWj4SMcWTvFlihT96DqJUfS6T3Ev0heaKys0CAtCQ+9AGH7onH1zJUYD/9aP8iTc9gLgEVwFwKIL6hr7X/VatPBiUH6Ev9mag5pFmG/g== X-Forefront-PRVS: 0256C18696 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR03MB2266; 23:6evMt4ET70aynyETswrolXxoRSGbQwBlk8buF+hjn?= =?us-ascii?Q?MJoSyvT1Y/Tx1GIk6l9OFA269PkVPLP5lzj2zITXsk20JycyJPK4h8RdwTBb?= =?us-ascii?Q?GmbaPNixNcvSotlWAythIVf9MZJV3h9bgfYTJ+BB5JjTPBxREcRlDQIr/0DQ?= =?us-ascii?Q?oWzs6HT8CXRwmMehBbhzyebL37XtisD8J2CkQKMqbv2kGWYbGLrnC8Em42yT?= =?us-ascii?Q?m41fhZ0FyOrIIu3EnoaCpe1QmNuGsqvm1PmsJFYMyiliab0R0vGEAbPA+F2W?= =?us-ascii?Q?XrL5d1isBhy2gDiurpuM7MBXiAN5YUPB4+ywC1aWfdr+5vwEop7bDKZDEUE8?= =?us-ascii?Q?VE1fk0hCMFc1mKGv1BR1ZE6yybEFbr8UaoiHJTuzonp30ZAyC1EihN9mxNN9?= =?us-ascii?Q?Ck1yvr+aKsDa+muSQzb6DNC0jzEz9C5QYwuBjIaKOPlXaxx3MEgpnrCsejQa?= =?us-ascii?Q?3C6QBeevylnWDtdYJW76juWBzRthfPfM8UOREW2KUD2LTugfIsQ2JHl9l74E?= =?us-ascii?Q?anhDsyniPMDhSeV3kY4YJgKsgkdw731frvcvkI9EIXUapKIMBMMHL8/ESSXH?= =?us-ascii?Q?Rwv0S+58mv5SMZBGY9evfr8Uu9RC4kl41YZqh8nfNB3r7pYLIPTZSpKNfpWx?= =?us-ascii?Q?1sVQ/83ATGZJG5MJZ7iJtqf3qQxuZi+yWbclq1qU+nIhF9EboShb78V5LNYb?= =?us-ascii?Q?pTixYWrpS27Fx23epusAambw60Vpnv75LEmnbGleAI4AD9SOWICZijEWCtWD?= =?us-ascii?Q?ZEBBKtT5PTR/EwZ0gJEOOaTvI81BffGmEyJ49aSEYb7ttilb+jGFijqKCts7?= =?us-ascii?Q?Fs/3lqW3DEcWIdN9Fb/RzzpnZQ1km/w7vW3gZNiTDRQH9EDcwECAab3INvNd?= =?us-ascii?Q?NcdVWO4tH9H7ip5e5MP+V0je26yDPQbJS+BFFWkcY7zD0limF035uJFiyiAG?= =?us-ascii?Q?u5DCRmmsRDzbaxclVlYsq3ZUaRxSXuKChr4IGzZKmWKC/fNamHDeoeJHqOfB?= =?us-ascii?Q?Bxo2nYJxnTNQg76vi0Zre2WMncB73E4eGFYFA12vYoxSihEGIzT8wx+BYS5a?= =?us-ascii?Q?3mXonES/qqM8EChHSm1LNjY18etDGFKfDJbDNgXCR0Pq946QUV6hew1FY84M?= =?us-ascii?Q?aYwiDHT30Xf3l/3gGrgTrUcu1DRege8H/6gp63WkRM7aNSGS1kaJiRiy33hA?= =?us-ascii?Q?GsRe/dHP0s3aUXR9xrN0yWbLzQ9JW0mOfpg0teo/VBMo7Q65fbtSMwRUnKib?= =?us-ascii?Q?px0jVw7aERinoreTr0=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB2266; 6:gc0z9L1zcqz45l+3d4Ls2SYmtspyaq/EZNhlhEdmyMjvzz0XooqT6HOUMekeJDitOgHuaIAhoE5glRnd7q28BhoBHT0PC7rK8gcT7Msi5cL+GDAvIelSYDZOMLYT3e2ppCjLCAHJq2mS2LmRyBpeLAJawPd3st2IhPoXIowDxOG2sg2bz1Ye0w65No/tIFJZNGWvUwR/FGlwJt0n4jdtgmA28GhSm5mS3zytFHIml7/Tm5H0gobpCYK87bu4qBDZc1OrbmyfhP+D5NCds8IaOP0xtszWqaFemnkgOyWq3qXzWXKU3AgyL5s9NHRPi4o56DzD23fWxC3N7DOsgEY3zS0whBKeLESctUZMjRflQuwq9iRp5hyuMhVMLuiRXuP/qy9MKeDzyhmk50uilMdkTYfd95J2p6hmN0pYtHOPzdc=; 5:SDjq3Uphex/+H8grP4GmJ+DbEynNO4ziz+OsV3INUkMSo6cZnkP9ijZYZuG/NLBPYI+loPNdU19Ri3Edf7ZqzKsvx5qISdyU0AZoltoz0J1v+DGNpyvta+zXhmIldt4j8xrUcOXUxeJ45xksykwirfKyhPnzK9XSz0vSr2pM5GK87o3YUz423ICtA7XWJ7W/; 24:MKDgiF/e1qexO5m+NvfkjVp9NXfr12sAOdpDLvfGBouqaIZK+1DvJs8vqKc58XEnKsnS0jDVY8JNVjyymYdwreCk4tzUYmQ+PxLxb0mkjCA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB2266; 7:ppdi+lTZPzdDmE9C14L9hU9IvRusZAaSgJH66fknFV9lnpI5ytvqng/dr/hrfeVpVB7ZNLhmwBX7zXepsUXagg2QePJKhynIvD3ZBRs46zg+zcBW7N1/ZKadydz394TGvMQtkmnqcHKnF3epCCffz2ZaDNozKxlfssWx7Nkmn7iet04z68JGGlHcYmebYBh+Z5rS8Dh5tWNZyGgeXferZBvz4tkaZ3XmyKW5XEKQ9AQbXs2ql0rreN7yeozgr3kcjvUV9DoviCqle1366hrKaHvPwYySyJz5pqKoMksxXpnTJ09FEFJHyBXCXcQ5yvfZ5ouYepLwsrKVJuiPPwESyA== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2017 12:41:56.9496 (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: CY1PR03MB2266 Subject: [dpdk-dev] [PATCH v2 05/22] 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Mar 2017 12:42:02 -0000 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 Signed-off-by: Hemant Agrawal --- drivers/bus/fslmc/Makefile | 5 +- drivers/bus/fslmc/mc/fsl_mc_cmd.h | 239 ++++++++++++++++++++++++++++ drivers/bus/fslmc/mc/fsl_mc_sys.h | 105 ++++++++++++ drivers/bus/fslmc/mc/mc_sys.c | 114 +++++++++++++ drivers/bus/fslmc/rte_bus_fslmc_version.map | 1 + 5 files changed, 463 insertions(+), 1 deletion(-) 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 7368ce0..d968a09 100644 --- a/drivers/bus/fslmc/Makefile +++ b/drivers/bus/fslmc/Makefile @@ -47,9 +47,9 @@ else CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) endif -CFLAGS += "-Wno-strict-aliasing" CFLAGS += -I$(RTE_SDK)/drivers/bus/fslmc +CFLAGS += -I$(RTE_SDK)/drivers/bus/fslmc/mc CFLAGS += -I$(RTE_SDK)/drivers/bus/fslmc/qbman/include CFLAGS += -I$(RTE_SDK)/lib/librte_eal/linuxapp/eal @@ -62,6 +62,9 @@ LIBABIVER := 1 SRCS-$(CONFIG_RTE_LIBRTE_FSLMC_BUS) += \ qbman/qbman_portal.c +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..d225222 --- /dev/null +++ b/drivers/bus/fslmc/mc/fsl_mc_cmd.h @@ -0,0 +1,239 @@ +/*- + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * BSD LICENSE + * + * 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. + * + * GPL LICENSE SUMMARY + * + * 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; + char *header = (char *)&portal->header; + + /* 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 *)header) + 1)); + + word = (uint32_t)mc_dec(cmd->header, 0, 32); + iowrite32(word, (uint32_t *)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..ebada60 --- /dev/null +++ b/drivers/bus/fslmc/mc/fsl_mc_sys.h @@ -0,0 +1,105 @@ +/*- + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * BSD LICENSE + * + * 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. + * + * GPL LICENSE SUMMARY + * + * 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/bus/fslmc/mc/mc_sys.c b/drivers/bus/fslmc/mc/mc_sys.c new file mode 100644 index 0000000..4573165 --- /dev/null +++ b/drivers/bus/fslmc/mc/mc_sys.c @@ -0,0 +1,114 @@ +/*- + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * BSD LICENSE + * + * 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. + * + * GPL LICENSE SUMMARY + * + * 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 + +#include + +/** 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); +} diff --git a/drivers/bus/fslmc/rte_bus_fslmc_version.map b/drivers/bus/fslmc/rte_bus_fslmc_version.map index 95c1804..9b0fec5 100644 --- a/drivers/bus/fslmc/rte_bus_fslmc_version.map +++ b/drivers/bus/fslmc/rte_bus_fslmc_version.map @@ -1,6 +1,7 @@ DPDK_17.05 { global: + mc_send_command; qbman_check_command_complete; qbman_eq_desc_clear; qbman_eq_desc_set_no_orp; -- 1.9.1