From patchwork Thu Sep 24 09:10:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Igal.Liberman" X-Patchwork-Id: 522335 X-Patchwork-Delegate: scottwood@freescale.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B45B814017E for ; Thu, 24 Sep 2015 23:31:16 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 97DC61A2E66 for ; Thu, 24 Sep 2015 23:31:16 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from na01-by2-obe.outbound.protection.outlook.com (mail-by2on0112.outbound.protection.outlook.com [207.46.100.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 783791A0437 for ; Thu, 24 Sep 2015 23:24:28 +1000 (AEST) Received: from DM2PR03CA0029.namprd03.prod.outlook.com (10.141.96.28) by DM2PR03MB512.namprd03.prod.outlook.com (10.141.87.22) with Microsoft SMTP Server (TLS) id 15.1.274.16; Thu, 24 Sep 2015 13:09:01 +0000 Received: from BL2FFO11OLC002.protection.gbl (2a01:111:f400:7c09::152) by DM2PR03CA0029.outlook.office365.com (2a01:111:e400:2428::28) with Microsoft SMTP Server (TLS) id 15.1.280.20 via Frontend Transport; Thu, 24 Sep 2015 13:09:01 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; freescale.mail.onmicrosoft.com; dmarc=none action=none header.from=freescale.com; Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BL2FFO11OLC002.mail.protection.outlook.com (10.173.161.186) with Microsoft SMTP Server (TLS) id 15.1.274.4 via Frontend Transport; Thu, 24 Sep 2015 13:09:00 +0000 Received: from b31950-Sun-Ultra-20-Workstation.fil.ea.freescale.net ([10.96.120.115]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t8OD8ZN2000502; Thu, 24 Sep 2015 06:08:57 -0700 From: To: Subject: [v5, 4/6] fsl/fman: Add FMan SP support Date: Thu, 24 Sep 2015 12:10:36 +0300 Message-ID: <1443085838-7539-5-git-send-email-igal.liberman@freescale.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1443085838-7539-1-git-send-email-igal.liberman@freescale.com> References: <1443085838-7539-1-git-send-email-igal.liberman@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11OLC002; 1:rs+Ky0Dzr6Xp7zzsva870jlllFQPB4iQvykMmQm+EDkA41qkunXUpZ355zJEcVFDgzqCxAOXHbQ2Riw8uy/VENLRm2QRMCP9fn8okAWJWn1JilkH/El6Fa5r1mB/fuHUZ5J7p0jqeecWtB4a8O8LidNfHxB3Iq/1W+P61r5k3VQLgOHIAEHw/oLMSQ57tllp7oHn88uc/jk1uFeNyI62N1btA/RlNC+5oHEaSc272WXOk6Zps/BIta9z0LNpxR5tPRPlTCBhaKQ6Krb3L+yiAS+aqDN6/8ChSvqFj+TdtH4NruzP/c1Eam+SywXIHqgpsMabEzmUV9wpNqlLDCwCBJxRz8fsYn+8ZR1hUYIJDPe0O7nu/RNRGbobzOjkVn2J1HJCpxvZ+trjNSPpcsbx0w== X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(229853001)(85426001)(106466001)(19580395003)(69596002)(64706001)(33646002)(2950100001)(87936001)(86152002)(43066003)(50466002)(50986999)(105606002)(86362001)(48376002)(2351001)(47776003)(50226001)(76176999)(77096005)(77156002)(62966003)(5003940100001)(5001860100001)(189998001)(5001960100002)(11100500001)(4001540100001)(81156007)(107886002)(36756003)(19580405001)(46102003)(97736004)(104016004)(5007970100001)(110136002)(5001830100001)(6806005)(53806999)(68736005)(2004002)(4001430100001); DIR:OUT; SFP:1102; SCL:1; SRVR:DM2PR03MB512; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; DM2PR03MB512; 2:yqSh6ImwsH+d70ilOFTFYbKvhJLH5/726RXmrSZNbWdcYDUHAXxtHhMPsiC8YgDEkqLZwTtNx2o8VZxb6kymWDvUh2WC+KfVkqO3Ns/JJ92OpT1rk4HWGBdZSTh5YX6bBIecRo9ABdMZbFIimGSnYRPAFD/jvq0+XwH73R1oNXI=; 3:UAUNk/ntXqz5H8/HRQn7fkYylE85jJQJqnYA/TfyKp50qQtP5ynO0xFAg0GP/kQNf75zeYVGTXuVFNDjuBlltrTpTFt3Qe9/QM5vlEZUF8bJvfU3E9NqBPDkNqUWUy6jmVL+dOFr1dVsLkN3+Y54p7I5Q+RAAYuv24nP1jyH5q0k1v39vQWnvYaZ8ShWO0atoOwjLylO3VaWjRtY6nqlsJfxX+7LLAX9YzOBOA8vDVY=; 25:2swbBngo/nQYSk1CYSoPybbgG4IezQLxqA4rAbnXXvHhrFwPJ/NwofeKlUmL7eXGjUtZj1iSEIHNaEmc18ygDj4da/ceuF+Ow69AAIH34qHodchu7AvIJPRoLS5FAkj3u+3XmXhNJAQUN6sC3iKJNwbGe8x85nzRV18iMvLtTa18piZCuYSYRY3Z/msVaollXWNnE+Vxn/vrUEH7saOAHs0LL3zIhykoqxPODQqZoDvmp9c26deq0w0x5aJx4NVRA+v+HfDaPztETQBh8z299w== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR03MB512; X-Microsoft-Exchange-Diagnostics: 1; DM2PR03MB512; 20:1bLAouY4fleREztwFzzzZI/OTCVaNuZKMmQML449UMGtaPBnARjKaknoQ9YKqzeH8Mz+/XqK/W/+U2OHX2QAiPOY4ysQsxWcw5Z/zeoda0iQSHEQwGT18hCawQkqEtcrCEb+3bNKkwIeCqDgkFkC7g+2Z84Yi/EQw+A2YmiokJrAxw1vTD0WPJ+wzgDa+IRXYORyi2zTZSIzx+aPMyDz9nRWKWxKlmhAh+aKz/z/ssKpoIlQoDHBnWPqK7AWiI1GZglGw7Z4wuTySyAMpIAVVC8shANM7jQVwB2TJauCODWgYadVeKj/MYUZHtuo1v5KgrYEyDioNhiRekOLS1lETocP87uBrGL3c6Z709hOA3s=; 4:g+TdlZOHgqPNmiMN6bkQYtTMG2RRNsgB/1fgAnUNv2TNaAZ9pDL8TB2sDKONXh7fAZ5YoLQb98FMmqP6vCY9dMexBg9eghkNBQcah7LjZfmtwxSdJ8U/xF7zxSVc+FNvMhaRkXDcDlZtlOjgwxXeT5tY6WHCVPf8MMCGj361mlgewkBb9qOfCNeXsHC/QX5ieCufv4fG3V+yi9ep8OqT/737p0Y17L74sMnaeX8260YtcTjZo9BFa7m/FiydBks0IaRqNZQy/8PZHi3X8Kf+av/JhKgwo9hg13BC2iU3oMDC7/E0OeHTG5LZJhyy/UlSqVIvbAqVhVnAUOnad46JAfN4UXbN4JQivBJxF2mW04k= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(3002001); SRVR:DM2PR03MB512; BCL:0; PCL:0; RULEID:; SRVR:DM2PR03MB512; X-Forefront-PRVS: 070912876F X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR03MB512; 23:gxm9W3/N0g6TX/A1wMfJAWdviENwRm4cxWWbWq9nCE?= =?us-ascii?Q?BJfnw50j78VWQqcRPG61BFxRkl9NQaioFP/nuHKtNeq4CT7mos17BwigalBj?= =?us-ascii?Q?/xtb+/Z5wd+ix47xeKsI1DG9hz/AfoS+PIoM0Xnr9wc5794ssD5v00G4QpfW?= =?us-ascii?Q?lsDagtxochZL20rB1ConZoRG1UEKS5urR9iP/6+lQbBA0TLRPsrJ7hBu22yi?= =?us-ascii?Q?dqT6VfzF65j2umzQywTt81yerorgHpavUakgZhflapGn8zlWnu+b4lKJalLd?= =?us-ascii?Q?jrrzxLAFtSI48YyjbFLwR2QUjP6bv/r7D8A3N9GsqVfencPk06gE2H/eOlKD?= =?us-ascii?Q?lLRMbrT3ygZVM2LDhKqbR7UntpNnLcTJCLXQNr3ySkpxRl3wWt/0xzD+Ak1c?= =?us-ascii?Q?u8ZMNT4FFoUK4k79LX/lLY/h2QeH/xhTTnoIOX7kSWYvb1/0aZLf6Obtc/Rk?= =?us-ascii?Q?UJmGcJx3Yjcef/hwW1xZFZUDDIwMaSrxjf60efLWGH+B+YzGisF/6U6YR3ge?= =?us-ascii?Q?PLZKAHTcMXHrPR/O45g4c2KihH3a2km4VFqtP906wXygkSx5OZ82cWmkqkls?= =?us-ascii?Q?+b+lQam3OKGjlJmMNBzjXd1uPFZpgLOUtQNelVOAx+JC0yAY5uWvwyWOTnUn?= =?us-ascii?Q?IjTq/KA/bavLugGErgToxZpeB9ZCQjO0ZBaOeJJwwY/qfK3VEnxIiC9knEis?= =?us-ascii?Q?tdHleiC+c6emKbLpyst0JAc9Q8/ap6/GnE34dYHEaevMIJySes0zBVyjEMSP?= =?us-ascii?Q?jsjk3efcHTmPbhBgcASH8+kHXCdWzrJ149z8mmMu8Y3GsSM779VYZ9cOAFfD?= =?us-ascii?Q?ZIQ4SbIQWXJigaMWzqRljrIwrG2KuLwcK2kjQeuNOsbd3ewKmKBBoVGo7QLE?= =?us-ascii?Q?0+MY872Vib7CCsYASj8VtKlQLfdM+KIHa4QyJrSxaW0K2wpsvoVZm/JTB0dq?= =?us-ascii?Q?jsXELQavJ7Ay2p85Z0Kcp4ULtuNHGqTrSXg5xGd2IyKN4Oqp8enA3N+Cxef6?= =?us-ascii?Q?RLyqYFR5pWaQUstTHaiFYG+rRzGKC6IJAjONQ6Zi5vjM4s/L7oIRjCmpUMXJ?= =?us-ascii?Q?WwATxamu+vuFBIx8UFXT8Msjqd67gEHNDQckdCBXav4HFgGrBsCHUIklS8Mz?= =?us-ascii?Q?IxJ3StimTrrFnCHCW1kbCIX7+NRmMTpmYWFh1CZXKXUxv526TKcFkyI7oRUn?= =?us-ascii?Q?dF17xDQNh4B/NXfohnSXuRREW7L+yR4SeRQyacSD5YJs0V5Wh5mkR6cDVS5X?= =?us-ascii?Q?rOlw5F7tF0PFRqbwjG0kcbqzLw3Mh+rDpyli4EfwND8bMKpHa0AXCh07YGII?= =?us-ascii?Q?fuwpNhwyqxWQqvLsz+3mwJ4inFktsx9GXYK15yne4l?= X-Microsoft-Exchange-Diagnostics: 1; DM2PR03MB512; 5:85Ylk/LDEMKksHwekhezOozbfDGWkEl0wF/728a6AgD/+uMDXHyQw1Mx4N3/5ZUbExsw4ek1tjA7sNU0WsI7rjR6YPSQOOoV578Wpq1F2F3ueALla70iTyEa4I/jSb0v7P2AJBm79uwuBx+VUPVqtg==; 24:Vxv4juiKHKvaJSz0JqSJGTVfrOvWB0bxXKmyULqRz8u5qUADzFCUFpRg+tg1/Em8sDawWG1w3LOkRV5uQ2ZjGgk7NQXOuLScx8tDoeN8Xwo=; 20:YxBpFnhtURMpyCT/XZSr49gr7h2X979kMNdEH5Vhe4ykGuQRj/KievACZzsAN42nUc299KcyfRP04bGd9ofs+w== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2015 13:09:00.5452 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR03MB512 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: igal.liberman@freescale.com Cc: pebolle@tiscali.nl, linux-kernel@vger.kernel.org, ppc@mindchasers.com, stephen@networkplumber.org, Igal Liberman , scottwood@freescale.com, linuxppc-dev@lists.ozlabs.org, davem@davemloft.net, madalin.bucur@freescale.com Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Igal Liberman The Storage Profiles contain parameters that are used by the FMan for frame reception and transmission. Signed-off-by: Igal Liberman --- drivers/net/ethernet/freescale/fman/Makefile | 2 +- drivers/net/ethernet/freescale/fman/fman_sp.c | 167 +++++++++++++++++++++++++ drivers/net/ethernet/freescale/fman/fman_sp.h | 103 +++++++++++++++ 3 files changed, 271 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/freescale/fman/fman_sp.c create mode 100644 drivers/net/ethernet/freescale/fman/fman_sp.h diff --git a/drivers/net/ethernet/freescale/fman/Makefile b/drivers/net/ethernet/freescale/fman/Makefile index 43360d70..5141532 100644 --- a/drivers/net/ethernet/freescale/fman/Makefile +++ b/drivers/net/ethernet/freescale/fman/Makefile @@ -2,5 +2,5 @@ subdir-ccflags-y += -I$(srctree)/drivers/net/ethernet/freescale/fman obj-y += fsl_fman.o fsl_fman_mac.o -fsl_fman-objs := fman_muram.o fman.o +fsl_fman-objs := fman_muram.o fman.o fman_sp.o fsl_fman_mac-objs := fman_dtsec.o fman_memac.o fman_tgec.o diff --git a/drivers/net/ethernet/freescale/fman/fman_sp.c b/drivers/net/ethernet/freescale/fman/fman_sp.c new file mode 100644 index 0000000..f36c622 --- /dev/null +++ b/drivers/net/ethernet/freescale/fman/fman_sp.c @@ -0,0 +1,167 @@ +/* + * Copyright 2008 - 2015 Freescale Semiconductor Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Freescale Semiconductor nor the + * names of its 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 Freescale Semiconductor ``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 Freescale Semiconductor 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 "fman_sp.h" +#include "fman.h" + +void fman_sp_set_buf_pools_in_asc_order_of_buf_sizes(struct fman_ext_pools + *fm_ext_pools, + u8 *ordered_array, + u16 *sizes_array) +{ + u16 buf_size = 0; + int i = 0, j = 0, k = 0; + + /* First we copy the external buffers pools information + * to an ordered local array + */ + for (i = 0; i < fm_ext_pools->num_of_pools_used; i++) { + /* get pool size */ + buf_size = fm_ext_pools->ext_buf_pool[i].size; + + /* keep sizes in an array according to poolId + * for direct access + */ + sizes_array[fm_ext_pools->ext_buf_pool[i].id] = buf_size; + + /* save poolId in an ordered array according to size */ + for (j = 0; j <= i; j++) { + /* this is the next free place in the array */ + if (j == i) + ordered_array[i] = + fm_ext_pools->ext_buf_pool[i].id; + else { + /* find the right place for this poolId */ + if (buf_size < sizes_array[ordered_array[j]]) { + /* move the pool_ids one place ahead + * to make room for this poolId + */ + for (k = i; k > j; k--) + ordered_array[k] = + ordered_array[k - 1]; + + /* now k==j, this is the place for + * the new size + */ + ordered_array[k] = + fm_ext_pools->ext_buf_pool[i].id; + break; + } + } + } + } +} + +int fman_sp_build_buffer_struct(struct fman_sp_int_context_data_copy * + int_context_data_copy, + struct fman_buffer_prefix_content * + buffer_prefix_content, + struct fman_sp_buf_margins *buf_margins, + struct fman_sp_buffer_offsets *buffer_offsets, + u8 *internal_buf_offset) +{ + u32 tmp; + + /* Align start of internal context data to 16 byte */ + int_context_data_copy->ext_buf_offset = (u16) + ((buffer_prefix_content->priv_data_size & (OFFSET_UNITS - 1)) ? + ((buffer_prefix_content->priv_data_size + OFFSET_UNITS) & + ~(u16)(OFFSET_UNITS - 1)) : + buffer_prefix_content->priv_data_size); + + /* Translate margin and int_context params to FM parameters */ + /* Initialize with illegal value. Later we'll set legal values. */ + buffer_offsets->prs_result_offset = (u32)ILLEGAL_BASE; + buffer_offsets->time_stamp_offset = (u32)ILLEGAL_BASE; + buffer_offsets->hash_result_offset = (u32)ILLEGAL_BASE; + + /* Internally the driver supports 4 options + * 1. prsResult/timestamp/hashResult selection (in fact 8 options, + * but for simplicity we'll + * relate to it as 1). + * 2. All IC context (from AD) not including debug. + */ + + /* This case covers the options under 1 */ + /* Copy size must be in 16-byte granularity. */ + int_context_data_copy->size = + (u16)((buffer_prefix_content->pass_prs_result ? 32 : 0) + + ((buffer_prefix_content->pass_time_stamp || + buffer_prefix_content->pass_hash_result) ? 16 : 0)); + + /* Align start of internal context data to 16 byte */ + int_context_data_copy->int_context_offset = + (u8)(buffer_prefix_content->pass_prs_result ? 32 : + ((buffer_prefix_content->pass_time_stamp || + buffer_prefix_content->pass_hash_result) ? 64 : 0)); + + if (buffer_prefix_content->pass_prs_result) + buffer_offsets->prs_result_offset = + int_context_data_copy->ext_buf_offset; + if (buffer_prefix_content->pass_time_stamp) + buffer_offsets->time_stamp_offset = + buffer_prefix_content->pass_prs_result ? + (int_context_data_copy->ext_buf_offset + + sizeof(struct fman_prs_result)) : + int_context_data_copy->ext_buf_offset; + if (buffer_prefix_content->pass_hash_result) + /* If PR is not requested, whether TS is + * requested or not, IC will be copied from TS + */ + buffer_offsets->hash_result_offset = + buffer_prefix_content->pass_prs_result ? + (int_context_data_copy->ext_buf_offset + + sizeof(struct fman_prs_result) + 8) : + int_context_data_copy->ext_buf_offset + 8; + + if (int_context_data_copy->size) + buf_margins->start_margins = + (u16)(int_context_data_copy->ext_buf_offset + + int_context_data_copy->size); + else + /* No Internal Context passing, STartMargin is + * immediately after private_info + */ + buf_margins->start_margins = + buffer_prefix_content->priv_data_size; + + /* align data start */ + tmp = (u32)(buf_margins->start_margins % + buffer_prefix_content->data_align); + if (tmp) + buf_margins->start_margins += + (buffer_prefix_content->data_align - tmp); + buffer_offsets->data_offset = buf_margins->start_margins; + + return 0; +} + diff --git a/drivers/net/ethernet/freescale/fman/fman_sp.h b/drivers/net/ethernet/freescale/fman/fman_sp.h new file mode 100644 index 0000000..820b7f6 --- /dev/null +++ b/drivers/net/ethernet/freescale/fman/fman_sp.h @@ -0,0 +1,103 @@ +/* + * Copyright 2008 - 2015 Freescale Semiconductor Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Freescale Semiconductor nor the + * names of its 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 Freescale Semiconductor ``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 Freescale Semiconductor 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 __FM_SP_H +#define __FM_SP_H + +#include "fman.h" +#include + +#define ILLEGAL_BASE (~0) + +/* defaults */ +#define DFLT_FM_SP_BUFFER_PREFIX_CONTEXT_DATA_ALIGN 64 + +/* Registers bit fields */ +#define FMAN_SP_EXT_BUF_POOL_EN_COUNTER 0x40000000 +#define FMAN_SP_EXT_BUF_POOL_VALID 0x80000000 +#define FMAN_SP_EXT_BUF_POOL_BACKUP 0x20000000 +#define FMAN_SP_DMA_ATTR_WRITE_OPTIMIZE 0x00100000 +#define FMAN_SP_SG_DISABLE 0x80000000 + +/* shifts */ +#define FMAN_SP_EXT_BUF_MARG_START_SHIFT 16 +#define FMAN_SP_DMA_ATTR_SWP_SHIFT 30 +#define FMAN_SP_IC_TO_EXT_SHIFT 16 +#define FMAN_SP_IC_FROM_INT_SHIFT 8 + +/* structure for defining internal context copying */ +struct fman_sp_int_context_data_copy { + /* < Offset in External buffer to which internal + * context is copied to (Rx) or taken from (Tx, Op). + */ + u16 ext_buf_offset; + /* Offset within internal context to copy from + * (Rx) or to copy to (Tx, Op). + */ + u8 int_context_offset; + /* Internal offset size to be copied */ + u16 size; +}; + +/* struct for defining external buffer margins */ +struct fman_sp_buf_margins { + /* Number of bytes to be left at the beginning + * of the external buffer (must be divisible by 16) + */ + u16 start_margins; + /* number of bytes to be left at the end + * of the external buffer(must be divisible by 16) + */ + u16 end_margins; +}; + +struct fman_sp_buffer_offsets { + u32 data_offset; + u32 prs_result_offset; + u32 time_stamp_offset; + u32 hash_result_offset; +}; + +int fman_sp_build_buffer_struct(struct fman_sp_int_context_data_copy + *int_context_data_copy, + struct fman_buffer_prefix_content + *buffer_prefix_content, + struct fman_sp_buf_margins *buf_margins, + struct fman_sp_buffer_offsets + *buffer_offsets, + u8 *internal_buf_offset); + +void fman_sp_set_buf_pools_in_asc_order_of_buf_sizes(struct fman_ext_pools + *fm_ext_pools, + u8 *ordered_array, + u16 *sizes_array); + +#endif /* __FM_SP_H */