aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Walle <michael@walle.cc>2018-08-29 11:24:11 -0400
committerDavid S. Miller <davem@davemloft.net>2018-09-01 01:56:46 -0400
commitaa4e689ed1a7b5c1a479a57f05da0a340b1f8d0c (patch)
treef576b7907f98f8a9fc18ac0f98016b8707053082
parentf061b48c1787e6fece2190e27da6878f4f1796d0 (diff)
veth: add software timestamping
Provide a software TX timestamp as well as the ethtool query interface and report the software timestamp capabilities. Tested with "ethtool -T" and two linuxptp instances each bound to a tunnel endpoint. Signed-off-by: Michael Walle <michael@walle.cc> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/veth.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 8d679c8b7f25..bc8faf13a731 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -24,6 +24,7 @@
24#include <linux/filter.h> 24#include <linux/filter.h>
25#include <linux/ptr_ring.h> 25#include <linux/ptr_ring.h>
26#include <linux/bpf_trace.h> 26#include <linux/bpf_trace.h>
27#include <linux/net_tstamp.h>
27 28
28#define DRV_NAME "veth" 29#define DRV_NAME "veth"
29#define DRV_VERSION "1.0" 30#define DRV_VERSION "1.0"
@@ -114,6 +115,18 @@ static void veth_get_ethtool_stats(struct net_device *dev,
114 data[0] = peer ? peer->ifindex : 0; 115 data[0] = peer ? peer->ifindex : 0;
115} 116}
116 117
118static int veth_get_ts_info(struct net_device *dev,
119 struct ethtool_ts_info *info)
120{
121 info->so_timestamping =
122 SOF_TIMESTAMPING_TX_SOFTWARE |
123 SOF_TIMESTAMPING_RX_SOFTWARE |
124 SOF_TIMESTAMPING_SOFTWARE;
125 info->phc_index = -1;
126
127 return 0;
128}
129
117static const struct ethtool_ops veth_ethtool_ops = { 130static const struct ethtool_ops veth_ethtool_ops = {
118 .get_drvinfo = veth_get_drvinfo, 131 .get_drvinfo = veth_get_drvinfo,
119 .get_link = ethtool_op_get_link, 132 .get_link = ethtool_op_get_link,
@@ -121,6 +134,7 @@ static const struct ethtool_ops veth_ethtool_ops = {
121 .get_sset_count = veth_get_sset_count, 134 .get_sset_count = veth_get_sset_count,
122 .get_ethtool_stats = veth_get_ethtool_stats, 135 .get_ethtool_stats = veth_get_ethtool_stats,
123 .get_link_ksettings = veth_get_link_ksettings, 136 .get_link_ksettings = veth_get_link_ksettings,
137 .get_ts_info = veth_get_ts_info,
124}; 138};
125 139
126/* general routines */ 140/* general routines */
@@ -201,6 +215,7 @@ static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev)
201 skb_record_rx_queue(skb, rxq); 215 skb_record_rx_queue(skb, rxq);
202 } 216 }
203 217
218 skb_tx_timestamp(skb);
204 if (likely(veth_forward_skb(rcv, skb, rq, rcv_xdp) == NET_RX_SUCCESS)) { 219 if (likely(veth_forward_skb(rcv, skb, rq, rcv_xdp) == NET_RX_SUCCESS)) {
205 struct pcpu_vstats *stats = this_cpu_ptr(dev->vstats); 220 struct pcpu_vstats *stats = this_cpu_ptr(dev->vstats);
206 221