be_ethtool.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183
  1. /*
  2. * Copyright (C) 2005 - 2013 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_mcast_pkts)},
  131. /* Number of page allocation failures while posting receive buffers
  132. * to HW.
  133. */
  134. {DRVSTAT_RX_INFO(rx_post_fail)},
  135. /* Recevied packets dropped due to skb allocation failure */
  136. {DRVSTAT_RX_INFO(rx_drops_no_skbs)},
  137. /* Received packets dropped due to lack of available fetched buffers
  138. * posted by the driver.
  139. */
  140. {DRVSTAT_RX_INFO(rx_drops_no_frags)}
  141. };
  142. #define ETHTOOL_RXSTATS_NUM (ARRAY_SIZE(et_rx_stats))
  143. /* Stats related to multi TX queues: get_stats routine assumes compl is the
  144. * first member
  145. */
  146. static const struct be_ethtool_stat et_tx_stats[] = {
  147. {DRVSTAT_TX_INFO(tx_compl)}, /* If moving this member see above note */
  148. {DRVSTAT_TX_INFO(tx_bytes)},
  149. {DRVSTAT_TX_INFO(tx_pkts)},
  150. /* Number of skbs queued for trasmission by the driver */
  151. {DRVSTAT_TX_INFO(tx_reqs)},
  152. /* Number of TX work request blocks DMAed to HW */
  153. {DRVSTAT_TX_INFO(tx_wrbs)},
  154. /* Number of times the TX queue was stopped due to lack
  155. * of spaces in the TXQ.
  156. */
  157. {DRVSTAT_TX_INFO(tx_stops)},
  158. /* Pkts dropped in the driver's transmit path */
  159. {DRVSTAT_TX_INFO(tx_drv_drops)}
  160. };
  161. #define ETHTOOL_TXSTATS_NUM (ARRAY_SIZE(et_tx_stats))
  162. static const char et_self_tests[][ETH_GSTRING_LEN] = {
  163. "MAC Loopback test",
  164. "PHY Loopback test",
  165. "External Loopback test",
  166. "DDR DMA test",
  167. "Link test"
  168. };
  169. #define ETHTOOL_TESTS_NUM ARRAY_SIZE(et_self_tests)
  170. #define BE_MAC_LOOPBACK 0x0
  171. #define BE_PHY_LOOPBACK 0x1
  172. #define BE_ONE_PORT_EXT_LOOPBACK 0x2
  173. #define BE_NO_LOOPBACK 0xff
  174. static void be_get_drvinfo(struct net_device *netdev,
  175. struct ethtool_drvinfo *drvinfo)
  176. {
  177. struct be_adapter *adapter = netdev_priv(netdev);
  178. strlcpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver));
  179. strlcpy(drvinfo->version, DRV_VER, sizeof(drvinfo->version));
  180. if (!memcmp(adapter->fw_ver, adapter->fw_on_flash, FW_VER_LEN))
  181. strlcpy(drvinfo->fw_version, adapter->fw_ver,
  182. sizeof(drvinfo->fw_version));
  183. else
  184. snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
  185. "%s [%s]", adapter->fw_ver, adapter->fw_on_flash);
  186. strlcpy(drvinfo->bus_info, pci_name(adapter->pdev),
  187. sizeof(drvinfo->bus_info));
  188. drvinfo->testinfo_len = 0;
  189. drvinfo->regdump_len = 0;
  190. drvinfo->eedump_len = 0;
  191. }
  192. static u32
  193. 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, &addn_status);
  203. return data_read;
  204. }
  205. static int
  206. 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, &read_len,
  228. &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
  243. be_get_reg_len(struct net_device *netdev)
  244. {
  245. struct be_adapter *adapter = netdev_priv(netdev);
  246. u32 log_size = 0;
  247. if (!check_privilege(adapter, MAX_PRIVILEGES))
  248. return 0;
  249. if (be_physfn(adapter)) {
  250. if (lancer_chip(adapter))
  251. log_size = lancer_cmd_get_file_len(adapter,
  252. LANCER_FW_DUMP_FILE);
  253. else
  254. be_cmd_get_reg_len(adapter, &log_size);
  255. }
  256. return log_size;
  257. }
  258. static void
  259. be_get_regs(struct net_device *netdev, struct ethtool_regs *regs, void *buf)
  260. {
  261. struct be_adapter *adapter = netdev_priv(netdev);
  262. if (be_physfn(adapter)) {
  263. memset(buf, 0, regs->len);
  264. if (lancer_chip(adapter))
  265. lancer_cmd_read_file(adapter, LANCER_FW_DUMP_FILE,
  266. regs->len, buf);
  267. else
  268. be_cmd_get_regs(adapter, regs->len, buf);
  269. }
  270. }
  271. static int be_get_coalesce(struct net_device *netdev,
  272. struct ethtool_coalesce *et)
  273. {
  274. struct be_adapter *adapter = netdev_priv(netdev);
  275. struct be_aic_obj *aic = &adapter->aic_obj[0];
  276. et->rx_coalesce_usecs = aic->prev_eqd;
  277. et->rx_coalesce_usecs_high = aic->max_eqd;
  278. et->rx_coalesce_usecs_low = aic->min_eqd;
  279. et->tx_coalesce_usecs = aic->prev_eqd;
  280. et->tx_coalesce_usecs_high = aic->max_eqd;
  281. et->tx_coalesce_usecs_low = aic->min_eqd;
  282. et->use_adaptive_rx_coalesce = aic->enable;
  283. et->use_adaptive_tx_coalesce = aic->enable;
  284. return 0;
  285. }
  286. /* TX attributes are ignored. Only RX attributes are considered
  287. * eqd cmd is issued in the worker thread.
  288. */
  289. static int be_set_coalesce(struct net_device *netdev,
  290. struct ethtool_coalesce *et)
  291. {
  292. struct be_adapter *adapter = netdev_priv(netdev);
  293. struct be_aic_obj *aic = &adapter->aic_obj[0];
  294. struct be_eq_obj *eqo;
  295. int i;
  296. for_all_evt_queues(adapter, eqo, i) {
  297. aic->enable = et->use_adaptive_rx_coalesce;
  298. aic->max_eqd = min(et->rx_coalesce_usecs_high, BE_MAX_EQD);
  299. aic->min_eqd = min(et->rx_coalesce_usecs_low, aic->max_eqd);
  300. aic->et_eqd = min(et->rx_coalesce_usecs, aic->max_eqd);
  301. aic->et_eqd = max(aic->et_eqd, aic->min_eqd);
  302. aic++;
  303. }
  304. return 0;
  305. }
  306. static void
  307. be_get_ethtool_stats(struct net_device *netdev,
  308. struct ethtool_stats *stats, uint64_t *data)
  309. {
  310. struct be_adapter *adapter = netdev_priv(netdev);
  311. struct be_rx_obj *rxo;
  312. struct be_tx_obj *txo;
  313. void *p;
  314. unsigned int i, j, base = 0, start;
  315. for (i = 0; i < ETHTOOL_STATS_NUM; i++) {
  316. p = (u8 *)&adapter->drv_stats + et_stats[i].offset;
  317. data[i] = *(u32 *)p;
  318. }
  319. base += ETHTOOL_STATS_NUM;
  320. for_all_rx_queues(adapter, rxo, j) {
  321. struct be_rx_stats *stats = rx_stats(rxo);
  322. do {
  323. start = u64_stats_fetch_begin_bh(&stats->sync);
  324. data[base] = stats->rx_bytes;
  325. data[base + 1] = stats->rx_pkts;
  326. } while (u64_stats_fetch_retry_bh(&stats->sync, start));
  327. for (i = 2; i < ETHTOOL_RXSTATS_NUM; i++) {
  328. p = (u8 *)stats + et_rx_stats[i].offset;
  329. data[base + i] = *(u32 *)p;
  330. }
  331. base += ETHTOOL_RXSTATS_NUM;
  332. }
  333. for_all_tx_queues(adapter, txo, j) {
  334. struct be_tx_stats *stats = tx_stats(txo);
  335. do {
  336. start = u64_stats_fetch_begin_bh(&stats->sync_compl);
  337. data[base] = stats->tx_compl;
  338. } while (u64_stats_fetch_retry_bh(&stats->sync_compl, start));
  339. do {
  340. start = u64_stats_fetch_begin_bh(&stats->sync);
  341. for (i = 1; i < ETHTOOL_TXSTATS_NUM; i++) {
  342. p = (u8 *)stats + et_tx_stats[i].offset;
  343. data[base + i] =
  344. (et_tx_stats[i].size == sizeof(u64)) ?
  345. *(u64 *)p : *(u32 *)p;
  346. }
  347. } while (u64_stats_fetch_retry_bh(&stats->sync, start));
  348. base += ETHTOOL_TXSTATS_NUM;
  349. }
  350. }
  351. static void
  352. be_get_stat_strings(struct net_device *netdev, uint32_t stringset,
  353. uint8_t *data)
  354. {
  355. struct be_adapter *adapter = netdev_priv(netdev);
  356. int i, j;
  357. switch (stringset) {
  358. case ETH_SS_STATS:
  359. for (i = 0; i < ETHTOOL_STATS_NUM; i++) {
  360. memcpy(data, et_stats[i].desc, ETH_GSTRING_LEN);
  361. data += ETH_GSTRING_LEN;
  362. }
  363. for (i = 0; i < adapter->num_rx_qs; i++) {
  364. for (j = 0; j < ETHTOOL_RXSTATS_NUM; j++) {
  365. sprintf(data, "rxq%d: %s", i,
  366. et_rx_stats[j].desc);
  367. data += ETH_GSTRING_LEN;
  368. }
  369. }
  370. for (i = 0; i < adapter->num_tx_qs; i++) {
  371. for (j = 0; j < ETHTOOL_TXSTATS_NUM; j++) {
  372. sprintf(data, "txq%d: %s", i,
  373. et_tx_stats[j].desc);
  374. data += ETH_GSTRING_LEN;
  375. }
  376. }
  377. break;
  378. case ETH_SS_TEST:
  379. for (i = 0; i < ETHTOOL_TESTS_NUM; i++) {
  380. memcpy(data, et_self_tests[i], ETH_GSTRING_LEN);
  381. data += ETH_GSTRING_LEN;
  382. }
  383. break;
  384. }
  385. }
  386. static int be_get_sset_count(struct net_device *netdev, int stringset)
  387. {
  388. struct be_adapter *adapter = netdev_priv(netdev);
  389. switch (stringset) {
  390. case ETH_SS_TEST:
  391. return ETHTOOL_TESTS_NUM;
  392. case ETH_SS_STATS:
  393. return ETHTOOL_STATS_NUM +
  394. adapter->num_rx_qs * ETHTOOL_RXSTATS_NUM +
  395. adapter->num_tx_qs * ETHTOOL_TXSTATS_NUM;
  396. default:
  397. return -EINVAL;
  398. }
  399. }
  400. static u32 be_get_port_type(u32 phy_type, u32 dac_cable_len)
  401. {
  402. u32 port;
  403. switch (phy_type) {
  404. case PHY_TYPE_BASET_1GB:
  405. case PHY_TYPE_BASEX_1GB:
  406. case PHY_TYPE_SGMII:
  407. port = PORT_TP;
  408. break;
  409. case PHY_TYPE_SFP_PLUS_10GB:
  410. port = dac_cable_len ? PORT_DA : PORT_FIBRE;
  411. break;
  412. case PHY_TYPE_XFP_10GB:
  413. case PHY_TYPE_SFP_1GB:
  414. port = PORT_FIBRE;
  415. break;
  416. case PHY_TYPE_BASET_10GB:
  417. port = PORT_TP;
  418. break;
  419. default:
  420. port = PORT_OTHER;
  421. }
  422. return port;
  423. }
  424. static u32 convert_to_et_setting(u32 if_type, u32 if_speeds)
  425. {
  426. u32 val = 0;
  427. switch (if_type) {
  428. case PHY_TYPE_BASET_1GB:
  429. case PHY_TYPE_BASEX_1GB:
  430. case PHY_TYPE_SGMII:
  431. val |= SUPPORTED_TP;
  432. if (if_speeds & BE_SUPPORTED_SPEED_1GBPS)
  433. val |= SUPPORTED_1000baseT_Full;
  434. if (if_speeds & BE_SUPPORTED_SPEED_100MBPS)
  435. val |= SUPPORTED_100baseT_Full;
  436. if (if_speeds & BE_SUPPORTED_SPEED_10MBPS)
  437. val |= SUPPORTED_10baseT_Full;
  438. break;
  439. case PHY_TYPE_KX4_10GB:
  440. val |= SUPPORTED_Backplane;
  441. if (if_speeds & BE_SUPPORTED_SPEED_1GBPS)
  442. val |= SUPPORTED_1000baseKX_Full;
  443. if (if_speeds & BE_SUPPORTED_SPEED_10GBPS)
  444. val |= SUPPORTED_10000baseKX4_Full;
  445. break;
  446. case PHY_TYPE_KR_10GB:
  447. val |= SUPPORTED_Backplane |
  448. SUPPORTED_10000baseKR_Full;
  449. break;
  450. case PHY_TYPE_SFP_PLUS_10GB:
  451. case PHY_TYPE_XFP_10GB:
  452. case PHY_TYPE_SFP_1GB:
  453. val |= SUPPORTED_FIBRE;
  454. if (if_speeds & BE_SUPPORTED_SPEED_10GBPS)
  455. val |= SUPPORTED_10000baseT_Full;
  456. if (if_speeds & BE_SUPPORTED_SPEED_1GBPS)
  457. val |= SUPPORTED_1000baseT_Full;
  458. break;
  459. case PHY_TYPE_BASET_10GB:
  460. val |= SUPPORTED_TP;
  461. if (if_speeds & BE_SUPPORTED_SPEED_10GBPS)
  462. val |= SUPPORTED_10000baseT_Full;
  463. if (if_speeds & BE_SUPPORTED_SPEED_1GBPS)
  464. val |= SUPPORTED_1000baseT_Full;
  465. if (if_speeds & BE_SUPPORTED_SPEED_100MBPS)
  466. val |= SUPPORTED_100baseT_Full;
  467. break;
  468. default:
  469. val |= SUPPORTED_TP;
  470. }
  471. return val;
  472. }
  473. bool be_pause_supported(struct be_adapter *adapter)
  474. {
  475. return (adapter->phy.interface_type == PHY_TYPE_SFP_PLUS_10GB ||
  476. adapter->phy.interface_type == PHY_TYPE_XFP_10GB) ?
  477. false : true;
  478. }
  479. static int be_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
  480. {
  481. struct be_adapter *adapter = netdev_priv(netdev);
  482. u8 link_status;
  483. u16 link_speed = 0;
  484. int status;
  485. u32 auto_speeds;
  486. u32 fixed_speeds;
  487. u32 dac_cable_len;
  488. u16 interface_type;
  489. if (adapter->phy.link_speed < 0) {
  490. status = be_cmd_link_status_query(adapter, &link_speed,
  491. &link_status, 0);
  492. if (!status)
  493. be_link_status_update(adapter, link_status);
  494. ethtool_cmd_speed_set(ecmd, link_speed);
  495. status = be_cmd_get_phy_info(adapter);
  496. if (!status) {
  497. interface_type = adapter->phy.interface_type;
  498. auto_speeds = adapter->phy.auto_speeds_supported;
  499. fixed_speeds = adapter->phy.fixed_speeds_supported;
  500. dac_cable_len = adapter->phy.dac_cable_len;
  501. ecmd->supported =
  502. convert_to_et_setting(interface_type,
  503. auto_speeds |
  504. fixed_speeds);
  505. ecmd->advertising =
  506. convert_to_et_setting(interface_type,
  507. auto_speeds);
  508. ecmd->port = be_get_port_type(interface_type,
  509. dac_cable_len);
  510. if (adapter->phy.auto_speeds_supported) {
  511. ecmd->supported |= SUPPORTED_Autoneg;
  512. ecmd->autoneg = AUTONEG_ENABLE;
  513. ecmd->advertising |= ADVERTISED_Autoneg;
  514. }
  515. ecmd->supported |= SUPPORTED_Pause;
  516. if (be_pause_supported(adapter))
  517. ecmd->advertising |= ADVERTISED_Pause;
  518. switch (adapter->phy.interface_type) {
  519. case PHY_TYPE_KR_10GB:
  520. case PHY_TYPE_KX4_10GB:
  521. ecmd->transceiver = XCVR_INTERNAL;
  522. break;
  523. default:
  524. ecmd->transceiver = XCVR_EXTERNAL;
  525. break;
  526. }
  527. } else {
  528. ecmd->port = PORT_OTHER;
  529. ecmd->autoneg = AUTONEG_DISABLE;
  530. ecmd->transceiver = XCVR_DUMMY1;
  531. }
  532. /* Save for future use */
  533. adapter->phy.link_speed = ethtool_cmd_speed(ecmd);
  534. adapter->phy.port_type = ecmd->port;
  535. adapter->phy.transceiver = ecmd->transceiver;
  536. adapter->phy.autoneg = ecmd->autoneg;
  537. adapter->phy.advertising = ecmd->advertising;
  538. adapter->phy.supported = ecmd->supported;
  539. } else {
  540. ethtool_cmd_speed_set(ecmd, adapter->phy.link_speed);
  541. ecmd->port = adapter->phy.port_type;
  542. ecmd->transceiver = adapter->phy.transceiver;
  543. ecmd->autoneg = adapter->phy.autoneg;
  544. ecmd->advertising = adapter->phy.advertising;
  545. ecmd->supported = adapter->phy.supported;
  546. }
  547. ecmd->duplex = netif_carrier_ok(netdev) ? DUPLEX_FULL : DUPLEX_UNKNOWN;
  548. ecmd->phy_address = adapter->port_num;
  549. return 0;
  550. }
  551. static void be_get_ringparam(struct net_device *netdev,
  552. struct ethtool_ringparam *ring)
  553. {
  554. struct be_adapter *adapter = netdev_priv(netdev);
  555. ring->rx_max_pending = ring->rx_pending = adapter->rx_obj[0].q.len;
  556. ring->tx_max_pending = ring->tx_pending = adapter->tx_obj[0].q.len;
  557. }
  558. static void
  559. be_get_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *ecmd)
  560. {
  561. struct be_adapter *adapter = netdev_priv(netdev);
  562. be_cmd_get_flow_control(adapter, &ecmd->tx_pause, &ecmd->rx_pause);
  563. ecmd->autoneg = adapter->phy.fc_autoneg;
  564. }
  565. static int
  566. be_set_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *ecmd)
  567. {
  568. struct be_adapter *adapter = netdev_priv(netdev);
  569. int status;
  570. if (ecmd->autoneg != adapter->phy.fc_autoneg)
  571. return -EINVAL;
  572. adapter->tx_fc = ecmd->tx_pause;
  573. adapter->rx_fc = ecmd->rx_pause;
  574. status = be_cmd_set_flow_control(adapter,
  575. adapter->tx_fc, adapter->rx_fc);
  576. if (status)
  577. dev_warn(&adapter->pdev->dev, "Pause param set failed.\n");
  578. return status;
  579. }
  580. static int
  581. be_set_phys_id(struct net_device *netdev,
  582. enum ethtool_phys_id_state state)
  583. {
  584. struct be_adapter *adapter = netdev_priv(netdev);
  585. switch (state) {
  586. case ETHTOOL_ID_ACTIVE:
  587. be_cmd_get_beacon_state(adapter, adapter->hba_port_num,
  588. &adapter->beacon_state);
  589. return 1; /* cycle on/off once per second */
  590. case ETHTOOL_ID_ON:
  591. be_cmd_set_beacon_state(adapter, adapter->hba_port_num, 0, 0,
  592. BEACON_STATE_ENABLED);
  593. break;
  594. case ETHTOOL_ID_OFF:
  595. be_cmd_set_beacon_state(adapter, adapter->hba_port_num, 0, 0,
  596. BEACON_STATE_DISABLED);
  597. break;
  598. case ETHTOOL_ID_INACTIVE:
  599. be_cmd_set_beacon_state(adapter, adapter->hba_port_num, 0, 0,
  600. adapter->beacon_state);
  601. }
  602. return 0;
  603. }
  604. static int be_set_dump(struct net_device *netdev, struct ethtool_dump *dump)
  605. {
  606. struct be_adapter *adapter = netdev_priv(netdev);
  607. struct device *dev = &adapter->pdev->dev;
  608. int status;
  609. if (!lancer_chip(adapter)) {
  610. dev_err(dev, "FW dump not supported\n");
  611. return -EOPNOTSUPP;
  612. }
  613. if (dump_present(adapter)) {
  614. dev_err(dev, "Previous dump not cleared, not forcing dump\n");
  615. return 0;
  616. }
  617. switch (dump->flag) {
  618. case LANCER_INITIATE_FW_DUMP:
  619. status = lancer_initiate_dump(adapter);
  620. if (!status)
  621. dev_info(dev, "F/w dump initiated successfully\n");
  622. break;
  623. default:
  624. dev_err(dev, "Invalid dump level: 0x%x\n", dump->flag);
  625. return -EINVAL;
  626. }
  627. return status;
  628. }
  629. static void
  630. be_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
  631. {
  632. struct be_adapter *adapter = netdev_priv(netdev);
  633. if (be_is_wol_supported(adapter)) {
  634. wol->supported |= WAKE_MAGIC;
  635. if (adapter->wol)
  636. wol->wolopts |= WAKE_MAGIC;
  637. } else
  638. wol->wolopts = 0;
  639. memset(&wol->sopass, 0, sizeof(wol->sopass));
  640. }
  641. static int
  642. be_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
  643. {
  644. struct be_adapter *adapter = netdev_priv(netdev);
  645. if (wol->wolopts & ~WAKE_MAGIC)
  646. return -EOPNOTSUPP;
  647. if (!be_is_wol_supported(adapter)) {
  648. dev_warn(&adapter->pdev->dev, "WOL not supported\n");
  649. return -EOPNOTSUPP;
  650. }
  651. if (wol->wolopts & WAKE_MAGIC)
  652. adapter->wol = true;
  653. else
  654. adapter->wol = false;
  655. return 0;
  656. }
  657. static int
  658. be_test_ddr_dma(struct be_adapter *adapter)
  659. {
  660. int ret, i;
  661. struct be_dma_mem ddrdma_cmd;
  662. static const u64 pattern[2] = {
  663. 0x5a5a5a5a5a5a5a5aULL, 0xa5a5a5a5a5a5a5a5ULL
  664. };
  665. ddrdma_cmd.size = sizeof(struct be_cmd_req_ddrdma_test);
  666. ddrdma_cmd.va = dma_alloc_coherent(&adapter->pdev->dev, ddrdma_cmd.size,
  667. &ddrdma_cmd.dma, GFP_KERNEL);
  668. if (!ddrdma_cmd.va)
  669. return -ENOMEM;
  670. for (i = 0; i < 2; i++) {
  671. ret = be_cmd_ddr_dma_test(adapter, pattern[i],
  672. 4096, &ddrdma_cmd);
  673. if (ret != 0)
  674. goto err;
  675. }
  676. err:
  677. dma_free_coherent(&adapter->pdev->dev, ddrdma_cmd.size, ddrdma_cmd.va,
  678. ddrdma_cmd.dma);
  679. return ret;
  680. }
  681. static u64 be_loopback_test(struct be_adapter *adapter, u8 loopback_type,
  682. u64 *status)
  683. {
  684. be_cmd_set_loopback(adapter, adapter->hba_port_num,
  685. loopback_type, 1);
  686. *status = be_cmd_loopback_test(adapter, adapter->hba_port_num,
  687. loopback_type, 1500,
  688. 2, 0xabc);
  689. be_cmd_set_loopback(adapter, adapter->hba_port_num,
  690. BE_NO_LOOPBACK, 1);
  691. return *status;
  692. }
  693. static void
  694. be_self_test(struct net_device *netdev, struct ethtool_test *test, u64 *data)
  695. {
  696. struct be_adapter *adapter = netdev_priv(netdev);
  697. int status;
  698. u8 link_status = 0;
  699. if (adapter->function_caps & BE_FUNCTION_CAPS_SUPER_NIC) {
  700. dev_err(&adapter->pdev->dev, "Self test not supported\n");
  701. test->flags |= ETH_TEST_FL_FAILED;
  702. return;
  703. }
  704. memset(data, 0, sizeof(u64) * ETHTOOL_TESTS_NUM);
  705. if (test->flags & ETH_TEST_FL_OFFLINE) {
  706. if (be_loopback_test(adapter, BE_MAC_LOOPBACK,
  707. &data[0]) != 0) {
  708. test->flags |= ETH_TEST_FL_FAILED;
  709. }
  710. if (be_loopback_test(adapter, BE_PHY_LOOPBACK,
  711. &data[1]) != 0) {
  712. test->flags |= ETH_TEST_FL_FAILED;
  713. }
  714. if (be_loopback_test(adapter, BE_ONE_PORT_EXT_LOOPBACK,
  715. &data[2]) != 0) {
  716. test->flags |= ETH_TEST_FL_FAILED;
  717. }
  718. }
  719. if (!lancer_chip(adapter) && be_test_ddr_dma(adapter) != 0) {
  720. data[3] = 1;
  721. test->flags |= ETH_TEST_FL_FAILED;
  722. }
  723. status = be_cmd_link_status_query(adapter, NULL, &link_status, 0);
  724. if (status) {
  725. test->flags |= ETH_TEST_FL_FAILED;
  726. data[4] = -1;
  727. } else if (!link_status) {
  728. test->flags |= ETH_TEST_FL_FAILED;
  729. data[4] = 1;
  730. }
  731. }
  732. static int
  733. be_do_flash(struct net_device *netdev, struct ethtool_flash *efl)
  734. {
  735. struct be_adapter *adapter = netdev_priv(netdev);
  736. return be_load_fw(adapter, efl->data);
  737. }
  738. static int
  739. be_get_eeprom_len(struct net_device *netdev)
  740. {
  741. struct be_adapter *adapter = netdev_priv(netdev);
  742. if (!check_privilege(adapter, MAX_PRIVILEGES))
  743. return 0;
  744. if (lancer_chip(adapter)) {
  745. if (be_physfn(adapter))
  746. return lancer_cmd_get_file_len(adapter,
  747. LANCER_VPD_PF_FILE);
  748. else
  749. return lancer_cmd_get_file_len(adapter,
  750. LANCER_VPD_VF_FILE);
  751. } else {
  752. return BE_READ_SEEPROM_LEN;
  753. }
  754. }
  755. static int
  756. be_read_eeprom(struct net_device *netdev, struct ethtool_eeprom *eeprom,
  757. uint8_t *data)
  758. {
  759. struct be_adapter *adapter = netdev_priv(netdev);
  760. struct be_dma_mem eeprom_cmd;
  761. struct be_cmd_resp_seeprom_read *resp;
  762. int status;
  763. if (!eeprom->len)
  764. return -EINVAL;
  765. if (lancer_chip(adapter)) {
  766. if (be_physfn(adapter))
  767. return lancer_cmd_read_file(adapter, LANCER_VPD_PF_FILE,
  768. eeprom->len, data);
  769. else
  770. return lancer_cmd_read_file(adapter, LANCER_VPD_VF_FILE,
  771. eeprom->len, data);
  772. }
  773. eeprom->magic = BE_VENDOR_ID | (adapter->pdev->device<<16);
  774. memset(&eeprom_cmd, 0, sizeof(struct be_dma_mem));
  775. eeprom_cmd.size = sizeof(struct be_cmd_req_seeprom_read);
  776. eeprom_cmd.va = dma_alloc_coherent(&adapter->pdev->dev, eeprom_cmd.size,
  777. &eeprom_cmd.dma, GFP_KERNEL);
  778. if (!eeprom_cmd.va)
  779. return -ENOMEM;
  780. status = be_cmd_get_seeprom_data(adapter, &eeprom_cmd);
  781. if (!status) {
  782. resp = eeprom_cmd.va;
  783. memcpy(data, resp->seeprom_data + eeprom->offset, eeprom->len);
  784. }
  785. dma_free_coherent(&adapter->pdev->dev, eeprom_cmd.size, eeprom_cmd.va,
  786. eeprom_cmd.dma);
  787. return status;
  788. }
  789. static u32 be_get_msg_level(struct net_device *netdev)
  790. {
  791. struct be_adapter *adapter = netdev_priv(netdev);
  792. if (lancer_chip(adapter)) {
  793. dev_err(&adapter->pdev->dev, "Operation not supported\n");
  794. return -EOPNOTSUPP;
  795. }
  796. return adapter->msg_enable;
  797. }
  798. static void be_set_fw_log_level(struct be_adapter *adapter, u32 level)
  799. {
  800. struct be_dma_mem extfat_cmd;
  801. struct be_fat_conf_params *cfgs;
  802. int status;
  803. int i, j;
  804. memset(&extfat_cmd, 0, sizeof(struct be_dma_mem));
  805. extfat_cmd.size = sizeof(struct be_cmd_resp_get_ext_fat_caps);
  806. extfat_cmd.va = pci_alloc_consistent(adapter->pdev, extfat_cmd.size,
  807. &extfat_cmd.dma);
  808. if (!extfat_cmd.va) {
  809. dev_err(&adapter->pdev->dev, "%s: Memory allocation failure\n",
  810. __func__);
  811. goto err;
  812. }
  813. status = be_cmd_get_ext_fat_capabilites(adapter, &extfat_cmd);
  814. if (!status) {
  815. cfgs = (struct be_fat_conf_params *)(extfat_cmd.va +
  816. sizeof(struct be_cmd_resp_hdr));
  817. for (i = 0; i < le32_to_cpu(cfgs->num_modules); i++) {
  818. u32 num_modes = le32_to_cpu(cfgs->module[i].num_modes);
  819. for (j = 0; j < num_modes; j++) {
  820. if (cfgs->module[i].trace_lvl[j].mode ==
  821. MODE_UART)
  822. cfgs->module[i].trace_lvl[j].dbg_lvl =
  823. cpu_to_le32(level);
  824. }
  825. }
  826. status = be_cmd_set_ext_fat_capabilites(adapter, &extfat_cmd,
  827. cfgs);
  828. if (status)
  829. dev_err(&adapter->pdev->dev,
  830. "Message level set failed\n");
  831. } else {
  832. dev_err(&adapter->pdev->dev, "Message level get failed\n");
  833. }
  834. pci_free_consistent(adapter->pdev, extfat_cmd.size, extfat_cmd.va,
  835. extfat_cmd.dma);
  836. err:
  837. return;
  838. }
  839. static void be_set_msg_level(struct net_device *netdev, u32 level)
  840. {
  841. struct be_adapter *adapter = netdev_priv(netdev);
  842. if (lancer_chip(adapter)) {
  843. dev_err(&adapter->pdev->dev, "Operation not supported\n");
  844. return;
  845. }
  846. if (adapter->msg_enable == level)
  847. return;
  848. if ((level & NETIF_MSG_HW) != (adapter->msg_enable & NETIF_MSG_HW))
  849. be_set_fw_log_level(adapter, level & NETIF_MSG_HW ?
  850. FW_LOG_LEVEL_DEFAULT : FW_LOG_LEVEL_FATAL);
  851. adapter->msg_enable = level;
  852. return;
  853. }
  854. static u64 be_get_rss_hash_opts(struct be_adapter *adapter, u64 flow_type)
  855. {
  856. u64 data = 0;
  857. switch (flow_type) {
  858. case TCP_V4_FLOW:
  859. if (adapter->rss_flags & RSS_ENABLE_IPV4)
  860. data |= RXH_IP_DST | RXH_IP_SRC;
  861. if (adapter->rss_flags & RSS_ENABLE_TCP_IPV4)
  862. data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
  863. break;
  864. case UDP_V4_FLOW:
  865. if (adapter->rss_flags & RSS_ENABLE_IPV4)
  866. data |= RXH_IP_DST | RXH_IP_SRC;
  867. if (adapter->rss_flags & RSS_ENABLE_UDP_IPV4)
  868. data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
  869. break;
  870. case TCP_V6_FLOW:
  871. if (adapter->rss_flags & RSS_ENABLE_IPV6)
  872. data |= RXH_IP_DST | RXH_IP_SRC;
  873. if (adapter->rss_flags & RSS_ENABLE_TCP_IPV6)
  874. data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
  875. break;
  876. case UDP_V6_FLOW:
  877. if (adapter->rss_flags & RSS_ENABLE_IPV6)
  878. data |= RXH_IP_DST | RXH_IP_SRC;
  879. if (adapter->rss_flags & RSS_ENABLE_UDP_IPV6)
  880. data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
  881. break;
  882. }
  883. return data;
  884. }
  885. static int be_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd,
  886. u32 *rule_locs)
  887. {
  888. struct be_adapter *adapter = netdev_priv(netdev);
  889. if (!be_multi_rxq(adapter)) {
  890. dev_info(&adapter->pdev->dev,
  891. "ethtool::get_rxnfc: RX flow hashing is disabled\n");
  892. return -EINVAL;
  893. }
  894. switch (cmd->cmd) {
  895. case ETHTOOL_GRXFH:
  896. cmd->data = be_get_rss_hash_opts(adapter, cmd->flow_type);
  897. break;
  898. case ETHTOOL_GRXRINGS:
  899. cmd->data = adapter->num_rx_qs - 1;
  900. break;
  901. default:
  902. return -EINVAL;
  903. }
  904. return 0;
  905. }
  906. static int be_set_rss_hash_opts(struct be_adapter *adapter,
  907. struct ethtool_rxnfc *cmd)
  908. {
  909. struct be_rx_obj *rxo;
  910. int status = 0, i, j;
  911. u8 rsstable[128];
  912. u32 rss_flags = adapter->rss_flags;
  913. if (cmd->data != L3_RSS_FLAGS &&
  914. cmd->data != (L3_RSS_FLAGS | L4_RSS_FLAGS))
  915. return -EINVAL;
  916. switch (cmd->flow_type) {
  917. case TCP_V4_FLOW:
  918. if (cmd->data == L3_RSS_FLAGS)
  919. rss_flags &= ~RSS_ENABLE_TCP_IPV4;
  920. else if (cmd->data == (L3_RSS_FLAGS | L4_RSS_FLAGS))
  921. rss_flags |= RSS_ENABLE_IPV4 |
  922. RSS_ENABLE_TCP_IPV4;
  923. break;
  924. case TCP_V6_FLOW:
  925. if (cmd->data == L3_RSS_FLAGS)
  926. rss_flags &= ~RSS_ENABLE_TCP_IPV6;
  927. else if (cmd->data == (L3_RSS_FLAGS | L4_RSS_FLAGS))
  928. rss_flags |= RSS_ENABLE_IPV6 |
  929. RSS_ENABLE_TCP_IPV6;
  930. break;
  931. case UDP_V4_FLOW:
  932. if ((cmd->data == (L3_RSS_FLAGS | L4_RSS_FLAGS)) &&
  933. BEx_chip(adapter))
  934. return -EINVAL;
  935. if (cmd->data == L3_RSS_FLAGS)
  936. rss_flags &= ~RSS_ENABLE_UDP_IPV4;
  937. else if (cmd->data == (L3_RSS_FLAGS | L4_RSS_FLAGS))
  938. rss_flags |= RSS_ENABLE_IPV4 |
  939. RSS_ENABLE_UDP_IPV4;
  940. break;
  941. case UDP_V6_FLOW:
  942. if ((cmd->data == (L3_RSS_FLAGS | L4_RSS_FLAGS)) &&
  943. BEx_chip(adapter))
  944. return -EINVAL;
  945. if (cmd->data == L3_RSS_FLAGS)
  946. rss_flags &= ~RSS_ENABLE_UDP_IPV6;
  947. else if (cmd->data == (L3_RSS_FLAGS | L4_RSS_FLAGS))
  948. rss_flags |= RSS_ENABLE_IPV6 |
  949. RSS_ENABLE_UDP_IPV6;
  950. break;
  951. default:
  952. return -EINVAL;
  953. }
  954. if (rss_flags == adapter->rss_flags)
  955. return status;
  956. if (be_multi_rxq(adapter)) {
  957. for (j = 0; j < 128; j += adapter->num_rx_qs - 1) {
  958. for_all_rss_queues(adapter, rxo, i) {
  959. if ((j + i) >= 128)
  960. break;
  961. rsstable[j + i] = rxo->rss_id;
  962. }
  963. }
  964. }
  965. status = be_cmd_rss_config(adapter, rsstable, rss_flags, 128);
  966. if (!status)
  967. adapter->rss_flags = rss_flags;
  968. return status;
  969. }
  970. static int be_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
  971. {
  972. struct be_adapter *adapter = netdev_priv(netdev);
  973. int status = 0;
  974. if (!be_multi_rxq(adapter)) {
  975. dev_err(&adapter->pdev->dev,
  976. "ethtool::set_rxnfc: RX flow hashing is disabled\n");
  977. return -EINVAL;
  978. }
  979. switch (cmd->cmd) {
  980. case ETHTOOL_SRXFH:
  981. status = be_set_rss_hash_opts(adapter, cmd);
  982. break;
  983. default:
  984. return -EINVAL;
  985. }
  986. return status;
  987. }
  988. static void be_get_channels(struct net_device *netdev,
  989. struct ethtool_channels *ch)
  990. {
  991. struct be_adapter *adapter = netdev_priv(netdev);
  992. ch->combined_count = adapter->num_evt_qs;
  993. ch->max_combined = be_max_qs(adapter);
  994. }
  995. static int be_set_channels(struct net_device *netdev,
  996. struct ethtool_channels *ch)
  997. {
  998. struct be_adapter *adapter = netdev_priv(netdev);
  999. if (ch->rx_count || ch->tx_count || ch->other_count ||
  1000. !ch->combined_count || ch->combined_count > be_max_qs(adapter))
  1001. return -EINVAL;
  1002. adapter->cfg_num_qs = ch->combined_count;
  1003. return be_update_queues(adapter);
  1004. }
  1005. const struct ethtool_ops be_ethtool_ops = {
  1006. .get_settings = be_get_settings,
  1007. .get_drvinfo = be_get_drvinfo,
  1008. .get_wol = be_get_wol,
  1009. .set_wol = be_set_wol,
  1010. .get_link = ethtool_op_get_link,
  1011. .get_eeprom_len = be_get_eeprom_len,
  1012. .get_eeprom = be_read_eeprom,
  1013. .get_coalesce = be_get_coalesce,
  1014. .set_coalesce = be_set_coalesce,
  1015. .get_ringparam = be_get_ringparam,
  1016. .get_pauseparam = be_get_pauseparam,
  1017. .set_pauseparam = be_set_pauseparam,
  1018. .get_strings = be_get_stat_strings,
  1019. .set_phys_id = be_set_phys_id,
  1020. .set_dump = be_set_dump,
  1021. .get_msglevel = be_get_msg_level,
  1022. .set_msglevel = be_set_msg_level,
  1023. .get_sset_count = be_get_sset_count,
  1024. .get_ethtool_stats = be_get_ethtool_stats,
  1025. .get_regs_len = be_get_reg_len,
  1026. .get_regs = be_get_regs,
  1027. .flash_device = be_do_flash,
  1028. .self_test = be_self_test,
  1029. .get_rxnfc = be_get_rxnfc,
  1030. .set_rxnfc = be_set_rxnfc,
  1031. .get_channels = be_get_channels,
  1032. .set_channels = be_set_channels
  1033. };