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