Skip to content

Commit

Permalink
Full rework of Ethernet HAL driver
Browse files Browse the repository at this point in the history
The reworked Ethernet HAL driver brings multiple changes and a compatibility break vs. previous Ethernet HAL driver.
Main changes are listed here:

* Add support for PTP and ARP
* Rework packets reception and buffers allocation for better integration and performance
* Rework packets transmission and buffers allocation (using interrupts instead of polling and prevent packets lock during transmission)
* Enhance DMA management
* Decouple Ethernet HAL driver from PHY driver
* Enhance maximum throughput in RX (94Mbs) and TX (92Mbs)
* Enhance footprint (new driver size is 6% less than previous driver)
* Ensure full integration with LwIP (with and without FreeRTOS)
* Rework applications to align with the new Ethernet HAL driver
* Add MISRA-C 2012 compliance, code coverage analysis, static code analysis and robustness validation
  • Loading branch information
ALABSTM committed Mar 8, 2022
1 parent e9472e4 commit c94252d
Show file tree
Hide file tree
Showing 431 changed files with 9,644 additions and 5,342 deletions.
1,164 changes: 664 additions & 500 deletions Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_eth.h

Large diffs are not rendered by default.

193 changes: 103 additions & 90 deletions Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_eth_ex.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
*/

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef STM32H7xx_HAL_ETH_EX_H
#define STM32H7xx_HAL_ETH_EX_H

