AM261x MCU+ SDK: Enet CPDMA APIs

| AM261x MCU+ SDK 26.00.00 |

Sub Modules | Functions | Typedefs | Macros
Enet CPDMA APIs
APIs for Networking modules » APIs for Enet LLD » Enet Data Path (DMA)

## Introduction

## Sub Modules
| CPDMA Configuration
| CPDMA Packet Definitions

## Functions
void | EnetCpdma_initRxChParams (EnetCpdma_OpenRxChPrms *pRxChPrms)
| Initialize RX channel open parameters. More...
EnetDma_RxChHandle | EnetCpdma_openRxCh (EnetDma_Handle hDma, const EnetCpdma_OpenRxChPrms *pRxChPrms)
| Enet DMA open RX channel. More...
int32_t | EnetCpdma_closeRxCh (EnetDma_RxChHandle hRxCh, EnetDma_PktQ *fq, EnetDma_PktQ *cq)
| Enet DMA close RX channel. More...
void | EnetCpdma_initTxChParams (EnetCpdma_OpenTxChPrms *pTxChPrms)
| Initialize TX channel open parameters. More...
EnetDma_TxChHandle | EnetCpdma_openTxCh (EnetDma_Handle hDma, const EnetCpdma_OpenTxChPrms *pTxChPrms)
| Enet DMA open TX channel. More...
int32_t | EnetCpdma_closeTxCh (EnetDma_TxChHandle hTxCh, EnetDma_PktQ *fq, EnetDma_PktQ *cq)
| Enet DMA close TX channel. More...
EnetDma_Handle | EnetCpdma_open (Enet_Type enetType, uint32_t instId, const EnetDma_Cfg *dmaCfg, uint32_t appCoreId)
| Set default data path parameters. More...
EnetDma_Handle | EnetCpdma_restoreCtxt (Enet_Type enetType, uint32_t instId, uint32_t appCoreId)
| Open DMA with default data path parameters. More...
int32_t | EnetCpdma_close (EnetDma_Handle hEnetDma)
| Close Enet DMA (data path). More...
int32_t | EnetCpdma_saveCtxt (EnetDma_Handle hEnetDma)
| Saves and closes Enet DMA (data path). More...
int32_t | EnetCpdma_rxThreshIsr (EnetDma_Handle hEnetDma)
| ENET CPDMA Rx Threshold interrupt service routine. More...
int32_t | EnetCpdma_rxIsr (EnetDma_Handle hEnetDma)
| ENET CPDMA Rx interrupt service routine. More...
int32_t | EnetCpdma_txIsr (EnetDma_Handle hEnetDma)
| ENET CPDMA Tx interrupt service routine. More...
int32_t | EnetCpdma_miscIsrGetStatus (EnetDma_Handle hEnetDma, uint32_t *pStatusMask)
| ENET CPDMA Miscellaneous interrupt service routine. More...
int32_t | EnetCpdma_ackMiscIsr (EnetDma_Handle hEnetDma)
void | EnetCpdma_initParams (EnetDma_Cfg *pDmaConfig)
| Initialize CPDMA config params. More...

## Typedefs
typedef EnetQ | EnetDma_PktQ
| Packet queue. More...

## Macros
#define | ENET_CPDMA_CPSW_MAX_SG_LIST (4U)
#define | ENET_CPDMA_CSUM_START_BYTE_SHIFT (16U)
#define | ENET_CPDMA_CSUM_START_BYTE_MASK (((uint32_t) 0xFFU) << ENET_CPDMA_CSUM_START_BYTE_SHIFT)
#define | ENET_CPDMA_CSUM_RESULT_BYTE_SHIFT (24U)
#define | ENET_CPDMA_CSUM_RESULT_BYTE_MASK (((uint32_t) 0xFFU) << ENET_CPDMA_CSUM_RESULT_BYTE_SHIFT)
#define | ENET_CPDMA_CSUM_BYTE_COUNT_SHIFT (0U)
#define | ENET_CPDMA_CSUM_BYTE_COUNT_MASK (((uint32_t) 0x3FFU) << ENET_CPDMA_CSUM_BYTE_COUNT_SHIFT)
#define | ENET_CPDMA_GET_CSUM_RESULT_BYTE(chkSumInfo) ENET_FEXT(chkSumInfo, ENET_CPDMA_CSUM_RESULT_BYTE)
#define | ENET_CPDMA_GET_CSUM_START_BYTE(chkSumInfo) ENET_FEXT(chkSumInfo, ENET_CPDMA_CSUM_START_BYTE)
#define | ENET_CPDMA_GET_CSUM_BYTE_COUNT(chkSumInfo) ENET_FEXT(chkSumInfo, ENET_CPDMA_CSUM_BYTE_COUNT)

