From patchwork Sat May 27 10:25:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shreyansh Jain X-Patchwork-Id: 24757 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 4A0337CB4; Sat, 27 May 2017 12:18:11 +0200 (CEST) Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0073.outbound.protection.outlook.com [104.47.32.73]) by dpdk.org (Postfix) with ESMTP id 8188A47CD for ; Sat, 27 May 2017 12:18:08 +0200 (CEST) Received: from BN6PR03CA0058.namprd03.prod.outlook.com (10.173.137.20) by BLUPR03MB168.namprd03.prod.outlook.com (10.255.212.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1124.9; Sat, 27 May 2017 10:18:06 +0000 Received: from BN1AFFO11OLC002.protection.gbl (2a01:111:f400:7c10::102) by BN6PR03CA0058.outlook.office365.com (2603:10b6:404:4c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1124.9 via Frontend Transport; Sat, 27 May 2017 10:18:06 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BN1AFFO11OLC002.mail.protection.outlook.com (10.58.53.73) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1075.5 via Frontend Transport; Sat, 27 May 2017 10:18:06 +0000 Received: from Tophie.ap.freescale.net ([10.232.14.39]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id v4RAHYtt029968; Sat, 27 May 2017 03:18:04 -0700 From: Shreyansh Jain To: CC: , Date: Sat, 27 May 2017 15:55:05 +0530 Message-ID: <1495880735-1651-10-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495880735-1651-1-git-send-email-shreyansh.jain@nxp.com> References: <1495880735-1651-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131403538865498869; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.158.2; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(39840400002)(39380400002)(39860400002)(39410400002)(39450400003)(39850400002)(39400400002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(9170700003)(4326008)(47776003)(53936002)(104016004)(2906002)(8936002)(50226002)(8676002)(81166006)(77096006)(33646002)(189998001)(85426001)(8656002)(38730400002)(36756003)(110136004)(305945005)(54906002)(356003)(50986999)(76176999)(498600001)(106466001)(50466002)(2351001)(48376002)(5003940100001)(105606002)(575784001)(86362001)(6916009)(2950100002)(5660300001)(68736007)(2004002)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR03MB168; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11OLC002; 1:yEFxB8ZhcqYT34EPUm7BjCQh+1dbovFEkMMkHBw0lYNtyKyB9T9Hs2vu83n7FycskHQmVQgBGH/0r5eIbX4ESqtpyMFFe55CJKLm0RGt7z7szETp6Jjg4r/3O7+G+ulZlEqWTpHZfF/C+RH8YxLXPK18Hfi+HYA78HOlMuiM++p/oQ21T+RP/iyrK8wV8GjtBFSX81bKUXkbACmkGx7NePcImso/hxj6Lk9Naz000PoygwcxUjejbTQQe4ORYEiZm2/PoIEDero8lPM95BSFwEkIqVR1p2dhIryWzO92MUrJQKELKcUl4gcDCAKao4Vrbn6qWF4D5ur1DJakYXCmoCcoQTH916WjNNCg0AhTKIkds/1i18BU9ZEXm9PAVD4XedaO0ID0bKASDTS38CCw5HZGI8hMNS92dGp2zYF+wKptI55LU5XPKIRoIb4MHUhqpPVEOa1I5kCQ8jZlPe7nQu9zHr4GRJfZjubgueH+/GLMk9UD48LerhF5Dh4E1YAXZ4D0pTDPnpHLQxjfH2El8laP8XJwaKxt5DBTglW/3cD3VnxVABZu8NkDco4DfCsaHFoNXFBPhnMCcLSjCWkiLPBal0W3Rzel0npSZ8w3IuFsETkLojkrdlkDZRigVAYN5C6kT+9nyj1285YnctKaEFONVyW9rENkdzuwLU3X/wSb3LDKtm6nF5y1LSeIyWoxXakOhuS3s8Wa0QHBmDlhJw== MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BLUPR03MB168: X-MS-Office365-Filtering-Correlation-Id: b874ce35-7029-43c1-4996-08d4a4e9aac3 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131430075)(201703131517081); SRVR:BLUPR03MB168; X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB168; 3:RYF7KDAJIIOpOZCBmtrq2Ikd7VX42TYGLWols8s6r+nu8KqIRBOOrxabax11itPGUt5gRGZnBEVZq1jQWr2eCZ6gz1hK5IOW3CGSWaBfDK0uovmPejJRh8+cSMkJn1omm/ScY0pChaZ5vCDWBcx6Z3OivnGh8UhxMdStDDBC3UpdFp5fN0PE/WyMz227+l0yBF5RJZwFJvFI9hOSrd2i5SjWOAGYqjV5hXci4m5q2nAg+GEyCktZdXi7e6efLn387Iq/ypkDij9KBhXeE8qI8wRV/1OEjtY+VHvPa0jvTxoPGK9BQ2t+Ot5UCmb6vtI+mvdX6iUMzNzxxYtxhRkiSs+Rc8eV+56FIvla8haRjAxrtjmGvhlCOTT6RouIhgOkMT5OHrBZhI7ahoF6NhrnaOCbNGo9HmVm6nQE/nSiYtNYZ2SlWaItbiyvLqoeGGUa; 25:2ZYwfh3MOqPyVpgtbqkFUAyza6hBP8C0C7DuZp3Jq8imNuHqcCFTC5Uc5rmsYKl0O4Hx8FD+162tAPjkx8ipmq0zK0auNVsfuJpHUN0W0aRce9lnvPo2z85OEZu4JqbvjuqP53W+m/aNLuG5vBat10hju+ATafDfZfWfCrLzOKzzxRAK5tsPBdcx89Y9zgvw6vFgtB2q0HCrXvy9d2DNQZmmnG14OPhElM1bcek8z9JR/rXO6QpYMK+mdRgVPR77zGZ157ERs74p4aaEQ/Yfj29SpLyiXZJej03//Foc7JC/ileFGTlIUa6dTGZSI9YRcqaHx+3eybWwKTHeh4lgYIVyRhtDVKGjSdCGoHHsd3oXA0R0G/2X1EzsF3C0syMICPp0IDP62v+iF9Mr7xvBHPUPeaAxcU4nlRR91NgBE8bTrjdRpInmQqSdS/ufwMF77gGwFrB2TkQfYHRX/xMeepOQ6MCwlFa9L/kb8iM4g5U= X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB168; 31:1giV+MClHwGJlv8vIXNIJHLRoK8JxIli987t5ZOiy6NoO/RY2a02oIZLnwUGpZA7dfqSZzXMz4FM0WZl6dkpu0fPXao+0onZDqepBLazAAGWq5LjKA47QBW2/u0UnFFvAQJj8xY0456yB9FhDmBtRuA72T669CXFHndHbQ926aTQV1qt2hbxIiZpOqWM/D2pVMgQN4E9WjVKtcEV9uUYEMcw+PLhsNX6dejfsllDlo5W7igJQvw85ERciTlFfgwJx7wGJGCJDzPKD5eyy/tg8Q== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(278428928389397)(35073007944872)(185117386973197)(227817650892897)(101931422205132)(275809806118684); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(601004)(2401047)(13018025)(13016025)(5005006)(8121501046)(3002001)(93006095)(93001095)(10201501046)(6055026)(6096035)(201703131430075)(201703131433075)(201703131448075)(201703161259150)(201703151042153)(20161123565025)(20161123559100)(20161123563025)(20161123561025)(20161123556025); SRVR:BLUPR03MB168; BCL:0; PCL:0; RULEID:(400006); SRVR:BLUPR03MB168; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR03MB168; 4:zQd0HOK0XPkkLpCXyuIlOPbA7elcFtJTjy6f19gR2tA?= GKymW3fh6yr9o8hKs/ELj4WIf3ldrGjIOowLV3ERGopSQ/0f3tLy7w1Q+Xb1sH8+NjdE9lNlpbJlN/eT72Giyue3jgQLyOwlY0WUaoFaOFM2lIurdS+kySVMxerRYuFERq1fCS7RPI6iKKHypMD/3vm4NoUYWmWPoAGKJxsNEhETBxcVd5Yi0zNWU8+eQAHVrJIA45ZgjwR6strcyoaYpWGWKoK/4IE8OXJl2XKeABYpNJxOJJVdt5eoFhGKfn8XmeYxDH+gQu92C9kAqU2jOuXDy/0/RB4yQulNmCWUPG3venVgywG4fk1w1U+0QE00WBg2FbPK+edGndwI3qoW14ABB5XMzwbG+gOeDIbwx7ZoCh+WNlA2tO9kwLbequcEBhd4qzNAhh2AS6ev0T2KTVB6K3bh/r9P36EawnQLI+flBED6MVX/lw0B+1L8zhNEvCMfwHeOVNXtFi4hDDjWtdZb8jq1TqspRmaLGCbuZflBS42rYmteokYHNzWyoMVzfU7dLamqhbQoyeHNgkEmdmSUMA0eTaBS9+sDs4cWOqiWeuF7HmDnsZgqu6DsjTkYV02uorUBrwY5BzT/0fc7OJxyE+iD747Nk5Idk7BBWW28MfIUhw1vcohHjscCc79yrHumiRoCjuQX4LRPXJrJgqcukwBX63hWX0IKFZCgS5RXmNmCwopqYUGCW1Ea3IRKDk8ZB9KcoO4ywcPnLyMHlrb6y/AmsfuE0MSWnn7qIf3AHzTzy5L5U5+GgwDTfO9FefSCAAkrUZ8b8VzDCiij/53V3G9if0l8XzZikad44X3xDe5PYDvSUk+hw68GnivTJwD4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XLzAEd+DOr3h4B688sNlENHUfDsD3zO7g==; 5:dJmYQhBrGZ1udIWDE8qgd3xCeTRCpI9YisBcRwa5asTiz4xPrxethrwRY9mCh7HBn+U60AHG2HIzGYW+Auy3RQjlBqgR6JNQaWEIQM1VEg4aOqbBxIXyQPD2IFyC+r15w8Pu2HQwQLqQueyWa5vuEFtU3A4gAHpjjSQzNgrN/d8EixcaMSWLk+pp8svEdyh1; 24:zzVUgcqnZLJk57xCB9LP9kfe1kFgYQRh0jas7CTQj8KDa2QUe52FUNX6GdSlABo0Oz4ETYrEZ2TUKXM8gEIVi5N/1ZGBlANwBBjT6+gBC+w= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB168; 7:khT4fpRJx/FCALH7Mwqylz+XU/GMmgMRhhnw+AvGAe9tR+fPjcVZeD65qDAVhGOFfcFZ6V+acdtaEKH4AwxpskYhIfhvXssS5yTG8o+xn1bz0FeCHN91TSvQ/0Z0d2kB92O0K3DA2c9ghXR2XMSgucNfBdrfNjJn4+Glw7zdE/Eu8tBzamKzb3DVbyaSAOQrhwiA9CT2Z5ZRMb0z3fFngkG3yNYQPhVXZ60MBluvNWjNpKhMv0PUwWvLiyt0mkEKrirxFKWLOdktalcsrqIR2Bjdw+9dAv6BcYqcSQXSW3iXnO9DMwPeO69vpjwXYU3YFgvsfKiryF59k9/fXXb1zw== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 May 2017 10:18:06.3158 (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.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB168 Subject: [dpdk-dev] [RFC Patch 09/39] bus/dpaa: enable DPAA IOCTL portal driver 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" Userspace applications interact with DPAA blocks using this IOCTL driver. Signed-off-by: Geoff Thorpe Signed-off-by: Hemant Agrawal Signed-off-by: Shreyansh Jain --- drivers/bus/dpaa/Makefile | 4 +- drivers/bus/dpaa/base/qbman/process.c | 331 ++++++++++++++++++++++++++++++++++ drivers/bus/dpaa/include/fsl_usd.h | 88 +++++++++ drivers/bus/dpaa/include/process.h | 107 +++++++++++ 4 files changed, 529 insertions(+), 1 deletion(-) create mode 100644 drivers/bus/dpaa/base/qbman/process.c create mode 100644 drivers/bus/dpaa/include/fsl_usd.h create mode 100644 drivers/bus/dpaa/include/process.h diff --git a/drivers/bus/dpaa/Makefile b/drivers/bus/dpaa/Makefile index 66b6f2f..07c9880 100644 --- a/drivers/bus/dpaa/Makefile +++ b/drivers/bus/dpaa/Makefile @@ -51,6 +51,7 @@ CFLAGS += -D _GNU_SOURCE CFLAGS += -I$(RTE_BUS_DPAA)/ CFLAGS += -I$(RTE_BUS_DPAA)/include +CFLAGS += -I$(RTE_BUS_DPAA)/base/qbman CFLAGS += -I$(RTE_SDK)/lib/librte_eal/linuxapp/eal CFLAGS += -I$(RTE_SDK)/lib/librte_eal/common/include @@ -68,6 +69,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_DPAA_BUS) += \ base/fman/fman.c \ base/fman/fman_hw.c \ base/fman/of.c \ - base/fman/netcfg_layer.c + base/fman/netcfg_layer.c \ + base/qbman/process.c include $(RTE_SDK)/mk/rte.lib.mk diff --git a/drivers/bus/dpaa/base/qbman/process.c b/drivers/bus/dpaa/base/qbman/process.c new file mode 100644 index 0000000..b8ec539 --- /dev/null +++ b/drivers/bus/dpaa/base/qbman/process.c @@ -0,0 +1,331 @@ +/*- + * 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 2011-2016 Freescale Semiconductor Inc. + * Copyright 2017 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. + */ +#include +#include +#include +#include + +#include "process.h" + +#include + +/* As higher-level drivers will be built on top of this (dma_mem, qbman, ...), + * it's preferable that the process driver itself not provide any exported API. + * As such, combined with the fact that none of these operations are + * performance critical, it is justified to use lazy initialisation, so that's + * what the lock is for. + */ +static int fd = -1; +static pthread_mutex_t fd_init_lock = PTHREAD_MUTEX_INITIALIZER; + +static int check_fd(void) +{ + int ret; + + if (fd >= 0) + return 0; + ret = pthread_mutex_lock(&fd_init_lock); + assert(!ret); + /* check again with the lock held */ + if (fd < 0) + fd = open(PROCESS_PATH, O_RDWR); + ret = pthread_mutex_unlock(&fd_init_lock); + assert(!ret); + return (fd >= 0) ? 0 : -ENODEV; +} + +#define DPAA_IOCTL_MAGIC 'u' +struct dpaa_ioctl_id_alloc { + uint32_t base; /* Return value, the start of the allocated range */ + enum dpaa_id_type id_type; /* what kind of resource(s) to allocate */ + uint32_t num; /* how many IDs to allocate (and return value) */ + uint32_t align; /* must be a power of 2, 0 is treated like 1 */ + int partial; /* whether to allow less than 'num' */ +}; + +struct dpaa_ioctl_id_release { + /* Input; */ + enum dpaa_id_type id_type; + uint32_t base; + uint32_t num; +}; + +struct dpaa_ioctl_id_reserve { + enum dpaa_id_type id_type; + uint32_t base; + uint32_t num; +}; + +#define DPAA_IOCTL_ID_ALLOC \ + _IOWR(DPAA_IOCTL_MAGIC, 0x01, struct dpaa_ioctl_id_alloc) +#define DPAA_IOCTL_ID_RELEASE \ + _IOW(DPAA_IOCTL_MAGIC, 0x02, struct dpaa_ioctl_id_release) +#define DPAA_IOCTL_ID_RESERVE \ + _IOW(DPAA_IOCTL_MAGIC, 0x0A, struct dpaa_ioctl_id_reserve) + +int process_alloc(enum dpaa_id_type id_type, uint32_t *base, uint32_t num, + uint32_t align, int partial) +{ + struct dpaa_ioctl_id_alloc id = { + .id_type = id_type, + .num = num, + .align = align, + .partial = partial + }; + int ret = check_fd(); + + if (ret) + return ret; + ret = ioctl(fd, DPAA_IOCTL_ID_ALLOC, &id); + if (ret) + return ret; + for (ret = 0; ret < (int)id.num; ret++) + base[ret] = id.base + ret; + return id.num; +} + +void process_release(enum dpaa_id_type id_type, uint32_t base, uint32_t num) +{ + struct dpaa_ioctl_id_release id = { + .id_type = id_type, + .base = base, + .num = num + }; + int ret = check_fd(); + + if (ret) { + fprintf(stderr, "Process FD failure\n"); + return; + } + ret = ioctl(fd, DPAA_IOCTL_ID_RELEASE, &id); + if (ret) + fprintf(stderr, "Process FD ioctl failure type %d base 0x%x num %d\n", + id_type, base, num); +} + +int process_reserve(enum dpaa_id_type id_type, uint32_t base, uint32_t num) +{ + struct dpaa_ioctl_id_reserve id = { + .id_type = id_type, + .base = base, + .num = num + }; + int ret = check_fd(); + + if (ret) + return ret; + return ioctl(fd, DPAA_IOCTL_ID_RESERVE, &id); +} + +/***************************************/ +/* Mapping and using QMan/BMan portals */ +/***************************************/ + +#define DPAA_IOCTL_PORTAL_MAP \ + _IOWR(DPAA_IOCTL_MAGIC, 0x07, struct dpaa_ioctl_portal_map) +#define DPAA_IOCTL_PORTAL_UNMAP \ + _IOW(DPAA_IOCTL_MAGIC, 0x08, struct dpaa_portal_map) + +int process_portal_map(struct dpaa_ioctl_portal_map *params) +{ + int ret = check_fd(); + + if (ret) + return ret; + + ret = ioctl(fd, DPAA_IOCTL_PORTAL_MAP, params); + if (ret) { + perror("ioctl(DPAA_IOCTL_PORTAL_MAP)"); + return ret; + } + return 0; +} + +int process_portal_unmap(struct dpaa_portal_map *map) +{ + int ret = check_fd(); + + if (ret) + return ret; + + ret = ioctl(fd, DPAA_IOCTL_PORTAL_UNMAP, map); + if (ret) { + perror("ioctl(DPAA_IOCTL_PORTAL_UNMAP)"); + return ret; + } + return 0; +} + +#define DPAA_IOCTL_PORTAL_IRQ_MAP \ + _IOW(DPAA_IOCTL_MAGIC, 0x09, struct dpaa_ioctl_irq_map) + +int process_portal_irq_map(int ifd, struct dpaa_ioctl_irq_map *map) +{ + map->fd = fd; + return ioctl(ifd, DPAA_IOCTL_PORTAL_IRQ_MAP, map); +} + +int process_portal_irq_unmap(int ifd) +{ + return close(ifd); +} + +struct dpaa_ioctl_raw_portal { + /* inputs */ + enum dpaa_portal_type type; /* Type of portal to allocate */ + + uint8_t enable_stash; /* set to non zero to turn on stashing */ + /* Stashing attributes for the portal */ + uint32_t cpu; + uint32_t cache; + uint32_t window; + /* Specifies the stash request queue this portal should use */ + uint8_t sdest; + + /* Specifes a specific portal index to map or QBMAN_ANY_PORTAL_IDX + * for don't care. The portal index will be populated by the + * driver when the ioctl() successfully completes. + */ + uint32_t index; + + /* outputs */ + uint64_t cinh; + uint64_t cena; +}; + +#define DPAA_IOCTL_ALLOC_RAW_PORTAL \ + _IOWR(DPAA_IOCTL_MAGIC, 0x0C, struct dpaa_ioctl_raw_portal) + +#define DPAA_IOCTL_FREE_RAW_PORTAL \ + _IOR(DPAA_IOCTL_MAGIC, 0x0D, struct dpaa_ioctl_raw_portal) + +static int process_portal_allocate(struct dpaa_ioctl_raw_portal *portal) +{ + int ret = check_fd(); + + if (ret) + return ret; + + ret = ioctl(fd, DPAA_IOCTL_ALLOC_RAW_PORTAL, portal); + if (ret) { + perror("ioctl(DPAA_IOCTL_ALLOC_RAW_PORTAL)"); + return ret; + } + return 0; +} + +static int process_portal_free(struct dpaa_ioctl_raw_portal *portal) +{ + int ret = check_fd(); + + if (ret) + return ret; + + ret = ioctl(fd, DPAA_IOCTL_FREE_RAW_PORTAL, portal); + if (ret) { + perror("ioctl(DPAA_IOCTL_FREE_RAW_PORTAL)"); + return ret; + } + return 0; +} + +int qman_allocate_raw_portal(struct dpaa_raw_portal *portal) +{ + struct dpaa_ioctl_raw_portal input; + int ret; + + input.type = dpaa_portal_qman; + input.index = portal->index; + input.enable_stash = portal->enable_stash; + input.cpu = portal->cpu; + input.cache = portal->cache; + input.window = portal->window; + input.sdest = portal->sdest; + + ret = process_portal_allocate(&input); + if (ret) + return ret; + portal->index = input.index; + portal->cinh = input.cinh; + portal->cena = input.cena; + return 0; +} + +int qman_free_raw_portal(struct dpaa_raw_portal *portal) +{ + struct dpaa_ioctl_raw_portal input; + + input.type = dpaa_portal_qman; + input.index = portal->index; + input.cinh = portal->cinh; + input.cena = portal->cena; + + return process_portal_free(&input); +} + +int bman_allocate_raw_portal(struct dpaa_raw_portal *portal) +{ + struct dpaa_ioctl_raw_portal input; + int ret; + + input.type = dpaa_portal_bman; + input.index = portal->index; + input.enable_stash = 0; + + ret = process_portal_allocate(&input); + if (ret) + return ret; + portal->index = input.index; + portal->cinh = input.cinh; + portal->cena = input.cena; + return 0; +} + +int bman_free_raw_portal(struct dpaa_raw_portal *portal) +{ + struct dpaa_ioctl_raw_portal input; + + input.type = dpaa_portal_bman; + input.index = portal->index; + input.cinh = portal->cinh; + input.cena = portal->cena; + + return process_portal_free(&input); +} diff --git a/drivers/bus/dpaa/include/fsl_usd.h b/drivers/bus/dpaa/include/fsl_usd.h new file mode 100644 index 0000000..4ff48c6 --- /dev/null +++ b/drivers/bus/dpaa/include/fsl_usd.h @@ -0,0 +1,88 @@ +/*- + * 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 2010-2011 Freescale Semiconductor, Inc. + * All rights reserved. + * + * 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_USD_H +#define __FSL_USD_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define QBMAN_ANY_PORTAL_IDX 0xffffffff + +/* Obtain and free raw (unitialized) portals */ + +struct dpaa_raw_portal { + /* inputs */ + + /* set to non zero to turn on stashing */ + uint8_t enable_stash; + /* Stashing attributes for the portal */ + uint32_t cpu; + uint32_t cache; + uint32_t window; + + /* Specifies the stash request queue this portal should use */ + uint8_t sdest; + + /* Specifes a specific portal index to map or QBMAN_ANY_PORTAL_IDX + * for don't care. The portal index will be populated by the + * driver when the ioctl() successfully completes. + */ + uint32_t index; + + /* outputs */ + uint64_t cinh; + uint64_t cena; +}; + +int qman_allocate_raw_portal(struct dpaa_raw_portal *portal); +int qman_free_raw_portal(struct dpaa_raw_portal *portal); + +int bman_allocate_raw_portal(struct dpaa_raw_portal *portal); +int bman_free_raw_portal(struct dpaa_raw_portal *portal); + +#ifdef __cplusplus +} +#endif + +#endif /* __FSL_USD_H */ diff --git a/drivers/bus/dpaa/include/process.h b/drivers/bus/dpaa/include/process.h new file mode 100644 index 0000000..989ddcd --- /dev/null +++ b/drivers/bus/dpaa/include/process.h @@ -0,0 +1,107 @@ +/*- + * 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 2010-2011 Freescale Semiconductor, Inc. + * All rights reserved. + * + * 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 __PROCESS_H +#define __PROCESS_H + +#include + +/* The process device underlies process-wide user/kernel interactions, such as + * mapping dma_mem memory and providing accompanying ioctl()s. (This isn't used + * for portals, which use one UIO device each.). + */ +#define PROCESS_PATH "/dev/fsl-usdpaa" + +/* Allocation of resource IDs uses a generic interface. This enum is used to + * distinguish between the type of underlying object being manipulated. + */ +enum dpaa_id_type { + dpaa_id_fqid, + dpaa_id_bpid, + dpaa_id_qpool, + dpaa_id_cgrid, + dpaa_id_max /* <-- not a valid type, represents the number of types */ +}; + +int process_alloc(enum dpaa_id_type id_type, uint32_t *base, uint32_t num, + uint32_t align, int partial); +void process_release(enum dpaa_id_type id_type, uint32_t base, uint32_t num); + +int process_reserve(enum dpaa_id_type id_type, uint32_t base, uint32_t num); + +/* Mapping and using QMan/BMan portals */ +enum dpaa_portal_type { + dpaa_portal_qman, + dpaa_portal_bman, +}; + +struct dpaa_ioctl_portal_map { + /* Input parameter, is a qman or bman portal required. */ + enum dpaa_portal_type type; + /* Specifes a specific portal index to map or 0xffffffff + * for don't care. + */ + uint32_t index; + + /* Return value if the map succeeds, this gives the mapped + * cache-inhibited (cinh) and cache-enabled (cena) addresses. + */ + struct dpaa_portal_map { + void *cinh; + void *cena; + } addr; + /* Qman-specific return values */ + u16 channel; + uint32_t pools; +}; + +int process_portal_map(struct dpaa_ioctl_portal_map *params); +int process_portal_unmap(struct dpaa_portal_map *map); + +struct dpaa_ioctl_irq_map { + enum dpaa_portal_type type; /* Type of portal to map */ + int fd; /* File descriptor that contains the portal */ + void *portal_cinh; /* Cache inhibited area to identify the portal */ +}; + +int process_portal_irq_map(int fd, struct dpaa_ioctl_irq_map *irq); +int process_portal_irq_unmap(int fd); + +#endif /* __PROCESS_H */