summaryrefslogtreecommitdiffstats
path: root/bsps/arm/stm32h7/include/stm32h7xx_hal_eth_ex.h
blob: f39e237cf7b526cec6dead81ed233040b8cd214b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
/**
  ******************************************************************************
  * @file    stm32h7xx_hal_eth_ex.h
  * @author  MCD Application Team
  * @brief   Header file of ETH HAL Extended module.
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2017 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * 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" {
#endif

#if defined(ETH)

/* Includes ------------------------------------------------------------------*/
#include "stm32h7xx_hal_def.h"

/** @addtogroup STM32H7xx_HAL_Driver
  * @{
  */

/** @addtogroup ETHEx
  * @{
  */

/* Exported types ------------------------------------------------------------*/
/** @defgroup ETHEx_Exported_Types ETHEx Exported Types
  * @ingroup RTEMSBSPsARMSTM32H7
  * @{
  */

/**
  * @brief  ETH RX VLAN structure definition
  */
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 */

  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
                                                  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;
/**
  *
  */

/**
  * @brief  ETH TX VLAN structure definition
  */
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;
/**
  *
  */

/**
  * @brief  ETH L3 filter structure definition
  */
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;
/**
  *
  */

/**
  * @brief  ETH L4 filter structure definition
  */
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
                                        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;
/**
  *
  */

/**
  * @}
  */

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

/** @defgroup ETHEx_LPI_Event ETHEx LPI Event
  * @ingroup RTEMSBSPsARMSTM32H7
  * @{
  */
