be_ethtool.c 31 KB

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