PDK API Guide for AM64x
udma_utils.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Texas Instruments Incorporated 2018
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
47 #ifndef UDMA_UTILS_H_
48 #define UDMA_UTILS_H_
49 
50 /* ========================================================================== */
51 /* Include Files */
52 /* ========================================================================== */
53 
54 /* None */
55 
56 #ifdef __cplusplus
57 extern "C" {
58 #endif
59 
60 /* ========================================================================== */
61 /* Macros & Typedefs */
62 /* ========================================================================== */
63 
72 #define UDMA_TR_TYPE_0 (CSL_UDMAP_TR_FLAGS_TYPE_1D_DATA_MOVE)
73 #define UDMA_TR_TYPE_1 (CSL_UDMAP_TR_FLAGS_TYPE_2D_DATA_MOVE)
74 #define UDMA_TR_TYPE_2 (CSL_UDMAP_TR_FLAGS_TYPE_3D_DATA_MOVE)
75 #define UDMA_TR_TYPE_3 (CSL_UDMAP_TR_FLAGS_TYPE_4D_DATA_MOVE)
76 #define UDMA_TR_TYPE_4 (CSL_UDMAP_TR_FLAGS_TYPE_4D_DATA_MOVE_FORMATTING)
77 #define UDMA_TR_TYPE_5 (CSL_UDMAP_TR_FLAGS_TYPE_4D_CACHE_WARM)
78 #define UDMA_TR_TYPE_8 (CSL_UDMAP_TR_FLAGS_TYPE_4D_BLOCK_MOVE)
79 #define UDMA_TR_TYPE_9 (CSL_UDMAP_TR_FLAGS_TYPE_4D_BLOCK_MOVE_REPACKING)
80 #define UDMA_TR_TYPE_10 (CSL_UDMAP_TR_FLAGS_TYPE_2D_BLOCK_MOVE)
81 #define UDMA_TR_TYPE_11 (CSL_UDMAP_TR_FLAGS_TYPE_2D_BLOCK_MOVE_REPACKING)
82 #define UDMA_TR_TYPE_15 (CSL_UDMAP_TR_FLAGS_TYPE_4D_BLOCK_MOVE_REPACKING_INDIRECTION)
83 /* @} */
84 
85 /* ========================================================================== */
86 /* Structure Declarations */
87 /* ========================================================================== */
88 
89 /* None */
90 
91 /* ========================================================================== */
92 /* Function Declarations */
93 /* ========================================================================== */
94 
104 uint32_t UdmaUtils_getRingMemSize(uint8_t mode,
105  uint32_t elemCnt,
106  uint8_t elemSize);
107 
121 static inline void UdmaUtils_makeTrpd(void *pTrpd,
122  uint32_t trType,
123  uint32_t trCnt,
124  uint32_t cqRingNum);
125 
133 uint32_t UdmaUtils_getTrSizeEncoded(uint32_t trType);
134 
142 uint32_t UdmaUtils_getTrSizeBytes(uint32_t trType);
143 
144 /* ========================================================================== */
145 /* Static Function Definitions */
146 /* ========================================================================== */
147 
148 static inline void UdmaUtils_makeTrpd(void *pTrpd,
149  uint32_t trType,
150  uint32_t trCnt,
151  uint32_t cqRingNum)
152 {
153  uint32_t descType = CSL_UDMAP_CPPI5_PD_DESCINFO_DTYPE_VAL_TR;
154  uint32_t trSizeEncoded = UdmaUtils_getTrSizeEncoded(trType);
155 
156  /* Setup descriptor */
157  CSL_udmapCppi5SetDescType(pTrpd, descType);
159  CSL_udmapCppi5SetPktLen(pTrpd, descType, trCnt);
160  CSL_udmapCppi5SetIds(pTrpd, descType, 0U, UDMA_DEFAULT_FLOW_ID); /* Flow ID and Packet ID */
161  CSL_udmapCppi5SetSrcTag(pTrpd, 0x0000);
162  CSL_udmapCppi5SetDstTag(pTrpd, 0x0000);
163  CSL_udmapCppi5TrSetEntryStride((CSL_UdmapCppi5TRPD*)pTrpd, trSizeEncoded);
165  pTrpd,
166  descType,
170  cqRingNum);
171 
172  return;
173 }
174 
175 #ifdef __cplusplus
176 }
177 #endif
178 
179 #endif /* #ifndef UDMA_UTILS_H_ */
180 
181 /* @} */
static void CSL_udmapCppi5SetReturnPolicy(void *pDesc, uint32_t descType, uint32_t retPolicy, uint32_t earlyReturn, uint32_t retPushPolicy, uint32_t retQnum)
Set descriptor return policy information.
Definition: csl_udmap_cppi5.h:1169
static void CSL_udmapCppi5SetDstTag(void *pDesc, uint32_t dstTag)
Set destination tag.
Definition: csl_udmap_cppi5.h:935
uint32_t UdmaUtils_getRingMemSize(uint8_t mode, uint32_t elemCnt, uint8_t elemSize)
UDMA get ring size utility API.
Definition: csl_udmap_cppi5.h:205
#define CSL_UDMAP_CPPI5_PD_PKTINFO2_RETPUSHPOLICY_VAL_TO_TAIL
Definition: csl_udmap_cppi5.h:176
static void CSL_udmapCppi5SetPktLen(void *pDesc, uint32_t descType, uint32_t pktLen)
Set the packet length.
Definition: csl_udmap_cppi5.h:392
#define UDMA_DEFAULT_FLOW_ID
Default flow ID.
Definition: udma_flow.h:66
static void CSL_udmapCppi5TrSetReload(CSL_UdmapCppi5TRPD *pDesc, uint32_t reloadEnable, uint32_t reloadIdx)
Set TR descriptor reload information.
Definition: csl_udmap_cppi5.h:1274
uint32_t UdmaUtils_getTrSizeBytes(uint32_t trType)
Returns the size of TR in bytes based on the type.
uint32_t UdmaUtils_getTrSizeEncoded(uint32_t trType)
Returns the size of TR (encoded) based on the type.
#define CSL_UDMAP_CPPI5_PD_PKTINFO2_EARLYRET_VAL_NO
Definition: csl_udmap_cppi5.h:172
static void CSL_udmapCppi5SetIds(void *pDesc, uint32_t descType, uint32_t pktId, uint32_t flowId)
Set IDs.
Definition: csl_udmap_cppi5.h:1066
#define CSL_UDMAP_CPPI5_PD_DESCINFO_DTYPE_VAL_TR
Definition: csl_udmap_cppi5.h:139
static void CSL_udmapCppi5SetSrcTag(void *pDesc, uint32_t srcTag)
Set source tag.
Definition: csl_udmap_cppi5.h:920
char mode[32]
Definition: tisci_pm_core.h:130
static void CSL_udmapCppi5SetDescType(void *pDesc, uint32_t descType)
Set the descriptor type.
Definition: csl_udmap_cppi5.h:332
#define CSL_UDMAP_CPPI5_PD_PKTINFO2_RETPOLICY_VAL_ENTIRE_PKT
Definition: csl_udmap_cppi5.h:166
static void CSL_udmapCppi5TrSetEntryStride(CSL_UdmapCppi5TRPD *pDesc, uint32_t nomElSz)
Set TR descriptor entry stride.
Definition: csl_udmap_cppi5.h:1313
static void UdmaUtils_makeTrpd(void *pTrpd, uint32_t trType, uint32_t trCnt, uint32_t cqRingNum)
UDMA utility API to make TRPD. Other TRPD make APIs should be called only after this API.
Definition: udma_utils.h:148