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