1 /**
2   ******************************************************************************
3   * @file    stm32h7xx_hal_eth_ex_legacy.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_LEGACY_H
21 #define STM32H7xx_HAL_ETH_EX_LEGACY_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   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 
54   FunctionalState InnerVLANTag;              /*!< Enables or disables Inner VLAN Tag */
55 
56   FunctionalState DoubleVLANProcessing;      /*!< Enable or Disable double VLAN processing */
57 
58   FunctionalState VLANTagHashTableMatch;     /*!< Enable or Disable VLAN Tag Hash Table Match */
59 
60   FunctionalState VLANTagInStatus;           /*!< Enable or Disable VLAN Tag in Rx status */
61 
62   uint32_t StripVLANTag;                     /*!< Set the VLAN Tag Stripping on Receive
63                                                   This parameter can be a value of @ref ETHEx_Rx_VLAN_Tag_Stripping */
64 
65   uint32_t VLANTypeCheck;                    /*!< Enable or Disable VLAN Type Check
66                                                   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 /**
75   * @brief  ETH TX VLAN structure definition
76   */
77 typedef struct{
78   FunctionalState SourceTxDesc;   /*!< Enable or Disable VLAN tag source from DMA tx descriptors */
79 
80   FunctionalState SVLANType;      /*!< Enable or Disable insertion of SVLAN type */
81 
82   uint32_t VLANTagControl;        /*!< Sets the VLAN tag control in tx packets
83                                       This parameter can be a value of @ref ETHEx_VLAN_Tag_Control */
84 }ETH_TxVLANConfigTypeDef;
85 /**
86   *
87   */
88 
89 /**
90   * @brief  ETH L3 filter structure definition
91   */
92 typedef struct{
93   uint32_t Protocol;                /*!< Sets the L3 filter protocol to IPv4 or IPv6
94                                          This parameter can be a value of @ref ETHEx_L3_Protocol */
95 
96   uint32_t SrcAddrFilterMatch;      /*!< Sets the L3 filter source address match
97                                          This parameter can be a value of @ref ETHEx_L3_Source_Match */
98 
99   uint32_t DestAddrFilterMatch;     /*!< Sets the L3 filter destination address match
100                                          This parameter can be a value of @ref ETHEx_L3_Destination_Match */
101 
102   uint32_t SrcAddrHigherBitsMatch;  /*!< Sets the L3 filter source address higher bits match
103                                          This parameter can be a value from 0 to 31 */
104 
105   uint32_t DestAddrHigherBitsMatch; /*!< Sets the L3 filter destination address higher bits match
106                                          This parameter can be a value from 0 to 31 */
107 
108   uint32_t Ip4SrcAddr;              /*!< Sets the L3 filter IPv4 source address if IPv4 protocol is used
109                                          This parameter can be a value from 0x0 to 0xFFFFFFFF */
110 
111   uint32_t Ip4DestAddr;             /*!< Sets the L3 filter IPv4 destination  address if IPv4 protocol is used
112                                          This parameter can be a value from 0 to 0xFFFFFFFF  */
113 
114   uint32_t Ip6Addr[4];                 /*!< Sets the L3 filter IPv6 address if IPv6 protocol is used
115                                           This parameter must be a table of 4 words (4* 32 bits) */
116 }ETH_L3FilterConfigTypeDef;
117 /**
118   *
119   */
120 
121 /**
122   * @brief  ETH L4 filter structure definition
123   */
124 typedef struct{
125   uint32_t Protocol;               /*!< Sets the L4 filter protocol to TCP or UDP
126                                         This parameter can be a value of @ref ETHEx_L4_Protocol */
127 
128   uint32_t SrcPortFilterMatch;     /*!< Sets the L4 filter source port match
129                                         This parameter can be a value of @ref ETHEx_L4_Source_Match */
130 
131   uint32_t DestPortFilterMatch;    /*!< Sets the L4 filter destination port match
132                                         This parameter can be a value of @ref ETHEx_L4_Destination_Match */
133 
134   uint32_t SourcePort;             /*!< Sets the L4 filter source port
135                                         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 /**
145   * @}
146   */
147 
148 /* Exported constants --------------------------------------------------------*/
149 /** @defgroup ETHEx_Exported_Constants ETHEx Exported Constants
150   * @{
151   */
152 
153 /** @defgroup ETHEx_LPI_Event ETHEx LPI Event
154   * @{
155   */
156 #define ETH_TX_LPI_ENTRY    ETH_MACLCSR_TLPIEN
157 #define ETH_TX_LPI_EXIT     ETH_MACLCSR_TLPIEX
158 #define ETH_RX_LPI_ENTRY    ETH_MACLCSR_RLPIEN
159 #define ETH_RX_LPI_EXIT     ETH_MACLCSR_RLPIEX
160 /**
161   * @}
162   */
163 
164 /** @defgroup ETHEx_L3_Filter ETHEx L3 Filter
165   * @{
166   */
167 #define ETH_L3_FILTER_0                 ((uint32_t)0x00000000)
168 #define ETH_L3_FILTER_1                 ((uint32_t)0x0000000C)
169 /**
170   * @}
171   */
172 
173 /** @defgroup ETHEx_L4_Filter ETHEx L4 Filter
174   * @{
175   */
176 #define ETH_L4_FILTER_0                 ((uint32_t)0x00000000)
177 #define ETH_L4_FILTER_1                 ((uint32_t)0x0000000C)
178 /**
179   * @}
180   */
181 
182 /** @defgroup ETHEx_L3_Protocol ETHEx L3 Protocol
183   * @{
184   */
185 #define ETH_L3_IPV6_MATCH                       ETH_MACL3L4CR_L3PEN
186 #define ETH_L3_IPV4_MATCH                       ((uint32_t)0x00000000)
187 /**
188   * @}
189   */
190 
191 /** @defgroup ETHEx_L3_Source_Match ETHEx L3 Source Match
192   * @{
193   */
194 #define ETH_L3_SRC_ADDR_PERFECT_MATCH_ENABLE    ETH_MACL3L4CR_L3SAM
195 #define ETH_L3_SRC_ADDR_INVERSE_MATCH_ENABLE    (ETH_MACL3L4CR_L3SAM | ETH_MACL3L4CR_L3SAIM)
196 #define ETH_L3_SRC_ADDR_MATCH_DISABLE           ((uint32_t)0x00000000)
197 /**
198   * @}
199   */
200 
201 /** @defgroup ETHEx_L3_Destination_Match ETHEx L3 Destination Match
202   * @{
203   */
204 #define ETH_L3_DEST_ADDR_PERFECT_MATCH_ENABLE   ETH_MACL3L4CR_L3DAM
205 #define ETH_L3_DEST_ADDR_INVERSE_MATCH_ENABLE   (ETH_MACL3L4CR_L3DAM | ETH_MACL3L4CR_L3DAIM)
206 #define ETH_L3_DEST_ADDR_MATCH_DISABLE          ((uint32_t)0x00000000)
207 /**
208   * @}
209   */
210 
211 /** @defgroup ETHEx_L4_Protocol ETHEx L4 Protocol
212   * @{
213   */
214 #define ETH_L4_UDP_MATCH                        ETH_MACL3L4CR_L4PEN
215 #define ETH_L4_TCP_MATCH                        ((uint32_t)0x00000000)
216 /**
217   * @}
218   */
219 
220 /** @defgroup ETHEx_L4_Source_Match ETHEx L4 Source Match
221   * @{
222   */
223 #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)
225 #define ETH_L4_SRC_PORT_MATCH_DISABLE           ((uint32_t)0x00000000)
226 /**
227   * @}
228   */
229 
230 /** @defgroup ETHEx_L4_Destination_Match ETHEx L4 Destination Match
231   * @{
232   */
233 #define ETH_L4_DEST_PORT_PERFECT_MATCH_ENABLE   ETH_MACL3L4CR_L4DPM
234 #define ETH_L4_DEST_PORT_INVERSE_MATCH_ENABLE   (ETH_MACL3L4CR_L4DPM | ETH_MACL3L4CR_L4DPIM)
235 #define ETH_L4_DEST_PORT_MATCH_DISABLE          ((uint32_t)0x00000000)
236 /**
237   * @}
238   */
239 
240 /** @defgroup ETHEx_Rx_Inner_VLAN_Tag_Stripping ETHEx Rx Inner VLAN Tag Stripping
241   * @{
242   */
243 #define ETH_INNERVLANTAGRXSTRIPPING_NONE      ETH_MACVTR_EIVLS_DONOTSTRIP
244 #define ETH_INNERVLANTAGRXSTRIPPING_IFPASS    ETH_MACVTR_EIVLS_STRIPIFPASS
245 #define ETH_INNERVLANTAGRXSTRIPPING_IFFAILS   ETH_MACVTR_EIVLS_STRIPIFFAILS
246 #define ETH_INNERVLANTAGRXSTRIPPING_ALWAYS    ETH_MACVTR_EIVLS_ALWAYSSTRIP
247 /**
248   * @}
249   */
250 
251 /** @defgroup ETHEx_Rx_VLAN_Tag_Stripping ETHEx Rx VLAN Tag Stripping
252   * @{
253   */
254 #define ETH_VLANTAGRXSTRIPPING_NONE      ETH_MACVTR_EVLS_DONOTSTRIP
255 #define ETH_VLANTAGRXSTRIPPING_IFPASS    ETH_MACVTR_EVLS_STRIPIFPASS
256 #define ETH_VLANTAGRXSTRIPPING_IFFAILS   ETH_MACVTR_EVLS_STRIPIFFAILS
257 #define ETH_VLANTAGRXSTRIPPING_ALWAYS    ETH_MACVTR_EVLS_ALWAYSSTRIP
258 /**
259   * @}
260   */
261 
262 /** @defgroup ETHEx_VLAN_Type_Check ETHEx VLAN Type Check
263   * @{
264   */
265 #define ETH_VLANTYPECHECK_DISABLE    ETH_MACVTR_DOVLTC
266 #define ETH_VLANTYPECHECK_SVLAN      (ETH_MACVTR_ERSVLM | ETH_MACVTR_ESVL)
267 #define ETH_VLANTYPECHECK_CVLAN      ((uint32_t)0x00000000)
268 /**
269   * @}
270   */
271 
272 /** @defgroup ETHEx_VLAN_Tag_Control ETHEx_VLAN_Tag_Control
273   * @{
274   */
275 #define ETH_VLANTAGCONTROL_NONE       (ETH_MACVIR_VLP | ETH_MACVIR_VLC_NOVLANTAG)
276 #define ETH_VLANTAGCONTROL_DELETE     (ETH_MACVIR_VLP | ETH_MACVIR_VLC_VLANTAGDELETE)
277 #define ETH_VLANTAGCONTROL_INSERT     (ETH_MACVIR_VLP | ETH_MACVIR_VLC_VLANTAGINSERT)
278 #define ETH_VLANTAGCONTROL_REPLACE    (ETH_MACVIR_VLP | ETH_MACVIR_VLC_VLANTAGREPLACE)
279 /**
280   * @}
281   */
282 
283 /** @defgroup ETHEx_Tx_VLAN_Tag ETHEx Tx VLAN Tag
284   * @{
285   */
286 #define ETH_INNER_TX_VLANTAG    ((uint32_t)0x00000001U)
287 #define ETH_OUTER_TX_VLANTAG    ((uint32_t)0x00000000U)
288 /**
289   * @}
290   */
291 
292 /**
293   * @}
294   */
295 
296 /* Exported functions --------------------------------------------------------*/
297 /** @addtogroup ETHEx_Exported_Functions
298   * @{
299   */
300 
301 /** @addtogroup ETHEx_Exported_Functions_Group1
302   * @{
303   */
304 /* MAC ARP Offloading APIs  ***************************************************/
305 void              HAL_ETHEx_EnableARPOffload(ETH_HandleTypeDef *heth);
306 void              HAL_ETHEx_DisableARPOffload(ETH_HandleTypeDef *heth);
307 void              HAL_ETHEx_SetARPAddressMatch(ETH_HandleTypeDef *heth, uint32_t IpAddress);
308 
309 /* MAC L3 L4 Filtering APIs ***************************************************/
310 void              HAL_ETHEx_EnableL3L4Filtering(ETH_HandleTypeDef *heth);
311 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);
316 
317 /* MAC VLAN Processing APIs    ************************************************/
318 void              HAL_ETHEx_EnableVLANProcessing(ETH_HandleTypeDef *heth);
319 void              HAL_ETHEx_DisableVLANProcessing(ETH_HandleTypeDef *heth);
320 HAL_StatusTypeDef HAL_ETHEx_GetRxVLANConfig(ETH_HandleTypeDef *heth, ETH_RxVLANConfigTypeDef *pVlanConfig);
321 HAL_StatusTypeDef HAL_ETHEx_SetRxVLANConfig(ETH_HandleTypeDef *heth, ETH_RxVLANConfigTypeDef *pVlanConfig);
322 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);
326 
327 /* Energy Efficient Ethernet APIs *********************************************/
328 void              HAL_ETHEx_EnterLPIMode(ETH_HandleTypeDef *heth, FunctionalState TxAutomate, FunctionalState TxClockStop);
329 void              HAL_ETHEx_ExitLPIMode(ETH_HandleTypeDef *heth);
330 uint32_t          HAL_ETHEx_GetMACLPIEvent(ETH_HandleTypeDef *heth);
331 
332 /**
333   * @}
334   */
335 
336 /**
337   * @}
338   */
339 
340 /**
341   * @}
342   */
343 
344 /**
345   * @}
346   */
347 
348 #endif /* ETH */
349 
350 #ifdef __cplusplus
351 }
352 #endif
353 
354 #endif /* STM32H7xx_HAL_ETH_EX_LEGACY_H */
355