Skip to content

Commit

Permalink
Add an option to assume two step messaging.
Browse files Browse the repository at this point in the history
Some commercial 802.1AS switches do not feel obliged to set the two step
flag. When we try to synchronize to their apparent one step sync messages,
nothing good happens. This commit adds a global option to work around the
issue.

Signed-off-by: Richard Cochran <[email protected]>
  • Loading branch information
richardcochran committed Jul 28, 2012
1 parent 4b0f4fd commit eed8ed0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ static void scan_line(char *s, struct config *cfg)

pod->transportSpecific = u8 << 4;

} else if (1 == sscanf(s, " assume_two_step %u", &val)) {

*cfg->assume_two_step = val ? 1 : 0;

} else if (1 == sscanf(s, " tx_timestamp_retries %u", &val)) {

if (val > 0)
Expand Down
1 change: 1 addition & 0 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
struct config {
struct defaultDS *dds;
struct port_defaults *pod;
int *assume_two_step;
int *tx_timestamp_retries;
int *rx_timestamp_l2only;
double *pi_proportional_const;
Expand Down
7 changes: 7 additions & 0 deletions msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,20 @@ void msg_put(struct ptp_message *m);
*/
int msg_sots_missing(struct ptp_message *m);

/**
* Work around buggy 802.1AS switches.
*/
extern int assume_two_step;

/**
* Test whether a message is one-step message.
* @param m Message to test.
* @return One if the message is a one-step, zero otherwise.
*/
static inline Boolean one_step(struct ptp_message *m)
{
if (assume_two_step)
return 0;
return !field_is_set(m, 0, TWO_STEP);
}

Expand Down
2 changes: 2 additions & 0 deletions ptp4l.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#define DEFAULT_PHC "/dev/ptp0"

int assume_two_step;
int sk_tx_retries = 2, sk_prefer_layer2 = 0; /*see sk.c*/
double configured_pi_kp, configured_pi_ki; /*see pi.c*/
extern unsigned char ptp_dst_mac[]; /*see raw.c*/
Expand Down Expand Up @@ -219,6 +220,7 @@ int main(int argc, char *argv[])

cfg_settings.dds = &ds;
cfg_settings.pod = &pod;
cfg_settings.assume_two_step = &assume_two_step;
cfg_settings.tx_timestamp_retries = &sk_tx_retries;
cfg_settings.rx_timestamp_l2only = &sk_prefer_layer2;
cfg_settings.pi_proportional_const = &configured_pi_kp;
Expand Down

0 comments on commit eed8ed0

Please sign in to comment.