2 * Copyright (C) 2005 - 2011 Emulex
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.
10 * Contact Information:
11 * linux-drivers@emulex.com
15 * Costa Mesa, CA 92626
20 #include <linux/ethtool.h>
22 struct be_ethtool_stat
{
23 char desc
[ETH_GSTRING_LEN
];
29 enum {DRVSTAT_TX
, DRVSTAT_RX
, DRVSTAT
};
30 #define FIELDINFO(_struct, field) FIELD_SIZEOF(_struct, field), \
31 offsetof(_struct, field)
32 #define DRVSTAT_TX_INFO(field) #field, DRVSTAT_TX,\
33 FIELDINFO(struct be_tx_stats, field)
34 #define DRVSTAT_RX_INFO(field) #field, DRVSTAT_RX,\
35 FIELDINFO(struct be_rx_stats, field)
36 #define DRVSTAT_INFO(field) #field, DRVSTAT,\
37 FIELDINFO(struct be_drv_stats, field)
39 static const struct be_ethtool_stat et_stats
[] = {
40 {DRVSTAT_INFO(tx_events
)},
41 {DRVSTAT_INFO(rx_crc_errors
)},
42 {DRVSTAT_INFO(rx_alignment_symbol_errors
)},
43 {DRVSTAT_INFO(rx_pause_frames
)},
44 {DRVSTAT_INFO(rx_control_frames
)},
45 {DRVSTAT_INFO(rx_in_range_errors
)},
46 {DRVSTAT_INFO(rx_out_range_errors
)},
47 {DRVSTAT_INFO(rx_frame_too_long
)},
48 {DRVSTAT_INFO(rx_address_match_errors
)},
49 {DRVSTAT_INFO(rx_dropped_too_small
)},
50 {DRVSTAT_INFO(rx_dropped_too_short
)},
51 {DRVSTAT_INFO(rx_dropped_header_too_small
)},
52 {DRVSTAT_INFO(rx_dropped_tcp_length
)},
53 {DRVSTAT_INFO(rx_dropped_runt
)},
54 {DRVSTAT_INFO(rxpp_fifo_overflow_drop
)},
55 {DRVSTAT_INFO(rx_input_fifo_overflow_drop
)},
56 {DRVSTAT_INFO(rx_ip_checksum_errs
)},
57 {DRVSTAT_INFO(rx_tcp_checksum_errs
)},
58 {DRVSTAT_INFO(rx_udp_checksum_errs
)},
59 {DRVSTAT_INFO(tx_pauseframes
)},
60 {DRVSTAT_INFO(tx_controlframes
)},
61 {DRVSTAT_INFO(rx_priority_pause_frames
)},
62 {DRVSTAT_INFO(pmem_fifo_overflow_drop
)},
63 {DRVSTAT_INFO(jabber_events
)},
64 {DRVSTAT_INFO(rx_drops_no_pbuf
)},
65 {DRVSTAT_INFO(rx_drops_no_txpb
)},
66 {DRVSTAT_INFO(rx_drops_no_erx_descr
)},
67 {DRVSTAT_INFO(rx_drops_no_tpre_descr
)},
68 {DRVSTAT_INFO(rx_drops_too_many_frags
)},
69 {DRVSTAT_INFO(rx_drops_invalid_ring
)},
70 {DRVSTAT_INFO(forwarded_packets
)},
71 {DRVSTAT_INFO(rx_drops_mtu
)},
72 {DRVSTAT_INFO(eth_red_drops
)},
73 {DRVSTAT_INFO(be_on_die_temperature
)}
75 #define ETHTOOL_STATS_NUM ARRAY_SIZE(et_stats)
77 /* Stats related to multi RX queues: get_stats routine assumes bytes, pkts
78 * are first and second members respectively.
80 static const struct be_ethtool_stat et_rx_stats
[] = {
81 {DRVSTAT_RX_INFO(rx_bytes
)},/* If moving this member see above note */
82 {DRVSTAT_RX_INFO(rx_pkts
)}, /* If moving this member see above note */
83 {DRVSTAT_RX_INFO(rx_polls
)},
84 {DRVSTAT_RX_INFO(rx_events
)},
85 {DRVSTAT_RX_INFO(rx_compl
)},
86 {DRVSTAT_RX_INFO(rx_mcast_pkts
)},
87 {DRVSTAT_RX_INFO(rx_post_fail
)},
88 {DRVSTAT_RX_INFO(rx_drops_no_skbs
)},
89 {DRVSTAT_RX_INFO(rx_drops_no_frags
)}
91 #define ETHTOOL_RXSTATS_NUM (ARRAY_SIZE(et_rx_stats))
93 /* Stats related to multi TX queues: get_stats routine assumes compl is the
96 static const struct be_ethtool_stat et_tx_stats
[] = {
97 {DRVSTAT_TX_INFO(tx_compl
)}, /* If moving this member see above note */
98 {DRVSTAT_TX_INFO(tx_bytes
)},
99 {DRVSTAT_TX_INFO(tx_pkts
)},
100 {DRVSTAT_TX_INFO(tx_reqs
)},
101 {DRVSTAT_TX_INFO(tx_wrbs
)},
102 {DRVSTAT_TX_INFO(tx_compl
)},
103 {DRVSTAT_TX_INFO(tx_stops
)}
105 #define ETHTOOL_TXSTATS_NUM (ARRAY_SIZE(et_tx_stats))
107 static const char et_self_tests
[][ETH_GSTRING_LEN
] = {
110 "External Loopback test",
115 #define ETHTOOL_TESTS_NUM ARRAY_SIZE(et_self_tests)
116 #define BE_MAC_LOOPBACK 0x0
117 #define BE_PHY_LOOPBACK 0x1
118 #define BE_ONE_PORT_EXT_LOOPBACK 0x2
119 #define BE_NO_LOOPBACK 0xff
121 static void be_get_drvinfo(struct net_device
*netdev
,
122 struct ethtool_drvinfo
*drvinfo
)
124 struct be_adapter
*adapter
= netdev_priv(netdev
);
125 char fw_on_flash
[FW_VER_LEN
];
127 memset(fw_on_flash
, 0 , sizeof(fw_on_flash
));
128 be_cmd_get_fw_ver(adapter
, adapter
->fw_ver
, fw_on_flash
);
130 strlcpy(drvinfo
->driver
, DRV_NAME
, sizeof(drvinfo
->driver
));
131 strlcpy(drvinfo
->version
, DRV_VER
, sizeof(drvinfo
->version
));
132 strncpy(drvinfo
->fw_version
, adapter
->fw_ver
, FW_VER_LEN
);
133 if (memcmp(adapter
->fw_ver
, fw_on_flash
, FW_VER_LEN
) != 0) {
134 strcat(drvinfo
->fw_version
, " [");
135 strcat(drvinfo
->fw_version
, fw_on_flash
);
136 strcat(drvinfo
->fw_version
, "]");
139 strlcpy(drvinfo
->bus_info
, pci_name(adapter
->pdev
),
140 sizeof(drvinfo
->bus_info
));
141 drvinfo
->testinfo_len
= 0;
142 drvinfo
->regdump_len
= 0;
143 drvinfo
->eedump_len
= 0;
147 lancer_cmd_get_file_len(struct be_adapter
*adapter
, u8
*file_name
)
149 u32 data_read
= 0, eof
;
151 struct be_dma_mem data_len_cmd
;
154 memset(&data_len_cmd
, 0, sizeof(data_len_cmd
));
155 /* data_offset and data_size should be 0 to get reg len */
156 status
= lancer_cmd_read_object(adapter
, &data_len_cmd
, 0, 0,
157 file_name
, &data_read
, &eof
, &addn_status
);
163 lancer_cmd_read_file(struct be_adapter
*adapter
, u8
*file_name
,
164 u32 buf_len
, void *buf
)
166 struct be_dma_mem read_cmd
;
167 u32 read_len
= 0, total_read_len
= 0, chunk_size
;
172 read_cmd
.size
= LANCER_READ_FILE_CHUNK
;
173 read_cmd
.va
= pci_alloc_consistent(adapter
->pdev
, read_cmd
.size
,
177 dev_err(&adapter
->pdev
->dev
,
178 "Memory allocation failure while reading dump\n");
182 while ((total_read_len
< buf_len
) && !eof
) {
183 chunk_size
= min_t(u32
, (buf_len
- total_read_len
),
184 LANCER_READ_FILE_CHUNK
);
185 chunk_size
= ALIGN(chunk_size
, 4);
186 status
= lancer_cmd_read_object(adapter
, &read_cmd
, chunk_size
,
187 total_read_len
, file_name
, &read_len
,
190 memcpy(buf
+ total_read_len
, read_cmd
.va
, read_len
);
191 total_read_len
+= read_len
;
192 eof
&= LANCER_READ_FILE_EOF_MASK
;
198 pci_free_consistent(adapter
->pdev
, read_cmd
.size
, read_cmd
.va
,
205 be_get_reg_len(struct net_device
*netdev
)
207 struct be_adapter
*adapter
= netdev_priv(netdev
);
210 if (be_physfn(adapter
)) {
211 if (lancer_chip(adapter
))
212 log_size
= lancer_cmd_get_file_len(adapter
,
213 LANCER_FW_DUMP_FILE
);
215 be_cmd_get_reg_len(adapter
, &log_size
);
221 be_get_regs(struct net_device
*netdev
, struct ethtool_regs
*regs
, void *buf
)
223 struct be_adapter
*adapter
= netdev_priv(netdev
);
225 if (be_physfn(adapter
)) {
226 memset(buf
, 0, regs
->len
);
227 if (lancer_chip(adapter
))
228 lancer_cmd_read_file(adapter
, LANCER_FW_DUMP_FILE
,
231 be_cmd_get_regs(adapter
, regs
->len
, buf
);
236 be_get_coalesce(struct net_device
*netdev
, struct ethtool_coalesce
*coalesce
)
238 struct be_adapter
*adapter
= netdev_priv(netdev
);
239 struct be_eq_obj
*rx_eq
= &adapter
->rx_obj
[0].rx_eq
;
240 struct be_eq_obj
*tx_eq
= &adapter
->tx_eq
;
242 coalesce
->rx_coalesce_usecs
= rx_eq
->cur_eqd
;
243 coalesce
->rx_coalesce_usecs_high
= rx_eq
->max_eqd
;
244 coalesce
->rx_coalesce_usecs_low
= rx_eq
->min_eqd
;
246 coalesce
->tx_coalesce_usecs
= tx_eq
->cur_eqd
;
247 coalesce
->tx_coalesce_usecs_high
= tx_eq
->max_eqd
;
248 coalesce
->tx_coalesce_usecs_low
= tx_eq
->min_eqd
;
250 coalesce
->use_adaptive_rx_coalesce
= rx_eq
->enable_aic
;
251 coalesce
->use_adaptive_tx_coalesce
= tx_eq
->enable_aic
;
257 * This routine is used to set interrup coalescing delay
260 be_set_coalesce(struct net_device
*netdev
, struct ethtool_coalesce
*coalesce
)
262 struct be_adapter
*adapter
= netdev_priv(netdev
);
263 struct be_rx_obj
*rxo
;
264 struct be_eq_obj
*rx_eq
;
265 struct be_eq_obj
*tx_eq
= &adapter
->tx_eq
;
266 u32 rx_max
, rx_min
, rx_cur
;
270 if (coalesce
->use_adaptive_tx_coalesce
== 1)
273 for_all_rx_queues(adapter
, rxo
, i
) {
276 if (!rx_eq
->enable_aic
&& coalesce
->use_adaptive_rx_coalesce
)
278 rx_eq
->enable_aic
= coalesce
->use_adaptive_rx_coalesce
;
280 rx_max
= coalesce
->rx_coalesce_usecs_high
;
281 rx_min
= coalesce
->rx_coalesce_usecs_low
;
282 rx_cur
= coalesce
->rx_coalesce_usecs
;
284 if (rx_eq
->enable_aic
) {
285 if (rx_max
> BE_MAX_EQD
)
289 rx_eq
->max_eqd
= rx_max
;
290 rx_eq
->min_eqd
= rx_min
;
291 if (rx_eq
->cur_eqd
> rx_max
)
292 rx_eq
->cur_eqd
= rx_max
;
293 if (rx_eq
->cur_eqd
< rx_min
)
294 rx_eq
->cur_eqd
= rx_min
;
296 if (rx_cur
> BE_MAX_EQD
)
298 if (rx_eq
->cur_eqd
!= rx_cur
) {
299 status
= be_cmd_modify_eqd(adapter
, rx_eq
->q
.id
,
302 rx_eq
->cur_eqd
= rx_cur
;
307 tx_cur
= coalesce
->tx_coalesce_usecs
;
309 if (tx_cur
> BE_MAX_EQD
)
311 if (tx_eq
->cur_eqd
!= tx_cur
) {
312 status
= be_cmd_modify_eqd(adapter
, tx_eq
->q
.id
, tx_cur
);
314 tx_eq
->cur_eqd
= tx_cur
;
321 be_get_ethtool_stats(struct net_device
*netdev
,
322 struct ethtool_stats
*stats
, uint64_t *data
)
324 struct be_adapter
*adapter
= netdev_priv(netdev
);
325 struct be_rx_obj
*rxo
;
326 struct be_tx_obj
*txo
;
328 unsigned int i
, j
, base
= 0, start
;
330 for (i
= 0; i
< ETHTOOL_STATS_NUM
; i
++) {
331 p
= (u8
*)&adapter
->drv_stats
+ et_stats
[i
].offset
;
334 base
+= ETHTOOL_STATS_NUM
;
336 for_all_rx_queues(adapter
, rxo
, j
) {
337 struct be_rx_stats
*stats
= rx_stats(rxo
);
340 start
= u64_stats_fetch_begin_bh(&stats
->sync
);
341 data
[base
] = stats
->rx_bytes
;
342 data
[base
+ 1] = stats
->rx_pkts
;
343 } while (u64_stats_fetch_retry_bh(&stats
->sync
, start
));
345 for (i
= 2; i
< ETHTOOL_RXSTATS_NUM
; i
++) {
346 p
= (u8
*)stats
+ et_rx_stats
[i
].offset
;
347 data
[base
+ i
] = *(u32
*)p
;
349 base
+= ETHTOOL_RXSTATS_NUM
;
352 for_all_tx_queues(adapter
, txo
, j
) {
353 struct be_tx_stats
*stats
= tx_stats(txo
);
356 start
= u64_stats_fetch_begin_bh(&stats
->sync_compl
);
357 data
[base
] = stats
->tx_compl
;
358 } while (u64_stats_fetch_retry_bh(&stats
->sync_compl
, start
));
361 start
= u64_stats_fetch_begin_bh(&stats
->sync
);
362 for (i
= 1; i
< ETHTOOL_TXSTATS_NUM
; i
++) {
363 p
= (u8
*)stats
+ et_tx_stats
[i
].offset
;
365 (et_tx_stats
[i
].size
== sizeof(u64
)) ?
366 *(u64
*)p
: *(u32
*)p
;
368 } while (u64_stats_fetch_retry_bh(&stats
->sync
, start
));
369 base
+= ETHTOOL_TXSTATS_NUM
;
374 be_get_stat_strings(struct net_device
*netdev
, uint32_t stringset
,
377 struct be_adapter
*adapter
= netdev_priv(netdev
);
382 for (i
= 0; i
< ETHTOOL_STATS_NUM
; i
++) {
383 memcpy(data
, et_stats
[i
].desc
, ETH_GSTRING_LEN
);
384 data
+= ETH_GSTRING_LEN
;
386 for (i
= 0; i
< adapter
->num_rx_qs
; i
++) {
387 for (j
= 0; j
< ETHTOOL_RXSTATS_NUM
; j
++) {
388 sprintf(data
, "rxq%d: %s", i
,
389 et_rx_stats
[j
].desc
);
390 data
+= ETH_GSTRING_LEN
;
393 for (i
= 0; i
< adapter
->num_tx_qs
; i
++) {
394 for (j
= 0; j
< ETHTOOL_TXSTATS_NUM
; j
++) {
395 sprintf(data
, "txq%d: %s", i
,
396 et_tx_stats
[j
].desc
);
397 data
+= ETH_GSTRING_LEN
;
402 for (i
= 0; i
< ETHTOOL_TESTS_NUM
; i
++) {
403 memcpy(data
, et_self_tests
[i
], ETH_GSTRING_LEN
);
404 data
+= ETH_GSTRING_LEN
;
410 static int be_get_sset_count(struct net_device
*netdev
, int stringset
)
412 struct be_adapter
*adapter
= netdev_priv(netdev
);
416 return ETHTOOL_TESTS_NUM
;
418 return ETHTOOL_STATS_NUM
+
419 adapter
->num_rx_qs
* ETHTOOL_RXSTATS_NUM
+
420 adapter
->num_tx_qs
* ETHTOOL_TXSTATS_NUM
;
426 static int be_get_settings(struct net_device
*netdev
, struct ethtool_cmd
*ecmd
)
428 struct be_adapter
*adapter
= netdev_priv(netdev
);
429 struct be_phy_info phy_info
;
435 if ((adapter
->link_speed
< 0) || (!(netdev
->flags
& IFF_UP
))) {
436 status
= be_cmd_link_status_query(adapter
, &mac_speed
,
437 &link_speed
, &link_status
, 0);
439 be_link_status_update(adapter
, link_status
);
441 /* link_speed is in units of 10 Mbps */
443 ethtool_cmd_speed_set(ecmd
, link_speed
*10);
446 case PHY_LINK_SPEED_10MBPS
:
447 ethtool_cmd_speed_set(ecmd
, SPEED_10
);
449 case PHY_LINK_SPEED_100MBPS
:
450 ethtool_cmd_speed_set(ecmd
, SPEED_100
);
452 case PHY_LINK_SPEED_1GBPS
:
453 ethtool_cmd_speed_set(ecmd
, SPEED_1000
);
455 case PHY_LINK_SPEED_10GBPS
:
456 ethtool_cmd_speed_set(ecmd
, SPEED_10000
);
458 case PHY_LINK_SPEED_ZERO
:
459 ethtool_cmd_speed_set(ecmd
, 0);
464 status
= be_cmd_get_phy_info(adapter
, &phy_info
);
466 switch (phy_info
.interface_type
) {
467 case PHY_TYPE_XFP_10GB
:
468 case PHY_TYPE_SFP_1GB
:
469 case PHY_TYPE_SFP_PLUS_10GB
:
470 ecmd
->port
= PORT_FIBRE
;
473 ecmd
->port
= PORT_TP
;
477 switch (phy_info
.interface_type
) {
478 case PHY_TYPE_KR_10GB
:
479 case PHY_TYPE_KX4_10GB
:
480 ecmd
->autoneg
= AUTONEG_ENABLE
;
481 ecmd
->transceiver
= XCVR_INTERNAL
;
484 ecmd
->autoneg
= AUTONEG_DISABLE
;
485 ecmd
->transceiver
= XCVR_EXTERNAL
;
490 /* Save for future use */
491 adapter
->link_speed
= ethtool_cmd_speed(ecmd
);
492 adapter
->port_type
= ecmd
->port
;
493 adapter
->transceiver
= ecmd
->transceiver
;
494 adapter
->autoneg
= ecmd
->autoneg
;
496 ethtool_cmd_speed_set(ecmd
, adapter
->link_speed
);
497 ecmd
->port
= adapter
->port_type
;
498 ecmd
->transceiver
= adapter
->transceiver
;
499 ecmd
->autoneg
= adapter
->autoneg
;
502 ecmd
->duplex
= DUPLEX_FULL
;
503 ecmd
->phy_address
= adapter
->port_num
;
504 switch (ecmd
->port
) {
506 ecmd
->supported
= (SUPPORTED_10000baseT_Full
| SUPPORTED_FIBRE
);
509 ecmd
->supported
= (SUPPORTED_10000baseT_Full
| SUPPORTED_TP
);
512 ecmd
->supported
= (SUPPORTED_10000baseT_Full
| SUPPORTED_AUI
);
517 ecmd
->supported
|= SUPPORTED_1000baseT_Full
;
518 ecmd
->supported
|= SUPPORTED_Autoneg
;
519 ecmd
->advertising
|= (ADVERTISED_10000baseT_Full
|
520 ADVERTISED_1000baseT_Full
);
526 static void be_get_ringparam(struct net_device
*netdev
,
527 struct ethtool_ringparam
*ring
)
529 struct be_adapter
*adapter
= netdev_priv(netdev
);
531 ring
->rx_max_pending
= ring
->rx_pending
= adapter
->rx_obj
[0].q
.len
;
532 ring
->tx_max_pending
= ring
->tx_pending
= adapter
->tx_obj
[0].q
.len
;
536 be_get_pauseparam(struct net_device
*netdev
, struct ethtool_pauseparam
*ecmd
)
538 struct be_adapter
*adapter
= netdev_priv(netdev
);
540 be_cmd_get_flow_control(adapter
, &ecmd
->tx_pause
, &ecmd
->rx_pause
);
545 be_set_pauseparam(struct net_device
*netdev
, struct ethtool_pauseparam
*ecmd
)
547 struct be_adapter
*adapter
= netdev_priv(netdev
);
550 if (ecmd
->autoneg
!= 0)
552 adapter
->tx_fc
= ecmd
->tx_pause
;
553 adapter
->rx_fc
= ecmd
->rx_pause
;
555 status
= be_cmd_set_flow_control(adapter
,
556 adapter
->tx_fc
, adapter
->rx_fc
);
558 dev_warn(&adapter
->pdev
->dev
, "Pause param set failed.\n");
564 be_set_phys_id(struct net_device
*netdev
,
565 enum ethtool_phys_id_state state
)
567 struct be_adapter
*adapter
= netdev_priv(netdev
);
570 case ETHTOOL_ID_ACTIVE
:
571 be_cmd_get_beacon_state(adapter
, adapter
->hba_port_num
,
572 &adapter
->beacon_state
);
573 return 1; /* cycle on/off once per second */
576 be_cmd_set_beacon_state(adapter
, adapter
->hba_port_num
, 0, 0,
577 BEACON_STATE_ENABLED
);
581 be_cmd_set_beacon_state(adapter
, adapter
->hba_port_num
, 0, 0,
582 BEACON_STATE_DISABLED
);
585 case ETHTOOL_ID_INACTIVE
:
586 be_cmd_set_beacon_state(adapter
, adapter
->hba_port_num
, 0, 0,
587 adapter
->beacon_state
);
594 be_is_wol_supported(struct be_adapter
*adapter
)
596 if (!be_physfn(adapter
))
603 be_get_wol(struct net_device
*netdev
, struct ethtool_wolinfo
*wol
)
605 struct be_adapter
*adapter
= netdev_priv(netdev
);
607 if (be_is_wol_supported(adapter
))
608 wol
->supported
= WAKE_MAGIC
;
611 wol
->wolopts
= WAKE_MAGIC
;
614 memset(&wol
->sopass
, 0, sizeof(wol
->sopass
));
618 be_set_wol(struct net_device
*netdev
, struct ethtool_wolinfo
*wol
)
620 struct be_adapter
*adapter
= netdev_priv(netdev
);
622 if (wol
->wolopts
& ~WAKE_MAGIC
)
625 if ((wol
->wolopts
& WAKE_MAGIC
) && be_is_wol_supported(adapter
))
628 adapter
->wol
= false;
634 be_test_ddr_dma(struct be_adapter
*adapter
)
637 struct be_dma_mem ddrdma_cmd
;
638 static const u64 pattern
[2] = {
639 0x5a5a5a5a5a5a5a5aULL
, 0xa5a5a5a5a5a5a5a5ULL
642 ddrdma_cmd
.size
= sizeof(struct be_cmd_req_ddrdma_test
);
643 ddrdma_cmd
.va
= dma_alloc_coherent(&adapter
->pdev
->dev
, ddrdma_cmd
.size
,
644 &ddrdma_cmd
.dma
, GFP_KERNEL
);
645 if (!ddrdma_cmd
.va
) {
646 dev_err(&adapter
->pdev
->dev
, "Memory allocation failure\n");
650 for (i
= 0; i
< 2; i
++) {
651 ret
= be_cmd_ddr_dma_test(adapter
, pattern
[i
],
658 dma_free_coherent(&adapter
->pdev
->dev
, ddrdma_cmd
.size
, ddrdma_cmd
.va
,
663 static u64
be_loopback_test(struct be_adapter
*adapter
, u8 loopback_type
,
666 be_cmd_set_loopback(adapter
, adapter
->hba_port_num
,
668 *status
= be_cmd_loopback_test(adapter
, adapter
->hba_port_num
,
671 be_cmd_set_loopback(adapter
, adapter
->hba_port_num
,
677 be_self_test(struct net_device
*netdev
, struct ethtool_test
*test
, u64
*data
)
679 struct be_adapter
*adapter
= netdev_priv(netdev
);
681 u16 qos_link_speed
= 0;
683 memset(data
, 0, sizeof(u64
) * ETHTOOL_TESTS_NUM
);
685 if (test
->flags
& ETH_TEST_FL_OFFLINE
) {
686 if (be_loopback_test(adapter
, BE_MAC_LOOPBACK
,
688 test
->flags
|= ETH_TEST_FL_FAILED
;
690 if (be_loopback_test(adapter
, BE_PHY_LOOPBACK
,
692 test
->flags
|= ETH_TEST_FL_FAILED
;
694 if (be_loopback_test(adapter
, BE_ONE_PORT_EXT_LOOPBACK
,
696 test
->flags
|= ETH_TEST_FL_FAILED
;
700 if (be_test_ddr_dma(adapter
) != 0) {
702 test
->flags
|= ETH_TEST_FL_FAILED
;
705 if (be_cmd_link_status_query(adapter
, &mac_speed
,
706 &qos_link_speed
, NULL
, 0) != 0) {
707 test
->flags
|= ETH_TEST_FL_FAILED
;
709 } else if (!mac_speed
) {
710 test
->flags
|= ETH_TEST_FL_FAILED
;
716 be_do_flash(struct net_device
*netdev
, struct ethtool_flash
*efl
)
718 struct be_adapter
*adapter
= netdev_priv(netdev
);
720 return be_load_fw(adapter
, efl
->data
);
724 be_get_eeprom_len(struct net_device
*netdev
)
726 struct be_adapter
*adapter
= netdev_priv(netdev
);
727 if (lancer_chip(adapter
)) {
728 if (be_physfn(adapter
))
729 return lancer_cmd_get_file_len(adapter
,
732 return lancer_cmd_get_file_len(adapter
,
735 return BE_READ_SEEPROM_LEN
;
740 be_read_eeprom(struct net_device
*netdev
, struct ethtool_eeprom
*eeprom
,
743 struct be_adapter
*adapter
= netdev_priv(netdev
);
744 struct be_dma_mem eeprom_cmd
;
745 struct be_cmd_resp_seeprom_read
*resp
;
751 if (lancer_chip(adapter
)) {
752 if (be_physfn(adapter
))
753 return lancer_cmd_read_file(adapter
, LANCER_VPD_PF_FILE
,
756 return lancer_cmd_read_file(adapter
, LANCER_VPD_VF_FILE
,
760 eeprom
->magic
= BE_VENDOR_ID
| (adapter
->pdev
->device
<<16);
762 memset(&eeprom_cmd
, 0, sizeof(struct be_dma_mem
));
763 eeprom_cmd
.size
= sizeof(struct be_cmd_req_seeprom_read
);
764 eeprom_cmd
.va
= dma_alloc_coherent(&adapter
->pdev
->dev
, eeprom_cmd
.size
,
765 &eeprom_cmd
.dma
, GFP_KERNEL
);
767 if (!eeprom_cmd
.va
) {
768 dev_err(&adapter
->pdev
->dev
,
769 "Memory allocation failure. Could not read eeprom\n");
773 status
= be_cmd_get_seeprom_data(adapter
, &eeprom_cmd
);
776 resp
= eeprom_cmd
.va
;
777 memcpy(data
, resp
->seeprom_data
+ eeprom
->offset
, eeprom
->len
);
779 dma_free_coherent(&adapter
->pdev
->dev
, eeprom_cmd
.size
, eeprom_cmd
.va
,
785 const struct ethtool_ops be_ethtool_ops
= {
786 .get_settings
= be_get_settings
,
787 .get_drvinfo
= be_get_drvinfo
,
788 .get_wol
= be_get_wol
,
789 .set_wol
= be_set_wol
,
790 .get_link
= ethtool_op_get_link
,
791 .get_eeprom_len
= be_get_eeprom_len
,
792 .get_eeprom
= be_read_eeprom
,
793 .get_coalesce
= be_get_coalesce
,
794 .set_coalesce
= be_set_coalesce
,
795 .get_ringparam
= be_get_ringparam
,
796 .get_pauseparam
= be_get_pauseparam
,
797 .set_pauseparam
= be_set_pauseparam
,
798 .get_strings
= be_get_stat_strings
,
799 .set_phys_id
= be_set_phys_id
,
800 .get_sset_count
= be_get_sset_count
,
801 .get_ethtool_stats
= be_get_ethtool_stats
,
802 .get_regs_len
= be_get_reg_len
,
803 .get_regs
= be_get_regs
,
804 .flash_device
= be_do_flash
,
805 .self_test
= be_self_test
,