PDK API Guide for J721E
gptpbasetypes.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023 Texas Instruments Incorporated
3  * Copyright (c) 2023 Excelfore Corporation (https://excelfore.com)
4  *
5  * All rights reserved not granted herein.
6  * Limited License.
7  *
8  * Texas Instruments Incorporated grants a world-wide, royalty-free,
9  * non-exclusive license under copyrights and patents it now or hereafter
10  * owns or controls to make, have made, use, import, offer to sell and sell ("Utilize")
11  * this software subject to the terms herein. With respect to the foregoing patent
12  * license, such license is granted solely to the extent that any such patent is necessary
13  * to Utilize the software alone. The patent license shall not apply to any combinations which
14  * include this software, other than combinations with devices manufactured by or for TI ("TI Devices").
15  * No hardware patent is licensed hereunder.
16  *
17  * Redistributions must preserve existing copyright notices and reproduce this license (including the
18  * above copyright notice and the disclaimer and (if applicable) source code license limitations below)
19  * in the documentation and/or other materials provided with the distribution
20  *
21  * Redistribution and use in binary form, without modification, are permitted provided that the following
22  * conditions are met:
23  *
24  * * No reverse engineering, decompilation, or disassembly of this software is permitted with respect to any
25  * software provided in binary form.
26  * * any redistribution and use are licensed by TI for use only with TI Devices.
27  * * Nothing shall obligate TI to provide you with source code for the software licensed and provided to you in object code.
28  *
29  * If software source code is provided to you, modification and redistribution of the source code are permitted
30  * provided that the following conditions are met:
31  *
32  * * any redistribution and use of the source code, including any resulting derivative works, are licensed by
33  * TI for use only with TI Devices.
34  * * any redistribution and use of any object code compiled from the source code and any resulting derivative
35  * works, are licensed by TI for use only with TI Devices.
36  *
37  * Neither the name of Texas Instruments Incorporated nor the names of its suppliers may be used to endorse or
38  * promote products derived from this software without specific prior written permission.
39  *
40  * DISCLAIMER.
41  *
42  * THIS SOFTWARE IS PROVIDED BY TI AND TI"S LICENSORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
43  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
44  * IN NO EVENT SHALL TI AND TI"S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
45  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
46  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
47  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
48  * POSSIBILITY OF SUCH DAMAGE.
49 */
58 #ifndef __GPTPBASETYPES_H_
59 #define __GPTPBASETYPES_H_
60 
61 #include <string.h>
62 
68 #define MAX_PORT_NUMBER_LIMIT 33
69 
79 #define MAX_PATH_TRACE_N 179
80 
84 #define CLOCK_IDENTITY_LENGTH 8
85 
87 
103 typedef uint8_t Nibble;
104 typedef uint8_t Octet;
105 typedef uint8_t Octet2[2];
106 typedef uint8_t Octet3[3];
107 typedef uint8_t Octet4[4];
108 typedef uint8_t Enumeration2;
109 typedef uint8_t Enumeration4;
110 typedef uint8_t Enumeration8;
111 typedef uint16_t Enumeration16;
112 typedef uint32_t Enumeration24;
113 typedef uint8_t UInteger4;
119 typedef struct PortIdentity {
121  uint16_t portNumber;
122 } PortIdentity;
123 
127 typedef struct ClockQuality {
128  uint8_t clockClass;
131 } ClockQuality;
132 
136 typedef struct UInteger48 {
137  uint32_t lsb;
138  uint16_t msb;
139 } UInteger48;
143 typedef struct UInteger48m32 {
144  uint16_t lsb;
145  uint32_t msb;
146 } UInteger48m32;
147 
151 typedef struct UInteger112 {
152  uint8_t priority1;
153  uint8_t clockClass;
154  uint8_t clockAccuracy;
156  uint8_t priority2;
158 } __attribute__((packed, aligned(1))) UInteger112;
159 
164 typedef struct UInteger224 {
166  uint16_t stepsRemoved;
168  uint16_t portNumber;
169 } __attribute__((packed, aligned(1))) UInteger224;
170 
175 typedef struct ScaledNs {
176  uint16_t subns;
177  int64_t nsec;
178  int16_t nsec_msb;
179 } ScaledNs;
180 
190 typedef struct UScaledNs {
191  uint16_t subns;
192  uint64_t nsec;
193  uint16_t nsec_msb;
194 } UScaledNs;
195 
196 /*
197  * @brief The TimeInterval type represents time intervals, in units of 2^-16 ns
198  * @verbatim Example to express ns@endverbatim
199  * @code
200  * //2.5 ns expressed as below
201  * 0x0000 0000 0002 8000
202  * @endcode
203  *
204  */
205 typedef struct TimeInterval {
207 } TimeInterval;
208 
217 typedef struct Timestamp {
218  uint32_t nanoseconds;
220 } Timestamp;
221 
232 typedef struct ExtendedTimestamp {
236 
237 #define VALUE_DISABLED 0
238 #define VALUE_ENABLED 1
239 
243 typedef enum {
244  ATOMIC_CLOCK = 0x10,
245  GPS = 0x20,
247  PTP = 0x40,
248  NTP = 0x50,
249  HAND_SET = 0x60,
250  OTHER = 0x90,
252 } TimeSource;
253 
254 // 14.8.3 portState, (from IEEE 1588 Table-8)
258 typedef enum {
263 } PTPPortState;
264 
265 #endif
266 
uint8_t clockClass
Definition: gptpbasetypes.h:153
PTPPortState
value of the port state (802.1AS 14.8.3 portState)
Definition: gptpbasetypes.h:258
48bit variable, msb is 32 bits
Definition: gptpbasetypes.h:143
UInteger112 rootSystemIdentity
Definition: gptpbasetypes.h:165
UInteger48m32 fractionalNanoseconds
Definition: gptpbasetypes.h:233
Definition: gptpbasetypes.h:260
int64_t nsec
Definition: gptpbasetypes.h:177
ClockIdentity clockIdentity
Definition: gptpbasetypes.h:120
The ScaledNs type represents signed values of time and time interval in units of 2e-16 ns.
Definition: gptpbasetypes.h:175
UInteger48 seconds
Definition: gptpbasetypes.h:234
UInteger48 seconds
Definition: gptpbasetypes.h:219
uint8_t priority1
Definition: gptpbasetypes.h:152
uint8_t Enumeration4
Definition: gptpbasetypes.h:109
int64_t scaledNanoseconds
Definition: gptpbasetypes.h:206
Enumeration8 clockAccuracy
Definition: gptpbasetypes.h:129
Definition: gptpbasetypes.h:259
The portIdentity identifies a port of a time-aware system.
Definition: gptpbasetypes.h:119
Definition: gptpbasetypes.h:245
The ExtendTimestamp type represents a positive time with respect to the epoch. The fractionalNanoseco...
Definition: gptpbasetypes.h:232
uint8_t clockClass
Definition: gptpbasetypes.h:128
Definition: gptpbasetypes.h:261
uint8_t Enumeration2
Definition: gptpbasetypes.h:108
uint32_t msb
Definition: gptpbasetypes.h:145
PortIdentity sourcePortIdentity
Definition: gptpbasetypes.h:167
The clock quality represents quality of clock.
Definition: gptpbasetypes.h:127
uint16_t offsetScaledLogVariance
Definition: gptpbasetypes.h:130
uint16_t msb
Definition: gptpbasetypes.h:138
Definition: gptpbasetypes.h:249
48bit variable, lsb is 32 bits
Definition: gptpbasetypes.h:136
#define CLOCK_IDENTITY_LENGTH
Macro which defines Clock Identity Length.
Definition: gptpbasetypes.h:84
Definition: gptpbasetypes.h:250
uint16_t Enumeration16
Definition: gptpbasetypes.h:111
uint8_t Octet
Definition: gptpbasetypes.h:104
uint32_t lsb
Definition: gptpbasetypes.h:137
uint32_t nanoseconds
Definition: gptpbasetypes.h:218
uint16_t stepsRemoved
Definition: gptpbasetypes.h:166
The ScaledNs type represents unsigned values of time and time interval in units of 2^-16 ns.
Definition: gptpbasetypes.h:190
Definition: gptpbasetypes.h:251
uint8_t clockAccuracy
Definition: gptpbasetypes.h:154
uint8_t Octet4[4]
Definition: gptpbasetypes.h:107
uint16_t offsetScaledLogVariance
Definition: gptpbasetypes.h:155
ClockIdentity clockIdentity
Definition: gptpbasetypes.h:157
uint8_t Octet3[3]
Definition: gptpbasetypes.h:106
uint16_t portNumber
Definition: gptpbasetypes.h:168
uint8_t ClockIdentity[CLOCK_IDENTITY_LENGTH]
Definition: gptpbasetypes.h:86
Definition: gptpbasetypes.h:247
Definition: gptpbasetypes.h:205
uint16_t subns
Definition: gptpbasetypes.h:176
uint16_t lsb
Definition: gptpbasetypes.h:144
uint32_t Enumeration24
Definition: gptpbasetypes.h:112
int16_t nsec_msb
Definition: gptpbasetypes.h:178
uint16_t nsec_msb
Definition: gptpbasetypes.h:193
Definition: gptpbasetypes.h:244
The Timestamp type represents a positive time with respect to the epoch.
Definition: gptpbasetypes.h:217
uint16_t subns
Definition: gptpbasetypes.h:191
struct UInteger112 __attribute__((packed, aligned(1))) UInteger112
UInteger112 (802.1AS, 10.3.2 systemIdentity)
uint64_t nsec
Definition: gptpbasetypes.h:192
Definition: gptpbasetypes.h:248
Definition: gptpbasetypes.h:246
uint8_t priority2
Definition: gptpbasetypes.h:156
UInteger112 (802.1AS, 10.3.2 systemIdentity)
Definition: gptpbasetypes.h:151
UInteger224 (802.1AS, 10.3.4 time-synchronization spanning tree priority vectors )
Definition: gptpbasetypes.h:164
uint16_t portNumber
Definition: gptpbasetypes.h:121
uint8_t Octet2[2]
Definition: gptpbasetypes.h:105
uint8_t Enumeration8
Definition: gptpbasetypes.h:110
uint8_t Nibble
Primitive data types specifications for IEEE 802.1AS. All non-primitive data types are derived from t...
Definition: gptpbasetypes.h:103
Definition: gptpbasetypes.h:262
uint8_t UInteger4
Definition: gptpbasetypes.h:113
TimeSource
the type of source of time used by a ClockMaster(802.1AS, 8.6.2.7 timeSource)
Definition: gptpbasetypes.h:243