All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Enable tx timestamping on loopback and dummy
@ 2017-03-11 14:42 Ezequiel Lara Gomez
  2017-03-11 15:59 ` Soheil Hassas Yeganeh
  2017-03-11 23:17 ` Oliver Hartkopp
  0 siblings, 2 replies; 12+ messages in thread
From: Ezequiel Lara Gomez @ 2017-03-11 14:42 UTC (permalink / raw)
  To: netdev

Also, cleanup some warnings from timestamping code.

This enables testing of SO_TIMESTAMPING options by targetting localhost
addresses.

Tested on qemu using txtimestamping.c from the kernel selftests.

Signed-off-by: Ezequiel Lara Gomez <ezegomez@amazon.com>
---
 drivers/net/dummy.c    |  1 +
 drivers/net/loopback.c | 14 +++++++-------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c
index 2c80611..32fdc00 100644
--- a/drivers/net/dummy.c
+++ b/drivers/net/dummy.c
@@ -125,6 +125,7 @@ static netdev_tx_t dummy_xmit(struct sk_buff *skb, struct net_device *dev)
 	dstats->tx_bytes += skb->len;
 	u64_stats_update_end(&dstats->syncp);
 
+	skb_tx_timestamp(skb);
 	dev_kfree_skb(skb);
 	return NETDEV_TX_OK;
 }
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index b23b719..8bcf479 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -13,7 +13,7 @@
  *
  *		Alan Cox	:	Fixed oddments for NET3.014
  *		Alan Cox	:	Rejig for NET3.029 snap #3
- *		Alan Cox	: 	Fixed NET3.029 bugs and sped up
+ *		Alan Cox	:	Fixed NET3.029 bugs and sped up
  *		Larry McVoy	:	Tiny tweak to double performance
  *		Alan Cox	:	Backed out LMV's tweak - the linux mm
  *					can't take it...
@@ -41,7 +41,7 @@
 #include <linux/in.h>
 
 #include <linux/uaccess.h>
-#include <asm/io.h>
+#include <linux/io.h>
 
 #include <linux/inet.h>
 #include <linux/netdevice.h>
@@ -74,6 +74,7 @@ static netdev_tx_t loopback_xmit(struct sk_buff *skb,
 	struct pcpu_lstats *lb_stats;
 	int len;
 
+	skb_tx_timestamp(skb);
 	skb_orphan(skb);
 
 	/* Before queueing this packet to netif_rx(),
@@ -149,8 +150,8 @@ static void loopback_dev_free(struct net_device *dev)
 }
 
 static const struct net_device_ops loopback_ops = {
-	.ndo_init      = loopback_dev_init,
-	.ndo_start_xmit= loopback_xmit,
+	.ndo_init        = loopback_dev_init,
+	.ndo_start_xmit  = loopback_xmit,
 	.ndo_get_stats64 = loopback_get_stats64,
 	.ndo_set_mac_address = eth_mac_addr,
 };
@@ -170,7 +171,7 @@ static void loopback_setup(struct net_device *dev)
 	dev->priv_flags		|= IFF_LIVE_ADDR_CHANGE | IFF_NO_QUEUE;
 	netif_keep_dst(dev);
 	dev->hw_features	= NETIF_F_GSO_SOFTWARE;
-	dev->features 		= NETIF_F_SG | NETIF_F_FRAGLIST
+	dev->features		= NETIF_F_SG | NETIF_F_FRAGLIST
 		| NETIF_F_GSO_SOFTWARE
 		| NETIF_F_HW_CSUM
 		| NETIF_F_RXCSUM
@@ -206,7 +207,6 @@ static __net_init int loopback_net_init(struct net *net)
 	net->loopback_dev = dev;
 	return 0;
 
-
 out_free_netdev:
 	free_netdev(dev);
 out:
@@ -217,5 +217,5 @@ static __net_init int loopback_net_init(struct net *net)
 
 /* Registered in net/core/dev.c */
 struct pernet_operations __net_initdata loopback_net_ops = {
-       .init = loopback_net_init,
+	.init = loopback_net_init,
 };
-- 
1.9.1

Amazon Data Services Ireland Limited registered office: One Burlington Plaza, Burlington Road, Dublin 4, Ireland. Registered in Ireland. Registration number 390566.

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] Enable tx timestamping on loopback and dummy
  2017-03-11 14:42 [PATCH] Enable tx timestamping on loopback and dummy Ezequiel Lara Gomez
@ 2017-03-11 15:59 ` Soheil Hassas Yeganeh
  2017-03-11 23:17 ` Oliver Hartkopp
  1 sibling, 0 replies; 12+ messages in thread
