Skip to content

Commit

Permalink
Introduce a non-portable management TLV for grand masters.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
richardcochran committed Jul 7, 2013
1 parent f89e203 commit 64ec047
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tlv.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ static int mgt_post_recv(struct management_tlv *m, uint16_t data_len,
struct timePropertiesDS *tp;
struct portDS *p;
struct time_status_np *tsn;
struct grandmaster_settings_np *gsn;
struct mgmt_clock_description *cd;
int extra_len = 0;
uint8_t *buf;
Expand Down Expand Up @@ -163,6 +164,14 @@ static int mgt_post_recv(struct management_tlv *m, uint16_t data_len,
scaled_ns_n2h(&tsn->lastGmPhaseChange);
tsn->gmPresent = ntohl(tsn->gmPresent);
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 % 2)
Expand All @@ -183,6 +192,7 @@ static void mgt_pre_send(struct management_tlv *m, struct tlv_extra *extra)
struct timePropertiesDS *tp;
struct portDS *p;
struct time_status_np *tsn;
struct grandmaster_settings_np *gsn;
struct mgmt_clock_description *cd;
switch (m->id) {
case CLOCK_DESCRIPTION:
Expand Down Expand Up @@ -236,6 +246,12 @@ static void mgt_pre_send(struct management_tlv *m, struct tlv_extra *extra)
scaled_ns_h2n(&tsn->lastGmPhaseChange);
tsn->gmPresent = htonl(tsn->gmPresent);
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;
}
}

Expand Down
8 changes: 8 additions & 0 deletions tlv.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ enum management_action {
#define TRANSPARENT_CLOCK_DEFAULT_DATA_SET 0x4000
#define PRIMARY_DOMAIN 0x4002
#define TIME_STATUS_NP 0xC000
#define GRANDMASTER_SETTINGS_NP 0xC001

/* Port management ID values */
#define NULL_MANAGEMENT 0x0000
Expand Down Expand Up @@ -182,6 +183,13 @@ struct time_status_np {
struct ClockIdentity gmIdentity;
} PACKED;

struct grandmaster_settings_np {
struct ClockQuality clockQuality;
Integer16 utc_offset;
UInteger8 time_flags;
Enumeration8 time_source;
} PACKED;

enum clock_type {
CLOCK_TYPE_ORDINARY = 0x8000,
CLOCK_TYPE_BOUNDARY = 0x4000,
Expand Down

0 comments on commit 64ec047

Please sign in to comment.