Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161267AbcLPQy3 (ORCPT ); Fri, 16 Dec 2016 11:54:29 -0500 Received: from mail-co1nam03on0054.outbound.protection.outlook.com ([104.47.40.54]:30720 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1161212AbcLPQyJ (ORCPT ); Fri, 16 Dec 2016 11:54:09 -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:980;Count:10 From: Stuart Yoder To: CC: , , , , , , , , , , Roy Pledge , Stuart Yoder Subject: [PATCH v5 3/8] bus: fsl-mc: dpio: add frame descriptor and scatter/gather APIs Date: Fri, 16 Dec 2016 10:31:01 -0600 Message-ID: <1481905866-10816-4-git-send-email-stuart.yoder@nxp.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1481905866-10816-1-git-send-email-stuart.yoder@nxp.com> References: <1481905866-10816-1-git-send-email-stuart.yoder@nxp.com> X-IncomingHeaderCount: 10 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131263799410295226;(91ab9b29-cfa4-454e-5278-08d120cd25b8);() X-Forefront-Antispam-Report: CIP:192.88.168.50;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(979002)(6009001)(7916002)(336005)(39840400002)(39410400002)(39450400003)(39850400002)(39380400002)(39860400002)(39400400002)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(8936002)(76176999)(86362001)(575784001)(189998001)(38730400001)(50986999)(68736007)(5003940100001)(77096006)(50466002)(50226002)(33646002)(104016004)(97736004)(48376002)(110136003)(356003)(47776003)(2950100002)(8666005)(6666003)(6916009)(626004)(36756003)(7416002)(5660300001)(92566002)(305945005)(85426001)(81166006)(8676002)(4326007)(106466001)(2351001)(2906002)(105606002)(81156014)(7059030)(2004002)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR03MB2466;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD042;1:XTzeXRXiXe7SpV5SUvTIryPQ84mTCo482MsVtUuNsBJXEDbInRL7hu9RG9lDClp8UAtKDKX4AChqOjtsexubCdBJTxAYCc9maQ87CmkB6cJYUmt7wqzI/MyiQNhEcdrBrd7ZBir9eMFnAVlY1AOTLY2cC7iotv1IB60zUXfM3KBEZxnKidGN32xH9UdFNI7A074z6WVQMUWSKGFOB2v5bvnqjpUrFknY8J8mxkD9lq/FKJ8+3mHaM6hf9pXsYmDx3ozU/iQETSEtxTQ5b56y8XMGSAe8yDXNztH4gqyrXFjRuk8K/lHcoX+8+dYvXybkZ3rfy5d8EajlwXDZvPFE1fRq1Tq/dSC719VR4jqMu8weHFV8XrUFwYsQYDGRhrJZxRXMXUIZ0dg8GHgh+/PT5MiH2AY+GEZYx6RBisxCk0tScu/or9nOAKIxQDsRcyviJh+P2WJF8c6dC8JXNfb0M/389fuGUrK9kJG6YRdPiBi3cw5sxgDoSivuiS2r7CzPjFcaGG50SHQZTbeRGJQqq7LeC7F9lRK+wyKUFeJ8d+BHDP7InGTkiRPDKxrBSH5Yh/V1fTBTMFocDH0gCk7S5ucHqjyLrCQutJ7YZk6KqpsJ9Gd7B2Ss8c0FZaQLR9Qbgek353wAKRSlYYqW6xZgowxhALuQ1Cw5g7cR2amkQ8p6072hZUJTbeeERMXXsegg0347NKih632shMHRAOgqvNUJiU3HKDMAp56E7lJUIlM= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 2ed48c38-2ec2-4e7a-f6b2-08d425d20a1b X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:BN6PR03MB2466; X-Microsoft-Exchange-Diagnostics: 1;BN6PR03MB2466;3:a7nK6cHtnacZrwUF1DBuqEpL0HOR5b0wjm2P4yydWWyK/4dQYrhUi5/RZiKMVLHV0z8GRgZCF3+ANX5XLSn9hmVx99vlMzAP7o61x9C7Mdn/becODFGkc7dKZeM5T5q8hqWsPNYILX39Pn0A7QiCnA8OZfDLG2y0Wk0pX2ZCri/dcrREK1PcW5gB5hvhJjO+XUsN6sfJoRr96lUiJkTLRR+/JKrA1IAtPcgo3yrtHlmRwtd/fMJaDusX8VgxXaUAizkdrP/AYoSGZezkx85qulKqbBr/j4js/mfD/rOvUaKFDho1UZBn7BY5zbS3Fn75/odf5ihRehe0BqQjhYEoO7oXG71GbeQxuEuL7oCcUjpdiRUU55MZjRMOFtG7P55C;25:nrw3QsXtEX2/lDNe514P9Cb1WihoDn4sZcB2lUXr5rcZ8WciJNDO3kBeZPmXj5qpjkcxBJTqnN8gQJu/g//eeSUSApTUScnnOCXXGlTfzzy09+iCcAihNUdOnQjiYCoXKsf36M1n1OKT8HBidgpq2O4/ZM14FrLyB+PN6/QYmykNlbklcPzVIlUtckPrMn1iI1gazc01ZfbedNeZ8os1iAKBNUfKMtdobHBtQ75xn8DktjEcD5erDNeT2ZKu2kKQL9hjmAxh8v+37kZJObR43f2pjqwaRVPVGHCc32at58Qe/jEbxsMEpMsH/boA8inb01guvY3w723ZAvFdENjwaco30p/ZySDxoRxk0Aqfn8R32e+pF92OKzLS2nBEfDCEpFDACmAcPaYI7R++2oc+KVclE75spc5/VGkZrskkHcHL3XXyZUvjAkjZUOFD7sIQOPbxSaEvIx9v0wBPuDP2oA== X-Microsoft-Exchange-Diagnostics: 1;BN6PR03MB2466;31:MiMYUyqHziDzKw5gGfnTTWYqYky71zOUpEeai3RlX8pG44WSTG5h/DGOtNbfHzShOeUeytWMz+ljERy/OkWT1KwtGF28fxrW6oL5LoIZKe6+7dFi94UTSxvrpwUvg6ZlMPqSHZazxc8t1r76FIBUWz70S7FzrMG+6tDJp5vQBC7WgtPYR1QajyjB2ZpgEJQK5FEFPsX23qR3Yxp3AWJeqfHT5mKGAH8pV8UGs/IpyZu8EgbicSzi0QIMCLnTf3AtvSU22eZ+EF1B4eL1Vp+4Hw== 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)(13015025)(13024025)(13023025)(13017025)(5005006)(8121501046)(13018025)(10201501046)(3002001)(6055026)(6096035)(20161123561025)(20161123559025)(20161123556025)(20161123563025)(20161123565025);SRVR:BN6PR03MB2466;BCL:0;PCL:0;RULEID:(400006);SRVR:BN6PR03MB2466; X-Microsoft-Exchange-Diagnostics: 1;BN6PR03MB2466;4:DQKK+i9vDHZRXbypMbNNqKIsdAOoJSGlK7FMP0YS5FQRhe2Q+HSDcHTeilleCPro1RepOPYrIdVsaQR/BYvwWLha51pPKZ4j9g0TFkiJRvZDUBPc20Dyu9DRm8cuUg4nPSopaXLqLTmWriiePks1/HtfrhjZvB8oMrfMGH4TF7eIVB3njyorm5Xyx44f42SedVh5cRErR804jUk31DOVqjpQkcC63HksBKOLgV/a3veRQH0fRuZMo2QD8KABrdsE9MAAA8uUCHagOOEO9S/hb2zRDBNxDQl8EPupw4IRxOhNASGmX70LelDjBMhSNCasQLQEl3F2whAVHywUG2CZvL+Q8Rz37ArkNPV0OnR75hVsSzmaY7py0dB4I56QNpSrQ+CFVg5cTLcnd8SdhSBH/noFiLBsF0VugOW6zEWpKRxsNEvuFBwJQWBYLERDtxy6JSiH/JqKxZVW+dVQ+4Xsw3TPYuq0YnsjhbPTHGH7xSzltTY4il5Nc5kgOvq48YXfQdp90Sr+3nLwKoOkEBjYONafhw+VkGSH+mQ98NtXg55k/xFr1uvR1BvdkzVvTseoVmyqqEldgmsE5HgkZ18frASh6B+0ta5UZ0f2MBtC3rVbwS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REvljx0P0KveUbHZSfRue+Dw7O1SDVVPpdHjr/F8sj0h7G5e0IyDb8dhBl95jBKaYSnYXK4IVsJhze3gxlQjld85ICDFegAOYA2+Ny3sfmn5mXidkyUaxRLApwcqbUYDeHDs60cVPxH5XBvszbwBKCT77kMlKXOYTj2HpaZJ//ssnfEIO4aQUWNASk8W8GhV2qeS3HWqEOEWjBwpyXGyKvJciNYHE9OgN9vQFlj82uHikWMougzI98BP8q3QnhYpKA3SAsBfVik/VQbex3lvw7xazjNromaRJqsZFw4pW3H0A7nchmC+7epdv7W+UqvZ3/OG+U4kLTvECCC;5:bk1JWun5mbzRtJ3A+7mWyVWhYadvmRmbUzNY1rkKjWksTeZ7OtOkZC0pMvB6CaC2AhRGJiXe0xURKqqMF/JclD+KxWcE5Drmx+wGroKzcihBeUqMesiM2h3RykA4qG8KrOJAn+QUtubXbvLd55MR5zlHWY8eCoUXd8/eNzeQX4hpaswPlep95olxVJs/qhwz;24:tITi4ugQP0HxXN9RnSEietDNErXs0rtn20JmulAqxc88HlQuC470x4kwqRtsiB6k0p/9v0biQTNmrzUfTaiN5ImbYKMp9oL2e2d3vIBbtHc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BN6PR03MB2466;7:YtLvb4Vg9a1i6akR+UonQ34VqmxmhGFazAYpadZi9J6oP1WRErou+E8njbLXqCRvAuDpD0eHL0oYziXXtiFtMq/Nay3I8MzTU/PBNloKF6d0GeEIjamEPmOTHREd9H4agB5JCMMPQNLZnQFZ1DJ01IFGfFDeQ8ftcH9oomwMPirbqvxf2yM8e5hmSB4oJ0UsilU8BhzHqxBj46lM4c0MCbxzKB0puIyMlagE/eeGiPB8ZPF8SObd+CtvXszoXSOuo13hW+nHEsMQYvRHWaAOG9lxEdjHI34hpsAC5HcCSg5OgnC4Nbrwde0iPLyt7N/DjCMuqfS2w1rKt/ry5CgCog9VJdNX6CFd2+tU2mt1saX5Qi0cOwOjnL2fBhNp2gKh6Q0WcXhWYmUOsJqhYrHRstolL4yl73MfnKDVQMtunbr9526tAy2yz6WQtecBTzH2KClbMQXNLv1syGSZ/XYThg== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Dec 2016 16:38:54.8206 (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: BN6PR03MB2466 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