eal: deprecate old cpu features check function
[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
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
46         priv->lad_dev->ethtool_ops->get_drvinfo(priv->lad_dev, info);
47 }
48
49 static int
50 kni_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
51 {
52         struct kni_dev *priv = netdev_priv(dev);
53
54         return priv->lad_dev->ethtool_ops->get_settings(priv->lad_dev, ecmd);
55 }
56
57 static int
58 kni_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
59 {
60         struct kni_dev *priv = netdev_priv(dev);
61
62         return priv->lad_dev->ethtool_ops->set_settings(priv->lad_dev, ecmd);
63 }
64
65 static void
66 kni_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
67 {
68         struct kni_dev *priv = netdev_priv(dev);
69
70         priv->lad_dev->ethtool_ops->get_wol(priv->lad_dev, wol);
71 }
72
73 static int
74 kni_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
75 {
76         struct kni_dev *priv = netdev_priv(dev);
77
78         return priv->lad_dev->ethtool_ops->set_wol(priv->lad_dev, wol);
79 }
80
81 static int
82 kni_nway_reset(struct net_device *dev)
83 {
84         struct kni_dev *priv = netdev_priv(dev);
85
86         return priv->lad_dev->ethtool_ops->nway_reset(priv->lad_dev);
87 }
88
89 static int
90 kni_get_eeprom_len(struct net_device *dev)
91 {
92         struct kni_dev *priv = netdev_priv(dev);
93
94         return priv->lad_dev->ethtool_ops->get_eeprom_len(priv->lad_dev);
95 }
96
97 static int
98 kni_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
99                                                         u8 *bytes)
100 {
101         struct kni_dev *priv = netdev_priv(dev);
102
103         return priv->lad_dev->ethtool_ops->get_eeprom(priv->lad_dev, eeprom,
104                                                                 bytes);
105 }
106
107 static int
108 kni_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
109                                                         u8 *bytes)
110 {
111         struct kni_dev *priv = netdev_priv(dev);
112
113         return priv->lad_dev->ethtool_ops->set_eeprom(priv->lad_dev, eeprom,
114                                                                 bytes);
115 }
116
117 static void
118 kni_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
119 {
120         struct kni_dev *priv = netdev_priv(dev);
121
122         priv->lad_dev->ethtool_ops->get_ringparam(priv->lad_dev, ring);
123 }
124
125 static int
126 kni_set_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
127 {
128         struct kni_dev *priv = netdev_priv(dev);
129
130         return priv->lad_dev->ethtool_ops->set_ringparam(priv->lad_dev, ring);
131 }
132
133 static void
134 kni_get_pauseparam(struct net_device *dev, struct ethtool_pauseparam *pause)
135 {
136         struct kni_dev *priv = netdev_priv(dev);
137
138         priv->lad_dev->ethtool_ops->get_pauseparam(priv->lad_dev, pause);
139 }
140
141 static int
142 kni_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam *pause)
143 {
144         struct kni_dev *priv = netdev_priv(dev);
145
146         return priv->lad_dev->ethtool_ops->set_pauseparam(priv->lad_dev,
147                                                                 pause);
148 }
149
150 static u32
151 kni_get_msglevel(struct net_device *dev)
152 {
153         struct kni_dev *priv = netdev_priv(dev);
154
155         return priv->lad_dev->ethtool_ops->get_msglevel(priv->lad_dev);
156 }
157
158 static void
159 kni_set_msglevel(struct net_device *dev, u32 data)
160 {
161         struct kni_dev *priv = netdev_priv(dev);
162
163         priv->lad_dev->ethtool_ops->set_msglevel(priv->lad_dev, data);
164 }
165
166 static int
167 kni_get_regs_len(struct net_device *dev)
168 {
169         struct kni_dev *priv = netdev_priv(dev);
170
171         return priv->lad_dev->ethtool_ops->get_regs_len(priv->lad_dev);
172 }
173
174 static void
175 kni_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p)
176 {
177         struct kni_dev *priv = netdev_priv(dev);
178
179         priv->lad_dev->ethtool_ops->get_regs(priv->lad_dev, regs, p);
180 }
181
182 static void
183 kni_get_strings(struct net_device *dev, u32 stringset, u8 *data)
184 {
185         struct kni_dev *priv = netdev_priv(dev);
186
187         priv->lad_dev->ethtool_ops->get_strings(priv->lad_dev, stringset,
188                                                                 data);
189 }
190
191 static int
192 kni_get_sset_count(struct net_device *dev, int sset)
193 {
194         struct kni_dev *priv = netdev_priv(dev);
195
196         return priv->lad_dev->ethtool_ops->get_sset_count(priv->lad_dev, sset);
197 }
198
199 static void
200 kni_get_ethtool_stats(struct net_device *dev, struct ethtool_stats *stats,
201                                                                 u64 *data)
202 {
203         struct kni_dev *priv = netdev_priv(dev);
204
205         priv->lad_dev->ethtool_ops->get_ethtool_stats(priv->lad_dev, stats,
206                                                                 data);
207 }
208
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,
232 };
233
234 void
235 kni_set_ethtool_ops(struct net_device *netdev)
236 {
237         netdev->ethtool_ops = &kni_ethtool_ops;
238 }