1# Copyright (c) 2018 Intel Corporation.
2# SPDX-License-Identifier: Apache-2.0
3
4menuconfig NET_GPTP
5	bool "Enable IEEE 802.1AS (gPTP) support [EXPERIMENTAL]"
6	select NET_PKT_TIMESTAMP
7	select PTP_CLOCK
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 "Enable 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_NUM_PORTS
107	int "Number of gPTP ports"
108	default 1
109	help
110	  Configures the gPTP stack to work with the given number of ports.
111	  The port concept is the same thing as network interface.
112
113config NET_GPTP_VLAN
114	bool "Run gPTP over VLAN link"
115	depends on NET_VLAN
116	select NET_L2_ETHERNET_MGMT
117	select NET_MGMT_EVENT
118	select NET_MGMT_EVENT_INFO
119	help
120	  This setting allows gPTP to run over VLAN link. Currently only
121	  one port can have VLAN tag set. Note that CONFIG_NET_GPTP_VLAN_TAG
122	  setting must have a proper tag value set, otherwise the gPTP over
123	  VLAN will not work.
124
125config NET_GPTP_VLAN_TAG
126	int "VLAN tag to use"
127	default 4095
128	depends on NET_GPTP_VLAN
129	help
130	  The VLAN tag to use when sending and receiving gPTP messages.
131	  The default value 4095 (0x0fff) means unspecified tag which is
132	  not a valid value. This means that you need to set the tag to
133	  a valid value.
134
135config NET_GPTP_NEIGHBOR_PROP_DELAY_THR
136	int "Set neighbor propagation delay threshold (ns)"
137	default 100000
138	help
139	  Defines the neighbor propagation delay threshold in nanoseconds.
140	  This is the propagation time threshold, above which a port is not
141	  considered capable of participating in the IEEE 802.1AS protocol.
142	  See IEEE 802.1AS chapter 11.2.12.6 for details.
143
144config NET_GPTP_INIT_LOG_PDELAY_REQ_ITV
145	int "Set initial pdelay request interval in Log2 base"
146	default 0
147	help
148	  Defines the interval at which a Path Delay Request will be sent.
149	  The value is the converted in nanoseconds as follow:
150	  nanoseconds = (10^9) * 2^(value)
151
152config NET_GPTP_INIT_LOG_SYNC_ITV
153	int "Set initial sync interval in Log2 base"
154	default -3
155	help
156	  Defines the interval at which a Sync message will be sent.
157	  The value is the converted in nanoseconds as follow:
158	  nanoseconds = (10^9) * 2^(value)
159
160config NET_GPTP_INIT_LOG_ANNOUNCE_ITV
161	int "Set initial announce interval in Log2 base"
162	default 0
163	help
164	  Defines the interval at which an Announce message will be sent.
165	  The value is the converted in nanoseconds as follow:
166	  nanoseconds = (10^9) * 2^(value)
167
168config NET_GPTP_SYNC_RECEIPT_TIMEOUT
169	int "Number of sync intervals to wait"
170	default 3
171	help
172	  Defines the number of sync intervals to wait without receiving
173	  synchronization information before assuming that the master is no
174	  longer transmitting synchronization information.
175
176config NET_GPTP_ANNOUNCE_RECEIPT_TIMEOUT
177	int "Number of announce intervals to wait"
178	default 3
179	help
180	  Defines the number of announce intervals to wait without receiving
181	  an Announce message before assuming that the master is no longer
182	  transmitting Announce messages.
183
184config NET_GPTP_USE_DEFAULT_CLOCK_UPDATE
185	bool "Use a default clock update function"
186	default y
187	help
188	  Use a default internal function to update port local clock.
189
190config NET_GPTP_PATH_TRACE_ELEMENTS
191	int "How many path trace elements to track"
192	default 8
193	help
194	  This tells the number of time-aware systems that transmits the
195	  Announce message. Each array element takes 8 bytes. If this value
196	  is set to 8, then 8 * 8 = 64 bytes of memory is used.
197
198config NET_GPTP_BMCA_PRIORITY1
199	int "BMCA priority1 value"
200	default 248 if NET_GPTP_GM_CAPABLE
201	default 255
202	range 0 255
203	help
204	  The priority1 attribute of the local clock. It is used in the
205	  Best Master Clock selection Algorithm (BMCA), lower values take
206	  precedence. The default value is 255 if the device is non grand
207	  master capable, and 248 if it is GM capable.
208	  See Chapter 8.6.2.1 of IEEE 802.1AS for a more detailed description
209	  of priority1. Note that if the system	is non GM capable, then the
210	  value 255 is used always and this setting is ignored.
211
212config NET_GPTP_BMCA_PRIORITY2
213	int "BMCA priority2 value"
214	default 248
215	range 0 255
216	help
217	  The priority2 attribute of the local clock. It is used in the BMCA
218	  (Best Master Clock selection Algorithm), lower values take
219	  precedence. The default value is 248.
220	  See Chapter 8.6.2.5 of IEEE 802.1AS for a more detailed description
221	  of priority2.
222
223config NET_GPTP_STATISTICS
224	bool "Collect gPTP statistics"
225	help
226	  Enable this if you need to collect gPTP statistics. The statistics
227	  can be seen in net-shell if needed.
228
229endif # NET_GPTP
230