Skip to content

Commit

Permalink
Support the grand master settings management query.
Browse files Browse the repository at this point in the history
This patch also replaces the hard coded logic for the UTC offset and the
time property flags with clock variables. This new clock state will be
used for adjusting the grand master attributes at run time.

Signed-off-by: Richard Cochran <[email protected]>
  • Loading branch information
richardcochran committed Jul 7, 2013
1 parent 64ec047 commit 24ecd78
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ struct clock {
int utc_timescale;
int leap_set;
int kernel_leap;
int utc_offset; /* grand master role */
int time_flags; /* grand master role */
int time_source; /* grand master role */
enum servo_state servo_state;
tmv_t master_offset;
Expand Down Expand Up @@ -172,6 +174,7 @@ static int clock_management_get_response(struct clock *c, struct port *p,
struct management_tlv_datum *mtd;
struct ptp_message *rsp;
struct time_status_np *tsn;
struct grandmaster_settings_np *gsn;
struct PortIdentity pid = port_identity(p);
struct PTPText *text;

Expand Down Expand Up @@ -271,6 +274,15 @@ static int clock_management_get_response(struct clock *c, struct port *p,
datalen = sizeof(*tsn);
respond = 1;
break;
case GRANDMASTER_SETTINGS_NP:
gsn = (struct grandmaster_settings_np *) tlv->data;
gsn->clockQuality = c->dds.clockQuality;
gsn->utc_offset = c->utc_offset;
gsn->time_flags = c->time_flags;
gsn->time_source = c->time_source;
datalen = sizeof(*gsn);
respond = 1;
break;
}
if (respond) {
if (datalen % 2) {
Expand Down Expand Up @@ -431,12 +443,8 @@ static void clock_update_grandmaster(struct clock *c)
pds->grandmasterPriority1 = c->dds.priority1;
pds->grandmasterPriority2 = c->dds.priority2;
c->dad.path_length = 0;
c->tds.currentUtcOffset = CURRENT_UTC_OFFSET;
if (c->utc_timescale) {
c->tds.flags = 0;
} else {
c->tds.flags = PTP_TIMESCALE;
}
c->tds.currentUtcOffset = c->utc_offset;
c->tds.flags = c->time_flags;
c->tds.timeSource = c->time_source;
}

Expand Down Expand Up @@ -571,6 +579,7 @@ struct clock *clock_create(int phc_index, struct interface *iface, int count,
c->free_running = dds->free_running;
c->freq_est_interval = dds->freq_est_interval;
c->kernel_leap = dds->kernel_leap;
c->utc_offset = CURRENT_UTC_OFFSET;
c->time_source = dds->time_source;
c->desc = dds->clock_desc;

Expand Down Expand Up @@ -598,6 +607,7 @@ struct clock *clock_create(int phc_index, struct interface *iface, int count,
sysclk_set_leap(0);
}
c->leap_set = 0;
c->time_flags = c->utc_timescale ? 0 : PTP_TIMESCALE;

if (c->clkid != CLOCK_INVALID) {
fadj = (int) clockadj_get_freq(c->clkid);
Expand Down Expand Up @@ -846,6 +856,7 @@ void clock_manage(struct clock *c, struct port *p, struct ptp_message *msg)
case TRANSPARENT_CLOCK_DEFAULT_DATA_SET:
case PRIMARY_DOMAIN:
case TIME_STATUS_NP:
case GRANDMASTER_SETTINGS_NP:
clock_management_send_error(p, msg, NOT_SUPPORTED);
break;
default:
Expand Down

0 comments on commit 24ecd78

Please sign in to comment.