Add a configuration option to support 802.1AS only hardware.
Some of the time stamping hardware out there only recognizes layer 2 packets, and these do not work without changing the receive filter in the SIOCSHWTSTAMP request. Signed-off-by: Richard Cochran <richardcochran@gmail.com>master
parent
7460d2756a
commit
e757b7a9d4
4
config.c
4
config.c
|
@ -92,6 +92,10 @@ static void scan_line(char *s, struct config *cfg)
|
||||||
if (val > 0)
|
if (val > 0)
|
||||||
*cfg->tx_timestamp_retries = val;
|
*cfg->tx_timestamp_retries = val;
|
||||||
|
|
||||||
|
} else if (1 == sscanf(s, " rx_timestamp_l2only %u", &val)) {
|
||||||
|
|
||||||
|
*cfg->rx_timestamp_l2only = val ? 1 : 0;
|
||||||
|
|
||||||
} else if (1 == sscanf(s, " pi_proportional_const %lf", &df)) {
|
} else if (1 == sscanf(s, " pi_proportional_const %lf", &df)) {
|
||||||
|
|
||||||
if (df > 0.0 && df < 1.0)
|
if (df > 0.0 && df < 1.0)
|
||||||
|
|
1
config.h
1
config.h
|
@ -26,6 +26,7 @@ struct config {
|
||||||
struct defaultDS *dds;
|
struct defaultDS *dds;
|
||||||
struct port_defaults *pod;
|
struct port_defaults *pod;
|
||||||
int *tx_timestamp_retries;
|
int *tx_timestamp_retries;
|
||||||
|
int *rx_timestamp_l2only;
|
||||||
double *pi_proportional_const;
|
double *pi_proportional_const;
|
||||||
double *pi_integral_const;
|
double *pi_integral_const;
|
||||||
unsigned char *ptp_dst_mac;
|
unsigned char *ptp_dst_mac;
|
||||||
|
|
|
@ -20,6 +20,7 @@ announceReceiptTimeout 3
|
||||||
# Run time options
|
# Run time options
|
||||||
#
|
#
|
||||||
tx_timestamp_retries 2
|
tx_timestamp_retries 2
|
||||||
|
rx_timestamp_l2only 0
|
||||||
pi_proportional_const 0.0
|
pi_proportional_const 0.0
|
||||||
pi_integral_const 0.0
|
pi_integral_const 0.0
|
||||||
#
|
#
|
||||||
|
|
3
ptp4l.c
3
ptp4l.c
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
#define DEFAULT_PHC "/dev/ptp0"
|
#define DEFAULT_PHC "/dev/ptp0"
|
||||||
|
|
||||||
int sk_tx_retries = 2; /*see sk.c*/
|
int sk_tx_retries = 2, sk_prefer_layer2 = 0; /*see sk.c*/
|
||||||
double configured_pi_kp, configured_pi_ki; /*see pi.c*/
|
double configured_pi_kp, configured_pi_ki; /*see pi.c*/
|
||||||
extern unsigned char ptp_dst_mac[]; /*see raw.c*/
|
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*/
|
||||||
|
@ -219,6 +219,7 @@ int main(int argc, char *argv[])
|
||||||
cfg_settings.dds = &ds;
|
cfg_settings.dds = &ds;
|
||||||
cfg_settings.pod = &pod;
|
cfg_settings.pod = &pod;
|
||||||
cfg_settings.tx_timestamp_retries = &sk_tx_retries;
|
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_proportional_const = &configured_pi_kp;
|
||||||
cfg_settings.pi_integral_const = &configured_pi_ki;
|
cfg_settings.pi_integral_const = &configured_pi_ki;
|
||||||
cfg_settings.ptp_dst_mac = ptp_dst_mac;
|
cfg_settings.ptp_dst_mac = ptp_dst_mac;
|
||||||
|
|
6
sk.c
6
sk.c
|
@ -45,7 +45,8 @@ static int hwts_init(int fd, char *device)
|
||||||
|
|
||||||
ifreq.ifr_data = (void *) &cfg;
|
ifreq.ifr_data = (void *) &cfg;
|
||||||
cfg.tx_type = HWTSTAMP_TX_ON;
|
cfg.tx_type = HWTSTAMP_TX_ON;
|
||||||
cfg.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT;
|
cfg.rx_filter = sk_prefer_layer2 ?
|
||||||
|
HWTSTAMP_FILTER_PTP_V2_L2_EVENT : HWTSTAMP_FILTER_PTP_V2_EVENT;
|
||||||
|
|
||||||
req = cfg;
|
req = cfg;
|
||||||
err = ioctl(fd, SIOCSHWTSTAMP, &ifreq);
|
err = ioctl(fd, SIOCSHWTSTAMP, &ifreq);
|
||||||
|
@ -59,7 +60,8 @@ static int hwts_init(int fd, char *device)
|
||||||
pr_warning("rx_filter %d not %d", cfg.rx_filter, req.rx_filter);
|
pr_warning("rx_filter %d not %d", cfg.rx_filter, req.rx_filter);
|
||||||
|
|
||||||
if (cfg.tx_type != HWTSTAMP_TX_ON ||
|
if (cfg.tx_type != HWTSTAMP_TX_ON ||
|
||||||
cfg.rx_filter != HWTSTAMP_FILTER_ALL) {
|
(cfg.rx_filter != HWTSTAMP_FILTER_ALL &&
|
||||||
|
cfg.rx_filter != HWTSTAMP_FILTER_PTP_V2_EVENT)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue