Introduce a non-portable management TLV for grand masters.
When running as grand master, the attributes of the local clock are not known by the ptp4l program. Since these attributes may change over time, for example when losing signal from GPS satellites, we need to have a way to provide updated information at run time. This patch provides a new TLV intended for local IPC that contains the required settings. Signed-off-by: Richard Cochran <richardcochran@gmail.com>master
parent
f89e203209
commit
64ec047823
16
tlv.c
16
tlv.c
|
@ -60,6 +60,7 @@ static int mgt_post_recv(struct management_tlv *m, uint16_t data_len,
|
||||||
struct timePropertiesDS *tp;
|
struct timePropertiesDS *tp;
|
||||||
struct portDS *p;
|
struct portDS *p;
|
||||||
struct time_status_np *tsn;
|
struct time_status_np *tsn;
|
||||||
|
struct grandmaster_settings_np *gsn;
|
||||||
struct mgmt_clock_description *cd;
|
struct mgmt_clock_description *cd;
|
||||||
int extra_len = 0;
|
int extra_len = 0;
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
|
@ -163,6 +164,14 @@ static int mgt_post_recv(struct management_tlv *m, uint16_t data_len,
|
||||||
scaled_ns_n2h(&tsn->lastGmPhaseChange);
|
scaled_ns_n2h(&tsn->lastGmPhaseChange);
|
||||||
tsn->gmPresent = ntohl(tsn->gmPresent);
|
tsn->gmPresent = ntohl(tsn->gmPresent);
|
||||||
break;
|
break;
|
||||||
|
case GRANDMASTER_SETTINGS_NP:
|
||||||
|
if (data_len != sizeof(struct grandmaster_settings_np))
|
||||||
|
goto bad_length;
|
||||||
|
gsn = (struct grandmaster_settings_np *) m->data;
|
||||||
|
gsn->clockQuality.offsetScaledLogVariance =
|
||||||
|
ntohs(gsn->clockQuality.offsetScaledLogVariance);
|
||||||
|
gsn->utc_offset = ntohs(gsn->utc_offset);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (extra_len) {
|
if (extra_len) {
|
||||||
if (extra_len % 2)
|
if (extra_len % 2)
|
||||||
|
@ -183,6 +192,7 @@ static void mgt_pre_send(struct management_tlv *m, struct tlv_extra *extra)
|
||||||
struct timePropertiesDS *tp;
|
struct timePropertiesDS *tp;
|
||||||
struct portDS *p;
|
struct portDS *p;
|
||||||
struct time_status_np *tsn;
|
struct time_status_np *tsn;
|
||||||
|
struct grandmaster_settings_np *gsn;
|
||||||
struct mgmt_clock_description *cd;
|
struct mgmt_clock_description *cd;
|
||||||
switch (m->id) {
|
switch (m->id) {
|
||||||
case CLOCK_DESCRIPTION:
|
case CLOCK_DESCRIPTION:
|
||||||
|
@ -236,6 +246,12 @@ static void mgt_pre_send(struct management_tlv *m, struct tlv_extra *extra)
|
||||||
scaled_ns_h2n(&tsn->lastGmPhaseChange);
|
scaled_ns_h2n(&tsn->lastGmPhaseChange);
|
||||||
tsn->gmPresent = htonl(tsn->gmPresent);
|
tsn->gmPresent = htonl(tsn->gmPresent);
|
||||||
break;
|
break;
|
||||||
|
case GRANDMASTER_SETTINGS_NP:
|
||||||
|
gsn = (struct grandmaster_settings_np *) m->data;
|
||||||
|
gsn->clockQuality.offsetScaledLogVariance =
|
||||||
|
htons(gsn->clockQuality.offsetScaledLogVariance);
|
||||||
|
gsn->utc_offset = htons(gsn->utc_offset);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
8
tlv.h
8
tlv.h
|
@ -78,6 +78,7 @@ enum management_action {
|
||||||
#define TRANSPARENT_CLOCK_DEFAULT_DATA_SET 0x4000
|
#define TRANSPARENT_CLOCK_DEFAULT_DATA_SET 0x4000
|
||||||
#define PRIMARY_DOMAIN 0x4002
|
#define PRIMARY_DOMAIN 0x4002
|
||||||
#define TIME_STATUS_NP 0xC000
|
#define TIME_STATUS_NP 0xC000
|
||||||
|
#define GRANDMASTER_SETTINGS_NP 0xC001
|
||||||
|
|
||||||
/* Port management ID values */
|
/* Port management ID values */
|
||||||
#define NULL_MANAGEMENT 0x0000
|
#define NULL_MANAGEMENT 0x0000
|
||||||
|
@ -182,6 +183,13 @@ struct time_status_np {
|
||||||
struct ClockIdentity gmIdentity;
|
struct ClockIdentity gmIdentity;
|
||||||
} PACKED;
|
} PACKED;
|
||||||
|
|
||||||
|
struct grandmaster_settings_np {
|
||||||
|
struct ClockQuality clockQuality;
|
||||||
|
Integer16 utc_offset;
|
||||||
|
UInteger8 time_flags;
|
||||||
|
Enumeration8 time_source;
|
||||||
|
} PACKED;
|
||||||
|
|
||||||
enum clock_type {
|
enum clock_type {
|
||||||
CLOCK_TYPE_ORDINARY = 0x8000,
|
CLOCK_TYPE_ORDINARY = 0x8000,
|
||||||
CLOCK_TYPE_BOUNDARY = 0x4000,
|
CLOCK_TYPE_BOUNDARY = 0x4000,
|
||||||
|
|
Loading…
Reference in New Issue