Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933537AbcJUOIP (ORCPT ); Fri, 21 Oct 2016 10:08:15 -0400 Received: from mail-dm3nam03on0043.outbound.protection.outlook.com ([104.47.41.43]:46816 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933183AbcJUOIH (ORCPT ); Fri, 21 Oct 2016 10:08:07 -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;nxp.com; dkim=none (message not signed) header.d=none; From: Stuart Yoder To: CC: , , , , , , Roy Pledge , Stuart Yoder Subject: [PATCH 4/9] bus: fsl-mc: dpio: add frame descriptor and scatter/gather APIs Date: Fri, 21 Oct 2016 09:01:44 -0500 Message-ID: <1477058509-12547-5-git-send-email-stuart.yoder@nxp.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1477058509-12547-1-git-send-email-stuart.yoder@nxp.com> References: <1477058509-12547-1-git-send-email-stuart.yoder@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131215324851625340;(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)(7916002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(81156014)(8936002)(47776003)(11100500001)(33646002)(2351001)(5660300001)(106466001)(8676002)(68736007)(105606002)(229853001)(92566002)(104016004)(305945005)(626004)(81166006)(50466002)(2950100002)(19580395003)(97736004)(4326007)(189998001)(110136003)(6666003)(356003)(586003)(7846002)(48376002)(77096005)(86362001)(50226002)(36756003)(575784001)(6916009)(87936001)(19580405001)(76176999)(8666005)(2906002)(85426001)(69596002)(5003940100001)(50986999)(7059030)(2004002);DIR:OUT;SFP:1101;SCL:1;SRVR:SN2PR03MB2383;H:az84smr01.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BN1BFFO11FD023;1:vi9OBFTCH6hnPQtv7bgW/gSzCYDeVvGNJHcRxxMSIo7lWm5c4Z+ps3fR22ZS49i4/HUOZGedi2q8+yPD6NuvgmQd3OToi93eIUotIHQMCp02N4YIfhPaxaJkZbzuxu9ZFA42QHJMDohGRDF8SkYEX7cSptFx25fexX3u2rUeYNjfEBwks7KHec6OqXMRmN7l7WaShAfUtyz9erUNDQs4QsEGwUQbm/Mdx1expQ7cklqeuk5UBj5Y3FmpLPZIgLJCXoQd96XOQU+YOJsPKzfEktPhPKsquyFxhsvc/YlVgwWFNoTNGWaNitT7+QmlpFArVQfSxw7GqwYHavup+tVPJ7joRFnd09UUIjVVlvIC+ehTdALbRXwG1VCj4oRrqO6PWAiIlJ55EkxjvmacDLJ4rwzbX7e7khJn3LQhX627QXECdyQsexWJBDUHEtbhxDwZtVXOHOvYhAyviQEAFgxajNUwMu5u6sSZgYlzmUl6Mk4rxtvVw4PV0bE3DgsGAc7iAwtz7fBvIrDvSX/T9Ct0ocHrfbOTDuy86ZzhvI9mzIk1j09yWh32I/K3sMRf758a7X5I/rE+d6mR03lcIxkCI5ka9eXSdgIjsHZe8jpabwFrAD+F6he8PEq/ZHL1xwYjVeK5cDTjj8gnlDhB7RoT5qWYoi/C1f1T5xcNJ59wpphx3AH2Au5uCjBBaVt7lI1YDuGSlMVcfkM9W8NQymcdCm31U7RFjsdthdqaWN5uZ6w= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 04f3e7e9-7535-4236-fc1b-08d3f9bbad52 X-Microsoft-Exchange-Diagnostics: 1;SN2PR03MB2383;2:ydmkDOtYd8HxwwGsbKI6E66uJXV8HnuVFnc6MwZCiXAd9TPrSyXILszCQOl7FGKdREtdgLoaMIRuwlcLzZnhl4fXMCX92tAVJEElRROeswIkr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soft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040176)(601004)(2401047)(13015025)(13024025)(13018025)(13023025)(13017025)(5005006)(8121501046)(3002001)(10201501046)(6055026);SRVR:SN2PR03MB2383;BCL:0;PCL:0;RULEID:(400006);SRVR:SN2PR03MB2383; X-Forefront-PRVS: 01026E1310 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;SN2PR03MB2383;23:Ap+RtytStAqzUJ8D8n3giH21MoVODc0eQE46OB0lf?= =?us-ascii?Q?B0ilTwnoPVRpsKKelQRBwosI/O8QExa635p253mKkxgWrZncMo/K7RxhG1ZS?= =?us-ascii?Q?E9brWRdW0pYp9M1L0BTvrcVYlxjDNlY+hs2ovPTiVAsic1PICpJHW0WGQXT2?= =?us-ascii?Q?pG++osBGBJJSZkXYKqVax0b5ZL63+PamgOjkZyPsBsGvwVPEhKAGBOFIcutq?= =?us-ascii?Q?FBc92/JugYSzeZfQ+xyR3UT4NH/XtJFB53DksotnIxr10cGv4rC+50SDdfLD?= =?us-ascii?Q?5DOXijeMgifkwOZp1fqlJ1Tp0xUvz5FnTb7eH7D5ByVKiZfUlWxaueEVEWxf?= =?us-ascii?Q?Z7wO/EnbRxeuLptbXU3xFuXMDaej5ZfX/LwD23p8mkbkg7i4fpAtMNf2GLRG?= =?us-ascii?Q?XKIfSRS57kAoRIeZWyaY1v3airkbLQC61vPrTprsae+aQYz5mni/r4SixEne?= =?us-ascii?Q?pbcJorzh/7vL2doWUIpCaiYI5xr/mFXQmJfFh+8C4FGI8Qi2n6ssFULjwULA?= =?us-ascii?Q?GbfhFYdOnmVz57utHIOzEODSpCDaqZkq0+L8ZnQW+mzZhdLtiG2Llea7D1bS?= =?us-ascii?Q?ouPXnB0D6puYYli/IaleVoKDYcULMyXsDqsGKwyNJ7Ut9q8X3Hy8ETgs11Hj?= =?us-ascii?Q?mMchM+cb5+G+2lvVhSL94WBJWBlZifzcLLqBibWBnTTDeOPTMJnp63cFBNg1?= =?us-ascii?Q?xpbSclw1NmXE/mF6bXXlPbWB1q/lWLVG1IpU1F+DzeF+rJymFolpZ3Ed1hk2?= =?us-ascii?Q?9AfHdEpEfoQ5MfsdTgxasjYfSsbp9wVQO9z5251DWF3mccbgino9bEncWjpV?= =?us-ascii?Q?jlJlOTvzBJilFlDvTYVZWF+C1ze7Qp1d+fjI+WbpECgJi+g9cVC2bJaGnCGD?= =?us-ascii?Q?d4o1qiyt4+icfLlT57F8x846zSOwtGCaHZGTca3eXtnDPzJEqyW8qMulOUbn?= =?us-ascii?Q?g50t5ohV4BawZDsa/I0wk2tRPP7SbJlZOlRYghMqOxbYT2M5jzl771+IaXSO?= =?us-ascii?Q?0KBrl4tSRvJ/lcvY+83uSAragle0Bx6E0dHGm9lyKMahYzLpRwJGGWJbuUsm?= =?us-ascii?Q?QcAMHdqFJzXNI1rJ5aCAewOhKRZIfOiHqIRwfDXSmtvkZmgSOWYTNreIprAI?= =?us-ascii?Q?ZucZAeZI3iDQYyU82BxdTkjAONy/lB8jFxz2Zn5RGUKuCiIWnacHT928lRTQ?= =?us-ascii?Q?9Aw1RAnSZEe4X1S+66E5GkTF7MpaDNFsehK4saSBOD1+XmANHCL/z/h1o++1?= =?us-ascii?Q?T5AJZytmG7H7rtnAqyfhsvfDC6s6/jJwSH05ugs?= X-Microsoft-Exchange-Diagnostics: 1;SN2PR03MB2383;6:/Ep/Meppw9pvRj55/S+LL2f7RFx4ck21XMspj7/+/szb4WgJN52fmLg67x676MYaT/q5ZP219XvEMGoPrMP+tRsOPCzAoRB6gg5EkFOv1fnac65aMEUqSEacMQ3VyHcDn9gr33m/vjJLktIq4oi3SxsissX3rphZIlOopMwDGz8ptUVrlIycCzsm/1uFfM4L0w/UfG6RiE5LdAP6SCsoxMKQwIYMqLbDr18JGDU+x+/jGXP+M8O1lVJjv3Wn9q5tlaqbz6DNNixrSvykekBOLWIPO5/NTLmnQ/sp3urSZmi9D7htZ6HUCHCTSR/S5mgw;5:oPthqZCeS77JS7Ileuly2GrsQzv7KDqqdfXf1hY06+N9ikbQYaLM3FfuOzQqJM9LGdikOdtH1N3RDY3JtA1sM4XxBWJJaKOlxG8m0ooR9x+zoHlWyhHY93Z/+GzbZMk6j4nDm1ETE8rHz/a4DX/Ur7Fwxwsj0jNc+eonVEWFmiG+ws/1Fho32RxC9ET/Baz/;24:3+Cx6f0EDnGuNVOC2Jsv9Q0N23xfeIfvoVxB2v2nXGUqQzTZHZyi0L8Bj9SK21xkHCVuWm6ZBgFgmGB8YgqvOKb3N6ZwcxuW6q9nNbsOM7s= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;SN2PR03MB2383;7:A3NDJufGmDiUIqwMpiVA8RRKhI2BJuVpJVxXfTsz7xe9tGWLZ1oQW6LREHYr5qVWealCpfzrHRakWLUiDGEzz190iKm0t0KEelfhmCRxSxxouT0e2br4ag3BU2TYKn1bOruQ+c/x+3c5+XKwxXbhJyEJl2JsaCaFGsH50VLNM6ICMmqmrjV7Aehc38TO6HYxXqztJ+GQAbKjZNV5KzlVqls6gm2Ip99hSeHqJYgF09krDfL0LV050HPzRABc3fummAN2DH7ONs+q/XUsYVSwrrjHUXG0D6jV6WMWUPl3ZdNJZJyEVNIZUNPsynxYQSauuDjWOXnykySGLFc/5loWSZ45FeH1wIslAn8WRyaJEDc= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2016 14:08:04.7881 (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: SN2PR03MB2383 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 12671 Lines: 435 From: Roy Pledge Add global definitions for DPAA2 frame descriptors and scatter gather entries. Signed-off-by: Roy Pledge Signed-off-by: Stuart Yoder --- include/linux/fsl/dpaa2-fd.h | 415 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 415 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..b3fa9ff --- /dev/null +++ b/include/linux/fsl/dpaa2-fd.h @@ -0,0 +1,415 @@ +/* + * 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 and offset 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_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_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; +} + +/** + * 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) +{ + 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: offset in the MS 16 bits, BPID in the LS 16 bits + */ +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