Commit aa4e689e authored by Michael Walle's avatar Michael Walle Committed by David S. Miller

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: default avatarMichael Walle <michael@walle.cc>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f061b48c
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/filter.h> #include <linux/filter.h>
#include <linux/ptr_ring.h> #include <linux/ptr_ring.h>
#include <linux/bpf_trace.h> #include <linux/bpf_trace.h>
#include <linux/net_tstamp.h>
#define DRV_NAME "veth" #define DRV_NAME "veth"
#define DRV_VERSION "1.0" #define DRV_VERSION "1.0"
...@@ -114,6 +115,18 @@ static void veth_get_ethtool_stats(struct net_device *dev, ...@@ -114,6 +115,18 @@ static void veth_get_ethtool_stats(struct net_device *dev,
data[0] = peer ? peer->ifindex : 0; data[0] = peer ? peer->ifindex : 0;
} }
static int veth_get_ts_info(struct net_device *dev,
struct ethtool_ts_info *info)
{
info->so_timestamping =
SOF_TIMESTAMPING_TX_SOFTWARE |
SOF_TIMESTAMPING_RX_SOFTWARE |
SOF_TIMESTAMPING_SOFTWARE;
info->phc_index = -1;
return 0;
}
static const struct ethtool_ops veth_ethtool_ops = { static const struct ethtool_ops veth_ethtool_ops = {
.get_drvinfo = veth_get_drvinfo, .get_drvinfo = veth_get_drvinfo,
.get_link = ethtool_op_get_link, .get_link = ethtool_op_get_link,
...@@ -121,6 +134,7 @@ static const struct ethtool_ops veth_ethtool_ops = { ...@@ -121,6 +134,7 @@ static const struct ethtool_ops veth_ethtool_ops = {
.get_sset_count = veth_get_sset_count, .get_sset_count = veth_get_sset_count,
.get_ethtool_stats = veth_get_ethtool_stats, .get_ethtool_stats = veth_get_ethtool_stats,
.get_link_ksettings = veth_get_link_ksettings, .get_link_ksettings = veth_get_link_ksettings,
.get_ts_info = veth_get_ts_info,
}; };
/* general routines */ /* general routines */
...@@ -201,6 +215,7 @@ static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -201,6 +215,7 @@ static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev)
skb_record_rx_queue(skb, rxq); skb_record_rx_queue(skb, rxq);
} }
skb_tx_timestamp(skb);
if (likely(veth_forward_skb(rcv, skb, rq, rcv_xdp) == NET_RX_SUCCESS)) { if (likely(veth_forward_skb(rcv, skb, rq, rcv_xdp) == NET_RX_SUCCESS)) {
struct pcpu_vstats *stats = this_cpu_ptr(dev->vstats); struct pcpu_vstats *stats = this_cpu_ptr(dev->vstats);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment