Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1 | /**************************************************************************** |
| 2 | * Driver for Solarflare Solarstorm network controllers and boards |
| 3 | * Copyright 2005-2006 Fen Systems Ltd. |
| 4 | * Copyright 2006-2008 Solarflare Communications Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License version 2 as published |
| 8 | * by the Free Software Foundation, incorporated herein by reference. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/netdevice.h> |
| 12 | #include <linux/ethtool.h> |
| 13 | #include <linux/rtnetlink.h> |
| 14 | #include "net_driver.h" |
Ben Hutchings | 04cc8ca | 2008-12-12 21:50:46 -0800 | [diff] [blame^] | 15 | #include "workarounds.h" |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 16 | #include "selftest.h" |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 17 | #include "efx.h" |
| 18 | #include "ethtool.h" |
| 19 | #include "falcon.h" |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 20 | #include "spi.h" |
Ben Hutchings | 04cc8ca | 2008-12-12 21:50:46 -0800 | [diff] [blame^] | 21 | #include "mdio_10g.h" |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 22 | |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 23 | const char *efx_loopback_mode_names[] = { |
| 24 | [LOOPBACK_NONE] = "NONE", |
Ben Hutchings | 177dfcd | 2008-12-12 21:50:08 -0800 | [diff] [blame] | 25 | [LOOPBACK_GMAC] = "GMAC", |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 26 | [LOOPBACK_XGMII] = "XGMII", |
| 27 | [LOOPBACK_XGXS] = "XGXS", |
| 28 | [LOOPBACK_XAUI] = "XAUI", |
Ben Hutchings | 177dfcd | 2008-12-12 21:50:08 -0800 | [diff] [blame] | 29 | [LOOPBACK_GPHY] = "GPHY", |
Ben Hutchings | 740ced9 | 2008-12-12 21:41:55 -0800 | [diff] [blame] | 30 | [LOOPBACK_PHYXS] = "PHYXS", |
| 31 | [LOOPBACK_PCS] = "PCS", |
| 32 | [LOOPBACK_PMAPMD] = "PMA/PMD", |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 33 | [LOOPBACK_NETWORK] = "NETWORK", |
| 34 | }; |
| 35 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 36 | struct ethtool_string { |
| 37 | char name[ETH_GSTRING_LEN]; |
| 38 | }; |
| 39 | |
| 40 | struct efx_ethtool_stat { |
| 41 | const char *name; |
| 42 | enum { |
| 43 | EFX_ETHTOOL_STAT_SOURCE_mac_stats, |
| 44 | EFX_ETHTOOL_STAT_SOURCE_nic, |
| 45 | EFX_ETHTOOL_STAT_SOURCE_channel |
| 46 | } source; |
| 47 | unsigned offset; |
| 48 | u64(*get_stat) (void *field); /* Reader function */ |
| 49 | }; |
| 50 | |
| 51 | /* Initialiser for a struct #efx_ethtool_stat with type-checking */ |
| 52 | #define EFX_ETHTOOL_STAT(stat_name, source_name, field, field_type, \ |
| 53 | get_stat_function) { \ |
| 54 | .name = #stat_name, \ |
| 55 | .source = EFX_ETHTOOL_STAT_SOURCE_##source_name, \ |
| 56 | .offset = ((((field_type *) 0) == \ |
| 57 | &((struct efx_##source_name *)0)->field) ? \ |
| 58 | offsetof(struct efx_##source_name, field) : \ |
| 59 | offsetof(struct efx_##source_name, field)), \ |
| 60 | .get_stat = get_stat_function, \ |
| 61 | } |
| 62 | |
| 63 | static u64 efx_get_uint_stat(void *field) |
| 64 | { |
| 65 | return *(unsigned int *)field; |
| 66 | } |
| 67 | |
| 68 | static u64 efx_get_ulong_stat(void *field) |
| 69 | { |
| 70 | return *(unsigned long *)field; |
| 71 | } |
| 72 | |
| 73 | static u64 efx_get_u64_stat(void *field) |
| 74 | { |
| 75 | return *(u64 *) field; |
| 76 | } |
| 77 | |
| 78 | static u64 efx_get_atomic_stat(void *field) |
| 79 | { |
| 80 | return atomic_read((atomic_t *) field); |
| 81 | } |
| 82 | |
| 83 | #define EFX_ETHTOOL_ULONG_MAC_STAT(field) \ |
| 84 | EFX_ETHTOOL_STAT(field, mac_stats, field, \ |
| 85 | unsigned long, efx_get_ulong_stat) |
| 86 | |
| 87 | #define EFX_ETHTOOL_U64_MAC_STAT(field) \ |
| 88 | EFX_ETHTOOL_STAT(field, mac_stats, field, \ |
| 89 | u64, efx_get_u64_stat) |
| 90 | |
| 91 | #define EFX_ETHTOOL_UINT_NIC_STAT(name) \ |
| 92 | EFX_ETHTOOL_STAT(name, nic, n_##name, \ |
| 93 | unsigned int, efx_get_uint_stat) |
| 94 | |
| 95 | #define EFX_ETHTOOL_ATOMIC_NIC_ERROR_STAT(field) \ |
| 96 | EFX_ETHTOOL_STAT(field, nic, field, \ |
| 97 | atomic_t, efx_get_atomic_stat) |
| 98 | |
| 99 | #define EFX_ETHTOOL_UINT_CHANNEL_STAT(field) \ |
| 100 | EFX_ETHTOOL_STAT(field, channel, n_##field, \ |
| 101 | unsigned int, efx_get_uint_stat) |
| 102 | |
| 103 | static struct efx_ethtool_stat efx_ethtool_stats[] = { |
| 104 | EFX_ETHTOOL_U64_MAC_STAT(tx_bytes), |
| 105 | EFX_ETHTOOL_U64_MAC_STAT(tx_good_bytes), |
| 106 | EFX_ETHTOOL_U64_MAC_STAT(tx_bad_bytes), |
| 107 | EFX_ETHTOOL_ULONG_MAC_STAT(tx_packets), |
| 108 | EFX_ETHTOOL_ULONG_MAC_STAT(tx_bad), |
| 109 | EFX_ETHTOOL_ULONG_MAC_STAT(tx_pause), |
| 110 | EFX_ETHTOOL_ULONG_MAC_STAT(tx_control), |
| 111 | EFX_ETHTOOL_ULONG_MAC_STAT(tx_unicast), |
| 112 | EFX_ETHTOOL_ULONG_MAC_STAT(tx_multicast), |
| 113 | EFX_ETHTOOL_ULONG_MAC_STAT(tx_broadcast), |
| 114 | EFX_ETHTOOL_ULONG_MAC_STAT(tx_lt64), |
| 115 | EFX_ETHTOOL_ULONG_MAC_STAT(tx_64), |
| 116 | EFX_ETHTOOL_ULONG_MAC_STAT(tx_65_to_127), |
| 117 | EFX_ETHTOOL_ULONG_MAC_STAT(tx_128_to_255), |
| 118 | EFX_ETHTOOL_ULONG_MAC_STAT(tx_256_to_511), |
| 119 | EFX_ETHTOOL_ULONG_MAC_STAT(tx_512_to_1023), |
| 120 | EFX_ETHTOOL_ULONG_MAC_STAT(tx_1024_to_15xx), |
| 121 | EFX_ETHTOOL_ULONG_MAC_STAT(tx_15xx_to_jumbo), |
| 122 | EFX_ETHTOOL_ULONG_MAC_STAT(tx_gtjumbo), |
| 123 | EFX_ETHTOOL_ULONG_MAC_STAT(tx_collision), |
| 124 | EFX_ETHTOOL_ULONG_MAC_STAT(tx_single_collision), |
| 125 | EFX_ETHTOOL_ULONG_MAC_STAT(tx_multiple_collision), |
| 126 | EFX_ETHTOOL_ULONG_MAC_STAT(tx_excessive_collision), |
| 127 | EFX_ETHTOOL_ULONG_MAC_STAT(tx_deferred), |
| 128 | EFX_ETHTOOL_ULONG_MAC_STAT(tx_late_collision), |
| 129 | EFX_ETHTOOL_ULONG_MAC_STAT(tx_excessive_deferred), |
| 130 | EFX_ETHTOOL_ULONG_MAC_STAT(tx_non_tcpudp), |
| 131 | EFX_ETHTOOL_ULONG_MAC_STAT(tx_mac_src_error), |
| 132 | EFX_ETHTOOL_ULONG_MAC_STAT(tx_ip_src_error), |
| 133 | EFX_ETHTOOL_U64_MAC_STAT(rx_bytes), |
| 134 | EFX_ETHTOOL_U64_MAC_STAT(rx_good_bytes), |
| 135 | EFX_ETHTOOL_U64_MAC_STAT(rx_bad_bytes), |
| 136 | EFX_ETHTOOL_ULONG_MAC_STAT(rx_packets), |
| 137 | EFX_ETHTOOL_ULONG_MAC_STAT(rx_good), |
| 138 | EFX_ETHTOOL_ULONG_MAC_STAT(rx_bad), |
| 139 | EFX_ETHTOOL_ULONG_MAC_STAT(rx_pause), |
| 140 | EFX_ETHTOOL_ULONG_MAC_STAT(rx_control), |
| 141 | EFX_ETHTOOL_ULONG_MAC_STAT(rx_unicast), |
| 142 | EFX_ETHTOOL_ULONG_MAC_STAT(rx_multicast), |
| 143 | EFX_ETHTOOL_ULONG_MAC_STAT(rx_broadcast), |
| 144 | EFX_ETHTOOL_ULONG_MAC_STAT(rx_lt64), |
| 145 | EFX_ETHTOOL_ULONG_MAC_STAT(rx_64), |
| 146 | EFX_ETHTOOL_ULONG_MAC_STAT(rx_65_to_127), |
| 147 | EFX_ETHTOOL_ULONG_MAC_STAT(rx_128_to_255), |
| 148 | EFX_ETHTOOL_ULONG_MAC_STAT(rx_256_to_511), |
| 149 | EFX_ETHTOOL_ULONG_MAC_STAT(rx_512_to_1023), |
| 150 | EFX_ETHTOOL_ULONG_MAC_STAT(rx_1024_to_15xx), |
| 151 | EFX_ETHTOOL_ULONG_MAC_STAT(rx_15xx_to_jumbo), |
| 152 | EFX_ETHTOOL_ULONG_MAC_STAT(rx_gtjumbo), |
| 153 | EFX_ETHTOOL_ULONG_MAC_STAT(rx_bad_lt64), |
| 154 | EFX_ETHTOOL_ULONG_MAC_STAT(rx_bad_64_to_15xx), |
| 155 | EFX_ETHTOOL_ULONG_MAC_STAT(rx_bad_15xx_to_jumbo), |
| 156 | EFX_ETHTOOL_ULONG_MAC_STAT(rx_bad_gtjumbo), |
| 157 | EFX_ETHTOOL_ULONG_MAC_STAT(rx_overflow), |
| 158 | EFX_ETHTOOL_ULONG_MAC_STAT(rx_missed), |
| 159 | EFX_ETHTOOL_ULONG_MAC_STAT(rx_false_carrier), |
| 160 | EFX_ETHTOOL_ULONG_MAC_STAT(rx_symbol_error), |
| 161 | EFX_ETHTOOL_ULONG_MAC_STAT(rx_align_error), |
| 162 | EFX_ETHTOOL_ULONG_MAC_STAT(rx_length_error), |
| 163 | EFX_ETHTOOL_ULONG_MAC_STAT(rx_internal_error), |
| 164 | EFX_ETHTOOL_UINT_NIC_STAT(rx_nodesc_drop_cnt), |
| 165 | EFX_ETHTOOL_ATOMIC_NIC_ERROR_STAT(rx_reset), |
| 166 | EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_tobe_disc), |
| 167 | EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_ip_hdr_chksum_err), |
| 168 | EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_tcp_udp_chksum_err), |
| 169 | EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_frm_trunc), |
| 170 | }; |
| 171 | |
| 172 | /* Number of ethtool statistics */ |
| 173 | #define EFX_ETHTOOL_NUM_STATS ARRAY_SIZE(efx_ethtool_stats) |
| 174 | |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 175 | #define EFX_ETHTOOL_EEPROM_MAGIC 0xEFAB |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 176 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 177 | /************************************************************************** |
| 178 | * |
| 179 | * Ethtool operations |
| 180 | * |
| 181 | ************************************************************************** |
| 182 | */ |
| 183 | |
| 184 | /* Identify device by flashing LEDs */ |
Ben Hutchings | 65f667f | 2008-12-12 21:32:10 -0800 | [diff] [blame] | 185 | static int efx_ethtool_phys_id(struct net_device *net_dev, u32 count) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 186 | { |
Ben Hutchings | 767e468 | 2008-09-01 12:43:14 +0100 | [diff] [blame] | 187 | struct efx_nic *efx = netdev_priv(net_dev); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 188 | |
| 189 | efx->board_info.blink(efx, 1); |
Ben Hutchings | 65f667f | 2008-12-12 21:32:10 -0800 | [diff] [blame] | 190 | set_current_state(TASK_INTERRUPTIBLE); |
| 191 | if (count) |
| 192 | schedule_timeout(count * HZ); |
| 193 | else |
| 194 | schedule(); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 195 | efx->board_info.blink(efx, 0); |
| 196 | return 0; |
| 197 | } |
| 198 | |
| 199 | /* This must be called with rtnl_lock held. */ |
| 200 | int efx_ethtool_get_settings(struct net_device *net_dev, |
| 201 | struct ethtool_cmd *ecmd) |
| 202 | { |
Ben Hutchings | 767e468 | 2008-09-01 12:43:14 +0100 | [diff] [blame] | 203 | struct efx_nic *efx = netdev_priv(net_dev); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 204 | |
| 205 | mutex_lock(&efx->mac_lock); |
Ben Hutchings | 177dfcd | 2008-12-12 21:50:08 -0800 | [diff] [blame] | 206 | efx->phy_op->get_settings(efx, ecmd); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 207 | mutex_unlock(&efx->mac_lock); |
| 208 | |
Ben Hutchings | 177dfcd | 2008-12-12 21:50:08 -0800 | [diff] [blame] | 209 | /* Falcon GMAC does not support 1000Mbps HD */ |
| 210 | ecmd->supported &= ~SUPPORTED_1000baseT_Half; |
| 211 | |
| 212 | return 0; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | /* This must be called with rtnl_lock held. */ |
| 216 | int efx_ethtool_set_settings(struct net_device *net_dev, |
| 217 | struct ethtool_cmd *ecmd) |
| 218 | { |
Ben Hutchings | 767e468 | 2008-09-01 12:43:14 +0100 | [diff] [blame] | 219 | struct efx_nic *efx = netdev_priv(net_dev); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 220 | int rc; |
| 221 | |
Ben Hutchings | 177dfcd | 2008-12-12 21:50:08 -0800 | [diff] [blame] | 222 | /* Falcon GMAC does not support 1000Mbps HD */ |
| 223 | if (ecmd->speed == SPEED_1000 && ecmd->duplex != DUPLEX_FULL) { |
| 224 | EFX_LOG(efx, "rejecting unsupported 1000Mbps HD" |
| 225 | " setting\n"); |
| 226 | return -EINVAL; |
| 227 | } |
| 228 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 229 | mutex_lock(&efx->mac_lock); |
Ben Hutchings | 177dfcd | 2008-12-12 21:50:08 -0800 | [diff] [blame] | 230 | rc = efx->phy_op->set_settings(efx, ecmd); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 231 | mutex_unlock(&efx->mac_lock); |
| 232 | if (!rc) |
| 233 | efx_reconfigure_port(efx); |
| 234 | |
| 235 | return rc; |
| 236 | } |
| 237 | |
| 238 | static void efx_ethtool_get_drvinfo(struct net_device *net_dev, |
| 239 | struct ethtool_drvinfo *info) |
| 240 | { |
Ben Hutchings | 767e468 | 2008-09-01 12:43:14 +0100 | [diff] [blame] | 241 | struct efx_nic *efx = netdev_priv(net_dev); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 242 | |
| 243 | strlcpy(info->driver, EFX_DRIVER_NAME, sizeof(info->driver)); |
| 244 | strlcpy(info->version, EFX_DRIVER_VERSION, sizeof(info->version)); |
| 245 | strlcpy(info->bus_info, pci_name(efx->pci_dev), sizeof(info->bus_info)); |
| 246 | } |
| 247 | |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 248 | /** |
| 249 | * efx_fill_test - fill in an individual self-test entry |
| 250 | * @test_index: Index of the test |
| 251 | * @strings: Ethtool strings, or %NULL |
| 252 | * @data: Ethtool test results, or %NULL |
| 253 | * @test: Pointer to test result (used only if data != %NULL) |
Ben Hutchings | 740ced9 | 2008-12-12 21:41:55 -0800 | [diff] [blame] | 254 | * @unit_format: Unit name format (e.g. "chan\%d") |
| 255 | * @unit_id: Unit id (e.g. 0 for "chan0") |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 256 | * @test_format: Test name format (e.g. "loopback.\%s.tx.sent") |
Ben Hutchings | 740ced9 | 2008-12-12 21:41:55 -0800 | [diff] [blame] | 257 | * @test_id: Test id (e.g. "PHYXS" for "loopback.PHYXS.tx_sent") |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 258 | * |
| 259 | * Fill in an individual self-test entry. |
| 260 | */ |
| 261 | static void efx_fill_test(unsigned int test_index, |
| 262 | struct ethtool_string *strings, u64 *data, |
| 263 | int *test, const char *unit_format, int unit_id, |
| 264 | const char *test_format, const char *test_id) |
| 265 | { |
| 266 | struct ethtool_string unit_str, test_str; |
| 267 | |
| 268 | /* Fill data value, if applicable */ |
| 269 | if (data) |
| 270 | data[test_index] = *test; |
| 271 | |
| 272 | /* Fill string, if applicable */ |
| 273 | if (strings) { |
| 274 | snprintf(unit_str.name, sizeof(unit_str.name), |
| 275 | unit_format, unit_id); |
| 276 | snprintf(test_str.name, sizeof(test_str.name), |
| 277 | test_format, test_id); |
| 278 | snprintf(strings[test_index].name, |
| 279 | sizeof(strings[test_index].name), |
Ben Hutchings | 740ced9 | 2008-12-12 21:41:55 -0800 | [diff] [blame] | 280 | "%-6s %-24s", unit_str.name, test_str.name); |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 281 | } |
| 282 | } |
| 283 | |
| 284 | #define EFX_PORT_NAME "port%d", 0 |
Ben Hutchings | 740ced9 | 2008-12-12 21:41:55 -0800 | [diff] [blame] | 285 | #define EFX_CHANNEL_NAME(_channel) "chan%d", _channel->channel |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 286 | #define EFX_TX_QUEUE_NAME(_tx_queue) "txq%d", _tx_queue->queue |
| 287 | #define EFX_RX_QUEUE_NAME(_rx_queue) "rxq%d", _rx_queue->queue |
| 288 | #define EFX_LOOPBACK_NAME(_mode, _counter) \ |
| 289 | "loopback.%s." _counter, LOOPBACK_MODE_NAME(mode) |
| 290 | |
| 291 | /** |
| 292 | * efx_fill_loopback_test - fill in a block of loopback self-test entries |
| 293 | * @efx: Efx NIC |
| 294 | * @lb_tests: Efx loopback self-test results structure |
| 295 | * @mode: Loopback test mode |
| 296 | * @test_index: Starting index of the test |
| 297 | * @strings: Ethtool strings, or %NULL |
| 298 | * @data: Ethtool test results, or %NULL |
| 299 | */ |
| 300 | static int efx_fill_loopback_test(struct efx_nic *efx, |
| 301 | struct efx_loopback_self_tests *lb_tests, |
| 302 | enum efx_loopback_mode mode, |
| 303 | unsigned int test_index, |
| 304 | struct ethtool_string *strings, u64 *data) |
| 305 | { |
| 306 | struct efx_tx_queue *tx_queue; |
| 307 | |
| 308 | efx_for_each_tx_queue(tx_queue, efx) { |
| 309 | efx_fill_test(test_index++, strings, data, |
| 310 | &lb_tests->tx_sent[tx_queue->queue], |
| 311 | EFX_TX_QUEUE_NAME(tx_queue), |
| 312 | EFX_LOOPBACK_NAME(mode, "tx_sent")); |
| 313 | efx_fill_test(test_index++, strings, data, |
| 314 | &lb_tests->tx_done[tx_queue->queue], |
| 315 | EFX_TX_QUEUE_NAME(tx_queue), |
| 316 | EFX_LOOPBACK_NAME(mode, "tx_done")); |
| 317 | } |
| 318 | efx_fill_test(test_index++, strings, data, |
| 319 | &lb_tests->rx_good, |
| 320 | EFX_PORT_NAME, |
| 321 | EFX_LOOPBACK_NAME(mode, "rx_good")); |
| 322 | efx_fill_test(test_index++, strings, data, |
| 323 | &lb_tests->rx_bad, |
| 324 | EFX_PORT_NAME, |
| 325 | EFX_LOOPBACK_NAME(mode, "rx_bad")); |
| 326 | |
| 327 | return test_index; |
| 328 | } |
| 329 | |
| 330 | /** |
| 331 | * efx_ethtool_fill_self_tests - get self-test details |
| 332 | * @efx: Efx NIC |
| 333 | * @tests: Efx self-test results structure, or %NULL |
| 334 | * @strings: Ethtool strings, or %NULL |
| 335 | * @data: Ethtool test results, or %NULL |
| 336 | */ |
| 337 | static int efx_ethtool_fill_self_tests(struct efx_nic *efx, |
| 338 | struct efx_self_tests *tests, |
| 339 | struct ethtool_string *strings, |
| 340 | u64 *data) |
| 341 | { |
| 342 | struct efx_channel *channel; |
| 343 | unsigned int n = 0; |
| 344 | enum efx_loopback_mode mode; |
| 345 | |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 346 | efx_fill_test(n++, strings, data, &tests->mii, |
| 347 | "core", 0, "mii", NULL); |
| 348 | efx_fill_test(n++, strings, data, &tests->nvram, |
| 349 | "core", 0, "nvram", NULL); |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 350 | efx_fill_test(n++, strings, data, &tests->interrupt, |
| 351 | "core", 0, "interrupt", NULL); |
| 352 | |
| 353 | /* Event queues */ |
| 354 | efx_for_each_channel(channel, efx) { |
| 355 | efx_fill_test(n++, strings, data, |
| 356 | &tests->eventq_dma[channel->channel], |
| 357 | EFX_CHANNEL_NAME(channel), |
| 358 | "eventq.dma", NULL); |
| 359 | efx_fill_test(n++, strings, data, |
| 360 | &tests->eventq_int[channel->channel], |
| 361 | EFX_CHANNEL_NAME(channel), |
| 362 | "eventq.int", NULL); |
| 363 | efx_fill_test(n++, strings, data, |
| 364 | &tests->eventq_poll[channel->channel], |
| 365 | EFX_CHANNEL_NAME(channel), |
| 366 | "eventq.poll", NULL); |
| 367 | } |
| 368 | |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 369 | efx_fill_test(n++, strings, data, &tests->registers, |
| 370 | "core", 0, "registers", NULL); |
| 371 | efx_fill_test(n++, strings, data, &tests->phy, |
| 372 | EFX_PORT_NAME, "phy", NULL); |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 373 | |
| 374 | /* Loopback tests */ |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 375 | for (mode = LOOPBACK_NONE; mode <= LOOPBACK_TEST_MAX; mode++) { |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 376 | if (!(efx->loopback_modes & (1 << mode))) |
| 377 | continue; |
| 378 | n = efx_fill_loopback_test(efx, |
| 379 | &tests->loopback[mode], mode, n, |
| 380 | strings, data); |
| 381 | } |
| 382 | |
| 383 | return n; |
| 384 | } |
| 385 | |
Ben Hutchings | 3594e13 | 2008-09-01 12:48:12 +0100 | [diff] [blame] | 386 | static int efx_ethtool_get_sset_count(struct net_device *net_dev, |
| 387 | int string_set) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 388 | { |
Ben Hutchings | 3594e13 | 2008-09-01 12:48:12 +0100 | [diff] [blame] | 389 | switch (string_set) { |
| 390 | case ETH_SS_STATS: |
| 391 | return EFX_ETHTOOL_NUM_STATS; |
| 392 | case ETH_SS_TEST: |
| 393 | return efx_ethtool_fill_self_tests(netdev_priv(net_dev), |
| 394 | NULL, NULL, NULL); |
| 395 | default: |
| 396 | return -EINVAL; |
| 397 | } |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 398 | } |
| 399 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 400 | static void efx_ethtool_get_strings(struct net_device *net_dev, |
| 401 | u32 string_set, u8 *strings) |
| 402 | { |
Ben Hutchings | 767e468 | 2008-09-01 12:43:14 +0100 | [diff] [blame] | 403 | struct efx_nic *efx = netdev_priv(net_dev); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 404 | struct ethtool_string *ethtool_strings = |
| 405 | (struct ethtool_string *)strings; |
| 406 | int i; |
| 407 | |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 408 | switch (string_set) { |
| 409 | case ETH_SS_STATS: |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 410 | for (i = 0; i < EFX_ETHTOOL_NUM_STATS; i++) |
| 411 | strncpy(ethtool_strings[i].name, |
| 412 | efx_ethtool_stats[i].name, |
| 413 | sizeof(ethtool_strings[i].name)); |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 414 | break; |
| 415 | case ETH_SS_TEST: |
| 416 | efx_ethtool_fill_self_tests(efx, NULL, |
| 417 | ethtool_strings, NULL); |
| 418 | break; |
| 419 | default: |
| 420 | /* No other string sets */ |
| 421 | break; |
| 422 | } |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 423 | } |
| 424 | |
| 425 | static void efx_ethtool_get_stats(struct net_device *net_dev, |
| 426 | struct ethtool_stats *stats, |
| 427 | u64 *data) |
| 428 | { |
Ben Hutchings | 767e468 | 2008-09-01 12:43:14 +0100 | [diff] [blame] | 429 | struct efx_nic *efx = netdev_priv(net_dev); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 430 | struct efx_mac_stats *mac_stats = &efx->mac_stats; |
| 431 | struct efx_ethtool_stat *stat; |
| 432 | struct efx_channel *channel; |
| 433 | int i; |
| 434 | |
| 435 | EFX_BUG_ON_PARANOID(stats->n_stats != EFX_ETHTOOL_NUM_STATS); |
| 436 | |
| 437 | /* Update MAC and NIC statistics */ |
Stephen Hemminger | eeda3fd | 2008-11-19 21:40:23 -0800 | [diff] [blame] | 438 | dev_get_stats(net_dev); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 439 | |
| 440 | /* Fill detailed statistics buffer */ |
| 441 | for (i = 0; i < EFX_ETHTOOL_NUM_STATS; i++) { |
| 442 | stat = &efx_ethtool_stats[i]; |
| 443 | switch (stat->source) { |
| 444 | case EFX_ETHTOOL_STAT_SOURCE_mac_stats: |
| 445 | data[i] = stat->get_stat((void *)mac_stats + |
| 446 | stat->offset); |
| 447 | break; |
| 448 | case EFX_ETHTOOL_STAT_SOURCE_nic: |
| 449 | data[i] = stat->get_stat((void *)efx + stat->offset); |
| 450 | break; |
| 451 | case EFX_ETHTOOL_STAT_SOURCE_channel: |
| 452 | data[i] = 0; |
| 453 | efx_for_each_channel(channel, efx) |
| 454 | data[i] += stat->get_stat((void *)channel + |
| 455 | stat->offset); |
| 456 | break; |
| 457 | } |
| 458 | } |
| 459 | } |
| 460 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 461 | static int efx_ethtool_set_rx_csum(struct net_device *net_dev, u32 enable) |
| 462 | { |
Ben Hutchings | 767e468 | 2008-09-01 12:43:14 +0100 | [diff] [blame] | 463 | struct efx_nic *efx = netdev_priv(net_dev); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 464 | |
| 465 | /* No way to stop the hardware doing the checks; we just |
| 466 | * ignore the result. |
| 467 | */ |
Ben Hutchings | dc8cfa5 | 2008-09-01 12:46:50 +0100 | [diff] [blame] | 468 | efx->rx_checksum_enabled = !!enable; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 469 | |
| 470 | return 0; |
| 471 | } |
| 472 | |
| 473 | static u32 efx_ethtool_get_rx_csum(struct net_device *net_dev) |
| 474 | { |
Ben Hutchings | 767e468 | 2008-09-01 12:43:14 +0100 | [diff] [blame] | 475 | struct efx_nic *efx = netdev_priv(net_dev); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 476 | |
| 477 | return efx->rx_checksum_enabled; |
| 478 | } |
| 479 | |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 480 | static void efx_ethtool_self_test(struct net_device *net_dev, |
| 481 | struct ethtool_test *test, u64 *data) |
| 482 | { |
Ben Hutchings | 767e468 | 2008-09-01 12:43:14 +0100 | [diff] [blame] | 483 | struct efx_nic *efx = netdev_priv(net_dev); |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 484 | struct efx_self_tests efx_tests; |
| 485 | int offline, already_up; |
| 486 | int rc; |
| 487 | |
| 488 | ASSERT_RTNL(); |
| 489 | if (efx->state != STATE_RUNNING) { |
| 490 | rc = -EIO; |
| 491 | goto fail1; |
| 492 | } |
| 493 | |
| 494 | /* We need rx buffers and interrupts. */ |
| 495 | already_up = (efx->net_dev->flags & IFF_UP); |
| 496 | if (!already_up) { |
| 497 | rc = dev_open(efx->net_dev); |
| 498 | if (rc) { |
| 499 | EFX_ERR(efx, "failed opening device.\n"); |
| 500 | goto fail2; |
| 501 | } |
| 502 | } |
| 503 | |
| 504 | memset(&efx_tests, 0, sizeof(efx_tests)); |
| 505 | offline = (test->flags & ETH_TEST_FL_OFFLINE); |
| 506 | |
| 507 | /* Perform online self tests first */ |
| 508 | rc = efx_online_test(efx, &efx_tests); |
| 509 | if (rc) |
| 510 | goto out; |
| 511 | |
| 512 | /* Perform offline tests only if online tests passed */ |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 513 | if (offline) |
Ben Hutchings | bc3c90a | 2008-09-01 12:48:46 +0100 | [diff] [blame] | 514 | rc = efx_offline_test(efx, &efx_tests, |
| 515 | efx->loopback_modes); |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 516 | |
| 517 | out: |
| 518 | if (!already_up) |
| 519 | dev_close(efx->net_dev); |
| 520 | |
| 521 | EFX_LOG(efx, "%s all %sline self-tests\n", |
| 522 | rc == 0 ? "passed" : "failed", offline ? "off" : "on"); |
| 523 | |
| 524 | fail2: |
| 525 | fail1: |
| 526 | /* Fill ethtool results structures */ |
| 527 | efx_ethtool_fill_self_tests(efx, &efx_tests, NULL, data); |
| 528 | if (rc) |
| 529 | test->flags |= ETH_TEST_FL_FAILED; |
| 530 | } |
| 531 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 532 | /* Restart autonegotiation */ |
| 533 | static int efx_ethtool_nway_reset(struct net_device *net_dev) |
| 534 | { |
Ben Hutchings | 767e468 | 2008-09-01 12:43:14 +0100 | [diff] [blame] | 535 | struct efx_nic *efx = netdev_priv(net_dev); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 536 | |
| 537 | return mii_nway_restart(&efx->mii); |
| 538 | } |
| 539 | |
| 540 | static u32 efx_ethtool_get_link(struct net_device *net_dev) |
| 541 | { |
Ben Hutchings | 767e468 | 2008-09-01 12:43:14 +0100 | [diff] [blame] | 542 | struct efx_nic *efx = netdev_priv(net_dev); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 543 | |
| 544 | return efx->link_up; |
| 545 | } |
| 546 | |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 547 | static int efx_ethtool_get_eeprom_len(struct net_device *net_dev) |
| 548 | { |
| 549 | struct efx_nic *efx = netdev_priv(net_dev); |
| 550 | struct efx_spi_device *spi = efx->spi_eeprom; |
| 551 | |
| 552 | if (!spi) |
| 553 | return 0; |
Ben Hutchings | 0a95f56 | 2008-11-04 20:33:11 +0000 | [diff] [blame] | 554 | return min(spi->size, EFX_EEPROM_BOOTCONFIG_END) - |
| 555 | min(spi->size, EFX_EEPROM_BOOTCONFIG_START); |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 556 | } |
| 557 | |
| 558 | static int efx_ethtool_get_eeprom(struct net_device *net_dev, |
| 559 | struct ethtool_eeprom *eeprom, u8 *buf) |
| 560 | { |
| 561 | struct efx_nic *efx = netdev_priv(net_dev); |
| 562 | struct efx_spi_device *spi = efx->spi_eeprom; |
| 563 | size_t len; |
| 564 | int rc; |
| 565 | |
Ben Hutchings | f415072 | 2008-11-04 20:34:28 +0000 | [diff] [blame] | 566 | mutex_lock(&efx->spi_lock); |
Ben Hutchings | 0a95f56 | 2008-11-04 20:33:11 +0000 | [diff] [blame] | 567 | rc = falcon_spi_read(spi, eeprom->offset + EFX_EEPROM_BOOTCONFIG_START, |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 568 | eeprom->len, &len, buf); |
Ben Hutchings | f415072 | 2008-11-04 20:34:28 +0000 | [diff] [blame] | 569 | mutex_unlock(&efx->spi_lock); |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 570 | eeprom->magic = EFX_ETHTOOL_EEPROM_MAGIC; |
| 571 | eeprom->len = len; |
| 572 | return rc; |
| 573 | } |
| 574 | |
| 575 | static int efx_ethtool_set_eeprom(struct net_device *net_dev, |
| 576 | struct ethtool_eeprom *eeprom, u8 *buf) |
| 577 | { |
| 578 | struct efx_nic *efx = netdev_priv(net_dev); |
| 579 | struct efx_spi_device *spi = efx->spi_eeprom; |
| 580 | size_t len; |
| 581 | int rc; |
| 582 | |
| 583 | if (eeprom->magic != EFX_ETHTOOL_EEPROM_MAGIC) |
| 584 | return -EINVAL; |
| 585 | |
Ben Hutchings | f415072 | 2008-11-04 20:34:28 +0000 | [diff] [blame] | 586 | mutex_lock(&efx->spi_lock); |
Ben Hutchings | 0a95f56 | 2008-11-04 20:33:11 +0000 | [diff] [blame] | 587 | rc = falcon_spi_write(spi, eeprom->offset + EFX_EEPROM_BOOTCONFIG_START, |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 588 | eeprom->len, &len, buf); |
Ben Hutchings | f415072 | 2008-11-04 20:34:28 +0000 | [diff] [blame] | 589 | mutex_unlock(&efx->spi_lock); |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 590 | eeprom->len = len; |
| 591 | return rc; |
| 592 | } |
| 593 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 594 | static int efx_ethtool_get_coalesce(struct net_device *net_dev, |
| 595 | struct ethtool_coalesce *coalesce) |
| 596 | { |
Ben Hutchings | 767e468 | 2008-09-01 12:43:14 +0100 | [diff] [blame] | 597 | struct efx_nic *efx = netdev_priv(net_dev); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 598 | struct efx_tx_queue *tx_queue; |
| 599 | struct efx_rx_queue *rx_queue; |
| 600 | struct efx_channel *channel; |
| 601 | |
| 602 | memset(coalesce, 0, sizeof(*coalesce)); |
| 603 | |
| 604 | /* Find lowest IRQ moderation across all used TX queues */ |
| 605 | coalesce->tx_coalesce_usecs_irq = ~((u32) 0); |
| 606 | efx_for_each_tx_queue(tx_queue, efx) { |
| 607 | channel = tx_queue->channel; |
| 608 | if (channel->irq_moderation < coalesce->tx_coalesce_usecs_irq) { |
| 609 | if (channel->used_flags != EFX_USED_BY_RX_TX) |
| 610 | coalesce->tx_coalesce_usecs_irq = |
| 611 | channel->irq_moderation; |
| 612 | else |
| 613 | coalesce->tx_coalesce_usecs_irq = 0; |
| 614 | } |
| 615 | } |
| 616 | |
| 617 | /* Find lowest IRQ moderation across all used RX queues */ |
| 618 | coalesce->rx_coalesce_usecs_irq = ~((u32) 0); |
| 619 | efx_for_each_rx_queue(rx_queue, efx) { |
| 620 | channel = rx_queue->channel; |
| 621 | if (channel->irq_moderation < coalesce->rx_coalesce_usecs_irq) |
| 622 | coalesce->rx_coalesce_usecs_irq = |
| 623 | channel->irq_moderation; |
| 624 | } |
| 625 | |
| 626 | return 0; |
| 627 | } |
| 628 | |
| 629 | /* Set coalescing parameters |
| 630 | * The difficulties occur for shared channels |
| 631 | */ |
| 632 | static int efx_ethtool_set_coalesce(struct net_device *net_dev, |
| 633 | struct ethtool_coalesce *coalesce) |
| 634 | { |
Ben Hutchings | 767e468 | 2008-09-01 12:43:14 +0100 | [diff] [blame] | 635 | struct efx_nic *efx = netdev_priv(net_dev); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 636 | struct efx_channel *channel; |
| 637 | struct efx_tx_queue *tx_queue; |
| 638 | unsigned tx_usecs, rx_usecs; |
| 639 | |
| 640 | if (coalesce->use_adaptive_rx_coalesce || |
| 641 | coalesce->use_adaptive_tx_coalesce) |
| 642 | return -EOPNOTSUPP; |
| 643 | |
| 644 | if (coalesce->rx_coalesce_usecs || coalesce->tx_coalesce_usecs) { |
| 645 | EFX_ERR(efx, "invalid coalescing setting. " |
| 646 | "Only rx/tx_coalesce_usecs_irq are supported\n"); |
| 647 | return -EOPNOTSUPP; |
| 648 | } |
| 649 | |
| 650 | rx_usecs = coalesce->rx_coalesce_usecs_irq; |
| 651 | tx_usecs = coalesce->tx_coalesce_usecs_irq; |
| 652 | |
| 653 | /* If the channel is shared only allow RX parameters to be set */ |
| 654 | efx_for_each_tx_queue(tx_queue, efx) { |
| 655 | if ((tx_queue->channel->used_flags == EFX_USED_BY_RX_TX) && |
| 656 | tx_usecs) { |
| 657 | EFX_ERR(efx, "Channel is shared. " |
| 658 | "Only RX coalescing may be set\n"); |
| 659 | return -EOPNOTSUPP; |
| 660 | } |
| 661 | } |
| 662 | |
| 663 | efx_init_irq_moderation(efx, tx_usecs, rx_usecs); |
| 664 | |
| 665 | /* Reset channel to pick up new moderation value. Note that |
| 666 | * this may change the value of the irq_moderation field |
| 667 | * (e.g. to allow for hardware timer granularity). |
| 668 | */ |
| 669 | efx_for_each_channel(channel, efx) |
| 670 | falcon_set_int_moderation(channel); |
| 671 | |
| 672 | return 0; |
| 673 | } |
| 674 | |
| 675 | static int efx_ethtool_set_pauseparam(struct net_device *net_dev, |
| 676 | struct ethtool_pauseparam *pause) |
| 677 | { |
Ben Hutchings | 767e468 | 2008-09-01 12:43:14 +0100 | [diff] [blame] | 678 | struct efx_nic *efx = netdev_priv(net_dev); |
Ben Hutchings | 04cc8ca | 2008-12-12 21:50:46 -0800 | [diff] [blame^] | 679 | enum efx_fc_type wanted_fc; |
| 680 | bool reset; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 681 | |
Ben Hutchings | 04cc8ca | 2008-12-12 21:50:46 -0800 | [diff] [blame^] | 682 | wanted_fc = ((pause->rx_pause ? EFX_FC_RX : 0) | |
| 683 | (pause->tx_pause ? EFX_FC_TX : 0) | |
| 684 | (pause->autoneg ? EFX_FC_AUTO : 0)); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 685 | |
Ben Hutchings | 04cc8ca | 2008-12-12 21:50:46 -0800 | [diff] [blame^] | 686 | if ((wanted_fc & EFX_FC_TX) && !(wanted_fc & EFX_FC_RX)) { |
| 687 | EFX_LOG(efx, "Flow control unsupported: tx ON rx OFF\n"); |
| 688 | return -EINVAL; |
| 689 | } |
| 690 | |
| 691 | if (!(efx->phy_op->mmds & DEV_PRESENT_BIT(MDIO_MMD_AN)) && |
| 692 | (wanted_fc & EFX_FC_AUTO)) { |
| 693 | EFX_LOG(efx, "PHY does not support flow control " |
| 694 | "autonegotiation\n"); |
| 695 | return -EINVAL; |
| 696 | } |
| 697 | |
| 698 | /* TX flow control may automatically turn itself off if the |
| 699 | * link partner (intermittently) stops responding to pause |
| 700 | * frames. There isn't any indication that this has happened, |
| 701 | * so the best we do is leave it up to the user to spot this |
| 702 | * and fix it be cycling transmit flow control on this end. */ |
| 703 | reset = (wanted_fc & EFX_FC_TX) && !(efx->wanted_fc & EFX_FC_TX); |
| 704 | if (EFX_WORKAROUND_11482(efx) && reset) { |
| 705 | if (falcon_rev(efx) >= FALCON_REV_B0) { |
| 706 | /* Recover by resetting the EM block */ |
| 707 | if (efx->link_up) |
| 708 | falcon_drain_tx_fifo(efx); |
| 709 | } else { |
| 710 | /* Schedule a reset to recover */ |
| 711 | efx_schedule_reset(efx, RESET_TYPE_INVISIBLE); |
| 712 | } |
| 713 | } |
| 714 | |
| 715 | /* Try to push the pause parameters */ |
| 716 | mutex_lock(&efx->mac_lock); |
| 717 | |
| 718 | efx->wanted_fc = wanted_fc; |
| 719 | mdio_clause45_set_pause(efx); |
| 720 | __efx_reconfigure_port(efx); |
| 721 | |
| 722 | mutex_unlock(&efx->mac_lock); |
| 723 | |
Ben Hutchings | 177dfcd | 2008-12-12 21:50:08 -0800 | [diff] [blame] | 724 | return 0; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 725 | } |
| 726 | |
| 727 | static void efx_ethtool_get_pauseparam(struct net_device *net_dev, |
| 728 | struct ethtool_pauseparam *pause) |
| 729 | { |
Ben Hutchings | 767e468 | 2008-09-01 12:43:14 +0100 | [diff] [blame] | 730 | struct efx_nic *efx = netdev_priv(net_dev); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 731 | |
Ben Hutchings | 04cc8ca | 2008-12-12 21:50:46 -0800 | [diff] [blame^] | 732 | pause->rx_pause = !!(efx->wanted_fc & EFX_FC_RX); |
| 733 | pause->tx_pause = !!(efx->wanted_fc & EFX_FC_TX); |
| 734 | pause->autoneg = !!(efx->wanted_fc & EFX_FC_AUTO); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 735 | } |
| 736 | |
| 737 | |
| 738 | struct ethtool_ops efx_ethtool_ops = { |
| 739 | .get_settings = efx_ethtool_get_settings, |
| 740 | .set_settings = efx_ethtool_set_settings, |
| 741 | .get_drvinfo = efx_ethtool_get_drvinfo, |
| 742 | .nway_reset = efx_ethtool_nway_reset, |
| 743 | .get_link = efx_ethtool_get_link, |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 744 | .get_eeprom_len = efx_ethtool_get_eeprom_len, |
| 745 | .get_eeprom = efx_ethtool_get_eeprom, |
| 746 | .set_eeprom = efx_ethtool_set_eeprom, |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 747 | .get_coalesce = efx_ethtool_get_coalesce, |
| 748 | .set_coalesce = efx_ethtool_set_coalesce, |
| 749 | .get_pauseparam = efx_ethtool_get_pauseparam, |
| 750 | .set_pauseparam = efx_ethtool_set_pauseparam, |
| 751 | .get_rx_csum = efx_ethtool_get_rx_csum, |
| 752 | .set_rx_csum = efx_ethtool_set_rx_csum, |
| 753 | .get_tx_csum = ethtool_op_get_tx_csum, |
Ben Hutchings | 60ac106 | 2008-09-01 12:44:59 +0100 | [diff] [blame] | 754 | .set_tx_csum = ethtool_op_set_tx_csum, |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 755 | .get_sg = ethtool_op_get_sg, |
| 756 | .set_sg = ethtool_op_set_sg, |
Ben Hutchings | b9b39b6 | 2008-05-07 12:51:12 +0100 | [diff] [blame] | 757 | .get_tso = ethtool_op_get_tso, |
Ben Hutchings | 60ac106 | 2008-09-01 12:44:59 +0100 | [diff] [blame] | 758 | .set_tso = ethtool_op_set_tso, |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 759 | .get_flags = ethtool_op_get_flags, |
| 760 | .set_flags = ethtool_op_set_flags, |
Ben Hutchings | 3594e13 | 2008-09-01 12:48:12 +0100 | [diff] [blame] | 761 | .get_sset_count = efx_ethtool_get_sset_count, |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 762 | .self_test = efx_ethtool_self_test, |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 763 | .get_strings = efx_ethtool_get_strings, |
| 764 | .phys_id = efx_ethtool_phys_id, |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 765 | .get_ethtool_stats = efx_ethtool_get_stats, |
| 766 | }; |