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 select NET_IPV4_IGMP 95 96 config PTP_UDP_IPv6_PROTOCOL 97 bool "UDP with IPv6" 98 select NET_IPV6_MLD 99endchoice 100 101choice 102 prompt "PTP Clock Accuracy" 103 default PTP_CLOCK_ACCURACY_UNKNOWN 104 help 105 Specify the accuracy of the clock. This setting should reflect 106 the actual capabilities of the hardware. 107 See 7.6.2.5 of IEEE 1588-2019 for more info. 108 109 config PTP_CLOCK_ACCURACY_UNKNOWN 110 bool "Unknown" 111 config PTP_CLOCK_ACCURACY_25NS 112 bool "25ns" 113 config PTP_CLOCK_ACCURACY_100NS 114 bool "100ns" 115 config PTP_CLOCK_ACCURACY_250NS 116 bool "250ns" 117 config PTP_CLOCK_ACCURACY_1US 118 bool "1us" 119 config PTP_CLOCK_ACCURACY_2_5US 120 bool "2.5us" 121 config PTP_CLOCK_ACCURACY_10US 122 bool "10us" 123 config PTP_CLOCK_ACCURACY_25US 124 bool "25us" 125 config PTP_CLOCK_ACCURACY_100US 126 bool "100us" 127 config PTP_CLOCK_ACCURACY_250US 128 bool "250us" 129 config PTP_CLOCK_ACCURACY_1MS 130 bool "1ms" 131 config PTP_CLOCK_ACCURACY_2_5MS 132 bool "1.5ms" 133 config PTP_CLOCK_ACCURACY_10MS 134 bool "10ms" 135 config PTP_CLOCK_ACCURACY_25MS 136 bool "25ms" 137 config PTP_CLOCK_ACCURACY_100MS 138 bool "100ms" 139 config PTP_CLOCK_ACCURACY_250MS 140 bool "250ms" 141 config PTP_CLOCK_ACCURACY_1S 142 bool "1s" 143 config PTP_CLOCK_ACCURACY_10S 144 bool "10s" 145 config PTP_CLOCK_ACCURACY_GT_10S 146 bool "> 10s" 147endchoice 148 149config PTP_CLOCK_ACCURACY 150 hex 151 default 0x20 if PTP_CLOCK_ACCURACY_25NS 152 default 0x21 if PTP_CLOCK_ACCURACY_100NS 153 default 0x22 if PTP_CLOCK_ACCURACY_250NS 154 default 0x23 if PTP_CLOCK_ACCURACY_1US 155 default 0x24 if PTP_CLOCK_ACCURACY_2_5US 156 default 0x25 if PTP_CLOCK_ACCURACY_10US 157 default 0x26 if PTP_CLOCK_ACCURACY_25US 158 default 0x27 if PTP_CLOCK_ACCURACY_100US 159 default 0x28 if PTP_CLOCK_ACCURACY_250US 160 default 0x29 if PTP_CLOCK_ACCURACY_1MS 161 default 0x2a if PTP_CLOCK_ACCURACY_2_5MS 162 default 0x2b if PTP_CLOCK_ACCURACY_10MS 163 default 0x2c if PTP_CLOCK_ACCURACY_25MS 164 default 0x2d if PTP_CLOCK_ACCURACY_100MS 165 default 0x2e if PTP_CLOCK_ACCURACY_250MS 166 default 0x2f if PTP_CLOCK_ACCURACY_1S 167 default 0x30 if PTP_CLOCK_ACCURACY_10S 168 default 0x31 if PTP_CLOCK_ACCURACY_GT_10S 169 default 0xfe 170 171config PTP_PRIORITY1 172 int "Value used in the Best TimeTransmitter Clock Algorithm (BTCA)" 173 default 128 174 range 0 $(UINT8_MAX) 175 176config PTP_PRIORITY2 177 int "Value used in the Best TimeTransmitter Clock Algorithm (BTCA)" 178 default 128 179 range 0 $(UINT8_MAX) 180 181config PTP_TIME_RECEIVER_ONLY 182 bool "Configure Clock as timeReceiver PTP Instance" 183 depends on PTP_ORDINARY_CLOCK 184 help 185 An Oridinary Clock may be designed to ba a timeReceiver PTP Instance. In that state 186 the instance can never enter the TIME_TRANSMITTER state. 187 188config PTP_ANNOUNCE_RECV_TIMEOUT 189 int "Number of announce intervals to wait" 190 default 3 191 range 2 10 192 help 193 Defines the number of announce intervals to wait without receiving 194 an Announce message before assuming that the timeTransmitter is no longer 195 transmitting Announce messages and rising timeout event. 196 197config PTP_ANNOUNCE_LOG_INTERVAL 198 int "Interval between successive Announce messages" 199 default 1 200 range 0 4 201 help 202 Defines mean time interval between successive Announce messages. The value should be 203 uniform through PTP domain. For more check IEEE 1588-2019 Section 7.7.2.2. 204 The value is the converted to nanoseconds as follow: nanoseconds = (10^9) * 2^(value) 205 206config PTP_MIN_DELAY_REQ_LOG_INTERVAL 207 int "Interval between successive Delay_Req messages" 208 default 0 209 range 0 5 210 help 211 The minimum time interval between Delay_Req messages. 212 The value is the converted to nanoseconds as follow: nanoseconds = (10^9) * 2^(value) 213 214config PTP_SYNC_LOG_INTERVAL 215 int "Interval between successive Sync messages" 216 default 0 217 range -1 1 218 help 219 Specify mean time interval between successive Sync messages, 220 when transmitted as multicast messages. The value is the converted 221 to nanoseconds as follow: nanoseconds = (10^9) * 2^(value) 222 223config PTP_MIN_PDELAY_REQ_LOG_INTERVAL 224 int "PDelay Req interval in Log2 base" 225 default 0 226 range 0 5 227 help 228 Specifies minimum permitted mean time interval between successive Pdelay_Req messages. 229 The value is the converted to nanoseconds as follow: nanoseconds = (10^9) * 2^(value) 230 231config PTP_DISABLED_PRESENT 232 bool 233 default y 234 235config PTP_FAULTY_PRESENT 236 bool 237 default y 238 239config PTP_LISTENING_PRESENT 240 bool 241 default y 242 243config PTP_PRE_TIME_TRANSMITTER_PRESENT 244 bool 245 default y 246 247config PTP_UNCALIBRATED_PRESENT 248 bool 249 default n 250 251config PTP_FOREIGN_TIME_TRANSMITTER_FEATURE 252 bool 253 default y 254 255config PTP_FOREIGN_TIME_TRANSMITTER_RECORD_SIZE 256 int "Size of an array that stores foreign timeTransmitters data" 257 depends on PTP_FOREIGN_TIME_TRANSMITTER_FEATURE 258 default 5 259 help 260 The IEEE 1588-2019 standard states that minimum size of the list 261 is 5 foreign timeTransmitter records per PTP Port. Kconfig does not allow for math 262 operation so if PTP_FOREIGN_TIME_TRANSMITTER_FEATURE is enabled and PTP_NUM_PORTS 263 is bigger than 1 the option value should be adjusted accordingly. 264 265choice PTP_DSCP_PRIORITY 266 prompt "Priority of PTP packets classification" 267 default PTP_DSCP_NONE_PRIORITY 268 269 config PTP_DSCP_HIGH_PRIORITY 270 bool "High priority of PTP packet classification" 271 272 config PTP_DSCP_MEDIUM_PRIORITY 273 bool "Medium priority of PTP packet classification" 274 275 config PTP_DSCP_NONE_PRIORITY 276 bool "Default priority of PTP packet classification" 277endchoice 278 279config PTP_DSCP_VALUE 280 int 281 default 56 if PTP_DSCP_HIGH_PRIORITY 282 default 46 if PTP_DSCP_MEDIUM_PRIORITY 283 default 0 if PTP_DSCP_NONE_PRIORITY 284 range 0 63 285 286endif # PTP 287