Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

can: mcp251xfd: advertise timestamping capabilities and add ioctl support

Currently, userland has no methods to query which timestamping
features are supported by the mcp251xfd 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 it 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-10-mailhol.vincent@wanadoo.fr
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

authored by

Vincent Mailhol and committed by
Marc Kleine-Budde
b1f6b93e 90f942c5

+2
+1
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
··· 1671 1671 .ndo_open = mcp251xfd_open, 1672 1672 .ndo_stop = mcp251xfd_stop, 1673 1673 .ndo_start_xmit = mcp251xfd_start_xmit, 1674 + .ndo_eth_ioctl = can_eth_ioctl_hwts, 1674 1675 .ndo_change_mtu = can_change_mtu, 1675 1676 }; 1676 1677
+1
drivers/net/can/spi/mcp251xfd/mcp251xfd-ethtool.c
··· 124 124 .set_ringparam = mcp251xfd_ring_set_ringparam, 125 125 .get_coalesce = mcp251xfd_ring_get_coalesce, 126 126 .set_coalesce = mcp251xfd_ring_set_coalesce, 127 + .get_ts_info = can_ethtool_op_get_ts_info_hwts, 127 128 }; 128 129 129 130 void mcp251xfd_ethtool_init(struct mcp251xfd_priv *priv)