Alessandro Angelino / target-freescale-ksdk

Fork of target-freescale-ksdk by Morpheus

Committer:
screamer
Date:
Wed Mar 23 21:26:50 2016 +0000
Revision:
0:e4d670b91a9a
Initial revision

Who changed what in which revision?

UserRevisionLine numberNew contents of line
screamer 0:e4d670b91a9a 1 /*
screamer 0:e4d670b91a9a 2 * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
screamer 0:e4d670b91a9a 3 * All rights reserved.
screamer 0:e4d670b91a9a 4 *
screamer 0:e4d670b91a9a 5 * Redistribution and use in source and binary forms, with or without modification,
screamer 0:e4d670b91a9a 6 * are permitted provided that the following conditions are met:
screamer 0:e4d670b91a9a 7 *
screamer 0:e4d670b91a9a 8 * o Redistributions of source code must retain the above copyright notice, this list
screamer 0:e4d670b91a9a 9 * of conditions and the following disclaimer.
screamer 0:e4d670b91a9a 10 *
screamer 0:e4d670b91a9a 11 * o Redistributions in binary form must reproduce the above copyright notice, this
screamer 0:e4d670b91a9a 12 * list of conditions and the following disclaimer in the documentation and/or
screamer 0:e4d670b91a9a 13 * other materials provided with the distribution.
screamer 0:e4d670b91a9a 14 *
screamer 0:e4d670b91a9a 15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
screamer 0:e4d670b91a9a 16 * contributors may be used to endorse or promote products derived from this
screamer 0:e4d670b91a9a 17 * software without specific prior written permission.
screamer 0:e4d670b91a9a 18 *
screamer 0:e4d670b91a9a 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
screamer 0:e4d670b91a9a 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
screamer 0:e4d670b91a9a 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
screamer 0:e4d670b91a9a 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
screamer 0:e4d670b91a9a 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
screamer 0:e4d670b91a9a 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
screamer 0:e4d670b91a9a 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
screamer 0:e4d670b91a9a 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
screamer 0:e4d670b91a9a 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
screamer 0:e4d670b91a9a 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
screamer 0:e4d670b91a9a 29 */
screamer 0:e4d670b91a9a 30 #ifndef __FSL_ENET_DRIVER_H__
screamer 0:e4d670b91a9a 31 #define __FSL_ENET_DRIVER_H__
screamer 0:e4d670b91a9a 32
screamer 0:e4d670b91a9a 33 #include <stdint.h>
screamer 0:e4d670b91a9a 34 #include <stdbool.h>
screamer 0:e4d670b91a9a 35 #include "fsl_enet_hal.h"
screamer 0:e4d670b91a9a 36 #include "fsl_os_abstraction.h"
screamer 0:e4d670b91a9a 37
screamer 0:e4d670b91a9a 38 #ifndef MBED_NO_ENET
screamer 0:e4d670b91a9a 39
screamer 0:e4d670b91a9a 40 /*!
screamer 0:e4d670b91a9a 41 * @addtogroup enet_driver
screamer 0:e4d670b91a9a 42 * @{
screamer 0:e4d670b91a9a 43 */
screamer 0:e4d670b91a9a 44
screamer 0:e4d670b91a9a 45 /*******************************************************************************
screamer 0:e4d670b91a9a 46 * Definitions
screamer 0:e4d670b91a9a 47
screamer 0:e4d670b91a9a 48 ******************************************************************************/
screamer 0:e4d670b91a9a 49 /*! @brief Defines the approach: ENET interrupt handler do receive */
screamer 0:e4d670b91a9a 50 #define ENET_RECEIVE_ALL_INTERRUPT 0
screamer 0:e4d670b91a9a 51
screamer 0:e4d670b91a9a 52 /*! @brief Defines the statistic enable macro.*/
screamer 0:e4d670b91a9a 53 #define ENET_ENABLE_DETAIL_STATS 0
screamer 0:e4d670b91a9a 54
screamer 0:e4d670b91a9a 55 /*! @brief Defines the alignment operation.*/
screamer 0:e4d670b91a9a 56 #define ENET_ALIGN(x,align) ((unsigned int)((x) + ((align)-1)) & (unsigned int)(~(unsigned int)((align)- 1)))
screamer 0:e4d670b91a9a 57
screamer 0:e4d670b91a9a 58 #if FSL_FEATURE_ENET_SUPPORT_PTP
screamer 0:e4d670b91a9a 59 /*! @brief Defines the PTP IOCTL macro.*/
screamer 0:e4d670b91a9a 60 typedef enum _enet_ptp_ioctl
screamer 0:e4d670b91a9a 61 {
screamer 0:e4d670b91a9a 62 kEnetPtpGetRxTimestamp = 0, /*!< ENET PTP gets receive timestamp*/
screamer 0:e4d670b91a9a 63 kEnetPtpGetTxTimestamp, /*!< ENET PTP gets transmit timestamp*/
screamer 0:e4d670b91a9a 64 kEnetPtpGetCurrentTime, /*!< ENET PTP gets current time*/
screamer 0:e4d670b91a9a 65 kEnetPtpSetCurrentTime, /*!< ENET PTP sets current time*/
screamer 0:e4d670b91a9a 66 kEnetPtpFlushTimestamp, /*!< ENET PTP flushes timestamp*/
screamer 0:e4d670b91a9a 67 kEnetPtpCorrectTime, /*!< ENET PTP time correction*/
screamer 0:e4d670b91a9a 68 kEnetPtpSendEthernetPtpV2, /*!< ENET PTPv2 sends Ethernet frame*/
screamer 0:e4d670b91a9a 69 kEnetPtpReceiveEthernetPtpV2 /*!< ENET PTPv2 receives with Ethernet frame*/
screamer 0:e4d670b91a9a 70 } enet_ptp_ioctl_t;
screamer 0:e4d670b91a9a 71
screamer 0:e4d670b91a9a 72 /*! @brief Defines the PTP message buffer number.*/
screamer 0:e4d670b91a9a 73 typedef enum _enet_ptp_buffer_number
screamer 0:e4d670b91a9a 74 {
screamer 0:e4d670b91a9a 75 kEnetPtpL2bufferNumber = 10, /*!< PTP layer2 frame buffer number*/
screamer 0:e4d670b91a9a 76 kEnetPtpRingNumber = 25 /*!< PTP Ring buffer number*/
screamer 0:e4d670b91a9a 77 } enet_ptp_buffer_number_t;
screamer 0:e4d670b91a9a 78
screamer 0:e4d670b91a9a 79 /*! @brief Defines the ENET PTP message related constant.*/
screamer 0:e4d670b91a9a 80 typedef enum _enet_ptp_event_type
screamer 0:e4d670b91a9a 81 {
screamer 0:e4d670b91a9a 82 kEnetPtpSourcePortIdLen = 10, /*!< PTP message sequence id length*/
screamer 0:e4d670b91a9a 83 kEnetPtpEventMsgType = 3, /*!< PTP event message type*/
screamer 0:e4d670b91a9a 84 kEnetPtpEventPort = 319, /*!< PTP event port number*/
screamer 0:e4d670b91a9a 85 kEnetPtpGnrlPort = 320 /*!< PTP general port number*/
screamer 0:e4d670b91a9a 86 } enet_ptp_event_type_t;
screamer 0:e4d670b91a9a 87
screamer 0:e4d670b91a9a 88 /*! @brief Defines all ENET PTP content offsets in the IPv4 PTP UDP/IP multicast message.*/
screamer 0:e4d670b91a9a 89 typedef enum _enet_ipv4_ptp_content_offset
screamer 0:e4d670b91a9a 90 {
screamer 0:e4d670b91a9a 91 kEnetPtpIpVersionOffset = 0xe, /*!< IPv4 PTP message IP version offset*/
screamer 0:e4d670b91a9a 92 kEnetPtpUdpProtocolOffset = 0x17,/*!< IPv4 PTP message UDP protocol offset*/
screamer 0:e4d670b91a9a 93 kEnetPtpUdpPortOffset = 0x24, /*!< IPv4 PTP message UDP port offset*/
screamer 0:e4d670b91a9a 94 kEnetPtpUdpMsgTypeOffset = 0x2a, /*!< IPv4 PTP message UDP message type offset*/
screamer 0:e4d670b91a9a 95 kEnetPtpUdpVersionoffset = 0x2b, /*!< IPv4 PTP message UDP version offset*/
screamer 0:e4d670b91a9a 96 kEnetPtpUdpClockIdOffset = 0x3e, /*!< IPv4 PTP message UDP clock id offset*/
screamer 0:e4d670b91a9a 97 kEnetPtpUdpSequenIdOffset = 0x48,/*!< IPv4 PTP message UDP sequence id offset*/
screamer 0:e4d670b91a9a 98 kEnetPtpUdpCtlOffset = 0x4a /*!< IPv4 PTP message UDP control offset*/
screamer 0:e4d670b91a9a 99 } enet_ipv4_ptp_content_offset_t;
screamer 0:e4d670b91a9a 100
screamer 0:e4d670b91a9a 101 /*! @brief Defines all ENET PTP content offset in THE IPv6 PTP UDP/IP multicast message.*/
screamer 0:e4d670b91a9a 102 typedef enum _enet_ipv6_ptp_content_offset
screamer 0:e4d670b91a9a 103 {
screamer 0:e4d670b91a9a 104 kEnetPtpIpv6UdpProtocolOffset = 0x14, /*!< IPv6 PTP message UDP protocol offset*/
screamer 0:e4d670b91a9a 105 kEnetPtpIpv6UdpPortOffset = 0x38, /*!< IPv6 PTP message UDP port offset*/
screamer 0:e4d670b91a9a 106 kEnetPtpIpv6UdpMsgTypeOffset = 0x3e, /*!< IPv6 PTP message UDP message type offset*/
screamer 0:e4d670b91a9a 107 kEnetPtpIpv6UdpVersionOffset = 0x3f, /*!< IPv6 PTP message UDP version offset*/
screamer 0:e4d670b91a9a 108 kEnetPtpIpv6UdpClockIdOffset = 0x52, /*!< IPv6 PTP message UDP clock id offset*/
screamer 0:e4d670b91a9a 109 kEnetPtpIpv6UdpSequenceIdOffset = 0x5c,/*!< IPv6 PTP message UDP sequence id offset*/
screamer 0:e4d670b91a9a 110 kEnetPtpIpv6UdpCtlOffset = 0x5e /*!< IPv6 PTP message UDP control offset*/
screamer 0:e4d670b91a9a 111 } enet_ipv6_ptp_content_offset_t;
screamer 0:e4d670b91a9a 112
screamer 0:e4d670b91a9a 113 /*! @brief Defines all ENET PTP content offset in the PTP Layer2 Ethernet message.*/
screamer 0:e4d670b91a9a 114 typedef enum _enet_ethernet_ptp_content_offset
screamer 0:e4d670b91a9a 115 {
screamer 0:e4d670b91a9a 116 kEnetPtpEtherPktTypeOffset = 0x0c, /*!< PTPv2 message Ethernet packet type offset*/
screamer 0:e4d670b91a9a 117 kEnetPtpEtherMsgTypeOffset = 0x0e, /*!< PTPv2 message Ethernet message type offset*/
screamer 0:e4d670b91a9a 118 kEnetPtpEtherVersionOffset = 0x0f, /*!< PTPv2 message Ethernet version type offset*/
screamer 0:e4d670b91a9a 119 kEnetPtpEtherClockIdOffset = 0x22, /*!< PTPv2 message Ethernet clock id offset*/
screamer 0:e4d670b91a9a 120 kEnetPtpEtherSequenceIdOffset = 0x2c,/*!< PTPv2 message Ethernet sequence id offset*/
screamer 0:e4d670b91a9a 121 kEnetPtpEtherCtlOffset = 0x2e /*!< PTPv2 message Ethernet control offset*/
screamer 0:e4d670b91a9a 122 } enet_ethernet_ptp_content_offset_t;
screamer 0:e4d670b91a9a 123
screamer 0:e4d670b91a9a 124 /*! @brief Defines the 1588 timer parameters.*/
screamer 0:e4d670b91a9a 125 typedef enum _enet_ptp_timer_wrap_period
screamer 0:e4d670b91a9a 126 {
screamer 0:e4d670b91a9a 127 kEnetPtpAtperVaule = 1000000000, /*!< PTP timer wrap around one second */
screamer 0:e4d670b91a9a 128 kEnetBaseIncreaseUnit = 2 /*!< PTP timer adjusts clock and increases value to 2*/
screamer 0:e4d670b91a9a 129 } enet_ptp_timer_wrap_period_t;
screamer 0:e4d670b91a9a 130 #endif
screamer 0:e4d670b91a9a 131
screamer 0:e4d670b91a9a 132 /*! @brief Defines the interrupt source index for the interrupt vector change table.*/
screamer 0:e4d670b91a9a 133 typedef enum _enet_interrupt_number
screamer 0:e4d670b91a9a 134 {
screamer 0:e4d670b91a9a 135 kEnetTstimerInt = 0, /*!< Timestamp interrupt*/
screamer 0:e4d670b91a9a 136 kEnetTsAvailInt, /*!< TS-avail interrupt*/
screamer 0:e4d670b91a9a 137 kEnetWakeUpInt, /*!< Wakeup interrupt*/
screamer 0:e4d670b91a9a 138 kEnetPlrInt, /*!< Plr interrupt*/
screamer 0:e4d670b91a9a 139 kEnetUnInt, /*!< Un interrupt*/
screamer 0:e4d670b91a9a 140 kEnetRlInt, /*!< RL interrupt*/
screamer 0:e4d670b91a9a 141 kEnetLcInt, /*!< LC interrupt*/
screamer 0:e4d670b91a9a 142 kEnetEberrInt, /*!< Eberr interrupt*/
screamer 0:e4d670b91a9a 143 kEnetMiiInt, /*!< MII interrupt*/
screamer 0:e4d670b91a9a 144 kEnetRxbInt , /*!< Receive byte interrupt*/
screamer 0:e4d670b91a9a 145 kEnetRxfInt, /*!< Receive frame interrupt*/
screamer 0:e4d670b91a9a 146 kEnetTxbInt, /*!< Transmit byte interrupt*/
screamer 0:e4d670b91a9a 147 kEnetTxfInt, /*!< Transmit frame interrupt*/
screamer 0:e4d670b91a9a 148 kEnetGraInt, /*!< Gra interrupt*/
screamer 0:e4d670b91a9a 149 kEnetBabtInt, /*!< Babt interrupt*/
screamer 0:e4d670b91a9a 150 kEnetBabrInt, /*!< Babr interrupt*/
screamer 0:e4d670b91a9a 151 kEnetIntNum /*!< Interrupt number*/
screamer 0:e4d670b91a9a 152 } enet_interrupt_number_t;
screamer 0:e4d670b91a9a 153
screamer 0:e4d670b91a9a 154 /*! @brief Defines the ENET main constant.*/
screamer 0:e4d670b91a9a 155 typedef enum _enet_frame_max
screamer 0:e4d670b91a9a 156 {
screamer 0:e4d670b91a9a 157 kEnetMaxTimeout = 0x10000, /*!< Maximum timeout*/
screamer 0:e4d670b91a9a 158 kEnetMaxFrameSize = 1518, /*!< Maximum frame size*/
screamer 0:e4d670b91a9a 159 kEnetMaxFrameVlanSize = 1522, /*!< Maximum VLAN frame size*/
screamer 0:e4d670b91a9a 160 kEnetMaxFrameDateSize = 1500, /*!< Maximum frame data size*/
screamer 0:e4d670b91a9a 161 kEnetMaxFrameBdNumbers = 7, /*!< Maximum buffer descriptor numbers of a frame*/
screamer 0:e4d670b91a9a 162 kEnetFrameFcsLen = 4, /*!< FCS length*/
screamer 0:e4d670b91a9a 163 kEnetEthernetHeadLen = 14 /*!< Ethernet Frame header length*/
screamer 0:e4d670b91a9a 164 } enet_frame_max_t;
screamer 0:e4d670b91a9a 165
screamer 0:e4d670b91a9a 166 /*! @brief Defines the CRC data for a hash value calculation.*/
screamer 0:e4d670b91a9a 167 typedef enum _enet_crc_parameter
screamer 0:e4d670b91a9a 168 {
screamer 0:e4d670b91a9a 169 kEnetCrcData = 0xFFFFFFFFU, /*!< CRC-32 maximum data */
screamer 0:e4d670b91a9a 170 kEnetCrcOffset = 8, /*!< CRC-32 offset2*/
screamer 0:e4d670b91a9a 171 kEnetCrcMask1 = 0x3F /*!< CRC-32 mask*/
screamer 0:e4d670b91a9a 172 } enet_crc_parameter_t;
screamer 0:e4d670b91a9a 173
screamer 0:e4d670b91a9a 174 /*! @brief Defines the ENET protocol type and main parameters.*/
screamer 0:e4d670b91a9a 175 typedef enum _enet_protocol_type
screamer 0:e4d670b91a9a 176 {
screamer 0:e4d670b91a9a 177 kEnetProtocolIeee8023 = 0x88F7, /*!< Packet type Ethernet ieee802.3*/
screamer 0:e4d670b91a9a 178 kEnetProtocolIpv4 = 0x0800, /*!< Packet type IPv4*/
screamer 0:e4d670b91a9a 179 kEnetProtocolIpv6 = 0x86dd, /*!< Packet type IPv6*/
screamer 0:e4d670b91a9a 180 kEnetProtocol8021QVlan = 0x8100, /*!< Packet type VLAN*/
screamer 0:e4d670b91a9a 181 kEnetPacketUdpVersion = 0x11, /*!< UDP protocol type*/
screamer 0:e4d670b91a9a 182 kEnetPacketIpv4Version = 0x4, /*!< Packet IP version IPv4*/
screamer 0:e4d670b91a9a 183 kEnetPacketIpv6Version = 0x6 /*!< Packet IP version IPv6*/
screamer 0:e4d670b91a9a 184 } enet_protocol_type_t;
screamer 0:e4d670b91a9a 185
screamer 0:e4d670b91a9a 186 /*! @brief Defines the ENET MAC control Configure*/
screamer 0:e4d670b91a9a 187 typedef enum _enet_mac_control_flag
screamer 0:e4d670b91a9a 188 {
screamer 0:e4d670b91a9a 189 kEnetSleepModeEnable = 0x1, /*!< ENET control sleep mode Enable*/
screamer 0:e4d670b91a9a 190 kEnetPayloadlenCheckEnable = 0x2, /*!< ENET receive payload length check Enable*/
screamer 0:e4d670b91a9a 191 kEnetRxFlowControlEnable = 0x4, /*!< ENET flow control, receiver detects PAUSE frames and stops transmitting data when a PAUSE frame is detected*/
screamer 0:e4d670b91a9a 192 kEnetRxCrcFwdEnable = 0x8, /*!< Received frame crc is stripped from the frame*/
screamer 0:e4d670b91a9a 193 kEnetRxPauseFwdEnable = 0x10,/*!< Pause frames are forwarded to the user application*/
screamer 0:e4d670b91a9a 194 kEnetRxPadRemoveEnable = 0x20, /*!< Padding is removed from received frames*/
screamer 0:e4d670b91a9a 195 kEnetRxBcRejectEnable = 0x40, /*!< Broadcast frame reject*/
screamer 0:e4d670b91a9a 196 kEnetRxPromiscuousEnable = 0x80, /*!< Promiscuous mode enabled*/
screamer 0:e4d670b91a9a 197 kEnetRxMiiLoopback = 0x100, /*!< MAC MII loopback mode*/
screamer 0:e4d670b91a9a 198 } enet_mac_control_flag_t;
screamer 0:e4d670b91a9a 199
screamer 0:e4d670b91a9a 200 /*! @brief Defines the multicast group structure for the ENET device. */
screamer 0:e4d670b91a9a 201 typedef struct ENETMulticastGroup
screamer 0:e4d670b91a9a 202 {
screamer 0:e4d670b91a9a 203 enetMacAddr groupAdddr; /*!< Multicast group address*/
screamer 0:e4d670b91a9a 204 uint32_t hash; /*!< Hash value of the multicast group address*/
screamer 0:e4d670b91a9a 205 struct ENETMulticastGroup *next; /*!< Pointer of the next group structure*/
screamer 0:e4d670b91a9a 206 struct ENETMulticastGroup *prv; /*!< Pointer of the previous structure*/
screamer 0:e4d670b91a9a 207 } enet_multicast_group_t;
screamer 0:e4d670b91a9a 208
screamer 0:e4d670b91a9a 209 /*! @brief Defines the receive buffer descriptor configure structure.*/
screamer 0:e4d670b91a9a 210 typedef struct ENETRxBdConfig
screamer 0:e4d670b91a9a 211 {
screamer 0:e4d670b91a9a 212 uint8_t *rxBdPtrAlign; /*!< Aligned receive buffer descriptor pointer */
screamer 0:e4d670b91a9a 213 uint8_t *rxBufferAlign; /*!< Aligned receive data buffer pointer */
screamer 0:e4d670b91a9a 214 uint8_t *rxLargeBufferAlign; /*!< Aligned receive large data buffer pointer*/
screamer 0:e4d670b91a9a 215 uint8_t rxBdNum; /*!< Aligned receive buffer descriptor pointer*/
screamer 0:e4d670b91a9a 216 uint8_t rxBufferNum; /*!< Receive buffer number*/
screamer 0:e4d670b91a9a 217 uint8_t rxLargeBufferNum; /*!< Large receive buffer number*/
screamer 0:e4d670b91a9a 218 uint32_t rxLargeBufferSizeAlign; /*!< Aligned large receive buffer size*/
screamer 0:e4d670b91a9a 219 }enet_rxbd_config_t;
screamer 0:e4d670b91a9a 220
screamer 0:e4d670b91a9a 221 /*! @brief Defines the transmit buffer descriptor configure structure.*/
screamer 0:e4d670b91a9a 222 typedef struct ENETTxBdConfig
screamer 0:e4d670b91a9a 223 {
screamer 0:e4d670b91a9a 224 uint8_t *txBdPtrAlign; /*!< Aligned transmit buffer descriptor pointer*/
screamer 0:e4d670b91a9a 225 uint8_t *txBufferAlign; /*!< Aligned transmit buffer descriptor pointer*/
screamer 0:e4d670b91a9a 226 uint8_t txBufferNum; /*!< Transmit buffer number*/
screamer 0:e4d670b91a9a 227 uint32_t txBufferSizeAlign; /*!< Aligned transmit buffer size*/
screamer 0:e4d670b91a9a 228 }enet_txbd_config_t;
screamer 0:e4d670b91a9a 229
screamer 0:e4d670b91a9a 230 /*! @brief Defines the basic configuration structure for the ENET device.*/
screamer 0:e4d670b91a9a 231 typedef struct ENETMacConfig
screamer 0:e4d670b91a9a 232 {
screamer 0:e4d670b91a9a 233 uint16_t rxBufferSize; /*!< Receive buffer size*/
screamer 0:e4d670b91a9a 234 uint16_t rxLargeBufferNumber; /*!< Receive large buffer number; Needed only when the BD size is smaller than the maximum frame length.*/
screamer 0:e4d670b91a9a 235 uint16_t rxBdNumber; /*!< Receive buffer descriptor number*/
screamer 0:e4d670b91a9a 236 uint16_t txBdNumber; /*!< Transmit buffer descriptor number*/
screamer 0:e4d670b91a9a 237 enetMacAddr macAddr; /*!< MAC hardware address*/
screamer 0:e4d670b91a9a 238 enet_config_rmii_t rmiiCfgMode;/*!< RMII configure mode*/
screamer 0:e4d670b91a9a 239 enet_config_speed_t speed; /*!< Speed configuration*/
screamer 0:e4d670b91a9a 240 enet_config_duplex_t duplex; /*!< Duplex configuration*/
screamer 0:e4d670b91a9a 241 /*!< Mac control configure, it is recommended to use enet_mac_control_flag_t
screamer 0:e4d670b91a9a 242 it is special control set for loop mode, sleep mode, crc forward/terminate etc*/
screamer 0:e4d670b91a9a 243 uint32_t macCtlConfigure;
screamer 0:e4d670b91a9a 244 bool isTxAccelEnabled;/*!< Switcher to enable transmit accelerator*/
screamer 0:e4d670b91a9a 245 bool isRxAccelEnabled;/*!< Switcher to enable receive accelerator*/
screamer 0:e4d670b91a9a 246 bool isStoreAndFwEnabled; /*!< Switcher to enable store and forward*/
screamer 0:e4d670b91a9a 247 enet_config_rx_accelerator_t rxAcceler; /*!< Receive accelerator configure*/
screamer 0:e4d670b91a9a 248 enet_config_tx_accelerator_t txAcceler; /*!< Transmit accelerator configure*/
screamer 0:e4d670b91a9a 249 bool isVlanEnabled; /*!< Switcher to enable VLAN frame*/
screamer 0:e4d670b91a9a 250 bool isPhyAutoDiscover;/*!< Switcher to use PHY auto discover*/
screamer 0:e4d670b91a9a 251 uint32_t miiClock; /*!< MII speed*/
screamer 0:e4d670b91a9a 252 #if FSL_FEATURE_ENET_SUPPORT_PTP
screamer 0:e4d670b91a9a 253 uint16_t ptpRingBufferNumber; /*!< PTP ring buffer number*/
screamer 0:e4d670b91a9a 254 bool isSlaveModeEnabled; /*!< PTP timer configuration*/
screamer 0:e4d670b91a9a 255 #endif
screamer 0:e4d670b91a9a 256 } enet_mac_config_t;
screamer 0:e4d670b91a9a 257
screamer 0:e4d670b91a9a 258 /*! @brief Defines the basic configuration for PHY.*/
screamer 0:e4d670b91a9a 259 typedef struct ENETPhyConfig
screamer 0:e4d670b91a9a 260 {
screamer 0:e4d670b91a9a 261 uint8_t phyAddr; /*!< PHY address*/
screamer 0:e4d670b91a9a 262 bool isLoopEnabled; /*!< Switcher to enable the HY loop mode*/
screamer 0:e4d670b91a9a 263 } enet_phy_config_t;
screamer 0:e4d670b91a9a 264
screamer 0:e4d670b91a9a 265 #if FSL_FEATURE_ENET_SUPPORT_PTP
screamer 0:e4d670b91a9a 266 /*! @brief Defines the ENET Mac PTP timestamp structure.*/
screamer 0:e4d670b91a9a 267 typedef struct ENETMacPtpTime
screamer 0:e4d670b91a9a 268 {
screamer 0:e4d670b91a9a 269 uint64_t second; /*!< Second*/
screamer 0:e4d670b91a9a 270 uint32_t nanosecond; /*!< Nanosecond*/
screamer 0:e4d670b91a9a 271 } enet_mac_ptp_time_t;
screamer 0:e4d670b91a9a 272
screamer 0:e4d670b91a9a 273 /*! @brief Defines the ENET PTP timer drift structure.*/
screamer 0:e4d670b91a9a 274 typedef struct ENETPtpDrift
screamer 0:e4d670b91a9a 275 {
screamer 0:e4d670b91a9a 276 int32_t drift; /*!< Drift for the PTP timer to adjust*/
screamer 0:e4d670b91a9a 277 } enet_ptp_drift_t;
screamer 0:e4d670b91a9a 278
screamer 0:e4d670b91a9a 279 /*! @brief Defines the ENET MAC PTP time parameter.*/
screamer 0:e4d670b91a9a 280 typedef struct ENETPtpMasterTimeData
screamer 0:e4d670b91a9a 281 {
screamer 0:e4d670b91a9a 282 uint8_t masterPtpInstance;/*!< PTP master timer instance*/
screamer 0:e4d670b91a9a 283 uint64_t second; /*!< PTP master timer second */
screamer 0:e4d670b91a9a 284 } enet_ptp_master_time_data_t;
screamer 0:e4d670b91a9a 285
screamer 0:e4d670b91a9a 286 /*! @brief Defines the structure for the ENET PTP message data and timestamp data.*/
screamer 0:e4d670b91a9a 287 typedef struct ENETMacPtpTsData
screamer 0:e4d670b91a9a 288 {
screamer 0:e4d670b91a9a 289 uint8_t version; /*!< PTP version*/
screamer 0:e4d670b91a9a 290 uint8_t sourcePortId[kEnetPtpSourcePortIdLen];/*!< PTP source port ID*/
screamer 0:e4d670b91a9a 291 uint16_t sequenceId; /*!< PTP sequence ID*/
screamer 0:e4d670b91a9a 292 uint8_t messageType; /*!< PTP message type*/
screamer 0:e4d670b91a9a 293 enet_mac_ptp_time_t timeStamp;/*!< PTP timestamp*/
screamer 0:e4d670b91a9a 294 } enet_mac_ptp_ts_data_t;
screamer 0:e4d670b91a9a 295
screamer 0:e4d670b91a9a 296 /*! @brief Defines the ENET PTP ring buffer structure for the PTP message timestamp store.*/
screamer 0:e4d670b91a9a 297 typedef struct ENETMacPtpTsRing
screamer 0:e4d670b91a9a 298 {
screamer 0:e4d670b91a9a 299 uint32_t front; /*!< The first index of the ring*/
screamer 0:e4d670b91a9a 300 uint32_t end; /*!< The end index of the ring*/
screamer 0:e4d670b91a9a 301 uint32_t size; /*!< The size of the ring*/
screamer 0:e4d670b91a9a 302 enet_mac_ptp_ts_data_t *ptpTsDataPtr;/*!< PTP message data structure*/
screamer 0:e4d670b91a9a 303 } enet_mac_ptp_ts_ring_t;
screamer 0:e4d670b91a9a 304
screamer 0:e4d670b91a9a 305 /*! @brief Defines the ENET packet for the PTP version2 message using the layer2 Ethernet frame.*/
screamer 0:e4d670b91a9a 306 typedef struct ENETPtpL2packet
screamer 0:e4d670b91a9a 307 {
screamer 0:e4d670b91a9a 308 uint8_t packet[kEnetMaxFrameDateSize]; /*!< Buffer for ptpv2 message*/
screamer 0:e4d670b91a9a 309 uint16_t length; /*!< PTP message length*/
screamer 0:e4d670b91a9a 310 } enet_ptp_l2packet_t;
screamer 0:e4d670b91a9a 311
screamer 0:e4d670b91a9a 312 /*! @brief Defines the ENET PTPv2 packet queue using the layer2 Ethernet frame.*/
screamer 0:e4d670b91a9a 313 typedef struct ENETPtpL2queue
screamer 0:e4d670b91a9a 314 {
screamer 0:e4d670b91a9a 315 enet_ptp_l2packet_t l2Packet[kEnetPtpL2bufferNumber]; /*!< PTP layer2 packet*/
screamer 0:e4d670b91a9a 316 uint16_t writeIdex; /*!< Queue write index*/
screamer 0:e4d670b91a9a 317 uint16_t readIdx; /*!< Queue read index*/
screamer 0:e4d670b91a9a 318 } enet_ptp_l2queue_t;
screamer 0:e4d670b91a9a 319
screamer 0:e4d670b91a9a 320 /*! @brief Defines the ENET PTP layer2 Ethernet frame structure.*/
screamer 0:e4d670b91a9a 321 typedef struct ENETPtpL2Ethernet
screamer 0:e4d670b91a9a 322 {
screamer 0:e4d670b91a9a 323 uint8_t *ptpMsg; /*!< PTP message*/
screamer 0:e4d670b91a9a 324 uint16_t length; /*!< Length of the PTP message*/
screamer 0:e4d670b91a9a 325 enetMacAddr hwAddr; /*!< Destination hardware address*/
screamer 0:e4d670b91a9a 326 } enet_ptp_l2_ethernet_t;
screamer 0:e4d670b91a9a 327
screamer 0:e4d670b91a9a 328 /*! @brief Defines the ENET PTP buffer structure for all 1588 data.*/
screamer 0:e4d670b91a9a 329 typedef struct ENETPrivatePtpBuffer
screamer 0:e4d670b91a9a 330 {
screamer 0:e4d670b91a9a 331 enet_mac_ptp_ts_ring_t rxTimeStamp;/*!< Data structure for receive message*/
screamer 0:e4d670b91a9a 332 enet_mac_ptp_ts_ring_t txTimeStamp;/*!< Data structure for transmit timestamp*/
screamer 0:e4d670b91a9a 333 enet_ptp_l2queue_t *l2QueuePtr; /*!< Data structure for layer2 Ethernet queue*/
screamer 0:e4d670b91a9a 334 uint64_t masterSecond; /*!< PTP time second when it's master time*/
screamer 0:e4d670b91a9a 335 } enet_private_ptp_buffer_t;
screamer 0:e4d670b91a9a 336 #endif
screamer 0:e4d670b91a9a 337
screamer 0:e4d670b91a9a 338 /*! @brief Defines the ENET header structure. */
screamer 0:e4d670b91a9a 339 typedef struct ENETEthernetHeader
screamer 0:e4d670b91a9a 340 {
screamer 0:e4d670b91a9a 341 enetMacAddr destAddr; /*!< Destination address */
screamer 0:e4d670b91a9a 342 enetMacAddr sourceAddr;/*!< Source address*/
screamer 0:e4d670b91a9a 343 uint16_t type; /*!< Protocol type*/
screamer 0:e4d670b91a9a 344 } enet_ethernet_header_t;
screamer 0:e4d670b91a9a 345
screamer 0:e4d670b91a9a 346 /*! @brief Defines the ENET VLAN frame header structure. */
screamer 0:e4d670b91a9a 347 typedef struct ENET8021vlanHeader
screamer 0:e4d670b91a9a 348 {
screamer 0:e4d670b91a9a 349 enetMacAddr destAddr; /*!< Destination address */
screamer 0:e4d670b91a9a 350 enetMacAddr sourceAddr;/*!< Source address*/
screamer 0:e4d670b91a9a 351 uint16_t tpidtag; /*!< ENET 8021tag header tag region*/
screamer 0:e4d670b91a9a 352 uint16_t othertag; /*!< ENET 8021tag header type region*/
screamer 0:e4d670b91a9a 353 uint16_t type; /*!< Protocol type*/
screamer 0:e4d670b91a9a 354 } enet_8021vlan_header_t;
screamer 0:e4d670b91a9a 355
screamer 0:e4d670b91a9a 356 /*! @brief Defines the ENET MAC context structure for the buffer address, buffer descriptor address, etc.*/
screamer 0:e4d670b91a9a 357 typedef struct ENETMacContext
screamer 0:e4d670b91a9a 358 {
screamer 0:e4d670b91a9a 359 uint8_t *rxBufferPtr; /*!< Receive buffer pointer*/
screamer 0:e4d670b91a9a 360 uint8_t *rxLargeBufferPtr; /*!< Receive large buffer descriptor*/
screamer 0:e4d670b91a9a 361 uint8_t *txBufferPtr; /*!< Transmit buffer pointer*/
screamer 0:e4d670b91a9a 362 uint8_t *rxBdBasePtr; /*!< Receive buffer descriptor base address pointer*/
screamer 0:e4d670b91a9a 363 uint8_t *rxBdCurPtr; /*!< Current receive buffer descriptor pointer*/
screamer 0:e4d670b91a9a 364 uint8_t *rxBdDirtyPtr; /*!< Receive dirty buffer descriptor*/
screamer 0:e4d670b91a9a 365 uint8_t *txBdBasePtr; /*!< Transmit buffer descriptor base address pointer*/
screamer 0:e4d670b91a9a 366 uint8_t *txBdCurPtr; /*!< Current transmit buffer descriptor pointer*/
screamer 0:e4d670b91a9a 367 uint8_t *txBdDirtyPtr; /*!< Last cleaned transmit buffer descriptor pointer*/
screamer 0:e4d670b91a9a 368 bool isTxFull; /*!< Transmit buffer descriptor full*/
screamer 0:e4d670b91a9a 369 bool isRxFull; /*!< Receive buffer descriptor full*/
screamer 0:e4d670b91a9a 370 uint32_t bufferdescSize; /*!< ENET buffer descriptor size*/
screamer 0:e4d670b91a9a 371 uint16_t rxBufferSizeAligned; /*!< Receive buffer alignment size*/
screamer 0:e4d670b91a9a 372 #if FSL_FEATURE_ENET_SUPPORT_PTP
screamer 0:e4d670b91a9a 373 enet_private_ptp_buffer_t privatePtp;/*!< PTP private buffer*/
screamer 0:e4d670b91a9a 374 #endif
screamer 0:e4d670b91a9a 375 } enet_mac_context_t;
screamer 0:e4d670b91a9a 376
screamer 0:e4d670b91a9a 377 /*! @brief Defines the ENET packets statistic structure.*/
screamer 0:e4d670b91a9a 378 typedef struct ENETMacStats
screamer 0:e4d670b91a9a 379 {
screamer 0:e4d670b91a9a 380 uint32_t statsRxTotal; /*!< Total number of receive packets*/
screamer 0:e4d670b91a9a 381 uint32_t statsRxMissed; /*!< Total number of receive packets*/
screamer 0:e4d670b91a9a 382 uint32_t statsRxDiscard; /*!< Receive discarded with error */
screamer 0:e4d670b91a9a 383 uint32_t statsRxError; /*!< Receive discarded with error packets*/
screamer 0:e4d670b91a9a 384 uint32_t statsTxTotal; /*!< Total number of transmit packets*/
screamer 0:e4d670b91a9a 385 uint32_t statsTxMissed; /*!< Transmit missed*/
screamer 0:e4d670b91a9a 386 uint32_t statsTxDiscard; /*!< Transmit discarded with error */
screamer 0:e4d670b91a9a 387 uint32_t statsTxError; /*!< Transmit error*/
screamer 0:e4d670b91a9a 388 uint32_t statsRxAlign; /*!< Receive non-octet alignment*/
screamer 0:e4d670b91a9a 389 uint32_t statsRxFcs; /*!< Receive CRC error*/
screamer 0:e4d670b91a9a 390 uint32_t statsRxTruncate;/*!< Receive truncate*/
screamer 0:e4d670b91a9a 391 uint32_t statsRxLengthGreater; /*!< Receive length greater than RCR[MAX_FL] */
screamer 0:e4d670b91a9a 392 uint32_t statsRxCollision; /*!< Receive collision*/
screamer 0:e4d670b91a9a 393 uint32_t statsRxOverRun; /*!< Receive over run*/
screamer 0:e4d670b91a9a 394 uint32_t statsTxOverFlow; /*!< Transmit overflow*/
screamer 0:e4d670b91a9a 395 uint32_t statsTxLateCollision; /*!< Transmit late collision*/
screamer 0:e4d670b91a9a 396 uint32_t statsTxExcessCollision;/*!< Transmit excess collision*/
screamer 0:e4d670b91a9a 397 uint32_t statsTxUnderFlow; /*!< Transmit under flow*/
screamer 0:e4d670b91a9a 398 uint32_t statsTxLarge; /*!< Transmit large packet*/
screamer 0:e4d670b91a9a 399 uint32_t statsTxSmall; /*!< Transmit small packet*/
screamer 0:e4d670b91a9a 400 } enet_stats_t;
screamer 0:e4d670b91a9a 401
screamer 0:e4d670b91a9a 402 /*! @brief Defines the ENET MAC packet buffer structure.*/
screamer 0:e4d670b91a9a 403 typedef struct ENETMacPacketBuffer
screamer 0:e4d670b91a9a 404 {
screamer 0:e4d670b91a9a 405 uint8_t *data;
screamer 0:e4d670b91a9a 406 uint16_t length;
screamer 0:e4d670b91a9a 407 } enet_mac_packet_buffer_t;
screamer 0:e4d670b91a9a 408
screamer 0:e4d670b91a9a 409 #if ENET_RECEIVE_ALL_INTERRUPT
screamer 0:e4d670b91a9a 410 typedef uint32_t (* enet_netif_callback_t)(void *enetPtr, enet_mac_packet_buffer_t *packetBuffer);
screamer 0:e4d670b91a9a 411 #endif
screamer 0:e4d670b91a9a 412
screamer 0:e4d670b91a9a 413 /*! @brief Defines the ENET device data structure for the ENET.*/
screamer 0:e4d670b91a9a 414 typedef struct ENETDevIf
screamer 0:e4d670b91a9a 415 {
screamer 0:e4d670b91a9a 416 struct ENETDevIf *next; /*!< Next device structure address*/
screamer 0:e4d670b91a9a 417 void *netIfPtr; /*!< Store the connected upper layer in the structure*/
screamer 0:e4d670b91a9a 418 #if ENET_RECEIVE_ALL_INTERRUPT
screamer 0:e4d670b91a9a 419 void *enetNetifService; /*!< Service function*/
screamer 0:e4d670b91a9a 420 #endif
screamer 0:e4d670b91a9a 421 enet_multicast_group_t *multiGroupPtr; /*!< Multicast group chain*/
screamer 0:e4d670b91a9a 422 uint32_t deviceNumber; /*!< Device number*/
screamer 0:e4d670b91a9a 423 bool isInitialized; /*!< Device initialized*/
screamer 0:e4d670b91a9a 424 uint16_t maxFrameSize; /*!< MAC maximum frame size*/
screamer 0:e4d670b91a9a 425 enet_mac_config_t *macCfgPtr;/*!< MAC configuration structure*/
screamer 0:e4d670b91a9a 426 enet_phy_config_t *phyCfgPtr;/*!< PHY configuration structure*/
screamer 0:e4d670b91a9a 427 const struct ENETMacApi *macApiPtr; /*!< MAC application interface structure*/
screamer 0:e4d670b91a9a 428 void *phyApiPtr; /*!< PHY application interface structure*/
screamer 0:e4d670b91a9a 429 enet_mac_context_t *macContextPtr; /*!< MAC context pointer*/
screamer 0:e4d670b91a9a 430 #if ENET_ENABLE_DETAIL_STATS
screamer 0:e4d670b91a9a 431 enet_stats_t stats; /*!< Packets statistic*/
screamer 0:e4d670b91a9a 432 #endif
screamer 0:e4d670b91a9a 433 #if ENET_RECEIVE_ALL_INTERRUPT
screamer 0:e4d670b91a9a 434 enet_netif_callback_t enetNetifcall; /*!< Receive callback function to the upper layer*/
screamer 0:e4d670b91a9a 435 #else
screamer 0:e4d670b91a9a 436 event_object_t enetReceiveSync; /*!< Receive sync signal*/
screamer 0:e4d670b91a9a 437 #endif
screamer 0:e4d670b91a9a 438 lock_object_t enetContextSync; /*!< Sync signal*/
screamer 0:e4d670b91a9a 439 } enet_dev_if_t;
screamer 0:e4d670b91a9a 440
screamer 0:e4d670b91a9a 441 /*! @brief Defines the basic application for the ENET device.*/
screamer 0:e4d670b91a9a 442 typedef struct ENETMacApi
screamer 0:e4d670b91a9a 443 {
screamer 0:e4d670b91a9a 444 uint32_t (* enet_mac_init)(enet_dev_if_t * enetIfPtr, enet_rxbd_config_t *rxbdCfg, enet_txbd_config_t *txbdCfg);/*!< MAC initialize interface*/
screamer 0:e4d670b91a9a 445 uint32_t (* enet_mac_deinit)(enet_dev_if_t * enetIfPtr);/*!< MAC close interface*/
screamer 0:e4d670b91a9a 446 uint32_t (* enet_mac_send)(enet_dev_if_t * enetIfPtr, uint8_t *packet, uint32_t size);/*!< MAC send packets*/
screamer 0:e4d670b91a9a 447 #if !ENET_RECEIVE_ALL_INTERRUPT
screamer 0:e4d670b91a9a 448 uint32_t (* enet_mac_receive)(enet_dev_if_t * enetIfPtr, enet_mac_packet_buffer_t *packBuffer);/*!< MAC receive interface*/
screamer 0:e4d670b91a9a 449 #endif
screamer 0:e4d670b91a9a 450 uint32_t (* enet_mii_read)(uint32_t instance, uint32_t phyAddr, uint32_t phyReg, uint32_t *dataPtr);/*!< MII reads PHY*/
screamer 0:e4d670b91a9a 451 uint32_t (* enet_mii_write)(uint32_t instance, uint32_t phyAddr, uint32_t phyReg, uint32_t data);/*!< MII writes PHY*/
screamer 0:e4d670b91a9a 452 uint32_t (* enet_add_multicast_group)(uint32_t instance, enet_multicast_group_t *multiGroupPtr, uint8_t *groupAddr);/*!< Add multicast group*/
screamer 0:e4d670b91a9a 453 uint32_t (* enet_leave_multicast_group)(uint32_t instance, enet_multicast_group_t *multiGroupPtr, uint8_t *groupAddr);/*!< Leave multicast group*/
screamer 0:e4d670b91a9a 454 } enet_mac_api_t;
screamer 0:e4d670b91a9a 455
screamer 0:e4d670b91a9a 456 /*******************************************************************
screamer 0:e4d670b91a9a 457 * Global variables
screamer 0:e4d670b91a9a 458
screamer 0:e4d670b91a9a 459 ***********************************************************************/
screamer 0:e4d670b91a9a 460 extern const enet_mac_api_t g_enetMacApi;
screamer 0:e4d670b91a9a 461
screamer 0:e4d670b91a9a 462 /*******************************************************************************
screamer 0:e4d670b91a9a 463 * API
screamer 0:e4d670b91a9a 464 ******************************************************************************/
screamer 0:e4d670b91a9a 465
screamer 0:e4d670b91a9a 466 #if defined(__cplusplus)
screamer 0:e4d670b91a9a 467 extern "C" {
screamer 0:e4d670b91a9a 468 #endif
screamer 0:e4d670b91a9a 469
screamer 0:e4d670b91a9a 470 /*!
screamer 0:e4d670b91a9a 471 * @name ENET Driver
screamer 0:e4d670b91a9a 472 * @{
screamer 0:e4d670b91a9a 473 */
screamer 0:e4d670b91a9a 474
screamer 0:e4d670b91a9a 475
screamer 0:e4d670b91a9a 476 #if FSL_FEATURE_ENET_SUPPORT_PTP
screamer 0:e4d670b91a9a 477 /*!
screamer 0:e4d670b91a9a 478 * @brief Initializes the ENET PTP context structure with the basic configuration.
screamer 0:e4d670b91a9a 479 *
screamer 0:e4d670b91a9a 480 * @param macContextPtr The pointer to the ENET MAC macContext structure.
screamer 0:e4d670b91a9a 481 * @return The execution status.
screamer 0:e4d670b91a9a 482 */
screamer 0:e4d670b91a9a 483 uint32_t enet_ptp_init(enet_private_ptp_buffer_t *privatePtpPtr, uint32_t ptpRxBufferNum, enet_mac_ptp_ts_data_t *ptpTsRxDataPtr, uint32_t ptpTxBufferNum, enet_mac_ptp_ts_data_t *ptpTsTxDataPtr);
screamer 0:e4d670b91a9a 484
screamer 0:e4d670b91a9a 485 /*!
screamer 0:e4d670b91a9a 486 * @brief Initializes the ENET PTP timer with the basic configuration.
screamer 0:e4d670b91a9a 487 *
screamer 0:e4d670b91a9a 488 * After the PTP starts, the 1588 timer also starts running. If the user wants the 1588 timer
screamer 0:e4d670b91a9a 489 * as the slave, enable the isSlaveEnabled flag.
screamer 0:e4d670b91a9a 490 *
screamer 0:e4d670b91a9a 491 * @param instance The ENET instance number.
screamer 0:e4d670b91a9a 492 * @param ptpCfgPtr The pointer to the basic PTP timer configuration structure.
screamer 0:e4d670b91a9a 493 * @return The execution status.
screamer 0:e4d670b91a9a 494 */
screamer 0:e4d670b91a9a 495 uint32_t enet_ptp_start(uint32_t instance, bool isSlaveEnabled);
screamer 0:e4d670b91a9a 496
screamer 0:e4d670b91a9a 497 /*!
screamer 0:e4d670b91a9a 498 * @brief Parses the ENET packet.
screamer 0:e4d670b91a9a 499 *
screamer 0:e4d670b91a9a 500 * Parses the ENET message and checks if it is a PTP message. If it is a PTP message,
screamer 0:e4d670b91a9a 501 * the message is stored in the PTP information structure. Message parsing
screamer 0:e4d670b91a9a 502 * decides whether timestamp processing is done after that.
screamer 0:e4d670b91a9a 503 *
screamer 0:e4d670b91a9a 504 * @param packet The ENET packet.
screamer 0:e4d670b91a9a 505 * @param ptpTsPtr The pointer to the PTP data structure.
screamer 0:e4d670b91a9a 506 * @param isPtpMsg The PTP message flag.
screamer 0:e4d670b91a9a 507 * @param isFastEnabled The fast operation flag. If set, only check if it is a ptp message
screamer 0:e4d670b91a9a 508 * and doesn't store any ptp message.
screamer 0:e4d670b91a9a 509 * @return The execution status.
screamer 0:e4d670b91a9a 510 */
screamer 0:e4d670b91a9a 511 uint32_t enet_ptp_parse(uint8_t *packet, enet_mac_ptp_ts_data_t *ptpTsPtr, bool *isPtpMsg, bool isFastEnabled);
screamer 0:e4d670b91a9a 512
screamer 0:e4d670b91a9a 513 /*!
screamer 0:e4d670b91a9a 514 * @brief Gets the current value of the ENET PTP time.
screamer 0:e4d670b91a9a 515 *
screamer 0:e4d670b91a9a 516 * @param ptpTimerPtr The PTP timer structure.
screamer 0:e4d670b91a9a 517 * @return The execution status.
screamer 0:e4d670b91a9a 518 */
screamer 0:e4d670b91a9a 519 uint32_t enet_ptp_get_time(enet_mac_ptp_time_t *ptpTimerPtr);
screamer 0:e4d670b91a9a 520
screamer 0:e4d670b91a9a 521 /*!
screamer 0:e4d670b91a9a 522 * @brief Sets the current value of the ENET PTP time.
screamer 0:e4d670b91a9a 523 *
screamer 0:e4d670b91a9a 524 * @param ptpTimerPtr The PTP timer structure.
screamer 0:e4d670b91a9a 525 * @return The execution status.
screamer 0:e4d670b91a9a 526 */
screamer 0:e4d670b91a9a 527 uint32_t enet_ptp_set_time(enet_mac_ptp_time_t *ptpTimerPtr);
screamer 0:e4d670b91a9a 528
screamer 0:e4d670b91a9a 529 /*!
screamer 0:e4d670b91a9a 530 * @brief Adjusts the ENET PTP time.
screamer 0:e4d670b91a9a 531 *
screamer 0:e4d670b91a9a 532 * @param instance The ENET instance number.
screamer 0:e4d670b91a9a 533 * @param drift The PTP timer drift value.
screamer 0:e4d670b91a9a 534 * @return The execution status.
screamer 0:e4d670b91a9a 535 */
screamer 0:e4d670b91a9a 536 uint32_t enet_ptp_correction_time(uint32_t instance, int32_t drift);
screamer 0:e4d670b91a9a 537
screamer 0:e4d670b91a9a 538
screamer 0:e4d670b91a9a 539 /*!
screamer 0:e4d670b91a9a 540 * @brief Stores the transmit timestamp.
screamer 0:e4d670b91a9a 541 *
screamer 0:e4d670b91a9a 542 * @param ptpBuffer The PTP buffer pointer.
screamer 0:e4d670b91a9a 543 * @param bdPtr The current transmit buffer descriptor.
screamer 0:e4d670b91a9a 544 * @return The execution status.
screamer 0:e4d670b91a9a 545 */
screamer 0:e4d670b91a9a 546 uint32_t enet_ptp_store_tx_timestamp(enet_private_ptp_buffer_t *ptpBuffer,void *bdPtr);
screamer 0:e4d670b91a9a 547
screamer 0:e4d670b91a9a 548 /*!
screamer 0:e4d670b91a9a 549 * @brief Stores receive timestamp.
screamer 0:e4d670b91a9a 550 *
screamer 0:e4d670b91a9a 551 * @param ptpBuffer The PTP buffer pointer.
screamer 0:e4d670b91a9a 552 * @param packet The current receive packet.
screamer 0:e4d670b91a9a 553 * @param bdPtr The current receive buffer descriptor.
screamer 0:e4d670b91a9a 554 * @return The execution status.
screamer 0:e4d670b91a9a 555 */
screamer 0:e4d670b91a9a 556 uint32_t enet_ptp_store_rx_timestamp(enet_private_ptp_buffer_t *ptpBuffer, uint8_t *packet, void *bdPtr);
screamer 0:e4d670b91a9a 557
screamer 0:e4d670b91a9a 558 /*!
screamer 0:e4d670b91a9a 559 * @brief Initializes the buffer queue for the PTP layer2 Ethernet packets.
screamer 0:e4d670b91a9a 560 *
screamer 0:e4d670b91a9a 561 * @param ptpBuffer The PTP buffer pointer.
screamer 0:e4d670b91a9a 562 * @return The execution status.
screamer 0:e4d670b91a9a 563 */
screamer 0:e4d670b91a9a 564 uint32_t enet_ptp_l2queue_init(enet_private_ptp_buffer_t *ptpBuffer, enet_ptp_l2queue_t *ptpL2QuePtr);
screamer 0:e4d670b91a9a 565
screamer 0:e4d670b91a9a 566 /*!
screamer 0:e4d670b91a9a 567 * @brief Adds the PTP layer2 Ethernet packet to the PTP Ethernet packet queue.
screamer 0:e4d670b91a9a 568 *
screamer 0:e4d670b91a9a 569 * @param ptpQuePtr The ENET private ptp layer2 buffer queue structure pointer.
screamer 0:e4d670b91a9a 570 * @param packet The packet buffer pointer.
screamer 0:e4d670b91a9a 571 * @param length The packet length.
screamer 0:e4d670b91a9a 572 * @return The execution status.
screamer 0:e4d670b91a9a 573 */
screamer 0:e4d670b91a9a 574 uint32_t enet_ptp_service_l2packet(enet_ptp_l2queue_t * ptpQuePtr, uint8_t *packet, uint16_t length);
screamer 0:e4d670b91a9a 575
screamer 0:e4d670b91a9a 576 /*!
screamer 0:e4d670b91a9a 577 * @brief Sends the PTP layer2 Ethernet packet to the Net.
screamer 0:e4d670b91a9a 578 *
screamer 0:e4d670b91a9a 579 * @param enetIfPtr The ENET context structure.
screamer 0:e4d670b91a9a 580 * @param paramPtr The buffer from upper layer.
screamer 0:e4d670b91a9a 581 * @return The execution status.
screamer 0:e4d670b91a9a 582 */
screamer 0:e4d670b91a9a 583 uint32_t enet_ptp_send_l2packet(enet_dev_if_t * enetIfPtr, void *paramPtr);
screamer 0:e4d670b91a9a 584
screamer 0:e4d670b91a9a 585 /*!
screamer 0:e4d670b91a9a 586 * @brief Receives the PTP layer2 Ethernet packet from the Net.
screamer 0:e4d670b91a9a 587 *
screamer 0:e4d670b91a9a 588 * @param enetIfPtr The ENET context structure.
screamer 0:e4d670b91a9a 589 * @param paramPtr The buffer receive from net and will send to upper layer.
screamer 0:e4d670b91a9a 590 * @return The execution status.
screamer 0:e4d670b91a9a 591 */
screamer 0:e4d670b91a9a 592 uint32_t enet_ptp_receive_l2packet(enet_dev_if_t * enetIfPtr,void *paramPtr);
screamer 0:e4d670b91a9a 593
screamer 0:e4d670b91a9a 594 /*!
screamer 0:e4d670b91a9a 595 * @brief Provides the handler for the 1588 stack to do PTP IOCTL.
screamer 0:e4d670b91a9a 596 *
screamer 0:e4d670b91a9a 597 * @param enetIfPtr The ENET context structure.
screamer 0:e4d670b91a9a 598 * @param commandId The command id.
screamer 0:e4d670b91a9a 599 * @param inOutPtr The data buffer.
screamer 0:e4d670b91a9a 600 * @return The execution status.
screamer 0:e4d670b91a9a 601 */
screamer 0:e4d670b91a9a 602 uint32_t enet_ptp_ioctl(enet_dev_if_t * enetIfPtr, uint32_t commandId, void *inOutPtr);
screamer 0:e4d670b91a9a 603
screamer 0:e4d670b91a9a 604 /*!
screamer 0:e4d670b91a9a 605 * @brief Stops the ENET PTP timer.
screamer 0:e4d670b91a9a 606 *
screamer 0:e4d670b91a9a 607 * @param instance The ENET instance number.
screamer 0:e4d670b91a9a 608 * @return The execution status.
screamer 0:e4d670b91a9a 609 */
screamer 0:e4d670b91a9a 610 uint32_t enet_ptp_stop(uint32_t instance);
screamer 0:e4d670b91a9a 611
screamer 0:e4d670b91a9a 612 /*!
screamer 0:e4d670b91a9a 613 * @brief Checks whether the PTP ring buffer is full.
screamer 0:e4d670b91a9a 614 *
screamer 0:e4d670b91a9a 615 * @param ptpTsRingPtr The ENET PTP timestamp ring.
screamer 0:e4d670b91a9a 616 * @return True if the PTP ring buffer is full. Otherwise, false.
screamer 0:e4d670b91a9a 617 */
screamer 0:e4d670b91a9a 618 bool enet_ptp_ring_is_full(enet_mac_ptp_ts_ring_t *ptpTsRingPtr);
screamer 0:e4d670b91a9a 619
screamer 0:e4d670b91a9a 620 /*!
screamer 0:e4d670b91a9a 621 * @brief Updates the latest ring buffers.
screamer 0:e4d670b91a9a 622 *
screamer 0:e4d670b91a9a 623 * Adds the PTP message data to the PTP ring buffers and increases the
screamer 0:e4d670b91a9a 624 * PTP ring buffer index.
screamer 0:e4d670b91a9a 625 *
screamer 0:e4d670b91a9a 626 * @param ptpTsRingPtr The ENET PTP timestamp ring.
screamer 0:e4d670b91a9a 627 * @param data The PTP data buffer.
screamer 0:e4d670b91a9a 628 * @return The execution status.
screamer 0:e4d670b91a9a 629 */
screamer 0:e4d670b91a9a 630 uint32_t enet_ptp_ring_update(enet_mac_ptp_ts_ring_t *ptpTsRingPtr, enet_mac_ptp_ts_data_t *data);
screamer 0:e4d670b91a9a 631
screamer 0:e4d670b91a9a 632 /*!
screamer 0:e4d670b91a9a 633 * @brief Searches the element in ring buffers with the message ID and Clock ID.
screamer 0:e4d670b91a9a 634 *
screamer 0:e4d670b91a9a 635 * @param ptpTsRingPtr The ENET PTP timestamp ring.
screamer 0:e4d670b91a9a 636 * @param data The PTP data buffer.
screamer 0:e4d670b91a9a 637 * @return The execution status.
screamer 0:e4d670b91a9a 638 */
screamer 0:e4d670b91a9a 639 uint32_t enet_ptp_ring_search(enet_mac_ptp_ts_ring_t *ptpTsRingPtr, enet_mac_ptp_ts_data_t *data);
screamer 0:e4d670b91a9a 640
screamer 0:e4d670b91a9a 641 /*!
screamer 0:e4d670b91a9a 642 * @brief Calculates the ENET PTP ring buffer index.
screamer 0:e4d670b91a9a 643 *
screamer 0:e4d670b91a9a 644 * @param size The ring size.
screamer 0:e4d670b91a9a 645 * @param curIdx The current ring index.
screamer 0:e4d670b91a9a 646 * @param offset The offset index.
screamer 0:e4d670b91a9a 647 * @return The execution status.
screamer 0:e4d670b91a9a 648 */
screamer 0:e4d670b91a9a 649 static inline uint32_t enet_ptp_ring_index(uint32_t size, uint32_t curIdx, uint32_t offset)
screamer 0:e4d670b91a9a 650 {
screamer 0:e4d670b91a9a 651 return ((curIdx + offset) % size);
screamer 0:e4d670b91a9a 652 }
screamer 0:e4d670b91a9a 653
screamer 0:e4d670b91a9a 654 /*!
screamer 0:e4d670b91a9a 655 * @brief Frees all ring buffers.
screamer 0:e4d670b91a9a 656 *
screamer 0:e4d670b91a9a 657 * @param enetContextPtr The ENET MAC context buffer.
screamer 0:e4d670b91a9a 658 * @return The execution status.
screamer 0:e4d670b91a9a 659 */
screamer 0:e4d670b91a9a 660 uint32_t enet_ptp_deinit(enet_mac_context_t *enetContextPtr);
screamer 0:e4d670b91a9a 661
screamer 0:e4d670b91a9a 662 /*!
screamer 0:e4d670b91a9a 663 * @brief The ENET PTP time interrupt handler.
screamer 0:e4d670b91a9a 664 *
screamer 0:e4d670b91a9a 665 * @param enetIfPtr The ENET context structure pointer.
screamer 0:e4d670b91a9a 666 */
screamer 0:e4d670b91a9a 667 void enet_mac_ts_isr(void *enetIfPtr);
screamer 0:e4d670b91a9a 668 #endif
screamer 0:e4d670b91a9a 669 /*!
screamer 0:e4d670b91a9a 670 * @brief(R)MII Read function.
screamer 0:e4d670b91a9a 671 *
screamer 0:e4d670b91a9a 672 * @param instance The ENET instance number.
screamer 0:e4d670b91a9a 673 * @param phyAddr The PHY address.
screamer 0:e4d670b91a9a 674 * @param phyReg The PHY register.
screamer 0:e4d670b91a9a 675 * @param dataPtr The data read from MII.
screamer 0:e4d670b91a9a 676 * @return The execution status.
screamer 0:e4d670b91a9a 677 */
screamer 0:e4d670b91a9a 678 uint32_t enet_mii_read(uint32_t instance, uint32_t phyAddr, uint32_t phyReg, uint32_t *dataPtr);
screamer 0:e4d670b91a9a 679
screamer 0:e4d670b91a9a 680 /*!
screamer 0:e4d670b91a9a 681 * @brief(R)MII Read function.
screamer 0:e4d670b91a9a 682 *
screamer 0:e4d670b91a9a 683 * @param instance The ENET instance number.
screamer 0:e4d670b91a9a 684 * @param phyAddr The PHY address.
screamer 0:e4d670b91a9a 685 * @param phyReg The PHY register.
screamer 0:e4d670b91a9a 686 * @param data The data write to MII.
screamer 0:e4d670b91a9a 687 * @return The execution status.
screamer 0:e4d670b91a9a 688 */
screamer 0:e4d670b91a9a 689 uint32_t enet_mii_write(uint32_t instance, uint32_t phyAddr, uint32_t phyReg, uint32_t data);
screamer 0:e4d670b91a9a 690
screamer 0:e4d670b91a9a 691 /*!
screamer 0:e4d670b91a9a 692 * @brief Initializes ENET buffer descriptors.
screamer 0:e4d670b91a9a 693 *
screamer 0:e4d670b91a9a 694 * @param enetIfPtr The ENET context structure.
screamer 0:e4d670b91a9a 695 * @return The execution status.
screamer 0:e4d670b91a9a 696 */
screamer 0:e4d670b91a9a 697 uint32_t enet_mac_bd_init(enet_dev_if_t * enetIfPtr);
screamer 0:e4d670b91a9a 698
screamer 0:e4d670b91a9a 699 /*!
screamer 0:e4d670b91a9a 700 * @brief Initializes the ENET MAC MII(MDC/MDIO) interface.
screamer 0:e4d670b91a9a 701 *
screamer 0:e4d670b91a9a 702 * @param enetIfPtr The ENET context structure.
screamer 0:e4d670b91a9a 703 * @return The execution status.
screamer 0:e4d670b91a9a 704 */
screamer 0:e4d670b91a9a 705 uint32_t enet_mac_mii_init(enet_dev_if_t * enetIfPtr);
screamer 0:e4d670b91a9a 706
screamer 0:e4d670b91a9a 707 /*!
screamer 0:e4d670b91a9a 708 * @brief Initialize the ENET receive buffer descriptors.
screamer 0:e4d670b91a9a 709 *
screamer 0:e4d670b91a9a 710 * If you open ENET_RECEIVE_ALL_INTERRUPT to do receive
screamer 0:e4d670b91a9a 711 * data buffer numbers can be the same as the receive descriptor numbers.
screamer 0:e4d670b91a9a 712 * But if you close ENET_RECEIVE_ALL_INTERRUPT and choose polling receive
screamer 0:e4d670b91a9a 713 * frames please make sure the receive data buffers are more than
screamer 0:e4d670b91a9a 714 * buffer descriptor numbers to guarantee a good performance.
screamer 0:e4d670b91a9a 715 *
screamer 0:e4d670b91a9a 716 * @param enetIfPtr The ENET context structure.
screamer 0:e4d670b91a9a 717 * @param rxbdCfg The receive buffer descriptor configuration.
screamer 0:e4d670b91a9a 718 * @return The execution status.
screamer 0:e4d670b91a9a 719 */
screamer 0:e4d670b91a9a 720 uint32_t enet_mac_rxbd_init(enet_dev_if_t * enetIfPtr, enet_rxbd_config_t *rxbdCfg);
screamer 0:e4d670b91a9a 721
screamer 0:e4d670b91a9a 722 /*!
screamer 0:e4d670b91a9a 723 * @brief Deinitialize the ENET receive buffer descriptors.
screamer 0:e4d670b91a9a 724 *
screamer 0:e4d670b91a9a 725 * Deinitialize the ENET receive buffer descriptors.
screamer 0:e4d670b91a9a 726 *
screamer 0:e4d670b91a9a 727 * @param enetIfPtr The ENET context structure.
screamer 0:e4d670b91a9a 728 * @return The execution status.
screamer 0:e4d670b91a9a 729 */
screamer 0:e4d670b91a9a 730
screamer 0:e4d670b91a9a 731 uint32_t enet_mac_rxbd_deinit(enet_dev_if_t * enetIfPtr);
screamer 0:e4d670b91a9a 732
screamer 0:e4d670b91a9a 733 /*!
screamer 0:e4d670b91a9a 734 * @brief Initialize the ENET transmit buffer descriptors.
screamer 0:e4d670b91a9a 735 *
screamer 0:e4d670b91a9a 736 * @param enetIfPtr The ENET context structure.
screamer 0:e4d670b91a9a 737 * @param txbdCfg The transmit buffer descriptor configuration.
screamer 0:e4d670b91a9a 738 * @return The execution status.
screamer 0:e4d670b91a9a 739 */
screamer 0:e4d670b91a9a 740 uint32_t enet_mac_txbd_init(enet_dev_if_t * enetIfPtr, enet_txbd_config_t *txbdCfg);
screamer 0:e4d670b91a9a 741
screamer 0:e4d670b91a9a 742 /*!
screamer 0:e4d670b91a9a 743 * @brief Deinitialize the ENET transmit buffer descriptors.
screamer 0:e4d670b91a9a 744 *
screamer 0:e4d670b91a9a 745 * Deinitialize the ENET transmit buffer descriptors.
screamer 0:e4d670b91a9a 746 *
screamer 0:e4d670b91a9a 747 * @param enetIfPtr The ENET context structure.
screamer 0:e4d670b91a9a 748 * @return The execution status.
screamer 0:e4d670b91a9a 749 */
screamer 0:e4d670b91a9a 750 uint32_t enet_mac_txbd_deinit(enet_dev_if_t * enetIfPtr);
screamer 0:e4d670b91a9a 751
screamer 0:e4d670b91a9a 752 /*!
screamer 0:e4d670b91a9a 753 * @brief Initializes ENET MAC FIFO and accelerator with the basic configuration.
screamer 0:e4d670b91a9a 754 *
screamer 0:e4d670b91a9a 755 * @param enetIfPtr The ENET context structure.
screamer 0:e4d670b91a9a 756 * @return The execution status.
screamer 0:e4d670b91a9a 757 */
screamer 0:e4d670b91a9a 758 uint32_t enet_mac_configure_fifo_accel(enet_dev_if_t * enetIfPtr);
screamer 0:e4d670b91a9a 759
screamer 0:e4d670b91a9a 760 /*!
screamer 0:e4d670b91a9a 761 * @brief the ENET controller with the basic configuration.
screamer 0:e4d670b91a9a 762 *
screamer 0:e4d670b91a9a 763 * @param enetIfPtr The ENET context structure.
screamer 0:e4d670b91a9a 764 * @return The execution status.
screamer 0:e4d670b91a9a 765 */
screamer 0:e4d670b91a9a 766 uint32_t enet_mac_configure_controller(enet_dev_if_t * enetIfPtr);
screamer 0:e4d670b91a9a 767
screamer 0:e4d670b91a9a 768 /*!
screamer 0:e4d670b91a9a 769 * @brief Deinit the ENET device.
screamer 0:e4d670b91a9a 770 *
screamer 0:e4d670b91a9a 771 * @param enetIfPtr The ENET context structure.
screamer 0:e4d670b91a9a 772 * @return The execution status.
screamer 0:e4d670b91a9a 773 */
screamer 0:e4d670b91a9a 774 uint32_t enet_mac_deinit(enet_dev_if_t * enetIfPtr);
screamer 0:e4d670b91a9a 775
screamer 0:e4d670b91a9a 776 #if !ENET_RECEIVE_ALL_INTERRUPT
screamer 0:e4d670b91a9a 777 /*!
screamer 0:e4d670b91a9a 778 * @brief Updates the receive buffer descriptor.
screamer 0:e4d670b91a9a 779 *
screamer 0:e4d670b91a9a 780 * This updates the used receive buffer descriptor ring to
screamer 0:e4d670b91a9a 781 * ensure that the used BDS is correctly used again. It cleans
screamer 0:e4d670b91a9a 782 * the status region and sets the control region of the used receive buffer
screamer 0:e4d670b91a9a 783 * descriptor. If the isBufferUpdate flag is set, the data buffer in the
screamer 0:e4d670b91a9a 784 * buffer descriptor is updated.
screamer 0:e4d670b91a9a 785 *
screamer 0:e4d670b91a9a 786 * @param enetIfPtr The ENET context structure.
screamer 0:e4d670b91a9a 787 * @param isBufferUpdate The data buffer update flag.
screamer 0:e4d670b91a9a 788 * @return The execution status.
screamer 0:e4d670b91a9a 789 */
screamer 0:e4d670b91a9a 790 uint32_t enet_mac_update_rxbd(enet_dev_if_t * enetIfPtr, bool isBufferUpdate);
screamer 0:e4d670b91a9a 791 #else
screamer 0:e4d670b91a9a 792 /*!
screamer 0:e4d670b91a9a 793 * @brief Updates the receive buffer descriptor.
screamer 0:e4d670b91a9a 794 *
screamer 0:e4d670b91a9a 795 * Clears the status region and sets the control region of the current receive buffer
screamer 0:e4d670b91a9a 796 * descriptor to ensure that it is used correctly again. It increases the buffer
screamer 0:e4d670b91a9a 797 * descriptor index to the next buffer descriptor.
screamer 0:e4d670b91a9a 798 *
screamer 0:e4d670b91a9a 799 * @param enetIfPtr The ENET context structure.
screamer 0:e4d670b91a9a 800 * @return The execution status.
screamer 0:e4d670b91a9a 801 */
screamer 0:e4d670b91a9a 802 uint32_t enet_mac_update_rxbd(enet_dev_if_t * enetIfPtr);
screamer 0:e4d670b91a9a 803 #endif
screamer 0:e4d670b91a9a 804 /*!
screamer 0:e4d670b91a9a 805 * @brief Processes the ENET receive frame error statistics.
screamer 0:e4d670b91a9a 806 *
screamer 0:e4d670b91a9a 807 * This interface gets the error statistics of the received frame.
screamer 0:e4d670b91a9a 808 * Because the error information is in the last BD of a frame, this interface
screamer 0:e4d670b91a9a 809 * should be called when processing the last BD of a frame.
screamer 0:e4d670b91a9a 810 *
screamer 0:e4d670b91a9a 811 * @param enetIfPtr The ENET context structure.
screamer 0:e4d670b91a9a 812 * @param data The current control and status data of the buffer descriptor.
screamer 0:e4d670b91a9a 813 * @return The frame error status.
screamer 0:e4d670b91a9a 814 * - True if the frame has an error.
screamer 0:e4d670b91a9a 815 * - False if the frame does not have an error.
screamer 0:e4d670b91a9a 816 */
screamer 0:e4d670b91a9a 817 bool enet_mac_rx_error_stats(enet_dev_if_t * enetIfPtr, uint32_t data);
screamer 0:e4d670b91a9a 818
screamer 0:e4d670b91a9a 819 /*!
screamer 0:e4d670b91a9a 820 * @brief Processes the ENET transmit frame statistics.
screamer 0:e4d670b91a9a 821 *
screamer 0:e4d670b91a9a 822 * This interface gets the error statistics of the transmit frame.
screamer 0:e4d670b91a9a 823 * Because the error information is in the last BD of a frame, this interface
screamer 0:e4d670b91a9a 824 * should be called when processing the last BD of a frame.
screamer 0:e4d670b91a9a 825 *
screamer 0:e4d670b91a9a 826 * @param enetIfPtr The ENET context structure.
screamer 0:e4d670b91a9a 827 * @param curBd The current buffer descriptor.
screamer 0:e4d670b91a9a 828 */
screamer 0:e4d670b91a9a 829 void enet_mac_tx_error_stats(enet_dev_if_t * enetIfPtr,void *curBd);
screamer 0:e4d670b91a9a 830
screamer 0:e4d670b91a9a 831 /*!
screamer 0:e4d670b91a9a 832 * @brief ENET transmit buffer descriptor cleanup.
screamer 0:e4d670b91a9a 833 *
screamer 0:e4d670b91a9a 834 * First, store the transmit frame error statistic and PTP timestamp of the transmitted packets.
screamer 0:e4d670b91a9a 835 * Second, clean up the used transmit buffer descriptors.
screamer 0:e4d670b91a9a 836 * If the PTP 1588 feature is open, this interface captures the 1588 timestamp.
screamer 0:e4d670b91a9a 837 * It is called by the transmit interrupt handler.
screamer 0:e4d670b91a9a 838 *
screamer 0:e4d670b91a9a 839 * @param enetIfPtr The ENET context structure.
screamer 0:e4d670b91a9a 840 * @return The execution status.
screamer 0:e4d670b91a9a 841 */
screamer 0:e4d670b91a9a 842 uint32_t enet_mac_tx_cleanup(enet_dev_if_t * enetIfPtr);
screamer 0:e4d670b91a9a 843 #if !ENET_RECEIVE_ALL_INTERRUPT
screamer 0:e4d670b91a9a 844 /*!
screamer 0:e4d670b91a9a 845 * @brief Receives ENET packets.
screamer 0:e4d670b91a9a 846 *
screamer 0:e4d670b91a9a 847 * @param enetIfPtr The ENET context structure.
screamer 0:e4d670b91a9a 848 * @param packBuffer The received data buffer.
screamer 0:e4d670b91a9a 849 * @return The execution status.
screamer 0:e4d670b91a9a 850 */
screamer 0:e4d670b91a9a 851 uint32_t enet_mac_receive(enet_dev_if_t * enetIfPtr, enet_mac_packet_buffer_t *packBuffer);
screamer 0:e4d670b91a9a 852 #else
screamer 0:e4d670b91a9a 853 /*!
screamer 0:e4d670b91a9a 854 * @brief Receives ENET packets.
screamer 0:e4d670b91a9a 855 *
screamer 0:e4d670b91a9a 856 * @param enetIfPtr The ENET context structure.
screamer 0:e4d670b91a9a 857 * @return The execution status.
screamer 0:e4d670b91a9a 858 */
screamer 0:e4d670b91a9a 859 uint32_t enet_mac_receive(enet_dev_if_t * enetIfPtr);
screamer 0:e4d670b91a9a 860 #endif
screamer 0:e4d670b91a9a 861 /*!
screamer 0:e4d670b91a9a 862 * @brief Transmits ENET packets.
screamer 0:e4d670b91a9a 863 *
screamer 0:e4d670b91a9a 864 * @param enetIfPtr The ENET context structure.
screamer 0:e4d670b91a9a 865 * @param packet The frame to be transmitted.
screamer 0:e4d670b91a9a 866 * @param size The frame size.
screamer 0:e4d670b91a9a 867 * @return The execution status.
screamer 0:e4d670b91a9a 868 */
screamer 0:e4d670b91a9a 869 uint32_t enet_mac_send(enet_dev_if_t * enetIfPtr, uint8_t *packet, uint32_t size);
screamer 0:e4d670b91a9a 870
screamer 0:e4d670b91a9a 871 /*!
screamer 0:e4d670b91a9a 872 * @brief The ENET receive interrupt handler.
screamer 0:e4d670b91a9a 873 *
screamer 0:e4d670b91a9a 874 * @param enetIfPtr The ENET context structure pointer.
screamer 0:e4d670b91a9a 875 */
screamer 0:e4d670b91a9a 876 void enet_mac_rx_isr(void *enetIfPtr);
screamer 0:e4d670b91a9a 877
screamer 0:e4d670b91a9a 878 /*!
screamer 0:e4d670b91a9a 879 * @brief The ENET transmit interrupt handler.
screamer 0:e4d670b91a9a 880 *
screamer 0:e4d670b91a9a 881 * @param enetIfPtr The ENET context structure pointer.
screamer 0:e4d670b91a9a 882 */
screamer 0:e4d670b91a9a 883 void enet_mac_tx_isr(void *enetIfPtr);
screamer 0:e4d670b91a9a 884
screamer 0:e4d670b91a9a 885 /*!
screamer 0:e4d670b91a9a 886 * @brief Calculates the CRC hash value.
screamer 0:e4d670b91a9a 887 *
screamer 0:e4d670b91a9a 888 * @param address The ENET MAC hardware address.
screamer 0:e4d670b91a9a 889 * @param crcVlaue The calculated CRC value of the Mac address.
screamer 0:e4d670b91a9a 890 */
screamer 0:e4d670b91a9a 891 void enet_mac_calculate_crc32(enetMacAddr address, uint32_t *crcValue);
screamer 0:e4d670b91a9a 892
screamer 0:e4d670b91a9a 893 /*!
screamer 0:e4d670b91a9a 894 * @brief Adds the ENET device to a multicast group.
screamer 0:e4d670b91a9a 895 *
screamer 0:e4d670b91a9a 896 * @param instance The ENET instance number.
screamer 0:e4d670b91a9a 897 * @param multiGroupPtr The ENET multicast group structure.
screamer 0:e4d670b91a9a 898 * @param address The ENET MAC hardware address.
screamer 0:e4d670b91a9a 899 * @return The execution status.
screamer 0:e4d670b91a9a 900 */
screamer 0:e4d670b91a9a 901 uint32_t enet_mac_add_multicast_group(uint32_t instance, enet_multicast_group_t *multiGroupPtr, enetMacAddr address);
screamer 0:e4d670b91a9a 902
screamer 0:e4d670b91a9a 903 /*!
screamer 0:e4d670b91a9a 904 * @brief Moves the ENET device from a multicast group.
screamer 0:e4d670b91a9a 905 *
screamer 0:e4d670b91a9a 906 * @param instance The ENET instance number.
screamer 0:e4d670b91a9a 907 * @param multiGroupPtr The ENET multicast group structure.
screamer 0:e4d670b91a9a 908 * @param address The ENET MAC hardware address.
screamer 0:e4d670b91a9a 909 * @return The execution status.
screamer 0:e4d670b91a9a 910 */
screamer 0:e4d670b91a9a 911 uint32_t enet_mac_leave_multicast_group(uint32_t instance, enet_multicast_group_t *multiGroupPtr, enetMacAddr address);
screamer 0:e4d670b91a9a 912
screamer 0:e4d670b91a9a 913 /*!
screamer 0:e4d670b91a9a 914 * @brief Initializes the ENET with the basic configuration.
screamer 0:e4d670b91a9a 915 *
screamer 0:e4d670b91a9a 916 * @param enetIfPtr The pointer to the basic configuration structure.
screamer 0:e4d670b91a9a 917 * @return The execution status.
screamer 0:e4d670b91a9a 918 */
screamer 0:e4d670b91a9a 919 uint32_t enet_mac_init(enet_dev_if_t * enetIfPtr, enet_rxbd_config_t *rxbdCfg,
screamer 0:e4d670b91a9a 920 enet_txbd_config_t *txbdCfg);
screamer 0:e4d670b91a9a 921
screamer 0:e4d670b91a9a 922 /*!
screamer 0:e4d670b91a9a 923 * @brief Enqueues a data buffer to the buffer queue.
screamer 0:e4d670b91a9a 924 *
screamer 0:e4d670b91a9a 925 * @param queue The buffer queue.
screamer 0:e4d670b91a9a 926 * @param buffer The buffer to add to the buffer queue.
screamer 0:e4d670b91a9a 927 */
screamer 0:e4d670b91a9a 928 void enet_mac_enqueue_buffer( void **queue, void *buffer);
screamer 0:e4d670b91a9a 929
screamer 0:e4d670b91a9a 930 /*!
screamer 0:e4d670b91a9a 931 * @brief Dequeues a buffer from the buffer queue.
screamer 0:e4d670b91a9a 932 *
screamer 0:e4d670b91a9a 933 * @param queue The buffer queue.
screamer 0:e4d670b91a9a 934 * @return The dequeued data buffer.
screamer 0:e4d670b91a9a 935 */
screamer 0:e4d670b91a9a 936 void *enet_mac_dequeue_buffer( void **queue);
screamer 0:e4d670b91a9a 937
screamer 0:e4d670b91a9a 938 /* @} */
screamer 0:e4d670b91a9a 939
screamer 0:e4d670b91a9a 940 #if defined(__cplusplus)
screamer 0:e4d670b91a9a 941 }
screamer 0:e4d670b91a9a 942 #endif
screamer 0:e4d670b91a9a 943
screamer 0:e4d670b91a9a 944 #endif
screamer 0:e4d670b91a9a 945
screamer 0:e4d670b91a9a 946 /*! @}*/
screamer 0:e4d670b91a9a 947
screamer 0:e4d670b91a9a 948 #endif /* __FSL_ENET_DRIVER_H__ */
screamer 0:e4d670b91a9a 949 /*******************************************************************************
screamer 0:e4d670b91a9a 950 * EOF
screamer 0:e4d670b91a9a 951 ******************************************************************************/
screamer 0:e4d670b91a9a 952