zephyr/drivers/ethernet/eth_stm32_hal_priv.h
Jeremy LOCHE 8e46f099bf drivers: ethernet: stm32h7 IT based ethernet TX
Modify the ethernet driver to use TX complete interrupts.
Adds HAL ethernet TX complete callback and locking semaphore.

Due to changing behavior/content of the TX DMA descriptors
on STM32H7 series, based on the state of the IP,
it is more reliable to wait for the TX complete interrupt to check
for DMA end of transmission event. This avoids polling the
DMA_DESC_OWN bit in the descriptors.

Improves reliability and performance of the ethernet peripheral.

Tested on CoapServer sample, Dumb HTTP server, telnet sample.

Signed-off-by: Jeremy LOCHE <lochejeremy@gmail.com>
2020-09-03 21:48:53 +02:00

58 lines
1.6 KiB
C

/*
* Copyright (c) 2017 Erwin Rol <erwin@erwinrol.com>
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_DRIVERS_ETHERNET_ETH_STM32_HAL_PRIV_H_
#define ZEPHYR_DRIVERS_ETHERNET_ETH_STM32_HAL_PRIV_H_
#include <kernel.h>
#include <zephyr/types.h>
#define ST_OUI_B0 0x00
#define ST_OUI_B1 0x80
#define ST_OUI_B2 0xE1
#define ETH_STM32_HAL_MTU NET_ETH_MTU
#define ETH_STM32_HAL_FRAME_SIZE_MAX (ETH_STM32_HAL_MTU + 18)
/* Definition of the Ethernet driver buffers size and count */
#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
/* Device constant configuration parameters */
struct eth_stm32_hal_dev_cfg {
void (*config_func)(void);
struct stm32_pclken pclken;
struct stm32_pclken pclken_rx;
struct stm32_pclken pclken_tx;
#if !defined(CONFIG_SOC_SERIES_STM32H7X)
struct stm32_pclken pclken_ptp;
#endif /* !defined(CONFIG_SOC_SERIES_STM32H7X) */
};
/* Device run time data */
struct eth_stm32_hal_dev_data {
struct net_if *iface;
uint8_t mac_addr[6];
ETH_HandleTypeDef heth;
/* clock device */
const struct device *clock;
struct k_mutex tx_mutex;
struct k_sem rx_int_sem;
#ifdef CONFIG_SOC_SERIES_STM32H7X
struct k_sem tx_int_sem;
#endif /* CONFIG_SOC_SERIES_STM32H7X */
K_KERNEL_STACK_MEMBER(rx_thread_stack,
CONFIG_ETH_STM32_HAL_RX_THREAD_STACK_SIZE);
struct k_thread rx_thread;
bool link_up;
};
#define DEV_CFG(dev) \
((const struct eth_stm32_hal_dev_cfg *)(dev)->config)
#define DEV_DATA(dev) \
((struct eth_stm32_hal_dev_data *)(dev)->data)
#endif /* ZEPHYR_DRIVERS_ETHERNET_ETH_STM32_HAL_PRIV_H_ */