ptp4l: use sk_get_ts_info to check timestamping mode
this patch uses the new sk_get_ts_info data to check whether the selected timestamping mode is supported on all ports. This check is not run if the port data isn't valid, so it will only fail if the IOCTL is supported. This allows for support of old kernels that do not support the IOCTL to still work as expected. Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>master
parent
004b62d22b
commit
a1b492aba9
27
ptp4l.c
27
ptp4l.c
|
@ -22,6 +22,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <linux/net_tstamp.h>
|
||||||
|
|
||||||
#include "clock.h"
|
#include "clock.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -135,7 +136,7 @@ int main(int argc, char *argv[])
|
||||||
enum timestamp_type *timestamping = &cfg_settings.timestamping;
|
enum timestamp_type *timestamping = &cfg_settings.timestamping;
|
||||||
struct clock *clock;
|
struct clock *clock;
|
||||||
struct defaultDS *ds = &cfg_settings.dds;
|
struct defaultDS *ds = &cfg_settings.dds;
|
||||||
int phc_index = -1;
|
int phc_index = -1, required_modes = 0;
|
||||||
|
|
||||||
if (SIG_ERR == signal(SIGINT, handle_int_quit_term)) {
|
if (SIG_ERR == signal(SIGINT, handle_int_quit_term)) {
|
||||||
fprintf(stderr, "cannot handle SIGINT\n");
|
fprintf(stderr, "cannot handle SIGINT\n");
|
||||||
|
@ -253,6 +254,30 @@ int main(int argc, char *argv[])
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (*timestamping == TS_SOFTWARE)
|
||||||
|
required_modes |= SOF_TIMESTAMPING_TX_SOFTWARE |
|
||||||
|
SOF_TIMESTAMPING_RX_SOFTWARE |
|
||||||
|
SOF_TIMESTAMPING_SOFTWARE;
|
||||||
|
else if (*timestamping == TS_LEGACY_HW)
|
||||||
|
required_modes |= SOF_TIMESTAMPING_TX_HARDWARE |
|
||||||
|
SOF_TIMESTAMPING_RX_HARDWARE |
|
||||||
|
SOF_TIMESTAMPING_SYS_HARDWARE;
|
||||||
|
else if (*timestamping == TS_HARDWARE)
|
||||||
|
required_modes |= SOF_TIMESTAMPING_TX_HARDWARE |
|
||||||
|
SOF_TIMESTAMPING_RX_HARDWARE |
|
||||||
|
SOF_TIMESTAMPING_RAW_HARDWARE;
|
||||||
|
|
||||||
|
/* check whether timestamping mode is supported. */
|
||||||
|
for (i = 0; i < cfg_settings.nports; i++) {
|
||||||
|
if (iface[i].ts_info.valid &&
|
||||||
|
!(iface[0].ts_info.so_timestamping & required_modes)) {
|
||||||
|
fprintf(stderr, "interface '%s' does not support "
|
||||||
|
"requested timestamping mode.\n",
|
||||||
|
iface[i].name);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* determine PHC Clock index */
|
/* determine PHC Clock index */
|
||||||
if (ds->free_running) {
|
if (ds->free_running) {
|
||||||
phc_index = -1;
|
phc_index = -1;
|
||||||
|
|
Loading…
Reference in New Issue