1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * Copyright 2021, Dario Binacchi <dariobin@libero.it> 4 */ 5 6 #include <linux/ethtool.h> 7 #include <linux/kernel.h> 8 #include <linux/platform_device.h> 9 #include <linux/netdevice.h> 10 #include <linux/can/dev.h> 11 12 #include "c_can.h" 13 14 static void c_can_get_drvinfo(struct net_device *netdev, 15 struct ethtool_drvinfo *info) 16 { 17 struct c_can_priv *priv = netdev_priv(netdev); 18 strscpy(info->driver, "c_can", sizeof(info->driver)); 19 strscpy(info->bus_info, dev_name(priv->device), sizeof(info->bus_info)); 20 } 21 22 static void c_can_get_ringparam(struct net_device *netdev, 23 struct ethtool_ringparam *ring) 24 { 25 struct c_can_priv *priv = netdev_priv(netdev); 26 27 ring->rx_max_pending = priv->msg_obj_num; 28 ring->tx_max_pending = priv->msg_obj_num; 29 ring->rx_pending = priv->msg_obj_rx_num; 30 ring->tx_pending = priv->msg_obj_tx_num; 31 } 32 33 static const struct ethtool_ops c_can_ethtool_ops = { 34 .get_drvinfo = c_can_get_drvinfo, 35 .get_ringparam = c_can_get_ringparam, 36 }; 37 38 void c_can_set_ethtool_ops(struct net_device *netdev) 39 { 40 netdev->ethtool_ops = &c_can_ethtool_ops; 41 } 42