AM263Px INDUSTRIAL COMMUNICATIONS SDK  10.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 
70 /* ========================================================================== */
71 /* Include Files */
72 /* ========================================================================== */
73 #include <stdint.h>
74 #include "icss_dlr.h"
76 
77 /* ========================================================================== */
78 /* Macros & Typedefs */
79 /* ========================================================================== */
80 /*Use compare reg 4*/
81 #define IEP_CMP_DEFAULT_VAL 0x11
82 #define IEP_CMP4_DEFAULT_VAL 0x5000
83 #define IEP_CMP0_DEFAULT_VAL 0xffffffff
84 
86 #define PRU_IEP_CMP_CFG_REG 0x40
87 /*Compare 0 register*/
88 #define PRU_IEP_CMP0_REG 0x48
89 
91 #define EIP_TICK_PERIOD 1 /*in milliseconds*/
92 #define LOOPBK_PKT_SEND_PERIOD 1000
93 
94 #define DEFAULT_BC_PKT_SIZE 60
95 
96 #define ONE_SECOND_INTERVAL 1000 /*in milliseconds*/
97 #define TWO_MINUTE_INTERVAL 120000 /*in milliseconds*/
98 
100 #define CRS_STATUS_MASK 0x2
101 
102 #define CRS_STATUS_SHIFT 0x1
103 
105 #define PTP_PROT_TYPE 0x88F7
106 #define DLR_MDIO_PHY0 1
107 #define DLR_MDIO_PHY1 2
108 
109 /*DLR port 0 Interrupt*/
110 #define PHYBMSR_OFFSET 0x1
111 #define PHYSTS_OFFSET 0x10
112 
113 #define PHY_LINK_STATUS_MASK 0x4
114 #define PHY_LINK_STATUS_SHIFT 0x2
115 
116 /* LLDP forwarding enabled offset */
117 /* 1 byte in order to check if LLDP forwarding to other port is enabeld or not */
118 #define LLDP_FORWARDING_ENABLED_OFFSET (0x2018U)
119 
120 typedef struct eip_Config_s *EIP_Handle;
121 
125 typedef enum
126 {
132  BOUNDARY_CLOCK = 2
133 
135 
136 /* ========================================================================== */
137 /* Structure Declarations */
138 /* ========================================================================== */
139 
143 typedef struct
144 {
146  uint8_t clockIdentity[8];
148  uint16_t clockClass;
150  uint16_t timeAccuracy;
162  uint16_t timeSource;
163 
167 
171 
172 } clockClass_t;
173 
177 typedef struct
178 {
180  uint32_t size;
182  uint8_t descr[32];
183 } descr_t;
184 
188 typedef struct
189 {
190  uint8_t portProfileIdentity[8];
192 
198 typedef struct
199 {
200  uint8_t physicalProtocol[16];
201  uint16_t sizeOfAddress;
202  uint8_t portPhysicalAddress[16];
204 
209 typedef struct
210 {
211  uint16_t portNumber;
212  uint16_t networkProtocol;
213  uint16_t addressSize;
214  uint8_t portProtocolAddress[16];
216 
221 typedef struct
222 {
223  uint64_t systemTime;
224  uint64_t systemOffset;
226 
231 typedef struct
232 {
234  uint8_t ifPTPEnable;
236  uint8_t IsSynchronized;
254  uint16_t numberOfPorts;
256  /*TODO: Review ICSS_EMAC_MAX_PORTS_PER_INSTANCE -> ICSS_EMAC_MAX_PORTS_PER_INSTANCE*/
259  uint16_t portEnable[ICSS_EMAC_MAX_PORTS_PER_INSTANCE];
262  uint16_t portLogAnnounceInterval[ICSS_EMAC_MAX_PORTS_PER_INSTANCE];
265  uint16_t portLogSyncInterval[ICSS_EMAC_MAX_PORTS_PER_INSTANCE];
266 
269  uint8_t priority1;
271  uint8_t priority2;
272 
274  uint8_t domainNumber;
278  uint8_t manufacturerIdentity[4];
285 
292 
295  uint16_t stepsRemoved;
298 
300 
301 /*
302 * \brief EIP Config
303 * Structure storing the EIP info
304 */
305 typedef struct eip_Config_s
306 {
307  PRUICSS_Handle pruicssHandle;
312  uint8_t tempFrame[ICSS_EMAC_MAXMTU];
314 } eip_Config;
315 
316 /* ========================================================================== */
317 /* Function Declarations */
318 /* ========================================================================== */
319 
334 void EIP_drvInit(EIP_Handle icssEipHandle);
343 void EIP_drvStop(EIP_Handle icssEipHandle);
352 void EIP_drvStart(EIP_Handle icssEipHandle);
364 void EIP_processProtocolFrames(uint32_t *queue_number, void *userArg);
365 
376 int8_t EIP_initializeCIPSync(EIP_Handle icssEipHandle);
377 
390 int32_t EIP_configureLLDPForwarding(EIP_Handle icssEipHandle, uint8_t enableFeature);
391 
402 int32_t EIP_configureLLDPFwdHelper(uint32_t pruBaseAddress, uint8_t val);
403 
411 #ifdef __cplusplus
412 }
413 #endif
414 
415 #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:126
clockClass_t::currentUTCOffset
uint16_t currentUTCOffset
Definition: icss_eip_driver.h:158
portProtAddr_t::networkProtocol
uint16_t networkProtocol
Definition: icss_eip_driver.h:212
eip_Config::timeSyncHandle
TimeSync_ParamsHandle_t timeSyncHandle
Definition: icss_eip_driver.h:309
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:211
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:250
cipSyncConfig_t::timeOffset
sysTimeOffset_t timeOffset
Definition: icss_eip_driver.h:297
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:307
EIP_Handle
struct eip_Config_s * EIP_Handle
Definition: icss_eip_driver.h:120
cipSyncConfig_t
CIP Sync configuration. Instance Attribute for PTP Class (Class Code 0x43. CIP Spec Vol 1)
Definition: icss_eip_driver.h:232
cipSyncConfig_t::numberOfPorts
uint16_t numberOfPorts
Definition: icss_eip_driver.h:254
sysTimeOffset_t::systemOffset
uint64_t systemOffset
Definition: icss_eip_driver.h:224
cipSyncConfig_t::domainNumber
uint8_t domainNumber
Definition: icss_eip_driver.h:274
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:199
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:180
eip_Config
Definition: icss_eip_driver.h:306
clockClass_t::observedOffsetScaledLogVariance
uint16_t observedOffsetScaledLogVariance
Definition: icss_eip_driver.h:166
EIP_drvStart
void EIP_drvStart(EIP_Handle icssEipHandle)
EIP driver start API.
portPhysAddr_t::sizeOfAddress
uint16_t sizeOfAddress
Definition: icss_eip_driver.h:201
cipSyncConfig_t::meanPathDelayToMaster
int64_t meanPathDelayToMaster
Definition: icss_eip_driver.h:246
EIP_drvStop
void EIP_drvStop(EIP_Handle icssEipHandle)
EIP driver stop API.
clockClass_t::timeAccuracy
uint16_t timeAccuracy
Definition: icss_eip_driver.h:150
clockClass_t::offsetScaledLogVariance
uint16_t offsetScaledLogVariance
Definition: icss_eip_driver.h:153
cipSyncConfig_t::revData
descr_t revData
Definition: icss_eip_driver.h:282
cipSyncConfig_t::localClkInfo
clockClass_t localClkInfo
Definition: icss_eip_driver.h:252
clockClass_t::timeSource
uint16_t timeSource
Definition: icss_eip_driver.h:162
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:160
BOUNDARY_CLOCK
@ BOUNDARY_CLOCK
Definition: icss_eip_driver.h:132
cipSyncConfig_t::IsSynchronized
uint8_t IsSynchronized
Definition: icss_eip_driver.h:236
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:238
cipSyncConfig_t::grandMasterClkInfo
clockClass_t grandMasterClkInfo
Definition: icss_eip_driver.h:248
TRANSPARENT_CLOCK
@ TRANSPARENT_CLOCK
Definition: icss_eip_driver.h:130
eip_Config::emacHandle
ICSS_EMAC_Handle emacHandle
Definition: icss_eip_driver.h:308
cipSyncConfig_t::systemTimeNanosec
uint64_t systemTimeNanosec
Definition: icss_eip_driver.h:240
cipSyncConfig_t::maxOffsetFromMaster
uint64_t maxOffsetFromMaster
Definition: icss_eip_driver.h:244
cipSyncConfig_t::priority2
uint8_t priority2
Definition: icss_eip_driver.h:271
clockClass_t
Specifies the properties of a clock.
Definition: icss_eip_driver.h:144
eip_Config::dlrHandle
EIP_DLRHandle dlrHandle
Definition: icss_eip_driver.h:313
cipSyncConfig_t::ifPTPEnable
uint8_t ifPTPEnable
Definition: icss_eip_driver.h:234
sysTimeOffset_t
Specifies the system time in microseconds and the Offset to the local clock value.
Definition: icss_eip_driver.h:222
cipSyncConfig_t::clockType
clockType clockType
Definition: icss_eip_driver.h:276
sysTimeOffset_t::systemTime
uint64_t systemTime
Definition: icss_eip_driver.h:223
clockClass_t::clockClass
uint16_t clockClass
Definition: icss_eip_driver.h:148
eip_Config::cipSyncObj
cipSyncConfig_t cipSyncObj
Definition: icss_eip_driver.h:310
descr_t
Description in unicode.
Definition: icss_eip_driver.h:178
clockClass_t::observedPhaseChangeRate
uint16_t observedPhaseChangeRate
Definition: icss_eip_driver.h:170
cipSyncConfig_t::userDesc
descr_t userDesc
Definition: icss_eip_driver.h:284
portProtAddr_t::addressSize
uint16_t addressSize
Definition: icss_eip_driver.h:213
cipSyncConfig_t::priority1
uint8_t priority1
Definition: icss_eip_driver.h:269
icss_timeSyncApi.h
ORDINARY_CLOCK
@ ORDINARY_CLOCK
Definition: icss_eip_driver.h:128
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:280
portProtAddr_t
Specifies the specifies the network and protocol address of each port of the device (e....
Definition: icss_eip_driver.h:210
icss_dlr.h
TimeSync_ParamsHandle_t
struct TimeSync_ParamsHandle_s * TimeSync_ParamsHandle_t
Definition: icss_timeSyncApi.h:985
portProfileIdentity_t
Specifies the PTP profile of each port of the device.
Definition: icss_eip_driver.h:189
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:295
cipSyncConfig_t::offsetFromMaster
int64_t offsetFromMaster
Definition: icss_eip_driver.h:242
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