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

can: flexcan: add ethtool support to get rx/tx ring parameters

This patch adds ethtool support to get the number of message buffers
configured for reception/transmission, which may also depends on
runtime configurations such as the 'rx-rtr' flag state.

Link: https://lore.kernel.org/all/20220108181633.420433-1-dario.binacchi@amarulasolutions.com
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
[mkl: port to net-next/master, replace __sw_hweight64 by simpler calculation]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

authored by

Dario Binacchi and committed by
Marc Kleine-Budde
74fc5a45 1c45f577

+21
+21
drivers/net/can/flexcan/flexcan-ethtool.c
··· 18 18 }; 19 19 20 20 static void 21 + flexcan_get_ringparam(struct net_device *ndev, struct ethtool_ringparam *ring, 22 + struct kernel_ethtool_ringparam *kernel_ring, 23 + struct netlink_ext_ack *ext_ack) 24 + { 25 + const struct flexcan_priv *priv = netdev_priv(ndev); 26 + 27 + ring->rx_max_pending = priv->mb_count; 28 + ring->tx_max_pending = priv->mb_count; 29 + 30 + if (priv->devtype_data.quirks & FLEXCAN_QUIRK_USE_RX_MAILBOX) 31 + ring->rx_pending = priv->offload.mb_last - 32 + priv->offload.mb_first + 1; 33 + else 34 + ring->rx_pending = 6; /* RX-FIFO depth is fixed */ 35 + 36 + /* the drive currently supports only on TX buffer */ 37 + ring->tx_pending = 1; 38 + } 39 + 40 + static void 21 41 flexcan_get_strings(struct net_device *ndev, u32 stringset, u8 *data) 22 42 { 23 43 switch (stringset) { ··· 101 81 } 102 82 103 83 static const struct ethtool_ops flexcan_ethtool_ops = { 84 + .get_ringparam = flexcan_get_ringparam, 104 85 .get_strings = flexcan_get_strings, 105 86 .get_priv_flags = flexcan_get_priv_flags, 106 87 .set_priv_flags = flexcan_set_priv_flags,