From: Soheil Hassas Yeganeh @ 2017-03-11 15:59 UTC (permalink / raw)
  To: Ezequiel Lara Gomez; +Cc: netdev

On Sat, Mar 11, 2017 at 9:42 AM, Ezequiel Lara Gomez
<ezegomez@amazon.com> wrote:
> Also, cleanup some warnings from timestamping code.

Can you please submit the styling fixes as a separate patch?

Thanks,
Soheil

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Enable tx timestamping on loopback and dummy
  2017-03-11 14:42 [PATCH] Enable tx timestamping on loopback and dummy Ezequiel Lara Gomez
  2017-03-11 15:59 ` Soheil Hassas Yeganeh
@ 2017-03-11 23:17 ` Oliver Hartkopp
  2017-03-11 23:37   ` Lara Gomez, Ezequiel
  2017-03-12 16:30   ` Richard Cochran
  1 sibling, 2 replies; 12+ messages in thread
From: Oliver Hartkopp @ 2017-03-11 23:17 UTC (permalink / raw)
  To: Ezequiel Lara Gomez, netdev

Hi Ezequiel,

On 03/11/2017 03:42 PM, Ezequiel Lara Gomez wrote:
> Also, cleanup some warnings from timestamping code.

in fact you're doing three different things here:

1. introduce tx timestamping
2. silently change an include: <asm/io.h> -> <linux/io.h>
3. fix some whitespace and empty line issues

You'd better provide one patch for 1 & 2 and explain why 2 is needed.

Regards,
Oliver

