be_ethtool.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188
  1. /*
  2. * Copyright (C) 2005 - 2014 Emulex
  3. * All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License version 2
  7. * as published by the Free Software Foundation. The full GNU General
  8. * Public License is included in this distribution in the file called COPYING.
  9. *
  10. * Contact Information:
  11. * linux-drivers@emulex.com
  12. *
  13. * Emulex
  14. * 3333 Susan Street
  15. * Costa Mesa, CA 92626
  16. */
  17. #include "be.h"
  18. #include "be_cmds.h"
  19. #include <linux/ethtool.h>
  20. struct be_ethtool_stat {
  21. char desc[ETH_GSTRING_LEN];
  22. int type;
  23. int size;
  24. int offset;
  25. };
  26. enum {DRVSTAT_TX, DRVSTAT_RX, DRVSTAT};
  27. #define FIELDINFO(_struct, field) FIELD_SIZEOF(_struct, field), \
  28. offsetof(_struct, field)
  29. #define DRVSTAT_TX_INFO(field) #field, DRVSTAT_TX,\
  30. FIELDINFO(struct be_tx_stats, field)
  31. #define DRVSTAT_RX_INFO(field) #field, DRVSTAT_RX,\
  32. FIELDINFO(struct be_rx_stats, field)
  33. #define DRVSTAT_INFO(field) #field, DRVSTAT,\
  34. FIELDINFO(struct be_drv_stats, field)
  35. static const struct be_ethtool_stat et_stats[] = {
  36. {DRVSTAT_INFO(rx_crc_errors)},
  37. {DRVSTAT_INFO(rx_alignment_symbol_errors)},
  38. {DRVSTAT_INFO(rx_pause_frames)},
  39. {DRVSTAT_INFO(rx_control_frames)},
  40. /* Received packets dropped when the Ethernet length field
  41. * is not equal to the actual Ethernet data length.
  42. */
  43. {DRVSTAT_INFO(rx_in_range_errors)},
  44. /* Received packets dropped when their length field is >= 1501 bytes
  45. * and <= 1535 bytes.
  46. */
  47. {DRVSTAT_INFO(rx_out_range_errors)},
  48. /* Received packets dropped when they are longer than 9216 bytes */
  49. {DRVSTAT_INFO(rx_frame_too_long)},
  50. /* Received packets dropped when they don't pass the unicast or
  51. * multicast address filtering.
  52. */
  53. {DRVSTAT_INFO(rx_address_filtered)},
  54. /* Received packets dropped when IP packet length field is less than
  55. * the IP header length field.
  56. */
  57. {DRVSTAT_INFO(rx_dropped_too_small)},
  58. /* Received packets dropped when IP length field is greater than
  59. * the actual packet length.
  60. */
  61. {DRVSTAT_INFO(rx_dropped_too_short)},
  62. /* Received packets dropped when the IP header length field is less
  63. * than 5.
  64. */
  65. {DRVSTAT_INFO(rx_dropped_header_too_small)},
  66. /* Received packets dropped when the TCP header length field is less
  67. * than 5 or the TCP header length + IP header length is more
  68. * than IP packet length.
  69. */
  70. {DRVSTAT_INFO(rx_dropped_tcp_length)},
  71. {DRVSTAT_INFO(rx_dropped_runt)},
  72. /* Number of received packets dropped when a fifo for descriptors going
  73. * into the packet demux block overflows. In normal operation, this
  74. * fifo must never overflow.
  75. */
  76. {DRVSTAT_INFO(rxpp_fifo_overflow_drop)},
  77. {DRVSTAT_INFO(rx_input_fifo_overflow_drop)},
  78. {DRVSTAT_INFO(rx_ip_checksum_errs)},
  79. {DRVSTAT_INFO(rx_tcp_checksum_errs)},
  80. {DRVSTAT_INFO(rx_udp_checksum_errs)},
  81. {DRVSTAT_INFO(tx_pauseframes)},
  82. {DRVSTAT_INFO(tx_controlframes)},
  83. {DRVSTAT_INFO(rx_priority_pause_frames)},
  84. {DRVSTAT_INFO(tx_priority_pauseframes)},
  85. /* Received packets dropped when an internal fifo going into
  86. * main packet buffer tank (PMEM) overflows.
  87. */
  88. {DRVSTAT_INFO(pmem_fifo_overflow_drop)},
  89. {DRVSTAT_INFO(jabber_events)},
  90. /* Received packets dropped due to lack of available HW packet buffers
  91. * used to temporarily hold the received packets.
  92. */
  93. {DRVSTAT_INFO(rx_drops_no_pbuf)},
  94. /* Received packets dropped due to input receive buffer
  95. * descriptor fifo overflowing.
  96. */
  97. {DRVSTAT_INFO(rx_drops_no_erx_descr)},
  98. /* Packets dropped because the internal FIFO to the offloaded TCP
  99. * receive processing block is full. This could happen only for
  100. * offloaded iSCSI or FCoE trarffic.
  101. */
  102. {DRVSTAT_INFO(rx_drops_no_tpre_descr)},
  103. /* Received packets dropped when they need more than 8
  104. * receive buffers. This cannot happen as the driver configures
  105. * 2048 byte receive buffers.
  106. */
  107. {DRVSTAT_INFO(rx_drops_too_many_frags)},
  108. {DRVSTAT_INFO(forwarded_packets)},
  109. /* Received packets dropped when the frame length
  110. * is more than 9018 bytes
  111. */
  112. {DRVSTAT_INFO(rx_drops_mtu)},
  113. /* Number of packets dropped due to random early drop function */
  114. {DRVSTAT_INFO(eth_red_drops)},
  115. {DRVSTAT_INFO(be_on_die_temperature)},
  116. {DRVSTAT_INFO(rx_roce_bytes_lsd)},
  117. {DRVSTAT_INFO(rx_roce_bytes_msd)},
  118. {DRVSTAT_INFO(rx_roce_frames)},
  119. {DRVSTAT_INFO(roce_drops_payload_len)},
  120. {DRVSTAT_INFO(roce_drops_crc)}
  121. };
  122. #define ETHTOOL_STATS_NUM ARRAY_SIZE(et_stats)
  123. /* Stats related to multi RX queues: get_stats routine assumes bytes, pkts
  124. * are first and second members respectively.
  125. */
  126. static const struct be_ethtool_stat et_rx_stats[] = {
  127. {DRVSTAT_RX_INFO(rx_bytes)},/* If moving this member see above note */
  128. {DRVSTAT_RX_INFO(rx_pkts)}, /* If moving this member see above note */
  129. {DRVSTAT_RX_INFO(rx_compl)},
  130. {DRVSTAT_RX_INFO(rx_compl_err)},
  131. {DRVSTAT_RX_INFO(rx_mcast_pkts)},
  132. /* Number of page allocation failures while posting receive buffers
  133. * to HW.
  134. */
  135. {DRVSTAT_RX_INFO(rx_post_fail)},
  136. /* Recevied packets dropped due to skb allocation failure */
  137. {DRVSTAT_RX_INFO(rx_drops_no_skbs)},
  138. /* Received packets dropped due to lack of available fetched buffers
  139. * posted by the driver.
  140. */
  141. {DRVSTAT_RX_INFO(rx_drops_no_frags)}
  142. };
  143. #define ETHTOOL_RXSTATS_NUM (ARRAY_SIZE(et_rx_stats))
  144. /* Stats related to multi TX queues: get_stats routine assumes compl is the
  145. * first member
  146. */
  147. static const struct be_ethtool_stat et_tx_stats[] = {
  148. {DRVSTAT_TX_INFO(tx_compl)}, /* If moving this member see above note */
  149. {DRVSTAT_TX_INFO(tx_bytes)},
  150. {DRVSTAT_TX_INFO(tx_pkts)},
  151. /* Number of skbs queued for trasmission by the driver */
  152. {DRVSTAT_TX_INFO(tx_reqs)},
  153. /* Number of TX work request blocks DMAed to HW */
  154. {DRVSTAT_TX_INFO(tx_wrbs)},
  155. /* Number of times the TX queue was stopped due to lack
  156. * of spaces in the TXQ.
  157. */
  158. {DRVSTAT_TX_INFO(tx_stops)},
  159. /* Pkts dropped in the driver's transmit path */
  160. {DRVSTAT_TX_INFO(tx_drv_drops)}
  161. };
  162. #define ETHTOOL_TXSTATS_NUM (ARRAY_SIZE(et_tx_stats))
  163. static const char et_self_tests[][ETH_GSTRING_LEN] = {
  164. "MAC Loopback test",
  165. "PHY Loopback test",
  166. "External Loopback test",
  167. "DDR DMA test",
  168. "Link test"
  169. };
  170. #define ETHTOOL_TESTS_NUM ARRAY_SIZE(et_self_tests)
  171. #define BE_MAC_LOOPBACK 0x0
  172. #define BE_PHY_LOOPBACK 0x1
  173. #define BE_ONE_PORT_EXT_LOOPBACK 0x2
  174. #define BE_NO_LOOPBACK 0xff
  175. static void be_get_drvinfo(struct net_device *netdev,
  176. struct ethtool_drvinfo *drvinfo)
  177. {
  178. struct be_adapter *adapter = netdev_priv(netdev);
  179. strlcpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver));
  180. strlcpy(drvinfo->version, DRV_VER, sizeof(drvinfo->version));
  181. if (!memcmp(adapter->fw_ver, adapter->fw_on_flash, FW_VER_LEN))
  182. strlcpy(drvinfo->fw_version, adapter->fw_ver,
  183. sizeof(drvinfo->fw_version));
  184. else
  185. snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
  186. "%s [%s]", adapter->fw_ver, adapter->fw_on_flash);
  187. strlcpy(drvinfo->bus_info, pci_name(adapter->pdev),
  188. sizeof(drvinfo->bus_info));
  189. drvinfo->testinfo_len = 0;
  190. drvinfo->regdump_len = 0;
  191. drvinfo->eedump_len = 0;
  192. }
  193. static u32 lancer_cmd_get_file_len(struct be_adapter *adapter, u8 *file_name)
  194. {
  195. u32 data_read = 0, eof;
  196. u8 addn_status;
  197. struct be_dma_mem data_len_cmd;
  198. int status;
  199. memset(&data_len_cmd, 0, sizeof(data_len_cmd));
  200. /* data_offset and data_size should be 0 to get reg len */
  201. status = lancer_cmd_read_object(adapter, &data_len_cmd, 0, 0,
  202. file_name, &data_read, &eof,
  203. &addn_status);
  204. return data_read;
  205. }
  206. static int lancer_cmd_read_file(struct be_adapter *adapter, u8 *file_name,
  207. u32 buf_len, void *buf)
  208. {
  209. struct be_dma_mem read_cmd;
  210. u32 read_len = 0, total_read_len = 0, chunk_size;
  211. u32 eof = 0;
  212. u8 addn_status;
  213. int status = 0;
  214. read_cmd.size = LANCER_READ_FILE_CHUNK;
  215. read_cmd.va = pci_alloc_consistent(adapter->pdev, read_cmd.size,
  216. &read_cmd.dma);
  217. if (!read_cmd.va) {
  218. dev_err(&adapter->pdev->dev,
  219. "Memory allocation failure while reading dump\n");
  220. return -ENOMEM;
  221. }
  222. while ((total_read_len < buf_len) && !eof) {
  223. chunk_size = min_t(u32, (buf_len - total_read_len),
  224. LANCER_READ_FILE_CHUNK);
  225. chunk_size = ALIGN(chunk_size, 4);
  226. status = lancer_cmd_read_object(adapter, &read_cmd, chunk_size,
  227. total_read_len, file_name,
  228. &read_len, &eof, &addn_status);
  229. if (!status) {
  230. memcpy(buf + total_read_len, read_cmd.va, read_len);
  231. total_read_len += read_len;
  232. eof &= LANCER_READ_FILE_EOF_MASK;
  233. } else {
  234. status = -EIO;
  235. break;
  236. }
  237. }
  238. pci_free_consistent(adapter->pdev, read_cmd.size, read_cmd.va,
  239. read_cmd.dma);
  240. return status;
  241. }
  242. static int be_get_reg_len(struct net_device *netdev)
  243. {
  244. struct be_adapter *adapter = netdev_priv(netdev);
  245. u32 log_size = 0;
  246. if (!check_privilege(adapter, MAX_PRIVILEGES))
  247. return 0;
  248. if (be_physfn(adapter)) {
  249. if (lancer_chip(adapter))
  250. log_size = lancer_cmd_get_file_len(adapter,
  251. LANCER_FW_DUMP_FILE);
  252. else
  253. be_cmd_get_reg_len(adapter, &log_size);
  254. }
  255. return log_size;
  256. }
  257. static void
  258. be_get_regs(struct net_device *netdev, struct ethtool_regs *regs, void *buf)
  259. {
  260. struct be_adapter *adapter = netdev_priv(netdev);
  261. if (be_physfn(adapter)) {
  262. memset(buf, 0, regs->len);
  263. if (lancer_chip(adapter))
  264. lancer_cmd_read_file(adapter, LANCER_FW_DUMP_FILE,
  265. regs->len, buf);
  266. else
  267. be_cmd_get_regs(adapter, regs->len, buf);
  268. }
  269. }
  270. static int be_get_coalesce(struct net_device *netdev,
  271. struct ethtool_coalesce *et)
  272. {
  273. struct be_adapter *adapter = netdev_priv(netdev);
  274. struct be_aic_obj *aic = &adapter->aic_obj[0];
  275. et->rx_coalesce_usecs = aic->prev_eqd;
  276. et->rx_coalesce_usecs_high = aic->max_eqd;
  277. et->rx_coalesce_usecs_low = aic->min_eqd;
  278. et->tx_coalesce_usecs = aic->prev_eqd;
  279. et->tx_coalesce_usecs_high = aic->max_eqd;
  280. et->tx_coalesce_usecs_low = aic->min_eqd;
  281. et->use_adaptive_rx_coalesce = aic->enable;
  282. et->use_adaptive_tx_coalesce = aic->enable;
  283. return 0;
  284. }
  285. /* TX attributes are ignored. Only RX attributes are considered
  286. * eqd cmd is issued in the worker thread.
  287. */
  288. static int be_set_coalesce(struct net_device *netdev,
  289. struct ethtool_coalesce *et)
  290. {
  291. struct be_adapter *adapter = netdev_priv(netdev);
  292. struct be_aic_obj *aic = &adapter->aic_obj[0];
  293. struct be_eq_obj *eqo;
  294. int i;
  295. for_all_evt_queues(adapter, eqo, i) {
  296. aic->enable = et->use_adaptive_rx_coalesce;
  297. aic->max_eqd = min(et->rx_coalesce_usecs_high, BE_MAX_EQD);
  298. aic->min_eqd = min(et->rx_coalesce_usecs_low, aic->max_eqd);
  299. aic->et_eqd = min(et->rx_coalesce_usecs, aic->max_eqd);
  300. aic->et_eqd = max(aic->et_eqd, aic->min_eqd);
  301. aic++;
  302. }
  303. return 0;
  304. }
  305. static void be_get_ethtool_stats(struct net_device *netdev,
  306. struct ethtool_stats *stats, uint64_t *data)
  307. {
  308. struct be_adapter *adapter = netdev_priv(netdev);
  309. struct be_rx_obj *rxo;
  310. struct be_tx_obj *txo;
  311. void *p;
  312. unsigned int i, j, base = 0, start;
  313. for (i = 0; i < ETHTOOL_STATS_NUM; i++) {
  314. p = (u8 *)&adapter->drv_stats + et_stats[i].offset;
  315. data[i] = *(u32 *)p;
  316. }
  317. base += ETHTOOL_STATS_NUM;
  318. for_all_rx_queues(adapter, rxo, j) {
  319. struct be_rx_stats *stats = rx_stats(rxo);
  320. do {
  321. start = u64_stats_fetch_begin_irq(&stats->sync);
  322. data[base] = stats->rx_bytes;
  323. data[base + 1] = stats->rx_pkts;
  324. } while (u64_stats_fetch_retry_irq(&stats->sync, start));
  325. for (i = 2; i < ETHTOOL_RXSTATS_NUM; i++) {
  326. p = (u8 *)stats + et_rx_stats[i].offset;
  327. data[base + i] = *(u32 *)p;
  328. }
  329. base += ETHTOOL_RXSTATS_NUM;
  330. }
  331. for_all_tx_queues(adapter, txo, j) {
  332. struct be_tx_stats *stats = tx_stats(txo);
  333. do {
  334. start = u64_stats_fetch_begin_irq(&stats->sync_compl);
  335. data[base] = stats->tx_compl;
  336. } while (u64_stats_fetch_retry_irq(&stats->sync_compl, start));
  337. do {
  338. start = u64_stats_fetch_begin_irq(&stats->sync);
  339. for (i = 1; i < ETHTOOL_TXSTATS_NUM; i++) {
  340. p = (u8 *)stats + et_tx_stats[i].offset;
  341. data[base + i] =
  342. (et_tx_stats[i].size == sizeof(u64)) ?
  343. *(u64 *)p : *(u32 *)p;
  344. }
  345. } while (u64_stats_fetch_retry_irq(&stats->sync, start));
  346. base += ETHTOOL_TXSTATS_NUM;
  347. }
  348. }
  349. static void be_get_stat_strings(struct net_device *netdev, uint32_t stringset,
  350. uint8_t *data)
  351. {
  352. struct be_adapter *adapter = netdev_priv(netdev);
  353. int i, j;
  354. switch (stringset) {
  355. case ETH_SS_STATS:
  356. for (i = 0; i < ETHTOOL_STATS_NUM; i++) {
  357. memcpy(data, et_stats[i].desc, ETH_GSTRING_LEN);
  358. data += ETH_GSTRING_LEN;
  359. }
  360. for (i = 0; i < adapter->num_rx_qs; i++) {
  361. for (j = 0; j < ETHTOOL_RXSTATS_NUM; j++) {
  362. sprintf(data, "rxq%d: %s", i,
  363. et_rx_stats[j].desc);
  364. data += ETH_GSTRING_LEN;
  365. }
  366. }
  367. for (i = 0; i < adapter->num_tx_qs; i++) {
  368. for (j = 0; j < ETHTOOL_TXSTATS_NUM; j++) {
  369. sprintf(data, "txq%d: %s", i,
  370. et_tx_stats[j].desc);
  371. data += ETH_GSTRING_LEN;
  372. }
  373. }
  374. break;
  375. case ETH_SS_TEST:
  376. for (i = 0; i < ETHTOOL_TESTS_NUM; i++) {
  377. memcpy(data, et_self_tests[i], ETH_GSTRING_LEN);
  378. data += ETH_GSTRING_LEN;
  379. }
  380. break;
  381. }
  382. }
  383. static int be_get_sset_count(struct net_device *netdev, int stringset)
  384. {
  385. struct be_adapter *adapter = netdev_priv(netdev);
  386. switch (stringset) {
  387. case ETH_SS_TEST:
  388. return ETHTOOL_TESTS_NUM;
  389. case ETH_SS_STATS:
  390. return ETHTOOL_STATS_NUM +
  391. adapter->num_rx_qs * ETHTOOL_RXSTATS_NUM +
  392. adapter->num_tx_qs * ETHTOOL_TXSTATS_NUM;
  393. default:
  394. return -EINVAL;
  395. }
  396. }
  397. static u32 be_get_port_type(u32 phy_type, u32 dac_cable_len)
  398. {
  399. u32 port;
  400. switch (phy_type) {
  401. case PHY_TYPE_BASET_1GB:
  402. case PHY_TYPE_BASEX_1GB:
  403. case PHY_TYPE_SGMII:
  404. port = PORT_TP;
  405. break;
  406. case PHY_TYPE_SFP_PLUS_10GB:
  407. port = dac_cable_len ? PORT_DA : PORT_FIBRE;
  408. break;
  409. case PHY_TYPE_XFP_10GB:
  410. case PHY_TYPE_SFP_1GB:
  411. port = PORT_FIBRE;
  412. break;
  413. case PHY_TYPE_BASET_10GB:
  414. port = PORT_TP;
  415. break;
  416. default:
  417. port = PORT_OTHER;
  418. }
  419. return port;
  420. }
  421. static u32 convert_to_et_setting(u32 if_type, u32 if_speeds)
  422. {
  423. u32 val = 0;
  424. switch (if_type) {
  425. case PHY_TYPE_BASET_1GB:
  426. case PHY_TYPE_BASEX_1GB:
  427. case PHY_TYPE_SGMII:
  428. val |= SUPPORTED_TP;
  429. if (if_speeds & BE_SUPPORTED_SPEED_1GBPS)
  430. val |= SUPPORTED_1000baseT_Full;
  431. if (if_speeds & BE_SUPPORTED_SPEED_100MBPS)
  432. val |= SUPPORTED_100baseT_Full;
  433. if (if_speeds & BE_SUPPORTED_SPEED_10MBPS)
  434. val |= SUPPORTED_10baseT_Full;
  435. break;
  436. case PHY_TYPE_KX4_10GB:
  437. val |= SUPPORTED_Backplane;
  438. if (if_speeds & BE_SUPPORTED_SPEED_1GBPS)
  439. val |= SUPPORTED_1000baseKX_Full;
  440. if (if_speeds & BE_SUPPORTED_SPEED_10GBPS)
  441. val |= SUPPORTED_10000baseKX4_Full;
  442. break;
  443. case PHY_TYPE_KR_10GB:
  444. val |= SUPPORTED_Backplane |
  445. SUPPORTED_10000baseKR_Full;
  446. break;
  447. case PHY_TYPE_SFP_PLUS_10GB:
  448. case PHY_TYPE_XFP_10GB:
  449. case PHY_TYPE_SFP_1GB:
  450. val |= SUPPORTED_FIBRE;
  451. if (if_speeds & BE_SUPPORTED_SPEED_10GBPS)
  452. val |= SUPPORTED_10000baseT_Full;
  453. if (if_speeds & BE_SUPPORTED_SPEED_1GBPS)
  454. val |= SUPPORTED_1000baseT_Full;
  455. break;
  456. case PHY_TYPE_BASET_10GB:
  457. val |= SUPPORTED_TP;
  458. if (if_speeds & BE_SUPPORTED_SPEED_10GBPS)
  459. val |= SUPPORTED_10000baseT_Full;
  460. if (if_speeds & BE_SUPPORTED_SPEED_1GBPS)
  461. val |= SUPPORTED_1000baseT_Full;
  462. if (if_speeds & BE_SUPPORTED_SPEED_100MBPS)
  463. val |= SUPPORTED_100baseT_Full;
  464. break;
  465. default:
  466. val |= SUPPORTED_TP;
  467. }
  468. return val;
  469. }
  470. bool be_pause_supported(struct be_adapter *adapter)
  471. {
  472. return (adapter->phy.interface_type == PHY_TYPE_SFP_PLUS_10GB ||
  473. adapter->phy.interface_type == PHY_TYPE_XFP_10GB) ?
  474. false : true;
  475. }
  476. static int be_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
  477. {
  478. struct be_adapter *adapter = netdev_priv(netdev);
  479. u8 link_status;
  480. u16 link_speed = 0;
  481. int status;
  482. u32 auto_speeds;
  483. u32 fixed_speeds;
  484. u32 dac_cable_len;
  485. u16 interface_type;
  486. if (adapter->phy.link_speed < 0) {
  487. status = be_cmd_link_status_query(adapter, &link_speed,
  488. &link_status, 0);
  489. if (!status)
  490. be_link_status_update(adapter, link_status);
  491. ethtool_cmd_speed_set(ecmd, link_speed);
  492. status = be_cmd_get_phy_info(adapter);
  493. if (!status) {
  494. interface_type = adapter->phy.interface_type;
  495. auto_speeds = adapter->phy.auto_speeds_supported;
  496. fixed_speeds = adapter->phy.fixed_speeds_supported;
  497. dac_cable_len = adapter->phy.dac_cable_len;
  498. ecmd->supported =
  499. convert_to_et_setting(interface_type,
  500. auto_speeds |
  501. fixed_speeds);
  502. ecmd->advertising =
  503. convert_to_et_setting(interface_type,
  504. auto_speeds);
  505. ecmd->port = be_get_port_type(interface_type,
  506. dac_cable_len);
  507. if (adapter->phy.auto_speeds_supported) {
  508. ecmd->supported |= SUPPORTED_Autoneg;
  509. ecmd->autoneg = AUTONEG_ENABLE;
  510. ecmd->advertising |= ADVERTISED_Autoneg;
  511. }
  512. ecmd->supported |= SUPPORTED_Pause;
  513. if (be_pause_supported(adapter))
  514. ecmd->advertising |= ADVERTISED_Pause;
  515. switch (adapter->phy.interface_type) {
  516. case PHY_TYPE_KR_10GB:
  517. case PHY_TYPE_KX4_10GB:
  518. ecmd->transceiver = XCVR_INTERNAL;
  519. break;
  520. default:
  521. ecmd->transceiver = XCVR_EXTERNAL;
  522. break;
  523. }
  524. } else {
  525. ecmd->port = PORT_OTHER;
  526. ecmd->autoneg = AUTONEG_DISABLE;
  527. ecmd->transceiver = XCVR_DUMMY1;
  528. }
  529. /* Save for future use */
  530. adapter->phy.link_speed = ethtool_cmd_speed(ecmd);
  531. adapter->phy.port_type = ecmd->port;
  532. adapter->phy.transceiver = ecmd->transceiver;
  533. adapter->phy.autoneg = ecmd->autoneg;
  534. adapter->phy.advertising = ecmd->advertising;
  535. adapter->phy.supported = ecmd->supported;
  536. } else {
  537. ethtool_cmd_speed_set(ecmd, adapter->phy.link_speed);
  538. ecmd->port = adapter->phy.port_type;
  539. ecmd->transceiver = adapter->phy.transceiver;
  540. ecmd->autoneg = adapter->phy.autoneg;
  541. ecmd->advertising = adapter->phy.advertising;
  542. ecmd->supported = adapter->phy.supported;
  543. }
  544. ecmd->duplex = netif_carrier_ok(netdev) ? DUPLEX_FULL : DUPLEX_UNKNOWN;
  545. ecmd->phy_address = adapter->port_num;
  546. return 0;
  547. }
  548. static void be_get_ringparam(struct net_device *netdev,
  549. struct ethtool_ringparam *ring)
  550. {
  551. struct be_adapter *adapter = netdev_priv(netdev);
  552. ring->rx_max_pending = ring->rx_pending = adapter->rx_obj[0].q.len;
  553. ring->tx_max_pending = ring->tx_pending = adapter->tx_obj[0].q.len;
  554. }
  555. static void
  556. be_get_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *ecmd)
  557. {
  558. struct be_adapter *adapter = netdev_priv(netdev);
  559. be_cmd_get_flow_control(adapter, &ecmd->tx_pause, &ecmd->rx_pause);
  560. ecmd->autoneg = adapter->phy.fc_autoneg;
  561. }
  562. static int
  563. be_set_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *ecmd)
  564. {
  565. struct be_adapter *adapter = netdev_priv(netdev);
  566. int status;
  567. if (ecmd->autoneg != adapter->phy.fc_autoneg)
  568. return -EINVAL;
  569. adapter->tx_fc = ecmd->tx_pause;
  570. adapter->rx_fc = ecmd->rx_pause;
  571. status = be_cmd_set_flow_control(adapter,
  572. adapter->tx_fc, adapter->rx_fc);
  573. if (status)
  574. dev_warn(&adapter->pdev->dev, "Pause param set failed.\n");
  575. return status;
  576. }
  577. static int be_set_phys_id(struct net_device *netdev,
  578. enum ethtool_phys_id_state state)
  579. {
  580. struct be_adapter *adapter = netdev_priv(netdev);
  581. switch (state) {
  582. case ETHTOOL_ID_ACTIVE:
  583. be_cmd_get_beacon_state(adapter, adapter->hba_port_num,
  584. &adapter->beacon_state);
  585. return 1; /* cycle on/off once per second */
  586. case ETHTOOL_ID_ON:
  587. be_cmd_set_beacon_state(adapter, adapter->hba_port_num, 0, 0,
  588. BEACON_STATE_ENABLED);
  589. break;
  590. case ETHTOOL_ID_OFF:
  591. be_cmd_set_beacon_state(adapter, adapter->hba_port_num, 0, 0,
  592. BEACON_STATE_DISABLED);
  593. break;
  594. case ETHTOOL_ID_INACTIVE:
  595. be_cmd_set_beacon_state(adapter, adapter->hba_port_num, 0, 0,
  596. adapter->beacon_state);
  597. }
  598. return 0;
  599. }
  600. static int be_set_dump(struct net_device *netdev, struct ethtool_dump *dump)
  601. {
  602. struct be_adapter *adapter = netdev_priv(netdev);
  603. struct device *dev = &adapter->pdev->dev;
  604. int status;
  605. if (!lancer_chip(adapter)) {
  606. dev_err(dev, "FW dump not supported\n");
  607. return -EOPNOTSUPP;
  608. }
  609. if (dump_present(adapter)) {
  610. dev_err(dev, "Previous dump not cleared, not forcing dump\n");
  611. return 0;
  612. }
  613. switch (dump->flag) {
  614. case LANCER_INITIATE_FW_DUMP:
  615. status = lancer_initiate_dump(adapter);
  616. if (!status)
  617. dev_info(dev, "F/w dump initiated successfully\n");
  618. break;
  619. default:
  620. dev_err(dev, "Invalid dump level: 0x%x\n", dump->flag);
  621. return -EINVAL;
  622. }
  623. return status;
  624. }
  625. static void be_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
  626. {
  627. struct be_adapter *adapter = netdev_priv(netdev);
  628. if (adapter->wol_cap & BE_WOL_CAP) {
  629. wol->supported |= WAKE_MAGIC;
  630. if (adapter->wol_en)
  631. wol->wolopts |= WAKE_MAGIC;
  632. } else {
  633. wol->wolopts = 0;
  634. }
  635. memset(&wol->sopass, 0, sizeof(wol->sopass));
  636. }
  637. static int be_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
  638. {
  639. struct be_adapter *adapter = netdev_priv(netdev);
  640. if (wol->wolopts & ~WAKE_MAGIC)
  641. return -EOPNOTSUPP;
  642. if (!(adapter->wol_cap & BE_WOL_CAP)) {
  643. dev_warn(&adapter->pdev->dev, "WOL not supported\n");
  644. return -EOPNOTSUPP;
  645. }
  646. if (wol->wolopts & WAKE_MAGIC)
  647. adapter->wol_en = true;
  648. else
  649. adapter->wol_en = false;
  650. return 0;
  651. }
  652. static int be_test_ddr_dma(struct be_adapter *adapter)
  653. {
  654. int ret, i;
  655. struct be_dma_mem ddrdma_cmd;
  656. static const u64 pattern[2] = {
  657. 0x5a5a5a5a5a5a5a5aULL, 0xa5a5a5a5a5a5a5a5ULL
  658. };
  659. ddrdma_cmd.size = sizeof(struct be_cmd_req_ddrdma_test);
  660. ddrdma_cmd.va = dma_alloc_coherent(&adapter->pdev->dev, ddrdma_cmd.size,
  661. &ddrdma_cmd.dma, GFP_KERNEL);
  662. if (!ddrdma_cmd.va)
  663. return -ENOMEM;
  664. for (i = 0; i < 2; i++) {
  665. ret = be_cmd_ddr_dma_test(adapter, pattern[i],
  666. 4096, &ddrdma_cmd);
  667. if (ret != 0)
  668. goto err;
  669. }
  670. err:
  671. dma_free_coherent(&adapter->pdev->dev, ddrdma_cmd.size, ddrdma_cmd.va,
  672. ddrdma_cmd.dma);
  673. return ret;
  674. }
  675. static u64 be_loopback_test(struct be_adapter *adapter, u8 loopback_type,
  676. u64 *status)
  677. {
  678. be_cmd_set_loopback(adapter, adapter->hba_port_num, loopback_type, 1);
  679. *status = be_cmd_loopback_test(adapter, adapter->hba_port_num,
  680. loopback_type, 1500, 2, 0xabc);
  681. be_cmd_set_loopback(adapter, adapter->hba_port_num, BE_NO_LOOPBACK, 1);
  682. return *status;
  683. }
  684. static void be_self_test(struct net_device *netdev, struct ethtool_test *test,
  685. u64 *data)
  686. {
  687. struct be_adapter *adapter = netdev_priv(netdev);
  688. int status;
  689. u8 link_status = 0;
  690. if (adapter->function_caps & BE_FUNCTION_CAPS_SUPER_NIC) {
  691. dev_err(&adapter->pdev->dev, "Self test not supported\n");
  692. test->flags |= ETH_TEST_FL_FAILED;
  693. return;
  694. }
  695. memset(data, 0, sizeof(u64) * ETHTOOL_TESTS_NUM);
  696. if (test->flags & ETH_TEST_FL_OFFLINE) {
  697. if (be_loopback_test(adapter, BE_MAC_LOOPBACK, &data[0]) != 0)
  698. test->flags |= ETH_TEST_FL_FAILED;
  699. if (be_loopback_test(adapter, BE_PHY_LOOPBACK, &data[1]) != 0)
  700. test->flags |= ETH_TEST_FL_FAILED;
  701. if (test->flags & ETH_TEST_FL_EXTERNAL_LB) {
  702. if (be_loopback_test(adapter, BE_ONE_PORT_EXT_LOOPBACK,
  703. &data[2]) != 0)
  704. test->flags |= ETH_TEST_FL_FAILED;
  705. test->flags |= ETH_TEST_FL_EXTERNAL_LB_DONE;
  706. }
  707. }
  708. if (!lancer_chip(adapter) && be_test_ddr_dma(adapter) != 0) {
  709. data[3] = 1;
  710. test->flags |= ETH_TEST_FL_FAILED;
  711. }
  712. status = be_cmd_link_status_query(adapter, NULL, &link_status, 0);
  713. if (status) {
  714. test->flags |= ETH_TEST_FL_FAILED;
  715. data[4] = -1;
  716. } else if (!link_status) {
  717. test->flags |= ETH_TEST_FL_FAILED;
  718. data[4] = 1;
  719. }
  720. }
  721. static int be_do_flash(struct net_device *netdev, struct ethtool_flash *efl)
  722. {
  723. struct be_adapter *adapter = netdev_priv(netdev);
  724. return be_load_fw(adapter, efl->data);
  725. }
  726. static int be_get_eeprom_len(struct net_device *netdev)
  727. {
  728. struct be_adapter *adapter = netdev_priv(netdev);
  729. if (!check_privilege(adapter, MAX_PRIVILEGES))
  730. return 0;
  731. if (lancer_chip(adapter)) {
  732. if (be_physfn(adapter))
  733. return lancer_cmd_get_file_len(adapter,
  734. LANCER_VPD_PF_FILE);
  735. else
  736. return lancer_cmd_get_file_len(adapter,
  737. LANCER_VPD_VF_FILE);
  738. } else {
  739. return BE_READ_SEEPROM_LEN;
  740. }
  741. }
  742. static int be_read_eeprom(struct net_device *netdev,
  743. struct ethtool_eeprom *eeprom, uint8_t *data)
  744. {
  745. struct be_adapter *adapter = netdev_priv(netdev);
  746. struct be_dma_mem eeprom_cmd;
  747. struct be_cmd_resp_seeprom_read *resp;
  748. int status;
  749. if (!eeprom->len)
  750. return -EINVAL;
  751. if (lancer_chip(adapter)) {
  752. if (be_physfn(adapter))
  753. return lancer_cmd_read_file(adapter, LANCER_VPD_PF_FILE,
  754. eeprom->len, data);
  755. else
  756. return lancer_cmd_read_file(adapter, LANCER_VPD_VF_FILE,
  757. eeprom->len, data);
  758. }
  759. eeprom->magic = BE_VENDOR_ID | (adapter->pdev->device<<16);
  760. memset(&eeprom_cmd, 0, sizeof(struct be_dma_mem));
  761. eeprom_cmd.size = sizeof(struct be_cmd_req_seeprom_read);
  762. eeprom_cmd.va = dma_alloc_coherent(&adapter->pdev->dev, eeprom_cmd.size,
  763. &eeprom_cmd.dma, GFP_KERNEL);
  764. if (!eeprom_cmd.va)
  765. return -ENOMEM;
  766. status = be_cmd_get_seeprom_data(adapter, &eeprom_cmd);
  767. if (!status) {
  768. resp = eeprom_cmd.va;
  769. memcpy(data, resp->seeprom_data + eeprom->offset, eeprom->len);
  770. }
  771. dma_free_coherent(&adapter->pdev->dev, eeprom_cmd.size, eeprom_cmd.va,
  772. eeprom_cmd.dma);
  773. return status;
  774. }
  775. static u32 be_get_msg_level(struct net_device *netdev)
  776. {
  777. struct be_adapter *adapter = netdev_priv(netdev);
  778. return adapter->msg_enable;
  779. }
  780. static void be_set_msg_level(struct net_device *netdev, u32 level)
  781. {
  782. struct be_adapter *adapter = netdev_priv(netdev);
  783. if (adapter->msg_enable == level)
  784. return;
  785. if ((level & NETIF_MSG_HW) != (adapter->msg_enable & NETIF_MSG_HW))
  786. if (BEx_chip(adapter))
  787. be_cmd_set_fw_log_level(adapter, level & NETIF_MSG_HW ?
  788. FW_LOG_LEVEL_DEFAULT :
  789. FW_LOG_LEVEL_FATAL);
  790. adapter->msg_enable = level;
  791. return;
  792. }
  793. static u64 be_get_rss_hash_opts(struct be_adapter *adapter, u64 flow_type)
  794. {
  795. u64 data = 0;
  796. switch (flow_type) {
  797. case TCP_V4_FLOW:
  798. if (adapter->rss_info.rss_flags & RSS_ENABLE_IPV4)
  799. data |= RXH_IP_DST | RXH_IP_SRC;
  800. if (adapter->rss_info.rss_flags & RSS_ENABLE_TCP_IPV4)
  801. data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
  802. break;
  803. case UDP_V4_FLOW:
  804. if (adapter->rss_info.rss_flags & RSS_ENABLE_IPV4)
  805. data |= RXH_IP_DST | RXH_IP_SRC;
  806. if (adapter->rss_info.rss_flags & RSS_ENABLE_UDP_IPV4)
  807. data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
  808. break;
  809. case TCP_V6_FLOW:
  810. if (adapter->rss_info.rss_flags & RSS_ENABLE_IPV6)
  811. data |= RXH_IP_DST | RXH_IP_SRC;
  812. if (adapter->rss_info.rss_flags & RSS_ENABLE_TCP_IPV6)
  813. data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
  814. break;
  815. case UDP_V6_FLOW:
  816. if (adapter->rss_info.rss_flags & RSS_ENABLE_IPV6)
  817. data |= RXH_IP_DST | RXH_IP_SRC;
  818. if (adapter->rss_info.rss_flags & RSS_ENABLE_UDP_IPV6)
  819. data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
  820. break;
  821. }
  822. return data;
  823. }
  824. static int be_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd,
  825. u32 *rule_locs)
  826. {
  827. struct be_adapter *adapter = netdev_priv(netdev);
  828. if (!be_multi_rxq(adapter)) {
  829. dev_info(&adapter->pdev->dev,
  830. "ethtool::get_rxnfc: RX flow hashing is disabled\n");
  831. return -EINVAL;
  832. }
  833. switch (cmd->cmd) {
  834. case ETHTOOL_GRXFH:
  835. cmd->data = be_get_rss_hash_opts(adapter, cmd->flow_type);
  836. break;
  837. case ETHTOOL_GRXRINGS:
  838. cmd->data = adapter->num_rx_qs - 1;
  839. break;
  840. default:
  841. return -EINVAL;
  842. }
  843. return 0;
  844. }
  845. static int be_set_rss_hash_opts(struct be_adapter *adapter,
  846. struct ethtool_rxnfc *cmd)
  847. {
  848. struct be_rx_obj *rxo;
  849. int status = 0, i, j;
  850. u8 rsstable[128];
  851. u32 rss_flags = adapter->rss_info.rss_flags;
  852. if (cmd->data != L3_RSS_FLAGS &&
  853. cmd->data != (L3_RSS_FLAGS | L4_RSS_FLAGS))
  854. return -EINVAL;
  855. switch (cmd->flow_type) {
  856. case TCP_V4_FLOW:
  857. if (cmd->data == L3_RSS_FLAGS)
  858. rss_flags &= ~RSS_ENABLE_TCP_IPV4;
  859. else if (cmd->data == (L3_RSS_FLAGS | L4_RSS_FLAGS))
  860. rss_flags |= RSS_ENABLE_IPV4 |
  861. RSS_ENABLE_TCP_IPV4;
  862. break;
  863. case TCP_V6_FLOW:
  864. if (cmd->data == L3_RSS_FLAGS)
  865. rss_flags &= ~RSS_ENABLE_TCP_IPV6;
  866. else if (cmd->data == (L3_RSS_FLAGS | L4_RSS_FLAGS))
  867. rss_flags |= RSS_ENABLE_IPV6 |
  868. RSS_ENABLE_TCP_IPV6;
  869. break;
  870. case UDP_V4_FLOW:
  871. if ((cmd->data == (L3_RSS_FLAGS | L4_RSS_FLAGS)) &&
  872. BEx_chip(adapter))
  873. return -EINVAL;
  874. if (cmd->data == L3_RSS_FLAGS)
  875. rss_flags &= ~RSS_ENABLE_UDP_IPV4;
  876. else if (cmd->data == (L3_RSS_FLAGS | L4_RSS_FLAGS))
  877. rss_flags |= RSS_ENABLE_IPV4 |
  878. RSS_ENABLE_UDP_IPV4;
  879. break;
  880. case UDP_V6_FLOW:
  881. if ((cmd->data == (L3_RSS_FLAGS | L4_RSS_FLAGS)) &&
  882. BEx_chip(adapter))
  883. return -EINVAL;
  884. if (cmd->data == L3_RSS_FLAGS)
  885. rss_flags &= ~RSS_ENABLE_UDP_IPV6;
  886. else if (cmd->data == (L3_RSS_FLAGS | L4_RSS_FLAGS))
  887. rss_flags |= RSS_ENABLE_IPV6 |
  888. RSS_ENABLE_UDP_IPV6;
  889. break;
  890. default:
  891. return -EINVAL;
  892. }
  893. if (rss_flags == adapter->rss_info.rss_flags)
  894. return status;
  895. if (be_multi_rxq(adapter)) {
  896. for (j = 0; j < 128; j += adapter->num_rx_qs - 1) {
  897. for_all_rss_queues(adapter, rxo, i) {
  898. if ((j + i) >= 128)
  899. break;
  900. rsstable[j + i] = rxo->rss_id;
  901. }
  902. }
  903. }
  904. status = be_cmd_rss_config(adapter, adapter->rss_info.rsstable,
  905. rss_flags, 128, adapter->rss_info.rss_hkey);
  906. if (!status)
  907. adapter->rss_info.rss_flags = rss_flags;
  908. return status;
  909. }
  910. static int be_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
  911. {
  912. struct be_adapter *adapter = netdev_priv(netdev);
  913. int status = 0;
  914. if (!be_multi_rxq(adapter)) {
  915. dev_err(&adapter->pdev->dev,
  916. "ethtool::set_rxnfc: RX flow hashing is disabled\n");
  917. return -EINVAL;
  918. }
  919. switch (cmd->cmd) {
  920. case ETHTOOL_SRXFH:
  921. status = be_set_rss_hash_opts(adapter, cmd);
  922. break;
  923. default:
  924. return -EINVAL;
  925. }
  926. return status;
  927. }
  928. static void be_get_channels(struct net_device *netdev,
  929. struct ethtool_channels *ch)
  930. {
  931. struct be_adapter *adapter = netdev_priv(netdev);
  932. ch->combined_count = adapter->num_evt_qs;
  933. ch->max_combined = be_max_qs(adapter);
  934. }
  935. static int be_set_channels(struct net_device *netdev,
  936. struct ethtool_channels *ch)
  937. {
  938. struct be_adapter *adapter = netdev_priv(netdev);
  939. if (ch->rx_count || ch->tx_count || ch->other_count ||
  940. !ch->combined_count || ch->combined_count > be_max_qs(adapter))
  941. return -EINVAL;
  942. adapter->cfg_num_qs = ch->combined_count;
  943. return be_update_queues(adapter);
  944. }
  945. static u32 be_get_rxfh_indir_size(struct net_device *netdev)
  946. {
  947. return RSS_INDIR_TABLE_LEN;
  948. }
  949. static u32 be_get_rxfh_key_size(struct net_device *netdev)
  950. {
  951. return RSS_HASH_KEY_LEN;
  952. }
  953. static int be_get_rxfh(struct net_device *netdev, u32 *indir, u8 *hkey)
  954. {
  955. struct be_adapter *adapter = netdev_priv(netdev);
  956. int i;
  957. struct rss_info *rss = &adapter->rss_info;
  958. if (indir) {
  959. for (i = 0; i < RSS_INDIR_TABLE_LEN; i++)
  960. indir[i] = rss->rss_queue[i];
  961. }
  962. if (hkey)
  963. memcpy(hkey, rss->rss_hkey, RSS_HASH_KEY_LEN);
  964. return 0;
  965. }
  966. static int be_set_rxfh(struct net_device *netdev, const u32 *indir,
  967. const u8 *hkey)
  968. {
  969. int rc = 0, i, j;
  970. struct be_adapter *adapter = netdev_priv(netdev);
  971. u8 rsstable[RSS_INDIR_TABLE_LEN];
  972. if (indir) {
  973. struct be_rx_obj *rxo;
  974. for (i = 0; i < RSS_INDIR_TABLE_LEN; i++) {
  975. j = indir[i];
  976. rxo = &adapter->rx_obj[j];
  977. rsstable[i] = rxo->rss_id;
  978. adapter->rss_info.rss_queue[i] = j;
  979. }
  980. } else {
  981. memcpy(rsstable, adapter->rss_info.rsstable,
  982. RSS_INDIR_TABLE_LEN);
  983. }
  984. if (!hkey)
  985. hkey = adapter->rss_info.rss_hkey;
  986. rc = be_cmd_rss_config(adapter, rsstable,
  987. adapter->rss_info.rss_flags,
  988. RSS_INDIR_TABLE_LEN, hkey);
  989. if (rc) {
  990. adapter->rss_info.rss_flags = RSS_ENABLE_NONE;
  991. return -EIO;
  992. }
  993. memcpy(adapter->rss_info.rss_hkey, hkey, RSS_HASH_KEY_LEN);
  994. memcpy(adapter->rss_info.rsstable, rsstable,
  995. RSS_INDIR_TABLE_LEN);
  996. return 0;
  997. }
  998. const struct ethtool_ops be_ethtool_ops = {
  999. .get_settings = be_get_settings,
  1000. .get_drvinfo = be_get_drvinfo,
  1001. .get_wol = be_get_wol,
  1002. .set_wol = be_set_wol,
  1003. .get_link = ethtool_op_get_link,
  1004. .get_eeprom_len = be_get_eeprom_len,
  1005. .get_eeprom = be_read_eeprom,
  1006. .get_coalesce = be_get_coalesce,
  1007. .set_coalesce = be_set_coalesce,
  1008. .get_ringparam = be_get_ringparam,
  1009. .get_pauseparam = be_get_pauseparam,
  1010. .set_pauseparam = be_set_pauseparam,
  1011. .get_strings = be_get_stat_strings,
  1012. .set_phys_id = be_set_phys_id,
  1013. .set_dump = be_set_dump,
  1014. .get_msglevel = be_get_msg_level,
  1015. .set_msglevel = be_set_msg_level,
  1016. .get_sset_count = be_get_sset_count,
  1017. .get_ethtool_stats = be_get_ethtool_stats,
  1018. .get_regs_len = be_get_reg_len,
  1019. .get_regs = be_get_regs,
  1020. .flash_device = be_do_flash,
  1021. .self_test = be_self_test,
  1022. .get_rxnfc = be_get_rxnfc,
  1023. .set_rxnfc = be_set_rxnfc,
  1024. .get_rxfh_indir_size = be_get_rxfh_indir_size,
  1025. .get_rxfh_key_size = be_get_rxfh_key_size,
  1026. .get_rxfh = be_get_rxfh,
  1027. .set_rxfh = be_set_rxfh,
  1028. .get_channels = be_get_channels,
  1029. .set_channels = be_set_channels
  1030. };