4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of version 2 of the GNU General Public License as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 * The full GNU General Public License is included in this distribution
19 * in the file called LICENSE.GPL.
21 * Contact Information:
25 #include <linux/device.h>
26 #include <linux/netdevice.h>
27 #include <linux/ethtool.h>
31 kni_check_if_running(struct net_device *dev)
33 struct kni_dev *priv = netdev_priv(dev);
42 kni_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
44 struct kni_dev *priv = netdev_priv(dev);
46 priv->lad_dev->ethtool_ops->get_drvinfo(priv->lad_dev, info);
50 kni_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
52 struct kni_dev *priv = netdev_priv(dev);
54 return priv->lad_dev->ethtool_ops->get_settings(priv->lad_dev, ecmd);
58 kni_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
60 struct kni_dev *priv = netdev_priv(dev);
62 return priv->lad_dev->ethtool_ops->set_settings(priv->lad_dev, ecmd);
66 kni_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
68 struct kni_dev *priv = netdev_priv(dev);
70 priv->lad_dev->ethtool_ops->get_wol(priv->lad_dev, wol);
74 kni_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
76 struct kni_dev *priv = netdev_priv(dev);
78 return priv->lad_dev->ethtool_ops->set_wol(priv->lad_dev, wol);
82 kni_nway_reset(struct net_device *dev)
84 struct kni_dev *priv = netdev_priv(dev);
86 return priv->lad_dev->ethtool_ops->nway_reset(priv->lad_dev);
90 kni_get_eeprom_len(struct net_device *dev)
92 struct kni_dev *priv = netdev_priv(dev);
94 return priv->lad_dev->ethtool_ops->get_eeprom_len(priv->lad_dev);
98 kni_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
101 struct kni_dev *priv = netdev_priv(dev);
103 return priv->lad_dev->ethtool_ops->get_eeprom(priv->lad_dev, eeprom,
108 kni_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
111 struct kni_dev *priv = netdev_priv(dev);
113 return priv->lad_dev->ethtool_ops->set_eeprom(priv->lad_dev, eeprom,
118 kni_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
120 struct kni_dev *priv = netdev_priv(dev);
122 priv->lad_dev->ethtool_ops->get_ringparam(priv->lad_dev, ring);
126 kni_set_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
128 struct kni_dev *priv = netdev_priv(dev);
130 return priv->lad_dev->ethtool_ops->set_ringparam(priv->lad_dev, ring);
134 kni_get_pauseparam(struct net_device *dev, struct ethtool_pauseparam *pause)
136 struct kni_dev *priv = netdev_priv(dev);
138 priv->lad_dev->ethtool_ops->get_pauseparam(priv->lad_dev, pause);
142 kni_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam *pause)
144 struct kni_dev *priv = netdev_priv(dev);
146 return priv->lad_dev->ethtool_ops->set_pauseparam(priv->lad_dev,
151 kni_get_msglevel(struct net_device *dev)
153 struct kni_dev *priv = netdev_priv(dev);
155 return priv->lad_dev->ethtool_ops->get_msglevel(priv->lad_dev);
159 kni_set_msglevel(struct net_device *dev, u32 data)
161 struct kni_dev *priv = netdev_priv(dev);
163 priv->lad_dev->ethtool_ops->set_msglevel(priv->lad_dev, data);
167 kni_get_regs_len(struct net_device *dev)
169 struct kni_dev *priv = netdev_priv(dev);
171 return priv->lad_dev->ethtool_ops->get_regs_len(priv->lad_dev);
175 kni_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p)
177 struct kni_dev *priv = netdev_priv(dev);
179 priv->lad_dev->ethtool_ops->get_regs(priv->lad_dev, regs, p);
183 kni_get_strings(struct net_device *dev, u32 stringset, u8 *data)
185 struct kni_dev *priv = netdev_priv(dev);
187 priv->lad_dev->ethtool_ops->get_strings(priv->lad_dev, stringset,
192 kni_get_sset_count(struct net_device *dev, int sset)
194 struct kni_dev *priv = netdev_priv(dev);
196 return priv->lad_dev->ethtool_ops->get_sset_count(priv->lad_dev, sset);
200 kni_get_ethtool_stats(struct net_device *dev, struct ethtool_stats *stats,
203 struct kni_dev *priv = netdev_priv(dev);
205 priv->lad_dev->ethtool_ops->get_ethtool_stats(priv->lad_dev, stats,
209 struct ethtool_ops kni_ethtool_ops = {
210 .begin = kni_check_if_running,
211 .get_drvinfo = kni_get_drvinfo,
212 .get_settings = kni_get_settings,
213 .set_settings = kni_set_settings,
214 .get_regs_len = kni_get_regs_len,
215 .get_regs = kni_get_regs,
216 .get_wol = kni_get_wol,
217 .set_wol = kni_set_wol,
218 .nway_reset = kni_nway_reset,
219 .get_link = ethtool_op_get_link,
220 .get_eeprom_len = kni_get_eeprom_len,
221 .get_eeprom = kni_get_eeprom,
222 .set_eeprom = kni_set_eeprom,
223 .get_ringparam = kni_get_ringparam,
224 .set_ringparam = kni_set_ringparam,
225 .get_pauseparam = kni_get_pauseparam,
226 .set_pauseparam = kni_set_pauseparam,
227 .get_msglevel = kni_get_msglevel,
228 .set_msglevel = kni_set_msglevel,
229 .get_strings = kni_get_strings,
230 .get_sset_count = kni_get_sset_count,
231 .get_ethtool_stats = kni_get_ethtool_stats,
235 kni_set_ethtool_ops(struct net_device *netdev)
237 netdev->ethtool_ops = &kni_ethtool_ops;