Accept external PHC devices from the command line.
A single, external PTP Hardware Clock device may be wired to one or more MAC devices, providing the MACs with an input clock. This patch adds support for such a hardware architecture by letting the command line PHC override the one discovered via the ethtool ioctl. Signed-off-by: Richard Cochran <richardcochran@gmail.com>master
parent
e0580929f4
commit
581a6bd59b
11
clock.c
11
clock.c
|
@ -771,8 +771,8 @@ struct currentDS *clock_current_dataset(struct clock *c)
|
||||||
return &c->cur;
|
return &c->cur;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int clock_add_port(struct clock *c, int phc_index,
|
static int clock_add_port(struct clock *c, const char *phc_device,
|
||||||
enum timestamp_type timestamping,
|
int phc_index, enum timestamp_type timestamping,
|
||||||
struct interface *iface)
|
struct interface *iface)
|
||||||
{
|
{
|
||||||
struct port *p, *piter, *lastp = NULL;
|
struct port *p, *piter, *lastp = NULL;
|
||||||
|
@ -780,7 +780,8 @@ static int clock_add_port(struct clock *c, int phc_index,
|
||||||
if (clock_resize_pollfd(c, c->nports + 1)) {
|
if (clock_resize_pollfd(c, c->nports + 1)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
p = port_open(phc_index, timestamping, ++c->last_port_number, iface, c);
|
p = port_open(phc_device, phc_index, timestamping,
|
||||||
|
++c->last_port_number, iface, c);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
/* No need to shrink pollfd */
|
/* No need to shrink pollfd */
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1136,7 +1137,7 @@ struct clock *clock_create(enum clock_type type, struct config *config,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create the UDS interface. */
|
/* Create the UDS interface. */
|
||||||
c->uds_port = port_open(phc_index, timestamping, 0, udsif, c);
|
c->uds_port = port_open(phc_device, phc_index, timestamping, 0, udsif, c);
|
||||||
if (!c->uds_port) {
|
if (!c->uds_port) {
|
||||||
pr_err("failed to open the UDS port");
|
pr_err("failed to open the UDS port");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1145,7 +1146,7 @@ struct clock *clock_create(enum clock_type type, struct config *config,
|
||||||
|
|
||||||
/* Create the ports. */
|
/* Create the ports. */
|
||||||
STAILQ_FOREACH(iface, &config->interfaces, list) {
|
STAILQ_FOREACH(iface, &config->interfaces, list) {
|
||||||
if (clock_add_port(c, phc_index, timestamping, iface)) {
|
if (clock_add_port(c, phc_device, phc_index, timestamping, iface)) {
|
||||||
pr_err("failed to open port %s", iface->name);
|
pr_err("failed to open port %s", iface->name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
8
port.c
8
port.c
|
@ -2934,7 +2934,8 @@ err:
|
||||||
msg_put(msg);
|
msg_put(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct port *port_open(int phc_index,
|
struct port *port_open(const char *phc_device,
|
||||||
|
int phc_index,
|
||||||
enum timestamp_type timestamping,
|
enum timestamp_type timestamping,
|
||||||
int number,
|
int number,
|
||||||
struct interface *interface,
|
struct interface *interface,
|
||||||
|
@ -2998,6 +2999,11 @@ struct port *port_open(int phc_index,
|
||||||
if (p->jbod) {
|
if (p->jbod) {
|
||||||
pr_warning("port %d: just a bunch of devices", number);
|
pr_warning("port %d: just a bunch of devices", number);
|
||||||
p->phc_index = interface->ts_info.phc_index;
|
p->phc_index = interface->ts_info.phc_index;
|
||||||
|
} else if (phc_device) {
|
||||||
|
pr_warning("port %d: taking %s from the command line, "
|
||||||
|
"not the attached ptp%d", number, phc_device,
|
||||||
|
interface->ts_info.phc_index);
|
||||||
|
p->phc_index = phc_index;
|
||||||
} else {
|
} else {
|
||||||
pr_err("port %d: PHC device mismatch", number);
|
pr_err("port %d: PHC device mismatch", number);
|
||||||
pr_err("port %d: /dev/ptp%d requested, ptp%d attached",
|
pr_err("port %d: /dev/ptp%d requested, ptp%d attached",
|
||||||
|
|
4
port.h
4
port.h
|
@ -192,6 +192,7 @@ void port_notify_event(struct port *p, enum notification event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open a network port.
|
* Open a network port.
|
||||||
|
* @param phc_device The name of PHC device as found on the command line.
|
||||||
* @param phc_index The PHC device index for the network device.
|
* @param phc_index The PHC device index for the network device.
|
||||||
* @param timestamping The timestamping mode for this port.
|
* @param timestamping The timestamping mode for this port.
|
||||||
* @param number An arbitrary number assigned to this port.
|
* @param number An arbitrary number assigned to this port.
|
||||||
|
@ -199,7 +200,8 @@ void port_notify_event(struct port *p, enum notification event);
|
||||||
* @param clock A pointer to the system PTP clock.
|
* @param clock A pointer to the system PTP clock.
|
||||||
* @return A pointer to an open port on success, or NULL otherwise.
|
* @return A pointer to an open port on success, or NULL otherwise.
|
||||||
*/
|
*/
|
||||||
struct port *port_open(int phc_index,
|
struct port *port_open(const char *phc_device,
|
||||||
|
int phc_index,
|
||||||
enum timestamp_type timestamping,
|
enum timestamp_type timestamping,
|
||||||
int number,
|
int number,
|
||||||
struct interface *interface,
|
struct interface *interface,
|
||||||
|
|
Loading…
Reference in New Issue