From patchwork Thu Jan 19 13:23:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 19786 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id AF23AF962; Thu, 19 Jan 2017 14:25:18 +0100 (CET) Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0063.outbound.protection.outlook.com [104.47.34.63]) by dpdk.org (Postfix) with ESMTP id A29C7F8AA for ; Thu, 19 Jan 2017 14:24:35 +0100 (CET) Received: from DM5PR03CA0007.namprd03.prod.outlook.com (10.175.104.17) by CY1PR0301MB0747.namprd03.prod.outlook.com (10.160.159.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.845.12; Thu, 19 Jan 2017 13:24:34 +0000 Received: from BN1AFFO11FD037.protection.gbl (2a01:111:f400:7c10::149) by DM5PR03CA0007.outlook.office365.com (2603:10b6:3:118::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.860.13 via Frontend Transport; Thu, 19 Jan 2017 13:24:33 +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 BN1AFFO11FD037.mail.protection.outlook.com (10.58.52.241) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.803.8 via Frontend Transport; Thu, 19 Jan 2017 13:24:32 +0000 Received: from bf-netperf1.idc ([10.232.134.28]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v0JDO4eh015351; Thu, 19 Jan 2017 06:24:29 -0700 From: Hemant Agrawal To: CC: , , , , , , Cristian Sovaiala , Hemant Agrawal Date: Thu, 19 Jan 2017 18:53:32 +0530 Message-ID: <1484832240-2048-8-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1484832240-2048-1-git-send-email-hemant.agrawal@nxp.com> References: <1484679174-4174-1-git-send-email-hemant.agrawal@nxp.com> <1484832240-2048-1-git-send-email-hemant.agrawal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131293058731540669; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(7916002)(39410400002)(39840400002)(39860400002)(39380400002)(39850400002)(39400400002)(39450400003)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(36756003)(8676002)(4326007)(2906002)(50466002)(6666003)(48376002)(81156014)(5660300001)(81166006)(68736007)(47776003)(8936002)(2950100002)(50226002)(6916009)(5003940100001)(110136003)(356003)(305945005)(105606002)(86362001)(2351001)(106466001)(33646002)(77096006)(104016004)(38730400001)(97736004)(54906002)(85426001)(53936002)(8656002)(189998001)(626004)(92566002)(50986999)(76176999)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB0747; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD037; 1:Hp/0LdpKZ/2WRE0JUtAFRW+hmWo5HGeSeiFCq/h/+mzUcC9bsFaFVou85SdIx33IqNcRm+tZeIYH6t/UKlcIFeS2NKS1o4VfXCQuDTVab6YnD8wh4BN/BLm3Zr7eyqOjTjLVofGDlGgKhFdKMXiJZzj71sSIePd0E8LwonKPGrI1llL51IjaiHpnkj8NKHZ3k1Xto6asrLaHM+RcQcVRpkAc74AlNVkgqvpRnWzKU+PwZLVsYZAmvQprBpVHx0IvDhHsp6UZczOkpDW/Q5X/FPfZJACN1BazFPFR8+KPe/uRiQO9lzZTG6ESo62zfffUvfgEpcXXUixaAKjF5lTlkNp/MsyiIbiAP5h7dpSSbuEmwtSH6+zXsnnD8jup2umBJDAYXBC1SAClZ0lvomXUWJWnbQFSGryTKOpr5fqrkVWnE/IWrw8W+N+XLkK1adv3S9hB6MwCxP5/izZTcr+SL0DiHIy/7qI6I8RI9x2qA+Zx4gnQbAS1kI3fEfX48sy03eV+t68qlGoietlwCKCLR7DquxrbMCBP7fXKRN/IL9f7saq9M4GzhppuowP+GBcIraiFOwmTYftt++MnLjSv7pFHOJQJUJvuiuW6WETQmkQDWIaLbNhpQr5/9+f7HsNhEE2d4h//DNAG4PepV2GB3EaWuD2DgYyL3LcvudeR0FK88D8+iMtwDm5Cf/GMZC4FqOSC92kCLrI8Xlrc91YNPfjCgEGztVyyAvwoXWyi2Usot3ACsFIaatafxtYn9+LB MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 504aa750-5182-4fc5-3e01-08d4406e819d X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:CY1PR0301MB0747; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0747; 3:KnQ4aVnAsfxHZZqufMqfh89zksODzXNRgrTNIJjub6ZTDrd+XFAZ/lfmYTBdyuZE/l5247If0oNnbo4QF7dliwkIT8OtrrOgy0cI7W71DXFprcS4XCPCNs4oG/HEM2479kdHsrzxDezEWFA9QEzr3mvXHBf+6c3IJtmBysWLquvQce2pPjLwYjSazFeEeQQrFuMmSnXX2HsHxtCUgKRiJITzPlnhlVZzkuMYWTBGrsUqHJA9rQbZOZZaQ0RUheqCqGanXirLG5/A1/+Yfo9soDDt8E1UHXpWk91aWQYRjJIGbM1ixKjQ4kRcLC89ncOym80sO8CXdsqMMw5N4Lz1ZT82oHto7qeSa8dcuz3GF7oRHQDrK0QSPqXrZndwy5/Q; 25:hx8G2NUXzj2lWHumkydY1NTr8NEJGpdMLpfjqm4NncRqQwyU8byx7amlMMz64doHn45Y9r8MU+MECQiLkNQNDGDaGCG+7zc3g40hw7Tr7lQTglddoYoktS9Jvz7Dk0r0PNm1V/lOQLUrkv8j7RbNnmWgdvyh0QxqSbHbCG8jG0Yd/xQLUo6YV1qOWrngH+z3Delg51BLR306U+3QfPI4a/ZHg7hlSVnY4OC/4ehv3XcSjyxqPLJ95V9aIHobixkkySaRu0VLFoBfhpgLb6t3AlrxcqLuaPKidWe8pT4EJBf4TU7XiuSLo05n4JEl8vId2+TqFZzL7pEuaD/WOxvcxYfaNKN6n6mm4rUdL9HwWNIFIot9hgyFW9Xh9CJv+qP0BNQYbAYf+ARdR5TdD6xGvKgkjM8MK51ud1xaxNXFlt5p7lSb6mBWbdLqPxyH05Mu5hIvw1xIT3gegreSbSrAAA== X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0747; 31:DmWcEUrV9RpnqlrAlz9db2EZe+G3s8mdOckwRGNPsGCvLzP+gnP8gkAw0X3SUYtCQ+4aV0tI157jyNNMeE6nxGRaFxtKlTeVX+vH6/NwZ57y8PmYaVyGJ7KGR0cNqgn3xxC1N413smZKYxYbMiXvEVxvibmb5+iETLPKtoZ1W5dUxSOzkuoWMz/2quXQhO5Ckhl6cTb0mo0YnW3XSX2BeW4jYhLOWlg2AkxbmLCyvUr7S9wxRtTJG0ecWbyIpQenwEF0pw+DFy+pjf97qhSUTg== 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)(13023025)(13017025)(13015025)(13024025)(13018025)(5005006)(8121501046)(3002001)(10201501046)(6055026)(6096035)(20161123561025)(20161123559025)(20161123556025)(20161123563025)(20161123565025); SRVR:CY1PR0301MB0747; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR0301MB0747; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0747; 4:I3dsna7k0swXu6QpqEwhxSnqzIQ/rZUuTHlipsGNRIijLYpAH/V8vuO7fw9OtlcuQabANTKCEXDC7PZadIE/uHvGa5TT+yNXWMK7jzRUCvaDf/NzZTo3/YdQWtQ4B028EbdGBqR3p7htz+V7g0D+/d0K+LYekNL9Gzn7YLgl7Z5sLoGSyo6tNyXMmVng7zC7aGy7oG5LdLtmuqQS4EVl/5cBwJP0wkAXS0uMuBkoTlph+YXYN7AycVEV8T8nSi4wLb2QiER80yGiXWzZknTWolCmdRY9H+Nq6Y5Zr7z4ca1DHl7Bq+EDM9BmhVe5+vTAlTihbf0mYldyzF+A4aiEnvqPVWJYL7ZxSuvaPGHcaC55b65u+tzwN7H9GCI6NdDnT/DIcaGTwl3X04Wn8BzGVMbTmLDAHtwqc4aN1xbOWyt+Aquxywst1A29592N/XszL8e4DV93Ty57sU4KyaewvnT4Rv6bFOxzY75zlq/UqYmHdTmk04hK7NX2HL8KAY4ANKLkksqmziSI8+GE6yTxnpgRHsW93lsmqecyWcBxSVF8a/b38hj7zZyyIfJ0cB0Rvxbxfx+zD1Fh5xFuAp8h/MWGtLPMrlKxwxTD82bAFZ3X28nGCu6LMXA64cRQ07eS+Wg2SgJdFrfo7brob8XpMj0R35CWuV3aLsvqb1kOM/DcYF6hST7riWHa6jUdgpzDUc+RwqRmNNxQ/ugr+s4ZUaH1XVmhzo6dfzD2NMuxwgXrRM+xW7DHK9ICEYBBDihN9EHvMrPKMQbJKVBPSFiTWQ== X-Forefront-PRVS: 0192E812EC X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0301MB0747; 23:XZeIzReke2AwzeKdGtb7rg1a/7o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ange-Diagnostics: 1; CY1PR0301MB0747; 7:rk81VzptI1n4fQDrnFlwytKxMfy9ByN5WY1Zf7qVSRPHopoZCe872Ekto+b13UjsFEjJSZuJDNc5eUA/3rOon5fWJxOhGT2ruoUG5KP+P8cx8OlFKuRxSuBkeGWANh5ZBGlBe3l8W5mNnWl7UtAS7W2VZ+aH4zoEeRNDs9blaF6P0csbFM8oiBAWFwzRsUYjhSossup37/+XaIJGkXvTRuk1h/1PEcJh01/1/8OcZrbiTWFCoZwRiEEBNvB2hq5jm9BILO8FCna+XUuzkGQes9JDf635Mk3nLku0P+7tPYmgJLgb15uNvZnQ9ln7jL0hiTad5RgGPf5NVDri9RT5Z7enHch1q69giIzJYbVUjlutEE6knRCxO0zNlCZS5N4W2f/OcyCrpPecYgjU40v0HvOzGWBvrxut3vv0Mm9IlR/ejtrS2n9SH8SDipo4d/nKoLZANSNo1nzQJvV/1Mt1dA== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2017 13:24:32.9512 (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: CY1PR0301MB0747 Subject: [dpdk-dev] [PATCHv5 05/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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 | 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 +#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..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 +#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); +}