Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754592AbdCMTDE (ORCPT ); Mon, 13 Mar 2017 15:03:04 -0400 Received: from mail-by2nam03on0085.outbound.protection.outlook.com ([104.47.42.85]:6912 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754342AbdCMTCT (ORCPT ); Mon, 13 Mar 2017 15:02:19 -0400 Authentication-Results: spf=fail (sender IP is 192.88.158.2) 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: Roy Pledge To: , , , , , CC: , , , , , , Roy Pledge , Stuart Yoder Subject: [RESEND PATCH v6 3/8] bus: fsl-mc: dpio: add frame descriptor and scatter/gather APIs Date: Mon, 13 Mar 2017 15:01:59 -0400 Message-ID: <20170313190204.28190-4-roy.pledge@nxp.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170313190204.28190-1-roy.pledge@nxp.com> References: <20170313190204.28190-1-roy.pledge@nxp.com> Reply-To: X-EOPAttributedMessage: 0 X-Matching-Connectors: 131339053375428189;(91ab9b29-cfa4-454e-5278-08d120cd25b8);() X-Forefront-Antispam-Report: CIP:192.88.158.2;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(336005)(39850400002)(39410400002)(39380400002)(39860400002)(39450400003)(39840400002)(39400400002)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(9170700003)(356003)(4326008)(50986999)(76176999)(54906002)(36756003)(33646002)(47776003)(8656002)(53936002)(189998001)(39060400002)(2906002)(38730400002)(105606002)(1076002)(305945005)(106466001)(3450700001)(43066003)(77096006)(5660300001)(6666003)(2950100002)(5003940100001)(81166006)(8676002)(85426001)(48376002)(575784001)(8936002)(50226002)(86362001)(50466002)(2201001)(104016004)(7416002)(2004002)(217873001)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:CY1PR0301MB1961;H:az84smr01.freescale.net;FPR:;SPF:Fail;MLV:ovrnspm;A:1;MX:1;PTR:InfoDomainNonexistent;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD025;1:DvUF6DDyEBuVBsTShc0K0DsFPsrRpfN5HUT9S7iRqmbcc5ZMtuYk4EnLVnTjcY266POlRRu9sDsrCLvAtmW82ozkGS/ostaaPWPvEgJwctIjA3UPbUeCMCyiBX8zmdcj1ZPeS8nOOQcPLpi78aRJ+qixmbShw9/pHnRKhyzq+kuWp0lyXcpd77vrLFsgPX8e5bD3PywkpT5+XGc9LI2bV2vIAyv8JCmlP8R6CVALCal+xBIsWTG2zCUstC+nQg4QChA6dtar8q5UXq77A2lYFLlQ1LIBmZmL7eQ6ToDYeNsuplgoulXcnoawraZ24XCu3vIdG1+WN3/llIWVpgAsmsW5ggFMB5R2d85uJrKBiCXKKw3e1k1uuBEnCUKfzdt6Jpn8Q1+gp+r1V8JdepnqYgpW10irEoJixwX6LKdWpdBAhLpmXW4Af5WFCjJQkZWxpGRCpcVUpOa7qQXPnPzNiKcQZNiO5gj8YJGpO5HjEleTjjMgeh5651CjGx7rN5dIdxZ1JPPyhcDjyNJ7KUfB29YJn6FN45Z0xvrkL+NnghqINd3gvEEc6HOL3aiwhlkIt7+pZNBYvtr+NRWad1BBIbZqt5Vsk4UHEIsjfOFEArTZgs1u/NmQBY/04FEzwYAMjmRrDlXfctLMiOYzvrgEQKzLfnWCFFqQ+rHcvbtMaM6j397G7bT1Ig4fgmp0H8uYfGnU/Y9fXlLClP2Ja3sRXw== MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 985eeb16-885c-4a2b-b50a-08d46a437808 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:CY1PR0301MB1961; X-Microsoft-Exchange-Diagnostics: 1;CY1PR0301MB1961;3:M1AU5PtOFb5omM8kxVieNksOmX3PyeN/xH+7rnD5msSgI2/Y8S+SWrE1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+U+5khC5dVBmGFYlkd2RXwOUdy3sOtrtfUJoo/0tnDtrhJ7UB+xzzkT04AQf01cMQKjno9hNdg1Q= 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)(13018025)(13015025)(8121501046)(5005006)(13023025)(13017025)(13024025)(3002001)(10201501046)(6055026)(6096035)(20161123559025)(20161123563025)(20161123556025)(20161123565025)(20161123561025);SRVR:CY1PR0301MB1961;BCL:0;PCL:0;RULEID:(400006);SRVR:CY1PR0301MB1961; X-Microsoft-Exchange-Diagnostics: 1;CY1PR0301MB1961;4:VQxX8XxSnqDmyMlYKprDQqV9JVJZWpQ613jzVDb0yHIgmjaSGxREDPs5Dv3wTAI5pVTg7NrS5BcC3ygS14jF98hagBcbwIjRZm962WSYGUUefAWxe8/pOZA9c7EM5tWBNJK9gAM9ICKrc3zfOGjbGg8mnrBZaq7v0KaUz6gz3w8Wy+rXfzGdD7o6XKoaLW2kEVFPdmfB+a94KxJpdAHLq6m4diKbi3Vwog+YdqwcdLg36WMbizqVuT8J91u5BoU+M4U2/pwp8giJqf9A/K1+VVUBDdNNyEAVMRjkU8Zda0IDWmPPrXrVTqE5UDEvh3NYGk+lc4CjPTUVWCOO0wkMk5Mb2ly4/8fLhQQ3ygtb5niDzgQzo6dLihDZxLAvMN700Pe4UVU6gzH1USbpvajLmr62qvuMmtc9sGankidhZh6WLwqRqLVOjOE9twCao9JEIaACCiOufDM7imuJzg8LNrnVX8co0q+xLyWlVMqBlnDVTfIToAbzs8Xr843ct70as/Ki7ymUKH3+5Av+5kT0aIx5A6Ar4Q2zlAdq2nYlnhM+ZacsbV1pGuYSYos8P+MupykQQ9JSyizmi+zyJBFMQ8s3G4F4n2dN5Wl5y6uaT1sod0hz4bmru8tNb9/8leYYIKtpAsI8wyMz/5o88XbDxjNx+eHmnHexlGljebyy74WqpOykI2E298oD2Da1R8oBiRJJ8fVlVvbygOIeYjdHb4z4QiK+wV7QVvnZuMtfFS+2Al9GwnzcQoq5SY4irdsr X-Forefront-PRVS: 0245702D7B X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY1PR0301MB1961;23:5OWz5BWD35dpqxL5TnN2hdqw+cefHE5YLReyyJi?= =?us-ascii?Q?m3l31zNb33G5u1w4E2TDo4Ep0oxU4cX1hPhrqlnGI60aJ9O/0qFpb8RsNZyK?= =?us-ascii?Q?0HXkXllIxVovg8F/bYTnbxMhqdBtMAeaC7q9oeCxrnJ5g6j0ZNCDzuj3G3+I?= =?us-ascii?Q?PohKPYHZ4dRqDh8o9NIYWtMcL0Q8GjAHXxWO1uXb1JYz/v0Qe0dkRVFQJH+X?= =?us-ascii?Q?RZcclQ/mMvyVQp2YXPXT7qeNEqOyCgqUh6WE/yR9DUnZBIs7e2hFtVKLo0jc?= =?us-ascii?Q?CS4b+JB4q1zVGWgz4KrD92vTAzwlo6t9K714cTF50xpLRNA1ZMKy56K6309Z?= =?us-ascii?Q?EIrugJXZ2u9bgkVL799A48YOTSPV2TTl1TzrhozD96bwNryfybr2NtdEk7S9?= =?us-ascii?Q?G7UerhdF8JOxCC16U/+T6gZbZTf6bbhDJNX7+St/jwGn1w9VdHk4YJvIiVp2?= =?us-ascii?Q?/BMqVAiKyLreWx8Tq3FXDOtMRZPsn2+XY2nQTQZziQ46QAo4cQtWeF4vyAPd?= =?us-ascii?Q?b8xf0dj6Eoumpbi6nKztjU+7bZz9EdhNcaGNXcim4dgE1vkDHKvdxDi9nkI8?= =?us-ascii?Q?pMviHV8oRddI9DUQr4XGYRvUPpmKXeRx7OpKbT1KdqFlimihujxntTfcOFqy?= =?us-ascii?Q?lNumdJUToA0rgiQ56ClQvGxt8zGDW1tqWf63SyIBnHewbjWgqA1VvgGQpNyk?= =?us-ascii?Q?mv27ny8z0fav04q7ARrX33790P3JNcK27AJwSFJaCnYI25HzhzVhTo6U0AXy?= =?us-ascii?Q?mmKI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P9NvrCz8GjBefHdU07Difz3ZqiC4KjGsd2ZSydqRQ3fUA7mAtIppHj41H3Yq1uoKYDmbrSad/8FmOG+SAgj2x5IGglvcZnHBE9fLcJS/hRWn14uAcNZM4gzDGOEjXWJKvVmuFuc3e8z1wDOL0qI2UwQ=;5:ZRs+lHeL8dBdh2xw4Jt6Y1LI63mKYj45OMl4Gc/sklggAHPht50irL79GdmuWHG1JNtOsD23NnKyKWuPPFxw4GLXHPmWCAd4b6y7y2d3mjOLYFAGvG2rl5gg5AwYQ4IkhCWIwSFWqD92B16Gmh7+j20yqCSzel6UMzBo6cWFiL+pjOlkKbME5RGrFUcAD3xM;24:eyquKVN/1egeO+lNc16Kt2RoePD/37nTmzAIe6K5xG5SKh/ECJqus8qePA+I4Ql6Uv4JOnB7v5V05L49dO/9NcPd3AQEc2Wvppt+oz7EGqk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;CY1PR0301MB1961;7:wPIR+OhHYu7vQruNTuK717uNnc1jOlZ6exWyrv7wD2I+PbtCvvQJ7sBKCRJE35aWC9xr4f1Xl853bgFlSEvpeuco/Ra4Ysw7f95c5j3cZ9Qkmmj30kEGBOZ8uxCbFXSWEV27xT+4a9vT00v3AGJ1toIFWmqhDL6u5V4e78rg0t+jnuHJAUZTkTTMbvLJwFxZONuDECa1kpnLsCL1byrlGc4B9HuS5C1udEMp5XjTwyzVJgzrqd7ZX/IMixSNYMEV3Ih5+MWNqEq6afF/3VMXEpg3kPIH1ikfZ91KCwAu05Rr2T9P6DxdY/fkUmCrVTzoC8d8ul9zHB0+mKlSl7uk/A== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Mar 2017 19:02:17.3088 (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.158.2];Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB1961 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 14205 Lines: 484 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: -v6 -Fix incorrect size of FD_SHORT_LEN_MASK -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..9500123 --- /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 0x3FFFF +#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 */ -- 2.9.3