#ifdef __cplusplus
extern "C" {
extern "C" {
#endif

#if defined(ETH)
Expand All @@ -41,126 +41,131 @@
/** @defgroup ETHEx_Exported_Types ETHEx Exported Types
* @{
*/
/**

/**
* @brief ETH RX VLAN structure definition
*/
typedef struct{
typedef struct
{
FunctionalState InnerVLANTagInStatus; /*!< Enables or disables Inner VLAN Tag in Rx Status */

uint32_t StripInnerVLANTag; /*!< Sets the Inner VLAN Tag Stripping on Receive
This parameter can be a value of @ref ETHEx_Rx_Inner_VLAN_Tag_Stripping */


uint32_t StripInnerVLANTag; /*!< Sets the Inner VLAN Tag Stripping on Receive
This parameter can be a value of
@ref ETHEx_Rx_Inner_VLAN_Tag_Stripping */

FunctionalState InnerVLANTag; /*!< Enables or disables Inner VLAN Tag */

FunctionalState DoubleVLANProcessing; /*!< Enable or Disable double VLAN processing */

FunctionalState VLANTagHashTableMatch; /*!< Enable or Disable VLAN Tag Hash Table Match */

FunctionalState VLANTagInStatus; /*!< Enable or Disable VLAN Tag in Rx status */
uint32_t StripVLANTag; /*!< Set the VLAN Tag Stripping on Receive

uint32_t StripVLANTag; /*!< Set the VLAN Tag Stripping on Receive
This parameter can be a value of @ref ETHEx_Rx_VLAN_Tag_Stripping */

uint32_t VLANTypeCheck; /*!< Enable or Disable VLAN Type Check
This parameter can be a value of @ref ETHEx_VLAN_Type_Check */
FunctionalState VLANTagInverceMatch; /*!< Enable or disable VLAN Tag Inverse Match */
}ETH_RxVLANConfigTypeDef;
/**
*
*/
/**

FunctionalState VLANTagInverceMatch; /*!< Enable or disable VLAN Tag Inverse Match */
} ETH_RxVLANConfigTypeDef;
/**
*
*/

/**
* @brief ETH TX VLAN structure definition
*/
typedef struct{
typedef struct
{
FunctionalState SourceTxDesc; /*!< Enable or Disable VLAN tag source from DMA tx descriptors */

FunctionalState SVLANType; /*!< Enable or Disable insertion of SVLAN type */

uint32_t VLANTagControl; /*!< Sets the VLAN tag control in tx packets
This parameter can be a value of @ref ETHEx_VLAN_Tag_Control */
}ETH_TxVLANConfigTypeDef;
/**
*
} ETH_TxVLANConfigTypeDef;
/**
*
*/

/**
/**
* @brief ETH L3 filter structure definition
*/
typedef struct{
typedef struct
{
uint32_t Protocol; /*!< Sets the L3 filter protocol to IPv4 or IPv6
This parameter can be a value of @ref ETHEx_L3_Protocol */

uint32_t SrcAddrFilterMatch; /*!< Sets the L3 filter source address match
This parameter can be a value of @ref ETHEx_L3_Source_Match */

uint32_t DestAddrFilterMatch; /*!< Sets the L3 filter destination address match
This parameter can be a value of @ref ETHEx_L3_Destination_Match */

uint32_t SrcAddrHigherBitsMatch; /*!< Sets the L3 filter source address higher bits match
This parameter can be a value from 0 to 31 */

uint32_t DestAddrHigherBitsMatch; /*!< Sets the L3 filter destination address higher bits match
This parameter can be a value from 0 to 31 */

uint32_t Ip4SrcAddr; /*!< Sets the L3 filter IPv4 source address if IPv4 protocol is used
This parameter can be a value from 0x0 to 0xFFFFFFFF */

uint32_t Ip4DestAddr; /*!< Sets the L3 filter IPv4 destination address if IPv4 protocol is used
This parameter can be a value from 0 to 0xFFFFFFFF */

uint32_t Ip6Addr[4]; /*!< Sets the L3 filter IPv6 address if IPv6 protocol is used
This parameter must be a table of 4 words (4* 32 bits) */
}ETH_L3FilterConfigTypeDef;
/**
*
} ETH_L3FilterConfigTypeDef;
/**
*
*/

/**
/**
* @brief ETH L4 filter structure definition
*/
typedef struct{
typedef struct
{
uint32_t Protocol; /*!< Sets the L4 filter protocol to TCP or UDP
This parameter can be a value of @ref ETHEx_L4_Protocol */

uint32_t SrcPortFilterMatch; /*!< Sets the L4 filter source port match
This parameter can be a value of @ref ETHEx_L4_Source_Match */

uint32_t DestPortFilterMatch; /*!< Sets the L4 filter destination port match
This parameter can be a value of @ref ETHEx_L4_Destination_Match */

uint32_t SourcePort; /*!< Sets the L4 filter source port

uint32_t SourcePort; /*!< Sets the L4 filter source port
This parameter must be a value from 0x0 to 0xFFFF */

uint32_t DestinationPort; /*!< Sets the L4 filter destination port
This parameter must be a value from 0x0 to 0xFFFF */

uint32_t DestinationPort; /*!< Sets the L4 filter destination port
This parameter must be a value from 0x0 to 0xFFFF */
}ETH_L4FilterConfigTypeDef;
/**
*
*/

} ETH_L4FilterConfigTypeDef;
/**
*
*/

/**
* @}
*/

/* Exported constants --------------------------------------------------------*/
/** @defgroup ETHEx_Exported_Constants ETHEx Exported Constants
* @{
*/

/** @defgroup ETHEx_LPI_Event ETHEx LPI Event
* @{
*/
#define ETH_TX_LPI_ENTRY ETH_MACLCSR_TLPIEN
#define ETH_TX_LPI_EXIT ETH_MACLCSR_TLPIEX
*/
#define ETH_TX_LPI_ENTRY ETH_MACLCSR_TLPIEN
#define ETH_TX_LPI_EXIT ETH_MACLCSR_TLPIEX
#define ETH_RX_LPI_ENTRY ETH_MACLCSR_RLPIEN
#define ETH_RX_LPI_EXIT ETH_MACLCSR_RLPIEX
/**
* @}
*/

/** @defgroup ETHEx_L3_Filter ETHEx L3 Filter
* @{
*/
Expand Down Expand Up @@ -197,7 +202,7 @@ typedef struct{
/**
* @}
*/

/** @defgroup ETHEx_L3_Destination_Match ETHEx L3 Destination Match
* @{
*/
Expand All @@ -207,7 +212,7 @@ typedef struct{
/**
* @}
*/

/** @defgroup ETHEx_L4_Protocol ETHEx L4 Protocol
* @{
*/
Expand All @@ -216,17 +221,17 @@ typedef struct{
/**
* @}
*/

/** @defgroup ETHEx_L4_Source_Match ETHEx L4 Source Match
* @{
*/
#define ETH_L4_SRC_PORT_PERFECT_MATCH_ENABLE ETH_MACL3L4CR_L4SPM
#define ETH_L4_SRC_PORT_INVERSE_MATCH_ENABLE (ETH_MACL3L4CR_L4SPM |ETH_MACL3L4CR_L4SPIM)
#define ETH_L4_SRC_PORT_INVERSE_MATCH_ENABLE (ETH_MACL3L4CR_L4SPM |ETH_MACL3L4CR_L4SPIM)
#define ETH_L4_SRC_PORT_MATCH_DISABLE ((uint32_t)0x00000000)
/**
* @}
*/

/** @defgroup ETHEx_L4_Destination_Match ETHEx L4 Destination Match
* @{
*/
Expand All @@ -236,10 +241,10 @@ typedef struct{
/**
* @}
*/

/** @defgroup ETHEx_Rx_Inner_VLAN_Tag_Stripping ETHEx Rx Inner VLAN Tag Stripping
* @{
*/
*/
#define ETH_INNERVLANTAGRXSTRIPPING_NONE ETH_MACVTR_EIVLS_DONOTSTRIP
#define ETH_INNERVLANTAGRXSTRIPPING_IFPASS ETH_MACVTR_EIVLS_STRIPIFPASS
#define ETH_INNERVLANTAGRXSTRIPPING_IFFAILS ETH_MACVTR_EIVLS_STRIPIFFAILS
Expand All @@ -250,25 +255,25 @@ typedef struct{

/** @defgroup ETHEx_Rx_VLAN_Tag_Stripping ETHEx Rx VLAN Tag Stripping
* @{
*/
*/
#define ETH_VLANTAGRXSTRIPPING_NONE ETH_MACVTR_EVLS_DONOTSTRIP
#define ETH_VLANTAGRXSTRIPPING_IFPASS ETH_MACVTR_EVLS_STRIPIFPASS
#define ETH_VLANTAGRXSTRIPPING_IFFAILS ETH_MACVTR_EVLS_STRIPIFFAILS
#define ETH_VLANTAGRXSTRIPPING_ALWAYS ETH_MACVTR_EVLS_ALWAYSSTRIP
/**
* @}
*/

/** @defgroup ETHEx_VLAN_Type_Check ETHEx VLAN Type Check
* @{
*/
*/
#define ETH_VLANTYPECHECK_DISABLE ETH_MACVTR_DOVLTC
#define ETH_VLANTYPECHECK_SVLAN (ETH_MACVTR_ERSVLM | ETH_MACVTR_ESVL)
#define ETH_VLANTYPECHECK_CVLAN ((uint32_t)0x00000000)
/**
* @}
*/

/** @defgroup ETHEx_VLAN_Tag_Control ETHEx_VLAN_Tag_Control
* @{
*/
Expand All @@ -278,21 +283,21 @@ typedef struct{
#define ETH_VLANTAGCONTROL_REPLACE (ETH_MACVIR_VLP | ETH_MACVIR_VLC_VLANTAGREPLACE)
/**
* @}
*/
*/

/** @defgroup ETHEx_Tx_VLAN_Tag ETHEx Tx VLAN Tag
* @{
*/
*/
#define ETH_INNER_TX_VLANTAG ((uint32_t)0x00000001U)
#define ETH_OUTER_TX_VLANTAG ((uint32_t)0x00000000U)
/**
* @}
*/
*/

/**
* @}
*/

/* Exported functions --------------------------------------------------------*/
/** @addtogroup ETHEx_Exported_Functions
* @{
Expand All @@ -304,42 +309,49 @@ typedef struct{
/* MAC ARP Offloading APIs ***************************************************/
void HAL_ETHEx_EnableARPOffload(ETH_HandleTypeDef *heth);
void HAL_ETHEx_DisableARPOffload(ETH_HandleTypeDef *heth);
void HAL_ETHEx_SetARPAddressMatch(ETH_HandleTypeDef *heth, uint32_t IpAddress);
void HAL_ETHEx_SetARPAddressMatch(ETH_HandleTypeDef *heth, uint32_t IpAddress);

/* MAC L3 L4 Filtering APIs ***************************************************/
void HAL_ETHEx_EnableL3L4Filtering(ETH_HandleTypeDef *heth);
void HAL_ETHEx_DisableL3L4Filtering(ETH_HandleTypeDef *heth);
HAL_StatusTypeDef HAL_ETHEx_GetL3FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter, ETH_L3FilterConfigTypeDef *pL3FilterConfig);
HAL_StatusTypeDef HAL_ETHEx_GetL4FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter, ETH_L4FilterConfigTypeDef *pL4FilterConfig);
HAL_StatusTypeDef HAL_ETHEx_SetL3FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter, ETH_L3FilterConfigTypeDef *pL3FilterConfig);
HAL_StatusTypeDef HAL_ETHEx_SetL4FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter, ETH_L4FilterConfigTypeDef *pL4FilterConfig);
HAL_StatusTypeDef HAL_ETHEx_GetL3FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter,
ETH_L3FilterConfigTypeDef *pL3FilterConfig);
HAL_StatusTypeDef HAL_ETHEx_GetL4FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter,
ETH_L4FilterConfigTypeDef *pL4FilterConfig);
HAL_StatusTypeDef HAL_ETHEx_SetL3FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter,
ETH_L3FilterConfigTypeDef *pL3FilterConfig);
HAL_StatusTypeDef HAL_ETHEx_SetL4FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter,
ETH_L4FilterConfigTypeDef *pL4FilterConfig);

/* MAC VLAN Processing APIs ************************************************/
void HAL_ETHEx_EnableVLANProcessing(ETH_HandleTypeDef *heth);
void HAL_ETHEx_DisableVLANProcessing(ETH_HandleTypeDef *heth);
HAL_StatusTypeDef HAL_ETHEx_GetRxVLANConfig(ETH_HandleTypeDef *heth, ETH_RxVLANConfigTypeDef *pVlanConfig);
HAL_StatusTypeDef HAL_ETHEx_SetRxVLANConfig(ETH_HandleTypeDef *heth, ETH_RxVLANConfigTypeDef *pVlanConfig);
void HAL_ETHEx_SetVLANHashTable(ETH_HandleTypeDef *heth, uint32_t VLANHashTable);
HAL_StatusTypeDef HAL_ETHEx_GetTxVLANConfig(ETH_HandleTypeDef *heth, uint32_t VLANTag ,ETH_TxVLANConfigTypeDef *pVlanConfig);
HAL_StatusTypeDef HAL_ETHEx_SetTxVLANConfig(ETH_HandleTypeDef *heth, uint32_t VLANTag ,ETH_TxVLANConfigTypeDef *pVlanConfig);
void HAL_ETHEx_SetTxVLANIdentifier(ETH_HandleTypeDef *heth, uint32_t VLANTag ,uint32_t VLANIdentifier);
HAL_StatusTypeDef HAL_ETHEx_GetTxVLANConfig(ETH_HandleTypeDef *heth, uint32_t VLANTag,
ETH_TxVLANConfigTypeDef *pVlanConfig);
HAL_StatusTypeDef HAL_ETHEx_SetTxVLANConfig(ETH_HandleTypeDef *heth, uint32_t VLANTag,
ETH_TxVLANConfigTypeDef *pVlanConfig);
void HAL_ETHEx_SetTxVLANIdentifier(ETH_HandleTypeDef *heth, uint32_t VLANTag, uint32_t VLANIdentifier);

/* Energy Efficient Ethernet APIs *********************************************/
void HAL_ETHEx_EnterLPIMode(ETH_HandleTypeDef *heth, FunctionalState TxAutomate, FunctionalState TxClockStop);
void HAL_ETHEx_EnterLPIMode(ETH_HandleTypeDef *heth, FunctionalState TxAutomate,
FunctionalState TxClockStop);
void HAL_ETHEx_ExitLPIMode(ETH_HandleTypeDef *heth);
uint32_t HAL_ETHEx_GetMACLPIEvent(ETH_HandleTypeDef *heth);

/**
* @}
*/
*/

/**
* @}
*/

/**
* @}
*/
*/

/**
* @}
Expand All @@ -353,3 +365,4 @@ uint32_t HAL_ETHEx_GetMACLPIEvent(ETH_HandleTypeDef *heth);

#endif /* STM32H7xx_HAL_ETH_EX_H */


Loading

0 comments on commit c94252d

Please sign in to comment.