1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2015 Intel Corporation
5 #ifndef _RTE_ETHTOOL_H_
6 #define _RTE_ETHTOOL_H_
9 * This new interface is designed to provide a user-space shim layer for
10 * Ethtool and Netdevice op API.
12 * rte_ethtool_get_driver: ethtool_ops::get_drvinfo
13 * rte_ethtool_get_link: ethtool_ops::get_link
14 * rte_ethtool_get_regs_len: ethtool_ops::get_regs_len
15 * rte_ethtool_get_regs: ethtool_ops::get_regs
16 * rte_ethtool_get_eeprom_len: ethtool_ops::get_eeprom_len
17 * rte_ethtool_get_eeprom: ethtool_ops::get_eeprom
18 * rte_ethtool_set_eeprom: ethtool_ops::set_eeprom
19 * rte_ethtool_get_pauseparam: ethtool_ops::get_pauseparam
20 * rte_ethtool_set_pauseparam: ethtool_ops::set_pauseparam
22 * rte_ethtool_net_open: net_device_ops::ndo_open
23 * rte_ethtool_net_stop: net_device_ops::ndo_stop
24 * rte_ethtool_net_set_mac_addr: net_device_ops::ndo_set_mac_address
25 * rte_ethtool_net_validate_addr: net_device_ops::ndo_validate_addr
26 * rte_ethtool_net_change_mtu: net_device_ops::ndo_change_mtu
27 * rte_ethtool_net_get_stats64: net_device_ops::ndo_get_stats64
28 * rte_ethtool_net_vlan_rx_add_vid net_device_ops::ndo_vlan_rx_add_vid
29 * rte_ethtool_net_vlan_rx_kill_vid net_device_ops::ndo_vlan_rx_kill_vid
30 * rte_ethtool_net_set_rx_mode net_device_ops::ndo_set_rx_mode
38 #include <rte_ethdev.h>
39 #include <linux/ethtool.h>
42 * Retrieve the Ethernet device driver information according to
43 * attributes described by ethtool data structure, ethtool_drvinfo.
46 * The port identifier of the Ethernet device.
48 * A pointer to get driver information
50 * - (0) if successful.
51 * - (-ENODEV) if *port_id* invalid.
53 int rte_ethtool_get_drvinfo(uint16_t port_id, struct ethtool_drvinfo *drvinfo);
56 * Retrieve the Ethernet device register length in bytes.
59 * The port identifier of the Ethernet device.
61 * - (> 0) # of device registers (in bytes) available for dump
62 * - (0) no registers available for dump.
63 * - (-ENOTSUP) if hardware doesn't support.
64 * - (-ENODEV) if *port_id* invalid.
65 * - others depends on the specific operations implementation.
67 int rte_ethtool_get_regs_len(uint16_t port_id);
70 * Retrieve the Ethernet device register information according to
71 * attributes described by ethtool data structure, ethtool_regs
74 * The port identifier of the Ethernet device.
76 * A pointer to ethtool_regs that has register information
78 * A pointer to a buffer that is used to retrieve device register content
80 * - (0) if successful.
81 * - (-ENOTSUP) if hardware doesn't support.
82 * - (-ENODEV) if *port_id* invalid.
83 * - others depends on the specific operations implementation.
85 int rte_ethtool_get_regs(uint16_t port_id, struct ethtool_regs *regs,
89 * Retrieve the Ethernet device link status
92 * The port identifier of the Ethernet device.
96 * - (-ENOTSUP) if hardware doesn't support.
97 * - (-ENODEV) if *port_id* invalid.
98 * - (-EINVAL) if parameters invalid.
99 * - others depends on the specific operations implementation.
101 int rte_ethtool_get_link(uint16_t port_id);
104 * Retrieve the Ethernet device EEPROM size
107 * The port identifier of the Ethernet device.
109 * - (> 0) device EEPROM size in bytes
110 * - (0) device has NO EEPROM
111 * - (-ENOTSUP) if hardware doesn't support.
112 * - (-ENODEV) if *port_id* invalid.
113 * - others depends on the specific operations implementation.
115 int rte_ethtool_get_eeprom_len(uint16_t port_id);
118 * Retrieve EEPROM content based upon eeprom range described in ethtool
119 * data structure, ethtool_eeprom
122 * The port identifier of the Ethernet device.
124 * The pointer of ethtool_eeprom that provides eeprom range
126 * A buffer that holds data read from eeprom
128 * - (0) if successful.
129 * - (-ENOTSUP) if hardware doesn't support.
130 * - (-ENODEV) if *port_id* invalid.
131 * - others depends on the specific operations implementation.
133 int rte_ethtool_get_eeprom(uint16_t port_id, struct ethtool_eeprom *eeprom,
137 * Setting EEPROM content based upon eeprom range described in ethtool
138 * data structure, ethtool_eeprom
141 * The port identifier of the Ethernet device.
143 * The pointer of ethtool_eeprom that provides eeprom range
145 * A buffer that holds data to be written into eeprom
147 * - (0) if successful.
148 * - (-ENOTSUP) if hardware doesn't support.
149 * - (-ENODEV) if *port_id* invalid.
150 * - (-EINVAL) if parameters invalid.
151 * - others depends on the specific operations implementation.
153 int rte_ethtool_set_eeprom(uint16_t port_id, struct ethtool_eeprom *eeprom,
157 * Retrieve the type and size of plugin module EEPROM
160 * The port identifier of the Ethernet device.
162 * The pointer that provides the type and size of plugin module EEPROM.
164 * - (0) if successful.
165 * - (-ENOTSUP) if hardware doesn't support.
166 * - (-ENODEV) if *port_id* invalid.
167 * - others depends on the specific operations implementation.
169 int rte_ethtool_get_module_info(uint16_t port_id, uint32_t *modinfo);
172 * Retrieve the data of plugin module EEPROM
175 * The port identifier of the Ethernet device.
177 * The pointer of ethtool_eeprom that provides plugin module eeprom
180 * A buffer that holds data read from plugin module eeprom
182 * - (0) if successful.
183 * - (-ENOTSUP) if hardware doesn't support.
184 * - (-ENODEV) if *port_id* invalid.
185 * - others depends on the specific operations implementation.
187 int rte_ethtool_get_module_eeprom(uint16_t port_id,
188 struct ethtool_eeprom *eeprom, void *words);
191 * Retrieve the Ethernet device pause frame configuration according to
192 * parameter attributes desribed by ethtool data structure,
193 * ethtool_pauseparam.
196 * The port identifier of the Ethernet device.
198 * The pointer of ethtool_coalesce that gets pause frame
199 * configuration parameters
201 * - (0) if successful.
202 * - (-ENOTSUP) if hardware doesn't support.
203 * - (-ENODEV) if *port_id* invalid.
204 * - (-EINVAL) if parameters invalid.
205 * - others depends on the specific operations implementation.
207 int rte_ethtool_get_pauseparam(uint16_t port_id,
208 struct ethtool_pauseparam *pause_param);
211 * Setting the Ethernet device pause frame configuration according to
212 * parameter attributes desribed by ethtool data structure, ethtool_pauseparam.
215 * The port identifier of the Ethernet device.
217 * The pointer of ethtool_coalesce that gets ring configuration parameters
219 * - (0) if successful.
220 * - (-ENOTSUP) if hardware doesn't support.
221 * - (-ENODEV) if *port_id* invalid.
222 * - (-EINVAL) if parameters invalid.
223 * - others depends on the specific operations implementation.
225 int rte_ethtool_set_pauseparam(uint16_t port_id,
226 struct ethtool_pauseparam *param);
229 * Start the Ethernet device.
232 * The port identifier of the Ethernet device.
234 * - (0) if successful.
235 * - (-ENOTSUP) if hardware doesn't support.
236 * - (-ENODEV) if *port_id* invalid.
237 * - others depends on the specific operations implementation.
239 int rte_ethtool_net_open(uint16_t port_id);
242 * Stop the Ethernet device.
245 * The port identifier of the Ethernet device.
247 * - (0) if successful.
248 * - (-ENODEV) if *port_id* invalid.
250 int rte_ethtool_net_stop(uint16_t port_id);
253 * Get the Ethernet device MAC address.
256 * The port identifier of the Ethernet device.
258 * MAC address of the Ethernet device.
260 * - (0) if successful.
261 * - (-ENODEV) if *port_id* invalid.
263 int rte_ethtool_net_get_mac_addr(uint16_t port_id, struct rte_ether_addr *addr);
266 * Setting the Ethernet device MAC address.
269 * The port identifier of the Ethernet device.
273 * - (0) if successful.
274 * - (-ENOTSUP) if hardware doesn't support.
275 * - (-ENODEV) if *port_id* invalid.
276 * - (-EINVAL) if parameters invalid.
277 * - others depends on the specific operations implementation.
279 int rte_ethtool_net_set_mac_addr(uint16_t port_id, struct rte_ether_addr *addr);
282 * Validate if the provided MAC address is valid unicast address
285 * The port identifier of the Ethernet device.
287 * A pointer to a buffer (6-byte, 48bit) for the target MAC address
289 * - (0) if successful.
290 * - (-ENOTSUP) if hardware doesn't support.
291 * - (-ENODEV) if *port_id* invalid.
292 * - (-EINVAL) if parameters invalid.
293 * - others depends on the specific operations implementation.
295 int rte_ethtool_net_validate_addr(uint16_t port_id,
296 struct rte_ether_addr *addr);
299 * Setting the Ethernet device maximum Tx unit.
302 * The port identifier of the Ethernet device.
306 * - (0) if successful.
307 * - (-ENOTSUP) if hardware doesn't support.
308 * - (-ENODEV) if *port_id* invalid.
309 * - (-EINVAL) if parameters invalid.
310 * - others depends on the specific operations implementation.
312 int rte_ethtool_net_change_mtu(uint16_t port_id, int mtu);
315 * Retrieve the Ethernet device traffic statistics
318 * The port identifier of the Ethernet device.
320 * A pointer to struct rte_eth_stats for statistics parameters
322 * - (0) if successful.
323 * - (-ENOTSUP) if hardware doesn't support.
324 * - (-ENODEV) if *port_id* invalid.
325 * - (-EINVAL) if parameters invalid.
326 * - others depends on the specific operations implementation.
328 int rte_ethtool_net_get_stats64(uint16_t port_id, struct rte_eth_stats *stats);
331 * Update the Ethernet device VLAN filter with new vid
334 * The port identifier of the Ethernet device.
338 * - (0) if successful.
339 * - (-ENOTSUP) if hardware doesn't support.
340 * - (-ENODEV) if *port_id* invalid.
341 * - others depends on the specific operations implementation.
343 int rte_ethtool_net_vlan_rx_add_vid(uint16_t port_id, uint16_t vid);
346 * Remove VLAN id from Ethernet device.
349 * The port identifier of the Ethernet device.
353 * - (0) if successful.
354 * - (-ENOTSUP) if hardware doesn't support.
355 * - (-ENODEV) if *port_id* invalid.
356 * - others depends on the specific operations implementation.
358 int rte_ethtool_net_vlan_rx_kill_vid(uint16_t port_id, uint16_t vid);
361 * Setting the Ethernet device rx mode.
364 * The port identifier of the Ethernet device.
366 * - (0) if successful.
367 * - (-ENOTSUP) if hardware doesn't support.
368 * - (-ENODEV) if *port_id* invalid.
369 * - others depends on the specific operations implementation.
371 int rte_ethtool_net_set_rx_mode(uint16_t port_id);
374 * Getting ring parameters for Ethernet device.
377 * The port identifier of the Ethernet device.
379 * Pointer to struct ethrool_ringparam to receive parameters.
381 * - (0) if successful.
382 * - (-ENOTSUP) if hardware doesn't support.
383 * - (-ENODEV) if *port_id* invalid.
384 * - others depends on the specific operations implementation.
386 * Only the tx_pending and rx_pending fields of struct ethtool_ringparam
387 * are used, and the function only gets parameters for queue 0.
389 int rte_ethtool_get_ringparam(uint16_t port_id,
390 struct ethtool_ringparam *ring_param);
393 * Setting ring parameters for Ethernet device.
396 * The port identifier of the Ethernet device.
398 * Pointer to struct ethrool_ringparam with parameters to set.
400 * - (0) if successful.
401 * - (-ENOTSUP) if hardware doesn't support.
402 * - (-ENODEV) if *port_id* invalid.
403 * - others depends on the specific operations implementation.
405 * Only the tx_pending and rx_pending fields of struct ethtool_ringparam
406 * are used, and the function only sets parameters for queue 0.
408 int rte_ethtool_set_ringparam(uint16_t port_id,
409 struct ethtool_ringparam *ring_param);
416 #endif /* _RTE_ETHTOOL_H_ */