From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0055.outbound.protection.outlook.com [104.47.38.55]) by dpdk.org (Postfix) with ESMTP id D5D9D2C6E for ; Mon, 23 Jan 2017 13:00:28 +0100 (CET) Received: from CY4PR03CA0015.namprd03.prod.outlook.com (10.168.162.25) by DM2PR0301MB0751.namprd03.prod.outlook.com (10.160.97.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.860.13; Mon, 23 Jan 2017 12:00:27 +0000 Received: from BN1BFFO11FD026.protection.gbl (2a01:111:f400:7c10::1:145) by CY4PR03CA0015.outlook.office365.com (2603:10b6:903:33::25) 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; Mon, 23 Jan 2017 12:00:26 +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 BN1BFFO11FD026.mail.protection.outlook.com (10.58.144.89) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.803.8 via Frontend Transport; Mon, 23 Jan 2017 12:00:26 +0000 Received: from bf-netperf1.idc ([10.232.134.28]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v0NC07eS019311; Mon, 23 Jan 2017 05:00:23 -0700 From: Hemant Agrawal To: CC: , , , , , , Cristian Sovaiala , Hemant Agrawal Date: Mon, 23 Jan 2017 17:29:34 +0530 Message-ID: <1485172803-17288-5-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1485172803-17288-1-git-send-email-hemant.agrawal@nxp.com> References: <1484832240-2048-1-git-send-email-hemant.agrawal@nxp.com> <1485172803-17288-1-git-send-email-hemant.agrawal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131296464265491783; (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)(39450400003)(39410400002)(39840400002)(39850400002)(39400400002)(39380400002)(39860400002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(5003940100001)(38730400001)(8676002)(81156014)(68736007)(97736004)(47776003)(4326007)(110136003)(5660300001)(53936002)(86362001)(575784001)(104016004)(77096006)(85426001)(81166006)(356003)(48376002)(6666003)(189998001)(33646002)(2351001)(50466002)(36756003)(2950100002)(6916009)(106466001)(8936002)(105606002)(50986999)(626004)(305945005)(76176999)(8656002)(92566002)(2906002)(50226002)(54906002)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR0301MB0751; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD026; 1:tsGfXfmXy0d36b+MyxkkqaI/pGfIGER24v7DNZysSITun04zd7F25O+Ml4e/owVZ//ZblUVy9Tbf6YS0BW+242n3m1hhpfA2c5q54YSRJLfSH859FCVzuCNh4tqHcAXXxgSN6xb5k2WJGVi/0HOXkYMP4emUKwpLoLuqJtFSuPXApziTRq1RRHe3U7w8MCAohLibx61Gx+06hfaIjR6vqls9NR8AIZ+L+ZcbsMVPZbICNAqkDLej6ax61Ge7uT9R3wiLKbyrBoozPdpcDSe28ppmFzAxnxZZYoM2QLMbWcvCkXy01Y06+U1Ndc7GinJGCuaJlVtjV4JYPXNefe7ekA/nBfCUHDXeU2wxLw+AcNPse3D/xkqWGI/shYlNduGmRRwNl3GKlorYoGzzOBZuyT+D8FtPfd79xRqi1CJliEBBE5fYx/ZJpkHp+vT8j6BvGUQCK5OcaTr9HBbR1atvt9kVgIOnRia0ZgC0BvgbkkL4Q0iHhEVAU8LOZfauieZWPx23elHOc3YUOPwrrNZRRmjGdLluUq2LemPozSpTjf50ZPodQ+D9GzMFatdAg5u/XgvNtS6VHpRPK48hrMNh5CxWm1mdRXg+NgwZPU8MtKmHQTJhx4HxM0M3/CxgDLXQkawrkcgG+kzn7HCMvbuZDNdeoLF7jK34JqyGInl/mdN9U09cH6L32CumyP9MrYXSxf4vequgIIQguamkTb6bmV07asS3fbSz2MKIjIoBHOZx7xYO67GifJLU/PRuWvVc MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 96cea0ab-2e45-4833-d3ea-08d443876b43 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:DM2PR0301MB0751; X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0751; 3:vaktOOHm2HqUwh7IFhDvuA541IfC1BrwMC6t16Nj1qAfRrk4U4VPnigAtyN8FdzNLhaB+b82ScZvEXS9D00Eji6HFIu4Zzmab/0Ls+7kgsEucgX5f+HecVnqThFQdLxjeNo3YKdGAF9Lb2vojcyyXtzZXYjcYREj2W3MDHQjLw5ZKN0q6mvy78lOpUzys32CX+GjLb2DGz0t+A0xNBJ46goCl87otZLwnvbGor+kXUxrHrBGsDaP5Sc4hHcwVTboQEL4ipYA+ZxSP1/IGMzaT49LTOVLVj7TO/ZE0slTToFsCLKOuO3V2gQY/I9M3tssnqbk9Sz1JFpYRvp+V/aQQzrHB9CChjJJW8KKITPFyQbZqT1DV2DsohUR8k0DSVo2 X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0751; 25:WySlg3OPjXAtwpOtwf2X62hhwAuytn1IImYK9yBoOhD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: UriScan:(185117386973197)(275809806118684); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095060)(601004)(2401047)(13015025)(13017025)(13023025)(13024025)(13018025)(5005006)(8121501046)(3002001)(10201501046)(6055026)(6096035)(20161123565025)(20161123563025)(20161123556025)(20161123559025)(20161123561025); SRVR:DM2PR0301MB0751; BCL:0; PCL:0; RULEID:(400006); SRVR:DM2PR0301MB0751; X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0751; 4:tXDcJMe5gqLfPN8OgmxYajQEu8Ieg/yhQMesZUi2p8z87NcFNt+Q0sOcxapd07q/5IFEgyagzSNkn3i7co2QCPGYk/smrk4YK2j2N0d3jOK+LpdIxAxX+zZroJRnhcCfgMWQ5H2CkOf7vPLzXVSFtfzyhfUCasqi7ox94+UBFv+nNQPqda9JIimORdMIOk357Wq3mTpChMdYwJIiVpM78CAE06zffYlTVA1im3W0q5LAnqLm0VFxqYZGsxabB/R2DGiVIpzHmJCoY64Pg7X1fAjJ9IlDX2CavVXZD/anWRhrNk0XsAdowxLpCKpbsYRXCZ7ZlyKSeBiBz9wzr5Arfs7yvpYPHhDWLKhkVLTOBa3I9Ql40IVzZGk2XUfQ3rLQvCnvvZMlL4UJaSHdSY8hXekR4ZZwdemtnYZxoH67xldvJ0HtpkzCXeenl22iMqSvMVJjrKMgW2VAQzN/39hXT30CMlvoII8Drw2lfHlZ9IW8+smL6W89cZWIWMJikNcFjS0X6ZiDz5fGYs5lvcQd5kyLw70gy9K33RIEj255TvwiFtmnJ6Gpj2pAKRYIUuDzfypgITawvI5aW+g592EV//EUcOjvTrI/CkuodSoWQfhswBBZw44wqCUm2+29wMWR9n/WUmkipVTY4o9jVCcCfIaJPD6RsaLDJ2nXw8LYrS26ikEd55J/zuTpfP0SlhpHneAcretJBUi4e119h///O5WXefmAmn7infpm3TIw22FyabSbwMz8KLuso48GeLRqukrWsjXa4cpkNC/okydtXA== X-Forefront-PRVS: 0196A226D1 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR0301MB0751; 23:jTFTh5OdidKB2uJ4QdeeGGNVz9LMtBj0HYZq30X?= =?us-ascii?Q?I/HTdW0I0/prb2WfDntAZuuBeNT/afqeR+5fyQdNHN2b61xnl+wSZVD02Nc7?= =?us-ascii?Q?wUgLuESk5hiHU2tlsjK24yYnVM5/P0XdPKOS8DTh7F8X/nS814fjzpMpv1mp?= =?us-ascii?Q?q1K/L1kBnHF62LFoePMZjDWTmCLvFeDv0pABw00mI0D8L64OHSombPiq14Mz?= =?us-ascii?Q?U+hOp/dU5lhoFOtJnA0swLW5b7iqEAb/gbK+fER3J8NKmBhu2HSLY72kCEoO?= =?us-ascii?Q?/j9cWZkI69w9281lHF1IyXY5UiEZ2JXmX/5SaL+UOe9nUKmiE32bDZekNNe9?= =?us-ascii?Q?EEmhVtfWgPlz0fgbIIoiKH+KF9F05i+zuA/JCECbozNP2hNW/Y9CH89pTIrk?= =?us-ascii?Q?Bpvg6T1s1kK6kcxbDeC0gnmwLg5/epykvx3hXiyyteCaLP8DL8Qrj9QOdn72?= =?us-ascii?Q?mn/s8qSrYpiKMjypCONeI+ayX1CDsmQiEWivf5Aok6gYdCyAtpreuKJszbGv?= =?us-ascii?Q?M09rXXE4BN6ufSYZNCO4UYhMJeOD2Tl0PSqbfvxJ07JZoY0sj8IUNvZOlEe1?= =?us-ascii?Q?fdCbWlH6prOMl3NZrRI06UwmLtVnCF5tIHVFmPUfDSwYRi+0Aj90Ur0FBYNN?= =?us-ascii?Q?MTpOx+VD2g8S8NswpMe6YtGA0QMNiatmHwukBY6Q0RZzc78tGNuRbnLPH1+L?= =?us-ascii?Q?n/F+j12DDqtU/mjDHUyTku004DtyHkhzqVjgyYZhYHC4Y/QIJ34auJR5u8bu?= =?us-ascii?Q?hhOG03mdsxna1vU3EL2ZdkJJoJ6zqmSjXxHktTHusV2f/dc3lonIcgtLIS5c?= =?us-ascii?Q?C8qsNhDDZeT0vDdezcuF9xYEnUGHbuZ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dovZcR8abc/wLz4Q/caLO9H+znQoN2yP4kQgacJQQPXnhLFEIGzFZA4puAKWZXsZXqf45; 5:EIJnCC9NCN/40eAQvSDZk+V1IqGHTW9/uTjxMAZSwa/GUh1Qcv1j/6O2N9G8IVk3EzV87BX/L/R1AzSqoFsNvVGLjsCPY5dhYnX0ny5hdYG65QMTvDOQMieu4H+XplodsjTbc3Vr9kj9a20/v75K7byjFJ/Gw4G8EdM9M0g2cxWyn9fgXlOfWZTtKSDide5+; 24:+oRKHq5aP12PxDRDz4sq9GFuycMlrcxKbkG93WQmmwbwL8d6tS8tfYMLyMdYblfjGTxPjN1ayEKuBseenpu6bGb8dUWSLz6CNPZ8CfsmiEQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0751; 7:gUMWFONnJNBCz0OX18/Hts40pMsdM7Get2nAnCNPaO9HIK/vrktogWve5YXdH5UXNIycnellVLNnog1qkfMPa/R3HLZiy5YHy4MhHCRzHCOKYyYv9j6CygmRxM7DYm4IFeOqhEdiBzmCbTs5QYZoXokdHDRECX8bKiB4/Pl4smXwXz1NyyEa63ayiFyyXX5FtBhPb/JLxwWzE7w2b6dIE00n9zZjfH+lj4bmkf7px4cp/NGGviSXwN3ukZ9/6lsHgDzCjAeNas67/aFGwAmQ3J1hvuGkUM60g+SiieC+hEIUkrQ6YuRZHIeXRQJAlf10lmZTtGhkQCpf/VQy3fhRQpQOiOMkdYU0RaLsuw+iqJHBT8is2O7nPIha6G5I7WAfskCrw+I0hSW0w6V3/NmXTMuojSt1iZpGh7ued/wYuKOfLog6InpLP+Wlj5BiuLovE9ywpBPFUEOsPE4lAb+Qew== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jan 2017 12:00:26.2995 (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: DM2PR0301MB0751 Subject: [dpdk-dev] [PATCHv6 04/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: Mon, 23 Jan 2017 12:00:29 -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 | 238 ++++++++++++++++++++++++++++++++++++++ drivers/bus/fslmc/mc/fsl_mc_sys.h | 105 +++++++++++++++++ drivers/bus/fslmc/mc/mc_sys.c | 114 ++++++++++++++++++ 4 files changed, 464 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 5a0fd61..1058f0f 100644 --- a/drivers/bus/fslmc/Makefile +++ b/drivers/bus/fslmc/Makefile @@ -37,6 +37,10 @@ LIB = librte_bus_fslmc.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_bus_fslmc_version.map @@ -44,6 +48,9 @@ EXPORT_MAP := rte_bus_fslmc_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..bc41646 --- /dev/null +++ b/drivers/bus/fslmc/mc/fsl_mc_cmd.h @@ -0,0 +1,238 @@ +/*- + * 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; + + /* 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..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); +} -- 1.9.1