## Enet CPDMA instance configuration
Configuration macros for Enet CPDMA module.
#define | ENET_CPDMA_CPSW_MAX_TX_CH (8U)
| Maximum number of CPSW TX DMA channels. More...
#define | ENET_CPDMA_CPSW_MAX_RX_CH (8U)
| Maximum number of CPSW RX DMA channels. More...

## Enet DMA driver opaque handles
Enet DMA configuration structure. Opaque handle typedefs for Enet DMA driver objects.
typedef void(* | EnetDma_PktNotifyCb) (void *cbArg)
| Function pointer type for packet notify call back. More...

## Macro Definition Documentation

## ◆ ENET_CPDMA_CPSW_MAX_TX_CH

#define ENET_CPDMA_CPSW_MAX_TX_CH (8U)

Maximum number of CPSW TX DMA channels.

## ◆ ENET_CPDMA_CPSW_MAX_RX_CH

#define ENET_CPDMA_CPSW_MAX_RX_CH (8U)

Maximum number of CPSW RX DMA channels.

## ◆ ENET_CPDMA_CPSW_MAX_SG_LIST

#define ENET_CPDMA_CPSW_MAX_SG_LIST (4U)

Maximum number of scatter gather segements supported in a packet

## ◆ ENET_CPDMA_CSUM_START_BYTE_SHIFT

#define ENET_CPDMA_CSUM_START_BYTE_SHIFT (16U)

Utilities to read the ChksumInfo fields

## ◆ ENET_CPDMA_CSUM_START_BYTE_MASK

#define ENET_CPDMA_CSUM_START_BYTE_MASK (((uint32_t) 0xFFU) << ENET_CPDMA_CSUM_START_BYTE_SHIFT)

## ◆ ENET_CPDMA_CSUM_RESULT_BYTE_SHIFT

#define ENET_CPDMA_CSUM_RESULT_BYTE_SHIFT (24U)

## ◆ ENET_CPDMA_CSUM_RESULT_BYTE_MASK

#define ENET_CPDMA_CSUM_RESULT_BYTE_MASK (((uint32_t) 0xFFU) << ENET_CPDMA_CSUM_RESULT_BYTE_SHIFT)

## ◆ ENET_CPDMA_CSUM_BYTE_COUNT_SHIFT

#define ENET_CPDMA_CSUM_BYTE_COUNT_SHIFT (0U)

## ◆ ENET_CPDMA_CSUM_BYTE_COUNT_MASK

#define ENET_CPDMA_CSUM_BYTE_COUNT_MASK (((uint32_t) 0x3FFU) << ENET_CPDMA_CSUM_BYTE_COUNT_SHIFT)

## ◆ ENET_CPDMA_GET_CSUM_RESULT_BYTE

#define ENET_CPDMA_GET_CSUM_RESULT_BYTE | ( |  | chkSumInfo | ) | ENET_FEXT(chkSumInfo, ENET_CPDMA_CSUM_RESULT_BYTE)

## ◆ ENET_CPDMA_GET_CSUM_START_BYTE

#define ENET_CPDMA_GET_CSUM_START_BYTE | ( |  | chkSumInfo | ) | ENET_FEXT(chkSumInfo, ENET_CPDMA_CSUM_START_BYTE)

## ◆ ENET_CPDMA_GET_CSUM_BYTE_COUNT

#define ENET_CPDMA_GET_CSUM_BYTE_COUNT | ( |  | chkSumInfo | ) | ENET_FEXT(chkSumInfo, ENET_CPDMA_CSUM_BYTE_COUNT)

## Typedef Documentation

## ◆ EnetDma_PktNotifyCb

typedef void(* EnetDma_PktNotifyCb) (void *cbArg)

Function pointer type for packet notify call back.

This is called by driver when packet is received on the RX channel or transmission completed from TX channel.

## ◆ EnetDma_PktQ

typedef EnetQ EnetDma_PktQ

Packet queue.

A queue of packets, which are used for managing the packets given to the DMA driver by an application. It can also be used by the translation or application layer to manage free packets pools.

## Function Documentation

## ◆ EnetCpdma_initRxChParams()

