diff options
author | Marc Kleine-Budde | 2021-10-25 11:34:32 +0200 |
---|---|---|
committer | Marc Kleine-Budde | 2022-03-13 09:45:35 +0100 |
commit | d86ba8db6af3af567cd9a20e194e5ebd8f21987e (patch) | |
tree | cf24bfd3400ebaa135271d5f714217eab64f548d /drivers/net/can/spi/mcp251xfd/mcp251xfd-ethtool.c | |
parent | b8123d94f58cdd1f3d476f60156fc356194bec55 (diff) |
can: mcp251xfd: ethtool: add support
This patch adds basic ethtool support (to query the current and
maximum ring parameters) to the driver.
Link: https://lore.kernel.org/20220313083640.501791-5-mkl@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'drivers/net/can/spi/mcp251xfd/mcp251xfd-ethtool.c')
-rw-r--r-- | drivers/net/can/spi/mcp251xfd/mcp251xfd-ethtool.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/drivers/net/can/spi/mcp251xfd/mcp251xfd-ethtool.c b/drivers/net/can/spi/mcp251xfd/mcp251xfd-ethtool.c new file mode 100644 index 000000000000..4131185eaf5a --- /dev/null +++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd-ethtool.c @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// mcp251xfd - Microchip MCP251xFD Family CAN controller driver +// +// Copyright (c) 2021, 2022 Pengutronix, +// Marc Kleine-Budde <kernel@pengutronix.de> +// + +#include <linux/ethtool.h> + +#include "mcp251xfd.h" + +static void +mcp251xfd_ring_get_ringparam(struct net_device *ndev, + struct ethtool_ringparam *ring, + struct kernel_ethtool_ringparam *kernel_ring, + struct netlink_ext_ack *extack) +{ + const struct mcp251xfd_priv *priv = netdev_priv(ndev); + + ring->rx_max_pending = MCP251XFD_RX_OBJ_NUM_MAX; + ring->tx_max_pending = MCP251XFD_TX_OBJ_NUM_MAX; + + ring->rx_pending = priv->rx_obj_num; + ring->tx_pending = priv->tx->obj_num; +} + +static const struct ethtool_ops mcp251xfd_ethtool_ops = { + .get_ringparam = mcp251xfd_ring_get_ringparam, +}; + +void mcp251xfd_ethtool_init(struct mcp251xfd_priv *priv) +{ + priv->ndev->ethtool_ops = &mcp251xfd_ethtool_ops; +} |