forked from nxp-archive/openil_linuxptp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsja1105-ptp.h
95 lines (80 loc) · 2.25 KB
/
sja1105-ptp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/**
* @file sja1105-ptp.h
* @brief definiton for SJA1105 transparent clock specific structures
* @note Copyright 2017 NXP
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef HAVE_SJA1105_PTP_H
#define HAVE_SJA1105_PTP_H
#include <stdbool.h>
#include <poll.h>
#include "fd.h"
#include "ddt.h"
#include <sja1105/ptp.h>
#include <sja1105/dynamic-config.h>
#define FD_NUM 3
#define FD_META 2
#define MASTER_STABLE_CNT 3
#define SJA1105_PORT 0x001f
#define SJA1105_PORT_HOST 0x0010
#define PTP_E2E_ETH_MULTI_ADDR 0x011B19000000
struct cfg {
char *if_name;
};
struct host_if {
const char *name;
struct transport *trans;
struct fdarray fd_array;
struct ptp_message *last_sync;
struct ptp_message *last_sync_fup;
struct ptp_message *sync;
struct ptp_message *sync_fup;
struct ptp_message *delay_req;
};
struct tc {
struct host_if *interface;
struct pollfd fd[FD_NUM];
struct ClockIdentity master_id;
bool master_setup;
int master_stable;
double cur_ratio;
uint32_t cur_ratio_u32;
int synt_exception;
};
struct meta_data {
char reserve;
char rx_ts_byte2;
char rx_ts_byte1;
char rx_ts_byte0;
char dst_mac_byte1;
char dst_mac_byte0;
char src_port;
char switch_id;
};
struct sja1105_egress_ts {
//assume frames are forwarded out on each port at same time
uint64_t tx_ts;
uint8_t ts_index;
uint8_t available;
};
extern struct tc tc;
extern struct cfg tc_cfg;
extern struct host_if tc_host_if;
extern struct sja1105_spi_setup spi_setup;
extern struct sja1105_egress_ts sync_tx_ts;
extern struct sja1105_egress_ts delay_req_tx_ts;
extern struct sja1105_egress_ts egress_ts_tmp;
#endif