>
> This enables testing of SO_TIMESTAMPING options by targetting localhost
> addresses.
>
> Tested on qemu using txtimestamping.c from the kernel selftests.
>
> Signed-off-by: Ezequiel Lara Gomez <ezegomez@amazon.com>
> ---
>  drivers/net/dummy.c    |  1 +
>  drivers/net/loopback.c | 14 +++++++-------
>  2 files changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c
> index 2c80611..32fdc00 100644
> --- a/drivers/net/dummy.c
> +++ b/drivers/net/dummy.c
> @@ -125,6 +125,7 @@ static netdev_tx_t dummy_xmit(struct sk_buff *skb, struct net_device *dev)
>  	dstats->tx_bytes += skb->len;
>  	u64_stats_update_end(&dstats->syncp);
>
> +	skb_tx_timestamp(skb);
>  	dev_kfree_skb(skb);
>  	return NETDEV_TX_OK;
>  }
> diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
> index b23b719..8bcf479 100644
> --- a/drivers/net/loopback.c
> +++ b/drivers/net/loopback.c
> @@ -13,7 +13,7 @@
>   *
>   *		Alan Cox	:	Fixed oddments for NET3.014
>   *		Alan Cox	:	Rejig for NET3.029 snap #3
> - *		Alan Cox	: 	Fixed NET3.029 bugs and sped up
> + *		Alan Cox	:	Fixed NET3.029 bugs and sped up
>   *		Larry McVoy	:	Tiny tweak to double performance
>   *		Alan Cox	:	Backed out LMV's tweak - the linux mm
>   *					can't take it...
> @@ -41,7 +41,7 @@
>  #include <linux/in.h>
>
>  #include <linux/uaccess.h>
> -#include <asm/io.h>
> +#include <linux/io.h>
>
>  #include <linux/inet.h>
>  #include <linux/netdevice.h>
> @@ -74,6 +74,7 @@ static netdev_tx_t loopback_xmit(struct sk_buff *skb,
>  	struct pcpu_lstats *lb_stats;
>  	int len;
>
> +	skb_tx_timestamp(skb);
>  	skb_orphan(skb);
>
>  	/* Before queueing this packet to netif_rx(),
> @@ -149,8 +150,8 @@ static void loopback_dev_free(struct net_device *dev)
>  }
>
>  static const struct net_device_ops loopback_ops = {
> -	.ndo_init      = loopback_dev_init,
> -	.ndo_start_xmit= loopback_xmit,
> +	.ndo_init        = loopback_dev_init,
> +	.ndo_start_xmit  = loopback_xmit,
>  	.ndo_get_stats64 = loopback_get_stats64,
>  	.ndo_set_mac_address = eth_mac_addr,
>  };
> @@ -170,7 +171,7 @@ static void loopback_setup(struct net_device *dev)
>  	dev->priv_flags		|= IFF_LIVE_ADDR_CHANGE | IFF_NO_QUEUE;
>  	netif_keep_dst(dev);
>  	dev->hw_features	= NETIF_F_GSO_SOFTWARE;
> -	dev->features 		= NETIF_F_SG | NETIF_F_FRAGLIST
> +	dev->features		= NETIF_F_SG | NETIF_F_FRAGLIST
>  		| NETIF_F_GSO_SOFTWARE
>  		| NETIF_F_HW_CSUM
>  		| NETIF_F_RXCSUM
> @@ -206,7 +207,6 @@ static __net_init int loopback_net_init(struct net *net)
>  	net->loopback_dev = dev;
>  	return 0;
>
> -
>  out_free_netdev:
>  	free_netdev(dev);
>  out:
> @@ -217,5 +217,5 @@ static __net_init int loopback_net_init(struct net *net)
>
>  /* Registered in net/core/dev.c */
>  struct pernet_operations __net_initdata loopback_net_ops = {
> -       .init = loopback_net_init,
> +	.init = loopback_net_init,
>  };
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Enable tx timestamping on loopback and dummy
  2017-03-11 23:17 ` Oliver Hartkopp
@ 2017-03-11 23:37   ` Lara Gomez, Ezequiel
  2017-03-12 16:30   ` Richard Cochran
  1 sibling, 0 replies; 12+ messages in thread
From: Lara Gomez, Ezequiel @ 2017-03-11 23:37 UTC (permalink / raw)
  To: Oliver Hartkopp; +Cc: netdev

2 and 3 were recommendations by the checkpatch.pl script; as suggested, I've broken them down from the timestamping code and resubmitted as two separate patches (on separate emails though).


> On 11 Mar 2017, at 23:17, Oliver Hartkopp <socketcan@hartkopp.net> wrote:
> 
> Hi Ezequiel,
> 
>> On 03/11/2017 03:42 PM, Ezequiel Lara Gomez wrote:
>> Also, cleanup some warnings from timestamping code.
> 
> in fact you're doing three different things here:
> 
> 1. introduce tx timestamping
> 2. silently change an include: <asm/io.h> -> <linux/io.h>
> 3. fix some whitespace and empty line issues
> 
> You'd better provide one patch for 1 & 2 and explain why 2 is needed.
> 
> Regards,
> Oliver
> 
>> 
>> This enables testing of SO_TIMESTAMPING options by targetting localhost
>> addresses.
>> 
>> Tested on qemu using txtimestamping.c from the kernel selftests.
>> 
>> Signed-off-by: Ezequiel Lara Gomez <ezegomez@amazon.com>
>> ---
>> drivers/net/dummy.c    |  1 +
>> drivers/net/loopback.c | 14 +++++++-------
>> 2 files changed, 8 insertions(+), 7 deletions(-)
>> 
>> diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c
>> index 2c80611..32fdc00 100644
>> --- a/drivers/net/dummy.c
>> +++ b/drivers/net/dummy.c
>> @@ -125,6 +125,7 @@ static netdev_tx_t dummy_xmit(struct sk_buff *skb, struct net_device *dev)
>>    dstats->tx_bytes += skb->len;
>>    u64_stats_update_end(&dstats->syncp);
>> 
>> +    skb_tx_timestamp(skb);
>>    dev_kfree_skb(skb);
>>    return NETDEV_TX_OK;
>> }
>> diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
>> index b23b719..8bcf479 100644
>> --- a/drivers/net/loopback.c
>> +++ b/drivers/net/loopback.c
>> @@ -13,7 +13,7 @@
>>  *
>>  *        Alan Cox    :    Fixed oddments for NET3.014
>>  *        Alan Cox    :    Rejig for NET3.029 snap #3
>> - *        Alan Cox    :    Fixed NET3.029 bugs and sped up
>> + *        Alan Cox    :    Fixed NET3.029 bugs and sped up
>>  *        Larry McVoy    :    Tiny tweak to double performance
>>  *        Alan Cox    :    Backed out LMV's tweak - the linux mm
>>  *                    can't take it...
>> @@ -41,7 +41,7 @@
>> #include <linux/in.h>
>> 
>> #include <linux/uaccess.h>
>> -#include <asm/io.h>
>> +#include <linux/io.h>
>> 
>> #include <linux/inet.h>
>> #include <linux/netdevice.h>
>> @@ -74,6 +74,7 @@ static netdev_tx_t loopback_xmit(struct sk_buff *skb,
>>    struct pcpu_lstats *lb_stats;
>>    int len;
>> 
>> +    skb_tx_timestamp(skb);
>>    skb_orphan(skb);
>> 
>>    /* Before queueing this packet to netif_rx(),
>> @@ -149,8 +150,8 @@ static void loopback_dev_free(struct net_device *dev)
>> }
>> 
>> static const struct net_device_ops loopback_ops = {
>> -    .ndo_init      = loopback_dev_init,
>> -    .ndo_start_xmit= loopback_xmit,
>> +    .ndo_init        = loopback_dev_init,
>> +    .ndo_start_xmit  = loopback_xmit,
>>    .ndo_get_stats64 = loopback_get_stats64,
>>    .ndo_set_mac_address = eth_mac_addr,
>> };
>> @@ -170,7 +171,7 @@ static void loopback_setup(struct net_device *dev)
>>    dev->priv_flags        |= IFF_LIVE_ADDR_CHANGE | IFF_NO_QUEUE;
>>    netif_keep_dst(dev);
>>    dev->hw_features    = NETIF_F_GSO_SOFTWARE;
>> -    dev->features        = NETIF_F_SG | NETIF_F_FRAGLIST
>> +    dev->features        = NETIF_F_SG | NETIF_F_FRAGLIST
>>        | NETIF_F_GSO_SOFTWARE
>>        | NETIF_F_HW_CSUM
>>        | NETIF_F_RXCSUM
>> @@ -206,7 +207,6 @@ static __net_init int loopback_net_init(struct net *net)
>>    net->loopback_dev = dev;
>>    return 0;
>> 
>> -
>> out_free_netdev:
>>    free_netdev(dev);
>> out:
>> @@ -217,5 +217,5 @@ static __net_init int loopback_net_init(struct net *net)
>> 
>> /* Registered in net/core/dev.c */
>> struct pernet_operations __net_initdata loopback_net_ops = {
>> -       .init = loopback_net_init,
>> +    .init = loopback_net_init,
>> };
>> 
> 
Amazon Data Services Ireland Limited registered office: One Burlington Plaza, Burlington Road, Dublin 4, Ireland. Registered in Ireland. Registration number 390566.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Enable tx timestamping on loopback and dummy
  2017-03-11 23:17 ` Oliver Hartkopp
  2017-03-11 23:37   ` Lara Gomez, Ezequiel
@ 2017-03-12 16:30   ` Richard Cochran
  2017-03-12 20:39     ` Ezequiel Lara Gomez
  2017-03-12 21:52     ` [PATCH v3] " Ezequiel Lara Gomez
  1 sibling, 2 replies; 12+ messages in thread
From: Richard Cochran @ 2017-03-12 16:30 UTC (permalink / raw)
  To: Oliver Hartkopp; +Cc: Ezequiel Lara Gomez, netdev

On Sun, Mar 12, 2017 at 12:17:30AM +0100, Oliver Hartkopp wrote:
> in fact you're doing three different things here:
> 
> 1. introduce tx timestamping
> 2. silently change an include: <asm/io.h> -> <linux/io.h>
> 3. fix some whitespace and empty line issues
> 
> You'd better provide one patch for 1 & 2 and explain why 2 is needed.

And while you are at it, explain why #1 is needed.

Thanks,
Richard

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Enable tx timestamping on loopback and dummy
  2017-03-12 16:30   ` Richard Cochran
@ 2017-03-12 20:39     ` Ezequiel Lara Gomez
  2017-03-13 10:35       ` Richard Cochran
  2017-03-12 21:52     ` [PATCH v3] " Ezequiel Lara Gomez
  1 sibling, 1 reply; 12+ messages in thread
From: Ezequiel Lara Gomez @ 2017-03-12 20:39 UTC (permalink / raw)
  To: Richard Cochran; +Cc: netdev

On Sun, Mar 12, 2017 at 05:30:00PM +0100, Richard Cochran wrote:
> On Sun, Mar 12, 2017 at 12:17:30AM +0100, Oliver Hartkopp wrote:
> > in fact you're doing three different things here:
> > 
> > 1. introduce tx timestamping
> > 2. silently change an include: <asm/io.h> -> <linux/io.h>
> > 3. fix some whitespace and empty line issues
> > 
> > You'd better provide one patch for 1 & 2 and explain why 2 is needed.
> 
> And while you are at it, explain why #1 is needed.

Certainly - 2 (and 3) come from checkpatch.pl suggestions 
(I'm mostly following through https://kernelnewbies.org/FirstKernelPatch ), 
so as suggested I've broken them into a separate patch, being
styling related only (at least according to that script output).

The intent behind 1 is helping developing code that does TX timestamping
- I lost a good chunk of time toying with it until I realised 127.0.0.1
could not do TX timestamping because lo did not implement it.

>
> 
> Thanks,
> Richard
> 
Amazon Data Services Ireland Limited registered office: One Burlington Plaza, Burlington Road, Dublin 4, Ireland. Registered in Ireland. Registration number 390566.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v3] Enable tx timestamping on loopback and dummy
  2017-03-12 16:30   ` Richard Cochran
  2017-03-12 20:39     ` Ezequiel Lara Gomez
@ 2017-03-12 21:52     ` Ezequiel Lara Gomez
  2017-03-13 10:40       ` Richard Cochran
  1 sibling, 1 reply; 12+ messages in thread
From: Ezequiel Lara Gomez @ 2017-03-12 21:52 UTC (permalink / raw)
  To: Richard Cochran; +Cc: netdev


>From f3483202625648be728df39622360508f2fb03e1 Mon Sep 17 00:00:00 2001
From: Ezequiel Lara Gomez <ezegomez@amazon.com>
Date: Sat, 11 Mar 2017 20:06:54 +0000
Subject: [PATCH v3] Enable tx timestamping on loopback and dummy

This enables testing of SO_TIMESTAMPING options by targetting localhost
addresses.

Tested on qemu using txtimestamping.c from the kernel selftests, and
ethtool -T.
---
Changes:
 * Added ethtool flags to both drivers to report they support timestamping.

 drivers/net/dummy.c    | 15 +++++++++++++++
 drivers/net/loopback.c | 15 +++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c
index 2c80611..149244a 100644
--- a/drivers/net/dummy.c
+++ b/drivers/net/dummy.c
@@ -35,6 +35,7 @@
 #include <linux/init.h>
 #include <linux/moduleparam.h>
 #include <linux/rtnetlink.h>
+#include <linux/net_tstamp.h>
 #include <net/rtnetlink.h>
 #include <linux/u64_stats_sync.h>
 
@@ -125,6 +126,7 @@ static netdev_tx_t dummy_xmit(struct sk_buff *skb, struct net_device *dev)
 	dstats->tx_bytes += skb->len;
 	u64_stats_update_end(&dstats->syncp);
 
+	skb_tx_timestamp(skb);
 	dev_kfree_skb(skb);
 	return NETDEV_TX_OK;
 }
