Skip to content

Commit f44124f

Browse files
vincent-mailholgregkh
authored andcommitted
can: etas_es58x: advertise timestamping capabilities and add ioctl support
[ Upstream commit 1d46efa ] Currently, userland has no method to query which timestamping features are supported by the etas_es58x driver (aside maybe of getting RX messages and observe whether or not hardware timestamps stay at zero). The canonical way for a network driver to advertise what kind of timestamping is supports is to implement ethtool_ops::get_ts_info(). Here, we use the CAN specific can_ethtool_op_get_ts_info_hwts() function to achieve this. In addition, the driver currently does not support the hardware timestamps ioctls. According to [1], SIOCSHWTSTAMP is "must" and SIOCGHWTSTAMP is "should". This patch fills up that gap by implementing net_device_ops::ndo_eth_ioctl() using the CAN specific function can_eth_ioctl_hwts(). [1] kernel doc Timestamping, section 3.1: "Hardware Timestamping Implementation: Device Drivers" Link: https://docs.kernel.org/networking/timestamping.html#hardware-timestamping-implementation-device-drivers Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> Link: https://lore.kernel.org/all/20220727101641.198847-11-mailhol.vincent@wanadoo.fr Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Stable-dep-of: 38c0aba ("can: etas_es58x: populate ndo_change_mtu() to prevent buffer overflow") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 0a6e1bd commit f44124f

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

drivers/net/can/usb/etas_es58x/es58x_core.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* Copyright (c) 2020, 2021 Vincent Mailhol <mailhol.vincent@wanadoo.fr>
1111
*/
1212

13+
#include <linux/ethtool.h>
1314
#include <linux/kernel.h>
1415
#include <linux/module.h>
1516
#include <linux/usb.h>
@@ -1981,7 +1982,12 @@ static netdev_tx_t es58x_start_xmit(struct sk_buff *skb,
19811982
static const struct net_device_ops es58x_netdev_ops = {
19821983
.ndo_open = es58x_open,
19831984
.ndo_stop = es58x_stop,
1984-
.ndo_start_xmit = es58x_start_xmit
1985+
.ndo_start_xmit = es58x_start_xmit,
1986+
.ndo_eth_ioctl = can_eth_ioctl_hwts,
1987+
};
1988+
1989+
static const struct ethtool_ops es58x_ethtool_ops = {
1990+
.get_ts_info = can_ethtool_op_get_ts_info_hwts,
19851991
};
19861992

19871993
/**
@@ -2088,6 +2094,7 @@ static int es58x_init_netdev(struct es58x_device *es58x_dev, int channel_idx)
20882094
es58x_init_priv(es58x_dev, es58x_priv(netdev), channel_idx);
20892095

20902096
netdev->netdev_ops = &es58x_netdev_ops;
2097+
netdev->ethtool_ops = &es58x_ethtool_ops;
20912098
netdev->flags |= IFF_ECHO; /* We support local echo */
20922099

20932100
ret = register_candev(netdev);

0 commit comments

Comments
 (0)