Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932818AbcLPAEl (ORCPT ); Thu, 15 Dec 2016 19:04:41 -0500 Received: from mail-dm3nam03on0066.outbound.protection.outlook.com ([104.47.41.66]:46877 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932675AbcLPAEW (ORCPT ); Thu, 15 Dec 2016 19:04:22 -0500 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;nxp.com; dkim=none (message not signed) header.d=none; X-IncomingTopHeaderMarker: OriginalChecksum:;UpperCasedChecksum:;SizeAsReceived:977;Count:10 From: Stuart Yoder To: CC: , , , , , , , , , , Roy Pledge , Stuart Yoder Subject: [PATCH v4 3/8] bus: fsl-mc: dpio: add frame descriptor and scatter/gather APIs Date: Thu, 15 Dec 2016 17:56:21 -0600 Message-ID: <1481846186-7783-4-git-send-email-stuart.yoder@nxp.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1481846186-7783-1-git-send-email-stuart.yoder@nxp.com> References: <1481846186-7783-1-git-send-email-stuart.yoder@nxp.com> X-IncomingHeaderCount: 10 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131263202597238170;(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)(7916002)(39400400002)(39410400002)(39380400002)(39850400002)(39450400003)(39840400002)(39860400002)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(104016004)(50986999)(38730400001)(7416002)(4326007)(356003)(8666005)(48376002)(2906002)(105606002)(77096006)(50466002)(68736007)(305945005)(76176999)(106466001)(92566002)(97736004)(47776003)(81166006)(81156014)(36756003)(5660300001)(626004)(110136003)(8936002)(85426001)(575784001)(33646002)(86362001)(50226002)(189998001)(2950100002)(6666003)(6916009)(8676002)(2351001)(5003940100001)(7059030)(2004002);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR03MB2469;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BN1BFFO11FD041;1:SEGff+kg/P534Hxp+5R6dPnx3El95HlL5e5EYkXc6CjeF0tpsMn6KpaTLxNrWPC/5kD6PhIVG0epBojw8ZC/CJ7kpyXgCXBmASZoXbpGXR+JluR8igtIeuqa0IXDRHXotU8xVhegQLgXB7TFdRxZpCmdQSleA+nS9C6ulrOJUrX+26yNWBKsSLIFA3IIa2qXjHfMXdvWfmDqYRHpMg1qbR+E9DZ0Rktv3ER0exBQwC8XRH2JarWASdLl5kefsfHQgfRW7fJJ0OBun+86GCCo1uJCvbeLl9MahldbpUnwbNzvNJIbqd2ztu3iw/63SkY4JUHoR4r9KEoWr3tbALYc2HYKB6DFpjM+VPJogt0EL+GTwos8ceJ5004m7VkgIIxf0kE9bejPeH4XVqEQbk330S1fz/SoskZ+P+tR1BQWKPubeUhRtbGInTHXnPmlujhuhpfERqzGHntaHXGRRae46vmG72TGCL8S5XpdyWBqr22QJKfN3FPGqKZsg0DLvsDzuz7bsH1WAuKKdbt6B99/Co1EMtbUenDRAZn+ctb20WsjBx5VQHD92dJo/pSkRDQ+gNQ8TEVdMMW0AhGhNGOCN8BeuyFk8pwKdieSSaIaAIz15nOEYcNiXfzDB+LyvTynS+B2kNKMR/6aQ+xvQjdXLGqIvMSUWqrIu8+YAB9yLaj3Y/ii6yfwvp8Gr9X7y5W5rKl+fy73afqB8kuOCKmLOKILeiOHqz+SroqZtsD9sLc= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: a0fc4e79-7b8b-4918-6a9a-08d425471547 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:CY4PR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WK1fRAgRL/dm/XirGJVSWTllb+Gnxa/01/fxd8u/EgKr8qwQ24UHmhc758VZd8P7uznG6rjMQ1xCFrdDVwTNpunSkJxKtpfkAdWQvUdFy0cCao2a9qms87096S4kxOyI5j/9IvDdSzNcgOTmRhIOCNpTWivpWRxKtPCITPdkLn433oVxVdd1E/rA== X-Microsoft-Exchange-Diagnostics: 1;CY4PR03MB2469;31:JFy3AQmhPH0WKPM/fXUs+7GTLkiWvarE14ausTR95kCIxC2mJAjZGcvJPblwxSkaxsfqvVNYdYdjk+GPb8cNc31ZyRjfBQQ9snl7fLE05q+7nJQ7ECgwUrIbMvNDpxMOgDvMX7y0Lb1mZJVNqnqSaV0YTYrJrjXKaFm4wJHVJIST23xT5Rquc98lqKAnHIY9SSjOvm7CaMCQJLu6Rxr5hgT+F3PVuiObtRpLvoy3c1RutAX2uQ1ke0v/E1Vx42j5KNfcE9uiDGzNUWtYLZPX1A== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6095060)(601004)(2401047)(13024025)(13018025)(13023025)(13015025)(8121501046)(13017025)(5005006)(3002001)(10201501046)(6055026)(6096035)(20161123561025)(20161123556025)(20161123559025)(20161123563025)(20161123565025);SRVR:CY4PR03MB2469;BCL:0;PCL:0;RULEID:(400006);SRVR:CY4PR03MB2469; X-Microsoft-Exchange-Diagnostics: 1;CY4PR03MB2469;4:9ZiyFyCiAcE53p4Aif6okcg+1lbOWouVycyJcdVfiN5MqQ8izLZXfPcDSfTJ91K581T5XPgm1D1qlgPJV3BXoR0cEiV8VKVdRNX33OuhIBDVnIIEoBdi7GwukAk/N8aJJnaBCzFZPKHFjviYmbm+v2Eh7zzHLgwjJhLhOYO5punGCVA9ZmlTZH52PeQzLQ7CTYcLWfCJx0xx4RFJOmBJYmdgVkDJKA5d3YvR36EHXlDtdn6B/mOxoXxochSRIMC/I5/zG5RJc5QmmFtZhVSsItswFubRLd6mb7hG+1gIkZbfSUKHBt3vlxUT8puptD4pjVL6ON5mURbKj2/Pf5CJ9Vr2su+Tl41CnvM41d4qw26xKBxpXSY4QICswn63iemUiek3r5duPp6CgfNgM+Wvwop5f7i2U01AtPu6Bozqw0waaoVqmovQxeiVWmLZK9vQ/CQ9UPeOhJh8HU5w5LbldAv6UGIubrYNaK4fSmJ0AlmyZmbEiA55XpuiOck+3jPbxo0RveZIYreHbvCx4ir/x8jbsQfZWInczcZRuwIjhB9a4+EHBamSlVcjqlPFiwIF5xDqHIjUQ7S5IAfkQwtzdRi5mmGAM1x1qpEHPDfF9L5S8upxnRa9QsmKw6JVBobWEd2dqShLU/KnIrOfWDOZk9jRBxfCl71+tjb6M6+8lxeL/ErvHPUp7+GXi/EFlQtPJ/Ihxtsihi7mui2hwifW7SYpXXIW2wLbvaHOOw4kyeuI8YiIAGls2vvpD5HqWLDT X-Forefront-PRVS: 01583E185C X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY4PR03MB2469;23:W1rqDz64FvYZS5hf2pWoS38xV1GCqSHAp7hzswQZk?= =?us-ascii?Q?4tMoRNrgI7sVApzYBPLMc2Jcrh8AXGri8OjZWK2LtADyGroL+1VkZYAyA34z?= =?us-ascii?Q?C7zTzzIV5YenwUEvh25Eb9/nS5bU+GKviSXdaE8d4UdZsAMJV+DR/IDkBlqN?= =?us-ascii?Q?dcX/aXqRLF6bhTRB5F2k+L0L0ulQtaXVaF+fgrghwAP8FP0s+x8LHI2XlF34?= =?us-ascii?Q?64dbEk2+j8COxXWl01D/44Ou4dZJ7l8P8ppSzyZ0m318avrymZFofbh1FvC7?= =?us-ascii?Q?izv3F172p0tFdn2B9GGmTa3xvds8GptPEi82fAEOMFjShxmbW3jPdTJb9jKS?= =?us-ascii?Q?3gjTMg0nYOiUxjs9cZ7/MJxDy0Pph5V7Tm/rVKtUJAlDasg7x3AG4+3n6XSy?= =?us-ascii?Q?/Q4mnaPz9GAkeBRCk9I9164Q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?us-ascii?Q?wJCpCEWXJmLPSb8BTd35/Bw+lkMBe/FAWL96xoyVaFoPPnCYA3NfdKk3nV7V?= =?us-ascii?Q?vRp8w=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;CY4PR03MB2469;6:z0D4VlgubOtUXUq4f9xbffE8RmMsFqRDLiXakgW/ldxHByjmUNqPXp4CqHNsdpJz/Q+0vfn1wYbQRhgaJoPJIPEA5tqjNOACHBAn4Z6vsMdl3gQMn74Pq3XcgCRPuU4poIHdZ4PapMatgK2kyTxVNIXKDD9+PUCdgfHG/p/dRaJReqzC0CwEheWmEKmT/sMk0Q6KFYvLZaPC6gBnQtRVdUx/q5qZfLCZWqcwqqMlFefLqUDxl0w2MtKXtF0MFHmiKdpxbKe7kivDBHWeriys0kz/9kC1QwtU5kjf0o2Otd9+S4+Q257wJ+XbXiXqupMc1MVE1x4Ko49TJThxkc5dBAr6UQXswPBfrKApV6WV/jY6Jgb2OwIfoubm2GmnuaKjz/bDCKUGggf75K46AiYHl9ZX+vN+yl/MvXybPVSFW0npUvIA3LVrePfdZRqwFjFR;5:SgmyQibKl6StBRxlR4kGBhGRkCJoBuI3qgBZubkgEoSwL9utvLV3709aVM5Fn90nQYWWDh1Ir4jlOIFEnbgpiMsMX15Xkc7iVQoon33mD94TpGnIt/BfKcgajhGdExaNTaNWfg04CWxb/H82dET4Uwt9mOqIBPbFF0mTu0yelhJtC2IT76xiihcHPEX/j0As;24:h/dqi7VcdkBsGg/GgnixNnf3wV/+hNfrqfz8DnJ0aG6MibYkYKEkSw8TXNM5k+RJ04EjNs/0oeJX8f4x6KzRPHhxikqgqx8JgskmvPjZOsA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;CY4PR03MB2469;7:S4rMb5wgQ9yCgqfAS6Z105RVT6+HBwniaNMj+7frSt9SYT2ltKwsjskDF9MB1fRaB/zbiIMn71L9HDrf8ZHqQjoSiWFIcTWUOHITWdwKYP94W+xH25Sk8HuIg8dd83T4saKX2tkI6Wm80HSpb9LVa/jmB4Tu+el7N5utm0HB2FjYIBFRGzNrbR/SbhkWRyuCo5PieqyTauhdRcyLO5DYCpJZk+RdISRaJkakNEUnFSv7+l0zdV62DJiciI2sO7aDTTe+t92Eoi0e5FpQUxYtnVhQbOrjHdV3L6XAoEc21ibkOZaW/8CQGXmGImUg04P3gWjMgZc7x3lufBeFMnzYT2PHJfNsR1H9biyr/7cu/Jn0smqaDlA4T+bz8YQ/X2wltSFrAHK/y9pFfEDSmsWcG485F2RHYYy0AQ/m/KDWpeLlf9Xe1m/2XutR1usyGoXfDP1x83AtFpQya1GZX/UPMA== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Dec 2016 00:04:14.3574 (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: CY4PR03MB2469 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 14097 Lines: 482 From: Roy Pledge Add global definitions for DPAA2 frame descriptors and scatter gather entries. Signed-off-by: Roy Pledge Signed-off-by: Stuart Yoder --- Notes: -v4 -updated copyright -adjust file location to be in drivers/staging -address cleanup comments-- whitespace cleanup, use !! consistently to convert expression to bool, remove unneeded parenthesis -v3 -no changes -v2 -added setter/getter for the FD ctrl field -corrected comment for SG format_offset field description -added support for short length field in FD drivers/staging/fsl-mc/include/dpaa2-fd.h | 448 ++++++++++++++++++++++++++++++ 1 file changed, 448 insertions(+) create mode 100644 drivers/staging/fsl-mc/include/dpaa2-fd.h diff --git a/drivers/staging/fsl-mc/include/dpaa2-fd.h b/drivers/staging/fsl-mc/include/dpaa2-fd.h new file mode 100644 index 0000000..21102e6 --- /dev/null +++ b/drivers/staging/fsl-mc/include/dpaa2-fd.h @@ -0,0 +1,448 @@ +/* + * Copyright 2014-2016 Freescale Semiconductor Inc. + * Copyright 2016 NXP + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of 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 __FSL_DPAA2_FD_H +#define __FSL_DPAA2_FD_H + +#include + +/** + * DOC: DPAA2 FD - Frame Descriptor APIs for DPAA2 + * + * Frame Descriptors (FDs) are used to describe frame data in the DPAA2. + * Frames can be enqueued and dequeued to Frame Queues (FQs) which are consumed + * by the various DPAA accelerators (WRIOP, SEC, PME, DCE) + * + * There are three types of frames: single, scatter gather, and frame lists. + * + * The set of APIs in this file must be used to create, manipulate and + * query Frame Descriptors. + */ + +/** + * struct dpaa2_fd - Struct describing FDs + * @words: for easier/faster copying the whole FD structure + * @addr: address in the FD + * @len: length in the FD + * @bpid: buffer pool ID + * @format_offset: format, offset, and short-length fields + * @frc: frame context + * @ctrl: control bits...including dd, sc, va, err, etc + * @flc: flow context address + * + * This structure represents the basic Frame Descriptor used in the system. + */ +struct dpaa2_fd { + union { + u32 words[8]; + struct dpaa2_fd_simple { + __le64 addr; + __le32 len; + __le16 bpid; + __le16 format_offset; + __le32 frc; + __le32 ctrl; + __le64 flc; + } simple; + }; +}; + +#define FD_SHORT_LEN_FLAG_MASK 0x1 +#define FD_SHORT_LEN_FLAG_SHIFT 14 +#define FD_SHORT_LEN_MASK 0x1FFFF +#define FD_OFFSET_MASK 0x0FFF +#define FD_FORMAT_MASK 0x3 +#define FD_FORMAT_SHIFT 12 +#define SG_SHORT_LEN_FLAG_MASK 0x1 +#define SG_SHORT_LEN_FLAG_SHIFT 14 +#define SG_SHORT_LEN_MASK 0x1FFFF +#define SG_OFFSET_MASK 0x0FFF +#define SG_FORMAT_MASK 0x3 +#define SG_FORMAT_SHIFT 12 +#define SG_BPID_MASK 0x3FFF +#define SG_FINAL_FLAG_MASK 0x1 +#define SG_FINAL_FLAG_SHIFT 15 + +enum dpaa2_fd_format { + dpaa2_fd_single = 0, + dpaa2_fd_list, + dpaa2_fd_sg +}; + +/** + * dpaa2_fd_get_addr() - get the addr field of frame descriptor + * @fd: the given frame descriptor + * + * Return the address in the frame descriptor. + */ +static inline dma_addr_t dpaa2_fd_get_addr(const struct dpaa2_fd *fd) +{ + return (dma_addr_t)fd->simple.addr; +} + +/** + * dpaa2_fd_set_addr() - Set the addr field of frame descriptor + * @fd: the given frame descriptor + * @addr: the address needs to be set in frame descriptor + */ +static inline void dpaa2_fd_set_addr(struct dpaa2_fd *fd, dma_addr_t addr) +{ + fd->simple.addr = addr; +} + +/** + * dpaa2_fd_get_frc() - Get the frame context in the frame descriptor + * @fd: the given frame descriptor + * + * Return the frame context field in the frame descriptor. + */ +static inline u32 dpaa2_fd_get_frc(const struct dpaa2_fd *fd) +{ + return fd->simple.frc; +} + +/** + * dpaa2_fd_set_frc() - Set the frame context in the frame descriptor + * @fd: the given frame descriptor + * @frc: the frame context needs to be set in frame descriptor + */ +static inline void dpaa2_fd_set_frc(struct dpaa2_fd *fd, u32 frc) +{ + fd->simple.frc = frc; +} + +/** + * dpaa2_fd_get_ctrl() - Get the control bits in the frame descriptor + * @fd: the given frame descriptor + * + * Return the control bits field in the frame descriptor. + */ +static inline u32 dpaa2_fd_get_ctrl(const struct dpaa2_fd *fd) +{ + return fd->simple.ctrl; +} + +/** + * dpaa2_fd_set_ctrl() - Set the control bits in the frame descriptor + * @fd: the given frame descriptor + * @ctrl: the control bits to be set in the frame descriptor + */ +static inline void dpaa2_fd_set_ctrl(struct dpaa2_fd *fd, u32 ctrl) +{ + fd->simple.ctrl = ctrl; +} + +/** + * dpaa2_fd_get_flc() - Get the flow context in the frame descriptor + * @fd: the given frame descriptor + * + * Return the flow context in the frame descriptor. + */ +static inline dma_addr_t dpaa2_fd_get_flc(const struct dpaa2_fd *fd) +{ + return (dma_addr_t)fd->simple.flc; +} + +/** + * dpaa2_fd_set_flc() - Set the flow context field of frame descriptor + * @fd: the given frame descriptor + * @flc_addr: the flow context needs to be set in frame descriptor + */ +static inline void dpaa2_fd_set_flc(struct dpaa2_fd *fd, dma_addr_t flc_addr) +{ + fd->simple.flc = flc_addr; +} + +static inline bool dpaa2_fd_short_len(const struct dpaa2_fd *fd) +{ + return !!((fd->simple.format_offset >> FD_SHORT_LEN_FLAG_SHIFT) + & FD_SHORT_LEN_FLAG_MASK); +} + +/** + * dpaa2_fd_get_len() - Get the length in the frame descriptor + * @fd: the given frame descriptor + * + * Return the length field in the frame descriptor. + */ +static inline u32 dpaa2_fd_get_len(const struct dpaa2_fd *fd) +{ + if (dpaa2_fd_short_len(fd)) + return fd->simple.len & FD_SHORT_LEN_MASK; + + return fd->simple.len; +} + +/** + * dpaa2_fd_set_len() - Set the length field of frame descriptor + * @fd: the given frame descriptor + * @len: the length needs to be set in frame descriptor + */ +static inline void dpaa2_fd_set_len(struct dpaa2_fd *fd, u32 len) +{ + fd->simple.len = len; +} + +/** + * dpaa2_fd_get_offset() - Get the offset field in the frame descriptor + * @fd: the given frame descriptor + * + * Return the offset. + */ +static inline uint16_t dpaa2_fd_get_offset(const struct dpaa2_fd *fd) +{ + return fd->simple.format_offset & FD_OFFSET_MASK; +} + +/** + * dpaa2_fd_set_offset() - Set the offset field of frame descriptor + * @fd: the given frame descriptor + * @offset: the offset needs to be set in frame descriptor + */ +static inline void dpaa2_fd_set_offset(struct dpaa2_fd *fd, uint16_t offset) +{ + fd->simple.format_offset &= ~FD_OFFSET_MASK; + fd->simple.format_offset |= offset; +} + +/** + * dpaa2_fd_get_format() - Get the format field in the frame descriptor + * @fd: the given frame descriptor + * + * Return the format. + */ +static inline enum dpaa2_fd_format dpaa2_fd_get_format( + const struct dpaa2_fd *fd) +{ + return (enum dpaa2_fd_format)((fd->simple.format_offset + >> FD_FORMAT_SHIFT) & FD_FORMAT_MASK); +} + +/** + * dpaa2_fd_set_format() - Set the format field of frame descriptor + * @fd: the given frame descriptor + * @format: the format needs to be set in frame descriptor + */ +static inline void dpaa2_fd_set_format(struct dpaa2_fd *fd, + enum dpaa2_fd_format format) +{ + fd->simple.format_offset &= ~(FD_FORMAT_MASK << FD_FORMAT_SHIFT); + fd->simple.format_offset |= format << FD_FORMAT_SHIFT; +} + +/** + * dpaa2_fd_get_bpid() - Get the bpid field in the frame descriptor + * @fd: the given frame descriptor + * + * Return the buffer pool id. + */ +static inline uint16_t dpaa2_fd_get_bpid(const struct dpaa2_fd *fd) +{ + return fd->simple.bpid; +} + +/** + * dpaa2_fd_set_bpid() - Set the bpid field of frame descriptor + * @fd: the given frame descriptor + * @bpid: buffer pool id to be set + */ +static inline void dpaa2_fd_set_bpid(struct dpaa2_fd *fd, uint16_t bpid) +{ + fd->simple.bpid = bpid; +} + +/** + * struct dpaa2_sg_entry - the scatter-gathering structure + * @addr: address of the sg entry + * @len: length in this sg entry + * @bpid: buffer pool id + * @format_offset: format and offset fields + */ +struct dpaa2_sg_entry { + __le64 addr; + __le32 len; + __le16 bpid; + __le16 format_offset; +}; + +enum dpaa2_sg_format { + dpaa2_sg_single = 0, + dpaa2_sg_frame_data, + dpaa2_sg_sgt_ext +}; + +/* Accessors for SG entry fields */ + +/** + * dpaa2_sg_get_addr() - Get the address from SG entry + * @sg: the given scatter-gathering object + * + * Return the address. + */ +static inline dma_addr_t dpaa2_sg_get_addr(const struct dpaa2_sg_entry *sg) +{ + return le64_to_cpu((dma_addr_t)sg->addr); +} + +/** + * dpaa2_sg_set_addr() - Set the address in SG entry + * @sg: the given scatter-gathering object + * @addr: the address to be set + */ +static inline void dpaa2_sg_set_addr(struct dpaa2_sg_entry *sg, dma_addr_t addr) +{ + sg->addr = cpu_to_le64(addr); +} + +static inline bool dpaa2_sg_short_len(const struct dpaa2_sg_entry *sg) +{ + return !!((le16_to_cpu(sg->format_offset) >> SG_SHORT_LEN_FLAG_SHIFT) + & SG_SHORT_LEN_FLAG_MASK); +} + +/** + * dpaa2_sg_get_len() - Get the length in SG entry + * @sg: the given scatter-gathering object + * + * Return the length. + */ +static inline u32 dpaa2_sg_get_len(const struct dpaa2_sg_entry *sg) +{ + if (dpaa2_sg_short_len(sg)) + return le32_to_cpu(sg->len) & SG_SHORT_LEN_MASK; + + return le32_to_cpu(sg->len); +} + +/** + * dpaa2_sg_set_len() - Set the length in SG entry + * @sg: the given scatter-gathering object + * @len: the length to be set + */ +static inline void dpaa2_sg_set_len(struct dpaa2_sg_entry *sg, u32 len) +{ + sg->len = cpu_to_le32(len); +} + +/** + * dpaa2_sg_get_offset() - Get the offset in SG entry + * @sg: the given scatter-gathering object + * + * Return the offset. + */ +static inline u16 dpaa2_sg_get_offset(const struct dpaa2_sg_entry *sg) +{ + return le16_to_cpu(sg->format_offset) & SG_OFFSET_MASK; +} + +/** + * dpaa2_sg_set_offset() - Set the offset in SG entry + * @sg: the given scatter-gathering object + * @offset: the offset to be set + */ +static inline void dpaa2_sg_set_offset(struct dpaa2_sg_entry *sg, + u16 offset) +{ + sg->format_offset &= cpu_to_le16(~SG_OFFSET_MASK); + sg->format_offset |= cpu_to_le16(offset); +} + +/** + * dpaa2_sg_get_format() - Get the SG format in SG entry + * @sg: the given scatter-gathering object + * + * Return the format. + */ +static inline enum dpaa2_sg_format + dpaa2_sg_get_format(const struct dpaa2_sg_entry *sg) +{ + return (enum dpaa2_sg_format)((le16_to_cpu(sg->format_offset) + >> SG_FORMAT_SHIFT) & SG_FORMAT_MASK); +} + +/** + * dpaa2_sg_set_format() - Set the SG format in SG entry + * @sg: the given scatter-gathering object + * @format: the format to be set + */ +static inline void dpaa2_sg_set_format(struct dpaa2_sg_entry *sg, + enum dpaa2_sg_format format) +{ + sg->format_offset &= cpu_to_le16(~(SG_FORMAT_MASK << SG_FORMAT_SHIFT)); + sg->format_offset |= cpu_to_le16(format << SG_FORMAT_SHIFT); +} + +/** + * dpaa2_sg_get_bpid() - Get the buffer pool id in SG entry + * @sg: the given scatter-gathering object + * + * Return the bpid. + */ +static inline u16 dpaa2_sg_get_bpid(const struct dpaa2_sg_entry *sg) +{ + return le16_to_cpu(sg->bpid) & SG_BPID_MASK; +} + +/** + * dpaa2_sg_set_bpid() - Set the buffer pool id in SG entry + * @sg: the given scatter-gathering object + * @bpid: the bpid to be set + */ +static inline void dpaa2_sg_set_bpid(struct dpaa2_sg_entry *sg, u16 bpid) +{ + sg->bpid &= cpu_to_le16(~(SG_BPID_MASK)); + sg->bpid |= cpu_to_le16(bpid); +} + +/** + * dpaa2_sg_is_final() - Check final bit in SG entry + * @sg: the given scatter-gathering object + * + * Return bool. + */ +static inline bool dpaa2_sg_is_final(const struct dpaa2_sg_entry *sg) +{ + return !!(le16_to_cpu(sg->format_offset) >> SG_FINAL_FLAG_SHIFT); +} + +/** + * dpaa2_sg_set_final() - Set the final bit in SG entry + * @sg: the given scatter-gathering object + * @final: the final boolean to be set + */ +static inline void dpaa2_sg_set_final(struct dpaa2_sg_entry *sg, bool final) +{ + sg->format_offset &= cpu_to_le16(~(SG_FINAL_FLAG_MASK + << SG_FINAL_FLAG_SHIFT)); + sg->format_offset |= cpu_to_le16(final << SG_FINAL_FLAG_SHIFT); +} + +#endif /* __FSL_DPAA2_FD_H */ -- 1.9.0