ethtool.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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. enum {
  54. ETH_RSS_HASH_TOP_BIT, /* Configurable RSS hash function - Toeplitz */
  55. ETH_RSS_HASH_XOR_BIT, /* Configurable RSS hash function - Xor */
  56. /*
  57. * Add your fresh new hash function bits above and remember to update
  58. * rss_hash_func_strings[] in ethtool.c
  59. */
  60. ETH_RSS_HASH_FUNCS_COUNT
  61. };
  62. #define __ETH_RSS_HASH_BIT(bit) ((u32)1 << (bit))
  63. #define __ETH_RSS_HASH(name) __ETH_RSS_HASH_BIT(ETH_RSS_HASH_##name##_BIT)
  64. #define ETH_RSS_HASH_TOP __ETH_RSS_HASH(TOP)
  65. #define ETH_RSS_HASH_XOR __ETH_RSS_HASH(XOR)
  66. #define ETH_RSS_HASH_UNKNOWN 0
  67. #define ETH_RSS_HASH_NO_CHANGE 0
  68. struct net_device;
  69. /* Some generic methods drivers may use in their ethtool_ops */
  70. u32 ethtool_op_get_link(struct net_device *dev);
  71. int ethtool_op_get_ts_info(struct net_device *dev, struct ethtool_ts_info *eti);
  72. /**
  73. * ethtool_rxfh_indir_default - get default value for RX flow hash indirection
  74. * @index: Index in RX flow hash indirection table
  75. * @n_rx_rings: Number of RX rings to use
  76. *
  77. * This function provides the default policy for RX flow hash indirection.
  78. */
  79. static inline u32 ethtool_rxfh_indir_default(u32 index, u32 n_rx_rings)
  80. {
  81. return index % n_rx_rings;
  82. }
  83. /**
  84. * struct ethtool_ops - optional netdev operations
  85. * @get_settings: Get various device settings including Ethernet link
  86. * settings. The @cmd parameter is expected to have been cleared
  87. * before get_settings is called. Returns a negative error code or
  88. * zero.
  89. * @set_settings: Set various device settings including Ethernet link
  90. * settings. Returns a negative error code or zero.
  91. * @get_drvinfo: Report driver/device information. Should only set the
  92. * @driver, @version, @fw_version and @bus_info fields. If not
  93. * implemented, the @driver and @bus_info fields will be filled in
  94. * according to the netdev's parent device.
  95. * @get_regs_len: Get buffer length required for @get_regs
  96. * @get_regs: Get device registers
  97. * @get_wol: Report whether Wake-on-Lan is enabled
  98. * @set_wol: Turn Wake-on-Lan on or off. Returns a negative error code
  99. * or zero.
  100. * @get_msglevel: Report driver message level. This should be the value
  101. * of the @msg_enable field used by netif logging functions.
  102. * @set_msglevel: Set driver message level
  103. * @nway_reset: Restart autonegotiation. Returns a negative error code
  104. * or zero.
  105. * @get_link: Report whether physical link is up. Will only be called if
  106. * the netdev is up. Should usually be set to ethtool_op_get_link(),
  107. * which uses netif_carrier_ok().
  108. * @get_eeprom: Read data from the device EEPROM.
  109. * Should fill in the magic field. Don't need to check len for zero
  110. * or wraparound. Fill in the data argument with the eeprom values
  111. * from offset to offset + len. Update len to the amount read.
  112. * Returns an error or zero.
  113. * @set_eeprom: Write data to the device EEPROM.
  114. * Should validate the magic field. Don't need to check len for zero
  115. * or wraparound. Update len to the amount written. Returns an error
  116. * or zero.
  117. * @get_coalesce: Get interrupt coalescing parameters. Returns a negative
  118. * error code or zero.
  119. * @set_coalesce: Set interrupt coalescing parameters. Returns a negative
  120. * error code or zero.
  121. * @get_ringparam: Report ring sizes
  122. * @set_ringparam: Set ring sizes. Returns a negative error code or zero.
  123. * @get_pauseparam: Report pause parameters
  124. * @set_pauseparam: Set pause parameters. Returns a negative error code
  125. * or zero.
  126. * @self_test: Run specified self-tests
  127. * @get_strings: Return a set of strings that describe the requested objects
  128. * @set_phys_id: Identify the physical devices, e.g. by flashing an LED
  129. * attached to it. The implementation may update the indicator
  130. * asynchronously or synchronously, but in either case it must return
  131. * quickly. It is initially called with the argument %ETHTOOL_ID_ACTIVE,
  132. * and must either activate asynchronous updates and return zero, return
  133. * a negative error or return a positive frequency for synchronous
  134. * indication (e.g. 1 for one on/off cycle per second). If it returns
  135. * a frequency then it will be called again at intervals with the
  136. * argument %ETHTOOL_ID_ON or %ETHTOOL_ID_OFF and should set the state of
  137. * the indicator accordingly. Finally, it is called with the argument
  138. * %ETHTOOL_ID_INACTIVE and must deactivate the indicator. Returns a
  139. * negative error code or zero.
  140. * @get_ethtool_stats: Return extended statistics about the device.
  141. * This is only useful if the device maintains statistics not
  142. * included in &struct rtnl_link_stats64.
  143. * @begin: Function to be called before any other operation. Returns a
  144. * negative error code or zero.
  145. * @complete: Function to be called after any other operation except
  146. * @begin. Will be called even if the other operation failed.
  147. * @get_priv_flags: Report driver-specific feature flags.
  148. * @set_priv_flags: Set driver-specific feature flags. Returns a negative
  149. * error code or zero.
  150. * @get_sset_count: Get number of strings that @get_strings will write.
  151. * @get_rxnfc: Get RX flow classification rules. Returns a negative
  152. * error code or zero.
  153. * @set_rxnfc: Set RX flow classification rules. Returns a negative
  154. * error code or zero.
  155. * @flash_device: Write a firmware image to device's flash memory.
  156. * Returns a negative error code or zero.
  157. * @reset: Reset (part of) the device, as specified by a bitmask of
  158. * flags from &enum ethtool_reset_flags. Returns a negative
  159. * error code or zero.
  160. * @get_rxfh_key_size: Get the size of the RX flow hash key.
  161. * Returns zero if not supported for this specific device.
  162. * @get_rxfh_indir_size: Get the size of the RX flow hash indirection table.
  163. * Returns zero if not supported for this specific device.
  164. * @get_rxfh: Get the contents of the RX flow hash indirection table, hash key
  165. * and/or hash function.
  166. * Returns a negative error code or zero.
  167. * @set_rxfh: Set the contents of the RX flow hash indirection table, hash
  168. * key, and/or hash function. Arguments which are set to %NULL or zero
  169. * will remain unchanged.
  170. * Returns a negative error code or zero. An error code must be returned
  171. * if at least one unsupported change was requested.
  172. * @get_channels: Get number of channels.
  173. * @set_channels: Set number of channels. Returns a negative error code or
  174. * zero.
  175. * @get_dump_flag: Get dump flag indicating current dump length, version,
  176. * and flag of the device.
  177. * @get_dump_data: Get dump data.
  178. * @set_dump: Set dump specific flags to the device.
  179. * @get_ts_info: Get the time stamping and PTP hardware clock capabilities.
  180. * Drivers supporting transmit time stamps in software should set this to
  181. * ethtool_op_get_ts_info().
  182. * @get_module_info: Get the size and type of the eeprom contained within
  183. * a plug-in module.
  184. * @get_module_eeprom: Get the eeprom information from the plug-in module
  185. * @get_eee: Get Energy-Efficient (EEE) supported and status.
  186. * @set_eee: Set EEE status (enable/disable) as well as LPI timers.
  187. *
  188. * All operations are optional (i.e. the function pointer may be set
  189. * to %NULL) and callers must take this into account. Callers must
  190. * hold the RTNL lock.
  191. *
  192. * See the structures used by these operations for further documentation.
  193. * Note that for all operations using a structure ending with a zero-
  194. * length array, the array is allocated separately in the kernel and
  195. * is passed to the driver as an additional parameter.
  196. *
  197. * See &struct net_device and &struct net_device_ops for documentation
  198. * of the generic netdev features interface.
  199. */
  200. struct ethtool_ops {
  201. int (*get_settings)(struct net_device *, struct ethtool_cmd *);
  202. int (*set_settings)(struct net_device *, struct ethtool_cmd *);
  203. void (*get_drvinfo)(struct net_device *, struct ethtool_drvinfo *);
  204. int (*get_regs_len)(struct net_device *);
  205. void (*get_regs)(struct net_device *, struct ethtool_regs *, void *);
  206. void (*get_wol)(struct net_device *, struct ethtool_wolinfo *);
  207. int (*set_wol)(struct net_device *, struct ethtool_wolinfo *);
  208. u32 (*get_msglevel)(struct net_device *);
  209. void (*set_msglevel)(struct net_device *, u32);
  210. int (*nway_reset)(struct net_device *);
  211. u32 (*get_link)(struct net_device *);
  212. int (*get_eeprom_len)(struct net_device *);
  213. int (*get_eeprom)(struct net_device *,
  214. struct ethtool_eeprom *, u8 *);
  215. int (*set_eeprom)(struct net_device *,
  216. struct ethtool_eeprom *, u8 *);
  217. int (*get_coalesce)(struct net_device *, struct ethtool_coalesce *);
  218. int (*set_coalesce)(struct net_device *, struct ethtool_coalesce *);
  219. void (*get_ringparam)(struct net_device *,
  220. struct ethtool_ringparam *);
  221. int (*set_ringparam)(struct net_device *,
  222. struct ethtool_ringparam *);
  223. void (*get_pauseparam)(struct net_device *,
  224. struct ethtool_pauseparam*);
  225. int (*set_pauseparam)(struct net_device *,
  226. struct ethtool_pauseparam*);
  227. void (*self_test)(struct net_device *, struct ethtool_test *, u64 *);
  228. void (*get_strings)(struct net_device *, u32 stringset, u8 *);
  229. int (*set_phys_id)(struct net_device *, enum ethtool_phys_id_state);
  230. void (*get_ethtool_stats)(struct net_device *,
  231. struct ethtool_stats *, u64 *);
  232. int (*begin)(struct net_device *);
  233. void (*complete)(struct net_device *);
  234. u32 (*get_priv_flags)(struct net_device *);
  235. int (*set_priv_flags)(struct net_device *, u32);
  236. int (*get_sset_count)(struct net_device *, int);
  237. int (*get_rxnfc)(struct net_device *,
  238. struct ethtool_rxnfc *, u32 *rule_locs);
  239. int (*set_rxnfc)(struct net_device *, struct ethtool_rxnfc *);
  240. int (*flash_device)(struct net_device *, struct ethtool_flash *);
  241. int (*reset)(struct net_device *, u32 *);
  242. u32 (*get_rxfh_key_size)(struct net_device *);
  243. u32 (*get_rxfh_indir_size)(struct net_device *);
  244. int (*get_rxfh)(struct net_device *, u32 *indir, u8 *key,
  245. u8 *hfunc);
  246. int (*set_rxfh)(struct net_device *, const u32 *indir,
  247. const u8 *key, const u8 hfunc);
  248. void (*get_channels)(struct net_device *, struct ethtool_channels *);
  249. int (*set_channels)(struct net_device *, struct ethtool_channels *);
  250. int (*get_dump_flag)(struct net_device *, struct ethtool_dump *);
  251. int (*get_dump_data)(struct net_device *,
  252. struct ethtool_dump *, void *);
  253. int (*set_dump)(struct net_device *, struct ethtool_dump *);
  254. int (*get_ts_info)(struct net_device *, struct ethtool_ts_info *);
  255. int (*get_module_info)(struct net_device *,
  256. struct ethtool_modinfo *);
  257. int (*get_module_eeprom)(struct net_device *,
  258. struct ethtool_eeprom *, u8 *);
  259. int (*get_eee)(struct net_device *, struct ethtool_eee *);
  260. int (*set_eee)(struct net_device *, struct ethtool_eee *);
  261. int (*get_tunable)(struct net_device *,
  262. const struct ethtool_tunable *, void *);
  263. int (*set_tunable)(struct net_device *,
  264. const struct ethtool_tunable *, const void *);
  265. };
  266. #endif /* _LINUX_ETHTOOL_H */