From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0066.outbound.protection.outlook.com [104.47.34.66]) by dpdk.org (Postfix) with ESMTP id 9FB80559A for ; Sun, 9 Apr 2017 09:48:30 +0200 (CEST) Received: from BN6PR03CA0089.namprd03.prod.outlook.com (10.164.122.155) by BN1PR03MB284.namprd03.prod.outlook.com (10.255.200.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1019.17; Sun, 9 Apr 2017 07:48:27 +0000 Received: from BY2FFO11FD044.protection.gbl (2a01:111:f400:7c0c::134) by BN6PR03CA0089.outlook.office365.com (2603:10b6:405:6f::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1019.17 via Frontend Transport; Sun, 9 Apr 2017 07:48:27 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; intel.com; dkim=none (message not signed) header.d=none;intel.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 BY2FFO11FD044.mail.protection.outlook.com (10.1.14.229) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1019.14 via Frontend Transport; Sun, 9 Apr 2017 07:48:26 +0000 Received: from DTS-02.ap.freescale.net (DTS-02.ap.freescale.net [10.232.132.223]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v397mBLN024015; Sun, 9 Apr 2017 00:48:24 -0700 From: Hemant Agrawal To: , CC: , , Date: Sun, 9 Apr 2017 13:20:07 +0530 Message-ID: <1491724224-6319-5-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1491724224-6319-1-git-send-email-hemant.agrawal@nxp.com> References: <1489754838-1455-1-git-send-email-hemant.agrawal@nxp.com> <1491724224-6319-1-git-send-email-hemant.agrawal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131361977072880136; (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)(39450400003)(39380400002)(39850400002)(39860400002)(39840400002)(39400400002)(39410400002)(2980300002)(1109001)(1110001)(3190300001)(339900001)(189002)(199003)(9170700003)(54906002)(575784001)(86362001)(53936002)(77096006)(4326008)(2950100002)(6666003)(47776003)(8656002)(50986999)(76176999)(305945005)(5003940100001)(48376002)(50466002)(356003)(36756003)(2906002)(5660300001)(33646002)(104016004)(189998001)(81166006)(8936002)(50226002)(8676002)(85426001)(38730400002)(105606002)(106466001)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN1PR03MB284; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; MX:1; A:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD044; 1:uOrhEV3weGmYmujh5EqonTCb0aa2xhHSLFOdPw8ZN7RCxZl7I/Uq5iEoC7fYW8n9EOQO0RgwW529vdh4K0rtsfp7xRdL8tejAfQwd/uICl3uzTAnqA5Z66n2KCoQWlnlttIPJmBnxBaafGDe6lv76M+neZwvOJe51Tcs4L/gALTAx/4SF97eqfo/m2ihoybamkfrLWJz3GRqBT8DbkCx0DEFEmoVd2syMWSro2+y+SorOQkIrbZXX+KvO3gXnvIcEL3BpIiYjpFNPbkxaN7LTr4YR7Qz47V7vQEGXKnqahK73ozUo/P9N5kKv4HsAMgQnnT3EDvPfin7wMaraYNVOAzcXgNbLyyIZrOpJk8OXj0rH1vJbIjToPPfp0bmZ08YgiQ4GUdfU7c93Lqt65AR0yfOId58zKs6SRohZ5J4sUmbo0RzkGfR7QLHbMuQG9sazOnWy7SU1f295OpzUppwzl32Xa03G0s7pemSzrCygZbrEUAVJesDa8uZmk6J4fYAmEwP8KUWvntVf9zP1GLy3owydrKVfM6kGsv/8Ut7BIuyARayU8sRwLwkyDaApOS/OGcv5AoxoSUkVJ83AnGCAjRBttfV5U57XbsojlG16Jb1LmIp3zx7Dj0Tw7jJ5Np/0WYBXjQs2txOrjigfxdC3UIwdR8ASQI3efYnj3mS3n/6fJMLTVXPHnzQVtjY9LFV MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: bf47c031-19e7-419e-9d96-08d47f1ccecd X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131430075)(201703131517081); SRVR:BN1PR03MB284; X-Microsoft-Exchange-Diagnostics: 1; BN1PR03MB284; 3:RRiG7AXNv+RhsEYUYxycc8hvmqBQ19r1ltWS1AmjgnHnDzRHEFe4znnyFqpdusO439aQaZHbarNSoa/7I8Rz8UD4kNzp9SIt2yA3KlB3J3mwjEv5y/f6fdKB+SOTJmN9KpOY4WR4iGUVXxK6wR3nPc8Gm0L31mbedE5rOM5AJtgffQxUnh//87/9oEz5OmxMqlicAcIiqs7E271oDBgnx8jFTsIYhxDKeq0FHuIxkpYdyJ4Evk06FzVhK9yX5jydOTQbEvjmJI1v4eVAaFJeAtK0Gwww+rwdj5+GFT8IdOQVVvUBNgdudcm/Y0GfFvW5MMTfRJVg1Ni6fGRL7stCV9kA62Id1WIeQkjJWK8ElTuj7QjDzF87WNIOxYkqWWR1pp6/n1NGj92EHp5El/QbYd4d2YWWKaWvzzgCt47/R83IgMERELJd5KWtOdxFjQhG; 25:CCwZPX+eG9ZMacGFr/IwTvlns9sZbrmuSayx1756nrqaN9NQgjFM+b47GxSWvSgRXBqOMiVCIdgGZfv76y+4lO+5wMqIpNvg7Dm/HGwSlsrglXw7U7SLdjUSyAA66lJ+I/KkPh+FBeOGeyrXa4oYBYJnHOTHZkPKcRc+/P8lXZblFIvMcuEmvBM2TjPtksf1iinWQJw2JjQdEU6e6/briox2k07bG5nHHxgyseVIO6uIDZLlIgpB60InCzGDwCw1GfdED/IZfybsgJL9Ljg0oYV3yl4pH1g31lU/V798i4tVkgQgHEH7w7g0JVkTKWMVP+/us81EHej/gheArVuHB64q8SJVg7rCaVciD90CatUyUswdVhU45bn2l7d0hHQyBEoJrHIzpaVBE925ORPqaETDw2tcweX97ZKe8rICLez68fcY/X83gxMWTMuTSWjwxNG4NbrgFfnFnO84kFU3Iw== X-Microsoft-Exchange-Diagnostics: 1; BN1PR03MB284; 31:/2xn/ggrT3k8/utpzSOfM5Wau2gGIpdD6zwW6ZoVhsiN1T1gPYImQ9Mhw1ibmlE70EtBtMdEOtREn9gxeJTMxT7gdkde6vdw7yK3coZ0B/gM3TiOkX2Oj1StNj/fHtSFSebnhx9Ew+emLKuy5pD+v6BXRgOAyLoDoiGMtTOFwZiqpQDXHne58MlrPNwIEcvpA3jQfjJ3hYDBa/QTSmh7RjFb1R/Hpj4Qk/vnyn++u11wa+iylE/MzclSLFU5IHsUWvHjhQ6NM5Zyb9/haYvEdoANdsRxhLQh0rP8GYu09GY= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(275809806118684); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(601004)(2401047)(13015025)(13017025)(13018025)(13024025)(13023025)(8121501046)(5005006)(10201501046)(3002001)(93006095)(93001095)(6055026)(6096035)(201703131430075)(201703131448075)(201703131433075)(201703161259075)(20161123561025)(20161123565025)(20161123556025)(20161123563025); SRVR:BN1PR03MB284; BCL:0; PCL:0; RULEID:(400006); SRVR:BN1PR03MB284; X-Microsoft-Exchange-Diagnostics: 1; BN1PR03MB284; 4:1DSeE31+Z9vWSocu6Y4062pjVMOhP+wSY0mBRcC/d2GFWru3a1kNUIkwage0EWc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KqxP1IA; 24:iwh+8jjsahcOm4HA52Z//Ol61UwmZOmEgY1jIriRB5JRNZXj+D78xGAHYLjKQIobfM0pyHhi7h/YdMmVbu/fa2nsbjWkOhfyLlzV7QoTIr4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN1PR03MB284; 7:vVBDbyYm/zvPIWOEl9U2aVBcqtioDIpruGUAQBOQWKCopI4mohyuzZd9t3hk7NKIe0JcVAZueufyNTkx2kcjLUvmwJ6ZCATXQ4G85eOj2ZGDpoffzFghlyZoJV0HJ8+dpxijl9WmDy6SfRP2qRX34YU0CSTUd4swn9HMSgHAOyELaq3eHXtVLS2zoPH+t4vV1HVfLNO5j4jjqprj8Q4pPodnDFfHpoigTW0du2vKnhqDFNdeq2F8evWnj+MbJG/b+QInr+qVv8wRxlkX8ALg/mZAz6do+sLjWkKUjjxHKh+Si+Yr0OY3TzrixBJqU/Okd/pY5/2dA11sWhozS8+yow== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2017 07:48:26.9448 (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: BN1PR03MB284 Subject: [dpdk-dev] [PATCH v3 04/21] 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: Sun, 09 Apr 2017 07:48:31 -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 | 4 + 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(+) 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 08afb8f..7000f2f 100644 --- a/drivers/bus/fslmc/Makefile +++ b/drivers/bus/fslmc/Makefile @@ -49,6 +49,7 @@ CFLAGS += $(WERROR_FLAGS) endif 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 @@ -61,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 include $(RTE_SDK)/mk/rte.lib.mk 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; -- 2.1.4