Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1 | /* |
Ajit Khaparde | 294aedc | 2010-02-19 13:54:58 +0000 | [diff] [blame] | 2 | * Copyright (C) 2005 - 2010 ServerEngines |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 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 Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 19 | #include "be_cmds.h" |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 20 | #include <linux/ethtool.h> |
| 21 | |
| 22 | struct be_ethtool_stat { |
| 23 | char desc[ETH_GSTRING_LEN]; |
| 24 | int type; |
| 25 | int size; |
| 26 | int offset; |
| 27 | }; |
| 28 | |
Ajit Khaparde | f6c4bf3 | 2011-02-20 11:41:04 +0000 | [diff] [blame] | 29 | enum {NETSTAT, PORTSTAT, MISCSTAT, DRVSTAT_TX, DRVSTAT_RX, ERXSTAT, |
| 30 | PMEMSTAT}; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 31 | #define FIELDINFO(_struct, field) FIELD_SIZEOF(_struct, field), \ |
| 32 | offsetof(_struct, field) |
| 33 | #define NETSTAT_INFO(field) #field, NETSTAT,\ |
| 34 | FIELDINFO(struct net_device_stats,\ |
| 35 | field) |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 36 | #define DRVSTAT_TX_INFO(field) #field, DRVSTAT_TX,\ |
| 37 | FIELDINFO(struct be_tx_stats, field) |
| 38 | #define DRVSTAT_RX_INFO(field) #field, DRVSTAT_RX,\ |
| 39 | FIELDINFO(struct be_rx_stats, field) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 40 | #define MISCSTAT_INFO(field) #field, MISCSTAT,\ |
| 41 | FIELDINFO(struct be_rxf_stats, field) |
| 42 | #define PORTSTAT_INFO(field) #field, PORTSTAT,\ |
| 43 | FIELDINFO(struct be_port_rxf_stats, \ |
| 44 | field) |
| 45 | #define ERXSTAT_INFO(field) #field, ERXSTAT,\ |
| 46 | FIELDINFO(struct be_erx_stats, field) |
Ajit Khaparde | f6c4bf3 | 2011-02-20 11:41:04 +0000 | [diff] [blame] | 47 | #define PMEMSTAT_INFO(field) #field, PMEMSTAT,\ |
| 48 | FIELDINFO(struct be_pmem_stats, field) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 49 | |
| 50 | static const struct be_ethtool_stat et_stats[] = { |
| 51 | {NETSTAT_INFO(rx_packets)}, |
| 52 | {NETSTAT_INFO(tx_packets)}, |
| 53 | {NETSTAT_INFO(rx_bytes)}, |
| 54 | {NETSTAT_INFO(tx_bytes)}, |
| 55 | {NETSTAT_INFO(rx_errors)}, |
| 56 | {NETSTAT_INFO(tx_errors)}, |
| 57 | {NETSTAT_INFO(rx_dropped)}, |
| 58 | {NETSTAT_INFO(tx_dropped)}, |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 59 | {DRVSTAT_TX_INFO(be_tx_rate)}, |
| 60 | {DRVSTAT_TX_INFO(be_tx_reqs)}, |
| 61 | {DRVSTAT_TX_INFO(be_tx_wrbs)}, |
| 62 | {DRVSTAT_TX_INFO(be_tx_stops)}, |
| 63 | {DRVSTAT_TX_INFO(be_tx_events)}, |
| 64 | {DRVSTAT_TX_INFO(be_tx_compl)}, |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 65 | {PORTSTAT_INFO(rx_unicast_frames)}, |
| 66 | {PORTSTAT_INFO(rx_multicast_frames)}, |
| 67 | {PORTSTAT_INFO(rx_broadcast_frames)}, |
| 68 | {PORTSTAT_INFO(rx_crc_errors)}, |
| 69 | {PORTSTAT_INFO(rx_alignment_symbol_errors)}, |
| 70 | {PORTSTAT_INFO(rx_pause_frames)}, |
| 71 | {PORTSTAT_INFO(rx_control_frames)}, |
| 72 | {PORTSTAT_INFO(rx_in_range_errors)}, |
| 73 | {PORTSTAT_INFO(rx_out_range_errors)}, |
| 74 | {PORTSTAT_INFO(rx_frame_too_long)}, |
| 75 | {PORTSTAT_INFO(rx_address_match_errors)}, |
| 76 | {PORTSTAT_INFO(rx_vlan_mismatch)}, |
| 77 | {PORTSTAT_INFO(rx_dropped_too_small)}, |
| 78 | {PORTSTAT_INFO(rx_dropped_too_short)}, |
| 79 | {PORTSTAT_INFO(rx_dropped_header_too_small)}, |
| 80 | {PORTSTAT_INFO(rx_dropped_tcp_length)}, |
| 81 | {PORTSTAT_INFO(rx_dropped_runt)}, |
| 82 | {PORTSTAT_INFO(rx_fifo_overflow)}, |
| 83 | {PORTSTAT_INFO(rx_input_fifo_overflow)}, |
| 84 | {PORTSTAT_INFO(rx_ip_checksum_errs)}, |
| 85 | {PORTSTAT_INFO(rx_tcp_checksum_errs)}, |
| 86 | {PORTSTAT_INFO(rx_udp_checksum_errs)}, |
| 87 | {PORTSTAT_INFO(rx_non_rss_packets)}, |
| 88 | {PORTSTAT_INFO(rx_ipv4_packets)}, |
| 89 | {PORTSTAT_INFO(rx_ipv6_packets)}, |
Ajit Khaparde | def824c | 2010-08-25 00:32:56 +0000 | [diff] [blame] | 90 | {PORTSTAT_INFO(rx_switched_unicast_packets)}, |
| 91 | {PORTSTAT_INFO(rx_switched_multicast_packets)}, |
| 92 | {PORTSTAT_INFO(rx_switched_broadcast_packets)}, |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 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)}, |
Ajit Khaparde | f6c4bf3 | 2011-02-20 11:41:04 +0000 | [diff] [blame] | 105 | {MISCSTAT_INFO(rx_drops_mtu)}, |
| 106 | {MISCSTAT_INFO(port0_jabber_events)}, |
| 107 | {MISCSTAT_INFO(port1_jabber_events)}, |
| 108 | {PMEMSTAT_INFO(eth_red_drops)} |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 109 | }; |
| 110 | #define ETHTOOL_STATS_NUM ARRAY_SIZE(et_stats) |
| 111 | |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 112 | /* Stats related to multi RX queues */ |
| 113 | static const struct be_ethtool_stat et_rx_stats[] = { |
| 114 | {DRVSTAT_RX_INFO(rx_bytes)}, |
| 115 | {DRVSTAT_RX_INFO(rx_pkts)}, |
| 116 | {DRVSTAT_RX_INFO(rx_rate)}, |
| 117 | {DRVSTAT_RX_INFO(rx_polls)}, |
| 118 | {DRVSTAT_RX_INFO(rx_events)}, |
| 119 | {DRVSTAT_RX_INFO(rx_compl)}, |
| 120 | {DRVSTAT_RX_INFO(rx_mcast_pkts)}, |
| 121 | {DRVSTAT_RX_INFO(rx_post_fail)}, |
| 122 | {ERXSTAT_INFO(rx_drops_no_fragments)} |
| 123 | }; |
| 124 | #define ETHTOOL_RXSTATS_NUM (ARRAY_SIZE(et_rx_stats)) |
| 125 | |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 126 | static const char et_self_tests[][ETH_GSTRING_LEN] = { |
| 127 | "MAC Loopback test", |
| 128 | "PHY Loopback test", |
| 129 | "External Loopback test", |
Ajit Khaparde | 4ee7721 | 2011-02-20 11:41:20 +0000 | [diff] [blame^] | 130 | "DDR DMA test", |
Sarveshwar Bandi | 4276e47 | 2010-01-19 05:15:36 +0000 | [diff] [blame] | 131 | "Link test" |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 132 | }; |
| 133 | |
| 134 | #define ETHTOOL_TESTS_NUM ARRAY_SIZE(et_self_tests) |
| 135 | #define BE_MAC_LOOPBACK 0x0 |
| 136 | #define BE_PHY_LOOPBACK 0x1 |
| 137 | #define BE_ONE_PORT_EXT_LOOPBACK 0x2 |
Sarveshwar Bandi | fced999 | 2009-12-23 04:41:44 +0000 | [diff] [blame] | 138 | #define BE_NO_LOOPBACK 0xff |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 139 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 140 | static void |
| 141 | be_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo) |
| 142 | { |
| 143 | struct be_adapter *adapter = netdev_priv(netdev); |
| 144 | |
| 145 | strcpy(drvinfo->driver, DRV_NAME); |
| 146 | strcpy(drvinfo->version, DRV_VER); |
| 147 | strncpy(drvinfo->fw_version, adapter->fw_ver, FW_VER_LEN); |
| 148 | strcpy(drvinfo->bus_info, pci_name(adapter->pdev)); |
| 149 | drvinfo->testinfo_len = 0; |
| 150 | drvinfo->regdump_len = 0; |
| 151 | drvinfo->eedump_len = 0; |
| 152 | } |
| 153 | |
| 154 | static int |
| 155 | be_get_coalesce(struct net_device *netdev, struct ethtool_coalesce *coalesce) |
| 156 | { |
| 157 | struct be_adapter *adapter = netdev_priv(netdev); |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 158 | struct be_eq_obj *rx_eq = &adapter->rx_obj[0].rx_eq; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 159 | struct be_eq_obj *tx_eq = &adapter->tx_eq; |
| 160 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 161 | coalesce->rx_coalesce_usecs = rx_eq->cur_eqd; |
| 162 | coalesce->rx_coalesce_usecs_high = rx_eq->max_eqd; |
| 163 | coalesce->rx_coalesce_usecs_low = rx_eq->min_eqd; |
| 164 | |
| 165 | coalesce->tx_coalesce_usecs = tx_eq->cur_eqd; |
| 166 | coalesce->tx_coalesce_usecs_high = tx_eq->max_eqd; |
| 167 | coalesce->tx_coalesce_usecs_low = tx_eq->min_eqd; |
| 168 | |
| 169 | coalesce->use_adaptive_rx_coalesce = rx_eq->enable_aic; |
| 170 | coalesce->use_adaptive_tx_coalesce = tx_eq->enable_aic; |
| 171 | |
| 172 | return 0; |
| 173 | } |
| 174 | |
| 175 | /* |
Ajit Khaparde | 5be93b9 | 2009-07-21 12:36:19 -0700 | [diff] [blame] | 176 | * This routine is used to set interrup coalescing delay |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 177 | */ |
| 178 | static int |
| 179 | be_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *coalesce) |
| 180 | { |
| 181 | struct be_adapter *adapter = netdev_priv(netdev); |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 182 | struct be_rx_obj *rxo; |
| 183 | struct be_eq_obj *rx_eq; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 184 | struct be_eq_obj *tx_eq = &adapter->tx_eq; |
| 185 | u32 tx_max, tx_min, tx_cur; |
| 186 | u32 rx_max, rx_min, rx_cur; |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 187 | int status = 0, i; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 188 | |
| 189 | if (coalesce->use_adaptive_tx_coalesce == 1) |
| 190 | return -EINVAL; |
| 191 | |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 192 | for_all_rx_queues(adapter, rxo, i) { |
| 193 | rx_eq = &rxo->rx_eq; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 194 | |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 195 | if (!rx_eq->enable_aic && coalesce->use_adaptive_rx_coalesce) |
| 196 | rx_eq->cur_eqd = 0; |
| 197 | rx_eq->enable_aic = coalesce->use_adaptive_rx_coalesce; |
| 198 | |
| 199 | rx_max = coalesce->rx_coalesce_usecs_high; |
| 200 | rx_min = coalesce->rx_coalesce_usecs_low; |
| 201 | rx_cur = coalesce->rx_coalesce_usecs; |
| 202 | |
| 203 | if (rx_eq->enable_aic) { |
| 204 | if (rx_max > BE_MAX_EQD) |
| 205 | rx_max = BE_MAX_EQD; |
| 206 | if (rx_min > rx_max) |
| 207 | rx_min = rx_max; |
| 208 | rx_eq->max_eqd = rx_max; |
| 209 | rx_eq->min_eqd = rx_min; |
| 210 | if (rx_eq->cur_eqd > rx_max) |
| 211 | rx_eq->cur_eqd = rx_max; |
| 212 | if (rx_eq->cur_eqd < rx_min) |
| 213 | rx_eq->cur_eqd = rx_min; |
| 214 | } else { |
| 215 | if (rx_cur > BE_MAX_EQD) |
| 216 | rx_cur = BE_MAX_EQD; |
| 217 | if (rx_eq->cur_eqd != rx_cur) { |
| 218 | status = be_cmd_modify_eqd(adapter, rx_eq->q.id, |
| 219 | rx_cur); |
| 220 | if (!status) |
| 221 | rx_eq->cur_eqd = rx_cur; |
| 222 | } |
| 223 | } |
| 224 | } |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 225 | |
| 226 | tx_max = coalesce->tx_coalesce_usecs_high; |
| 227 | tx_min = coalesce->tx_coalesce_usecs_low; |
| 228 | tx_cur = coalesce->tx_coalesce_usecs; |
| 229 | |
| 230 | if (tx_cur > BE_MAX_EQD) |
| 231 | tx_cur = BE_MAX_EQD; |
| 232 | if (tx_eq->cur_eqd != tx_cur) { |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 233 | status = be_cmd_modify_eqd(adapter, tx_eq->q.id, tx_cur); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 234 | if (!status) |
| 235 | tx_eq->cur_eqd = tx_cur; |
| 236 | } |
| 237 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 238 | return 0; |
| 239 | } |
| 240 | |
| 241 | static u32 be_get_rx_csum(struct net_device *netdev) |
| 242 | { |
| 243 | struct be_adapter *adapter = netdev_priv(netdev); |
| 244 | |
| 245 | return adapter->rx_csum; |
| 246 | } |
| 247 | |
| 248 | static int be_set_rx_csum(struct net_device *netdev, uint32_t data) |
| 249 | { |
| 250 | struct be_adapter *adapter = netdev_priv(netdev); |
| 251 | |
| 252 | if (data) |
| 253 | adapter->rx_csum = true; |
| 254 | else |
| 255 | adapter->rx_csum = false; |
| 256 | |
| 257 | return 0; |
| 258 | } |
| 259 | |
| 260 | static void |
| 261 | be_get_ethtool_stats(struct net_device *netdev, |
| 262 | struct ethtool_stats *stats, uint64_t *data) |
| 263 | { |
| 264 | struct be_adapter *adapter = netdev_priv(netdev); |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 265 | struct be_hw_stats *hw_stats = hw_stats_from_cmd(adapter->stats_cmd.va); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 266 | struct be_erx_stats *erx_stats = &hw_stats->erx; |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 267 | struct be_rx_obj *rxo; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 268 | void *p = NULL; |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 269 | int i, j; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 270 | |
| 271 | for (i = 0; i < ETHTOOL_STATS_NUM; i++) { |
| 272 | switch (et_stats[i].type) { |
| 273 | case NETSTAT: |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 274 | p = &netdev->stats; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 275 | break; |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 276 | case DRVSTAT_TX: |
| 277 | p = &adapter->tx_stats; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 278 | break; |
| 279 | case PORTSTAT: |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 280 | p = &hw_stats->rxf.port[adapter->port_num]; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 281 | break; |
| 282 | case MISCSTAT: |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 283 | p = &hw_stats->rxf; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 284 | break; |
Ajit Khaparde | f6c4bf3 | 2011-02-20 11:41:04 +0000 | [diff] [blame] | 285 | case PMEMSTAT: |
| 286 | p = &hw_stats->pmem; |
| 287 | break; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | p = (u8 *)p + et_stats[i].offset; |
| 291 | data[i] = (et_stats[i].size == sizeof(u64)) ? |
| 292 | *(u64 *)p: *(u32 *)p; |
| 293 | } |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 294 | |
| 295 | for_all_rx_queues(adapter, rxo, j) { |
| 296 | for (i = 0; i < ETHTOOL_RXSTATS_NUM; i++) { |
| 297 | switch (et_rx_stats[i].type) { |
| 298 | case DRVSTAT_RX: |
| 299 | p = (u8 *)&rxo->stats + et_rx_stats[i].offset; |
| 300 | break; |
| 301 | case ERXSTAT: |
| 302 | p = (u32 *)erx_stats + rxo->q.id; |
| 303 | break; |
| 304 | } |
| 305 | data[ETHTOOL_STATS_NUM + j * ETHTOOL_RXSTATS_NUM + i] = |
| 306 | (et_rx_stats[i].size == sizeof(u64)) ? |
| 307 | *(u64 *)p: *(u32 *)p; |
| 308 | } |
| 309 | } |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 310 | } |
| 311 | |
| 312 | static void |
| 313 | be_get_stat_strings(struct net_device *netdev, uint32_t stringset, |
| 314 | uint8_t *data) |
| 315 | { |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 316 | struct be_adapter *adapter = netdev_priv(netdev); |
| 317 | int i, j; |
| 318 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 319 | switch (stringset) { |
| 320 | case ETH_SS_STATS: |
| 321 | for (i = 0; i < ETHTOOL_STATS_NUM; i++) { |
| 322 | memcpy(data, et_stats[i].desc, ETH_GSTRING_LEN); |
| 323 | data += ETH_GSTRING_LEN; |
| 324 | } |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 325 | for (i = 0; i < adapter->num_rx_qs; i++) { |
| 326 | for (j = 0; j < ETHTOOL_RXSTATS_NUM; j++) { |
| 327 | sprintf(data, "rxq%d: %s", i, |
| 328 | et_rx_stats[j].desc); |
| 329 | data += ETH_GSTRING_LEN; |
| 330 | } |
| 331 | } |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 332 | break; |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 333 | case ETH_SS_TEST: |
| 334 | for (i = 0; i < ETHTOOL_TESTS_NUM; i++) { |
| 335 | memcpy(data, et_self_tests[i], ETH_GSTRING_LEN); |
| 336 | data += ETH_GSTRING_LEN; |
| 337 | } |
| 338 | break; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 339 | } |
| 340 | } |
| 341 | |
Ben Hutchings | 15f0a39 | 2009-10-01 11:58:24 +0000 | [diff] [blame] | 342 | static int be_get_sset_count(struct net_device *netdev, int stringset) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 343 | { |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 344 | struct be_adapter *adapter = netdev_priv(netdev); |
| 345 | |
Ben Hutchings | 15f0a39 | 2009-10-01 11:58:24 +0000 | [diff] [blame] | 346 | switch (stringset) { |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 347 | case ETH_SS_TEST: |
| 348 | return ETHTOOL_TESTS_NUM; |
Ben Hutchings | 15f0a39 | 2009-10-01 11:58:24 +0000 | [diff] [blame] | 349 | case ETH_SS_STATS: |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 350 | return ETHTOOL_STATS_NUM + |
| 351 | adapter->num_rx_qs * ETHTOOL_RXSTATS_NUM; |
Ben Hutchings | 15f0a39 | 2009-10-01 11:58:24 +0000 | [diff] [blame] | 352 | default: |
| 353 | return -EINVAL; |
| 354 | } |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 355 | } |
| 356 | |
| 357 | static int be_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) |
| 358 | { |
Sarveshwar Bandi | 0388f25 | 2009-10-28 04:15:20 -0700 | [diff] [blame] | 359 | struct be_adapter *adapter = netdev_priv(netdev); |
Ajit Khaparde | ee3cb62 | 2010-07-01 03:51:00 +0000 | [diff] [blame] | 360 | struct be_dma_mem phy_cmd; |
| 361 | struct be_cmd_resp_get_phy_info *resp; |
| 362 | u8 mac_speed = 0; |
Sarveshwar Bandi | 0388f25 | 2009-10-28 04:15:20 -0700 | [diff] [blame] | 363 | u16 link_speed = 0; |
| 364 | bool link_up = false; |
Ajit Khaparde | 0dffc83 | 2009-11-29 17:57:46 +0000 | [diff] [blame] | 365 | int status; |
Ajit Khaparde | ee3cb62 | 2010-07-01 03:51:00 +0000 | [diff] [blame] | 366 | u16 intf_type; |
Sarveshwar Bandi | 0388f25 | 2009-10-28 04:15:20 -0700 | [diff] [blame] | 367 | |
Ajit Khaparde | 48e9989 | 2010-07-29 06:17:17 +0000 | [diff] [blame] | 368 | if ((adapter->link_speed < 0) || (!(netdev->flags & IFF_UP))) { |
Ajit Khaparde | 0dffc83 | 2009-11-29 17:57:46 +0000 | [diff] [blame] | 369 | status = be_cmd_link_status_query(adapter, &link_up, |
| 370 | &mac_speed, &link_speed); |
Sarveshwar Bandi | 0388f25 | 2009-10-28 04:15:20 -0700 | [diff] [blame] | 371 | |
Ajit Khaparde | 48e9989 | 2010-07-29 06:17:17 +0000 | [diff] [blame] | 372 | be_link_status_update(adapter, link_up); |
Ajit Khaparde | 0dffc83 | 2009-11-29 17:57:46 +0000 | [diff] [blame] | 373 | /* link_speed is in units of 10 Mbps */ |
| 374 | if (link_speed) { |
| 375 | ecmd->speed = link_speed*10; |
| 376 | } else { |
| 377 | switch (mac_speed) { |
| 378 | case PHY_LINK_SPEED_1GBPS: |
| 379 | ecmd->speed = SPEED_1000; |
| 380 | break; |
| 381 | case PHY_LINK_SPEED_10GBPS: |
| 382 | ecmd->speed = SPEED_10000; |
| 383 | break; |
| 384 | } |
| 385 | } |
| 386 | |
Ajit Khaparde | ee3cb62 | 2010-07-01 03:51:00 +0000 | [diff] [blame] | 387 | phy_cmd.size = sizeof(struct be_cmd_req_get_phy_info); |
Ivan Vecera | 2b7bceb | 2011-02-02 08:05:12 +0000 | [diff] [blame] | 388 | phy_cmd.va = dma_alloc_coherent(&adapter->pdev->dev, |
| 389 | phy_cmd.size, &phy_cmd.dma, |
| 390 | GFP_KERNEL); |
Ajit Khaparde | ee3cb62 | 2010-07-01 03:51:00 +0000 | [diff] [blame] | 391 | if (!phy_cmd.va) { |
| 392 | dev_err(&adapter->pdev->dev, "Memory alloc failure\n"); |
| 393 | return -ENOMEM; |
| 394 | } |
| 395 | status = be_cmd_get_phy_info(adapter, &phy_cmd); |
Sarveshwar Bandi | 16c0214 | 2009-12-23 04:42:51 +0000 | [diff] [blame] | 396 | if (!status) { |
Ajit Khaparde | ee3cb62 | 2010-07-01 03:51:00 +0000 | [diff] [blame] | 397 | resp = (struct be_cmd_resp_get_phy_info *) phy_cmd.va; |
| 398 | intf_type = le16_to_cpu(resp->interface_type); |
| 399 | |
| 400 | switch (intf_type) { |
| 401 | case PHY_TYPE_XFP_10GB: |
| 402 | case PHY_TYPE_SFP_1GB: |
| 403 | case PHY_TYPE_SFP_PLUS_10GB: |
Sarveshwar Bandi | 16c0214 | 2009-12-23 04:42:51 +0000 | [diff] [blame] | 404 | ecmd->port = PORT_FIBRE; |
Sarveshwar Bandi | 16c0214 | 2009-12-23 04:42:51 +0000 | [diff] [blame] | 405 | break; |
| 406 | default: |
| 407 | ecmd->port = PORT_TP; |
Sarveshwar Bandi | 16c0214 | 2009-12-23 04:42:51 +0000 | [diff] [blame] | 408 | break; |
| 409 | } |
Ajit Khaparde | ee3cb62 | 2010-07-01 03:51:00 +0000 | [diff] [blame] | 410 | |
| 411 | switch (intf_type) { |
| 412 | case PHY_TYPE_KR_10GB: |
| 413 | case PHY_TYPE_KX4_10GB: |
| 414 | ecmd->autoneg = AUTONEG_ENABLE; |
Sarveshwar Bandi | 16c0214 | 2009-12-23 04:42:51 +0000 | [diff] [blame] | 415 | ecmd->transceiver = XCVR_INTERNAL; |
Ajit Khaparde | ee3cb62 | 2010-07-01 03:51:00 +0000 | [diff] [blame] | 416 | break; |
| 417 | default: |
| 418 | ecmd->autoneg = AUTONEG_DISABLE; |
| 419 | ecmd->transceiver = XCVR_EXTERNAL; |
| 420 | break; |
| 421 | } |
Sarveshwar Bandi | 0388f25 | 2009-10-28 04:15:20 -0700 | [diff] [blame] | 422 | } |
Ajit Khaparde | 0dffc83 | 2009-11-29 17:57:46 +0000 | [diff] [blame] | 423 | |
| 424 | /* Save for future use */ |
| 425 | adapter->link_speed = ecmd->speed; |
| 426 | adapter->port_type = ecmd->port; |
Sarveshwar Bandi | 16c0214 | 2009-12-23 04:42:51 +0000 | [diff] [blame] | 427 | adapter->transceiver = ecmd->transceiver; |
Ajit Khaparde | ee3cb62 | 2010-07-01 03:51:00 +0000 | [diff] [blame] | 428 | adapter->autoneg = ecmd->autoneg; |
Ivan Vecera | 2b7bceb | 2011-02-02 08:05:12 +0000 | [diff] [blame] | 429 | dma_free_coherent(&adapter->pdev->dev, phy_cmd.size, phy_cmd.va, |
| 430 | phy_cmd.dma); |
Ajit Khaparde | 0dffc83 | 2009-11-29 17:57:46 +0000 | [diff] [blame] | 431 | } else { |
| 432 | ecmd->speed = adapter->link_speed; |
| 433 | ecmd->port = adapter->port_type; |
Sarveshwar Bandi | 16c0214 | 2009-12-23 04:42:51 +0000 | [diff] [blame] | 434 | ecmd->transceiver = adapter->transceiver; |
Ajit Khaparde | ee3cb62 | 2010-07-01 03:51:00 +0000 | [diff] [blame] | 435 | ecmd->autoneg = adapter->autoneg; |
Sarveshwar Bandi | 0388f25 | 2009-10-28 04:15:20 -0700 | [diff] [blame] | 436 | } |
Ajit Khaparde | 0dffc83 | 2009-11-29 17:57:46 +0000 | [diff] [blame] | 437 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 438 | ecmd->duplex = DUPLEX_FULL; |
Sarveshwar Bandi | 0388f25 | 2009-10-28 04:15:20 -0700 | [diff] [blame] | 439 | ecmd->phy_address = adapter->port_num; |
Sarveshwar Bandi | 16c0214 | 2009-12-23 04:42:51 +0000 | [diff] [blame] | 440 | switch (ecmd->port) { |
| 441 | case PORT_FIBRE: |
| 442 | ecmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE); |
| 443 | break; |
| 444 | case PORT_TP: |
| 445 | ecmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_TP); |
| 446 | break; |
| 447 | case PORT_AUI: |
| 448 | ecmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_AUI); |
| 449 | break; |
| 450 | } |
Sarveshwar Bandi | 0388f25 | 2009-10-28 04:15:20 -0700 | [diff] [blame] | 451 | |
Ajit Khaparde | ee3cb62 | 2010-07-01 03:51:00 +0000 | [diff] [blame] | 452 | if (ecmd->autoneg) { |
| 453 | ecmd->supported |= SUPPORTED_1000baseT_Full; |
| 454 | ecmd->supported |= SUPPORTED_Autoneg; |
| 455 | ecmd->advertising |= (ADVERTISED_10000baseT_Full | |
| 456 | ADVERTISED_1000baseT_Full); |
| 457 | } |
| 458 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 459 | return 0; |
| 460 | } |
| 461 | |
| 462 | static void |
| 463 | be_get_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring) |
| 464 | { |
| 465 | struct be_adapter *adapter = netdev_priv(netdev); |
| 466 | |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 467 | ring->rx_max_pending = adapter->rx_obj[0].q.len; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 468 | ring->tx_max_pending = adapter->tx_obj.q.len; |
| 469 | |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 470 | ring->rx_pending = atomic_read(&adapter->rx_obj[0].q.used); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 471 | ring->tx_pending = atomic_read(&adapter->tx_obj.q.used); |
| 472 | } |
| 473 | |
| 474 | static void |
| 475 | be_get_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *ecmd) |
| 476 | { |
| 477 | struct be_adapter *adapter = netdev_priv(netdev); |
| 478 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 479 | be_cmd_get_flow_control(adapter, &ecmd->tx_pause, &ecmd->rx_pause); |
Ajit Khaparde | 03a980d | 2009-04-13 15:41:50 -0700 | [diff] [blame] | 480 | ecmd->autoneg = 0; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 481 | } |
| 482 | |
| 483 | static int |
| 484 | be_set_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *ecmd) |
| 485 | { |
| 486 | struct be_adapter *adapter = netdev_priv(netdev); |
| 487 | int status; |
| 488 | |
Ajit Khaparde | 03a980d | 2009-04-13 15:41:50 -0700 | [diff] [blame] | 489 | if (ecmd->autoneg != 0) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 490 | return -EINVAL; |
Ajit Khaparde | 9e90c96 | 2009-11-06 02:06:59 +0000 | [diff] [blame] | 491 | adapter->tx_fc = ecmd->tx_pause; |
| 492 | adapter->rx_fc = ecmd->rx_pause; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 493 | |
Ajit Khaparde | 9e90c96 | 2009-11-06 02:06:59 +0000 | [diff] [blame] | 494 | status = be_cmd_set_flow_control(adapter, |
| 495 | adapter->tx_fc, adapter->rx_fc); |
| 496 | if (status) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 497 | dev_warn(&adapter->pdev->dev, "Pause param set failed.\n"); |
| 498 | |
| 499 | return status; |
| 500 | } |
| 501 | |
Ajit Khaparde | 8451748 | 2009-09-04 03:12:16 +0000 | [diff] [blame] | 502 | static int |
Sarveshwar Bandi | fad9ab2 | 2009-10-12 04:23:15 -0700 | [diff] [blame] | 503 | be_phys_id(struct net_device *netdev, u32 data) |
| 504 | { |
| 505 | struct be_adapter *adapter = netdev_priv(netdev); |
| 506 | int status; |
| 507 | u32 cur; |
| 508 | |
Sarveshwar Bandi | fad9ab2 | 2009-10-12 04:23:15 -0700 | [diff] [blame] | 509 | be_cmd_get_beacon_state(adapter, adapter->port_num, &cur); |
| 510 | |
| 511 | if (cur == BEACON_STATE_ENABLED) |
| 512 | return 0; |
| 513 | |
| 514 | if (data < 2) |
| 515 | data = 2; |
| 516 | |
| 517 | status = be_cmd_set_beacon_state(adapter, adapter->port_num, 0, 0, |
| 518 | BEACON_STATE_ENABLED); |
| 519 | set_current_state(TASK_INTERRUPTIBLE); |
| 520 | schedule_timeout(data*HZ); |
| 521 | |
| 522 | status = be_cmd_set_beacon_state(adapter, adapter->port_num, 0, 0, |
| 523 | BEACON_STATE_DISABLED); |
| 524 | |
| 525 | return status; |
| 526 | } |
| 527 | |
Ajit Khaparde | dcf96f1 | 2011-02-11 13:39:30 +0000 | [diff] [blame] | 528 | static bool |
| 529 | be_is_wol_supported(struct be_adapter *adapter) |
| 530 | { |
| 531 | if (!be_physfn(adapter)) |
| 532 | return false; |
| 533 | else |
| 534 | return true; |
| 535 | } |
| 536 | |
Ajit Khaparde | 71d8d1b | 2009-12-03 06:16:59 +0000 | [diff] [blame] | 537 | static void |
| 538 | be_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) |
| 539 | { |
| 540 | struct be_adapter *adapter = netdev_priv(netdev); |
| 541 | |
Ajit Khaparde | dcf96f1 | 2011-02-11 13:39:30 +0000 | [diff] [blame] | 542 | if (be_is_wol_supported(adapter)) |
| 543 | wol->supported = WAKE_MAGIC; |
| 544 | |
Ajit Khaparde | 71d8d1b | 2009-12-03 06:16:59 +0000 | [diff] [blame] | 545 | if (adapter->wol) |
| 546 | wol->wolopts = WAKE_MAGIC; |
| 547 | else |
| 548 | wol->wolopts = 0; |
| 549 | memset(&wol->sopass, 0, sizeof(wol->sopass)); |
Ajit Khaparde | 71d8d1b | 2009-12-03 06:16:59 +0000 | [diff] [blame] | 550 | } |
| 551 | |
| 552 | static int |
| 553 | be_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) |
| 554 | { |
| 555 | struct be_adapter *adapter = netdev_priv(netdev); |
| 556 | |
| 557 | if (wol->wolopts & ~WAKE_MAGIC) |
| 558 | return -EINVAL; |
| 559 | |
Ajit Khaparde | dcf96f1 | 2011-02-11 13:39:30 +0000 | [diff] [blame] | 560 | if ((wol->wolopts & WAKE_MAGIC) && be_is_wol_supported(adapter)) |
Ajit Khaparde | 71d8d1b | 2009-12-03 06:16:59 +0000 | [diff] [blame] | 561 | adapter->wol = true; |
| 562 | else |
| 563 | adapter->wol = false; |
| 564 | |
| 565 | return 0; |
| 566 | } |
| 567 | |
Sarveshwar Bandi | fad9ab2 | 2009-10-12 04:23:15 -0700 | [diff] [blame] | 568 | static int |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 569 | be_test_ddr_dma(struct be_adapter *adapter) |
| 570 | { |
| 571 | int ret, i; |
| 572 | struct be_dma_mem ddrdma_cmd; |
Joe Perches | 215faf9 | 2010-12-21 02:16:10 -0800 | [diff] [blame] | 573 | static const u64 pattern[2] = { |
| 574 | 0x5a5a5a5a5a5a5a5aULL, 0xa5a5a5a5a5a5a5a5ULL |
| 575 | }; |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 576 | |
| 577 | ddrdma_cmd.size = sizeof(struct be_cmd_req_ddrdma_test); |
Ivan Vecera | 2b7bceb | 2011-02-02 08:05:12 +0000 | [diff] [blame] | 578 | ddrdma_cmd.va = dma_alloc_coherent(&adapter->pdev->dev, ddrdma_cmd.size, |
| 579 | &ddrdma_cmd.dma, GFP_KERNEL); |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 580 | if (!ddrdma_cmd.va) { |
Frans Pop | 2381a55 | 2010-03-24 07:57:36 +0000 | [diff] [blame] | 581 | dev_err(&adapter->pdev->dev, "Memory allocation failure\n"); |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 582 | return -ENOMEM; |
| 583 | } |
| 584 | |
| 585 | for (i = 0; i < 2; i++) { |
| 586 | ret = be_cmd_ddr_dma_test(adapter, pattern[i], |
| 587 | 4096, &ddrdma_cmd); |
| 588 | if (ret != 0) |
| 589 | goto err; |
| 590 | } |
| 591 | |
| 592 | err: |
Ivan Vecera | 2b7bceb | 2011-02-02 08:05:12 +0000 | [diff] [blame] | 593 | dma_free_coherent(&adapter->pdev->dev, ddrdma_cmd.size, ddrdma_cmd.va, |
| 594 | ddrdma_cmd.dma); |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 595 | return ret; |
| 596 | } |
| 597 | |
Sarveshwar Bandi | fced999 | 2009-12-23 04:41:44 +0000 | [diff] [blame] | 598 | static u64 be_loopback_test(struct be_adapter *adapter, u8 loopback_type, |
| 599 | u64 *status) |
| 600 | { |
| 601 | be_cmd_set_loopback(adapter, adapter->port_num, |
| 602 | loopback_type, 1); |
| 603 | *status = be_cmd_loopback_test(adapter, adapter->port_num, |
| 604 | loopback_type, 1500, |
| 605 | 2, 0xabc); |
| 606 | be_cmd_set_loopback(adapter, adapter->port_num, |
| 607 | BE_NO_LOOPBACK, 1); |
| 608 | return *status; |
| 609 | } |
| 610 | |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 611 | static void |
| 612 | be_self_test(struct net_device *netdev, struct ethtool_test *test, u64 *data) |
| 613 | { |
| 614 | struct be_adapter *adapter = netdev_priv(netdev); |
Sarveshwar Bandi | 4276e47 | 2010-01-19 05:15:36 +0000 | [diff] [blame] | 615 | bool link_up; |
| 616 | u8 mac_speed = 0; |
| 617 | u16 qos_link_speed = 0; |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 618 | |
| 619 | memset(data, 0, sizeof(u64) * ETHTOOL_TESTS_NUM); |
| 620 | |
| 621 | if (test->flags & ETH_TEST_FL_OFFLINE) { |
Sarveshwar Bandi | fced999 | 2009-12-23 04:41:44 +0000 | [diff] [blame] | 622 | if (be_loopback_test(adapter, BE_MAC_LOOPBACK, |
| 623 | &data[0]) != 0) { |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 624 | test->flags |= ETH_TEST_FL_FAILED; |
Sarveshwar Bandi | fced999 | 2009-12-23 04:41:44 +0000 | [diff] [blame] | 625 | } |
| 626 | if (be_loopback_test(adapter, BE_PHY_LOOPBACK, |
| 627 | &data[1]) != 0) { |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 628 | test->flags |= ETH_TEST_FL_FAILED; |
Sarveshwar Bandi | fced999 | 2009-12-23 04:41:44 +0000 | [diff] [blame] | 629 | } |
| 630 | if (be_loopback_test(adapter, BE_ONE_PORT_EXT_LOOPBACK, |
| 631 | &data[2]) != 0) { |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 632 | test->flags |= ETH_TEST_FL_FAILED; |
Sarveshwar Bandi | fced999 | 2009-12-23 04:41:44 +0000 | [diff] [blame] | 633 | } |
Sarveshwar Bandi | 8f47afe | 2010-01-19 05:15:00 +0000 | [diff] [blame] | 634 | } |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 635 | |
Sarveshwar Bandi | 8f47afe | 2010-01-19 05:15:00 +0000 | [diff] [blame] | 636 | if (be_test_ddr_dma(adapter) != 0) { |
| 637 | data[3] = 1; |
| 638 | test->flags |= ETH_TEST_FL_FAILED; |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 639 | } |
| 640 | |
Sarveshwar Bandi | 4276e47 | 2010-01-19 05:15:36 +0000 | [diff] [blame] | 641 | if (be_cmd_link_status_query(adapter, &link_up, &mac_speed, |
| 642 | &qos_link_speed) != 0) { |
| 643 | test->flags |= ETH_TEST_FL_FAILED; |
| 644 | data[4] = -1; |
Ajit Khaparde | 4ee7721 | 2011-02-20 11:41:20 +0000 | [diff] [blame^] | 645 | } else if (!mac_speed) { |
| 646 | test->flags |= ETH_TEST_FL_FAILED; |
Sarveshwar Bandi | 4276e47 | 2010-01-19 05:15:36 +0000 | [diff] [blame] | 647 | data[4] = 1; |
| 648 | } |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 649 | } |
| 650 | |
| 651 | static int |
Ajit Khaparde | 8451748 | 2009-09-04 03:12:16 +0000 | [diff] [blame] | 652 | be_do_flash(struct net_device *netdev, struct ethtool_flash *efl) |
| 653 | { |
| 654 | struct be_adapter *adapter = netdev_priv(netdev); |
| 655 | char file_name[ETHTOOL_FLASH_MAX_FILENAME]; |
| 656 | u32 region; |
| 657 | |
| 658 | file_name[ETHTOOL_FLASH_MAX_FILENAME - 1] = 0; |
| 659 | strcpy(file_name, efl->data); |
| 660 | region = efl->region; |
| 661 | |
| 662 | return be_load_fw(adapter, file_name); |
| 663 | } |
| 664 | |
Sarveshwar Bandi | 368c0ca | 2010-01-08 00:07:27 -0800 | [diff] [blame] | 665 | static int |
| 666 | be_get_eeprom_len(struct net_device *netdev) |
| 667 | { |
| 668 | return BE_READ_SEEPROM_LEN; |
| 669 | } |
| 670 | |
| 671 | static int |
| 672 | be_read_eeprom(struct net_device *netdev, struct ethtool_eeprom *eeprom, |
| 673 | uint8_t *data) |
| 674 | { |
| 675 | struct be_adapter *adapter = netdev_priv(netdev); |
| 676 | struct be_dma_mem eeprom_cmd; |
| 677 | struct be_cmd_resp_seeprom_read *resp; |
| 678 | int status; |
| 679 | |
| 680 | if (!eeprom->len) |
| 681 | return -EINVAL; |
| 682 | |
| 683 | eeprom->magic = BE_VENDOR_ID | (adapter->pdev->device<<16); |
| 684 | |
| 685 | memset(&eeprom_cmd, 0, sizeof(struct be_dma_mem)); |
| 686 | eeprom_cmd.size = sizeof(struct be_cmd_req_seeprom_read); |
Ivan Vecera | 2b7bceb | 2011-02-02 08:05:12 +0000 | [diff] [blame] | 687 | eeprom_cmd.va = dma_alloc_coherent(&adapter->pdev->dev, eeprom_cmd.size, |
| 688 | &eeprom_cmd.dma, GFP_KERNEL); |
Sarveshwar Bandi | 368c0ca | 2010-01-08 00:07:27 -0800 | [diff] [blame] | 689 | |
| 690 | if (!eeprom_cmd.va) { |
| 691 | dev_err(&adapter->pdev->dev, |
| 692 | "Memory allocation failure. Could not read eeprom\n"); |
| 693 | return -ENOMEM; |
| 694 | } |
| 695 | |
| 696 | status = be_cmd_get_seeprom_data(adapter, &eeprom_cmd); |
| 697 | |
| 698 | if (!status) { |
| 699 | resp = (struct be_cmd_resp_seeprom_read *) eeprom_cmd.va; |
Ajit Khaparde | c0ad984 | 2010-02-08 17:51:26 +0000 | [diff] [blame] | 700 | memcpy(data, resp->seeprom_data + eeprom->offset, eeprom->len); |
Sarveshwar Bandi | 368c0ca | 2010-01-08 00:07:27 -0800 | [diff] [blame] | 701 | } |
Ivan Vecera | 2b7bceb | 2011-02-02 08:05:12 +0000 | [diff] [blame] | 702 | dma_free_coherent(&adapter->pdev->dev, eeprom_cmd.size, eeprom_cmd.va, |
| 703 | eeprom_cmd.dma); |
Sarveshwar Bandi | 368c0ca | 2010-01-08 00:07:27 -0800 | [diff] [blame] | 704 | |
| 705 | return status; |
| 706 | } |
| 707 | |
Stephen Hemminger | 0fc0b73 | 2009-09-02 01:03:33 -0700 | [diff] [blame] | 708 | const struct ethtool_ops be_ethtool_ops = { |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 709 | .get_settings = be_get_settings, |
| 710 | .get_drvinfo = be_get_drvinfo, |
Ajit Khaparde | 71d8d1b | 2009-12-03 06:16:59 +0000 | [diff] [blame] | 711 | .get_wol = be_get_wol, |
| 712 | .set_wol = be_set_wol, |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 713 | .get_link = ethtool_op_get_link, |
Sarveshwar Bandi | 368c0ca | 2010-01-08 00:07:27 -0800 | [diff] [blame] | 714 | .get_eeprom_len = be_get_eeprom_len, |
| 715 | .get_eeprom = be_read_eeprom, |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 716 | .get_coalesce = be_get_coalesce, |
| 717 | .set_coalesce = be_set_coalesce, |
| 718 | .get_ringparam = be_get_ringparam, |
| 719 | .get_pauseparam = be_get_pauseparam, |
| 720 | .set_pauseparam = be_set_pauseparam, |
| 721 | .get_rx_csum = be_get_rx_csum, |
| 722 | .set_rx_csum = be_set_rx_csum, |
| 723 | .get_tx_csum = ethtool_op_get_tx_csum, |
Ajit Khaparde | 583e3f3 | 2009-10-05 02:22:19 +0000 | [diff] [blame] | 724 | .set_tx_csum = ethtool_op_set_tx_hw_csum, |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 725 | .get_sg = ethtool_op_get_sg, |
| 726 | .set_sg = ethtool_op_set_sg, |
| 727 | .get_tso = ethtool_op_get_tso, |
| 728 | .set_tso = ethtool_op_set_tso, |
| 729 | .get_strings = be_get_stat_strings, |
Sarveshwar Bandi | fad9ab2 | 2009-10-12 04:23:15 -0700 | [diff] [blame] | 730 | .phys_id = be_phys_id, |
Ben Hutchings | 15f0a39 | 2009-10-01 11:58:24 +0000 | [diff] [blame] | 731 | .get_sset_count = be_get_sset_count, |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 732 | .get_ethtool_stats = be_get_ethtool_stats, |
Ajit Khaparde | 8451748 | 2009-09-04 03:12:16 +0000 | [diff] [blame] | 733 | .flash_device = be_do_flash, |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 734 | .self_test = be_self_test, |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 735 | }; |