Add a command line option to select the peer delay mechanism.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2012-04-05 12:04:11 +02:00
parent a8a5409b04
commit b35a45d1a4
3 changed files with 20 additions and 3 deletions

View File

@ -236,7 +236,7 @@ struct clock *clock_create(char *phc, struct interface *iface, int count,
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
c->port[i] = port_open(pod, iface[i].name, iface[i].transport, c->port[i] = port_open(pod, iface[i].name, iface[i].transport,
iface[i].timestamping, 1+i, DM_E2E, c); iface[i].timestamping, 1+i, iface[i].dm, c);
if (!c->port[i]) { if (!c->port[i]) {
pr_err("failed to open port %s", iface[i].name); pr_err("failed to open port %s", iface[i].name);
return NULL; return NULL;

View File

@ -20,6 +20,7 @@
#ifndef HAVE_CLOCK_H #ifndef HAVE_CLOCK_H
#define HAVE_CLOCK_H #define HAVE_CLOCK_H
#include "dm.h"
#include "ds.h" #include "ds.h"
#include "servo.h" #include "servo.h"
#include "tmv.h" #include "tmv.h"
@ -30,6 +31,7 @@
/** Defines a network interface, with PTP options. */ /** Defines a network interface, with PTP options. */
struct interface { struct interface {
char *name; char *name;
enum delay_mechanism dm;
enum transport_type transport; enum transport_type transport;
enum timestamp_type timestamping; enum timestamp_type timestamping;
}; };

19
ptp4l.c
View File

@ -57,7 +57,11 @@ static void usage(char *progname)
{ {
fprintf(stderr, fprintf(stderr,
"\nusage: %s [options]\n\n" "\nusage: %s [options]\n\n"
" Network Transport\n\n" " Delay Mechanism (per interface)\n\n"
" -A Auto, starting with E2E\n"
" -E E2E, delay request-response (default)\n"
" -P P2P, peer delay mechanism\n\n"
" Network Transport (per interface)\n\n"
" -2 IEEE 802.3\n" " -2 IEEE 802.3\n"
" -4 UDP IPV4 (default)\n" " -4 UDP IPV4 (default)\n"
" -6 UDP IPV6\n\n" " -6 UDP IPV6\n\n"
@ -85,6 +89,7 @@ int main(int argc, char *argv[])
char *config = NULL, *phc = DEFAULT_PHC, *progname; char *config = NULL, *phc = DEFAULT_PHC, *progname;
int c, i, nports = 0, slaveonly = 0; int c, i, nports = 0, slaveonly = 0;
struct interface iface[MAX_PORTS]; struct interface iface[MAX_PORTS];
enum delay_mechanism dm = DM_E2E;
enum transport_type transport = TRANS_UDP_IPV4; enum transport_type transport = TRANS_UDP_IPV4;
enum timestamp_type timestamping = TS_HARDWARE; enum timestamp_type timestamping = TS_HARDWARE;
struct clock *clock; struct clock *clock;
@ -92,7 +97,7 @@ int main(int argc, char *argv[])
/* Process the command line arguments. */ /* Process the command line arguments. */
progname = strrchr(argv[0], '/'); progname = strrchr(argv[0], '/');
progname = progname ? 1+progname : argv[0]; progname = progname ? 1+progname : argv[0];
while (EOF != (c = getopt(argc, argv, "246f:hi:l:mp:qrsvz"))) { while (EOF != (c = getopt(argc, argv, "246AEf:hi:l:mPp:qrsvz"))) {
switch (c) { switch (c) {
case '2': case '2':
transport = TRANS_IEEE_802_3; transport = TRANS_IEEE_802_3;
@ -103,12 +108,19 @@ int main(int argc, char *argv[])
case '6': case '6':
transport = TRANS_UDP_IPV6; transport = TRANS_UDP_IPV6;
break; break;
case 'A':
dm = DM_AUTO;
break;
case 'E':
dm = DM_E2E;
break;
case 'f': case 'f':
config = optarg; config = optarg;
break; break;
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].transport = transport; iface[nports].transport = transport;
nports++; nports++;
} else { } else {
@ -122,6 +134,9 @@ int main(int argc, char *argv[])
case 'm': case 'm':
slaveonly = 1; slaveonly = 1;
break; break;
case 'P':
dm = DM_P2P;
break;
case 'p': case 'p':
phc = optarg; phc = optarg;
break; break;