HAL ETH Use Cases

ETH Initialization


@startuml
hide footbox
!pragma teoz true

<style>
box {
  LineColor transparent
  LineThickness 5
  BackgroundColor #APPLICATION

  .system_boundary {
    LineColor #6b254b
    LineThickness 3
    LineStyle 5-5
    FontColor #6b254b
    BackgroundColor transparent
    BorderColor #6b254b
  }
}
</style>

skinparam sequencebox<<container_boundary>> {
    FontColor #d7a538
    BackgroundColor transparent
    BorderColor #d7a538
    BorderStyle dashed
}

title ETH Peripheral Initialization

!$APP_COLOR = " #fff4bf"
!$GLUE_COLOR = " #ceecf9"
!$POOL_COLOR = " #e9c0f5"
!$HW_COLOR = " #E6007E"

participant "Application" as Application  $APP_COLOR
box HAL System Peripheral Drivers #cfdbf3
participant "HAL Core" as STM32_HAL
participant "RCC HAL" as RCC_HAL
participant "GPIO HAL" as GPIO_HAL
end box

box Ethernet Network Interface #EEEFF1
participant "Tx Buffer Pool" as TX_POOL $POOL_COLOR
participant "Rx Buffer Pool" as RX_POOL $POOL_COLOR
participant "ETH Memory Pool" as ETH_MEM_POOL $POOL_COLOR
participant "Applicative glue" as APP_GLUE $GLUE_COLOR
control "Ethernet Process" as ETH_PROC $GLUE_COLOR
participant "Messages Queue" as WT_QUEUE $POOL_COLOR
end box
participant "Ethernet HAL" as ETH_HAL << Peripheral driver >>
control "Ethernet HW" as ETH_HW << Ethernet hardware >>
participant "External PHY driver" as PHY_DRV << Part driver >>

