update Intel copyright years to 2014
[dpdk.git] / lib / librte_eal / linuxapp / kni / kni_ethtool.c
1 /*-
2  * GPL LICENSE SUMMARY
3  * 
4  *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5  * 
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.
9  * 
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.
14  * 
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.
20  * 
21  *   Contact Information:
22  *   Intel Corporation
23  */
24
25 #include <linux/device.h>
26 #include <linux/netdevice.h>
27 #include <linux/ethtool.h>
28 #include "kni_dev.h"
29
30 static int
31 kni_check_if_running(struct net_device *dev)
32 {
33         struct kni_dev *priv = netdev_priv(dev);
34         if (priv->lad_dev)
35                 return 0;
36         else
37                 return -EOPNOTSUPP;
38 }
39
40 static void
41 kni_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
42 {
43         struct kni_dev *priv = netdev_priv(dev);
44         priv->lad_dev->ethtool_ops->get_drvinfo(priv->lad_dev, info);
45 }
46
47 static int
48 kni_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
49 {
50         struct kni_dev *priv = netdev_priv(dev);
51         return priv->lad_dev->ethtool_ops->get_settings(priv->lad_dev, ecmd);
52 }
53
54 static int
55 kni_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
56 {
57         struct kni_dev *priv = netdev_priv(dev);
58         return priv->lad_dev->ethtool_ops->set_settings(priv->lad_dev, ecmd);
59 }
60
61 static void
62 kni_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
63 {
64         struct kni_dev *priv = netdev_priv(dev);
65         priv->lad_dev->ethtool_ops->get_wol(priv->lad_dev, wol);
66 }
67
68 static int
69 kni_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
70 {
71         struct kni_dev *priv = netdev_priv(dev);
72         return priv->lad_dev->ethtool_ops->set_wol(priv->lad_dev, wol);
73 }
74
75 static int
76 kni_nway_reset(struct net_device *dev)
77 {
78         struct kni_dev *priv = netdev_priv(dev);
79         return priv->lad_dev->ethtool_ops->nway_reset(priv->lad_dev);
80 }
81
82 static int
83 kni_get_eeprom_len(struct net_device *dev)
84 {
85         struct kni_dev *priv = netdev_priv(dev);
86         return priv->lad_dev->ethtool_ops->get_eeprom_len(priv->lad_dev);
87 }
88
89 static int
90 kni_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
91                                                         u8 *bytes)
92 {
93         struct kni_dev *priv = netdev_priv(dev);
94         return priv->lad_dev->ethtool_ops->get_eeprom(priv->lad_dev, eeprom,
95                                                                 bytes);
96 }
97
98 static int
99 kni_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
100                                                         u8 *bytes)
101 {
102         struct kni_dev *priv = netdev_priv(dev);
103         return priv->lad_dev->ethtool_ops->set_eeprom(priv->lad_dev, eeprom,
104                                                                 bytes);
105 }
106
107 static void
108 kni_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
109 {
110         struct kni_dev *priv = netdev_priv(dev);
111         priv->lad_dev->ethtool_ops->get_ringparam(priv->lad_dev, ring);
112 }
113
114 static int
115 kni_set_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
116 {
117         struct kni_dev *priv = netdev_priv(dev);
118         return priv->lad_dev->ethtool_ops->set_ringparam(priv->lad_dev, ring);
119 }
120
121 static void
122 kni_get_pauseparam(struct net_device *dev, struct ethtool_pauseparam *pause)
123 {
124         struct kni_dev *priv = netdev_priv(dev);
125         priv->lad_dev->ethtool_ops->get_pauseparam(priv->lad_dev, pause);
126 }
127
128 static int
129 kni_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam *pause)
130 {
131         struct kni_dev *priv = netdev_priv(dev);
132         return priv->lad_dev->ethtool_ops->set_pauseparam(priv->lad_dev,
133                                                                 pause);
134 }
135
136 static u32
137 kni_get_msglevel(struct net_device *dev)
138 {
139         struct kni_dev *priv = netdev_priv(dev);
140         return priv->lad_dev->ethtool_ops->get_msglevel(priv->lad_dev);
141 }
142
143 static void
144 kni_set_msglevel(struct net_device *dev, u32 data)
145 {
146         struct kni_dev *priv = netdev_priv(dev);
147         priv->lad_dev->ethtool_ops->set_msglevel(priv->lad_dev, data);
148 }
149
150 static int
151 kni_get_regs_len(struct net_device *dev)
152 {
153         struct kni_dev *priv = netdev_priv(dev);
154         return priv->lad_dev->ethtool_ops->get_regs_len(priv->lad_dev);
155 }
156
157 static void
158 kni_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p)
159 {
160         struct kni_dev *priv = netdev_priv(dev);
161         priv->lad_dev->ethtool_ops->get_regs(priv->lad_dev, regs, p);
162 }
163
164 static void
165 kni_get_strings(struct net_device *dev, u32 stringset, u8 *data)
166 {
167         struct kni_dev *priv = netdev_priv(dev);
168         priv->lad_dev->ethtool_ops->get_strings(priv->lad_dev, stringset,
169                                                                 data);
170 }
171
172 static int
173 kni_get_sset_count(struct net_device *dev, int sset)
174 {
175         struct kni_dev *priv = netdev_priv(dev);
176         return priv->lad_dev->ethtool_ops->get_sset_count(priv->lad_dev, sset);
177 }
178
179 static void
180 kni_get_ethtool_stats(struct net_device *dev, struct ethtool_stats *stats,
181                                                                 u64 *data)
182 {
183         struct kni_dev *priv = netdev_priv(dev);
184         priv->lad_dev->ethtool_ops->get_ethtool_stats(priv->lad_dev, stats,
185                                                                 data);
186 }
187
188 struct ethtool_ops kni_ethtool_ops = {
189         .begin                          = kni_check_if_running,
190         .get_drvinfo            = kni_get_drvinfo,
191         .get_settings           = kni_get_settings,
192         .set_settings           = kni_set_settings,
193         .get_regs_len           = kni_get_regs_len,
194         .get_regs                       = kni_get_regs,
195         .get_wol                        = kni_get_wol,
196         .set_wol                        = kni_set_wol,
197         .nway_reset                     = kni_nway_reset,
198         .get_link                       = ethtool_op_get_link,
199         .get_eeprom_len         = kni_get_eeprom_len,
200         .get_eeprom                     = kni_get_eeprom,
201         .set_eeprom                     = kni_set_eeprom,
202         .get_ringparam          = kni_get_ringparam,
203         .set_ringparam          = kni_set_ringparam,
204         .get_pauseparam         = kni_get_pauseparam,
205         .set_pauseparam         = kni_set_pauseparam,
206         .get_msglevel           = kni_get_msglevel,
207         .set_msglevel           = kni_set_msglevel,
208         .get_strings            = kni_get_strings,
209         .get_sset_count         = kni_get_sset_count,
210         .get_ethtool_stats  = kni_get_ethtool_stats,
211 };
212
213 void
214 kni_set_ethtool_ops(struct net_device *netdev)
215 {
216         SET_ETHTOOL_OPS(netdev, &kni_ethtool_ops);
217 }