void EnetCpdma_initRxChParams | ( | EnetCpdma_OpenRxChPrms * | pRxChPrms | ) |

Initialize RX channel open parameters.

Initializes RX channel parameters with default values. Refer to SOC DMA specific RX channel config structure for specific config details.

Parameters

  pRxChPrms | RX channel configuration parameters.

## ◆ EnetCpdma_openRxCh()

EnetDma_RxChHandle EnetCpdma_openRxCh | ( | EnetDma_Handle | hDma,
|  | const EnetCpdma_OpenRxChPrms * | pRxChPrms
| ) |  |

Enet DMA open RX channel.

Opens the Enet DMA RX channel based on the channel parameters. This function configures the DMA channel. This also configures event if notifyCb is not null. Refer to SOC DMA specific RX channel config structure for specific config details.

Enet DMA is peripheral-aware as peripherals in a given SoC may need different handling, i.e. DMA descriptor's extra fields having different meaning for two peripherals using same DMA engine. This peripheral-awareness is given to the RX channel/flow via EnetDma_Handle passed at open time.

Parameters

  hDma | Enet DMA handle
  pRxChPrms | RX channel configuration parameters. This parameter can't be NULL.

Returns
  RX channel opaque handle if opened. Otherwise, NULL.

## ◆ EnetCpdma_closeRxCh()

int32_t EnetCpdma_closeRxCh | ( | EnetDma_RxChHandle | hRxCh,
|  | EnetDma_PktQ * | fq,
|  | EnetDma_PktQ * | cq
| ) |  |

Enet DMA close RX channel.

Closes the Enet DMA RX channel 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 EnetDma_retrieveRxPktQ() function call) and return those to app. App doesn't need to call function EnetDma_retrieveRxPktQ() explicitly to retrieve these packets.

Parameters

  hRxCh | [IN] Enet DMA channel handle. This parameter can't be NULL.
  fq | [OUT] Pointer to EnetDma_PktQ structure where packets from FQ (submitted for reception) are retrieved and returned to application. This parameter can't be NULL.
  cq | [OUT] Pointer to EnetDma_PktQ structure where packets from CQ (received packets) are retrieved and returned to application. This parameter can't be NULL.

Returns
  Enet_ErrorCodes

## ◆ EnetCpdma_initTxChParams()

void EnetCpdma_initTxChParams | ( | EnetCpdma_OpenTxChPrms * | pTxChPrms | ) |

Initialize TX channel open parameters.

Initializes TX channel open parameters with default values. Refer to SOC DMA specific RX channel config structure for specific config details.

Parameters

  pTxChPrms | TX channel configuration parameters.

## ◆ EnetCpdma_openTxCh()

EnetDma_TxChHandle EnetCpdma_openTxCh | ( | EnetDma_Handle | hDma,
|  | const EnetCpdma_OpenTxChPrms * | pTxChPrms
| ) |  |

Enet DMA open TX channel.

Opens the DMA TX DMA channel based on the channel parameters. This function open TX channel using chNum provided in EnetDma_OpenTxChPrms() and configures TX channel. This also configures event if notifyCb is not null. Refer to SOC DMA specific RX channel config structure for specific config details.

Enet DMA is peripheral-aware as peripherals in a given SoC may need different handling, i.e. DMA descriptor's extra fields having different meaning for two peripherals using same DMA engine. This peripheral-awareness is given to the TX channel via EnetDma_Handle passed at open time.

Parameters

  hDma | Enet DMA handle
  pTxChPrms | TX channel configuration parameters. This parameter can't be NULL.

Returns
  TX channel opaque handle if opened. Otherwise, NULL.

## ◆ EnetCpdma_closeTxCh()

int32_t EnetCpdma_closeTxCh | ( | EnetDma_TxChHandle | hTxCh,
|  | EnetDma_PktQ * | fq,
|  | EnetDma_PktQ * | cq
| ) |  |

Enet DMA close TX channel.

Closes the Enet 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 EnetDma_retrieveTxPktQ() explicitly to retrieve these packets.

Parameters

  hTxCh | [IN] Enet DMA TX Channel handle. This parameter can't be NULL.
  fq | [OUT] Pointer to EnetDma_PktQ structure where packets from FQ (TX ready - submitted for transmission) are retrieved and returned to application. This parameter can't be NULL.
  cq | [OUT] Pointer to EnetDma_PktQ structure where packets from CQ (TX free - transmitted packets) are retrieved and returned to application. This parameter can't be NULL.

