Skip to content

Commit aa4e689

Browse files
mwalledavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f061b48 commit aa4e689

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

drivers/net/veth.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/filter.h>
2525
#include <linux/ptr_ring.h>
2626
#include <linux/bpf_trace.h>
27+
#include <linux/net_tstamp.h>
2728

2829
#define DRV_NAME "veth"
2930
#define DRV_VERSION "1.0"
@@ -114,13 +115,26 @@ static void veth_get_ethtool_stats(struct net_device *dev,
114115
data[0] = peer ? peer->ifindex : 0;
115116
}
116117

118+
static 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+
117130
static const struct ethtool_ops veth_ethtool_ops = {
118131
.get_drvinfo = veth_get_drvinfo,
119132
.get_link = ethtool_op_get_link,
120133
.get_strings = veth_get_strings,
121134
.get_sset_count = veth_get_sset_count,
122135
.get_ethtool_stats = veth_get_ethtool_stats,
123136
.get_link_ksettings = veth_get_link_ksettings,
137+
.get_ts_info = veth_get_ts_info,
124138
};
125139

126140
/* general routines */
@@ -201,6 +215,7 @@ static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev)
201215
skb_record_rx_queue(skb, rxq);
202216
}
203217

218+
skb_tx_timestamp(skb);
204219
if (likely(veth_forward_skb(rcv, skb, rq, rcv_xdp) == NET_RX_SUCCESS)) {
205220
struct pcpu_vstats *stats = this_cpu_ptr(dev->vstats);
206221

0 commit comments

Comments
 (0)