bnad_ethtool.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153
  1. /*
  2. * Linux network driver for QLogic BR-series Converged Network Adapter.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License (GPL) Version 2 as
  6. * published by the Free Software Foundation
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * General Public License for more details.
  12. */
  13. /*
  14. * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
  15. * Copyright (c) 2014-2015 QLogic Corporation
  16. * All rights reserved
  17. * www.qlogic.com
  18. */
  19. #include "cna.h"
  20. #include <linux/netdevice.h>
  21. #include <linux/skbuff.h>
  22. #include <linux/ethtool.h>
  23. #include <linux/rtnetlink.h>
  24. #include "bna.h"
  25. #include "bnad.h"
  26. #define BNAD_NUM_TXF_COUNTERS 12
  27. #define BNAD_NUM_RXF_COUNTERS 10
  28. #define BNAD_NUM_CQ_COUNTERS (3 + 5)
  29. #define BNAD_NUM_RXQ_COUNTERS 7
  30. #define BNAD_NUM_TXQ_COUNTERS 5
  31. static const char *bnad_net_stats_strings[] = {
  32. "rx_packets",
  33. "tx_packets",
  34. "rx_bytes",
  35. "tx_bytes",
  36. "rx_errors",
  37. "tx_errors",
  38. "rx_dropped",
  39. "tx_dropped",
  40. "multicast",
  41. "collisions",
  42. "rx_length_errors",
  43. "rx_crc_errors",
  44. "rx_frame_errors",
  45. "tx_fifo_errors",
  46. "netif_queue_stop",
  47. "netif_queue_wakeup",
  48. "netif_queue_stopped",
  49. "tso4",
  50. "tso6",
  51. "tso_err",
  52. "tcpcsum_offload",
  53. "udpcsum_offload",
  54. "csum_help",
  55. "tx_skb_too_short",
  56. "tx_skb_stopping",
  57. "tx_skb_max_vectors",
  58. "tx_skb_mss_too_long",
  59. "tx_skb_tso_too_short",
  60. "tx_skb_tso_prepare",
  61. "tx_skb_non_tso_too_long",
  62. "tx_skb_tcp_hdr",
  63. "tx_skb_udp_hdr",
  64. "tx_skb_csum_err",
  65. "tx_skb_headlen_too_long",
  66. "tx_skb_headlen_zero",
  67. "tx_skb_frag_zero",
  68. "tx_skb_len_mismatch",
  69. "tx_skb_map_failed",
  70. "hw_stats_updates",
  71. "netif_rx_dropped",
  72. "link_toggle",
  73. "cee_toggle",
  74. "rxp_info_alloc_failed",
  75. "mbox_intr_disabled",
  76. "mbox_intr_enabled",
  77. "tx_unmap_q_alloc_failed",
  78. "rx_unmap_q_alloc_failed",
  79. "rxbuf_alloc_failed",
  80. "rxbuf_map_failed",
  81. "mac_stats_clr_cnt",
  82. "mac_frame_64",
  83. "mac_frame_65_127",
  84. "mac_frame_128_255",
  85. "mac_frame_256_511",
  86. "mac_frame_512_1023",
  87. "mac_frame_1024_1518",
  88. "mac_frame_1518_1522",
  89. "mac_rx_bytes",
  90. "mac_rx_packets",
  91. "mac_rx_fcs_error",
  92. "mac_rx_multicast",
  93. "mac_rx_broadcast",
  94. "mac_rx_control_frames",
  95. "mac_rx_pause",
  96. "mac_rx_unknown_opcode",
  97. "mac_rx_alignment_error",
  98. "mac_rx_frame_length_error",
  99. "mac_rx_code_error",
  100. "mac_rx_carrier_sense_error",
  101. "mac_rx_undersize",
  102. "mac_rx_oversize",
  103. "mac_rx_fragments",
  104. "mac_rx_jabber",
  105. "mac_rx_drop",
  106. "mac_tx_bytes",
  107. "mac_tx_packets",
  108. "mac_tx_multicast",
  109. "mac_tx_broadcast",
  110. "mac_tx_pause",
  111. "mac_tx_deferral",
  112. "mac_tx_excessive_deferral",
  113. "mac_tx_single_collision",
  114. "mac_tx_muliple_collision",
  115. "mac_tx_late_collision",
  116. "mac_tx_excessive_collision",
  117. "mac_tx_total_collision",
  118. "mac_tx_pause_honored",
  119. "mac_tx_drop",
  120. "mac_tx_jabber",
  121. "mac_tx_fcs_error",
  122. "mac_tx_control_frame",
  123. "mac_tx_oversize",
  124. "mac_tx_undersize",
  125. "mac_tx_fragments",
  126. "bpc_tx_pause_0",
  127. "bpc_tx_pause_1",
  128. "bpc_tx_pause_2",
  129. "bpc_tx_pause_3",
  130. "bpc_tx_pause_4",
  131. "bpc_tx_pause_5",
  132. "bpc_tx_pause_6",
  133. "bpc_tx_pause_7",
  134. "bpc_tx_zero_pause_0",
  135. "bpc_tx_zero_pause_1",
  136. "bpc_tx_zero_pause_2",
  137. "bpc_tx_zero_pause_3",
  138. "bpc_tx_zero_pause_4",
  139. "bpc_tx_zero_pause_5",
  140. "bpc_tx_zero_pause_6",
  141. "bpc_tx_zero_pause_7",
  142. "bpc_tx_first_pause_0",
  143. "bpc_tx_first_pause_1",
  144. "bpc_tx_first_pause_2",
  145. "bpc_tx_first_pause_3",
  146. "bpc_tx_first_pause_4",
  147. "bpc_tx_first_pause_5",
  148. "bpc_tx_first_pause_6",
  149. "bpc_tx_first_pause_7",
  150. "bpc_rx_pause_0",
  151. "bpc_rx_pause_1",
  152. "bpc_rx_pause_2",
  153. "bpc_rx_pause_3",
  154. "bpc_rx_pause_4",
  155. "bpc_rx_pause_5",
  156. "bpc_rx_pause_6",
  157. "bpc_rx_pause_7",
  158. "bpc_rx_zero_pause_0",
  159. "bpc_rx_zero_pause_1",
  160. "bpc_rx_zero_pause_2",
  161. "bpc_rx_zero_pause_3",
  162. "bpc_rx_zero_pause_4",
  163. "bpc_rx_zero_pause_5",
  164. "bpc_rx_zero_pause_6",
  165. "bpc_rx_zero_pause_7",
  166. "bpc_rx_first_pause_0",
  167. "bpc_rx_first_pause_1",
  168. "bpc_rx_first_pause_2",
  169. "bpc_rx_first_pause_3",
  170. "bpc_rx_first_pause_4",
  171. "bpc_rx_first_pause_5",
  172. "bpc_rx_first_pause_6",
  173. "bpc_rx_first_pause_7",
  174. "rad_rx_frames",
  175. "rad_rx_octets",
  176. "rad_rx_vlan_frames",
  177. "rad_rx_ucast",
  178. "rad_rx_ucast_octets",
  179. "rad_rx_ucast_vlan",
  180. "rad_rx_mcast",
  181. "rad_rx_mcast_octets",
  182. "rad_rx_mcast_vlan",
  183. "rad_rx_bcast",
  184. "rad_rx_bcast_octets",
  185. "rad_rx_bcast_vlan",
  186. "rad_rx_drops",
  187. "rlb_rad_rx_frames",
  188. "rlb_rad_rx_octets",
  189. "rlb_rad_rx_vlan_frames",
  190. "rlb_rad_rx_ucast",
  191. "rlb_rad_rx_ucast_octets",
  192. "rlb_rad_rx_ucast_vlan",
  193. "rlb_rad_rx_mcast",
  194. "rlb_rad_rx_mcast_octets",
  195. "rlb_rad_rx_mcast_vlan",
  196. "rlb_rad_rx_bcast",
  197. "rlb_rad_rx_bcast_octets",
  198. "rlb_rad_rx_bcast_vlan",
  199. "rlb_rad_rx_drops",
  200. "fc_rx_ucast_octets",
  201. "fc_rx_ucast",
  202. "fc_rx_ucast_vlan",
  203. "fc_rx_mcast_octets",
  204. "fc_rx_mcast",
  205. "fc_rx_mcast_vlan",
  206. "fc_rx_bcast_octets",
  207. "fc_rx_bcast",
  208. "fc_rx_bcast_vlan",
  209. "fc_tx_ucast_octets",
  210. "fc_tx_ucast",
  211. "fc_tx_ucast_vlan",
  212. "fc_tx_mcast_octets",
  213. "fc_tx_mcast",
  214. "fc_tx_mcast_vlan",
  215. "fc_tx_bcast_octets",
  216. "fc_tx_bcast",
  217. "fc_tx_bcast_vlan",
  218. "fc_tx_parity_errors",
  219. "fc_tx_timeout",
  220. "fc_tx_fid_parity_errors",
  221. };
  222. #define BNAD_ETHTOOL_STATS_NUM ARRAY_SIZE(bnad_net_stats_strings)
  223. static int
  224. bnad_get_link_ksettings(struct net_device *netdev,
  225. struct ethtool_link_ksettings *cmd)
  226. {
  227. u32 supported, advertising;
  228. supported = SUPPORTED_10000baseT_Full;
  229. advertising = ADVERTISED_10000baseT_Full;
  230. cmd->base.autoneg = AUTONEG_DISABLE;
  231. supported |= SUPPORTED_FIBRE;
  232. advertising |= ADVERTISED_FIBRE;
  233. cmd->base.port = PORT_FIBRE;
  234. cmd->base.phy_address = 0;
  235. if (netif_carrier_ok(netdev)) {
  236. cmd->base.speed = SPEED_10000;
  237. cmd->base.duplex = DUPLEX_FULL;
  238. } else {
  239. cmd->base.speed = SPEED_UNKNOWN;
  240. cmd->base.duplex = DUPLEX_UNKNOWN;
  241. }
  242. ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
  243. supported);
  244. ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising,
  245. advertising);
  246. return 0;
  247. }
  248. static int
  249. bnad_set_link_ksettings(struct net_device *netdev,
  250. const struct ethtool_link_ksettings *cmd)
  251. {
  252. /* 10G full duplex setting supported only */
  253. if (cmd->base.autoneg == AUTONEG_ENABLE)
  254. return -EOPNOTSUPP;
  255. if ((cmd->base.speed == SPEED_10000) &&
  256. (cmd->base.duplex == DUPLEX_FULL))
  257. return 0;
  258. return -EOPNOTSUPP;
  259. }
  260. static void
  261. bnad_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo)
  262. {
  263. struct bnad *bnad = netdev_priv(netdev);
  264. struct bfa_ioc_attr *ioc_attr;
  265. unsigned long flags;
  266. strlcpy(drvinfo->driver, BNAD_NAME, sizeof(drvinfo->driver));
  267. strlcpy(drvinfo->version, BNAD_VERSION, sizeof(drvinfo->version));
  268. ioc_attr = kzalloc(sizeof(*ioc_attr), GFP_KERNEL);
  269. if (ioc_attr) {
  270. spin_lock_irqsave(&bnad->bna_lock, flags);
  271. bfa_nw_ioc_get_attr(&bnad->bna.ioceth.ioc, ioc_attr);
  272. spin_unlock_irqrestore(&bnad->bna_lock, flags);
  273. strlcpy(drvinfo->fw_version, ioc_attr->adapter_attr.fw_ver,
  274. sizeof(drvinfo->fw_version));
  275. kfree(ioc_attr);
  276. }
  277. strlcpy(drvinfo->bus_info, pci_name(bnad->pcidev),
  278. sizeof(drvinfo->bus_info));
  279. }
  280. static void
  281. bnad_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wolinfo)
  282. {
  283. wolinfo->supported = 0;
  284. wolinfo->wolopts = 0;
  285. }
  286. static int
  287. bnad_get_coalesce(struct net_device *netdev, struct ethtool_coalesce *coalesce)
  288. {
  289. struct bnad *bnad = netdev_priv(netdev);
  290. unsigned long flags;
  291. /* Lock rqd. to access bnad->bna_lock */
  292. spin_lock_irqsave(&bnad->bna_lock, flags);
  293. coalesce->use_adaptive_rx_coalesce =
  294. (bnad->cfg_flags & BNAD_CF_DIM_ENABLED) ? true : false;
  295. spin_unlock_irqrestore(&bnad->bna_lock, flags);
  296. coalesce->rx_coalesce_usecs = bnad->rx_coalescing_timeo *
  297. BFI_COALESCING_TIMER_UNIT;
  298. coalesce->tx_coalesce_usecs = bnad->tx_coalescing_timeo *
  299. BFI_COALESCING_TIMER_UNIT;
  300. coalesce->tx_max_coalesced_frames = BFI_TX_INTERPKT_COUNT;
  301. return 0;
  302. }
  303. static int
  304. bnad_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *coalesce)
  305. {
  306. struct bnad *bnad = netdev_priv(netdev);
  307. unsigned long flags;
  308. int to_del = 0;
  309. if (coalesce->rx_coalesce_usecs == 0 ||
  310. coalesce->rx_coalesce_usecs >
  311. BFI_MAX_COALESCING_TIMEO * BFI_COALESCING_TIMER_UNIT)
  312. return -EINVAL;
  313. if (coalesce->tx_coalesce_usecs == 0 ||
  314. coalesce->tx_coalesce_usecs >
  315. BFI_MAX_COALESCING_TIMEO * BFI_COALESCING_TIMER_UNIT)
  316. return -EINVAL;
  317. mutex_lock(&bnad->conf_mutex);
  318. /*
  319. * Do not need to store rx_coalesce_usecs here
  320. * Every time DIM is disabled, we can get it from the
  321. * stack.
  322. */
  323. spin_lock_irqsave(&bnad->bna_lock, flags);
  324. if (coalesce->use_adaptive_rx_coalesce) {
  325. if (!(bnad->cfg_flags & BNAD_CF_DIM_ENABLED)) {
  326. bnad->cfg_flags |= BNAD_CF_DIM_ENABLED;
  327. bnad_dim_timer_start(bnad);
  328. }
  329. } else {
  330. if (bnad->cfg_flags & BNAD_CF_DIM_ENABLED) {
  331. bnad->cfg_flags &= ~BNAD_CF_DIM_ENABLED;
  332. if (bnad->cfg_flags & BNAD_CF_DIM_ENABLED &&
  333. test_bit(BNAD_RF_DIM_TIMER_RUNNING,
  334. &bnad->run_flags)) {
  335. clear_bit(BNAD_RF_DIM_TIMER_RUNNING,
  336. &bnad->run_flags);
  337. to_del = 1;
  338. }
  339. spin_unlock_irqrestore(&bnad->bna_lock, flags);
  340. if (to_del)
  341. del_timer_sync(&bnad->dim_timer);
  342. spin_lock_irqsave(&bnad->bna_lock, flags);
  343. bnad_rx_coalescing_timeo_set(bnad);
  344. }
  345. }
  346. if (bnad->tx_coalescing_timeo != coalesce->tx_coalesce_usecs /
  347. BFI_COALESCING_TIMER_UNIT) {
  348. bnad->tx_coalescing_timeo = coalesce->tx_coalesce_usecs /
  349. BFI_COALESCING_TIMER_UNIT;
  350. bnad_tx_coalescing_timeo_set(bnad);
  351. }
  352. if (bnad->rx_coalescing_timeo != coalesce->rx_coalesce_usecs /
  353. BFI_COALESCING_TIMER_UNIT) {
  354. bnad->rx_coalescing_timeo = coalesce->rx_coalesce_usecs /
  355. BFI_COALESCING_TIMER_UNIT;
  356. if (!(bnad->cfg_flags & BNAD_CF_DIM_ENABLED))
  357. bnad_rx_coalescing_timeo_set(bnad);
  358. }
  359. /* Add Tx Inter-pkt DMA count? */
  360. spin_unlock_irqrestore(&bnad->bna_lock, flags);
  361. mutex_unlock(&bnad->conf_mutex);
  362. return 0;
  363. }
  364. static void
  365. bnad_get_ringparam(struct net_device *netdev,
  366. struct ethtool_ringparam *ringparam)
  367. {
  368. struct bnad *bnad = netdev_priv(netdev);
  369. ringparam->rx_max_pending = BNAD_MAX_RXQ_DEPTH;
  370. ringparam->tx_max_pending = BNAD_MAX_TXQ_DEPTH;
  371. ringparam->rx_pending = bnad->rxq_depth;
  372. ringparam->tx_pending = bnad->txq_depth;
  373. }
  374. static int
  375. bnad_set_ringparam(struct net_device *netdev,
  376. struct ethtool_ringparam *ringparam)
  377. {
  378. int i, current_err, err = 0;
  379. struct bnad *bnad = netdev_priv(netdev);
  380. unsigned long flags;
  381. mutex_lock(&bnad->conf_mutex);
  382. if (ringparam->rx_pending == bnad->rxq_depth &&
  383. ringparam->tx_pending == bnad->txq_depth) {
  384. mutex_unlock(&bnad->conf_mutex);
  385. return 0;
  386. }
  387. if (ringparam->rx_pending < BNAD_MIN_Q_DEPTH ||
  388. ringparam->rx_pending > BNAD_MAX_RXQ_DEPTH ||
  389. !is_power_of_2(ringparam->rx_pending)) {
  390. mutex_unlock(&bnad->conf_mutex);
  391. return -EINVAL;
  392. }
  393. if (ringparam->tx_pending < BNAD_MIN_Q_DEPTH ||
  394. ringparam->tx_pending > BNAD_MAX_TXQ_DEPTH ||
  395. !is_power_of_2(ringparam->tx_pending)) {
  396. mutex_unlock(&bnad->conf_mutex);
  397. return -EINVAL;
  398. }
  399. if (ringparam->rx_pending != bnad->rxq_depth) {
  400. bnad->rxq_depth = ringparam->rx_pending;
  401. if (!netif_running(netdev)) {
  402. mutex_unlock(&bnad->conf_mutex);
  403. return 0;
  404. }
  405. for (i = 0; i < bnad->num_rx; i++) {
  406. if (!bnad->rx_info[i].rx)
  407. continue;
  408. bnad_destroy_rx(bnad, i);
  409. current_err = bnad_setup_rx(bnad, i);
  410. if (current_err && !err)
  411. err = current_err;
  412. }
  413. if (!err && bnad->rx_info[0].rx) {
  414. /* restore rx configuration */
  415. bnad_restore_vlans(bnad, 0);
  416. bnad_enable_default_bcast(bnad);
  417. spin_lock_irqsave(&bnad->bna_lock, flags);
  418. bnad_mac_addr_set_locked(bnad, netdev->dev_addr);
  419. spin_unlock_irqrestore(&bnad->bna_lock, flags);
  420. bnad->cfg_flags &= ~(BNAD_CF_ALLMULTI |
  421. BNAD_CF_PROMISC);
  422. bnad_set_rx_mode(netdev);
  423. }
  424. }
  425. if (ringparam->tx_pending != bnad->txq_depth) {
  426. bnad->txq_depth = ringparam->tx_pending;
  427. if (!netif_running(netdev)) {
  428. mutex_unlock(&bnad->conf_mutex);
  429. return 0;
  430. }
  431. for (i = 0; i < bnad->num_tx; i++) {
  432. if (!bnad->tx_info[i].tx)
  433. continue;
  434. bnad_destroy_tx(bnad, i);
  435. current_err = bnad_setup_tx(bnad, i);
  436. if (current_err && !err)
  437. err = current_err;
  438. }
  439. }
  440. mutex_unlock(&bnad->conf_mutex);
  441. return err;
  442. }
  443. static void
  444. bnad_get_pauseparam(struct net_device *netdev,
  445. struct ethtool_pauseparam *pauseparam)
  446. {
  447. struct bnad *bnad = netdev_priv(netdev);
  448. pauseparam->autoneg = 0;
  449. pauseparam->rx_pause = bnad->bna.enet.pause_config.rx_pause;
  450. pauseparam->tx_pause = bnad->bna.enet.pause_config.tx_pause;
  451. }
  452. static int
  453. bnad_set_pauseparam(struct net_device *netdev,
  454. struct ethtool_pauseparam *pauseparam)
  455. {
  456. struct bnad *bnad = netdev_priv(netdev);
  457. struct bna_pause_config pause_config;
  458. unsigned long flags;
  459. if (pauseparam->autoneg == AUTONEG_ENABLE)
  460. return -EINVAL;
  461. mutex_lock(&bnad->conf_mutex);
  462. if (pauseparam->rx_pause != bnad->bna.enet.pause_config.rx_pause ||
  463. pauseparam->tx_pause != bnad->bna.enet.pause_config.tx_pause) {
  464. pause_config.rx_pause = pauseparam->rx_pause;
  465. pause_config.tx_pause = pauseparam->tx_pause;
  466. spin_lock_irqsave(&bnad->bna_lock, flags);
  467. bna_enet_pause_config(&bnad->bna.enet, &pause_config);
  468. spin_unlock_irqrestore(&bnad->bna_lock, flags);
  469. }
  470. mutex_unlock(&bnad->conf_mutex);
  471. return 0;
  472. }
  473. static void
  474. bnad_get_strings(struct net_device *netdev, u32 stringset, u8 *string)
  475. {
  476. struct bnad *bnad = netdev_priv(netdev);
  477. int i, j, q_num;
  478. u32 bmap;
  479. mutex_lock(&bnad->conf_mutex);
  480. switch (stringset) {
  481. case ETH_SS_STATS:
  482. for (i = 0; i < BNAD_ETHTOOL_STATS_NUM; i++) {
  483. BUG_ON(!(strlen(bnad_net_stats_strings[i]) <
  484. ETH_GSTRING_LEN));
  485. strncpy(string, bnad_net_stats_strings[i],
  486. ETH_GSTRING_LEN);
  487. string += ETH_GSTRING_LEN;
  488. }
  489. bmap = bna_tx_rid_mask(&bnad->bna);
  490. for (i = 0; bmap; i++) {
  491. if (bmap & 1) {
  492. sprintf(string, "txf%d_ucast_octets", i);
  493. string += ETH_GSTRING_LEN;
  494. sprintf(string, "txf%d_ucast", i);
  495. string += ETH_GSTRING_LEN;
  496. sprintf(string, "txf%d_ucast_vlan", i);
  497. string += ETH_GSTRING_LEN;
  498. sprintf(string, "txf%d_mcast_octets", i);
  499. string += ETH_GSTRING_LEN;
  500. sprintf(string, "txf%d_mcast", i);
  501. string += ETH_GSTRING_LEN;
  502. sprintf(string, "txf%d_mcast_vlan", i);
  503. string += ETH_GSTRING_LEN;
  504. sprintf(string, "txf%d_bcast_octets", i);
  505. string += ETH_GSTRING_LEN;
  506. sprintf(string, "txf%d_bcast", i);
  507. string += ETH_GSTRING_LEN;
  508. sprintf(string, "txf%d_bcast_vlan", i);
  509. string += ETH_GSTRING_LEN;
  510. sprintf(string, "txf%d_errors", i);
  511. string += ETH_GSTRING_LEN;
  512. sprintf(string, "txf%d_filter_vlan", i);
  513. string += ETH_GSTRING_LEN;
  514. sprintf(string, "txf%d_filter_mac_sa", i);
  515. string += ETH_GSTRING_LEN;
  516. }
  517. bmap >>= 1;
  518. }
  519. bmap = bna_rx_rid_mask(&bnad->bna);
  520. for (i = 0; bmap; i++) {
  521. if (bmap & 1) {
  522. sprintf(string, "rxf%d_ucast_octets", i);
  523. string += ETH_GSTRING_LEN;
  524. sprintf(string, "rxf%d_ucast", i);
  525. string += ETH_GSTRING_LEN;
  526. sprintf(string, "rxf%d_ucast_vlan", i);
  527. string += ETH_GSTRING_LEN;
  528. sprintf(string, "rxf%d_mcast_octets", i);
  529. string += ETH_GSTRING_LEN;
  530. sprintf(string, "rxf%d_mcast", i);
  531. string += ETH_GSTRING_LEN;
  532. sprintf(string, "rxf%d_mcast_vlan", i);
  533. string += ETH_GSTRING_LEN;
  534. sprintf(string, "rxf%d_bcast_octets", i);
  535. string += ETH_GSTRING_LEN;
  536. sprintf(string, "rxf%d_bcast", i);
  537. string += ETH_GSTRING_LEN;
  538. sprintf(string, "rxf%d_bcast_vlan", i);
  539. string += ETH_GSTRING_LEN;
  540. sprintf(string, "rxf%d_frame_drops", i);
  541. string += ETH_GSTRING_LEN;
  542. }
  543. bmap >>= 1;
  544. }
  545. q_num = 0;
  546. for (i = 0; i < bnad->num_rx; i++) {
  547. if (!bnad->rx_info[i].rx)
  548. continue;
  549. for (j = 0; j < bnad->num_rxp_per_rx; j++) {
  550. sprintf(string, "cq%d_producer_index", q_num);
  551. string += ETH_GSTRING_LEN;
  552. sprintf(string, "cq%d_consumer_index", q_num);
  553. string += ETH_GSTRING_LEN;
  554. sprintf(string, "cq%d_hw_producer_index",
  555. q_num);
  556. string += ETH_GSTRING_LEN;
  557. sprintf(string, "cq%d_intr", q_num);
  558. string += ETH_GSTRING_LEN;
  559. sprintf(string, "cq%d_poll", q_num);
  560. string += ETH_GSTRING_LEN;
  561. sprintf(string, "cq%d_schedule", q_num);
  562. string += ETH_GSTRING_LEN;
  563. sprintf(string, "cq%d_keep_poll", q_num);
  564. string += ETH_GSTRING_LEN;
  565. sprintf(string, "cq%d_complete", q_num);
  566. string += ETH_GSTRING_LEN;
  567. q_num++;
  568. }
  569. }
  570. q_num = 0;
  571. for (i = 0; i < bnad->num_rx; i++) {
  572. if (!bnad->rx_info[i].rx)
  573. continue;
  574. for (j = 0; j < bnad->num_rxp_per_rx; j++) {
  575. sprintf(string, "rxq%d_packets", q_num);
  576. string += ETH_GSTRING_LEN;
  577. sprintf(string, "rxq%d_bytes", q_num);
  578. string += ETH_GSTRING_LEN;
  579. sprintf(string, "rxq%d_packets_with_error",
  580. q_num);
  581. string += ETH_GSTRING_LEN;
  582. sprintf(string, "rxq%d_allocbuf_failed", q_num);
  583. string += ETH_GSTRING_LEN;
  584. sprintf(string, "rxq%d_mapbuf_failed", q_num);
  585. string += ETH_GSTRING_LEN;
  586. sprintf(string, "rxq%d_producer_index", q_num);
  587. string += ETH_GSTRING_LEN;
  588. sprintf(string, "rxq%d_consumer_index", q_num);
  589. string += ETH_GSTRING_LEN;
  590. q_num++;
  591. if (bnad->rx_info[i].rx_ctrl[j].ccb &&
  592. bnad->rx_info[i].rx_ctrl[j].ccb->
  593. rcb[1] &&
  594. bnad->rx_info[i].rx_ctrl[j].ccb->
  595. rcb[1]->rxq) {
  596. sprintf(string, "rxq%d_packets", q_num);
  597. string += ETH_GSTRING_LEN;
  598. sprintf(string, "rxq%d_bytes", q_num);
  599. string += ETH_GSTRING_LEN;
  600. sprintf(string,
  601. "rxq%d_packets_with_error", q_num);
  602. string += ETH_GSTRING_LEN;
  603. sprintf(string, "rxq%d_allocbuf_failed",
  604. q_num);
  605. string += ETH_GSTRING_LEN;
  606. sprintf(string, "rxq%d_mapbuf_failed",
  607. q_num);
  608. string += ETH_GSTRING_LEN;
  609. sprintf(string, "rxq%d_producer_index",
  610. q_num);
  611. string += ETH_GSTRING_LEN;
  612. sprintf(string, "rxq%d_consumer_index",
  613. q_num);
  614. string += ETH_GSTRING_LEN;
  615. q_num++;
  616. }
  617. }
  618. }
  619. q_num = 0;
  620. for (i = 0; i < bnad->num_tx; i++) {
  621. if (!bnad->tx_info[i].tx)
  622. continue;
  623. for (j = 0; j < bnad->num_txq_per_tx; j++) {
  624. sprintf(string, "txq%d_packets", q_num);
  625. string += ETH_GSTRING_LEN;
  626. sprintf(string, "txq%d_bytes", q_num);
  627. string += ETH_GSTRING_LEN;
  628. sprintf(string, "txq%d_producer_index", q_num);
  629. string += ETH_GSTRING_LEN;
  630. sprintf(string, "txq%d_consumer_index", q_num);
  631. string += ETH_GSTRING_LEN;
  632. sprintf(string, "txq%d_hw_consumer_index",
  633. q_num);
  634. string += ETH_GSTRING_LEN;
  635. q_num++;
  636. }
  637. }
  638. break;
  639. default:
  640. break;
  641. }
  642. mutex_unlock(&bnad->conf_mutex);
  643. }
  644. static int
  645. bnad_get_stats_count_locked(struct net_device *netdev)
  646. {
  647. struct bnad *bnad = netdev_priv(netdev);
  648. int i, j, count = 0, rxf_active_num = 0, txf_active_num = 0;
  649. u32 bmap;
  650. bmap = bna_tx_rid_mask(&bnad->bna);
  651. for (i = 0; bmap; i++) {
  652. if (bmap & 1)
  653. txf_active_num++;
  654. bmap >>= 1;
  655. }
  656. bmap = bna_rx_rid_mask(&bnad->bna);
  657. for (i = 0; bmap; i++) {
  658. if (bmap & 1)
  659. rxf_active_num++;
  660. bmap >>= 1;
  661. }
  662. count = BNAD_ETHTOOL_STATS_NUM +
  663. txf_active_num * BNAD_NUM_TXF_COUNTERS +
  664. rxf_active_num * BNAD_NUM_RXF_COUNTERS;
  665. for (i = 0; i < bnad->num_rx; i++) {
  666. if (!bnad->rx_info[i].rx)
  667. continue;
  668. count += bnad->num_rxp_per_rx * BNAD_NUM_CQ_COUNTERS;
  669. count += bnad->num_rxp_per_rx * BNAD_NUM_RXQ_COUNTERS;
  670. for (j = 0; j < bnad->num_rxp_per_rx; j++)
  671. if (bnad->rx_info[i].rx_ctrl[j].ccb &&
  672. bnad->rx_info[i].rx_ctrl[j].ccb->rcb[1] &&
  673. bnad->rx_info[i].rx_ctrl[j].ccb->rcb[1]->rxq)
  674. count += BNAD_NUM_RXQ_COUNTERS;
  675. }
  676. for (i = 0; i < bnad->num_tx; i++) {
  677. if (!bnad->tx_info[i].tx)
  678. continue;
  679. count += bnad->num_txq_per_tx * BNAD_NUM_TXQ_COUNTERS;
  680. }
  681. return count;
  682. }
  683. static int
  684. bnad_per_q_stats_fill(struct bnad *bnad, u64 *buf, int bi)
  685. {
  686. int i, j;
  687. struct bna_rcb *rcb = NULL;
  688. struct bna_tcb *tcb = NULL;
  689. for (i = 0; i < bnad->num_rx; i++) {
  690. if (!bnad->rx_info[i].rx)
  691. continue;
  692. for (j = 0; j < bnad->num_rxp_per_rx; j++)
  693. if (bnad->rx_info[i].rx_ctrl[j].ccb &&
  694. bnad->rx_info[i].rx_ctrl[j].ccb->rcb[0] &&
  695. bnad->rx_info[i].rx_ctrl[j].ccb->rcb[0]->rxq) {
  696. buf[bi++] = bnad->rx_info[i].rx_ctrl[j].
  697. ccb->producer_index;
  698. buf[bi++] = 0; /* ccb->consumer_index */
  699. buf[bi++] = *(bnad->rx_info[i].rx_ctrl[j].
  700. ccb->hw_producer_index);
  701. buf[bi++] = bnad->rx_info[i].
  702. rx_ctrl[j].rx_intr_ctr;
  703. buf[bi++] = bnad->rx_info[i].
  704. rx_ctrl[j].rx_poll_ctr;
  705. buf[bi++] = bnad->rx_info[i].
  706. rx_ctrl[j].rx_schedule;
  707. buf[bi++] = bnad->rx_info[i].
  708. rx_ctrl[j].rx_keep_poll;
  709. buf[bi++] = bnad->rx_info[i].
  710. rx_ctrl[j].rx_complete;
  711. }
  712. }
  713. for (i = 0; i < bnad->num_rx; i++) {
  714. if (!bnad->rx_info[i].rx)
  715. continue;
  716. for (j = 0; j < bnad->num_rxp_per_rx; j++)
  717. if (bnad->rx_info[i].rx_ctrl[j].ccb) {
  718. if (bnad->rx_info[i].rx_ctrl[j].ccb->rcb[0] &&
  719. bnad->rx_info[i].rx_ctrl[j].ccb->
  720. rcb[0]->rxq) {
  721. rcb = bnad->rx_info[i].rx_ctrl[j].
  722. ccb->rcb[0];
  723. buf[bi++] = rcb->rxq->rx_packets;
  724. buf[bi++] = rcb->rxq->rx_bytes;
  725. buf[bi++] = rcb->rxq->
  726. rx_packets_with_error;
  727. buf[bi++] = rcb->rxq->
  728. rxbuf_alloc_failed;
  729. buf[bi++] = rcb->rxq->rxbuf_map_failed;
  730. buf[bi++] = rcb->producer_index;
  731. buf[bi++] = rcb->consumer_index;
  732. }
  733. if (bnad->rx_info[i].rx_ctrl[j].ccb->rcb[1] &&
  734. bnad->rx_info[i].rx_ctrl[j].ccb->
  735. rcb[1]->rxq) {
  736. rcb = bnad->rx_info[i].rx_ctrl[j].
  737. ccb->rcb[1];
  738. buf[bi++] = rcb->rxq->rx_packets;
  739. buf[bi++] = rcb->rxq->rx_bytes;
  740. buf[bi++] = rcb->rxq->
  741. rx_packets_with_error;
  742. buf[bi++] = rcb->rxq->
  743. rxbuf_alloc_failed;
  744. buf[bi++] = rcb->rxq->rxbuf_map_failed;
  745. buf[bi++] = rcb->producer_index;
  746. buf[bi++] = rcb->consumer_index;
  747. }
  748. }
  749. }
  750. for (i = 0; i < bnad->num_tx; i++) {
  751. if (!bnad->tx_info[i].tx)
  752. continue;
  753. for (j = 0; j < bnad->num_txq_per_tx; j++)
  754. if (bnad->tx_info[i].tcb[j] &&
  755. bnad->tx_info[i].tcb[j]->txq) {
  756. tcb = bnad->tx_info[i].tcb[j];
  757. buf[bi++] = tcb->txq->tx_packets;
  758. buf[bi++] = tcb->txq->tx_bytes;
  759. buf[bi++] = tcb->producer_index;
  760. buf[bi++] = tcb->consumer_index;
  761. buf[bi++] = *(tcb->hw_consumer_index);
  762. }
  763. }
  764. return bi;
  765. }
  766. static void
  767. bnad_get_ethtool_stats(struct net_device *netdev, struct ethtool_stats *stats,
  768. u64 *buf)
  769. {
  770. struct bnad *bnad = netdev_priv(netdev);
  771. int i, j, bi = 0;
  772. unsigned long flags;
  773. struct rtnl_link_stats64 net_stats64;
  774. u64 *stats64;
  775. u32 bmap;
  776. mutex_lock(&bnad->conf_mutex);
  777. if (bnad_get_stats_count_locked(netdev) != stats->n_stats) {
  778. mutex_unlock(&bnad->conf_mutex);
  779. return;
  780. }
  781. /*
  782. * Used bna_lock to sync reads from bna_stats, which is written
  783. * under the same lock
  784. */
  785. spin_lock_irqsave(&bnad->bna_lock, flags);
  786. memset(&net_stats64, 0, sizeof(net_stats64));
  787. bnad_netdev_qstats_fill(bnad, &net_stats64);
  788. bnad_netdev_hwstats_fill(bnad, &net_stats64);
  789. buf[bi++] = net_stats64.rx_packets;
  790. buf[bi++] = net_stats64.tx_packets;
  791. buf[bi++] = net_stats64.rx_bytes;
  792. buf[bi++] = net_stats64.tx_bytes;
  793. buf[bi++] = net_stats64.rx_errors;
  794. buf[bi++] = net_stats64.tx_errors;
  795. buf[bi++] = net_stats64.rx_dropped;
  796. buf[bi++] = net_stats64.tx_dropped;
  797. buf[bi++] = net_stats64.multicast;
  798. buf[bi++] = net_stats64.collisions;
  799. buf[bi++] = net_stats64.rx_length_errors;
  800. buf[bi++] = net_stats64.rx_crc_errors;
  801. buf[bi++] = net_stats64.rx_frame_errors;
  802. buf[bi++] = net_stats64.tx_fifo_errors;
  803. /* Get netif_queue_stopped from stack */
  804. bnad->stats.drv_stats.netif_queue_stopped = netif_queue_stopped(netdev);
  805. /* Fill driver stats into ethtool buffers */
  806. stats64 = (u64 *)&bnad->stats.drv_stats;
  807. for (i = 0; i < sizeof(struct bnad_drv_stats) / sizeof(u64); i++)
  808. buf[bi++] = stats64[i];
  809. /* Fill hardware stats excluding the rxf/txf into ethtool bufs */
  810. stats64 = (u64 *) &bnad->stats.bna_stats->hw_stats;
  811. for (i = 0;
  812. i < offsetof(struct bfi_enet_stats, rxf_stats[0]) /
  813. sizeof(u64);
  814. i++)
  815. buf[bi++] = stats64[i];
  816. /* Fill txf stats into ethtool buffers */
  817. bmap = bna_tx_rid_mask(&bnad->bna);
  818. for (i = 0; bmap; i++) {
  819. if (bmap & 1) {
  820. stats64 = (u64 *)&bnad->stats.bna_stats->
  821. hw_stats.txf_stats[i];
  822. for (j = 0; j < sizeof(struct bfi_enet_stats_txf) /
  823. sizeof(u64); j++)
  824. buf[bi++] = stats64[j];
  825. }
  826. bmap >>= 1;
  827. }
  828. /* Fill rxf stats into ethtool buffers */
  829. bmap = bna_rx_rid_mask(&bnad->bna);
  830. for (i = 0; bmap; i++) {
  831. if (bmap & 1) {
  832. stats64 = (u64 *)&bnad->stats.bna_stats->
  833. hw_stats.rxf_stats[i];
  834. for (j = 0; j < sizeof(struct bfi_enet_stats_rxf) /
  835. sizeof(u64); j++)
  836. buf[bi++] = stats64[j];
  837. }
  838. bmap >>= 1;
  839. }
  840. /* Fill per Q stats into ethtool buffers */
  841. bi = bnad_per_q_stats_fill(bnad, buf, bi);
  842. spin_unlock_irqrestore(&bnad->bna_lock, flags);
  843. mutex_unlock(&bnad->conf_mutex);
  844. }
  845. static int
  846. bnad_get_sset_count(struct net_device *netdev, int sset)
  847. {
  848. switch (sset) {
  849. case ETH_SS_STATS:
  850. return bnad_get_stats_count_locked(netdev);
  851. default:
  852. return -EOPNOTSUPP;
  853. }
  854. }
  855. static u32
  856. bnad_get_flash_partition_by_offset(struct bnad *bnad, u32 offset,
  857. u32 *base_offset)
  858. {
  859. struct bfa_flash_attr *flash_attr;
  860. struct bnad_iocmd_comp fcomp;
  861. u32 i, flash_part = 0, ret;
  862. unsigned long flags = 0;
  863. flash_attr = kzalloc(sizeof(struct bfa_flash_attr), GFP_KERNEL);
  864. if (!flash_attr)
  865. return 0;
  866. fcomp.bnad = bnad;
  867. fcomp.comp_status = 0;
  868. init_completion(&fcomp.comp);
  869. spin_lock_irqsave(&bnad->bna_lock, flags);
  870. ret = bfa_nw_flash_get_attr(&bnad->bna.flash, flash_attr,
  871. bnad_cb_completion, &fcomp);
  872. if (ret != BFA_STATUS_OK) {
  873. spin_unlock_irqrestore(&bnad->bna_lock, flags);
  874. kfree(flash_attr);
  875. return 0;
  876. }
  877. spin_unlock_irqrestore(&bnad->bna_lock, flags);
  878. wait_for_completion(&fcomp.comp);
  879. ret = fcomp.comp_status;
  880. /* Check for the flash type & base offset value */
  881. if (ret == BFA_STATUS_OK) {
  882. for (i = 0; i < flash_attr->npart; i++) {
  883. if (offset >= flash_attr->part[i].part_off &&
  884. offset < (flash_attr->part[i].part_off +
  885. flash_attr->part[i].part_size)) {
  886. flash_part = flash_attr->part[i].part_type;
  887. *base_offset = flash_attr->part[i].part_off;
  888. break;
  889. }
  890. }
  891. }
  892. kfree(flash_attr);
  893. return flash_part;
  894. }
  895. static int
  896. bnad_get_eeprom_len(struct net_device *netdev)
  897. {
  898. return BFA_TOTAL_FLASH_SIZE;
  899. }
  900. static int
  901. bnad_get_eeprom(struct net_device *netdev, struct ethtool_eeprom *eeprom,
  902. u8 *bytes)
  903. {
  904. struct bnad *bnad = netdev_priv(netdev);
  905. struct bnad_iocmd_comp fcomp;
  906. u32 flash_part = 0, base_offset = 0;
  907. unsigned long flags = 0;
  908. int ret = 0;
  909. /* Fill the magic value */
  910. eeprom->magic = bnad->pcidev->vendor | (bnad->pcidev->device << 16);
  911. /* Query the flash partition based on the offset */
  912. flash_part = bnad_get_flash_partition_by_offset(bnad,
  913. eeprom->offset, &base_offset);
  914. if (flash_part == 0)
  915. return -EFAULT;
  916. fcomp.bnad = bnad;
  917. fcomp.comp_status = 0;
  918. init_completion(&fcomp.comp);
  919. spin_lock_irqsave(&bnad->bna_lock, flags);
  920. ret = bfa_nw_flash_read_part(&bnad->bna.flash, flash_part,
  921. bnad->id, bytes, eeprom->len,
  922. eeprom->offset - base_offset,
  923. bnad_cb_completion, &fcomp);
  924. if (ret != BFA_STATUS_OK) {
  925. spin_unlock_irqrestore(&bnad->bna_lock, flags);
  926. goto done;
  927. }
  928. spin_unlock_irqrestore(&bnad->bna_lock, flags);
  929. wait_for_completion(&fcomp.comp);
  930. ret = fcomp.comp_status;
  931. done:
  932. return ret;
  933. }
  934. static int
  935. bnad_set_eeprom(struct net_device *netdev, struct ethtool_eeprom *eeprom,
  936. u8 *bytes)
  937. {
  938. struct bnad *bnad = netdev_priv(netdev);
  939. struct bnad_iocmd_comp fcomp;
  940. u32 flash_part = 0, base_offset = 0;
  941. unsigned long flags = 0;
  942. int ret = 0;
  943. /* Check if the flash update request is valid */
  944. if (eeprom->magic != (bnad->pcidev->vendor |
  945. (bnad->pcidev->device << 16)))
  946. return -EINVAL;
  947. /* Query the flash partition based on the offset */
  948. flash_part = bnad_get_flash_partition_by_offset(bnad,
  949. eeprom->offset, &base_offset);
  950. if (flash_part == 0)
  951. return -EFAULT;
  952. fcomp.bnad = bnad;
  953. fcomp.comp_status = 0;
  954. init_completion(&fcomp.comp);
  955. spin_lock_irqsave(&bnad->bna_lock, flags);
  956. ret = bfa_nw_flash_update_part(&bnad->bna.flash, flash_part,
  957. bnad->id, bytes, eeprom->len,
  958. eeprom->offset - base_offset,
  959. bnad_cb_completion, &fcomp);
  960. if (ret != BFA_STATUS_OK) {
  961. spin_unlock_irqrestore(&bnad->bna_lock, flags);
  962. goto done;
  963. }
  964. spin_unlock_irqrestore(&bnad->bna_lock, flags);
  965. wait_for_completion(&fcomp.comp);
  966. ret = fcomp.comp_status;
  967. done:
  968. return ret;
  969. }
  970. static int
  971. bnad_flash_device(struct net_device *netdev, struct ethtool_flash *eflash)
  972. {
  973. struct bnad *bnad = netdev_priv(netdev);
  974. struct bnad_iocmd_comp fcomp;
  975. const struct firmware *fw;
  976. int ret = 0;
  977. ret = request_firmware(&fw, eflash->data, &bnad->pcidev->dev);
  978. if (ret) {
  979. netdev_err(netdev, "can't load firmware %s\n", eflash->data);
  980. goto out;
  981. }
  982. fcomp.bnad = bnad;
  983. fcomp.comp_status = 0;
  984. init_completion(&fcomp.comp);
  985. spin_lock_irq(&bnad->bna_lock);
  986. ret = bfa_nw_flash_update_part(&bnad->bna.flash, BFA_FLASH_PART_FWIMG,
  987. bnad->id, (u8 *)fw->data, fw->size, 0,
  988. bnad_cb_completion, &fcomp);
  989. if (ret != BFA_STATUS_OK) {
  990. netdev_warn(netdev, "flash update failed with err=%d\n", ret);
  991. ret = -EIO;
  992. spin_unlock_irq(&bnad->bna_lock);
  993. goto out;
  994. }
  995. spin_unlock_irq(&bnad->bna_lock);
  996. wait_for_completion(&fcomp.comp);
  997. if (fcomp.comp_status != BFA_STATUS_OK) {
  998. ret = -EIO;
  999. netdev_warn(netdev,
  1000. "firmware image update failed with err=%d\n",
  1001. fcomp.comp_status);
  1002. }
  1003. out:
  1004. release_firmware(fw);
  1005. return ret;
  1006. }
  1007. static const struct ethtool_ops bnad_ethtool_ops = {
  1008. .get_drvinfo = bnad_get_drvinfo,
  1009. .get_wol = bnad_get_wol,
  1010. .get_link = ethtool_op_get_link,
  1011. .get_coalesce = bnad_get_coalesce,
  1012. .set_coalesce = bnad_set_coalesce,
  1013. .get_ringparam = bnad_get_ringparam,
  1014. .set_ringparam = bnad_set_ringparam,
  1015. .get_pauseparam = bnad_get_pauseparam,
  1016. .set_pauseparam = bnad_set_pauseparam,
  1017. .get_strings = bnad_get_strings,
  1018. .get_ethtool_stats = bnad_get_ethtool_stats,
  1019. .get_sset_count = bnad_get_sset_count,
  1020. .get_eeprom_len = bnad_get_eeprom_len,
  1021. .get_eeprom = bnad_get_eeprom,
  1022. .set_eeprom = bnad_set_eeprom,
  1023. .flash_device = bnad_flash_device,
  1024. .get_ts_info = ethtool_op_get_ts_info,
  1025. .get_link_ksettings = bnad_get_link_ksettings,
  1026. .set_link_ksettings = bnad_set_link_ksettings,
  1027. };
  1028. void
  1029. bnad_set_ethtool_ops(struct net_device *netdev)
  1030. {
  1031. netdev->ethtool_ops = &bnad_ethtool_ops;
  1032. }