AM263x MCU+ SDK  11.00.00
enet_cpdma.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Texas Instruments Incorporated 2020-25
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_CPDMA_H_
48 #define ENET_CPDMA_H_
49 
50 /* ========================================================================== */
51 /* Include Files */
52 /* ========================================================================== */
53 
54 #include <stdint.h>
56 #include <include/core/enet_base.h>
59 
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
63 
64 /* ========================================================================== */
65 /* Macros */
66 /* ========================================================================== */
67 
77 #define ENET_CPDMA_CPSW_MAX_TX_CH (8U)
78 
80 #define ENET_CPDMA_CPSW_MAX_RX_CH (8U)
81 
85 #define ENET_CPDMA_CPSW_MAX_SG_LIST (4U)
86 
87 #if ((__ARM_ARCH == 7) && (__ARM_ARCH_PROFILE == 'R'))
88 
89 #define ENETDMA_CACHELINE_ALIGNMENT (32U)
90 #else
91 #error "Enet library compilation not supported on non cortex R cores. Update correct cache line size"
92 #endif
93 
96 #define ENET_CPDMA_CSUM_START_BYTE_SHIFT (16U)
97 
98 #define ENET_CPDMA_CSUM_START_BYTE_MASK (((uint32_t) 0xFFU) << ENET_CPDMA_CSUM_START_BYTE_SHIFT)
99 
100 #define ENET_CPDMA_CSUM_RESULT_BYTE_SHIFT (24U)
101 
102 #define ENET_CPDMA_CSUM_RESULT_BYTE_MASK (((uint32_t) 0xFFU) << ENET_CPDMA_CSUM_RESULT_BYTE_SHIFT)
103 
104 #define ENET_CPDMA_CSUM_BYTE_COUNT_SHIFT (0U)
105 
106 #define ENET_CPDMA_CSUM_BYTE_COUNT_MASK (((uint32_t) 0x3FFU) << ENET_CPDMA_CSUM_BYTE_COUNT_SHIFT)
107 
108 #define ENET_CPDMA_GET_CSUM_RESULT_BYTE(chkSumInfo) \
109  ENET_FEXT(chkSumInfo, ENET_CPDMA_CSUM_RESULT_BYTE)
110 
111 #define ENET_CPDMA_GET_CSUM_START_BYTE(chkSumInfo) \
112  ENET_FEXT(chkSumInfo, ENET_CPDMA_CSUM_START_BYTE)
113 
114 #define ENET_CPDMA_GET_CSUM_BYTE_COUNT(chkSumInfo) \
115  ENET_FEXT(chkSumInfo, ENET_CPDMA_CSUM_BYTE_COUNT)
116 
126 /* TODO: may be deleted */
133 typedef void (*EnetDma_PktNotifyCb)(void *cbArg);
134 
145 
146 /* ========================================================================== */
147 /* Structures and Enums */
148 /* ========================================================================== */
149 
160 /*
161  * TODO: CPDMA does not support timestamp within packet
162  * Stub to share the application code?
163  */
164 
170 typedef struct EnetCpdma_PktTsInfo_s
171 {
174 
176  uint32_t txPktSeqId;
177 
179  uint8_t txPktMsgType;
180 
182  uint8_t txPktDomain;
183 
185  uint64_t rxPktTs;
187 
196 typedef struct EnetCpdma_SGListEntry_s
197 {
204  uint8_t *bufPtr;
205 
207  uint8_t *origBufPtr;
208 
211 
213  uint32_t segmentAllocLen;
214 
217 
229 typedef struct EnetCpdma_SGList_s
230 {
239 
241 
270 typedef struct EnetCpdma_PktInfo_s
271 {
276 
278  void *appPriv;
279 
285  uint32_t pktState;
286 
296  uint32_t chkSumInfo;
297 
308 
319 
324 
327  uint32_t txPktTc;
328 
331  uint32_t txTsId;
332 
340 
359 typedef struct EnetCpdma_OpenTxChPrms_s
360 {
363 
365  uint32_t chNum;
366 
370 
373  uint32_t numTxPkts;
374 
377  void *cbArg;
378 
380 
386 typedef struct EnetCpdma_OpenRxChPrms_s
387 {
390 
392  uint32_t chNum;
393 
397 
400  uint32_t numRxPkts;
401 
404  void *cbArg;
405 
407 
413 
420 typedef struct EnetCpdma_RxChInitPrms_s
421 {
423  uint32_t rxBufferOffset;
425 
432 typedef struct EnetCpdma_Cfg_s
433 {
436 
439 
446 
449 
452 
454  uint32_t maxTxChannels;
455 
457  uint32_t maxRxChannels;
458 
459 } EnetDma_Cfg;
460 
466 typedef struct EnetDma_initCfg_s
467 {
468 }
472 /* ========================================================================== */
473 /* Global Variables Declarations */
474 /* ========================================================================== */
475 
476 /* None */
477 
478 /* ========================================================================== */
479 /* Function Declarations */
480 /* ========================================================================== */
481 
491 
511  const EnetCpdma_OpenRxChPrms *pRxChPrms);
512 
536  EnetDma_PktQ *fq,
537  EnetDma_PktQ *cq);
538 
548 
568  const EnetCpdma_OpenTxChPrms *pTxChPrms);
569 
592  EnetDma_PktQ *fq,
593  EnetDma_PktQ *cq);
594 
607  uint32_t instId,
608  const EnetDma_Cfg *dmaCfg,
609  uint32_t appCoreId);
610 
622  uint32_t instId,
623  uint32_t appCoreId);
624 
632 int32_t EnetCpdma_close(EnetDma_Handle hEnetDma);
633 
642 
657 
671 int32_t EnetCpdma_rxIsr(EnetDma_Handle hEnetDma);
672 
686 int32_t EnetCpdma_txIsr(EnetDma_Handle hEnetDma);
687 
702 int32_t EnetCpdma_miscIsrGetStatus(EnetDma_Handle hEnetDma, uint32_t *pStatusMask);
703 
715 
727 
728 /* ========================================================================== */
729 /* Deprecated Function Declarations */
730 /* ========================================================================== */
731 
732 /* None */
733 
734 /* ========================================================================== */
735 /* Static Function Definitions */
736 /* ========================================================================== */
737 
738 /* None */
739 
740 #ifdef __cplusplus
741 }
742 #endif
743 
744 #endif /* ENET_CPDMA_H_ */
745 
EnetCpdma_PktInfo::txTsId
uint32_t txTsId
Definition: enet_cpdma.h:331
EnetCpdma_SGListEntry::origBufPtr
uint8_t * origBufPtr
Definition: enet_cpdma.h:207
EnetCpdma_txIsr
int32_t EnetCpdma_txIsr(EnetDma_Handle hEnetDma)
ENET CPDMA Tx interrupt service routine.
EnetCpdma_initRxChParams
void EnetCpdma_initRxChParams(EnetCpdma_OpenRxChPrms *pRxChPrms)
Initialize RX channel open parameters.
EnetCpdma_RxChInitPrms
Global Param struct for the Rx channel open.
Definition: enet_cpdma.h:421
EnetDma_Cfg::maxTxChannels
uint32_t maxTxChannels
Definition: enet_cpdma.h:454
ENET_CPDMA_CPSW_MAX_SG_LIST
#define ENET_CPDMA_CPSW_MAX_SG_LIST
Definition: enet_cpdma.h:85
EnetDma_PktNotifyCb
void(* EnetDma_PktNotifyCb)(void *cbArg)
Function pointer type for packet notify call back.
Definition: enet_cpdma.h:133
EnetCpdma_PktTsInfo::txPktDomain
uint8_t txPktDomain
Definition: enet_cpdma.h:182
EnetCpdma_open
EnetDma_Handle EnetCpdma_open(Enet_Type enetType, uint32_t instId, const EnetDma_Cfg *dmaCfg, uint32_t appCoreId)
Set default data path parameters.
EnetCpdma_PktInfo::txPortNum
Enet_MacPort txPortNum
Definition: enet_cpdma.h:318
EnetDma_Cfg
Config structure for Enet CPDMA.
Definition: enet_cpdma.h:433
EnetCpdma_PktInfo::node
EnetQ_Node node
Definition: enet_cpdma.h:275
EnetCpdma_saveCtxt
int32_t EnetCpdma_saveCtxt(EnetDma_Handle hEnetDma)
Saves and closes Enet DMA (data path).
EnetCpdma_miscIsrGetStatus
int32_t EnetCpdma_miscIsrGetStatus(EnetDma_Handle hEnetDma, uint32_t *pStatusMask)
ENET CPDMA Miscellaneous interrupt service routine.
EnetCpdma_OpenRxChPrms::chNum
uint32_t chNum
Definition: enet_cpdma.h:392
EnetCpdma_SGListEntry::disableCacheOps
bool disableCacheOps
Definition: enet_cpdma.h:215
EnetCpdma_SGListEntry::segmentAllocLen
uint32_t segmentAllocLen
Definition: enet_cpdma.h:213
EnetDma_RxChHandle
struct EnetCpdma_RxChObj_s * EnetDma_RxChHandle
Opaque handle that holds software state for Enet RX DMA channel.
Definition: enet_cpdma_types.h:92
enet_types.h
This file contains the basic types using across the Enet driver.
EnetCpdma_OpenRxChPrms::hEnet
Enet_Handle hEnet
Definition: enet_cpdma.h:389
enet_cpdma_types.h
This file contains the base DMA definitions.
EnetCpdma_PktTsInfo::txPktSeqId
uint32_t txPktSeqId
Definition: enet_cpdma.h:176
EnetCpdma_closeTxCh
int32_t EnetCpdma_closeTxCh(EnetDma_TxChHandle hTxCh, EnetDma_PktQ *fq, EnetDma_PktQ *cq)
Enet DMA close TX channel.
Enet_MacPort
Enet_MacPort
MAC port.
Definition: enet_types.h:412
EnetCpdma_PktInfo
Packet data structure.
Definition: enet_cpdma.h:271
EnetCpdma_PktInfo::chkSumInfo
uint32_t chkSumInfo
Definition: enet_cpdma.h:296
enet_queue.h
This file contains the type definitions and helper macros for the Enet software queue.
EnetCpdma_OpenTxChPrms::hEnet
Enet_Handle hEnet
Definition: enet_cpdma.h:362
EnetCpdma_OpenTxChPrms::notifyCb
EnetDma_PktNotifyCb notifyCb
Definition: enet_cpdma.h:369
EnetCpdma_SGListEntry::bufPtr
uint8_t * bufPtr
Definition: enet_cpdma.h:204
EnetDma_Cfg::rxInterruptPerMSec
uint32_t rxInterruptPerMSec
Definition: enet_cpdma.h:438
EnetCpdma_openRxCh
EnetDma_RxChHandle EnetCpdma_openRxCh(EnetDma_Handle hDma, const EnetCpdma_OpenRxChPrms *pRxChPrms)
Enet DMA open RX channel.
EnetCpdma_OpenTxChPrms::chNum
uint32_t chNum
Definition: enet_cpdma.h:365
EnetCpdma_restoreCtxt
EnetDma_Handle EnetCpdma_restoreCtxt(Enet_Type enetType, uint32_t instId, uint32_t appCoreId)
Open DMA with default data path parameters.
EnetCpdma_ackMiscIsr
int32_t EnetCpdma_ackMiscIsr(EnetDma_Handle hEnetDma)
EnetQ_Node
A generic node structure for a single link list.
Definition: enet_queue.h:74
EnetCpdma_OpenTxChPrms::numTxPkts
uint32_t numTxPkts
Definition: enet_cpdma.h:373
EnetCpdma_initTxChParams
void EnetCpdma_initTxChParams(EnetCpdma_OpenTxChPrms *pTxChPrms)
Initialize TX channel open parameters.
EnetCpdma_SGListEntry
Transmit Packet scatter gather list entry.
Definition: enet_cpdma.h:197
EnetDma_Cfg::rxChInitPrms
EnetCpdma_RxChInitPrms rxChInitPrms
Definition: enet_cpdma.h:451
EnetCpdma_OpenRxChPrms::numRxPkts
uint32_t numRxPkts
Definition: enet_cpdma.h:400
EnetCpdma_PktTsInfo
CPPI buffer timestamp info.
Definition: enet_cpdma.h:171
EnetDma_OpenRxChPrms
EnetCpdma_OpenRxChPrms EnetDma_OpenRxChPrms
Param struct for the RX channel open function. We include this typedef as top level DMA APIs use Enet...
Definition: enet_cpdma.h:412
EnetDma_Cfg::txInterruptPerMSec
uint32_t txInterruptPerMSec
Definition: enet_cpdma.h:435
EnetCpdma_OpenRxChPrms::notifyCb
EnetDma_PktNotifyCb notifyCb
Definition: enet_cpdma.h:396
EnetCpdma_rxThreshIsr
int32_t EnetCpdma_rxThreshIsr(EnetDma_Handle hEnetDma)
ENET CPDMA Rx Threshold interrupt service routine.
EnetCpdma_OpenTxChPrms::cbArg
void * cbArg
Definition: enet_cpdma.h:377
EnetCpdma_PktInfo::rxPortNum
Enet_MacPort rxPortNum
Definition: enet_cpdma.h:323
EnetDma_Cfg::enHostRxTsFlag
bool enHostRxTsFlag
Definition: enet_cpdma.h:448
EnetCpdma_SGListEntry::segmentFilledLen
uint32_t segmentFilledLen
Definition: enet_cpdma.h:210
Enet_Type
Enet_Type
Ethernet peripheral type.
Definition: enet_types.h:202
EnetDma_Handle
struct EnetCpdma_DrvObj_s * EnetDma_Handle
Opaque handle for Enet CPDMA driver object.
Definition: enet_cpdma_types.h:86
EnetCpdma_PktInfo::sgList
EnetCpdma_SGList sgList
Definition: enet_cpdma.h:338
EnetCpdma_PktTsInfo::txPktMsgType
uint8_t txPktMsgType
Definition: enet_cpdma.h:179
EnetDma_TxChHandle
struct EnetCpdma_TxChObj_s * EnetDma_TxChHandle
Opaque handle that holds software state for Enet TX DMA channel.
Definition: enet_cpdma_types.h:97
EnetCpdma_PktInfo::txPktTc
uint32_t txPktTc
Definition: enet_cpdma.h:327
EnetDma_Cfg::maxRxChannels
uint32_t maxRxChannels
Definition: enet_cpdma.h:457
EnetCpdma_close
int32_t EnetCpdma_close(EnetDma_Handle hEnetDma)
Close Enet DMA (data path).
EnetCpdma_openTxCh
EnetDma_TxChHandle EnetCpdma_openTxCh(EnetDma_Handle hDma, const EnetCpdma_OpenTxChPrms *pTxChPrms)
Enet DMA open TX channel.
enet_base.h
This file contains the type definitions and helper macros for the Enet Peripheral interface.
EnetCpdma_SGList
Transmit packet scatter list info.
Definition: enet_cpdma.h:230
EnetCpdma_PktInfo::pktState
uint32_t pktState
Definition: enet_cpdma.h:285
EnetCpdma_initParams
void EnetCpdma_initParams(EnetDma_Cfg *pDmaConfig)
Initialize CPDMA config params.
EnetDma_initCfg
Config structure for Enet CPDMA Data Path initialization.
Definition: enet_cpdma.h:467
EnetCpdma_RxChInitPrms::rxBufferOffset
uint32_t rxBufferOffset
Definition: enet_cpdma.h:423
EnetCpdma_OpenRxChPrms::cbArg
void * cbArg
Definition: enet_cpdma.h:404
EnetCpdma_PktInfo::appPriv
void * appPriv
Definition: enet_cpdma.h:278
EnetDma_SGListEntry
EnetCpdma_SGListEntry EnetDma_SGListEntry
Definition: enet_cpdma.h:240
EnetCpdma_closeRxCh
int32_t EnetCpdma_closeRxCh(EnetDma_RxChHandle hRxCh, EnetDma_PktQ *fq, EnetDma_PktQ *cq)
Enet DMA close RX channel.
EnetDma_Cfg::enChOverrideFlag
bool enChOverrideFlag
Definition: enet_cpdma.h:445
EnetCpdma_OpenRxChPrms
Param struct for the RX channel open function.
Definition: enet_cpdma.h:387
EnetCpdma_SGList::numScatterSegments
uint32_t numScatterSegments
Definition: enet_cpdma.h:235
EnetCpdma_PktInfo::tsInfo
EnetCpdma_PktTsInfo tsInfo
Definition: enet_cpdma.h:307
EnetCpdma_PktTsInfo::enableHostTxTs
bool enableHostTxTs
Definition: enet_cpdma.h:173
EnetCpdma_PktTsInfo::rxPktTs
uint64_t rxPktTs
Definition: enet_cpdma.h:185
Enet_Handle
struct Enet_Obj_s * Enet_Handle
Ethernet driver handle.
Definition: enet_base.h:106
EnetQ
Generic queue.
Definition: enet_queue.h:83
EnetCpdma_OpenTxChPrms
Param struct for the TX channel open function.
Definition: enet_cpdma.h:360
EnetCpdma_rxIsr
int32_t EnetCpdma_rxIsr(EnetDma_Handle hEnetDma)
ENET CPDMA Rx interrupt service routine.
EnetDma_PktQ
EnetQ EnetDma_PktQ
Packet queue.
Definition: enet_cpdma.h:144