1 /**
2   ******************************************************************************
3   * @file    stm32h7xx_hal_eth_ex.h
4   * @author  MCD Application Team
5   * @brief   Header file of ETH HAL Extended module.
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2017 STMicroelectronics.
10   * All rights reserved.
11   *
12   * This software is licensed under terms that can be found in the LICENSE file
13   * in the root directory of this software component.
14   * If no LICENSE file comes with this software, it is provided AS-IS.
15   *
16   ******************************************************************************
17   */
18 
19 /* Define to prevent recursive inclusion -------------------------------------*/
20 #ifndef STM32H7xx_HAL_ETH_EX_H
21 #define STM32H7xx_HAL_ETH_EX_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #if defined(ETH)
28 
29 /* Includes ------------------------------------------------------------------*/
30 #include "stm32h7xx_hal_def.h"
31 
32 /** @addtogroup STM32H7xx_HAL_Driver
33   * @{
34   */
35 
36 /** @addtogroup ETHEx
37   * @{
38   */
39 
40 /* Exported types ------------------------------------------------------------*/
41 /** @defgroup ETHEx_Exported_Types ETHEx Exported Types
42   * @{
43   */
44 
45 /**
46   * @brief  ETH RX VLAN structure definition
47   */
48 typedef struct
49 {
50   FunctionalState InnerVLANTagInStatus;      /*!< Enables or disables Inner VLAN Tag in Rx Status  */
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 
56   FunctionalState InnerVLANTag;              /*!< Enables or disables Inner VLAN Tag */
57 
58   FunctionalState DoubleVLANProcessing;      /*!< Enable or Disable double VLAN processing */
59 
60   FunctionalState VLANTagHashTableMatch;     /*!< Enable or Disable VLAN Tag Hash Table Match */
61 
62   FunctionalState VLANTagInStatus;           /*!< Enable or Disable VLAN Tag in Rx status */
63 
64   uint32_t StripVLANTag;                     /*!< Set the VLAN Tag Stripping on Receive
65                                                   This parameter can be a value of @ref ETHEx_Rx_VLAN_Tag_Stripping */
66 
67   uint32_t VLANTypeCheck;                    /*!< Enable or Disable VLAN Type Check
68                                                   This parameter can be a value of @ref ETHEx_VLAN_Type_Check */
69 
70   FunctionalState VLANTagInverceMatch;       /*!< Enable or disable VLAN Tag Inverse Match */
71 } ETH_RxVLANConfigTypeDef;
72 /**
73   *
74   */
75 
76 /**
77   * @brief  ETH TX VLAN structure definition
78   */
79 typedef struct
80 {
81   FunctionalState SourceTxDesc;   /*!< Enable or Disable VLAN tag source from DMA tx descriptors */
82 
83   FunctionalState SVLANType;      /*!< Enable or Disable insertion of SVLAN type */
84 
85   uint32_t VLANTagControl;        /*!< Sets the VLAN tag control in tx packets
86                                       This parameter can be a value of @ref ETHEx_VLAN_Tag_Control */
87 } ETH_TxVLANConfigTypeDef;
88 /**
89   *
90   */
91 
92 /**
93   * @brief  ETH L3 filter structure definition
94   */
95 typedef struct
96 {
97   uint32_t Protocol;                /*!< Sets the L3 filter protocol to IPv4 or IPv6
98                                          This parameter can be a value of @ref ETHEx_L3_Protocol */
99 
100   uint32_t SrcAddrFilterMatch;      /*!< Sets the L3 filter source address match
101                                          This parameter can be a value of @ref ETHEx_L3_Source_Match */
102 
103   uint32_t DestAddrFilterMatch;     /*!< Sets the L3 filter destination address match
104                                          This parameter can be a value of @ref ETHEx_L3_Destination_Match */
105 
106   uint32_t SrcAddrHigherBitsMatch;  /*!< Sets the L3 filter source address higher bits match
107                                          This parameter can be a value from 0 to 31 */
108 
109   uint32_t DestAddrHigherBitsMatch; /*!< Sets the L3 filter destination address higher bits match
110                                          This parameter can be a value from 0 to 31 */
111 
112   uint32_t Ip4SrcAddr;              /*!< Sets the L3 filter IPv4 source address if IPv4 protocol is used
113                                          This parameter can be a value from 0x0 to 0xFFFFFFFF */
114 
115   uint32_t Ip4DestAddr;             /*!< Sets the L3 filter IPv4 destination  address if IPv4 protocol is used
116                                          This parameter can be a value from 0 to 0xFFFFFFFF  */
117 
118   uint32_t Ip6Addr[4];                 /*!< Sets the L3 filter IPv6 address if IPv6 protocol is used
119                                           This parameter must be a table of 4 words (4* 32 bits) */
120 } ETH_L3FilterConfigTypeDef;
121 /**
122   *
123   */
124 
125 /**
126   * @brief  ETH L4 filter structure definition
127   */
128 typedef struct
129 {
130   uint32_t Protocol;               /*!< Sets the L4 filter protocol to TCP or UDP
131                                         This parameter can be a value of @ref ETHEx_L4_Protocol */
132 
133   uint32_t SrcPortFilterMatch;     /*!< Sets the L4 filter source port match
134                                         This parameter can be a value of @ref ETHEx_L4_Source_Match */
135 
136   uint32_t DestPortFilterMatch;    /*!< Sets the L4 filter destination port match
137                                         This parameter can be a value of @ref ETHEx_L4_Destination_Match */
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
143                                         This parameter must be a value from 0x0 to 0xFFFF */
144 } ETH_L4FilterConfigTypeDef;
145 /**
146   *
147   */
148 
149 /**
150   * @}
151   */
152 
153 /* Exported constants --------------------------------------------------------*/
154 /** @defgroup ETHEx_Exported_Constants ETHEx Exported Constants
155   * @{
156   */
157 
158 /** @defgroup ETHEx_LPI_Event ETHEx LPI Event
159   * @{
160   */
161 #define ETH_TX_LPI_ENTRY    ETH_MACLCSR_TLPIEN
162 #define ETH_TX_LPI_EXIT     ETH_MACLCSR_TLPIEX
163 #define ETH_RX_LPI_ENTRY    ETH_MACLCSR_RLPIEN
164 #define ETH_RX_LPI_EXIT     ETH_MACLCSR_RLPIEX
165 /**
166   * @}
167   */
168 
169 /** @defgroup ETHEx_L3_Filter ETHEx L3 Filter
170   * @{
171   */
172 #define ETH_L3_FILTER_0                 0x00000000U
173 #define ETH_L3_FILTER_1                 0x0000000CU
174 /**
175   * @}
176   */
177 
178 /** @defgroup ETHEx_L4_Filter ETHEx L4 Filter
179   * @{
180   */
181 #define ETH_L4_FILTER_0                 0x00000000U
182 #define ETH_L4_FILTER_1                 0x0000000CU
183 /**
184   * @}
185   */
186 
187 /** @defgroup ETHEx_L3_Protocol ETHEx L3 Protocol
188   * @{
189   */
190 #define ETH_L3_IPV6_MATCH                       ETH_MACL3L4CR_L3PEN
191 #define ETH_L3_IPV4_MATCH                       0x00000000U
192 /**
193   * @}
194   */
195 
196 /** @defgroup ETHEx_L3_Source_Match ETHEx L3 Source Match
197   * @{
198   */
199 #define ETH_L3_SRC_ADDR_PERFECT_MATCH_ENABLE    ETH_MACL3L4CR_L3SAM
200 #define ETH_L3_SRC_ADDR_INVERSE_MATCH_ENABLE    (ETH_MACL3L4CR_L3SAM | ETH_MACL3L4CR_L3SAIM)
201 #define ETH_L3_SRC_ADDR_MATCH_DISABLE           0x00000000U
202 /**
203   * @}
204   */
205 
206 /** @defgroup ETHEx_L3_Destination_Match ETHEx L3 Destination Match
207   * @{
208   */
209 #define ETH_L3_DEST_ADDR_PERFECT_MATCH_ENABLE   ETH_MACL3L4CR_L3DAM
210 #define ETH_L3_DEST_ADDR_INVERSE_MATCH_ENABLE   (ETH_MACL3L4CR_L3DAM | ETH_MACL3L4CR_L3DAIM)
211 #define ETH_L3_DEST_ADDR_MATCH_DISABLE          0x00000000U
212 /**
213   * @}
214   */
215 
216 /** @defgroup ETHEx_L4_Protocol ETHEx L4 Protocol
217   * @{
218   */
219 #define ETH_L4_UDP_MATCH                        ETH_MACL3L4CR_L4PEN
220 #define ETH_L4_TCP_MATCH                        0x00000000U
221 /**
222   * @}
223   */
224 
225 /** @defgroup ETHEx_L4_Source_Match ETHEx L4 Source Match
226   * @{
227   */
228 #define ETH_L4_SRC_PORT_PERFECT_MATCH_ENABLE    ETH_MACL3L4CR_L4SPM
229 #define ETH_L4_SRC_PORT_INVERSE_MATCH_ENABLE    (ETH_MACL3L4CR_L4SPM |ETH_MACL3L4CR_L4SPIM)
230 #define ETH_L4_SRC_PORT_MATCH_DISABLE           0x00000000U
231 /**
232   * @}
233   */
234 
235 /** @defgroup ETHEx_L4_Destination_Match ETHEx L4 Destination Match
236   * @{
237   */
238 #define ETH_L4_DEST_PORT_PERFECT_MATCH_ENABLE   ETH_MACL3L4CR_L4DPM
239 #define ETH_L4_DEST_PORT_INVERSE_MATCH_ENABLE   (ETH_MACL3L4CR_L4DPM | ETH_MACL3L4CR_L4DPIM)
240 #define ETH_L4_DEST_PORT_MATCH_DISABLE          0x00000000U
241 /**
242   * @}
243   */
244 
245 /** @defgroup ETHEx_Rx_Inner_VLAN_Tag_Stripping ETHEx Rx Inner VLAN Tag Stripping
246   * @{
247   */
248 #define ETH_INNERVLANTAGRXSTRIPPING_NONE      ETH_MACVTR_EIVLS_DONOTSTRIP
249 #define ETH_INNERVLANTAGRXSTRIPPING_IFPASS    ETH_MACVTR_EIVLS_STRIPIFPASS
250 #define ETH_INNERVLANTAGRXSTRIPPING_IFFAILS   ETH_MACVTR_EIVLS_STRIPIFFAILS
251 #define ETH_INNERVLANTAGRXSTRIPPING_ALWAYS    ETH_MACVTR_EIVLS_ALWAYSSTRIP
252 /**
253   * @}
254   */
255 
256 /** @defgroup ETHEx_Rx_VLAN_Tag_Stripping ETHEx Rx VLAN Tag Stripping
257   * @{
258   */
259 #define ETH_VLANTAGRXSTRIPPING_NONE      ETH_MACVTR_EVLS_DONOTSTRIP
260 #define ETH_VLANTAGRXSTRIPPING_IFPASS    ETH_MACVTR_EVLS_STRIPIFPASS
261 #define ETH_VLANTAGRXSTRIPPING_IFFAILS   ETH_MACVTR_EVLS_STRIPIFFAILS
262 #define ETH_VLANTAGRXSTRIPPING_ALWAYS    ETH_MACVTR_EVLS_ALWAYSSTRIP
263 /**
264   * @}
265   */
266 
267 /** @defgroup ETHEx_VLAN_Type_Check ETHEx VLAN Type Check
268   * @{
269   */
270 #define ETH_VLANTYPECHECK_DISABLE    ETH_MACVTR_DOVLTC
271 #define ETH_VLANTYPECHECK_SVLAN      (ETH_MACVTR_ERSVLM | ETH_MACVTR_ESVL)
272 #define ETH_VLANTYPECHECK_CVLAN      0x00000000U
273 /**
274   * @}
275   */
276 
277 /** @defgroup ETHEx_VLAN_Tag_Control ETHEx_VLAN_Tag_Control
278   * @{
279   */
280 #define ETH_VLANTAGCONTROL_NONE       (ETH_MACVIR_VLP | ETH_MACVIR_VLC_NOVLANTAG)
281 #define ETH_VLANTAGCONTROL_DELETE     (ETH_MACVIR_VLP | ETH_MACVIR_VLC_VLANTAGDELETE)
282 #define ETH_VLANTAGCONTROL_INSERT     (ETH_MACVIR_VLP | ETH_MACVIR_VLC_VLANTAGINSERT)
283 #define ETH_VLANTAGCONTROL_REPLACE    (ETH_MACVIR_VLP | ETH_MACVIR_VLC_VLANTAGREPLACE)
284 /**
285   * @}
286   */
287 
288 /** @defgroup ETHEx_Tx_VLAN_Tag ETHEx Tx VLAN Tag
289   * @{
290   */
291 #define ETH_INNER_TX_VLANTAG    0x00000001U
292 #define ETH_OUTER_TX_VLANTAG    0x00000000U
293 /**
294   * @}
295   */
296 
297 /**
298   * @}
299   */
300 
301 /* Exported functions --------------------------------------------------------*/
302 /** @addtogroup ETHEx_Exported_Functions
303   * @{
304   */
305 
306 /** @addtogroup ETHEx_Exported_Functions_Group1
307   * @{
308   */
309 /* MAC ARP Offloading APIs  ***************************************************/
310 void              HAL_ETHEx_EnableARPOffload(ETH_HandleTypeDef *heth);
311 void              HAL_ETHEx_DisableARPOffload(ETH_HandleTypeDef *heth);
312 void              HAL_ETHEx_SetARPAddressMatch(ETH_HandleTypeDef *heth, uint32_t IpAddress);
313 
314 /* MAC L3 L4 Filtering APIs ***************************************************/
315 void              HAL_ETHEx_EnableL3L4Filtering(ETH_HandleTypeDef *heth);
316 void              HAL_ETHEx_DisableL3L4Filtering(ETH_HandleTypeDef *heth);
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);
325 
326 /* MAC VLAN Processing APIs    ************************************************/
327 void              HAL_ETHEx_EnableVLANProcessing(ETH_HandleTypeDef *heth);
328 void              HAL_ETHEx_DisableVLANProcessing(ETH_HandleTypeDef *heth);
329 HAL_StatusTypeDef HAL_ETHEx_GetRxVLANConfig(ETH_HandleTypeDef *heth, ETH_RxVLANConfigTypeDef *pVlanConfig);
330 HAL_StatusTypeDef HAL_ETHEx_SetRxVLANConfig(ETH_HandleTypeDef *heth, ETH_RxVLANConfigTypeDef *pVlanConfig);
331 void              HAL_ETHEx_SetVLANHashTable(ETH_HandleTypeDef *heth, uint32_t VLANHashTable);
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);
337 
338 /* Energy Efficient Ethernet APIs *********************************************/
339 void              HAL_ETHEx_EnterLPIMode(ETH_HandleTypeDef *heth, FunctionalState TxAutomate,
340                                          FunctionalState TxClockStop);
341 void              HAL_ETHEx_ExitLPIMode(ETH_HandleTypeDef *heth);
342 uint32_t          HAL_ETHEx_GetMACLPIEvent(ETH_HandleTypeDef *heth);
343 
344 /**
345   * @}
346   */
347 
348 /**
349   * @}
350   */
351 
352 /**
353   * @}
354   */
355 
356 /**
357   * @}
358   */
359 
360 #endif /* ETH */
361 
362 #ifdef __cplusplus
363 }
364 #endif
365 
366 #endif /* STM32H7xx_HAL_ETH_EX_H */
367 
368