Skip to content

Commit c94252d

Browse files
committed
Full rework of Ethernet HAL driver
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
1 parent e9472e4 commit c94252d

File tree

431 files changed

+9644
-5342
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

431 files changed

+9644
-5342
lines changed

Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_eth.h

Lines changed: 664 additions & 500 deletions
Large diffs are not rendered by default.

Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_eth_ex.h

Lines changed: 103 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
* If no LICENSE file comes with this software, it is provided AS-IS.
1515
*
1616
******************************************************************************
17-
*/
17+
*/
1818

1919
/* Define to prevent recursive inclusion -------------------------------------*/
2020
#ifndef STM32H7xx_HAL_ETH_EX_H
2121
#define STM32H7xx_HAL_ETH_EX_H
2222

2323
#ifdef __cplusplus
24-
extern "C" {
24+
extern "C" {
2525
#endif
2626

2727
#if defined(ETH)
@@ -41,126 +41,131 @@
4141
/** @defgroup ETHEx_Exported_Types ETHEx Exported Types
4242
* @{
4343
*/
44-
45-
/**
44+
45+
/**
4646
* @brief ETH RX VLAN structure definition
4747
*/
48-
typedef struct{
48+
typedef struct
49+
{
4950
FunctionalState InnerVLANTagInStatus; /*!< Enables or disables Inner VLAN Tag in Rx Status */
50-
51-
uint32_t StripInnerVLANTag; /*!< Sets the Inner VLAN Tag Stripping on Receive
52-
This parameter can be a value of @ref ETHEx_Rx_Inner_VLAN_Tag_Stripping */
53-
51+
52+
uint32_t StripInnerVLANTag; /*!< Sets the Inner VLAN Tag Stripping on Receive
53+
This parameter can be a value of
54+
@ref ETHEx_Rx_Inner_VLAN_Tag_Stripping */
55+
5456
FunctionalState InnerVLANTag; /*!< Enables or disables Inner VLAN Tag */
5557

5658
FunctionalState DoubleVLANProcessing; /*!< Enable or Disable double VLAN processing */
57-
59+
5860
FunctionalState VLANTagHashTableMatch; /*!< Enable or Disable VLAN Tag Hash Table Match */
59-
61+
6062
FunctionalState VLANTagInStatus; /*!< Enable or Disable VLAN Tag in Rx status */
61-
62-
uint32_t StripVLANTag; /*!< Set the VLAN Tag Stripping on Receive
63+
64+
uint32_t StripVLANTag; /*!< Set the VLAN Tag Stripping on Receive
6365
This parameter can be a value of @ref ETHEx_Rx_VLAN_Tag_Stripping */
64-
66+
6567
uint32_t VLANTypeCheck; /*!< Enable or Disable VLAN Type Check
6668
This parameter can be a value of @ref ETHEx_VLAN_Type_Check */
67-
68-
FunctionalState VLANTagInverceMatch; /*!< Enable or disable VLAN Tag Inverse Match */
69-
}ETH_RxVLANConfigTypeDef;
70-
/**
71-
*
72-
*/
73-
74-
/**
69+
70+
FunctionalState VLANTagInverceMatch; /*!< Enable or disable VLAN Tag Inverse Match */
71+
} ETH_RxVLANConfigTypeDef;
72+
/**
73+
*
74+
*/
75+
76+
/**
7577
* @brief ETH TX VLAN structure definition
7678
*/
77-
typedef struct{
79+
typedef struct
80+
{
7881
FunctionalState SourceTxDesc; /*!< Enable or Disable VLAN tag source from DMA tx descriptors */
79-
82+
8083
FunctionalState SVLANType; /*!< Enable or Disable insertion of SVLAN type */
81-
84+
8285
uint32_t VLANTagControl; /*!< Sets the VLAN tag control in tx packets
8386
This parameter can be a value of @ref ETHEx_VLAN_Tag_Control */
84-
}ETH_TxVLANConfigTypeDef;
85-
/**
86-
*
87+
} ETH_TxVLANConfigTypeDef;
88+
/**
89+
*
8790
*/
8891

89-
/**
92+
/**
9093
* @brief ETH L3 filter structure definition
9194
*/
92-
typedef struct{
95+
typedef struct
96+
{
9397
uint32_t Protocol; /*!< Sets the L3 filter protocol to IPv4 or IPv6
9498
This parameter can be a value of @ref ETHEx_L3_Protocol */
95-
99+
96100
uint32_t SrcAddrFilterMatch; /*!< Sets the L3 filter source address match
97101
This parameter can be a value of @ref ETHEx_L3_Source_Match */
98-
102+
99103
uint32_t DestAddrFilterMatch; /*!< Sets the L3 filter destination address match
100104
This parameter can be a value of @ref ETHEx_L3_Destination_Match */
101-
105+
102106
uint32_t SrcAddrHigherBitsMatch; /*!< Sets the L3 filter source address higher bits match
103107
This parameter can be a value from 0 to 31 */
104-
108+
105109
uint32_t DestAddrHigherBitsMatch; /*!< Sets the L3 filter destination address higher bits match
106110
This parameter can be a value from 0 to 31 */
107-
111+
108112
uint32_t Ip4SrcAddr; /*!< Sets the L3 filter IPv4 source address if IPv4 protocol is used
109113
This parameter can be a value from 0x0 to 0xFFFFFFFF */
110-
114+
111115
uint32_t Ip4DestAddr; /*!< Sets the L3 filter IPv4 destination address if IPv4 protocol is used
112116
This parameter can be a value from 0 to 0xFFFFFFFF */
113-
117+
114118
uint32_t Ip6Addr[4]; /*!< Sets the L3 filter IPv6 address if IPv6 protocol is used
115119
This parameter must be a table of 4 words (4* 32 bits) */
116-
}ETH_L3FilterConfigTypeDef;
117-
/**
118-
*
120+
} ETH_L3FilterConfigTypeDef;
121+
/**
122+
*
119123
*/
120124

121-
/**
125+
/**
122126
* @brief ETH L4 filter structure definition
123127
*/
124-
typedef struct{
128+
typedef struct
129+
{
125130
uint32_t Protocol; /*!< Sets the L4 filter protocol to TCP or UDP
126131
This parameter can be a value of @ref ETHEx_L4_Protocol */
127-
132+
128133
uint32_t SrcPortFilterMatch; /*!< Sets the L4 filter source port match
129134
This parameter can be a value of @ref ETHEx_L4_Source_Match */
130-
135+
131136
uint32_t DestPortFilterMatch; /*!< Sets the L4 filter destination port match
132137
This parameter can be a value of @ref ETHEx_L4_Destination_Match */
133-
134-
uint32_t SourcePort; /*!< Sets the L4 filter source port
138+
139+
uint32_t SourcePort; /*!< Sets the L4 filter source port
140+
This parameter must be a value from 0x0 to 0xFFFF */
141+
142+
uint32_t DestinationPort; /*!< Sets the L4 filter destination port
135143
This parameter must be a value from 0x0 to 0xFFFF */
136-
137-
uint32_t DestinationPort; /*!< Sets the L4 filter destination port
138-
This parameter must be a value from 0x0 to 0xFFFF */
139-
}ETH_L4FilterConfigTypeDef;
140-
/**
141-
*
142-
*/
143-
144+
} ETH_L4FilterConfigTypeDef;
145+
/**
146+
*
147+
*/
148+
144149
/**
145150
* @}
146151
*/
147-
152+
148153
/* Exported constants --------------------------------------------------------*/
149154
/** @defgroup ETHEx_Exported_Constants ETHEx Exported Constants
150155
* @{
151156
*/
152-
157+
153158
/** @defgroup ETHEx_LPI_Event ETHEx LPI Event
154159
* @{
155-
*/
156-
#define ETH_TX_LPI_ENTRY ETH_MACLCSR_TLPIEN
157-
#define ETH_TX_LPI_EXIT ETH_MACLCSR_TLPIEX
160+
*/
161+
#define ETH_TX_LPI_ENTRY ETH_MACLCSR_TLPIEN
162+
#define ETH_TX_LPI_EXIT ETH_MACLCSR_TLPIEX
158163
#define ETH_RX_LPI_ENTRY ETH_MACLCSR_RLPIEN
159164
#define ETH_RX_LPI_EXIT ETH_MACLCSR_RLPIEX
160165
/**
161166
* @}
162167
*/
163-
168+
164169
/** @defgroup ETHEx_L3_Filter ETHEx L3 Filter
165170
* @{
166171
*/
@@ -197,7 +202,7 @@ typedef struct{
197202
/**
198203
* @}
199204
*/
200-
205+
201206
/** @defgroup ETHEx_L3_Destination_Match ETHEx L3 Destination Match
202207
* @{
203208
*/
@@ -207,7 +212,7 @@ typedef struct{
207212
/**
208213
* @}
209214
*/
210-
215+
211216
/** @defgroup ETHEx_L4_Protocol ETHEx L4 Protocol
212217
* @{
213218
*/
@@ -216,17 +221,17 @@ typedef struct{
216221
/**
217222
* @}
218223
*/
219-
224+
220225
/** @defgroup ETHEx_L4_Source_Match ETHEx L4 Source Match
221226
* @{
222227
*/
223228
#define ETH_L4_SRC_PORT_PERFECT_MATCH_ENABLE ETH_MACL3L4CR_L4SPM
224-
#define ETH_L4_SRC_PORT_INVERSE_MATCH_ENABLE (ETH_MACL3L4CR_L4SPM |ETH_MACL3L4CR_L4SPIM)
229+
#define ETH_L4_SRC_PORT_INVERSE_MATCH_ENABLE (ETH_MACL3L4CR_L4SPM |ETH_MACL3L4CR_L4SPIM)
225230
#define ETH_L4_SRC_PORT_MATCH_DISABLE ((uint32_t)0x00000000)
226231
/**
227232
* @}
228233
*/
229-
234+
230235
/** @defgroup ETHEx_L4_Destination_Match ETHEx L4 Destination Match
231236
* @{
232237
*/
@@ -236,10 +241,10 @@ typedef struct{
236241
/**
237242
* @}
238243
*/
239-
244+
240245
/** @defgroup ETHEx_Rx_Inner_VLAN_Tag_Stripping ETHEx Rx Inner VLAN Tag Stripping
241246
* @{
242-
*/
247+
*/
243248
#define ETH_INNERVLANTAGRXSTRIPPING_NONE ETH_MACVTR_EIVLS_DONOTSTRIP
244249
#define ETH_INNERVLANTAGRXSTRIPPING_IFPASS ETH_MACVTR_EIVLS_STRIPIFPASS
245250
#define ETH_INNERVLANTAGRXSTRIPPING_IFFAILS ETH_MACVTR_EIVLS_STRIPIFFAILS
@@ -250,25 +255,25 @@ typedef struct{
250255

251256
/** @defgroup ETHEx_Rx_VLAN_Tag_Stripping ETHEx Rx VLAN Tag Stripping
252257
* @{
253-
*/
258+
*/
254259
#define ETH_VLANTAGRXSTRIPPING_NONE ETH_MACVTR_EVLS_DONOTSTRIP
255260
#define ETH_VLANTAGRXSTRIPPING_IFPASS ETH_MACVTR_EVLS_STRIPIFPASS
256261
#define ETH_VLANTAGRXSTRIPPING_IFFAILS ETH_MACVTR_EVLS_STRIPIFFAILS
257262
#define ETH_VLANTAGRXSTRIPPING_ALWAYS ETH_MACVTR_EVLS_ALWAYSSTRIP
258263
/**
259264
* @}
260265
*/
261-
266+
262267
/** @defgroup ETHEx_VLAN_Type_Check ETHEx VLAN Type Check
263268
* @{
264-
*/
269+
*/
265270
#define ETH_VLANTYPECHECK_DISABLE ETH_MACVTR_DOVLTC
266271
#define ETH_VLANTYPECHECK_SVLAN (ETH_MACVTR_ERSVLM | ETH_MACVTR_ESVL)
267272
#define ETH_VLANTYPECHECK_CVLAN ((uint32_t)0x00000000)
268273
/**
269274
* @}
270275
*/
271-
276+
272277
/** @defgroup ETHEx_VLAN_Tag_Control ETHEx_VLAN_Tag_Control
273278
* @{
274279
*/
@@ -278,21 +283,21 @@ typedef struct{
278283
#define ETH_VLANTAGCONTROL_REPLACE (ETH_MACVIR_VLP | ETH_MACVIR_VLC_VLANTAGREPLACE)
279284
/**
280285
* @}
281-
*/
282-
286+
*/
287+
283288
/** @defgroup ETHEx_Tx_VLAN_Tag ETHEx Tx VLAN Tag
284289
* @{
285-
*/
290+
*/
286291
#define ETH_INNER_TX_VLANTAG ((uint32_t)0x00000001U)
287292
#define ETH_OUTER_TX_VLANTAG ((uint32_t)0x00000000U)
288293
/**
289294
* @}
290-
*/
291-
295+
*/
296+
292297
/**
293298
* @}
294299
*/
295-
300+
296301
/* Exported functions --------------------------------------------------------*/
297302
/** @addtogroup ETHEx_Exported_Functions
298303
* @{
@@ -304,42 +309,49 @@ typedef struct{
304309
/* MAC ARP Offloading APIs ***************************************************/
305310
void HAL_ETHEx_EnableARPOffload(ETH_HandleTypeDef *heth);
306311
void HAL_ETHEx_DisableARPOffload(ETH_HandleTypeDef *heth);
307-
void HAL_ETHEx_SetARPAddressMatch(ETH_HandleTypeDef *heth, uint32_t IpAddress);
312+
void HAL_ETHEx_SetARPAddressMatch(ETH_HandleTypeDef *heth, uint32_t IpAddress);
308313

309314
/* MAC L3 L4 Filtering APIs ***************************************************/
310315
void HAL_ETHEx_EnableL3L4Filtering(ETH_HandleTypeDef *heth);
311316
void HAL_ETHEx_DisableL3L4Filtering(ETH_HandleTypeDef *heth);
312-
HAL_StatusTypeDef HAL_ETHEx_GetL3FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter, ETH_L3FilterConfigTypeDef *pL3FilterConfig);
313-
HAL_StatusTypeDef HAL_ETHEx_GetL4FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter, ETH_L4FilterConfigTypeDef *pL4FilterConfig);
314-
HAL_StatusTypeDef HAL_ETHEx_SetL3FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter, ETH_L3FilterConfigTypeDef *pL3FilterConfig);
315-
HAL_StatusTypeDef HAL_ETHEx_SetL4FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter, ETH_L4FilterConfigTypeDef *pL4FilterConfig);
317+
HAL_StatusTypeDef HAL_ETHEx_GetL3FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter,
318+
ETH_L3FilterConfigTypeDef *pL3FilterConfig);
319+
HAL_StatusTypeDef HAL_ETHEx_GetL4FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter,
320+
ETH_L4FilterConfigTypeDef *pL4FilterConfig);
321+
HAL_StatusTypeDef HAL_ETHEx_SetL3FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter,
322+
ETH_L3FilterConfigTypeDef *pL3FilterConfig);
323+
HAL_StatusTypeDef HAL_ETHEx_SetL4FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter,
324+
ETH_L4FilterConfigTypeDef *pL4FilterConfig);
316325

317326
/* MAC VLAN Processing APIs ************************************************/
318327
void HAL_ETHEx_EnableVLANProcessing(ETH_HandleTypeDef *heth);
319328
void HAL_ETHEx_DisableVLANProcessing(ETH_HandleTypeDef *heth);
320329
HAL_StatusTypeDef HAL_ETHEx_GetRxVLANConfig(ETH_HandleTypeDef *heth, ETH_RxVLANConfigTypeDef *pVlanConfig);
321330
HAL_StatusTypeDef HAL_ETHEx_SetRxVLANConfig(ETH_HandleTypeDef *heth, ETH_RxVLANConfigTypeDef *pVlanConfig);
322331
void HAL_ETHEx_SetVLANHashTable(ETH_HandleTypeDef *heth, uint32_t VLANHashTable);
323-
HAL_StatusTypeDef HAL_ETHEx_GetTxVLANConfig(ETH_HandleTypeDef *heth, uint32_t VLANTag ,ETH_TxVLANConfigTypeDef *pVlanConfig);
324-
HAL_StatusTypeDef HAL_ETHEx_SetTxVLANConfig(ETH_HandleTypeDef *heth, uint32_t VLANTag ,ETH_TxVLANConfigTypeDef *pVlanConfig);
325-
void HAL_ETHEx_SetTxVLANIdentifier(ETH_HandleTypeDef *heth, uint32_t VLANTag ,uint32_t VLANIdentifier);
332+
HAL_StatusTypeDef HAL_ETHEx_GetTxVLANConfig(ETH_HandleTypeDef *heth, uint32_t VLANTag,
333+
ETH_TxVLANConfigTypeDef *pVlanConfig);
334+
HAL_StatusTypeDef HAL_ETHEx_SetTxVLANConfig(ETH_HandleTypeDef *heth, uint32_t VLANTag,
335+
ETH_TxVLANConfigTypeDef *pVlanConfig);
336+
void HAL_ETHEx_SetTxVLANIdentifier(ETH_HandleTypeDef *heth, uint32_t VLANTag, uint32_t VLANIdentifier);
326337

327338
/* Energy Efficient Ethernet APIs *********************************************/
328-
void HAL_ETHEx_EnterLPIMode(ETH_HandleTypeDef *heth, FunctionalState TxAutomate, FunctionalState TxClockStop);
339+
void HAL_ETHEx_EnterLPIMode(ETH_HandleTypeDef *heth, FunctionalState TxAutomate,
340+
FunctionalState TxClockStop);
329341
void HAL_ETHEx_ExitLPIMode(ETH_HandleTypeDef *heth);
330342
uint32_t HAL_ETHEx_GetMACLPIEvent(ETH_HandleTypeDef *heth);
331-
343+
332344
/**
333345
* @}
334-
*/
346+
*/
335347

336348
/**
337349
* @}
338350
*/
339-
351+
340352
/**
341353
* @}
342-
*/
354+
*/
343355

344356
/**
345357
* @}
@@ -353,3 +365,4 @@ uint32_t HAL_ETHEx_GetMACLPIEvent(ETH_HandleTypeDef *heth);
353365

354366
#endif /* STM32H7xx_HAL_ETH_EX_H */
355367

368+

0 commit comments

Comments
 (0)