ethtool.c 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123
  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 const 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. }
  362. efx_fill_test(n++, strings, data, &tests->registers,
  363. "core", 0, "registers", NULL);
  364. if (efx->phy_op->run_tests != NULL) {
  365. EFX_BUG_ON_PARANOID(efx->phy_op->test_name == NULL);
  366. for (i = 0; true; ++i) {
  367. const char *name;
  368. EFX_BUG_ON_PARANOID(i >= EFX_MAX_PHY_TESTS);
  369. name = efx->phy_op->test_name(efx, i);
  370. if (name == NULL)
  371. break;
  372. efx_fill_test(n++, strings, data, &tests->phy_ext[i],
  373. "phy", 0, name, NULL);
  374. }
  375. }
  376. /* Loopback tests */
  377. for (mode = LOOPBACK_NONE; mode <= LOOPBACK_TEST_MAX; mode++) {
  378. if (!(efx->loopback_modes & (1 << mode)))
  379. continue;
  380. n = efx_fill_loopback_test(efx,
  381. &tests->loopback[mode], mode, n,
  382. strings, data);
  383. }
  384. return n;
  385. }
  386. static int efx_ethtool_get_sset_count(struct net_device *net_dev,
  387. int string_set)
  388. {
  389. switch (string_set) {
  390. case ETH_SS_STATS:
  391. return EFX_ETHTOOL_NUM_STATS;
  392. case ETH_SS_TEST:
  393. return efx_ethtool_fill_self_tests(netdev_priv(net_dev),
  394. NULL, NULL, NULL);
  395. default:
  396. return -EINVAL;
  397. }
  398. }
  399. static void efx_ethtool_get_strings(struct net_device *net_dev,
  400. u32 string_set, u8 *strings)
  401. {
  402. struct efx_nic *efx = netdev_priv(net_dev);
  403. struct ethtool_string *ethtool_strings =
  404. (struct ethtool_string *)strings;
  405. int i;
  406. switch (string_set) {
  407. case ETH_SS_STATS:
  408. for (i = 0; i < EFX_ETHTOOL_NUM_STATS; i++)
  409. strncpy(ethtool_strings[i].name,
  410. efx_ethtool_stats[i].name,
  411. sizeof(ethtool_strings[i].name));
  412. break;
  413. case ETH_SS_TEST:
  414. efx_ethtool_fill_self_tests(efx, NULL,
  415. ethtool_strings, NULL);
  416. break;
  417. default:
  418. /* No other string sets */
  419. break;
  420. }
  421. }
  422. static void efx_ethtool_get_stats(struct net_device *net_dev,
  423. struct ethtool_stats *stats,
  424. u64 *data)
  425. {
  426. struct efx_nic *efx = netdev_priv(net_dev);
  427. struct efx_mac_stats *mac_stats = &efx->mac_stats;
  428. const struct efx_ethtool_stat *stat;
  429. struct efx_channel *channel;
  430. struct efx_tx_queue *tx_queue;
  431. int i;
  432. EFX_BUG_ON_PARANOID(stats->n_stats != EFX_ETHTOOL_NUM_STATS);
  433. spin_lock_bh(&efx->stats_lock);
  434. /* Update MAC and NIC statistics */
  435. efx->type->update_stats(efx);
  436. /* Fill detailed statistics buffer */
  437. for (i = 0; i < EFX_ETHTOOL_NUM_STATS; i++) {
  438. stat = &efx_ethtool_stats[i];
  439. switch (stat->source) {
  440. case EFX_ETHTOOL_STAT_SOURCE_mac_stats:
  441. data[i] = stat->get_stat((void *)mac_stats +
  442. stat->offset);
  443. break;
  444. case EFX_ETHTOOL_STAT_SOURCE_nic:
  445. data[i] = stat->get_stat((void *)efx + stat->offset);
  446. break;
  447. case EFX_ETHTOOL_STAT_SOURCE_channel:
  448. data[i] = 0;
  449. efx_for_each_channel(channel, efx)
  450. data[i] += stat->get_stat((void *)channel +
  451. stat->offset);
  452. break;
  453. case EFX_ETHTOOL_STAT_SOURCE_tx_queue:
  454. data[i] = 0;
  455. efx_for_each_channel(channel, efx) {
  456. efx_for_each_channel_tx_queue(tx_queue, channel)
  457. data[i] +=
  458. stat->get_stat((void *)tx_queue
  459. + stat->offset);
  460. }
  461. break;
  462. }
  463. }
  464. spin_unlock_bh(&efx->stats_lock);
  465. }
  466. static void efx_ethtool_self_test(struct net_device *net_dev,
  467. struct ethtool_test *test, u64 *data)
  468. {
  469. struct efx_nic *efx = netdev_priv(net_dev);
  470. struct efx_self_tests *efx_tests;
  471. int already_up;
  472. int rc = -ENOMEM;
  473. efx_tests = kzalloc(sizeof(*efx_tests), GFP_KERNEL);
  474. if (!efx_tests)
  475. goto fail;
  476. ASSERT_RTNL();
  477. if (efx->state != STATE_RUNNING) {
  478. rc = -EIO;
  479. goto fail1;
  480. }
  481. netif_info(efx, drv, efx->net_dev, "starting %sline testing\n",
  482. (test->flags & ETH_TEST_FL_OFFLINE) ? "off" : "on");
  483. /* We need rx buffers and interrupts. */
  484. already_up = (efx->net_dev->flags & IFF_UP);
  485. if (!already_up) {
  486. rc = dev_open(efx->net_dev);
  487. if (rc) {
  488. netif_err(efx, drv, efx->net_dev,
  489. "failed opening device.\n");
  490. goto fail1;
  491. }
  492. }
  493. rc = efx_selftest(efx, efx_tests, test->flags);
  494. if (!already_up)
  495. dev_close(efx->net_dev);
  496. netif_info(efx, drv, efx->net_dev, "%s %sline self-tests\n",
  497. rc == 0 ? "passed" : "failed",
  498. (test->flags & ETH_TEST_FL_OFFLINE) ? "off" : "on");
  499. fail1:
  500. /* Fill ethtool results structures */
  501. efx_ethtool_fill_self_tests(efx, efx_tests, NULL, data);
  502. kfree(efx_tests);
  503. fail:
  504. if (rc)
  505. test->flags |= ETH_TEST_FL_FAILED;
  506. }
  507. /* Restart autonegotiation */
  508. static int efx_ethtool_nway_reset(struct net_device *net_dev)
  509. {
  510. struct efx_nic *efx = netdev_priv(net_dev);
  511. return mdio45_nway_restart(&efx->mdio);
  512. }
  513. /*
  514. * Each channel has a single IRQ and moderation timer, started by any
  515. * completion (or other event). Unless the module parameter
  516. * separate_tx_channels is set, IRQs and moderation are therefore
  517. * shared between RX and TX completions. In this case, when RX IRQ
  518. * moderation is explicitly changed then TX IRQ moderation is
  519. * automatically changed too, but otherwise we fail if the two values
  520. * are requested to be different.
  521. *
  522. * The hardware does not support a limit on the number of completions
  523. * before an IRQ, so we do not use the max_frames fields. We should
  524. * report and require that max_frames == (usecs != 0), but this would
  525. * invalidate existing user documentation.
  526. *
  527. * The hardware does not have distinct settings for interrupt
  528. * moderation while the previous IRQ is being handled, so we should
  529. * not use the 'irq' fields. However, an earlier developer
  530. * misunderstood the meaning of the 'irq' fields and the driver did
  531. * not support the standard fields. To avoid invalidating existing
  532. * user documentation, we report and accept changes through either the
  533. * standard or 'irq' fields. If both are changed at the same time, we
  534. * prefer the standard field.
  535. *
  536. * We implement adaptive IRQ moderation, but use a different algorithm
  537. * from that assumed in the definition of struct ethtool_coalesce.
  538. * Therefore we do not use any of the adaptive moderation parameters
  539. * in it.
  540. */
  541. static int efx_ethtool_get_coalesce(struct net_device *net_dev,
  542. struct ethtool_coalesce *coalesce)
  543. {
  544. struct efx_nic *efx = netdev_priv(net_dev);
  545. unsigned int tx_usecs, rx_usecs;
  546. bool rx_adaptive;
  547. efx_get_irq_moderation(efx, &tx_usecs, &rx_usecs, &rx_adaptive);
  548. coalesce->tx_coalesce_usecs = tx_usecs;
  549. coalesce->tx_coalesce_usecs_irq = tx_usecs;
  550. coalesce->rx_coalesce_usecs = rx_usecs;
  551. coalesce->rx_coalesce_usecs_irq = rx_usecs;
  552. coalesce->use_adaptive_rx_coalesce = rx_adaptive;
  553. return 0;
  554. }
  555. static int efx_ethtool_set_coalesce(struct net_device *net_dev,
  556. struct ethtool_coalesce *coalesce)
  557. {
  558. struct efx_nic *efx = netdev_priv(net_dev);
  559. struct efx_channel *channel;
  560. unsigned int tx_usecs, rx_usecs;
  561. bool adaptive, rx_may_override_tx;
  562. int rc;
  563. if (coalesce->use_adaptive_tx_coalesce)
  564. return -EINVAL;
  565. efx_get_irq_moderation(efx, &tx_usecs, &rx_usecs, &adaptive);
  566. if (coalesce->rx_coalesce_usecs != rx_usecs)
  567. rx_usecs = coalesce->rx_coalesce_usecs;
  568. else
  569. rx_usecs = coalesce->rx_coalesce_usecs_irq;
  570. adaptive = coalesce->use_adaptive_rx_coalesce;
  571. /* If channels are shared, TX IRQ moderation can be quietly
  572. * overridden unless it is changed from its old value.
  573. */
  574. rx_may_override_tx = (coalesce->tx_coalesce_usecs == tx_usecs &&
  575. coalesce->tx_coalesce_usecs_irq == tx_usecs);
  576. if (coalesce->tx_coalesce_usecs != tx_usecs)
  577. tx_usecs = coalesce->tx_coalesce_usecs;
  578. else
  579. tx_usecs = coalesce->tx_coalesce_usecs_irq;
  580. rc = efx_init_irq_moderation(efx, tx_usecs, rx_usecs, adaptive,
  581. rx_may_override_tx);
  582. if (rc != 0)
  583. return rc;
  584. efx_for_each_channel(channel, efx)
  585. efx->type->push_irq_moderation(channel);
  586. return 0;
  587. }
  588. static void efx_ethtool_get_ringparam(struct net_device *net_dev,
  589. struct ethtool_ringparam *ring)
  590. {
  591. struct efx_nic *efx = netdev_priv(net_dev);
  592. ring->rx_max_pending = EFX_MAX_DMAQ_SIZE;
  593. ring->tx_max_pending = EFX_MAX_DMAQ_SIZE;
  594. ring->rx_pending = efx->rxq_entries;
  595. ring->tx_pending = efx->txq_entries;
  596. }
  597. static int efx_ethtool_set_ringparam(struct net_device *net_dev,
  598. struct ethtool_ringparam *ring)
  599. {
  600. struct efx_nic *efx = netdev_priv(net_dev);
  601. if (ring->rx_mini_pending || ring->rx_jumbo_pending ||
  602. ring->rx_pending > EFX_MAX_DMAQ_SIZE ||
  603. ring->tx_pending > EFX_MAX_DMAQ_SIZE)
  604. return -EINVAL;
  605. if (ring->rx_pending < EFX_MIN_RING_SIZE ||
  606. ring->tx_pending < EFX_MIN_RING_SIZE) {
  607. netif_err(efx, drv, efx->net_dev,
  608. "TX and RX queues cannot be smaller than %ld\n",
  609. EFX_MIN_RING_SIZE);
  610. return -EINVAL;
  611. }
  612. return efx_realloc_channels(efx, ring->rx_pending, ring->tx_pending);
  613. }
  614. static int efx_ethtool_set_pauseparam(struct net_device *net_dev,
  615. struct ethtool_pauseparam *pause)
  616. {
  617. struct efx_nic *efx = netdev_priv(net_dev);
  618. u8 wanted_fc, old_fc;
  619. u32 old_adv;
  620. bool reset;
  621. int rc = 0;
  622. mutex_lock(&efx->mac_lock);
  623. wanted_fc = ((pause->rx_pause ? EFX_FC_RX : 0) |
  624. (pause->tx_pause ? EFX_FC_TX : 0) |
  625. (pause->autoneg ? EFX_FC_AUTO : 0));
  626. if ((wanted_fc & EFX_FC_TX) && !(wanted_fc & EFX_FC_RX)) {
  627. netif_dbg(efx, drv, efx->net_dev,
  628. "Flow control unsupported: tx ON rx OFF\n");
  629. rc = -EINVAL;
  630. goto out;
  631. }
  632. if ((wanted_fc & EFX_FC_AUTO) && !efx->link_advertising) {
  633. netif_dbg(efx, drv, efx->net_dev,
  634. "Autonegotiation is disabled\n");
  635. rc = -EINVAL;
  636. goto out;
  637. }
  638. /* TX flow control may automatically turn itself off if the
  639. * link partner (intermittently) stops responding to pause
  640. * frames. There isn't any indication that this has happened,
  641. * so the best we do is leave it up to the user to spot this
  642. * and fix it be cycling transmit flow control on this end. */
  643. reset = (wanted_fc & EFX_FC_TX) && !(efx->wanted_fc & EFX_FC_TX);
  644. if (EFX_WORKAROUND_11482(efx) && reset) {
  645. if (efx_nic_rev(efx) == EFX_REV_FALCON_B0) {
  646. /* Recover by resetting the EM block */
  647. falcon_stop_nic_stats(efx);
  648. falcon_drain_tx_fifo(efx);
  649. falcon_reconfigure_xmac(efx);
  650. falcon_start_nic_stats(efx);
  651. } else {
  652. /* Schedule a reset to recover */
  653. efx_schedule_reset(efx, RESET_TYPE_INVISIBLE);
  654. }
  655. }
  656. old_adv = efx->link_advertising;
  657. old_fc = efx->wanted_fc;
  658. efx_link_set_wanted_fc(efx, wanted_fc);
  659. if (efx->link_advertising != old_adv ||
  660. (efx->wanted_fc ^ old_fc) & EFX_FC_AUTO) {
  661. rc = efx->phy_op->reconfigure(efx);
  662. if (rc) {
  663. netif_err(efx, drv, efx->net_dev,
  664. "Unable to advertise requested flow "
  665. "control setting\n");
  666. goto out;
  667. }
  668. }
  669. /* Reconfigure the MAC. The PHY *may* generate a link state change event
  670. * if the user just changed the advertised capabilities, but there's no
  671. * harm doing this twice */
  672. efx->type->reconfigure_mac(efx);
  673. out:
  674. mutex_unlock(&efx->mac_lock);
  675. return rc;
  676. }
  677. static void efx_ethtool_get_pauseparam(struct net_device *net_dev,
  678. struct ethtool_pauseparam *pause)
  679. {
  680. struct efx_nic *efx = netdev_priv(net_dev);
  681. pause->rx_pause = !!(efx->wanted_fc & EFX_FC_RX);
  682. pause->tx_pause = !!(efx->wanted_fc & EFX_FC_TX);
  683. pause->autoneg = !!(efx->wanted_fc & EFX_FC_AUTO);
  684. }
  685. static void efx_ethtool_get_wol(struct net_device *net_dev,
  686. struct ethtool_wolinfo *wol)
  687. {
  688. struct efx_nic *efx = netdev_priv(net_dev);
  689. return efx->type->get_wol(efx, wol);
  690. }
  691. static int efx_ethtool_set_wol(struct net_device *net_dev,
  692. struct ethtool_wolinfo *wol)
  693. {
  694. struct efx_nic *efx = netdev_priv(net_dev);
  695. return efx->type->set_wol(efx, wol->wolopts);
  696. }
  697. static int efx_ethtool_reset(struct net_device *net_dev, u32 *flags)
  698. {
  699. struct efx_nic *efx = netdev_priv(net_dev);
  700. int rc;
  701. rc = efx->type->map_reset_flags(flags);
  702. if (rc < 0)
  703. return rc;
  704. return efx_reset(efx, rc);
  705. }
  706. static int efx_ethtool_get_class_rule(struct efx_nic *efx,
  707. struct ethtool_rx_flow_spec *rule)
  708. {
  709. struct ethtool_tcpip4_spec *ip_entry = &rule->h_u.tcp_ip4_spec;
  710. struct ethtool_tcpip4_spec *ip_mask = &rule->m_u.tcp_ip4_spec;
  711. struct efx_filter_spec spec;
  712. u16 vid;
  713. u8 proto;
  714. int rc;
  715. rc = efx_filter_get_filter_safe(efx, EFX_FILTER_PRI_MANUAL,
  716. rule->location, &spec);
  717. if (rc)
  718. return rc;
  719. if (spec.dmaq_id == 0xfff)
  720. rule->ring_cookie = RX_CLS_FLOW_DISC;
  721. else
  722. rule->ring_cookie = spec.dmaq_id;
  723. rc = efx_filter_get_eth_local(&spec, &vid,
  724. rule->h_u.ether_spec.h_dest);
  725. if (rc == 0) {
  726. rule->flow_type = ETHER_FLOW;
  727. memset(rule->m_u.ether_spec.h_dest, ~0, ETH_ALEN);
  728. if (vid != EFX_FILTER_VID_UNSPEC) {
  729. rule->flow_type |= FLOW_EXT;
  730. rule->h_ext.vlan_tci = htons(vid);
  731. rule->m_ext.vlan_tci = htons(0xfff);
  732. }
  733. return 0;
  734. }
  735. rc = efx_filter_get_ipv4_local(&spec, &proto,
  736. &ip_entry->ip4dst, &ip_entry->pdst);
  737. if (rc != 0) {
  738. rc = efx_filter_get_ipv4_full(
  739. &spec, &proto, &ip_entry->ip4src, &ip_entry->psrc,
  740. &ip_entry->ip4dst, &ip_entry->pdst);
  741. EFX_WARN_ON_PARANOID(rc);
  742. ip_mask->ip4src = ~0;
  743. ip_mask->psrc = ~0;
  744. }
  745. rule->flow_type = (proto == IPPROTO_TCP) ? TCP_V4_FLOW : UDP_V4_FLOW;
  746. ip_mask->ip4dst = ~0;
  747. ip_mask->pdst = ~0;
  748. return rc;
  749. }
  750. static int
  751. efx_ethtool_get_rxnfc(struct net_device *net_dev,
  752. struct ethtool_rxnfc *info, u32 *rule_locs)
  753. {
  754. struct efx_nic *efx = netdev_priv(net_dev);
  755. switch (info->cmd) {
  756. case ETHTOOL_GRXRINGS:
  757. info->data = efx->n_rx_channels;
  758. return 0;
  759. case ETHTOOL_GRXFH: {
  760. unsigned min_revision = 0;
  761. info->data = 0;
  762. switch (info->flow_type) {
  763. case TCP_V4_FLOW:
  764. info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
  765. /* fall through */
  766. case UDP_V4_FLOW:
  767. case SCTP_V4_FLOW:
  768. case AH_ESP_V4_FLOW:
  769. case IPV4_FLOW:
  770. info->data |= RXH_IP_SRC | RXH_IP_DST;
  771. min_revision = EFX_REV_FALCON_B0;
  772. break;
  773. case TCP_V6_FLOW:
  774. info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
  775. /* fall through */
  776. case UDP_V6_FLOW:
  777. case SCTP_V6_FLOW:
  778. case AH_ESP_V6_FLOW:
  779. case IPV6_FLOW:
  780. info->data |= RXH_IP_SRC | RXH_IP_DST;
  781. min_revision = EFX_REV_SIENA_A0;
  782. break;
  783. default:
  784. break;
  785. }
  786. if (efx_nic_rev(efx) < min_revision)
  787. info->data = 0;
  788. return 0;
  789. }
  790. case ETHTOOL_GRXCLSRLCNT:
  791. info->data = efx_filter_get_rx_id_limit(efx);
  792. if (info->data == 0)
  793. return -EOPNOTSUPP;
  794. info->data |= RX_CLS_LOC_SPECIAL;
  795. info->rule_cnt =
  796. efx_filter_count_rx_used(efx, EFX_FILTER_PRI_MANUAL);
  797. return 0;
  798. case ETHTOOL_GRXCLSRULE:
  799. if (efx_filter_get_rx_id_limit(efx) == 0)
  800. return -EOPNOTSUPP;
  801. return efx_ethtool_get_class_rule(efx, &info->fs);
  802. case ETHTOOL_GRXCLSRLALL: {
  803. s32 rc;
  804. info->data = efx_filter_get_rx_id_limit(efx);
  805. if (info->data == 0)
  806. return -EOPNOTSUPP;
  807. rc = efx_filter_get_rx_ids(efx, EFX_FILTER_PRI_MANUAL,
  808. rule_locs, info->rule_cnt);
  809. if (rc < 0)
  810. return rc;
  811. info->rule_cnt = rc;
  812. return 0;
  813. }
  814. default:
  815. return -EOPNOTSUPP;
  816. }
  817. }
  818. static int efx_ethtool_set_class_rule(struct efx_nic *efx,
  819. struct ethtool_rx_flow_spec *rule)
  820. {
  821. struct ethtool_tcpip4_spec *ip_entry = &rule->h_u.tcp_ip4_spec;
  822. struct ethtool_tcpip4_spec *ip_mask = &rule->m_u.tcp_ip4_spec;
  823. struct ethhdr *mac_entry = &rule->h_u.ether_spec;
  824. struct ethhdr *mac_mask = &rule->m_u.ether_spec;
  825. struct efx_filter_spec spec;
  826. int rc;
  827. /* Check that user wants us to choose the location */
  828. if (rule->location != RX_CLS_LOC_ANY &&
  829. rule->location != RX_CLS_LOC_FIRST &&
  830. rule->location != RX_CLS_LOC_LAST)
  831. return -EINVAL;
  832. /* Range-check ring_cookie */
  833. if (rule->ring_cookie >= efx->n_rx_channels &&
  834. rule->ring_cookie != RX_CLS_FLOW_DISC)
  835. return -EINVAL;
  836. /* Check for unsupported extensions */
  837. if ((rule->flow_type & FLOW_EXT) &&
  838. (rule->m_ext.vlan_etype | rule->m_ext.data[0] |
  839. rule->m_ext.data[1]))
  840. return -EINVAL;
  841. efx_filter_init_rx(&spec, EFX_FILTER_PRI_MANUAL,
  842. (rule->location == RX_CLS_LOC_FIRST) ?
  843. EFX_FILTER_FLAG_RX_OVERRIDE_IP : 0,
  844. (rule->ring_cookie == RX_CLS_FLOW_DISC) ?
  845. 0xfff : rule->ring_cookie);
  846. switch (rule->flow_type) {
  847. case TCP_V4_FLOW:
  848. case UDP_V4_FLOW: {
  849. u8 proto = (rule->flow_type == TCP_V4_FLOW ?
  850. IPPROTO_TCP : IPPROTO_UDP);
  851. /* Must match all of destination, */
  852. if ((__force u32)~ip_mask->ip4dst |
  853. (__force u16)~ip_mask->pdst)
  854. return -EINVAL;
  855. /* all or none of source, */
  856. if ((ip_mask->ip4src | ip_mask->psrc) &&
  857. ((__force u32)~ip_mask->ip4src |
  858. (__force u16)~ip_mask->psrc))
  859. return -EINVAL;
  860. /* and nothing else */
  861. if (ip_mask->tos | rule->m_ext.vlan_tci)
  862. return -EINVAL;
  863. if (ip_mask->ip4src)
  864. rc = efx_filter_set_ipv4_full(&spec, proto,
  865. ip_entry->ip4dst,
  866. ip_entry->pdst,
  867. ip_entry->ip4src,
  868. ip_entry->psrc);
  869. else
  870. rc = efx_filter_set_ipv4_local(&spec, proto,
  871. ip_entry->ip4dst,
  872. ip_entry->pdst);
  873. if (rc)
  874. return rc;
  875. break;
  876. }
  877. case ETHER_FLOW | FLOW_EXT:
  878. /* Must match all or none of VID */
  879. if (rule->m_ext.vlan_tci != htons(0xfff) &&
  880. rule->m_ext.vlan_tci != 0)
  881. return -EINVAL;
  882. case ETHER_FLOW:
  883. /* Must match all of destination */
  884. if (!is_broadcast_ether_addr(mac_mask->h_dest))
  885. return -EINVAL;
  886. /* and nothing else */
  887. if (!is_zero_ether_addr(mac_mask->h_source) ||
  888. mac_mask->h_proto)
  889. return -EINVAL;
  890. rc = efx_filter_set_eth_local(
  891. &spec,
  892. (rule->flow_type & FLOW_EXT && rule->m_ext.vlan_tci) ?
  893. ntohs(rule->h_ext.vlan_tci) : EFX_FILTER_VID_UNSPEC,
  894. mac_entry->h_dest);
  895. if (rc)
  896. return rc;
  897. break;
  898. default:
  899. return -EINVAL;
  900. }
  901. rc = efx_filter_insert_filter(efx, &spec, true);
  902. if (rc < 0)
  903. return rc;
  904. rule->location = rc;
  905. return 0;
  906. }
  907. static int efx_ethtool_set_rxnfc(struct net_device *net_dev,
  908. struct ethtool_rxnfc *info)
  909. {
  910. struct efx_nic *efx = netdev_priv(net_dev);
  911. if (efx_filter_get_rx_id_limit(efx) == 0)
  912. return -EOPNOTSUPP;
  913. switch (info->cmd) {
  914. case ETHTOOL_SRXCLSRLINS:
  915. return efx_ethtool_set_class_rule(efx, &info->fs);
  916. case ETHTOOL_SRXCLSRLDEL:
  917. return efx_filter_remove_id_safe(efx, EFX_FILTER_PRI_MANUAL,
  918. info->fs.location);
  919. default:
  920. return -EOPNOTSUPP;
  921. }
  922. }
  923. static u32 efx_ethtool_get_rxfh_indir_size(struct net_device *net_dev)
  924. {
  925. struct efx_nic *efx = netdev_priv(net_dev);
  926. return (efx_nic_rev(efx) < EFX_REV_FALCON_B0 ?
  927. 0 : ARRAY_SIZE(efx->rx_indir_table));
  928. }
  929. static int efx_ethtool_get_rxfh_indir(struct net_device *net_dev, u32 *indir)
  930. {
  931. struct efx_nic *efx = netdev_priv(net_dev);
  932. memcpy(indir, efx->rx_indir_table, sizeof(efx->rx_indir_table));
  933. return 0;
  934. }
  935. static int efx_ethtool_set_rxfh_indir(struct net_device *net_dev,
  936. const u32 *indir)
  937. {
  938. struct efx_nic *efx = netdev_priv(net_dev);
  939. memcpy(efx->rx_indir_table, indir, sizeof(efx->rx_indir_table));
  940. efx_nic_push_rx_indir_table(efx);
  941. return 0;
  942. }
  943. const struct ethtool_ops efx_ethtool_ops = {
  944. .get_settings = efx_ethtool_get_settings,
  945. .set_settings = efx_ethtool_set_settings,
  946. .get_drvinfo = efx_ethtool_get_drvinfo,
  947. .get_regs_len = efx_ethtool_get_regs_len,
  948. .get_regs = efx_ethtool_get_regs,
  949. .get_msglevel = efx_ethtool_get_msglevel,
  950. .set_msglevel = efx_ethtool_set_msglevel,
  951. .nway_reset = efx_ethtool_nway_reset,
  952. .get_link = ethtool_op_get_link,
  953. .get_coalesce = efx_ethtool_get_coalesce,
  954. .set_coalesce = efx_ethtool_set_coalesce,
  955. .get_ringparam = efx_ethtool_get_ringparam,
  956. .set_ringparam = efx_ethtool_set_ringparam,
  957. .get_pauseparam = efx_ethtool_get_pauseparam,
  958. .set_pauseparam = efx_ethtool_set_pauseparam,
  959. .get_sset_count = efx_ethtool_get_sset_count,
  960. .self_test = efx_ethtool_self_test,
  961. .get_strings = efx_ethtool_get_strings,
  962. .set_phys_id = efx_ethtool_phys_id,
  963. .get_ethtool_stats = efx_ethtool_get_stats,
  964. .get_wol = efx_ethtool_get_wol,
  965. .set_wol = efx_ethtool_set_wol,
  966. .reset = efx_ethtool_reset,
  967. .get_rxnfc = efx_ethtool_get_rxnfc,
  968. .set_rxnfc = efx_ethtool_set_rxnfc,
  969. .get_rxfh_indir_size = efx_ethtool_get_rxfh_indir_size,
  970. .get_rxfh_indir = efx_ethtool_get_rxfh_indir,
  971. .set_rxfh_indir = efx_ethtool_set_rxfh_indir,
  972. };