Use the management message memory layout for the parentDS.
Reforming the data structure in this way will greatly simplify the implementation of the management message for this data set. Signed-off-by: Richard Cochran <richardcochran@gmail.com>master
parent
d60ccc7484
commit
71c4bf203c
40
clock.c
40
clock.c
|
@ -57,7 +57,7 @@ struct clock {
|
|||
struct defaultDS dds;
|
||||
struct dataset default_dataset;
|
||||
struct currentDS cur;
|
||||
struct parentDS dad;
|
||||
struct parent_ds dad;
|
||||
struct timePropertiesDS tds;
|
||||
struct ClockIdentity ptl[PATH_TRACE_MAX];
|
||||
struct foreign_clock *best;
|
||||
|
@ -163,11 +163,11 @@ static int clock_management_response(struct clock *c, struct port *p, int id,
|
|||
tsn->scaledLastGmPhaseChange = c->status.scaledLastGmPhaseChange;
|
||||
tsn->gmTimeBaseIndicator = c->status.gmTimeBaseIndicator;
|
||||
tsn->lastGmPhaseChange = c->status.lastGmPhaseChange;
|
||||
if (cid_eq(&c->dad.grandmasterIdentity, &c->dds.clockIdentity))
|
||||
if (cid_eq(&c->dad.pds.grandmasterIdentity, &c->dds.clockIdentity))
|
||||
tsn->gmPresent = 0;
|
||||
else
|
||||
tsn->gmPresent = 1;
|
||||
tsn->gmIdentity = c->dad.grandmasterIdentity;
|
||||
tsn->gmIdentity = c->dad.pds.grandmasterIdentity;
|
||||
datalen = sizeof(*tsn);
|
||||
respond = 1;
|
||||
break;
|
||||
|
@ -310,14 +310,15 @@ static void clock_step(clockid_t clkid, int64_t ns)
|
|||
|
||||
static void clock_update_grandmaster(struct clock *c)
|
||||
{
|
||||
struct parentDS *pds = &c->dad.pds;
|
||||
memset(&c->cur, 0, sizeof(c->cur));
|
||||
memset(c->ptl, 0, sizeof(c->ptl));
|
||||
c->dad.parentPortIdentity.clockIdentity = c->dds.clockIdentity;
|
||||
c->dad.parentPortIdentity.portNumber = 0;
|
||||
c->dad.grandmasterIdentity = c->dds.clockIdentity;
|
||||
c->dad.grandmasterClockQuality = c->dds.clockQuality;
|
||||
c->dad.grandmasterPriority1 = c->dds.priority1;
|
||||
c->dad.grandmasterPriority2 = c->dds.priority2;
|
||||
pds->parentPortIdentity.clockIdentity = c->dds.clockIdentity;
|
||||
pds->parentPortIdentity.portNumber = 0;
|
||||
pds->grandmasterIdentity = c->dds.clockIdentity;
|
||||
pds->grandmasterClockQuality = c->dds.clockQuality;
|
||||
pds->grandmasterPriority1 = c->dds.priority1;
|
||||
pds->grandmasterPriority2 = c->dds.priority2;
|
||||
c->dad.path_length = 0;
|
||||
c->tds.currentUtcOffset = CURRENT_UTC_OFFSET;
|
||||
c->tds.currentUtcOffsetValid = FALSE;
|
||||
|
@ -331,13 +332,14 @@ static void clock_update_grandmaster(struct clock *c)
|
|||
|
||||
static void clock_update_slave(struct clock *c)
|
||||
{
|
||||
struct parentDS *pds = &c->dad.pds;
|
||||
struct ptp_message *msg = TAILQ_FIRST(&c->best->messages);
|
||||
c->cur.stepsRemoved = 1 + c->best->dataset.stepsRemoved;
|
||||
c->dad.parentPortIdentity = c->best->dataset.sender;
|
||||
c->dad.grandmasterIdentity = msg->announce.grandmasterIdentity;
|
||||
c->dad.grandmasterClockQuality = msg->announce.grandmasterClockQuality;
|
||||
c->dad.grandmasterPriority1 = msg->announce.grandmasterPriority1;
|
||||
c->dad.grandmasterPriority2 = msg->announce.grandmasterPriority2;
|
||||
pds->parentPortIdentity = c->best->dataset.sender;
|
||||
pds->grandmasterIdentity = msg->announce.grandmasterIdentity;
|
||||
pds->grandmasterClockQuality = msg->announce.grandmasterClockQuality;
|
||||
pds->grandmasterPriority1 = msg->announce.grandmasterPriority1;
|
||||
pds->grandmasterPriority2 = msg->announce.grandmasterPriority2;
|
||||
c->tds.currentUtcOffset = msg->announce.currentUtcOffset;
|
||||
c->tds.currentUtcOffsetValid = field_is_set(msg, 1, UTC_OFF_VALID);
|
||||
c->tds.leap61 = field_is_set(msg, 1, LEAP_61);
|
||||
|
@ -458,9 +460,9 @@ struct clock *clock_create(int phc_index, struct interface *iface, int count,
|
|||
|
||||
/* Initialize the parentDS. */
|
||||
clock_update_grandmaster(c);
|
||||
c->dad.parentStats = 0;
|
||||
c->dad.observedParentOffsetScaledLogVariance = 0xffff;
|
||||
c->dad.observedParentClockPhaseChangeRate = 0x7fffffff;
|
||||
c->dad.pds.parentStats = 0;
|
||||
c->dad.pds.observedParentOffsetScaledLogVariance = 0xffff;
|
||||
c->dad.pds.observedParentClockPhaseChangeRate = 0x7fffffff;
|
||||
c->dad.ptl = c->ptl;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(c->pollfd); i++) {
|
||||
|
@ -658,14 +660,14 @@ void clock_manage(struct clock *c, struct port *p, struct ptp_message *msg)
|
|||
}
|
||||
}
|
||||
|
||||
struct parentDS *clock_parent_ds(struct clock *c)
|
||||
struct parent_ds *clock_parent_ds(struct clock *c)
|
||||
{
|
||||
return &c->dad;
|
||||
}
|
||||
|
||||
struct PortIdentity clock_parent_identity(struct clock *c)
|
||||
{
|
||||
return c->dad.parentPortIdentity;
|
||||
return c->dad.pds.parentPortIdentity;
|
||||
}
|
||||
|
||||
int clock_poll(struct clock *c)
|
||||
|
|
2
clock.h
2
clock.h
|
@ -128,7 +128,7 @@ void clock_manage(struct clock *c, struct port *p, struct ptp_message *msg);
|
|||
* @param c The clock instance.
|
||||
* @return A pointer to the parent data set of the clock.
|
||||
*/
|
||||
struct parentDS *clock_parent_ds(struct clock *c);
|
||||
struct parent_ds *clock_parent_ds(struct clock *c);
|
||||
|
||||
/**
|
||||
* Obtain the parent port identity from a clock's parent data set.
|
||||
|
|
7
ds.h
7
ds.h
|
@ -63,13 +63,18 @@ struct currentDS {
|
|||
|
||||
struct parentDS {
|
||||
struct PortIdentity parentPortIdentity;
|
||||
Boolean parentStats;
|
||||
UInteger8 parentStats;
|
||||
UInteger8 reserved;
|
||||
UInteger16 observedParentOffsetScaledLogVariance;
|
||||
Integer32 observedParentClockPhaseChangeRate;
|
||||
UInteger8 grandmasterPriority1;
|
||||
struct ClockQuality grandmasterClockQuality;
|
||||
UInteger8 grandmasterPriority2;
|
||||
struct ClockIdentity grandmasterIdentity;
|
||||
} PACKED;
|
||||
|
||||
struct parent_ds {
|
||||
struct parentDS pds;
|
||||
struct ClockIdentity *ptl;
|
||||
unsigned int path_length;
|
||||
};
|
||||
|
|
14
port.c
14
port.c
|
@ -313,7 +313,7 @@ static void free_foreign_masters(struct port *p)
|
|||
}
|
||||
|
||||
static int path_trace_append(struct port *p, struct ptp_message *m,
|
||||
struct parentDS *dad)
|
||||
struct parent_ds *dad)
|
||||
{
|
||||
struct path_trace_tlv *ptt;
|
||||
int length = 1 + dad->path_length;
|
||||
|
@ -645,7 +645,7 @@ out:
|
|||
|
||||
static int port_tx_announce(struct port *p)
|
||||
{
|
||||
struct parentDS *dad = clock_parent_ds(p->clock);
|
||||
struct parent_ds *dad = clock_parent_ds(p->clock);
|
||||
struct timePropertiesDS *tp = clock_time_properties(p->clock);
|
||||
struct ptp_message *msg;
|
||||
int cnt, err = 0, pdulen;
|
||||
|
@ -683,10 +683,10 @@ static int port_tx_announce(struct port *p)
|
|||
msg->header.flagField[1] |= FREQ_TRACEABLE;
|
||||
|
||||
msg->announce.currentUtcOffset = tp->currentUtcOffset;
|
||||
msg->announce.grandmasterPriority1 = dad->grandmasterPriority1;
|
||||
msg->announce.grandmasterClockQuality = dad->grandmasterClockQuality;
|
||||
msg->announce.grandmasterPriority2 = dad->grandmasterPriority2;
|
||||
msg->announce.grandmasterIdentity = dad->grandmasterIdentity;
|
||||
msg->announce.grandmasterPriority1 = dad->pds.grandmasterPriority1;
|
||||
msg->announce.grandmasterClockQuality = dad->pds.grandmasterClockQuality;
|
||||
msg->announce.grandmasterPriority2 = dad->pds.grandmasterPriority2;
|
||||
msg->announce.grandmasterIdentity = dad->pds.grandmasterIdentity;
|
||||
msg->announce.stepsRemoved = clock_steps_removed(p->clock);
|
||||
msg->announce.timeSource = tp->timeSource;
|
||||
|
||||
|
@ -919,7 +919,7 @@ static int update_current_master(struct port *p, struct ptp_message *m)
|
|||
{
|
||||
struct foreign_clock *fc = p->best;
|
||||
struct ptp_message *tmp;
|
||||
struct parentDS *dad;
|
||||
struct parent_ds *dad;
|
||||
struct path_trace_tlv *ptt;
|
||||
|
||||
if (!msg_source_equal(m, fc))
|
||||
|
|
Loading…
Reference in New Issue