1# Copyright (c) 2018 Intel Corporation.
2# SPDX-License-Identifier: Apache-2.0
3
4menuconfig NET_GPTP
5	bool "IEEE 802.1AS (gPTP) support [EXPERIMENTAL]"
6	select NET_L2_PTP
7	select EXPERIMENTAL
8	help
9	  Enable gPTP driver that send and receives gPTP packets
10	  and handles network packet timestamps.
11
12if NET_GPTP
13
14module = NET_GPTP
15module-dep = NET_LOG
16module-str = Log level for gPTP
17module-help = Enable logs for the gPTP stack.
18source "subsys/net/Kconfig.template.log_config.net"
19
20config NET_GPTP_GM_CAPABLE
21	bool "IEEE 802.1AS GrandMaster Capability"
22	help
23	  Enable to mark the whole system as Grand Master Capable.
24
25config NET_GPTP_PROBE_CLOCK_SOURCE_ON_DEMAND
26	bool "Probe clock source on demand"
27	depends on NET_GPTP_GM_CAPABLE
28	default y
29	help
30	  This option is helpful if the driver does not fully support the
31	  ClockSourceTime.invoke function. If this is enabled, the clock
32	  source is probed when it is actually needed instead of being
33	  updated on each tick.
34	  See IEEE 802.1AS-2011, chapter 9.2 for more details.
35
36choice
37	prompt "gPTP Clock Accuracy"
38	default NET_GPTP_CLOCK_ACCURACY_UNKNOWN
39	help
40	  Specify the accuracy of the clock. This setting should reflect
41	  the actual capabilities of the hardware.
42	  See 7.6.2.5 of IEEE 1588-2008 for more info.
43
44	config NET_GPTP_CLOCK_ACCURACY_UNKNOWN
45		bool "Unknown"
46	config NET_GPTP_CLOCK_ACCURACY_25NS
47		bool "25ns"
48	config NET_GPTP_CLOCK_ACCURACY_100NS
49		bool "100ns"
50	config NET_GPTP_CLOCK_ACCURACY_250NS
51		bool "250ns"
52	config NET_GPTP_CLOCK_ACCURACY_1US
53		bool "1us"
54	config NET_GPTP_CLOCK_ACCURACY_2_5US
55		bool "2.5us"
56	config NET_GPTP_CLOCK_ACCURACY_10US
57		bool "10us"
58	config NET_GPTP_CLOCK_ACCURACY_25US
59		bool "25us"
60	config NET_GPTP_CLOCK_ACCURACY_100US
61		bool "100us"
62	config NET_GPTP_CLOCK_ACCURACY_250US
63		bool "250us"
64	config NET_GPTP_CLOCK_ACCURACY_1MS
65		bool "1ms"
66	config NET_GPTP_CLOCK_ACCURACY_2_5MS
67		bool "1.5ms"
68	config NET_GPTP_CLOCK_ACCURACY_10MS
69		bool "10ms"
70	config NET_GPTP_CLOCK_ACCURACY_25MS
71		bool "25ms"
72	config NET_GPTP_CLOCK_ACCURACY_100MS
73		bool "100ms"
74	config NET_GPTP_CLOCK_ACCURACY_250MS
75		bool "250ms"
76	config NET_GPTP_CLOCK_ACCURACY_1S
77		bool "1s"
78	config NET_GPTP_CLOCK_ACCURACY_10S
79		bool "10s"
80	config NET_GPTP_CLOCK_ACCURACY_GT_10S
81		bool "> 10s"
82endchoice
83
84config NET_GPTP_CLOCK_ACCURACY
85	hex
86	default 0x20 if NET_GPTP_CLOCK_ACCURACY_25NS
87	default 0x21 if NET_GPTP_CLOCK_ACCURACY_100NS
88	default 0x22 if NET_GPTP_CLOCK_ACCURACY_250NS
89	default 0x23 if NET_GPTP_CLOCK_ACCURACY_1US
90	default 0x24 if NET_GPTP_CLOCK_ACCURACY_2_5US
91	default 0x25 if NET_GPTP_CLOCK_ACCURACY_10US
92	default 0x26 if NET_GPTP_CLOCK_ACCURACY_25US
93	default 0x27 if NET_GPTP_CLOCK_ACCURACY_100US
94	default 0x28 if NET_GPTP_CLOCK_ACCURACY_250US
95	default 0x29 if NET_GPTP_CLOCK_ACCURACY_1MS
96	default 0x2a if NET_GPTP_CLOCK_ACCURACY_2_5MS
97	default 0x2b if NET_GPTP_CLOCK_ACCURACY_10MS
98	default 0x2c if NET_GPTP_CLOCK_ACCURACY_25MS
99	default 0x2d if NET_GPTP_CLOCK_ACCURACY_100MS
100	default 0x2e if NET_GPTP_CLOCK_ACCURACY_250MS
101	default 0x2f if NET_GPTP_CLOCK_ACCURACY_1S
102	default 0x30 if NET_GPTP_CLOCK_ACCURACY_10S
103	default 0x31 if NET_GPTP_CLOCK_ACCURACY_GT_10S
104	default 0xfe
105
106config NET_GPTP_STACK_SIZE
107	int "gPTP thread stack size"
108	default 2048
109	help
110	  Set the gPTP thread stack size in bytes. The gPTP thread handles the
111	  gPTP state machine. There is one gPTP thread in the system.
112
113config NET_GPTP_NUM_PORTS
114	int "Number of gPTP ports"
115	default 1
116	help
117	  Configures the gPTP stack to work with the given number of ports.
118	  The port concept is the same thing as network interface.
119
120config NET_GPTP_NEIGHBOR_PROP_DELAY_THR
121	int "Set neighbor propagation delay threshold (ns)"
122	default 100000
123	help
124	  Defines the neighbor propagation delay threshold in nanoseconds.
125	  This is the propagation time threshold, above which a port is not
126	  considered capable of participating in the IEEE 802.1AS protocol.
127	  See IEEE 802.1AS chapter 11.2.12.6 for details.
128
129config NET_GPTP_INIT_LOG_PDELAY_REQ_ITV
130	int "Set initial pdelay request interval in Log2 base"
131	default 0
132	help
133	  Defines the interval at which a Path Delay Request will be sent.
134	  The value is the converted in nanoseconds as follow:
135	  nanoseconds = (10^9) * 2^(value)
136
137config NET_GPTP_INIT_LOG_SYNC_ITV
138	int "Set initial sync interval in Log2 base"
139	default -3
140	help
141	  Defines the interval at which a Sync message will be sent.
142	  The value is the converted in nanoseconds as follow:
143	  nanoseconds = (10^9) * 2^(value)
144
145config NET_GPTP_INIT_LOG_ANNOUNCE_ITV
146	int "Set initial announce interval in Log2 base"
147	default 0
148	help
149	  Defines the interval at which an Announce message will be sent.
150	  The value is the converted in nanoseconds as follow:
151	  nanoseconds = (10^9) * 2^(value)
152
153config NET_GPTP_SYNC_RECEIPT_TIMEOUT
154	int "Number of sync intervals to wait"
155	default 3
156	help
157	  Defines the number of sync intervals to wait without receiving
158	  synchronization information before assuming that the master is no
159	  longer transmitting synchronization information.
160
161config NET_GPTP_ANNOUNCE_RECEIPT_TIMEOUT
162	int "Number of announce intervals to wait"
163	default 3
164	help
165	  Defines the number of announce intervals to wait without receiving
166	  an Announce message before assuming that the master is no longer
167	  transmitting Announce messages.
168
169config NET_GPTP_USE_DEFAULT_CLOCK_UPDATE
170	bool "Use a default clock update function"
171	default y
172	help
173	  Use a default internal function to update port local clock.
174
175config NET_GPTP_PATH_TRACE_ELEMENTS
176	int "How many path trace elements to track"
177	default 8
178	help
179	  This tells the number of time-aware systems that transmits the
180	  Announce message. Each array element takes 8 bytes. If this value
181	  is set to 8, then 8 * 8 = 64 bytes of memory is used.
182
183config NET_GPTP_BMCA_PRIORITY1
184	int "BMCA priority1 value"
185	default 248 if NET_GPTP_GM_CAPABLE
186	default $(UINT8_MAX)
187	range 0 $(UINT8_MAX)
188	help
189	  The priority1 attribute of the local clock. It is used in the
190	  Best Master Clock selection Algorithm (BMCA), lower values take
191	  precedence. The default value is 255 if the device is non grand
192	  master capable, and 248 if it is GM capable.
193	  See Chapter 8.6.2.1 of IEEE 802.1AS for a more detailed description
194	  of priority1. Note that if the system	is non GM capable, then the
195	  value 255 is used always and this setting is ignored.
196
197config NET_GPTP_BMCA_PRIORITY2
198	int "BMCA priority2 value"
199	default 248
200	range 0 $(UINT8_MAX)
201	help
202	  The priority2 attribute of the local clock. It is used in the BMCA
203	  (Best Master Clock selection Algorithm), lower values take
204	  precedence. The default value is 248.
205	  See Chapter 8.6.2.5 of IEEE 802.1AS for a more detailed description
206	  of priority2.
207
208config NET_GPTP_STATISTICS
209	bool "Collect gPTP statistics"
210	help
211	  Enable this if you need to collect gPTP statistics. The statistics
212	  can be seen in net-shell if needed.
213
214endif # NET_GPTP
215