Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932158AbdCHV4m (ORCPT ); Wed, 8 Mar 2017 16:56:42 -0500 Received: from mail-dm3nam03on0067.outbound.protection.outlook.com ([104.47.41.67]:50080 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754064AbdCHV4D (ORCPT ); Wed, 8 Mar 2017 16:56:03 -0500 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: [v6 3/8] bus: fsl-mc: dpio: add frame descriptor and scatter/gather APIs Date: Wed, 8 Mar 2017 16:54:45 -0500 Message-ID: <1489010090-18025-4-git-send-email-roy.pledge@nxp.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1489010090-18025-1-git-send-email-roy.pledge@nxp.com> References: <1489010090-18025-1-git-send-email-roy.pledge@nxp.com> Reply-To: X-EOPAttributedMessage: 0 X-Matching-Connectors: 131334837100458051;(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)(39840400002)(39850400002)(39400400002)(39450400003)(39410400002)(39380400002)(39860400002)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(9170700003)(8676002)(305945005)(2906002)(7416002)(106466001)(575784001)(104016004)(54906002)(6666003)(86362001)(38730400002)(85426001)(39060400002)(47776003)(3450700001)(2950100002)(33646002)(97736004)(110136004)(105606002)(4720700003)(5003940100001)(43066003)(4326008)(53936002)(50986999)(36756003)(5660300001)(8936002)(50226002)(50466002)(76176999)(81166006)(48376002)(6916009)(189998001)(77096006)(356003)(2351001)(8656002)(2004002);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR0301MB0725;H:az84smr01.freescale.net;FPR:;SPF:Fail;MLV:ovrnspm;A:1;MX:1;PTR:InfoDomainNonexistent;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD012;1:PEBlDBdNOSPi4eltcbEoY011hNqqMdz2lm85Wbyhk6mvxx3JEVMiEnELhua39/tj+8zsBJhlwMdfAWjtfQeMeZElWwpspvCwl7Td27N9F/EvXU7hpTeWqJA8Zk4nwlANRl0pEm171vqdNR7ovTGQuduoiMaxpWToi3FqHu9G+7RkEDljD+NuBjbm5RMo624556k7+Rzkj2duj1F44WbGBiYe4PBtv+4MVURZgetsVm7rza+t5C5OYWMYi1ok8UzSC0IkqAXTGLzkd0X8+Oe236h99tBWaeCDBSxBX9irt9YrNZK+edM+RuxbrgrX9+gXKoh6UleNmOYDpRn1FjBNpnlaiuWdocQjZBkE4BzU6MrPIdzLcGO4u3iDvU1eNUXowObJb5lnJmt7kEo+aMUQWVgNl1q9c5ReB/48syRALMQmCtBBxBd+kN4M8d4H0O/bvRSIWn5b23ikgRXOvpEE54qZXQnfT08pvJphKKZ2Lga+qrFmDrwy+AuimTWaMStdIrOTJY2zhrOZ56J5bcdTtw5hMwGuXBtffgGLhjqUg8kdFDY0eIAYLcAheOy6I8XPzGg/2lHc/GpC3A5YMCsFb1UVZL3EhNHXE0D1qbFwUkoGPt0nRE+vQZj9DxEr5h+9Ufp5Uw568lwvurrOXefYMw7kTQ/qFdFphoT9MeS8ENM7/pNiP2TPpXXodszrIb/ZkqDaRMWngu+fVDkpHJO77A== MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 13a2aec2-09d1-4aa4-4ee2-08d4666dca76 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:BY2PR0301MB0725; X-Microsoft-Exchange-Diagnostics: 1;BY2PR0301MB0725;3:c+CeWFMzpfe4rhV8Knxt3qNUTmVFKy6n5JYev703lxvhMYVe+JTya1oir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V3pbL94BkXFRvldjkNwC/YOtgGSClWM8a6+8o4vDQqGeal9j4AJDDBCwY+FuIxKSzlRt+l0wU= 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)(5005006)(13023025)(13024025)(8121501046)(13015025)(13018025)(10201501046)(3002001)(6055026)(6096035)(20161123565025)(20161123561025)(20161123556025)(20161123563025)(20161123559025);SRVR:BY2PR0301MB0725;BCL:0;PCL:0;RULEID:(400006);SRVR:BY2PR0301MB0725; X-Microsoft-Exchange-Diagnostics: 1;BY2PR0301MB0725;4:LvXDAp/kYWL72o6JNpasP535JtY7nUuioVccHVYR5Ueyovi1j7bq01WpDmB+sKZMZRR/yA7LeQt7pMzLOfPOAJDzNSX3tTPgehvf7HDs7pNAW6DmjQyTia6Yg6smkDen2ARKpJjYtJKUWix7+t/U+H8X/SqDr8kvt6Sd0zXOI3Nf/ajXY23D6EjI7bWEZStD67ffbmRPaQx73WUWUvyc97FGOrc5t7JaUFwnz2b+PPpI+q4FAgr5UmQ1u+tNAFlFgzyxAu74nPP7RPDZW48OkrrCScJ8qqZNgIxDYYmJ5cTWwDS9uUalEylLuJqoiTx/xEeEQb0PvUhTP3YKWPKhDpnL//KR1QwlE+MJUARN+8NUJME7ZZkP13JDCOL940ig5G9l0AhZzMuzn2WmYxJ9QIjF4zZn5cmeeV5JECcVyNslqsH8aQo31RBkA9y3k2rtnf/EffgVAuEQLU2totDHk6GOft9nCpCNdUpT7tMffQZ7aNeql/pix/jaWanW5OLb6PNySKnw7wVENH51y0S8CCqwH4YSI4ygJkAjUdZtCxtPRZZzSG5vn4jKL9PLCV2WdH3OwUhOyOkV2fD5foNUs/j+BeOB7goPeP5+xzIuFJU2fkx2WFj9JZTA9jgOMKjoGkQRenML1YBwPDD2zkE5K6U9/BjKSMsNSq3IroSyfDLAyCXYqghx9ZWjZFaUz2L0mnK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RjronOT6gAAU7yDQqF80bIWUYKySt9Tf6/AB/6Q8m2Y5ujlS6CiIPxBCUMowAi4eEfaOpfxxOkzyiXb9dyxko/AODY7hxsFwpk9S6DrI1pfB7Fc9N/hc7TkKI1zWi2TfYM6yhMMBHcVP7J+9+kHwvV660m1CWETG+Qg6gcr87Fz9wvKBhorMjKAPA=;5:M0tEXBeQDjzuZXbFj9MVg+OKnYzxQsK4pPSjoVLPxI3MrDpM36SaVd0etiZiKLro8V/K9CoZydGsiq0WGpzKzlCfnda/E5O8ts1Xk7GYqY0ra/RRDTvLQ1ItcxMNtZHdotyQxfRmSlIZnRYwHsSdCkmtmzLUlg6nbdxvZvKySA5guvWeWiH1326oaXbkMQgx;24:zm2akzW3LTFRnsPxoxeaoAQWPCk9JdBaaO8tj2m7izaME9jN+ER2qUnNYEma+QPIJhNFQgN7586H/A+E7p56Di2kxU4D5HQzh1Nqh21dDAs= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BY2PR0301MB0725;7:lLirSFGD/Xcktx/0WWJqwcS0T3vPAlkMIP+Q20LCToh1aweqZogmp9x2+UqErRZVD296Ih0ZXke8L/SCTaZ6YWwxFl894npsNDXLbEcTePnydobH+6az1fGZvJfkyHRJOhb6Wf1kl9FeCjUmvYRV4PBrledXFppJ7egT1cC4yMc5LVnHClMZ+qPEvt5zWrS79W0DswyNo8vy4eDVga9ktOK9XQX0A7RNG1vc184BhmDRCIK3uXOmtwS2uK9a++xrENOixhmIm00cCDP5yD7RiUpX/2W/VAe7J4YOdhjHB/zo+0XvqGP8Frzb94xJyfh5pNW3UXt92+YL2FKfLL4cGQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2017 21:55:04.8353 (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: BY2PR0301MB0725 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 13659 Lines: 468 From: Roy Pledge Add global definitions for DPAA2 frame descriptors and scatter gather entries. Signed-off-by: Roy Pledge Signed-off-by: Stuart Yoder --- 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 */ -- 1.7.9.5