Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1946097AbdD1Jwn (ORCPT ); Fri, 28 Apr 2017 05:52:43 -0400 Received: from mail-co1nam03on0048.outbound.protection.outlook.com ([104.47.40.48]:20512 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1425596AbdD1JvQ (ORCPT ); Fri, 28 Apr 2017 05:51:16 -0400 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; From: Ioana Radulescu To: CC: , , , , , , , , , , , , Subject: [PATCH v3 1/9] bus: fsl-mc: add DPCON object APIs Date: Fri, 28 Apr 2017 04:50:26 -0500 Message-ID: <20170428095034.8842-2-ruxandra.radulescu@nxp.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170428095034.8842-1-ruxandra.radulescu@nxp.com> References: <20170428095034.8842-1-ruxandra.radulescu@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131378466360916678;(91ab9b29-cfa4-454e-5278-08d120cd25b8);() X-Forefront-Antispam-Report: CIP:192.88.168.50;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(336005)(39450400003)(39860400002)(39850400002)(39840400002)(39410400002)(39380400002)(39400400002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(9170700003)(8656002)(2950100002)(6916009)(53936002)(81166006)(48376002)(76176999)(50986999)(356003)(50466002)(6666003)(8676002)(77096006)(54906002)(36756003)(5003940100001)(189998001)(39060400002)(38730400002)(104016004)(110136004)(2906002)(33646002)(1076002)(105606002)(106466001)(47776003)(2351001)(4326008)(575784001)(305945005)(8936002)(86362001)(85426001)(5660300001)(50226002)(7416002)(2004002);DIR:OUT;SFP:1101;SCL:1;SRVR:DM2PR0301MB1199;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;MLV:ovrnspm;MX:1;A:1;PTR:InfoDomainNonexistent;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11FD046;1:SK/cMF+dBjKDU/QdkKT2j3oFZ/sybzIixMdb1PhoYbD0C8PxW//nsVzBgDvJ1WCbavgp/tCX+jOy/G4rZiU/2PnXFBux2ZvK/CqloAkFxeqv2MJQhdJT1zeEEyh35pW+K+TwGlKs8nOEKDaEZ4VNiQ/7skQ+TtygOn5VP+S+LqlHzWU3OpTJXDU6tMEittYPmETteOOSvWlsFUk56Dp34JRD9pi8pTQ1OFQ5adqn6bz1L2zd/pdBMRsRm3/iIxjiFwb2Y3I9vSDQ2H9FG33AboGXBoTl5jAxPQwIRJROb67rybbqBX/xBFXLrWQ4kC24UBPP3ps8ReYmBvqGRLnjX4jc8k9PqJxIAj8+XPB9VMduHGfn8WmcroZMRUU47iSMk+nTgwZsM4lqnbbPWDOE6yk201CxquJNAmpngD22YBX2XFgJjVvWWcP6MQ4jZ3uukx5pRXOcP7iSWz+HzRGeNmhHuQE2xkSZcPgI0te1s2QODvYdgJneOW+zBeEXwDcNyxZ91FmdOX7+kd/4WwGYoZJhJJ2rWfGg0ZXwGQ30m9AVEMz/8UG9sey9dXbM5jLh0xKySoF5WDix7KPv7j6NIxJDTthgqKKyBgoUSxnG9Q52d9mpeloYXJl3k9TqZSYOhYaEnwjjkJAIFlBrNKK4D+n7bkIUkr+DpEVRAlhAug+P2rTY5+1lTetVBKBxKePQnbOxzo069hVcHZS+8CAF3yurkIU2tqWWL/hJ4vsddAM= MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 90a8f4e1-c534-4dda-fac6-08d48e1c050a X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131430075)(201703131517081);SRVR:DM2PR0301MB1199; X-Microsoft-Exchange-Diagnostics: 1;DM2PR0301MB1199;3:QQ7Zv/uMWTqdFCC5VaBvrof/EyaPQ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IRL2wVm4CVl7vp7p95En6OnhagvG9j/dJwomxtO4vdXKNPhDqKdrhP8CH8d/cOKDk3y4b/V/JjcHDk3eDFBSchU79vDO02JOqJXZ36iAw1kdCk4eA5rg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(101931422205132)(275809806118684); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6095135)(601004)(2401047)(5005006)(13015025)(8121501046)(13023025)(13017025)(13018025)(13024025)(3002001)(10201501046)(93006095)(93001095)(6055026)(6096035)(201703131430075)(201703131441075)(201703131448075)(201703131433075)(201703161259150)(20161123556025)(20161123561025)(20161123565025)(20161123563025);SRVR:DM2PR0301MB1199;BCL:0;PCL:0;RULEID:(400006);SRVR:DM2PR0301MB1199; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM2PR0301MB1199;4:C38ttahl3NYGNRXf+xB1+a0ELwTzCyAx/pFIqOD+?= =?us-ascii?Q?I6QmQaeXCPevtDI7Pyw0xN0vKAOlZnTsn53w62ceCMokUfVggPxahQHMdwZl?= =?us-ascii?Q?EUqBhfjzM7z5xUC6I5p5m5ImBF3urCNRo13JiHS/K+mYg6lVWXbVkWwXvki4?= =?us-ascii?Q?TFVucHlQFAGyZYRV8AY6ffF5rkDrQmzF9JaLEh5wGeLywn+G1ifNuV3Ii9RT?= =?us-ascii?Q?Ue/RCPAijKIjEf/hqMF1SYT3HvYFERGSAuKn+pgBZ/9p0wp3Csk9zFZ/oufS?= =?us-ascii?Q?ZpyyZJoMgxczutPE80rhcZZKa4sfHrjiQ3Ft4pfwOdVvxVXapwkeTwhzp7gt?= =?us-ascii?Q?T7CxA5lvu35osKbgNRcmWtVjEGDAXeNDr9o8myB56CKz8L10Xeu+QCSU8iI2?= =?us-ascii?Q?Rs50FNCyukc+IeGsiKvGRFoTNgHuMqt5DEy6ILC22xpU1LVuanv7NdaO3Sc0?= =?us-ascii?Q?HzjA0s0pBzgPsR3V9FaQkKo4hICUIm8YKtakKO7tKNMvXszyoVmjo3xOoG7l?= =?us-ascii?Q?MWnBrZF5A/aFhUpN1Q9tsk266Xk3yHz5Zk/6md2XzI5d06IiSadfOjZy8kq/?= =?us-ascii?Q?SzTLwNM+AAHLqcIOGs1OTvqWdi393M5KeJTCUD7549uj/c0uRvasEjlGH+tL?= =?us-ascii?Q?dv3farDoqLLpR4TYIMTa9Mohdlhcb/XyIZUZHPQ5zqWaTQrZ5qzNgWaXEHvJ?= =?us-ascii?Q?cSbrA1H03AxU6zFx0uDHxQ+ZdnD8YW94t18J7iEUeVzEBchvL+oOR5pKmZL7?= =?us-ascii?Q?B9ZRqO2CaZLtL7NdmGF76UOvinBu6kGs/9TJ5p0rDSlD29NQmfz1pX6cMb7E?= =?us-ascii?Q?jmpu2SyrnPPcuw9uJ2zxEtzQF8S+whXh3JF7Zc+o/jUe+7IDx6LmSB7NuywU?= =?us-ascii?Q?G4CSLXUits6g6qyVqtrmkORqPzeoFy79dtHcgramLI9PnacT9cIzBlkzKbcY?= =?us-ascii?Q?kfDQCkNjOG1zTgdLdDltDInseungUuvQK8LobZkocWPDw4B/o3/D9bDcvQ3O?= =?us-ascii?Q?738=3D?= X-Forefront-PRVS: 029174C036 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM2PR0301MB1199;23:pilRgeGaaztVVLYuYIdpbnUSXWFnUSBWKSCBzxa?= =?us-ascii?Q?jyB8TSUeBu9TPb9h9jxMo/WAT1yV90Z7tEbmBx7Zi+giOQhiaOagISIYFzSd?= =?us-ascii?Q?I2m+oZfmLl9qP/8+Thbs/2Yb5fmEd/CuA5OEiVSgYANOvABs9QNhW5xlI9X2?= =?us-ascii?Q?SxegEpzSIWNn31y/oViEmo6EvSNsCp28pEaZouPHAIlKOCAOCHuMUUDdjAmn?= =?us-ascii?Q?4T4fR8dWlTC6zJX6ewU/V6HY2rjteqkkDJC5QCTaSqjSPh7PO0b/wNVE6p8E?= =?us-ascii?Q?NHPEthOVXZ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e0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DM2PR0301MB1199;7:4zpKOgfJjF4zii+tYN7mlQCDQsipmQnTEA0DcEBQk6I28w9B/Wnm6IYr/Fwfwe4Kc38v6mG2DBs28KQwwMMyi+DB82FKmDdHoMuWLnfPYtND5lM21e8EuXW4AEYC0PYwa7mYbajReBKz1Pc+cueGaMm/yQwNVFrCuKltXkNWnvgkZWEIw28nOOCp28d6IxzHcB7Ot/YJYj0bXpFpsn74IgllGdmisKVrzRgVTYRPOSDV+Jmtcx9HeceF9As5B617XYfitWT6ihzOl37OJYKELzI1V1OnyWhKLj9zmZMCkYrP3Pi5yN+mdWV34VwfiAgL+yAceoA6kx4QNehz9FK+ZQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2017 09:50:35.9200 (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: DM2PR0301MB1199 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 17850 Lines: 570 From: Ioana Radulescu This patch adds the command building/parsing wrapper functions for the DPCON object. The binary interface version is v3.2. A DPCON (DataPath Concentrator) is an aggregator object that allows ingress frames from multiple hardware queues to be seen as coming from a single source, from the CPU point of view. Signed-off-by: Ioana Radulescu Signed-off-by: Ioana Ciornei Signed-off-by: Stuart Yoder --- v3: no changes v2: update #include paths since fsl-mc bus driver is still in staging Note: The DPAA2 Ethernet driver is the first user of the DPCON objects, but they can also be used as building blocks by other DPAA2 drivers, so the API files are located for now under staging/fsl-mc/bus, along the other "common" MC object files. drivers/staging/fsl-mc/bus/Makefile | 3 +- drivers/staging/fsl-mc/bus/dpcon-cmd.h | 69 ++++--- drivers/staging/fsl-mc/bus/dpcon.c | 317 +++++++++++++++++++++++++++++++++ drivers/staging/fsl-mc/include/dpcon.h | 115 ++++++++++++ 4 files changed, 480 insertions(+), 24 deletions(-) create mode 100644 drivers/staging/fsl-mc/bus/dpcon.c create mode 100644 drivers/staging/fsl-mc/include/dpcon.h diff --git a/drivers/staging/fsl-mc/bus/Makefile b/drivers/staging/fsl-mc/bus/Makefile index 577e9fab34ec..659eccf52a4f 100644 --- a/drivers/staging/fsl-mc/bus/Makefile +++ b/drivers/staging/fsl-mc/bus/Makefile @@ -17,7 +17,8 @@ mc-bus-driver-objs := fsl-mc-bus.o \ fsl-mc-msi.o \ irq-gic-v3-its-fsl-mc-msi.o \ dpmcp.o \ - dpbp.o + dpbp.o \ + dpcon.o # MC DPIO driver obj-$(CONFIG_FSL_MC_DPIO) += dpio/ diff --git a/drivers/staging/fsl-mc/bus/dpcon-cmd.h b/drivers/staging/fsl-mc/bus/dpcon-cmd.h index d0a5e194c5e1..2bb66988ecf6 100644 --- a/drivers/staging/fsl-mc/bus/dpcon-cmd.h +++ b/drivers/staging/fsl-mc/bus/dpcon-cmd.h @@ -33,30 +33,53 @@ #define _FSL_DPCON_CMD_H /* DPCON Version */ -#define DPCON_VER_MAJOR 2 -#define DPCON_VER_MINOR 1 +#define DPCON_VER_MAJOR 3 +#define DPCON_VER_MINOR 2 + +/* 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 0x800 -#define DPCON_CMDID_OPEN 0x808 -#define DPCON_CMDID_CREATE 0x908 -#define DPCON_CMDID_DESTROY 0x900 - -#define DPCON_CMDID_ENABLE 0x002 -#define DPCON_CMDID_DISABLE 0x003 -#define DPCON_CMDID_GET_ATTR 0x004 -#define DPCON_CMDID_RESET 0x005 -#define DPCON_CMDID_IS_ENABLED 0x006 - -#define DPCON_CMDID_SET_IRQ 0x010 -#define DPCON_CMDID_GET_IRQ 0x011 -#define DPCON_CMDID_SET_IRQ_ENABLE 0x012 -#define DPCON_CMDID_GET_IRQ_ENABLE 0x013 -#define DPCON_CMDID_SET_IRQ_MASK 0x014 -#define DPCON_CMDID_GET_IRQ_MASK 0x015 -#define DPCON_CMDID_GET_IRQ_STATUS 0x016 -#define DPCON_CMDID_CLEAR_IRQ_STATUS 0x017 - -#define DPCON_CMDID_SET_NOTIFICATION 0x100 +#define DPCON_CMDID_CLOSE DPCON_CMD(0x800) +#define DPCON_CMDID_OPEN DPCON_CMD(0x808) +#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) + +struct dpcon_cmd_open { + __le32 dpcon_id; +}; + +#define DPCON_ENABLE 1 + +struct dpcon_rsp_is_enabled { + u8 enabled; +}; + +struct dpcon_rsp_get_attr { + /* response word 0 */ + __le32 id; + __le16 qbman_ch_id; + u8 num_priorities; + u8 pad; +}; + +struct dpcon_cmd_set_notification { + /* cmd word 0 */ + __le32 dpio_id; + u8 priority; + u8 pad[3]; + /* cmd word 1 */ + __le64 user_ctx; +}; #endif /* _FSL_DPCON_CMD_H */ diff --git a/drivers/staging/fsl-mc/bus/dpcon.c b/drivers/staging/fsl-mc/bus/dpcon.c new file mode 100644 index 000000000000..eb713578b817 --- /dev/null +++ b/drivers/staging/fsl-mc/bus/dpcon.c @@ -0,0 +1,317 @@ +/* Copyright 2013-2016 Freescale Semiconductor Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the above-listed copyright holders nor the + * names of any contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * + * ALTERNATIVELY, this software may be distributed under the terms of the + * GNU General Public License ("GPL") as published by the Free Software + * Foundation, either version 2 of that License or (at your option) any + * later version. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#include "../include/mc-sys.h" +#include "../include/mc-cmd.h" +#include "../include/dpcon.h" + +#include "dpcon-cmd.h" + +/** + * 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, + u32 cmd_flags, + int dpcon_id, + u16 *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 = (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); + if (err) + return err; + + /* retrieve response parameters */ + *token = mc_cmd_hdr_read_token(&cmd); + + return 0; +} +EXPORT_SYMBOL(dpcon_open); + +/** + * 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, + u32 cmd_flags, + u16 token) +{ + struct mc_command cmd = { 0 }; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPCON_CMDID_CLOSE, + cmd_flags, + token); + + /* send command to mc*/ + return mc_send_command(mc_io, &cmd); +} +EXPORT_SYMBOL(dpcon_close); + +/** + * 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, + u32 cmd_flags, + u16 token) +{ + struct mc_command cmd = { 0 }; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPCON_CMDID_ENABLE, + cmd_flags, + token); + + /* send command to mc*/ + return mc_send_command(mc_io, &cmd); +} +EXPORT_SYMBOL(dpcon_enable); + +/** + * 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, + u32 cmd_flags, + u16 token) +{ + struct mc_command cmd = { 0 }; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPCON_CMDID_DISABLE, + cmd_flags, + token); + + /* send command to mc*/ + return mc_send_command(mc_io, &cmd); +} +EXPORT_SYMBOL(dpcon_disable); + +/** + * 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, + u32 cmd_flags, + u16 token, + int *en) +{ + struct mc_command cmd = { 0 }; + struct dpcon_rsp_is_enabled *dpcon_rsp; + int err; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPCON_CMDID_IS_ENABLED, + cmd_flags, + token); + + /* send command to mc*/ + err = mc_send_command(mc_io, &cmd); + if (err) + return err; + + /* retrieve response parameters */ + dpcon_rsp = (struct dpcon_rsp_is_enabled *)cmd.params; + *en = dpcon_rsp->enabled & DPCON_ENABLE; + + return 0; +} +EXPORT_SYMBOL(dpcon_is_enabled); + +/** + * 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, + u32 cmd_flags, + u16 token) +{ + struct mc_command cmd = { 0 }; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPCON_CMDID_RESET, + cmd_flags, token); + + /* send command to mc*/ + return mc_send_command(mc_io, &cmd); +} +EXPORT_SYMBOL(dpcon_reset); + +/** + * 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, + u32 cmd_flags, + u16 token, + struct dpcon_attr *attr) +{ + struct mc_command cmd = { 0 }; + struct dpcon_rsp_get_attr *dpcon_rsp; + int err; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPCON_CMDID_GET_ATTR, + cmd_flags, + token); + + /* send command to mc*/ + err = mc_send_command(mc_io, &cmd); + if (err) + return err; + + /* retrieve response parameters */ + 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; +} +EXPORT_SYMBOL(dpcon_get_attributes); + +/** + * dpcon_set_notification() - Set DPCON notification 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 DPCON object + * @cfg: Notification parameters + * + * Return: '0' on Success; Error code otherwise + */ +int dpcon_set_notification(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token, + struct dpcon_notification_cfg *cfg) +{ + struct mc_command cmd = { 0 }; + struct dpcon_cmd_set_notification *dpcon_cmd; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPCON_CMDID_SET_NOTIFICATION, + cmd_flags, + token); + dpcon_cmd = (struct dpcon_cmd_set_notification *)cmd.params; + dpcon_cmd->dpio_id = cpu_to_le32(cfg->dpio_id); + dpcon_cmd->priority = cfg->priority; + dpcon_cmd->user_ctx = cpu_to_le64(cfg->user_ctx); + + /* send command to mc*/ + return mc_send_command(mc_io, &cmd); +} +EXPORT_SYMBOL(dpcon_set_notification); + +/** + * 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, + u32 cmd_flags, + u16 *major_ver, + u16 *minor_ver) +{ + struct mc_command cmd = { 0 }; + int err; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPCON_CMDID_GET_API_VERSION, + cmd_flags, 0); + + /* send command to mc */ + err = mc_send_command(mc_io, &cmd); + if (err) + return err; + + /* retrieve response parameters */ + mc_cmd_read_api_version(&cmd, major_ver, minor_ver); + + return 0; +} +EXPORT_SYMBOL(dpcon_get_api_version); diff --git a/drivers/staging/fsl-mc/include/dpcon.h b/drivers/staging/fsl-mc/include/dpcon.h new file mode 100644 index 000000000000..efa23906b364 --- /dev/null +++ b/drivers/staging/fsl-mc/include/dpcon.h @@ -0,0 +1,115 @@ +/* Copyright 2013-2016 Freescale Semiconductor Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the above-listed copyright holders nor the + * names of any contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * + * ALTERNATIVELY, this software may be distributed under the terms of the + * GNU General Public License ("GPL") as published by the Free Software + * Foundation, either version 2 of that License or (at your option) any + * later version. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef __FSL_DPCON_H +#define __FSL_DPCON_H + +/* Data Path Concentrator API + * Contains initialization APIs and runtime control APIs for DPCON + */ + +struct fsl_mc_io; + +/** General DPCON macros */ + +/** + * Use it to disable notifications; see dpcon_set_notification() + */ +#define DPCON_INVALID_DPIO_ID (int)(-1) + +int dpcon_open(struct fsl_mc_io *mc_io, + u32 cmd_flags, + int dpcon_id, + u16 *token); + +int dpcon_close(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token); + +int dpcon_enable(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token); + +int dpcon_disable(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token); + +int dpcon_is_enabled(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token, + int *en); + +int dpcon_reset(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 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) + */ +struct dpcon_attr { + int id; + u16 qbman_ch_id; + u8 num_priorities; +}; + +int dpcon_get_attributes(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token, + struct dpcon_attr *attr); + +/** + * struct dpcon_notification_cfg - Structure representing notification params + * @dpio_id: DPIO object ID; must be configured with a notification channel; + * to disable notifications set it to 'DPCON_INVALID_DPIO_ID'; + * @priority: Priority selection within the DPIO channel; valid values + * are 0-7, depending on the number of priorities in that channel + * @user_ctx: User context value provided with each CDAN message + */ +struct dpcon_notification_cfg { + int dpio_id; + u8 priority; + u64 user_ctx; +}; + +int dpcon_set_notification(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token, + struct dpcon_notification_cfg *cfg); + +int dpcon_get_api_version(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 *major_ver, + u16 *minor_ver); + +#endif /* __FSL_DPCON_H */ -- 2.11.0