Skip to content

Commit

Permalink
drivers: stm32_hal: Add option to enable HW checksum
Browse files Browse the repository at this point in the history
Provide a Kconfig option to enable HW RX and TX checksum, which
can increase throughput performances.

Signed-off-by: Erwan Gouriou <[email protected]>
  • Loading branch information
erwango authored and carlescufi committed Jan 11, 2023
1 parent c8014d1 commit 8eee0af
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions drivers/ethernet/Kconfig.stm32_hal
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ config ETH_STM32_AUTO_NEGOTIATION_ENABLE
help
Enable this if using autonegotiation

config ETH_STM32_HW_CHECKSUM
bool "Use TX and RX hardware checksum"
depends on !SOC_SERIES_STM32H7X
help
Enable receive and transmit checksum offload to enhance throughput
performances.
See reference manual for more information on this feature.

if !ETH_STM32_AUTO_NEGOTIATION_ENABLE

config ETH_STM32_SPEED_10M
Expand Down
8 changes: 8 additions & 0 deletions drivers/ethernet/eth_stm32_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1245,6 +1245,10 @@ static enum ethernet_hw_caps eth_stm32_hal_get_capabilities(const struct device
#endif
#if defined(CONFIG_NET_LLDP)
| ETHERNET_LLDP
#endif
#if defined(CONFIG_ETH_STM32_HW_CHECKSUM)
| ETHERNET_HW_RX_CHKSUM_OFFLOAD
| ETHERNET_HW_TX_CHKSUM_OFFLOAD
#endif
;
}
Expand Down Expand Up @@ -1364,7 +1368,11 @@ static struct eth_stm32_hal_dev_data eth0_data = {
#endif /* !CONFIG_ETH_STM32_AUTO_NEGOTIATION_ENABLE */
.PhyAddress = PHY_ADDR,
.RxMode = ETH_RXINTERRUPT_MODE,
#if defined(CONFIG_ETH_STM32_HW_CHECKSUM)
.ChecksumMode = ETH_CHECKSUM_BY_HARDWARE,
#else
.ChecksumMode = ETH_CHECKSUM_BY_SOFTWARE,
#endif
#endif /* !CONFIG_SOC_SERIES_STM32H7X */
#if defined(CONFIG_ETH_STM32_HAL_MII)
.MediaInterface = ETH_MEDIA_INTERFACE_MII,
Expand Down

0 comments on commit 8eee0af

Please sign in to comment.