ptp4l: make ds and pod part of cfg_settings
make ds and pod static inside cfg_settings instead of created via pointers. Also statically initialize the defaults. Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>master
parent
08a6a14e6c
commit
8250e80581
4
config.c
4
config.c
|
@ -30,8 +30,8 @@ static void scan_line(char *s, struct config *cfg)
|
||||||
UInteger8 u8;
|
UInteger8 u8;
|
||||||
unsigned char mac[MAC_LEN];
|
unsigned char mac[MAC_LEN];
|
||||||
|
|
||||||
struct defaultDS *dds = cfg->dds;
|
struct defaultDS *dds = &cfg->dds;
|
||||||
struct port_defaults *pod = cfg->pod;
|
struct port_defaults *pod = &cfg->pod;
|
||||||
|
|
||||||
if (1 == sscanf(s, " twoStepFlag %d", &val)) {
|
if (1 == sscanf(s, " twoStepFlag %d", &val)) {
|
||||||
|
|
||||||
|
|
4
config.h
4
config.h
|
@ -38,8 +38,8 @@ struct config {
|
||||||
struct interface iface[MAX_PORTS];
|
struct interface iface[MAX_PORTS];
|
||||||
int nports;
|
int nports;
|
||||||
|
|
||||||
struct defaultDS *dds;
|
struct defaultDS dds;
|
||||||
struct port_defaults *pod;
|
struct port_defaults pod;
|
||||||
int *assume_two_step;
|
int *assume_two_step;
|
||||||
int *tx_timestamp_retries;
|
int *tx_timestamp_retries;
|
||||||
int *rx_timestamp_l2only;
|
int *rx_timestamp_l2only;
|
||||||
|
|
69
ptp4l.c
69
ptp4l.c
|
@ -35,9 +35,36 @@ extern unsigned char ptp_dst_mac[]; /*see raw.c*/
|
||||||
extern unsigned char p2p_dst_mac[]; /*see raw.c*/
|
extern unsigned char p2p_dst_mac[]; /*see raw.c*/
|
||||||
|
|
||||||
static int running = 1;
|
static int running = 1;
|
||||||
static struct defaultDS ds;
|
|
||||||
static struct port_defaults pod;
|
static struct config cfg_settings = {
|
||||||
static struct config cfg_settings;
|
.dds = {
|
||||||
|
.slaveOnly = FALSE,
|
||||||
|
.priority1 = 128,
|
||||||
|
.clockQuality.clockClass = 248,
|
||||||
|
.clockQuality.clockAccuracy = 0xfe,
|
||||||
|
.clockQuality.offsetScaledLogVariance = 0xffff,
|
||||||
|
.priority2 = 128,
|
||||||
|
},
|
||||||
|
|
||||||
|
.pod = {
|
||||||
|
.logAnnounceInterval = 1,
|
||||||
|
.logSyncInterval = 0,
|
||||||
|
.logMinDelayReqInterval = 0,
|
||||||
|
.logMinPdelayReqInterval = 0,
|
||||||
|
.announceReceiptTimeout = 3,
|
||||||
|
.transportSpecific = 0,
|
||||||
|
.path_trace_enabled = 0,
|
||||||
|
.follow_up_info = 0,
|
||||||
|
},
|
||||||
|
|
||||||
|
.assume_two_step = &assume_two_step,
|
||||||
|
.tx_timestamp_retries = &sk_tx_retries,
|
||||||
|
.rx_timestamp_l2only = &sk_prefer_layer2,
|
||||||
|
.pi_proportional_const = &configured_pi_kp,
|
||||||
|
.pi_integral_const = &configured_pi_ki,
|
||||||
|
.ptp_dst_mac = ptp_dst_mac,
|
||||||
|
.p2p_dst_mac = p2p_dst_mac,
|
||||||
|
};
|
||||||
|
|
||||||
static void usage(char *progname)
|
static void usage(char *progname)
|
||||||
{
|
{
|
||||||
|
@ -80,6 +107,8 @@ int main(int argc, char *argv[])
|
||||||
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;
|
||||||
|
struct defaultDS *ds = &cfg_settings.dds;
|
||||||
|
struct port_defaults *pod = &cfg_settings.pod;
|
||||||
int phc_index = -1;
|
int phc_index = -1;
|
||||||
|
|
||||||
/* Process the command line arguments. */
|
/* Process the command line arguments. */
|
||||||
|
@ -179,48 +208,22 @@ int main(int argc, char *argv[])
|
||||||
pr_info("selected /dev/ptp%d as PTP clock", phc_index);
|
pr_info("selected /dev/ptp%d as PTP clock", phc_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
ds.slaveOnly = FALSE;
|
if (generate_clock_identity(&ds->clockIdentity, iface[0].name)) {
|
||||||
ds.priority1 = 128;
|
|
||||||
ds.clockQuality.clockClass = 248;
|
|
||||||
ds.clockQuality.clockAccuracy = 0xfe;
|
|
||||||
ds.clockQuality.offsetScaledLogVariance = 0xffff;
|
|
||||||
ds.priority2 = 128;
|
|
||||||
|
|
||||||
pod.logAnnounceInterval = 1;
|
|
||||||
pod.logSyncInterval = 0;
|
|
||||||
pod.logMinDelayReqInterval = 0;
|
|
||||||
pod.logMinPdelayReqInterval = 0;
|
|
||||||
pod.announceReceiptTimeout = 3;
|
|
||||||
pod.transportSpecific = 0;
|
|
||||||
pod.path_trace_enabled = 0;
|
|
||||||
pod.follow_up_info = 0;
|
|
||||||
|
|
||||||
if (generate_clock_identity(&ds.clockIdentity, iface[0].name)) {
|
|
||||||
fprintf(stderr, "failed to generate a clock identity\n");
|
fprintf(stderr, "failed to generate a clock identity\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
|
||||||
cfg_settings.pi_integral_const = &configured_pi_ki;
|
|
||||||
cfg_settings.ptp_dst_mac = ptp_dst_mac;
|
|
||||||
cfg_settings.p2p_dst_mac = p2p_dst_mac;
|
|
||||||
|
|
||||||
if (config && config_read(config, &cfg_settings)) {
|
if (config && config_read(config, &cfg_settings)) {
|
||||||
fprintf(stderr, "failed to read configuration file\n");
|
fprintf(stderr, "failed to read configuration file\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slaveonly) {
|
if (slaveonly) {
|
||||||
ds.slaveOnly = TRUE;
|
ds->slaveOnly = TRUE;
|
||||||
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;
|
||||||
|
|
Loading…
Reference in New Issue