From patchwork Fri Aug 25 10:49:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 110992 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp810783qge; Fri, 25 Aug 2017 03:52:10 -0700 (PDT) X-Received: by 10.223.170.2 with SMTP id p2mr5907285wrd.22.1503658329903; Fri, 25 Aug 2017 03:52:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503658329; cv=none; d=google.com; s=arc-20160816; b=LhtJ7juu55H9uNP3Q7NfGjV55ywvCLRZvkxA2++Ic2thCS5edMdFKRAEyeAUlt+bm9 XOgt8z2K9bUVLKCcCaN4odtSc9MwIr2h4XfhoUb5xNV58DE9buOsGdPm37gL8YhJ5za/ dWCgwaidQa37p/IrTgJ3fPMvlYGbxFBr/kRINQeMVzNtL64nCGO3qC+E5/YkWLipr7Sc qpvQmplVkDi0hok5Y2bR/uhrNcTGZ53/8SuD5jp1V0KBv0fj7/dLh296xd1Zd1xGgxEU mVU8+RsoaUf5xLyzXZPzVbTwAEJDBGjRI6cefQzXKRr47jiBMPSjsmOvq8jEPeWvAJrD Gfgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:references:in-reply-to:message-id :date:cc:to:from:arc-authentication-results; bh=P+QUtgM7P7q6qhB1H/JRfBuJJAlq7GRsUuCKoY91jtk=; b=Kr6s5UzINbGnu8d/G5LFbv94tj72CZWLO6PVqJjIAXaI716CIbL/8znglK8u2fAoap 4d8W1Hl78pOzilGuIwa3pIsDg7osK6k9f4snsIVBH+qyMlgUdO/EMa4eZT3VeadNrmj7 79bERPRDL3HTjBnMdCaqz300vxvHrbqeqkonevMge8stixGu6x1G1pBe+Hj/0OahPSGs GePICEIZVqR/unt8ZrALc80S+R8tHIx1nTNCiMRLfomYu//yQLhF5evXEdgKzdJ8M31w nPgEAuILp3+E1Xw7aPTp6RSedpXYuOy0t2CXEmya0O0r7z38CqqUtN6CHLYQEPY031oD nEKw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from dpdk.org (dpdk.org. [92.243.14.124]) by mx.google.com with ESMTP id m70si1023054wmc.120.2017.08.25.03.52.09; Fri, 25 Aug 2017 03:52:09 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) client-ip=92.243.14.124; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 7BEBD9179; Fri, 25 Aug 2017 12:50:25 +0200 (CEST) Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0077.outbound.protection.outlook.com [104.47.32.77]) by dpdk.org (Postfix) with ESMTP id 7C747915B for ; Fri, 25 Aug 2017 12:50:22 +0200 (CEST) Received: from BN3PR03CA0063.namprd03.prod.outlook.com (10.167.1.151) by CY1PR03MB2265.namprd03.prod.outlook.com (10.166.207.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Fri, 25 Aug 2017 10:50:19 +0000 Received: from BY2FFO11FD014.protection.gbl (2a01:111:f400:7c0c::196) by BN3PR03CA0063.outlook.office365.com (2a01:111:e400:7a4d::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1385.9 via Frontend Transport; Fri, 25 Aug 2017 10:50:19 +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; 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 BY2FFO11FD014.mail.protection.outlook.com (10.1.14.76) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1341.15 via Frontend Transport; Fri, 25 Aug 2017 10:50:18 +0000 Received: from bf-netperf1.ap.freescale.net (bf-netperf1.ap.freescale.net [10.232.134.28]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v7PAnw6D032070; Fri, 25 Aug 2017 03:50:16 -0700 From: Hemant Agrawal To: CC: , Date: Fri, 25 Aug 2017 16:19:25 +0530 Message-ID: <1503658183-4078-10-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503658183-4078-1-git-send-email-hemant.agrawal@nxp.com> References: <1503658183-4078-1-git-send-email-hemant.agrawal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131481318186296283; (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)(39380400002)(39860400002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(33646002)(4326008)(47776003)(53946003)(50986999)(76176999)(626005)(15650500001)(105606002)(106466001)(2351001)(8656003)(6916009)(77096006)(189998001)(5003940100001)(104016004)(2906002)(2950100002)(48376002)(68736007)(6666003)(97736004)(81166006)(50466002)(53936002)(8676002)(356003)(36756003)(560934005)(498600001)(85426001)(81156014)(54906002)(16200700003)(5660300001)(86362001)(305945005)(50226002)(575784001)(8936002)(110136004)(559001)(579004)(569006); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR03MB2265; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD014; 1:+AKygtY0AvqcUK3ojoI7WspXwGuAZY78SJqoqoAmONaiCIm+Mu0PO0ZoCW9QruLo6qZPOMCytpyw/+L4Ab5h7tDXCPwVMY8lX3KJQk4RRIIM71naFXYhSH6D9dwOzEcw MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 39d29db3-97b7-42f4-23db-08d4eba7138f X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(300000503095)(300135400095)(2017052603199)(201703131430075)(201703131517081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:CY1PR03MB2265; X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB2265; 3:WrHrfEyFVEiRKnV4rrfNrc8Mi7FsSiyKSACBR9VBBM5gn47y/2noPuFkixcyqzSx+1wERsvIdlBJdBWhOxKSlPUivqa1/7zrxPx8EOZv5CsMlufGfC+HCTK3wUMvD+gmH5o1cs44L5DcKtKJ4zWNCL9g4P56Ke1ox8V6H5YX8RFd5TtPU0SCYBE1iXCJ58hxMkwvWqdQ+T2R9iOOUGl25XqVndUYaNpG6pw51YvmUYfwWj6qQvIaJVk5raslvWNBY093lM2aDO3Q0nqFkzxlaxQI37Ud+B/BBGvuKQtcSIsA0xE7/Vj098PNDkPuSL5LTcJsvYH+5fCHcGqb3GMlMDMrsa/J1PUJqrzYPRAFYZE=; 25:GTLf/MfkN8B8Nd3c9ptn17g4vb+qajpZjJA/adCRftCsfEJIuLs6rxa47d0VXj0SrI2EwKZX3E0lNjNgBKX3/KNWcMZbubo7iCWB4rI7om9qcYSTz7oZXBmGqylfhst821ydOmozQ+fN7qo8Sr4k/NaFMB1boBowzGpVGiwItlOGG+6eNUqFrYqSo/HmfffUD+J8MgsXwDgvm4diig/TmWrdwVrEKjenCKFuAISge8rKGUMR5+t/wnpzfE2HElIGlH+Mu9YkQKHp9MSKJOxR8vjr0oVwi074tEY20ax60kyPpdNx0i5sRlHf4hnkWzvXgiqVQwq28ksL2BzBYZgLUA== X-MS-TrafficTypeDiagnostic: CY1PR03MB2265: X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB2265; 31:4zlh91jAV5dURqaXWYXYy7Dqtae9y1V+2PAYL6FCc8iE9RbMaboDU6xoURm9D8kA1YPeV3s49T2AGpnenzyYQRm1oUA5wSBOLd4hLMBc9bfGXdkDK8dflFCwgE6NusZVogQDSmXcR/lr7UTwQEnkhP5cf0f213PTt9rUE2mlOJampEWApP2QAvWdaLcl0TI3zLkRFndnnPnkjWk/p0MDC59MSsh9HWTeqM4dsP0C3bA=; 4:Q3ngmfg3Fa4ljBNquvvqNoWv/n2D2XjgFLhedhwOqDPzJbklmf1RsYyo4KfvU0YE0ERRvQKqApMq/mnZgH3i98iKU07gdqnP3kjAc1HeZjkavh05pHIbDmPmBMMuQn1cSjnj+xYdkWyDaFcbHv/iaBNlXg/mmPNwsfe2zAiDMjR3mY/51FsJzhsfVNTXRuHYDZDROnLMNAnIxQiQwZ4NQF3eGJdULEzdJE1/erBonQSVk/vScaGMKNUm6vzddSMKd/HvnkvaSKpUpuDakxR2mb6msKl4gdSRawRRLsRh5qsXY5VmP+74fDy7nun+y6Nxr5Jnh7JS4srofZ8XAqxl95u8toy14FXSllfX1e3xuSarPn56zRn2GUb25EhoNGF2 X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(227817650892897)(275809806118684); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6095135)(601004)(2401047)(5005006)(13018025)(13016025)(8121501046)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(6055026)(6096035)(201703131430075)(201703131433075)(201703131448075)(201703161259150)(201703151042153)(20161123556025)(20161123561025)(20161123565025)(20161123559100)(20161123563025)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:CY1PR03MB2265; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:CY1PR03MB2265; X-Forefront-PRVS: 041032FF37 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR03MB2265; 23:YSqvo5Az85s6tANmEO3V807OZCQ2M19KFUtoJyOof?= G0yKDkz/avMpycIbt3xiNw8Rl+n7+z/vrxV5n4GJCRF51G5FT8gms/SOE1fKrh8A00Bzs8bf6NoyY9D4CjXpRSOvv9KjZf1MgG40qvNupR0RLs4XgucY0z2gIXEkznoGx3qh6wjdDuOtkTtoe1FmKyfidBdZL1hNaqjGD/twMmyxqcJwAhDIX5x27wgoUqGotkAP4U89eXUujl70Qe5rsMjB4HrhZsujCizwxS4AnO0GIwwRnDUeY0aqOwBgQFSJJn8rSiOR2GYbHj6cDbNOLOS9KMRx3W9Aw6cTRmusHdWF+/c9UbK5wInGxnRS0ZDU1ZEJRn7kjcmCvUMH9nUbDYLCpXTRW0vNQJesDtyo5sBd6OoUYj2XhkjmYgoceLKrxWzoISddAdtzUQF5oX0l1wBBIOLv5pvr+g/diwCl7iLzYcA2TVn0m0Fpls/xJUxs94eyrarkGuUAK86gScgXWZlcXL2ureYpYKjxgC1EMo97VFES1P4zEx5KJ50cNKzYeJG5fRVRtuGXkLLEX7DVEohjrBgaXHibamga/5N0jW2V7XXO2CKZXJY3D2uS7Q9sSdyR51fwe/lCa5mMFVyEmhbkHCEQceNiPWobCW8z6jAfxPmrG8RyNAPqJRtdxyG+nBnZwj8mmkF+KJiDfbXEIeq2kQpR8tjxUSPpAY0jMSDdVp8mFqsNd5ZIPPuc8hiuaqjDNocGB4pq9QSHNBj3etHCY/p90ZTQdg7K0hvAika5Q+ttYBJtbONmLADo9bNo0adRE5wObGWPZzcLivHVV41dzdBhfIrEFav1rVrT3kAkO2mZuwTfHfo5Y1emq7ZEgbXmGGY1Ob/u2YfVlJZR9PI5eL0FCKSIhP60dEzAzAhUI8lquH0qFDMraFgFU6BznL3Az9X0aOJeBdtOga0I2QgWfcAVhao1NB+s/Q911XUkGP93J3/IQ/svZ3JSBEXUme62oasqNV9wrUDNm5A25YGtK+5+WrPzAB838S+vF41uRo7rd382t3uD8I4cxA2UwsF9/M/Gwbipg9jpT3an3+uNTLGUQ4iMad+ieEJqJ/i4BwNYYefrKh2tgwIMvHcVPTevH31NEEPQlkgzpGwv92Unz2nlRruMjvczaqVCB+Wd1ALI7fWfTy3jkfz48S52KkGoIZLpe3zi08nCYh/jbR9/2h3o8+DsX7XZauExzLbNbcadFBKqWMjsLe4TfbmzKfola72hmhRToG/FuvK+NtHCnV5NKGXJ8qNq8mbTjBQ4TF3/1GIqDFnsk7i35own4I= X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB2265; 6:p6Q6xOh3hrUg97hNcgeWhyLAWYiNhoVA6Q/7WvY/X7uXxHhYRoAtmxli0NUhweS0fE948PcurFBhIg9Tx8fVchzNaDPuXL5UhutqXwtxgybBpeKYwoto3mPn29Cqnj0sRSurn2xy1u+uYG3dWQWJNaRrAKUdJere1iXFdT2sozX90d8ySd6lYztw+T9I0mYKZ++bE2FQGZlbUk+sJiFItgrkoX+9AymdSUNOBooCjvvBr8cYKacOq0i+80CDPT2XzxeQ/vSWjXuVEtIXvrxtfoLyKpbHxgnVW1aclP0Nzd+o1O1L/IOTbNTfSLufWja4oIy2HQCoh8iRDwZXhg15Uw==; 5:jPHO7gNfHxr5D1tEh6j6pVQ352a3uZsYwlW6jGgloWT+ItukT+jxU2ZWthuIc6VD4Iw3ElLVBQH+VfDudDEVEHXmNvT+ovp75YH/BP72lm+Ub16i3F+RXsLrAlSNmAotYq1YpVp9+vOewKjjDzHclA==; 24:9+52NNDWKXlehHqV4ALm/IVz4buZY2NxUIa3dcgVWbgBvDOuTwhMPVt3qCjB9GuvcOpDIjOUh8ssMt37NNSkqRQTFfYicjscjHUkYAUNxg8=; 7:32M91U5zyaNBfO5w91Us1Tre6w2YYcLMdFDcQHeZ9LzFzfYciuU1C8NiWRcuDUDHyqnJ+ULFXUMaaOEyVLzrVT9htvHjcBya0bOc0Q0h7y72lgNRhuGmxvThzkrn8UNbsq+9pSrip3FyVgeDakBkBVlPGvSPLUu1mZlrHNgCbraTVggexSlh/895bBGWJoiuPlw7EBF3kDi6OKs0MZkfVCvpEjnB1ccHEVG9a/3ppg0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2017 10:50:18.4424 (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: CY1PR03MB2265 Subject: [dpdk-dev] [PATCH 09/27] bus/fslmc: update MC to 10.3.x 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" From: Shreyansh Jain Signed-off-by: Shreyansh Jain Signed-off-by: Hemant Agrawal --- drivers/bus/fslmc/fslmc_vfio.c | 19 +++ drivers/bus/fslmc/mc/dpbp.c | 182 +++++++++++++++++---- drivers/bus/fslmc/mc/dpci.c | 202 ++++++++++++++++++++--- drivers/bus/fslmc/mc/dpcon.c | 163 ++++++++++++++++--- drivers/bus/fslmc/mc/dpio.c | 230 ++++++++++++++++++++++++--- drivers/bus/fslmc/mc/dpmng.c | 33 +++- drivers/bus/fslmc/mc/fsl_dpbp.h | 191 +++++----------------- drivers/bus/fslmc/mc/fsl_dpbp_cmd.h | 125 ++++++++++----- drivers/bus/fslmc/mc/fsl_dpci.h | 257 +++++++----------------------- drivers/bus/fslmc/mc/fsl_dpci_cmd.h | 222 ++++++++++++++------------ drivers/bus/fslmc/mc/fsl_dpcon.h | 186 ++++------------------ drivers/bus/fslmc/mc/fsl_dpcon_cmd.h | 193 ++++++++-------------- drivers/bus/fslmc/mc/fsl_dpio.h | 299 +++++++++-------------------------- drivers/bus/fslmc/mc/fsl_dpio_cmd.h | 178 ++++++++++++--------- drivers/bus/fslmc/mc/fsl_dpmng.h | 41 ++--- drivers/bus/fslmc/mc/fsl_dpmng_cmd.h | 41 +++-- drivers/bus/fslmc/mc/fsl_mc_cmd.h | 217 +++++++++++-------------- drivers/bus/fslmc/mc/fsl_mc_sys.h | 36 ++--- drivers/bus/fslmc/mc/mc_sys.c | 5 +- 19 files changed, 1452 insertions(+), 1368 deletions(-) -- 2.7.4 diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c index 42a99e8..cdc982b 100644 --- a/drivers/bus/fslmc/fslmc_vfio.c +++ b/drivers/bus/fslmc/fslmc_vfio.c @@ -58,6 +58,7 @@ #include "rte_fslmc.h" #include "fslmc_vfio.h" +#include #include "portal/dpaa2_hw_pvt.h" #include "portal/dpaa2_hw_dpio.h" @@ -417,6 +418,8 @@ fslmc_process_mcp(struct rte_dpaa2_device *dev) { int64_t v_addr; char *dev_name; + struct fsl_mc_io dpmng = {0}; + struct mc_version mc_ver_info = {0}; rte_mcp_ptr_list = malloc(sizeof(void *) * 1); if (!rte_mcp_ptr_list) { @@ -441,6 +444,22 @@ fslmc_process_mcp(struct rte_dpaa2_device *dev) return -1; } + /* check the MC version compatibility */ + dpmng.regs = (void *)v_addr; + if (mc_get_version(&dpmng, CMD_PRI_LOW, &mc_ver_info)) + RTE_LOG(WARNING, PMD, "\tmc_get_version failed\n"); + + if ((mc_ver_info.major != MC_VER_MAJOR) || + (mc_ver_info.minor < MC_VER_MINOR)) { + RTE_LOG(ERR, PMD, "DPAA2 MC version not compatible!" + " Expected %d.%d.x, Detected %d.%d.%d\n", + MC_VER_MAJOR, MC_VER_MINOR, + mc_ver_info.major, mc_ver_info.minor, + mc_ver_info.revision); + free(rte_mcp_ptr_list); + rte_mcp_ptr_list = NULL; + return -1; + } rte_mcp_ptr_list[0] = (void *)v_addr; return 0; diff --git a/drivers/bus/fslmc/mc/dpbp.c b/drivers/bus/fslmc/mc/dpbp.c index fd9a52d..a846245 100644 --- a/drivers/bus/fslmc/mc/dpbp.c +++ b/drivers/bus/fslmc/mc/dpbp.c @@ -5,7 +5,7 @@ * BSD LICENSE * * Copyright 2013-2016 Freescale Semiconductor Inc. - * Copyright 2016 NXP. + * Copyright 2016-2017 NXP. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -42,19 +42,37 @@ #include #include +/** + * dpbp_open() - Open a control session for the specified object. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @dpbp_id: DPBP unique ID + * @token: Returned token; use in subsequent API calls + * + * This function can be used to open a control session for an + * already created object; an object may have been declared in + * the DPL or by calling the dpbp_create function. + * This function returns a unique authentication token, + * associated with the specific object ID and the specific MC + * portal; this token must be used in all subsequent commands for + * this specific object + * + * Return: '0' on Success; Error code otherwise. + */ int dpbp_open(struct fsl_mc_io *mc_io, uint32_t cmd_flags, int dpbp_id, uint16_t *token) { + struct dpbp_cmd_open *cmd_params; struct mc_command cmd = { 0 }; int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPBP_CMDID_OPEN, - cmd_flags, - 0); - DPBP_CMD_OPEN(cmd, dpbp_id); + cmd_flags, 0); + cmd_params = (struct dpbp_cmd_open *)cmd.params; + cmd_params->dpbp_id = cpu_to_le32(dpbp_id); /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -62,11 +80,22 @@ int dpbp_open(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - *token = MC_CMD_HDR_READ_TOKEN(cmd.header); + *token = mc_cmd_hdr_read_token(&cmd); return err; } +/** + * dpbp_close() - Close the control session of the object + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPBP object + * + * After this function is called, no further operations are + * allowed on the object without opening a new control session. + * + * Return: '0' on Success; Error code otherwise. + */ int dpbp_close(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token) @@ -81,6 +110,24 @@ int dpbp_close(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); } +/** + * dpbp_create() - Create the DPBP object. + * @mc_io: Pointer to MC portal's I/O object + * @dprc_token: Parent container token; '0' for default container + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @cfg: Configuration structure + * @obj_id: Returned object id; use in subsequent API calls + * + * Create the DPBP object, allocate required resources and + * perform required initialization. + * + * This function accepts an authentication token of a parent + * container that this object should be assigned to and returns + * an object id. This object_id will be used in all subsequent calls to + * this specific object. + * + * Return: '0' on Success; Error code otherwise. + */ int dpbp_create(struct fsl_mc_io *mc_io, uint16_t dprc_token, uint32_t cmd_flags, @@ -94,8 +141,7 @@ int dpbp_create(struct fsl_mc_io *mc_io, /* prepare command */ cmd.header = mc_encode_cmd_header(DPBP_CMDID_CREATE, - cmd_flags, - dprc_token); + cmd_flags, dprc_token); /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -103,28 +149,47 @@ int dpbp_create(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - CMD_CREATE_RSP_GET_OBJ_ID_PARAM0(cmd, *obj_id); + *obj_id = mc_cmd_read_object_id(&cmd); return 0; } +/** + * dpbp_destroy() - Destroy the DPBP object and release all its resources. + * @mc_io: Pointer to MC portal's I/O object + * @dprc_token: Parent container token; '0' for default container + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @obj_id: ID of DPBP object + * + * Return: '0' on Success; error code otherwise. + */ int dpbp_destroy(struct fsl_mc_io *mc_io, uint16_t dprc_token, - uint32_t cmd_flags, - uint32_t object_id) + uint32_t cmd_flags, + uint32_t obj_id) { + struct dpbp_cmd_destroy *cmd_params; struct mc_command cmd = { 0 }; /* prepare command */ cmd.header = mc_encode_cmd_header(DPBP_CMDID_DESTROY, - cmd_flags, - dprc_token); - /* set object id to destroy */ - CMD_DESTROY_SET_OBJ_ID_PARAM0(cmd, object_id); + cmd_flags, dprc_token); + + cmd_params = (struct dpbp_cmd_destroy *)cmd.params; + cmd_params->object_id = cpu_to_le32(obj_id); + /* send command to mc*/ return mc_send_command(mc_io, &cmd); } +/** + * dpbp_enable() - Enable the DPBP. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPBP object + * + * Return: '0' on Success; Error code otherwise. + */ int dpbp_enable(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token) @@ -139,6 +204,14 @@ int dpbp_enable(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); } +/** + * dpbp_disable() - Disable the DPBP. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPBP object + * + * Return: '0' on Success; Error code otherwise. + */ int dpbp_disable(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token) @@ -147,20 +220,30 @@ int dpbp_disable(struct fsl_mc_io *mc_io, /* prepare command */ cmd.header = mc_encode_cmd_header(DPBP_CMDID_DISABLE, - cmd_flags, - token); + cmd_flags, token); /* send command to mc*/ return mc_send_command(mc_io, &cmd); } +/** + * dpbp_is_enabled() - Check if the DPBP is enabled. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPBP object + * @en: Returns '1' if object is enabled; '0' otherwise + * + * Return: '0' on Success; Error code otherwise. + */ int dpbp_is_enabled(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, int *en) { + struct dpbp_rsp_is_enabled *rsp_params; struct mc_command cmd = { 0 }; int err; + /* prepare command */ cmd.header = mc_encode_cmd_header(DPBP_CMDID_IS_ENABLED, cmd_flags, token); @@ -171,11 +254,20 @@ int dpbp_is_enabled(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - DPBP_RSP_IS_ENABLED(cmd, *en); + rsp_params = (struct dpbp_rsp_is_enabled *)cmd.params; + *en = rsp_params->enabled & DPBP_ENABLE; return 0; } +/** + * dpbp_reset() - Reset the DPBP, returns the object to initial state. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPBP object + * + * Return: '0' on Success; Error code otherwise. + */ int dpbp_reset(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token) @@ -184,8 +276,7 @@ int dpbp_reset(struct fsl_mc_io *mc_io, /* prepare command */ cmd.header = mc_encode_cmd_header(DPBP_CMDID_RESET, - cmd_flags, - token); + cmd_flags, token); /* send command to mc*/ return mc_send_command(mc_io, &cmd); @@ -195,13 +286,13 @@ int dpbp_get_attributes(struct fsl_mc_io *mc_io, uint16_t token, struct dpbp_attr *attr) { + struct dpbp_rsp_get_attributes *rsp_params; struct mc_command cmd = { 0 }; int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_ATTR, - cmd_flags, - token); + cmd_flags, token); /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -209,38 +300,64 @@ int dpbp_get_attributes(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - DPBP_RSP_GET_ATTRIBUTES(cmd, attr); + rsp_params = (struct dpbp_rsp_get_attributes *)cmd.params; + attr->bpid = le16_to_cpu(rsp_params->bpid); + attr->id = le32_to_cpu(rsp_params->id); return 0; } - +/** + * dpbp_get_api_version - Get Data Path Buffer Pool API version + * @mc_io: Pointer to Mc portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @major_ver: Major version of Buffer Pool API + * @minor_ver: Minor version of Buffer Pool API + * + * Return: '0' on Success; Error code otherwise. + */ int dpbp_get_api_version(struct fsl_mc_io *mc_io, uint32_t cmd_flags, - uint16_t *major_ver, - uint16_t *minor_ver) + uint16_t *major_ver, + uint16_t *minor_ver) { + struct dpbp_rsp_get_api_version *rsp_params; struct mc_command cmd = { 0 }; int err; + /* prepare command */ cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_API_VERSION, - cmd_flags, - 0); + cmd_flags, 0); + /* send command to mc */ err = mc_send_command(mc_io, &cmd); if (err) return err; - DPBP_RSP_GET_API_VERSION(cmd, *major_ver, *minor_ver); + /* retrieve response parameters */ + rsp_params = (struct dpbp_rsp_get_api_version *)cmd.params; + *major_ver = le16_to_cpu(rsp_params->major); + *minor_ver = le16_to_cpu(rsp_params->minor); return 0; } -int dpbp_get_num_free_bufs(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, +/** + * dpbp_get_num_free_bufs() - Get number of free buffers in the buffer pool + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPBP object + * @num_free_bufs: Number of free buffers + * + * Return: '0' on Success; Error code otherwise. + */ + +int dpbp_get_num_free_bufs(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, uint32_t *num_free_bufs) { + struct dpbp_rsp_get_num_free_bufs *rsp_params; struct mc_command cmd = { 0 }; int err; @@ -255,7 +372,8 @@ int dpbp_get_num_free_bufs(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - DPBP_RSP_GET_NUM_FREE_BUFS(cmd, *num_free_bufs); + rsp_params = (struct dpbp_rsp_get_num_free_bufs *)cmd.params; + *num_free_bufs = le32_to_cpu(rsp_params->num_free_bufs); return 0; } diff --git a/drivers/bus/fslmc/mc/dpci.c b/drivers/bus/fslmc/mc/dpci.c index 0ea7837..5471024 100644 --- a/drivers/bus/fslmc/mc/dpci.c +++ b/drivers/bus/fslmc/mc/dpci.c @@ -41,11 +41,29 @@ #include #include +/** + * dpci_open() - Open a control session for the specified object + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @dpci_id: DPCI unique ID + * @token: Returned token; use in subsequent API calls + * + * This function can be used to open a control session for an + * already created object; an object may have been declared in + * the DPL or by calling the dpci_create() function. + * This function returns a unique authentication token, + * associated with the specific object ID and the specific MC + * portal; this token must be used in all subsequent commands for + * this specific object. + * + * Return: '0' on Success; Error code otherwise. + */ int dpci_open(struct fsl_mc_io *mc_io, uint32_t cmd_flags, int dpci_id, uint16_t *token) { + struct dpci_cmd_open *cmd_params; struct mc_command cmd = { 0 }; int err; @@ -53,7 +71,8 @@ int dpci_open(struct fsl_mc_io *mc_io, cmd.header = mc_encode_cmd_header(DPCI_CMDID_OPEN, cmd_flags, 0); - DPCI_CMD_OPEN(cmd, dpci_id); + cmd_params = (struct dpci_cmd_open *)cmd.params; + cmd_params->dpci_id = cpu_to_le32(dpci_id); /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -61,11 +80,22 @@ int dpci_open(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - *token = MC_CMD_HDR_READ_TOKEN(cmd.header); + *token = mc_cmd_hdr_read_token(&cmd); return 0; } +/** + * dpci_close() - Close the control session of the object + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPCI object + * + * After this function is called, no further operations are + * allowed on the object without opening a new control session. + * + * Return: '0' on Success; Error code otherwise. + */ int dpci_close(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token) @@ -81,12 +111,35 @@ int dpci_close(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); } +/** + * dpci_create() - Create the DPCI object. + * @mc_io: Pointer to MC portal's I/O object + * @dprc_token: Parent container token; '0' for default container + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @cfg: Configuration structure + * @obj_id: Returned object id + * + * Create the DPCI object, allocate required resources and perform required + * initialization. + * + * The object can be created either by declaring it in the + * DPL file, or by calling this function. + * + * The function accepts an authentication token of a parent + * container that this object should be assigned to. The token + * can be '0' so the object will be assigned to the default container. + * The newly created object can be opened with the returned + * object id and using the container's associated tokens and MC portals. + * + * Return: '0' on Success; Error code otherwise. + */ int dpci_create(struct fsl_mc_io *mc_io, uint16_t dprc_token, uint32_t cmd_flags, const struct dpci_cfg *cfg, uint32_t *obj_id) { + struct dpci_cmd_create *cmd_params; struct mc_command cmd = { 0 }; int err; @@ -94,7 +147,8 @@ int dpci_create(struct fsl_mc_io *mc_io, cmd.header = mc_encode_cmd_header(DPCI_CMDID_CREATE, cmd_flags, dprc_token); - DPCI_CMD_CREATE(cmd, cfg); + cmd_params = (struct dpci_cmd_create *)cmd.params; + cmd_params->num_of_priorities = cfg->num_of_priorities; /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -102,28 +156,53 @@ int dpci_create(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - CMD_CREATE_RSP_GET_OBJ_ID_PARAM0(cmd, *obj_id); + *obj_id = mc_cmd_read_object_id(&cmd); return 0; } +/** + * dpci_destroy() - Destroy the DPCI object and release all its resources. + * @mc_io: Pointer to MC portal's I/O object + * @dprc_token: Parent container token; '0' for default container + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @object_id: The object id; it must be a valid id within the container that + * created this object; + * + * The function accepts the authentication token of the parent container that + * created the object (not the one that currently owns the object). The object + * is searched within parent using the provided 'object_id'. + * All tokens to the object must be closed before calling destroy. + * + * Return: '0' on Success; error code otherwise. + */ int dpci_destroy(struct fsl_mc_io *mc_io, uint16_t dprc_token, - uint32_t cmd_flags, - uint32_t object_id) + uint32_t cmd_flags, + uint32_t object_id) { + struct dpci_cmd_destroy *cmd_params; struct mc_command cmd = { 0 }; /* prepare command */ cmd.header = mc_encode_cmd_header(DPCI_CMDID_DESTROY, cmd_flags, dprc_token); - /* set object id to destroy */ - CMD_DESTROY_SET_OBJ_ID_PARAM0(cmd, object_id); + cmd_params = (struct dpci_cmd_destroy *)cmd.params; + cmd_params->dpci_id = cpu_to_le32(object_id); + /* send command to mc*/ return mc_send_command(mc_io, &cmd); } +/** + * dpci_enable() - Enable the DPCI, allow sending and receiving frames. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPCI object + * + * Return: '0' on Success; Error code otherwise. + */ int dpci_enable(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token) @@ -139,6 +218,14 @@ int dpci_enable(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); } +/** + * dpci_disable() - Disable the DPCI, stop sending and receiving frames. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPCI object + * + * Return: '0' on Success; Error code otherwise. + */ int dpci_disable(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token) @@ -154,13 +241,24 @@ int dpci_disable(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); } +/** + * dpci_is_enabled() - Check if the DPCI is enabled. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPCI object + * @en: Returns '1' if object is enabled; '0' otherwise + * + * Return: '0' on Success; Error code otherwise. + */ int dpci_is_enabled(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, int *en) { + struct dpci_rsp_is_enabled *rsp_params; struct mc_command cmd = { 0 }; int err; + /* prepare command */ cmd.header = mc_encode_cmd_header(DPCI_CMDID_IS_ENABLED, cmd_flags, token); @@ -171,11 +269,20 @@ int dpci_is_enabled(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - DPCI_RSP_IS_ENABLED(cmd, *en); + rsp_params = (struct dpci_rsp_is_enabled *)cmd.params; + *en = dpci_get_field(rsp_params->en, ENABLE); return 0; } +/** + * dpci_reset() - Reset the DPCI, returns the object to initial state. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPCI object + * + * Return: '0' on Success; Error code otherwise. + */ int dpci_reset(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token) @@ -196,6 +303,7 @@ int dpci_get_attributes(struct fsl_mc_io *mc_io, uint16_t token, struct dpci_attr *attr) { + struct dpci_rsp_get_attr *rsp_params; struct mc_command cmd = { 0 }; int err; @@ -210,7 +318,9 @@ int dpci_get_attributes(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - DPCI_RSP_GET_ATTRIBUTES(cmd, attr); + rsp_params = (struct dpci_rsp_get_attr *)cmd.params; + attr->id = le32_to_cpu(rsp_params->id); + attr->num_of_priorities = rsp_params->num_of_priorities; return 0; } @@ -221,24 +331,46 @@ int dpci_set_rx_queue(struct fsl_mc_io *mc_io, uint8_t priority, const struct dpci_rx_queue_cfg *cfg) { + struct dpci_cmd_set_rx_queue *cmd_params; struct mc_command cmd = { 0 }; /* prepare command */ cmd.header = mc_encode_cmd_header(DPCI_CMDID_SET_RX_QUEUE, cmd_flags, token); - DPCI_CMD_SET_RX_QUEUE(cmd, priority, cfg); + cmd_params = (struct dpci_cmd_set_rx_queue *)cmd.params; + cmd_params->dest_id = cpu_to_le32(cfg->dest_cfg.dest_id); + cmd_params->dest_priority = cfg->dest_cfg.priority; + cmd_params->priority = priority; + cmd_params->user_ctx = cpu_to_le64(cfg->user_ctx); + cmd_params->options = cpu_to_le32(cfg->options); + dpci_set_field(cmd_params->dest_type, + DEST_TYPE, + cfg->dest_cfg.dest_type); /* send command to mc*/ return mc_send_command(mc_io, &cmd); } +/** + * dpci_get_rx_queue() - Retrieve Rx queue attributes. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPCI object + * @priority: Select the queue relative to number of + * priorities configured at DPCI creation + * @attr: Returned Rx queue attributes + * + * Return: '0' on Success; Error code otherwise. + */ int dpci_get_rx_queue(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, uint8_t priority, struct dpci_rx_queue_attr *attr) { + struct dpci_cmd_get_queue *cmd_params; + struct dpci_rsp_get_rx_queue *rsp_params; struct mc_command cmd = { 0 }; int err; @@ -246,7 +378,8 @@ int dpci_get_rx_queue(struct fsl_mc_io *mc_io, cmd.header = mc_encode_cmd_header(DPCI_CMDID_GET_RX_QUEUE, cmd_flags, token); - DPCI_CMD_GET_RX_QUEUE(cmd, priority); + cmd_params = (struct dpci_cmd_get_queue *)cmd.params; + cmd_params->priority = priority; /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -254,17 +387,36 @@ int dpci_get_rx_queue(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - DPCI_RSP_GET_RX_QUEUE(cmd, attr); + rsp_params = (struct dpci_rsp_get_rx_queue *)cmd.params; + attr->user_ctx = le64_to_cpu(rsp_params->user_ctx); + attr->fqid = le32_to_cpu(rsp_params->fqid); + attr->dest_cfg.dest_id = le32_to_cpu(rsp_params->dest_id); + attr->dest_cfg.priority = rsp_params->dest_priority; + attr->dest_cfg.dest_type = dpci_get_field(rsp_params->dest_type, + DEST_TYPE); return 0; } +/** + * dpci_get_tx_queue() - Retrieve Tx queue attributes. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPCI object + * @priority: Select the queue relative to number of + * priorities of the peer DPCI object + * @attr: Returned Tx queue attributes + * + * Return: '0' on Success; Error code otherwise. + */ int dpci_get_tx_queue(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, uint8_t priority, struct dpci_tx_queue_attr *attr) { + struct dpci_cmd_get_queue *cmd_params; + struct dpci_rsp_get_tx_queue *rsp_params; struct mc_command cmd = { 0 }; int err; @@ -272,7 +424,8 @@ int dpci_get_tx_queue(struct fsl_mc_io *mc_io, cmd.header = mc_encode_cmd_header(DPCI_CMDID_GET_TX_QUEUE, cmd_flags, token); - DPCI_CMD_GET_TX_QUEUE(cmd, priority); + cmd_params = (struct dpci_cmd_get_queue *)cmd.params; + cmd_params->priority = priority; /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -280,16 +433,27 @@ int dpci_get_tx_queue(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - DPCI_RSP_GET_TX_QUEUE(cmd, attr); + rsp_params = (struct dpci_rsp_get_tx_queue *)cmd.params; + attr->fqid = le32_to_cpu(rsp_params->fqid); return 0; } +/** + * dpci_get_api_version() - Get communication interface API version + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @major_ver: Major version of data path communication interface API + * @minor_ver: Minor version of data path communication interface API + * + * Return: '0' on Success; Error code otherwise. + */ int dpci_get_api_version(struct fsl_mc_io *mc_io, uint32_t cmd_flags, - uint16_t *major_ver, - uint16_t *minor_ver) + uint16_t *major_ver, + uint16_t *minor_ver) { + struct dpci_rsp_get_api_version *rsp_params; struct mc_command cmd = { 0 }; int err; @@ -301,7 +465,9 @@ int dpci_get_api_version(struct fsl_mc_io *mc_io, if (err) return err; - DPCI_RSP_GET_API_VERSION(cmd, *major_ver, *minor_ver); + rsp_params = (struct dpci_rsp_get_api_version *)cmd.params; + *major_ver = le16_to_cpu(rsp_params->major); + *minor_ver = le16_to_cpu(rsp_params->minor); return 0; } diff --git a/drivers/bus/fslmc/mc/dpcon.c b/drivers/bus/fslmc/mc/dpcon.c index b078dff..477ee46 100644 --- a/drivers/bus/fslmc/mc/dpcon.c +++ b/drivers/bus/fslmc/mc/dpcon.c @@ -34,19 +34,38 @@ #include #include +/** + * dpcon_open() - Open a control session for the specified object + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @dpcon_id: DPCON unique ID + * @token: Returned token; use in subsequent API calls + * + * This function can be used to open a control session for an + * already created object; an object may have been declared in + * the DPL or by calling the dpcon_create() function. + * This function returns a unique authentication token, + * associated with the specific object ID and the specific MC + * portal; this token must be used in all subsequent commands for + * this specific object. + * + * Return: '0' on Success; Error code otherwise. + */ int dpcon_open(struct fsl_mc_io *mc_io, uint32_t cmd_flags, int dpcon_id, uint16_t *token) { struct mc_command cmd = { 0 }; + struct dpcon_cmd_open *dpcon_cmd; int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPCON_CMDID_OPEN, cmd_flags, 0); - DPCON_CMD_OPEN(cmd, dpcon_id); + dpcon_cmd = (struct dpcon_cmd_open *)cmd.params; + dpcon_cmd->dpcon_id = cpu_to_le32(dpcon_id); /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -54,11 +73,22 @@ int dpcon_open(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - *token = MC_CMD_HDR_READ_TOKEN(cmd.header); + *token = mc_cmd_hdr_read_token(&cmd); return 0; } +/** + * dpcon_close() - Close the control session of the object + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPCON object + * + * After this function is called, no further operations are + * allowed on the object without opening a new control session. + * + * Return: '0' on Success; Error code otherwise. + */ int dpcon_close(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token) @@ -74,12 +104,34 @@ int dpcon_close(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); } +/** + * dpcon_create() - Create the DPCON object. + * @mc_io: Pointer to MC portal's I/O object + * @dprc_token: Parent container token; '0' for default container + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @cfg: Configuration structure + * @obj_id: Returned object id; use in subsequent API calls + * + * Create the DPCON object, allocate required resources and + * perform required initialization. + * + * The object can be created either by declaring it in the + * DPL file, or by calling this function. + * + * This function accepts an authentication token of a parent + * container that this object should be assigned to and returns + * an object id. This object_id will be used in all subsequent calls to + * this specific object. + * + * Return: '0' on Success; Error code otherwise. + */ int dpcon_create(struct fsl_mc_io *mc_io, uint16_t dprc_token, - uint32_t cmd_flags, - const struct dpcon_cfg *cfg, - uint32_t *obj_id) + uint32_t cmd_flags, + const struct dpcon_cfg *cfg, + uint32_t *obj_id) { + struct dpcon_cmd_create *dpcon_cmd; struct mc_command cmd = { 0 }; int err; @@ -87,7 +139,8 @@ int dpcon_create(struct fsl_mc_io *mc_io, cmd.header = mc_encode_cmd_header(DPCON_CMDID_CREATE, cmd_flags, dprc_token); - DPCON_CMD_CREATE(cmd, cfg); + dpcon_cmd = (struct dpcon_cmd_create *)cmd.params; + dpcon_cmd->num_priorities = cfg->num_priorities; /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -95,28 +148,47 @@ int dpcon_create(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - CMD_CREATE_RSP_GET_OBJ_ID_PARAM0(cmd, *obj_id); + *obj_id = mc_cmd_read_object_id(&cmd); return 0; } +/** + * dpcon_destroy() - Destroy the DPCON object and release all its resources. + * @mc_io: Pointer to MC portal's I/O object + * @dprc_token: Parent container token; '0' for default container + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @obj_id: ID of DPCON object + * + * Return: '0' on Success; error code otherwise. + */ int dpcon_destroy(struct fsl_mc_io *mc_io, uint16_t dprc_token, - uint32_t cmd_flags, - uint32_t object_id) + uint32_t cmd_flags, + uint32_t obj_id) { + struct dpcon_cmd_destroy *cmd_params; struct mc_command cmd = { 0 }; /* prepare command */ cmd.header = mc_encode_cmd_header(DPCON_CMDID_DESTROY, cmd_flags, dprc_token); - /* set object id to destroy */ - CMD_DESTROY_SET_OBJ_ID_PARAM0(cmd, object_id); + cmd_params = (struct dpcon_cmd_destroy *)cmd.params; + cmd_params->object_id = cpu_to_le32(obj_id); + /* send command to mc*/ return mc_send_command(mc_io, &cmd); } +/** + * dpcon_enable() - Enable the DPCON + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPCON object + * + * Return: '0' on Success; Error code otherwise + */ int dpcon_enable(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token) @@ -132,6 +204,14 @@ int dpcon_enable(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); } +/** + * dpcon_disable() - Disable the DPCON + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPCON object + * + * Return: '0' on Success; Error code otherwise + */ int dpcon_disable(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token) @@ -147,13 +227,24 @@ int dpcon_disable(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); } +/** + * dpcon_is_enabled() - Check if the DPCON is enabled. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPCON object + * @en: Returns '1' if object is enabled; '0' otherwise + * + * Return: '0' on Success; Error code otherwise. + */ int dpcon_is_enabled(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, int *en) { + struct dpcon_rsp_is_enabled *dpcon_rsp; struct mc_command cmd = { 0 }; int err; + /* prepare command */ cmd.header = mc_encode_cmd_header(DPCON_CMDID_IS_ENABLED, cmd_flags, @@ -165,11 +256,20 @@ int dpcon_is_enabled(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - DPCON_RSP_IS_ENABLED(cmd, *en); + dpcon_rsp = (struct dpcon_rsp_is_enabled *)cmd.params; + *en = dpcon_rsp->enabled & DPCON_ENABLE; return 0; } +/** + * dpcon_reset() - Reset the DPCON, returns the object to initial state. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPCON object + * + * Return: '0' on Success; Error code otherwise. + */ int dpcon_reset(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token) @@ -184,11 +284,21 @@ int dpcon_reset(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); } +/** + * dpcon_get_attributes() - Retrieve DPCON attributes. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPCON object + * @attr: Object's attributes + * + * Return: '0' on Success; Error code otherwise. + */ int dpcon_get_attributes(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, struct dpcon_attr *attr) { + struct dpcon_rsp_get_attr *dpcon_rsp; struct mc_command cmd = { 0 }; int err; @@ -203,28 +313,45 @@ int dpcon_get_attributes(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - DPCON_RSP_GET_ATTR(cmd, attr); + dpcon_rsp = (struct dpcon_rsp_get_attr *)cmd.params; + attr->id = le32_to_cpu(dpcon_rsp->id); + attr->qbman_ch_id = le16_to_cpu(dpcon_rsp->qbman_ch_id); + attr->num_priorities = dpcon_rsp->num_priorities; return 0; } +/** + * dpcon_get_api_version - Get Data Path Concentrator API version + * @mc_io: Pointer to MC portal's DPCON object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @major_ver: Major version of DPCON API + * @minor_ver: Minor version of DPCON API + * + * Return: '0' on Success; Error code otherwise + */ int dpcon_get_api_version(struct fsl_mc_io *mc_io, uint32_t cmd_flags, - uint16_t *major_ver, - uint16_t *minor_ver) + uint16_t *major_ver, + uint16_t *minor_ver) { + struct dpcon_rsp_get_api_version *rsp_params; struct mc_command cmd = { 0 }; int err; + /* prepare command */ cmd.header = mc_encode_cmd_header(DPCON_CMDID_GET_API_VERSION, - cmd_flags, - 0); + cmd_flags, 0); + /* send command to mc */ err = mc_send_command(mc_io, &cmd); if (err) return err; - DPCON_RSP_GET_API_VERSION(cmd, *major_ver, *minor_ver); + /* retrieve response parameters */ + rsp_params = (struct dpcon_rsp_get_api_version *)cmd.params; + *major_ver = le16_to_cpu(rsp_params->major); + *minor_ver = le16_to_cpu(rsp_params->minor); return 0; } diff --git a/drivers/bus/fslmc/mc/dpio.c b/drivers/bus/fslmc/mc/dpio.c index 608b57a..76c5d7b 100644 --- a/drivers/bus/fslmc/mc/dpio.c +++ b/drivers/bus/fslmc/mc/dpio.c @@ -5,7 +5,7 @@ * BSD LICENSE * * Copyright 2013-2016 Freescale Semiconductor Inc. - * Copyright 2016 NXP. + * Copyright 2016-2017 NXP. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -42,11 +42,29 @@ #include #include +/** + * dpio_open() - Open a control session for the specified object + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @dpio_id: DPIO unique ID + * @token: Returned token; use in subsequent API calls + * + * This function can be used to open a control session for an + * already created object; an object may have been declared in + * the DPL or by calling the dpio_create() function. + * This function returns a unique authentication token, + * associated with the specific object ID and any MC portals + * assigned to the parent container; this token must be used in + * all subsequent commands for this specific object. + * + * Return: '0' on Success; Error code otherwise. + */ int dpio_open(struct fsl_mc_io *mc_io, uint32_t cmd_flags, int dpio_id, uint16_t *token) { + struct dpio_cmd_open *cmd_params; struct mc_command cmd = { 0 }; int err; @@ -54,7 +72,8 @@ int dpio_open(struct fsl_mc_io *mc_io, cmd.header = mc_encode_cmd_header(DPIO_CMDID_OPEN, cmd_flags, 0); - DPIO_CMD_OPEN(cmd, dpio_id); + cmd_params = (struct dpio_cmd_open *)cmd.params; + cmd_params->dpio_id = cpu_to_le32(dpio_id); /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -62,11 +81,19 @@ int dpio_open(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - *token = MC_CMD_HDR_READ_TOKEN(cmd.header); + *token = mc_cmd_hdr_read_token(&cmd); return 0; } +/** + * dpio_close() - Close the control session of the object + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPIO object + * + * Return: '0' on Success; Error code otherwise. + */ int dpio_close(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token) @@ -82,12 +109,35 @@ int dpio_close(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); } -int dpio_create(struct fsl_mc_io *mc_io, - uint16_t dprc_token, - uint32_t cmd_flags, - const struct dpio_cfg *cfg, - uint32_t *obj_id) +/** + * dpio_create() - Create the DPIO object. + * @mc_io: Pointer to MC portal's I/O object + * @dprc_token: Parent container token; '0' for default container + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @cfg: Configuration structure + * @obj_id: Returned object id + * + * Create the DPIO object, allocate required resources and + * perform required initialization. + * + * The object can be created either by declaring it in the + * DPL file, or by calling this function. + * + * The function accepts an authentication token of a parent + * container that this object should be assigned to. The token + * can be '0' so the object will be assigned to the default container. + * The newly created object can be opened with the returned + * object id and using the container's associated tokens and MC portals. + * + * Return: '0' on Success; Error code otherwise. + */ +int dpio_create(struct fsl_mc_io *mc_io, + uint16_t dprc_token, + uint32_t cmd_flags, + const struct dpio_cfg *cfg, + uint32_t *obj_id) { + struct dpio_cmd_create *cmd_params; struct mc_command cmd = { 0 }; int err; @@ -95,7 +145,11 @@ int dpio_create(struct fsl_mc_io *mc_io, cmd.header = mc_encode_cmd_header(DPIO_CMDID_CREATE, cmd_flags, dprc_token); - DPIO_CMD_CREATE(cmd, cfg); + cmd_params = (struct dpio_cmd_create *)cmd.params; + cmd_params->num_priorities = cfg->num_priorities; + dpio_set_field(cmd_params->channel_mode, + CHANNEL_MODE, + cfg->channel_mode); /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -103,28 +157,55 @@ int dpio_create(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - CMD_CREATE_RSP_GET_OBJ_ID_PARAM0(cmd, *obj_id); + *obj_id = mc_cmd_read_object_id(&cmd); return 0; } -int dpio_destroy(struct fsl_mc_io *mc_io, - uint16_t dprc_token, - uint32_t cmd_flags, - uint32_t object_id) +/** + * dpio_destroy() - Destroy the DPIO object and release all its resources. + * @mc_io: Pointer to MC portal's I/O object + * @dprc_token: Parent container token; '0' for default container + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @object_id: The object id; it must be a valid id within the container that + * created this object; + * + * The function accepts the authentication token of the parent container that + * created the object (not the one that currently owns the object). The object + * is searched within parent using the provided 'object_id'. + * All tokens to the object must be closed before calling destroy. + * + * Return: '0' on Success; Error code otherwise + */ +int dpio_destroy(struct fsl_mc_io *mc_io, + uint16_t dprc_token, + uint32_t cmd_flags, + uint32_t object_id) { + struct dpio_cmd_destroy *cmd_params; struct mc_command cmd = { 0 }; /* prepare command */ cmd.header = mc_encode_cmd_header(DPIO_CMDID_DESTROY, cmd_flags, dprc_token); + /* set object id to destroy */ - CMD_DESTROY_SET_OBJ_ID_PARAM0(cmd, object_id); + cmd_params = (struct dpio_cmd_destroy *)cmd.params; + cmd_params->dpio_id = cpu_to_le32(object_id); + /* send command to mc*/ return mc_send_command(mc_io, &cmd); } +/** + * dpio_enable() - Enable the DPIO, allow I/O portal operations. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPIO object + * + * Return: '0' on Success; Error code otherwise + */ int dpio_enable(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token) @@ -140,6 +221,14 @@ int dpio_enable(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); } +/** + * dpio_disable() - Disable the DPIO, stop any I/O portal operation. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPIO object + * + * Return: '0' on Success; Error code otherwise + */ int dpio_disable(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token) @@ -155,13 +244,24 @@ int dpio_disable(struct fsl_mc_io *mc_io, return mc_send_command(mc_io, &cmd); } +/** + * dpio_is_enabled() - Check if the DPIO is enabled. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPIO object + * @en: Returns '1' if object is enabled; '0' otherwise + * + * Return: '0' on Success; Error code otherwise. + */ int dpio_is_enabled(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, int *en) { + struct dpio_rsp_is_enabled *rsp_params; struct mc_command cmd = { 0 }; int err; + /* prepare command */ cmd.header = mc_encode_cmd_header(DPIO_CMDID_IS_ENABLED, cmd_flags, token); @@ -172,11 +272,20 @@ int dpio_is_enabled(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - DPIO_RSP_IS_ENABLED(cmd, *en); + rsp_params = (struct dpio_rsp_is_enabled *)cmd.params; + *en = dpio_get_field(rsp_params->en, ENABLE); return 0; } +/** + * dpio_reset() - Reset the DPIO, returns the object to initial state. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPIO object + * + * Return: '0' on Success; Error code otherwise. + */ int dpio_reset(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token) @@ -197,6 +306,7 @@ int dpio_get_attributes(struct fsl_mc_io *mc_io, uint16_t token, struct dpio_attr *attr) { + struct dpio_rsp_get_attr *rsp_params; struct mc_command cmd = { 0 }; int err; @@ -211,33 +321,65 @@ int dpio_get_attributes(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - DPIO_RSP_GET_ATTRIBUTES(cmd, attr); + rsp_params = (struct dpio_rsp_get_attr *)cmd.params; + attr->id = le32_to_cpu(rsp_params->id); + attr->qbman_portal_id = le16_to_cpu(rsp_params->qbman_portal_id); + attr->num_priorities = rsp_params->num_priorities; + attr->qbman_portal_ce_offset = + le64_to_cpu(rsp_params->qbman_portal_ce_offset); + attr->qbman_portal_ci_offset = + le64_to_cpu(rsp_params->qbman_portal_ci_offset); + attr->qbman_version = le32_to_cpu(rsp_params->qbman_version); + attr->clk = le32_to_cpu(rsp_params->clk); + attr->channel_mode = dpio_get_field(rsp_params->channel_mode, + ATTR_CHANNEL_MODE); return 0; } +/** + * dpio_set_stashing_destination() - Set the stashing destination. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPIO object + * @sdest: Stashing destination value + * + * Return: '0' on Success; Error code otherwise. + */ int dpio_set_stashing_destination(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, uint8_t sdest) { + struct dpio_stashing_dest *cmd_params; struct mc_command cmd = { 0 }; /* prepare command */ cmd.header = mc_encode_cmd_header(DPIO_CMDID_SET_STASHING_DEST, cmd_flags, token); - DPIO_CMD_SET_STASHING_DEST(cmd, sdest); + cmd_params = (struct dpio_stashing_dest *)cmd.params; + cmd_params->sdest = sdest; /* send command to mc*/ return mc_send_command(mc_io, &cmd); } +/** + * dpio_get_stashing_destination() - Get the stashing destination.. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPIO object + * @sdest: Returns the stashing destination value + * + * Return: '0' on Success; Error code otherwise. + */ int dpio_get_stashing_destination(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, uint8_t *sdest) { + struct dpio_stashing_dest *rsp_params; struct mc_command cmd = { 0 }; int err; @@ -252,17 +394,30 @@ int dpio_get_stashing_destination(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - DPIO_RSP_GET_STASHING_DEST(cmd, *sdest); + rsp_params = (struct dpio_stashing_dest *)cmd.params; + *sdest = rsp_params->sdest; return 0; } +/** + * dpio_add_static_dequeue_channel() - Add a static dequeue channel. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPIO object + * @dpcon_id: DPCON object ID + * @channel_index: Returned channel index to be used in qbman API + * + * Return: '0' on Success; Error code otherwise. + */ int dpio_add_static_dequeue_channel(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, int dpcon_id, uint8_t *channel_index) { + struct dpio_rsp_add_static_dequeue_channel *rsp_params; + struct dpio_cmd_static_dequeue_channel *cmd_params; struct mc_command cmd = { 0 }; int err; @@ -270,7 +425,8 @@ int dpio_add_static_dequeue_channel(struct fsl_mc_io *mc_io, cmd.header = mc_encode_cmd_header(DPIO_CMDID_ADD_STATIC_DEQUEUE_CHANNEL, cmd_flags, token); - DPIO_CMD_ADD_STATIC_DEQUEUE_CHANNEL(cmd, dpcon_id); + cmd_params = (struct dpio_cmd_static_dequeue_channel *)cmd.params; + cmd_params->dpcon_id = cpu_to_le32(dpcon_id); /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -278,16 +434,27 @@ int dpio_add_static_dequeue_channel(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - DPIO_RSP_ADD_STATIC_DEQUEUE_CHANNEL(cmd, *channel_index); + rsp_params = (struct dpio_rsp_add_static_dequeue_channel *)cmd.params; + *channel_index = rsp_params->channel_index; return 0; } +/** + * dpio_remove_static_dequeue_channel() - Remove a static dequeue channel. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPIO object + * @dpcon_id: DPCON object ID + * + * Return: '0' on Success; Error code otherwise. + */ int dpio_remove_static_dequeue_channel(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, int dpcon_id) { + struct dpio_cmd_static_dequeue_channel *cmd_params; struct mc_command cmd = { 0 }; /* prepare command */ @@ -295,17 +462,28 @@ int dpio_remove_static_dequeue_channel(struct fsl_mc_io *mc_io, DPIO_CMDID_REMOVE_STATIC_DEQUEUE_CHANNEL, cmd_flags, token); - DPIO_CMD_REMOVE_STATIC_DEQUEUE_CHANNEL(cmd, dpcon_id); + cmd_params = (struct dpio_cmd_static_dequeue_channel *)cmd.params; + cmd_params->dpcon_id = cpu_to_le32(dpcon_id); /* send command to mc*/ return mc_send_command(mc_io, &cmd); } +/** + * dpio_get_api_version() - Get Data Path I/O API version + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @major_ver: Major version of data path i/o API + * @minor_ver: Minor version of data path i/o API + * + * Return: '0' on Success; Error code otherwise. + */ int dpio_get_api_version(struct fsl_mc_io *mc_io, uint32_t cmd_flags, - uint16_t *major_ver, - uint16_t *minor_ver) + uint16_t *major_ver, + uint16_t *minor_ver) { + struct dpio_rsp_get_api_version *rsp_params; struct mc_command cmd = { 0 }; int err; @@ -317,7 +495,9 @@ int dpio_get_api_version(struct fsl_mc_io *mc_io, if (err) return err; - DPIO_RSP_GET_API_VERSION(cmd, *major_ver, *minor_ver); + rsp_params = (struct dpio_rsp_get_api_version *)cmd.params; + *major_ver = le16_to_cpu(rsp_params->major); + *minor_ver = le16_to_cpu(rsp_params->minor); return 0; } diff --git a/drivers/bus/fslmc/mc/dpmng.c b/drivers/bus/fslmc/mc/dpmng.c index dd1c3ac..f9946e8 100644 --- a/drivers/bus/fslmc/mc/dpmng.c +++ b/drivers/bus/fslmc/mc/dpmng.c @@ -5,6 +5,7 @@ * BSD LICENSE * * Copyright 2013-2015 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: @@ -41,11 +42,21 @@ #include #include +/** + * mc_get_version() - Retrieves the Management Complex firmware + * version information + * @mc_io: Pointer to opaque I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @mc_ver_info: Returned version information structure + * + * Return: '0' on Success; Error code otherwise. + */ int mc_get_version(struct fsl_mc_io *mc_io, uint32_t cmd_flags, struct mc_version *mc_ver_info) { struct mc_command cmd = { 0 }; + struct dpmng_rsp_get_version *rsp_params; int err; /* prepare command */ @@ -59,15 +70,31 @@ int mc_get_version(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - DPMNG_RSP_GET_VERSION(cmd, mc_ver_info); + rsp_params = (struct dpmng_rsp_get_version *)cmd.params; + mc_ver_info->revision = le32_to_cpu(rsp_params->revision); + mc_ver_info->major = le32_to_cpu(rsp_params->version_major); + mc_ver_info->minor = le32_to_cpu(rsp_params->version_minor); return 0; } +/** + * mc_get_soc_version() - Retrieves the Management Complex firmware + * version information + * @mc_io Pointer to opaque I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @mc_platform_info: Returned version information structure. The structure + * contains the values of SVR and PVR registers. + * Please consult platform specific reference manual + * for detailed information. + * + * Return: '0' on Success; Error code otherwise. + */ int mc_get_soc_version(struct fsl_mc_io *mc_io, uint32_t cmd_flags, struct mc_soc_version *mc_platform_info) { + struct dpmng_rsp_get_soc_version *rsp_params; struct mc_command cmd = { 0 }; int err; @@ -82,7 +109,9 @@ int mc_get_soc_version(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - DPMNG_RSP_GET_SOC_VERSION(cmd, mc_platform_info); + rsp_params = (struct dpmng_rsp_get_soc_version *)cmd.params; + mc_platform_info->svr = le32_to_cpu(rsp_params->svr); + mc_platform_info->pvr = le32_to_cpu(rsp_params->pvr); return 0; } diff --git a/drivers/bus/fslmc/mc/fsl_dpbp.h b/drivers/bus/fslmc/mc/fsl_dpbp.h index 32bb9aa..77ea6f2 100644 --- a/drivers/bus/fslmc/mc/fsl_dpbp.h +++ b/drivers/bus/fslmc/mc/fsl_dpbp.h @@ -5,7 +5,7 @@ * BSD LICENSE * * Copyright 2013-2016 Freescale Semiconductor Inc. - * Copyright 2016 NXP. + * Copyright 2016-2017 NXP. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -40,48 +40,21 @@ #ifndef __FSL_DPBP_H #define __FSL_DPBP_H -/* Data Path Buffer Pool API +/* + * Data Path Buffer Pool API * Contains initialization APIs and runtime control APIs for DPBP */ struct fsl_mc_io; -/** - * dpbp_open() - Open a control session for the specified object. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @dpbp_id: DPBP unique ID - * @token: Returned token; use in subsequent API calls - * - * This function can be used to open a control session for an - * already created object; an object may have been declared in - * the DPL or by calling the dpbp_create function. - * This function returns a unique authentication token, - * associated with the specific object ID and the specific MC - * portal; this token must be used in all subsequent commands for - * this specific object - * - * Return: '0' on Success; Error code otherwise. - */ -int dpbp_open(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - int dpbp_id, - uint16_t *token); +int dpbp_open(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + int dpbp_id, + uint16_t *token); -/** - * dpbp_close() - Close the control session of the object - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPBP object - * - * After this function is called, no further operations are - * allowed on the object without opening a new control session. - * - * Return: '0' on Success; Error code otherwise. - */ -int dpbp_close(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +int dpbp_close(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token); /** * struct dpbp_cfg - Structure representing DPBP configuration @@ -91,98 +64,33 @@ struct dpbp_cfg { uint32_t options; }; -/** - * dpbp_create() - Create the DPBP object. - * @mc_io: Pointer to MC portal's I/O object - * @dprc_token: Parent container token; '0' for default container - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @cfg: Configuration structure - * @obj_id: returned object id - * - * Create the DPBP object, allocate required resources and - * perform required initialization. - * - * The object can be created either by declaring it in the - * DPL file, or by calling this function. - * - * The function accepts an authentication token of a parent - * container that this object should be assigned to. The token - * can be '0' so the object will be assigned to the default container. - * The newly created object can be opened with the returned - * object id and using the container's associated tokens and MC portals. - * - * Return: '0' on Success; Error code otherwise. - */ -int dpbp_create(struct fsl_mc_io *mc_io, - uint16_t dprc_token, - uint32_t cmd_flags, - const struct dpbp_cfg *cfg, - uint32_t *obj_id); +int dpbp_create(struct fsl_mc_io *mc_io, + uint16_t dprc_token, + uint32_t cmd_flags, + const struct dpbp_cfg *cfg, + uint32_t *obj_id); -/** - * dpbp_destroy() - Destroy the DPBP object and release all its resources. - * @dprc_token: Parent container token; '0' for default container - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @object_id: The object id; it must be a valid id within the container that - * created this object; - * - * Return: '0' on Success; error code otherwise. - */ -int dpbp_destroy(struct fsl_mc_io *mc_io, - uint16_t dprc_token, - uint32_t cmd_flags, - uint32_t object_id); +int dpbp_destroy(struct fsl_mc_io *mc_io, + uint16_t dprc_token, + uint32_t cmd_flags, + uint32_t obj_id); -/** - * dpbp_enable() - Enable the DPBP. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPBP object - * - * Return: '0' on Success; Error code otherwise. - */ -int dpbp_enable(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +int dpbp_enable(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token); -/** - * dpbp_disable() - Disable the DPBP. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPBP object - * - * Return: '0' on Success; Error code otherwise. - */ -int dpbp_disable(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +int dpbp_disable(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token); -/** - * dpbp_is_enabled() - Check if the DPBP is enabled. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPBP object - * @en: Returns '1' if object is enabled; '0' otherwise - * - * Return: '0' on Success; Error code otherwise. - */ -int dpbp_is_enabled(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - int *en); +int dpbp_is_enabled(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + int *en); -/** - * dpbp_reset() - Reset the DPBP, returns the object to initial state. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPBP object - * - * Return: '0' on Success; Error code otherwise. - */ -int dpbp_reset(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +int dpbp_reset(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token); /** * struct dpbp_attr - Structure representing DPBP attributes @@ -195,44 +103,23 @@ struct dpbp_attr { uint16_t bpid; }; +int dpbp_get_attributes(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + struct dpbp_attr *attr); + /** - * dpbp_get_attributes - Retrieve DPBP attributes. - * - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPBP object - * @attr: Returned object's attributes - * - * Return: '0' on Success; Error code otherwise. + * DPBP notifications options */ -int dpbp_get_attributes(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - struct dpbp_attr *attr); /** - * dpbp_get_api_version() - Get buffer pool API version - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @major_ver: Major version of data path buffer pool API - * @minor_ver: Minor version of data path buffer pool API - * - * Return: '0' on Success; Error code otherwise. + * BPSCN write will attempt to allocate into a cache (coherent write) */ int dpbp_get_api_version(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t *major_ver, uint16_t *minor_ver); -/** - * dpbp_get_num_free_bufs() - Get number of free buffers in the buffer pool - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPBP object - * @num_free_bufs: Number of free buffers - * - * Return: '0' on Success; Error code otherwise. - */ int dpbp_get_num_free_bufs(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token, diff --git a/drivers/bus/fslmc/mc/fsl_dpbp_cmd.h b/drivers/bus/fslmc/mc/fsl_dpbp_cmd.h index f0ee65a..ce38c79 100644 --- a/drivers/bus/fslmc/mc/fsl_dpbp_cmd.h +++ b/drivers/bus/fslmc/mc/fsl_dpbp_cmd.h @@ -5,7 +5,7 @@ * BSD LICENSE * * Copyright 2013-2016 Freescale Semiconductor Inc. - * Copyright 2016 NXP. + * Copyright 2016-2017 NXP. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -42,47 +42,90 @@ /* DPBP Version */ #define DPBP_VER_MAJOR 3 -#define DPBP_VER_MINOR 2 +#define DPBP_VER_MINOR 3 + +/* Command versioning */ +#define DPBP_CMD_BASE_VERSION 1 +#define DPBP_CMD_ID_OFFSET 4 + +#define DPBP_CMD(id) ((id << DPBP_CMD_ID_OFFSET) | DPBP_CMD_BASE_VERSION) /* Command IDs */ -#define DPBP_CMDID_CLOSE 0x8001 -#define DPBP_CMDID_OPEN 0x8041 -#define DPBP_CMDID_CREATE 0x9041 -#define DPBP_CMDID_DESTROY 0x9841 -#define DPBP_CMDID_GET_API_VERSION 0xa041 - -#define DPBP_CMDID_ENABLE 0x0021 -#define DPBP_CMDID_DISABLE 0x0031 -#define DPBP_CMDID_GET_ATTR 0x0041 -#define DPBP_CMDID_RESET 0x0051 -#define DPBP_CMDID_IS_ENABLED 0x0061 - -#define DPBP_CMDID_GET_FREE_BUFFERS_NUM 0x1b21 - -/* cmd, param, offset, width, type, arg_name */ -#define DPBP_CMD_OPEN(cmd, dpbp_id) \ - MC_CMD_OP(cmd, 0, 0, 32, int, dpbp_id) - -/* cmd, param, offset, width, type, arg_name */ -#define DPBP_RSP_IS_ENABLED(cmd, en) \ - MC_RSP_OP(cmd, 0, 0, 1, int, en) - -/* cmd, param, offset, width, type, arg_name */ -#define DPBP_RSP_GET_ATTRIBUTES(cmd, attr) \ -do { \ - MC_RSP_OP(cmd, 0, 16, 16, uint16_t, (attr)->bpid); \ - MC_RSP_OP(cmd, 0, 32, 32, int, (attr)->id);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPBP_RSP_GET_API_VERSION(cmd, major, minor) \ -do { \ - MC_RSP_OP(cmd, 0, 0, 16, uint16_t, major);\ - MC_RSP_OP(cmd, 0, 16, 16, uint16_t, minor);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPBP_RSP_GET_NUM_FREE_BUFS(cmd, num_free_bufs) \ - MC_RSP_OP(cmd, 0, 0, 32, uint32_t, num_free_bufs) +#define DPBP_CMDID_CLOSE DPBP_CMD(0x800) +#define DPBP_CMDID_OPEN DPBP_CMD(0x804) +#define DPBP_CMDID_CREATE DPBP_CMD(0x904) +#define DPBP_CMDID_DESTROY DPBP_CMD(0x984) +#define DPBP_CMDID_GET_API_VERSION DPBP_CMD(0xa04) + +#define DPBP_CMDID_ENABLE DPBP_CMD(0x002) +#define DPBP_CMDID_DISABLE DPBP_CMD(0x003) +#define DPBP_CMDID_GET_ATTR DPBP_CMD(0x004) +#define DPBP_CMDID_RESET DPBP_CMD(0x005) +#define DPBP_CMDID_IS_ENABLED DPBP_CMD(0x006) + +#define DPBP_CMDID_SET_IRQ_ENABLE DPBP_CMD(0x012) +#define DPBP_CMDID_GET_IRQ_ENABLE DPBP_CMD(0x013) +#define DPBP_CMDID_SET_IRQ_MASK DPBP_CMD(0x014) +#define DPBP_CMDID_GET_IRQ_MASK DPBP_CMD(0x015) +#define DPBP_CMDID_GET_IRQ_STATUS DPBP_CMD(0x016) +#define DPBP_CMDID_CLEAR_IRQ_STATUS DPBP_CMD(0x017) + +#define DPBP_CMDID_SET_NOTIFICATIONS DPBP_CMD(0x1b0) +#define DPBP_CMDID_GET_NOTIFICATIONS DPBP_CMD(0x1b1) + +#define DPBP_CMDID_GET_FREE_BUFFERS_NUM DPBP_CMD(0x1b2) + +#pragma pack(push, 1) +struct dpbp_cmd_open { + uint32_t dpbp_id; +}; + +struct dpbp_cmd_destroy { + uint32_t object_id; +}; + +#define DPBP_ENABLE 0x1 + +struct dpbp_rsp_is_enabled { + uint8_t enabled; +}; + +struct dpbp_rsp_get_attributes { + uint16_t pad; + uint16_t bpid; + uint32_t id; +}; + +struct dpbp_cmd_set_notifications { + uint32_t depletion_entry; + uint32_t depletion_exit; + uint32_t surplus_entry; + uint32_t surplus_exit; + uint16_t options; + uint16_t pad[3]; + uint64_t message_ctx; + uint64_t message_iova; +}; + +struct dpbp_rsp_get_notifications { + uint32_t depletion_entry; + uint32_t depletion_exit; + uint32_t surplus_entry; + uint32_t surplus_exit; + uint16_t options; + uint16_t pad[3]; + uint64_t message_ctx; + uint64_t message_iova; +}; + +struct dpbp_rsp_get_api_version { + uint16_t major; + uint16_t minor; +}; + +struct dpbp_rsp_get_num_free_bufs { + uint32_t num_free_bufs; +}; +#pragma pack(pop) #endif /* _FSL_DPBP_CMD_H */ diff --git a/drivers/bus/fslmc/mc/fsl_dpci.h b/drivers/bus/fslmc/mc/fsl_dpci.h index 1e155dd..f4aa6e5 100644 --- a/drivers/bus/fslmc/mc/fsl_dpci.h +++ b/drivers/bus/fslmc/mc/fsl_dpci.h @@ -62,42 +62,14 @@ struct fsl_mc_io; */ #define DPCI_ALL_QUEUES (uint8_t)(-1) -/** - * dpci_open() - Open a control session for the specified object - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @dpci_id: DPCI unique ID - * @token: Returned token; use in subsequent API calls - * - * This function can be used to open a control session for an - * already created object; an object may have been declared in - * the DPL or by calling the dpci_create() function. - * This function returns a unique authentication token, - * associated with the specific object ID and the specific MC - * portal; this token must be used in all subsequent commands for - * this specific object. - * - * Return: '0' on Success; Error code otherwise. - */ int dpci_open(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - int dpci_id, - uint16_t *token); + uint32_t cmd_flags, + int dpci_id, + uint16_t *token); -/** - * dpci_close() - Close the control session of the object - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPCI object - * - * After this function is called, no further operations are - * allowed on the object without opening a new control session. - * - * Return: '0' on Success; Error code otherwise. - */ -int dpci_close(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +int dpci_close(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token); /** * Enable the Order Restoration support @@ -124,107 +96,37 @@ struct dpci_cfg { uint8_t num_of_priorities; }; -/** - * dpci_create() - Create the DPCI object. - * @mc_io: Pointer to MC portal's I/O object - * @dprc_token: Parent container token; '0' for default container - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @cfg: Configuration structure - * @obj_id: returned object id - * - * Create the DPCI object, allocate required resources and perform required - * initialization. - * - * The object can be created either by declaring it in the - * DPL file, or by calling this function. - * - * The function accepts an authentication token of a parent - * container that this object should be assigned to. The token - * can be '0' so the object will be assigned to the default container. - * The newly created object can be opened with the returned - * object id and using the container's associated tokens and MC portals. - * - * Return: '0' on Success; Error code otherwise. - */ -int dpci_create(struct fsl_mc_io *mc_io, - uint16_t dprc_token, - uint32_t cmd_flags, - const struct dpci_cfg *cfg, - uint32_t *obj_id); +int dpci_create(struct fsl_mc_io *mc_io, + uint16_t dprc_token, + uint32_t cmd_flags, + const struct dpci_cfg *cfg, + uint32_t *obj_id); -/** - * dpci_destroy() - Destroy the DPCI object and release all its resources. - * @mc_io: Pointer to MC portal's I/O object - * @dprc_token: Parent container token; '0' for default container - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @object_id: The object id; it must be a valid id within the container that - * created this object; - * - * The function accepts the authentication token of the parent container that - * created the object (not the one that currently owns the object). The object - * is searched within parent using the provided 'object_id'. - * All tokens to the object must be closed before calling destroy. - * - * Return: '0' on Success; error code otherwise. - */ -int dpci_destroy(struct fsl_mc_io *mc_io, - uint16_t dprc_token, - uint32_t cmd_flags, - uint32_t object_id); +int dpci_destroy(struct fsl_mc_io *mc_io, + uint16_t dprc_token, + uint32_t cmd_flags, + uint32_t object_id); -/** - * dpci_enable() - Enable the DPCI, allow sending and receiving frames. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPCI object - * - * Return: '0' on Success; Error code otherwise. - */ -int dpci_enable(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +int dpci_enable(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token); -/** - * dpci_disable() - Disable the DPCI, stop sending and receiving frames. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPCI object - * - * Return: '0' on Success; Error code otherwise. - */ -int dpci_disable(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +int dpci_disable(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token); -/** - * dpci_is_enabled() - Check if the DPCI is enabled. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPCI object - * @en: Returns '1' if object is enabled; '0' otherwise - * - * Return: '0' on Success; Error code otherwise. - */ -int dpci_is_enabled(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - int *en); +int dpci_is_enabled(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + int *en); -/** - * dpci_reset() - Reset the DPCI, returns the object to initial state. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPCI object - * - * Return: '0' on Success; Error code otherwise. - */ int dpci_reset(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); + uint32_t cmd_flags, + uint16_t token); /** * struct dpci_attr - Structure representing DPCI attributes - * @id: DPCI object ID + * @id: DPCI object ID * @num_of_priorities: Number of receive priorities */ struct dpci_attr { @@ -232,19 +134,10 @@ struct dpci_attr { uint8_t num_of_priorities; }; -/** - * dpci_get_attributes() - Retrieve DPCI attributes. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPCI object - * @attr: Returned object's attributes - * - * Return: '0' on Success; Error code otherwise. - */ -int dpci_get_attributes(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - struct dpci_attr *attr); +int dpci_get_attributes(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + struct dpci_attr *attr); /** * enum dpci_dest - DPCI destination types @@ -310,24 +203,11 @@ struct dpci_rx_queue_cfg { struct dpci_dest_cfg dest_cfg; }; -/** - * dpci_set_rx_queue() - Set Rx queue configuration - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPCI object - * @priority: Select the queue relative to number of - * priorities configured at DPCI creation; use - * DPCI_ALL_QUEUES to configure all Rx queues - * identically. - * @cfg: Rx queue configuration - * - * Return: '0' on Success; Error code otherwise. - */ -int dpci_set_rx_queue(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint8_t priority, - const struct dpci_rx_queue_cfg *cfg); +int dpci_set_rx_queue(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint8_t priority, + const struct dpci_rx_queue_cfg *cfg); /** * struct dpci_rx_queue_attr - Structure representing Rx queue attributes @@ -337,26 +217,15 @@ int dpci_set_rx_queue(struct fsl_mc_io *mc_io, * @fqid: Virtual FQID value to be used for dequeue operations */ struct dpci_rx_queue_attr { - uint64_t user_ctx; - struct dpci_dest_cfg dest_cfg; - uint32_t fqid; + uint64_t user_ctx; + struct dpci_dest_cfg dest_cfg; + uint32_t fqid; }; -/** - * dpci_get_rx_queue() - Retrieve Rx queue attributes. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPCI object - * @priority: Select the queue relative to number of - * priorities configured at DPCI creation - * @attr: Returned Rx queue attributes - * - * Return: '0' on Success; Error code otherwise. - */ -int dpci_get_rx_queue(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint8_t priority, +int dpci_get_rx_queue(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint8_t priority, struct dpci_rx_queue_attr *attr); /** @@ -370,35 +239,15 @@ struct dpci_tx_queue_attr { uint32_t fqid; }; -/** - * dpci_get_tx_queue() - Retrieve Tx queue attributes. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPCI object - * @priority: Select the queue relative to number of - * priorities of the peer DPCI object - * @attr: Returned Tx queue attributes - * - * Return: '0' on Success; Error code otherwise. - */ -int dpci_get_tx_queue(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint8_t priority, - struct dpci_tx_queue_attr *attr); +int dpci_get_tx_queue(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint8_t priority, + struct dpci_tx_queue_attr *attr); -/** - * dpci_get_api_version() - Get communication interface API version - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @major_ver: Major version of data path communication interface API - * @minor_ver: Minor version of data path communication interface API - * - * Return: '0' on Success; Error code otherwise. - */ -int dpci_get_api_version(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t *major_ver, - uint16_t *minor_ver); +int dpci_get_api_version(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t *major_ver, + uint16_t *minor_ver); #endif /* __FSL_DPCI_H */ diff --git a/drivers/bus/fslmc/mc/fsl_dpci_cmd.h b/drivers/bus/fslmc/mc/fsl_dpci_cmd.h index 6d4e273..73a551a 100644 --- a/drivers/bus/fslmc/mc/fsl_dpci_cmd.h +++ b/drivers/bus/fslmc/mc/fsl_dpci_cmd.h @@ -40,108 +40,126 @@ #define _FSL_DPCI_CMD_H /* DPCI Version */ -#define DPCI_VER_MAJOR 3 -#define DPCI_VER_MINOR 3 +#define DPCI_VER_MAJOR 3 +#define DPCI_VER_MINOR 3 -/* Command IDs */ -#define DPCI_CMDID_CLOSE 0x8001 -#define DPCI_CMDID_OPEN 0x8071 -#define DPCI_CMDID_CREATE 0x9072 -#define DPCI_CMDID_DESTROY 0x9871 -#define DPCI_CMDID_GET_API_VERSION 0xa071 - -#define DPCI_CMDID_ENABLE 0x0021 -#define DPCI_CMDID_DISABLE 0x0031 -#define DPCI_CMDID_GET_ATTR 0x0041 -#define DPCI_CMDID_RESET 0x0051 -#define DPCI_CMDID_IS_ENABLED 0x0061 - -#define DPCI_CMDID_SET_IRQ_ENABLE 0x0121 -#define DPCI_CMDID_GET_IRQ_ENABLE 0x0131 -#define DPCI_CMDID_SET_IRQ_MASK 0x0141 -#define DPCI_CMDID_GET_IRQ_MASK 0x0151 -#define DPCI_CMDID_GET_IRQ_STATUS 0x0161 -#define DPCI_CMDID_CLEAR_IRQ_STATUS 0x0171 - -#define DPCI_CMDID_SET_RX_QUEUE 0x0e01 -#define DPCI_CMDID_GET_LINK_STATE 0x0e11 -#define DPCI_CMDID_GET_PEER_ATTR 0x0e21 -#define DPCI_CMDID_GET_RX_QUEUE 0x0e31 -#define DPCI_CMDID_GET_TX_QUEUE 0x0e41 -#define DPCI_CMDID_SET_OPR 0x0e51 -#define DPCI_CMDID_GET_OPR 0x0e61 - -/* cmd, param, offset, width, type, arg_name */ -#define DPCI_CMD_OPEN(cmd, dpci_id) \ - MC_CMD_OP(cmd, 0, 0, 32, int, dpci_id) - -/* cmd, param, offset, width, type, arg_name */ -#define DPCI_CMD_CREATE(cmd, cfg) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 8, uint8_t, cfg->num_of_priorities);\ - MC_CMD_OP(cmd, 2, 0, 32, uint32_t, cfg->options);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPCI_RSP_IS_ENABLED(cmd, en) \ - MC_RSP_OP(cmd, 0, 0, 1, int, en) - -/* cmd, param, offset, width, type, arg_name */ -#define DPCI_RSP_GET_ATTRIBUTES(cmd, attr) \ -do { \ - MC_RSP_OP(cmd, 0, 0, 32, int, (attr)->id);\ - MC_RSP_OP(cmd, 0, 48, 8, uint8_t, (attr)->num_of_priorities);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPCI_RSP_GET_PEER_ATTR(cmd, attr) \ -do { \ - MC_RSP_OP(cmd, 0, 0, 32, int, attr->peer_id);\ - MC_RSP_OP(cmd, 1, 0, 8, uint8_t, attr->num_of_priorities);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPCI_RSP_GET_LINK_STATE(cmd, up) \ - MC_RSP_OP(cmd, 0, 0, 1, int, up) - -/* cmd, param, offset, width, type, arg_name */ -#define DPCI_CMD_SET_RX_QUEUE(cmd, priority, cfg) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 32, int, cfg->dest_cfg.dest_id);\ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->dest_cfg.priority);\ - MC_CMD_OP(cmd, 0, 40, 8, uint8_t, priority);\ - MC_CMD_OP(cmd, 0, 48, 4, enum dpci_dest, cfg->dest_cfg.dest_type);\ - MC_CMD_OP(cmd, 1, 0, 64, uint64_t, cfg->user_ctx);\ - MC_CMD_OP(cmd, 2, 0, 32, uint32_t, cfg->options);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPCI_CMD_GET_RX_QUEUE(cmd, priority) \ - MC_CMD_OP(cmd, 0, 40, 8, uint8_t, priority) - -/* cmd, param, offset, width, type, arg_name */ -#define DPCI_RSP_GET_RX_QUEUE(cmd, attr) \ -do { \ - MC_RSP_OP(cmd, 0, 0, 32, int, attr->dest_cfg.dest_id);\ - MC_RSP_OP(cmd, 0, 32, 8, uint8_t, attr->dest_cfg.priority);\ - MC_RSP_OP(cmd, 0, 48, 4, enum dpci_dest, attr->dest_cfg.dest_type);\ - MC_RSP_OP(cmd, 1, 0, 8, uint64_t, attr->user_ctx);\ - MC_RSP_OP(cmd, 2, 0, 32, uint32_t, attr->fqid);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPCI_CMD_GET_TX_QUEUE(cmd, priority) \ - MC_CMD_OP(cmd, 0, 40, 8, uint8_t, priority) - -/* cmd, param, offset, width, type, arg_name */ -#define DPCI_RSP_GET_TX_QUEUE(cmd, attr) \ - MC_RSP_OP(cmd, 0, 32, 32, uint32_t, attr->fqid) - -/* cmd, param, offset, width, type, arg_name */ -#define DPCI_RSP_GET_API_VERSION(cmd, major, minor) \ -do { \ - MC_RSP_OP(cmd, 0, 0, 16, uint16_t, major);\ - MC_RSP_OP(cmd, 0, 16, 16, uint16_t, minor);\ -} while (0) +#define DPCI_CMD_BASE_VERSION 1 +#define DPCI_CMD_BASE_VERSION_V2 2 +#define DPCI_CMD_ID_OFFSET 4 + +#define DPCI_CMD_V1(id) ((id << DPCI_CMD_ID_OFFSET) | DPCI_CMD_BASE_VERSION) +#define DPCI_CMD_V2(id) ((id << DPCI_CMD_ID_OFFSET) | DPCI_CMD_BASE_VERSION_V2) +/* Command IDs */ +#define DPCI_CMDID_CLOSE DPCI_CMD_V1(0x800) +#define DPCI_CMDID_OPEN DPCI_CMD_V1(0x807) +#define DPCI_CMDID_CREATE DPCI_CMD_V2(0x907) +#define DPCI_CMDID_DESTROY DPCI_CMD_V1(0x987) +#define DPCI_CMDID_GET_API_VERSION DPCI_CMD_V1(0xa07) + +#define DPCI_CMDID_ENABLE DPCI_CMD_V1(0x002) +#define DPCI_CMDID_DISABLE DPCI_CMD_V1(0x003) +#define DPCI_CMDID_GET_ATTR DPCI_CMD_V1(0x004) +#define DPCI_CMDID_RESET DPCI_CMD_V1(0x005) +#define DPCI_CMDID_IS_ENABLED DPCI_CMD_V1(0x006) + +#define DPCI_CMDID_SET_RX_QUEUE DPCI_CMD_V1(0x0e0) +#define DPCI_CMDID_GET_LINK_STATE DPCI_CMD_V1(0x0e1) +#define DPCI_CMDID_GET_PEER_ATTR DPCI_CMD_V1(0x0e2) +#define DPCI_CMDID_GET_RX_QUEUE DPCI_CMD_V1(0x0e3) +#define DPCI_CMDID_GET_TX_QUEUE DPCI_CMD_V1(0x0e4) + +/* Macros for accessing command fields smaller than 1byte */ +#define DPCI_MASK(field) \ + GENMASK(DPCI_##field##_SHIFT + DPCI_##field##_SIZE - 1, \ + DPCI_##field##_SHIFT) +#define dpci_set_field(var, field, val) \ + ((var) |= (((val) << DPCI_##field##_SHIFT) & DPCI_MASK(field))) +#define dpci_get_field(var, field) \ + (((var) & DPCI_MASK(field)) >> DPCI_##field##_SHIFT) + +#pragma pack(push, 1) +struct dpci_cmd_open { + uint32_t dpci_id; +}; + +struct dpci_cmd_create { + uint8_t num_of_priorities; + uint8_t pad[15]; + uint32_t options; +}; + +struct dpci_cmd_destroy { + uint32_t dpci_id; +}; + +#define DPCI_ENABLE_SHIFT 0 +#define DPCI_ENABLE_SIZE 1 + +struct dpci_rsp_is_enabled { + /* only the LSB bit */ + uint8_t en; +}; + +struct dpci_rsp_get_attr { + uint32_t id; + uint16_t pad; + uint8_t num_of_priorities; +}; + +struct dpci_rsp_get_peer_attr { + uint32_t id; + uint32_t pad; + uint8_t num_of_priorities; +}; + +#define DPCI_UP_SHIFT 0 +#define DPCI_UP_SIZE 1 + +struct dpci_rsp_get_link_state { + /* only the LSB bit */ + uint8_t up; +}; + +#define DPCI_DEST_TYPE_SHIFT 0 +#define DPCI_DEST_TYPE_SIZE 4 + +struct dpci_cmd_set_rx_queue { + uint32_t dest_id; + uint8_t dest_priority; + uint8_t priority; + /* from LSB: dest_type:4 */ + uint8_t dest_type; + uint8_t pad; + uint64_t user_ctx; + uint32_t options; +}; + +struct dpci_cmd_get_queue { + uint8_t pad[5]; + uint8_t priority; +}; + +struct dpci_rsp_get_rx_queue { + uint32_t dest_id; + uint8_t dest_priority; + uint8_t pad; + /* from LSB: dest_type:4 */ + uint8_t dest_type; + uint8_t pad1; + uint64_t user_ctx; + uint32_t fqid; +}; + +struct dpci_rsp_get_tx_queue { + uint32_t pad; + uint32_t fqid; +}; + +struct dpci_rsp_get_api_version { + uint16_t major; + uint16_t minor; +}; + +#pragma pack(pop) #endif /* _FSL_DPCI_CMD_H */ diff --git a/drivers/bus/fslmc/mc/fsl_dpcon.h b/drivers/bus/fslmc/mc/fsl_dpcon.h index 0ed9db5..1da807f 100644 --- a/drivers/bus/fslmc/mc/fsl_dpcon.h +++ b/drivers/bus/fslmc/mc/fsl_dpcon.h @@ -52,42 +52,14 @@ struct fsl_mc_io; */ #define DPCON_INVALID_DPIO_ID (int)(-1) -/** - * dpcon_open() - Open a control session for the specified object - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @dpcon_id: DPCON unique ID - * @token: Returned token; use in subsequent API calls - * - * This function can be used to open a control session for an - * already created object; an object may have been declared in - * the DPL or by calling the dpcon_create() function. - * This function returns a unique authentication token, - * associated with the specific object ID and the specific MC - * portal; this token must be used in all subsequent commands for - * this specific object. - * - * Return: '0' on Success; Error code otherwise. - */ int dpcon_open(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - int dpcon_id, - uint16_t *token); + uint32_t cmd_flags, + int dpcon_id, + uint16_t *token); -/** - * dpcon_close() - Close the control session of the object - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPCON object - * - * After this function is called, no further operations are - * allowed on the object without opening a new control session. - * - * Return: '0' on Success; Error code otherwise. - */ -int dpcon_close(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +int dpcon_close(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token); /** * struct dpcon_cfg - Structure representing DPCON configuration @@ -97,109 +69,39 @@ struct dpcon_cfg { uint8_t num_priorities; }; -/** - * dpcon_create() - Create the DPCON object. - * @mc_io: Pointer to MC portal's I/O object - * @dprc_token: Parent container token; '0' for default container - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @cfg: Configuration structure - * @obj_id: returned object id - * - * Create the DPCON object, allocate required resources and - * perform required initialization. - * - * The object can be created either by declaring it in the - * DPL file, or by calling this function. - * - * The function accepts an authentication token of a parent - * container that this object should be assigned to. The token - * can be '0' so the object will be assigned to the default container. - * The newly created object can be opened with the returned - * object id and using the container's associated tokens and MC portals. - * - * Return: '0' on Success; Error code otherwise. - */ -int dpcon_create(struct fsl_mc_io *mc_io, - uint16_t dprc_token, - uint32_t cmd_flags, - const struct dpcon_cfg *cfg, - uint32_t *obj_id); +int dpcon_create(struct fsl_mc_io *mc_io, + uint16_t dprc_token, + uint32_t cmd_flags, + const struct dpcon_cfg *cfg, + uint32_t *obj_id); -/** - * dpcon_destroy() - Destroy the DPCON object and release all its resources. - * @mc_io: Pointer to MC portal's I/O object - * @dprc_token: Parent container token; '0' for default container - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @object_id: The object id; it must be a valid id within the container that - * created this object; - * - * The function accepts the authentication token of the parent container that - * created the object (not the one that currently owns the object). The object - * is searched within parent using the provided 'object_id'. - * All tokens to the object must be closed before calling destroy. - * - * Return: '0' on Success; error code otherwise. - */ -int dpcon_destroy(struct fsl_mc_io *mc_io, - uint16_t dprc_token, - uint32_t cmd_flags, - uint32_t object_id); +int dpcon_destroy(struct fsl_mc_io *mc_io, + uint16_t dprc_token, + uint32_t cmd_flags, + uint32_t obj_id); -/** - * dpcon_enable() - Enable the DPCON - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPCON object - * - * Return: '0' on Success; Error code otherwise - */ -int dpcon_enable(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +int dpcon_enable(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token); -/** - * dpcon_disable() - Disable the DPCON - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPCON object - * - * Return: '0' on Success; Error code otherwise - */ -int dpcon_disable(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +int dpcon_disable(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token); -/** - * dpcon_is_enabled() - Check if the DPCON is enabled. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPCON object - * @en: Returns '1' if object is enabled; '0' otherwise - * - * Return: '0' on Success; Error code otherwise. - */ -int dpcon_is_enabled(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - int *en); +int dpcon_is_enabled(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + int *en); -/** - * dpcon_reset() - Reset the DPCON, returns the object to initial state. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPCON object - * - * Return: '0' on Success; Error code otherwise. - */ -int dpcon_reset(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +int dpcon_reset(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token); /** * struct dpcon_attr - Structure representing DPCON attributes - * @id: DPCON object ID - * @qbman_ch_id: Channel ID to be used by dequeue operation - * @num_priorities: Number of priorities for the DPCON channel (1-8) + * @id: DPCON object ID + * @qbman_ch_id: Channel ID to be used by dequeue operation + * @num_priorities: Number of priorities for the DPCON channel (1-8) */ struct dpcon_attr { int id; @@ -207,29 +109,11 @@ struct dpcon_attr { uint8_t num_priorities; }; -/** - * dpcon_get_attributes() - Retrieve DPCON attributes. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPCON object - * @attr: Object's attributes - * - * Return: '0' on Success; Error code otherwise. - */ -int dpcon_get_attributes(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - struct dpcon_attr *attr); +int dpcon_get_attributes(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + struct dpcon_attr *attr); -/** - * dpcon_get_api_version() - Get Data Path Concentrator API version - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @major_ver: Major version of data path concentrator API - * @minor_ver: Minor version of data path concentrator API - * - * Return: '0' on Success; Error code otherwise. - */ int dpcon_get_api_version(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t *major_ver, diff --git a/drivers/bus/fslmc/mc/fsl_dpcon_cmd.h b/drivers/bus/fslmc/mc/fsl_dpcon_cmd.h index f7f7690..4d0522c 100644 --- a/drivers/bus/fslmc/mc/fsl_dpcon_cmd.h +++ b/drivers/bus/fslmc/mc/fsl_dpcon_cmd.h @@ -5,6 +5,7 @@ * BSD LICENSE * * Copyright 2013-2016 Freescale Semiconductor Inc. + * Copyright 2016-2017 NXP. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -40,136 +41,68 @@ #define _FSL_DPCON_CMD_H /* DPCON Version */ -#define DPCON_VER_MAJOR 3 -#define DPCON_VER_MINOR 2 +#define DPCON_VER_MAJOR 3 +#define DPCON_VER_MINOR 3 -/* Command IDs */ -#define DPCON_CMDID_CLOSE ((0x800 << 4) | (0x1)) -#define DPCON_CMDID_OPEN ((0x808 << 4) | (0x1)) -#define DPCON_CMDID_CREATE ((0x908 << 4) | (0x1)) -#define DPCON_CMDID_DESTROY ((0x988 << 4) | (0x1)) -#define DPCON_CMDID_GET_API_VERSION ((0xa08 << 4) | (0x1)) - -#define DPCON_CMDID_ENABLE ((0x002 << 4) | (0x1)) -#define DPCON_CMDID_DISABLE ((0x003 << 4) | (0x1)) -#define DPCON_CMDID_GET_ATTR ((0x004 << 4) | (0x1)) -#define DPCON_CMDID_RESET ((0x005 << 4) | (0x1)) -#define DPCON_CMDID_IS_ENABLED ((0x006 << 4) | (0x1)) - -#define DPCON_CMDID_SET_IRQ ((0x010 << 4) | (0x1)) -#define DPCON_CMDID_GET_IRQ ((0x011 << 4) | (0x1)) -#define DPCON_CMDID_SET_IRQ_ENABLE ((0x012 << 4) | (0x1)) -#define DPCON_CMDID_GET_IRQ_ENABLE ((0x013 << 4) | (0x1)) -#define DPCON_CMDID_SET_IRQ_MASK ((0x014 << 4) | (0x1)) -#define DPCON_CMDID_GET_IRQ_MASK ((0x015 << 4) | (0x1)) -#define DPCON_CMDID_GET_IRQ_STATUS ((0x016 << 4) | (0x1)) -#define DPCON_CMDID_CLEAR_IRQ_STATUS ((0x017 << 4) | (0x1)) - -#define DPCON_CMDID_SET_NOTIFICATION ((0x100 << 4) | (0x1)) - -/* cmd, param, offset, width, type, arg_name */ -#define DPCON_CMD_OPEN(cmd, dpcon_id) \ - MC_CMD_OP(cmd, 0, 0, 32, int, dpcon_id) - -/* cmd, param, offset, width, type, arg_name */ -#define DPCON_CMD_CREATE(cmd, cfg) \ - MC_CMD_OP(cmd, 0, 0, 8, uint8_t, cfg->num_priorities) - -/* cmd, param, offset, width, type, arg_name */ -#define DPCON_RSP_IS_ENABLED(cmd, en) \ - MC_RSP_OP(cmd, 0, 0, 1, int, en) - -/* cmd, param, offset, width, type, arg_name */ -#define DPCON_CMD_SET_IRQ(cmd, irq_index, irq_cfg) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 8, uint8_t, irq_index);\ - MC_CMD_OP(cmd, 0, 32, 32, uint32_t, irq_cfg->val);\ - MC_CMD_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr);\ - MC_CMD_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPCON_CMD_GET_IRQ(cmd, irq_index) \ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index) - -/* cmd, param, offset, width, type, arg_name */ -#define DPCON_RSP_GET_IRQ(cmd, type, irq_cfg) \ -do { \ - MC_RSP_OP(cmd, 0, 0, 32, uint32_t, irq_cfg->val);\ - MC_RSP_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr);\ - MC_RSP_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \ - MC_RSP_OP(cmd, 2, 32, 32, int, type);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPCON_CMD_SET_IRQ_ENABLE(cmd, irq_index, en) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 8, uint8_t, en); \ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPCON_CMD_GET_IRQ_ENABLE(cmd, irq_index) \ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index) - -/* cmd, param, offset, width, type, arg_name */ -#define DPCON_RSP_GET_IRQ_ENABLE(cmd, en) \ - MC_RSP_OP(cmd, 0, 0, 8, uint8_t, en) - -/* cmd, param, offset, width, type, arg_name */ -#define DPCON_CMD_SET_IRQ_MASK(cmd, irq_index, mask) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 32, uint32_t, mask); \ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPCON_CMD_GET_IRQ_MASK(cmd, irq_index) \ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index) - -/* cmd, param, offset, width, type, arg_name */ -#define DPCON_RSP_GET_IRQ_MASK(cmd, mask) \ - MC_RSP_OP(cmd, 0, 0, 32, uint32_t, mask) - -/* cmd, param, offset, width, type, arg_name */ -#define DPCON_CMD_GET_IRQ_STATUS(cmd, irq_index, status) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status);\ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPCON_RSP_GET_IRQ_STATUS(cmd, status) \ - MC_RSP_OP(cmd, 0, 0, 32, uint32_t, status) - -/* cmd, param, offset, width, type, arg_name */ -#define DPCON_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status); \ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPCON_RSP_GET_ATTR(cmd, attr) \ -do { \ - MC_RSP_OP(cmd, 0, 0, 32, int, attr->id);\ - MC_RSP_OP(cmd, 0, 32, 16, uint16_t, attr->qbman_ch_id);\ - MC_RSP_OP(cmd, 0, 48, 8, uint8_t, attr->num_priorities);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPCON_CMD_SET_NOTIFICATION(cmd, cfg) \ -do { \ - MC_CMD_OP(cmd, 0, 0, 32, int, cfg->dpio_id);\ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->priority);\ - MC_CMD_OP(cmd, 1, 0, 64, uint64_t, cfg->user_ctx);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPCON_RSP_GET_API_VERSION(cmd, major, minor) \ -do { \ - MC_RSP_OP(cmd, 0, 0, 16, uint16_t, major);\ - MC_RSP_OP(cmd, 0, 16, 16, uint16_t, minor);\ -} while (0) +/* Command versioning */ +#define DPCON_CMD_BASE_VERSION 1 +#define DPCON_CMD_ID_OFFSET 4 + +#define DPCON_CMD(id) ((id << DPCON_CMD_ID_OFFSET) | DPCON_CMD_BASE_VERSION) + +/* Command IDs */ +#define DPCON_CMDID_CLOSE DPCON_CMD(0x800) +#define DPCON_CMDID_OPEN DPCON_CMD(0x808) +#define DPCON_CMDID_CREATE DPCON_CMD(0x908) +#define DPCON_CMDID_DESTROY DPCON_CMD(0x988) +#define DPCON_CMDID_GET_API_VERSION DPCON_CMD(0xa08) + +#define DPCON_CMDID_ENABLE DPCON_CMD(0x002) +#define DPCON_CMDID_DISABLE DPCON_CMD(0x003) +#define DPCON_CMDID_GET_ATTR DPCON_CMD(0x004) +#define DPCON_CMDID_RESET DPCON_CMD(0x005) +#define DPCON_CMDID_IS_ENABLED DPCON_CMD(0x006) + +#define DPCON_CMDID_SET_NOTIFICATION DPCON_CMD(0x100) + +#pragma pack(push, 1) +struct dpcon_cmd_open { + uint32_t dpcon_id; +}; + +struct dpcon_cmd_create { + uint8_t num_priorities; +}; + +struct dpcon_cmd_destroy { + uint32_t object_id; +}; + +#define DPCON_ENABLE 1 + +struct dpcon_rsp_is_enabled { + uint8_t enabled; +}; + +struct dpcon_rsp_get_attr { + uint32_t id; + uint16_t qbman_ch_id; + uint8_t num_priorities; + uint8_t pad; +}; + +struct dpcon_cmd_set_notification { + uint32_t dpio_id; + uint8_t priority; + uint8_t pad[3]; + uint64_t user_ctx; +}; + +struct dpcon_rsp_get_api_version { + uint16_t major; + uint16_t minor; +}; + +#pragma pack(pop) #endif /* _FSL_DPCON_CMD_H */ diff --git a/drivers/bus/fslmc/mc/fsl_dpio.h b/drivers/bus/fslmc/mc/fsl_dpio.h index 4448cca..3d96adf 100644 --- a/drivers/bus/fslmc/mc/fsl_dpio.h +++ b/drivers/bus/fslmc/mc/fsl_dpio.h @@ -5,7 +5,7 @@ * BSD LICENSE * * Copyright 2013-2016 Freescale Semiconductor Inc. - * Copyright 2016 NXP. + * Copyright 2016-2017 NXP. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -46,44 +46,19 @@ struct fsl_mc_io; -/** - * dpio_open() - Open a control session for the specified object - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @dpio_id: DPIO unique ID - * @token: Returned token; use in subsequent API calls - * - * This function can be used to open a control session for an - * already created object; an object may have been declared in - * the DPL or by calling the dpio_create() function. - * This function returns a unique authentication token, - * associated with the specific object ID and any MC portals - * assigned to the parent container; this token must be used in - * all subsequent commands for this specific object. - * - * Return: '0' on Success; Error code otherwise. - */ -int dpio_open(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - int dpio_id, - uint16_t *token); +int dpio_open(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + int dpio_id, + uint16_t *token); -/** - * dpio_close() - Close the control session of the object - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPIO object - * - * Return: '0' on Success; Error code otherwise. - */ -int dpio_close(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +int dpio_close(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token); /** * enum dpio_channel_mode - DPIO notification channel mode - * @DPIO_NO_CHANNEL: No support for notification channel - * @DPIO_LOCAL_CHANNEL: Notifications on data availability can be received by a + * @DPIO_NO_CHANNEL: No support for notification channel + * @DPIO_LOCAL_CHANNEL: Notifications on data availability can be received by a * dedicated channel in the DPIO; user should point the queue's * destination in the relevant interface to this DPIO */ @@ -94,216 +69,94 @@ enum dpio_channel_mode { /** * struct dpio_cfg - Structure representing DPIO configuration - * @channel_mode: Notification channel mode - * @num_priorities: Number of priorities for the notification channel (1-8); + * @channel_mode: Notification channel mode + * @num_priorities: Number of priorities for the notification channel (1-8); * relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL' */ struct dpio_cfg { - enum dpio_channel_mode channel_mode; - uint8_t num_priorities; + enum dpio_channel_mode channel_mode; + uint8_t num_priorities; }; -/** - * dpio_create() - Create the DPIO object. - * @mc_io: Pointer to MC portal's I/O object - * @dprc_token: Parent container token; '0' for default container - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @cfg: Configuration structure - * @obj_id: returned object id - * - * Create the DPIO object, allocate required resources and - * perform required initialization. - * - * The object can be created either by declaring it in the - * DPL file, or by calling this function. - * - * The function accepts an authentication token of a parent - * container that this object should be assigned to. The token - * can be '0' so the object will be assigned to the default container. - * The newly created object can be opened with the returned - * object id and using the container's associated tokens and MC portals. - * - * Return: '0' on Success; Error code otherwise. - */ -int dpio_create(struct fsl_mc_io *mc_io, - uint16_t dprc_token, - uint32_t cmd_flags, - const struct dpio_cfg *cfg, - uint32_t *obj_id); -/** - * dpio_destroy() - Destroy the DPIO object and release all its resources. - * @mc_io: Pointer to MC portal's I/O object - * @dprc_token: Parent container token; '0' for default container - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @object_id: The object id; it must be a valid id within the container that - * created this object; - * - * The function accepts the authentication token of the parent container that - * created the object (not the one that currently owns the object). The object - * is searched within parent using the provided 'object_id'. - * All tokens to the object must be closed before calling destroy. - * - * Return: '0' on Success; Error code otherwise - */ -int dpio_destroy(struct fsl_mc_io *mc_io, - uint16_t dprc_token, - uint32_t cmd_flags, - uint32_t object_id); +int dpio_create(struct fsl_mc_io *mc_io, + uint16_t dprc_token, + uint32_t cmd_flags, + const struct dpio_cfg *cfg, + uint32_t *obj_id); -/** - * dpio_enable() - Enable the DPIO, allow I/O portal operations. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPIO object - * - * Return: '0' on Success; Error code otherwise - */ -int dpio_enable(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +int dpio_destroy(struct fsl_mc_io *mc_io, + uint16_t dprc_token, + uint32_t cmd_flags, + uint32_t object_id); -/** - * dpio_disable() - Disable the DPIO, stop any I/O portal operation. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPIO object - * - * Return: '0' on Success; Error code otherwise - */ -int dpio_disable(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +int dpio_enable(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token); -/** - * dpio_is_enabled() - Check if the DPIO is enabled. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPIO object - * @en: Returns '1' if object is enabled; '0' otherwise - * - * Return: '0' on Success; Error code otherwise. - */ -int dpio_is_enabled(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - int *en); +int dpio_disable(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token); -/** - * dpio_reset() - Reset the DPIO, returns the object to initial state. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPIO object - * - * Return: '0' on Success; Error code otherwise. - */ -int dpio_reset(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token); +int dpio_is_enabled(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + int *en); -/** - * dpio_set_stashing_destination() - Set the stashing destination. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPIO object - * @sdest: stashing destination value - * - * Return: '0' on Success; Error code otherwise. - */ -int dpio_set_stashing_destination(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint8_t sdest); +int dpio_reset(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token); -/** - * dpio_get_stashing_destination() - Get the stashing destination.. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPIO object - * @sdest: Returns the stashing destination value - * - * Return: '0' on Success; Error code otherwise. - */ -int dpio_get_stashing_destination(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - uint8_t *sdest); +int dpio_set_stashing_destination(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint8_t sdest); -/** - * dpio_add_static_dequeue_channel() - Add a static dequeue channel. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPIO object - * @dpcon_id: DPCON object ID - * @channel_index: Returned channel index to be used in qbman API - * - * Return: '0' on Success; Error code otherwise. - */ -int dpio_add_static_dequeue_channel(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - int dpcon_id, - uint8_t *channel_index); +int dpio_get_stashing_destination(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + uint8_t *sdest); -/** - * dpio_remove_static_dequeue_channel() - Remove a static dequeue channel. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPIO object - * @dpcon_id: DPCON object ID - * - * Return: '0' on Success; Error code otherwise. - */ -int dpio_remove_static_dequeue_channel(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - int dpcon_id); +int dpio_add_static_dequeue_channel(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + int dpcon_id, + uint8_t *channel_index); + +int dpio_remove_static_dequeue_channel(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + int dpcon_id); /** * struct dpio_attr - Structure representing DPIO attributes - * @id: DPIO object ID - * @qbman_portal_ce_offset: offset of the software portal cache-enabled area - * @qbman_portal_ci_offset: offset of the software portal cache-inhibited area - * @qbman_portal_id: Software portal ID - * @channel_mode: Notification channel mode - * @num_priorities: Number of priorities for the notification channel (1-8); - * relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL' - * @qbman_version: QBMAN version + * @id: DPIO object ID + * @qbman_portal_ce_offset: Offset of the software portal cache-enabled area + * @qbman_portal_ci_offset: Offset of the software portal + * cache-inhibited area + * @qbman_portal_id: Software portal ID + * @channel_mode: Notification channel mode + * @num_priorities: Number of priorities for the notification + * channel (1-8); relevant only if + * 'channel_mode = DPIO_LOCAL_CHANNEL' + * @qbman_version: QBMAN version */ struct dpio_attr { - int id; - uint64_t qbman_portal_ce_offset; - uint64_t qbman_portal_ci_offset; - uint16_t qbman_portal_id; - enum dpio_channel_mode channel_mode; - uint8_t num_priorities; - uint32_t qbman_version; - uint32_t clk; + int id; + uint64_t qbman_portal_ce_offset; + uint64_t qbman_portal_ci_offset; + uint16_t qbman_portal_id; + enum dpio_channel_mode channel_mode; + uint8_t num_priorities; + uint32_t qbman_version; + uint32_t clk; }; -/** - * dpio_get_attributes() - Retrieve DPIO attributes - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPIO object - * @attr: Returned object's attributes - * - * Return: '0' on Success; Error code otherwise - */ -int dpio_get_attributes(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - uint16_t token, - struct dpio_attr *attr); +int dpio_get_attributes(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + uint16_t token, + struct dpio_attr *attr); -/** - * dpio_get_api_version() - Get Data Path I/O API version - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @major_ver: Major version of data path i/o API - * @minor_ver: Minor version of data path i/o API - * - * Return: '0' on Success; Error code otherwise. - */ int dpio_get_api_version(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t *major_ver, diff --git a/drivers/bus/fslmc/mc/fsl_dpio_cmd.h b/drivers/bus/fslmc/mc/fsl_dpio_cmd.h index d757507..3e9e1f6 100644 --- a/drivers/bus/fslmc/mc/fsl_dpio_cmd.h +++ b/drivers/bus/fslmc/mc/fsl_dpio_cmd.h @@ -5,7 +5,7 @@ * BSD LICENSE * * Copyright 2013-2016 Freescale Semiconductor Inc. - * Copyright 2016 NXP. + * Copyright 2016-2017 NXP. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -41,82 +41,108 @@ #define _FSL_DPIO_CMD_H /* DPIO Version */ -#define DPIO_VER_MAJOR 4 -#define DPIO_VER_MINOR 2 +#define DPIO_VER_MAJOR 4 +#define DPIO_VER_MINOR 2 + +#define DPIO_CMD_BASE_VERSION 1 +#define DPIO_CMD_ID_OFFSET 4 + +#define DPIO_CMD(id) (((id) << DPIO_CMD_ID_OFFSET) | DPIO_CMD_BASE_VERSION) /* Command IDs */ -#define DPIO_CMDID_CLOSE 0x8001 -#define DPIO_CMDID_OPEN 0x8031 -#define DPIO_CMDID_CREATE 0x9031 -#define DPIO_CMDID_DESTROY 0x9831 -#define DPIO_CMDID_GET_API_VERSION 0xa031 - -#define DPIO_CMDID_ENABLE 0x0021 -#define DPIO_CMDID_DISABLE 0x0031 -#define DPIO_CMDID_GET_ATTR 0x0041 -#define DPIO_CMDID_RESET 0x0051 -#define DPIO_CMDID_IS_ENABLED 0x0061 - -#define DPIO_CMDID_SET_STASHING_DEST 0x1201 -#define DPIO_CMDID_GET_STASHING_DEST 0x1211 -#define DPIO_CMDID_ADD_STATIC_DEQUEUE_CHANNEL 0x1221 -#define DPIO_CMDID_REMOVE_STATIC_DEQUEUE_CHANNEL 0x1231 - -/* cmd, param, offset, width, type, arg_name */ -#define DPIO_CMD_OPEN(cmd, dpio_id) \ - MC_CMD_OP(cmd, 0, 0, 32, uint32_t, dpio_id) - -/* cmd, param, offset, width, type, arg_name */ -#define DPIO_CMD_CREATE(cmd, cfg) \ -do { \ - MC_CMD_OP(cmd, 0, 16, 2, enum dpio_channel_mode, \ - cfg->channel_mode);\ - MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->num_priorities);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPIO_RSP_IS_ENABLED(cmd, en) \ - MC_RSP_OP(cmd, 0, 0, 1, int, en) - -/* cmd, param, offset, width, type, arg_name */ -#define DPIO_RSP_GET_ATTRIBUTES(cmd, attr) \ -do { \ - MC_RSP_OP(cmd, 0, 0, 32, int, (attr)->id);\ - MC_RSP_OP(cmd, 0, 32, 16, uint16_t, (attr)->qbman_portal_id);\ - MC_RSP_OP(cmd, 0, 48, 8, uint8_t, (attr)->num_priorities);\ - MC_RSP_OP(cmd, 0, 56, 4, enum dpio_channel_mode,\ - (attr)->channel_mode);\ - MC_RSP_OP(cmd, 1, 0, 64, uint64_t, (attr)->qbman_portal_ce_offset);\ - MC_RSP_OP(cmd, 2, 0, 64, uint64_t, (attr)->qbman_portal_ci_offset);\ - MC_RSP_OP(cmd, 3, 0, 32, uint32_t, (attr)->qbman_version);\ - MC_RSP_OP(cmd, 4, 0, 32, uint32_t, (attr)->clk);\ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPIO_CMD_SET_STASHING_DEST(cmd, sdest) \ - MC_CMD_OP(cmd, 0, 0, 8, uint8_t, sdest) - -/* cmd, param, offset, width, type, arg_name */ -#define DPIO_RSP_GET_STASHING_DEST(cmd, sdest) \ - MC_RSP_OP(cmd, 0, 0, 8, uint8_t, sdest) - -/* cmd, param, offset, width, type, arg_name */ -#define DPIO_CMD_ADD_STATIC_DEQUEUE_CHANNEL(cmd, dpcon_id) \ - MC_CMD_OP(cmd, 0, 0, 32, int, dpcon_id) - -/* cmd, param, offset, width, type, arg_name */ -#define DPIO_RSP_ADD_STATIC_DEQUEUE_CHANNEL(cmd, channel_index) \ - MC_RSP_OP(cmd, 0, 0, 8, uint8_t, channel_index) - -/* cmd, param, offset, width, type, arg_name */ -#define DPIO_CMD_REMOVE_STATIC_DEQUEUE_CHANNEL(cmd, dpcon_id) \ - MC_CMD_OP(cmd, 0, 0, 32, int, dpcon_id) - -/* cmd, param, offset, width, type, arg_name */ -#define DPIO_RSP_GET_API_VERSION(cmd, major, minor) \ -do { \ - MC_RSP_OP(cmd, 0, 0, 16, uint16_t, major);\ - MC_RSP_OP(cmd, 0, 16, 16, uint16_t, minor);\ -} while (0) +#define DPIO_CMDID_CLOSE DPIO_CMD(0x800) +#define DPIO_CMDID_OPEN DPIO_CMD(0x803) +#define DPIO_CMDID_CREATE DPIO_CMD(0x903) +#define DPIO_CMDID_DESTROY DPIO_CMD(0x983) +#define DPIO_CMDID_GET_API_VERSION DPIO_CMD(0xa03) + +#define DPIO_CMDID_ENABLE DPIO_CMD(0x002) +#define DPIO_CMDID_DISABLE DPIO_CMD(0x003) +#define DPIO_CMDID_GET_ATTR DPIO_CMD(0x004) +#define DPIO_CMDID_RESET DPIO_CMD(0x005) +#define DPIO_CMDID_IS_ENABLED DPIO_CMD(0x006) + +#define DPIO_CMDID_SET_IRQ_ENABLE DPIO_CMD(0x012) +#define DPIO_CMDID_GET_IRQ_ENABLE DPIO_CMD(0x013) +#define DPIO_CMDID_SET_IRQ_MASK DPIO_CMD(0x014) +#define DPIO_CMDID_GET_IRQ_MASK DPIO_CMD(0x015) +#define DPIO_CMDID_GET_IRQ_STATUS DPIO_CMD(0x016) +#define DPIO_CMDID_CLEAR_IRQ_STATUS DPIO_CMD(0x017) + +#define DPIO_CMDID_SET_STASHING_DEST DPIO_CMD(0x120) +#define DPIO_CMDID_GET_STASHING_DEST DPIO_CMD(0x121) +#define DPIO_CMDID_ADD_STATIC_DEQUEUE_CHANNEL DPIO_CMD(0x122) +#define DPIO_CMDID_REMOVE_STATIC_DEQUEUE_CHANNEL DPIO_CMD(0x123) + +/* Macros for accessing command fields smaller than 1byte */ +#define DPIO_MASK(field) \ + GENMASK(DPIO_##field##_SHIFT + DPIO_##field##_SIZE - 1, \ + DPIO_##field##_SHIFT) +#define dpio_set_field(var, field, val) \ + ((var) |= (((val) << DPIO_##field##_SHIFT) & DPIO_MASK(field))) +#define dpio_get_field(var, field) \ + (((var) & DPIO_MASK(field)) >> DPIO_##field##_SHIFT) + +#pragma pack(push, 1) +struct dpio_cmd_open { + uint32_t dpio_id; +}; + +#define DPIO_CHANNEL_MODE_SHIFT 0 +#define DPIO_CHANNEL_MODE_SIZE 2 + +struct dpio_cmd_create { + uint16_t pad1; + /* from LSB: channel_mode:2 */ + uint8_t channel_mode; + uint8_t pad2; + uint8_t num_priorities; +}; + +struct dpio_cmd_destroy { + uint32_t dpio_id; +}; + +#define DPIO_ENABLE_SHIFT 0 +#define DPIO_ENABLE_SIZE 1 + +struct dpio_rsp_is_enabled { + /* only the LSB */ + uint8_t en; +}; + +#define DPIO_ATTR_CHANNEL_MODE_SHIFT 0 +#define DPIO_ATTR_CHANNEL_MODE_SIZE 4 + +struct dpio_rsp_get_attr { + uint32_t id; + uint16_t qbman_portal_id; + uint8_t num_priorities; + /* from LSB: channel_mode:4 */ + uint8_t channel_mode; + uint64_t qbman_portal_ce_offset; + uint64_t qbman_portal_ci_offset; + uint32_t qbman_version; + uint32_t pad; + uint32_t clk; +}; + +struct dpio_stashing_dest { + uint8_t sdest; +}; + +struct dpio_cmd_static_dequeue_channel { + uint32_t dpcon_id; +}; + +struct dpio_rsp_add_static_dequeue_channel { + uint8_t channel_index; +}; + +struct dpio_rsp_get_api_version { + uint16_t major; + uint16_t minor; +}; +#pragma pack(pop) #endif /* _FSL_DPIO_CMD_H */ diff --git a/drivers/bus/fslmc/mc/fsl_dpmng.h b/drivers/bus/fslmc/mc/fsl_dpmng.h index c2ddde0..97030e4 100644 --- a/drivers/bus/fslmc/mc/fsl_dpmng.h +++ b/drivers/bus/fslmc/mc/fsl_dpmng.h @@ -5,6 +5,7 @@ * BSD LICENSE * * Copyright 2013-2015 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: @@ -39,7 +40,8 @@ #ifndef __FSL_DPMNG_H #define __FSL_DPMNG_H -/* Management Complex General API +/* + * Management Complex General API * Contains general API for the Management Complex firmware */ @@ -49,10 +51,10 @@ struct fsl_mc_io; * Management Complex firmware version information */ #define MC_VER_MAJOR 10 -#define MC_VER_MINOR 1 +#define MC_VER_MINOR 3 /** - * struct mc_versoin + * struct mc_version * @major: Major version number: incremented on API compatibility changes * @minor: Minor version number: incremented on API additions (that are * backward compatible); reset when major version is incremented @@ -65,42 +67,21 @@ struct mc_version { uint32_t revision; }; +int mc_get_version(struct fsl_mc_io *mc_io, + uint32_t cmd_flags, + struct mc_version *mc_ver_info); + /** * struct mc_platform - * @svr: system version (content of platform SVR register) - * @pvr: processor version (content of platform PVR register) + * @svr: System version (content of platform SVR register) + * @pvr: Processor version (content of platform PVR register) */ struct mc_soc_version { uint32_t svr; uint32_t pvr; }; -/** - * mc_get_version() - Retrieves the Management Complex firmware - * version information - * @mc_io: Pointer to opaque I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @mc_ver_info: Returned version information structure - * - * Return: '0' on Success; Error code otherwise. - */ -int mc_get_version(struct fsl_mc_io *mc_io, - uint32_t cmd_flags, - struct mc_version *mc_ver_info); - -/** - * mc_get_soc_version() - Retrieves the Management Complex firmware - * version information - * @mc_io: Pointer to opaque I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @mc_platform_info: Returned version information structure. The structure - * contains the values of SVR and PVR registers. Please consult platform - * specific reference manual for detailed information. - * - * Return: '0' on Success; Error code otherwise. - */ int mc_get_soc_version(struct fsl_mc_io *mc_io, uint32_t cmd_flags, struct mc_soc_version *mc_platform_info); - #endif /* __FSL_DPMNG_H */ diff --git a/drivers/bus/fslmc/mc/fsl_dpmng_cmd.h b/drivers/bus/fslmc/mc/fsl_dpmng_cmd.h index 3a36b6d..4c0a629 100644 --- a/drivers/bus/fslmc/mc/fsl_dpmng_cmd.h +++ b/drivers/bus/fslmc/mc/fsl_dpmng_cmd.h @@ -5,6 +5,7 @@ * BSD LICENSE * * Copyright 2013-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: @@ -36,26 +37,32 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ + #ifndef __FSL_DPMNG_CMD_H #define __FSL_DPMNG_CMD_H +/* Command versioning */ +#define DPMNG_CMD_BASE_VERSION 1 +#define DPMNG_CMD_ID_OFFSET 4 + +#define DPMNG_CMD(id) ((id << DPMNG_CMD_ID_OFFSET) | DPMNG_CMD_BASE_VERSION) + /* Command IDs */ -#define DPMNG_CMDID_GET_VERSION 0x8311 -#define DPMNG_CMDID_GET_SOC_VERSION 0x8321 - -/* cmd, param, offset, width, type, arg_name */ -#define DPMNG_RSP_GET_VERSION(cmd, mc_ver_info) \ -do { \ - MC_RSP_OP(cmd, 0, 0, 32, uint32_t, mc_ver_info->revision); \ - MC_RSP_OP(cmd, 0, 32, 32, uint32_t, mc_ver_info->major); \ - MC_RSP_OP(cmd, 1, 0, 32, uint32_t, mc_ver_info->minor); \ -} while (0) - -/* cmd, param, offset, width, type, arg_name */ -#define DPMNG_RSP_GET_SOC_VERSION(cmd, mc_soc_version) \ -do { \ - MC_RSP_OP(cmd, 0, 0, 32, uint32_t, mc_soc_version->svr); \ - MC_RSP_OP(cmd, 0, 32, 32, uint32_t, mc_soc_version->pvr); \ -} while (0) +#define DPMNG_CMDID_GET_VERSION DPMNG_CMD(0x831) +#define DPMNG_CMDID_GET_SOC_VERSION DPMNG_CMD(0x832) + +#pragma pack(push, 1) +struct dpmng_rsp_get_version { + uint32_t revision; + uint32_t version_major; + uint32_t version_minor; +}; + +struct dpmng_rsp_get_soc_version { + uint32_t svr; + uint32_t pvr; +}; + +#pragma pack(pop) #endif /* __FSL_DPMNG_CMD_H */ diff --git a/drivers/bus/fslmc/mc/fsl_mc_cmd.h b/drivers/bus/fslmc/mc/fsl_mc_cmd.h index 0ca4345..2cec29e 100644 --- a/drivers/bus/fslmc/mc/fsl_mc_cmd.h +++ b/drivers/bus/fslmc/mc/fsl_mc_cmd.h @@ -5,7 +5,7 @@ * BSD LICENSE * * Copyright 2013-2016 Freescale Semiconductor Inc. - * Copyright 2016 NXP. + * Copyright 2016-2017 NXP. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -40,146 +40,118 @@ #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)) +#include +#include -static inline uint64_t mc_enc(int lsoffset, int width, uint64_t val) -{ - return (uint64_t)(((uint64_t)val & MAKE_UMASK64(width)) << lsoffset); -} +#define MC_CMD_NUM_OF_PARAMS 7 -static inline uint64_t mc_dec(uint64_t val, int lsoffset, int width) -{ - return (uint64_t)((val >> lsoffset) & MAKE_UMASK64(width)); -} +#define phys_addr_t uint64_t + +#define u64 uint64_t +#define u32 uint32_t +#define u16 uint16_t +#define u8 uint8_t + +#define cpu_to_le64 rte_cpu_to_le_64 +#define cpu_to_le32 rte_cpu_to_le_32 +#define cpu_to_le16 rte_cpu_to_le_16 + +#define le64_to_cpu rte_le_to_cpu_64 +#define le32_to_cpu rte_le_to_cpu_32 +#define le16_to_cpu rte_le_to_cpu_16 + +#define BITS_PER_LONG 64 +#define GENMASK(h, l) \ + (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) + +struct mc_cmd_header { + union { + struct { + uint8_t src_id; + uint8_t flags_hw; + uint8_t status; + uint8_t flags_sw; + uint16_t token; + uint16_t cmd_id; + }; + uint32_t word[2]; + }; +}; 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 +struct mc_rsp_create { + uint32_t object_id; }; -/* MC command flags */ +enum mc_cmd_status { + MC_CMD_STATUS_OK = 0x0, /* Completed successfully */ + MC_CMD_STATUS_READY = 0x1, /* Ready to be processed */ + MC_CMD_STATUS_AUTH_ERR = 0x3, /* Authentication error */ + MC_CMD_STATUS_NO_PRIVILEGE = 0x4, /* No privilege */ + MC_CMD_STATUS_DMA_ERR = 0x5, /* DMA or I/O error */ + MC_CMD_STATUS_CONFIG_ERR = 0x6, /* Configuration error */ + MC_CMD_STATUS_TIMEOUT = 0x7, /* Operation timed out */ + MC_CMD_STATUS_NO_RESOURCE = 0x8, /* No resources */ + MC_CMD_STATUS_NO_MEMORY = 0x9, /* No memory available */ + MC_CMD_STATUS_BUSY = 0xA, /* Device is busy */ + MC_CMD_STATUS_UNSUPPORTED_OP = 0xB, /* Unsupported operation */ + MC_CMD_STATUS_INVALID_STATE = 0xC /* Invalid state */ +}; -/** - * High priority flag - */ -#define MC_CMD_FLAG_PRI 0x00008000 -/** - * Command completion flag +/* + * MC command flags */ -#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 - */ +/* High priority flag */ +#define MC_CMD_FLAG_PRI 0x80 +/* Command completion flag */ +#define MC_CMD_FLAG_INTR_DIS 0x01 + #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)) +int mc_send_command(struct fsl_mc_io *mc_io, struct mc_command *cmd); -#define MC_CMD_HDR_READ_TOKEN(_hdr) \ - ((uint16_t)mc_dec((_hdr), MC_CMD_HDR_TOKEN_O, MC_CMD_HDR_TOKEN_S)) +static inline uint64_t mc_encode_cmd_header(uint16_t cmd_id, + uint32_t cmd_flags, + uint16_t token) +{ + uint64_t header = 0; + struct mc_cmd_header *hdr = (struct mc_cmd_header *)&header; -#define MC_PREP_OP(_ext, _param, _offset, _width, _type, _arg) \ - ((_ext)[_param] |= cpu_to_le64(mc_enc((_offset), (_width), _arg))) + hdr->cmd_id = cpu_to_le16(cmd_id); + hdr->token = cpu_to_le16(token); + hdr->status = MC_CMD_STATUS_READY; + hdr->word[0] |= cpu_to_le32(cmd_flags & MC_CMD_HDR_FLAGS_MASK); -#define MC_EXT_OP(_ext, _param, _offset, _width, _type, _arg) \ - (_arg = (_type)mc_dec(cpu_to_le64(_ext[_param]), (_offset), (_width))) + return header; +} -#define MC_CMD_OP(_cmd, _param, _offset, _width, _type, _arg) \ - ((_cmd).params[_param] |= mc_enc((_offset), (_width), _arg)) +static inline uint16_t mc_cmd_hdr_read_token(struct mc_command *cmd) +{ + struct mc_cmd_header *hdr = (struct mc_cmd_header *)&cmd->header; + uint16_t token = le16_to_cpu(hdr->token); -#define MC_RSP_OP(_cmd, _param, _offset, _width, _type, _arg) \ - (_arg = (_type)mc_dec(_cmd.params[_param], (_offset), (_width))) + return token; +} -/* 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) +static inline uint32_t mc_cmd_read_object_id(struct mc_command *cmd) +{ + struct mc_rsp_create *rsp_params; -/* 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) + rsp_params = (struct mc_rsp_create *)cmd->params; + return le32_to_cpu(rsp_params->object_id); +} -static inline uint64_t mc_encode_cmd_header(uint16_t cmd_id, - uint32_t cmd_flags, - uint16_t token) +static inline enum mc_cmd_status mc_cmd_read_status(struct mc_command *cmd) { - 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); + struct mc_cmd_header *hdr = (struct mc_cmd_header *)&cmd->header; + uint8_t status = hdr->status; - return hdr; + return (enum mc_cmd_status)status; } /** @@ -191,20 +163,17 @@ static inline uint64_t mc_encode_cmd_header(uint16_t cmd_id, static inline void mc_write_command(struct mc_command __iomem *portal, struct mc_command *cmd) { - int i; - uint32_t word; + struct mc_cmd_header *cmd_header = (struct mc_cmd_header *)&cmd->header; char *header = (char *)&portal->header; + int i; /* 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); + iowrite32(le32_to_cpu(cmd_header->word[1]), (((uint32_t *)header) + 1)); + iowrite32(le32_to_cpu(cmd_header->word[0]), (uint32_t *)header); } /** @@ -225,7 +194,7 @@ static inline enum mc_cmd_status mc_read_response( /* Copy command response header from MC portal: */ resp->header = ioread64(&portal->header); - status = MC_CMD_HDR_READ_STATUS(resp->header); + status = mc_cmd_read_status(resp); if (status != MC_CMD_STATUS_OK) return status; diff --git a/drivers/bus/fslmc/mc/fsl_mc_sys.h b/drivers/bus/fslmc/mc/fsl_mc_sys.h index ebada60..d803205 100644 --- a/drivers/bus/fslmc/mc/fsl_mc_sys.h +++ b/drivers/bus/fslmc/mc/fsl_mc_sys.h @@ -5,6 +5,7 @@ * BSD LICENSE * * Copyright 2013-2015 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: @@ -65,40 +66,31 @@ struct fsl_mc_io { #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) \ +#define __iormb() dmb() +#define __iowmb() dmb() +#define __arch_getq(a) (*(volatile uint64_t *)(a)) +#define __arch_putq(v, a) (*(volatile uint64_t *)(a) = (v)) +#define __arch_putq32(v, a) (*(volatile uint32_t *)(a) = (v)) +#define readq(c) \ ({ uint64_t __v = __arch_getq(c); __iormb(); __v; }) -#define writeq(v, c) \ +#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 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); +struct fsl_mc_io { + void *regs; +}; #endif /* __linux_driver__ */ diff --git a/drivers/bus/fslmc/mc/mc_sys.c b/drivers/bus/fslmc/mc/mc_sys.c index 4573165..f0f9a26 100644 --- a/drivers/bus/fslmc/mc/mc_sys.c +++ b/drivers/bus/fslmc/mc/mc_sys.c @@ -5,6 +5,7 @@ * BSD LICENSE * * Copyright 2013-2015 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: @@ -86,6 +87,7 @@ static int mc_status_to_error(enum mc_cmd_status status) int mc_send_command(struct fsl_mc_io *mc_io, struct mc_command *cmd) { enum mc_cmd_status status; + uint64_t response; if (!mc_io || !mc_io->regs) return -EACCES; @@ -97,7 +99,8 @@ int mc_send_command(struct fsl_mc_io *mc_io, struct mc_command *cmd) /* Spin until status changes */ do { - status = MC_CMD_HDR_READ_STATUS(ioread64(mc_io->regs)); + response = ioread64(mc_io->regs); + status = mc_cmd_read_status((struct mc_command *)&response); /* --- Call wait function here to prevent blocking --- * Change the loop condition accordingly to exit on timeout.