1# Copyright (c) 2024 BayLibre 2# SPDX-License-Identifier: Apache-2.0 3 4menuconfig PTP 5 bool "IEEE 1588 (PTP) support [EXPERIMENTAL]" 6 select EXPERIMENTAL 7 select ZVFS 8 select ZVFS_EVENTFD 9 select NET_SOCKETS 10 select NET_CONTEXT_PRIORITY 11 select NET_L2_PTP 12 depends on NET_L2_ETHERNET 13 depends on !NET_GPTP 14 help 15 Enable PTP Stack that send and receives PTP packets 16 and handles network packet timestamps. The protocol's implementation 17 supports only one PTP Instance in the PTP Node. 18 19if PTP 20 21module = PTP 22module-dep = NET_LOG 23module-str = Log level for PTP 24module-help = Enable logs for the PTP stack. 25source "subsys/net/Kconfig.template.log_config.net" 26 27config PTP_STACK_SIZE 28 int "PTP thread stack size" 29 default 2048 30 help 31 Set the PTP thread stack size in bytes. The PTP thread handles the 32 PTP state machine. There is one PTP thread in the system. 33 34config PTP_INIT_PRIO 35 int "Startup priority for the PTP stack init" 36 default 96 37 38config PTP_SERVICE_THREAD_PRIO 39 int "Priority of the PTP service thread" 40 default NUM_PREEMPT_PRIORITIES 41 help 42 Set the priority of the PTP. This handler polls the sockets and checks 43 timers, depending on received PTP messages or timeouts actions defined 44 in the standard are taken. The value should be selected carefully. 45 46config PTP_MSG_POLL_SIZE 47 int "Number of messages available for allocation" 48 default 10 49 help 50 PTP messages are allocated dynamically from memory slab. The Kconfig symbol 51 defines number of blocks in the memory slab. 52 53choice 54 prompt "PTP Clock Type" 55 default PTP_ORDINARY_CLOCK 56 help 57 Specifies type of PTP Clock implemented on the target device 58 59config PTP_ORDINARY_CLOCK 60 bool "Ordinary Clock" 61 62config PTP_BOUNDARY_CLOCK 63 bool "Boundary Clock" 64 65config PTP_TRANSPARENT_P2P_CLOCK 66 bool "Transparent Peer-to-Peer Clock" 67 68config PTP_TRANSPARENT_E2E_CLOCK 69 bool "Transparent End-to-End Clock" 70 71endchoice 72 73config PTP_CLOCK_TYPE 74 hex 75 default 0x00 if PTP_ORDINARY_CLOCK 76 default 0x01 if PTP_BOUNDARY_CLOCK 77 default 0x02 if PTP_TRANSPARENT_P2P_CLOCK 78 default 0x03 if PTP_TRANSPARENT_E2E_CLOCK 79 80config PTP_NUM_PORTS 81 int "Number of PTP Ports" 82 default 1 if PTP_ORDINARY_CLOCK 83 default 2 if PTP_BOUNDARY_CLOCK || PTP_TRANSPARENT_P2P_CLOCK || PTP_TRANSPARENT_E2E_CLOCK 84 range 1 32 if PTP_ORDINARY_CLOCK 85 range 2 32 if PTP_BOUNDARY_CLOCK || PTP_TRANSPARENT_P2P_CLOCK || PTP_TRANSPARENT_E2E_CLOCK 86 help 87 Configures the PTP stack to work with the given number of ports. 88 The port concept is the same thing as network interface. 89 90choice 91 prompt "PTP Networking Protocol used by PTP Stack" 92 default PTP_UDP_IPv4_PROTOCOL 93 94config PTP_UDP_IPv4_PROTOCOL 95 bool "UDP with IPv4" 96 depends on NET_IPV4 97 select NET_IPV4_IGMP 98 99config PTP_UDP_IPv6_PROTOCOL 100 bool "UDP with IPv6" 101 depends on NET_IPV6 102 select NET_IPV6_MLD 103 104endchoice 105 106choice 107 prompt "PTP Clock Accuracy" 108 default PTP_CLOCK_ACCURACY_UNKNOWN 109 help 110 Specify the accuracy of the clock. This setting should reflect 111 the actual capabilities of the hardware. 112 See 7.6.2.5 of IEEE 1588-2019 for more info. 113 114config PTP_CLOCK_ACCURACY_UNKNOWN 115 bool "Unknown" 116 117config PTP_CLOCK_ACCURACY_25NS 118 bool "25ns" 119 120config PTP_CLOCK_ACCURACY_100NS 121 bool "100ns" 122 123config PTP_CLOCK_ACCURACY_250NS 124 bool "250ns" 125 126config PTP_CLOCK_ACCURACY_1US 127 bool "1us" 128 129config PTP_CLOCK_ACCURACY_2_5US 130 bool "2.5us" 131 132config PTP_CLOCK_ACCURACY_10US 133 bool "10us" 134 135config PTP_CLOCK_ACCURACY_25US 136 bool "25us" 137 138config PTP_CLOCK_ACCURACY_100US 139 bool "100us" 140 141config PTP_CLOCK_ACCURACY_250US 142 bool "250us" 143 144config PTP_CLOCK_ACCURACY_1MS 145 bool "1ms" 146 147config PTP_CLOCK_ACCURACY_2_5MS 148 bool "1.5ms" 149 150config PTP_CLOCK_ACCURACY_10MS 151 bool "10ms" 152 153config PTP_CLOCK_ACCURACY_25MS 154 bool "25ms" 155 156config PTP_CLOCK_ACCURACY_100MS 157 bool "100ms" 158 159config PTP_CLOCK_ACCURACY_250MS 160 bool "250ms" 161 162config PTP_CLOCK_ACCURACY_1S 163 bool "1s" 164 165config PTP_CLOCK_ACCURACY_10S 166 bool "10s" 167 168config PTP_CLOCK_ACCURACY_GT_10S 169 bool "> 10s" 170 171endchoice 172 173config PTP_CLOCK_ACCURACY 174 hex 175 default 0x20 if PTP_CLOCK_ACCURACY_25NS 176 default 0x21 if PTP_CLOCK_ACCURACY_100NS 177 default 0x22 if PTP_CLOCK_ACCURACY_250NS 178 default 0x23 if PTP_CLOCK_ACCURACY_1US 179 default 0x24 if PTP_CLOCK_ACCURACY_2_5US 180 default 0x25 if PTP_CLOCK_ACCURACY_10US 181 default 0x26 if PTP_CLOCK_ACCURACY_25US 182 default 0x27 if PTP_CLOCK_ACCURACY_100US 183 default 0x28 if PTP_CLOCK_ACCURACY_250US 184 default 0x29 if PTP_CLOCK_ACCURACY_1MS 185 default 0x2a if PTP_CLOCK_ACCURACY_2_5MS 186 default 0x2b if PTP_CLOCK_ACCURACY_10MS 187 default 0x2c if PTP_CLOCK_ACCURACY_25MS 188 default 0x2d if PTP_CLOCK_ACCURACY_100MS 189 default 0x2e if PTP_CLOCK_ACCURACY_250MS 190 default 0x2f if PTP_CLOCK_ACCURACY_1S 191 default 0x30 if PTP_CLOCK_ACCURACY_10S 192 default 0x31 if PTP_CLOCK_ACCURACY_GT_10S 193 default 0xfe 194 195config PTP_PRIORITY1 196 int "Value used in the Best TimeTransmitter Clock Algorithm (BTCA)" 197 default 128 198 range 0 $(UINT8_MAX) 199 200config PTP_PRIORITY2 201 int "Value used in the Best TimeTransmitter Clock Algorithm (BTCA)" 202 default 128 203 range 0 $(UINT8_MAX) 204 205config PTP_TIME_RECEIVER_ONLY 206 bool "Configure Clock as timeReceiver PTP Instance" 207 depends on PTP_ORDINARY_CLOCK 208 help 209 An Oridinary Clock may be designed to ba a timeReceiver PTP Instance. In that state 210 the instance can never enter the TIME_TRANSMITTER state. 211 212config PTP_ANNOUNCE_RECV_TIMEOUT 213 int "Number of announce intervals to wait" 214 default 3 215 range 2 10 216 help 217 Defines the number of announce intervals to wait without receiving 218 an Announce message before assuming that the timeTransmitter is no longer 219 transmitting Announce messages and rising timeout event. 220 221config PTP_ANNOUNCE_LOG_INTERVAL 222 int "Interval between successive Announce messages" 223 default 1 224 range 0 4 225 help 226 Defines mean time interval between successive Announce messages. The value should be 227 uniform through PTP domain. For more check IEEE 1588-2019 Section 7.7.2.2. 228 The value is the converted to nanoseconds as follow: nanoseconds = (10^9) * 2^(value) 229 230config PTP_MIN_DELAY_REQ_LOG_INTERVAL 231 int "Interval between successive Delay_Req messages" 232 default 0 233 range 0 5 234 help 235 The minimum time interval between Delay_Req messages. 236 The value is the converted to nanoseconds as follow: nanoseconds = (10^9) * 2^(value) 237 238config PTP_SYNC_LOG_INTERVAL 239 int "Interval between successive Sync messages" 240 default 0 241 range -1 1 242 help 243 Specify mean time interval between successive Sync messages, 244 when transmitted as multicast messages. The value is the converted 245 to nanoseconds as follow: nanoseconds = (10^9) * 2^(value) 246 247config PTP_MIN_PDELAY_REQ_LOG_INTERVAL 248 int "PDelay Req interval in Log2 base" 249 default 0 250 range 0 5 251 help 252 Specifies minimum permitted mean time interval between successive Pdelay_Req messages. 253 The value is the converted to nanoseconds as follow: nanoseconds = (10^9) * 2^(value) 254 255config PTP_DISABLED_PRESENT 256 bool 257 default y 258 259config PTP_FAULTY_PRESENT 260 bool 261 default y 262 263config PTP_LISTENING_PRESENT 264 bool 265 default y 266 267config PTP_PRE_TIME_TRANSMITTER_PRESENT 268 bool 269 default y 270 271config PTP_UNCALIBRATED_PRESENT 272 bool 273 274config PTP_FOREIGN_TIME_TRANSMITTER_FEATURE 275 bool 276 default y 277 278config PTP_FOREIGN_TIME_TRANSMITTER_RECORD_SIZE 279 int "Size of an array that stores foreign timeTransmitters data" 280 depends on PTP_FOREIGN_TIME_TRANSMITTER_FEATURE 281 default 5 282 help 283 The IEEE 1588-2019 standard states that minimum size of the list 284 is 5 foreign timeTransmitter records per PTP Port. Kconfig does not allow for math 285 operation so if PTP_FOREIGN_TIME_TRANSMITTER_FEATURE is enabled and PTP_NUM_PORTS 286 is bigger than 1 the option value should be adjusted accordingly. 287 288choice PTP_DSCP_PRIORITY 289 prompt "Priority of PTP packets classification" 290 default PTP_DSCP_NONE_PRIORITY 291 292config PTP_DSCP_HIGH_PRIORITY 293 bool "High priority of PTP packet classification" 294 295config PTP_DSCP_MEDIUM_PRIORITY 296 bool "Medium priority of PTP packet classification" 297 298config PTP_DSCP_NONE_PRIORITY 299 bool "Default priority of PTP packet classification" 300 301endchoice 302 303config PTP_DSCP_VALUE 304 int 305 default 56 if PTP_DSCP_HIGH_PRIORITY 306 default 46 if PTP_DSCP_MEDIUM_PRIORITY 307 default 0 if PTP_DSCP_NONE_PRIORITY 308 range 0 63 309 310endif # PTP 311