Skip to content

Commit 74fc5a4

Browse files
passgatmarckleinebudde
authored andcommitted
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/[email protected] Signed-off-by: Dario Binacchi <[email protected]> [mkl: port to net-next/master, replace __sw_hweight64 by simpler calculation] Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent 1c45f57 commit 74fc5a4

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

drivers/net/can/flexcan/flexcan-ethtool.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,26 @@ static const char flexcan_priv_flags_strings[][ETH_GSTRING_LEN] = {
1717
"rx-rtr",
1818
};
1919

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+
2040
static void
2141
flexcan_get_strings(struct net_device *ndev, u32 stringset, u8 *data)
2242
{
@@ -81,6 +101,7 @@ static int flexcan_get_sset_count(struct net_device *netdev, int sset)
81101
}
82102

83103
static const struct ethtool_ops flexcan_ethtool_ops = {
104+
.get_ringparam = flexcan_get_ringparam,
84105
.get_strings = flexcan_get_strings,
85106
.get_priv_flags = flexcan_get_priv_flags,
86107
.set_priv_flags = flexcan_set_priv_flags,

0 commit comments

Comments
 (0)