4 * Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #ifndef _RTE_ETHTOOL_H_
35 #define _RTE_ETHTOOL_H_
38 * This new interface is designed to provide a user-space shim layer for
39 * Ethtool and Netdevice op API.
41 * rte_ethtool_get_driver: ethtool_ops::get_driverinfo
42 * rte_ethtool_get_link: ethtool_ops::get_link
43 * rte_ethtool_get_regs_len: ethtool_ops::get_regs_len
44 * rte_ethtool_get_regs: ethtool_ops::get_regs
45 * rte_ethtool_get_eeprom_len: ethtool_ops::get_eeprom_len
46 * rte_ethtool_get_eeprom: ethtool_ops::get_eeprom
47 * rte_ethtool_set_eeprom: ethtool_ops::set_eeprom
48 * rte_ethtool_get_pauseparam: ethtool_ops::get_pauseparam
49 * rte_ethtool_set_pauseparam: ethtool_ops::set_pauseparam
51 * rte_ethtool_net_open: net_device_ops::ndo_open
52 * rte_ethtool_net_stop: net_device_ops::ndo_stop
53 * rte_ethtool_net_set_mac_addr: net_device_ops::ndo_set_mac_address
54 * rte_ethtool_net_validate_addr: net_device_ops::ndo_validate_addr
55 * rte_ethtool_net_change_mtu: net_device_ops::rte_net_change_mtu
56 * rte_ethtool_net_get_stats64: net_device_ops::ndo_get_stats64
57 * rte_ethtool_net_vlan_rx_add_vid net_device_ops::ndo_vlan_rx_add_vid
58 * rte_ethtool_net_vlan_rx_kill_vid net_device_ops::ndo_vlan_rx_kill_vid
59 * rte_ethtool_net_set_rx_mode net_device_ops::ndo_set_rx_mode
67 #include <rte_ethdev.h>
68 #include <linux/ethtool.h>
71 * Retrieve the Ethernet device driver information according to
72 * attributes described by ethtool data structure, ethtool_drvinfo.
75 * The port identifier of the Ethernet device.
77 * A pointer to get driver information
79 * - (0) if successful.
80 * - (-ENODEV) if *port_id* invalid.
82 int rte_ethtool_get_drvinfo(uint16_t port_id, struct ethtool_drvinfo *drvinfo);
85 * Retrieve the Ethernet device register length in bytes.
88 * The port identifier of the Ethernet device.
90 * - (> 0) # of device registers (in bytes) available for dump
91 * - (0) no registers available for dump.
92 * - (-ENOTSUP) if hardware doesn't support.
93 * - (-ENODEV) if *port_id* invalid.
94 * - others depends on the specific operations implementation.
96 int rte_ethtool_get_regs_len(uint16_t port_id);
99 * Retrieve the Ethernet device register information according to
100 * attributes described by ethtool data structure, ethtool_regs
103 * The port identifier of the Ethernet device.
105 * A pointer to ethtool_regs that has register information
107 * A pointer to a buffer that is used to retrieve device register content
109 * - (0) if successful.
110 * - (-ENOTSUP) if hardware doesn't support.
111 * - (-ENODEV) if *port_id* invalid.
112 * - others depends on the specific operations implementation.
114 int rte_ethtool_get_regs(uint16_t port_id, struct ethtool_regs *regs,
118 * Retrieve the Ethernet device link status
121 * The port identifier of the Ethernet device.
124 * - (0) if link down.
125 * - (-ENOTSUP) if hardware doesn't support.
126 * - (-ENODEV) if *port_id* invalid.
127 * - (-EINVAL) if parameters invalid.
128 * - others depends on the specific operations implementation.
130 int rte_ethtool_get_link(uint16_t port_id);
133 * Retrieve the Ethernet device EEPROM size
136 * The port identifier of the Ethernet device.
138 * - (> 0) device EEPROM size in bytes
139 * - (0) device has NO EEPROM
140 * - (-ENOTSUP) if hardware doesn't support.
141 * - (-ENODEV) if *port_id* invalid.
142 * - others depends on the specific operations implementation.
144 int rte_ethtool_get_eeprom_len(uint16_t port_id);
147 * Retrieve EEPROM content based upon eeprom range described in ethtool
148 * data structure, ethtool_eeprom
151 * The port identifier of the Ethernet device.
153 * The pointer of ethtool_eeprom that provides eeprom range
155 * A buffer that holds data read from eeprom
157 * - (0) if successful.
158 * - (-ENOTSUP) if hardware doesn't support.
159 * - (-ENODEV) if *port_id* invalid.
160 * - others depends on the specific operations implementation.
162 int rte_ethtool_get_eeprom(uint16_t port_id, struct ethtool_eeprom *eeprom,
166 * Setting EEPROM content based upon eeprom range described in ethtool
167 * data structure, ethtool_eeprom
170 * The port identifier of the Ethernet device.
172 * The pointer of ethtool_eeprom that provides eeprom range
174 * A buffer that holds data to be written into eeprom
176 * - (0) if successful.
177 * - (-ENOTSUP) if hardware doesn't support.
178 * - (-ENODEV) if *port_id* invalid.
179 * - (-EINVAL) if parameters invalid.
180 * - others depends on the specific operations implementation.
182 int rte_ethtool_set_eeprom(uint16_t port_id, struct ethtool_eeprom *eeprom,
186 * Retrieve the Ethernet device pause frame configuration according to
187 * parameter attributes desribed by ethtool data structure,
188 * ethtool_pauseparam.
191 * The port identifier of the Ethernet device.
193 * The pointer of ethtool_coalesce that gets pause frame
194 * configuration parameters
196 * - (0) if successful.
197 * - (-ENOTSUP) if hardware doesn't support.
198 * - (-ENODEV) if *port_id* invalid.
199 * - (-EINVAL) if parameters invalid.
200 * - others depends on the specific operations implementation.
202 int rte_ethtool_get_pauseparam(uint16_t port_id,
203 struct ethtool_pauseparam *pause_param);
206 * Setting the Ethernet device pause frame configuration according to
207 * parameter attributes desribed by ethtool data structure, ethtool_pauseparam.
210 * The port identifier of the Ethernet device.
212 * The pointer of ethtool_coalesce that gets ring configuration parameters
214 * - (0) if successful.
215 * - (-ENOTSUP) if hardware doesn't support.
216 * - (-ENODEV) if *port_id* invalid.
217 * - (-EINVAL) if parameters invalid.
218 * - others depends on the specific operations implementation.
220 int rte_ethtool_set_pauseparam(uint16_t port_id,
221 struct ethtool_pauseparam *param);
224 * Start the Ethernet device.
227 * The port identifier of the Ethernet device.
229 * - (0) if successful.
230 * - (-ENOTSUP) if hardware doesn't support.
231 * - (-ENODEV) if *port_id* invalid.
232 * - others depends on the specific operations implementation.
234 int rte_ethtool_net_open(uint16_t port_id);
237 * Stop the Ethernet device.
240 * The port identifier of the Ethernet device.
242 * - (0) if successful.
243 * - (-ENODEV) if *port_id* invalid.
245 int rte_ethtool_net_stop(uint16_t port_id);
248 * Get the Ethernet device MAC address.
251 * The port identifier of the Ethernet device.
253 * MAC address of the Ethernet device.
255 * - (0) if successful.
256 * - (-ENODEV) if *port_id* invalid.
258 int rte_ethtool_net_get_mac_addr(uint16_t port_id, struct ether_addr *addr);
261 * Setting the Ethernet device MAC address.
264 * The port identifier of the Ethernet device.
268 * - (0) if successful.
269 * - (-ENOTSUP) if hardware doesn't support.
270 * - (-ENODEV) if *port_id* invalid.
271 * - (-EINVAL) if parameters invalid.
272 * - others depends on the specific operations implementation.
274 int rte_ethtool_net_set_mac_addr(uint16_t port_id, struct ether_addr *addr);
277 * Validate if the provided MAC address is valid unicast address
280 * The port identifier of the Ethernet device.
282 * A pointer to a buffer (6-byte, 48bit) for the target MAC address
284 * - (0) if successful.
285 * - (-ENOTSUP) if hardware doesn't support.
286 * - (-ENODEV) if *port_id* invalid.
287 * - (-EINVAL) if parameters invalid.
288 * - others depends on the specific operations implementation.
290 int rte_ethtool_net_validate_addr(uint16_t port_id, struct ether_addr *addr);
293 * Setting the Ethernet device maximum Tx unit.
296 * The port identifier of the Ethernet device.
300 * - (0) if successful.
301 * - (-ENOTSUP) if hardware doesn't support.
302 * - (-ENODEV) if *port_id* invalid.
303 * - (-EINVAL) if parameters invalid.
304 * - others depends on the specific operations implementation.
306 int rte_ethtool_net_change_mtu(uint16_t port_id, int mtu);
309 * Retrieve the Ethernet device traffic statistics
312 * The port identifier of the Ethernet device.
314 * A pointer to struct rte_eth_stats for statistics parameters
316 * - (0) if successful.
317 * - (-ENOTSUP) if hardware doesn't support.
318 * - (-ENODEV) if *port_id* invalid.
319 * - (-EINVAL) if parameters invalid.
320 * - others depends on the specific operations implementation.
322 int rte_ethtool_net_get_stats64(uint16_t port_id, struct rte_eth_stats *stats);
325 * Update the Ethernet device VLAN filter with new vid
328 * The port identifier of the Ethernet device.
332 * - (0) if successful.
333 * - (-ENOTSUP) if hardware doesn't support.
334 * - (-ENODEV) if *port_id* invalid.
335 * - others depends on the specific operations implementation.
337 int rte_ethtool_net_vlan_rx_add_vid(uint16_t port_id, uint16_t vid);
340 * Remove VLAN id from Ethernet device.
343 * The port identifier of the Ethernet device.
347 * - (0) if successful.
348 * - (-ENOTSUP) if hardware doesn't support.
349 * - (-ENODEV) if *port_id* invalid.
350 * - others depends on the specific operations implementation.
352 int rte_ethtool_net_vlan_rx_kill_vid(uint16_t port_id, uint16_t vid);
355 * Setting the Ethernet device rx mode.
358 * The port identifier of the Ethernet device.
360 * - (0) if successful.
361 * - (-ENOTSUP) if hardware doesn't support.
362 * - (-ENODEV) if *port_id* invalid.
363 * - others depends on the specific operations implementation.
365 int rte_ethtool_net_set_rx_mode(uint16_t port_id);
368 * Getting ring parameters for Ethernet device.
371 * The port identifier of the Ethernet device.
373 * Pointer to struct ethrool_ringparam to receive parameters.
375 * - (0) if successful.
376 * - (-ENOTSUP) if hardware doesn't support.
377 * - (-ENODEV) if *port_id* invalid.
378 * - others depends on the specific operations implementation.
380 * Only the tx_pending and rx_pending fields of struct ethtool_ringparam
381 * are used, and the function only gets parameters for queue 0.
383 int rte_ethtool_get_ringparam(uint16_t port_id,
384 struct ethtool_ringparam *ring_param);
387 * Setting ring parameters for Ethernet device.
390 * The port identifier of the Ethernet device.
392 * Pointer to struct ethrool_ringparam with parameters to set.
394 * - (0) if successful.
395 * - (-ENOTSUP) if hardware doesn't support.
396 * - (-ENODEV) if *port_id* invalid.
397 * - others depends on the specific operations implementation.
399 * Only the tx_pending and rx_pending fields of struct ethtool_ringparam
400 * are used, and the function only sets parameters for queue 0.
402 int rte_ethtool_set_ringparam(uint16_t port_id,
403 struct ethtool_ringparam *ring_param);
410 #endif /* _RTE_ETHTOOL_H_ */