AM243x INDUSTRIAL COMMUNICATIONS SDK  09.02.00
icss_eip_driver.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 Texas Instruments Incorporated
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 #ifndef ICSS_EIP_DRIVER_H_
33 #define ICSS_EIP_DRIVER_H_
34 
35 #ifdef __cplusplus
36 extern "C"
37 {
38 #endif
39 
40 
41 /* ========================================================================== */
42 /* Doxygen */
43 /* ========================================================================== */
44 
65 /* ========================================================================== */
66 /* Include Files */
67 /* ========================================================================== */
68 #include <stdint.h>
69 #include "icss_dlr.h"
71 
72 /* ========================================================================== */
73 /* Macros & Typedefs */
74 /* ========================================================================== */
75 /*Use compare reg 4*/
76 #define IEP_CMP_DEFAULT_VAL 0x11
77 #define IEP_CMP4_DEFAULT_VAL 0x5000
78 #define IEP_CMP0_DEFAULT_VAL 0xffffffff
79 
81 #define PRU_IEP_CMP_CFG_REG 0x40
82 /*Compare 0 register*/
83 #define PRU_IEP_CMP0_REG 0x48
84 
86 #define EIP_TICK_PERIOD 1 /*in milliseconds*/
87 #define LOOPBK_PKT_SEND_PERIOD 1000
88 
89 #define DEFAULT_BC_PKT_SIZE 60
90 
91 #define ONE_SECOND_INTERVAL 1000 /*in milliseconds*/
92 #define TWO_MINUTE_INTERVAL 120000 /*in milliseconds*/
93 
95 #define CRS_STATUS_MASK 0x2
96 
97 #define CRS_STATUS_SHIFT 0x1
98 
100 #define PTP_PROT_TYPE 0x88F7
101 #define DLR_MDIO_PHY0 1
102 #define DLR_MDIO_PHY1 2
103 
104 /*DLR port 0 Interrupt*/
105 #define PHYBMSR_OFFSET 0x1
106 #define PHYSTS_OFFSET 0x10
107 
108 #define PHY_LINK_STATUS_MASK 0x4
109 #define PHY_LINK_STATUS_SHIFT 0x2
110 
111 /* LLDP forwarding enabled offset */
112 /* 1 byte in order to check if LLDP forwarding to other port is enabeld or not */
113 #define LLDP_FORWARDING_ENABLED_OFFSET (0x2018U)
114 
115 typedef struct eip_Config_s *EIP_Handle;
116 
120 typedef enum
121 {
127  BOUNDARY_CLOCK = 2
128 
130 
131 /* ========================================================================== */
132 /* Structure Declarations */
133 /* ========================================================================== */
134 
138 typedef struct
139 {
141  uint8_t clockIdentity[8];
143  uint16_t clockClass;
145  uint16_t timeAccuracy;
157  uint16_t timeSource;
158 
162 
166 
167 } clockClass_t;
168 
172 typedef struct
173 {
175  uint32_t size;
177  uint8_t descr[32];
178 } descr_t;
179 
183 typedef struct
184 {
185  uint8_t portProfileIdentity[8];
187 
193 typedef struct
194 {
195  uint8_t physicalProtocol[16];
196  uint16_t sizeOfAddress;
197  uint8_t portPhysicalAddress[16];
199 
204 typedef struct
205 {
206  uint16_t portNumber;
207  uint16_t networkProtocol;
208  uint16_t addressSize;
209  uint8_t portProtocolAddress[16];
211 
216 typedef struct
217 {
218  uint64_t systemTime;
219  uint64_t systemOffset;
221 
226 typedef struct
227 {
229  uint8_t ifPTPEnable;
231  uint8_t IsSynchronized;
249  uint16_t numberOfPorts;
251  /*TODO: Review ICSS_EMAC_MAX_PORTS_PER_INSTANCE -> ICSS_EMAC_MAX_PORTS_PER_INSTANCE*/
254  uint16_t portEnable[ICSS_EMAC_MAX_PORTS_PER_INSTANCE];
257  uint16_t portLogAnnounceInterval[ICSS_EMAC_MAX_PORTS_PER_INSTANCE];
260  uint16_t portLogSyncInterval[ICSS_EMAC_MAX_PORTS_PER_INSTANCE];
261 
264  uint8_t priority1;
266  uint8_t priority2;
267 
269  uint8_t domainNumber;
273  uint8_t manufacturerIdentity[4];
280 
287 
290  uint16_t stepsRemoved;
293 
295 
296 /*
297 * \brief EIP Config
298 * Structure storing the EIP info
299 */
300 typedef struct eip_Config_s
301 {
302  PRUICSS_Handle pruicssHandle;
307  uint8_t tempFrame[ICSS_EMAC_MAXMTU];
309 } eip_Config;
310 
311 /* ========================================================================== */
312 /* Function Declarations */
313 /* ========================================================================== */
314 
329 void EIP_drvInit(EIP_Handle icssEipHandle);
338 void EIP_drvStop(EIP_Handle icssEipHandle);
347 void EIP_drvStart(EIP_Handle icssEipHandle);
359 void EIP_processProtocolFrames(uint32_t *queue_number, void *userArg);
360 
371 int8_t EIP_initializeCIPSync(EIP_Handle icssEipHandle);
372 
385 int32_t EIP_configureLLDPForwarding(EIP_Handle icssEipHandle, uint8_t enableFeature);
386 
397 int32_t EIP_configureLLDPFwdHelper(uint32_t pruBaseAddress, uint8_t val);
398 
406 #ifdef __cplusplus
407 }
408 #endif
409 
410 #endif /* ICSS_EIP_DRIVER_H_ */
clockType
clockType
Type of clock supported by PTP Implementation. This is not specified by standard.
Definition: icss_eip_driver.h:121
clockClass_t::currentUTCOffset
uint16_t currentUTCOffset
Definition: icss_eip_driver.h:153
portProtAddr_t::networkProtocol
uint16_t networkProtocol
Definition: icss_eip_driver.h:207
eip_Config::timeSyncHandle
TimeSync_ParamsHandle_t timeSyncHandle
Definition: icss_eip_driver.h:304
ICSS_EMAC_Handle
struct ICSS_EMAC_Config_s * ICSS_EMAC_Handle
Alias for ICSS EMAC Handle containing base addresses and modules.
Definition: icss_emac.h:467
portProtAddr_t::portNumber
uint16_t portNumber
Definition: icss_eip_driver.h:206
port_State
port_State
Port States, from IEEE 1588v2.
Definition: icss_timeSyncApi.h:142
cipSyncConfig_t::parentClkInfo
clockClass_t parentClkInfo
Definition: icss_eip_driver.h:245
cipSyncConfig_t::timeOffset
sysTimeOffset_t timeOffset
Definition: icss_eip_driver.h:292
EIP_drvInit
void EIP_drvInit(EIP_Handle icssEipHandle)
Initialization routine for Ethernet/IP driver functions.
EIP_DLRHandle
struct dlr_Config_s * EIP_DLRHandle
Definition: icss_dlr.h:208
eip_Config::pruicssHandle
PRUICSS_Handle pruicssHandle
Definition: icss_eip_driver.h:302
EIP_Handle
struct eip_Config_s * EIP_Handle
Definition: icss_eip_driver.h:115
cipSyncConfig_t
CIP Sync configuration. Instance Attribute for PTP Class (Class Code 0x43. CIP Spec Vol 1)
Definition: icss_eip_driver.h:227
cipSyncConfig_t::numberOfPorts
uint16_t numberOfPorts
Definition: icss_eip_driver.h:249
sysTimeOffset_t::systemOffset
uint64_t systemOffset
Definition: icss_eip_driver.h:219
cipSyncConfig_t::domainNumber
uint8_t domainNumber
Definition: icss_eip_driver.h:269
portPhysAddr_t
Specifies the physical protocol and physical address (e.g. IEEE 802.3) of each port of the device (e....
Definition: icss_eip_driver.h:194
EIP_initializeCIPSync
int8_t EIP_initializeCIPSync(EIP_Handle icssEipHandle)
API to initialize the CIP Sync objects in the EIP handle Initialize CIP Sync member variables based o...
descr_t::size
uint32_t size
Definition: icss_eip_driver.h:175
eip_Config
Definition: icss_eip_driver.h:301
clockClass_t::observedOffsetScaledLogVariance
uint16_t observedOffsetScaledLogVariance
Definition: icss_eip_driver.h:161
EIP_drvStart
void EIP_drvStart(EIP_Handle icssEipHandle)
EIP driver start API.
portPhysAddr_t::sizeOfAddress
uint16_t sizeOfAddress
Definition: icss_eip_driver.h:196
cipSyncConfig_t::meanPathDelayToMaster
int64_t meanPathDelayToMaster
Definition: icss_eip_driver.h:241
EIP_drvStop
void EIP_drvStop(EIP_Handle icssEipHandle)
EIP driver stop API.
clockClass_t::timeAccuracy
uint16_t timeAccuracy
Definition: icss_eip_driver.h:145
clockClass_t::offsetScaledLogVariance
uint16_t offsetScaledLogVariance
Definition: icss_eip_driver.h:148
cipSyncConfig_t::revData
descr_t revData
Definition: icss_eip_driver.h:277
cipSyncConfig_t::localClkInfo
clockClass_t localClkInfo
Definition: icss_eip_driver.h:247
clockClass_t::timeSource
uint16_t timeSource
Definition: icss_eip_driver.h:157
ICSS_EMAC_MAXMTU
#define ICSS_EMAC_MAXMTU
Maximum Valid size (incl header + VLAN TAG..., no CRC)
Definition: icss_emac.h:261
clockClass_t::timePropertyFlags
uint16_t timePropertyFlags
Definition: icss_eip_driver.h:155
BOUNDARY_CLOCK
@ BOUNDARY_CLOCK
Definition: icss_eip_driver.h:127
cipSyncConfig_t::IsSynchronized
uint8_t IsSynchronized
Definition: icss_eip_driver.h:231
EIP_processProtocolFrames
void EIP_processProtocolFrames(uint32_t *queue_number, void *userArg)
API to process the real time Packets.
cipSyncConfig_t::systemTimeMicrosec
uint64_t systemTimeMicrosec
Definition: icss_eip_driver.h:233
cipSyncConfig_t::grandMasterClkInfo
clockClass_t grandMasterClkInfo
Definition: icss_eip_driver.h:243
TRANSPARENT_CLOCK
@ TRANSPARENT_CLOCK
Definition: icss_eip_driver.h:125
eip_Config::emacHandle
ICSS_EMAC_Handle emacHandle
Definition: icss_eip_driver.h:303
cipSyncConfig_t::systemTimeNanosec
uint64_t systemTimeNanosec
Definition: icss_eip_driver.h:235
cipSyncConfig_t::maxOffsetFromMaster
uint64_t maxOffsetFromMaster
Definition: icss_eip_driver.h:239
cipSyncConfig_t::priority2
uint8_t priority2
Definition: icss_eip_driver.h:266
clockClass_t
Specifies the properties of a clock.
Definition: icss_eip_driver.h:139
eip_Config::dlrHandle
EIP_DLRHandle dlrHandle
Definition: icss_eip_driver.h:308
cipSyncConfig_t::ifPTPEnable
uint8_t ifPTPEnable
Definition: icss_eip_driver.h:229
sysTimeOffset_t
Specifies the system time in microseconds and the Offset to the local clock value.
Definition: icss_eip_driver.h:217
cipSyncConfig_t::clockType
clockType clockType
Definition: icss_eip_driver.h:271
sysTimeOffset_t::systemTime
uint64_t systemTime
Definition: icss_eip_driver.h:218
clockClass_t::clockClass
uint16_t clockClass
Definition: icss_eip_driver.h:143
eip_Config::cipSyncObj
cipSyncConfig_t cipSyncObj
Definition: icss_eip_driver.h:305
descr_t
Description in unicode.
Definition: icss_eip_driver.h:173
clockClass_t::observedPhaseChangeRate
uint16_t observedPhaseChangeRate
Definition: icss_eip_driver.h:165
cipSyncConfig_t::userDesc
descr_t userDesc
Definition: icss_eip_driver.h:279
portProtAddr_t::addressSize
uint16_t addressSize
Definition: icss_eip_driver.h:208
cipSyncConfig_t::priority1
uint8_t priority1
Definition: icss_eip_driver.h:264
icss_timeSyncApi.h
ORDINARY_CLOCK
@ ORDINARY_CLOCK
Definition: icss_eip_driver.h:123
EIP_configureLLDPFwdHelper
int32_t EIP_configureLLDPFwdHelper(uint32_t pruBaseAddress, uint8_t val)
API to configure the value stored at the required offset in ICSS SMEM.
cipSyncConfig_t::productType
descr_t productType
Definition: icss_eip_driver.h:275
portProtAddr_t
Specifies the specifies the network and protocol address of each port of the device (e....
Definition: icss_eip_driver.h:205
icss_dlr.h
TimeSync_ParamsHandle_t
struct TimeSync_ParamsHandle_s * TimeSync_ParamsHandle_t
Definition: icss_timeSyncApi.h:962
portProfileIdentity_t
Specifies the PTP profile of each port of the device.
Definition: icss_eip_driver.h:184
EIP_configureLLDPForwarding
int32_t EIP_configureLLDPForwarding(EIP_Handle icssEipHandle, uint8_t enableFeature)
API to configure the LLDP forwarding to the other port.
cipSyncConfig_t::stepsRemoved
uint16_t stepsRemoved
Definition: icss_eip_driver.h:290
cipSyncConfig_t::offsetFromMaster
int64_t offsetFromMaster
Definition: icss_eip_driver.h:237
ICSS_EMAC_MAX_PORTS_PER_INSTANCE
#define ICSS_EMAC_MAX_PORTS_PER_INSTANCE
Maximum number of Ports in a single ICSS
Definition: icss_emac.h:66