Returns
  Enet_ErrorCodes

## ◆ EnetCpdma_open()

EnetDma_Handle EnetCpdma_open | ( | Enet_Type | enetType,
|  | uint32_t | instId,
|  | const EnetDma_Cfg * | dmaCfg,
|  | uint32_t | appCoreId
| ) |  |

Set default data path parameters.

Parameters

  enetType | [IN] Enet Peripheral type
  instId | [IN] Enet Peripheral instance id
  dmaCfg | [IN] DMA module (data path) configuration pointer.
  appCoreId | [IN] Application core Id

Return values

  Enet | DMA handle if opened. Otherwise, NULL.

## ◆ EnetCpdma_restoreCtxt()

EnetDma_Handle EnetCpdma_restoreCtxt | ( | Enet_Type | enetType,
|  | uint32_t | instId,
|  | uint32_t | appCoreId
| ) |  |

Open DMA with default data path parameters.

Parameters

  enetType | [IN] Enet Peripheral type
  instId | [IN] Enet Peripheral instance id
  appCoreId | [IN] Application core Id

Return values

  Enet | DMA handle if opened. Otherwise, NULL.

## ◆ EnetCpdma_close()

int32_t EnetCpdma_close | ( | EnetDma_Handle | hEnetDma | ) |

Close Enet DMA (data path).

Parameters

  hEnetDma | [IN] DMA handle

Returns
  Enet_ErrorCodes

## ◆ EnetCpdma_saveCtxt()

int32_t EnetCpdma_saveCtxt | ( | EnetDma_Handle | hEnetDma | ) |

Saves and closes Enet DMA (data path).

Parameters

  hEnetDma | [IN] DMA handle

Returns
  Enet_ErrorCodes

## ◆ EnetCpdma_rxThreshIsr()

int32_t EnetCpdma_rxThreshIsr | ( | EnetDma_Handle | hEnetDma | ) |

ENET CPDMA Rx Threshold interrupt service routine.

Processes Rx Threshold interrupt. This function retrieves the received packets from the linked CPPI descriptors and passes them to the receive queue when the number of received descriptors exceed the threshold

Requirement:

Parameters

  hEnetDma | [IN] Enet DMA Handle

Returns
  Enet_ErrorCodes

## ◆ EnetCpdma_rxIsr()

int32_t EnetCpdma_rxIsr | ( | EnetDma_Handle | hEnetDma | ) |

ENET CPDMA Rx interrupt service routine.

Processes Rx interrupt. This function retrieves the received packets from the linked CPPI descriptors and passes them to the receive queue when one or more packets has been received

Requirement:

Parameters

  hEnetDma | [IN] Enet DMA Handle

Returns
  Enet_ErrorCodes

## ◆ EnetCpdma_txIsr()

int32_t EnetCpdma_txIsr | ( | EnetDma_Handle | hEnetDma | ) |

ENET CPDMA Tx interrupt service routine.

Processes Tx interrupt. This function retrieves the completed Tx packets from the linked CPPI descriptors and passes them to the free queue when one or more packets have been transmitted.

Requirement:

Parameters

  hEnetDma | [IN] Enet DMA Handle

Returns
  Enet_ErrorCodes

## ◆ EnetCpdma_miscIsrGetStatus()

int32_t EnetCpdma_miscIsrGetStatus | ( | EnetDma_Handle | hEnetDma,
|  | uint32_t * | pStatusMask
| ) |  |

ENET CPDMA Miscellaneous interrupt service routine.

Processes Miscellaneous interrupt. This function extracts the intrrupt status bit masks from MMR and pass it to the caller to process all masked interrupts.

Requirement:

Parameters

  hEnetDma | [IN] Enet DMA Handle
  pStatusMask | [IN] pointer to the interrupt status bit mask

Returns
  Enet_ErrorCodes

## ◆ EnetCpdma_ackMiscIsr()

int32_t EnetCpdma_ackMiscIsr | ( | EnetDma_Handle | hEnetDma | ) |

EnetCpdma_ackMiscIsr
CPSW CPDMA Miscellaneous ISR ACK.

Parameters

  [in] | hEnetDma |

Return values

  ENET_SOK |

## ◆ EnetCpdma_initParams()

void EnetCpdma_initParams | ( | EnetDma_Cfg * | pDmaConfig | ) |

Initialize CPDMA config params.

Initialize CPDMA config params to default values

Requirement:

Parameters

  pDmaConfig | [IN] pointer to the config structure