Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934666AbcKPUQz (ORCPT ); Wed, 16 Nov 2016 15:16:55 -0500 Received: from mail-by2nam03on0083.outbound.protection.outlook.com ([104.47.42.83]:62409 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934381AbcKPUQv (ORCPT ); Wed, 16 Nov 2016 15:16:51 -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:1028;Count:10 From: Stuart Yoder To: CC: , , , , , , , , Roy Pledge , Stuart Yoder , Laurentiu Tudor , Ioana Radulescu Subject: [PATCH v2 4/9] bus: fsl-mc: dpio: add frame descriptor and scatter/gather APIs Date: Wed, 16 Nov 2016 14:09:54 -0600 Message-ID: <1479326999-29340-5-git-send-email-stuart.yoder@nxp.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1479326999-29340-1-git-send-email-stuart.yoder@nxp.com> References: <1479326999-29340-1-git-send-email-stuart.yoder@nxp.com> X-IncomingHeaderCount: 10 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131238010094378577;(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)(7916002)(2980300002)(1109001)(1110001)(339900001)(336004)(189002)(199003)(92566002)(33646002)(4326007)(6666003)(356003)(575784001)(6916009)(8676002)(86362001)(50226002)(104016004)(2906002)(626004)(2950100002)(7416002)(97736004)(77096005)(68736007)(85426001)(189998001)(87936001)(8666005)(110136003)(105606002)(2351001)(76176999)(5003940100001)(305945005)(47776003)(7846002)(50986999)(81156014)(106466001)(8936002)(50466002)(48376002)(36756003)(5660300001)(81166006)(7059030)(2004002);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR03MB2468;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD036;1:ajXCkPmbOT9Mu2rs7rNsnT9zyShq6OYYIeyOCoDsqzipLaplfBICdWpXlsNNBYyeX5yPMRnT84aVX0u8gVMctTJ2Ju3AxiJ4o4Q0uRruQbF5RiBTRimbZ/loU2/TXiK1Pk9eWv7y0ehZT79byq0kKy07QEhe6PqpuIoFlJBI7Rzikq9Ptiw/P7SAhiwm6rbQ4EN3nnmbFn5UKofelcCUw1V3seumTQs5Ivpzt0aNqoCzott7ezMBDjyDaYv3QEd8klPMDaNuyIlgH/J47kJYkQqTXY+BvbeWQd1x5HM53I5lMjKQ2SUrYGEbXrGadozpIDW4UZ0kXRROgFXdKSmh3+CsAmfwAQOG7N6NSNemkqXc0CUanflRQLtaxUcCQ/fNJpGfSkKMLOOWOwu3W4AViY78Usc0d4N1bZSNYfoDLw88tvkoGcSR1FAFkyn+yyxgCtglg+UxqpQeKj9WwfUm+Zu2qa8WwgAg8SRAwoNhJgvrmkDctkVGJpLfIpXfmWQxs+8jXjXrARy933qrs1w5hZ9SCMasYugkEEXoeXPWcq963FrcqwM2iaIoqeZhHBZzgP6KAh8fHLwgJdn4H5wnJNKO6JtmW53WlFrMubVt/2cgVWNEL8eB6nXlKRDmkR6o9VpPOiU1c/Fh7VA3uAYixeNSkzYcgiUgINgyQ6dkim5nmkqTqEBUxJlq0Ssj635bU4p2beFQBZJrOj40JB1N+yyiPAGmJgdj505MwlENG9g= MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;BN6PR03MB2468;2:EVVgkzah5Rv7qaP4bJGBbJjoqeQEfGcq/zMSzFSg4w/oGH6nMCBFXG/4GVFYlnn5N+9H8NAheaUknl0nmo9tMZg8oEmz3jl9ezkYnevtqfn33A2zbz4G1beERFDCShmo+saFGRVOJmPIhpcXmbAlQswkIPx9TswoVk7ivDv7eZY=;3:fj26MX1xpOphBrSvyna6qqSo98uG2rAQh3gY/eBfvX53kVRtYlY2dPK/Ek8wSr5oEjAaq/hrzj+fXx+iyPCbxUBk96pp9ryvHy+2DbzF73WShPMe661YMp1ao7y08kjMqoaM+2LFdd9BlKuZkol22+oYaDYa7WgCpS7B5izCH0z4/VLgOwGnOXqHNtQH6GYAzRdp4WpwSNG7O+a4rGG8KiHoRAAMEvR8Dj5ngbBa6Fuf2WWt/qf7zipWjMykkUrFfSJN1sNUSHzxOSQVnbjd0g== X-MS-Office365-Filtering-Correlation-Id: dbf5eca7-cfd3-41db-f1df-08d40e5d7f15 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:BN6PR03MB2468; X-Microsoft-Exchange-Diagnostics: 1;BN6PR03MB2468;25:PmGtI89TBPysR3Msg29qzn/M80AdV5Ax4WNjAvpdH0nz1GqhhLmVUKuNkpn9LiGgGpZoKWI68grrlnx5ELv2WO1ssAFa5CqRGRWnxwcp6L8xjo1OnsxhZfy4h7lljYaqMUZb7AVQSBOhqRqXligTCXhj7Kp30/8GaLWLmvvON5xO4U9nujH5CLLBSpHJrcci5+27M657+jf//9U/yK6D/KSZ+AkscWaTHa+HhlHGiLAXOswCXMnLtO6xiiEsy3isLx+CtOfktLbXmct979QZx44eqZyfxuAR/gMnitK4Ni4YhvSjjYHJgr9KH7CnBtswuLxzZbyp9Htim0k2RonmNmJqu2vO6V855jQw0Ad45AnvWZnGalx1uTtB62bF5Ba0u7IGnvq60lZSSRLWpNy5UuA8xYXmdNR+c9r04avHaZekPx5dHAtYOD1VYV+3p+V1biGACBEig0cpJoqDwoCK300qcLD16vebEouhDfsQMdtJ8xetjvrXpUPcpg09rQOLHVh8x1lhu1WUj1nhUcCi9bOfzP6LCL41Mf8fMx0GaGX+6qXhL5De9Hi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OVgpfYSJB5+cwTUm/jfsmCs7BDAhHhvCIqaLP9wo5emJB10bx7zTFAkkv2J5kF4M+dyW5bJgEvD/Q== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6095035)(601004)(2401047)(13017025)(13015025)(13024025)(5005006)(8121501046)(13023025)(13018025)(10201501046)(3002001)(6055026)(6096035);SRVR:BN6PR03MB2468;BCL:0;PCL:0;RULEID:(400006);SRVR:BN6PR03MB2468; X-Forefront-PRVS: 01283822F8 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN6PR03MB2468;23:/Cd8RviIYehhCDXd94ZT3h9tDh02L08yhFq/gQiXM?= =?us-ascii?Q?9IlbGX5j2kUDGUCJlE0/yBO1ys6kxdM5ywThvv2cklQciyKwzgierf8DEmjk?= =?us-ascii?Q?mhzXtXGqBtIe2g0/084RHwuC/bN+LmQAF7MssApm8P4IpQWW+spbJeyLTgpl?= =?us-ascii?Q?bzmZGej9ejZQ+9BY/qE2Tq4X2mwWU7orJZ3zQt3dY0RZCibaUMboSNjqa16N?= =?us-ascii?Q?gZCaWEkEoksodXf2VdAMgX6nE4shSL7ahKmfW0LUdoMX9APE6VH2x5AtKnR2?= =?us-ascii?Q?ajGGAL7M56XyRK8fx5w3ikqZr5vgRYF1RAP9CEWYBHFeBGybpiZPgieu8MeU?= =?us-ascii?Q?1YZq+pykqcYHcX0FJwMAYuVjOQ3axINOePHdnMCyLMsImrp4vaTQn+Lox0iQ?= =?us-ascii?Q?jfei2X6SiGQygasqUY9a+p/TwYHh3BOXmvcIOg8KYbzEIPO2uwwHI04obz6u?= =?us-ascii?Q?880JwpVA9mGWKWu5Bf5kXqTW9Bh2bYCFt3uGOhluvESs26lKWHtjqOMmQXR4?= =?us-ascii?Q?VBya4wGMNQM6YTrU3ZvjVmvpRVkomlOQIi/JXWx6kEyqyq/1Z0k/2WGIJ4Y+?= =?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MvViiu0BXYn7MwYmwrW9tgBag==;5:dee7FIyWsDY5ljFEd9w4bu+tj7bHZTEQDwA8H5Y45nhYC4vo0inRmApTnOsS+igHPu1Akr2FVN9Z3neRRVQlfhkclo1r8xW2ueefz+f4AkkHXCtq0YmVwa0MSO4nVVt1q0LHJh5T2cojIyP3M5JDuV5dxuT+qC/A9ve9/s1/e4q+KJhyJSqICydVa6o1HXss;24:aWxnKaxSfgv1Ac3sJZZVktj0XaTFTZdDeZ2jJgku2tNE4FFTYOkkBaU0YxCwPwpRO93RsaF3ceLRblj9JIRKnbSFTkv9K/bhMegS8VpGQvA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BN6PR03MB2468;7:bu9X5sGqJs66naiNR8OKI28xCZimK85P07JmOnxvnfn997N8zRcYxbKgp2ymAGpULFz9W9cATy5AMHPb65tR9sMRANPiVJj2SNfebnPMA1dP8jT3n96RKIvGccOKUsdSMFEjZQvT/hGgMWl6tFMgHLp02uymOOe31E5bUHWP2Z3UWtJHb0mfST96KQRKujyAKVF/JBvxTfWrd/dvmKPCYA/OM42DufBDvR+5Iv2YsZxRVYm/Gt2gGK/94Nqi4tVxlihLs3aQNT3+dz2bepXenN78vnH84r5Mi0bN8lXyBDXWAOuDWDywGSXP0l0abndZi/Mm/OGtKxH033bi2CyAzTu8LKGJuQ9b17vHXYBajyM= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2016 20:16:49.0322 (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: BN6PR03MB2468 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 13827 Lines: 475 From: Roy Pledge Add global definitions for DPAA2 frame descriptors and scatter gather entries. Signed-off-by: Roy Pledge Signed-off-by: Stuart Yoder Cc: Laurentiu Tudor Cc: Ioana Radulescu --- -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 include/linux/fsl/dpaa2-fd.h | 448 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 448 insertions(+) create mode 100644 include/linux/fsl/dpaa2-fd.h diff --git a/include/linux/fsl/dpaa2-fd.h b/include/linux/fsl/dpaa2-fd.h new file mode 100644 index 0000000..182c8f4 --- /dev/null +++ b/include/linux/fsl/dpaa2-fd.h @@ -0,0 +1,448 @@ +/* + * Copyright 2014-2016 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 __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