Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754514AbcDKQtL (ORCPT ); Mon, 11 Apr 2016 12:49:11 -0400 Received: from mail-bn1bon0072.outbound.protection.outlook.com ([157.56.111.72]:48592 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751706AbcDKQtE (ORCPT ); Mon, 11 Apr 2016 12:49:04 -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=none action=none header.from=nxp.com; From: Stuart Yoder To: , CC: , , , , , Stuart Yoder Subject: [PATCH 04/14] staging: fsl-mc: update dpbp binary interface to v2.2 Date: Mon, 11 Apr 2016 11:48:54 -0500 Message-ID: <1460393334-15860-1-git-send-email-stuart.yoder@nxp.com> X-Mailer: git-send-email 1.7.9.5 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131048669356481460;(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)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(11100500001)(6806005)(33646002)(86362001)(104016004)(81166005)(106466001)(105606002)(189998001)(5001770100001)(50226001)(92566002)(50986999)(19580395003)(4326007)(19580405001)(50466002)(47776003)(48376002)(15650500001)(5008740100001)(586003)(87936001)(77096005)(2906002)(36756003)(1096002)(1220700001)(7059030)(4720700001);DIR:OUT;SFP:1101;SCL:1;SRVR:BN1PR0301MB0708;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;MLV:sfv;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD042;1:XvYHn9bh71i9IAQayoDgOFwWxqAblJ2Pq/lxAv+cJ+cQCuhSfsziA3UHq8Hm+uIdn/6tGodWmGxIldw1xDRm0/ZfeC+OrS1kqYHm5NGEmLHssbRA3wgJrgDvMR+gVeNtXq55mFOFhwKvWip2xHA5XcxdbvM+CSjlZzkCs+xZflqZSX3TTe+z7eCslAbDUnzboOA6Ie7gERU6MDCSoEQHMTz5KclOmpOVMJCaASo1PTDDcAUpPZz4CU9kvxzqFufCz1Y8eIQqmBchrYFsul+pegPei511EBNcN1xlffwNPjPkJAXPoXAhmalceV9X1MZuIujbhL5hn0vrP4Ct92So7SnP3xTIij6XBr3Hl182IJ+ckb5yStNFhBbaukGvdi6P1GwAHgNIKJbmzavog6MHqlpT3F4AgO3dUfIlt7cG2CSoaMEcMFg6MtdxNqw9g2AM+cfnmFKEjEHhIMmgDR7kMjdQCDafBW9zXyj1m9w9Qv3ke8J2RjwETit5EsDN0nbiJ9xSAFV4BxHeKFh5leCVru061OnLrQ5gD9EgWALIskkIqhKVRzR808sKosimGyW2JRnRzpUlNpQMFLqCYbIN2LsXHP8jZWZ8MtsnNESLPeIXDkH8owJiX0xMsJQlf0EEaFwq8uiAzxyNpPkqsv44nZrJLzmZRJF1Q05Jjm9KdC53uSra+NWtC8VzwI+5+zOd MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: bc95f2cc-9af0-47f7-7a53-08d362292bbc X-Microsoft-Exchange-Diagnostics: 1;BN1PR0301MB0708;2:bcKwpoS3l5AuId236Ybb/yIs0WsVht+7/t3tETzZi7gHVVgxe8w8cU+panvBCEK62zr5z1nAYa4O+hB4E9wdSUeu1cIG86EAhSXO1zAgZ+lTT3sqlsfAz6iCU67AKiDtGNjQVfD4XmYsgVtNZlyAj1C/Vn5X6nLH0EagRA0/X9H1/PU0h0HRQ29FbJLH1z6H;3:RpuqyJq/PPFOLCndmegvEyttw84wV/zG7n6tLMLA6JDcX9VFQ1GiUTVKhbvOUQdBpWWs80T64olcMti2+ScNIoyX2dHrC3hbAAxnAaAyq33KySBqFA3CX7YVvPgND6tfdsOfsLTDcpsuvVjAfpCrLz7SzMGgmSvN2ur1EXGpg85KS0KUGoQlnn6OfR1OfLYMVwovEMyQxsyThaV5VLgeglEjcn4SXZa1ajSKYnZMDHs= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN1PR0301MB0708; X-Microsoft-Exchange-Diagnostics: 1;BN1PR0301MB0708;25:MN2pFpAOAISHF59ZCcSp/JC7++0N9PDfzGIs3iG9Ft+m+quaeKE/dtkNvCzRN/yWB4WQEWCntBoi4BDiW5JcayqLk+SC9RkGL94zUv+opMOOYWjbF3hn6KXolDXOFo/T/8EYXmKRAJHePR/Hcol3n+Y/YBseB9MxJ2q2vJWgX9bzxEIFeHjVWV5HkLJ3+UFRwD4gfyu/Xv4BsbxHv7wDtu4rfJzhSVm2TgDbTVOAwGztHVw41GZSzRcid5h5vTFUGUlGh2F82fjXgELg9qhHEDZYpSxC2wlk4qVzjSV8sErlB2QZ9R80/9OpP8xghQU67N/0cmfE0bp9qBu3HKcGZflW6SFuVvuKs0PQpBn3y1B8sIQ4E0VrnTKdJjIiFj2p4OfBeC/cF0ZLs1LJbleX9uqnKdG85M0xTtZ4CxwEoe5X72V2uaQw1ObHWX4InBGRpjCLPmbm4FK/9Gl7/19uk6tIHfN0wjkiS713H3A0nIqOqLW68yLuVUHU0FJp1arqSOlpJ/p2uOUvytw+EOb+W+hs7oc0XK4Rzras/5oCA/JB2GlEFjYGphFUvU8tQO7p+GRvOP23VEjbjhKjSJjrja3PJVgFpQ+7l9mWfLkXvFmiZD4zwBrSCrVJulvoT0LI/3GsZZnBcPtL6tJb2oAgtbWOJKZcxjOtFNqkKPj94lDpZsoBbkBKCv+L3u2duKL/ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(13018025)(13017025)(13015025)(13024025)(13023025)(8121501046)(10201501046)(3002001)(6055026);SRVR:BN1PR0301MB0708;BCL:0;PCL:0;RULEID:(400006);SRVR:BN1PR0301MB0708; X-Microsoft-Exchange-Diagnostics: 1;BN1PR0301MB0708;4:f10QtmRNUIvGKo/mv0vCP9kczO1qkdstT/aN4GxSlI5Aom5jj/QvKCyWuQRUWsmODTgKn4olXwvya8J2nFrFBeyxZRi/4trNwAycT3lrYClsCwVNPBwa7hVKM3wwQjzKT6m1/G6aiwyB/AuJ8ccfc/uEIUXCAneZAQzItwGxNWY7rAAbUvPxa/ler2e/WpKTa6FmafFJ835r0zb01/UejKYBmuZvi2NDIyEjc8txjhehcR8ly7lXTHlw/F0Ue1INgY2Mn0N5UZJLMSkWeMLu3nrGfQL0g7+6MI+KZc+f/9EJKfmmWgukhZEd4HDonHoHtz+X6LKSruR0GJJ+zW6yIuYrkiVmQ4q9vj7vq4J5l1W1mJ/+yqHR4edHCFh5EiQPcUv918jn1RSfr4CKi4rlHRajQ+iStyfw1fzmX6P+VDH7R+Pb8PKNBhTznkbpvSh176zjbx8PF8xjS3zEoxvQsCqI1+xHeyrh3dvAu1shB20= X-Forefront-PRVS: 09090B6B69 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN1PR0301MB0708;23:8jGYMRRMj+M4jdHthP2yn+B/K2yJJY/kd6gARCk?= =?us-ascii?Q?tHlAZtdgFi/HvQqtlpdW+QAkdcBQo/DQnkcR9xxeC62ocz/JpHSU8BXGoKCH?= =?us-ascii?Q?5TWPg+s7bmgPtNfzAZYxvQhFW+brVcGfdfdPAUpijJGLtSUe9XRTVXzPip8P?= =?us-ascii?Q?A0+llg/aG8kGovlc/JrGnpH/f7XIt0bQ7zSSD3UHPsnIuaz1qpU1ARtEXnqi?= =?us-ascii?Q?2BSGviFaroUOsmHVQFg3QmyUNezztuVvipeynzzgM79y1veEk9TEAzxcguK2?= =?us-ascii?Q?bpiGGNu1fgKV1BIzI4Er1eHEczpfJAaq8Rjk39CqmMrecq7guBzCTZVFw69S?= =?us-ascii?Q?pVIyVl/M9oDDc7x5c0ogq1py/lQNQjwNNlUggHbPWBmZCv85K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a2Io2iZuoM= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2016 16:48:55.4609 (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: BN1PR0301MB0708 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6982 Lines: 210 From: Stuart Yoder Signed-off-by: Stuart Yoder --- drivers/staging/fsl-mc/bus/dpbp.c | 77 ++++++++++++++++++++++++++++- drivers/staging/fsl-mc/include/dpbp-cmd.h | 4 +- drivers/staging/fsl-mc/include/dpbp.h | 51 ++++++++++++++++++- 3 files changed, 127 insertions(+), 5 deletions(-) diff --git a/drivers/staging/fsl-mc/bus/dpbp.c b/drivers/staging/fsl-mc/bus/dpbp.c index 2d97173..c31fe1b 100644 --- a/drivers/staging/fsl-mc/bus/dpbp.c +++ b/drivers/staging/fsl-mc/bus/dpbp.c @@ -293,7 +293,7 @@ int dpbp_set_irq(struct fsl_mc_io *mc_io, cmd.params[0] |= mc_enc(0, 8, irq_index); cmd.params[0] |= mc_enc(32, 32, irq_cfg->val); cmd.params[1] |= mc_enc(0, 64, irq_cfg->addr); - cmd.params[2] |= mc_enc(0, 32, irq_cfg->user_irq_id); + cmd.params[2] |= mc_enc(0, 32, irq_cfg->irq_num); /* send command to mc*/ return mc_send_command(mc_io, &cmd); @@ -334,7 +334,7 @@ int dpbp_get_irq(struct fsl_mc_io *mc_io, /* retrieve response parameters */ irq_cfg->val = (u32)mc_dec(cmd.params[0], 0, 32); irq_cfg->addr = (u64)mc_dec(cmd.params[1], 0, 64); - irq_cfg->user_irq_id = (int)mc_dec(cmd.params[2], 0, 32); + irq_cfg->irq_num = (int)mc_dec(cmd.params[2], 0, 32); *type = (int)mc_dec(cmd.params[2], 32, 32); return 0; } @@ -502,6 +502,7 @@ int dpbp_get_irq_status(struct fsl_mc_io *mc_io, /* prepare command */ cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_IRQ_STATUS, cmd_flags, token); + cmd.params[0] |= mc_enc(0, 32, *status); cmd.params[0] |= mc_enc(32, 8, irq_index); /* send command to mc*/ @@ -580,3 +581,75 @@ int dpbp_get_attributes(struct fsl_mc_io *mc_io, return 0; } EXPORT_SYMBOL(dpbp_get_attributes); + +/** + * dpbp_set_notifications() - Set notifications towards software + * @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 + * @cfg: notifications configuration + * + * Return: '0' on Success; Error code otherwise. + */ +int dpbp_set_notifications(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token, + struct dpbp_notification_cfg *cfg) +{ + struct mc_command cmd = { 0 }; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPBP_CMDID_SET_NOTIFICATIONS, + cmd_flags, + token); + + cmd.params[0] |= mc_enc(0, 32, cfg->depletion_entry); + cmd.params[0] |= mc_enc(32, 32, cfg->depletion_exit); + cmd.params[1] |= mc_enc(0, 32, cfg->surplus_entry); + cmd.params[1] |= mc_enc(32, 32, cfg->surplus_exit); + cmd.params[2] |= mc_enc(0, 16, cfg->options); + cmd.params[3] |= mc_enc(0, 64, cfg->message_ctx); + cmd.params[4] |= mc_enc(0, 64, cfg->message_iova); + + /* send command to mc*/ + return mc_send_command(mc_io, &cmd); +} + +/** + * dpbp_get_notifications() - Get the notifications 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 DPBP object + * @cfg: notifications configuration + * + * Return: '0' on Success; Error code otherwise. + */ +int dpbp_get_notifications(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token, + struct dpbp_notification_cfg *cfg) +{ + struct mc_command cmd = { 0 }; + int err; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_NOTIFICATIONS, + cmd_flags, + token); + + /* send command to mc*/ + err = mc_send_command(mc_io, &cmd); + if (err) + return err; + + /* retrieve response parameters */ + cfg->depletion_entry = (u32)mc_dec(cmd.params[0], 0, 32); + cfg->depletion_exit = (u32)mc_dec(cmd.params[0], 32, 32); + cfg->surplus_entry = (u32)mc_dec(cmd.params[1], 0, 32); + cfg->surplus_exit = (u32)mc_dec(cmd.params[1], 32, 32); + cfg->options = (u16)mc_dec(cmd.params[2], 0, 16); + cfg->message_ctx = (u64)mc_dec(cmd.params[3], 0, 64); + cfg->message_iova = (u64)mc_dec(cmd.params[4], 0, 64); + + return 0; +} diff --git a/drivers/staging/fsl-mc/include/dpbp-cmd.h b/drivers/staging/fsl-mc/include/dpbp-cmd.h index efa9bf3..c57b454 100644 --- a/drivers/staging/fsl-mc/include/dpbp-cmd.h +++ b/drivers/staging/fsl-mc/include/dpbp-cmd.h @@ -34,7 +34,7 @@ /* DPBP Version */ #define DPBP_VER_MAJOR 2 -#define DPBP_VER_MINOR 1 +#define DPBP_VER_MINOR 2 /* Command IDs */ #define DPBP_CMDID_CLOSE 0x800 @@ -57,4 +57,6 @@ #define DPBP_CMDID_GET_IRQ_STATUS 0x016 #define DPBP_CMDID_CLEAR_IRQ_STATUS 0x017 +#define DPBP_CMDID_SET_NOTIFICATIONS 0x01b0 +#define DPBP_CMDID_GET_NOTIFICATIONS 0x01b1 #endif /* _FSL_DPBP_CMD_H */ diff --git a/drivers/staging/fsl-mc/include/dpbp.h b/drivers/staging/fsl-mc/include/dpbp.h index 37ed951..e14e85a 100644 --- a/drivers/staging/fsl-mc/include/dpbp.h +++ b/drivers/staging/fsl-mc/include/dpbp.h @@ -85,12 +85,12 @@ int dpbp_reset(struct fsl_mc_io *mc_io, * struct dpbp_irq_cfg - IRQ configuration * @addr: Address that must be written to signal a message-based interrupt * @val: Value to write into irq_addr address - * @user_irq_id: A user defined number associated with this IRQ + * @irq_num: A user defined number associated with this IRQ */ struct dpbp_irq_cfg { u64 addr; u32 val; - int user_irq_id; + int irq_num; }; int dpbp_set_irq(struct fsl_mc_io *mc_io, @@ -168,6 +168,53 @@ int dpbp_get_attributes(struct fsl_mc_io *mc_io, u16 token, struct dpbp_attr *attr); +/** + * DPBP notifications options + */ + +/** + * BPSCN write will attempt to allocate into a cache (coherent write) + */ +#define DPBP_NOTIF_OPT_COHERENT_WRITE 0x00000001 + +/** + * struct dpbp_notification_cfg - Structure representing DPBP notifications + * towards software + * @depletion_entry: below this threshold the pool is "depleted"; + * set it to '0' to disable it + * @depletion_exit: greater than or equal to this threshold the pool exit its + * "depleted" state + * @surplus_entry: above this threshold the pool is in "surplus" state; + * set it to '0' to disable it + * @surplus_exit: less than or equal to this threshold the pool exit its + * "surplus" state + * @message_iova: MUST be given if either 'depletion_entry' or 'surplus_entry' + * is not '0' (enable); I/O virtual address (must be in DMA-able memory), + * must be 16B aligned. + * @message_ctx: The context that will be part of the BPSCN message and will + * be written to 'message_iova' + * @options: Mask of available options; use 'DPBP_NOTIF_OPT_' values + */ +struct dpbp_notification_cfg { + u32 depletion_entry; + u32 depletion_exit; + u32 surplus_entry; + u32 surplus_exit; + u64 message_iova; + u64 message_ctx; + u16 options; +}; + +int dpbp_set_notifications(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token, + struct dpbp_notification_cfg *cfg); + +int dpbp_get_notifications(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token, + struct dpbp_notification_cfg *cfg); + /** @} */ #endif /* __FSL_DPBP_H */ -- 1.7.9.5