Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761674AbcLAWvA (ORCPT ); Thu, 1 Dec 2016 17:51:00 -0500 Received: from mail-by2nam03on0054.outbound.protection.outlook.com ([104.47.42.54]:35136 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754576AbcLAWt3 (ORCPT ); Thu, 1 Dec 2016 17:49:29 -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:956;Count:10 From: Stuart Yoder To: CC: , , , , , , , , , Roy Pledge , Stuart Yoder Subject: [PATCH v3 4/9] bus: fsl-mc: dpio: add frame descriptor and scatter/gather APIs Date: Thu, 1 Dec 2016 16:41:29 -0600 Message-ID: <1480632094-3621-5-git-send-email-stuart.yoder@nxp.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1480632094-3621-1-git-send-email-stuart.yoder@nxp.com> References: <1480632094-3621-1-git-send-email-stuart.yoder@nxp.com> X-IncomingHeaderCount: 10 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131251061352504395;(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)(1110001)(1109001)(336004)(339900001)(199003)(189002)(39410400001)(189998001)(356003)(81166006)(50226002)(39450400002)(92566002)(8666005)(2351001)(81156014)(39380400001)(47776003)(86362001)(8676002)(305945005)(39400400001)(5003940100001)(4326007)(7416002)(97736004)(7846002)(85426001)(50466002)(105606002)(50986999)(626004)(2906002)(575784001)(48376002)(38730400001)(8936002)(76176999)(110136003)(68736007)(2950100002)(5660300001)(6666003)(106466001)(104016004)(6916009)(77096006)(36756003)(33646002)(7059030)(2004002);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR0301MB0743;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD039;1:+vP9zCBRvfHjRTTNMX5NsUub9N9IZ/LMBvttTfGAYonK3YHGd29vBCzG0EBSK1PJc/oCMUs9r+wAsy9r8YXvYWl6NF8o2uWgEKq4ULlrrn9CW5nhOqTFrwa47Cr0sXdUkYTdMwaoLO2F59p6nnNH+htgAhFiORhImsYTgCrfDlhKvv0C5dgE80V3tDzpeY+yq+uDILcHt/nU6S0GdDSvI9fZJDX0kuXpVRWgEcsjkenT0Nqr/1pYDAfhJKU8qbidKRck3s0xKo6c4icXroaHIA8GASb9rWMU7tUB12eOkRJmB5nrdP4ySOVr7NU83NoxasYqOObg+OqMh/qLK6Hgd7KjJJlpJXG3LnDpfkGsyLiXcB7uWwNW8ywVyXr82ZV8uRfV46eQqvc8WafY3RsK+xyQQpHvyQjh4J1t5MO+Xqz9NSq5PZNlxa+gPSmFe3Akmbax2M4mehnuuhrIf9tNMwIR4QF/MFQtZ4J2luq9X6fG4PgsdwLeFL82b1hc/HmURWjDIw8oSxlK8wBrV2k3td75EFifwINgRtInmuqyAFcd+6Op3uaPUc12r3lwCVkjVCFRICs1hDCn4kCBc0LSOzgqt92PJZRqOAKSpdH9LrDABaCxUsW3SNxcsY2E0yVQzzUVpcK1p3SP6mD1WQsf95+SsQI+bJWbeU50tombZ46b1YGECj1wKdwN0Uz/XxGRS0hKbRtdlWk9ckNqHPS4/KCxk9U1ldDARNtHPIbPi2g= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: fb542323-f01d-4e29-1c4b-08d41a3c3ac6 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:BY2PR0301MB0743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GsyyHcoOmLxA35vRcUUMr1/kOUrNbQYA6KORapooGaVhRcgtf6QVZJDexwui4IPrAcRXZqpG8w0ob84VoYvrCBkVJJn4LOe8pPDbqEHUshbpkW2eGoMSdN9KCU9ql/dFmUi0fUy1QIMH/+cQSaT9S9hs5vkzRF9MSXrDnKDHa7RQpMg== X-Microsoft-Exchange-Diagnostics: 1;BY2PR0301MB0743;31:E0LZ5r31+2W/N2j9TRVF8I5/N8KW7cN1A+asbPIZDtUDmtuQ3qXkRECAfyvNBsUiTBpfP0933mB2aIrtQqfEpdWcXKfcLWpm6t/TPHVDyPfnQ+g0oAjI9qIZ3Rr2itR++vtMfCN1KjiMZlULgRFCqcZhKjhZG9CmpN/GkftN01QG5Lr/2JEc19RfvJ/xewBfZk1a3+iu456UBmenNX5/9Onb6heiHrpTNBIZPvbJR3wKDpEYRCoTYd2sAkj6P/E5LI7+KrYuCxmxU0QEB8HwEw== 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)(13017025)(13024025)(5005006)(13023025)(13015025)(13018025)(8121501046)(3002001)(10201501046)(6055026)(6096035)(20161123556025)(20161123559025)(20161123563025)(20161123565025)(20161123561025);SRVR:BY2PR0301MB0743;BCL:0;PCL:0;RULEID:(400006);SRVR:BY2PR0301MB0743; X-Microsoft-Exchange-Diagnostics: 1;BY2PR0301MB0743;4:pYWrqf2MkYnQg1IFcYkJ+8LdQ7l9QOeiXbTW2xlOL8OWMaxs0uVQ+jmRqjzzb1t9sv8WlDyUlWNuNX0Vw+SN2aPYqZvQVIX/Sh8FF0JnPbkh7ixM2bxeQYtI6CN8DCylJNfD2EBdIAlzjPqluRlCiqk+4eYlfnto9dpM/jiWQ4kBwha/YvtDaAB+QVWAWUnp9ljD10mlpLyimV3rswHYLfdihwX1azkRFnD8kzs/B4puQg09STKC9z32z3FqvPaxD4XHq4tAFPVL+Z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xiSOgqgs4/Idpn8LqYQEJfPNIFin2ErDsvYl0fswcy9QMBSFGsarnnOMb7YArqTvzYv+GtxchbXLSlXbV2Yi00R/04klDFgKSWb/AR4UT5eQgww2ZHsgtJEpQqM0SH+oTXc4e5WRnPi/13Wpg5waofMCQVpvLUChNGzdBUBeJ5API1i59RlpSwPKYawUEKuufA6lfJRgOW3NKrO/2NSPZt3a2Xd7J3x6p1OISCiU1I6lR+7Xdt1CrTgtbeXlRtWjNoPWK8/9FfYvugeW9elLZxqS7V3WalvyckWMzMotA== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2016 22:48:55.0788 (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: BY2PR0301MB0743 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 13783 Lines: 477 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: -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 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