@@ -304,8 +306,21 @@ static void dummy_get_drvinfo(struct net_device *dev,
 	strlcpy(info->version, DRV_VERSION, sizeof(info->version));
 }
 
+static int dummy_get_ts_info(struct net_device *dev,
+			      struct ethtool_ts_info *ts_info)
+{
+	ts_info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE |
+				   SOF_TIMESTAMPING_RX_SOFTWARE |
+				   SOF_TIMESTAMPING_SOFTWARE;
+
+	ts_info->phc_index = -1;
+
+	return 0;
+};
+
 static const struct ethtool_ops dummy_ethtool_ops = {
 	.get_drvinfo            = dummy_get_drvinfo,
+	.get_ts_info		= dummy_get_ts_info,
 };
 
 static void dummy_free_netdev(struct net_device *dev)
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index 122cc2d..3a60d27 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -55,6 +55,7 @@
 #include <linux/ip.h>
 #include <linux/tcp.h>
 #include <linux/percpu.h>
+#include <linux/net_tstamp.h>
 #include <net/net_namespace.h>
 #include <linux/u64_stats_sync.h>
 
@@ -74,6 +75,7 @@ static netdev_tx_t loopback_xmit(struct sk_buff *skb,
 	struct pcpu_lstats *lb_stats;
 	int len;
 
+	skb_tx_timestamp(skb);
 	skb_orphan(skb);
 
 	/* Before queueing this packet to netif_rx(),
@@ -129,8 +131,21 @@ static u32 always_on(struct net_device *dev)
 	return 1;
 }
 
+static int loopback_get_ts_info(struct net_device *netdev,
+				struct ethtool_ts_info *ts_info)
+{
+	ts_info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE |
+				   SOF_TIMESTAMPING_RX_SOFTWARE |
+				   SOF_TIMESTAMPING_SOFTWARE;
+
+	ts_info->phc_index = -1;
+
+	return 0;
+};
+
 static const struct ethtool_ops loopback_ethtool_ops = {
 	.get_link		= always_on,
+	.get_ts_info		= loopback_get_ts_info,
 };
 
 static int loopback_dev_init(struct net_device *dev)
-- 
1.9.1

Amazon Data Services Ireland Limited registered office: One Burlington Plaza, Burlington Road, Dublin 4, Ireland. Registered in Ireland. Registration number 390566.

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] Enable tx timestamping on loopback and dummy
  2017-03-12 20:39     ` Ezequiel Lara Gomez
@ 2017-03-13 10:35       ` Richard Cochran
  0 siblings, 0 replies; 12+ messages in thread
From: Richard Cochran @ 2017-03-13 10:35 UTC (permalink / raw)
  To: Ezequiel Lara Gomez; +Cc: netdev

On Sun, Mar 12, 2017 at 08:39:03PM +0000, Ezequiel Lara Gomez wrote:
> On Sun, Mar 12, 2017 at 05:30:00PM +0100, Richard Cochran wrote:
> > And while you are at it, explain why #1 is needed.
> 
> Certainly - 2 (and 3) come from checkpatch.pl suggestions 
> (I'm mostly following through https://kernelnewbies.org/FirstKernelPatch ), 
> so as suggested I've broken them into a separate patch, being
> styling related only (at least according to that script output).
> 
> The intent behind 1 is helping developing code that does TX timestamping
> - I lost a good chunk of time toying with it until I realised 127.0.0.1
> could not do TX timestamping because lo did not implement it.

IMHO this is not a very convincing reason, but I won't object if
others agree with this change.

In any case, the motivation belongs in the commit message...

Thanks,
Richard

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3] Enable tx timestamping on loopback and dummy
  2017-03-12 21:52     ` [PATCH v3] " Ezequiel Lara Gomez
@ 2017-03-13 10:40       ` Richard Cochran
  2017-03-13 11:16         ` [PATCH v4] " Ezequiel Lara Gomez
  0 siblings, 1 reply; 12+ messages in thread
From: Richard Cochran @ 2017-03-13 10:40 UTC (permalink / raw)
  To: Ezequiel Lara Gomez; +Cc: netdev

On Sun, Mar 12, 2017 at 09:52:32PM +0000, Ezequiel Lara Gomez wrote:
> 
> From f3483202625648be728df39622360508f2fb03e1 Mon Sep 17 00:00:00 2001
> From: Ezequiel Lara Gomez <ezegomez@amazon.com>
> Date: Sat, 11 Mar 2017 20:06:54 +0000
> Subject: [PATCH v3] Enable tx timestamping on loopback and dummy
> 
> This enables testing of SO_TIMESTAMPING options by targetting localhost
> addresses.

Yes, we can see from the patch that this enables the transmit
SO_TIMESTAMPING option, but why is this important?  Proper changelog
messages always tell WHY.

Thanks,
Richard

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v4] Enable tx timestamping on loopback and dummy
  2017-03-13 10:40       ` Richard Cochran
@ 2017-03-13 11:16         ` Ezequiel Lara Gomez
  2017-03-13 19:15           ` David Miller
  0 siblings, 1 reply; 12+ messages in thread
From: Ezequiel Lara Gomez @ 2017-03-13 11:16 UTC (permalink / raw)
  To: Richard Cochran; +Cc: netdev


>From aef15784aecbf6cb08d181eca6186fe7d2261771 Mon Sep 17 00:00:00 2001
From: Ezequiel Lara Gomez <ezegomez@amazon.com>
Date: Sat, 11 Mar 2017 20:06:54 +0000
Subject: [PATCH v4] Enable tx timestamping on loopback and dummy

This enables developing code that uses SOF_TIMESTAMPING_TX_SOFTWARE
by using local addresses (without needing to send packets outside),
as well as enabling unit and functional testing of TX timestamping code
without needing hardware support or network access.

It also fulfills the expectation of software network devices supporting
software-based timestamping.

Tested on qemu using txtimestamping.c from the kernel selftests, and
ethtool -T.
---
Changes:
* v2: split styling changes suggested by checkpatch.pl to a separate patch
* v3: added ethtool reporting of tx timestamping support
* v4: clarified on the commit message the reason to introduce this.

 drivers/net/dummy.c    | 15 +++++++++++++++
 drivers/net/loopback.c | 15 +++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c
index 2c80611..149244a 100644
--- a/drivers/net/dummy.c
+++ b/drivers/net/dummy.c
@@ -35,6 +35,7 @@
 #include <linux/init.h>
 #include <linux/moduleparam.h>
 #include <linux/rtnetlink.h>
+#include <linux/net_tstamp.h>
 #include <net/rtnetlink.h>
 #include <linux/u64_stats_sync.h>
 
@@ -125,6 +126,7 @@ static netdev_tx_t dummy_xmit(struct sk_buff *skb, struct net_device *dev)
 	dstats->tx_bytes += skb->len;
 	u64_stats_update_end(&dstats->syncp);
 
+	skb_tx_timestamp(skb);
 	dev_kfree_skb(skb);
 	return NETDEV_TX_OK;
 }
@@ -304,8 +306,21 @@ static void dummy_get_drvinfo(struct net_device *dev,
 	strlcpy(info->version, DRV_VERSION, sizeof(info->version));
 }
 
+static int dummy_get_ts_info(struct net_device *dev,
+			      struct ethtool_ts_info *ts_info)
+{
+	ts_info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE |
+				   SOF_TIMESTAMPING_RX_SOFTWARE |
+				   SOF_TIMESTAMPING_SOFTWARE;
+
+	ts_info->phc_index = -1;
+
+	return 0;
+};
+
 static const struct ethtool_ops dummy_ethtool_ops = {
 	.get_drvinfo            = dummy_get_drvinfo,
+	.get_ts_info		= dummy_get_ts_info,
 };
 
 static void dummy_free_netdev(struct net_device *dev)
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index 122cc2d..3a60d27 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -55,6 +55,7 @@
 #include <linux/ip.h>
 #include <linux/tcp.h>
 #include <linux/percpu.h>
+#include <linux/net_tstamp.h>
 #include <net/net_namespace.h>
 #include <linux/u64_stats_sync.h>
 
@@ -74,6 +75,7 @@ static netdev_tx_t loopback_xmit(struct sk_buff *skb,
 	struct pcpu_lstats *lb_stats;
 	int len;
 
+	skb_tx_timestamp(skb);
 	skb_orphan(skb);
 
 	/* Before queueing this packet to netif_rx(),
@@ -129,8 +131,21 @@ static u32 always_on(struct net_device *dev)
 	return 1;
 }
 
+static int loopback_get_ts_info(struct net_device *netdev,
+				struct ethtool_ts_info *ts_info)
+{
+	ts_info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE |
+				   SOF_TIMESTAMPING_RX_SOFTWARE |
+				   SOF_TIMESTAMPING_SOFTWARE;
+
+	ts_info->phc_index = -1;
+
+	return 0;
+};
+
 static const struct ethtool_ops loopback_ethtool_ops = {
 	.get_link		= always_on,
+	.get_ts_info		= loopback_get_ts_info,
 };
 
 static int loopback_dev_init(struct net_device *dev)
-- 
1.9.1

Amazon Data Services Ireland Limited registered office: One Burlington Plaza, Burlington Road, Dublin 4, Ireland. Registered in Ireland. Registration number 390566.

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v4] Enable tx timestamping on loopback and dummy
  2017-03-13 11:16         ` [PATCH v4] " Ezequiel Lara Gomez
@ 2017-03-13 19:15           ` David Miller
  2017-03-14 10:59             ` [PATCH v5] " Ezequiel Lara Gomez
  0 siblings, 1 reply; 12+ messages in thread
From: David Miller @ 2017-03-13 19:15 UTC (permalink / raw)
  To: ezegomez; +Cc: richardcochran, netdev

From: Ezequiel Lara Gomez <ezegomez@amazon.com>
Date: Mon, 13 Mar 2017 11:16:10 +0000

> 
> From aef15784aecbf6cb08d181eca6186fe7d2261771 Mon Sep 17 00:00:00 2001
> From: Ezequiel Lara Gomez <ezegomez@amazon.com>
> Date: Sat, 11 Mar 2017 20:06:54 +0000
> Subject: [PATCH v4] Enable tx timestamping on loopback and dummy
> 
> This enables developing code that uses SOF_TIMESTAMPING_TX_SOFTWARE
> by using local addresses (without needing to send packets outside),
> as well as enabling unit and functional testing of TX timestamping code
> without needing hardware support or network access.
> 
> It also fulfills the expectation of software network devices supporting
> software-based timestamping.
> 
> Tested on qemu using txtimestamping.c from the kernel selftests, and
> ethtool -T.

Please read Documentation/SubmittingPatches, you are failing to provide
a proper signoff in your patch postings.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v5] Enable tx timestamping on loopback and dummy
  2017-03-13 19:15           ` David Miller
@ 2017-03-14 10:59             ` Ezequiel Lara Gomez
  0 siblings, 0 replies; 12+ messages in thread
From: Ezequiel Lara Gomez @ 2017-03-14 10:59 UTC (permalink / raw)
  To: David Miller; +Cc: richardcochran, netdev


>From aafd3312170ed658571ef443675036f96114c2d7 Mon Sep 17 00:00:00 2001
From: Ezequiel Lara Gomez <ezegomez@amazon.com>
Date: Sat, 11 Mar 2017 20:06:54 +0000
Subject: [PATCH v5] Enable tx timestamping on loopback and dummy

This enables developing code that uses SOF_TIMESTAMPING_TX_SOFTWARE
by using localhost addresses (without needing to send packets outside),
as well as enabling unit and functional testing of TX timestamping code
without needing hardware support or network access.

It also fulfills the expectation of software network devices supporting
software-based timestamping.

Tested on qemu using txtimestamping.c from the kernel selftests, and
ethtool -T.

Signed-off-by: Ezequiel Lara Gomez <ezegomez@amazon.com>
---
Changes:
* v2: split styling changes suggested by checkpatch.pl to a separate patch
* v3: added ethtool reporting of tx timestamping support
* v4: clarified on the commit message the reason to introduce this.
* v5: proper signoff of the change. Apologies!

 drivers/net/dummy.c    | 15 +++++++++++++++
 drivers/net/loopback.c | 15 +++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c
index 2c80611..149244a 100644
--- a/drivers/net/dummy.c
+++ b/drivers/net/dummy.c
@@ -35,6 +35,7 @@
 #include <linux/init.h>
 #include <linux/moduleparam.h>
 #include <linux/rtnetlink.h>
+#include <linux/net_tstamp.h>
 #include <net/rtnetlink.h>
 #include <linux/u64_stats_sync.h>
 
@@ -125,6 +126,7 @@ static netdev_tx_t dummy_xmit(struct sk_buff *skb, struct net_device *dev)
 	dstats->tx_bytes += skb->len;
 	u64_stats_update_end(&dstats->syncp);
 
+	skb_tx_timestamp(skb);
 	dev_kfree_skb(skb);
 	return NETDEV_TX_OK;
 }
@@ -304,8 +306,21 @@ static void dummy_get_drvinfo(struct net_device *dev,
 	strlcpy(info->version, DRV_VERSION, sizeof(info->version));
 }
 
+static int dummy_get_ts_info(struct net_device *dev,
+			      struct ethtool_ts_info *ts_info)
+{
+	ts_info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE |
+				   SOF_TIMESTAMPING_RX_SOFTWARE |
+				   SOF_TIMESTAMPING_SOFTWARE;
+
+	ts_info->phc_index = -1;
+
+	return 0;
+};
+
 static const struct ethtool_ops dummy_ethtool_ops = {
 	.get_drvinfo            = dummy_get_drvinfo,
+	.get_ts_info		= dummy_get_ts_info,
 };
 
 static void dummy_free_netdev(struct net_device *dev)
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index 122cc2d..3a60d27 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -55,6 +55,7 @@
 #include <linux/ip.h>
 #include <linux/tcp.h>
 #include <linux/percpu.h>
+#include <linux/net_tstamp.h>
 #include <net/net_namespace.h>
 #include <linux/u64_stats_sync.h>
 
@@ -74,6 +75,7 @@ static netdev_tx_t loopback_xmit(struct sk_buff *skb,
 	struct pcpu_lstats *lb_stats;
 	int len;
 
+	skb_tx_timestamp(skb);
 	skb_orphan(skb);
 
 	/* Before queueing this packet to netif_rx(),
@@ -129,8 +131,21 @@ static u32 always_on(struct net_device *dev)
 	return 1;
 }
 
+static int loopback_get_ts_info(struct net_device *netdev,
+				struct ethtool_ts_info *ts_info)
+{
+	ts_info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE |
+				   SOF_TIMESTAMPING_RX_SOFTWARE |
+				   SOF_TIMESTAMPING_SOFTWARE;
+
+	ts_info->phc_index = -1;
+
+	return 0;
+};
+
 static const struct ethtool_ops loopback_ethtool_ops = {
 	.get_link		= always_on,
+	.get_ts_info		= loopback_get_ts_info,
 };
 
 static int loopback_dev_init(struct net_device *dev)
-- 
1.9.1

Amazon Data Services Ireland Limited registered office: One Burlington Plaza, Burlington Road, Dublin 4, Ireland. Registered in Ireland. Registration number 390566.

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2017-03-14 10:59 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-11 14:42 [PATCH] Enable tx timestamping on loopback and dummy Ezequiel Lara Gomez
2017-03-11 15:59 ` Soheil Hassas Yeganeh
2017-03-11 23:17 ` Oliver Hartkopp
2017-03-11 23:37   ` Lara Gomez, Ezequiel
2017-03-12 16:30   ` Richard Cochran
2017-03-12 20:39     ` Ezequiel Lara Gomez
2017-03-13 10:35       ` Richard Cochran
2017-03-12 21:52     ` [PATCH v3] " Ezequiel Lara Gomez
2017-03-13 10:40       ` Richard Cochran
2017-03-13 11:16         ` [PATCH v4] " Ezequiel Lara Gomez
2017-03-13 19:15           ` David Miller
2017-03-14 10:59             ` [PATCH v5] " Ezequiel Lara Gomez

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.