ethtool.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  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/bitmap.h>
  15. #include <linux/compat.h>
  16. #include <uapi/linux/ethtool.h>
  17. #ifdef CONFIG_COMPAT
  18. struct compat_ethtool_rx_flow_spec {
  19. u32 flow_type;
  20. union ethtool_flow_union h_u;
  21. struct ethtool_flow_ext h_ext;
  22. union ethtool_flow_union m_u;
  23. struct ethtool_flow_ext m_ext;
  24. compat_u64 ring_cookie;
  25. u32 location;
  26. };
  27. struct compat_ethtool_rxnfc {
  28. u32 cmd;
  29. u32 flow_type;
  30. compat_u64 data;
  31. struct compat_ethtool_rx_flow_spec fs;
  32. u32 rule_cnt;
  33. u32 rule_locs[0];
  34. };
  35. #endif /* CONFIG_COMPAT */
  36. #include <linux/rculist.h>
  37. /**
  38. * enum ethtool_phys_id_state - indicator state for physical identification
  39. * @ETHTOOL_ID_INACTIVE: Physical ID indicator should be deactivated
  40. * @ETHTOOL_ID_ACTIVE: Physical ID indicator should be activated
  41. * @ETHTOOL_ID_ON: LED should be turned on (used iff %ETHTOOL_ID_ACTIVE
  42. * is not supported)
  43. * @ETHTOOL_ID_OFF: LED should be turned off (used iff %ETHTOOL_ID_ACTIVE
  44. * is not supported)
  45. */
  46. enum ethtool_phys_id_state {
  47. ETHTOOL_ID_INACTIVE,
  48. ETHTOOL_ID_ACTIVE,
  49. ETHTOOL_ID_ON,
  50. ETHTOOL_ID_OFF
  51. };
  52. enum {
  53. ETH_RSS_HASH_TOP_BIT, /* Configurable RSS hash function - Toeplitz */
  54. ETH_RSS_HASH_XOR_BIT, /* Configurable RSS hash function - Xor */
  55. /*
  56. * Add your fresh new hash function bits above and remember to update
  57. * rss_hash_func_strings[] in ethtool.c
  58. */
  59. ETH_RSS_HASH_FUNCS_COUNT
  60. };
  61. #define __ETH_RSS_HASH_BIT(bit) ((u32)1 << (bit))
  62. #define __ETH_RSS_HASH(name) __ETH_RSS_HASH_BIT(ETH_RSS_HASH_##name##_BIT)
  63. #define ETH_RSS_HASH_TOP __ETH_RSS_HASH(TOP)
  64. #define ETH_RSS_HASH_XOR __ETH_RSS_HASH(XOR)
  65. #define ETH_RSS_HASH_UNKNOWN 0
  66. #define ETH_RSS_HASH_NO_CHANGE 0
  67. struct net_device;
  68. /* Some generic methods drivers may use in their ethtool_ops */
  69. u32 ethtool_op_get_link(struct net_device *dev);
  70. int ethtool_op_get_ts_info(struct net_device *dev, struct ethtool_ts_info *eti);
  71. /**
  72. * ethtool_rxfh_indir_default - get default value for RX flow hash indirection
  73. * @index: Index in RX flow hash indirection table
  74. * @n_rx_rings: Number of RX rings to use
  75. *
  76. * This function provides the default policy for RX flow hash indirection.
  77. */
  78. static inline u32 ethtool_rxfh_indir_default(u32 index, u32 n_rx_rings)
  79. {
  80. return index % n_rx_rings;
  81. }
  82. /* number of link mode bits/ulongs handled internally by kernel */
  83. #define __ETHTOOL_LINK_MODE_MASK_NBITS \
  84. (__ETHTOOL_LINK_MODE_LAST + 1)
  85. /* declare a link mode bitmap */
  86. #define __ETHTOOL_DECLARE_LINK_MODE_MASK(name) \
  87. DECLARE_BITMAP(name, __ETHTOOL_LINK_MODE_MASK_NBITS)
  88. /* drivers must ignore base.cmd and base.link_mode_masks_nwords
  89. * fields, but they are allowed to overwrite them (will be ignored).
  90. */
  91. struct ethtool_link_ksettings {
  92. struct ethtool_link_settings base;
  93. struct {
  94. __ETHTOOL_DECLARE_LINK_MODE_MASK(supported);
  95. __ETHTOOL_DECLARE_LINK_MODE_MASK(advertising);
  96. __ETHTOOL_DECLARE_LINK_MODE_MASK(lp_advertising);
  97. } link_modes;
  98. };
  99. /**
  100. * ethtool_link_ksettings_zero_link_mode - clear link_ksettings link mode mask
  101. * @ptr : pointer to struct ethtool_link_ksettings
  102. * @name : one of supported/advertising/lp_advertising
  103. */
  104. #define ethtool_link_ksettings_zero_link_mode(ptr, name) \
  105. bitmap_zero((ptr)->link_modes.name, __ETHTOOL_LINK_MODE_MASK_NBITS)
  106. /**
  107. * ethtool_link_ksettings_add_link_mode - set bit in link_ksettings
  108. * link mode mask
  109. * @ptr : pointer to struct ethtool_link_ksettings
  110. * @name : one of supported/advertising/lp_advertising
  111. * @mode : one of the ETHTOOL_LINK_MODE_*_BIT
  112. * (not atomic, no bound checking)
  113. */
  114. #define ethtool_link_ksettings_add_link_mode(ptr, name, mode) \
  115. __set_bit(ETHTOOL_LINK_MODE_ ## mode ## _BIT, (ptr)->link_modes.name)
  116. /**
  117. * ethtool_link_ksettings_test_link_mode - test bit in ksettings link mode mask
  118. * @ptr : pointer to struct ethtool_link_ksettings
  119. * @name : one of supported/advertising/lp_advertising
  120. * @mode : one of the ETHTOOL_LINK_MODE_*_BIT
  121. * (not atomic, no bound checking)
  122. *
  123. * Returns true/false.
  124. */
  125. #define ethtool_link_ksettings_test_link_mode(ptr, name, mode) \
  126. test_bit(ETHTOOL_LINK_MODE_ ## mode ## _BIT, (ptr)->link_modes.name)
  127. extern int
  128. __ethtool_get_link_ksettings(struct net_device *dev,
  129. struct ethtool_link_ksettings *link_ksettings);
  130. /**
  131. * struct ethtool_ops - optional netdev operations
  132. * @get_settings: DEPRECATED, use %get_link_ksettings/%set_link_ksettings
  133. * API. Get various device settings including Ethernet link
  134. * settings. The @cmd parameter is expected to have been cleared
  135. * before get_settings is called. Returns a negative error code
  136. * or zero.
  137. * @set_settings: DEPRECATED, use %get_link_ksettings/%set_link_ksettings
  138. * API. Set various device settings including Ethernet link
  139. * settings. Returns a negative error code or zero.
  140. * @get_drvinfo: Report driver/device information. Should only set the
  141. * @driver, @version, @fw_version and @bus_info fields. If not
  142. * implemented, the @driver and @bus_info fields will be filled in
  143. * according to the netdev's parent device.
  144. * @get_regs_len: Get buffer length required for @get_regs
  145. * @get_regs: Get device registers
  146. * @get_wol: Report whether Wake-on-Lan is enabled
  147. * @set_wol: Turn Wake-on-Lan on or off. Returns a negative error code
  148. * or zero.
  149. * @get_msglevel: Report driver message level. This should be the value
  150. * of the @msg_enable field used by netif logging functions.
  151. * @set_msglevel: Set driver message level
  152. * @nway_reset: Restart autonegotiation. Returns a negative error code
  153. * or zero.
  154. * @get_link: Report whether physical link is up. Will only be called if
  155. * the netdev is up. Should usually be set to ethtool_op_get_link(),
  156. * which uses netif_carrier_ok().
  157. * @get_eeprom: Read data from the device EEPROM.
  158. * Should fill in the magic field. Don't need to check len for zero
  159. * or wraparound. Fill in the data argument with the eeprom values
  160. * from offset to offset + len. Update len to the amount read.
  161. * Returns an error or zero.
  162. * @set_eeprom: Write data to the device EEPROM.
  163. * Should validate the magic field. Don't need to check len for zero
  164. * or wraparound. Update len to the amount written. Returns an error
  165. * or zero.
  166. * @get_coalesce: Get interrupt coalescing parameters. Returns a negative
  167. * error code or zero.
  168. * @set_coalesce: Set interrupt coalescing parameters. Returns a negative
  169. * error code or zero.
  170. * @get_ringparam: Report ring sizes
  171. * @set_ringparam: Set ring sizes. Returns a negative error code or zero.
  172. * @get_pauseparam: Report pause parameters
  173. * @set_pauseparam: Set pause parameters. Returns a negative error code
  174. * or zero.
  175. * @self_test: Run specified self-tests
  176. * @get_strings: Return a set of strings that describe the requested objects
  177. * @set_phys_id: Identify the physical devices, e.g. by flashing an LED
  178. * attached to it. The implementation may update the indicator
  179. * asynchronously or synchronously, but in either case it must return
  180. * quickly. It is initially called with the argument %ETHTOOL_ID_ACTIVE,
  181. * and must either activate asynchronous updates and return zero, return
  182. * a negative error or return a positive frequency for synchronous
  183. * indication (e.g. 1 for one on/off cycle per second). If it returns
  184. * a frequency then it will be called again at intervals with the
  185. * argument %ETHTOOL_ID_ON or %ETHTOOL_ID_OFF and should set the state of
  186. * the indicator accordingly. Finally, it is called with the argument
  187. * %ETHTOOL_ID_INACTIVE and must deactivate the indicator. Returns a
  188. * negative error code or zero.
  189. * @get_ethtool_stats: Return extended statistics about the device.
  190. * This is only useful if the device maintains statistics not
  191. * included in &struct rtnl_link_stats64.
  192. * @begin: Function to be called before any other operation. Returns a
  193. * negative error code or zero.
  194. * @complete: Function to be called after any other operation except
  195. * @begin. Will be called even if the other operation failed.
  196. * @get_priv_flags: Report driver-specific feature flags.
  197. * @set_priv_flags: Set driver-specific feature flags. Returns a negative
  198. * error code or zero.
  199. * @get_sset_count: Get number of strings that @get_strings will write.
  200. * @get_rxnfc: Get RX flow classification rules. Returns a negative
  201. * error code or zero.
  202. * @set_rxnfc: Set RX flow classification rules. Returns a negative
  203. * error code or zero.
  204. * @flash_device: Write a firmware image to device's flash memory.
  205. * Returns a negative error code or zero.
  206. * @reset: Reset (part of) the device, as specified by a bitmask of
  207. * flags from &enum ethtool_reset_flags. Returns a negative
  208. * error code or zero.
  209. * @get_rxfh_key_size: Get the size of the RX flow hash key.
  210. * Returns zero if not supported for this specific device.
  211. * @get_rxfh_indir_size: Get the size of the RX flow hash indirection table.
  212. * Returns zero if not supported for this specific device.
  213. * @get_rxfh: Get the contents of the RX flow hash indirection table, hash key
  214. * and/or hash function.
  215. * Returns a negative error code or zero.
  216. * @set_rxfh: Set the contents of the RX flow hash indirection table, hash
  217. * key, and/or hash function. Arguments which are set to %NULL or zero
  218. * will remain unchanged.
  219. * Returns a negative error code or zero. An error code must be returned
  220. * if at least one unsupported change was requested.
  221. * @get_channels: Get number of channels.
  222. * @set_channels: Set number of channels. Returns a negative error code or
  223. * zero.
  224. * @get_dump_flag: Get dump flag indicating current dump length, version,
  225. * and flag of the device.
  226. * @get_dump_data: Get dump data.
  227. * @set_dump: Set dump specific flags to the device.
  228. * @get_ts_info: Get the time stamping and PTP hardware clock capabilities.
  229. * Drivers supporting transmit time stamps in software should set this to
  230. * ethtool_op_get_ts_info().
  231. * @get_module_info: Get the size and type of the eeprom contained within
  232. * a plug-in module.
  233. * @get_module_eeprom: Get the eeprom information from the plug-in module
  234. * @get_eee: Get Energy-Efficient (EEE) supported and status.
  235. * @set_eee: Set EEE status (enable/disable) as well as LPI timers.
  236. * @get_per_queue_coalesce: Get interrupt coalescing parameters per queue.
  237. * It must check that the given queue number is valid. If neither a RX nor
  238. * a TX queue has this number, return -EINVAL. If only a RX queue or a TX
  239. * queue has this number, set the inapplicable fields to ~0 and return 0.
  240. * Returns a negative error code or zero.
  241. * @set_per_queue_coalesce: Set interrupt coalescing parameters per queue.
  242. * It must check that the given queue number is valid. If neither a RX nor
  243. * a TX queue has this number, return -EINVAL. If only a RX queue or a TX
  244. * queue has this number, ignore the inapplicable fields.
  245. * Returns a negative error code or zero.
  246. * @get_link_ksettings: When defined, takes precedence over the
  247. * %get_settings method. Get various device settings
  248. * including Ethernet link settings. The %cmd and
  249. * %link_mode_masks_nwords fields should be ignored (use
  250. * %__ETHTOOL_LINK_MODE_MASK_NBITS instead of the latter), any
  251. * change to them will be overwritten by kernel. Returns a
  252. * negative error code or zero.
  253. * @set_link_ksettings: When defined, takes precedence over the
  254. * %set_settings method. Set various device settings including
  255. * Ethernet link settings. The %cmd and %link_mode_masks_nwords
  256. * fields should be ignored (use %__ETHTOOL_LINK_MODE_MASK_NBITS
  257. * instead of the latter), any change to them will be overwritten
  258. * by kernel. Returns a negative error code or zero.
  259. *
  260. * All operations are optional (i.e. the function pointer may be set
  261. * to %NULL) and callers must take this into account. Callers must
  262. * hold the RTNL lock.
  263. *
  264. * See the structures used by these operations for further documentation.
  265. * Note that for all operations using a structure ending with a zero-
  266. * length array, the array is allocated separately in the kernel and
  267. * is passed to the driver as an additional parameter.
  268. *
  269. * See &struct net_device and &struct net_device_ops for documentation
  270. * of the generic netdev features interface.
  271. */
  272. struct ethtool_ops {
  273. int (*get_settings)(struct net_device *, struct ethtool_cmd *);
  274. int (*set_settings)(struct net_device *, struct ethtool_cmd *);
  275. void (*get_drvinfo)(struct net_device *, struct ethtool_drvinfo *);
  276. int (*get_regs_len)(struct net_device *);
  277. void (*get_regs)(struct net_device *, struct ethtool_regs *, void *);
  278. void (*get_wol)(struct net_device *, struct ethtool_wolinfo *);
  279. int (*set_wol)(struct net_device *, struct ethtool_wolinfo *);
  280. u32 (*get_msglevel)(struct net_device *);
  281. void (*set_msglevel)(struct net_device *, u32);
  282. int (*nway_reset)(struct net_device *);
  283. u32 (*get_link)(struct net_device *);
  284. int (*get_eeprom_len)(struct net_device *);
  285. int (*get_eeprom)(struct net_device *,
  286. struct ethtool_eeprom *, u8 *);
  287. int (*set_eeprom)(struct net_device *,
  288. struct ethtool_eeprom *, u8 *);
  289. int (*get_coalesce)(struct net_device *, struct ethtool_coalesce *);
  290. int (*set_coalesce)(struct net_device *, struct ethtool_coalesce *);
  291. void (*get_ringparam)(struct net_device *,
  292. struct ethtool_ringparam *);
  293. int (*set_ringparam)(struct net_device *,
  294. struct ethtool_ringparam *);
  295. void (*get_pauseparam)(struct net_device *,
  296. struct ethtool_pauseparam*);
  297. int (*set_pauseparam)(struct net_device *,
  298. struct ethtool_pauseparam*);
  299. void (*self_test)(struct net_device *, struct ethtool_test *, u64 *);
  300. void (*get_strings)(struct net_device *, u32 stringset, u8 *);
  301. int (*set_phys_id)(struct net_device *, enum ethtool_phys_id_state);
  302. void (*get_ethtool_stats)(struct net_device *,
  303. struct ethtool_stats *, u64 *);
  304. int (*begin)(struct net_device *);
  305. void (*complete)(struct net_device *);
  306. u32 (*get_priv_flags)(struct net_device *);
  307. int (*set_priv_flags)(struct net_device *, u32);
  308. int (*get_sset_count)(struct net_device *, int);
  309. int (*get_rxnfc)(struct net_device *,
  310. struct ethtool_rxnfc *, u32 *rule_locs);
  311. int (*set_rxnfc)(struct net_device *, struct ethtool_rxnfc *);
  312. int (*flash_device)(struct net_device *, struct ethtool_flash *);
  313. int (*reset)(struct net_device *, u32 *);
  314. u32 (*get_rxfh_key_size)(struct net_device *);
  315. u32 (*get_rxfh_indir_size)(struct net_device *);
  316. int (*get_rxfh)(struct net_device *, u32 *indir, u8 *key,
  317. u8 *hfunc);
  318. int (*set_rxfh)(struct net_device *, const u32 *indir,
  319. const u8 *key, const u8 hfunc);
  320. void (*get_channels)(struct net_device *, struct ethtool_channels *);
  321. int (*set_channels)(struct net_device *, struct ethtool_channels *);
  322. int (*get_dump_flag)(struct net_device *, struct ethtool_dump *);
  323. int (*get_dump_data)(struct net_device *,
  324. struct ethtool_dump *, void *);
  325. int (*set_dump)(struct net_device *, struct ethtool_dump *);
  326. int (*get_ts_info)(struct net_device *, struct ethtool_ts_info *);
  327. int (*get_module_info)(struct net_device *,
  328. struct ethtool_modinfo *);
  329. int (*get_module_eeprom)(struct net_device *,
  330. struct ethtool_eeprom *, u8 *);
  331. int (*get_eee)(struct net_device *, struct ethtool_eee *);
  332. int (*set_eee)(struct net_device *, struct ethtool_eee *);
  333. int (*get_tunable)(struct net_device *,
  334. const struct ethtool_tunable *, void *);
  335. int (*set_tunable)(struct net_device *,
  336. const struct ethtool_tunable *, const void *);
  337. int (*get_per_queue_coalesce)(struct net_device *, u32,
  338. struct ethtool_coalesce *);
  339. int (*set_per_queue_coalesce)(struct net_device *, u32,
  340. struct ethtool_coalesce *);
  341. int (*get_link_ksettings)(struct net_device *,
  342. struct ethtool_link_ksettings *);
  343. int (*set_link_ksettings)(struct net_device *,
  344. const struct ethtool_link_ksettings *);
  345. };
  346. #endif /* _LINUX_ETHTOOL_H */