ethtool.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. /*
  2. * ethtool.h: Defines for Linux ethtool.
  3. *
  4. * Copyright (C) 1998 David S. Miller (davem@redhat.com)
  5. * Copyright 2001 Jeff Garzik <jgarzik@pobox.com>
  6. * Portions Copyright 2001 Sun Microsystems (thockin@sun.com)
  7. * Portions Copyright 2002 Intel (eli.kupermann@intel.com,
  8. * christopher.leech@intel.com,
  9. * scott.feldman@intel.com)
  10. * Portions Copyright (C) Sun Microsystems 2008
  11. */
  12. #ifndef _LINUX_ETHTOOL_H
  13. #define _LINUX_ETHTOOL_H
  14. #include <linux/compat.h>
  15. #include <uapi/linux/ethtool.h>
  16. #ifdef CONFIG_COMPAT
  17. struct compat_ethtool_rx_flow_spec {
  18. u32 flow_type;
  19. union ethtool_flow_union h_u;
  20. struct ethtool_flow_ext h_ext;
  21. union ethtool_flow_union m_u;
  22. struct ethtool_flow_ext m_ext;
  23. compat_u64 ring_cookie;
  24. u32 location;
  25. };
  26. struct compat_ethtool_rxnfc {
  27. u32 cmd;
  28. u32 flow_type;
  29. compat_u64 data;
  30. struct compat_ethtool_rx_flow_spec fs;
  31. u32 rule_cnt;
  32. u32 rule_locs[0];
  33. };
  34. #endif /* CONFIG_COMPAT */
  35. #include <linux/rculist.h>
  36. extern int __ethtool_get_settings(struct net_device *dev,
  37. struct ethtool_cmd *cmd);
  38. /**
  39. * enum ethtool_phys_id_state - indicator state for physical identification
  40. * @ETHTOOL_ID_INACTIVE: Physical ID indicator should be deactivated
  41. * @ETHTOOL_ID_ACTIVE: Physical ID indicator should be activated
  42. * @ETHTOOL_ID_ON: LED should be turned on (used iff %ETHTOOL_ID_ACTIVE
  43. * is not supported)
  44. * @ETHTOOL_ID_OFF: LED should be turned off (used iff %ETHTOOL_ID_ACTIVE
  45. * is not supported)
  46. */
  47. enum ethtool_phys_id_state {
  48. ETHTOOL_ID_INACTIVE,
  49. ETHTOOL_ID_ACTIVE,
  50. ETHTOOL_ID_ON,
  51. ETHTOOL_ID_OFF
  52. };
  53. struct net_device;
  54. /* Some generic methods drivers may use in their ethtool_ops */
  55. u32 ethtool_op_get_link(struct net_device *dev);
  56. int ethtool_op_get_ts_info(struct net_device *dev, struct ethtool_ts_info *eti);
  57. /**
  58. * ethtool_rxfh_indir_default - get default value for RX flow hash indirection
  59. * @index: Index in RX flow hash indirection table
  60. * @n_rx_rings: Number of RX rings to use
  61. *
  62. * This function provides the default policy for RX flow hash indirection.
  63. */
  64. static inline u32 ethtool_rxfh_indir_default(u32 index, u32 n_rx_rings)
  65. {
  66. return index % n_rx_rings;
  67. }
  68. /**
  69. * struct ethtool_ops - optional netdev operations
  70. * @get_settings: Get various device settings including Ethernet link
  71. * settings. The @cmd parameter is expected to have been cleared
  72. * before get_settings is called. Returns a negative error code or
  73. * zero.
  74. * @set_settings: Set various device settings including Ethernet link
  75. * settings. Returns a negative error code or zero.
  76. * @get_drvinfo: Report driver/device information. Should only set the
  77. * @driver, @version, @fw_version and @bus_info fields. If not
  78. * implemented, the @driver and @bus_info fields will be filled in
  79. * according to the netdev's parent device.
  80. * @get_regs_len: Get buffer length required for @get_regs
  81. * @get_regs: Get device registers
  82. * @get_wol: Report whether Wake-on-Lan is enabled
  83. * @set_wol: Turn Wake-on-Lan on or off. Returns a negative error code
  84. * or zero.
  85. * @get_msglevel: Report driver message level. This should be the value
  86. * of the @msg_enable field used by netif logging functions.
  87. * @set_msglevel: Set driver message level
  88. * @nway_reset: Restart autonegotiation. Returns a negative error code
  89. * or zero.
  90. * @get_link: Report whether physical link is up. Will only be called if
  91. * the netdev is up. Should usually be set to ethtool_op_get_link(),
  92. * which uses netif_carrier_ok().
  93. * @get_eeprom: Read data from the device EEPROM.
  94. * Should fill in the magic field. Don't need to check len for zero
  95. * or wraparound. Fill in the data argument with the eeprom values
  96. * from offset to offset + len. Update len to the amount read.
  97. * Returns an error or zero.
  98. * @set_eeprom: Write data to the device EEPROM.
  99. * Should validate the magic field. Don't need to check len for zero
  100. * or wraparound. Update len to the amount written. Returns an error
  101. * or zero.
  102. * @get_coalesce: Get interrupt coalescing parameters. Returns a negative
  103. * error code or zero.
  104. * @set_coalesce: Set interrupt coalescing parameters. Returns a negative
  105. * error code or zero.
  106. * @get_ringparam: Report ring sizes
  107. * @set_ringparam: Set ring sizes. Returns a negative error code or zero.
  108. * @get_pauseparam: Report pause parameters
  109. * @set_pauseparam: Set pause parameters. Returns a negative error code
  110. * or zero.
  111. * @self_test: Run specified self-tests
  112. * @get_strings: Return a set of strings that describe the requested objects
  113. * @set_phys_id: Identify the physical devices, e.g. by flashing an LED
  114. * attached to it. The implementation may update the indicator
  115. * asynchronously or synchronously, but in either case it must return
  116. * quickly. It is initially called with the argument %ETHTOOL_ID_ACTIVE,
  117. * and must either activate asynchronous updates and return zero, return
  118. * a negative error or return a positive frequency for synchronous
  119. * indication (e.g. 1 for one on/off cycle per second). If it returns
  120. * a frequency then it will be called again at intervals with the
  121. * argument %ETHTOOL_ID_ON or %ETHTOOL_ID_OFF and should set the state of
  122. * the indicator accordingly. Finally, it is called with the argument
  123. * %ETHTOOL_ID_INACTIVE and must deactivate the indicator. Returns a
  124. * negative error code or zero.
  125. * @get_ethtool_stats: Return extended statistics about the device.
  126. * This is only useful if the device maintains statistics not
  127. * included in &struct rtnl_link_stats64.
  128. * @begin: Function to be called before any other operation. Returns a
  129. * negative error code or zero.
  130. * @complete: Function to be called after any other operation except
  131. * @begin. Will be called even if the other operation failed.
  132. * @get_priv_flags: Report driver-specific feature flags.
  133. * @set_priv_flags: Set driver-specific feature flags. Returns a negative
  134. * error code or zero.
  135. * @get_sset_count: Get number of strings that @get_strings will write.
  136. * @get_rxnfc: Get RX flow classification rules. Returns a negative
  137. * error code or zero.
  138. * @set_rxnfc: Set RX flow classification rules. Returns a negative
  139. * error code or zero.
  140. * @flash_device: Write a firmware image to device's flash memory.
  141. * Returns a negative error code or zero.
  142. * @reset: Reset (part of) the device, as specified by a bitmask of
  143. * flags from &enum ethtool_reset_flags. Returns a negative
  144. * error code or zero.
  145. * @get_rxfh_indir_size: Get the size of the RX flow hash indirection table.
  146. * Returns zero if not supported for this specific device.
  147. * @get_rxfh_indir: Get the contents of the RX flow hash indirection table.
  148. * Will not be called if @get_rxfh_indir_size returns zero.
  149. * Returns a negative error code or zero.
  150. * @set_rxfh_indir: Set the contents of the RX flow hash indirection table.
  151. * Will not be called if @get_rxfh_indir_size returns zero.
  152. * Returns a negative error code or zero.
  153. * @get_channels: Get number of channels.
  154. * @set_channels: Set number of channels. Returns a negative error code or
  155. * zero.
  156. * @get_dump_flag: Get dump flag indicating current dump length, version,
  157. * and flag of the device.
  158. * @get_dump_data: Get dump data.
  159. * @set_dump: Set dump specific flags to the device.
  160. * @get_ts_info: Get the time stamping and PTP hardware clock capabilities.
  161. * Drivers supporting transmit time stamps in software should set this to
  162. * ethtool_op_get_ts_info().
  163. * @get_module_info: Get the size and type of the eeprom contained within
  164. * a plug-in module.
  165. * @get_module_eeprom: Get the eeprom information from the plug-in module
  166. * @get_eee: Get Energy-Efficient (EEE) supported and status.
  167. * @set_eee: Set EEE status (enable/disable) as well as LPI timers.
  168. *
  169. * All operations are optional (i.e. the function pointer may be set
  170. * to %NULL) and callers must take this into account. Callers must
  171. * hold the RTNL lock.
  172. *
  173. * See the structures used by these operations for further documentation.
  174. *
  175. * See &struct net_device and &struct net_device_ops for documentation
  176. * of the generic netdev features interface.
  177. */
  178. struct ethtool_ops {
  179. int (*get_settings)(struct net_device *, struct ethtool_cmd *);
  180. int (*set_settings)(struct net_device *, struct ethtool_cmd *);
  181. void (*get_drvinfo)(struct net_device *, struct ethtool_drvinfo *);
  182. int (*get_regs_len)(struct net_device *);
  183. void (*get_regs)(struct net_device *, struct ethtool_regs *, void *);
  184. void (*get_wol)(struct net_device *, struct ethtool_wolinfo *);
  185. int (*set_wol)(struct net_device *, struct ethtool_wolinfo *);
  186. u32 (*get_msglevel)(struct net_device *);
  187. void (*set_msglevel)(struct net_device *, u32);
  188. int (*nway_reset)(struct net_device *);
  189. u32 (*get_link)(struct net_device *);
  190. int (*get_eeprom_len)(struct net_device *);
  191. int (*get_eeprom)(struct net_device *,
  192. struct ethtool_eeprom *, u8 *);
  193. int (*set_eeprom)(struct net_device *,
  194. struct ethtool_eeprom *, u8 *);
  195. int (*get_coalesce)(struct net_device *, struct ethtool_coalesce *);
  196. int (*set_coalesce)(struct net_device *, struct ethtool_coalesce *);
  197. void (*get_ringparam)(struct net_device *,
  198. struct ethtool_ringparam *);
  199. int (*set_ringparam)(struct net_device *,
  200. struct ethtool_ringparam *);
  201. void (*get_pauseparam)(struct net_device *,
  202. struct ethtool_pauseparam*);
  203. int (*set_pauseparam)(struct net_device *,
  204. struct ethtool_pauseparam*);
  205. void (*self_test)(struct net_device *, struct ethtool_test *, u64 *);
  206. void (*get_strings)(struct net_device *, u32 stringset, u8 *);
  207. int (*set_phys_id)(struct net_device *, enum ethtool_phys_id_state);
  208. void (*get_ethtool_stats)(struct net_device *,
  209. struct ethtool_stats *, u64 *);
  210. int (*begin)(struct net_device *);
  211. void (*complete)(struct net_device *);
  212. u32 (*get_priv_flags)(struct net_device *);
  213. int (*set_priv_flags)(struct net_device *, u32);
  214. int (*get_sset_count)(struct net_device *, int);
  215. int (*get_rxnfc)(struct net_device *,
  216. struct ethtool_rxnfc *, u32 *rule_locs);
  217. int (*set_rxnfc)(struct net_device *, struct ethtool_rxnfc *);
  218. int (*flash_device)(struct net_device *, struct ethtool_flash *);
  219. int (*reset)(struct net_device *, u32 *);
  220. u32 (*get_rxfh_indir_size)(struct net_device *);
  221. int (*get_rxfh_indir)(struct net_device *, u32 *);
  222. int (*set_rxfh_indir)(struct net_device *, const u32 *);
  223. void (*get_channels)(struct net_device *, struct ethtool_channels *);
  224. int (*set_channels)(struct net_device *, struct ethtool_channels *);
  225. int (*get_dump_flag)(struct net_device *, struct ethtool_dump *);
  226. int (*get_dump_data)(struct net_device *,
  227. struct ethtool_dump *, void *);
  228. int (*set_dump)(struct net_device *, struct ethtool_dump *);
  229. int (*get_ts_info)(struct net_device *, struct ethtool_ts_info *);
  230. int (*get_module_info)(struct net_device *,
  231. struct ethtool_modinfo *);
  232. int (*get_module_eeprom)(struct net_device *,
  233. struct ethtool_eeprom *, u8 *);
  234. int (*get_eee)(struct net_device *, struct ethtool_eee *);
  235. int (*set_eee)(struct net_device *, struct ethtool_eee *);
  236. };
  237. #endif /* _LINUX_ETHTOOL_H */