PDK API Guide for J721E
enet_dma.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Texas Instruments Incorporated 2020
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 ENET_DMA_H_
48 #define ENET_DMA_H_
49 
50 /* ========================================================================== */
51 /* Include Files */
52 /* ========================================================================== */
53 
54 #include <stdint.h>
58 
59 #if defined(SOC_J721E) || defined(SOC_J7200) || defined(SOC_AM65XX)
60 #include <ti/drv/udma/udma.h>
64 #elif defined (SOC_TPR12) || defined(SOC_AWR294X)
65 #include <ti/drv/enet/include/dma/cpdma/enet_cpdma.h>
66 #endif
67 
68 #ifdef __cplusplus
69 extern "C" {
70 #endif
71 
72 /* ========================================================================== */
73 /* Macros */
74 /* ========================================================================== */
75 
76 #if defined(SOC_TPR12) || defined(SOC_AWR294X)
77 
78 #define Enet_isCacheCoherent() (false)
79 
80 #define ENETDMA_CACHELINE_ALIGNMENT (128U)
81 #elif defined(SOC_J721E) || defined(SOC_J7200) || defined(SOC_AM65XX)
82 
83 #define Enet_isCacheCoherent() (Udma_isCacheCoherent())
84 
85 #define ENETDMA_CACHELINE_ALIGNMENT (UDMA_CACHELINE_ALIGNMENT)
86 #else
87 #error "SOC not supported"
88 #endif
89 
90 
96 #define ENET_DMA_STATS_HISTORY_CNT ((uint32_t)32U)
97 
108 typedef EnetDma_Pkt *(*EnetDma_AllocEthPktFxn)(uint32_t pktSize,
109  uint32_t alignSize,
110  void *appPriv);
111 
113 typedef void (*EnetDma_FreeEthPktFxn)(EnetDma_Pkt *pPktInfo);
114 
125 
126 
127 /* ========================================================================== */
128 /* Structures and Enums */
129 /* ========================================================================== */
130 
142 typedef struct EnetDma_CbStats_s
143 {
145  uint64_t dataNotifyCnt;
146 
149  uint64_t zeroNotifyCnt;
151  uint64_t totalPktCnt;
153  uint64_t totalCycleCnt;
154 
159 
162  uint64_t pktsPerNotify[ENET_DMA_STATS_HISTORY_CNT];
165 
168  uint64_t cycleCntPerNotify[ENET_DMA_STATS_HISTORY_CNT];
171 
174  uint64_t cycleCntPerPkt[ENET_DMA_STATS_HISTORY_CNT];
175 
179  uint64_t readyDmaDescQCnt[ENET_DMA_STATS_HISTORY_CNT];
181 
185 typedef struct EnetDma_DmaDescStats_s
186 {
188  uint64_t readyDmaDescEnq;
190  uint64_t freeDmaDescDeq;
192  uint64_t underFlowCnt;
194 
198 typedef struct EnetDma_RxChStats_s
199 {
207  uint64_t rxSubmitPktEnq;
213 
217 typedef struct EnetDma_TxChStats_s
218 {
226  uint64_t txSubmitPktEnq;
232 
235 /* ========================================================================== */
236 /* Global Variables Declarations */
237 /* ========================================================================== */
238 
239 /* None */
240 
241 /* ========================================================================== */
242 /* Function Declarations */
243 /* ========================================================================== */
244 
257  uint32_t instId,
258  const EnetDma_initCfg *pDmaCfg);
259 
269 int32_t EnetDma_deinitDmaCfg(EnetDma_Handle hEnetUdma);
270 
282  uint32_t instId,
283  const void *dmaCfg);
284 
292 int32_t EnetDma_close(EnetDma_Handle hEnetDma);
293 
303 void EnetDma_initRxChParams(void *pRxChCfg);
304 
324  const void *pRxChCfg);
325 
347  EnetDma_PktQ *fq,
348  EnetDma_PktQ *cq);
349 
362 
373 
383 void EnetDma_initTxChParams(void *pTxChCfg);
384 
404  const void *pTxChCfg);
405 
428  EnetDma_PktQ *fq,
429  EnetDma_PktQ *cq);
430 
443 
454 
467  EnetDma_PktQ *pRetrieveQ);
468 
481  EnetDma_Pkt **pPkt);
482 
496  EnetDma_PktQ *pSubmitQ);
497 
509  EnetDma_Pkt *pPkt);
510 
523  EnetDma_PktQ *pRetrieveQ);
524 
537  EnetDma_Pkt **pPkt);
538 
550  EnetDma_PktQ *pSubmitQ);
551 
563  EnetDma_Pkt *pPkt);
564 
572 void EnetDma_initPktInfo(EnetDma_Pkt *pktInfo);
573 
585  EnetDma_RxChStats *pStats);
586 
598  EnetDma_TxChStats *pStats);
599 
609 
619 
620 /* ========================================================================== */
621 /* Deprecated Function Declarations */
622 /* ========================================================================== */
623 
624 /* None */
625 
626 /* ========================================================================== */
627 /* Static Function Definitions */
628 /* ========================================================================== */
629 
630 /* None */
631 
632 #ifdef __cplusplus
633 }
634 #endif
635 
636 #endif /* ENET_DMA_H_ */
637 
This file contains the type definitions and helper macros for the Enet UDMA data path (DMA) interface...
uint64_t readyDmaDescEnq
Definition: enet_dma.h:188
uint64_t txSubmitPktEnq
Definition: enet_dma.h:226
void(* EnetDma_FreeEthPktFxn)(EnetDma_Pkt *pPktInfo)
Function pointer type for Ethernet packet free function.
Definition: enet_dma.h:113
uint64_t cycleCntPerNotifyMax
Definition: enet_dma.h:164
int32_t EnetDma_enableRxEvent(EnetDma_RxChHandle hRxCh)
Enable RX channel packet reception event.
Enet_Type
Ethernet peripheral type.
Definition: enet_types.h:195
struct EnetUdma_TxChObj_s * EnetDma_TxChHandle
Opaque handle that holds software state for Enet TX DMA channel.
Definition: enet_udma_types.h:100
int32_t EnetDma_getTxChStats(EnetDma_TxChHandle hTxCh, EnetDma_TxChStats *pStats)
Get TX channel statistics.
int32_t EnetDma_enableTxEvent(EnetDma_TxChHandle hTxCh)
Enable TX channel packet transmit completion event.
uint64_t freeDmaDescDeq
Definition: enet_dma.h:190
uint64_t rxSubmitPktUnderFlowCnt
Definition: enet_dma.h:211
RX channel statistics.
Definition: enet_dma.h:198
TX channel statistics.
Definition: enet_dma.h:217
This file contains the basic types using across the Enet driver.
This file contains the type definitions and helper macros for the Enet software queue.
struct EnetUdma_RxFlowObj_s * EnetDma_RxChHandle
Opaque handle that holds software state for Enet RX DMA flow.
Definition: enet_udma_types.h:95
int32_t EnetDma_disableTxEvent(EnetDma_TxChHandle hTxCh)
Disable TX channel packet transmit completion event.
int32_t EnetDma_closeRxCh(EnetDma_RxChHandle hRxCh, EnetDma_PktQ *fq, EnetDma_PktQ *cq)
Enet DMA close RX channel.
uint64_t zeroNotifyCnt
Definition: enet_dma.h:149
struct EnetUdma_PktInfo_s EnetDma_Pkt
Opaque handle that represents a DMA packet.
Definition: enet_udma_types.h:105
Config structure for Enet UDMA Data Path initialization.
Definition: enet_udma.h:744
int32_t EnetDma_resetTxChStats(EnetDma_TxChHandle hTxCh)
Reset TX channel statistics.
int32_t EnetDma_deinitDmaCfg(EnetDma_Handle hEnetUdma)
De-initialize data path.
Generic queue.
Definition: enet_queue.h:82
DMA descriptor stats for the RX & TX channels.
Definition: enet_dma.h:185
void EnetDma_initRxChParams(void *pRxChCfg)
Initialize RX channel open parameters.
EnetDma_Handle EnetDma_open(Enet_Type enetType, uint32_t instId, const void *dmaCfg)
Set default data path parameters.
EnetDma_DmaDescStats dmaDescStats
Definition: enet_dma.h:205
int32_t EnetDma_close(EnetDma_Handle hEnetDma)
Close Enet DMA (data path).
EnetDma_DmaDescStats dmaDescStats
Definition: enet_dma.h:224
struct EnetUdma_DrvObj_s * EnetDma_Handle
Opaque handle for Enet UDMA driver object.
Definition: enet_udma_types.h:86
This file contains the base DMA definitions.
UDMA Driver API/interface file.
uint64_t txSubmitPktOverFlowCnt
Definition: enet_dma.h:230
uint64_t txRetrievePktDeq
Definition: enet_dma.h:228
uint64_t pktsPerNotifyMax
Definition: enet_dma.h:158
EnetQ EnetDma_PktQ
Packet queue.
Definition: enet_dma.h:124
EnetDma_CbStats retrievePktStats
Definition: enet_dma.h:222
int32_t EnetDma_submitTxPktQ(EnetDma_TxChHandle hTxCh, EnetDma_PktQ *pSubmitQ)
Submit a queue of ready (full) packets to TX channel.
int32_t EnetDma_retrieveRxPkt(EnetDma_RxChHandle hRxCh, EnetDma_Pkt **pPkt)
Retrieve single RX ready (full) packet (single) from RX channel.
uint64_t totalCycleCnt
Definition: enet_dma.h:153
EnetDma_CbStats submitPktStats
Definition: enet_dma.h:220
uint64_t rxSubmitPktEnq
Definition: enet_dma.h:207
EnetDma_CbStats retrievePktStats
Definition: enet_dma.h:203
EnetDma_RxChHandle EnetDma_openRxCh(EnetDma_Handle hDma, const void *pRxChCfg)
Enet DMA open RX channel.
void EnetDma_initPktInfo(EnetDma_Pkt *pktInfo)
Initialize packet information structure.
int32_t EnetDma_getRxChStats(EnetDma_RxChHandle hRxCh, EnetDma_RxChStats *pStats)
Get RX channel statistics.
int32_t EnetDma_retrieveRxPktQ(EnetDma_RxChHandle hRxCh, EnetDma_PktQ *pRetrieveQ)
Retrieve queue of RX ready (full) packets from RX channel.
uint64_t dataNotifyCnt
Definition: enet_dma.h:145
void EnetDma_initTxChParams(void *pTxChCfg)
Initialize TX channel open parameters.
Enet DMA utility API to check packet and descriptor ownership states during development and debug.
uint64_t totalPktCnt
Definition: enet_dma.h:151
This file contains the type definitions and helper macros for the Enet UDMA CPPI protocol specific in...
uint64_t rxRetrievePktDeq
Definition: enet_dma.h:209
int32_t EnetDma_submitRxPkt(EnetDma_RxChHandle hRxCh, EnetDma_Pkt *pPkt)
Submit single RX free (empty) packet for reception to RX channel.
int32_t EnetDma_submitTxPkt(EnetDma_TxChHandle hTxCh, EnetDma_Pkt *pPkt)
Submit a single ready (full) packet to TX channel.
int32_t EnetDma_closeTxCh(EnetDma_TxChHandle hTxCh, EnetDma_PktQ *fq, EnetDma_PktQ *cq)
Enet DMA close TX channel.
int32_t EnetDma_resetRxChStats(EnetDma_RxChHandle hRxCh)
Reset RX channel statistics.
#define ENET_DMA_STATS_HISTORY_CNT
Enet DMA statistics configuration.
Definition: enet_dma.h:96
uint64_t underFlowCnt
Definition: enet_dma.h:192
EnetDma_TxChHandle EnetDma_openTxCh(EnetDma_Handle hDma, const void *pTxChCfg)
Enet DMA open TX channel.
int32_t EnetDma_retrieveTxPkt(EnetDma_TxChHandle hTxCh, EnetDma_Pkt **pPkt)
Retrieve single TX free (empty) packet from TX channel.
int32_t EnetDma_disableRxEvent(EnetDma_RxChHandle hRxCh)
Disable RX channel packet reception event.
uint64_t cycleCntPerPktMax
Definition: enet_dma.h:170
int32_t EnetDma_retrieveTxPktQ(EnetDma_TxChHandle hTxCh, EnetDma_PktQ *pRetrieveQ)
Retrieve queue of TX free (empty) packets from TX channel.
EnetDma_Handle EnetDma_initDmaCfg(Enet_Type enetType, uint32_t instId, const EnetDma_initCfg *pDmaCfg)
Initialize data path.
EnetDma_CbStats submitPktStats
Definition: enet_dma.h:201
int32_t EnetDma_submitRxPktQ(EnetDma_RxChHandle hRxCh, EnetDma_PktQ *pSubmitQ)
Submit queue of RX free (empty) packets for reception to RX channel.
Stats for packets submitted/retrieved in the DMA event callbacks functions.
Definition: enet_dma.h:142