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