#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
  * @ingroup RTEMSBSPsARMSTM32H7
  * @{
  */
#define ETH_L3_FILTER_0                 0x00000000U
#define ETH_L3_FILTER_1                 0x0000000CU
/**
  * @}
  */

/** @defgroup ETHEx_L4_Filter ETHEx L4 Filter
  * @ingroup RTEMSBSPsARMSTM32H7
  * @{
  */
#define ETH_L4_FILTER_0                 0x00000000U
#define ETH_L4_FILTER_1                 0x0000000CU
/**
  * @}
  */

/** @defgroup ETHEx_L3_Protocol ETHEx L3 Protocol
  * @ingroup RTEMSBSPsARMSTM32H7
  * @{
  */
#define ETH_L3_IPV6_MATCH                       ETH_MACL3L4CR_L3PEN
#define ETH_L3_IPV4_MATCH                       0x00000000U
/**
  * @}
  */

/** @defgroup ETHEx_L3_Source_Match ETHEx L3 Source Match
  * @ingroup RTEMSBSPsARMSTM32H7
  * @{
  */
#define ETH_L3_SRC_ADDR_PERFECT_MATCH_ENABLE    ETH_MACL3L4CR_L3SAM
#define ETH_L3_SRC_ADDR_INVERSE_MATCH_ENABLE    (ETH_MACL3L4CR_L3SAM | ETH_MACL3L4CR_L3SAIM)
#define ETH_L3_SRC_ADDR_MATCH_DISABLE           0x00000000U
/**
  * @}
  */

/** @defgroup ETHEx_L3_Destination_Match ETHEx L3 Destination Match
  * @ingroup RTEMSBSPsARMSTM32H7
  * @{
  */
#define ETH_L3_DEST_ADDR_PERFECT_MATCH_ENABLE   ETH_MACL3L4CR_L3DAM
#define ETH_L3_DEST_ADDR_INVERSE_MATCH_ENABLE   (ETH_MACL3L4CR_L3DAM | ETH_MACL3L4CR_L3DAIM)
#define ETH_L3_DEST_ADDR_MATCH_DISABLE          0x00000000U
/**
  * @}
  */

/** @defgroup ETHEx_L4_Protocol ETHEx L4 Protocol
  * @ingroup RTEMSBSPsARMSTM32H7
  * @{
  */
#define ETH_L4_UDP_MATCH                        ETH_MACL3L4CR_L4PEN
#define ETH_L4_TCP_MATCH                        0x00000000U
/**
  * @}
  */

/** @defgroup ETHEx_L4_Source_Match ETHEx L4 Source Match
  * @ingroup RTEMSBSPsARMSTM32H7
  * @{
  */
#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_MATCH_DISABLE           0x00000000U
/**
  * @}
  */

/** @defgroup ETHEx_L4_Destination_Match ETHEx L4 Destination Match
  * @ingroup RTEMSBSPsARMSTM32H7
  * @{
  */
#define ETH_L4_DEST_PORT_PERFECT_MATCH_ENABLE   ETH_MACL3L4CR_L4DPM
#define ETH_L4_DEST_PORT_INVERSE_MATCH_ENABLE   (ETH_MACL3L4CR_L4DPM | ETH_MACL3L4CR_L4DPIM)
#define ETH_L4_DEST_PORT_MATCH_DISABLE          0x00000000U
/**
  * @}
  */

/** @defgroup ETHEx_Rx_Inner_VLAN_Tag_Stripping ETHEx Rx Inner VLAN Tag Stripping
  * @ingroup RTEMSBSPsARMSTM32H7
  * @{
  */
#define ETH_INNERVLANTAGRXSTRIPPING_NONE      ETH_MACVTR_EIVLS_DONOTSTRIP
#define ETH_INNERVLANTAGRXSTRIPPING_IFPASS    ETH_MACVTR_EIVLS_STRIPIFPASS
#define ETH_INNERVLANTAGRXSTRIPPING_IFFAILS   ETH_MACVTR_EIVLS_STRIPIFFAILS
#define ETH_INNERVLANTAGRXSTRIPPING_ALWAYS    ETH_MACVTR_EIVLS_ALWAYSSTRIP
/**
  * @}
  */

/** @defgroup ETHEx_Rx_VLAN_Tag_Stripping ETHEx Rx VLAN Tag Stripping
  * @ingroup RTEMSBSPsARMSTM32H7
  * @{
  */
#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
  * @ingroup RTEMSBSPsARMSTM32H7
  * @{
  */
#define ETH_VLANTYPECHECK_DISABLE    ETH_MACVTR_DOVLTC
#define ETH_VLANTYPECHECK_SVLAN      (ETH_MACVTR_ERSVLM | ETH_MACVTR_ESVL)
#define ETH_VLANTYPECHECK_CVLAN      0x00000000U
/**
  * @}
  */

/** @defgroup ETHEx_VLAN_Tag_Control ETHEx_VLAN_Tag_Control
  * @ingroup RTEMSBSPsARMSTM32H7
  * @{
  */
#define ETH_VLANTAGCONTROL_NONE       (ETH_MACVIR_VLP | ETH_MACVIR_VLC_NOVLANTAG)
#define ETH_VLANTAGCONTROL_DELETE     (ETH_MACVIR_VLP | ETH_MACVIR_VLC_VLANTAGDELETE)
#define ETH_VLANTAGCONTROL_INSERT     (ETH_MACVIR_VLP | ETH_MACVIR_VLC_VLANTAGINSERT)
#define ETH_VLANTAGCONTROL_REPLACE    (ETH_MACVIR_VLP | ETH_MACVIR_VLC_VLANTAGREPLACE)
/**
  * @}
  */

/** @defgroup ETHEx_Tx_VLAN_Tag ETHEx Tx VLAN Tag
  * @ingroup RTEMSBSPsARMSTM32H7
  * @{
  */
#define ETH_INNER_TX_VLANTAG    0x00000001U
#define ETH_OUTER_TX_VLANTAG    0x00000000U
/**
  * @}
  */

/**
  * @}
  */

/* Exported functions --------------------------------------------------------*/
/** @addtogroup ETHEx_Exported_Functions
  * @{
  */

/** @addtogroup ETHEx_Exported_Functions_Group1
  * @{
  */
/* 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);

/* 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);

/* 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);

/* Energy Efficient Ethernet APIs *********************************************/
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);

/**
  * @}
  */

/**
  * @}
  */

/**
  * @}
  */

/**
  * @}
  */

#endif /* ETH */

#ifdef __cplusplus
}
#endif

#endif /* STM32H7xx_HAL_ETH_EX_H */