Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1 | /* |
Dhananjay Phadke | 5d242f1 | 2009-02-25 15:57:56 +0000 | [diff] [blame] | 2 | * Copyright (C) 2003 - 2009 NetXen, Inc. |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 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 |
Dhananjay Phadke | 5d242f1 | 2009-02-25 15:57:56 +0000 | [diff] [blame] | 25 | * NetXen Inc, |
| 26 | * 18922 Forge Drive |
| 27 | * Cupertino, CA 95014-0701 |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 28 | * |
| 29 | */ |
| 30 | |
| 31 | #include <linux/types.h> |
Amit S. Kale | 27d2ab5 | 2007-02-05 07:40:49 -0800 | [diff] [blame] | 32 | #include <linux/delay.h> |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 33 | #include <linux/pci.h> |
| 34 | #include <asm/io.h> |
| 35 | #include <linux/netdevice.h> |
| 36 | #include <linux/ethtool.h> |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 37 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 38 | #include "netxen_nic.h" |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 39 | #include "netxen_nic_hw.h" |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 40 | #include "netxen_nic_phan_reg.h" |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 41 | |
| 42 | struct netxen_nic_stats { |
| 43 | char stat_string[ETH_GSTRING_LEN]; |
| 44 | int sizeof_stat; |
| 45 | int stat_offset; |
| 46 | }; |
| 47 | |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 48 | #define NETXEN_NIC_STAT(m) sizeof(((struct netxen_adapter *)0)->m), \ |
| 49 | offsetof(struct netxen_adapter, m) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 50 | |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 51 | #define NETXEN_NIC_PORT_WINDOW 0x10000 |
| 52 | #define NETXEN_NIC_INVALID_DATA 0xDEADBEEF |
| 53 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 54 | static const struct netxen_nic_stats netxen_nic_gstrings_stats[] = { |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 55 | {"xmit_called", NETXEN_NIC_STAT(stats.xmitcalled)}, |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 56 | {"xmit_finished", NETXEN_NIC_STAT(stats.xmitfinished)}, |
Dhananjay Phadke | e98e335 | 2009-04-07 22:50:38 +0000 | [diff] [blame] | 57 | {"rx_dropped", NETXEN_NIC_STAT(stats.rxdropped)}, |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 58 | {"tx_dropped", NETXEN_NIC_STAT(stats.txdropped)}, |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 59 | {"csummed", NETXEN_NIC_STAT(stats.csummed)}, |
| 60 | {"no_rcv", NETXEN_NIC_STAT(stats.no_rcv)}, |
| 61 | {"rx_bytes", NETXEN_NIC_STAT(stats.rxbytes)}, |
| 62 | {"tx_bytes", NETXEN_NIC_STAT(stats.txbytes)}, |
| 63 | }; |
| 64 | |
Stephen Hemminger | 92104e9 | 2006-12-15 07:57:08 -0800 | [diff] [blame] | 65 | #define NETXEN_NIC_STATS_LEN ARRAY_SIZE(netxen_nic_gstrings_stats) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 66 | |
| 67 | static const char netxen_nic_gstrings_test[][ETH_GSTRING_LEN] = { |
Linsys Contractor Mithlesh Thukral | 0c25cfe | 2007-02-28 05:14:07 -0800 | [diff] [blame] | 68 | "Register_Test_on_offline", |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 69 | "Link_Test_on_offline" |
| 70 | }; |
| 71 | |
Alejandro Martinez Ruiz | 4c3616c | 2007-10-18 10:00:15 +0200 | [diff] [blame] | 72 | #define NETXEN_NIC_TEST_LEN ARRAY_SIZE(netxen_nic_gstrings_test) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 73 | |
| 74 | #define NETXEN_NIC_REGS_COUNT 42 |
| 75 | #define NETXEN_NIC_REGS_LEN (NETXEN_NIC_REGS_COUNT * sizeof(__le32)) |
| 76 | #define NETXEN_MAX_EEPROM_LEN 1024 |
| 77 | |
| 78 | static int netxen_nic_get_eeprom_len(struct net_device *dev) |
| 79 | { |
Mithlesh Thukral | 0d04761 | 2007-06-07 04:36:36 -0700 | [diff] [blame] | 80 | return NETXEN_FLASH_TOTAL_SIZE; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | static void |
| 84 | netxen_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) |
| 85 | { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 86 | struct netxen_adapter *adapter = netdev_priv(dev); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 87 | unsigned long flags; |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 88 | u32 fw_major = 0; |
| 89 | u32 fw_minor = 0; |
| 90 | u32 fw_build = 0; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 91 | |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 92 | strncpy(drvinfo->driver, netxen_nic_driver_name, 32); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 93 | strncpy(drvinfo->version, NETXEN_NIC_LINUX_VERSIONID, 32); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 94 | write_lock_irqsave(&adapter->adapter_lock, flags); |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 95 | fw_major = NXRD32(adapter, NETXEN_FW_VERSION_MAJOR); |
| 96 | fw_minor = NXRD32(adapter, NETXEN_FW_VERSION_MINOR); |
| 97 | fw_build = NXRD32(adapter, NETXEN_FW_VERSION_SUB); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 98 | write_unlock_irqrestore(&adapter->adapter_lock, flags); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 99 | sprintf(drvinfo->fw_version, "%d.%d.%d", fw_major, fw_minor, fw_build); |
| 100 | |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 101 | strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 102 | drvinfo->regdump_len = NETXEN_NIC_REGS_LEN; |
| 103 | drvinfo->eedump_len = netxen_nic_get_eeprom_len(dev); |
| 104 | } |
| 105 | |
| 106 | static int |
| 107 | netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) |
| 108 | { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 109 | struct netxen_adapter *adapter = netdev_priv(dev); |
Dhananjay Phadke | 3bf26ce | 2009-04-07 22:50:42 +0000 | [diff] [blame] | 110 | int check_sfp_module = 0; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 111 | |
| 112 | /* read which mode */ |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 113 | if (adapter->ahw.port_type == NETXEN_NIC_GBE) { |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 114 | ecmd->supported = (SUPPORTED_10baseT_Half | |
| 115 | SUPPORTED_10baseT_Full | |
| 116 | SUPPORTED_100baseT_Half | |
| 117 | SUPPORTED_100baseT_Full | |
| 118 | SUPPORTED_1000baseT_Half | |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 119 | SUPPORTED_1000baseT_Full); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 120 | |
| 121 | ecmd->advertising = (ADVERTISED_100baseT_Half | |
| 122 | ADVERTISED_100baseT_Full | |
| 123 | ADVERTISED_1000baseT_Half | |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 124 | ADVERTISED_1000baseT_Full); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 125 | |
| 126 | ecmd->port = PORT_TP; |
| 127 | |
Dhananjay Phadke | c7860a2 | 2009-01-14 20:48:32 -0800 | [diff] [blame] | 128 | ecmd->speed = adapter->link_speed; |
| 129 | ecmd->duplex = adapter->link_duplex; |
| 130 | ecmd->autoneg = adapter->link_autoneg; |
Dhananjay Phadke | 24a7a45 | 2008-08-01 03:14:55 -0700 | [diff] [blame] | 131 | |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 132 | } else if (adapter->ahw.port_type == NETXEN_NIC_XGBE) { |
Dhananjay Phadke | 24a7a45 | 2008-08-01 03:14:55 -0700 | [diff] [blame] | 133 | u32 val; |
| 134 | |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 135 | val = NXRD32(adapter, NETXEN_PORT_MODE_ADDR); |
Dhananjay Phadke | 24a7a45 | 2008-08-01 03:14:55 -0700 | [diff] [blame] | 136 | if (val == NETXEN_PORT_MODE_802_3_AP) { |
| 137 | ecmd->supported = SUPPORTED_1000baseT_Full; |
| 138 | ecmd->advertising = ADVERTISED_1000baseT_Full; |
| 139 | } else { |
| 140 | ecmd->supported = SUPPORTED_10000baseT_Full; |
| 141 | ecmd->advertising = ADVERTISED_10000baseT_Full; |
| 142 | } |
| 143 | |
Dhananjay Phadke | 3bf26ce | 2009-04-07 22:50:42 +0000 | [diff] [blame] | 144 | if (netif_running(dev) && adapter->has_link_events) { |
| 145 | ecmd->speed = adapter->link_speed; |
| 146 | ecmd->autoneg = adapter->link_autoneg; |
| 147 | ecmd->duplex = adapter->link_duplex; |
| 148 | goto skip; |
| 149 | } |
| 150 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 151 | ecmd->port = PORT_TP; |
| 152 | |
Dhananjay Phadke | 24a7a45 | 2008-08-01 03:14:55 -0700 | [diff] [blame] | 153 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { |
| 154 | u16 pcifn = adapter->ahw.pci_func; |
| 155 | |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 156 | val = NXRD32(adapter, P3_LINK_SPEED_REG(pcifn)); |
Dhananjay Phadke | 24a7a45 | 2008-08-01 03:14:55 -0700 | [diff] [blame] | 157 | ecmd->speed = P3_LINK_SPEED_MHZ * |
| 158 | P3_LINK_SPEED_VAL(pcifn, val); |
| 159 | } else |
| 160 | ecmd->speed = SPEED_10000; |
| 161 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 162 | ecmd->duplex = DUPLEX_FULL; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 163 | ecmd->autoneg = AUTONEG_DISABLE; |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 164 | } else |
| 165 | return -EIO; |
| 166 | |
Dhananjay Phadke | 3bf26ce | 2009-04-07 22:50:42 +0000 | [diff] [blame] | 167 | skip: |
Dhananjay Phadke | c7860a2 | 2009-01-14 20:48:32 -0800 | [diff] [blame] | 168 | ecmd->phy_address = adapter->physical_port; |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 169 | ecmd->transceiver = XCVR_EXTERNAL; |
| 170 | |
Dhananjay Phadke | e98e335 | 2009-04-07 22:50:38 +0000 | [diff] [blame] | 171 | switch (adapter->ahw.board_type) { |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 172 | case NETXEN_BRDTYPE_P2_SB35_4G: |
| 173 | case NETXEN_BRDTYPE_P2_SB31_2G: |
Dhananjay Phadke | e4c93c8 | 2008-07-21 19:44:02 -0700 | [diff] [blame] | 174 | case NETXEN_BRDTYPE_P3_REF_QG: |
| 175 | case NETXEN_BRDTYPE_P3_4_GB: |
| 176 | case NETXEN_BRDTYPE_P3_4_GB_MM: |
Dhananjay Phadke | e4c93c8 | 2008-07-21 19:44:02 -0700 | [diff] [blame] | 177 | |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 178 | ecmd->supported |= SUPPORTED_Autoneg; |
| 179 | ecmd->advertising |= ADVERTISED_Autoneg; |
| 180 | case NETXEN_BRDTYPE_P2_SB31_10G_CX4: |
Dhananjay Phadke | e4c93c8 | 2008-07-21 19:44:02 -0700 | [diff] [blame] | 181 | case NETXEN_BRDTYPE_P3_10G_CX4: |
| 182 | case NETXEN_BRDTYPE_P3_10G_CX4_LP: |
Dhananjay Phadke | c7860a2 | 2009-01-14 20:48:32 -0800 | [diff] [blame] | 183 | case NETXEN_BRDTYPE_P3_10000_BASE_T: |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 184 | ecmd->supported |= SUPPORTED_TP; |
| 185 | ecmd->advertising |= ADVERTISED_TP; |
| 186 | ecmd->port = PORT_TP; |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 187 | ecmd->autoneg = (adapter->ahw.board_type == |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 188 | NETXEN_BRDTYPE_P2_SB31_10G_CX4) ? |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 189 | (AUTONEG_DISABLE) : (adapter->link_autoneg); |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 190 | break; |
| 191 | case NETXEN_BRDTYPE_P2_SB31_10G_HMEZ: |
| 192 | case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ: |
Dhananjay Phadke | e4c93c8 | 2008-07-21 19:44:02 -0700 | [diff] [blame] | 193 | case NETXEN_BRDTYPE_P3_IMEZ: |
| 194 | case NETXEN_BRDTYPE_P3_XG_LOM: |
| 195 | case NETXEN_BRDTYPE_P3_HMEZ: |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 196 | ecmd->supported |= SUPPORTED_MII; |
| 197 | ecmd->advertising |= ADVERTISED_MII; |
Dhananjay Phadke | 3bf26ce | 2009-04-07 22:50:42 +0000 | [diff] [blame] | 198 | ecmd->port = PORT_MII; |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 199 | ecmd->autoneg = AUTONEG_DISABLE; |
| 200 | break; |
Dhananjay Phadke | e4c93c8 | 2008-07-21 19:44:02 -0700 | [diff] [blame] | 201 | case NETXEN_BRDTYPE_P3_10G_SFP_PLUS: |
Dhananjay Phadke | a70f939 | 2008-08-01 03:14:56 -0700 | [diff] [blame] | 202 | case NETXEN_BRDTYPE_P3_10G_SFP_CT: |
| 203 | case NETXEN_BRDTYPE_P3_10G_SFP_QT: |
Dhananjay Phadke | c7860a2 | 2009-01-14 20:48:32 -0800 | [diff] [blame] | 204 | ecmd->advertising |= ADVERTISED_TP; |
| 205 | ecmd->supported |= SUPPORTED_TP; |
Dhananjay Phadke | 3bf26ce | 2009-04-07 22:50:42 +0000 | [diff] [blame] | 206 | check_sfp_module = netif_running(dev) && |
| 207 | adapter->has_link_events; |
Dhananjay Phadke | c7860a2 | 2009-01-14 20:48:32 -0800 | [diff] [blame] | 208 | case NETXEN_BRDTYPE_P2_SB31_10G: |
Dhananjay Phadke | e4c93c8 | 2008-07-21 19:44:02 -0700 | [diff] [blame] | 209 | case NETXEN_BRDTYPE_P3_10G_XFP: |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 210 | ecmd->supported |= SUPPORTED_FIBRE; |
| 211 | ecmd->advertising |= ADVERTISED_FIBRE; |
| 212 | ecmd->port = PORT_FIBRE; |
| 213 | ecmd->autoneg = AUTONEG_DISABLE; |
| 214 | break; |
Dhananjay Phadke | c7860a2 | 2009-01-14 20:48:32 -0800 | [diff] [blame] | 215 | case NETXEN_BRDTYPE_P3_10G_TP: |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 216 | if (adapter->ahw.port_type == NETXEN_NIC_XGBE) { |
Dhananjay Phadke | c7860a2 | 2009-01-14 20:48:32 -0800 | [diff] [blame] | 217 | ecmd->autoneg = AUTONEG_DISABLE; |
| 218 | ecmd->supported |= (SUPPORTED_FIBRE | SUPPORTED_TP); |
| 219 | ecmd->advertising |= |
| 220 | (ADVERTISED_FIBRE | ADVERTISED_TP); |
| 221 | ecmd->port = PORT_FIBRE; |
Dhananjay Phadke | 3bf26ce | 2009-04-07 22:50:42 +0000 | [diff] [blame] | 222 | check_sfp_module = netif_running(dev) && |
| 223 | adapter->has_link_events; |
Dhananjay Phadke | c7860a2 | 2009-01-14 20:48:32 -0800 | [diff] [blame] | 224 | } else { |
| 225 | ecmd->autoneg = AUTONEG_ENABLE; |
| 226 | ecmd->supported |= (SUPPORTED_TP |SUPPORTED_Autoneg); |
| 227 | ecmd->advertising |= |
| 228 | (ADVERTISED_TP | ADVERTISED_Autoneg); |
| 229 | ecmd->port = PORT_TP; |
| 230 | } |
| 231 | break; |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 232 | default: |
Amit S. Kale | 71bd787 | 2006-12-01 05:36:22 -0800 | [diff] [blame] | 233 | printk(KERN_ERR "netxen-nic: Unsupported board model %d\n", |
Dhananjay Phadke | e98e335 | 2009-04-07 22:50:38 +0000 | [diff] [blame] | 234 | adapter->ahw.board_type); |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 235 | return -EIO; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 236 | } |
| 237 | |
Dhananjay Phadke | 3bf26ce | 2009-04-07 22:50:42 +0000 | [diff] [blame] | 238 | if (check_sfp_module) { |
| 239 | switch (adapter->module_type) { |
| 240 | case LINKEVENT_MODULE_OPTICAL_UNKNOWN: |
| 241 | case LINKEVENT_MODULE_OPTICAL_SRLR: |
| 242 | case LINKEVENT_MODULE_OPTICAL_LRM: |
| 243 | case LINKEVENT_MODULE_OPTICAL_SFP_1G: |
| 244 | ecmd->port = PORT_FIBRE; |
| 245 | break; |
| 246 | case LINKEVENT_MODULE_TWINAX_UNSUPPORTED_CABLE: |
| 247 | case LINKEVENT_MODULE_TWINAX_UNSUPPORTED_CABLELEN: |
| 248 | case LINKEVENT_MODULE_TWINAX: |
| 249 | ecmd->port = PORT_TP; |
Dhananjay Phadke | 5103c9f | 2009-04-28 15:29:09 +0000 | [diff] [blame] | 250 | break; |
Dhananjay Phadke | 3bf26ce | 2009-04-07 22:50:42 +0000 | [diff] [blame] | 251 | default: |
| 252 | ecmd->port = -1; |
| 253 | } |
| 254 | } |
| 255 | |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 256 | return 0; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | static int |
| 260 | netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) |
| 261 | { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 262 | struct netxen_adapter *adapter = netdev_priv(dev); |
Al Viro | a608ab9c | 2007-01-02 10:39:10 +0000 | [diff] [blame] | 263 | __u32 status; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 264 | |
| 265 | /* read which mode */ |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 266 | if (adapter->ahw.port_type == NETXEN_NIC_GBE) { |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 267 | /* autonegotiation */ |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 268 | if (adapter->phy_write |
Mithlesh Thukral | 13ba9c7 | 2007-04-20 07:53:05 -0700 | [diff] [blame] | 269 | && adapter->phy_write(adapter, |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 270 | NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG, |
Al Viro | a608ab9c | 2007-01-02 10:39:10 +0000 | [diff] [blame] | 271 | ecmd->autoneg) != 0) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 272 | return -EIO; |
| 273 | else |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 274 | adapter->link_autoneg = ecmd->autoneg; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 275 | |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 276 | if (adapter->phy_read |
Mithlesh Thukral | 13ba9c7 | 2007-04-20 07:53:05 -0700 | [diff] [blame] | 277 | && adapter->phy_read(adapter, |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 278 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, |
| 279 | &status) != 0) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 280 | return -EIO; |
| 281 | |
| 282 | /* speed */ |
| 283 | switch (ecmd->speed) { |
| 284 | case SPEED_10: |
| 285 | netxen_set_phy_speed(status, 0); |
| 286 | break; |
| 287 | case SPEED_100: |
| 288 | netxen_set_phy_speed(status, 1); |
| 289 | break; |
| 290 | case SPEED_1000: |
| 291 | netxen_set_phy_speed(status, 2); |
| 292 | break; |
| 293 | } |
| 294 | /* set duplex mode */ |
| 295 | if (ecmd->duplex == DUPLEX_HALF) |
| 296 | netxen_clear_phy_duplex(status); |
| 297 | if (ecmd->duplex == DUPLEX_FULL) |
| 298 | netxen_set_phy_duplex(status); |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 299 | if (adapter->phy_write |
Mithlesh Thukral | 13ba9c7 | 2007-04-20 07:53:05 -0700 | [diff] [blame] | 300 | && adapter->phy_write(adapter, |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 301 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, |
| 302 | *((int *)&status)) != 0) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 303 | return -EIO; |
| 304 | else { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 305 | adapter->link_speed = ecmd->speed; |
| 306 | adapter->link_duplex = ecmd->duplex; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 307 | } |
| 308 | } else |
| 309 | return -EOPNOTSUPP; |
| 310 | |
Stephen Hemminger | 1abd266 | 2008-11-21 17:32:15 -0800 | [diff] [blame] | 311 | if (!netif_running(dev)) |
| 312 | return 0; |
| 313 | |
| 314 | dev->netdev_ops->ndo_stop(dev); |
| 315 | return dev->netdev_ops->ndo_open(dev); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 316 | } |
| 317 | |
| 318 | static int netxen_nic_get_regs_len(struct net_device *dev) |
| 319 | { |
| 320 | return NETXEN_NIC_REGS_LEN; |
| 321 | } |
| 322 | |
| 323 | struct netxen_niu_regs { |
Al Viro | a608ab9c | 2007-01-02 10:39:10 +0000 | [diff] [blame] | 324 | __u32 reg[NETXEN_NIC_REGS_COUNT]; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 325 | }; |
| 326 | |
| 327 | static struct netxen_niu_regs niu_registers[] = { |
| 328 | { |
| 329 | /* GB Mode */ |
| 330 | { |
| 331 | NETXEN_NIU_GB_SERDES_RESET, |
| 332 | NETXEN_NIU_GB0_MII_MODE, |
| 333 | NETXEN_NIU_GB1_MII_MODE, |
| 334 | NETXEN_NIU_GB2_MII_MODE, |
| 335 | NETXEN_NIU_GB3_MII_MODE, |
| 336 | NETXEN_NIU_GB0_GMII_MODE, |
| 337 | NETXEN_NIU_GB1_GMII_MODE, |
| 338 | NETXEN_NIU_GB2_GMII_MODE, |
| 339 | NETXEN_NIU_GB3_GMII_MODE, |
| 340 | NETXEN_NIU_REMOTE_LOOPBACK, |
| 341 | NETXEN_NIU_GB0_HALF_DUPLEX, |
| 342 | NETXEN_NIU_GB1_HALF_DUPLEX, |
| 343 | NETXEN_NIU_RESET_SYS_FIFOS, |
| 344 | NETXEN_NIU_GB_CRC_DROP, |
| 345 | NETXEN_NIU_GB_DROP_WRONGADDR, |
| 346 | NETXEN_NIU_TEST_MUX_CTL, |
| 347 | |
| 348 | NETXEN_NIU_GB_MAC_CONFIG_0(0), |
| 349 | NETXEN_NIU_GB_MAC_CONFIG_1(0), |
| 350 | NETXEN_NIU_GB_HALF_DUPLEX_CTRL(0), |
| 351 | NETXEN_NIU_GB_MAX_FRAME_SIZE(0), |
| 352 | NETXEN_NIU_GB_TEST_REG(0), |
| 353 | NETXEN_NIU_GB_MII_MGMT_CONFIG(0), |
| 354 | NETXEN_NIU_GB_MII_MGMT_COMMAND(0), |
| 355 | NETXEN_NIU_GB_MII_MGMT_ADDR(0), |
| 356 | NETXEN_NIU_GB_MII_MGMT_CTRL(0), |
| 357 | NETXEN_NIU_GB_MII_MGMT_STATUS(0), |
| 358 | NETXEN_NIU_GB_MII_MGMT_INDICATE(0), |
| 359 | NETXEN_NIU_GB_INTERFACE_CTRL(0), |
| 360 | NETXEN_NIU_GB_INTERFACE_STATUS(0), |
| 361 | NETXEN_NIU_GB_STATION_ADDR_0(0), |
| 362 | NETXEN_NIU_GB_STATION_ADDR_1(0), |
| 363 | -1, |
| 364 | } |
| 365 | }, |
| 366 | { |
| 367 | /* XG Mode */ |
| 368 | { |
| 369 | NETXEN_NIU_XG_SINGLE_TERM, |
| 370 | NETXEN_NIU_XG_DRIVE_HI, |
| 371 | NETXEN_NIU_XG_DRIVE_LO, |
| 372 | NETXEN_NIU_XG_DTX, |
| 373 | NETXEN_NIU_XG_DEQ, |
| 374 | NETXEN_NIU_XG_WORD_ALIGN, |
| 375 | NETXEN_NIU_XG_RESET, |
| 376 | NETXEN_NIU_XG_POWER_DOWN, |
| 377 | NETXEN_NIU_XG_RESET_PLL, |
| 378 | NETXEN_NIU_XG_SERDES_LOOPBACK, |
| 379 | NETXEN_NIU_XG_DO_BYTE_ALIGN, |
| 380 | NETXEN_NIU_XG_TX_ENABLE, |
| 381 | NETXEN_NIU_XG_RX_ENABLE, |
| 382 | NETXEN_NIU_XG_STATUS, |
| 383 | NETXEN_NIU_XG_PAUSE_THRESHOLD, |
| 384 | NETXEN_NIU_XGE_CONFIG_0, |
| 385 | NETXEN_NIU_XGE_CONFIG_1, |
| 386 | NETXEN_NIU_XGE_IPG, |
| 387 | NETXEN_NIU_XGE_STATION_ADDR_0_HI, |
| 388 | NETXEN_NIU_XGE_STATION_ADDR_0_1, |
| 389 | NETXEN_NIU_XGE_STATION_ADDR_1_LO, |
| 390 | NETXEN_NIU_XGE_STATUS, |
| 391 | NETXEN_NIU_XGE_MAX_FRAME_SIZE, |
| 392 | NETXEN_NIU_XGE_PAUSE_FRAME_VALUE, |
| 393 | NETXEN_NIU_XGE_TX_BYTE_CNT, |
| 394 | NETXEN_NIU_XGE_TX_FRAME_CNT, |
| 395 | NETXEN_NIU_XGE_RX_BYTE_CNT, |
| 396 | NETXEN_NIU_XGE_RX_FRAME_CNT, |
| 397 | NETXEN_NIU_XGE_AGGR_ERROR_CNT, |
| 398 | NETXEN_NIU_XGE_MULTICAST_FRAME_CNT, |
| 399 | NETXEN_NIU_XGE_UNICAST_FRAME_CNT, |
| 400 | NETXEN_NIU_XGE_CRC_ERROR_CNT, |
| 401 | NETXEN_NIU_XGE_OVERSIZE_FRAME_ERR, |
| 402 | NETXEN_NIU_XGE_UNDERSIZE_FRAME_ERR, |
| 403 | NETXEN_NIU_XGE_LOCAL_ERROR_CNT, |
| 404 | NETXEN_NIU_XGE_REMOTE_ERROR_CNT, |
| 405 | NETXEN_NIU_XGE_CONTROL_CHAR_CNT, |
| 406 | NETXEN_NIU_XGE_PAUSE_FRAME_CNT, |
| 407 | -1, |
| 408 | } |
| 409 | } |
| 410 | }; |
| 411 | |
| 412 | static void |
| 413 | netxen_nic_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p) |
| 414 | { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 415 | struct netxen_adapter *adapter = netdev_priv(dev); |
Al Viro | a608ab9c | 2007-01-02 10:39:10 +0000 | [diff] [blame] | 416 | __u32 mode, *regs_buff = p; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 417 | int i, window; |
| 418 | |
| 419 | memset(p, 0, NETXEN_NIC_REGS_LEN); |
| 420 | regs->version = (1 << 24) | (adapter->ahw.revision_id << 16) | |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 421 | (adapter->pdev)->device; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 422 | /* which mode */ |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 423 | regs_buff[0] = NXRD32(adapter, NETXEN_NIU_MODE); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 424 | mode = regs_buff[0]; |
| 425 | |
| 426 | /* Common registers to all the modes */ |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 427 | regs_buff[2] = NXRD32(adapter, NETXEN_NIU_STRAP_VALUE_SAVE_HIGHER); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 428 | /* GB/XGB Mode */ |
| 429 | mode = (mode / 2) - 1; |
| 430 | window = 0; |
| 431 | if (mode <= 1) { |
| 432 | for (i = 3; niu_registers[mode].reg[i - 3] != -1; i++) { |
| 433 | /* GB: port specific registers */ |
| 434 | if (mode == 0 && i >= 19) |
Dhananjay Phadke | 3276fba | 2008-06-15 22:59:44 -0700 | [diff] [blame] | 435 | window = adapter->physical_port * |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 436 | NETXEN_NIC_PORT_WINDOW; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 437 | |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 438 | regs_buff[i] = NXRD32(adapter, |
Dhananjay Phadke | 1fbe632 | 2009-04-07 22:50:44 +0000 | [diff] [blame] | 439 | niu_registers[mode].reg[i - 3] + window); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 440 | } |
| 441 | |
| 442 | } |
| 443 | } |
| 444 | |
Amit S. Kale | e45d9ab | 2007-02-09 05:49:08 -0800 | [diff] [blame] | 445 | static u32 netxen_nic_test_link(struct net_device *dev) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 446 | { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 447 | struct netxen_adapter *adapter = netdev_priv(dev); |
Al Viro | a608ab9c | 2007-01-02 10:39:10 +0000 | [diff] [blame] | 448 | __u32 status; |
Linsys Contractor Mithlesh Thukral | 0c25cfe | 2007-02-28 05:14:07 -0800 | [diff] [blame] | 449 | int val; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 450 | |
| 451 | /* read which mode */ |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 452 | if (adapter->ahw.port_type == NETXEN_NIC_GBE) { |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 453 | if (adapter->phy_read |
Mithlesh Thukral | 13ba9c7 | 2007-04-20 07:53:05 -0700 | [diff] [blame] | 454 | && adapter->phy_read(adapter, |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 455 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, |
| 456 | &status) != 0) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 457 | return -EIO; |
Linsys Contractor Mithlesh Thukral | 0c25cfe | 2007-02-28 05:14:07 -0800 | [diff] [blame] | 458 | else { |
| 459 | val = netxen_get_phy_link(status); |
| 460 | return !val; |
| 461 | } |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 462 | } else if (adapter->ahw.port_type == NETXEN_NIC_XGBE) { |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 463 | val = NXRD32(adapter, CRB_XG_STATE); |
Linsys Contractor Mithlesh Thukral | 0c25cfe | 2007-02-28 05:14:07 -0800 | [diff] [blame] | 464 | return (val == XG_LINK_UP) ? 0 : 1; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 465 | } |
| 466 | return -EIO; |
| 467 | } |
| 468 | |
| 469 | static int |
| 470 | netxen_nic_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, |
| 471 | u8 * bytes) |
| 472 | { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 473 | struct netxen_adapter *adapter = netdev_priv(dev); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 474 | int offset; |
Amit S. Kale | 27d2ab5 | 2007-02-05 07:40:49 -0800 | [diff] [blame] | 475 | int ret; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 476 | |
| 477 | if (eeprom->len == 0) |
| 478 | return -EINVAL; |
| 479 | |
Jeff Garzik | 4790654 | 2007-11-23 21:23:36 -0500 | [diff] [blame] | 480 | eeprom->magic = (adapter->pdev)->vendor | |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 481 | ((adapter->pdev)->device << 16); |
Amit S. Kale | 27d2ab5 | 2007-02-05 07:40:49 -0800 | [diff] [blame] | 482 | offset = eeprom->offset; |
| 483 | |
Jeff Garzik | 4790654 | 2007-11-23 21:23:36 -0500 | [diff] [blame] | 484 | ret = netxen_rom_fast_read_words(adapter, offset, bytes, |
Amit S. Kale | 27d2ab5 | 2007-02-05 07:40:49 -0800 | [diff] [blame] | 485 | eeprom->len); |
| 486 | if (ret < 0) |
| 487 | return ret; |
| 488 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 489 | return 0; |
| 490 | } |
| 491 | |
| 492 | static void |
| 493 | netxen_nic_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring) |
| 494 | { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 495 | struct netxen_adapter *adapter = netdev_priv(dev); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 496 | |
| 497 | ring->rx_pending = 0; |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 498 | ring->rx_jumbo_pending = 0; |
Dhananjay Phadke | becf46a | 2009-03-09 08:50:55 +0000 | [diff] [blame] | 499 | ring->rx_pending += adapter->recv_ctx. |
Dhananjay Phadke | 438627c | 2009-03-13 14:52:03 +0000 | [diff] [blame] | 500 | rds_rings[RCV_RING_NORMAL].num_desc; |
Dhananjay Phadke | becf46a | 2009-03-09 08:50:55 +0000 | [diff] [blame] | 501 | ring->rx_jumbo_pending += adapter->recv_ctx. |
Dhananjay Phadke | 438627c | 2009-03-13 14:52:03 +0000 | [diff] [blame] | 502 | rds_rings[RCV_RING_JUMBO].num_desc; |
| 503 | ring->tx_pending = adapter->num_txd; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 504 | |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 505 | if (adapter->ahw.port_type == NETXEN_NIC_GBE) |
Dhananjay Phadke | 32ec803 | 2009-01-26 12:35:19 -0800 | [diff] [blame] | 506 | ring->rx_max_pending = MAX_RCV_DESCRIPTORS_1G; |
| 507 | else |
| 508 | ring->rx_max_pending = MAX_RCV_DESCRIPTORS_10G; |
Dhananjay Phadke | 200eef2 | 2007-09-03 10:33:35 +0530 | [diff] [blame] | 509 | ring->tx_max_pending = MAX_CMD_DESCRIPTORS_HOST; |
| 510 | ring->rx_jumbo_max_pending = MAX_JUMBO_RCV_DESCRIPTORS; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 511 | ring->rx_mini_max_pending = 0; |
| 512 | ring->rx_mini_pending = 0; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 513 | } |
| 514 | |
| 515 | static void |
| 516 | netxen_nic_get_pauseparam(struct net_device *dev, |
| 517 | struct ethtool_pauseparam *pause) |
| 518 | { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 519 | struct netxen_adapter *adapter = netdev_priv(dev); |
Al Viro | a608ab9c | 2007-01-02 10:39:10 +0000 | [diff] [blame] | 520 | __u32 val; |
Dhananjay Phadke | 3276fba | 2008-06-15 22:59:44 -0700 | [diff] [blame] | 521 | int port = adapter->physical_port; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 522 | |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 523 | if (adapter->ahw.port_type == NETXEN_NIC_GBE) { |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 524 | if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS)) |
| 525 | return; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 526 | /* get flow control settings */ |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 527 | val = NXRD32(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port)); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 528 | pause->rx_pause = netxen_gb_get_rx_flowctl(val); |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 529 | val = NXRD32(adapter, NETXEN_NIU_GB_PAUSE_CTL); |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 530 | switch (port) { |
| 531 | case 0: |
| 532 | pause->tx_pause = !(netxen_gb_get_gb0_mask(val)); |
| 533 | break; |
| 534 | case 1: |
| 535 | pause->tx_pause = !(netxen_gb_get_gb1_mask(val)); |
| 536 | break; |
| 537 | case 2: |
| 538 | pause->tx_pause = !(netxen_gb_get_gb2_mask(val)); |
| 539 | break; |
| 540 | case 3: |
| 541 | default: |
| 542 | pause->tx_pause = !(netxen_gb_get_gb3_mask(val)); |
| 543 | break; |
| 544 | } |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 545 | } else if (adapter->ahw.port_type == NETXEN_NIC_XGBE) { |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 546 | if ((port < 0) || (port > NETXEN_NIU_MAX_XG_PORTS)) |
| 547 | return; |
| 548 | pause->rx_pause = 1; |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 549 | val = NXRD32(adapter, NETXEN_NIU_XG_PAUSE_CTL); |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 550 | if (port == 0) |
| 551 | pause->tx_pause = !(netxen_xg_get_xg0_mask(val)); |
| 552 | else |
| 553 | pause->tx_pause = !(netxen_xg_get_xg1_mask(val)); |
| 554 | } else { |
Jeff Garzik | 4790654 | 2007-11-23 21:23:36 -0500 | [diff] [blame] | 555 | printk(KERN_ERR"%s: Unknown board type: %x\n", |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 556 | netxen_nic_driver_name, adapter->ahw.port_type); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 557 | } |
| 558 | } |
| 559 | |
| 560 | static int |
| 561 | netxen_nic_set_pauseparam(struct net_device *dev, |
| 562 | struct ethtool_pauseparam *pause) |
| 563 | { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 564 | struct netxen_adapter *adapter = netdev_priv(dev); |
Al Viro | a608ab9c | 2007-01-02 10:39:10 +0000 | [diff] [blame] | 565 | __u32 val; |
Dhananjay Phadke | 3276fba | 2008-06-15 22:59:44 -0700 | [diff] [blame] | 566 | int port = adapter->physical_port; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 567 | /* read mode */ |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 568 | if (adapter->ahw.port_type == NETXEN_NIC_GBE) { |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 569 | if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS)) |
| 570 | return -EIO; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 571 | /* set flow control */ |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 572 | val = NXRD32(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port)); |
Jeff Garzik | 4790654 | 2007-11-23 21:23:36 -0500 | [diff] [blame] | 573 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 574 | if (pause->rx_pause) |
| 575 | netxen_gb_rx_flowctl(val); |
| 576 | else |
| 577 | netxen_gb_unset_rx_flowctl(val); |
| 578 | |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 579 | NXWR32(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port), |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 580 | val); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 581 | /* set autoneg */ |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 582 | val = NXRD32(adapter, NETXEN_NIU_GB_PAUSE_CTL); |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 583 | switch (port) { |
| 584 | case 0: |
| 585 | if (pause->tx_pause) |
| 586 | netxen_gb_unset_gb0_mask(val); |
| 587 | else |
| 588 | netxen_gb_set_gb0_mask(val); |
| 589 | break; |
| 590 | case 1: |
| 591 | if (pause->tx_pause) |
| 592 | netxen_gb_unset_gb1_mask(val); |
| 593 | else |
| 594 | netxen_gb_set_gb1_mask(val); |
| 595 | break; |
| 596 | case 2: |
| 597 | if (pause->tx_pause) |
| 598 | netxen_gb_unset_gb2_mask(val); |
| 599 | else |
| 600 | netxen_gb_set_gb2_mask(val); |
| 601 | break; |
| 602 | case 3: |
| 603 | default: |
| 604 | if (pause->tx_pause) |
| 605 | netxen_gb_unset_gb3_mask(val); |
| 606 | else |
| 607 | netxen_gb_set_gb3_mask(val); |
| 608 | break; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 609 | } |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 610 | NXWR32(adapter, NETXEN_NIU_GB_PAUSE_CTL, val); |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 611 | } else if (adapter->ahw.port_type == NETXEN_NIC_XGBE) { |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 612 | if ((port < 0) || (port > NETXEN_NIU_MAX_XG_PORTS)) |
| 613 | return -EIO; |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 614 | val = NXRD32(adapter, NETXEN_NIU_XG_PAUSE_CTL); |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 615 | if (port == 0) { |
| 616 | if (pause->tx_pause) |
| 617 | netxen_xg_unset_xg0_mask(val); |
| 618 | else |
| 619 | netxen_xg_set_xg0_mask(val); |
| 620 | } else { |
| 621 | if (pause->tx_pause) |
| 622 | netxen_xg_unset_xg1_mask(val); |
| 623 | else |
| 624 | netxen_xg_set_xg1_mask(val); |
| 625 | } |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 626 | NXWR32(adapter, NETXEN_NIU_XG_PAUSE_CTL, val); |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 627 | } else { |
| 628 | printk(KERN_ERR "%s: Unknown board type: %x\n", |
Jeff Garzik | 4790654 | 2007-11-23 21:23:36 -0500 | [diff] [blame] | 629 | netxen_nic_driver_name, |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 630 | adapter->ahw.port_type); |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 631 | } |
| 632 | return 0; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 633 | } |
| 634 | |
| 635 | static int netxen_nic_reg_test(struct net_device *dev) |
| 636 | { |
Linsys Contractor Mithlesh Thukral | 0c25cfe | 2007-02-28 05:14:07 -0800 | [diff] [blame] | 637 | struct netxen_adapter *adapter = netdev_priv(dev); |
| 638 | u32 data_read, data_written; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 639 | |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 640 | data_read = NXRD32(adapter, NETXEN_PCIX_PH_REG(0)); |
Linsys Contractor Mithlesh Thukral | 0c25cfe | 2007-02-28 05:14:07 -0800 | [diff] [blame] | 641 | if ((data_read & 0xffff) != PHAN_VENDOR_ID) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 642 | return 1; |
Linsys Contractor Mithlesh Thukral | 0c25cfe | 2007-02-28 05:14:07 -0800 | [diff] [blame] | 643 | |
| 644 | data_written = (u32)0xa5a5a5a5; |
| 645 | |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 646 | NXWR32(adapter, CRB_SCRATCHPAD_TEST, data_written); |
| 647 | data_read = NXRD32(adapter, CRB_SCRATCHPAD_TEST); |
Linsys Contractor Mithlesh Thukral | 0c25cfe | 2007-02-28 05:14:07 -0800 | [diff] [blame] | 648 | if (data_written != data_read) |
| 649 | return 1; |
| 650 | |
| 651 | return 0; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 652 | } |
| 653 | |
Jeff Garzik | b9f2c04 | 2007-10-03 18:07:32 -0700 | [diff] [blame] | 654 | static int netxen_get_sset_count(struct net_device *dev, int sset) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 655 | { |
Jeff Garzik | b9f2c04 | 2007-10-03 18:07:32 -0700 | [diff] [blame] | 656 | switch (sset) { |
| 657 | case ETH_SS_TEST: |
| 658 | return NETXEN_NIC_TEST_LEN; |
| 659 | case ETH_SS_STATS: |
| 660 | return NETXEN_NIC_STATS_LEN; |
| 661 | default: |
| 662 | return -EOPNOTSUPP; |
| 663 | } |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 664 | } |
| 665 | |
| 666 | static void |
| 667 | netxen_nic_diag_test(struct net_device *dev, struct ethtool_test *eth_test, |
| 668 | u64 * data) |
| 669 | { |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 670 | memset(data, 0, sizeof(uint64_t) * NETXEN_NIC_TEST_LEN); |
| 671 | if ((data[0] = netxen_nic_reg_test(dev))) |
| 672 | eth_test->flags |= ETH_TEST_FL_FAILED; |
| 673 | /* link test */ |
| 674 | if ((data[1] = (u64) netxen_nic_test_link(dev))) |
| 675 | eth_test->flags |= ETH_TEST_FL_FAILED; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 676 | } |
| 677 | |
| 678 | static void |
| 679 | netxen_nic_get_strings(struct net_device *dev, u32 stringset, u8 * data) |
| 680 | { |
| 681 | int index; |
| 682 | |
| 683 | switch (stringset) { |
| 684 | case ETH_SS_TEST: |
| 685 | memcpy(data, *netxen_nic_gstrings_test, |
| 686 | NETXEN_NIC_TEST_LEN * ETH_GSTRING_LEN); |
| 687 | break; |
| 688 | case ETH_SS_STATS: |
| 689 | for (index = 0; index < NETXEN_NIC_STATS_LEN; index++) { |
| 690 | memcpy(data + index * ETH_GSTRING_LEN, |
| 691 | netxen_nic_gstrings_stats[index].stat_string, |
| 692 | ETH_GSTRING_LEN); |
| 693 | } |
| 694 | break; |
| 695 | } |
| 696 | } |
| 697 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 698 | static void |
| 699 | netxen_nic_get_ethtool_stats(struct net_device *dev, |
| 700 | struct ethtool_stats *stats, u64 * data) |
| 701 | { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 702 | struct netxen_adapter *adapter = netdev_priv(dev); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 703 | int index; |
| 704 | |
| 705 | for (index = 0; index < NETXEN_NIC_STATS_LEN; index++) { |
| 706 | char *p = |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 707 | (char *)adapter + |
| 708 | netxen_nic_gstrings_stats[index].stat_offset; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 709 | data[index] = |
| 710 | (netxen_nic_gstrings_stats[index].sizeof_stat == |
| 711 | sizeof(u64)) ? *(u64 *) p : *(u32 *) p; |
| 712 | } |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 713 | } |
| 714 | |
Dhananjay Phadke | 200eef2 | 2007-09-03 10:33:35 +0530 | [diff] [blame] | 715 | static u32 netxen_nic_get_rx_csum(struct net_device *dev) |
| 716 | { |
| 717 | struct netxen_adapter *adapter = netdev_priv(dev); |
| 718 | return adapter->rx_csum; |
| 719 | } |
| 720 | |
| 721 | static int netxen_nic_set_rx_csum(struct net_device *dev, u32 data) |
| 722 | { |
| 723 | struct netxen_adapter *adapter = netdev_priv(dev); |
| 724 | adapter->rx_csum = !!data; |
| 725 | return 0; |
| 726 | } |
| 727 | |
Dhananjay Phadke | cd1f816 | 2008-07-21 19:44:09 -0700 | [diff] [blame] | 728 | static u32 netxen_nic_get_tso(struct net_device *dev) |
| 729 | { |
| 730 | struct netxen_adapter *adapter = netdev_priv(dev); |
| 731 | |
| 732 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) |
| 733 | return (dev->features & (NETIF_F_TSO | NETIF_F_TSO6)) != 0; |
| 734 | |
| 735 | return (dev->features & NETIF_F_TSO) != 0; |
| 736 | } |
| 737 | |
| 738 | static int netxen_nic_set_tso(struct net_device *dev, u32 data) |
| 739 | { |
| 740 | if (data) { |
| 741 | struct netxen_adapter *adapter = netdev_priv(dev); |
| 742 | |
| 743 | dev->features |= NETIF_F_TSO; |
| 744 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) |
| 745 | dev->features |= NETIF_F_TSO6; |
| 746 | } else |
| 747 | dev->features &= ~(NETIF_F_TSO | NETIF_F_TSO6); |
| 748 | |
| 749 | return 0; |
| 750 | } |
| 751 | |
Dhananjay Phadke | 4da1294 | 2009-02-24 16:38:44 -0800 | [diff] [blame] | 752 | static void |
| 753 | netxen_nic_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) |
| 754 | { |
| 755 | struct netxen_adapter *adapter = netdev_priv(dev); |
| 756 | u32 wol_cfg = 0; |
| 757 | |
| 758 | wol->supported = 0; |
| 759 | wol->wolopts = 0; |
| 760 | |
| 761 | if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) |
| 762 | return; |
| 763 | |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 764 | wol_cfg = NXRD32(adapter, NETXEN_WOL_CONFIG_NV); |
Dhananjay Phadke | 4da1294 | 2009-02-24 16:38:44 -0800 | [diff] [blame] | 765 | if (wol_cfg & (1UL << adapter->portnum)) |
| 766 | wol->supported |= WAKE_MAGIC; |
| 767 | |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 768 | wol_cfg = NXRD32(adapter, NETXEN_WOL_CONFIG); |
Dhananjay Phadke | 4da1294 | 2009-02-24 16:38:44 -0800 | [diff] [blame] | 769 | if (wol_cfg & (1UL << adapter->portnum)) |
| 770 | wol->wolopts |= WAKE_MAGIC; |
| 771 | } |
| 772 | |
| 773 | static int |
| 774 | netxen_nic_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) |
| 775 | { |
| 776 | struct netxen_adapter *adapter = netdev_priv(dev); |
| 777 | u32 wol_cfg = 0; |
| 778 | |
| 779 | if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) |
| 780 | return -EOPNOTSUPP; |
| 781 | |
| 782 | if (wol->wolopts & ~WAKE_MAGIC) |
| 783 | return -EOPNOTSUPP; |
| 784 | |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 785 | wol_cfg = NXRD32(adapter, NETXEN_WOL_CONFIG_NV); |
Dhananjay Phadke | 4da1294 | 2009-02-24 16:38:44 -0800 | [diff] [blame] | 786 | if (!(wol_cfg & (1 << adapter->portnum))) |
| 787 | return -EOPNOTSUPP; |
| 788 | |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 789 | wol_cfg = NXRD32(adapter, NETXEN_WOL_CONFIG); |
Dhananjay Phadke | 4da1294 | 2009-02-24 16:38:44 -0800 | [diff] [blame] | 790 | if (wol->wolopts & WAKE_MAGIC) |
| 791 | wol_cfg |= 1UL << adapter->portnum; |
| 792 | else |
| 793 | wol_cfg &= ~(1UL << adapter->portnum); |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 794 | NXWR32(adapter, NETXEN_WOL_CONFIG, wol_cfg); |
Dhananjay Phadke | 4da1294 | 2009-02-24 16:38:44 -0800 | [diff] [blame] | 795 | |
| 796 | return 0; |
| 797 | } |
| 798 | |
Dhananjay Phadke | cd1f816 | 2008-07-21 19:44:09 -0700 | [diff] [blame] | 799 | /* |
| 800 | * Set the coalescing parameters. Currently only normal is supported. |
| 801 | * If rx_coalesce_usecs == 0 or rx_max_coalesced_frames == 0 then set the |
| 802 | * firmware coalescing to default. |
| 803 | */ |
| 804 | static int netxen_set_intr_coalesce(struct net_device *netdev, |
| 805 | struct ethtool_coalesce *ethcoal) |
| 806 | { |
| 807 | struct netxen_adapter *adapter = netdev_priv(netdev); |
| 808 | |
| 809 | if (!NX_IS_REVISION_P3(adapter->ahw.revision_id)) |
| 810 | return -EINVAL; |
| 811 | |
| 812 | if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC) |
| 813 | return -EINVAL; |
| 814 | |
| 815 | /* |
| 816 | * Return Error if unsupported values or |
| 817 | * unsupported parameters are set. |
| 818 | */ |
| 819 | if (ethcoal->rx_coalesce_usecs > 0xffff || |
| 820 | ethcoal->rx_max_coalesced_frames > 0xffff || |
| 821 | ethcoal->tx_coalesce_usecs > 0xffff || |
| 822 | ethcoal->tx_max_coalesced_frames > 0xffff || |
| 823 | ethcoal->rx_coalesce_usecs_irq || |
| 824 | ethcoal->rx_max_coalesced_frames_irq || |
| 825 | ethcoal->tx_coalesce_usecs_irq || |
| 826 | ethcoal->tx_max_coalesced_frames_irq || |
| 827 | ethcoal->stats_block_coalesce_usecs || |
| 828 | ethcoal->use_adaptive_rx_coalesce || |
| 829 | ethcoal->use_adaptive_tx_coalesce || |
| 830 | ethcoal->pkt_rate_low || |
| 831 | ethcoal->rx_coalesce_usecs_low || |
| 832 | ethcoal->rx_max_coalesced_frames_low || |
| 833 | ethcoal->tx_coalesce_usecs_low || |
| 834 | ethcoal->tx_max_coalesced_frames_low || |
| 835 | ethcoal->pkt_rate_high || |
| 836 | ethcoal->rx_coalesce_usecs_high || |
| 837 | ethcoal->rx_max_coalesced_frames_high || |
| 838 | ethcoal->tx_coalesce_usecs_high || |
| 839 | ethcoal->tx_max_coalesced_frames_high) |
| 840 | return -EINVAL; |
| 841 | |
| 842 | if (!ethcoal->rx_coalesce_usecs || |
| 843 | !ethcoal->rx_max_coalesced_frames) { |
| 844 | adapter->coal.flags = NETXEN_NIC_INTR_DEFAULT; |
| 845 | adapter->coal.normal.data.rx_time_us = |
| 846 | NETXEN_DEFAULT_INTR_COALESCE_RX_TIME_US; |
| 847 | adapter->coal.normal.data.rx_packets = |
| 848 | NETXEN_DEFAULT_INTR_COALESCE_RX_PACKETS; |
| 849 | } else { |
| 850 | adapter->coal.flags = 0; |
| 851 | adapter->coal.normal.data.rx_time_us = |
| 852 | ethcoal->rx_coalesce_usecs; |
| 853 | adapter->coal.normal.data.rx_packets = |
| 854 | ethcoal->rx_max_coalesced_frames; |
| 855 | } |
| 856 | adapter->coal.normal.data.tx_time_us = ethcoal->tx_coalesce_usecs; |
| 857 | adapter->coal.normal.data.tx_packets = |
| 858 | ethcoal->tx_max_coalesced_frames; |
| 859 | |
| 860 | netxen_config_intr_coalesce(adapter); |
| 861 | |
| 862 | return 0; |
| 863 | } |
| 864 | |
| 865 | static int netxen_get_intr_coalesce(struct net_device *netdev, |
| 866 | struct ethtool_coalesce *ethcoal) |
| 867 | { |
| 868 | struct netxen_adapter *adapter = netdev_priv(netdev); |
| 869 | |
| 870 | if (!NX_IS_REVISION_P3(adapter->ahw.revision_id)) |
| 871 | return -EINVAL; |
| 872 | |
| 873 | if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC) |
| 874 | return -EINVAL; |
| 875 | |
| 876 | ethcoal->rx_coalesce_usecs = adapter->coal.normal.data.rx_time_us; |
| 877 | ethcoal->tx_coalesce_usecs = adapter->coal.normal.data.tx_time_us; |
| 878 | ethcoal->rx_max_coalesced_frames = |
| 879 | adapter->coal.normal.data.rx_packets; |
| 880 | ethcoal->tx_max_coalesced_frames = |
| 881 | adapter->coal.normal.data.tx_packets; |
| 882 | |
| 883 | return 0; |
| 884 | } |
| 885 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 886 | struct ethtool_ops netxen_nic_ethtool_ops = { |
| 887 | .get_settings = netxen_nic_get_settings, |
| 888 | .set_settings = netxen_nic_set_settings, |
| 889 | .get_drvinfo = netxen_nic_get_drvinfo, |
| 890 | .get_regs_len = netxen_nic_get_regs_len, |
| 891 | .get_regs = netxen_nic_get_regs, |
Amit S. Kale | e45d9ab | 2007-02-09 05:49:08 -0800 | [diff] [blame] | 892 | .get_link = ethtool_op_get_link, |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 893 | .get_eeprom_len = netxen_nic_get_eeprom_len, |
| 894 | .get_eeprom = netxen_nic_get_eeprom, |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 895 | .get_ringparam = netxen_nic_get_ringparam, |
| 896 | .get_pauseparam = netxen_nic_get_pauseparam, |
| 897 | .set_pauseparam = netxen_nic_set_pauseparam, |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 898 | .set_tx_csum = ethtool_op_set_tx_csum, |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 899 | .set_sg = ethtool_op_set_sg, |
Dhananjay Phadke | cd1f816 | 2008-07-21 19:44:09 -0700 | [diff] [blame] | 900 | .get_tso = netxen_nic_get_tso, |
| 901 | .set_tso = netxen_nic_set_tso, |
Dhananjay Phadke | 4da1294 | 2009-02-24 16:38:44 -0800 | [diff] [blame] | 902 | .get_wol = netxen_nic_get_wol, |
| 903 | .set_wol = netxen_nic_set_wol, |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 904 | .self_test = netxen_nic_diag_test, |
| 905 | .get_strings = netxen_nic_get_strings, |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 906 | .get_ethtool_stats = netxen_nic_get_ethtool_stats, |
Jeff Garzik | b9f2c04 | 2007-10-03 18:07:32 -0700 | [diff] [blame] | 907 | .get_sset_count = netxen_get_sset_count, |
Dhananjay Phadke | 200eef2 | 2007-09-03 10:33:35 +0530 | [diff] [blame] | 908 | .get_rx_csum = netxen_nic_get_rx_csum, |
| 909 | .set_rx_csum = netxen_nic_set_rx_csum, |
Dhananjay Phadke | cd1f816 | 2008-07-21 19:44:09 -0700 | [diff] [blame] | 910 | .get_coalesce = netxen_get_intr_coalesce, |
| 911 | .set_coalesce = netxen_set_intr_coalesce, |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 912 | }; |