From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0068.outbound.protection.outlook.com [104.47.38.68]) by dpdk.org (Postfix) with ESMTP id B74E05424 for ; Tue, 17 Jan 2017 14:19:34 +0100 (CET) Received: from BN3PR0301CA0078.namprd03.prod.outlook.com (10.160.152.174) by BY2PR0301MB0742.namprd03.prod.outlook.com (10.160.63.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.845.12; Tue, 17 Jan 2017 13:19:31 +0000 Received: from BN1AFFO11OLC001.protection.gbl (2a01:111:f400:7c10::157) by BN3PR0301CA0078.outlook.office365.com (2a01:111:e400:401e::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.845.12 via Frontend Transport; Tue, 17 Jan 2017 13:19:31 +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 BN1AFFO11OLC001.mail.protection.outlook.com (10.58.53.72) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.803.8 via Frontend Transport; Tue, 17 Jan 2017 13:19:31 +0000 Received: from bf-netperf1.idc ([10.232.134.28]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v0HDJ8mC021741; Tue, 17 Jan 2017 06:19:27 -0700 From: Hemant Agrawal To: CC: , , , , , , Cristian Sovaiala , Hemant Agrawal Date: Wed, 18 Jan 2017 00:22:26 +0530 Message-ID: <1484679174-4174-6-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1484679174-4174-1-git-send-email-hemant.agrawal@nxp.com> References: <1482988612-6638-1-git-send-email-shreyansh.jain@nxp.com> <1484679174-4174-1-git-send-email-hemant.agrawal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131291327714319263; (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)(336005)(39850400002)(39450400003)(39410400002)(39860400002)(39840400002)(39380400002)(39400400002)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(48376002)(6916009)(2950100002)(50466002)(38730400001)(97736004)(47776003)(104016004)(36756003)(81166006)(68736007)(8676002)(54906002)(85426001)(2906002)(4326007)(8656002)(8936002)(50226002)(77096006)(81156014)(5003940100001)(189998001)(50986999)(33646002)(76176999)(106466001)(105606002)(2351001)(86362001)(110136003)(356003)(5660300001)(305945005)(92566002)(30001)(626004)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR0301MB0742; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11OLC001; 1:PgEqEvF1rT0DqwzDMIj33t54A9aRxb4tJeQT+Kj2XdrwytmVVxwwOBsfEF0PZbjUQhkt5dk/82ZS1Nm6ATLp53zk3lNH39M8/Sgdc8Ivdat/aSDCkRDkEOifLJ/0I5MQWcjmAxDo/AhyLDUdmDVvEkQZlB7DkJu3RX3slFZMDxP3v6EPQmB2IsDQjVJUDgW37wOROPOSgaP6sQKSoWCbwTRG0X7lSup3g1HGLJ0SfjH2bAB91KGN8FLoPfdJVbm8K8ByZlEGNCfJ/Dqz8vqS8rhbhbegNxzSPpbNxP+VwUn9aEyHW3VMQoCrYjfhA3srd5FmkqOlq6/CiXWoDaKlS7UmgRkAApfOs/pg1uJoG59UQVWc3tCBDjAXbRRgqIU/BUYnST6trUzSspisPTLOgIFJ16GqWGSXR220U8uHm2kRAiM0Kt2FPRKmZ7U7RPl2tIsEbDf8pgAAcvm4kF4VTkAxpprH3YxWRqkrVuuxcTGWLLBGvGF/V5oTyBgbXU2hFzRTB2FVRJB2F1YFU5V88MSmtnj8zPiTlKopYbkPe9SDZCv0DJeEIuZPne8uGwbLx3TI+x0z0n9AFyByPqKPzjdPbn9mUXjhH0MepuJD3VHMNA6okYhb4jo2KDpc8i74qpDKS0aGLuqpzl8F7KflpaquTLRB331i1IuJYEGO11hxyUfcKn/yicf6foWaNuuzqXOXPoE9tzA7xUIWxM8emv+RGYL9TLgbyFxmAjojt0E6Oj5HoDUpf+BGEzCz2x0l MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 2a1aee44-14c7-4381-fa42-08d43edb78f4 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:BY2PR0301MB0742; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0742; 3:BJdmws7BXVLKi/2bN7cayAukPkKYwfFrpXdadLpcpRQ9/tZkPpDSlt87amnrIu+9dLr2N3c/kjVWpCL09OevJsE9r5gioDolWNJA5nwGXew42Ha3CBl94R9qme7ho7XImwU9Ty6xUq5nlrMiI5JhsAXRHOcVbDl6DcZFz7LR/fa0I/ffzVcLxcJ0FX1fdiVTdNtsmnogubTg6CZgOhCgbQc9pBnjzzAWBMiEchmRKZgnXo8pHfwvw7D8TP2th1CNKEkttPAG2TCST/30NyphVkzZs/DMaTjPmrln6reQTUC/bGTgfWTsl0xm88cQED/3gJcyLzx44P/bbgO6+MlMBedmhLg9AONs1UH3Pq0nCktWamrrI0QyqHUvs6moU3s7 X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0742; 25:PjvCc+GNUWadyidqkWJym6WGsy0Jc0vU7H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-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:BY2PR0301MB0742; BCL:0; PCL:0; RULEID:(400006); SRVR:BY2PR0301MB0742; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0742; 4:89OYieByypm5zLXvrMAlaoCUOC3mrPACQSYoyB7B4fFJJvWH3BaK5RcXAyl8dN3A6qSW08gVvPjaJIbVLF3a/y4EnrcU1wpuuVVqCy6LgDXTE8hUHZQ7kPeR4aX/qbJ8zlIOSyBH90otw4OYWtzPgtrt3/utFs2/f21C53Fwexk0DeHG7WxhPb2gizH6J13d11f7APy34D0lKiwvJUXu2TCTVMBiB2g/38aIcF2qek9OiiI/JetAm3FKeKAT/BvEkXlTA95ZsSF2r1s1AVyLv5CDSe7UulkNrOI/stsqcsTGLvrjj3SOQa3payw+b8SBA5LmF2iv4TujhLVo4qBMbZjOb6KTVnjLPL5/hxEHX3hn2O4l5S53bg3CInfUIzkVrkOo44KKw8dvYY5DiTEGwaUkPz+AmwYyeBbSTV9IW6q0ahjA9osf5JWGcI6xbrcp2uW21AHYWnxaw2AmVILpKwDKqbVqUP3wJJnvYSLOyhvWRE5muy9xEgB2eA1vAsNl+BXOuXg1bET7r5jhOQZJ7H2VDCIECc64WTkIUdWUlTJ8FTX5nP1x6TcJycJSY8d3NlmcKwDE+Vhe1VsLwg9L5Hu2mnLxtjri0r13KtH0h+1yspk9fP2niuXda73v87isk9kuGAGUtVsJsHn7jewzF7j0yxQ/40TKz/082XpYvGGGVlqwoa1/UvHsFoTfRH0kOJ7V2R2vd8qrgTQB6YSDeOpAWiGzT9Ifa8S8KNF5AGiSF2yLulagWMZU+//3R1r4upDG9DQZri4+7pQjCiHgvA== X-Forefront-PRVS: 01901B3451 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR0301MB0742; 23:4hIExF0ObuArsrQhsVqwfezQ9aEXwAMXIYGKjns?= =?us-ascii?Q?rDc1p7EWEwEJxhKudOmFPpu6YjvEgQBXaEmalLk0DEIDqKQfQ4wsad3oQKp8?= =?us-ascii?Q?XoMDrjiVS6BeiEoTuc/xpyZERL9SUQVPbbx4KWo7fhKcj2YCkSLE7OpmvKaY?= =?us-ascii?Q?AlqCx8vIPvgLyC/J6CZodKUTg+2rr4SOcYN70epSOWKdPykPOvoDywa73HGF?= =?us-ascii?Q?3YXZuohB4eRmQdQ1ksJ/O6bgXb2apLVDckzs7/ZlJxQdCBJzKfpGC2vSbZFb?= =?us-ascii?Q?QIq+YQyUVoRO0By1UZQUZvLxc9Jnxkot5ViX0aTIhlXtQtm4bxHBw4cx84H1?= =?us-ascii?Q?Fs0mBiItbJeFCiMUV0JT3TuQjonouiH5h79m5hr3e4SZYCYwOLYIwF/5JCeu?= =?us-ascii?Q?mDdInP/gBu9eoBWABTFsM/T+GzNsAvoO1Vt4BiUmfBe6SK1I/82W//2TJ624?= =?us-ascii?Q?+cT1xqsf0llxzHADpaIM26s74/wyRR9AeA5eHXKzWT61eMBGlb0DvPumV4gn?= =?us-ascii?Q?w5KcjZSS92AuN9JRSDcVW+T+IBqTphzxNsdGyx+EptWGbDzDmmNr9UmGise1?= =?us-ascii?Q?INo6AWkNHT8b9CYXf85/jqklD29KFPJ5mszxbOYIpB8yRu3fJH/OnMw6gZGU?= =?us-ascii?Q?dnkNKCX+q5NrDfQuk8eANb6SmYtNobcgAnrazQCvWCQ7dlTQVG93mZqdDl2h?= =?us-ascii?Q?UF0Ud7Ul5d3tzC78tIzRya0/KM6tbYx1sFBB/SuIkbGo5KxR9o+NhdRJtyxQ?= =?us-ascii?Q?qt/uXk+lx97x5830fVmd0vnRfSwI3NMFWh2L6K8HYSduwc2eANj9oqlhYhod?= =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2Rb+PdVQi8z; 5:ru/7emo2jYxlUhor8J8HwP7AIhgYdix0lX5X9JqLuUzUfKUPDEMyxCurL9uMByTxLEYfGu7wg+rnlA27QHa5yTRCLuw3KBk18xRarLUq6iWKPIXbVSmYpl96RsfnnocW3hk/IbcxyDak2TTpKpOuJFK+mqdhtUkM+ShFT0FGESUYhKdpPTMrB2C3uKN9Ulz6; 24:WTgR+jIvqMioR8Y9w6Oz3thVHpzGsUEEZQneuO13YtbdhfcZHCoyxxiBAjrl0IS6O9UlZ6gXpvvV9SjeonAr8jSyPmOIvY8diFfbVNUyXFU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0742; 7:9smaO5Xso7yR1ieiSn0MU4F5z2y1D6i0x3vsJ7AG2Hkmw+Phx9CApGfYyzApch/BpaqXNwOW7dFtqfG1t0mXR0ptAsvFj/BhojrpDJsDQAIaev1NP3XBaiFbyZXeMa8qjfst8zNkZnnTssTdha9+xqazo//1or9MKFQldNNW7zN+lVWiq5PQZyq6gEyRIlxP9EQh6HoqKBAjZm8oi4I8ItfJBLhamnVkWL1IOxJLkjmHhQxbY8mLELwWwlKwRdm2UALLEZ3GNeSi5KcxpDtVEV1MpvJD2d+AzHrf249mybma+HirpRqr3jeBEVlTy+mqVqPC0oHQWv8/VQsGP1fH3JmT5svUWJI3tux882EozSvRbl9UgzUbwjwMqmxZpoTg644RLgEf9Ic++MoYVaYeuFhJ2WZl80hxfaWzWcN9TZ0YC7+AFanh7uLNfHOu1eSNfraVgDQSiO5/UjZyu4/3SA== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2017 13:19:31.2291 (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: BY2PR0301MB0742 Subject: [dpdk-dev] [PATCHv4 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: , X-List-Received-Date: Tue, 17 Jan 2017 13:19:35 -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 | 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); +} -- 1.9.1