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_driverinfo
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::rte_net_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 Ethernet device pause frame configuration according to
158 * parameter attributes desribed by ethtool data structure,
159 * ethtool_pauseparam.
162 * The port identifier of the Ethernet device.
164 * The pointer of ethtool_coalesce that gets pause frame
165 * configuration parameters
167 * - (0) if successful.
168 * - (-ENOTSUP) if hardware doesn't support.
169 * - (-ENODEV) if *port_id* invalid.
170 * - (-EINVAL) if parameters invalid.
171 * - others depends on the specific operations implementation.
173 int rte_ethtool_get_pauseparam(uint16_t port_id,
174 struct ethtool_pauseparam *pause_param);
177 * Setting the Ethernet device pause frame configuration according to
178 * parameter attributes desribed by ethtool data structure, ethtool_pauseparam.
181 * The port identifier of the Ethernet device.
183 * The pointer of ethtool_coalesce that gets ring configuration parameters
185 * - (0) if successful.
186 * - (-ENOTSUP) if hardware doesn't support.
187 * - (-ENODEV) if *port_id* invalid.
188 * - (-EINVAL) if parameters invalid.
189 * - others depends on the specific operations implementation.
191 int rte_ethtool_set_pauseparam(uint16_t port_id,
192 struct ethtool_pauseparam *param);
195 * Start the Ethernet device.
198 * The port identifier of the Ethernet device.
200 * - (0) if successful.
201 * - (-ENOTSUP) if hardware doesn't support.
202 * - (-ENODEV) if *port_id* invalid.
203 * - others depends on the specific operations implementation.
205 int rte_ethtool_net_open(uint16_t port_id);
208 * Stop the Ethernet device.
211 * The port identifier of the Ethernet device.
213 * - (0) if successful.
214 * - (-ENODEV) if *port_id* invalid.
216 int rte_ethtool_net_stop(uint16_t port_id);
219 * Get the Ethernet device MAC address.
222 * The port identifier of the Ethernet device.
224 * MAC address of the Ethernet device.
226 * - (0) if successful.
227 * - (-ENODEV) if *port_id* invalid.
229 int rte_ethtool_net_get_mac_addr(uint16_t port_id, struct ether_addr *addr);
232 * Setting the Ethernet device MAC address.
235 * The port identifier of the Ethernet device.
239 * - (0) if successful.
240 * - (-ENOTSUP) if hardware doesn't support.
241 * - (-ENODEV) if *port_id* invalid.
242 * - (-EINVAL) if parameters invalid.
243 * - others depends on the specific operations implementation.
245 int rte_ethtool_net_set_mac_addr(uint16_t port_id, struct ether_addr *addr);
248 * Validate if the provided MAC address is valid unicast address
251 * The port identifier of the Ethernet device.
253 * A pointer to a buffer (6-byte, 48bit) for the target MAC address
255 * - (0) if successful.
256 * - (-ENOTSUP) if hardware doesn't support.
257 * - (-ENODEV) if *port_id* invalid.
258 * - (-EINVAL) if parameters invalid.
259 * - others depends on the specific operations implementation.
261 int rte_ethtool_net_validate_addr(uint16_t port_id, struct ether_addr *addr);
264 * Setting the Ethernet device maximum Tx unit.
267 * The port identifier of the Ethernet device.
271 * - (0) if successful.
272 * - (-ENOTSUP) if hardware doesn't support.
273 * - (-ENODEV) if *port_id* invalid.
274 * - (-EINVAL) if parameters invalid.
275 * - others depends on the specific operations implementation.
277 int rte_ethtool_net_change_mtu(uint16_t port_id, int mtu);
280 * Retrieve the Ethernet device traffic statistics
283 * The port identifier of the Ethernet device.
285 * A pointer to struct rte_eth_stats for statistics parameters
287 * - (0) if successful.
288 * - (-ENOTSUP) if hardware doesn't support.
289 * - (-ENODEV) if *port_id* invalid.
290 * - (-EINVAL) if parameters invalid.
291 * - others depends on the specific operations implementation.
293 int rte_ethtool_net_get_stats64(uint16_t port_id, struct rte_eth_stats *stats);
296 * Update the Ethernet device VLAN filter with new vid
299 * The port identifier of the Ethernet device.
303 * - (0) if successful.
304 * - (-ENOTSUP) if hardware doesn't support.
305 * - (-ENODEV) if *port_id* invalid.
306 * - others depends on the specific operations implementation.
308 int rte_ethtool_net_vlan_rx_add_vid(uint16_t port_id, uint16_t vid);
311 * Remove VLAN id from Ethernet device.
314 * The port identifier of the Ethernet device.
318 * - (0) if successful.
319 * - (-ENOTSUP) if hardware doesn't support.
320 * - (-ENODEV) if *port_id* invalid.
321 * - others depends on the specific operations implementation.
323 int rte_ethtool_net_vlan_rx_kill_vid(uint16_t port_id, uint16_t vid);
326 * Setting the Ethernet device rx mode.
329 * The port identifier of the Ethernet device.
331 * - (0) if successful.
332 * - (-ENOTSUP) if hardware doesn't support.
333 * - (-ENODEV) if *port_id* invalid.
334 * - others depends on the specific operations implementation.
336 int rte_ethtool_net_set_rx_mode(uint16_t port_id);
339 * Getting ring parameters for Ethernet device.
342 * The port identifier of the Ethernet device.
344 * Pointer to struct ethrool_ringparam to receive parameters.
346 * - (0) if successful.
347 * - (-ENOTSUP) if hardware doesn't support.
348 * - (-ENODEV) if *port_id* invalid.
349 * - others depends on the specific operations implementation.
351 * Only the tx_pending and rx_pending fields of struct ethtool_ringparam
352 * are used, and the function only gets parameters for queue 0.
354 int rte_ethtool_get_ringparam(uint16_t port_id,
355 struct ethtool_ringparam *ring_param);
358 * Setting ring parameters for Ethernet device.
361 * The port identifier of the Ethernet device.
363 * Pointer to struct ethrool_ringparam with parameters to set.
365 * - (0) if successful.
366 * - (-ENOTSUP) if hardware doesn't support.
367 * - (-ENODEV) if *port_id* invalid.
368 * - others depends on the specific operations implementation.
370 * Only the tx_pending and rx_pending fields of struct ethtool_ringparam
371 * are used, and the function only sets parameters for queue 0.
373 int rte_ethtool_set_ringparam(uint16_t port_id,
374 struct ethtool_ringparam *ring_param);
381 #endif /* _RTE_ETHTOOL_H_ */