Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2003 - 2006 NetXen, Inc. |
| 3 | * All rights reserved. |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 4 | * |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License |
| 7 | * as published by the Free Software Foundation; either version 2 |
| 8 | * of the License, or (at your option) any later version. |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 9 | * |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 10 | * This program is distributed in the hope that it will be useful, but |
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 14 | * |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
| 18 | * MA 02111-1307, USA. |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 19 | * |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 20 | * The full GNU General Public License is included in this distribution |
| 21 | * in the file called LICENSE. |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 22 | * |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 23 | * Contact Information: |
| 24 | * info@netxen.com |
| 25 | * NetXen, |
| 26 | * 3965 Freedom Circle, Fourth floor, |
| 27 | * Santa Clara, CA 95054 |
| 28 | * |
| 29 | * |
| 30 | * ethtool support for netxen nic |
| 31 | * |
| 32 | */ |
| 33 | |
| 34 | #include <linux/types.h> |
Amit S. Kale | 27d2ab5 | 2007-02-05 07:40:49 -0800 | [diff] [blame] | 35 | #include <linux/delay.h> |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 36 | #include <asm/uaccess.h> |
| 37 | #include <linux/pci.h> |
| 38 | #include <asm/io.h> |
| 39 | #include <linux/netdevice.h> |
| 40 | #include <linux/ethtool.h> |
| 41 | #include <linux/version.h> |
| 42 | |
| 43 | #include "netxen_nic_hw.h" |
| 44 | #include "netxen_nic.h" |
| 45 | #include "netxen_nic_phan_reg.h" |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 46 | |
| 47 | struct netxen_nic_stats { |
| 48 | char stat_string[ETH_GSTRING_LEN]; |
| 49 | int sizeof_stat; |
| 50 | int stat_offset; |
| 51 | }; |
| 52 | |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 53 | #define NETXEN_NIC_STAT(m) sizeof(((struct netxen_adapter *)0)->m), \ |
| 54 | offsetof(struct netxen_adapter, m) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 55 | |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 56 | #define NETXEN_NIC_PORT_WINDOW 0x10000 |
| 57 | #define NETXEN_NIC_INVALID_DATA 0xDEADBEEF |
| 58 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 59 | static const struct netxen_nic_stats netxen_nic_gstrings_stats[] = { |
| 60 | {"rcvd_bad_skb", NETXEN_NIC_STAT(stats.rcvdbadskb)}, |
| 61 | {"xmit_called", NETXEN_NIC_STAT(stats.xmitcalled)}, |
| 62 | {"xmited_frames", NETXEN_NIC_STAT(stats.xmitedframes)}, |
| 63 | {"xmit_finished", NETXEN_NIC_STAT(stats.xmitfinished)}, |
| 64 | {"bad_skb_len", NETXEN_NIC_STAT(stats.badskblen)}, |
| 65 | {"no_cmd_desc", NETXEN_NIC_STAT(stats.nocmddescriptor)}, |
| 66 | {"polled", NETXEN_NIC_STAT(stats.polled)}, |
| 67 | {"uphappy", NETXEN_NIC_STAT(stats.uphappy)}, |
| 68 | {"updropped", NETXEN_NIC_STAT(stats.updropped)}, |
| 69 | {"uplcong", NETXEN_NIC_STAT(stats.uplcong)}, |
| 70 | {"uphcong", NETXEN_NIC_STAT(stats.uphcong)}, |
| 71 | {"upmcong", NETXEN_NIC_STAT(stats.upmcong)}, |
| 72 | {"updunno", NETXEN_NIC_STAT(stats.updunno)}, |
| 73 | {"skb_freed", NETXEN_NIC_STAT(stats.skbfreed)}, |
| 74 | {"tx_dropped", NETXEN_NIC_STAT(stats.txdropped)}, |
| 75 | {"tx_null_skb", NETXEN_NIC_STAT(stats.txnullskb)}, |
| 76 | {"csummed", NETXEN_NIC_STAT(stats.csummed)}, |
| 77 | {"no_rcv", NETXEN_NIC_STAT(stats.no_rcv)}, |
| 78 | {"rx_bytes", NETXEN_NIC_STAT(stats.rxbytes)}, |
| 79 | {"tx_bytes", NETXEN_NIC_STAT(stats.txbytes)}, |
| 80 | }; |
| 81 | |
Stephen Hemminger | 92104e9 | 2006-12-15 07:57:08 -0800 | [diff] [blame] | 82 | #define NETXEN_NIC_STATS_LEN ARRAY_SIZE(netxen_nic_gstrings_stats) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 83 | |
| 84 | static const char netxen_nic_gstrings_test[][ETH_GSTRING_LEN] = { |
Linsys Contractor Mithlesh Thukral | 0c25cfe | 2007-02-28 05:14:07 -0800 | [diff] [blame] | 85 | "Register_Test_on_offline", |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 86 | "Link_Test_on_offline" |
| 87 | }; |
| 88 | |
| 89 | #define NETXEN_NIC_TEST_LEN sizeof(netxen_nic_gstrings_test) / ETH_GSTRING_LEN |
| 90 | |
| 91 | #define NETXEN_NIC_REGS_COUNT 42 |
| 92 | #define NETXEN_NIC_REGS_LEN (NETXEN_NIC_REGS_COUNT * sizeof(__le32)) |
| 93 | #define NETXEN_MAX_EEPROM_LEN 1024 |
| 94 | |
| 95 | static int netxen_nic_get_eeprom_len(struct net_device *dev) |
| 96 | { |
Amit S. Kale | 27d2ab5 | 2007-02-05 07:40:49 -0800 | [diff] [blame] | 97 | return FLASH_TOTAL_SIZE; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | static void |
| 101 | netxen_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) |
| 102 | { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 103 | struct netxen_adapter *adapter = netdev_priv(dev); |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 104 | u32 fw_major = 0; |
| 105 | u32 fw_minor = 0; |
| 106 | u32 fw_build = 0; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 107 | |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 108 | strncpy(drvinfo->driver, netxen_nic_driver_name, 32); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 109 | strncpy(drvinfo->version, NETXEN_NIC_LINUX_VERSIONID, 32); |
| 110 | fw_major = readl(NETXEN_CRB_NORMALIZE(adapter, |
| 111 | NETXEN_FW_VERSION_MAJOR)); |
| 112 | fw_minor = readl(NETXEN_CRB_NORMALIZE(adapter, |
| 113 | NETXEN_FW_VERSION_MINOR)); |
| 114 | fw_build = readl(NETXEN_CRB_NORMALIZE(adapter, NETXEN_FW_VERSION_SUB)); |
| 115 | sprintf(drvinfo->fw_version, "%d.%d.%d", fw_major, fw_minor, fw_build); |
| 116 | |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 117 | strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 118 | drvinfo->n_stats = NETXEN_NIC_STATS_LEN; |
| 119 | drvinfo->testinfo_len = NETXEN_NIC_TEST_LEN; |
| 120 | drvinfo->regdump_len = NETXEN_NIC_REGS_LEN; |
| 121 | drvinfo->eedump_len = netxen_nic_get_eeprom_len(dev); |
| 122 | } |
| 123 | |
| 124 | static int |
| 125 | netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) |
| 126 | { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 127 | struct netxen_adapter *adapter = netdev_priv(dev); |
Amit S. Kale | 71bd787 | 2006-12-01 05:36:22 -0800 | [diff] [blame] | 128 | struct netxen_board_info *boardinfo = &adapter->ahw.boardcfg; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 129 | |
| 130 | /* read which mode */ |
| 131 | if (adapter->ahw.board_type == NETXEN_NIC_GBE) { |
| 132 | ecmd->supported = (SUPPORTED_10baseT_Half | |
| 133 | SUPPORTED_10baseT_Full | |
| 134 | SUPPORTED_100baseT_Half | |
| 135 | SUPPORTED_100baseT_Full | |
| 136 | SUPPORTED_1000baseT_Half | |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 137 | SUPPORTED_1000baseT_Full); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 138 | |
| 139 | ecmd->advertising = (ADVERTISED_100baseT_Half | |
| 140 | ADVERTISED_100baseT_Full | |
| 141 | ADVERTISED_1000baseT_Half | |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 142 | ADVERTISED_1000baseT_Full); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 143 | |
| 144 | ecmd->port = PORT_TP; |
| 145 | |
| 146 | if (netif_running(dev)) { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 147 | ecmd->speed = adapter->link_speed; |
| 148 | ecmd->duplex = adapter->link_duplex; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 149 | } else |
| 150 | return -EIO; /* link absent */ |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 151 | } else if (adapter->ahw.board_type == NETXEN_NIC_XGBE) { |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 152 | ecmd->supported = (SUPPORTED_TP | |
| 153 | SUPPORTED_1000baseT_Full | |
| 154 | SUPPORTED_10000baseT_Full); |
| 155 | ecmd->advertising = (ADVERTISED_TP | |
| 156 | ADVERTISED_1000baseT_Full | |
| 157 | ADVERTISED_10000baseT_Full); |
| 158 | ecmd->port = PORT_TP; |
| 159 | |
| 160 | ecmd->speed = SPEED_10000; |
| 161 | ecmd->duplex = DUPLEX_FULL; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 162 | ecmd->autoneg = AUTONEG_DISABLE; |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 163 | } else |
| 164 | return -EIO; |
| 165 | |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 166 | ecmd->phy_address = adapter->portnum; |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 167 | ecmd->transceiver = XCVR_EXTERNAL; |
| 168 | |
| 169 | switch ((netxen_brdtype_t) boardinfo->board_type) { |
| 170 | case NETXEN_BRDTYPE_P2_SB35_4G: |
| 171 | case NETXEN_BRDTYPE_P2_SB31_2G: |
| 172 | ecmd->supported |= SUPPORTED_Autoneg; |
| 173 | ecmd->advertising |= ADVERTISED_Autoneg; |
| 174 | case NETXEN_BRDTYPE_P2_SB31_10G_CX4: |
| 175 | ecmd->supported |= SUPPORTED_TP; |
| 176 | ecmd->advertising |= ADVERTISED_TP; |
| 177 | ecmd->port = PORT_TP; |
| 178 | ecmd->autoneg = (boardinfo->board_type == |
| 179 | NETXEN_BRDTYPE_P2_SB31_10G_CX4) ? |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 180 | (AUTONEG_DISABLE) : (adapter->link_autoneg); |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 181 | break; |
| 182 | case NETXEN_BRDTYPE_P2_SB31_10G_HMEZ: |
| 183 | case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ: |
| 184 | ecmd->supported |= SUPPORTED_MII; |
| 185 | ecmd->advertising |= ADVERTISED_MII; |
| 186 | ecmd->port = PORT_FIBRE; |
| 187 | ecmd->autoneg = AUTONEG_DISABLE; |
| 188 | break; |
| 189 | case NETXEN_BRDTYPE_P2_SB31_10G: |
| 190 | ecmd->supported |= SUPPORTED_FIBRE; |
| 191 | ecmd->advertising |= ADVERTISED_FIBRE; |
| 192 | ecmd->port = PORT_FIBRE; |
| 193 | ecmd->autoneg = AUTONEG_DISABLE; |
| 194 | break; |
| 195 | default: |
Amit S. Kale | 71bd787 | 2006-12-01 05:36:22 -0800 | [diff] [blame] | 196 | printk(KERN_ERR "netxen-nic: Unsupported board model %d\n", |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 197 | (netxen_brdtype_t) boardinfo->board_type); |
| 198 | return -EIO; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 199 | } |
| 200 | |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 201 | return 0; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | static int |
| 205 | netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) |
| 206 | { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 207 | struct netxen_adapter *adapter = netdev_priv(dev); |
Al Viro | a608ab9 | 2007-01-02 10:39:10 +0000 | [diff] [blame] | 208 | __u32 status; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 209 | |
| 210 | /* read which mode */ |
| 211 | if (adapter->ahw.board_type == NETXEN_NIC_GBE) { |
| 212 | /* autonegotiation */ |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 213 | if (adapter->phy_write |
Mithlesh Thukral | 13ba9c7 | 2007-04-20 07:53:05 -0700 | [diff] [blame^] | 214 | && adapter->phy_write(adapter, |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 215 | NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG, |
Al Viro | a608ab9 | 2007-01-02 10:39:10 +0000 | [diff] [blame] | 216 | ecmd->autoneg) != 0) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 217 | return -EIO; |
| 218 | else |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 219 | adapter->link_autoneg = ecmd->autoneg; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 220 | |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 221 | if (adapter->phy_read |
Mithlesh Thukral | 13ba9c7 | 2007-04-20 07:53:05 -0700 | [diff] [blame^] | 222 | && adapter->phy_read(adapter, |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 223 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, |
| 224 | &status) != 0) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 225 | return -EIO; |
| 226 | |
| 227 | /* speed */ |
| 228 | switch (ecmd->speed) { |
| 229 | case SPEED_10: |
| 230 | netxen_set_phy_speed(status, 0); |
| 231 | break; |
| 232 | case SPEED_100: |
| 233 | netxen_set_phy_speed(status, 1); |
| 234 | break; |
| 235 | case SPEED_1000: |
| 236 | netxen_set_phy_speed(status, 2); |
| 237 | break; |
| 238 | } |
| 239 | /* set duplex mode */ |
| 240 | if (ecmd->duplex == DUPLEX_HALF) |
| 241 | netxen_clear_phy_duplex(status); |
| 242 | if (ecmd->duplex == DUPLEX_FULL) |
| 243 | netxen_set_phy_duplex(status); |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 244 | if (adapter->phy_write |
Mithlesh Thukral | 13ba9c7 | 2007-04-20 07:53:05 -0700 | [diff] [blame^] | 245 | && adapter->phy_write(adapter, |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 246 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, |
| 247 | *((int *)&status)) != 0) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 248 | return -EIO; |
| 249 | else { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 250 | adapter->link_speed = ecmd->speed; |
| 251 | adapter->link_duplex = ecmd->duplex; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 252 | } |
| 253 | } else |
| 254 | return -EOPNOTSUPP; |
| 255 | |
| 256 | if (netif_running(dev)) { |
| 257 | dev->stop(dev); |
| 258 | dev->open(dev); |
| 259 | } |
| 260 | return 0; |
| 261 | } |
| 262 | |
| 263 | static int netxen_nic_get_regs_len(struct net_device *dev) |
| 264 | { |
| 265 | return NETXEN_NIC_REGS_LEN; |
| 266 | } |
| 267 | |
| 268 | struct netxen_niu_regs { |
Al Viro | a608ab9 | 2007-01-02 10:39:10 +0000 | [diff] [blame] | 269 | __u32 reg[NETXEN_NIC_REGS_COUNT]; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 270 | }; |
| 271 | |
| 272 | static struct netxen_niu_regs niu_registers[] = { |
| 273 | { |
| 274 | /* GB Mode */ |
| 275 | { |
| 276 | NETXEN_NIU_GB_SERDES_RESET, |
| 277 | NETXEN_NIU_GB0_MII_MODE, |
| 278 | NETXEN_NIU_GB1_MII_MODE, |
| 279 | NETXEN_NIU_GB2_MII_MODE, |
| 280 | NETXEN_NIU_GB3_MII_MODE, |
| 281 | NETXEN_NIU_GB0_GMII_MODE, |
| 282 | NETXEN_NIU_GB1_GMII_MODE, |
| 283 | NETXEN_NIU_GB2_GMII_MODE, |
| 284 | NETXEN_NIU_GB3_GMII_MODE, |
| 285 | NETXEN_NIU_REMOTE_LOOPBACK, |
| 286 | NETXEN_NIU_GB0_HALF_DUPLEX, |
| 287 | NETXEN_NIU_GB1_HALF_DUPLEX, |
| 288 | NETXEN_NIU_RESET_SYS_FIFOS, |
| 289 | NETXEN_NIU_GB_CRC_DROP, |
| 290 | NETXEN_NIU_GB_DROP_WRONGADDR, |
| 291 | NETXEN_NIU_TEST_MUX_CTL, |
| 292 | |
| 293 | NETXEN_NIU_GB_MAC_CONFIG_0(0), |
| 294 | NETXEN_NIU_GB_MAC_CONFIG_1(0), |
| 295 | NETXEN_NIU_GB_HALF_DUPLEX_CTRL(0), |
| 296 | NETXEN_NIU_GB_MAX_FRAME_SIZE(0), |
| 297 | NETXEN_NIU_GB_TEST_REG(0), |
| 298 | NETXEN_NIU_GB_MII_MGMT_CONFIG(0), |
| 299 | NETXEN_NIU_GB_MII_MGMT_COMMAND(0), |
| 300 | NETXEN_NIU_GB_MII_MGMT_ADDR(0), |
| 301 | NETXEN_NIU_GB_MII_MGMT_CTRL(0), |
| 302 | NETXEN_NIU_GB_MII_MGMT_STATUS(0), |
| 303 | NETXEN_NIU_GB_MII_MGMT_INDICATE(0), |
| 304 | NETXEN_NIU_GB_INTERFACE_CTRL(0), |
| 305 | NETXEN_NIU_GB_INTERFACE_STATUS(0), |
| 306 | NETXEN_NIU_GB_STATION_ADDR_0(0), |
| 307 | NETXEN_NIU_GB_STATION_ADDR_1(0), |
| 308 | -1, |
| 309 | } |
| 310 | }, |
| 311 | { |
| 312 | /* XG Mode */ |
| 313 | { |
| 314 | NETXEN_NIU_XG_SINGLE_TERM, |
| 315 | NETXEN_NIU_XG_DRIVE_HI, |
| 316 | NETXEN_NIU_XG_DRIVE_LO, |
| 317 | NETXEN_NIU_XG_DTX, |
| 318 | NETXEN_NIU_XG_DEQ, |
| 319 | NETXEN_NIU_XG_WORD_ALIGN, |
| 320 | NETXEN_NIU_XG_RESET, |
| 321 | NETXEN_NIU_XG_POWER_DOWN, |
| 322 | NETXEN_NIU_XG_RESET_PLL, |
| 323 | NETXEN_NIU_XG_SERDES_LOOPBACK, |
| 324 | NETXEN_NIU_XG_DO_BYTE_ALIGN, |
| 325 | NETXEN_NIU_XG_TX_ENABLE, |
| 326 | NETXEN_NIU_XG_RX_ENABLE, |
| 327 | NETXEN_NIU_XG_STATUS, |
| 328 | NETXEN_NIU_XG_PAUSE_THRESHOLD, |
| 329 | NETXEN_NIU_XGE_CONFIG_0, |
| 330 | NETXEN_NIU_XGE_CONFIG_1, |
| 331 | NETXEN_NIU_XGE_IPG, |
| 332 | NETXEN_NIU_XGE_STATION_ADDR_0_HI, |
| 333 | NETXEN_NIU_XGE_STATION_ADDR_0_1, |
| 334 | NETXEN_NIU_XGE_STATION_ADDR_1_LO, |
| 335 | NETXEN_NIU_XGE_STATUS, |
| 336 | NETXEN_NIU_XGE_MAX_FRAME_SIZE, |
| 337 | NETXEN_NIU_XGE_PAUSE_FRAME_VALUE, |
| 338 | NETXEN_NIU_XGE_TX_BYTE_CNT, |
| 339 | NETXEN_NIU_XGE_TX_FRAME_CNT, |
| 340 | NETXEN_NIU_XGE_RX_BYTE_CNT, |
| 341 | NETXEN_NIU_XGE_RX_FRAME_CNT, |
| 342 | NETXEN_NIU_XGE_AGGR_ERROR_CNT, |
| 343 | NETXEN_NIU_XGE_MULTICAST_FRAME_CNT, |
| 344 | NETXEN_NIU_XGE_UNICAST_FRAME_CNT, |
| 345 | NETXEN_NIU_XGE_CRC_ERROR_CNT, |
| 346 | NETXEN_NIU_XGE_OVERSIZE_FRAME_ERR, |
| 347 | NETXEN_NIU_XGE_UNDERSIZE_FRAME_ERR, |
| 348 | NETXEN_NIU_XGE_LOCAL_ERROR_CNT, |
| 349 | NETXEN_NIU_XGE_REMOTE_ERROR_CNT, |
| 350 | NETXEN_NIU_XGE_CONTROL_CHAR_CNT, |
| 351 | NETXEN_NIU_XGE_PAUSE_FRAME_CNT, |
| 352 | -1, |
| 353 | } |
| 354 | } |
| 355 | }; |
| 356 | |
| 357 | static void |
| 358 | netxen_nic_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p) |
| 359 | { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 360 | struct netxen_adapter *adapter = netdev_priv(dev); |
Al Viro | a608ab9 | 2007-01-02 10:39:10 +0000 | [diff] [blame] | 361 | __u32 mode, *regs_buff = p; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 362 | void __iomem *addr; |
| 363 | int i, window; |
| 364 | |
| 365 | memset(p, 0, NETXEN_NIC_REGS_LEN); |
| 366 | regs->version = (1 << 24) | (adapter->ahw.revision_id << 16) | |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 367 | (adapter->pdev)->device; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 368 | /* which mode */ |
| 369 | NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_MODE, ®s_buff[0]); |
| 370 | mode = regs_buff[0]; |
| 371 | |
| 372 | /* Common registers to all the modes */ |
| 373 | NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_STRAP_VALUE_SAVE_HIGHER, |
| 374 | ®s_buff[2]); |
| 375 | /* GB/XGB Mode */ |
| 376 | mode = (mode / 2) - 1; |
| 377 | window = 0; |
| 378 | if (mode <= 1) { |
| 379 | for (i = 3; niu_registers[mode].reg[i - 3] != -1; i++) { |
| 380 | /* GB: port specific registers */ |
| 381 | if (mode == 0 && i >= 19) |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 382 | window = adapter->portnum * |
| 383 | NETXEN_NIC_PORT_WINDOW; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 384 | |
| 385 | NETXEN_NIC_LOCKED_READ_REG(niu_registers[mode]. |
| 386 | reg[i - 3] + window, |
| 387 | ®s_buff[i]); |
| 388 | } |
| 389 | |
| 390 | } |
| 391 | } |
| 392 | |
Amit S. Kale | e45d9ab | 2007-02-09 05:49:08 -0800 | [diff] [blame] | 393 | static u32 netxen_nic_test_link(struct net_device *dev) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 394 | { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 395 | struct netxen_adapter *adapter = netdev_priv(dev); |
Al Viro | a608ab9 | 2007-01-02 10:39:10 +0000 | [diff] [blame] | 396 | __u32 status; |
Linsys Contractor Mithlesh Thukral | 0c25cfe | 2007-02-28 05:14:07 -0800 | [diff] [blame] | 397 | int val; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 398 | |
| 399 | /* read which mode */ |
| 400 | if (adapter->ahw.board_type == NETXEN_NIC_GBE) { |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 401 | if (adapter->phy_read |
Mithlesh Thukral | 13ba9c7 | 2007-04-20 07:53:05 -0700 | [diff] [blame^] | 402 | && adapter->phy_read(adapter, |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 403 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, |
| 404 | &status) != 0) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 405 | return -EIO; |
Linsys Contractor Mithlesh Thukral | 0c25cfe | 2007-02-28 05:14:07 -0800 | [diff] [blame] | 406 | else { |
| 407 | val = netxen_get_phy_link(status); |
| 408 | return !val; |
| 409 | } |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 410 | } else if (adapter->ahw.board_type == NETXEN_NIC_XGBE) { |
Linsys Contractor Mithlesh Thukral | 0c25cfe | 2007-02-28 05:14:07 -0800 | [diff] [blame] | 411 | val = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_XG_STATE)); |
| 412 | return (val == XG_LINK_UP) ? 0 : 1; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 413 | } |
| 414 | return -EIO; |
| 415 | } |
| 416 | |
| 417 | static int |
| 418 | netxen_nic_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, |
| 419 | u8 * bytes) |
| 420 | { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 421 | struct netxen_adapter *adapter = netdev_priv(dev); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 422 | int offset; |
Amit S. Kale | 27d2ab5 | 2007-02-05 07:40:49 -0800 | [diff] [blame] | 423 | int ret; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 424 | |
| 425 | if (eeprom->len == 0) |
| 426 | return -EINVAL; |
| 427 | |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 428 | eeprom->magic = (adapter->pdev)->vendor | |
| 429 | ((adapter->pdev)->device << 16); |
Amit S. Kale | 27d2ab5 | 2007-02-05 07:40:49 -0800 | [diff] [blame] | 430 | offset = eeprom->offset; |
| 431 | |
| 432 | ret = netxen_rom_fast_read_words(adapter, offset, bytes, |
| 433 | eeprom->len); |
| 434 | if (ret < 0) |
| 435 | return ret; |
| 436 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 437 | return 0; |
| 438 | } |
| 439 | |
Amit S. Kale | 27d2ab5 | 2007-02-05 07:40:49 -0800 | [diff] [blame] | 440 | static int |
| 441 | netxen_nic_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, |
| 442 | u8 * bytes) |
| 443 | { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 444 | struct netxen_adapter *adapter = netdev_priv(dev); |
Amit S. Kale | 27d2ab5 | 2007-02-05 07:40:49 -0800 | [diff] [blame] | 445 | int offset = eeprom->offset; |
| 446 | static int flash_start; |
| 447 | static int ready_to_flash; |
| 448 | int ret; |
| 449 | |
| 450 | if (flash_start == 0) { |
Amit S. Kale | e45d9ab | 2007-02-09 05:49:08 -0800 | [diff] [blame] | 451 | netxen_halt_pegs(adapter); |
Amit S. Kale | 27d2ab5 | 2007-02-05 07:40:49 -0800 | [diff] [blame] | 452 | ret = netxen_flash_unlock(adapter); |
| 453 | if (ret < 0) { |
| 454 | printk(KERN_ERR "%s: Flash unlock failed.\n", |
| 455 | netxen_nic_driver_name); |
| 456 | return ret; |
| 457 | } |
| 458 | printk(KERN_INFO "%s: flash unlocked. \n", |
| 459 | netxen_nic_driver_name); |
Linsys Contractor Mithlesh Thukral | b58ecad | 2007-03-13 04:15:06 -0800 | [diff] [blame] | 460 | last_schedule_time = jiffies; |
Amit S. Kale | 27d2ab5 | 2007-02-05 07:40:49 -0800 | [diff] [blame] | 461 | ret = netxen_flash_erase_secondary(adapter); |
| 462 | if (ret != FLASH_SUCCESS) { |
| 463 | printk(KERN_ERR "%s: Flash erase failed.\n", |
| 464 | netxen_nic_driver_name); |
| 465 | return ret; |
| 466 | } |
| 467 | printk(KERN_INFO "%s: secondary flash erased successfully.\n", |
| 468 | netxen_nic_driver_name); |
| 469 | flash_start = 1; |
| 470 | return 0; |
| 471 | } |
| 472 | |
| 473 | if (offset == BOOTLD_START) { |
| 474 | ret = netxen_flash_erase_primary(adapter); |
| 475 | if (ret != FLASH_SUCCESS) { |
| 476 | printk(KERN_ERR "%s: Flash erase failed.\n", |
| 477 | netxen_nic_driver_name); |
| 478 | return ret; |
| 479 | } |
| 480 | |
| 481 | ret = netxen_rom_se(adapter, USER_START); |
| 482 | if (ret != FLASH_SUCCESS) |
| 483 | return ret; |
| 484 | ret = netxen_rom_se(adapter, FIXED_START); |
| 485 | if (ret != FLASH_SUCCESS) |
| 486 | return ret; |
| 487 | |
| 488 | printk(KERN_INFO "%s: primary flash erased successfully\n", |
| 489 | netxen_nic_driver_name); |
| 490 | |
| 491 | ret = netxen_backup_crbinit(adapter); |
| 492 | if (ret != FLASH_SUCCESS) { |
| 493 | printk(KERN_ERR "%s: CRBinit backup failed.\n", |
| 494 | netxen_nic_driver_name); |
| 495 | return ret; |
| 496 | } |
| 497 | printk(KERN_INFO "%s: CRBinit backup done.\n", |
| 498 | netxen_nic_driver_name); |
| 499 | ready_to_flash = 1; |
| 500 | } |
| 501 | |
| 502 | if (!ready_to_flash) { |
| 503 | printk(KERN_ERR "%s: Invalid write sequence, returning...\n", |
| 504 | netxen_nic_driver_name); |
| 505 | return -EINVAL; |
| 506 | } |
| 507 | |
| 508 | return netxen_rom_fast_write_words(adapter, offset, bytes, eeprom->len); |
| 509 | } |
| 510 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 511 | static void |
| 512 | netxen_nic_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring) |
| 513 | { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 514 | struct netxen_adapter *adapter = netdev_priv(dev); |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 515 | int i; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 516 | |
| 517 | ring->rx_pending = 0; |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 518 | ring->rx_jumbo_pending = 0; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 519 | for (i = 0; i < MAX_RCV_CTX; ++i) { |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 520 | ring->rx_pending += adapter->recv_ctx[i]. |
| 521 | rcv_desc[RCV_DESC_NORMAL_CTXID].rcv_pending; |
| 522 | ring->rx_jumbo_pending += adapter->recv_ctx[i]. |
| 523 | rcv_desc[RCV_DESC_JUMBO_CTXID].rcv_pending; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 524 | } |
| 525 | |
| 526 | ring->rx_max_pending = adapter->max_rx_desc_count; |
| 527 | ring->tx_max_pending = adapter->max_tx_desc_count; |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 528 | ring->rx_jumbo_max_pending = adapter->max_jumbo_rx_desc_count; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 529 | ring->rx_mini_max_pending = 0; |
| 530 | ring->rx_mini_pending = 0; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 531 | ring->rx_jumbo_pending = 0; |
| 532 | } |
| 533 | |
| 534 | static void |
| 535 | netxen_nic_get_pauseparam(struct net_device *dev, |
| 536 | struct ethtool_pauseparam *pause) |
| 537 | { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 538 | struct netxen_adapter *adapter = netdev_priv(dev); |
Al Viro | a608ab9 | 2007-01-02 10:39:10 +0000 | [diff] [blame] | 539 | __u32 val; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 540 | |
| 541 | if (adapter->ahw.board_type == NETXEN_NIC_GBE) { |
| 542 | /* get flow control settings */ |
| 543 | netxen_nic_read_w0(adapter, |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 544 | NETXEN_NIU_GB_MAC_CONFIG_0(adapter->portnum), |
Al Viro | a608ab9 | 2007-01-02 10:39:10 +0000 | [diff] [blame] | 545 | &val); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 546 | pause->rx_pause = netxen_gb_get_rx_flowctl(val); |
| 547 | pause->tx_pause = netxen_gb_get_tx_flowctl(val); |
| 548 | /* get autoneg settings */ |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 549 | pause->autoneg = adapter->link_autoneg; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 550 | } |
| 551 | } |
| 552 | |
| 553 | static int |
| 554 | netxen_nic_set_pauseparam(struct net_device *dev, |
| 555 | struct ethtool_pauseparam *pause) |
| 556 | { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 557 | struct netxen_adapter *adapter = netdev_priv(dev); |
Al Viro | a608ab9 | 2007-01-02 10:39:10 +0000 | [diff] [blame] | 558 | __u32 val; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 559 | unsigned int autoneg; |
| 560 | |
| 561 | /* read mode */ |
| 562 | if (adapter->ahw.board_type == NETXEN_NIC_GBE) { |
| 563 | /* set flow control */ |
| 564 | netxen_nic_read_w0(adapter, |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 565 | NETXEN_NIU_GB_MAC_CONFIG_0(adapter->portnum), |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 566 | (u32 *) & val); |
| 567 | if (pause->tx_pause) |
| 568 | netxen_gb_tx_flowctl(val); |
| 569 | else |
| 570 | netxen_gb_unset_tx_flowctl(val); |
| 571 | if (pause->rx_pause) |
| 572 | netxen_gb_rx_flowctl(val); |
| 573 | else |
| 574 | netxen_gb_unset_rx_flowctl(val); |
| 575 | |
| 576 | netxen_nic_write_w0(adapter, |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 577 | NETXEN_NIU_GB_MAC_CONFIG_0(adapter->portnum), |
Al Viro | a608ab9 | 2007-01-02 10:39:10 +0000 | [diff] [blame] | 578 | *&val); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 579 | /* set autoneg */ |
| 580 | autoneg = pause->autoneg; |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 581 | if (adapter->phy_write |
Mithlesh Thukral | 13ba9c7 | 2007-04-20 07:53:05 -0700 | [diff] [blame^] | 582 | && adapter->phy_write(adapter, |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 583 | NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG, |
Al Viro | a608ab9 | 2007-01-02 10:39:10 +0000 | [diff] [blame] | 584 | autoneg) != 0) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 585 | return -EIO; |
| 586 | else { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 587 | adapter->link_autoneg = pause->autoneg; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 588 | return 0; |
| 589 | } |
| 590 | } else |
| 591 | return -EOPNOTSUPP; |
| 592 | } |
| 593 | |
| 594 | static int netxen_nic_reg_test(struct net_device *dev) |
| 595 | { |
Linsys Contractor Mithlesh Thukral | 0c25cfe | 2007-02-28 05:14:07 -0800 | [diff] [blame] | 596 | struct netxen_adapter *adapter = netdev_priv(dev); |
| 597 | u32 data_read, data_written; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 598 | |
Linsys Contractor Mithlesh Thukral | 0c25cfe | 2007-02-28 05:14:07 -0800 | [diff] [blame] | 599 | netxen_nic_read_w0(adapter, NETXEN_PCIX_PH_REG(0), &data_read); |
| 600 | if ((data_read & 0xffff) != PHAN_VENDOR_ID) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 601 | return 1; |
Linsys Contractor Mithlesh Thukral | 0c25cfe | 2007-02-28 05:14:07 -0800 | [diff] [blame] | 602 | |
| 603 | data_written = (u32)0xa5a5a5a5; |
| 604 | |
| 605 | netxen_nic_reg_write(adapter, CRB_SCRATCHPAD_TEST, data_written); |
| 606 | data_read = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_SCRATCHPAD_TEST)); |
| 607 | if (data_written != data_read) |
| 608 | return 1; |
| 609 | |
| 610 | return 0; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 611 | } |
| 612 | |
| 613 | static int netxen_nic_diag_test_count(struct net_device *dev) |
| 614 | { |
| 615 | return NETXEN_NIC_TEST_LEN; |
| 616 | } |
| 617 | |
| 618 | static void |
| 619 | netxen_nic_diag_test(struct net_device *dev, struct ethtool_test *eth_test, |
| 620 | u64 * data) |
| 621 | { |
| 622 | if (eth_test->flags == ETH_TEST_FL_OFFLINE) { /* offline tests */ |
| 623 | /* link test */ |
Linsys Contractor Mithlesh Thukral | 0c25cfe | 2007-02-28 05:14:07 -0800 | [diff] [blame] | 624 | if ((data[1] = (u64) netxen_nic_test_link(dev))) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 625 | eth_test->flags |= ETH_TEST_FL_FAILED; |
| 626 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 627 | /* register tests */ |
Linsys Contractor Mithlesh Thukral | 0c25cfe | 2007-02-28 05:14:07 -0800 | [diff] [blame] | 628 | if ((data[0] = netxen_nic_reg_test(dev))) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 629 | eth_test->flags |= ETH_TEST_FL_FAILED; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 630 | } else { /* online tests */ |
Linsys Contractor Mithlesh Thukral | 0c25cfe | 2007-02-28 05:14:07 -0800 | [diff] [blame] | 631 | /* register tests */ |
| 632 | if((data[0] = netxen_nic_reg_test(dev))) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 633 | eth_test->flags |= ETH_TEST_FL_FAILED; |
| 634 | |
Linsys Contractor Mithlesh Thukral | 0c25cfe | 2007-02-28 05:14:07 -0800 | [diff] [blame] | 635 | /* link test */ |
| 636 | if ((data[1] = (u64) netxen_nic_test_link(dev))) |
| 637 | eth_test->flags |= ETH_TEST_FL_FAILED; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 638 | } |
| 639 | } |
| 640 | |
| 641 | static void |
| 642 | netxen_nic_get_strings(struct net_device *dev, u32 stringset, u8 * data) |
| 643 | { |
| 644 | int index; |
| 645 | |
| 646 | switch (stringset) { |
| 647 | case ETH_SS_TEST: |
| 648 | memcpy(data, *netxen_nic_gstrings_test, |
| 649 | NETXEN_NIC_TEST_LEN * ETH_GSTRING_LEN); |
| 650 | break; |
| 651 | case ETH_SS_STATS: |
| 652 | for (index = 0; index < NETXEN_NIC_STATS_LEN; index++) { |
| 653 | memcpy(data + index * ETH_GSTRING_LEN, |
| 654 | netxen_nic_gstrings_stats[index].stat_string, |
| 655 | ETH_GSTRING_LEN); |
| 656 | } |
| 657 | break; |
| 658 | } |
| 659 | } |
| 660 | |
| 661 | static int netxen_nic_get_stats_count(struct net_device *dev) |
| 662 | { |
| 663 | return NETXEN_NIC_STATS_LEN; |
| 664 | } |
| 665 | |
| 666 | static void |
| 667 | netxen_nic_get_ethtool_stats(struct net_device *dev, |
| 668 | struct ethtool_stats *stats, u64 * data) |
| 669 | { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 670 | struct netxen_adapter *adapter = netdev_priv(dev); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 671 | int index; |
| 672 | |
| 673 | for (index = 0; index < NETXEN_NIC_STATS_LEN; index++) { |
| 674 | char *p = |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 675 | (char *)adapter + |
| 676 | netxen_nic_gstrings_stats[index].stat_offset; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 677 | data[index] = |
| 678 | (netxen_nic_gstrings_stats[index].sizeof_stat == |
| 679 | sizeof(u64)) ? *(u64 *) p : *(u32 *) p; |
| 680 | } |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 681 | } |
| 682 | |
| 683 | struct ethtool_ops netxen_nic_ethtool_ops = { |
| 684 | .get_settings = netxen_nic_get_settings, |
| 685 | .set_settings = netxen_nic_set_settings, |
| 686 | .get_drvinfo = netxen_nic_get_drvinfo, |
| 687 | .get_regs_len = netxen_nic_get_regs_len, |
| 688 | .get_regs = netxen_nic_get_regs, |
Amit S. Kale | e45d9ab | 2007-02-09 05:49:08 -0800 | [diff] [blame] | 689 | .get_link = ethtool_op_get_link, |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 690 | .get_eeprom_len = netxen_nic_get_eeprom_len, |
| 691 | .get_eeprom = netxen_nic_get_eeprom, |
Amit S. Kale | 27d2ab5 | 2007-02-05 07:40:49 -0800 | [diff] [blame] | 692 | .set_eeprom = netxen_nic_set_eeprom, |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 693 | .get_ringparam = netxen_nic_get_ringparam, |
| 694 | .get_pauseparam = netxen_nic_get_pauseparam, |
| 695 | .set_pauseparam = netxen_nic_set_pauseparam, |
| 696 | .get_tx_csum = ethtool_op_get_tx_csum, |
| 697 | .set_tx_csum = ethtool_op_set_tx_csum, |
| 698 | .get_sg = ethtool_op_get_sg, |
| 699 | .set_sg = ethtool_op_set_sg, |
| 700 | .get_tso = ethtool_op_get_tso, |
| 701 | .set_tso = ethtool_op_set_tso, |
| 702 | .self_test_count = netxen_nic_diag_test_count, |
| 703 | .self_test = netxen_nic_diag_test, |
| 704 | .get_strings = netxen_nic_get_strings, |
| 705 | .get_stats_count = netxen_nic_get_stats_count, |
| 706 | .get_ethtool_stats = netxen_nic_get_ethtool_stats, |
| 707 | .get_perm_addr = ethtool_op_get_perm_addr, |
| 708 | }; |