alt Main Initialization
  [-> Application++ $APP_COLOR: //User::AppInit()//\nMain Application Initialization.
end
' ===================================================================
== System Initialization ==
' ===================================================================
Application -> STM32_HAL++ $APP_COLOR: HAL Initialization <b>HAL_Init</b>()
  note right of STM32_HAL #Yellow
    Initialize System Time Base
  end note
return success or failure

Application -> RCC_HAL++ $APP_COLOR: System and Peripherals Clock Configurations
  note right of RCC_HAL #Yellow
    Configure System and Peripherals Clocks
  end note
return success or failure

Application -> PHY_DRV++ $APP_COLOR: Initialize PHY <b>lan8742_init</b>()
return success or failure

' ===================================================================
== ETH Peripheral Instance (<b>eth_instance</b>) Initialization ==
' ===================================================================
alt "Ethernet Clocks Enabling If USE_ETH_CLK_ENABLE_MODEL = HAL_CLK_ENABLE_NO"
  note right of Application #Yellow
    if <b>USE_ETH_CLK_ENABLE_MODEL</b> > HAL_CLK_ENABLE_NO
    - Enable ETH Clocks
    - Enable ETH GPIOs Clocks
  end note
  Application -> RCC_HAL++ $APP_COLOR : <b>HAL_RCC_ETH1_EnableClock</b>()
  return success or failure
  Application -> RCC_HAL++ $APP_COLOR : <b>HAL_RCC_ETH1TX_EnableClock</b>()
  return success or failure
  Application -> RCC_HAL++ $APP_COLOR : <b>HAL_RCC_ETH1RX_EnableClock</b>()
  return success or failure
  Application -> RCC_HAL++ $APP_COLOR : <b>HAL_RCC_ETH1CK_EnableClock</b>()
  return success or failure
end

Application -> RCC_HAL++ $APP_COLOR: Enable ETH GPIO clocks: <b>HAL_RCC_GPIO<x>_EnableClock</b>()
return success or failure
Application -> GPIO_HAL++ $APP_COLOR: Initialize ETH GPIO Pins: <b>HAL_GPIO_Init</b>()
return success or failure

Application -> ETH_HAL++ $APP_COLOR: Initialize the HAL ETH: <b>HAL_ETH_Init</b>(<b>eth_instance</b>)
return success or failure

Application -> APP_GLUE++ $APP_COLOR: Initialize the Ethernet Network Interface : <b>EthInit</b>(<b>p_eth_handler</b>)
APP_GLUE -> ETH_MEM_POOL++ $APP_COLOR: Driver Memory Pool Initialization <b>MemPoolInit</b>()
return success or failure
APP_GLUE -> TX_POOL++ $APP_COLOR: Tx Memory Pool Initialization <b>TxPoolInit</b>()
return success or failure
APP_GLUE -> RX_POOL++ $APP_COLOR: Rx Memory Pool Initialization <b>RxPoolInit</b>()
return success or failure

APP_GLUE -> ETH_HAL++ $APP_COLOR: Register Data callback : <b>HAL_ETH_RegisterDataCallback(\n p_eth_handler, data_callback)</b>
return success or failure
return success or failure
@enduml

Called functions:

ETH De-initialization


@startuml
hide footbox
!pragma teoz true

<style>
box {
  LineColor transparent
  LineThickness 5
  BackgroundColor #APPLICATION

  .system_boundary {
    LineColor #6b254b
    LineThickness 3
    LineStyle 5-5
    FontColor #6b254b
    BackgroundColor transparent
    BorderColor #6b254b
  }
}
</style>

skinparam sequencebox<<container_boundary>> {
    FontColor #d7a538
    BackgroundColor transparent
    BorderColor #d7a538
    BorderStyle dashed
}

title ETH Peripheral De-Initialization

!$APP_COLOR = " #fff4bf"
!$GLUE_COLOR = " #ceecf9"
!$POOL_COLOR = " #e9c0f5"
!$HW_COLOR = " #E6007E"

participant "Application" as Application  $APP_COLOR
box HAL System Peripheral Drivers #cfdbf3
participant "HAL Core" as STM32_HAL
participant "RCC HAL" as RCC_HAL
participant "GPIO HAL" as GPIO_HAL
end box

box Ethernet Network Interface #EEEFF1
participant "Tx Buffer Pool" as TX_POOL $POOL_COLOR
participant "Rx Buffer Pool" as RX_POOL $POOL_COLOR
participant "ETH Memory Pool" as ETH_MEM_POOL $POOL_COLOR
participant "Applicative glue" as APP_GLUE $GLUE_COLOR
control "Ethernet Process" as ETH_PROC $GLUE_COLOR
participant "Messages Queue" as WT_QUEUE $POOL_COLOR
end box
participant "Ethernet HAL" as ETH_HAL << Peripheral driver >>
control "Ethernet HW" as ETH_HW << Ethernet hardware >>
participant "External PHY driver" as PHY_DRV << Part driver >>

alt Main De-Initialization
  [-> Application++ $APP_COLOR: //User::AppDeInit()//\nMain Application De-Initialization.
end
' ===================================================================
== ETH Network Interface De-Initialization ==
' ===================================================================
Application -> APP_GLUE++ $APP_COLOR: De-initialize the Ethernet Network Interface: <b>EthDeInit</b>(<b>p_eth_handler</b>)
note right of APP_GLUE #Yellow
  All Used ETH Channels should be stopped
end note
APP_GLUE -> ETH_MEM_POOL++ $APP_COLOR: Driver Memory Pool De-Initialization: <b>MemPoolDeInit</b>()
return success or failure
APP_GLUE -> TX_POOL++ $APP_COLOR: Tx Memory Pool De-Initialization: <b>TxPoolDeInit</b>()
return success or failure
APP_GLUE -> RX_POOL++ $APP_COLOR: Rx Memory Pool De-Initialization: <b>RxPoolDeInit</b>()
return success or failure
return success or failure

' ===================================================================
== ETH Peripheral Instance (<b>eth_instance</b>) De-Initialization ==
' ===================================================================
Application -> ETH_HAL++ $APP_COLOR: De-initialize the HAL ETH: <b>HAL_ETH_DeInit</b>(<b>eth_instance</b>)
return success or failure
alt "Ethernet Clocks Disabling If USE_ETH_CLK_ENABLE_MODEL = HAL_CLK_ENABLE_NO"
  note right of Application #Yellow
    if <b>USE_ETH_CLK_ENABLE_MODEL</b> > HAL_CLK_ENABLE_NO
    - Disable ETH Clocks
    - Disable ETH GPIOs Clocks
  end note
  Application -> RCC_HAL++ $APP_COLOR : <b>HAL_RCC_ETH1_DisableClock</b>()
  return success or failure
  Application -> RCC_HAL++ $APP_COLOR : <b>HAL_RCC_ETH1TX_DisableClock</b>()
  return success or failure
  Application -> RCC_HAL++ $APP_COLOR : <b>HAL_RCC_ETH1RX_DisableClock</b>()
  return success or failure
  Application -> RCC_HAL++ $APP_COLOR : <b>HAL_RCC_ETH1CK_DisableClock</b>()
  return success or failure
end

Application -> GPIO_HAL++ $APP_COLOR: De-initialize ETH GPIO Pins: <b>HAL_GPIO_DeInit</b>()
return success or failure
Application -> RCC_HAL++ $APP_COLOR: Disable ETH GPIO clocks: <b>HAL_RCC_GPIO<x>_DisableClock</b>()
return success or failure

' ===================================================================
== System De-Initialization ==
' ===================================================================

Application -> PHY_DRV++ $APP_COLOR: De-initialize PHY <b>lan8742_deinit</b>()
return success or failure

Application -> RCC_HAL++ $APP_COLOR: System and Peripherals Clock Reset
  note right of RCC_HAL #Yellow
    Reset System and Peripherals Clocks
  end note
return success or failure

Application -> STM32_HAL++ $APP_COLOR: HAL De-Initialization <b>HAL_DeInit</b>()
  note right of STM32_HAL #Yellow
    De-Initialize System Time Base
  end note
return success or failure
@enduml

Called functions:

ETH Peripheral Configuration



@startuml
hide footbox
!pragma teoz true

<style>
box {
  LineColor transparent
  LineThickness 5
  BackgroundColor #APPLICATION

  .system_boundary {
    LineColor #6b254b
    LineThickness 3
    LineStyle 5-5
    FontColor #6b254b
    BackgroundColor transparent
    BorderColor #6b254b
  }
}
</style>

skinparam sequencebox<<container_boundary>> {
    FontColor #d7a538
    BackgroundColor transparent
    BorderColor #d7a538
    BorderStyle dashed
}

title Ethernet Peripheral Configuration

!$APP_COLOR = " #fff4bf"
!$GLUE_COLOR = " #ceecf9"
!$POOL_COLOR = " #e9c0f5"
!$HW_COLOR = " #E6007E"

participant "Application" as Application  $APP_COLOR
box Ethernet Network Interface #EEEFF1
participant "Tx Buffer Pool" as TX_POOL $POOL_COLOR
participant "Rx Buffer Pool" as RX_POOL $POOL_COLOR
participant "ETH Memory Pool" as ETH_MEM_POOL $POOL_COLOR
participant "Applicative glue" as APP_GLUE $GLUE_COLOR
control "Ethernet Process" as ETH_PROC $GLUE_COLOR
participant "Messages Queue" as WT_QUEUE $POOL_COLOR
end box
participant "Ethernet HAL" as ETH_HAL << Peripheral driver >>
control "Ethernet HW" as ETH_HW << Ethernet hardware >>

alt Request for Frame Transmission
  [-> Application++ $APP_COLOR: //User::SetEthConfig(<b>mac_addr</b>, <b>media_interface</b>)//\nConfigure the Ethernet peripheral.
end
' ===================================================================
== Basic Ethernet Peripheral Configuration ==
' ===================================================================
note over Application
Setup ETH Peripheral Configuration
  - eth_config.mac_addr = <b>mac_addr</b>
  - eth_config.media_interface = <b>media_interface</b>
end note
Application -> ETH_HAL++ $APP_COLOR : <b>HAL_ETH_SetConfig</b>(p_eth_handler, &eth_config)
ETH_HAL -> ETH_HW++ $APP_COLOR: <b>Write Global Configuration</b>\n <b>to hardware</b>
return
return success or failure

' ===================================================================
== Advanced Ethernet Peripheral Configuration ==
' ===================================================================
group Advenced : ETH MAC Configuration
note over Application
Get current ETH MAC Configuration (Default)
end note
Application -> ETH_HAL++ $APP_COLOR : <b>HAL_ETH_MAC_GetConfig</b>(p_eth_handler, &eth_mac_config)
ETH_HAL -> ETH_HW++ $APP_COLOR: <b>Read MAC Configuration</b>\n <b>from hardware</b>
return
return success or failure

note over Application
Setup ETH MAC Configuration
  - Update eth_mac_config fields i.e :
    - eth_mac_config.link_config.speed = <b>HAL_ETH_MAC_SPEED_100M</b>
    - eth_mac_config.loopback_mode = <b>HAL_ETH_MAC_LOOPBACK_ENABLE</b>
end note
Application -> ETH_HAL++ $APP_COLOR : <b>HAL_ETH_MAC_SetConfig</b>(p_eth_handler, &eth_mac_config)
ETH_HAL -> ETH_HW++ $APP_COLOR: <b>Write ETH MAC Configuration</b>\n <b>to hardware</b>
return
return success or failure
end group

group Advenced : ETH MTL Configuration
note over Application
Get current ETH MTL Configuration (Default)
end note
Application -> ETH_HAL++ $APP_COLOR : <b>HAL_ETH_MTL_GetConfig</b>(p_eth_handler, &eth_mtl_config)
ETH_HAL -> ETH_HW++ $APP_COLOR: <b>Read MTL Configuration</b>\n <b>from hardware</b>
return
return success or failure

note over Application
Setup ETH MTL Configuration
  - Update eth_mtl_config fields i.e :
    - eth_mtl_config.tx_fwd_status = <b>HAL_ETH_MTL_TX_FWD_STATUS_DISABLE</b>
end note
Application -> ETH_HAL++ $APP_COLOR : <b>HAL_ETH_MTL_SetConfig</b>(p_eth_handler, &eth_mtl_config)
ETH_HAL -> ETH_HW++ $APP_COLOR: <b>Write ETH MTL Configuration</b>\n <b>to hardware</b>
return
return success or failure
end group

group Advenced : ETH DMA Configuration
note over Application
Get current ETH DMA Configuration (Default)
end note
Application -> ETH_HAL++ $APP_COLOR : <b>HAL_ETH_DMA_GetConfig</b>(p_eth_handler, &eth_dma_config)
ETH_HAL -> ETH_HW++ $APP_COLOR: <b>Read DMA Configuration</b>\n <b>from hardware</b>
return
return success or failure

note over Application
Setup ETH DMA Configuration
  - Update eth_dma_config fields i.e :
    - eth_dma_config.burst_mode = <b>HAL_ETH_DMA_BURST_LEN_FIXED</b>
    - eth_dma_config.tr_priority = <b>HAL_ETH_DMA_TR_PRIO_ENABLE</b>
end note
Application -> ETH_HAL++ $APP_COLOR : <b>HAL_ETH_DMA_SetConfig</b>(p_eth_handler, &eth_mtl_config)
ETH_HAL -> ETH_HW++ $APP_COLOR: <b>Write ETH DMA Configuration</b>\n <b>to hardware</b>
return
return success or failure
end group

@enduml

Called functions:

ETH Tx Channel Configuration


@startuml
hide footbox
!pragma teoz true

<style>
box {
  LineColor transparent
  LineThickness 5
  BackgroundColor #APPLICATION

  .system_boundary {
    LineColor #6b254b
    LineThickness 3
    LineStyle 5-5
    FontColor #6b254b
    BackgroundColor transparent
    BorderColor #6b254b
  }
}
</style>

skinparam sequencebox<<container_boundary>> {
    FontColor #d7a538
    BackgroundColor transparent
    BorderColor #d7a538
    BorderStyle dashed
}

title ETH Tx Channel Configuration

!$APP_COLOR = " #fff4bf"
!$GLUE_COLOR = " #ceecf9"
!$POOL_COLOR = " #e9c0f5"
!$HW_COLOR = " #E6007E"

participant "Application" as Application  $APP_COLOR
box Ethernet Network Interface #EEEFF1
participant "Tx Buffer Pool" as TX_POOL $POOL_COLOR
participant "Rx Buffer Pool" as RX_POOL $POOL_COLOR
participant "ETH Memory Pool" as ETH_MEM_POOL $POOL_COLOR
participant "Applicative glue" as APP_GLUE $GLUE_COLOR
control "Ethernet Process" as ETH_PROC $GLUE_COLOR
participant "Messages Queue" as WT_QUEUE $POOL_COLOR
end box
participant "Ethernet HAL" as ETH_HAL << Peripheral driver >>
control "Ethernet HW" as ETH_HW << Ethernet hardware >>

alt Tx Channel Configuration
  [-> Application++ $APP_COLOR: //User::ConfigTxChannel(<b>channel_id</b>, <b>app_buff_nb</b>, <b>fifo_mode</b>)//\nConfigure the specified Tx Channel <b>channel_id</b>.
end
' ===================================================================
== Tx Channel Configuration ==
' ===================================================================
Application -> APP_GLUE++ $APP_COLOR: Tx Channel <b>channel_id</b> Configuration\n with <b>app_buff_nb</b> buffers

APP_GLUE -> TX_POOL++ $APP_COLOR: Request memory from Tx Pool (buffer)
return success or failure

alt "Data Callbacks Registration"
  note right of APP_GLUE #Yellow
    if <b>fifo_mode</b> != HAL_ETH_FIFO_EVENT_NONE
    - Register Data Event Callback
  end note
  APP_GLUE -> ETH_HAL++ $APP_COLOR : <b>HAL_ETH_RegisterDataCallback</b>(p_eth_handler,\n data_callback)
  return
end

note over APP_GLUE
Get current Tx Channel Configuration (Default)
end note
APP_GLUE -> ETH_HAL++ $APP_COLOR : <b>HAL_ETH_GetConfigTxChannel</b>(p_eth_handler,\n <b>channel_id</b>,\n &tx_channel_config)
ETH_HAL -> ETH_HW++ $APP_COLOR: <b>Read Channel Configuration</b>\n <b>from hardware</b>
return
return success or failure

note over APP_GLUE
Update Tx Channel Configuration
  - tx_channel_config.max_app_buffers_num = <b>app_buff_nb</b>
  - tx_channel_config.fifo_event_config.event_mode = <b>fifo_mode</b>
end note
APP_GLUE -> ETH_HAL++ $APP_COLOR : <b>HAL_ETH_SetConfigTxChannel</b>(p_eth_handler,\n <b>channel_id</b>,\n &tx_channel_config)
ETH_HAL -> ETH_HW++ $APP_COLOR: <b>Write Channel Configuration</b>\n <b>to hardware</b>
return
return success or failure
APP_GLUE -> ETH_HAL++ $APP_COLOR : <b>HAL_ETH_RegisterChannelTxCptCallback</b>(\n p_eth_handler, <b>channel_id</b>, tx_complete_callback)
return success or failure
return
return

@enduml

Called functions:

ETH Rx Channel Configuration


@startuml
hide footbox
!pragma teoz true

<style>
box {
  LineColor transparent
  LineThickness 5
  BackgroundColor #APPLICATION

  .system_boundary {
    LineColor #6b254b
    LineThickness 3
    LineStyle 5-5
    FontColor #6b254b
    BackgroundColor transparent
    BorderColor #6b254b
  }
}
</style>

skinparam sequencebox<<container_boundary>> {
    FontColor #d7a538
    BackgroundColor transparent
    BorderColor #d7a538
    BorderStyle dashed
}

title ETH Rx Channel Configuration

!$APP_COLOR = " #fff4bf"
!$GLUE_COLOR = " #ceecf9"
!$POOL_COLOR = " #e9c0f5"
!$HW_COLOR = " #E6007E"

participant "Application" as Application  $APP_COLOR
box Ethernet Network Interface #EEEFF1
participant "Tx Buffer Pool" as TX_POOL $POOL_COLOR
participant "Rx Buffer Pool" as RX_POOL $POOL_COLOR
participant "ETH Memory Pool" as ETH_MEM_POOL $POOL_COLOR
participant "Applicative glue" as APP_GLUE $GLUE_COLOR
control "Ethernet Process" as ETH_PROC $GLUE_COLOR
participant "Messages Queue" as WT_QUEUE $POOL_COLOR
end box
participant "Ethernet HAL" as ETH_HAL << Peripheral driver >>
control "Ethernet HW" as ETH_HW << Ethernet hardware >>

alt Rx Channel Configuration
  [-> Application++ $APP_COLOR: //User::ConfigRxChannel(<b>channel_id</b>, <b>app_buff_nb</b>, <b>fifo_mode</b>)//\nConfigure the specified Tx Channel <b>channel_id</b>.
end
' ===================================================================
== Rx Channel Configuration ==
' ===================================================================
Application -> APP_GLUE++ $APP_COLOR: Rx Channel <b>channel_id</b> Configuration\n with <b>app_buff_nb</b> buffers

APP_GLUE -> RX_POOL++ $APP_COLOR: Request memory from Rx Pool (buffer)
return success or failure

alt "Data Callbacks Registration"
  note right of APP_GLUE #Yellow
    if <b>fifo_mode</b> != HAL_ETH_FIFO_EVENT_NONE
    - Register Data Event Callback
  end note
  APP_GLUE -> ETH_HAL++ $APP_COLOR : <b>HAL_ETH_RegisterDataCallback</b>(p_eth_handler,\n data_callback)
  return success or failure
end

note over APP_GLUE
Get current Rx Channel Configuration (Default)
end note
APP_GLUE -> ETH_HAL++ $APP_COLOR : <b>HAL_ETH_GetConfigRxChannel</b>(p_eth_handler,\n <b>channel_id</b>,\n &rx_channel_config)
ETH_HAL -> ETH_HW++ $APP_COLOR: <b>Read Channel Configuration</b>\n <b>from hardware</b>
return
return success or failure

note over APP_GLUE
Update Rx Channel Configuration
  - rx_channel_config.max_app_buffers_num = <b>app_buff_nb</b>
  - rx_channel_config.fifo_event_config.event_mode = <b>fifo_mode</b>
end note
APP_GLUE -> ETH_HAL++ $APP_COLOR : <b>HAL_ETH_SetConfigRxChannel</b>(p_eth_handler,\n <b>channel_id</b>,\n &rx_channel_config)
ETH_HAL -> ETH_HW++ $APP_COLOR: <b>Write Channel Configuration</b>\n <b>to hardware</b>
return
return success or failure
APP_GLUE -> ETH_HAL++ $APP_COLOR : <b>HAL_ETH_RegisterChannelRxCptCallback</b>(\n p_eth_handler, <b>channel_id</b>, rx_complete_callback)
return success or failure
APP_GLUE -> ETH_HAL++ $APP_COLOR : <b>HAL_ETH_RegisterChannelRxAllocateCallback</b>(\n p_eth_handler, <b>channel_id</b>, rx_allocate_callback)
return success or failure
return
return

@enduml

Called functions:

ETH Start Rx/Tx Channel(s)


@startuml
hide footbox
!pragma teoz true

<style>
box {
  LineColor transparent
  LineThickness 5
  BackgroundColor #APPLICATION

  .system_boundary {
    LineColor #6b254b
    LineThickness 3
    LineStyle 5-5
    FontColor #6b254b
    BackgroundColor transparent
    BorderColor #6b254b
  }
}
</style>

skinparam sequencebox<<container_boundary>> {
    FontColor #d7a538
    BackgroundColor transparent
    BorderColor #d7a538
    BorderStyle dashed
}

title Start ETH Channel

!$APP_COLOR = " #fff4bf"
!$GLUE_COLOR = " #ceecf9"
!$POOL_COLOR = " #e9c0f5"
!$HW_COLOR = " #E6007E"

participant "Application" as Application  $APP_COLOR
box Ethernet Network Interface #EEEFF1
participant "Tx Buffer Pool" as TX_POOL $POOL_COLOR
participant "Rx Buffer Pool" as RX_POOL $POOL_COLOR
participant "ETH Memory Pool" as ETH_MEM_POOL $POOL_COLOR
participant "Applicative glue" as APP_GLUE $GLUE_COLOR
control "Ethernet Process" as ETH_PROC $GLUE_COLOR
participant "Messages Queue" as WT_QUEUE $POOL_COLOR
end box
participant "Ethernet HAL" as ETH_HAL << Peripheral driver >>
control "Ethernet HW" as ETH_HW << Ethernet hardware >>

alt Start ETH Channel
  [-> Application++ $APP_COLOR: //User::StartChannel(<b>channel_id</b>)//\nStart the specified Channel <b>channel_id</b>.
end

Application -> APP_GLUE++ $APP_COLOR: Start ETH Channel <b>channel_id</b>
' ===================================================================
== ETH driver Memory Allocation ==
' ===================================================================
alt "Static ETH driver Memory Allocation"
  note right of APP_GLUE #Yellow
    Use a static memory eth_ch_drv_mem[ETH_MEM_SIZE_BYTE] Array:
    - Memory address should be aligned to <b>ETH_BUS_DATA_WIDTH_BYTE</b>
    - Memory Size is calculated as below :
      - Size of 1 descriptor <b><color:red>x 2</color></b> x Number of Application Buffers
    - The Minimum size of 1 descriptor is <b><color:red>24 bytes</color></b>
    - The Minimum number of Application Buffers is <b><color:red>2</color></b>
  end note
else "Dynamic ETH driver Memory Allocation"
  note right of APP_GLUE #Yellow
    Allocate memory :
    - Get HAL ETH Driver Memory Needs (address alignment and size)
    - Allocate Aligned memory
  end note
  APP_GLUE -> ETH_HAL++ $APP_COLOR: Get ETH Memory Allocation Needs:\n<b>HAL_ETH_GetChannelAllocNeeds</b>(\n p_eth_handler, <b>channel_id</b>, p_ch_alloc_req)
  return p_ch_alloc_req (mem_size_byte & mem_addr_align_byte)
  APP_GLUE -> ETH_MEM_POOL++ $APP_COLOR: <b>EthAllocMem</b>(\nmem_size, addr_align, eth_ch_drv_mem)
  note right of ETH_MEM_POOL #Yellow
    Allocate Memory eth_ch_drv_mem[]:
    - Memory address should be aligned to <b>addr_align</b>
    - Memory Size is given through <b>mem_size</b> argument.
  end note
  return success or failure
end

' ===================================================================
== Start ETH Channel ==
' ===================================================================
APP_GLUE -> ETH_HAL++ $APP_COLOR : <b>HAL_ETH_StartChannel</b>(\n p_eth_handler, <b>channel_id</b>, eth_ch_drv_mem,\n ETH_MEM_SIZE_SIZE_BYTE)
return success or failure
return

@enduml

Called functions:

ETH Stop Rx/Tx Channel(s)


@startuml
hide footbox
!pragma teoz true

<style>
box {
  LineColor transparent
  LineThickness 5
  BackgroundColor #APPLICATION

  .system_boundary {
    LineColor #6b254b
    LineThickness 3
    LineStyle 5-5
    FontColor #6b254b
    BackgroundColor transparent
    BorderColor #6b254b
  }
}
</style>

skinparam sequencebox<<container_boundary>> {
    FontColor #d7a538
    BackgroundColor transparent
    BorderColor #d7a538
    BorderStyle dashed
}

title Stop ETH Channel

!$APP_COLOR = " #fff4bf"
!$GLUE_COLOR = " #ceecf9"
!$POOL_COLOR = " #e9c0f5"
!$HW_COLOR = " #E6007E"

participant "Application" as Application  $APP_COLOR
box Ethernet Network Interface #EEEFF1
participant "Tx Buffer Pool" as TX_POOL $POOL_COLOR
participant "Rx Buffer Pool" as RX_POOL $POOL_COLOR
participant "ETH Memory Pool" as ETH_MEM_POOL $POOL_COLOR
participant "Applicative glue" as APP_GLUE $GLUE_COLOR
control "Ethernet Process" as ETH_PROC $GLUE_COLOR
participant "Messages Queue" as WT_QUEUE $POOL_COLOR
end box
participant "Ethernet HAL" as ETH_HAL << Peripheral driver >>
control "Ethernet HW" as ETH_HW << Ethernet hardware >>

alt Stop ETH Channel
  [-> Application++ $APP_COLOR: //User::StopChannel(<b>channel_id</b>)//\nStop the specified Channel <b>channel_id</b>.
end

Application -> APP_GLUE++ $APP_COLOR: Stop ETH Channel <b>channel_id</b>
' ===================================================================
== Stop ETH Channel ==
' ===================================================================
APP_GLUE -> ETH_HAL++ $APP_COLOR: <b>HAL_ETH_StopChannel</b>(\n p_eth_handler, <b>channel_id</b>)
ETH_HAL -> ETH_HW++ $APP_COLOR: Request HW to Stop the selected Channel: <b>ETH_StopChannel</b>()
  note right of ETH_HAL #Yellow
    Wait until the Stop is completed or Timeout is reached
  end note
return success or timeout

  loop For each descriptor with completed reception
    alt "Rx Channel"
      ETH_HAL -> APP_GLUE $APP_COLOR: **p_rx_complete_cb**(channel, buffer, size, <metadata>)
      APP_GLUE ->> RX_POOL++ $APP_COLOR: Put received buffer in Rx FIFO
      note over RX_POOL
      The buffer remains referenced
      until the payload is consumed
      by the user application.
      end note
      return
    else "Tx Channel"
      ETH_HAL -> APP_GLUE $APP_COLOR: **p_tx_complete_cb**(channel, buffer, size, <metadata>)
      APP_GLUE ->> TX_POOL++ $APP_COLOR: Put transmitted buffer in Tx FIFO
      note over TX_POOL
      The buffer remains referenced
      until the payload is consumed
      by the user application.
      end note
      return
    end
  end   
    APP_GLUE --> ETH_HAL
return success or failure

' ===================================================================
== Release all Rx/Tx Application Buffers ==
' ===================================================================
APP_GLUE -> Application $APP_COLOR: Release all Rx/Tx Application Buffers for Channel <b>channel_id</b>
Application -> Application: Process released buffers
Application --> APP_GLUE: return success or failure

' ===================================================================
== ETH driver Memory De-allocation ==
' ===================================================================
alt "Static ETH driver Memory De-allocation"
  note right of APP_GLUE #Yellow
    Clear eth_ch_drv_mem[ETH_MEM_SIZE_BYTE] Array.
  end note
else "Dynamic ETH driver Memory De-allocation"
  note right of APP_GLUE #Yellow
    De-allocate memory.
  end note
  return success or failure
end

@enduml

Called functions:

ETH Rx/Tx Processing


@startuml
hide footbox
!pragma teoz true

<style>
box {
  LineColor transparent
  LineThickness 5
  BackgroundColor #APPLICATION

  .system_boundary {
    LineColor #6b254b
    LineThickness 3
    LineStyle 5-5
    FontColor #6b254b
    BackgroundColor transparent
    BorderColor #6b254b
  }
}
</style>

skinparam sequencebox<<container_boundary>> {
    FontColor #d7a538
    BackgroundColor transparent
    BorderColor #d7a538
    BorderStyle dashed
}

title Ethernet Rx/Tx Processing

!$APP_COLOR = " #fff4bf"
!$GLUE_COLOR = " #ceecf9"
!$POOL_COLOR = " #e9c0f5"
!$HW_COLOR = " #E6007E"

participant "Application" as Application  $APP_COLOR
box Ethernet Network Interface #EEEFF1
participant "Tx Buffer Pool" as TX_POOL $POOL_COLOR
participant "Rx Buffer Pool" as RX_POOL $POOL_COLOR
participant "ETH Memory Pool" as ETH_MEM_POOL $POOL_COLOR
participant "Applicative glue" as APP_GLUE $GLUE_COLOR
control "Ethernet Process" as ETH_PROC $GLUE_COLOR
participant "Messages Queue" as WT_QUEUE $POOL_COLOR
end box
participant "Ethernet HAL" as ETH_HAL << Peripheral driver >>
control "Ethernet HW" as ETH_HW << Ethernet hardware >>

alt Request for Frame Transmission
  [-> Application++ $APP_COLOR: //User::SendFrame(<b>channel_id</b>)//\nTransmit a frame on the specified\n<b>channel_id</b>
end
' ===================================================================
== Frame Transmission ==
' ===================================================================
Application -> Application: Frame processing
Application -> APP_GLUE++ $APP_COLOR: Request for Frame Transmission
APP_GLUE -> TX_POOL++ $APP_COLOR: Request memory from Tx Pool (buffer)
return
APP_GLUE -> APP_GLUE: Transmit Request configuration
APP_GLUE -> ETH_HAL++ $APP_COLOR: **HAL_ETH_RequestTx**(<b>channel_id</b>)
ETH_HAL -> ETH_HW++ $APP_COLOR: <b>Submit Request</b>\n <b>to hardware</b>
return
return
return
deactivate Application

alt
  [-> Application++ $APP_COLOR: //MainApp::ReceiveFrame(<b>channel_id</b>)//\nReceive an incoming frame on the\nspecified <b>channel_id</b> 
end
' ===================================================================
== Frame Reception ==
' ===================================================================
Application -> APP_GLUE++ $APP_COLOR: Get a Received Frame
APP_GLUE -> RX_POOL++ $APP_COLOR: Get a Frame from Rx FIFO
return
return
Application -> Application $APP_COLOR: Frame processing
Application -> APP_GLUE++ $APP_COLOR: Release to pool (buffer)
APP_GLUE -> RX_POOL++ $APP_COLOR: Release Frame in Rx FIFO
return
return
deactivate Application

' ===================================================================
== Hardware Event(s) ==
' ===================================================================
ETH_HW ->> ETH_HAL++ $HW_COLOR: **HAL_ETH_IRQHandler**()
ETH_HAL -> ETH_HAL: Clear IT
ETH_HAL -> APP_GLUE++ $HW_COLOR: **p_data_cb**(set of channels with pending SW operations)
APP_GLUE ->> WT_QUEUE++ $HW_COLOR: queue message (data event id + channel(s) mask)
return

APP_GLUE --> ETH_HAL
deactivate ETH_HAL
deactivate APP_GLUE

alt Worker Thread
  [-> ETH_PROC++ $GLUE_COLOR: //OS::Scheduler()//\nWorker Thread scheduled for execution
end
' ===================================================================
== Rx/Tx Frame(s) Processing ==
' ===================================================================
ETH_PROC -> WT_QUEUE++ $GLUE_COLOR: dequeue messages (data event id + channel(s) mask)
return
ETH_PROC -> ETH_HAL++ $GLUE_COLOR: **HAL_ETH_ExecDataHandler**(in: set of channels selected by appli for processing,\n out: set of channels with pending SW operations)

loop For each TX channel in the set (decreasing priority order)
  loop For each descriptor with completed transmission
  ETH_HAL -> APP_GLUE++ $GLUE_COLOR: **p_tx_complete_cb**(channel, buffer, <metadata>)
  APP_GLUE -> TX_POOL++ $GLUE_COLOR: Release to pool (buffer)
  return
  return
  end
end

loop For each RX channel in the set (decreasing priority order)
  loop For each descriptor with completed reception
    ETH_HAL -> APP_GLUE++ $GLUE_COLOR: **p_rx_complete_cb**(channel, buffer, size, <metadata>)
    APP_GLUE ->> RX_POOL++ $GLUE_COLOR: Put received buffer in Rx FIFO
    note over RX_POOL
    The buffer remains referenced
    until the payload is consumed
    by the user application.
    end note
    return
    APP_GLUE --> ETH_HAL
    deactivate APP_GLUE

alt New Frame Received (Optional)
  [<- APP_GLUE++ $GLUE_COLOR: //OS::Notify()//\nNotify Application about the reception\nof a new Frame
  return
  deactivate APP_GLUE
end

    ETH_HAL -> APP_GLUE++ $GLUE_COLOR: **p_rx_allocate_cb**(channel, buffer, size)
    APP_GLUE -> RX_POOL++ $GLUE_COLOR: Get new buffer from RX FIFO
    note over RX_POOL
    The memory allocation is done
    by the application. If no more
    memory the rx_allocate_cp should
    return error to the callee.
    end note
    return
    return
    return
    deactivate ETH_HAL
    deactivate ETH_PROC
  end
end

@enduml

Called functions: