Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | |
Auke Kok | 0abb6eb | 2006-09-27 12:53:14 -0700 | [diff] [blame] | 3 | Intel PRO/10GbE Linux driver |
Jesse Brandeburg | f731a9e | 2008-07-08 15:53:09 -0700 | [diff] [blame] | 4 | Copyright(c) 1999 - 2008 Intel Corporation. |
Auke Kok | 0abb6eb | 2006-09-27 12:53:14 -0700 | [diff] [blame] | 5 | |
| 6 | This program is free software; you can redistribute it and/or modify it |
| 7 | under the terms and conditions of the GNU General Public License, |
| 8 | version 2, as published by the Free Software Foundation. |
| 9 | |
| 10 | This program is distributed in the hope it will be useful, but WITHOUT |
| 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | more details. |
Auke Kok | 0abb6eb | 2006-09-27 12:53:14 -0700 | [diff] [blame] | 14 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | You should have received a copy of the GNU General Public License along with |
Auke Kok | 0abb6eb | 2006-09-27 12:53:14 -0700 | [diff] [blame] | 16 | this program; if not, write to the Free Software Foundation, Inc., |
| 17 | 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | |
| 19 | The full GNU General Public License is included in this distribution in |
| 20 | the file called "COPYING". |
| 21 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | Contact Information: |
| 23 | Linux NICS <linux.nics@intel.com> |
Auke Kok | 0abb6eb | 2006-09-27 12:53:14 -0700 | [diff] [blame] | 24 | e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 26 | |
| 27 | *******************************************************************************/ |
| 28 | |
| 29 | /* ethtool support for ixgb */ |
| 30 | |
| 31 | #include "ixgb.h" |
| 32 | |
| 33 | #include <asm/uaccess.h> |
| 34 | |
Auke Kok | c85fd6f | 2006-05-23 10:30:02 -0700 | [diff] [blame] | 35 | #define IXGB_ALL_RAR_ENTRIES 16 |
| 36 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | struct ixgb_stats { |
| 38 | char stat_string[ETH_GSTRING_LEN]; |
| 39 | int sizeof_stat; |
| 40 | int stat_offset; |
| 41 | }; |
| 42 | |
Julia Lawall | 030ed68 | 2008-02-11 09:25:40 -0800 | [diff] [blame] | 43 | #define IXGB_STAT(m) FIELD_SIZEOF(struct ixgb_adapter, m), \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | offsetof(struct ixgb_adapter, m) |
Ajit Khaparde | 0cdc036 | 2009-10-07 02:46:59 +0000 | [diff] [blame] | 45 | #define IXGB_NETDEV_STAT(m) FIELD_SIZEOF(struct net_device, m), \ |
| 46 | offsetof(struct net_device, m) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | static struct ixgb_stats ixgb_gstrings_stats[] = { |
Ajit Khaparde | 0cdc036 | 2009-10-07 02:46:59 +0000 | [diff] [blame] | 48 | {"rx_packets", IXGB_NETDEV_STAT(stats.rx_packets)}, |
| 49 | {"tx_packets", IXGB_NETDEV_STAT(stats.tx_packets)}, |
| 50 | {"rx_bytes", IXGB_NETDEV_STAT(stats.rx_bytes)}, |
| 51 | {"tx_bytes", IXGB_NETDEV_STAT(stats.tx_bytes)}, |
| 52 | {"rx_errors", IXGB_NETDEV_STAT(stats.rx_errors)}, |
| 53 | {"tx_errors", IXGB_NETDEV_STAT(stats.tx_errors)}, |
| 54 | {"rx_dropped", IXGB_NETDEV_STAT(stats.rx_dropped)}, |
| 55 | {"tx_dropped", IXGB_NETDEV_STAT(stats.tx_dropped)}, |
| 56 | {"multicast", IXGB_NETDEV_STAT(stats.multicast)}, |
| 57 | {"collisions", IXGB_NETDEV_STAT(stats.collisions)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | |
Ajit Khaparde | 0cdc036 | 2009-10-07 02:46:59 +0000 | [diff] [blame] | 59 | /* { "rx_length_errors", IXGB_NETDEV_STAT(stats.rx_length_errors) }, */ |
| 60 | {"rx_over_errors", IXGB_NETDEV_STAT(stats.rx_over_errors)}, |
| 61 | {"rx_crc_errors", IXGB_NETDEV_STAT(stats.rx_crc_errors)}, |
| 62 | {"rx_frame_errors", IXGB_NETDEV_STAT(stats.rx_frame_errors)}, |
Auke Kok | ac0b350 | 2008-02-21 15:10:41 -0800 | [diff] [blame] | 63 | {"rx_no_buffer_count", IXGB_STAT(stats.rnbc)}, |
Ajit Khaparde | 0cdc036 | 2009-10-07 02:46:59 +0000 | [diff] [blame] | 64 | {"rx_fifo_errors", IXGB_NETDEV_STAT(stats.rx_fifo_errors)}, |
| 65 | {"rx_missed_errors", IXGB_NETDEV_STAT(stats.rx_missed_errors)}, |
| 66 | {"tx_aborted_errors", IXGB_NETDEV_STAT(stats.tx_aborted_errors)}, |
| 67 | {"tx_carrier_errors", IXGB_NETDEV_STAT(stats.tx_carrier_errors)}, |
| 68 | {"tx_fifo_errors", IXGB_NETDEV_STAT(stats.tx_fifo_errors)}, |
| 69 | {"tx_heartbeat_errors", IXGB_NETDEV_STAT(stats.tx_heartbeat_errors)}, |
| 70 | {"tx_window_errors", IXGB_NETDEV_STAT(stats.tx_window_errors)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | {"tx_deferred_ok", IXGB_STAT(stats.dc)}, |
Auke Kok | 9b8118d | 2006-05-23 10:35:04 -0700 | [diff] [blame] | 72 | {"tx_timeout_count", IXGB_STAT(tx_timeout_count) }, |
Jesse Brandeburg | dfd341e | 2007-01-06 09:51:38 -0800 | [diff] [blame] | 73 | {"tx_restart_queue", IXGB_STAT(restart_queue) }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | {"rx_long_length_errors", IXGB_STAT(stats.roc)}, |
| 75 | {"rx_short_length_errors", IXGB_STAT(stats.ruc)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | {"tx_tcp_seg_good", IXGB_STAT(stats.tsctc)}, |
| 77 | {"tx_tcp_seg_failed", IXGB_STAT(stats.tsctfc)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | {"rx_flow_control_xon", IXGB_STAT(stats.xonrxc)}, |
| 79 | {"rx_flow_control_xoff", IXGB_STAT(stats.xoffrxc)}, |
| 80 | {"tx_flow_control_xon", IXGB_STAT(stats.xontxc)}, |
| 81 | {"tx_flow_control_xoff", IXGB_STAT(stats.xofftxc)}, |
| 82 | {"rx_csum_offload_good", IXGB_STAT(hw_csum_rx_good)}, |
| 83 | {"rx_csum_offload_errors", IXGB_STAT(hw_csum_rx_error)}, |
| 84 | {"tx_csum_offload_good", IXGB_STAT(hw_csum_tx_good)}, |
| 85 | {"tx_csum_offload_errors", IXGB_STAT(hw_csum_tx_error)} |
| 86 | }; |
| 87 | |
Denis Cheng | ff8ac60 | 2007-09-02 18:30:18 +0800 | [diff] [blame] | 88 | #define IXGB_STATS_LEN ARRAY_SIZE(ixgb_gstrings_stats) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | |
| 90 | static int |
| 91 | ixgb_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) |
| 92 | { |
Malli Chilakala | 8908c6c | 2005-08-11 13:58:40 -0700 | [diff] [blame] | 93 | struct ixgb_adapter *adapter = netdev_priv(netdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | |
| 95 | ecmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE); |
Malli Chilakala | db0baca | 2005-08-11 13:59:20 -0700 | [diff] [blame] | 96 | ecmd->advertising = (ADVERTISED_10000baseT_Full | ADVERTISED_FIBRE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | ecmd->port = PORT_FIBRE; |
| 98 | ecmd->transceiver = XCVR_EXTERNAL; |
| 99 | |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 100 | if (netif_carrier_ok(adapter->netdev)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | ecmd->speed = SPEED_10000; |
| 102 | ecmd->duplex = DUPLEX_FULL; |
| 103 | } else { |
| 104 | ecmd->speed = -1; |
| 105 | ecmd->duplex = -1; |
| 106 | } |
| 107 | |
| 108 | ecmd->autoneg = AUTONEG_DISABLE; |
| 109 | return 0; |
| 110 | } |
| 111 | |
Auke Kok | 4de17c8 | 2006-05-23 10:29:46 -0700 | [diff] [blame] | 112 | static void ixgb_set_speed_duplex(struct net_device *netdev) |
| 113 | { |
| 114 | struct ixgb_adapter *adapter = netdev_priv(netdev); |
| 115 | /* be optimistic about our link, since we were up before */ |
| 116 | adapter->link_speed = 10000; |
| 117 | adapter->link_duplex = FULL_DUPLEX; |
| 118 | netif_carrier_on(netdev); |
| 119 | netif_wake_queue(netdev); |
| 120 | } |
| 121 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | static int |
| 123 | ixgb_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) |
| 124 | { |
Malli Chilakala | 8908c6c | 2005-08-11 13:58:40 -0700 | [diff] [blame] | 125 | struct ixgb_adapter *adapter = netdev_priv(netdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 127 | if (ecmd->autoneg == AUTONEG_ENABLE || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | ecmd->speed + ecmd->duplex != SPEED_10000 + DUPLEX_FULL) |
| 129 | return -EINVAL; |
Jesse Brandeburg | 0060c07 | 2008-07-08 15:52:23 -0700 | [diff] [blame] | 130 | |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 131 | if (netif_running(adapter->netdev)) { |
Joe Perches | 446490c | 2008-03-21 11:06:37 -0700 | [diff] [blame] | 132 | ixgb_down(adapter, true); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | ixgb_reset(adapter); |
| 134 | ixgb_up(adapter); |
Auke Kok | 4de17c8 | 2006-05-23 10:29:46 -0700 | [diff] [blame] | 135 | ixgb_set_speed_duplex(netdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | } else |
| 137 | ixgb_reset(adapter); |
| 138 | |
| 139 | return 0; |
| 140 | } |
| 141 | |
| 142 | static void |
| 143 | ixgb_get_pauseparam(struct net_device *netdev, |
| 144 | struct ethtool_pauseparam *pause) |
| 145 | { |
Malli Chilakala | 8908c6c | 2005-08-11 13:58:40 -0700 | [diff] [blame] | 146 | struct ixgb_adapter *adapter = netdev_priv(netdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | struct ixgb_hw *hw = &adapter->hw; |
Jesse Brandeburg | 0060c07 | 2008-07-08 15:52:23 -0700 | [diff] [blame] | 148 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | pause->autoneg = AUTONEG_DISABLE; |
Jesse Brandeburg | 0060c07 | 2008-07-08 15:52:23 -0700 | [diff] [blame] | 150 | |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 151 | if (hw->fc.type == ixgb_fc_rx_pause) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | pause->rx_pause = 1; |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 153 | else if (hw->fc.type == ixgb_fc_tx_pause) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | pause->tx_pause = 1; |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 155 | else if (hw->fc.type == ixgb_fc_full) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | pause->rx_pause = 1; |
| 157 | pause->tx_pause = 1; |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | static int |
| 162 | ixgb_set_pauseparam(struct net_device *netdev, |
| 163 | struct ethtool_pauseparam *pause) |
| 164 | { |
Malli Chilakala | 8908c6c | 2005-08-11 13:58:40 -0700 | [diff] [blame] | 165 | struct ixgb_adapter *adapter = netdev_priv(netdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | struct ixgb_hw *hw = &adapter->hw; |
Jesse Brandeburg | 0060c07 | 2008-07-08 15:52:23 -0700 | [diff] [blame] | 167 | |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 168 | if (pause->autoneg == AUTONEG_ENABLE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | return -EINVAL; |
| 170 | |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 171 | if (pause->rx_pause && pause->tx_pause) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | hw->fc.type = ixgb_fc_full; |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 173 | else if (pause->rx_pause && !pause->tx_pause) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | hw->fc.type = ixgb_fc_rx_pause; |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 175 | else if (!pause->rx_pause && pause->tx_pause) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | hw->fc.type = ixgb_fc_tx_pause; |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 177 | else if (!pause->rx_pause && !pause->tx_pause) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | hw->fc.type = ixgb_fc_none; |
| 179 | |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 180 | if (netif_running(adapter->netdev)) { |
Joe Perches | 446490c | 2008-03-21 11:06:37 -0700 | [diff] [blame] | 181 | ixgb_down(adapter, true); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | ixgb_up(adapter); |
Auke Kok | 4de17c8 | 2006-05-23 10:29:46 -0700 | [diff] [blame] | 183 | ixgb_set_speed_duplex(netdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | } else |
| 185 | ixgb_reset(adapter); |
Jesse Brandeburg | 0060c07 | 2008-07-08 15:52:23 -0700 | [diff] [blame] | 186 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | return 0; |
| 188 | } |
| 189 | |
Joe Perches | 222441a | 2008-04-03 10:06:25 -0700 | [diff] [blame] | 190 | static u32 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | ixgb_get_rx_csum(struct net_device *netdev) |
| 192 | { |
Malli Chilakala | 8908c6c | 2005-08-11 13:58:40 -0700 | [diff] [blame] | 193 | struct ixgb_adapter *adapter = netdev_priv(netdev); |
| 194 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | return adapter->rx_csum; |
| 196 | } |
| 197 | |
| 198 | static int |
Joe Perches | 222441a | 2008-04-03 10:06:25 -0700 | [diff] [blame] | 199 | ixgb_set_rx_csum(struct net_device *netdev, u32 data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | { |
Malli Chilakala | 8908c6c | 2005-08-11 13:58:40 -0700 | [diff] [blame] | 201 | struct ixgb_adapter *adapter = netdev_priv(netdev); |
| 202 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | adapter->rx_csum = data; |
| 204 | |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 205 | if (netif_running(netdev)) { |
Joe Perches | 446490c | 2008-03-21 11:06:37 -0700 | [diff] [blame] | 206 | ixgb_down(adapter, true); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | ixgb_up(adapter); |
Auke Kok | 4de17c8 | 2006-05-23 10:29:46 -0700 | [diff] [blame] | 208 | ixgb_set_speed_duplex(netdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | } else |
| 210 | ixgb_reset(adapter); |
| 211 | return 0; |
| 212 | } |
Jesse Brandeburg | 0060c07 | 2008-07-08 15:52:23 -0700 | [diff] [blame] | 213 | |
Joe Perches | 222441a | 2008-04-03 10:06:25 -0700 | [diff] [blame] | 214 | static u32 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | ixgb_get_tx_csum(struct net_device *netdev) |
| 216 | { |
| 217 | return (netdev->features & NETIF_F_HW_CSUM) != 0; |
| 218 | } |
| 219 | |
| 220 | static int |
Joe Perches | 222441a | 2008-04-03 10:06:25 -0700 | [diff] [blame] | 221 | ixgb_set_tx_csum(struct net_device *netdev, u32 data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | { |
| 223 | if (data) |
| 224 | netdev->features |= NETIF_F_HW_CSUM; |
| 225 | else |
| 226 | netdev->features &= ~NETIF_F_HW_CSUM; |
| 227 | |
| 228 | return 0; |
| 229 | } |
| 230 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | static int |
Joe Perches | 222441a | 2008-04-03 10:06:25 -0700 | [diff] [blame] | 232 | ixgb_set_tso(struct net_device *netdev, u32 data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | { |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 234 | if (data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | netdev->features |= NETIF_F_TSO; |
| 236 | else |
| 237 | netdev->features &= ~NETIF_F_TSO; |
| 238 | return 0; |
Jesse Brandeburg | 0060c07 | 2008-07-08 15:52:23 -0700 | [diff] [blame] | 239 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | |
Joe Perches | 222441a | 2008-04-03 10:06:25 -0700 | [diff] [blame] | 241 | static u32 |
Auke Kok | ec9c3f5 | 2006-05-23 10:34:59 -0700 | [diff] [blame] | 242 | ixgb_get_msglevel(struct net_device *netdev) |
| 243 | { |
Auke Kok | 2594307 | 2006-05-26 09:35:57 -0700 | [diff] [blame] | 244 | struct ixgb_adapter *adapter = netdev_priv(netdev); |
Auke Kok | ec9c3f5 | 2006-05-23 10:34:59 -0700 | [diff] [blame] | 245 | return adapter->msg_enable; |
| 246 | } |
| 247 | |
| 248 | static void |
Joe Perches | 222441a | 2008-04-03 10:06:25 -0700 | [diff] [blame] | 249 | ixgb_set_msglevel(struct net_device *netdev, u32 data) |
Auke Kok | ec9c3f5 | 2006-05-23 10:34:59 -0700 | [diff] [blame] | 250 | { |
Auke Kok | 2594307 | 2006-05-26 09:35:57 -0700 | [diff] [blame] | 251 | struct ixgb_adapter *adapter = netdev_priv(netdev); |
Auke Kok | ec9c3f5 | 2006-05-23 10:34:59 -0700 | [diff] [blame] | 252 | adapter->msg_enable = data; |
| 253 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | #define IXGB_GET_STAT(_A_, _R_) _A_->stats._R_ |
| 255 | |
Jesse Brandeburg | 0060c07 | 2008-07-08 15:52:23 -0700 | [diff] [blame] | 256 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | ixgb_get_regs_len(struct net_device *netdev) |
| 258 | { |
Joe Perches | 222441a | 2008-04-03 10:06:25 -0700 | [diff] [blame] | 259 | #define IXGB_REG_DUMP_LEN 136*sizeof(u32) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | return IXGB_REG_DUMP_LEN; |
| 261 | } |
| 262 | |
| 263 | static void |
| 264 | ixgb_get_regs(struct net_device *netdev, |
| 265 | struct ethtool_regs *regs, void *p) |
| 266 | { |
Malli Chilakala | 8908c6c | 2005-08-11 13:58:40 -0700 | [diff] [blame] | 267 | struct ixgb_adapter *adapter = netdev_priv(netdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | struct ixgb_hw *hw = &adapter->hw; |
Joe Perches | 222441a | 2008-04-03 10:06:25 -0700 | [diff] [blame] | 269 | u32 *reg = p; |
| 270 | u32 *reg_start = reg; |
| 271 | u8 i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | |
Malli Chilakala | 5e3c30d | 2005-04-28 19:04:07 -0700 | [diff] [blame] | 273 | /* the 1 (one) below indicates an attempt at versioning, if the |
Malli Chilakala | ab707da | 2005-08-11 13:59:59 -0700 | [diff] [blame] | 274 | * interface in ethtool or the driver changes, this 1 should be |
| 275 | * incremented */ |
Malli Chilakala | 5e3c30d | 2005-04-28 19:04:07 -0700 | [diff] [blame] | 276 | regs->version = (1<<24) | hw->revision_id << 16 | hw->device_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | |
| 278 | /* General Registers */ |
| 279 | *reg++ = IXGB_READ_REG(hw, CTRL0); /* 0 */ |
| 280 | *reg++ = IXGB_READ_REG(hw, CTRL1); /* 1 */ |
| 281 | *reg++ = IXGB_READ_REG(hw, STATUS); /* 2 */ |
| 282 | *reg++ = IXGB_READ_REG(hw, EECD); /* 3 */ |
| 283 | *reg++ = IXGB_READ_REG(hw, MFS); /* 4 */ |
| 284 | |
| 285 | /* Interrupt */ |
| 286 | *reg++ = IXGB_READ_REG(hw, ICR); /* 5 */ |
| 287 | *reg++ = IXGB_READ_REG(hw, ICS); /* 6 */ |
| 288 | *reg++ = IXGB_READ_REG(hw, IMS); /* 7 */ |
| 289 | *reg++ = IXGB_READ_REG(hw, IMC); /* 8 */ |
| 290 | |
| 291 | /* Receive */ |
| 292 | *reg++ = IXGB_READ_REG(hw, RCTL); /* 9 */ |
| 293 | *reg++ = IXGB_READ_REG(hw, FCRTL); /* 10 */ |
| 294 | *reg++ = IXGB_READ_REG(hw, FCRTH); /* 11 */ |
| 295 | *reg++ = IXGB_READ_REG(hw, RDBAL); /* 12 */ |
| 296 | *reg++ = IXGB_READ_REG(hw, RDBAH); /* 13 */ |
| 297 | *reg++ = IXGB_READ_REG(hw, RDLEN); /* 14 */ |
| 298 | *reg++ = IXGB_READ_REG(hw, RDH); /* 15 */ |
| 299 | *reg++ = IXGB_READ_REG(hw, RDT); /* 16 */ |
| 300 | *reg++ = IXGB_READ_REG(hw, RDTR); /* 17 */ |
| 301 | *reg++ = IXGB_READ_REG(hw, RXDCTL); /* 18 */ |
| 302 | *reg++ = IXGB_READ_REG(hw, RAIDC); /* 19 */ |
| 303 | *reg++ = IXGB_READ_REG(hw, RXCSUM); /* 20 */ |
| 304 | |
Malli Chilakala | 9ef2eec | 2005-08-11 13:59:07 -0700 | [diff] [blame] | 305 | /* there are 16 RAR entries in hardware, we only use 3 */ |
Jesse Brandeburg | 1459336 | 2008-07-08 15:52:33 -0700 | [diff] [blame] | 306 | for (i = 0; i < IXGB_ALL_RAR_ENTRIES; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | *reg++ = IXGB_READ_REG_ARRAY(hw, RAL, (i << 1)); /*21,...,51 */ |
| 308 | *reg++ = IXGB_READ_REG_ARRAY(hw, RAH, (i << 1)); /*22,...,52 */ |
| 309 | } |
| 310 | |
| 311 | /* Transmit */ |
| 312 | *reg++ = IXGB_READ_REG(hw, TCTL); /* 53 */ |
| 313 | *reg++ = IXGB_READ_REG(hw, TDBAL); /* 54 */ |
| 314 | *reg++ = IXGB_READ_REG(hw, TDBAH); /* 55 */ |
| 315 | *reg++ = IXGB_READ_REG(hw, TDLEN); /* 56 */ |
| 316 | *reg++ = IXGB_READ_REG(hw, TDH); /* 57 */ |
| 317 | *reg++ = IXGB_READ_REG(hw, TDT); /* 58 */ |
| 318 | *reg++ = IXGB_READ_REG(hw, TIDV); /* 59 */ |
| 319 | *reg++ = IXGB_READ_REG(hw, TXDCTL); /* 60 */ |
| 320 | *reg++ = IXGB_READ_REG(hw, TSPMT); /* 61 */ |
| 321 | *reg++ = IXGB_READ_REG(hw, PAP); /* 62 */ |
| 322 | |
| 323 | /* Physical */ |
| 324 | *reg++ = IXGB_READ_REG(hw, PCSC1); /* 63 */ |
| 325 | *reg++ = IXGB_READ_REG(hw, PCSC2); /* 64 */ |
| 326 | *reg++ = IXGB_READ_REG(hw, PCSS1); /* 65 */ |
| 327 | *reg++ = IXGB_READ_REG(hw, PCSS2); /* 66 */ |
| 328 | *reg++ = IXGB_READ_REG(hw, XPCSS); /* 67 */ |
| 329 | *reg++ = IXGB_READ_REG(hw, UCCR); /* 68 */ |
| 330 | *reg++ = IXGB_READ_REG(hw, XPCSTC); /* 69 */ |
| 331 | *reg++ = IXGB_READ_REG(hw, MACA); /* 70 */ |
| 332 | *reg++ = IXGB_READ_REG(hw, APAE); /* 71 */ |
| 333 | *reg++ = IXGB_READ_REG(hw, ARD); /* 72 */ |
| 334 | *reg++ = IXGB_READ_REG(hw, AIS); /* 73 */ |
| 335 | *reg++ = IXGB_READ_REG(hw, MSCA); /* 74 */ |
| 336 | *reg++ = IXGB_READ_REG(hw, MSRWD); /* 75 */ |
| 337 | |
| 338 | /* Statistics */ |
| 339 | *reg++ = IXGB_GET_STAT(adapter, tprl); /* 76 */ |
| 340 | *reg++ = IXGB_GET_STAT(adapter, tprh); /* 77 */ |
| 341 | *reg++ = IXGB_GET_STAT(adapter, gprcl); /* 78 */ |
| 342 | *reg++ = IXGB_GET_STAT(adapter, gprch); /* 79 */ |
| 343 | *reg++ = IXGB_GET_STAT(adapter, bprcl); /* 80 */ |
| 344 | *reg++ = IXGB_GET_STAT(adapter, bprch); /* 81 */ |
| 345 | *reg++ = IXGB_GET_STAT(adapter, mprcl); /* 82 */ |
| 346 | *reg++ = IXGB_GET_STAT(adapter, mprch); /* 83 */ |
| 347 | *reg++ = IXGB_GET_STAT(adapter, uprcl); /* 84 */ |
| 348 | *reg++ = IXGB_GET_STAT(adapter, uprch); /* 85 */ |
| 349 | *reg++ = IXGB_GET_STAT(adapter, vprcl); /* 86 */ |
| 350 | *reg++ = IXGB_GET_STAT(adapter, vprch); /* 87 */ |
| 351 | *reg++ = IXGB_GET_STAT(adapter, jprcl); /* 88 */ |
| 352 | *reg++ = IXGB_GET_STAT(adapter, jprch); /* 89 */ |
| 353 | *reg++ = IXGB_GET_STAT(adapter, gorcl); /* 90 */ |
| 354 | *reg++ = IXGB_GET_STAT(adapter, gorch); /* 91 */ |
| 355 | *reg++ = IXGB_GET_STAT(adapter, torl); /* 92 */ |
| 356 | *reg++ = IXGB_GET_STAT(adapter, torh); /* 93 */ |
| 357 | *reg++ = IXGB_GET_STAT(adapter, rnbc); /* 94 */ |
| 358 | *reg++ = IXGB_GET_STAT(adapter, ruc); /* 95 */ |
| 359 | *reg++ = IXGB_GET_STAT(adapter, roc); /* 96 */ |
| 360 | *reg++ = IXGB_GET_STAT(adapter, rlec); /* 97 */ |
| 361 | *reg++ = IXGB_GET_STAT(adapter, crcerrs); /* 98 */ |
| 362 | *reg++ = IXGB_GET_STAT(adapter, icbc); /* 99 */ |
| 363 | *reg++ = IXGB_GET_STAT(adapter, ecbc); /* 100 */ |
| 364 | *reg++ = IXGB_GET_STAT(adapter, mpc); /* 101 */ |
| 365 | *reg++ = IXGB_GET_STAT(adapter, tptl); /* 102 */ |
| 366 | *reg++ = IXGB_GET_STAT(adapter, tpth); /* 103 */ |
| 367 | *reg++ = IXGB_GET_STAT(adapter, gptcl); /* 104 */ |
| 368 | *reg++ = IXGB_GET_STAT(adapter, gptch); /* 105 */ |
| 369 | *reg++ = IXGB_GET_STAT(adapter, bptcl); /* 106 */ |
| 370 | *reg++ = IXGB_GET_STAT(adapter, bptch); /* 107 */ |
| 371 | *reg++ = IXGB_GET_STAT(adapter, mptcl); /* 108 */ |
| 372 | *reg++ = IXGB_GET_STAT(adapter, mptch); /* 109 */ |
| 373 | *reg++ = IXGB_GET_STAT(adapter, uptcl); /* 110 */ |
| 374 | *reg++ = IXGB_GET_STAT(adapter, uptch); /* 111 */ |
| 375 | *reg++ = IXGB_GET_STAT(adapter, vptcl); /* 112 */ |
| 376 | *reg++ = IXGB_GET_STAT(adapter, vptch); /* 113 */ |
| 377 | *reg++ = IXGB_GET_STAT(adapter, jptcl); /* 114 */ |
| 378 | *reg++ = IXGB_GET_STAT(adapter, jptch); /* 115 */ |
| 379 | *reg++ = IXGB_GET_STAT(adapter, gotcl); /* 116 */ |
| 380 | *reg++ = IXGB_GET_STAT(adapter, gotch); /* 117 */ |
| 381 | *reg++ = IXGB_GET_STAT(adapter, totl); /* 118 */ |
| 382 | *reg++ = IXGB_GET_STAT(adapter, toth); /* 119 */ |
| 383 | *reg++ = IXGB_GET_STAT(adapter, dc); /* 120 */ |
| 384 | *reg++ = IXGB_GET_STAT(adapter, plt64c); /* 121 */ |
| 385 | *reg++ = IXGB_GET_STAT(adapter, tsctc); /* 122 */ |
| 386 | *reg++ = IXGB_GET_STAT(adapter, tsctfc); /* 123 */ |
| 387 | *reg++ = IXGB_GET_STAT(adapter, ibic); /* 124 */ |
| 388 | *reg++ = IXGB_GET_STAT(adapter, rfc); /* 125 */ |
| 389 | *reg++ = IXGB_GET_STAT(adapter, lfc); /* 126 */ |
| 390 | *reg++ = IXGB_GET_STAT(adapter, pfrc); /* 127 */ |
| 391 | *reg++ = IXGB_GET_STAT(adapter, pftc); /* 128 */ |
| 392 | *reg++ = IXGB_GET_STAT(adapter, mcfrc); /* 129 */ |
| 393 | *reg++ = IXGB_GET_STAT(adapter, mcftc); /* 130 */ |
| 394 | *reg++ = IXGB_GET_STAT(adapter, xonrxc); /* 131 */ |
| 395 | *reg++ = IXGB_GET_STAT(adapter, xontxc); /* 132 */ |
| 396 | *reg++ = IXGB_GET_STAT(adapter, xoffrxc); /* 133 */ |
| 397 | *reg++ = IXGB_GET_STAT(adapter, xofftxc); /* 134 */ |
| 398 | *reg++ = IXGB_GET_STAT(adapter, rjc); /* 135 */ |
| 399 | |
Joe Perches | 222441a | 2008-04-03 10:06:25 -0700 | [diff] [blame] | 400 | regs->len = (reg - reg_start) * sizeof(u32); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | } |
| 402 | |
| 403 | static int |
| 404 | ixgb_get_eeprom_len(struct net_device *netdev) |
| 405 | { |
| 406 | /* return size in bytes */ |
| 407 | return (IXGB_EEPROM_SIZE << 1); |
| 408 | } |
| 409 | |
| 410 | static int |
| 411 | ixgb_get_eeprom(struct net_device *netdev, |
Joe Perches | 222441a | 2008-04-03 10:06:25 -0700 | [diff] [blame] | 412 | struct ethtool_eeprom *eeprom, u8 *bytes) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | { |
Malli Chilakala | 8908c6c | 2005-08-11 13:58:40 -0700 | [diff] [blame] | 414 | struct ixgb_adapter *adapter = netdev_priv(netdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | struct ixgb_hw *hw = &adapter->hw; |
Al Viro | c676504 | 2007-08-23 00:47:03 -0400 | [diff] [blame] | 416 | __le16 *eeprom_buff; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 417 | int i, max_len, first_word, last_word; |
| 418 | int ret_val = 0; |
| 419 | |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 420 | if (eeprom->len == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | ret_val = -EINVAL; |
| 422 | goto geeprom_error; |
| 423 | } |
| 424 | |
| 425 | eeprom->magic = hw->vendor_id | (hw->device_id << 16); |
| 426 | |
| 427 | max_len = ixgb_get_eeprom_len(netdev); |
| 428 | |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 429 | if (eeprom->offset > eeprom->offset + eeprom->len) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 430 | ret_val = -EINVAL; |
| 431 | goto geeprom_error; |
| 432 | } |
| 433 | |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 434 | if ((eeprom->offset + eeprom->len) > max_len) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | eeprom->len = (max_len - eeprom->offset); |
| 436 | |
| 437 | first_word = eeprom->offset >> 1; |
| 438 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; |
| 439 | |
Al Viro | c676504 | 2007-08-23 00:47:03 -0400 | [diff] [blame] | 440 | eeprom_buff = kmalloc(sizeof(__le16) * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | (last_word - first_word + 1), GFP_KERNEL); |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 442 | if (!eeprom_buff) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | return -ENOMEM; |
| 444 | |
| 445 | /* note the eeprom was good because the driver loaded */ |
Jesse Brandeburg | 1459336 | 2008-07-08 15:52:33 -0700 | [diff] [blame] | 446 | for (i = 0; i <= (last_word - first_word); i++) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 447 | eeprom_buff[i] = ixgb_get_eeprom_word(hw, (first_word + i)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | |
Jesse Brandeburg | 1459336 | 2008-07-08 15:52:33 -0700 | [diff] [blame] | 449 | memcpy(bytes, (u8 *)eeprom_buff + (eeprom->offset & 1), eeprom->len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | kfree(eeprom_buff); |
| 451 | |
| 452 | geeprom_error: |
| 453 | return ret_val; |
| 454 | } |
| 455 | |
| 456 | static int |
| 457 | ixgb_set_eeprom(struct net_device *netdev, |
Joe Perches | 222441a | 2008-04-03 10:06:25 -0700 | [diff] [blame] | 458 | struct ethtool_eeprom *eeprom, u8 *bytes) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | { |
Malli Chilakala | 8908c6c | 2005-08-11 13:58:40 -0700 | [diff] [blame] | 460 | struct ixgb_adapter *adapter = netdev_priv(netdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | struct ixgb_hw *hw = &adapter->hw; |
Joe Perches | 222441a | 2008-04-03 10:06:25 -0700 | [diff] [blame] | 462 | u16 *eeprom_buff; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | void *ptr; |
| 464 | int max_len, first_word, last_word; |
Joe Perches | 222441a | 2008-04-03 10:06:25 -0700 | [diff] [blame] | 465 | u16 i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 467 | if (eeprom->len == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | return -EINVAL; |
| 469 | |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 470 | if (eeprom->magic != (hw->vendor_id | (hw->device_id << 16))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | return -EFAULT; |
| 472 | |
| 473 | max_len = ixgb_get_eeprom_len(netdev); |
| 474 | |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 475 | if (eeprom->offset > eeprom->offset + eeprom->len) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 476 | return -EINVAL; |
| 477 | |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 478 | if ((eeprom->offset + eeprom->len) > max_len) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | eeprom->len = (max_len - eeprom->offset); |
| 480 | |
| 481 | first_word = eeprom->offset >> 1; |
| 482 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; |
| 483 | eeprom_buff = kmalloc(max_len, GFP_KERNEL); |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 484 | if (!eeprom_buff) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | return -ENOMEM; |
| 486 | |
| 487 | ptr = (void *)eeprom_buff; |
| 488 | |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 489 | if (eeprom->offset & 1) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | /* need read/modify/write of first changed EEPROM word */ |
| 491 | /* only the second byte of the word is being modified */ |
| 492 | eeprom_buff[0] = ixgb_read_eeprom(hw, first_word); |
| 493 | ptr++; |
| 494 | } |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 495 | if ((eeprom->offset + eeprom->len) & 1) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | /* need read/modify/write of last changed EEPROM word */ |
| 497 | /* only the first byte of the word is being modified */ |
Jesse Brandeburg | 0060c07 | 2008-07-08 15:52:23 -0700 | [diff] [blame] | 498 | eeprom_buff[last_word - first_word] |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 499 | = ixgb_read_eeprom(hw, last_word); |
| 500 | } |
| 501 | |
| 502 | memcpy(ptr, bytes, eeprom->len); |
Jesse Brandeburg | 1459336 | 2008-07-08 15:52:33 -0700 | [diff] [blame] | 503 | for (i = 0; i <= (last_word - first_word); i++) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 504 | ixgb_write_eeprom(hw, first_word + i, eeprom_buff[i]); |
| 505 | |
| 506 | /* Update the checksum over the first part of the EEPROM if needed */ |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 507 | if (first_word <= EEPROM_CHECKSUM_REG) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | ixgb_update_eeprom_checksum(hw); |
| 509 | |
| 510 | kfree(eeprom_buff); |
| 511 | return 0; |
| 512 | } |
| 513 | |
| 514 | static void |
| 515 | ixgb_get_drvinfo(struct net_device *netdev, |
| 516 | struct ethtool_drvinfo *drvinfo) |
| 517 | { |
Malli Chilakala | 8908c6c | 2005-08-11 13:58:40 -0700 | [diff] [blame] | 518 | struct ixgb_adapter *adapter = netdev_priv(netdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 519 | |
| 520 | strncpy(drvinfo->driver, ixgb_driver_name, 32); |
| 521 | strncpy(drvinfo->version, ixgb_driver_version, 32); |
| 522 | strncpy(drvinfo->fw_version, "N/A", 32); |
| 523 | strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); |
| 524 | drvinfo->n_stats = IXGB_STATS_LEN; |
| 525 | drvinfo->regdump_len = ixgb_get_regs_len(netdev); |
| 526 | drvinfo->eedump_len = ixgb_get_eeprom_len(netdev); |
| 527 | } |
| 528 | |
| 529 | static void |
| 530 | ixgb_get_ringparam(struct net_device *netdev, |
| 531 | struct ethtool_ringparam *ring) |
| 532 | { |
Malli Chilakala | 8908c6c | 2005-08-11 13:58:40 -0700 | [diff] [blame] | 533 | struct ixgb_adapter *adapter = netdev_priv(netdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | struct ixgb_desc_ring *txdr = &adapter->tx_ring; |
| 535 | struct ixgb_desc_ring *rxdr = &adapter->rx_ring; |
| 536 | |
Jesse Brandeburg | 0060c07 | 2008-07-08 15:52:23 -0700 | [diff] [blame] | 537 | ring->rx_max_pending = MAX_RXD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | ring->tx_max_pending = MAX_TXD; |
| 539 | ring->rx_mini_max_pending = 0; |
| 540 | ring->rx_jumbo_max_pending = 0; |
| 541 | ring->rx_pending = rxdr->count; |
| 542 | ring->tx_pending = txdr->count; |
| 543 | ring->rx_mini_pending = 0; |
| 544 | ring->rx_jumbo_pending = 0; |
| 545 | } |
| 546 | |
Jesse Brandeburg | 0060c07 | 2008-07-08 15:52:23 -0700 | [diff] [blame] | 547 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 548 | ixgb_set_ringparam(struct net_device *netdev, |
| 549 | struct ethtool_ringparam *ring) |
| 550 | { |
Malli Chilakala | 8908c6c | 2005-08-11 13:58:40 -0700 | [diff] [blame] | 551 | struct ixgb_adapter *adapter = netdev_priv(netdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 552 | struct ixgb_desc_ring *txdr = &adapter->tx_ring; |
| 553 | struct ixgb_desc_ring *rxdr = &adapter->rx_ring; |
| 554 | struct ixgb_desc_ring tx_old, tx_new, rx_old, rx_new; |
| 555 | int err; |
| 556 | |
| 557 | tx_old = adapter->tx_ring; |
| 558 | rx_old = adapter->rx_ring; |
| 559 | |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 560 | if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 561 | return -EINVAL; |
| 562 | |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 563 | if (netif_running(adapter->netdev)) |
Joe Perches | 446490c | 2008-03-21 11:06:37 -0700 | [diff] [blame] | 564 | ixgb_down(adapter, true); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | |
Joe Perches | 222441a | 2008-04-03 10:06:25 -0700 | [diff] [blame] | 566 | rxdr->count = max(ring->rx_pending,(u32)MIN_RXD); |
| 567 | rxdr->count = min(rxdr->count,(u32)MAX_RXD); |
Milind Arun Choudhary | 55e924c | 2007-04-27 13:55:31 -0700 | [diff] [blame] | 568 | rxdr->count = ALIGN(rxdr->count, IXGB_REQ_RX_DESCRIPTOR_MULTIPLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | |
Joe Perches | 222441a | 2008-04-03 10:06:25 -0700 | [diff] [blame] | 570 | txdr->count = max(ring->tx_pending,(u32)MIN_TXD); |
| 571 | txdr->count = min(txdr->count,(u32)MAX_TXD); |
Milind Arun Choudhary | 55e924c | 2007-04-27 13:55:31 -0700 | [diff] [blame] | 572 | txdr->count = ALIGN(txdr->count, IXGB_REQ_TX_DESCRIPTOR_MULTIPLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 573 | |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 574 | if (netif_running(adapter->netdev)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 575 | /* Try to get new resources before deleting old */ |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 576 | if ((err = ixgb_setup_rx_resources(adapter))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | goto err_setup_rx; |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 578 | if ((err = ixgb_setup_tx_resources(adapter))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 579 | goto err_setup_tx; |
| 580 | |
| 581 | /* save the new, restore the old in order to free it, |
| 582 | * then restore the new back again */ |
| 583 | |
| 584 | rx_new = adapter->rx_ring; |
| 585 | tx_new = adapter->tx_ring; |
| 586 | adapter->rx_ring = rx_old; |
| 587 | adapter->tx_ring = tx_old; |
| 588 | ixgb_free_rx_resources(adapter); |
| 589 | ixgb_free_tx_resources(adapter); |
| 590 | adapter->rx_ring = rx_new; |
| 591 | adapter->tx_ring = tx_new; |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 592 | if ((err = ixgb_up(adapter))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | return err; |
Auke Kok | 4de17c8 | 2006-05-23 10:29:46 -0700 | [diff] [blame] | 594 | ixgb_set_speed_duplex(netdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | } |
| 596 | |
| 597 | return 0; |
| 598 | err_setup_tx: |
| 599 | ixgb_free_rx_resources(adapter); |
| 600 | err_setup_rx: |
| 601 | adapter->rx_ring = rx_old; |
| 602 | adapter->tx_ring = tx_old; |
| 603 | ixgb_up(adapter); |
| 604 | return err; |
| 605 | } |
| 606 | |
| 607 | /* toggle LED 4 times per second = 2 "blinks" per second */ |
| 608 | #define IXGB_ID_INTERVAL (HZ/4) |
| 609 | |
| 610 | /* bit defines for adapter->led_status */ |
| 611 | #define IXGB_LED_ON 0 |
| 612 | |
| 613 | static void |
| 614 | ixgb_led_blink_callback(unsigned long data) |
| 615 | { |
| 616 | struct ixgb_adapter *adapter = (struct ixgb_adapter *)data; |
| 617 | |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 618 | if (test_and_change_bit(IXGB_LED_ON, &adapter->led_status)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | ixgb_led_off(&adapter->hw); |
| 620 | else |
| 621 | ixgb_led_on(&adapter->hw); |
| 622 | |
| 623 | mod_timer(&adapter->blink_timer, jiffies + IXGB_ID_INTERVAL); |
| 624 | } |
| 625 | |
| 626 | static int |
Joe Perches | 222441a | 2008-04-03 10:06:25 -0700 | [diff] [blame] | 627 | ixgb_phys_id(struct net_device *netdev, u32 data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 628 | { |
Malli Chilakala | 8908c6c | 2005-08-11 13:58:40 -0700 | [diff] [blame] | 629 | struct ixgb_adapter *adapter = netdev_priv(netdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | |
Stephen Hemminger | 273dc74 | 2007-10-29 10:46:13 -0700 | [diff] [blame] | 631 | if (!data) |
| 632 | data = INT_MAX; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 633 | |
Jesse Brandeburg | 03f8304 | 2008-07-08 15:52:13 -0700 | [diff] [blame] | 634 | if (!adapter->blink_timer.function) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 635 | init_timer(&adapter->blink_timer); |
| 636 | adapter->blink_timer.function = ixgb_led_blink_callback; |
| 637 | adapter->blink_timer.data = (unsigned long)adapter; |
| 638 | } |
| 639 | |
| 640 | mod_timer(&adapter->blink_timer, jiffies); |
| 641 | |
Jesse Brandeburg | a91bb6a | 2006-08-31 14:27:50 -0700 | [diff] [blame] | 642 | msleep_interruptible(data * 1000); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 643 | del_timer_sync(&adapter->blink_timer); |
| 644 | ixgb_led_off(&adapter->hw); |
| 645 | clear_bit(IXGB_LED_ON, &adapter->led_status); |
| 646 | |
| 647 | return 0; |
| 648 | } |
| 649 | |
Jesse Brandeburg | 0060c07 | 2008-07-08 15:52:23 -0700 | [diff] [blame] | 650 | static int |
Jeff Garzik | b9f2c04 | 2007-10-03 18:07:32 -0700 | [diff] [blame] | 651 | ixgb_get_sset_count(struct net_device *netdev, int sset) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 652 | { |
Jeff Garzik | b9f2c04 | 2007-10-03 18:07:32 -0700 | [diff] [blame] | 653 | switch (sset) { |
| 654 | case ETH_SS_STATS: |
| 655 | return IXGB_STATS_LEN; |
| 656 | default: |
| 657 | return -EOPNOTSUPP; |
| 658 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | } |
| 660 | |
Jesse Brandeburg | 0060c07 | 2008-07-08 15:52:23 -0700 | [diff] [blame] | 661 | static void |
| 662 | ixgb_get_ethtool_stats(struct net_device *netdev, |
Joe Perches | 222441a | 2008-04-03 10:06:25 -0700 | [diff] [blame] | 663 | struct ethtool_stats *stats, u64 *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 664 | { |
Malli Chilakala | 8908c6c | 2005-08-11 13:58:40 -0700 | [diff] [blame] | 665 | struct ixgb_adapter *adapter = netdev_priv(netdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 666 | int i; |
| 667 | |
| 668 | ixgb_update_stats(adapter); |
Jesse Brandeburg | 1459336 | 2008-07-08 15:52:33 -0700 | [diff] [blame] | 669 | for (i = 0; i < IXGB_STATS_LEN; i++) { |
Jesse Brandeburg | 0060c07 | 2008-07-08 15:52:23 -0700 | [diff] [blame] | 670 | char *p = (char *)adapter+ixgb_gstrings_stats[i].stat_offset; |
| 671 | data[i] = (ixgb_gstrings_stats[i].sizeof_stat == |
Joe Perches | 222441a | 2008-04-03 10:06:25 -0700 | [diff] [blame] | 672 | sizeof(u64)) ? *(u64 *)p : *(u32 *)p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | } |
| 674 | } |
| 675 | |
Jesse Brandeburg | 0060c07 | 2008-07-08 15:52:23 -0700 | [diff] [blame] | 676 | static void |
Joe Perches | 222441a | 2008-04-03 10:06:25 -0700 | [diff] [blame] | 677 | ixgb_get_strings(struct net_device *netdev, u32 stringset, u8 *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 678 | { |
| 679 | int i; |
| 680 | |
| 681 | switch(stringset) { |
| 682 | case ETH_SS_STATS: |
Jesse Brandeburg | 1459336 | 2008-07-08 15:52:33 -0700 | [diff] [blame] | 683 | for (i = 0; i < IXGB_STATS_LEN; i++) { |
Jesse Brandeburg | 0060c07 | 2008-07-08 15:52:23 -0700 | [diff] [blame] | 684 | memcpy(data + i * ETH_GSTRING_LEN, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 685 | ixgb_gstrings_stats[i].stat_string, |
| 686 | ETH_GSTRING_LEN); |
| 687 | } |
| 688 | break; |
| 689 | } |
| 690 | } |
| 691 | |
Jeff Garzik | 7282d49 | 2006-09-13 14:30:00 -0400 | [diff] [blame] | 692 | static const struct ethtool_ops ixgb_ethtool_ops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 693 | .get_settings = ixgb_get_settings, |
| 694 | .set_settings = ixgb_set_settings, |
| 695 | .get_drvinfo = ixgb_get_drvinfo, |
| 696 | .get_regs_len = ixgb_get_regs_len, |
| 697 | .get_regs = ixgb_get_regs, |
| 698 | .get_link = ethtool_op_get_link, |
| 699 | .get_eeprom_len = ixgb_get_eeprom_len, |
| 700 | .get_eeprom = ixgb_get_eeprom, |
| 701 | .set_eeprom = ixgb_set_eeprom, |
| 702 | .get_ringparam = ixgb_get_ringparam, |
| 703 | .set_ringparam = ixgb_set_ringparam, |
| 704 | .get_pauseparam = ixgb_get_pauseparam, |
| 705 | .set_pauseparam = ixgb_set_pauseparam, |
| 706 | .get_rx_csum = ixgb_get_rx_csum, |
| 707 | .set_rx_csum = ixgb_set_rx_csum, |
| 708 | .get_tx_csum = ixgb_get_tx_csum, |
| 709 | .set_tx_csum = ixgb_set_tx_csum, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 710 | .set_sg = ethtool_op_set_sg, |
Auke Kok | ec9c3f5 | 2006-05-23 10:34:59 -0700 | [diff] [blame] | 711 | .get_msglevel = ixgb_get_msglevel, |
| 712 | .set_msglevel = ixgb_set_msglevel, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 713 | .set_tso = ixgb_set_tso, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 714 | .get_strings = ixgb_get_strings, |
| 715 | .phys_id = ixgb_phys_id, |
Jeff Garzik | b9f2c04 | 2007-10-03 18:07:32 -0700 | [diff] [blame] | 716 | .get_sset_count = ixgb_get_sset_count, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 717 | .get_ethtool_stats = ixgb_get_ethtool_stats, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 718 | }; |
| 719 | |
| 720 | void ixgb_set_ethtool_ops(struct net_device *netdev) |
| 721 | { |
| 722 | SET_ETHTOOL_OPS(netdev, &ixgb_ethtool_ops); |
| 723 | } |