Hi,

It make sense for HWTS_FILTER_NORMAL.

But for HWTSTAMP_FILTER_ALL, it does not make sense to get 
HWTSTAMP_FILTER_SOME. 
Some of what? You ask for all!
Neither can you use rx_filter in this case, since it was not used in the 
SIOCSHWTSTAMP request.

Erez

________________________________________
From: Petr Machata [pe...@mellanox.com]
Sent: 11 June 2019 15:18
To: linuxptp-devel@lists.sourceforge.net
Subject: [Linuxptp-devel] [PATCH v3] sk: Recognize HWTSTAMP_FILTER_SOME

struct hwtstamp_config.rx_filter passed to SIOCSHWTSTAMP can be updated by
the kernel with the value of HWTSTAMP_FILTER_SOME. That indicates that all
requested packets will be timestamped, and some others as well.

Update hwts_init() to recognize this as a valid response, instead of
rejecting it as mismatch.

Cc: "Keller, Jacob E" <jacob.e.kel...@intel.com>
Signed-off-by: Petr Machata <pe...@mellanox.com>
---

Notes:
    v3:
    - Do not permit HWTSTAMP_FILTER_SOME for SIOCGHWTSTAMP.

    v2:
    - Fix whitespace.

 sk.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/sk.c b/sk.c
index 93ba77a..8fda9c2 100644
--- a/sk.c
+++ b/sk.c
@@ -61,6 +61,7 @@ static int hwts_init(int fd, const char *device, int 
rx_filter,
 {
        struct ifreq ifreq;
        struct hwtstamp_config cfg;
+       int orig_rx_filter;
        int err;

        init_ifreq(&ifreq, &cfg, device);
@@ -81,17 +82,19 @@ static int hwts_init(int fd, const char *device, int 
rx_filter,
                        pr_err("ioctl SIOCSHWTSTAMP failed: %m");
                        return err;
                }
+               if (cfg.rx_filter == HWTSTAMP_FILTER_SOME)
+                       cfg.rx_filter = rx_filter;
                break;
        case HWTS_FILTER_NORMAL:
                cfg.tx_type   = tx_type;
-               cfg.rx_filter = rx_filter;
+               cfg.rx_filter = orig_rx_filter = rx_filter;
                err = ioctl(fd, SIOCSHWTSTAMP, &ifreq);
                if (err < 0) {
                        pr_info("driver rejected most general HWTSTAMP filter");

                        init_ifreq(&ifreq, &cfg, device);
                        cfg.tx_type   = tx_type;
-                       cfg.rx_filter = rx_filter2;
+                       cfg.rx_filter = orig_rx_filter = rx_filter2;

                        err = ioctl(fd, SIOCSHWTSTAMP, &ifreq);
                        if (err < 0) {
@@ -99,6 +102,8 @@ static int hwts_init(int fd, const char *device, int 
rx_filter,
                                return err;
                        }
                }
+               if (cfg.rx_filter == HWTSTAMP_FILTER_SOME)
+                       cfg.rx_filter = orig_rx_filter;
                break;
        }

--
2.20.1


_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to