Utilize a code spell-checking tool to scan for and correct spelling errors
in all files within the `subsys/net/lib` directory.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Add cast to NSEC_PER_SEC macro to correctly check offset.
Prior to this commit, the would eval to true incorrectly.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Generally, we should avoid using reserved names in global
contexts.
subsys/net/lib/ptp/clock.c:58:25: \
error: 'clock' redeclared as different kind of symbol
58 | static struct ptp_clock clock = { 0 };
/opt/toolchains/zephyr-sdk-0.16.8/arm-zephyr-eabi/picolibc/ \
include/time.h💯12: \
note: previous declaration of 'clock' with type 'clock_t(void)' \
{aka 'long unsigned int(void)'}
100 | clock_t clock (void);
subsys/net/lib/ptp/clock.c:58:25: \
error: 'clock' defined but not used [-Werror=unused-variable]
58 | static struct ptp_clock clock = { 0 };
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Adding network interface status monitor function. Depending
on the interface operation state and change of the state
events are generated and handled by the function.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
This commit adds implementation of the PTP thread that will
poll sockets descriptors and PTP Port's timeres for timeouts,
generate events and handle them and trigger STATE_DECISION_EVENT
handling when needed.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
The STATE_DECISION_EVENT in PTP is a pivotal mechanism that
facilitates dynamic state management within the protocol,
allowing devices to adapt their operational states based on the BTCA's
recommendations and the health of the network.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Introduction of PTP stack's core functions responsible for
event generation and handling of these events. Events are generated
base on timeouts and/or PTP messages received via BSD sockets
assigned to a specific PTP Port. These function will be used
in PTP thread.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
The commit adds functions that enable and disable PTP Port.
This is going to be used by event handling routine.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Timers are used to trigger message transmission and detect
inactivity of other PTP Clocks what should result in an action
of the PTP Port.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
This commit introduces routines for PTP message transmission.
It includes transmission of three types of messages (Announce,
Sync, Delay_Req) that should be send periodically depending
on the PTP Port's state.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Introduction of routines processing received PTP Management messages.
The processing is split into clock-oriented and port-oriented parts.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Add handler for STATE_DECISION_EVENT it consists of following routines:
- state decision algorithm
- best timeTransmitter clock algorithm
- data sets comparison algorithm
Based on IEEE 1588-2019 section 9.3.3
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
This commit adds routines for handling incoming messages
needed for correct operation of the PTP stack in end to end
mode with multicast operation mode.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Initial implementation of the clock adjustment and delay calculation.
Timestamp values used for calculations will be obtained from
proper PTP messages (Sync, Follow_Up, Delay_Req, and Delay_Resp)
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Foreign timeTransmitters are other PTP Clocks in a domain. They announce
their parameters via announce messages. PTP Ports should record
these foreign timeTransmitters.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
This commit introduces module responsible for sending and receiving
messages. It is based on BSD Sockets API.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Add allocation of container used for TLVs and dummy functions for
preparing correct byte order of data. TLV stands for Type, Length,
Value, and it is extension of PTP messages that's used to transmit
extra information. This data is attached at the end of PTP message.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Add functions preparing messages to network byte order before sending
and changing to host byte order after reception and before processing
by PTP stack.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Add dynamic memory allocation for PTP messages. Memory allocation
is done with Zephyr's memory slab. It's size can be configured
with `PTP_MSG_POLL_SIZE` Kconfig symbol.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Introduces definition of structures for all types of PTP messages
defined in the IEEE 1588-2019 standard.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Based on IEEE 1588-2019 some of PTP Port states might not be used
if the option of 17.7 is implemented. This patch prepares state
machine implementation for such scenario.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Implement possibility to configure PTP stack in TIME_RECEIVER_ONLY mode.
This restrics stack behaviour and doesn't allow for any PTP Port
of the PTP Clock become a TimeTransmitter Clock.
The change includes:
- Kconfig option
- Additional field in `struct ptp_port` structure
- New state machine function for a timeReceiver-only PTP Port.
- Extra steps in PTP Clock and PTP Port initialization.
New finite state machine is based on the figure 31
in section 9.2.5 of the IEEE 1588-2019.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
This commit introduces PTP Clock and PTP Port structures
and API for initializing PTP Clock and PTP Ports. Configuration
options has been added as Kconfig symbols to configure parameters
of the Clock and Ports at compile time.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Datasets defined in the header file are going to be used
in PTP Clock's structure and PTP Port's structure. They
gather data into structures defined in IEEE 1588-2019.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
The patch brings implementationof a state machine for full
PTP implementation. It returns new PTP Port's state based
on event that occured and previous state.
Based on the figure 30 in section 9.2.5 of the IEEE 1588-2019.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
The header's file content is based on 5.3 section of
the IEEE 1588-2019 standard describing Precise Time Protocol (PTP)
used to synchronize devices in the network.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
This is an initial commit that introduces PTP library in the Zephyr.
It adds basic Kconfig symbols for enabling library, CMakeLists.txt
for compiling it, public header file, and initial PTP thread definition
and library initialization. Implementation of the functional PTP stack
will be introduced in following commits.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>