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