1 /*
2  * Copyright (c) 2017 Intel Corporation.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /**
8  * @file
9  * @brief GPTP Media Independent interface
10  *
11  * This is not to be included by the application.
12  */
13 
14 #ifndef __GPTP_MI_H
15 #define __GPTP_MI_H
16 
17 #include "gptp_md.h"
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 /**
24  * @brief Media Independent Sync Information.
25  *
26  * This structure applies for MDSyncReceive as well as MDSyncSend.
27  */
28 struct gptp_mi_port_sync_sync {
29 	/** Time at which the sync receipt timeout occurs. */
30 	uint64_t sync_receipt_timeout_time;
31 
32 	/** Copy of the gptp_md_sync_info to be transmitted. */
33 	struct gptp_md_sync_info sync_info;
34 
35 	/** Port to which the Sync Information belongs to. */
36 	uint16_t local_port_number;
37 };
38 
39 /**
40  * @brief Initialize all Media Independent State Machines.
41  */
42 void gptp_mi_init_state_machine(void);
43 
44 /**
45  * @brief Run all Media Independent Port Sync State Machines.
46  *
47  * @param port Number of the port the State Machines needs to be run on.
48  */
49 void gptp_mi_port_sync_state_machines(int port);
50 
51 /**
52  * @brief Run all Media Independent Port BMCA State Machines.
53  *
54  * @param port Number of the port the State Machines needs to be run on.
55  */
56 void gptp_mi_port_bmca_state_machines(int port);
57 
58 /**
59  * @brief Run all Media Independent State Machines.
60  */
61 void gptp_mi_state_machines(void);
62 
63 /**
64  * @brief Return current time in nanoseconds.
65  *
66  * @param port Port number of the clock to use.
67  *
68  * @return Current time in nanoseconds.
69  */
70 uint64_t gptp_get_current_time_nanosecond(int port);
71 
72 #ifdef __cplusplus
73 }
74 #endif
75 
76 #endif /* __GPTP_MI_H */
77