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

netdevsim: support ethtool ring and coalesce settings

Add ethtool ring and coalesce settings support for testing.

Signed-off-by: Antonio Cardace <acardace@redhat.com>
Reviewed-by: Michal Kubecek <mkubecek@suse.cz>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Antonio Cardace and committed by
Jakub Kicinski
a7fc6db0 77f9591b

+66 -3
+63 -3
drivers/net/netdevsim/ethtool.c
··· 42 42 return 0; 43 43 } 44 44 45 + static int nsim_get_coalesce(struct net_device *dev, 46 + struct ethtool_coalesce *coal) 47 + { 48 + struct netdevsim *ns = netdev_priv(dev); 49 + 50 + memcpy(coal, &ns->ethtool.coalesce, sizeof(ns->ethtool.coalesce)); 51 + return 0; 52 + } 53 + 54 + static int nsim_set_coalesce(struct net_device *dev, 55 + struct ethtool_coalesce *coal) 56 + { 57 + struct netdevsim *ns = netdev_priv(dev); 58 + 59 + memcpy(&ns->ethtool.coalesce, coal, sizeof(ns->ethtool.coalesce)); 60 + return 0; 61 + } 62 + 63 + static void nsim_get_ringparam(struct net_device *dev, 64 + struct ethtool_ringparam *ring) 65 + { 66 + struct netdevsim *ns = netdev_priv(dev); 67 + 68 + memcpy(ring, &ns->ethtool.ring, sizeof(ns->ethtool.ring)); 69 + } 70 + 71 + static int nsim_set_ringparam(struct net_device *dev, 72 + struct ethtool_ringparam *ring) 73 + { 74 + struct netdevsim *ns = netdev_priv(dev); 75 + 76 + memcpy(&ns->ethtool.ring, ring, sizeof(ns->ethtool.ring)); 77 + return 0; 78 + } 79 + 45 80 static const struct ethtool_ops nsim_ethtool_ops = { 46 - .get_pause_stats = nsim_get_pause_stats, 47 - .get_pauseparam = nsim_get_pauseparam, 48 - .set_pauseparam = nsim_set_pauseparam, 81 + .supported_coalesce_params = ETHTOOL_COALESCE_ALL_PARAMS, 82 + .get_pause_stats = nsim_get_pause_stats, 83 + .get_pauseparam = nsim_get_pauseparam, 84 + .set_pauseparam = nsim_set_pauseparam, 85 + .set_coalesce = nsim_set_coalesce, 86 + .get_coalesce = nsim_get_coalesce, 87 + .get_ringparam = nsim_get_ringparam, 88 + .set_ringparam = nsim_set_ringparam, 49 89 }; 90 + 91 + static void nsim_ethtool_ring_init(struct netdevsim *ns) 92 + { 93 + ns->ethtool.ring.rx_max_pending = 4096; 94 + ns->ethtool.ring.rx_jumbo_max_pending = 4096; 95 + ns->ethtool.ring.rx_mini_max_pending = 4096; 96 + ns->ethtool.ring.tx_max_pending = 4096; 97 + } 50 98 51 99 void nsim_ethtool_init(struct netdevsim *ns) 52 100 { 53 101 struct dentry *ethtool, *dir; 54 102 55 103 ns->netdev->ethtool_ops = &nsim_ethtool_ops; 104 + 105 + nsim_ethtool_ring_init(ns); 56 106 57 107 ethtool = debugfs_create_dir("ethtool", ns->nsim_dev_port->ddir); 58 108 ··· 111 61 &ns->ethtool.pauseparam.report_stats_rx); 112 62 debugfs_create_bool("report_stats_tx", 0600, dir, 113 63 &ns->ethtool.pauseparam.report_stats_tx); 64 + 65 + dir = debugfs_create_dir("ring", ethtool); 66 + debugfs_create_u32("rx_max_pending", 0600, dir, 67 + &ns->ethtool.ring.rx_max_pending); 68 + debugfs_create_u32("rx_jumbo_max_pending", 0600, dir, 69 + &ns->ethtool.ring.rx_jumbo_max_pending); 70 + debugfs_create_u32("rx_mini_max_pending", 0600, dir, 71 + &ns->ethtool.ring.rx_mini_max_pending); 72 + debugfs_create_u32("tx_max_pending", 0600, dir, 73 + &ns->ethtool.ring.tx_max_pending); 114 74 }
+3
drivers/net/netdevsim/netdevsim.h
··· 15 15 16 16 #include <linux/debugfs.h> 17 17 #include <linux/device.h> 18 + #include <linux/ethtool.h> 18 19 #include <linux/kernel.h> 19 20 #include <linux/list.h> 20 21 #include <linux/netdevice.h> ··· 61 60 62 61 struct nsim_ethtool { 63 62 struct nsim_ethtool_pauseparam pauseparam; 63 + struct ethtool_coalesce coalesce; 64 + struct ethtool_ringparam ring; 64 65 }; 65 66 66 67 struct netdevsim {