2006-10-22 03:33:03 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2003 - 2006 NetXen, Inc.
|
|
|
|
* All rights reserved.
|
2006-12-05 01:18:00 +08:00
|
|
|
*
|
2006-10-22 03:33:03 +08:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2006-12-05 01:18:00 +08:00
|
|
|
*
|
2006-10-22 03:33:03 +08:00
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2006-12-05 01:18:00 +08:00
|
|
|
*
|
2006-10-22 03:33:03 +08:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
|
|
|
* MA 02111-1307, USA.
|
2006-12-05 01:18:00 +08:00
|
|
|
*
|
2006-10-22 03:33:03 +08:00
|
|
|
* The full GNU General Public License is included in this distribution
|
|
|
|
* in the file called LICENSE.
|
2006-12-05 01:18:00 +08:00
|
|
|
*
|
2006-10-22 03:33:03 +08:00
|
|
|
* Contact Information:
|
|
|
|
* info@netxen.com
|
|
|
|
* NetXen,
|
|
|
|
* 3965 Freedom Circle, Fourth floor,
|
|
|
|
* Santa Clara, CA 95054
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* ethtool support for netxen nic
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
2007-02-05 23:40:49 +08:00
|
|
|
#include <linux/delay.h>
|
2006-10-22 03:33:03 +08:00
|
|
|
#include <asm/uaccess.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/ethtool.h>
|
|
|
|
#include <linux/version.h>
|
|
|
|
|
|
|
|
#include "netxen_nic.h"
|
2007-04-20 22:55:26 +08:00
|
|
|
#include "netxen_nic_hw.h"
|
2006-10-22 03:33:03 +08:00
|
|
|
#include "netxen_nic_phan_reg.h"
|
|
|
|
|
|
|
|
struct netxen_nic_stats {
|
|
|
|
char stat_string[ETH_GSTRING_LEN];
|
|
|
|
int sizeof_stat;
|
|
|
|
int stat_offset;
|
|
|
|
};
|
|
|
|
|
2007-04-20 22:52:37 +08:00
|
|
|
#define NETXEN_NIC_STAT(m) sizeof(((struct netxen_adapter *)0)->m), \
|
|
|
|
offsetof(struct netxen_adapter, m)
|
2006-10-22 03:33:03 +08:00
|
|
|
|
2006-11-30 01:00:10 +08:00
|
|
|
#define NETXEN_NIC_PORT_WINDOW 0x10000
|
|
|
|
#define NETXEN_NIC_INVALID_DATA 0xDEADBEEF
|
|
|
|
|
2006-10-22 03:33:03 +08:00
|
|
|
static const struct netxen_nic_stats netxen_nic_gstrings_stats[] = {
|
|
|
|
{"rcvd_bad_skb", NETXEN_NIC_STAT(stats.rcvdbadskb)},
|
|
|
|
{"xmit_called", NETXEN_NIC_STAT(stats.xmitcalled)},
|
|
|
|
{"xmited_frames", NETXEN_NIC_STAT(stats.xmitedframes)},
|
|
|
|
{"xmit_finished", NETXEN_NIC_STAT(stats.xmitfinished)},
|
|
|
|
{"bad_skb_len", NETXEN_NIC_STAT(stats.badskblen)},
|
|
|
|
{"no_cmd_desc", NETXEN_NIC_STAT(stats.nocmddescriptor)},
|
|
|
|
{"polled", NETXEN_NIC_STAT(stats.polled)},
|
|
|
|
{"tx_dropped", NETXEN_NIC_STAT(stats.txdropped)},
|
|
|
|
{"csummed", NETXEN_NIC_STAT(stats.csummed)},
|
|
|
|
{"no_rcv", NETXEN_NIC_STAT(stats.no_rcv)},
|
|
|
|
{"rx_bytes", NETXEN_NIC_STAT(stats.rxbytes)},
|
|
|
|
{"tx_bytes", NETXEN_NIC_STAT(stats.txbytes)},
|
|
|
|
};
|
|
|
|
|
2006-12-15 23:57:08 +08:00
|
|
|
#define NETXEN_NIC_STATS_LEN ARRAY_SIZE(netxen_nic_gstrings_stats)
|
2006-10-22 03:33:03 +08:00
|
|
|
|
|
|
|
static const char netxen_nic_gstrings_test[][ETH_GSTRING_LEN] = {
|
2007-02-28 21:14:07 +08:00
|
|
|
"Register_Test_on_offline",
|
2006-10-22 03:33:03 +08:00
|
|
|
"Link_Test_on_offline"
|
|
|
|
};
|
|
|
|
|
2007-10-18 16:00:15 +08:00
|
|
|
#define NETXEN_NIC_TEST_LEN ARRAY_SIZE(netxen_nic_gstrings_test)
|
2006-10-22 03:33:03 +08:00
|
|
|
|
|
|
|
#define NETXEN_NIC_REGS_COUNT 42
|
|
|
|
#define NETXEN_NIC_REGS_LEN (NETXEN_NIC_REGS_COUNT * sizeof(__le32))
|
|
|
|
#define NETXEN_MAX_EEPROM_LEN 1024
|
|
|
|
|
|
|
|
static int netxen_nic_get_eeprom_len(struct net_device *dev)
|
|
|
|
{
|
2007-06-07 19:36:36 +08:00
|
|
|
return NETXEN_FLASH_TOTAL_SIZE;
|
2006-10-22 03:33:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
netxen_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo)
|
|
|
|
{
|
2007-04-20 22:52:37 +08:00
|
|
|
struct netxen_adapter *adapter = netdev_priv(dev);
|
2006-11-30 01:00:10 +08:00
|
|
|
u32 fw_major = 0;
|
|
|
|
u32 fw_minor = 0;
|
|
|
|
u32 fw_build = 0;
|
2006-10-22 03:33:03 +08:00
|
|
|
|
2006-12-05 01:18:00 +08:00
|
|
|
strncpy(drvinfo->driver, netxen_nic_driver_name, 32);
|
2006-10-22 03:33:03 +08:00
|
|
|
strncpy(drvinfo->version, NETXEN_NIC_LINUX_VERSIONID, 32);
|
|
|
|
fw_major = readl(NETXEN_CRB_NORMALIZE(adapter,
|
|
|
|
NETXEN_FW_VERSION_MAJOR));
|
|
|
|
fw_minor = readl(NETXEN_CRB_NORMALIZE(adapter,
|
|
|
|
NETXEN_FW_VERSION_MINOR));
|
|
|
|
fw_build = readl(NETXEN_CRB_NORMALIZE(adapter, NETXEN_FW_VERSION_SUB));
|
|
|
|
sprintf(drvinfo->fw_version, "%d.%d.%d", fw_major, fw_minor, fw_build);
|
|
|
|
|
2007-04-20 22:52:37 +08:00
|
|
|
strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32);
|
2006-10-22 03:33:03 +08:00
|
|
|
drvinfo->regdump_len = NETXEN_NIC_REGS_LEN;
|
|
|
|
drvinfo->eedump_len = netxen_nic_get_eeprom_len(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
|
|
|
|
{
|
2007-04-20 22:52:37 +08:00
|
|
|
struct netxen_adapter *adapter = netdev_priv(dev);
|
2006-12-01 21:36:22 +08:00
|
|
|
struct netxen_board_info *boardinfo = &adapter->ahw.boardcfg;
|
2006-10-22 03:33:03 +08:00
|
|
|
|
|
|
|
/* read which mode */
|
|
|
|
if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
|
|
|
|
ecmd->supported = (SUPPORTED_10baseT_Half |
|
|
|
|
SUPPORTED_10baseT_Full |
|
|
|
|
SUPPORTED_100baseT_Half |
|
|
|
|
SUPPORTED_100baseT_Full |
|
|
|
|
SUPPORTED_1000baseT_Half |
|
2006-11-30 01:00:10 +08:00
|
|
|
SUPPORTED_1000baseT_Full);
|
2006-10-22 03:33:03 +08:00
|
|
|
|
|
|
|
ecmd->advertising = (ADVERTISED_100baseT_Half |
|
|
|
|
ADVERTISED_100baseT_Full |
|
|
|
|
ADVERTISED_1000baseT_Half |
|
2006-11-30 01:00:10 +08:00
|
|
|
ADVERTISED_1000baseT_Full);
|
2006-10-22 03:33:03 +08:00
|
|
|
|
|
|
|
ecmd->port = PORT_TP;
|
|
|
|
|
|
|
|
if (netif_running(dev)) {
|
2007-04-20 22:52:37 +08:00
|
|
|
ecmd->speed = adapter->link_speed;
|
|
|
|
ecmd->duplex = adapter->link_duplex;
|
2006-10-22 03:33:03 +08:00
|
|
|
} else
|
|
|
|
return -EIO; /* link absent */
|
2006-11-30 01:00:10 +08:00
|
|
|
} else if (adapter->ahw.board_type == NETXEN_NIC_XGBE) {
|
2006-10-22 03:33:03 +08:00
|
|
|
ecmd->supported = (SUPPORTED_TP |
|
|
|
|
SUPPORTED_1000baseT_Full |
|
|
|
|
SUPPORTED_10000baseT_Full);
|
|
|
|
ecmd->advertising = (ADVERTISED_TP |
|
|
|
|
ADVERTISED_1000baseT_Full |
|
|
|
|
ADVERTISED_10000baseT_Full);
|
|
|
|
ecmd->port = PORT_TP;
|
|
|
|
|
|
|
|
ecmd->speed = SPEED_10000;
|
|
|
|
ecmd->duplex = DUPLEX_FULL;
|
|
|
|
ecmd->autoneg = AUTONEG_DISABLE;
|
2006-11-30 01:00:10 +08:00
|
|
|
} else
|
|
|
|
return -EIO;
|
|
|
|
|
2007-04-20 22:52:37 +08:00
|
|
|
ecmd->phy_address = adapter->portnum;
|
2006-11-30 01:00:10 +08:00
|
|
|
ecmd->transceiver = XCVR_EXTERNAL;
|
|
|
|
|
|
|
|
switch ((netxen_brdtype_t) boardinfo->board_type) {
|
|
|
|
case NETXEN_BRDTYPE_P2_SB35_4G:
|
|
|
|
case NETXEN_BRDTYPE_P2_SB31_2G:
|
2008-07-22 10:44:02 +08:00
|
|
|
case NETXEN_BRDTYPE_P3_REF_QG:
|
|
|
|
case NETXEN_BRDTYPE_P3_4_GB:
|
|
|
|
case NETXEN_BRDTYPE_P3_4_GB_MM:
|
|
|
|
case NETXEN_BRDTYPE_P3_10000_BASE_T:
|
|
|
|
|
2006-11-30 01:00:10 +08:00
|
|
|
ecmd->supported |= SUPPORTED_Autoneg;
|
|
|
|
ecmd->advertising |= ADVERTISED_Autoneg;
|
|
|
|
case NETXEN_BRDTYPE_P2_SB31_10G_CX4:
|
2008-07-22 10:44:02 +08:00
|
|
|
case NETXEN_BRDTYPE_P3_10G_CX4:
|
|
|
|
case NETXEN_BRDTYPE_P3_10G_CX4_LP:
|
2006-11-30 01:00:10 +08:00
|
|
|
ecmd->supported |= SUPPORTED_TP;
|
|
|
|
ecmd->advertising |= ADVERTISED_TP;
|
|
|
|
ecmd->port = PORT_TP;
|
|
|
|
ecmd->autoneg = (boardinfo->board_type ==
|
|
|
|
NETXEN_BRDTYPE_P2_SB31_10G_CX4) ?
|
2007-04-20 22:52:37 +08:00
|
|
|
(AUTONEG_DISABLE) : (adapter->link_autoneg);
|
2006-11-30 01:00:10 +08:00
|
|
|
break;
|
|
|
|
case NETXEN_BRDTYPE_P2_SB31_10G_HMEZ:
|
|
|
|
case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ:
|
2008-07-22 10:44:02 +08:00
|
|
|
case NETXEN_BRDTYPE_P3_IMEZ:
|
|
|
|
case NETXEN_BRDTYPE_P3_XG_LOM:
|
|
|
|
case NETXEN_BRDTYPE_P3_HMEZ:
|
2006-11-30 01:00:10 +08:00
|
|
|
ecmd->supported |= SUPPORTED_MII;
|
|
|
|
ecmd->advertising |= ADVERTISED_MII;
|
|
|
|
ecmd->port = PORT_FIBRE;
|
|
|
|
ecmd->autoneg = AUTONEG_DISABLE;
|
|
|
|
break;
|
|
|
|
case NETXEN_BRDTYPE_P2_SB31_10G:
|
2008-07-22 10:44:02 +08:00
|
|
|
case NETXEN_BRDTYPE_P3_10G_SFP_PLUS:
|
|
|
|
case NETXEN_BRDTYPE_P3_10G_XFP:
|
2006-11-30 01:00:10 +08:00
|
|
|
ecmd->supported |= SUPPORTED_FIBRE;
|
|
|
|
ecmd->advertising |= ADVERTISED_FIBRE;
|
|
|
|
ecmd->port = PORT_FIBRE;
|
|
|
|
ecmd->autoneg = AUTONEG_DISABLE;
|
|
|
|
break;
|
|
|
|
default:
|
2006-12-01 21:36:22 +08:00
|
|
|
printk(KERN_ERR "netxen-nic: Unsupported board model %d\n",
|
2006-11-30 01:00:10 +08:00
|
|
|
(netxen_brdtype_t) boardinfo->board_type);
|
|
|
|
return -EIO;
|
2006-10-22 03:33:03 +08:00
|
|
|
}
|
|
|
|
|
2006-11-30 01:00:10 +08:00
|
|
|
return 0;
|
2006-10-22 03:33:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
|
|
|
|
{
|
2007-04-20 22:52:37 +08:00
|
|
|
struct netxen_adapter *adapter = netdev_priv(dev);
|
2007-01-02 18:39:10 +08:00
|
|
|
__u32 status;
|
2006-10-22 03:33:03 +08:00
|
|
|
|
|
|
|
/* read which mode */
|
|
|
|
if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
|
|
|
|
/* autonegotiation */
|
2006-12-05 01:18:00 +08:00
|
|
|
if (adapter->phy_write
|
2007-04-20 22:53:05 +08:00
|
|
|
&& adapter->phy_write(adapter,
|
2006-12-05 01:18:00 +08:00
|
|
|
NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG,
|
2007-01-02 18:39:10 +08:00
|
|
|
ecmd->autoneg) != 0)
|
2006-10-22 03:33:03 +08:00
|
|
|
return -EIO;
|
|
|
|
else
|
2007-04-20 22:52:37 +08:00
|
|
|
adapter->link_autoneg = ecmd->autoneg;
|
2006-10-22 03:33:03 +08:00
|
|
|
|
2006-12-05 01:18:00 +08:00
|
|
|
if (adapter->phy_read
|
2007-04-20 22:53:05 +08:00
|
|
|
&& adapter->phy_read(adapter,
|
2006-12-05 01:18:00 +08:00
|
|
|
NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
|
|
|
|
&status) != 0)
|
2006-10-22 03:33:03 +08:00
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
/* speed */
|
|
|
|
switch (ecmd->speed) {
|
|
|
|
case SPEED_10:
|
|
|
|
netxen_set_phy_speed(status, 0);
|
|
|
|
break;
|
|
|
|
case SPEED_100:
|
|
|
|
netxen_set_phy_speed(status, 1);
|
|
|
|
break;
|
|
|
|
case SPEED_1000:
|
|
|
|
netxen_set_phy_speed(status, 2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* set duplex mode */
|
|
|
|
if (ecmd->duplex == DUPLEX_HALF)
|
|
|
|
netxen_clear_phy_duplex(status);
|
|
|
|
if (ecmd->duplex == DUPLEX_FULL)
|
|
|
|
netxen_set_phy_duplex(status);
|
2006-12-05 01:18:00 +08:00
|
|
|
if (adapter->phy_write
|
2007-04-20 22:53:05 +08:00
|
|
|
&& adapter->phy_write(adapter,
|
2006-12-05 01:18:00 +08:00
|
|
|
NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
|
|
|
|
*((int *)&status)) != 0)
|
2006-10-22 03:33:03 +08:00
|
|
|
return -EIO;
|
|
|
|
else {
|
2007-04-20 22:52:37 +08:00
|
|
|
adapter->link_speed = ecmd->speed;
|
|
|
|
adapter->link_duplex = ecmd->duplex;
|
2006-10-22 03:33:03 +08:00
|
|
|
}
|
|
|
|
} else
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
if (netif_running(dev)) {
|
|
|
|
dev->stop(dev);
|
|
|
|
dev->open(dev);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int netxen_nic_get_regs_len(struct net_device *dev)
|
|
|
|
{
|
|
|
|
return NETXEN_NIC_REGS_LEN;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct netxen_niu_regs {
|
2007-01-02 18:39:10 +08:00
|
|
|
__u32 reg[NETXEN_NIC_REGS_COUNT];
|
2006-10-22 03:33:03 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct netxen_niu_regs niu_registers[] = {
|
|
|
|
{
|
|
|
|
/* GB Mode */
|
|
|
|
{
|
|
|
|
NETXEN_NIU_GB_SERDES_RESET,
|
|
|
|
NETXEN_NIU_GB0_MII_MODE,
|
|
|
|
NETXEN_NIU_GB1_MII_MODE,
|
|
|
|
NETXEN_NIU_GB2_MII_MODE,
|
|
|
|
NETXEN_NIU_GB3_MII_MODE,
|
|
|
|
NETXEN_NIU_GB0_GMII_MODE,
|
|
|
|
NETXEN_NIU_GB1_GMII_MODE,
|
|
|
|
NETXEN_NIU_GB2_GMII_MODE,
|
|
|
|
NETXEN_NIU_GB3_GMII_MODE,
|
|
|
|
NETXEN_NIU_REMOTE_LOOPBACK,
|
|
|
|
NETXEN_NIU_GB0_HALF_DUPLEX,
|
|
|
|
NETXEN_NIU_GB1_HALF_DUPLEX,
|
|
|
|
NETXEN_NIU_RESET_SYS_FIFOS,
|
|
|
|
NETXEN_NIU_GB_CRC_DROP,
|
|
|
|
NETXEN_NIU_GB_DROP_WRONGADDR,
|
|
|
|
NETXEN_NIU_TEST_MUX_CTL,
|
|
|
|
|
|
|
|
NETXEN_NIU_GB_MAC_CONFIG_0(0),
|
|
|
|
NETXEN_NIU_GB_MAC_CONFIG_1(0),
|
|
|
|
NETXEN_NIU_GB_HALF_DUPLEX_CTRL(0),
|
|
|
|
NETXEN_NIU_GB_MAX_FRAME_SIZE(0),
|
|
|
|
NETXEN_NIU_GB_TEST_REG(0),
|
|
|
|
NETXEN_NIU_GB_MII_MGMT_CONFIG(0),
|
|
|
|
NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
|
|
|
|
NETXEN_NIU_GB_MII_MGMT_ADDR(0),
|
|
|
|
NETXEN_NIU_GB_MII_MGMT_CTRL(0),
|
|
|
|
NETXEN_NIU_GB_MII_MGMT_STATUS(0),
|
|
|
|
NETXEN_NIU_GB_MII_MGMT_INDICATE(0),
|
|
|
|
NETXEN_NIU_GB_INTERFACE_CTRL(0),
|
|
|
|
NETXEN_NIU_GB_INTERFACE_STATUS(0),
|
|
|
|
NETXEN_NIU_GB_STATION_ADDR_0(0),
|
|
|
|
NETXEN_NIU_GB_STATION_ADDR_1(0),
|
|
|
|
-1,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
/* XG Mode */
|
|
|
|
{
|
|
|
|
NETXEN_NIU_XG_SINGLE_TERM,
|
|
|
|
NETXEN_NIU_XG_DRIVE_HI,
|
|
|
|
NETXEN_NIU_XG_DRIVE_LO,
|
|
|
|
NETXEN_NIU_XG_DTX,
|
|
|
|
NETXEN_NIU_XG_DEQ,
|
|
|
|
NETXEN_NIU_XG_WORD_ALIGN,
|
|
|
|
NETXEN_NIU_XG_RESET,
|
|
|
|
NETXEN_NIU_XG_POWER_DOWN,
|
|
|
|
NETXEN_NIU_XG_RESET_PLL,
|
|
|
|
NETXEN_NIU_XG_SERDES_LOOPBACK,
|
|
|
|
NETXEN_NIU_XG_DO_BYTE_ALIGN,
|
|
|
|
NETXEN_NIU_XG_TX_ENABLE,
|
|
|
|
NETXEN_NIU_XG_RX_ENABLE,
|
|
|
|
NETXEN_NIU_XG_STATUS,
|
|
|
|
NETXEN_NIU_XG_PAUSE_THRESHOLD,
|
|
|
|
NETXEN_NIU_XGE_CONFIG_0,
|
|
|
|
NETXEN_NIU_XGE_CONFIG_1,
|
|
|
|
NETXEN_NIU_XGE_IPG,
|
|
|
|
NETXEN_NIU_XGE_STATION_ADDR_0_HI,
|
|
|
|
NETXEN_NIU_XGE_STATION_ADDR_0_1,
|
|
|
|
NETXEN_NIU_XGE_STATION_ADDR_1_LO,
|
|
|
|
NETXEN_NIU_XGE_STATUS,
|
|
|
|
NETXEN_NIU_XGE_MAX_FRAME_SIZE,
|
|
|
|
NETXEN_NIU_XGE_PAUSE_FRAME_VALUE,
|
|
|
|
NETXEN_NIU_XGE_TX_BYTE_CNT,
|
|
|
|
NETXEN_NIU_XGE_TX_FRAME_CNT,
|
|
|
|
NETXEN_NIU_XGE_RX_BYTE_CNT,
|
|
|
|
NETXEN_NIU_XGE_RX_FRAME_CNT,
|
|
|
|
NETXEN_NIU_XGE_AGGR_ERROR_CNT,
|
|
|
|
NETXEN_NIU_XGE_MULTICAST_FRAME_CNT,
|
|
|
|
NETXEN_NIU_XGE_UNICAST_FRAME_CNT,
|
|
|
|
NETXEN_NIU_XGE_CRC_ERROR_CNT,
|
|
|
|
NETXEN_NIU_XGE_OVERSIZE_FRAME_ERR,
|
|
|
|
NETXEN_NIU_XGE_UNDERSIZE_FRAME_ERR,
|
|
|
|
NETXEN_NIU_XGE_LOCAL_ERROR_CNT,
|
|
|
|
NETXEN_NIU_XGE_REMOTE_ERROR_CNT,
|
|
|
|
NETXEN_NIU_XGE_CONTROL_CHAR_CNT,
|
|
|
|
NETXEN_NIU_XGE_PAUSE_FRAME_CNT,
|
|
|
|
-1,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
netxen_nic_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p)
|
|
|
|
{
|
2007-04-20 22:52:37 +08:00
|
|
|
struct netxen_adapter *adapter = netdev_priv(dev);
|
2007-01-02 18:39:10 +08:00
|
|
|
__u32 mode, *regs_buff = p;
|
2006-10-22 03:33:03 +08:00
|
|
|
void __iomem *addr;
|
|
|
|
int i, window;
|
|
|
|
|
|
|
|
memset(p, 0, NETXEN_NIC_REGS_LEN);
|
|
|
|
regs->version = (1 << 24) | (adapter->ahw.revision_id << 16) |
|
2007-04-20 22:52:37 +08:00
|
|
|
(adapter->pdev)->device;
|
2006-10-22 03:33:03 +08:00
|
|
|
/* which mode */
|
|
|
|
NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_MODE, ®s_buff[0]);
|
|
|
|
mode = regs_buff[0];
|
|
|
|
|
|
|
|
/* Common registers to all the modes */
|
|
|
|
NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_STRAP_VALUE_SAVE_HIGHER,
|
|
|
|
®s_buff[2]);
|
|
|
|
/* GB/XGB Mode */
|
|
|
|
mode = (mode / 2) - 1;
|
|
|
|
window = 0;
|
|
|
|
if (mode <= 1) {
|
|
|
|
for (i = 3; niu_registers[mode].reg[i - 3] != -1; i++) {
|
|
|
|
/* GB: port specific registers */
|
|
|
|
if (mode == 0 && i >= 19)
|
2008-06-16 13:59:44 +08:00
|
|
|
window = adapter->physical_port *
|
2007-04-20 22:52:37 +08:00
|
|
|
NETXEN_NIC_PORT_WINDOW;
|
2006-10-22 03:33:03 +08:00
|
|
|
|
|
|
|
NETXEN_NIC_LOCKED_READ_REG(niu_registers[mode].
|
|
|
|
reg[i - 3] + window,
|
|
|
|
®s_buff[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-09 21:49:08 +08:00
|
|
|
static u32 netxen_nic_test_link(struct net_device *dev)
|
2006-10-22 03:33:03 +08:00
|
|
|
{
|
2007-04-20 22:52:37 +08:00
|
|
|
struct netxen_adapter *adapter = netdev_priv(dev);
|
2007-01-02 18:39:10 +08:00
|
|
|
__u32 status;
|
2007-02-28 21:14:07 +08:00
|
|
|
int val;
|
2006-10-22 03:33:03 +08:00
|
|
|
|
|
|
|
/* read which mode */
|
|
|
|
if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
|
2006-12-05 01:18:00 +08:00
|
|
|
if (adapter->phy_read
|
2007-04-20 22:53:05 +08:00
|
|
|
&& adapter->phy_read(adapter,
|
2006-12-05 01:18:00 +08:00
|
|
|
NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
|
|
|
|
&status) != 0)
|
2006-10-22 03:33:03 +08:00
|
|
|
return -EIO;
|
2007-02-28 21:14:07 +08:00
|
|
|
else {
|
|
|
|
val = netxen_get_phy_link(status);
|
|
|
|
return !val;
|
|
|
|
}
|
2006-10-22 03:33:03 +08:00
|
|
|
} else if (adapter->ahw.board_type == NETXEN_NIC_XGBE) {
|
2007-02-28 21:14:07 +08:00
|
|
|
val = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_XG_STATE));
|
|
|
|
return (val == XG_LINK_UP) ? 0 : 1;
|
2006-10-22 03:33:03 +08:00
|
|
|
}
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
netxen_nic_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
|
|
|
|
u8 * bytes)
|
|
|
|
{
|
2007-04-20 22:52:37 +08:00
|
|
|
struct netxen_adapter *adapter = netdev_priv(dev);
|
2006-10-22 03:33:03 +08:00
|
|
|
int offset;
|
2007-02-05 23:40:49 +08:00
|
|
|
int ret;
|
2006-10-22 03:33:03 +08:00
|
|
|
|
|
|
|
if (eeprom->len == 0)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2007-11-24 10:23:36 +08:00
|
|
|
eeprom->magic = (adapter->pdev)->vendor |
|
2007-04-20 22:52:37 +08:00
|
|
|
((adapter->pdev)->device << 16);
|
2007-02-05 23:40:49 +08:00
|
|
|
offset = eeprom->offset;
|
|
|
|
|
2007-11-24 10:23:36 +08:00
|
|
|
ret = netxen_rom_fast_read_words(adapter, offset, bytes,
|
2007-02-05 23:40:49 +08:00
|
|
|
eeprom->len);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
2006-10-22 03:33:03 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-07-22 10:44:00 +08:00
|
|
|
#if 0
|
2007-02-05 23:40:49 +08:00
|
|
|
static int
|
|
|
|
netxen_nic_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
|
|
|
|
u8 * bytes)
|
|
|
|
{
|
2007-04-20 22:52:37 +08:00
|
|
|
struct netxen_adapter *adapter = netdev_priv(dev);
|
2007-02-05 23:40:49 +08:00
|
|
|
int offset = eeprom->offset;
|
|
|
|
static int flash_start;
|
|
|
|
static int ready_to_flash;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (flash_start == 0) {
|
2007-02-09 21:49:08 +08:00
|
|
|
netxen_halt_pegs(adapter);
|
2007-02-05 23:40:49 +08:00
|
|
|
ret = netxen_flash_unlock(adapter);
|
|
|
|
if (ret < 0) {
|
|
|
|
printk(KERN_ERR "%s: Flash unlock failed.\n",
|
|
|
|
netxen_nic_driver_name);
|
|
|
|
return ret;
|
|
|
|
}
|
2007-11-24 10:23:36 +08:00
|
|
|
printk(KERN_INFO "%s: flash unlocked. \n",
|
2007-02-05 23:40:49 +08:00
|
|
|
netxen_nic_driver_name);
|
|
|
|
ret = netxen_flash_erase_secondary(adapter);
|
|
|
|
if (ret != FLASH_SUCCESS) {
|
2007-11-24 10:23:36 +08:00
|
|
|
printk(KERN_ERR "%s: Flash erase failed.\n",
|
2007-02-05 23:40:49 +08:00
|
|
|
netxen_nic_driver_name);
|
|
|
|
return ret;
|
|
|
|
}
|
2007-11-24 10:23:36 +08:00
|
|
|
printk(KERN_INFO "%s: secondary flash erased successfully.\n",
|
2007-02-05 23:40:49 +08:00
|
|
|
netxen_nic_driver_name);
|
|
|
|
flash_start = 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-06-07 19:36:36 +08:00
|
|
|
if (offset == NETXEN_BOOTLD_START) {
|
2007-02-05 23:40:49 +08:00
|
|
|
ret = netxen_flash_erase_primary(adapter);
|
|
|
|
if (ret != FLASH_SUCCESS) {
|
2007-11-24 10:23:36 +08:00
|
|
|
printk(KERN_ERR "%s: Flash erase failed.\n",
|
2007-02-05 23:40:49 +08:00
|
|
|
netxen_nic_driver_name);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-06-07 19:36:36 +08:00
|
|
|
ret = netxen_rom_se(adapter, NETXEN_USER_START);
|
2007-02-05 23:40:49 +08:00
|
|
|
if (ret != FLASH_SUCCESS)
|
|
|
|
return ret;
|
2007-06-07 19:36:36 +08:00
|
|
|
ret = netxen_rom_se(adapter, NETXEN_FIXED_START);
|
2007-02-05 23:40:49 +08:00
|
|
|
if (ret != FLASH_SUCCESS)
|
|
|
|
return ret;
|
|
|
|
|
2007-11-24 10:23:36 +08:00
|
|
|
printk(KERN_INFO "%s: primary flash erased successfully\n",
|
2007-02-05 23:40:49 +08:00
|
|
|
netxen_nic_driver_name);
|
|
|
|
|
|
|
|
ret = netxen_backup_crbinit(adapter);
|
|
|
|
if (ret != FLASH_SUCCESS) {
|
2007-11-24 10:23:36 +08:00
|
|
|
printk(KERN_ERR "%s: CRBinit backup failed.\n",
|
2007-02-05 23:40:49 +08:00
|
|
|
netxen_nic_driver_name);
|
|
|
|
return ret;
|
|
|
|
}
|
2007-11-24 10:23:36 +08:00
|
|
|
printk(KERN_INFO "%s: CRBinit backup done.\n",
|
2007-02-05 23:40:49 +08:00
|
|
|
netxen_nic_driver_name);
|
|
|
|
ready_to_flash = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ready_to_flash) {
|
|
|
|
printk(KERN_ERR "%s: Invalid write sequence, returning...\n",
|
|
|
|
netxen_nic_driver_name);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return netxen_rom_fast_write_words(adapter, offset, bytes, eeprom->len);
|
|
|
|
}
|
2008-07-22 10:44:00 +08:00
|
|
|
#endif /* 0 */
|
2007-02-05 23:40:49 +08:00
|
|
|
|
2006-10-22 03:33:03 +08:00
|
|
|
static void
|
|
|
|
netxen_nic_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
|
|
|
|
{
|
2007-04-20 22:52:37 +08:00
|
|
|
struct netxen_adapter *adapter = netdev_priv(dev);
|
2006-12-05 01:23:25 +08:00
|
|
|
int i;
|
2006-10-22 03:33:03 +08:00
|
|
|
|
|
|
|
ring->rx_pending = 0;
|
2006-12-05 01:23:25 +08:00
|
|
|
ring->rx_jumbo_pending = 0;
|
2006-10-22 03:33:03 +08:00
|
|
|
for (i = 0; i < MAX_RCV_CTX; ++i) {
|
2006-12-05 01:23:25 +08:00
|
|
|
ring->rx_pending += adapter->recv_ctx[i].
|
2007-09-03 13:03:35 +08:00
|
|
|
rcv_desc[RCV_DESC_NORMAL_CTXID].max_rx_desc_count;
|
2006-12-05 01:23:25 +08:00
|
|
|
ring->rx_jumbo_pending += adapter->recv_ctx[i].
|
2007-09-03 13:03:35 +08:00
|
|
|
rcv_desc[RCV_DESC_JUMBO_CTXID].max_rx_desc_count;
|
2006-10-22 03:33:03 +08:00
|
|
|
}
|
2007-09-03 13:03:35 +08:00
|
|
|
ring->tx_pending = adapter->max_tx_desc_count;
|
2006-10-22 03:33:03 +08:00
|
|
|
|
2007-09-03 13:03:35 +08:00
|
|
|
ring->rx_max_pending = MAX_RCV_DESCRIPTORS;
|
|
|
|
ring->tx_max_pending = MAX_CMD_DESCRIPTORS_HOST;
|
|
|
|
ring->rx_jumbo_max_pending = MAX_JUMBO_RCV_DESCRIPTORS;
|
2006-10-22 03:33:03 +08:00
|
|
|
ring->rx_mini_max_pending = 0;
|
|
|
|
ring->rx_mini_pending = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
netxen_nic_get_pauseparam(struct net_device *dev,
|
|
|
|
struct ethtool_pauseparam *pause)
|
|
|
|
{
|
2007-04-20 22:52:37 +08:00
|
|
|
struct netxen_adapter *adapter = netdev_priv(dev);
|
2007-01-02 18:39:10 +08:00
|
|
|
__u32 val;
|
2008-06-16 13:59:44 +08:00
|
|
|
int port = adapter->physical_port;
|
2006-10-22 03:33:03 +08:00
|
|
|
|
|
|
|
if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
|
2007-04-20 22:55:26 +08:00
|
|
|
if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS))
|
|
|
|
return;
|
2006-10-22 03:33:03 +08:00
|
|
|
/* get flow control settings */
|
2007-04-20 22:55:26 +08:00
|
|
|
netxen_nic_read_w0(adapter,NETXEN_NIU_GB_MAC_CONFIG_0(port),
|
|
|
|
&val);
|
2006-10-22 03:33:03 +08:00
|
|
|
pause->rx_pause = netxen_gb_get_rx_flowctl(val);
|
2007-04-20 22:55:26 +08:00
|
|
|
netxen_nic_read_w0(adapter, NETXEN_NIU_GB_PAUSE_CTL, &val);
|
|
|
|
switch (port) {
|
|
|
|
case 0:
|
|
|
|
pause->tx_pause = !(netxen_gb_get_gb0_mask(val));
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
pause->tx_pause = !(netxen_gb_get_gb1_mask(val));
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
pause->tx_pause = !(netxen_gb_get_gb2_mask(val));
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
default:
|
|
|
|
pause->tx_pause = !(netxen_gb_get_gb3_mask(val));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else if (adapter->ahw.board_type == NETXEN_NIC_XGBE) {
|
|
|
|
if ((port < 0) || (port > NETXEN_NIU_MAX_XG_PORTS))
|
|
|
|
return;
|
|
|
|
pause->rx_pause = 1;
|
|
|
|
netxen_nic_read_w0(adapter, NETXEN_NIU_XG_PAUSE_CTL, &val);
|
|
|
|
if (port == 0)
|
|
|
|
pause->tx_pause = !(netxen_xg_get_xg0_mask(val));
|
|
|
|
else
|
|
|
|
pause->tx_pause = !(netxen_xg_get_xg1_mask(val));
|
|
|
|
} else {
|
2007-11-24 10:23:36 +08:00
|
|
|
printk(KERN_ERR"%s: Unknown board type: %x\n",
|
2007-04-20 22:55:26 +08:00
|
|
|
netxen_nic_driver_name, adapter->ahw.board_type);
|
2006-10-22 03:33:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
netxen_nic_set_pauseparam(struct net_device *dev,
|
|
|
|
struct ethtool_pauseparam *pause)
|
|
|
|
{
|
2007-04-20 22:52:37 +08:00
|
|
|
struct netxen_adapter *adapter = netdev_priv(dev);
|
2007-01-02 18:39:10 +08:00
|
|
|
__u32 val;
|
2008-06-16 13:59:44 +08:00
|
|
|
int port = adapter->physical_port;
|
2006-10-22 03:33:03 +08:00
|
|
|
/* read mode */
|
|
|
|
if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
|
2007-04-20 22:55:26 +08:00
|
|
|
if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS))
|
|
|
|
return -EIO;
|
2006-10-22 03:33:03 +08:00
|
|
|
/* set flow control */
|
|
|
|
netxen_nic_read_w0(adapter,
|
2007-04-20 22:55:26 +08:00
|
|
|
NETXEN_NIU_GB_MAC_CONFIG_0(port), &val);
|
2007-11-24 10:23:36 +08:00
|
|
|
|
2006-10-22 03:33:03 +08:00
|
|
|
if (pause->rx_pause)
|
|
|
|
netxen_gb_rx_flowctl(val);
|
|
|
|
else
|
|
|
|
netxen_gb_unset_rx_flowctl(val);
|
|
|
|
|
2007-04-20 22:55:26 +08:00
|
|
|
netxen_nic_write_w0(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
|
|
|
|
val);
|
2006-10-22 03:33:03 +08:00
|
|
|
/* set autoneg */
|
2007-04-20 22:55:26 +08:00
|
|
|
netxen_nic_read_w0(adapter, NETXEN_NIU_GB_PAUSE_CTL, &val);
|
|
|
|
switch (port) {
|
|
|
|
case 0:
|
|
|
|
if (pause->tx_pause)
|
|
|
|
netxen_gb_unset_gb0_mask(val);
|
|
|
|
else
|
|
|
|
netxen_gb_set_gb0_mask(val);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (pause->tx_pause)
|
|
|
|
netxen_gb_unset_gb1_mask(val);
|
|
|
|
else
|
|
|
|
netxen_gb_set_gb1_mask(val);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (pause->tx_pause)
|
|
|
|
netxen_gb_unset_gb2_mask(val);
|
|
|
|
else
|
|
|
|
netxen_gb_set_gb2_mask(val);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
default:
|
|
|
|
if (pause->tx_pause)
|
|
|
|
netxen_gb_unset_gb3_mask(val);
|
|
|
|
else
|
|
|
|
netxen_gb_set_gb3_mask(val);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
netxen_nic_write_w0(adapter, NETXEN_NIU_GB_PAUSE_CTL, val);
|
|
|
|
} else if (adapter->ahw.board_type == NETXEN_NIC_XGBE) {
|
|
|
|
if ((port < 0) || (port > NETXEN_NIU_MAX_XG_PORTS))
|
2006-10-22 03:33:03 +08:00
|
|
|
return -EIO;
|
2007-04-20 22:55:26 +08:00
|
|
|
netxen_nic_read_w0(adapter, NETXEN_NIU_XG_PAUSE_CTL, &val);
|
|
|
|
if (port == 0) {
|
|
|
|
if (pause->tx_pause)
|
|
|
|
netxen_xg_unset_xg0_mask(val);
|
|
|
|
else
|
|
|
|
netxen_xg_set_xg0_mask(val);
|
|
|
|
} else {
|
|
|
|
if (pause->tx_pause)
|
|
|
|
netxen_xg_unset_xg1_mask(val);
|
|
|
|
else
|
|
|
|
netxen_xg_set_xg1_mask(val);
|
2006-10-22 03:33:03 +08:00
|
|
|
}
|
2007-11-24 10:23:36 +08:00
|
|
|
netxen_nic_write_w0(adapter, NETXEN_NIU_XG_PAUSE_CTL, val);
|
2007-04-20 22:55:26 +08:00
|
|
|
} else {
|
|
|
|
printk(KERN_ERR "%s: Unknown board type: %x\n",
|
2007-11-24 10:23:36 +08:00
|
|
|
netxen_nic_driver_name,
|
2007-04-20 22:55:26 +08:00
|
|
|
adapter->ahw.board_type);
|
|
|
|
}
|
|
|
|
return 0;
|
2006-10-22 03:33:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int netxen_nic_reg_test(struct net_device *dev)
|
|
|
|
{
|
2007-02-28 21:14:07 +08:00
|
|
|
struct netxen_adapter *adapter = netdev_priv(dev);
|
|
|
|
u32 data_read, data_written;
|
2006-10-22 03:33:03 +08:00
|
|
|
|
2007-02-28 21:14:07 +08:00
|
|
|
netxen_nic_read_w0(adapter, NETXEN_PCIX_PH_REG(0), &data_read);
|
|
|
|
if ((data_read & 0xffff) != PHAN_VENDOR_ID)
|
|
|
|
return 1;
|
2006-10-22 03:33:03 +08:00
|
|
|
|
2007-02-28 21:14:07 +08:00
|
|
|
data_written = (u32)0xa5a5a5a5;
|
2006-10-22 03:33:03 +08:00
|
|
|
|
2007-02-28 21:14:07 +08:00
|
|
|
netxen_nic_reg_write(adapter, CRB_SCRATCHPAD_TEST, data_written);
|
|
|
|
data_read = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_SCRATCHPAD_TEST));
|
|
|
|
if (data_written != data_read)
|
|
|
|
return 1;
|
2006-10-22 03:33:03 +08:00
|
|
|
|
2007-02-28 21:14:07 +08:00
|
|
|
return 0;
|
2006-10-22 03:33:03 +08:00
|
|
|
}
|
|
|
|
|
2007-10-04 09:07:32 +08:00
|
|
|
static int netxen_get_sset_count(struct net_device *dev, int sset)
|
2006-10-22 03:33:03 +08:00
|
|
|
{
|
2007-10-04 09:07:32 +08:00
|
|
|
switch (sset) {
|
|
|
|
case ETH_SS_TEST:
|
|
|
|
return NETXEN_NIC_TEST_LEN;
|
|
|
|
case ETH_SS_STATS:
|
|
|
|
return NETXEN_NIC_STATS_LEN;
|
|
|
|
default:
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
2006-10-22 03:33:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
netxen_nic_diag_test(struct net_device *dev, struct ethtool_test *eth_test,
|
|
|
|
u64 * data)
|
|
|
|
{
|
2007-04-20 22:55:26 +08:00
|
|
|
memset(data, 0, sizeof(uint64_t) * NETXEN_NIC_TEST_LEN);
|
|
|
|
if ((data[0] = netxen_nic_reg_test(dev)))
|
|
|
|
eth_test->flags |= ETH_TEST_FL_FAILED;
|
|
|
|
/* link test */
|
|
|
|
if ((data[1] = (u64) netxen_nic_test_link(dev)))
|
|
|
|
eth_test->flags |= ETH_TEST_FL_FAILED;
|
2006-10-22 03:33:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
netxen_nic_get_strings(struct net_device *dev, u32 stringset, u8 * data)
|
|
|
|
{
|
|
|
|
int index;
|
|
|
|
|
|
|
|
switch (stringset) {
|
|
|
|
case ETH_SS_TEST:
|
|
|
|
memcpy(data, *netxen_nic_gstrings_test,
|
|
|
|
NETXEN_NIC_TEST_LEN * ETH_GSTRING_LEN);
|
|
|
|
break;
|
|
|
|
case ETH_SS_STATS:
|
|
|
|
for (index = 0; index < NETXEN_NIC_STATS_LEN; index++) {
|
|
|
|
memcpy(data + index * ETH_GSTRING_LEN,
|
|
|
|
netxen_nic_gstrings_stats[index].stat_string,
|
|
|
|
ETH_GSTRING_LEN);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
netxen_nic_get_ethtool_stats(struct net_device *dev,
|
|
|
|
struct ethtool_stats *stats, u64 * data)
|
|
|
|
{
|
2007-04-20 22:52:37 +08:00
|
|
|
struct netxen_adapter *adapter = netdev_priv(dev);
|
2006-10-22 03:33:03 +08:00
|
|
|
int index;
|
|
|
|
|
|
|
|
for (index = 0; index < NETXEN_NIC_STATS_LEN; index++) {
|
|
|
|
char *p =
|
2007-04-20 22:52:37 +08:00
|
|
|
(char *)adapter +
|
|
|
|
netxen_nic_gstrings_stats[index].stat_offset;
|
2006-10-22 03:33:03 +08:00
|
|
|
data[index] =
|
|
|
|
(netxen_nic_gstrings_stats[index].sizeof_stat ==
|
|
|
|
sizeof(u64)) ? *(u64 *) p : *(u32 *) p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-03 13:03:35 +08:00
|
|
|
static u32 netxen_nic_get_rx_csum(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct netxen_adapter *adapter = netdev_priv(dev);
|
|
|
|
return adapter->rx_csum;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int netxen_nic_set_rx_csum(struct net_device *dev, u32 data)
|
|
|
|
{
|
|
|
|
struct netxen_adapter *adapter = netdev_priv(dev);
|
|
|
|
adapter->rx_csum = !!data;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-10-22 03:33:03 +08:00
|
|
|
struct ethtool_ops netxen_nic_ethtool_ops = {
|
|
|
|
.get_settings = netxen_nic_get_settings,
|
|
|
|
.set_settings = netxen_nic_set_settings,
|
|
|
|
.get_drvinfo = netxen_nic_get_drvinfo,
|
|
|
|
.get_regs_len = netxen_nic_get_regs_len,
|
|
|
|
.get_regs = netxen_nic_get_regs,
|
2007-02-09 21:49:08 +08:00
|
|
|
.get_link = ethtool_op_get_link,
|
2006-10-22 03:33:03 +08:00
|
|
|
.get_eeprom_len = netxen_nic_get_eeprom_len,
|
|
|
|
.get_eeprom = netxen_nic_get_eeprom,
|
2008-07-22 10:44:00 +08:00
|
|
|
#if 0
|
2007-02-05 23:40:49 +08:00
|
|
|
.set_eeprom = netxen_nic_set_eeprom,
|
2008-07-22 10:44:00 +08:00
|
|
|
#endif
|
2006-10-22 03:33:03 +08:00
|
|
|
.get_ringparam = netxen_nic_get_ringparam,
|
|
|
|
.get_pauseparam = netxen_nic_get_pauseparam,
|
|
|
|
.set_pauseparam = netxen_nic_set_pauseparam,
|
|
|
|
.set_tx_csum = ethtool_op_set_tx_csum,
|
|
|
|
.set_sg = ethtool_op_set_sg,
|
|
|
|
.set_tso = ethtool_op_set_tso,
|
|
|
|
.self_test = netxen_nic_diag_test,
|
|
|
|
.get_strings = netxen_nic_get_strings,
|
|
|
|
.get_ethtool_stats = netxen_nic_get_ethtool_stats,
|
2007-10-04 09:07:32 +08:00
|
|
|
.get_sset_count = netxen_get_sset_count,
|
2007-09-03 13:03:35 +08:00
|
|
|
.get_rx_csum = netxen_nic_get_rx_csum,
|
|
|
|
.set_rx_csum = netxen_nic_set_rx_csum,
|
2006-10-22 03:33:03 +08:00
|
|
|
};
|