blob: 298b92cbd68948e3d54893a7e8f11885bda7c01c [file] [log] [blame]
Sathya Perla6b7c5b92009-03-11 23:32:03 -07001/*
2 * Copyright (C) 2005 - 2009 ServerEngines
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@serverengines.com
12 *
13 * ServerEngines
14 * 209 N. Fair Oaks Ave
15 * Sunnyvale, CA 94085
16 */
17
18#include "be.h"
Sathya Perla8788fdc2009-07-27 22:52:03 +000019#include "be_cmds.h"
Sathya Perla6b7c5b92009-03-11 23:32:03 -070020#include <linux/ethtool.h>
21
22struct be_ethtool_stat {
23 char desc[ETH_GSTRING_LEN];
24 int type;
25 int size;
26 int offset;
27};
28
29enum {NETSTAT, PORTSTAT, MISCSTAT, DRVSTAT, ERXSTAT};
30#define FIELDINFO(_struct, field) FIELD_SIZEOF(_struct, field), \
31 offsetof(_struct, field)
32#define NETSTAT_INFO(field) #field, NETSTAT,\
33 FIELDINFO(struct net_device_stats,\
34 field)
35#define DRVSTAT_INFO(field) #field, DRVSTAT,\
36 FIELDINFO(struct be_drvr_stats, field)
37#define MISCSTAT_INFO(field) #field, MISCSTAT,\
38 FIELDINFO(struct be_rxf_stats, field)
39#define PORTSTAT_INFO(field) #field, PORTSTAT,\
40 FIELDINFO(struct be_port_rxf_stats, \
41 field)
42#define ERXSTAT_INFO(field) #field, ERXSTAT,\
43 FIELDINFO(struct be_erx_stats, field)
44
45static const struct be_ethtool_stat et_stats[] = {
46 {NETSTAT_INFO(rx_packets)},
47 {NETSTAT_INFO(tx_packets)},
48 {NETSTAT_INFO(rx_bytes)},
49 {NETSTAT_INFO(tx_bytes)},
50 {NETSTAT_INFO(rx_errors)},
51 {NETSTAT_INFO(tx_errors)},
52 {NETSTAT_INFO(rx_dropped)},
53 {NETSTAT_INFO(tx_dropped)},
54 {DRVSTAT_INFO(be_tx_reqs)},
55 {DRVSTAT_INFO(be_tx_stops)},
56 {DRVSTAT_INFO(be_fwd_reqs)},
57 {DRVSTAT_INFO(be_tx_wrbs)},
Ajit Khapardeb7b83ac2009-11-29 17:57:22 +000058 {DRVSTAT_INFO(be_rx_polls)},
Sathya Perla6b7c5b92009-03-11 23:32:03 -070059 {DRVSTAT_INFO(be_tx_events)},
60 {DRVSTAT_INFO(be_rx_events)},
61 {DRVSTAT_INFO(be_tx_compl)},
62 {DRVSTAT_INFO(be_rx_compl)},
63 {DRVSTAT_INFO(be_ethrx_post_fail)},
64 {DRVSTAT_INFO(be_802_3_dropped_frames)},
65 {DRVSTAT_INFO(be_802_3_malformed_frames)},
66 {DRVSTAT_INFO(be_tx_rate)},
67 {DRVSTAT_INFO(be_rx_rate)},
68 {PORTSTAT_INFO(rx_unicast_frames)},
69 {PORTSTAT_INFO(rx_multicast_frames)},
70 {PORTSTAT_INFO(rx_broadcast_frames)},
71 {PORTSTAT_INFO(rx_crc_errors)},
72 {PORTSTAT_INFO(rx_alignment_symbol_errors)},
73 {PORTSTAT_INFO(rx_pause_frames)},
74 {PORTSTAT_INFO(rx_control_frames)},
75 {PORTSTAT_INFO(rx_in_range_errors)},
76 {PORTSTAT_INFO(rx_out_range_errors)},
77 {PORTSTAT_INFO(rx_frame_too_long)},
78 {PORTSTAT_INFO(rx_address_match_errors)},
79 {PORTSTAT_INFO(rx_vlan_mismatch)},
80 {PORTSTAT_INFO(rx_dropped_too_small)},
81 {PORTSTAT_INFO(rx_dropped_too_short)},
82 {PORTSTAT_INFO(rx_dropped_header_too_small)},
83 {PORTSTAT_INFO(rx_dropped_tcp_length)},
84 {PORTSTAT_INFO(rx_dropped_runt)},
85 {PORTSTAT_INFO(rx_fifo_overflow)},
86 {PORTSTAT_INFO(rx_input_fifo_overflow)},
87 {PORTSTAT_INFO(rx_ip_checksum_errs)},
88 {PORTSTAT_INFO(rx_tcp_checksum_errs)},
89 {PORTSTAT_INFO(rx_udp_checksum_errs)},
90 {PORTSTAT_INFO(rx_non_rss_packets)},
91 {PORTSTAT_INFO(rx_ipv4_packets)},
92 {PORTSTAT_INFO(rx_ipv6_packets)},
93 {PORTSTAT_INFO(tx_unicastframes)},
94 {PORTSTAT_INFO(tx_multicastframes)},
95 {PORTSTAT_INFO(tx_broadcastframes)},
96 {PORTSTAT_INFO(tx_pauseframes)},
97 {PORTSTAT_INFO(tx_controlframes)},
98 {MISCSTAT_INFO(rx_drops_no_pbuf)},
99 {MISCSTAT_INFO(rx_drops_no_txpb)},
100 {MISCSTAT_INFO(rx_drops_no_erx_descr)},
101 {MISCSTAT_INFO(rx_drops_no_tpre_descr)},
102 {MISCSTAT_INFO(rx_drops_too_many_frags)},
103 {MISCSTAT_INFO(rx_drops_invalid_ring)},
104 {MISCSTAT_INFO(forwarded_packets)},
105 {MISCSTAT_INFO(rx_drops_mtu)},
106 {ERXSTAT_INFO(rx_drops_no_fragments)},
107};
108#define ETHTOOL_STATS_NUM ARRAY_SIZE(et_stats)
109
Suresh Rff33a6e2009-12-03 16:15:52 -0800110static const char et_self_tests[][ETH_GSTRING_LEN] = {
111 "MAC Loopback test",
112 "PHY Loopback test",
113 "External Loopback test",
114 "DDR DMA test"
115};
116
117#define ETHTOOL_TESTS_NUM ARRAY_SIZE(et_self_tests)
118#define BE_MAC_LOOPBACK 0x0
119#define BE_PHY_LOOPBACK 0x1
120#define BE_ONE_PORT_EXT_LOOPBACK 0x2
121
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700122static void
123be_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo)
124{
125 struct be_adapter *adapter = netdev_priv(netdev);
126
127 strcpy(drvinfo->driver, DRV_NAME);
128 strcpy(drvinfo->version, DRV_VER);
129 strncpy(drvinfo->fw_version, adapter->fw_ver, FW_VER_LEN);
130 strcpy(drvinfo->bus_info, pci_name(adapter->pdev));
131 drvinfo->testinfo_len = 0;
132 drvinfo->regdump_len = 0;
133 drvinfo->eedump_len = 0;
134}
135
136static int
137be_get_coalesce(struct net_device *netdev, struct ethtool_coalesce *coalesce)
138{
139 struct be_adapter *adapter = netdev_priv(netdev);
140 struct be_eq_obj *rx_eq = &adapter->rx_eq;
141 struct be_eq_obj *tx_eq = &adapter->tx_eq;
142
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700143 coalesce->rx_coalesce_usecs = rx_eq->cur_eqd;
144 coalesce->rx_coalesce_usecs_high = rx_eq->max_eqd;
145 coalesce->rx_coalesce_usecs_low = rx_eq->min_eqd;
146
147 coalesce->tx_coalesce_usecs = tx_eq->cur_eqd;
148 coalesce->tx_coalesce_usecs_high = tx_eq->max_eqd;
149 coalesce->tx_coalesce_usecs_low = tx_eq->min_eqd;
150
151 coalesce->use_adaptive_rx_coalesce = rx_eq->enable_aic;
152 coalesce->use_adaptive_tx_coalesce = tx_eq->enable_aic;
153
154 return 0;
155}
156
157/*
Ajit Khaparde5be93b92009-07-21 12:36:19 -0700158 * This routine is used to set interrup coalescing delay
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700159 */
160static int
161be_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *coalesce)
162{
163 struct be_adapter *adapter = netdev_priv(netdev);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700164 struct be_eq_obj *rx_eq = &adapter->rx_eq;
165 struct be_eq_obj *tx_eq = &adapter->tx_eq;
166 u32 tx_max, tx_min, tx_cur;
167 u32 rx_max, rx_min, rx_cur;
168 int status = 0;
169
170 if (coalesce->use_adaptive_tx_coalesce == 1)
171 return -EINVAL;
172
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700173 /* if AIC is being turned on now, start with an EQD of 0 */
174 if (rx_eq->enable_aic == 0 &&
175 coalesce->use_adaptive_rx_coalesce == 1) {
176 rx_eq->cur_eqd = 0;
177 }
178 rx_eq->enable_aic = coalesce->use_adaptive_rx_coalesce;
179
180 rx_max = coalesce->rx_coalesce_usecs_high;
181 rx_min = coalesce->rx_coalesce_usecs_low;
182 rx_cur = coalesce->rx_coalesce_usecs;
183
184 tx_max = coalesce->tx_coalesce_usecs_high;
185 tx_min = coalesce->tx_coalesce_usecs_low;
186 tx_cur = coalesce->tx_coalesce_usecs;
187
188 if (tx_cur > BE_MAX_EQD)
189 tx_cur = BE_MAX_EQD;
190 if (tx_eq->cur_eqd != tx_cur) {
Sathya Perla8788fdc2009-07-27 22:52:03 +0000191 status = be_cmd_modify_eqd(adapter, tx_eq->q.id, tx_cur);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700192 if (!status)
193 tx_eq->cur_eqd = tx_cur;
194 }
195
196 if (rx_eq->enable_aic) {
197 if (rx_max > BE_MAX_EQD)
198 rx_max = BE_MAX_EQD;
199 if (rx_min > rx_max)
200 rx_min = rx_max;
201 rx_eq->max_eqd = rx_max;
202 rx_eq->min_eqd = rx_min;
203 if (rx_eq->cur_eqd > rx_max)
204 rx_eq->cur_eqd = rx_max;
205 if (rx_eq->cur_eqd < rx_min)
206 rx_eq->cur_eqd = rx_min;
207 } else {
208 if (rx_cur > BE_MAX_EQD)
209 rx_cur = BE_MAX_EQD;
210 if (rx_eq->cur_eqd != rx_cur) {
Sathya Perla8788fdc2009-07-27 22:52:03 +0000211 status = be_cmd_modify_eqd(adapter, rx_eq->q.id,
212 rx_cur);
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700213 if (!status)
214 rx_eq->cur_eqd = rx_cur;
215 }
216 }
217 return 0;
218}
219
220static u32 be_get_rx_csum(struct net_device *netdev)
221{
222 struct be_adapter *adapter = netdev_priv(netdev);
223
224 return adapter->rx_csum;
225}
226
227static int be_set_rx_csum(struct net_device *netdev, uint32_t data)
228{
229 struct be_adapter *adapter = netdev_priv(netdev);
230
231 if (data)
232 adapter->rx_csum = true;
233 else
234 adapter->rx_csum = false;
235
236 return 0;
237}
238
239static void
240be_get_ethtool_stats(struct net_device *netdev,
241 struct ethtool_stats *stats, uint64_t *data)
242{
243 struct be_adapter *adapter = netdev_priv(netdev);
244 struct be_drvr_stats *drvr_stats = &adapter->stats.drvr_stats;
245 struct be_hw_stats *hw_stats = hw_stats_from_cmd(adapter->stats.cmd.va);
246 struct be_rxf_stats *rxf_stats = &hw_stats->rxf;
247 struct be_port_rxf_stats *port_stats =
248 &rxf_stats->port[adapter->port_num];
Ajit Khaparde78122a52009-10-07 03:11:20 -0700249 struct net_device_stats *net_stats = &netdev->stats;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700250 struct be_erx_stats *erx_stats = &hw_stats->erx;
251 void *p = NULL;
252 int i;
253
254 for (i = 0; i < ETHTOOL_STATS_NUM; i++) {
255 switch (et_stats[i].type) {
256 case NETSTAT:
257 p = net_stats;
258 break;
259 case DRVSTAT:
260 p = drvr_stats;
261 break;
262 case PORTSTAT:
263 p = port_stats;
264 break;
265 case MISCSTAT:
266 p = rxf_stats;
267 break;
268 case ERXSTAT: /* Currently only one ERX stat is provided */
269 p = (u32 *)erx_stats + adapter->rx_obj.q.id;
270 break;
271 }
272
273 p = (u8 *)p + et_stats[i].offset;
274 data[i] = (et_stats[i].size == sizeof(u64)) ?
275 *(u64 *)p: *(u32 *)p;
276 }
277
278 return;
279}
280
281static void
282be_get_stat_strings(struct net_device *netdev, uint32_t stringset,
283 uint8_t *data)
284{
285 int i;
286 switch (stringset) {
287 case ETH_SS_STATS:
288 for (i = 0; i < ETHTOOL_STATS_NUM; i++) {
289 memcpy(data, et_stats[i].desc, ETH_GSTRING_LEN);
290 data += ETH_GSTRING_LEN;
291 }
292 break;
Suresh Rff33a6e2009-12-03 16:15:52 -0800293 case ETH_SS_TEST:
294 for (i = 0; i < ETHTOOL_TESTS_NUM; i++) {
295 memcpy(data, et_self_tests[i], ETH_GSTRING_LEN);
296 data += ETH_GSTRING_LEN;
297 }
298 break;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700299 }
300}
301
Ben Hutchings15f0a392009-10-01 11:58:24 +0000302static int be_get_sset_count(struct net_device *netdev, int stringset)
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700303{
Ben Hutchings15f0a392009-10-01 11:58:24 +0000304 switch (stringset) {
Suresh Rff33a6e2009-12-03 16:15:52 -0800305 case ETH_SS_TEST:
306 return ETHTOOL_TESTS_NUM;
Ben Hutchings15f0a392009-10-01 11:58:24 +0000307 case ETH_SS_STATS:
308 return ETHTOOL_STATS_NUM;
309 default:
310 return -EINVAL;
311 }
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700312}
313
314static int be_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
315{
Sarveshwar Bandi0388f252009-10-28 04:15:20 -0700316 struct be_adapter *adapter = netdev_priv(netdev);
317 u8 mac_speed = 0, connector = 0;
318 u16 link_speed = 0;
319 bool link_up = false;
Ajit Khaparde0dffc832009-11-29 17:57:46 +0000320 int status;
Sarveshwar Bandi0388f252009-10-28 04:15:20 -0700321
Ajit Khaparde0dffc832009-11-29 17:57:46 +0000322 if (adapter->link_speed < 0) {
323 status = be_cmd_link_status_query(adapter, &link_up,
324 &mac_speed, &link_speed);
Sarveshwar Bandi0388f252009-10-28 04:15:20 -0700325
Ajit Khaparde0dffc832009-11-29 17:57:46 +0000326 /* link_speed is in units of 10 Mbps */
327 if (link_speed) {
328 ecmd->speed = link_speed*10;
329 } else {
330 switch (mac_speed) {
331 case PHY_LINK_SPEED_1GBPS:
332 ecmd->speed = SPEED_1000;
333 break;
334 case PHY_LINK_SPEED_10GBPS:
335 ecmd->speed = SPEED_10000;
336 break;
337 }
338 }
339
340 status = be_cmd_read_port_type(adapter, adapter->port_num,
341 &connector);
342 switch (connector) {
343 case 7:
344 ecmd->port = PORT_FIBRE;
Sarveshwar Bandi0388f252009-10-28 04:15:20 -0700345 break;
Ajit Khaparde0dffc832009-11-29 17:57:46 +0000346 default:
347 ecmd->port = PORT_TP;
Sarveshwar Bandi0388f252009-10-28 04:15:20 -0700348 break;
349 }
Ajit Khaparde0dffc832009-11-29 17:57:46 +0000350
351 /* Save for future use */
352 adapter->link_speed = ecmd->speed;
353 adapter->port_type = ecmd->port;
354 } else {
355 ecmd->speed = adapter->link_speed;
356 ecmd->port = adapter->port_type;
Sarveshwar Bandi0388f252009-10-28 04:15:20 -0700357 }
Ajit Khaparde0dffc832009-11-29 17:57:46 +0000358
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700359 ecmd->duplex = DUPLEX_FULL;
360 ecmd->autoneg = AUTONEG_DISABLE;
Sarveshwar Bandi0388f252009-10-28 04:15:20 -0700361 ecmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_TP);
Sarveshwar Bandi0388f252009-10-28 04:15:20 -0700362 ecmd->phy_address = adapter->port_num;
363 ecmd->transceiver = XCVR_INTERNAL;
364
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700365 return 0;
366}
367
368static void
369be_get_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring)
370{
371 struct be_adapter *adapter = netdev_priv(netdev);
372
373 ring->rx_max_pending = adapter->rx_obj.q.len;
374 ring->tx_max_pending = adapter->tx_obj.q.len;
375
376 ring->rx_pending = atomic_read(&adapter->rx_obj.q.used);
377 ring->tx_pending = atomic_read(&adapter->tx_obj.q.used);
378}
379
380static void
381be_get_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *ecmd)
382{
383 struct be_adapter *adapter = netdev_priv(netdev);
384
Sathya Perla8788fdc2009-07-27 22:52:03 +0000385 be_cmd_get_flow_control(adapter, &ecmd->tx_pause, &ecmd->rx_pause);
Ajit Khaparde03a980d2009-04-13 15:41:50 -0700386 ecmd->autoneg = 0;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700387}
388
389static int
390be_set_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *ecmd)
391{
392 struct be_adapter *adapter = netdev_priv(netdev);
393 int status;
394
Ajit Khaparde03a980d2009-04-13 15:41:50 -0700395 if (ecmd->autoneg != 0)
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700396 return -EINVAL;
Ajit Khaparde9e90c962009-11-06 02:06:59 +0000397 adapter->tx_fc = ecmd->tx_pause;
398 adapter->rx_fc = ecmd->rx_pause;
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700399
Ajit Khaparde9e90c962009-11-06 02:06:59 +0000400 status = be_cmd_set_flow_control(adapter,
401 adapter->tx_fc, adapter->rx_fc);
402 if (status)
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700403 dev_warn(&adapter->pdev->dev, "Pause param set failed.\n");
404
405 return status;
406}
407
Ajit Khaparde84517482009-09-04 03:12:16 +0000408static int
Sarveshwar Bandifad9ab22009-10-12 04:23:15 -0700409be_phys_id(struct net_device *netdev, u32 data)
410{
411 struct be_adapter *adapter = netdev_priv(netdev);
412 int status;
413 u32 cur;
414
Sarveshwar Bandifad9ab22009-10-12 04:23:15 -0700415 be_cmd_get_beacon_state(adapter, adapter->port_num, &cur);
416
417 if (cur == BEACON_STATE_ENABLED)
418 return 0;
419
420 if (data < 2)
421 data = 2;
422
423 status = be_cmd_set_beacon_state(adapter, adapter->port_num, 0, 0,
424 BEACON_STATE_ENABLED);
425 set_current_state(TASK_INTERRUPTIBLE);
426 schedule_timeout(data*HZ);
427
428 status = be_cmd_set_beacon_state(adapter, adapter->port_num, 0, 0,
429 BEACON_STATE_DISABLED);
430
431 return status;
432}
433
Ajit Khaparde71d8d1b2009-12-03 06:16:59 +0000434static void
435be_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
436{
437 struct be_adapter *adapter = netdev_priv(netdev);
438
439 wol->supported = WAKE_MAGIC;
440 if (adapter->wol)
441 wol->wolopts = WAKE_MAGIC;
442 else
443 wol->wolopts = 0;
444 memset(&wol->sopass, 0, sizeof(wol->sopass));
445 return;
446}
447
448static int
449be_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
450{
451 struct be_adapter *adapter = netdev_priv(netdev);
452
453 if (wol->wolopts & ~WAKE_MAGIC)
454 return -EINVAL;
455
456 if (wol->wolopts & WAKE_MAGIC)
457 adapter->wol = true;
458 else
459 adapter->wol = false;
460
461 return 0;
462}
463
Sarveshwar Bandifad9ab22009-10-12 04:23:15 -0700464static int
Suresh Rff33a6e2009-12-03 16:15:52 -0800465be_test_ddr_dma(struct be_adapter *adapter)
466{
467 int ret, i;
468 struct be_dma_mem ddrdma_cmd;
469 u64 pattern[2] = {0x5a5a5a5a5a5a5a5a, 0xa5a5a5a5a5a5a5a5};
470
471 ddrdma_cmd.size = sizeof(struct be_cmd_req_ddrdma_test);
472 ddrdma_cmd.va = pci_alloc_consistent(adapter->pdev, ddrdma_cmd.size,
473 &ddrdma_cmd.dma);
474 if (!ddrdma_cmd.va) {
475 dev_err(&adapter->pdev->dev, "Memory allocation failure \n");
476 return -ENOMEM;
477 }
478
479 for (i = 0; i < 2; i++) {
480 ret = be_cmd_ddr_dma_test(adapter, pattern[i],
481 4096, &ddrdma_cmd);
482 if (ret != 0)
483 goto err;
484 }
485
486err:
487 pci_free_consistent(adapter->pdev, ddrdma_cmd.size,
488 ddrdma_cmd.va, ddrdma_cmd.dma);
489 return ret;
490}
491
492static void
493be_self_test(struct net_device *netdev, struct ethtool_test *test, u64 *data)
494{
495 struct be_adapter *adapter = netdev_priv(netdev);
496
497 memset(data, 0, sizeof(u64) * ETHTOOL_TESTS_NUM);
498
499 if (test->flags & ETH_TEST_FL_OFFLINE) {
500 data[0] = be_cmd_loopback_test(adapter, adapter->port_num,
501 BE_MAC_LOOPBACK, 1500,
502 2, 0xabc);
503 if (data[0] != 0)
504 test->flags |= ETH_TEST_FL_FAILED;
505
506 data[1] = be_cmd_loopback_test(adapter, adapter->port_num,
507 BE_PHY_LOOPBACK, 1500,
508 2, 0xabc);
509 if (data[1] != 0)
510 test->flags |= ETH_TEST_FL_FAILED;
511
512 data[2] = be_cmd_loopback_test(adapter, adapter->port_num,
513 BE_ONE_PORT_EXT_LOOPBACK,
514 1500, 2, 0xabc);
515 if (data[2] != 0)
516 test->flags |= ETH_TEST_FL_FAILED;
517
518 data[3] = be_test_ddr_dma(adapter);
519 if (data[3] != 0)
520 test->flags |= ETH_TEST_FL_FAILED;
521 }
522
523}
524
525static int
Ajit Khaparde84517482009-09-04 03:12:16 +0000526be_do_flash(struct net_device *netdev, struct ethtool_flash *efl)
527{
528 struct be_adapter *adapter = netdev_priv(netdev);
529 char file_name[ETHTOOL_FLASH_MAX_FILENAME];
530 u32 region;
531
532 file_name[ETHTOOL_FLASH_MAX_FILENAME - 1] = 0;
533 strcpy(file_name, efl->data);
534 region = efl->region;
535
536 return be_load_fw(adapter, file_name);
537}
538
Stephen Hemminger0fc0b732009-09-02 01:03:33 -0700539const struct ethtool_ops be_ethtool_ops = {
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700540 .get_settings = be_get_settings,
541 .get_drvinfo = be_get_drvinfo,
Ajit Khaparde71d8d1b2009-12-03 06:16:59 +0000542 .get_wol = be_get_wol,
543 .set_wol = be_set_wol,
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700544 .get_link = ethtool_op_get_link,
545 .get_coalesce = be_get_coalesce,
546 .set_coalesce = be_set_coalesce,
547 .get_ringparam = be_get_ringparam,
548 .get_pauseparam = be_get_pauseparam,
549 .set_pauseparam = be_set_pauseparam,
550 .get_rx_csum = be_get_rx_csum,
551 .set_rx_csum = be_set_rx_csum,
552 .get_tx_csum = ethtool_op_get_tx_csum,
Ajit Khaparde583e3f32009-10-05 02:22:19 +0000553 .set_tx_csum = ethtool_op_set_tx_hw_csum,
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700554 .get_sg = ethtool_op_get_sg,
555 .set_sg = ethtool_op_set_sg,
556 .get_tso = ethtool_op_get_tso,
557 .set_tso = ethtool_op_set_tso,
558 .get_strings = be_get_stat_strings,
Sarveshwar Bandifad9ab22009-10-12 04:23:15 -0700559 .phys_id = be_phys_id,
Ben Hutchings15f0a392009-10-01 11:58:24 +0000560 .get_sset_count = be_get_sset_count,
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700561 .get_ethtool_stats = be_get_ethtool_stats,
Ajit Khaparde84517482009-09-04 03:12:16 +0000562 .flash_device = be_do_flash,
Suresh Rff33a6e2009-12-03 16:15:52 -0800563 .self_test = be_self_test,
Sathya Perla6b7c5b92009-03-11 23:32:03 -0700564};