I feel like this would be better implemented as a config option - for
example, an option to not adjust SIOCSHWTSTAMP at all, or to have an
explicit value to set it to.

My preference would be to have an option to not adjust it. Then you could
use hwstamp_ctl or another program before running ptp4l to set it to the
value you want. In this mode, ptp4l would simply check to see whether the
filter was set to a sufficient value for PTP operations and fail with an
error if it was not.

On Mon, Jun 11, 2018 at 10:04 AM Geva, Erez <erez.geva....@siemens.com>
wrote:

> Signed-off-by: Erez Geva <erez.geva....@siemens.com>
> ---
>  sk.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/sk.c b/sk.c
> index f18b2bf..de8bf58 100644
> --- a/sk.c
> +++ b/sk.c
> @@ -55,8 +55,17 @@ static int hwts_init(int fd, const char *device, int
> rx_filter, int tx_type)
>         strncpy(ifreq.ifr_name, device, sizeof(ifreq.ifr_name) - 1);
>
>         ifreq.ifr_data = (void *) &cfg;
> +
> +       if (ioctl(fd, SIOCGHWTSTAMP, &ifreq) < 0)
> +       {
> +               pr_err("ioctl SIOCGHWTSTAMP failed: %m");
> +               return -1;
> +       }
> +
>         cfg.tx_type    = tx_type;
> -       cfg.rx_filter  = rx_filter;
> +       // Do not downgrade the rx filter, as it may be used by an AVB/TSN
> application
> +       if (cfg.rx_filter != HWTSTAMP_FILTER_ALL)
> +               cfg.rx_filter = rx_filter;
>         req = cfg;
>         err = ioctl(fd, SIOCSHWTSTAMP, &ifreq);
>         if (err < 0)
> --
> 2.17.1
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Linuxptp-devel mailing list
> Linuxptp-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to