![]() |
PDK Documentation
|
CPSW DMA submodule provides a API layer which allows applications to set up the UDMA peripheral to control the flow of packet data to/from the core from/to CPSW. CPSW DMA module is used to for
The application using CPSW DMA submodule need to allocate memories for different DMA data structures like ring memories, host packet descriptors and packet buffer memories.
Sub Modules | |
| CPSW DMA Configuration Definitions | |
| CPSW DMA Packet Utils | |
| CPSW_CONFIG_DEFINTIONS | |
| Packet Definitions | |
| Packet stats Definitions | |
Files | |
| file | cpsw_dma.h |
| This file contains the structure definitions and function prototypes of the CPSW Data/DMA path set up. | |
Functions | |
| void | CpswDma_initRxFlowParams (CpswDma_OpenRxFlowPrms *pRxFlowPrm) |
| CpswDma_OpenRxFlowPrms structure init function. More... | |
| void | CpswDma_initTxChParams (CpswDma_OpenTxChPrms *pTxChCfg) |
| CpswDma_OpenTxChPrms structure init function. More... | |
| void | CpswDma_pktInfoInit (CpswDma_PktInfo *pktInfo) |
| CpswDma_PktInfo structure init function. More... | |
| CpswDma_RxFlowHandle | CpswDma_openRxFlow (CpswDma_OpenRxFlowPrms *pRxFlowPrms) |
| CPSW DMA open Rx flow. More... | |
| int32_t | CpswDma_closeRxFlow (CpswDma_RxFlowHandle hRxFlow, CpswDma_PktInfoQ *pFqPktInfoQ, CpswDma_PktInfoQ *pCqPktInfoQ) |
| CPSW DMA close Rx flow. More... | |
| CpswDma_TxChHandle | CpswDma_openTxCh (CpswDma_OpenTxChPrms *pTxChCfg) |
| CPSW DMA open TX Channel. More... | |
| int32_t | CpswDma_closeTxCh (CpswDma_TxChHandle txChHandle, CpswDma_PktInfoQ *pFqPktInfoQ, CpswDma_PktInfoQ *pCqPktInfoQ) |
| CPSW DMA close TX channel. More... | |
| int32_t | CpswDma_enableTxEvent (CpswDma_TxChHandle txChHandle) |
| Enable TX channel ring event. More... | |
| int32_t | CpswDma_disableTxEvent (CpswDma_TxChHandle txChHandle) |
| Disable TX channel ring event. More... | |
| int32_t | CpswDma_enableRxEvent (CpswDma_RxFlowHandle hRxFlow) |
| Enable RX Flow ring event. More... | |
| int32_t | CpswDma_disableRxEvent (CpswDma_RxFlowHandle hRxFlow) |
| Disable RX Flow ring event. More... | |
| int32_t | CpswDma_retrieveRxPackets (CpswDma_RxFlowHandle hRxFlow, CpswDma_PktInfoQ *pFromFlowQueue) |
| RX Flow Retrieve ready(full) packet queue API. More... | |
| int32_t | CpswDma_submitRxPackets (CpswDma_RxFlowHandle hRxFlow, CpswDma_PktInfoQ *pToFlowQueue, CpswDma_PktInfoQ *pUnUsedPktQueue) |
| RX Flow Submit free packet queue API. More... | |
| int32_t | CpswDma_retrieveTxDonePackets (CpswDma_TxChHandle hTxCh, CpswDma_PktInfoQ *pFromTxChQueue) |
| TX channel Retrieve ready(empty) packet queue API. More... | |
| int32_t | CpswDma_submitTxReadyPackets (CpswDma_TxChHandle hTxCh, CpswDma_PktInfoQ *pToTxChQueue, CpswDma_PktInfoQ *pUnUsedPktQueue) |
| TX channel Submit Ready(full) packet queue API. More... | |
| int32_t | CpswDma_checkRxFlowSanity (CpswDma_RxFlowHandle hRxFlow, uint32_t margin) |
| API to check if any packet loss in RX flow FQ and CQ rings. More... | |
| int32_t | CpswDma_checkTxChSanity (CpswDma_TxChHandle hTxCh, uint32_t margin) |
| API to check if any packet loss in TX Channel FQ and CQ rings. More... | |
| int32_t | CpswDma_getRxFlowStats (CpswDma_RxFlowHandle hRxFlow, CpswDma_RxFlowStats *rxFlowStats) |
| Get RX flow statistics API. More... | |
| int32_t | CpswDma_getTxChStats (CpswDma_TxChHandle hTxCh, CpswDma_TxChStats *txChStats) |
| Get TX Channel statistics API. More... | |
| int32_t | CpswDma_resetRxFlowStats (CpswDma_RxFlowHandle hRxFlow) |
| Reset RX flow statistics API. More... | |
| int32_t | CpswDma_resetTxChStats (CpswDma_TxChHandle hTxCh) |
| Reset TX Channel statistics API. More... | |
| void | CpswDma_initDataPathParams (CpswDma_DataPathConfig *pDmaConfig) |
| Set default data path params. More... | |
| CpswDma_Handle | CpswDma_initDataPath (Cpsw_Type cpswType, const CpswDma_DataPathConfig *pCpswDmaDataPathConfig) |
| Init Data Path. More... | |
| int32_t | CpswDma_deInitDataPath (CpswDma_Handle hCpswDma) |
| DeInit Data Path. More... | |
CPSW Error Codes | |
| #define | CPSW_DMA_S_SUCCESS ((uint32_t)0x00000000U) |
| #define | CPSW_DMA_E_FAILURE ((uint32_t)0xFFFFFFFFU) |
| #define | CPSW_DMA_E_NO_RX_FLOWS_AVAILABLE ((uint32_t)0x00000003U) |
| #define | CPSW_DMA_E_NO_TX_CHANNELS_AVAILABLE ((uint32_t)0x00000004U) |
| #define | CPSW_DMA_E_CHANNEL_NOT_OPEN ((uint32_t)0x00000005U) |
| #define | CPSW_DMA_E_INVALID_PARAM ((uint32_t)0x00000006U) |
CPSW DMA Instance configuration | |
| #define | CPSW_DMA_MAX_TX_CH (8U) |
| #define | CPSW_DMA_MAX_RX_FLOW (64U) |
| #define | CPSW_DMA_MAX_RX_FREE_QUEUE (4U) |
| #define | CPSW_DMA_HPD_SIZE (128U) |
| #define | CPSW_DMA_EXTENDED_PKT_INFO_BLOCK_SIZE (16U) |
| #define | CPSW_DMA_PROTOCOL_SPECIFIC_INFO_BLOCK_SIZE (16U) |
| #define | CPSW_DMA_PKT_DESC_RESERVED_SIZE |
| #define | CPSW_DMA_RING_MEM_SIZE (sizeof(uint64_t)) |
| #define | CPSW_DMA_RXFLOWIDX_INVALID (0xABCDABCDU) |
CPSW DMA Statistics configuration | |
| #define | CPSW_DMA_STATS_HISTORY_CNT ((uint32_t)32U) |
CPSW DMA driver opaque handles | |
| typedef struct CpswDma_RxFlowObj_s * | CpswDma_RxFlowHandle |
| Opaque structure to hold software state for CPSW DMA RX flow. More... | |
| typedef struct CpswDma_TxChObj_s * | CpswDma_TxChHandle |
| Opaque structure to hold software state for CPSW TX DMA channel. More... | |
| typedef struct CpswDma_PktInfo_s * | CpswDma_PktHandle |
| Opaque structure to hold software state for CPSW Packet Info. More... | |
CPSW DMA driver Callback function types | |
Callback function typedefs so that the CpswDma layer can call into the app layer and let it translate between the hardware packet descriptors and packets and the stack/translation layer's buffers and packets. | |
| typedef uint8_t *(* | CpswDma_AllocRingMemFxn) (void *appPriv, uint32_t numRingEle, uint32_t alignSize) |
| typedef void(* | CpswDma_FreeRingMemFxn) (void *appPriv, void *pRingMem, uint32_t numRingEle) |
| typedef struct CpswDma_DmaDesc_s *(* | CpswDma_AllocDmaDesccFxn) (void *appPriv, uint32_t alignSize) |
| typedef void(* | CpswDma_FreeDmaDescFxn) (void *appPriv, struct CpswDma_DmaDesc_s *dmaDescPtr) |
| typedef void(* | CpswDma_PktNotifyCb) (void *hCbArg) |
| #define CPSW_DMA_S_SUCCESS ((uint32_t)0x00000000U) |
| #define CPSW_DMA_E_FAILURE ((uint32_t)0xFFFFFFFFU) |
| #define CPSW_DMA_E_NO_RX_FLOWS_AVAILABLE ((uint32_t)0x00000003U) |
| #define CPSW_DMA_E_NO_TX_CHANNELS_AVAILABLE ((uint32_t)0x00000004U) |
| #define CPSW_DMA_E_CHANNEL_NOT_OPEN ((uint32_t)0x00000005U) |
| #define CPSW_DMA_E_INVALID_PARAM ((uint32_t)0x00000006U) |
| #define CPSW_DMA_MAX_TX_CH (8U) |
Maximum number of CPSW TX DMA channels
| #define CPSW_DMA_MAX_RX_FLOW (64U) |
Maximum number of CPSW RX FLOWS channels
| #define CPSW_DMA_MAX_RX_FREE_QUEUE (4U) |
Max. number for Rx free queues for CPSW RX DMA flow
| #define CPSW_DMA_HPD_SIZE (128U) |
CPSW DMA HPD packet size
| #define CPSW_DMA_EXTENDED_PKT_INFO_BLOCK_SIZE (16U) |
Extended Packet Info Block size
| #define CPSW_DMA_PROTOCOL_SPECIFIC_INFO_BLOCK_SIZE (16U) |
Extended Packet Info Block size
| #define CPSW_DMA_PKT_DESC_RESERVED_SIZE |
Extended Packet Info Block size
| #define CPSW_DMA_RING_MEM_SIZE (sizeof(uint64_t)) |
CPSW DMA Desc size - this is used by applications to allocate DMA desc memory
| #define CPSW_DMA_RXFLOWIDX_INVALID (0xABCDABCDU) |
CPSW DMA Invalid RX flow id
| #define CPSW_DMA_STATS_HISTORY_CNT ((uint32_t)32U) |
| typedef struct CpswDma_RxFlowObj_s* CpswDma_RxFlowHandle |
Opaque structure to hold software state for CPSW DMA RX flow.
| typedef struct CpswDma_TxChObj_s* CpswDma_TxChHandle |
Opaque structure to hold software state for CPSW TX DMA channel.
| typedef struct CpswDma_PktInfo_s* CpswDma_PktHandle |
Opaque structure to hold software state for CPSW Packet Info.
| typedef uint8_t*(* CpswDma_AllocRingMemFxn) (void *appPriv, uint32_t numRingEle, uint32_t alignSize) |
Function pointer type for DMAC packet allocation function
| typedef void(* CpswDma_FreeRingMemFxn) (void *appPriv, void *pRingMem, uint32_t numRingEle) |
Function pointer type for DMAC packet free function
| typedef struct CpswDma_DmaDesc_s*(* CpswDma_AllocDmaDesccFxn) (void *appPriv, uint32_t alignSize) |
Function pointer type for DMAC packet allocation function
| typedef void(* CpswDma_FreeDmaDescFxn) (void *appPriv, struct CpswDma_DmaDesc_s *dmaDescPtr) |
Function pointer type for DMAC packet free function
| typedef void(* CpswDma_PktNotifyCb) (void *hCbArg) |
Function pointer type for packet notify call back. This is called by driver when packet is received on the Rx flow or transmission completed from Tx channel.
| void CpswDma_initRxFlowParams | ( | CpswDma_OpenRxFlowPrms * | pRxFlowPrm | ) |
CpswDma_OpenRxFlowPrms structure init function.
| pRxFlowPrm | [IN] Pointer to CpswDma_OpenRxFlowPrms structure. |
| void CpswDma_initTxChParams | ( | CpswDma_OpenTxChPrms * | pTxChCfg | ) |
CpswDma_OpenTxChPrms structure init function.
| pTxChCfg | [IN] Pointer to CpswDma_OpenTxChPrms structure. |
| void CpswDma_pktInfoInit | ( | CpswDma_PktInfo * | pktInfo | ) |
CpswDma_PktInfo structure init function.
| pktInfo | [IN] Pointer to CpswDma_PktInfo structure. |
| CpswDma_RxFlowHandle CpswDma_openRxFlow | ( | CpswDma_OpenRxFlowPrms * | pRxFlowPrms | ) |
CPSW DMA open Rx flow.
Opens the CPSW DMA RX flow based on the flow parameters. This function attaches flow using flowIdx provided in CpswDma_OpenRxFlowPrms and configures the UDMA flow. This also configures event if notifyCb is not null
Requirement:
| pRxFlowPrms | [IN] CPSW RX Flow parameters CpswDma_OpenRxFlowPrms. This parameter can't be NULL. |
| int32_t CpswDma_closeRxFlow | ( | CpswDma_RxFlowHandle | hRxFlow, |
| CpswDma_PktInfoQ * | pFqPktInfoQ, | ||
| CpswDma_PktInfoQ * | pCqPktInfoQ | ||
| ) |
CPSW DMA close Rx flow.
Closes the CPSW DMA RX flow and frees all associated resources. During close operation, we flush FQ taking all DMA descriptors with packet submitted in advance for reception and return to app. Also we retrieve all packets from the CQ (packets received between last CpswDma_retrieveRxPackets packets call) and return those to app. App doesn't need to call CpswDma_retrieveRxPackets explicitly to retrieve these packets
Requirement:
| hRxFlow | [IN] CPSW DMA flow handle. This parameter can't be NULL. |
| pFqPktInfoQ | [OUT] Pointer to CpswDma_PktInfoQ structure where packets from FQ (submitted for reception) are retrieved and returned to application. This parameter can't be NULL. |
| pCqPktInfoQ | [OUT] Pointer to CpswDma_PktInfoQ structure where packets from CQ (received packets) are retrieved and returned to application. This parameter can't be NULL. |
| CpswDma_TxChHandle CpswDma_openTxCh | ( | CpswDma_OpenTxChPrms * | pTxChCfg | ) |
CPSW DMA open TX Channel.
Opens the CPSW TX UDMA channel based on the channel parameters. This function open TX channel using chNum provided in CpswDma_OpenTxChPrms and configures TX channel. This also configures event if notifyCb is not null
Requirement:
| pTxChCfg | [IN] CPSW TX channel parameters CpswDma_OpenTxChPrms. This parameter can't be NULL. |
| int32_t CpswDma_closeTxCh | ( | CpswDma_TxChHandle | txChHandle, |
| CpswDma_PktInfoQ * | pFqPktInfoQ, | ||
| CpswDma_PktInfoQ * | pCqPktInfoQ | ||
| ) |
CPSW DMA close TX channel.
Closes the CPSW DMA TX channel and frees all associated resources. During close operation, we flush FQ taking all DMA descriptors with packet submitted but not yet transmitted and return to app. Also we retrieve all packets from the CQ (transmission completed packets) and return those to app. App doesn't need to call CpswDma_retrieveTxDonePackets explicitly to retrieve these packets
Requirement:
| txChHandle | [IN] CPSW DMA TX Channel handle. This parameter can't be NULL. |
| pFqPktInfoQ | [OUT] Pointer to CpswDma_PktInfoQ structure where packets from FQ (submitted but not transmitted) are retrieved and returned to application. This parameter can't be NULL. |
| pCqPktInfoQ | [OUT] Pointer to CpswDma_PktInfoQ structure where packets from CQ (transmission completed) are retrieved and returned to application. This parameter can't be NULL. |
| int32_t CpswDma_enableTxEvent | ( | CpswDma_TxChHandle | txChHandle | ) |
Enable TX channel ring event.
Enables the ring completion event for TX channel. This allows application to run time control ring events and retrieve packet once to do burst packet processing.
| txChHandle | [IN] Handle to CPSW DMA TX channel |
| int32_t CpswDma_disableTxEvent | ( | CpswDma_TxChHandle | txChHandle | ) |
Disable TX channel ring event.
Disable the ring completion event for TX channel. This allows application to run time control ring events and retrieve packet once.
| txChHandle | [IN] Handle to CPSW DMA TX channel |
| int32_t CpswDma_enableRxEvent | ( | CpswDma_RxFlowHandle | hRxFlow | ) |
Enable RX Flow ring event.
Enables the ring completion event for RX Flow. This allows application to run time control ring events and retrieve packet once to do burst packet processing.
| hRxFlow | [IN] Handle to CPSW DMA RX Flow |
| int32_t CpswDma_disableRxEvent | ( | CpswDma_RxFlowHandle | hRxFlow | ) |
Disable RX Flow ring event.
Disable the ring completion event for RX Flow. This allows application to run time control ring events and retrieve packet once.
| hRxFlow | [IN] Handle to CPSW DMA RX Flow |
| int32_t CpswDma_retrieveRxPackets | ( | CpswDma_RxFlowHandle | hRxFlow, |
| CpswDma_PktInfoQ * | pFromFlowQueue | ||
| ) |
RX Flow Retrieve ready(full) packet queue API.
| hRxFlow | [IN] flow handle for the flow we wish to retrieve packets from. |
| pFromFlowQueue | [OUT] Pointer to CpswDma_PktInfoQ structure where packets from hardware are retrieved and returned to application. |
| int32_t CpswDma_submitRxPackets | ( | CpswDma_RxFlowHandle | hRxFlow, |
| CpswDma_PktInfoQ * | pToFlowQueue, | ||
| CpswDma_PktInfoQ * | pUnUsedPktQueue | ||
| ) |
RX Flow Submit free packet queue API.
| hRxFlow | [IN] flow handle for the flow we wish to submit packets to. |
| pToFlowQueue | [OUT] Pointer to CpswDma_PktInfoQ structure containing packets to be submitted to flow. |
| pUnUsedPktQueue | [OUT] Pointer to CpswDma_PktInfoQ structure. This Q is used by driver to return packets for which it couldn't allocate the DMA descriptors. |
| int32_t CpswDma_retrieveTxDonePackets | ( | CpswDma_TxChHandle | hTxCh, |
| CpswDma_PktInfoQ * | pFromTxChQueue | ||
| ) |
TX channel Retrieve ready(empty) packet queue API.
| hTxCh | [IN] CPSW DMA TX channel handle for the TX Channel we wish to retrieve packets from. |
| pFromTxChQueue | [OUT] Pointer to CpswDma_PktInfoQ structure where packets from hardware are retrieved and returned to application. |
| int32_t CpswDma_submitTxReadyPackets | ( | CpswDma_TxChHandle | hTxCh, |
| CpswDma_PktInfoQ * | pToTxChQueue, | ||
| CpswDma_PktInfoQ * | pUnUsedPktQueue | ||
| ) |
TX channel Submit Ready(full) packet queue API.
| hTxCh | [IN] TX Channel handle for the TX channel we wish to submit packets to. |
| pToTxChQueue | [OUT] Pointer to CpswDma_PktInfoQ structure containing packets to be submitted to TX Channel. |
| pUnUsedPktQueue | [OUT] Pointer to CpswDma_PktInfoQ structure. This Q is used by driver to return packets for which it couldn't allocate the DMA descriptors. |
| int32_t CpswDma_checkRxFlowSanity | ( | CpswDma_RxFlowHandle | hRxFlow, |
| uint32_t | margin | ||
| ) |
API to check if any packet loss in RX flow FQ and CQ rings.
This development time error checks API checks dma desc loss due to any timing issues We check amount of descriptors with DMA and free matches the no. of allocated with some "margin" for packets in flight.
| hRxFlow | [IN] flow handle for the flow we wish to check sanity. |
| margin | [IN] Amount of packets which can be in flight in DMA. |
Note - Margin can vary drastically based on Core (A72 vs R5), type of Udma channel (NORMAL/HC etc.) and size of packet. This makes these API dependent on application configuration.
| int32_t CpswDma_checkTxChSanity | ( | CpswDma_TxChHandle | hTxCh, |
| uint32_t | margin | ||
| ) |
API to check if any packet loss in TX Channel FQ and CQ rings.
This development time error checks API checks dma desc loss due to any timing issues We check amount of descriptors with DMA and free matches the no. of allocated with some "margin" for packets in flight.
| hTxCh | [IN] TX Channel handle for the TX channel we wish to check sanity. |
| margin | [IN] Amount of packets which can be in flight in DMA. |
Note - Margin can vary drastically based on Core (A72 vs R5), type of Udma channel (NORMAL/HC etc.) and size of packet. This makes these API dependent on application configuration.
| int32_t CpswDma_getRxFlowStats | ( | CpswDma_RxFlowHandle | hRxFlow, |
| CpswDma_RxFlowStats * | rxFlowStats | ||
| ) |
Get RX flow statistics API.
| hRxFlow | [IN] RX flow handle. |
| rxFlowStats | [INOUT] Pointer to RX Flow stats object where stats would be returned |
| int32_t CpswDma_getTxChStats | ( | CpswDma_TxChHandle | hTxCh, |
| CpswDma_TxChStats * | txChStats | ||
| ) |
Get TX Channel statistics API.
| hTxCh | [IN] TX Channel handle |
| txChStats | [INOUT] Pointer to TX Channel stats object where stats would be returned |
| int32_t CpswDma_resetRxFlowStats | ( | CpswDma_RxFlowHandle | hRxFlow | ) |
Reset RX flow statistics API.
| hRxFlow | [IN] RX flow handle. |
| int32_t CpswDma_resetTxChStats | ( | CpswDma_TxChHandle | hTxCh | ) |
Reset TX Channel statistics API.
| hTxCh | [IN] TX Channel handle |
| void CpswDma_initDataPathParams | ( | CpswDma_DataPathConfig * | pDmaConfig | ) |
Set default data path params.
| pDmaConfig | [IN] Data Path Config structure to be initialized |
| CpswDma_Handle CpswDma_initDataPath | ( | Cpsw_Type | cpswType, |
| const CpswDma_DataPathConfig * | pCpswDmaDataPathConfig | ||
| ) |
Init Data Path.
Init Dma data path state on remote core
| cpswType | [IN] Cpsw Type |
| pCpswDmaDataPathConfig | [IN] Data Path Init params |
| int32_t CpswDma_deInitDataPath | ( | CpswDma_Handle | hCpswDma | ) |
DeInit Data Path.
DeInit Dma data path state on remote core
| hCpswDma | [IN] Cpsw DMA Handle |