ethtool.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124
  1. /****************************************************************************
  2. * Driver for Solarflare Solarstorm network controllers and boards
  3. * Copyright 2005-2006 Fen Systems Ltd.
  4. * Copyright 2006-2010 Solarflare Communications Inc.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License version 2 as published
  8. * by the Free Software Foundation, incorporated herein by reference.
  9. */
  10. #include <linux/netdevice.h>
  11. #include <linux/ethtool.h>
  12. #include <linux/rtnetlink.h>
  13. #include <linux/in.h>
  14. #include "net_driver.h"
  15. #include "workarounds.h"
  16. #include "selftest.h"
  17. #include "efx.h"
  18. #include "filter.h"
  19. #include "nic.h"
  20. struct ethtool_string {
  21. char name[ETH_GSTRING_LEN];
  22. };
  23. struct efx_ethtool_stat {
  24. const char *name;
  25. enum {
  26. EFX_ETHTOOL_STAT_SOURCE_mac_stats,
  27. EFX_ETHTOOL_STAT_SOURCE_nic,
  28. EFX_ETHTOOL_STAT_SOURCE_channel,
  29. EFX_ETHTOOL_STAT_SOURCE_tx_queue
  30. } source;
  31. unsigned offset;
  32. u64(*get_stat) (void *field); /* Reader function */
  33. };
  34. /* Initialiser for a struct #efx_ethtool_stat with type-checking */
  35. #define EFX_ETHTOOL_STAT(stat_name, source_name, field, field_type, \
  36. get_stat_function) { \
  37. .name = #stat_name, \
  38. .source = EFX_ETHTOOL_STAT_SOURCE_##source_name, \
  39. .offset = ((((field_type *) 0) == \
  40. &((struct efx_##source_name *)0)->field) ? \
  41. offsetof(struct efx_##source_name, field) : \
  42. offsetof(struct efx_##source_name, field)), \
  43. .get_stat = get_stat_function, \
  44. }
  45. static u64 efx_get_uint_stat(void *field)
  46. {
  47. return *(unsigned int *)field;
  48. }
  49. static u64 efx_get_ulong_stat(void *field)
  50. {
  51. return *(unsigned long *)field;
  52. }
  53. static u64 efx_get_u64_stat(void *field)
  54. {
  55. return *(u64 *) field;
  56. }
  57. static u64 efx_get_atomic_stat(void *field)
  58. {
  59. return atomic_read((atomic_t *) field);
  60. }
  61. #define EFX_ETHTOOL_ULONG_MAC_STAT(field) \
  62. EFX_ETHTOOL_STAT(field, mac_stats, field, \
  63. unsigned long, efx_get_ulong_stat)
  64. #define EFX_ETHTOOL_U64_MAC_STAT(field) \
  65. EFX_ETHTOOL_STAT(field, mac_stats, field, \
  66. u64, efx_get_u64_stat)
  67. #define EFX_ETHTOOL_UINT_NIC_STAT(name) \
  68. EFX_ETHTOOL_STAT(name, nic, n_##name, \
  69. unsigned int, efx_get_uint_stat)
  70. #define EFX_ETHTOOL_ATOMIC_NIC_ERROR_STAT(field) \
  71. EFX_ETHTOOL_STAT(field, nic, field, \
  72. atomic_t, efx_get_atomic_stat)
  73. #define EFX_ETHTOOL_UINT_CHANNEL_STAT(field) \
  74. EFX_ETHTOOL_STAT(field, channel, n_##field, \
  75. unsigned int, efx_get_uint_stat)
  76. #define EFX_ETHTOOL_UINT_TXQ_STAT(field) \
  77. EFX_ETHTOOL_STAT(tx_##field, tx_queue, field, \
  78. unsigned int, efx_get_uint_stat)
  79. static struct efx_ethtool_stat efx_ethtool_stats[] = {
  80. EFX_ETHTOOL_U64_MAC_STAT(tx_bytes),
  81. EFX_ETHTOOL_U64_MAC_STAT(tx_good_bytes),
  82. EFX_ETHTOOL_U64_MAC_STAT(tx_bad_bytes),
  83. EFX_ETHTOOL_ULONG_MAC_STAT(tx_packets),
  84. EFX_ETHTOOL_ULONG_MAC_STAT(tx_bad),
  85. EFX_ETHTOOL_ULONG_MAC_STAT(tx_pause),
  86. EFX_ETHTOOL_ULONG_MAC_STAT(tx_control),
  87. EFX_ETHTOOL_ULONG_MAC_STAT(tx_unicast),
  88. EFX_ETHTOOL_ULONG_MAC_STAT(tx_multicast),
  89. EFX_ETHTOOL_ULONG_MAC_STAT(tx_broadcast),
  90. EFX_ETHTOOL_ULONG_MAC_STAT(tx_lt64),
  91. EFX_ETHTOOL_ULONG_MAC_STAT(tx_64),
  92. EFX_ETHTOOL_ULONG_MAC_STAT(tx_65_to_127),
  93. EFX_ETHTOOL_ULONG_MAC_STAT(tx_128_to_255),
  94. EFX_ETHTOOL_ULONG_MAC_STAT(tx_256_to_511),
  95. EFX_ETHTOOL_ULONG_MAC_STAT(tx_512_to_1023),
  96. EFX_ETHTOOL_ULONG_MAC_STAT(tx_1024_to_15xx),
  97. EFX_ETHTOOL_ULONG_MAC_STAT(tx_15xx_to_jumbo),
  98. EFX_ETHTOOL_ULONG_MAC_STAT(tx_gtjumbo),
  99. EFX_ETHTOOL_ULONG_MAC_STAT(tx_collision),
  100. EFX_ETHTOOL_ULONG_MAC_STAT(tx_single_collision),
  101. EFX_ETHTOOL_ULONG_MAC_STAT(tx_multiple_collision),
  102. EFX_ETHTOOL_ULONG_MAC_STAT(tx_excessive_collision),
  103. EFX_ETHTOOL_ULONG_MAC_STAT(tx_deferred),
  104. EFX_ETHTOOL_ULONG_MAC_STAT(tx_late_collision),
  105. EFX_ETHTOOL_ULONG_MAC_STAT(tx_excessive_deferred),
  106. EFX_ETHTOOL_ULONG_MAC_STAT(tx_non_tcpudp),
  107. EFX_ETHTOOL_ULONG_MAC_STAT(tx_mac_src_error),
  108. EFX_ETHTOOL_ULONG_MAC_STAT(tx_ip_src_error),
  109. EFX_ETHTOOL_UINT_TXQ_STAT(tso_bursts),
  110. EFX_ETHTOOL_UINT_TXQ_STAT(tso_long_headers),
  111. EFX_ETHTOOL_UINT_TXQ_STAT(tso_packets),
  112. EFX_ETHTOOL_UINT_TXQ_STAT(pushes),
  113. EFX_ETHTOOL_U64_MAC_STAT(rx_bytes),
  114. EFX_ETHTOOL_U64_MAC_STAT(rx_good_bytes),
  115. EFX_ETHTOOL_U64_MAC_STAT(rx_bad_bytes),
  116. EFX_ETHTOOL_ULONG_MAC_STAT(rx_packets),
  117. EFX_ETHTOOL_ULONG_MAC_STAT(rx_good),
  118. EFX_ETHTOOL_ULONG_MAC_STAT(rx_bad),
  119. EFX_ETHTOOL_ULONG_MAC_STAT(rx_pause),
  120. EFX_ETHTOOL_ULONG_MAC_STAT(rx_control),
  121. EFX_ETHTOOL_ULONG_MAC_STAT(rx_unicast),
  122. EFX_ETHTOOL_ULONG_MAC_STAT(rx_multicast),
  123. EFX_ETHTOOL_ULONG_MAC_STAT(rx_broadcast),
  124. EFX_ETHTOOL_ULONG_MAC_STAT(rx_lt64),
  125. EFX_ETHTOOL_ULONG_MAC_STAT(rx_64),
  126. EFX_ETHTOOL_ULONG_MAC_STAT(rx_65_to_127),
  127. EFX_ETHTOOL_ULONG_MAC_STAT(rx_128_to_255),
  128. EFX_ETHTOOL_ULONG_MAC_STAT(rx_256_to_511),
  129. EFX_ETHTOOL_ULONG_MAC_STAT(rx_512_to_1023),
  130. EFX_ETHTOOL_ULONG_MAC_STAT(rx_1024_to_15xx),
  131. EFX_ETHTOOL_ULONG_MAC_STAT(rx_15xx_to_jumbo),
  132. EFX_ETHTOOL_ULONG_MAC_STAT(rx_gtjumbo),
  133. EFX_ETHTOOL_ULONG_MAC_STAT(rx_bad_lt64),
  134. EFX_ETHTOOL_ULONG_MAC_STAT(rx_bad_64_to_15xx),
  135. EFX_ETHTOOL_ULONG_MAC_STAT(rx_bad_15xx_to_jumbo),
  136. EFX_ETHTOOL_ULONG_MAC_STAT(rx_bad_gtjumbo),
  137. EFX_ETHTOOL_ULONG_MAC_STAT(rx_overflow),
  138. EFX_ETHTOOL_ULONG_MAC_STAT(rx_missed),
  139. EFX_ETHTOOL_ULONG_MAC_STAT(rx_false_carrier),
  140. EFX_ETHTOOL_ULONG_MAC_STAT(rx_symbol_error),
  141. EFX_ETHTOOL_ULONG_MAC_STAT(rx_align_error),
  142. EFX_ETHTOOL_ULONG_MAC_STAT(rx_length_error),
  143. EFX_ETHTOOL_ULONG_MAC_STAT(rx_internal_error),
  144. EFX_ETHTOOL_UINT_NIC_STAT(rx_nodesc_drop_cnt),
  145. EFX_ETHTOOL_ATOMIC_NIC_ERROR_STAT(rx_reset),
  146. EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_tobe_disc),
  147. EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_ip_hdr_chksum_err),
  148. EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_tcp_udp_chksum_err),
  149. EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_mcast_mismatch),
  150. EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_frm_trunc),
  151. };
  152. /* Number of ethtool statistics */
  153. #define EFX_ETHTOOL_NUM_STATS ARRAY_SIZE(efx_ethtool_stats)
  154. #define EFX_ETHTOOL_EEPROM_MAGIC 0xEFAB
  155. /**************************************************************************
  156. *
  157. * Ethtool operations
  158. *
  159. **************************************************************************
  160. */
  161. /* Identify device by flashing LEDs */
  162. static int efx_ethtool_phys_id(struct net_device *net_dev,
  163. enum ethtool_phys_id_state state)
  164. {
  165. struct efx_nic *efx = netdev_priv(net_dev);
  166. enum efx_led_mode mode = EFX_LED_DEFAULT;
  167. switch (state) {
  168. case ETHTOOL_ID_ON:
  169. mode = EFX_LED_ON;
  170. break;
  171. case ETHTOOL_ID_OFF:
  172. mode = EFX_LED_OFF;
  173. break;
  174. case ETHTOOL_ID_INACTIVE:
  175. mode = EFX_LED_DEFAULT;
  176. break;
  177. case ETHTOOL_ID_ACTIVE:
  178. return 1; /* cycle on/off once per second */
  179. }
  180. efx->type->set_id_led(efx, mode);
  181. return 0;
  182. }
  183. /* This must be called with rtnl_lock held. */
  184. static int efx_ethtool_get_settings(struct net_device *net_dev,
  185. struct ethtool_cmd *ecmd)
  186. {
  187. struct efx_nic *efx = netdev_priv(net_dev);
  188. struct efx_link_state *link_state = &efx->link_state;
  189. mutex_lock(&efx->mac_lock);
  190. efx->phy_op->get_settings(efx, ecmd);
  191. mutex_unlock(&efx->mac_lock);
  192. /* GMAC does not support 1000Mbps HD */
  193. ecmd->supported &= ~SUPPORTED_1000baseT_Half;
  194. /* Both MACs support pause frames (bidirectional and respond-only) */
  195. ecmd->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
  196. if (LOOPBACK_INTERNAL(efx)) {
  197. ethtool_cmd_speed_set(ecmd, link_state->speed);
  198. ecmd->duplex = link_state->fd ? DUPLEX_FULL : DUPLEX_HALF;
  199. }
  200. return 0;
  201. }
  202. /* This must be called with rtnl_lock held. */
  203. static int efx_ethtool_set_settings(struct net_device *net_dev,
  204. struct ethtool_cmd *ecmd)
  205. {
  206. struct efx_nic *efx = netdev_priv(net_dev);
  207. int rc;
  208. /* GMAC does not support 1000Mbps HD */
  209. if ((ethtool_cmd_speed(ecmd) == SPEED_1000) &&
  210. (ecmd->duplex != DUPLEX_FULL)) {
  211. netif_dbg(efx, drv, efx->net_dev,
  212. "rejecting unsupported 1000Mbps HD setting\n");
  213. return -EINVAL;
  214. }
  215. mutex_lock(&efx->mac_lock);
  216. rc = efx->phy_op->set_settings(efx, ecmd);
  217. mutex_unlock(&efx->mac_lock);
  218. return rc;
  219. }
  220. static void efx_ethtool_get_drvinfo(struct net_device *net_dev,
  221. struct ethtool_drvinfo *info)
  222. {
  223. struct efx_nic *efx = netdev_priv(net_dev);
  224. strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
  225. strlcpy(info->version, EFX_DRIVER_VERSION, sizeof(info->version));
  226. if (efx_nic_rev(efx) >= EFX_REV_SIENA_A0)
  227. efx_mcdi_print_fwver(efx, info->fw_version,
  228. sizeof(info->fw_version));
  229. strlcpy(info->bus_info, pci_name(efx->pci_dev), sizeof(info->bus_info));
  230. }
  231. static int efx_ethtool_get_regs_len(struct net_device *net_dev)
  232. {
  233. return efx_nic_get_regs_len(netdev_priv(net_dev));
  234. }
  235. static void efx_ethtool_get_regs(struct net_device *net_dev,
  236. struct ethtool_regs *regs, void *buf)
  237. {
  238. struct efx_nic *efx = netdev_priv(net_dev);
  239. regs->version = efx->type->revision;
  240. efx_nic_get_regs(efx, buf);
  241. }
  242. static u32 efx_ethtool_get_msglevel(struct net_device *net_dev)
  243. {
  244. struct efx_nic *efx = netdev_priv(net_dev);
  245. return efx->msg_enable;
  246. }
  247. static void efx_ethtool_set_msglevel(struct net_device *net_dev, u32 msg_enable)
  248. {
  249. struct efx_nic *efx = netdev_priv(net_dev);
  250. efx->msg_enable = msg_enable;
  251. }
  252. /**
  253. * efx_fill_test - fill in an individual self-test entry
  254. * @test_index: Index of the test
  255. * @strings: Ethtool strings, or %NULL
  256. * @data: Ethtool test results, or %NULL
  257. * @test: Pointer to test result (used only if data != %NULL)
  258. * @unit_format: Unit name format (e.g. "chan\%d")
  259. * @unit_id: Unit id (e.g. 0 for "chan0")
  260. * @test_format: Test name format (e.g. "loopback.\%s.tx.sent")
  261. * @test_id: Test id (e.g. "PHYXS" for "loopback.PHYXS.tx_sent")
  262. *
  263. * Fill in an individual self-test entry.
  264. */
  265. static void efx_fill_test(unsigned int test_index,
  266. struct ethtool_string *strings, u64 *data,
  267. int *test, const char *unit_format, int unit_id,
  268. const char *test_format, const char *test_id)
  269. {
  270. struct ethtool_string unit_str, test_str;
  271. /* Fill data value, if applicable */
  272. if (data)
  273. data[test_index] = *test;
  274. /* Fill string, if applicable */
  275. if (strings) {
  276. if (strchr(unit_format, '%'))
  277. snprintf(unit_str.name, sizeof(unit_str.name),
  278. unit_format, unit_id);
  279. else
  280. strcpy(unit_str.name, unit_format);
  281. snprintf(test_str.name, sizeof(test_str.name),
  282. test_format, test_id);
  283. snprintf(strings[test_index].name,
  284. sizeof(strings[test_index].name),
  285. "%-6s %-24s", unit_str.name, test_str.name);
  286. }
  287. }
  288. #define EFX_CHANNEL_NAME(_channel) "chan%d", _channel->channel
  289. #define EFX_TX_QUEUE_NAME(_tx_queue) "txq%d", _tx_queue->queue
  290. #define EFX_RX_QUEUE_NAME(_rx_queue) "rxq%d", _rx_queue->queue
  291. #define EFX_LOOPBACK_NAME(_mode, _counter) \
  292. "loopback.%s." _counter, STRING_TABLE_LOOKUP(_mode, efx_loopback_mode)
  293. /**
  294. * efx_fill_loopback_test - fill in a block of loopback self-test entries
  295. * @efx: Efx NIC
  296. * @lb_tests: Efx loopback self-test results structure
  297. * @mode: Loopback test mode
  298. * @test_index: Starting index of the test
  299. * @strings: Ethtool strings, or %NULL
  300. * @data: Ethtool test results, or %NULL
  301. */
  302. static int efx_fill_loopback_test(struct efx_nic *efx,
  303. struct efx_loopback_self_tests *lb_tests,
  304. enum efx_loopback_mode mode,
  305. unsigned int test_index,
  306. struct ethtool_string *strings, u64 *data)
  307. {
  308. struct efx_channel *channel = efx_get_channel(efx, 0);
  309. struct efx_tx_queue *tx_queue;
  310. efx_for_each_channel_tx_queue(tx_queue, channel) {
  311. efx_fill_test(test_index++, strings, data,
  312. &lb_tests->tx_sent[tx_queue->queue],
  313. EFX_TX_QUEUE_NAME(tx_queue),
  314. EFX_LOOPBACK_NAME(mode, "tx_sent"));
  315. efx_fill_test(test_index++, strings, data,
  316. &lb_tests->tx_done[tx_queue->queue],
  317. EFX_TX_QUEUE_NAME(tx_queue),
  318. EFX_LOOPBACK_NAME(mode, "tx_done"));
  319. }
  320. efx_fill_test(test_index++, strings, data,
  321. &lb_tests->rx_good,
  322. "rx", 0,
  323. EFX_LOOPBACK_NAME(mode, "rx_good"));
  324. efx_fill_test(test_index++, strings, data,
  325. &lb_tests->rx_bad,
  326. "rx", 0,
  327. EFX_LOOPBACK_NAME(mode, "rx_bad"));
  328. return test_index;
  329. }
  330. /**
  331. * efx_ethtool_fill_self_tests - get self-test details
  332. * @efx: Efx NIC
  333. * @tests: Efx self-test results structure, or %NULL
  334. * @strings: Ethtool strings, or %NULL
  335. * @data: Ethtool test results, or %NULL
  336. */
  337. static int efx_ethtool_fill_self_tests(struct efx_nic *efx,
  338. struct efx_self_tests *tests,
  339. struct ethtool_string *strings,
  340. u64 *data)
  341. {
  342. struct efx_channel *channel;
  343. unsigned int n = 0, i;
  344. enum efx_loopback_mode mode;
  345. efx_fill_test(n++, strings, data, &tests->phy_alive,
  346. "phy", 0, "alive", NULL);
  347. efx_fill_test(n++, strings, data, &tests->nvram,
  348. "core", 0, "nvram", NULL);
  349. efx_fill_test(n++, strings, data, &tests->interrupt,
  350. "core", 0, "interrupt", NULL);
  351. /* Event queues */
  352. efx_for_each_channel(channel, efx) {
  353. efx_fill_test(n++, strings, data,
  354. &tests->eventq_dma[channel->channel],
  355. EFX_CHANNEL_NAME(channel),
  356. "eventq.dma", NULL);
  357. efx_fill_test(n++, strings, data,
  358. &tests->eventq_int[channel->channel],
  359. EFX_CHANNEL_NAME(channel),
  360. "eventq.int", NULL);
  361. efx_fill_test(n++, strings, data,
  362. &tests->eventq_poll[channel->channel],
  363. EFX_CHANNEL_NAME(channel),
  364. "eventq.poll", NULL);
  365. }
  366. efx_fill_test(n++, strings, data, &tests->registers,
  367. "core", 0, "registers", NULL);
  368. if (efx->phy_op->run_tests != NULL) {
  369. EFX_BUG_ON_PARANOID(efx->phy_op->test_name == NULL);
  370. for (i = 0; true; ++i) {
  371. const char *name;
  372. EFX_BUG_ON_PARANOID(i >= EFX_MAX_PHY_TESTS);
  373. name = efx->phy_op->test_name(efx, i);
  374. if (name == NULL)
  375. break;
  376. efx_fill_test(n++, strings, data, &tests->phy_ext[i],
  377. "phy", 0, name, NULL);
  378. }
  379. }
  380. /* Loopback tests */
  381. for (mode = LOOPBACK_NONE; mode <= LOOPBACK_TEST_MAX; mode++) {
  382. if (!(efx->loopback_modes & (1 << mode)))
  383. continue;
  384. n = efx_fill_loopback_test(efx,
  385. &tests->loopback[mode], mode, n,
  386. strings, data);
  387. }
  388. return n;
  389. }
  390. static int efx_ethtool_get_sset_count(struct net_device *net_dev,
  391. int string_set)
  392. {
  393. switch (string_set) {
  394. case ETH_SS_STATS:
  395. return EFX_ETHTOOL_NUM_STATS;
  396. case ETH_SS_TEST:
  397. return efx_ethtool_fill_self_tests(netdev_priv(net_dev),
  398. NULL, NULL, NULL);
  399. default:
  400. return -EINVAL;
  401. }
  402. }
  403. static void efx_ethtool_get_strings(struct net_device *net_dev,
  404. u32 string_set, u8 *strings)
  405. {
  406. struct efx_nic *efx = netdev_priv(net_dev);
  407. struct ethtool_string *ethtool_strings =
  408. (struct ethtool_string *)strings;
  409. int i;
  410. switch (string_set) {
  411. case ETH_SS_STATS:
  412. for (i = 0; i < EFX_ETHTOOL_NUM_STATS; i++)
  413. strncpy(ethtool_strings[i].name,
  414. efx_ethtool_stats[i].name,
  415. sizeof(ethtool_strings[i].name));
  416. break;
  417. case ETH_SS_TEST:
  418. efx_ethtool_fill_self_tests(efx, NULL,
  419. ethtool_strings, NULL);
  420. break;
  421. default:
  422. /* No other string sets */
  423. break;
  424. }
  425. }
  426. static void efx_ethtool_get_stats(struct net_device *net_dev,
  427. struct ethtool_stats *stats,
  428. u64 *data)
  429. {
  430. struct efx_nic *efx = netdev_priv(net_dev);
  431. struct efx_mac_stats *mac_stats = &efx->mac_stats;
  432. struct efx_ethtool_stat *stat;
  433. struct efx_channel *channel;
  434. struct efx_tx_queue *tx_queue;
  435. struct rtnl_link_stats64 temp;
  436. int i;
  437. EFX_BUG_ON_PARANOID(stats->n_stats != EFX_ETHTOOL_NUM_STATS);
  438. /* Update MAC and NIC statistics */
  439. dev_get_stats(net_dev, &temp);
  440. /* Fill detailed statistics buffer */
  441. for (i = 0; i < EFX_ETHTOOL_NUM_STATS; i++) {
  442. stat = &efx_ethtool_stats[i];
  443. switch (stat->source) {
  444. case EFX_ETHTOOL_STAT_SOURCE_mac_stats:
  445. data[i] = stat->get_stat((void *)mac_stats +
  446. stat->offset);
  447. break;
  448. case EFX_ETHTOOL_STAT_SOURCE_nic:
  449. data[i] = stat->get_stat((void *)efx + stat->offset);
  450. break;
  451. case EFX_ETHTOOL_STAT_SOURCE_channel:
  452. data[i] = 0;
  453. efx_for_each_channel(channel, efx)
  454. data[i] += stat->get_stat((void *)channel +
  455. stat->offset);
  456. break;
  457. case EFX_ETHTOOL_STAT_SOURCE_tx_queue:
  458. data[i] = 0;
  459. efx_for_each_channel(channel, efx) {
  460. efx_for_each_channel_tx_queue(tx_queue, channel)
  461. data[i] +=
  462. stat->get_stat((void *)tx_queue
  463. + stat->offset);
  464. }
  465. break;
  466. }
  467. }
  468. }
  469. static void efx_ethtool_self_test(struct net_device *net_dev,
  470. struct ethtool_test *test, u64 *data)
  471. {
  472. struct efx_nic *efx = netdev_priv(net_dev);
  473. struct efx_self_tests *efx_tests;
  474. int already_up;
  475. int rc = -ENOMEM;
  476. efx_tests = kzalloc(sizeof(*efx_tests), GFP_KERNEL);
  477. if (!efx_tests)
  478. goto fail;
  479. ASSERT_RTNL();
  480. if (efx->state != STATE_RUNNING) {
  481. rc = -EIO;
  482. goto fail1;
  483. }
  484. netif_info(efx, drv, efx->net_dev, "starting %sline testing\n",
  485. (test->flags & ETH_TEST_FL_OFFLINE) ? "off" : "on");
  486. /* We need rx buffers and interrupts. */
  487. already_up = (efx->net_dev->flags & IFF_UP);
  488. if (!already_up) {
  489. rc = dev_open(efx->net_dev);
  490. if (rc) {
  491. netif_err(efx, drv, efx->net_dev,
  492. "failed opening device.\n");
  493. goto fail1;
  494. }
  495. }
  496. rc = efx_selftest(efx, efx_tests, test->flags);
  497. if (!already_up)
  498. dev_close(efx->net_dev);
  499. netif_info(efx, drv, efx->net_dev, "%s %sline self-tests\n",
  500. rc == 0 ? "passed" : "failed",
  501. (test->flags & ETH_TEST_FL_OFFLINE) ? "off" : "on");
  502. fail1:
  503. /* Fill ethtool results structures */
  504. efx_ethtool_fill_self_tests(efx, efx_tests, NULL, data);
  505. kfree(efx_tests);
  506. fail:
  507. if (rc)
  508. test->flags |= ETH_TEST_FL_FAILED;
  509. }
  510. /* Restart autonegotiation */
  511. static int efx_ethtool_nway_reset(struct net_device *net_dev)
  512. {
  513. struct efx_nic *efx = netdev_priv(net_dev);
  514. return mdio45_nway_restart(&efx->mdio);
  515. }
  516. /*
  517. * Each channel has a single IRQ and moderation timer, started by any
  518. * completion (or other event). Unless the module parameter
  519. * separate_tx_channels is set, IRQs and moderation are therefore
  520. * shared between RX and TX completions. In this case, when RX IRQ
  521. * moderation is explicitly changed then TX IRQ moderation is
  522. * automatically changed too, but otherwise we fail if the two values
  523. * are requested to be different.
  524. *
  525. * The hardware does not support a limit on the number of completions
  526. * before an IRQ, so we do not use the max_frames fields. We should
  527. * report and require that max_frames == (usecs != 0), but this would
  528. * invalidate existing user documentation.
  529. *
  530. * The hardware does not have distinct settings for interrupt
  531. * moderation while the previous IRQ is being handled, so we should
  532. * not use the 'irq' fields. However, an earlier developer
  533. * misunderstood the meaning of the 'irq' fields and the driver did
  534. * not support the standard fields. To avoid invalidating existing
  535. * user documentation, we report and accept changes through either the
  536. * standard or 'irq' fields. If both are changed at the same time, we
  537. * prefer the standard field.
  538. *
  539. * We implement adaptive IRQ moderation, but use a different algorithm
  540. * from that assumed in the definition of struct ethtool_coalesce.
  541. * Therefore we do not use any of the adaptive moderation parameters
  542. * in it.
  543. */
  544. static int efx_ethtool_get_coalesce(struct net_device *net_dev,
  545. struct ethtool_coalesce *coalesce)
  546. {
  547. struct efx_nic *efx = netdev_priv(net_dev);
  548. unsigned int tx_usecs, rx_usecs;
  549. bool rx_adaptive;
  550. efx_get_irq_moderation(efx, &tx_usecs, &rx_usecs, &rx_adaptive);
  551. coalesce->tx_coalesce_usecs = tx_usecs;
  552. coalesce->tx_coalesce_usecs_irq = tx_usecs;
  553. coalesce->rx_coalesce_usecs = rx_usecs;
  554. coalesce->rx_coalesce_usecs_irq = rx_usecs;
  555. coalesce->use_adaptive_rx_coalesce = rx_adaptive;
  556. return 0;
  557. }
  558. static int efx_ethtool_set_coalesce(struct net_device *net_dev,
  559. struct ethtool_coalesce *coalesce)
  560. {
  561. struct efx_nic *efx = netdev_priv(net_dev);
  562. struct efx_channel *channel;
  563. unsigned int tx_usecs, rx_usecs;
  564. bool adaptive, rx_may_override_tx;
  565. int rc;
  566. if (coalesce->use_adaptive_tx_coalesce)
  567. return -EINVAL;
  568. efx_get_irq_moderation(efx, &tx_usecs, &rx_usecs, &adaptive);
  569. if (coalesce->rx_coalesce_usecs != rx_usecs)
  570. rx_usecs = coalesce->rx_coalesce_usecs;
  571. else
  572. rx_usecs = coalesce->rx_coalesce_usecs_irq;
  573. adaptive = coalesce->use_adaptive_rx_coalesce;
  574. /* If channels are shared, TX IRQ moderation can be quietly
  575. * overridden unless it is changed from its old value.
  576. */
  577. rx_may_override_tx = (coalesce->tx_coalesce_usecs == tx_usecs &&
  578. coalesce->tx_coalesce_usecs_irq == tx_usecs);
  579. if (coalesce->tx_coalesce_usecs != tx_usecs)
  580. tx_usecs = coalesce->tx_coalesce_usecs;
  581. else
  582. tx_usecs = coalesce->tx_coalesce_usecs_irq;
  583. rc = efx_init_irq_moderation(efx, tx_usecs, rx_usecs, adaptive,
  584. rx_may_override_tx);
  585. if (rc != 0)
  586. return rc;
  587. efx_for_each_channel(channel, efx)
  588. efx->type->push_irq_moderation(channel);
  589. return 0;
  590. }
  591. static void efx_ethtool_get_ringparam(struct net_device *net_dev,
  592. struct ethtool_ringparam *ring)
  593. {
  594. struct efx_nic *efx = netdev_priv(net_dev);
  595. ring->rx_max_pending = EFX_MAX_DMAQ_SIZE;
  596. ring->tx_max_pending = EFX_MAX_DMAQ_SIZE;
  597. ring->rx_pending = efx->rxq_entries;
  598. ring->tx_pending = efx->txq_entries;
  599. }
  600. static int efx_ethtool_set_ringparam(struct net_device *net_dev,
  601. struct ethtool_ringparam *ring)
  602. {
  603. struct efx_nic *efx = netdev_priv(net_dev);
  604. if (ring->rx_mini_pending || ring->rx_jumbo_pending ||
  605. ring->rx_pending > EFX_MAX_DMAQ_SIZE ||
  606. ring->tx_pending > EFX_MAX_DMAQ_SIZE)
  607. return -EINVAL;
  608. if (ring->rx_pending < EFX_MIN_RING_SIZE ||
  609. ring->tx_pending < EFX_MIN_RING_SIZE) {
  610. netif_err(efx, drv, efx->net_dev,
  611. "TX and RX queues cannot be smaller than %ld\n",
  612. EFX_MIN_RING_SIZE);
  613. return -EINVAL;
  614. }
  615. return efx_realloc_channels(efx, ring->rx_pending, ring->tx_pending);
  616. }
  617. static int efx_ethtool_set_pauseparam(struct net_device *net_dev,
  618. struct ethtool_pauseparam *pause)
  619. {
  620. struct efx_nic *efx = netdev_priv(net_dev);
  621. u8 wanted_fc, old_fc;
  622. u32 old_adv;
  623. bool reset;
  624. int rc = 0;
  625. mutex_lock(&efx->mac_lock);
  626. wanted_fc = ((pause->rx_pause ? EFX_FC_RX : 0) |
  627. (pause->tx_pause ? EFX_FC_TX : 0) |
  628. (pause->autoneg ? EFX_FC_AUTO : 0));
  629. if ((wanted_fc & EFX_FC_TX) && !(wanted_fc & EFX_FC_RX)) {
  630. netif_dbg(efx, drv, efx->net_dev,
  631. "Flow control unsupported: tx ON rx OFF\n");
  632. rc = -EINVAL;
  633. goto out;
  634. }
  635. if ((wanted_fc & EFX_FC_AUTO) && !efx->link_advertising) {
  636. netif_dbg(efx, drv, efx->net_dev,
  637. "Autonegotiation is disabled\n");
  638. rc = -EINVAL;
  639. goto out;
  640. }
  641. /* TX flow control may automatically turn itself off if the
  642. * link partner (intermittently) stops responding to pause
  643. * frames. There isn't any indication that this has happened,
  644. * so the best we do is leave it up to the user to spot this
  645. * and fix it be cycling transmit flow control on this end. */
  646. reset = (wanted_fc & EFX_FC_TX) && !(efx->wanted_fc & EFX_FC_TX);
  647. if (EFX_WORKAROUND_11482(efx) && reset) {
  648. if (efx_nic_rev(efx) == EFX_REV_FALCON_B0) {
  649. /* Recover by resetting the EM block */
  650. falcon_stop_nic_stats(efx);
  651. falcon_drain_tx_fifo(efx);
  652. efx->mac_op->reconfigure(efx);
  653. falcon_start_nic_stats(efx);
  654. } else {
  655. /* Schedule a reset to recover */
  656. efx_schedule_reset(efx, RESET_TYPE_INVISIBLE);
  657. }
  658. }
  659. old_adv = efx->link_advertising;
  660. old_fc = efx->wanted_fc;
  661. efx_link_set_wanted_fc(efx, wanted_fc);
  662. if (efx->link_advertising != old_adv ||
  663. (efx->wanted_fc ^ old_fc) & EFX_FC_AUTO) {
  664. rc = efx->phy_op->reconfigure(efx);
  665. if (rc) {
  666. netif_err(efx, drv, efx->net_dev,
  667. "Unable to advertise requested flow "
  668. "control setting\n");
  669. goto out;
  670. }
  671. }
  672. /* Reconfigure the MAC. The PHY *may* generate a link state change event
  673. * if the user just changed the advertised capabilities, but there's no
  674. * harm doing this twice */
  675. efx->mac_op->reconfigure(efx);
  676. out:
  677. mutex_unlock(&efx->mac_lock);
  678. return rc;
  679. }
  680. static void efx_ethtool_get_pauseparam(struct net_device *net_dev,
  681. struct ethtool_pauseparam *pause)
  682. {
  683. struct efx_nic *efx = netdev_priv(net_dev);
  684. pause->rx_pause = !!(efx->wanted_fc & EFX_FC_RX);
  685. pause->tx_pause = !!(efx->wanted_fc & EFX_FC_TX);
  686. pause->autoneg = !!(efx->wanted_fc & EFX_FC_AUTO);
  687. }
  688. static void efx_ethtool_get_wol(struct net_device *net_dev,
  689. struct ethtool_wolinfo *wol)
  690. {
  691. struct efx_nic *efx = netdev_priv(net_dev);
  692. return efx->type->get_wol(efx, wol);
  693. }
  694. static int efx_ethtool_set_wol(struct net_device *net_dev,
  695. struct ethtool_wolinfo *wol)
  696. {
  697. struct efx_nic *efx = netdev_priv(net_dev);
  698. return efx->type->set_wol(efx, wol->wolopts);
  699. }
  700. static int efx_ethtool_reset(struct net_device *net_dev, u32 *flags)
  701. {
  702. struct efx_nic *efx = netdev_priv(net_dev);
  703. int rc;
  704. rc = efx->type->map_reset_flags(flags);
  705. if (rc < 0)
  706. return rc;
  707. return efx_reset(efx, rc);
  708. }
  709. static int efx_ethtool_get_class_rule(struct efx_nic *efx,
  710. struct ethtool_rx_flow_spec *rule)
  711. {
  712. struct ethtool_tcpip4_spec *ip_entry = &rule->h_u.tcp_ip4_spec;
  713. struct ethtool_tcpip4_spec *ip_mask = &rule->m_u.tcp_ip4_spec;
  714. struct efx_filter_spec spec;
  715. u16 vid;
  716. u8 proto;
  717. int rc;
  718. rc = efx_filter_get_filter_safe(efx, EFX_FILTER_PRI_MANUAL,
  719. rule->location, &spec);
  720. if (rc)
  721. return rc;
  722. if (spec.dmaq_id == 0xfff)
  723. rule->ring_cookie = RX_CLS_FLOW_DISC;
  724. else
  725. rule->ring_cookie = spec.dmaq_id;
  726. rc = efx_filter_get_eth_local(&spec, &vid,
  727. rule->h_u.ether_spec.h_dest);
  728. if (rc == 0) {
  729. rule->flow_type = ETHER_FLOW;
  730. memset(rule->m_u.ether_spec.h_dest, ~0, ETH_ALEN);
  731. if (vid != EFX_FILTER_VID_UNSPEC) {
  732. rule->flow_type |= FLOW_EXT;
  733. rule->h_ext.vlan_tci = htons(vid);
  734. rule->m_ext.vlan_tci = htons(0xfff);
  735. }
  736. return 0;
  737. }
  738. rc = efx_filter_get_ipv4_local(&spec, &proto,
  739. &ip_entry->ip4dst, &ip_entry->pdst);
  740. if (rc != 0) {
  741. rc = efx_filter_get_ipv4_full(
  742. &spec, &proto, &ip_entry->ip4src, &ip_entry->psrc,
  743. &ip_entry->ip4dst, &ip_entry->pdst);
  744. EFX_WARN_ON_PARANOID(rc);
  745. ip_mask->ip4src = ~0;
  746. ip_mask->psrc = ~0;
  747. }
  748. rule->flow_type = (proto == IPPROTO_TCP) ? TCP_V4_FLOW : UDP_V4_FLOW;
  749. ip_mask->ip4dst = ~0;
  750. ip_mask->pdst = ~0;
  751. return rc;
  752. }
  753. static int
  754. efx_ethtool_get_rxnfc(struct net_device *net_dev,
  755. struct ethtool_rxnfc *info, u32 *rule_locs)
  756. {
  757. struct efx_nic *efx = netdev_priv(net_dev);
  758. switch (info->cmd) {
  759. case ETHTOOL_GRXRINGS:
  760. info->data = efx->n_rx_channels;
  761. return 0;
  762. case ETHTOOL_GRXFH: {
  763. unsigned min_revision = 0;
  764. info->data = 0;
  765. switch (info->flow_type) {
  766. case TCP_V4_FLOW:
  767. info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
  768. /* fall through */
  769. case UDP_V4_FLOW:
  770. case SCTP_V4_FLOW:
  771. case AH_ESP_V4_FLOW:
  772. case IPV4_FLOW:
  773. info->data |= RXH_IP_SRC | RXH_IP_DST;
  774. min_revision = EFX_REV_FALCON_B0;
  775. break;
  776. case TCP_V6_FLOW:
  777. info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
  778. /* fall through */
  779. case UDP_V6_FLOW:
  780. case SCTP_V6_FLOW:
  781. case AH_ESP_V6_FLOW:
  782. case IPV6_FLOW:
  783. info->data |= RXH_IP_SRC | RXH_IP_DST;
  784. min_revision = EFX_REV_SIENA_A0;
  785. break;
  786. default:
  787. break;
  788. }
  789. if (efx_nic_rev(efx) < min_revision)
  790. info->data = 0;
  791. return 0;
  792. }
  793. case ETHTOOL_GRXCLSRLCNT:
  794. info->data = efx_filter_get_rx_id_limit(efx);
  795. if (info->data == 0)
  796. return -EOPNOTSUPP;
  797. info->data |= RX_CLS_LOC_SPECIAL;
  798. info->rule_cnt =
  799. efx_filter_count_rx_used(efx, EFX_FILTER_PRI_MANUAL);
  800. return 0;
  801. case ETHTOOL_GRXCLSRULE:
  802. if (efx_filter_get_rx_id_limit(efx) == 0)
  803. return -EOPNOTSUPP;
  804. return efx_ethtool_get_class_rule(efx, &info->fs);
  805. case ETHTOOL_GRXCLSRLALL: {
  806. s32 rc;
  807. info->data = efx_filter_get_rx_id_limit(efx);
  808. if (info->data == 0)
  809. return -EOPNOTSUPP;
  810. rc = efx_filter_get_rx_ids(efx, EFX_FILTER_PRI_MANUAL,
  811. rule_locs, info->rule_cnt);
  812. if (rc < 0)
  813. return rc;
  814. info->rule_cnt = rc;
  815. return 0;
  816. }
  817. default:
  818. return -EOPNOTSUPP;
  819. }
  820. }
  821. static int efx_ethtool_set_class_rule(struct efx_nic *efx,
  822. struct ethtool_rx_flow_spec *rule)
  823. {
  824. struct ethtool_tcpip4_spec *ip_entry = &rule->h_u.tcp_ip4_spec;
  825. struct ethtool_tcpip4_spec *ip_mask = &rule->m_u.tcp_ip4_spec;
  826. struct ethhdr *mac_entry = &rule->h_u.ether_spec;
  827. struct ethhdr *mac_mask = &rule->m_u.ether_spec;
  828. struct efx_filter_spec spec;
  829. int rc;
  830. /* Check that user wants us to choose the location */
  831. if (rule->location != RX_CLS_LOC_ANY &&
  832. rule->location != RX_CLS_LOC_FIRST &&
  833. rule->location != RX_CLS_LOC_LAST)
  834. return -EINVAL;
  835. /* Range-check ring_cookie */
  836. if (rule->ring_cookie >= efx->n_rx_channels &&
  837. rule->ring_cookie != RX_CLS_FLOW_DISC)
  838. return -EINVAL;
  839. /* Check for unsupported extensions */
  840. if ((rule->flow_type & FLOW_EXT) &&
  841. (rule->m_ext.vlan_etype | rule->m_ext.data[0] |
  842. rule->m_ext.data[1]))
  843. return -EINVAL;
  844. efx_filter_init_rx(&spec, EFX_FILTER_PRI_MANUAL,
  845. (rule->location == RX_CLS_LOC_FIRST) ?
  846. EFX_FILTER_FLAG_RX_OVERRIDE_IP : 0,
  847. (rule->ring_cookie == RX_CLS_FLOW_DISC) ?
  848. 0xfff : rule->ring_cookie);
  849. switch (rule->flow_type) {
  850. case TCP_V4_FLOW:
  851. case UDP_V4_FLOW: {
  852. u8 proto = (rule->flow_type == TCP_V4_FLOW ?
  853. IPPROTO_TCP : IPPROTO_UDP);
  854. /* Must match all of destination, */
  855. if ((__force u32)~ip_mask->ip4dst |
  856. (__force u16)~ip_mask->pdst)
  857. return -EINVAL;
  858. /* all or none of source, */
  859. if ((ip_mask->ip4src | ip_mask->psrc) &&
  860. ((__force u32)~ip_mask->ip4src |
  861. (__force u16)~ip_mask->psrc))
  862. return -EINVAL;
  863. /* and nothing else */
  864. if (ip_mask->tos | rule->m_ext.vlan_tci)
  865. return -EINVAL;
  866. if (ip_mask->ip4src)
  867. rc = efx_filter_set_ipv4_full(&spec, proto,
  868. ip_entry->ip4dst,
  869. ip_entry->pdst,
  870. ip_entry->ip4src,
  871. ip_entry->psrc);
  872. else
  873. rc = efx_filter_set_ipv4_local(&spec, proto,
  874. ip_entry->ip4dst,
  875. ip_entry->pdst);
  876. if (rc)
  877. return rc;
  878. break;
  879. }
  880. case ETHER_FLOW | FLOW_EXT:
  881. /* Must match all or none of VID */
  882. if (rule->m_ext.vlan_tci != htons(0xfff) &&
  883. rule->m_ext.vlan_tci != 0)
  884. return -EINVAL;
  885. case ETHER_FLOW:
  886. /* Must match all of destination */
  887. if (!is_broadcast_ether_addr(mac_mask->h_dest))
  888. return -EINVAL;
  889. /* and nothing else */
  890. if (!is_zero_ether_addr(mac_mask->h_source) ||
  891. mac_mask->h_proto)
  892. return -EINVAL;
  893. rc = efx_filter_set_eth_local(
  894. &spec,
  895. (rule->flow_type & FLOW_EXT && rule->m_ext.vlan_tci) ?
  896. ntohs(rule->h_ext.vlan_tci) : EFX_FILTER_VID_UNSPEC,
  897. mac_entry->h_dest);
  898. if (rc)
  899. return rc;
  900. break;
  901. default:
  902. return -EINVAL;
  903. }
  904. rc = efx_filter_insert_filter(efx, &spec, true);
  905. if (rc < 0)
  906. return rc;
  907. rule->location = rc;
  908. return 0;
  909. }
  910. static int efx_ethtool_set_rxnfc(struct net_device *net_dev,
  911. struct ethtool_rxnfc *info)
  912. {
  913. struct efx_nic *efx = netdev_priv(net_dev);
  914. if (efx_filter_get_rx_id_limit(efx) == 0)
  915. return -EOPNOTSUPP;
  916. switch (info->cmd) {
  917. case ETHTOOL_SRXCLSRLINS:
  918. return efx_ethtool_set_class_rule(efx, &info->fs);
  919. case ETHTOOL_SRXCLSRLDEL:
  920. return efx_filter_remove_id_safe(efx, EFX_FILTER_PRI_MANUAL,
  921. info->fs.location);
  922. default:
  923. return -EOPNOTSUPP;
  924. }
  925. }
  926. static u32 efx_ethtool_get_rxfh_indir_size(struct net_device *net_dev)
  927. {
  928. struct efx_nic *efx = netdev_priv(net_dev);
  929. return (efx_nic_rev(efx) < EFX_REV_FALCON_B0 ?
  930. 0 : ARRAY_SIZE(efx->rx_indir_table));
  931. }
  932. static int efx_ethtool_get_rxfh_indir(struct net_device *net_dev, u32 *indir)
  933. {
  934. struct efx_nic *efx = netdev_priv(net_dev);
  935. memcpy(indir, efx->rx_indir_table, sizeof(efx->rx_indir_table));
  936. return 0;
  937. }
  938. static int efx_ethtool_set_rxfh_indir(struct net_device *net_dev,
  939. const u32 *indir)
  940. {
  941. struct efx_nic *efx = netdev_priv(net_dev);
  942. memcpy(efx->rx_indir_table, indir, sizeof(efx->rx_indir_table));
  943. efx_nic_push_rx_indir_table(efx);
  944. return 0;
  945. }
  946. const struct ethtool_ops efx_ethtool_ops = {
  947. .get_settings = efx_ethtool_get_settings,
  948. .set_settings = efx_ethtool_set_settings,
  949. .get_drvinfo = efx_ethtool_get_drvinfo,
  950. .get_regs_len = efx_ethtool_get_regs_len,
  951. .get_regs = efx_ethtool_get_regs,
  952. .get_msglevel = efx_ethtool_get_msglevel,
  953. .set_msglevel = efx_ethtool_set_msglevel,
  954. .nway_reset = efx_ethtool_nway_reset,
  955. .get_link = ethtool_op_get_link,
  956. .get_coalesce = efx_ethtool_get_coalesce,
  957. .set_coalesce = efx_ethtool_set_coalesce,
  958. .get_ringparam = efx_ethtool_get_ringparam,
  959. .set_ringparam = efx_ethtool_set_ringparam,
  960. .get_pauseparam = efx_ethtool_get_pauseparam,
  961. .set_pauseparam = efx_ethtool_set_pauseparam,
  962. .get_sset_count = efx_ethtool_get_sset_count,
  963. .self_test = efx_ethtool_self_test,
  964. .get_strings = efx_ethtool_get_strings,
  965. .set_phys_id = efx_ethtool_phys_id,
  966. .get_ethtool_stats = efx_ethtool_get_stats,
  967. .get_wol = efx_ethtool_get_wol,
  968. .set_wol = efx_ethtool_set_wol,
  969. .reset = efx_ethtool_reset,
  970. .get_rxnfc = efx_ethtool_get_rxnfc,
  971. .set_rxnfc = efx_ethtool_set_rxnfc,
  972. .get_rxfh_indir_size = efx_ethtool_get_rxfh_indir_size,
  973. .get_rxfh_indir = efx_ethtool_get_rxfh_indir,
  974. .set_rxfh_indir = efx_ethtool_set_rxfh_indir,
  975. };