1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2010-2015 Intel Corporation 3 */ 4 5 #ifndef _RTE_ETHTOOL_H_ 6 #define _RTE_ETHTOOL_H_ 7 8 /* 9 * This new interface is designed to provide a user-space shim layer for 10 * Ethtool and Netdevice op API. 11 * 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 21 * 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 31 * 32 */ 33 #include <stdint.h> 34 #include <rte_ethdev.h> 35 #include <linux/ethtool.h> 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 /** 42 * Retrieve the Ethernet device driver information according to 43 * attributes described by ethtool data structure, ethtool_drvinfo. 44 * 45 * @param port_id 46 * The port identifier of the Ethernet device. 47 * @param drvinfo 48 * A pointer to get driver information 49 * @return 50 * - (0) if successful. 51 * - (-ENODEV) if *port_id* invalid. 52 */ 53 int rte_ethtool_get_drvinfo(uint16_t port_id, struct ethtool_drvinfo *drvinfo); 54 55 /** 56 * Retrieve the Ethernet device register length in bytes. 57 * 58 * @param port_id 59 * The port identifier of the Ethernet device. 60 * @return 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. 66 */ 67 int rte_ethtool_get_regs_len(uint16_t port_id); 68 69 /** 70 * Retrieve the Ethernet device register information according to 71 * attributes described by ethtool data structure, ethtool_regs 72 * 73 * @param port_id 74 * The port identifier of the Ethernet device. 75 * @param reg 76 * A pointer to ethtool_regs that has register information 77 * @param data 78 * A pointer to a buffer that is used to retrieve device register content 79 * @return 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. 84 */ 85 int rte_ethtool_get_regs(uint16_t port_id, struct ethtool_regs *regs, 86 void *data); 87 88 /** 89 * Retrieve the Ethernet device link status 90 * 91 * @param port_id 92 * The port identifier of the Ethernet device. 93 * @return 94 * - (1) if link up. 95 * - (0) if link down. 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. 100 */ 101 int rte_ethtool_get_link(uint16_t port_id); 102 103 /** 104 * Retrieve the Ethernet device EEPROM size 105 * 106 * @param port_id 107 * The port identifier of the Ethernet device. 108 * @return 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. 114 */ 115 int rte_ethtool_get_eeprom_len(uint16_t port_id); 116 117 /** 118 * Retrieve EEPROM content based upon eeprom range described in ethtool 119 * data structure, ethtool_eeprom 120 * 121 * @param port_id 122 * The port identifier of the Ethernet device. 123 * @param eeprom 124 * The pointer of ethtool_eeprom that provides eeprom range 125 * @param words 126 * A buffer that holds data read from eeprom 127 * @return 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. 132 */ 133 int rte_ethtool_get_eeprom(uint16_t port_id, struct ethtool_eeprom *eeprom, 134 void *words); 135 136 /** 137 * Setting EEPROM content based upon eeprom range described in ethtool 138 * data structure, ethtool_eeprom 139 * 140 * @param port_id 141 * The port identifier of the Ethernet device. 142 * @param eeprom 143 * The pointer of ethtool_eeprom that provides eeprom range 144 * @param words 145 * A buffer that holds data to be written into eeprom 146 * @return 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. 152 */ 153 int rte_ethtool_set_eeprom(uint16_t port_id, struct ethtool_eeprom *eeprom, 154 void *words); 155 156 /** 157 * Retrieve the type and size of plugin module EEPROM 158 * 159 * @param port_id 160 * The port identifier of the Ethernet device. 161 * @param modinfo 162 * The pointer that provides the type and size of plugin module EEPROM. 163 * @return 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. 168 */ 169 int rte_ethtool_get_module_info(uint16_t port_id, uint32_t *modinfo); 170 171 /** 172 * Retrieve the data of plugin module EEPROM 173 * 174 * @param port_id 175 * The port identifier of the Ethernet device. 176 * @param eeprom 177 * The pointer of ethtool_eeprom that provides plugin module eeprom 178 * offset and length 179 * @param words 180 * A buffer that holds data read from plugin module eeprom 181 * @return 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. 186 */ 187 int rte_ethtool_get_module_eeprom(uint16_t port_id, 188 struct ethtool_eeprom *eeprom, void *words); 189 190 /** 191 * Retrieve the Ethernet device pause frame configuration according to 192 * parameter attributes described by ethtool data structure, 193 * ethtool_pauseparam. 194 * 195 * @param port_id 196 * The port identifier of the Ethernet device. 197 * @param pause_param 198 * The pointer of ethtool_coalesce that gets pause frame 199 * configuration parameters 200 * @return 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. 206 */ 207 int rte_ethtool_get_pauseparam(uint16_t port_id, 208 struct ethtool_pauseparam *pause_param); 209 210 /** 211 * Setting the Ethernet device pause frame configuration according to 212 * parameter attributes described by ethtool data structure, ethtool_pauseparam. 213 * 214 * @param port_id 215 * The port identifier of the Ethernet device. 216 * @param pause_param 217 * The pointer of ethtool_coalesce that gets ring configuration parameters 218 * @return 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. 224 */ 225 int rte_ethtool_set_pauseparam(uint16_t port_id, 226 struct ethtool_pauseparam *param); 227 228 /** 229 * Start the Ethernet device. 230 * 231 * @param port_id 232 * The port identifier of the Ethernet device. 233 * @return 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. 238 */ 239 int rte_ethtool_net_open(uint16_t port_id); 240 241 /** 242 * Stop the Ethernet device. 243 * 244 * @param port_id 245 * The port identifier of the Ethernet device. 246 * @return 247 * - (0) if successful. 248 * - (-ENODEV) if *port_id* invalid. 249 */ 250 int rte_ethtool_net_stop(uint16_t port_id); 251 252 /** 253 * Get the Ethernet device MAC address. 254 * 255 * @param port_id 256 * The port identifier of the Ethernet device. 257 * @param addr 258 * MAC address of the Ethernet device. 259 * @return 260 * - (0) if successful. 261 * - (-ENODEV) if *port_id* invalid. 262 */ 263 int rte_ethtool_net_get_mac_addr(uint16_t port_id, struct rte_ether_addr *addr); 264 265 /** 266 * Setting the Ethernet device MAC address. 267 * 268 * @param port_id 269 * The port identifier of the Ethernet device. 270 * @param addr 271 * The new MAC addr. 272 * @return 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. 278 */ 279 int rte_ethtool_net_set_mac_addr(uint16_t port_id, struct rte_ether_addr *addr); 280 281 /** 282 * Validate if the provided MAC address is valid unicast address 283 * 284 * @param port_id 285 * The port identifier of the Ethernet device. 286 * @param addr 287 * A pointer to a buffer (6-byte, 48bit) for the target MAC address 288 * @return 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. 294 */ 295 int rte_ethtool_net_validate_addr(uint16_t port_id, 296 struct rte_ether_addr *addr); 297 298 /** 299 * Setting the Ethernet device maximum Tx unit. 300 * 301 * @param port_id 302 * The port identifier of the Ethernet device. 303 * @param mtu 304 * New MTU 305 * @return 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. 311 */ 312 int rte_ethtool_net_change_mtu(uint16_t port_id, int mtu); 313 314 /** 315 * Retrieve the Ethernet device traffic statistics 316 * 317 * @param port_id 318 * The port identifier of the Ethernet device. 319 * @param stats 320 * A pointer to struct rte_eth_stats for statistics parameters 321 * @return 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. 327 */ 328 int rte_ethtool_net_get_stats64(uint16_t port_id, struct rte_eth_stats *stats); 329 330 /** 331 * Update the Ethernet device VLAN filter with new vid 332 * 333 * @param port_id 334 * The port identifier of the Ethernet device. 335 * @param vid 336 * A new VLAN id 337 * @return 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. 342 */ 343 int rte_ethtool_net_vlan_rx_add_vid(uint16_t port_id, uint16_t vid); 344 345 /** 346 * Remove VLAN id from Ethernet device. 347 * 348 * @param port_id 349 * The port identifier of the Ethernet device. 350 * @param vid 351 * A new VLAN id 352 * @return 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. 357 */ 358 int rte_ethtool_net_vlan_rx_kill_vid(uint16_t port_id, uint16_t vid); 359 360 /** 361 * Setting the Ethernet device rx mode. 362 * 363 * @param port_id 364 * The port identifier of the Ethernet device. 365 * @return 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. 370 */ 371 int rte_ethtool_net_set_rx_mode(uint16_t port_id); 372 373 /** 374 * Getting ring parameters for Ethernet device. 375 * 376 * @param port_id 377 * The port identifier of the Ethernet device. 378 * @param ring_param 379 * Pointer to struct ethrool_ringparam to receive parameters. 380 * @return 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. 385 * @note 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. 388 */ 389 int rte_ethtool_get_ringparam(uint16_t port_id, 390 struct ethtool_ringparam *ring_param); 391 392 /** 393 * Setting ring parameters for Ethernet device. 394 * 395 * @param port_id 396 * The port identifier of the Ethernet device. 397 * @param ring_param 398 * Pointer to struct ethrool_ringparam with parameters to set. 399 * @return 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. 404 * @note 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. 407 */ 408 int rte_ethtool_set_ringparam(uint16_t port_id, 409 struct ethtool_ringparam *ring_param); 410 411 412 #ifdef __cplusplus 413 } 414 #endif 415 416 #endif /* _RTE_ETHTOOL_H_ */ 417