Discussion:
[Linuxptp-devel] [PATCH] sk.c: only show HWTSTAMP that differs
Jacob Keller
2013-08-30 17:57:46 UTC
Permalink
This patch updates the warning for when the driver changed the requested
tx_type or rx_filter mode. Rather than blindly displaying both, check which
ones changed and display them only if they do.

Signed-off-by: Jacob Keller <***@intel.com>
---
sk.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/sk.c b/sk.c
index a13d14d..39c7742 100644
--- a/sk.c
+++ b/sk.c
@@ -58,17 +58,21 @@ static int hwts_init(int fd, char *device, int rx_filter, int one_step)
if (err < 0)
return err;

- if (memcmp(&cfg, &req, sizeof(cfg))) {
-
- pr_warning("driver changed our HWTSTAMP options");
+ if (cfg.tx_type != req.tx_type) {
+ pr_warning("driver changed our Rx HWTSTAMP options");
pr_warning("tx_type %d not %d", cfg.tx_type, req.tx_type);
+ }
+
+ if (cfg.rx_filter != req.rx_filter) {
+ pr_warning("driver changed our Tx HWTSTAMP options");
pr_warning("rx_filter %d not %d", cfg.rx_filter, req.rx_filter);
+ }

- if (cfg.tx_type != req.tx_type ||
- (cfg.rx_filter != HWTSTAMP_FILTER_ALL &&
- cfg.rx_filter != HWTSTAMP_FILTER_PTP_V2_EVENT)) {
- return -1;
- }
+ /* Exit only after checking both Tx and Rx types */
+ if (cfg.tx_type != req.tx_type ||
+ (cfg.rx_filter != HWTSTAMP_FILTER_ALL &&
+ cfg.rx_filter != HWTSTAMP_FILTER_PTP_V2_EVENT)) {
+ return -1;
}

return 0;
Richard Cochran
2013-09-03 19:16:38 UTC
Permalink
Post by Jacob Keller
This patch updates the warning for when the driver changed the requested
tx_type or rx_filter mode. Rather than blindly displaying both, check which
ones changed and display them only if they do.
I like the idea, but...
Post by Jacob Keller
---
sk.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/sk.c b/sk.c
index a13d14d..39c7742 100644
--- a/sk.c
+++ b/sk.c
@@ -58,17 +58,21 @@ static int hwts_init(int fd, char *device, int rx_filter, int one_step)
if (err < 0)
return err;
- if (memcmp(&cfg, &req, sizeof(cfg))) {
-
- pr_warning("driver changed our HWTSTAMP options");
+ if (cfg.tx_type != req.tx_type) {
+ pr_warning("driver changed our Rx HWTSTAMP options");
pr_warning("tx_type %d not %d", cfg.tx_type, req.tx_type);
+ }
+
+ if (cfg.rx_filter != req.rx_filter) {
+ pr_warning("driver changed our Tx HWTSTAMP options");
pr_warning("rx_filter %d not %d", cfg.rx_filter, req.rx_filter);
+ }
- if (cfg.tx_type != req.tx_type ||
- (cfg.rx_filter != HWTSTAMP_FILTER_ALL &&
- cfg.rx_filter != HWTSTAMP_FILTER_PTP_V2_EVENT)) {
- return -1;
- }
+ /* Exit only after checking both Tx and Rx types */
+ if (cfg.tx_type != req.tx_type ||
+ (cfg.rx_filter != HWTSTAMP_FILTER_ALL &&
+ cfg.rx_filter != HWTSTAMP_FILTER_PTP_V2_EVENT)) {
+ return -1;
This won't work when we ask for HWTSTAMP_FILTER_PTP_V2_L4_EVENT or
HWTSTAMP_FILTER_PTP_V2_L2_EVENT in the rx_filter.

Thanks,
Richard
Keller, Jacob E
2013-09-03 20:36:33 UTC
Permalink
-----Original Message-----
Sent: Tuesday, September 03, 2013 12:17 PM
To: Keller, Jacob E
Subject: Re: [Linuxptp-devel] [PATCH] sk.c: only show HWTSTAMP that
differs
Post by Jacob Keller
This patch updates the warning for when the driver changed the
requested
Post by Jacob Keller
tx_type or rx_filter mode. Rather than blindly displaying both, check
which
Post by Jacob Keller
ones changed and display them only if they do.
I like the idea, but...
Post by Jacob Keller
---
sk.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/sk.c b/sk.c
index a13d14d..39c7742 100644
--- a/sk.c
+++ b/sk.c
@@ -58,17 +58,21 @@ static int hwts_init(int fd, char *device, int
rx_filter, int one_step)
Post by Jacob Keller
if (err < 0)
return err;
- if (memcmp(&cfg, &req, sizeof(cfg))) {
-
- pr_warning("driver changed our HWTSTAMP options");
+ if (cfg.tx_type != req.tx_type) {
+ pr_warning("driver changed our Rx HWTSTAMP
options");
Post by Jacob Keller
pr_warning("tx_type %d not %d", cfg.tx_type,
req.tx_type);
Post by Jacob Keller
+ }
+
+ if (cfg.rx_filter != req.rx_filter) {
+ pr_warning("driver changed our Tx HWTSTAMP
options");
Post by Jacob Keller
pr_warning("rx_filter %d not %d", cfg.rx_filter,
req.rx_filter);
Post by Jacob Keller
+ }
- if (cfg.tx_type != req.tx_type ||
- (cfg.rx_filter != HWTSTAMP_FILTER_ALL &&
- cfg.rx_filter != HWTSTAMP_FILTER_PTP_V2_EVENT)) {
- return -1;
- }
+ /* Exit only after checking both Tx and Rx types */
+ if (cfg.tx_type != req.tx_type ||
+ (cfg.rx_filter != HWTSTAMP_FILTER_ALL &&
+ cfg.rx_filter != HWTSTAMP_FILTER_PTP_V2_EVENT)) {
+ return -1;
This won't work when we ask for HWTSTAMP_FILTER_PTP_V2_L4_EVENT or
HWTSTAMP_FILTER_PTP_V2_L2_EVENT in the rx_filter.
Thanks,
Richard
Where's that code? I will try to see if I can make it work for that..

Thanks,
Jake
Keller, Jacob E
2013-09-04 00:13:19 UTC
Permalink
-----Original Message-----
Sent: Tuesday, September 03, 2013 12:17 PM
To: Keller, Jacob E
Subject: Re: [Linuxptp-devel] [PATCH] sk.c: only show HWTSTAMP that
differs
Post by Jacob Keller
This patch updates the warning for when the driver changed the
requested
Post by Jacob Keller
tx_type or rx_filter mode. Rather than blindly displaying both, check
which
Post by Jacob Keller
ones changed and display them only if they do.
I like the idea, but...
Post by Jacob Keller
---
sk.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/sk.c b/sk.c
index a13d14d..39c7742 100644
--- a/sk.c
+++ b/sk.c
@@ -58,17 +58,21 @@ static int hwts_init(int fd, char *device, int
rx_filter, int one_step)
Post by Jacob Keller
if (err < 0)
return err;
- if (memcmp(&cfg, &req, sizeof(cfg))) {
-
- pr_warning("driver changed our HWTSTAMP options");
+ if (cfg.tx_type != req.tx_type) {
+ pr_warning("driver changed our Rx HWTSTAMP
options");
Post by Jacob Keller
pr_warning("tx_type %d not %d", cfg.tx_type,
req.tx_type);
Post by Jacob Keller
+ }
+
+ if (cfg.rx_filter != req.rx_filter) {
+ pr_warning("driver changed our Tx HWTSTAMP
options");
Post by Jacob Keller
pr_warning("rx_filter %d not %d", cfg.rx_filter,
req.rx_filter);
Post by Jacob Keller
+ }
- if (cfg.tx_type != req.tx_type ||
- (cfg.rx_filter != HWTSTAMP_FILTER_ALL &&
- cfg.rx_filter != HWTSTAMP_FILTER_PTP_V2_EVENT)) {
- return -1;
- }
+ /* Exit only after checking both Tx and Rx types */
+ if (cfg.tx_type != req.tx_type ||
+ (cfg.rx_filter != HWTSTAMP_FILTER_ALL &&
+ cfg.rx_filter != HWTSTAMP_FILTER_PTP_V2_EVENT)) {
+ return -1;
This won't work when we ask for HWTSTAMP_FILTER_PTP_V2_L4_EVENT or
HWTSTAMP_FILTER_PTP_V2_L2_EVENT in the rx_filter.
How did it work before?

Thanks,
Jake
Thanks,
Richard
Loading...