ptp4l: Allow per-port customized port defaults
this patch allows each port to maintain its own pod structure since it is only used in ports. This will allow the user to configure any special settings per port. It takes a copy of the default pod, and a future patch will allow the configuration file to set per-port specific changes -v2 * Minor change to fix merge with previous patch Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>master
parent
733d4ccf9e
commit
7a69db2379
5
clock.c
5
clock.c
|
@ -210,8 +210,7 @@ UInteger8 clock_class(struct clock *c)
|
|||
}
|
||||
|
||||
struct clock *clock_create(int phc_index, struct interface *iface, int count,
|
||||
enum timestamp_type timestamping, struct defaultDS *ds,
|
||||
struct port_defaults *pod)
|
||||
enum timestamp_type timestamping, struct defaultDS *ds)
|
||||
{
|
||||
int i, max_adj, sw_ts = timestamping == TS_SOFTWARE ? 1 : 0;
|
||||
struct clock *c = &the_clock;
|
||||
|
@ -267,7 +266,7 @@ struct clock *clock_create(int phc_index, struct interface *iface, int count,
|
|||
c->fault_timeout = FAULT_RESET_SECONDS;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
c->port[i] = port_open(pod, phc_index, timestamping, 1+i, &iface[i], c);
|
||||
c->port[i] = port_open(phc_index, timestamping, 1+i, &iface[i], c);
|
||||
if (!c->port[i]) {
|
||||
pr_err("failed to open port %s", iface[i].name);
|
||||
return NULL;
|
||||
|
|
4
clock.h
4
clock.h
|
@ -65,12 +65,10 @@ UInteger8 clock_class(struct clock *c);
|
|||
* @param count The number of elements in @a interfaces.
|
||||
* @param timestamping The timestamping mode for this clock.
|
||||
* @param ds A pointer to a default data set for the clock.
|
||||
* @param pod A pointer to a default port data set for the clock.
|
||||
* @return A pointer to the single global clock instance.
|
||||
*/
|
||||
struct clock *clock_create(int phc_index, struct interface *iface, int count,
|
||||
enum timestamp_type timestamping, struct defaultDS *ds,
|
||||
struct port_defaults *pod);
|
||||
enum timestamp_type timestamping, struct defaultDS *ds);
|
||||
|
||||
/**
|
||||
* Obtains a clock's default data set.
|
||||
|
|
2
config.c
2
config.c
|
@ -177,6 +177,8 @@ int config_create_interface(char *name, struct config *cfg)
|
|||
strncpy(iface->name, name, MAX_IFNAME_SIZE);
|
||||
iface->dm = cfg->dm;
|
||||
iface->transport = cfg->transport;
|
||||
memcpy(&iface->pod, &cfg->pod, sizeof(cfg->pod));
|
||||
|
||||
cfg->nports++;
|
||||
|
||||
return i;
|
||||
|
|
1
config.h
1
config.h
|
@ -32,6 +32,7 @@ struct interface {
|
|||
char name[MAX_IFNAME_SIZE + 1];
|
||||
enum delay_mechanism dm;
|
||||
enum transport_type transport;
|
||||
struct port_defaults pod;
|
||||
};
|
||||
|
||||
struct config {
|
||||
|
|
5
port.c
5
port.c
|
@ -1537,8 +1537,7 @@ struct ptp_message *port_management_reply(struct PortIdentity pid,
|
|||
return msg;
|
||||
}
|
||||
|
||||
struct port *port_open(struct port_defaults *pod,
|
||||
int phc_index,
|
||||
struct port *port_open(int phc_index,
|
||||
enum timestamp_type timestamping,
|
||||
int number,
|
||||
struct interface *interface,
|
||||
|
@ -1561,7 +1560,7 @@ struct port *port_open(struct port_defaults *pod,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
p->pod = *pod;
|
||||
p->pod = interface->pod;
|
||||
p->name = interface->name;
|
||||
p->clock = clock;
|
||||
p->trp = transport_create(interface->transport);
|
||||
|
|
4
port.h
4
port.h
|
@ -128,7 +128,6 @@ struct ptp_message *port_management_reply(struct PortIdentity pid,
|
|||
|
||||
/**
|
||||
* Open a network port.
|
||||
* @param pod A pointer to a default port data set for this port.
|
||||
* @param phc_index The PHC device index for the network device.
|
||||
* @param timestamping The timestamping mode for this port.
|
||||
* @param number An arbitrary number assigned to this port.
|
||||
|
@ -136,8 +135,7 @@ struct ptp_message *port_management_reply(struct PortIdentity pid,
|
|||
* @param clock A pointer to the system PTP clock.
|
||||
* @return A pointer to an open port on success, or NULL otherwise.
|
||||
*/
|
||||
struct port *port_open(struct port_defaults *pod,
|
||||
int phc_index,
|
||||
struct port *port_open(int phc_index,
|
||||
enum timestamp_type timestamping,
|
||||
int number,
|
||||
struct interface *interface,
|
||||
|
|
3
ptp4l.c
3
ptp4l.c
|
@ -112,7 +112,6 @@ int main(int argc, char *argv[])
|
|||
enum timestamp_type *timestamping = &cfg_settings.timestamping;
|
||||
struct clock *clock;
|
||||
struct defaultDS *ds = &cfg_settings.dds;
|
||||
struct port_defaults *pod = &cfg_settings.pod;
|
||||
int phc_index = -1;
|
||||
|
||||
/* Process the command line arguments. */
|
||||
|
@ -222,7 +221,7 @@ int main(int argc, char *argv[])
|
|||
ds->clockQuality.clockClass = 255;
|
||||
}
|
||||
|
||||
clock = clock_create(phc_index, iface, *nports, *timestamping, ds, pod);
|
||||
clock = clock_create(phc_index, iface, *nports, *timestamping, ds);
|
||||
if (!clock) {
|
||||
fprintf(stderr, "failed to create a clock\n");
|
||||
return -1;
|
||||
|
|
Loading…
Reference in New Issue