ethtool.h 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325
  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. #ifdef __KERNEL__
  15. #include <linux/compat.h>
  16. #endif
  17. #include <linux/types.h>
  18. #include <linux/if_ether.h>
  19. /* This should work for both 32 and 64 bit userland. */
  20. struct ethtool_cmd {
  21. __u32 cmd;
  22. __u32 supported; /* Features this interface supports */
  23. __u32 advertising; /* Features this interface advertises */
  24. __u16 speed; /* The forced speed (lower bits) in
  25. * Mbps. Please use
  26. * ethtool_cmd_speed()/_set() to
  27. * access it */
  28. __u8 duplex; /* Duplex, half or full */
  29. __u8 port; /* Which connector port */
  30. __u8 phy_address; /* MDIO PHY address (PRTAD for clause 45).
  31. * May be read-only or read-write
  32. * depending on the driver.
  33. */
  34. __u8 transceiver; /* Which transceiver to use */
  35. __u8 autoneg; /* Enable or disable autonegotiation */
  36. __u8 mdio_support; /* MDIO protocols supported. Read-only.
  37. * Not set by all drivers.
  38. */
  39. __u32 maxtxpkt; /* Tx pkts before generating tx int */
  40. __u32 maxrxpkt; /* Rx pkts before generating rx int */
  41. __u16 speed_hi; /* The forced speed (upper
  42. * bits) in Mbps. Please use
  43. * ethtool_cmd_speed()/_set() to
  44. * access it */
  45. __u8 eth_tp_mdix; /* twisted pair MDI-X status */
  46. __u8 eth_tp_mdix_ctrl; /* twisted pair MDI-X control, when set,
  47. * link should be renegotiated if necessary
  48. */
  49. __u32 lp_advertising; /* Features the link partner advertises */
  50. __u32 reserved[2];
  51. };
  52. static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep,
  53. __u32 speed)
  54. {
  55. ep->speed = (__u16)speed;
  56. ep->speed_hi = (__u16)(speed >> 16);
  57. }
  58. static inline __u32 ethtool_cmd_speed(const struct ethtool_cmd *ep)
  59. {
  60. return (ep->speed_hi << 16) | ep->speed;
  61. }
  62. /* Device supports clause 22 register access to PHY or peripherals
  63. * using the interface defined in <linux/mii.h>. This should not be
  64. * set if there are known to be no such peripherals present or if
  65. * the driver only emulates clause 22 registers for compatibility.
  66. */
  67. #define ETH_MDIO_SUPPORTS_C22 1
  68. /* Device supports clause 45 register access to PHY or peripherals
  69. * using the interface defined in <linux/mii.h> and <linux/mdio.h>.
  70. * This should not be set if there are known to be no such peripherals
  71. * present.
  72. */
  73. #define ETH_MDIO_SUPPORTS_C45 2
  74. #define ETHTOOL_FWVERS_LEN 32
  75. #define ETHTOOL_BUSINFO_LEN 32
  76. /* these strings are set to whatever the driver author decides... */
  77. struct ethtool_drvinfo {
  78. __u32 cmd;
  79. char driver[32]; /* driver short name, "tulip", "eepro100" */
  80. char version[32]; /* driver version string */
  81. char fw_version[ETHTOOL_FWVERS_LEN]; /* firmware version string */
  82. char bus_info[ETHTOOL_BUSINFO_LEN]; /* Bus info for this IF. */
  83. /* For PCI devices, use pci_name(pci_dev). */
  84. char reserved1[32];
  85. char reserved2[12];
  86. /*
  87. * Some struct members below are filled in
  88. * using ops->get_sset_count(). Obtaining
  89. * this info from ethtool_drvinfo is now
  90. * deprecated; Use ETHTOOL_GSSET_INFO
  91. * instead.
  92. */
  93. __u32 n_priv_flags; /* number of flags valid in ETHTOOL_GPFLAGS */
  94. __u32 n_stats; /* number of u64's from ETHTOOL_GSTATS */
  95. __u32 testinfo_len;
  96. __u32 eedump_len; /* Size of data from ETHTOOL_GEEPROM (bytes) */
  97. __u32 regdump_len; /* Size of data from ETHTOOL_GREGS (bytes) */
  98. };
  99. #define SOPASS_MAX 6
  100. /* wake-on-lan settings */
  101. struct ethtool_wolinfo {
  102. __u32 cmd;
  103. __u32 supported;
  104. __u32 wolopts;
  105. __u8 sopass[SOPASS_MAX]; /* SecureOn(tm) password */
  106. };
  107. /* for passing single values */
  108. struct ethtool_value {
  109. __u32 cmd;
  110. __u32 data;
  111. };
  112. /* for passing big chunks of data */
  113. struct ethtool_regs {
  114. __u32 cmd;
  115. __u32 version; /* driver-specific, indicates different chips/revs */
  116. __u32 len; /* bytes */
  117. __u8 data[0];
  118. };
  119. /* for passing EEPROM chunks */
  120. struct ethtool_eeprom {
  121. __u32 cmd;
  122. __u32 magic;
  123. __u32 offset; /* in bytes */
  124. __u32 len; /* in bytes */
  125. __u8 data[0];
  126. };
  127. /**
  128. * struct ethtool_eee - Energy Efficient Ethernet information
  129. * @cmd: ETHTOOL_{G,S}EEE
  130. * @supported: Mask of %SUPPORTED_* flags for the speed/duplex combinations
  131. * for which there is EEE support.
  132. * @advertised: Mask of %ADVERTISED_* flags for the speed/duplex combinations
  133. * advertised as eee capable.
  134. * @lp_advertised: Mask of %ADVERTISED_* flags for the speed/duplex
  135. * combinations advertised by the link partner as eee capable.
  136. * @eee_active: Result of the eee auto negotiation.
  137. * @eee_enabled: EEE configured mode (enabled/disabled).
  138. * @tx_lpi_enabled: Whether the interface should assert its tx lpi, given
  139. * that eee was negotiated.
  140. * @tx_lpi_timer: Time in microseconds the interface delays prior to asserting
  141. * its tx lpi (after reaching 'idle' state). Effective only when eee
  142. * was negotiated and tx_lpi_enabled was set.
  143. */
  144. struct ethtool_eee {
  145. __u32 cmd;
  146. __u32 supported;
  147. __u32 advertised;
  148. __u32 lp_advertised;
  149. __u32 eee_active;
  150. __u32 eee_enabled;
  151. __u32 tx_lpi_enabled;
  152. __u32 tx_lpi_timer;
  153. __u32 reserved[2];
  154. };
  155. /**
  156. * struct ethtool_modinfo - plugin module eeprom information
  157. * @cmd: %ETHTOOL_GMODULEINFO
  158. * @type: Standard the module information conforms to %ETH_MODULE_SFF_xxxx
  159. * @eeprom_len: Length of the eeprom
  160. *
  161. * This structure is used to return the information to
  162. * properly size memory for a subsequent call to %ETHTOOL_GMODULEEEPROM.
  163. * The type code indicates the eeprom data format
  164. */
  165. struct ethtool_modinfo {
  166. __u32 cmd;
  167. __u32 type;
  168. __u32 eeprom_len;
  169. __u32 reserved[8];
  170. };
  171. /**
  172. * struct ethtool_coalesce - coalescing parameters for IRQs and stats updates
  173. * @cmd: ETHTOOL_{G,S}COALESCE
  174. * @rx_coalesce_usecs: How many usecs to delay an RX interrupt after
  175. * a packet arrives.
  176. * @rx_max_coalesced_frames: Maximum number of packets to receive
  177. * before an RX interrupt.
  178. * @rx_coalesce_usecs_irq: Same as @rx_coalesce_usecs, except that
  179. * this value applies while an IRQ is being serviced by the host.
  180. * @rx_max_coalesced_frames_irq: Same as @rx_max_coalesced_frames,
  181. * except that this value applies while an IRQ is being serviced
  182. * by the host.
  183. * @tx_coalesce_usecs: How many usecs to delay a TX interrupt after
  184. * a packet is sent.
  185. * @tx_max_coalesced_frames: Maximum number of packets to be sent
  186. * before a TX interrupt.
  187. * @tx_coalesce_usecs_irq: Same as @tx_coalesce_usecs, except that
  188. * this value applies while an IRQ is being serviced by the host.
  189. * @tx_max_coalesced_frames_irq: Same as @tx_max_coalesced_frames,
  190. * except that this value applies while an IRQ is being serviced
  191. * by the host.
  192. * @stats_block_coalesce_usecs: How many usecs to delay in-memory
  193. * statistics block updates. Some drivers do not have an
  194. * in-memory statistic block, and in such cases this value is
  195. * ignored. This value must not be zero.
  196. * @use_adaptive_rx_coalesce: Enable adaptive RX coalescing.
  197. * @use_adaptive_tx_coalesce: Enable adaptive TX coalescing.
  198. * @pkt_rate_low: Threshold for low packet rate (packets per second).
  199. * @rx_coalesce_usecs_low: How many usecs to delay an RX interrupt after
  200. * a packet arrives, when the packet rate is below @pkt_rate_low.
  201. * @rx_max_coalesced_frames_low: Maximum number of packets to be received
  202. * before an RX interrupt, when the packet rate is below @pkt_rate_low.
  203. * @tx_coalesce_usecs_low: How many usecs to delay a TX interrupt after
  204. * a packet is sent, when the packet rate is below @pkt_rate_low.
  205. * @tx_max_coalesced_frames_low: Maximum nuumber of packets to be sent before
  206. * a TX interrupt, when the packet rate is below @pkt_rate_low.
  207. * @pkt_rate_high: Threshold for high packet rate (packets per second).
  208. * @rx_coalesce_usecs_high: How many usecs to delay an RX interrupt after
  209. * a packet arrives, when the packet rate is above @pkt_rate_high.
  210. * @rx_max_coalesced_frames_high: Maximum number of packets to be received
  211. * before an RX interrupt, when the packet rate is above @pkt_rate_high.
  212. * @tx_coalesce_usecs_high: How many usecs to delay a TX interrupt after
  213. * a packet is sent, when the packet rate is above @pkt_rate_high.
  214. * @tx_max_coalesced_frames_high: Maximum number of packets to be sent before
  215. * a TX interrupt, when the packet rate is above @pkt_rate_high.
  216. * @rate_sample_interval: How often to do adaptive coalescing packet rate
  217. * sampling, measured in seconds. Must not be zero.
  218. *
  219. * Each pair of (usecs, max_frames) fields specifies this exit
  220. * condition for interrupt coalescing:
  221. * (usecs > 0 && time_since_first_completion >= usecs) ||
  222. * (max_frames > 0 && completed_frames >= max_frames)
  223. * It is illegal to set both usecs and max_frames to zero as this
  224. * would cause interrupts to never be generated. To disable
  225. * coalescing, set usecs = 0 and max_frames = 1.
  226. *
  227. * Some implementations ignore the value of max_frames and use the
  228. * condition:
  229. * time_since_first_completion >= usecs
  230. * This is deprecated. Drivers for hardware that does not support
  231. * counting completions should validate that max_frames == !rx_usecs.
  232. *
  233. * Adaptive RX/TX coalescing is an algorithm implemented by some
  234. * drivers to improve latency under low packet rates and improve
  235. * throughput under high packet rates. Some drivers only implement
  236. * one of RX or TX adaptive coalescing. Anything not implemented by
  237. * the driver causes these values to be silently ignored.
  238. *
  239. * When the packet rate is below @pkt_rate_high but above
  240. * @pkt_rate_low (both measured in packets per second) the
  241. * normal {rx,tx}_* coalescing parameters are used.
  242. */
  243. struct ethtool_coalesce {
  244. __u32 cmd;
  245. __u32 rx_coalesce_usecs;
  246. __u32 rx_max_coalesced_frames;
  247. __u32 rx_coalesce_usecs_irq;
  248. __u32 rx_max_coalesced_frames_irq;
  249. __u32 tx_coalesce_usecs;
  250. __u32 tx_max_coalesced_frames;
  251. __u32 tx_coalesce_usecs_irq;
  252. __u32 tx_max_coalesced_frames_irq;
  253. __u32 stats_block_coalesce_usecs;
  254. __u32 use_adaptive_rx_coalesce;
  255. __u32 use_adaptive_tx_coalesce;
  256. __u32 pkt_rate_low;
  257. __u32 rx_coalesce_usecs_low;
  258. __u32 rx_max_coalesced_frames_low;
  259. __u32 tx_coalesce_usecs_low;
  260. __u32 tx_max_coalesced_frames_low;
  261. __u32 pkt_rate_high;
  262. __u32 rx_coalesce_usecs_high;
  263. __u32 rx_max_coalesced_frames_high;
  264. __u32 tx_coalesce_usecs_high;
  265. __u32 tx_max_coalesced_frames_high;
  266. __u32 rate_sample_interval;
  267. };
  268. /* for configuring RX/TX ring parameters */
  269. struct ethtool_ringparam {
  270. __u32 cmd; /* ETHTOOL_{G,S}RINGPARAM */
  271. /* Read only attributes. These indicate the maximum number
  272. * of pending RX/TX ring entries the driver will allow the
  273. * user to set.
  274. */
  275. __u32 rx_max_pending;
  276. __u32 rx_mini_max_pending;
  277. __u32 rx_jumbo_max_pending;
  278. __u32 tx_max_pending;
  279. /* Values changeable by the user. The valid values are
  280. * in the range 1 to the "*_max_pending" counterpart above.
  281. */
  282. __u32 rx_pending;
  283. __u32 rx_mini_pending;
  284. __u32 rx_jumbo_pending;
  285. __u32 tx_pending;
  286. };
  287. /**
  288. * struct ethtool_channels - configuring number of network channel
  289. * @cmd: ETHTOOL_{G,S}CHANNELS
  290. * @max_rx: Read only. Maximum number of receive channel the driver support.
  291. * @max_tx: Read only. Maximum number of transmit channel the driver support.
  292. * @max_other: Read only. Maximum number of other channel the driver support.
  293. * @max_combined: Read only. Maximum number of combined channel the driver
  294. * support. Set of queues RX, TX or other.
  295. * @rx_count: Valid values are in the range 1 to the max_rx.
  296. * @tx_count: Valid values are in the range 1 to the max_tx.
  297. * @other_count: Valid values are in the range 1 to the max_other.
  298. * @combined_count: Valid values are in the range 1 to the max_combined.
  299. *
  300. * This can be used to configure RX, TX and other channels.
  301. */
  302. struct ethtool_channels {
  303. __u32 cmd;
  304. __u32 max_rx;
  305. __u32 max_tx;
  306. __u32 max_other;
  307. __u32 max_combined;
  308. __u32 rx_count;
  309. __u32 tx_count;
  310. __u32 other_count;
  311. __u32 combined_count;
  312. };
  313. /* for configuring link flow control parameters */
  314. struct ethtool_pauseparam {
  315. __u32 cmd; /* ETHTOOL_{G,S}PAUSEPARAM */
  316. /* If the link is being auto-negotiated (via ethtool_cmd.autoneg
  317. * being true) the user may set 'autoneg' here non-zero to have the
  318. * pause parameters be auto-negotiated too. In such a case, the
  319. * {rx,tx}_pause values below determine what capabilities are
  320. * advertised.
  321. *
  322. * If 'autoneg' is zero or the link is not being auto-negotiated,
  323. * then {rx,tx}_pause force the driver to use/not-use pause
  324. * flow control.
  325. */
  326. __u32 autoneg;
  327. __u32 rx_pause;
  328. __u32 tx_pause;
  329. };
  330. #define ETH_GSTRING_LEN 32
  331. enum ethtool_stringset {
  332. ETH_SS_TEST = 0,
  333. ETH_SS_STATS,
  334. ETH_SS_PRIV_FLAGS,
  335. ETH_SS_NTUPLE_FILTERS, /* Do not use, GRXNTUPLE is now deprecated */
  336. ETH_SS_FEATURES,
  337. };
  338. /* for passing string sets for data tagging */
  339. struct ethtool_gstrings {
  340. __u32 cmd; /* ETHTOOL_GSTRINGS */
  341. __u32 string_set; /* string set id e.c. ETH_SS_TEST, etc*/
  342. __u32 len; /* number of strings in the string set */
  343. __u8 data[0];
  344. };
  345. struct ethtool_sset_info {
  346. __u32 cmd; /* ETHTOOL_GSSET_INFO */
  347. __u32 reserved;
  348. __u64 sset_mask; /* input: each bit selects an sset to query */
  349. /* output: each bit a returned sset */
  350. __u32 data[0]; /* ETH_SS_xxx count, in order, based on bits
  351. in sset_mask. One bit implies one
  352. __u32, two bits implies two
  353. __u32's, etc. */
  354. };
  355. /**
  356. * enum ethtool_test_flags - flags definition of ethtool_test
  357. * @ETH_TEST_FL_OFFLINE: if set perform online and offline tests, otherwise
  358. * only online tests.
  359. * @ETH_TEST_FL_FAILED: Driver set this flag if test fails.
  360. * @ETH_TEST_FL_EXTERNAL_LB: Application request to perform external loopback
  361. * test.
  362. * @ETH_TEST_FL_EXTERNAL_LB_DONE: Driver performed the external loopback test
  363. */
  364. enum ethtool_test_flags {
  365. ETH_TEST_FL_OFFLINE = (1 << 0),
  366. ETH_TEST_FL_FAILED = (1 << 1),
  367. ETH_TEST_FL_EXTERNAL_LB = (1 << 2),
  368. ETH_TEST_FL_EXTERNAL_LB_DONE = (1 << 3),
  369. };
  370. /* for requesting NIC test and getting results*/
  371. struct ethtool_test {
  372. __u32 cmd; /* ETHTOOL_TEST */
  373. __u32 flags; /* ETH_TEST_FL_xxx */
  374. __u32 reserved;
  375. __u32 len; /* result length, in number of u64 elements */
  376. __u64 data[0];
  377. };
  378. /* for dumping NIC-specific statistics */
  379. struct ethtool_stats {
  380. __u32 cmd; /* ETHTOOL_GSTATS */
  381. __u32 n_stats; /* number of u64's being returned */
  382. __u64 data[0];
  383. };
  384. struct ethtool_perm_addr {
  385. __u32 cmd; /* ETHTOOL_GPERMADDR */
  386. __u32 size;
  387. __u8 data[0];
  388. };
  389. /* boolean flags controlling per-interface behavior characteristics.
  390. * When reading, the flag indicates whether or not a certain behavior
  391. * is enabled/present. When writing, the flag indicates whether
  392. * or not the driver should turn on (set) or off (clear) a behavior.
  393. *
  394. * Some behaviors may read-only (unconditionally absent or present).
  395. * If such is the case, return EINVAL in the set-flags operation if the
  396. * flag differs from the read-only value.
  397. */
  398. enum ethtool_flags {
  399. ETH_FLAG_TXVLAN = (1 << 7), /* TX VLAN offload enabled */
  400. ETH_FLAG_RXVLAN = (1 << 8), /* RX VLAN offload enabled */
  401. ETH_FLAG_LRO = (1 << 15), /* LRO is enabled */
  402. ETH_FLAG_NTUPLE = (1 << 27), /* N-tuple filters enabled */
  403. ETH_FLAG_RXHASH = (1 << 28),
  404. };
  405. /* The following structures are for supporting RX network flow
  406. * classification and RX n-tuple configuration. Note, all multibyte
  407. * fields, e.g., ip4src, ip4dst, psrc, pdst, spi, etc. are expected to
  408. * be in network byte order.
  409. */
  410. /**
  411. * struct ethtool_tcpip4_spec - flow specification for TCP/IPv4 etc.
  412. * @ip4src: Source host
  413. * @ip4dst: Destination host
  414. * @psrc: Source port
  415. * @pdst: Destination port
  416. * @tos: Type-of-service
  417. *
  418. * This can be used to specify a TCP/IPv4, UDP/IPv4 or SCTP/IPv4 flow.
  419. */
  420. struct ethtool_tcpip4_spec {
  421. __be32 ip4src;
  422. __be32 ip4dst;
  423. __be16 psrc;
  424. __be16 pdst;
  425. __u8 tos;
  426. };
  427. /**
  428. * struct ethtool_ah_espip4_spec - flow specification for IPsec/IPv4
  429. * @ip4src: Source host
  430. * @ip4dst: Destination host
  431. * @spi: Security parameters index
  432. * @tos: Type-of-service
  433. *
  434. * This can be used to specify an IPsec transport or tunnel over IPv4.
  435. */
  436. struct ethtool_ah_espip4_spec {
  437. __be32 ip4src;
  438. __be32 ip4dst;
  439. __be32 spi;
  440. __u8 tos;
  441. };
  442. #define ETH_RX_NFC_IP4 1
  443. /**
  444. * struct ethtool_usrip4_spec - general flow specification for IPv4
  445. * @ip4src: Source host
  446. * @ip4dst: Destination host
  447. * @l4_4_bytes: First 4 bytes of transport (layer 4) header
  448. * @tos: Type-of-service
  449. * @ip_ver: Value must be %ETH_RX_NFC_IP4; mask must be 0
  450. * @proto: Transport protocol number; mask must be 0
  451. */
  452. struct ethtool_usrip4_spec {
  453. __be32 ip4src;
  454. __be32 ip4dst;
  455. __be32 l4_4_bytes;
  456. __u8 tos;
  457. __u8 ip_ver;
  458. __u8 proto;
  459. };
  460. union ethtool_flow_union {
  461. struct ethtool_tcpip4_spec tcp_ip4_spec;
  462. struct ethtool_tcpip4_spec udp_ip4_spec;
  463. struct ethtool_tcpip4_spec sctp_ip4_spec;
  464. struct ethtool_ah_espip4_spec ah_ip4_spec;
  465. struct ethtool_ah_espip4_spec esp_ip4_spec;
  466. struct ethtool_usrip4_spec usr_ip4_spec;
  467. struct ethhdr ether_spec;
  468. __u8 hdata[60];
  469. };
  470. struct ethtool_flow_ext {
  471. __be16 vlan_etype;
  472. __be16 vlan_tci;
  473. __be32 data[2];
  474. };
  475. /**
  476. * struct ethtool_rx_flow_spec - classification rule for RX flows
  477. * @flow_type: Type of match to perform, e.g. %TCP_V4_FLOW
  478. * @h_u: Flow fields to match (dependent on @flow_type)
  479. * @h_ext: Additional fields to match
  480. * @m_u: Masks for flow field bits to be matched
  481. * @m_ext: Masks for additional field bits to be matched
  482. * Note, all additional fields must be ignored unless @flow_type
  483. * includes the %FLOW_EXT flag.
  484. * @ring_cookie: RX ring/queue index to deliver to, or %RX_CLS_FLOW_DISC
  485. * if packets should be discarded
  486. * @location: Location of rule in the table. Locations must be
  487. * numbered such that a flow matching multiple rules will be
  488. * classified according to the first (lowest numbered) rule.
  489. */
  490. struct ethtool_rx_flow_spec {
  491. __u32 flow_type;
  492. union ethtool_flow_union h_u;
  493. struct ethtool_flow_ext h_ext;
  494. union ethtool_flow_union m_u;
  495. struct ethtool_flow_ext m_ext;
  496. __u64 ring_cookie;
  497. __u32 location;
  498. };
  499. /**
  500. * struct ethtool_rxnfc - command to get or set RX flow classification rules
  501. * @cmd: Specific command number - %ETHTOOL_GRXFH, %ETHTOOL_SRXFH,
  502. * %ETHTOOL_GRXRINGS, %ETHTOOL_GRXCLSRLCNT, %ETHTOOL_GRXCLSRULE,
  503. * %ETHTOOL_GRXCLSRLALL, %ETHTOOL_SRXCLSRLDEL or %ETHTOOL_SRXCLSRLINS
  504. * @flow_type: Type of flow to be affected, e.g. %TCP_V4_FLOW
  505. * @data: Command-dependent value
  506. * @fs: Flow classification rule
  507. * @rule_cnt: Number of rules to be affected
  508. * @rule_locs: Array of used rule locations
  509. *
  510. * For %ETHTOOL_GRXFH and %ETHTOOL_SRXFH, @data is a bitmask indicating
  511. * the fields included in the flow hash, e.g. %RXH_IP_SRC. The following
  512. * structure fields must not be used.
  513. *
  514. * For %ETHTOOL_GRXRINGS, @data is set to the number of RX rings/queues
  515. * on return.
  516. *
  517. * For %ETHTOOL_GRXCLSRLCNT, @rule_cnt is set to the number of defined
  518. * rules on return. If @data is non-zero on return then it is the
  519. * size of the rule table, plus the flag %RX_CLS_LOC_SPECIAL if the
  520. * driver supports any special location values. If that flag is not
  521. * set in @data then special location values should not be used.
  522. *
  523. * For %ETHTOOL_GRXCLSRULE, @fs.@location specifies the location of an
  524. * existing rule on entry and @fs contains the rule on return.
  525. *
  526. * For %ETHTOOL_GRXCLSRLALL, @rule_cnt specifies the array size of the
  527. * user buffer for @rule_locs on entry. On return, @data is the size
  528. * of the rule table, @rule_cnt is the number of defined rules, and
  529. * @rule_locs contains the locations of the defined rules. Drivers
  530. * must use the second parameter to get_rxnfc() instead of @rule_locs.
  531. *
  532. * For %ETHTOOL_SRXCLSRLINS, @fs specifies the rule to add or update.
  533. * @fs.@location either specifies the location to use or is a special
  534. * location value with %RX_CLS_LOC_SPECIAL flag set. On return,
  535. * @fs.@location is the actual rule location.
  536. *
  537. * For %ETHTOOL_SRXCLSRLDEL, @fs.@location specifies the location of an
  538. * existing rule on entry.
  539. *
  540. * A driver supporting the special location values for
  541. * %ETHTOOL_SRXCLSRLINS may add the rule at any suitable unused
  542. * location, and may remove a rule at a later location (lower
  543. * priority) that matches exactly the same set of flows. The special
  544. * values are: %RX_CLS_LOC_ANY, selecting any location;
  545. * %RX_CLS_LOC_FIRST, selecting the first suitable location (maximum
  546. * priority); and %RX_CLS_LOC_LAST, selecting the last suitable
  547. * location (minimum priority). Additional special values may be
  548. * defined in future and drivers must return -%EINVAL for any
  549. * unrecognised value.
  550. */
  551. struct ethtool_rxnfc {
  552. __u32 cmd;
  553. __u32 flow_type;
  554. __u64 data;
  555. struct ethtool_rx_flow_spec fs;
  556. __u32 rule_cnt;
  557. __u32 rule_locs[0];
  558. };
  559. #ifdef __KERNEL__
  560. #ifdef CONFIG_COMPAT
  561. struct compat_ethtool_rx_flow_spec {
  562. u32 flow_type;
  563. union ethtool_flow_union h_u;
  564. struct ethtool_flow_ext h_ext;
  565. union ethtool_flow_union m_u;
  566. struct ethtool_flow_ext m_ext;
  567. compat_u64 ring_cookie;
  568. u32 location;
  569. };
  570. struct compat_ethtool_rxnfc {
  571. u32 cmd;
  572. u32 flow_type;
  573. compat_u64 data;
  574. struct compat_ethtool_rx_flow_spec fs;
  575. u32 rule_cnt;
  576. u32 rule_locs[0];
  577. };
  578. #endif /* CONFIG_COMPAT */
  579. #endif /* __KERNEL__ */
  580. /**
  581. * struct ethtool_rxfh_indir - command to get or set RX flow hash indirection
  582. * @cmd: Specific command number - %ETHTOOL_GRXFHINDIR or %ETHTOOL_SRXFHINDIR
  583. * @size: On entry, the array size of the user buffer, which may be zero.
  584. * On return from %ETHTOOL_GRXFHINDIR, the array size of the hardware
  585. * indirection table.
  586. * @ring_index: RX ring/queue index for each hash value
  587. *
  588. * For %ETHTOOL_GRXFHINDIR, a @size of zero means that only the size
  589. * should be returned. For %ETHTOOL_SRXFHINDIR, a @size of zero means
  590. * the table should be reset to default values. This last feature
  591. * is not supported by the original implementations.
  592. */
  593. struct ethtool_rxfh_indir {
  594. __u32 cmd;
  595. __u32 size;
  596. __u32 ring_index[0];
  597. };
  598. /**
  599. * struct ethtool_rx_ntuple_flow_spec - specification for RX flow filter
  600. * @flow_type: Type of match to perform, e.g. %TCP_V4_FLOW
  601. * @h_u: Flow field values to match (dependent on @flow_type)
  602. * @m_u: Masks for flow field value bits to be ignored
  603. * @vlan_tag: VLAN tag to match
  604. * @vlan_tag_mask: Mask for VLAN tag bits to be ignored
  605. * @data: Driver-dependent data to match
  606. * @data_mask: Mask for driver-dependent data bits to be ignored
  607. * @action: RX ring/queue index to deliver to (non-negative) or other action
  608. * (negative, e.g. %ETHTOOL_RXNTUPLE_ACTION_DROP)
  609. *
  610. * For flow types %TCP_V4_FLOW, %UDP_V4_FLOW and %SCTP_V4_FLOW, where
  611. * a field value and mask are both zero this is treated as if all mask
  612. * bits are set i.e. the field is ignored.
  613. */
  614. struct ethtool_rx_ntuple_flow_spec {
  615. __u32 flow_type;
  616. union {
  617. struct ethtool_tcpip4_spec tcp_ip4_spec;
  618. struct ethtool_tcpip4_spec udp_ip4_spec;
  619. struct ethtool_tcpip4_spec sctp_ip4_spec;
  620. struct ethtool_ah_espip4_spec ah_ip4_spec;
  621. struct ethtool_ah_espip4_spec esp_ip4_spec;
  622. struct ethtool_usrip4_spec usr_ip4_spec;
  623. struct ethhdr ether_spec;
  624. __u8 hdata[72];
  625. } h_u, m_u;
  626. __u16 vlan_tag;
  627. __u16 vlan_tag_mask;
  628. __u64 data;
  629. __u64 data_mask;
  630. __s32 action;
  631. #define ETHTOOL_RXNTUPLE_ACTION_DROP (-1) /* drop packet */
  632. #define ETHTOOL_RXNTUPLE_ACTION_CLEAR (-2) /* clear filter */
  633. };
  634. /**
  635. * struct ethtool_rx_ntuple - command to set or clear RX flow filter
  636. * @cmd: Command number - %ETHTOOL_SRXNTUPLE
  637. * @fs: Flow filter specification
  638. */
  639. struct ethtool_rx_ntuple {
  640. __u32 cmd;
  641. struct ethtool_rx_ntuple_flow_spec fs;
  642. };
  643. #define ETHTOOL_FLASH_MAX_FILENAME 128
  644. enum ethtool_flash_op_type {
  645. ETHTOOL_FLASH_ALL_REGIONS = 0,
  646. };
  647. /* for passing firmware flashing related parameters */
  648. struct ethtool_flash {
  649. __u32 cmd;
  650. __u32 region;
  651. char data[ETHTOOL_FLASH_MAX_FILENAME];
  652. };
  653. /**
  654. * struct ethtool_dump - used for retrieving, setting device dump
  655. * @cmd: Command number - %ETHTOOL_GET_DUMP_FLAG, %ETHTOOL_GET_DUMP_DATA, or
  656. * %ETHTOOL_SET_DUMP
  657. * @version: FW version of the dump, filled in by driver
  658. * @flag: driver dependent flag for dump setting, filled in by driver during
  659. * get and filled in by ethtool for set operation.
  660. * flag must be initialized by macro ETH_FW_DUMP_DISABLE value when
  661. * firmware dump is disabled.
  662. * @len: length of dump data, used as the length of the user buffer on entry to
  663. * %ETHTOOL_GET_DUMP_DATA and this is returned as dump length by driver
  664. * for %ETHTOOL_GET_DUMP_FLAG command
  665. * @data: data collected for get dump data operation
  666. */
  667. #define ETH_FW_DUMP_DISABLE 0
  668. struct ethtool_dump {
  669. __u32 cmd;
  670. __u32 version;
  671. __u32 flag;
  672. __u32 len;
  673. __u8 data[0];
  674. };
  675. /* for returning and changing feature sets */
  676. /**
  677. * struct ethtool_get_features_block - block with state of 32 features
  678. * @available: mask of changeable features
  679. * @requested: mask of features requested to be enabled if possible
  680. * @active: mask of currently enabled features
  681. * @never_changed: mask of features not changeable for any device
  682. */
  683. struct ethtool_get_features_block {
  684. __u32 available;
  685. __u32 requested;
  686. __u32 active;
  687. __u32 never_changed;
  688. };
  689. /**
  690. * struct ethtool_gfeatures - command to get state of device's features
  691. * @cmd: command number = %ETHTOOL_GFEATURES
  692. * @size: in: number of elements in the features[] array;
  693. * out: number of elements in features[] needed to hold all features
  694. * @features: state of features
  695. */
  696. struct ethtool_gfeatures {
  697. __u32 cmd;
  698. __u32 size;
  699. struct ethtool_get_features_block features[0];
  700. };
  701. /**
  702. * struct ethtool_set_features_block - block with request for 32 features
  703. * @valid: mask of features to be changed
  704. * @requested: values of features to be changed
  705. */
  706. struct ethtool_set_features_block {
  707. __u32 valid;
  708. __u32 requested;
  709. };
  710. /**
  711. * struct ethtool_sfeatures - command to request change in device's features
  712. * @cmd: command number = %ETHTOOL_SFEATURES
  713. * @size: array size of the features[] array
  714. * @features: feature change masks
  715. */
  716. struct ethtool_sfeatures {
  717. __u32 cmd;
  718. __u32 size;
  719. struct ethtool_set_features_block features[0];
  720. };
  721. /**
  722. * struct ethtool_ts_info - holds a device's timestamping and PHC association
  723. * @cmd: command number = %ETHTOOL_GET_TS_INFO
  724. * @so_timestamping: bit mask of the sum of the supported SO_TIMESTAMPING flags
  725. * @phc_index: device index of the associated PHC, or -1 if there is none
  726. * @tx_types: bit mask of the supported hwtstamp_tx_types enumeration values
  727. * @rx_filters: bit mask of the supported hwtstamp_rx_filters enumeration values
  728. *
  729. * The bits in the 'tx_types' and 'rx_filters' fields correspond to
  730. * the 'hwtstamp_tx_types' and 'hwtstamp_rx_filters' enumeration values,
  731. * respectively. For example, if the device supports HWTSTAMP_TX_ON,
  732. * then (1 << HWTSTAMP_TX_ON) in 'tx_types' will be set.
  733. */
  734. struct ethtool_ts_info {
  735. __u32 cmd;
  736. __u32 so_timestamping;
  737. __s32 phc_index;
  738. __u32 tx_types;
  739. __u32 tx_reserved[3];
  740. __u32 rx_filters;
  741. __u32 rx_reserved[3];
  742. };
  743. /*
  744. * %ETHTOOL_SFEATURES changes features present in features[].valid to the
  745. * values of corresponding bits in features[].requested. Bits in .requested
  746. * not set in .valid or not changeable are ignored.
  747. *
  748. * Returns %EINVAL when .valid contains undefined or never-changeable bits
  749. * or size is not equal to required number of features words (32-bit blocks).
  750. * Returns >= 0 if request was completed; bits set in the value mean:
  751. * %ETHTOOL_F_UNSUPPORTED - there were bits set in .valid that are not
  752. * changeable (not present in %ETHTOOL_GFEATURES' features[].available)
  753. * those bits were ignored.
  754. * %ETHTOOL_F_WISH - some or all changes requested were recorded but the
  755. * resulting state of bits masked by .valid is not equal to .requested.
  756. * Probably there are other device-specific constraints on some features
  757. * in the set. When %ETHTOOL_F_UNSUPPORTED is set, .valid is considered
  758. * here as though ignored bits were cleared.
  759. * %ETHTOOL_F_COMPAT - some or all changes requested were made by calling
  760. * compatibility functions. Requested offload state cannot be properly
  761. * managed by kernel.
  762. *
  763. * Meaning of bits in the masks are obtained by %ETHTOOL_GSSET_INFO (number of
  764. * bits in the arrays - always multiple of 32) and %ETHTOOL_GSTRINGS commands
  765. * for ETH_SS_FEATURES string set. First entry in the table corresponds to least
  766. * significant bit in features[0] fields. Empty strings mark undefined features.
  767. */
  768. enum ethtool_sfeatures_retval_bits {
  769. ETHTOOL_F_UNSUPPORTED__BIT,
  770. ETHTOOL_F_WISH__BIT,
  771. ETHTOOL_F_COMPAT__BIT,
  772. };
  773. #define ETHTOOL_F_UNSUPPORTED (1 << ETHTOOL_F_UNSUPPORTED__BIT)
  774. #define ETHTOOL_F_WISH (1 << ETHTOOL_F_WISH__BIT)
  775. #define ETHTOOL_F_COMPAT (1 << ETHTOOL_F_COMPAT__BIT)
  776. #ifdef __KERNEL__
  777. #include <linux/rculist.h>
  778. extern int __ethtool_get_settings(struct net_device *dev,
  779. struct ethtool_cmd *cmd);
  780. /**
  781. * enum ethtool_phys_id_state - indicator state for physical identification
  782. * @ETHTOOL_ID_INACTIVE: Physical ID indicator should be deactivated
  783. * @ETHTOOL_ID_ACTIVE: Physical ID indicator should be activated
  784. * @ETHTOOL_ID_ON: LED should be turned on (used iff %ETHTOOL_ID_ACTIVE
  785. * is not supported)
  786. * @ETHTOOL_ID_OFF: LED should be turned off (used iff %ETHTOOL_ID_ACTIVE
  787. * is not supported)
  788. */
  789. enum ethtool_phys_id_state {
  790. ETHTOOL_ID_INACTIVE,
  791. ETHTOOL_ID_ACTIVE,
  792. ETHTOOL_ID_ON,
  793. ETHTOOL_ID_OFF
  794. };
  795. struct net_device;
  796. /* Some generic methods drivers may use in their ethtool_ops */
  797. u32 ethtool_op_get_link(struct net_device *dev);
  798. int ethtool_op_get_ts_info(struct net_device *dev, struct ethtool_ts_info *eti);
  799. /**
  800. * ethtool_rxfh_indir_default - get default value for RX flow hash indirection
  801. * @index: Index in RX flow hash indirection table
  802. * @n_rx_rings: Number of RX rings to use
  803. *
  804. * This function provides the default policy for RX flow hash indirection.
  805. */
  806. static inline u32 ethtool_rxfh_indir_default(u32 index, u32 n_rx_rings)
  807. {
  808. return index % n_rx_rings;
  809. }
  810. /**
  811. * struct ethtool_ops - optional netdev operations
  812. * @get_settings: Get various device settings including Ethernet link
  813. * settings. The @cmd parameter is expected to have been cleared
  814. * before get_settings is called. Returns a negative error code or
  815. * zero.
  816. * @set_settings: Set various device settings including Ethernet link
  817. * settings. Returns a negative error code or zero.
  818. * @get_drvinfo: Report driver/device information. Should only set the
  819. * @driver, @version, @fw_version and @bus_info fields. If not
  820. * implemented, the @driver and @bus_info fields will be filled in
  821. * according to the netdev's parent device.
  822. * @get_regs_len: Get buffer length required for @get_regs
  823. * @get_regs: Get device registers
  824. * @get_wol: Report whether Wake-on-Lan is enabled
  825. * @set_wol: Turn Wake-on-Lan on or off. Returns a negative error code
  826. * or zero.
  827. * @get_msglevel: Report driver message level. This should be the value
  828. * of the @msg_enable field used by netif logging functions.
  829. * @set_msglevel: Set driver message level
  830. * @nway_reset: Restart autonegotiation. Returns a negative error code
  831. * or zero.
  832. * @get_link: Report whether physical link is up. Will only be called if
  833. * the netdev is up. Should usually be set to ethtool_op_get_link(),
  834. * which uses netif_carrier_ok().
  835. * @get_eeprom: Read data from the device EEPROM.
  836. * Should fill in the magic field. Don't need to check len for zero
  837. * or wraparound. Fill in the data argument with the eeprom values
  838. * from offset to offset + len. Update len to the amount read.
  839. * Returns an error or zero.
  840. * @set_eeprom: Write data to the device EEPROM.
  841. * Should validate the magic field. Don't need to check len for zero
  842. * or wraparound. Update len to the amount written. Returns an error
  843. * or zero.
  844. * @get_coalesce: Get interrupt coalescing parameters. Returns a negative
  845. * error code or zero.
  846. * @set_coalesce: Set interrupt coalescing parameters. Returns a negative
  847. * error code or zero.
  848. * @get_ringparam: Report ring sizes
  849. * @set_ringparam: Set ring sizes. Returns a negative error code or zero.
  850. * @get_pauseparam: Report pause parameters
  851. * @set_pauseparam: Set pause parameters. Returns a negative error code
  852. * or zero.
  853. * @self_test: Run specified self-tests
  854. * @get_strings: Return a set of strings that describe the requested objects
  855. * @set_phys_id: Identify the physical devices, e.g. by flashing an LED
  856. * attached to it. The implementation may update the indicator
  857. * asynchronously or synchronously, but in either case it must return
  858. * quickly. It is initially called with the argument %ETHTOOL_ID_ACTIVE,
  859. * and must either activate asynchronous updates and return zero, return
  860. * a negative error or return a positive frequency for synchronous
  861. * indication (e.g. 1 for one on/off cycle per second). If it returns
  862. * a frequency then it will be called again at intervals with the
  863. * argument %ETHTOOL_ID_ON or %ETHTOOL_ID_OFF and should set the state of
  864. * the indicator accordingly. Finally, it is called with the argument
  865. * %ETHTOOL_ID_INACTIVE and must deactivate the indicator. Returns a
  866. * negative error code or zero.
  867. * @get_ethtool_stats: Return extended statistics about the device.
  868. * This is only useful if the device maintains statistics not
  869. * included in &struct rtnl_link_stats64.
  870. * @begin: Function to be called before any other operation. Returns a
  871. * negative error code or zero.
  872. * @complete: Function to be called after any other operation except
  873. * @begin. Will be called even if the other operation failed.
  874. * @get_priv_flags: Report driver-specific feature flags.
  875. * @set_priv_flags: Set driver-specific feature flags. Returns a negative
  876. * error code or zero.
  877. * @get_sset_count: Get number of strings that @get_strings will write.
  878. * @get_rxnfc: Get RX flow classification rules. Returns a negative
  879. * error code or zero.
  880. * @set_rxnfc: Set RX flow classification rules. Returns a negative
  881. * error code or zero.
  882. * @flash_device: Write a firmware image to device's flash memory.
  883. * Returns a negative error code or zero.
  884. * @reset: Reset (part of) the device, as specified by a bitmask of
  885. * flags from &enum ethtool_reset_flags. Returns a negative
  886. * error code or zero.
  887. * @get_rxfh_indir_size: Get the size of the RX flow hash indirection table.
  888. * Returns zero if not supported for this specific device.
  889. * @get_rxfh_indir: Get the contents of the RX flow hash indirection table.
  890. * Will not be called if @get_rxfh_indir_size returns zero.
  891. * Returns a negative error code or zero.
  892. * @set_rxfh_indir: Set the contents of the RX flow hash indirection table.
  893. * Will not be called if @get_rxfh_indir_size returns zero.
  894. * Returns a negative error code or zero.
  895. * @get_channels: Get number of channels.
  896. * @set_channels: Set number of channels. Returns a negative error code or
  897. * zero.
  898. * @get_dump_flag: Get dump flag indicating current dump length, version,
  899. * and flag of the device.
  900. * @get_dump_data: Get dump data.
  901. * @set_dump: Set dump specific flags to the device.
  902. * @get_ts_info: Get the time stamping and PTP hardware clock capabilities.
  903. * Drivers supporting transmit time stamps in software should set this to
  904. * ethtool_op_get_ts_info().
  905. * @get_module_info: Get the size and type of the eeprom contained within
  906. * a plug-in module.
  907. * @get_module_eeprom: Get the eeprom information from the plug-in module
  908. * @get_eee: Get Energy-Efficient (EEE) supported and status.
  909. * @set_eee: Set EEE status (enable/disable) as well as LPI timers.
  910. *
  911. * All operations are optional (i.e. the function pointer may be set
  912. * to %NULL) and callers must take this into account. Callers must
  913. * hold the RTNL lock.
  914. *
  915. * See the structures used by these operations for further documentation.
  916. *
  917. * See &struct net_device and &struct net_device_ops for documentation
  918. * of the generic netdev features interface.
  919. */
  920. struct ethtool_ops {
  921. int (*get_settings)(struct net_device *, struct ethtool_cmd *);
  922. int (*set_settings)(struct net_device *, struct ethtool_cmd *);
  923. void (*get_drvinfo)(struct net_device *, struct ethtool_drvinfo *);
  924. int (*get_regs_len)(struct net_device *);
  925. void (*get_regs)(struct net_device *, struct ethtool_regs *, void *);
  926. void (*get_wol)(struct net_device *, struct ethtool_wolinfo *);
  927. int (*set_wol)(struct net_device *, struct ethtool_wolinfo *);
  928. u32 (*get_msglevel)(struct net_device *);
  929. void (*set_msglevel)(struct net_device *, u32);
  930. int (*nway_reset)(struct net_device *);
  931. u32 (*get_link)(struct net_device *);
  932. int (*get_eeprom_len)(struct net_device *);
  933. int (*get_eeprom)(struct net_device *,
  934. struct ethtool_eeprom *, u8 *);
  935. int (*set_eeprom)(struct net_device *,
  936. struct ethtool_eeprom *, u8 *);
  937. int (*get_coalesce)(struct net_device *, struct ethtool_coalesce *);
  938. int (*set_coalesce)(struct net_device *, struct ethtool_coalesce *);
  939. void (*get_ringparam)(struct net_device *,
  940. struct ethtool_ringparam *);
  941. int (*set_ringparam)(struct net_device *,
  942. struct ethtool_ringparam *);
  943. void (*get_pauseparam)(struct net_device *,
  944. struct ethtool_pauseparam*);
  945. int (*set_pauseparam)(struct net_device *,
  946. struct ethtool_pauseparam*);
  947. void (*self_test)(struct net_device *, struct ethtool_test *, u64 *);
  948. void (*get_strings)(struct net_device *, u32 stringset, u8 *);
  949. int (*set_phys_id)(struct net_device *, enum ethtool_phys_id_state);
  950. void (*get_ethtool_stats)(struct net_device *,
  951. struct ethtool_stats *, u64 *);
  952. int (*begin)(struct net_device *);
  953. void (*complete)(struct net_device *);
  954. u32 (*get_priv_flags)(struct net_device *);
  955. int (*set_priv_flags)(struct net_device *, u32);
  956. int (*get_sset_count)(struct net_device *, int);
  957. int (*get_rxnfc)(struct net_device *,
  958. struct ethtool_rxnfc *, u32 *rule_locs);
  959. int (*set_rxnfc)(struct net_device *, struct ethtool_rxnfc *);
  960. int (*flash_device)(struct net_device *, struct ethtool_flash *);
  961. int (*reset)(struct net_device *, u32 *);
  962. u32 (*get_rxfh_indir_size)(struct net_device *);
  963. int (*get_rxfh_indir)(struct net_device *, u32 *);
  964. int (*set_rxfh_indir)(struct net_device *, const u32 *);
  965. void (*get_channels)(struct net_device *, struct ethtool_channels *);
  966. int (*set_channels)(struct net_device *, struct ethtool_channels *);
  967. int (*get_dump_flag)(struct net_device *, struct ethtool_dump *);
  968. int (*get_dump_data)(struct net_device *,
  969. struct ethtool_dump *, void *);
  970. int (*set_dump)(struct net_device *, struct ethtool_dump *);
  971. int (*get_ts_info)(struct net_device *, struct ethtool_ts_info *);
  972. int (*get_module_info)(struct net_device *,
  973. struct ethtool_modinfo *);
  974. int (*get_module_eeprom)(struct net_device *,
  975. struct ethtool_eeprom *, u8 *);
  976. int (*get_eee)(struct net_device *, struct ethtool_eee *);
  977. int (*set_eee)(struct net_device *, struct ethtool_eee *);
  978. };
  979. #endif /* __KERNEL__ */
  980. /* CMDs currently supported */
  981. #define ETHTOOL_GSET 0x00000001 /* Get settings. */
  982. #define ETHTOOL_SSET 0x00000002 /* Set settings. */
  983. #define ETHTOOL_GDRVINFO 0x00000003 /* Get driver info. */
  984. #define ETHTOOL_GREGS 0x00000004 /* Get NIC registers. */
  985. #define ETHTOOL_GWOL 0x00000005 /* Get wake-on-lan options. */
  986. #define ETHTOOL_SWOL 0x00000006 /* Set wake-on-lan options. */
  987. #define ETHTOOL_GMSGLVL 0x00000007 /* Get driver message level */
  988. #define ETHTOOL_SMSGLVL 0x00000008 /* Set driver msg level. */
  989. #define ETHTOOL_NWAY_RST 0x00000009 /* Restart autonegotiation. */
  990. /* Get link status for host, i.e. whether the interface *and* the
  991. * physical port (if there is one) are up (ethtool_value). */
  992. #define ETHTOOL_GLINK 0x0000000a
  993. #define ETHTOOL_GEEPROM 0x0000000b /* Get EEPROM data */
  994. #define ETHTOOL_SEEPROM 0x0000000c /* Set EEPROM data. */
  995. #define ETHTOOL_GCOALESCE 0x0000000e /* Get coalesce config */
  996. #define ETHTOOL_SCOALESCE 0x0000000f /* Set coalesce config. */
  997. #define ETHTOOL_GRINGPARAM 0x00000010 /* Get ring parameters */
  998. #define ETHTOOL_SRINGPARAM 0x00000011 /* Set ring parameters. */
  999. #define ETHTOOL_GPAUSEPARAM 0x00000012 /* Get pause parameters */
  1000. #define ETHTOOL_SPAUSEPARAM 0x00000013 /* Set pause parameters. */
  1001. #define ETHTOOL_GRXCSUM 0x00000014 /* Get RX hw csum enable (ethtool_value) */
  1002. #define ETHTOOL_SRXCSUM 0x00000015 /* Set RX hw csum enable (ethtool_value) */
  1003. #define ETHTOOL_GTXCSUM 0x00000016 /* Get TX hw csum enable (ethtool_value) */
  1004. #define ETHTOOL_STXCSUM 0x00000017 /* Set TX hw csum enable (ethtool_value) */
  1005. #define ETHTOOL_GSG 0x00000018 /* Get scatter-gather enable
  1006. * (ethtool_value) */
  1007. #define ETHTOOL_SSG 0x00000019 /* Set scatter-gather enable
  1008. * (ethtool_value). */
  1009. #define ETHTOOL_TEST 0x0000001a /* execute NIC self-test. */
  1010. #define ETHTOOL_GSTRINGS 0x0000001b /* get specified string set */
  1011. #define ETHTOOL_PHYS_ID 0x0000001c /* identify the NIC */
  1012. #define ETHTOOL_GSTATS 0x0000001d /* get NIC-specific statistics */
  1013. #define ETHTOOL_GTSO 0x0000001e /* Get TSO enable (ethtool_value) */
  1014. #define ETHTOOL_STSO 0x0000001f /* Set TSO enable (ethtool_value) */
  1015. #define ETHTOOL_GPERMADDR 0x00000020 /* Get permanent hardware address */
  1016. #define ETHTOOL_GUFO 0x00000021 /* Get UFO enable (ethtool_value) */
  1017. #define ETHTOOL_SUFO 0x00000022 /* Set UFO enable (ethtool_value) */
  1018. #define ETHTOOL_GGSO 0x00000023 /* Get GSO enable (ethtool_value) */
  1019. #define ETHTOOL_SGSO 0x00000024 /* Set GSO enable (ethtool_value) */
  1020. #define ETHTOOL_GFLAGS 0x00000025 /* Get flags bitmap(ethtool_value) */
  1021. #define ETHTOOL_SFLAGS 0x00000026 /* Set flags bitmap(ethtool_value) */
  1022. #define ETHTOOL_GPFLAGS 0x00000027 /* Get driver-private flags bitmap */
  1023. #define ETHTOOL_SPFLAGS 0x00000028 /* Set driver-private flags bitmap */
  1024. #define ETHTOOL_GRXFH 0x00000029 /* Get RX flow hash configuration */
  1025. #define ETHTOOL_SRXFH 0x0000002a /* Set RX flow hash configuration */
  1026. #define ETHTOOL_GGRO 0x0000002b /* Get GRO enable (ethtool_value) */
  1027. #define ETHTOOL_SGRO 0x0000002c /* Set GRO enable (ethtool_value) */
  1028. #define ETHTOOL_GRXRINGS 0x0000002d /* Get RX rings available for LB */
  1029. #define ETHTOOL_GRXCLSRLCNT 0x0000002e /* Get RX class rule count */
  1030. #define ETHTOOL_GRXCLSRULE 0x0000002f /* Get RX classification rule */
  1031. #define ETHTOOL_GRXCLSRLALL 0x00000030 /* Get all RX classification rule */
  1032. #define ETHTOOL_SRXCLSRLDEL 0x00000031 /* Delete RX classification rule */
  1033. #define ETHTOOL_SRXCLSRLINS 0x00000032 /* Insert RX classification rule */
  1034. #define ETHTOOL_FLASHDEV 0x00000033 /* Flash firmware to device */
  1035. #define ETHTOOL_RESET 0x00000034 /* Reset hardware */
  1036. #define ETHTOOL_SRXNTUPLE 0x00000035 /* Add an n-tuple filter to device */
  1037. #define ETHTOOL_GRXNTUPLE 0x00000036 /* deprecated */
  1038. #define ETHTOOL_GSSET_INFO 0x00000037 /* Get string set info */
  1039. #define ETHTOOL_GRXFHINDIR 0x00000038 /* Get RX flow hash indir'n table */
  1040. #define ETHTOOL_SRXFHINDIR 0x00000039 /* Set RX flow hash indir'n table */
  1041. #define ETHTOOL_GFEATURES 0x0000003a /* Get device offload settings */
  1042. #define ETHTOOL_SFEATURES 0x0000003b /* Change device offload settings */
  1043. #define ETHTOOL_GCHANNELS 0x0000003c /* Get no of channels */
  1044. #define ETHTOOL_SCHANNELS 0x0000003d /* Set no of channels */
  1045. #define ETHTOOL_SET_DUMP 0x0000003e /* Set dump settings */
  1046. #define ETHTOOL_GET_DUMP_FLAG 0x0000003f /* Get dump settings */
  1047. #define ETHTOOL_GET_DUMP_DATA 0x00000040 /* Get dump data */
  1048. #define ETHTOOL_GET_TS_INFO 0x00000041 /* Get time stamping and PHC info */
  1049. #define ETHTOOL_GMODULEINFO 0x00000042 /* Get plug-in module information */
  1050. #define ETHTOOL_GMODULEEEPROM 0x00000043 /* Get plug-in module eeprom */
  1051. #define ETHTOOL_GEEE 0x00000044 /* Get EEE settings */
  1052. #define ETHTOOL_SEEE 0x00000045 /* Set EEE settings */
  1053. /* compatibility with older code */
  1054. #define SPARC_ETH_GSET ETHTOOL_GSET
  1055. #define SPARC_ETH_SSET ETHTOOL_SSET
  1056. /* Indicates what features are supported by the interface. */
  1057. #define SUPPORTED_10baseT_Half (1 << 0)
  1058. #define SUPPORTED_10baseT_Full (1 << 1)
  1059. #define SUPPORTED_100baseT_Half (1 << 2)
  1060. #define SUPPORTED_100baseT_Full (1 << 3)
  1061. #define SUPPORTED_1000baseT_Half (1 << 4)
  1062. #define SUPPORTED_1000baseT_Full (1 << 5)
  1063. #define SUPPORTED_Autoneg (1 << 6)
  1064. #define SUPPORTED_TP (1 << 7)
  1065. #define SUPPORTED_AUI (1 << 8)
  1066. #define SUPPORTED_MII (1 << 9)
  1067. #define SUPPORTED_FIBRE (1 << 10)
  1068. #define SUPPORTED_BNC (1 << 11)
  1069. #define SUPPORTED_10000baseT_Full (1 << 12)
  1070. #define SUPPORTED_Pause (1 << 13)
  1071. #define SUPPORTED_Asym_Pause (1 << 14)
  1072. #define SUPPORTED_2500baseX_Full (1 << 15)
  1073. #define SUPPORTED_Backplane (1 << 16)
  1074. #define SUPPORTED_1000baseKX_Full (1 << 17)
  1075. #define SUPPORTED_10000baseKX4_Full (1 << 18)
  1076. #define SUPPORTED_10000baseKR_Full (1 << 19)
  1077. #define SUPPORTED_10000baseR_FEC (1 << 20)
  1078. #define SUPPORTED_20000baseMLD2_Full (1 << 21)
  1079. #define SUPPORTED_20000baseKR2_Full (1 << 22)
  1080. #define SUPPORTED_40000baseKR4_Full (1 << 23)
  1081. #define SUPPORTED_40000baseCR4_Full (1 << 24)
  1082. #define SUPPORTED_40000baseSR4_Full (1 << 25)
  1083. #define SUPPORTED_40000baseLR4_Full (1 << 26)
  1084. /* Indicates what features are advertised by the interface. */
  1085. #define ADVERTISED_10baseT_Half (1 << 0)
  1086. #define ADVERTISED_10baseT_Full (1 << 1)
  1087. #define ADVERTISED_100baseT_Half (1 << 2)
  1088. #define ADVERTISED_100baseT_Full (1 << 3)
  1089. #define ADVERTISED_1000baseT_Half (1 << 4)
  1090. #define ADVERTISED_1000baseT_Full (1 << 5)
  1091. #define ADVERTISED_Autoneg (1 << 6)
  1092. #define ADVERTISED_TP (1 << 7)
  1093. #define ADVERTISED_AUI (1 << 8)
  1094. #define ADVERTISED_MII (1 << 9)
  1095. #define ADVERTISED_FIBRE (1 << 10)
  1096. #define ADVERTISED_BNC (1 << 11)
  1097. #define ADVERTISED_10000baseT_Full (1 << 12)
  1098. #define ADVERTISED_Pause (1 << 13)
  1099. #define ADVERTISED_Asym_Pause (1 << 14)
  1100. #define ADVERTISED_2500baseX_Full (1 << 15)
  1101. #define ADVERTISED_Backplane (1 << 16)
  1102. #define ADVERTISED_1000baseKX_Full (1 << 17)
  1103. #define ADVERTISED_10000baseKX4_Full (1 << 18)
  1104. #define ADVERTISED_10000baseKR_Full (1 << 19)
  1105. #define ADVERTISED_10000baseR_FEC (1 << 20)
  1106. #define ADVERTISED_20000baseMLD2_Full (1 << 21)
  1107. #define ADVERTISED_20000baseKR2_Full (1 << 22)
  1108. #define ADVERTISED_40000baseKR4_Full (1 << 23)
  1109. #define ADVERTISED_40000baseCR4_Full (1 << 24)
  1110. #define ADVERTISED_40000baseSR4_Full (1 << 25)
  1111. #define ADVERTISED_40000baseLR4_Full (1 << 26)
  1112. /* The following are all involved in forcing a particular link
  1113. * mode for the device for setting things. When getting the
  1114. * devices settings, these indicate the current mode and whether
  1115. * it was forced up into this mode or autonegotiated.
  1116. */
  1117. /* The forced speed, 10Mb, 100Mb, gigabit, 2.5Gb, 10GbE. */
  1118. #define SPEED_10 10
  1119. #define SPEED_100 100
  1120. #define SPEED_1000 1000
  1121. #define SPEED_2500 2500
  1122. #define SPEED_10000 10000
  1123. #define SPEED_UNKNOWN -1
  1124. /* Duplex, half or full. */
  1125. #define DUPLEX_HALF 0x00
  1126. #define DUPLEX_FULL 0x01
  1127. #define DUPLEX_UNKNOWN 0xff
  1128. /* Which connector port. */
  1129. #define PORT_TP 0x00
  1130. #define PORT_AUI 0x01
  1131. #define PORT_MII 0x02
  1132. #define PORT_FIBRE 0x03
  1133. #define PORT_BNC 0x04
  1134. #define PORT_DA 0x05
  1135. #define PORT_NONE 0xef
  1136. #define PORT_OTHER 0xff
  1137. /* Which transceiver to use. */
  1138. #define XCVR_INTERNAL 0x00
  1139. #define XCVR_EXTERNAL 0x01
  1140. #define XCVR_DUMMY1 0x02
  1141. #define XCVR_DUMMY2 0x03
  1142. #define XCVR_DUMMY3 0x04
  1143. /* Enable or disable autonegotiation. If this is set to enable,
  1144. * the forced link modes above are completely ignored.
  1145. */
  1146. #define AUTONEG_DISABLE 0x00
  1147. #define AUTONEG_ENABLE 0x01
  1148. /* MDI or MDI-X status/control - if MDI/MDI_X/AUTO is set then
  1149. * the driver is required to renegotiate link
  1150. */
  1151. #define ETH_TP_MDI_INVALID 0x00 /* status: unknown; control: unsupported */
  1152. #define ETH_TP_MDI 0x01 /* status: MDI; control: force MDI */
  1153. #define ETH_TP_MDI_X 0x02 /* status: MDI-X; control: force MDI-X */
  1154. #define ETH_TP_MDI_AUTO 0x03 /* control: auto-select */
  1155. /* Wake-On-Lan options. */
  1156. #define WAKE_PHY (1 << 0)
  1157. #define WAKE_UCAST (1 << 1)
  1158. #define WAKE_MCAST (1 << 2)
  1159. #define WAKE_BCAST (1 << 3)
  1160. #define WAKE_ARP (1 << 4)
  1161. #define WAKE_MAGIC (1 << 5)
  1162. #define WAKE_MAGICSECURE (1 << 6) /* only meaningful if WAKE_MAGIC */
  1163. /* L2-L4 network traffic flow types */
  1164. #define TCP_V4_FLOW 0x01 /* hash or spec (tcp_ip4_spec) */
  1165. #define UDP_V4_FLOW 0x02 /* hash or spec (udp_ip4_spec) */
  1166. #define SCTP_V4_FLOW 0x03 /* hash or spec (sctp_ip4_spec) */
  1167. #define AH_ESP_V4_FLOW 0x04 /* hash only */
  1168. #define TCP_V6_FLOW 0x05 /* hash only */
  1169. #define UDP_V6_FLOW 0x06 /* hash only */
  1170. #define SCTP_V6_FLOW 0x07 /* hash only */
  1171. #define AH_ESP_V6_FLOW 0x08 /* hash only */
  1172. #define AH_V4_FLOW 0x09 /* hash or spec (ah_ip4_spec) */
  1173. #define ESP_V4_FLOW 0x0a /* hash or spec (esp_ip4_spec) */
  1174. #define AH_V6_FLOW 0x0b /* hash only */
  1175. #define ESP_V6_FLOW 0x0c /* hash only */
  1176. #define IP_USER_FLOW 0x0d /* spec only (usr_ip4_spec) */
  1177. #define IPV4_FLOW 0x10 /* hash only */
  1178. #define IPV6_FLOW 0x11 /* hash only */
  1179. #define ETHER_FLOW 0x12 /* spec only (ether_spec) */
  1180. /* Flag to enable additional fields in struct ethtool_rx_flow_spec */
  1181. #define FLOW_EXT 0x80000000
  1182. /* L3-L4 network traffic flow hash options */
  1183. #define RXH_L2DA (1 << 1)
  1184. #define RXH_VLAN (1 << 2)
  1185. #define RXH_L3_PROTO (1 << 3)
  1186. #define RXH_IP_SRC (1 << 4)
  1187. #define RXH_IP_DST (1 << 5)
  1188. #define RXH_L4_B_0_1 (1 << 6) /* src port in case of TCP/UDP/SCTP */
  1189. #define RXH_L4_B_2_3 (1 << 7) /* dst port in case of TCP/UDP/SCTP */
  1190. #define RXH_DISCARD (1 << 31)
  1191. #define RX_CLS_FLOW_DISC 0xffffffffffffffffULL
  1192. /* Special RX classification rule insert location values */
  1193. #define RX_CLS_LOC_SPECIAL 0x80000000 /* flag */
  1194. #define RX_CLS_LOC_ANY 0xffffffff
  1195. #define RX_CLS_LOC_FIRST 0xfffffffe
  1196. #define RX_CLS_LOC_LAST 0xfffffffd
  1197. /* EEPROM Standards for plug in modules */
  1198. #define ETH_MODULE_SFF_8079 0x1
  1199. #define ETH_MODULE_SFF_8079_LEN 256
  1200. #define ETH_MODULE_SFF_8472 0x2
  1201. #define ETH_MODULE_SFF_8472_LEN 512
  1202. /* Reset flags */
  1203. /* The reset() operation must clear the flags for the components which
  1204. * were actually reset. On successful return, the flags indicate the
  1205. * components which were not reset, either because they do not exist
  1206. * in the hardware or because they cannot be reset independently. The
  1207. * driver must never reset any components that were not requested.
  1208. */
  1209. enum ethtool_reset_flags {
  1210. /* These flags represent components dedicated to the interface
  1211. * the command is addressed to. Shift any flag left by
  1212. * ETH_RESET_SHARED_SHIFT to reset a shared component of the
  1213. * same type.
  1214. */
  1215. ETH_RESET_MGMT = 1 << 0, /* Management processor */
  1216. ETH_RESET_IRQ = 1 << 1, /* Interrupt requester */
  1217. ETH_RESET_DMA = 1 << 2, /* DMA engine */
  1218. ETH_RESET_FILTER = 1 << 3, /* Filtering/flow direction */
  1219. ETH_RESET_OFFLOAD = 1 << 4, /* Protocol offload */
  1220. ETH_RESET_MAC = 1 << 5, /* Media access controller */
  1221. ETH_RESET_PHY = 1 << 6, /* Transceiver/PHY */
  1222. ETH_RESET_RAM = 1 << 7, /* RAM shared between
  1223. * multiple components */
  1224. ETH_RESET_DEDICATED = 0x0000ffff, /* All components dedicated to
  1225. * this interface */
  1226. ETH_RESET_ALL = 0xffffffff, /* All components used by this
  1227. * interface, even if shared */
  1228. };
  1229. #define ETH_RESET_SHARED_SHIFT 16
  1230. #endif /* _LINUX_ETHTOOL_H */