timemaster: add support for bonded interfaces.
Use the rtnl_get_ts_device() function to get the name of the slave interface which will be timestamping PTP packets and use it instead of the master interface to check the timestamping capabilities and PHC. Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>master
parent
742f878821
commit
e5ba2dae5f
2
makefile
2
makefile
|
@ -60,7 +60,7 @@ hwstamp_ctl: hwstamp_ctl.o version.o
|
||||||
|
|
||||||
phc_ctl: phc_ctl.o phc.o sk.o util.o clockadj.o sysoff.o print.o version.o
|
phc_ctl: phc_ctl.o phc.o sk.o util.o clockadj.o sysoff.o print.o version.o
|
||||||
|
|
||||||
timemaster: print.o sk.o timemaster.o util.o version.o
|
timemaster: print.o rtnl.o sk.o timemaster.o util.o version.o
|
||||||
|
|
||||||
version.o: .version version.sh $(filter-out version.d,$(DEPEND))
|
version.o: .version version.sh $(filter-out version.d,$(DEPEND))
|
||||||
|
|
||||||
|
|
27
timemaster.c
27
timemaster.c
|
@ -23,6 +23,7 @@
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <linux/net_tstamp.h>
|
#include <linux/net_tstamp.h>
|
||||||
|
#include <net/if.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <spawn.h>
|
#include <spawn.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
@ -35,6 +36,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "print.h"
|
#include "print.h"
|
||||||
|
#include "rtnl.h"
|
||||||
#include "sk.h"
|
#include "sk.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
@ -674,6 +676,7 @@ static int add_ptp_source(struct ptp_domain *source,
|
||||||
{
|
{
|
||||||
struct config_file *config_file;
|
struct config_file *config_file;
|
||||||
char **command, *uds_path, **interfaces, *message_tag;
|
char **command, *uds_path, **interfaces, *message_tag;
|
||||||
|
char ts_interface[IF_NAMESIZE];
|
||||||
int i, j, num_interfaces, *phc, *phcs, hw_ts, sw_ts;
|
int i, j, num_interfaces, *phc, *phcs, hw_ts, sw_ts;
|
||||||
struct sk_ts_info ts_info;
|
struct sk_ts_info ts_info;
|
||||||
|
|
||||||
|
@ -696,26 +699,38 @@ static int add_ptp_source(struct ptp_domain *source,
|
||||||
for (i = 0; i < num_interfaces; i++) {
|
for (i = 0; i < num_interfaces; i++) {
|
||||||
phcs[i] = -1;
|
phcs[i] = -1;
|
||||||
|
|
||||||
/* check if the interface has a usable PHC */
|
/*
|
||||||
if (sk_get_ts_info(source->interfaces[i], &ts_info)) {
|
* if it is a bonded interface, use the name of the active
|
||||||
pr_err("failed to get time stamping info for %s",
|
* slave interface (which will be timestamping packets)
|
||||||
|
*/
|
||||||
|
if (!rtnl_get_ts_device(source->interfaces[i], ts_interface)) {
|
||||||
|
pr_debug("slave interface of %s: %s",
|
||||||
|
source->interfaces[i], ts_interface);
|
||||||
|
} else {
|
||||||
|
snprintf(ts_interface, sizeof(ts_interface), "%s",
|
||||||
source->interfaces[i]);
|
source->interfaces[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check if the interface has a usable PHC */
|
||||||
|
if (sk_get_ts_info(ts_interface, &ts_info)) {
|
||||||
|
pr_err("failed to get time stamping info for %s",
|
||||||
|
ts_interface);
|
||||||
free(phcs);
|
free(phcs);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((ts_info.so_timestamping & hw_ts) != hw_ts)) {
|
if (((ts_info.so_timestamping & hw_ts) != hw_ts)) {
|
||||||
pr_debug("interface %s: no PHC", source->interfaces[i]);
|
pr_debug("interface %s: no PHC", ts_interface);
|
||||||
if ((ts_info.so_timestamping & sw_ts) != sw_ts) {
|
if ((ts_info.so_timestamping & sw_ts) != sw_ts) {
|
||||||
pr_err("time stamping not supported on %s",
|
pr_err("time stamping not supported on %s",
|
||||||
source->interfaces[i]);
|
ts_interface);
|
||||||
free(phcs);
|
free(phcs);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
pr_debug("interface %s: PHC %d", source->interfaces[i],
|
pr_debug("interface %s: PHC %d", ts_interface,
|
||||||
ts_info.phc_index);
|
ts_info.phc_index);
|
||||||
|
|
||||||
/* and the PHC isn't already used in another source */
|
/* and the PHC isn't already used in another source */
|
||||||
|
|
Loading…
Reference in New Issue