ptp4l: move port default values into cfg_settings

move the dm, timestamping, and transport settings into the cfg_settings, and
treat them as defaults for new ports.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
master
Jacob Keller 2012-08-20 10:56:35 -07:00 committed by Richard Cochran
parent 8250e80581
commit 5a0b6c3cd3
2 changed files with 24 additions and 16 deletions

View File

@ -38,6 +38,10 @@ struct config {
struct interface iface[MAX_PORTS]; struct interface iface[MAX_PORTS];
int nports; int nports;
enum timestamp_type timestamping;
enum transport_type transport;
enum delay_mechanism dm;
struct defaultDS dds; struct defaultDS dds;
struct port_defaults pod; struct port_defaults pod;
int *assume_two_step; int *assume_two_step;

36
ptp4l.c
View File

@ -57,6 +57,10 @@ static struct config cfg_settings = {
.follow_up_info = 0, .follow_up_info = 0,
}, },
.timestamping = TS_HARDWARE,
.dm = DM_E2E,
.transport = TRANS_UDP_IPV4,
.assume_two_step = &assume_two_step, .assume_two_step = &assume_two_step,
.tx_timestamp_retries = &sk_tx_retries, .tx_timestamp_retries = &sk_tx_retries,
.rx_timestamp_l2only = &sk_prefer_layer2, .rx_timestamp_l2only = &sk_prefer_layer2,
@ -103,9 +107,9 @@ int main(int argc, char *argv[])
int c, slaveonly = 0; int c, slaveonly = 0;
struct interface *iface = cfg_settings.iface; struct interface *iface = cfg_settings.iface;
int *nports = &cfg_settings.nports; int *nports = &cfg_settings.nports;
enum delay_mechanism dm = DM_E2E; enum delay_mechanism *dm = &cfg_settings.dm;
enum transport_type transport = TRANS_UDP_IPV4; enum transport_type *transport = &cfg_settings.transport;
enum timestamp_type timestamping = TS_HARDWARE; enum timestamp_type *timestamping = &cfg_settings.timestamping;
struct clock *clock; struct clock *clock;
struct defaultDS *ds = &cfg_settings.dds; struct defaultDS *ds = &cfg_settings.dds;
struct port_defaults *pod = &cfg_settings.pod; struct port_defaults *pod = &cfg_settings.pod;
@ -117,31 +121,31 @@ int main(int argc, char *argv[])
while (EOF != (c = getopt(argc, argv, "AEP246HSLf:i:p:sl:qvh"))) { while (EOF != (c = getopt(argc, argv, "AEP246HSLf:i:p:sl:qvh"))) {
switch (c) { switch (c) {
case 'A': case 'A':
dm = DM_AUTO; *dm = DM_AUTO;
break; break;
case 'E': case 'E':
dm = DM_E2E; *dm = DM_E2E;
break; break;
case 'P': case 'P':
dm = DM_P2P; *dm = DM_P2P;
break; break;
case '2': case '2':
transport = TRANS_IEEE_802_3; *transport = TRANS_IEEE_802_3;
break; break;
case '4': case '4':
transport = TRANS_UDP_IPV4; *transport = TRANS_UDP_IPV4;
break; break;
case '6': case '6':
transport = TRANS_UDP_IPV6; *transport = TRANS_UDP_IPV6;
break; break;
case 'H': case 'H':
timestamping = TS_HARDWARE; *timestamping = TS_HARDWARE;
break; break;
case 'S': case 'S':
timestamping = TS_SOFTWARE; *timestamping = TS_SOFTWARE;
break; break;
case 'L': case 'L':
timestamping = TS_LEGACY_HW; *timestamping = TS_LEGACY_HW;
break; break;
case 'f': case 'f':
config = optarg; config = optarg;
@ -149,8 +153,8 @@ int main(int argc, char *argv[])
case 'i': case 'i':
if (*nports < MAX_PORTS) { if (*nports < MAX_PORTS) {
iface[*nports].name = optarg; iface[*nports].name = optarg;
iface[*nports].dm = dm; iface[*nports].dm = *dm;
iface[*nports].transport = transport; iface[*nports].transport = *transport;
(*nports)++; (*nports)++;
} else { } else {
fprintf(stderr, "too many interfaces\n"); fprintf(stderr, "too many interfaces\n");
@ -191,7 +195,7 @@ int main(int argc, char *argv[])
} }
/* determine PHC Clock index */ /* determine PHC Clock index */
if (timestamping == TS_SOFTWARE || timestamping == TS_LEGACY_HW) { if (*timestamping == TS_SOFTWARE || *timestamping == TS_LEGACY_HW) {
phc_index = -1; phc_index = -1;
} else if (req_phc) { } else if (req_phc) {
if (1 != sscanf(req_phc, "/dev/ptp%d", &phc_index)) { if (1 != sscanf(req_phc, "/dev/ptp%d", &phc_index)) {
@ -223,7 +227,7 @@ int main(int argc, char *argv[])
ds->clockQuality.clockClass = 255; ds->clockQuality.clockClass = 255;
} }
clock = clock_create(phc_index, iface, *nports, timestamping, ds, pod); clock = clock_create(phc_index, iface, *nports, *timestamping, ds, pod);
if (!clock) { if (!clock) {
fprintf(stderr, "failed to create a clock\n"); fprintf(stderr, "failed to create a clock\n");
return -1; return -1;