2019-05-27 13:55:02 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2005-09-06 05:19:29 +07:00
|
|
|
/*
|
|
|
|
* Network device driver for Cell Processor-Based Blade
|
|
|
|
*
|
|
|
|
* (C) Copyright IBM Corp. 2005
|
|
|
|
*
|
|
|
|
* Authors : Utz Bacher <utz.bacher@de.ibm.com>
|
|
|
|
* Jens Osterkamp <Jens.Osterkamp@de.ibm.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/ethtool.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
|
|
|
|
#include "spider_net.h"
|
|
|
|
|
2006-09-23 07:22:53 +07:00
|
|
|
|
|
|
|
static struct {
|
|
|
|
const char str[ETH_GSTRING_LEN];
|
|
|
|
} ethtool_stats_keys[] = {
|
|
|
|
{ "tx_packets" },
|
|
|
|
{ "tx_bytes" },
|
|
|
|
{ "rx_packets" },
|
|
|
|
{ "rx_bytes" },
|
|
|
|
{ "tx_errors" },
|
|
|
|
{ "tx_dropped" },
|
|
|
|
{ "rx_dropped" },
|
|
|
|
{ "rx_descriptor_error" },
|
|
|
|
{ "tx_timeouts" },
|
|
|
|
{ "alloc_rx_skb_error" },
|
|
|
|
{ "rx_iommu_map_error" },
|
|
|
|
{ "tx_iommu_map_error" },
|
|
|
|
{ "rx_desc_unk_state" },
|
|
|
|
};
|
|
|
|
|
2005-09-07 09:30:55 +07:00
|
|
|
static int
|
2017-03-06 05:46:00 +07:00
|
|
|
spider_net_ethtool_get_link_ksettings(struct net_device *netdev,
|
|
|
|
struct ethtool_link_ksettings *cmd)
|
2005-09-07 09:30:55 +07:00
|
|
|
{
|
|
|
|
struct spider_net_card *card;
|
|
|
|
card = netdev_priv(netdev);
|
|
|
|
|
2017-03-06 05:46:00 +07:00
|
|
|
ethtool_link_ksettings_zero_link_mode(cmd, supported);
|
|
|
|
ethtool_link_ksettings_add_link_mode(cmd, supported, 1000baseT_Full);
|
|
|
|
ethtool_link_ksettings_add_link_mode(cmd, supported, FIBRE);
|
|
|
|
|
|
|
|
ethtool_link_ksettings_zero_link_mode(cmd, advertising);
|
|
|
|
ethtool_link_ksettings_add_link_mode(cmd, advertising, 1000baseT_Full);
|
|
|
|
ethtool_link_ksettings_add_link_mode(cmd, advertising, FIBRE);
|
|
|
|
|
|
|
|
cmd->base.port = PORT_FIBRE;
|
|
|
|
cmd->base.speed = card->phy.speed;
|
|
|
|
cmd->base.duplex = DUPLEX_FULL;
|
2005-09-07 09:30:55 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-09-06 05:19:29 +07:00
|
|
|
static void
|
|
|
|
spider_net_ethtool_get_drvinfo(struct net_device *netdev,
|
|
|
|
struct ethtool_drvinfo *drvinfo)
|
|
|
|
{
|
|
|
|
struct spider_net_card *card;
|
|
|
|
card = netdev_priv(netdev);
|
|
|
|
|
|
|
|
/* clear and fill out info */
|
2013-01-06 07:44:26 +07:00
|
|
|
strlcpy(drvinfo->driver, spider_net_driver_name,
|
|
|
|
sizeof(drvinfo->driver));
|
|
|
|
strlcpy(drvinfo->version, VERSION, sizeof(drvinfo->version));
|
|
|
|
strlcpy(drvinfo->fw_version, "no information",
|
|
|
|
sizeof(drvinfo->fw_version));
|
|
|
|
strlcpy(drvinfo->bus_info, pci_name(card->pdev),
|
|
|
|
sizeof(drvinfo->bus_info));
|
2005-09-06 05:19:29 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
spider_net_ethtool_get_wol(struct net_device *netdev,
|
|
|
|
struct ethtool_wolinfo *wolinfo)
|
|
|
|
{
|
|
|
|
/* no support for wol */
|
|
|
|
wolinfo->supported = 0;
|
|
|
|
wolinfo->wolopts = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static u32
|
|
|
|
spider_net_ethtool_get_msglevel(struct net_device *netdev)
|
|
|
|
{
|
|
|
|
struct spider_net_card *card;
|
|
|
|
card = netdev_priv(netdev);
|
|
|
|
return card->msg_enable;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
spider_net_ethtool_set_msglevel(struct net_device *netdev,
|
|
|
|
u32 level)
|
|
|
|
{
|
|
|
|
struct spider_net_card *card;
|
|
|
|
card = netdev_priv(netdev);
|
|
|
|
card->msg_enable = level;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
spider_net_ethtool_nway_reset(struct net_device *netdev)
|
|
|
|
{
|
|
|
|
if (netif_running(netdev)) {
|
|
|
|
spider_net_stop(netdev);
|
|
|
|
spider_net_open(netdev);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-08-15 13:00:23 +07:00
|
|
|
static void
|
|
|
|
spider_net_ethtool_get_ringparam(struct net_device *netdev,
|
|
|
|
struct ethtool_ringparam *ering)
|
|
|
|
{
|
2008-11-13 14:38:36 +07:00
|
|
|
struct spider_net_card *card = netdev_priv(netdev);
|
2006-08-15 13:00:23 +07:00
|
|
|
|
|
|
|
ering->tx_max_pending = SPIDER_NET_TX_DESCRIPTORS_MAX;
|
2006-12-14 04:06:59 +07:00
|
|
|
ering->tx_pending = card->tx_chain.num_desc;
|
2006-08-15 13:00:23 +07:00
|
|
|
ering->rx_max_pending = SPIDER_NET_RX_DESCRIPTORS_MAX;
|
2006-12-14 04:06:59 +07:00
|
|
|
ering->rx_pending = card->rx_chain.num_desc;
|
2006-08-15 13:00:23 +07:00
|
|
|
}
|
|
|
|
|
2007-10-04 08:07:32 +07:00
|
|
|
static int spider_net_get_sset_count(struct net_device *netdev, int sset)
|
2006-09-23 07:22:53 +07:00
|
|
|
{
|
2007-10-04 08:07:32 +07:00
|
|
|
switch (sset) {
|
|
|
|
case ETH_SS_STATS:
|
2007-09-27 12:29:02 +07:00
|
|
|
return ARRAY_SIZE(ethtool_stats_keys);
|
2007-10-04 08:07:32 +07:00
|
|
|
default:
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
2006-09-23 07:22:53 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void spider_net_get_ethtool_stats(struct net_device *netdev,
|
|
|
|
struct ethtool_stats *stats, u64 *data)
|
|
|
|
{
|
2008-11-13 14:38:36 +07:00
|
|
|
struct spider_net_card *card = netdev_priv(netdev);
|
2006-09-23 07:22:53 +07:00
|
|
|
|
2007-09-27 12:29:02 +07:00
|
|
|
data[0] = netdev->stats.tx_packets;
|
|
|
|
data[1] = netdev->stats.tx_bytes;
|
|
|
|
data[2] = netdev->stats.rx_packets;
|
|
|
|
data[3] = netdev->stats.rx_bytes;
|
|
|
|
data[4] = netdev->stats.tx_errors;
|
|
|
|
data[5] = netdev->stats.tx_dropped;
|
|
|
|
data[6] = netdev->stats.rx_dropped;
|
2006-09-23 07:22:53 +07:00
|
|
|
data[7] = card->spider_stats.rx_desc_error;
|
|
|
|
data[8] = card->spider_stats.tx_timeouts;
|
|
|
|
data[9] = card->spider_stats.alloc_rx_skb_error;
|
|
|
|
data[10] = card->spider_stats.rx_iommu_map_error;
|
|
|
|
data[11] = card->spider_stats.tx_iommu_map_error;
|
|
|
|
data[12] = card->spider_stats.rx_desc_unk_state;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void spider_net_get_strings(struct net_device *netdev, u32 stringset,
|
|
|
|
u8 *data)
|
|
|
|
{
|
|
|
|
memcpy(data, ethtool_stats_keys, sizeof(ethtool_stats_keys));
|
|
|
|
}
|
|
|
|
|
2006-09-14 01:30:00 +07:00
|
|
|
const struct ethtool_ops spider_net_ethtool_ops = {
|
2005-09-06 05:19:29 +07:00
|
|
|
.get_drvinfo = spider_net_ethtool_get_drvinfo,
|
|
|
|
.get_wol = spider_net_ethtool_get_wol,
|
|
|
|
.get_msglevel = spider_net_ethtool_get_msglevel,
|
|
|
|
.set_msglevel = spider_net_ethtool_set_msglevel,
|
2007-06-12 01:35:23 +07:00
|
|
|
.get_link = ethtool_op_get_link,
|
2005-09-06 05:19:29 +07:00
|
|
|
.nway_reset = spider_net_ethtool_nway_reset,
|
2006-08-15 13:00:23 +07:00
|
|
|
.get_ringparam = spider_net_ethtool_get_ringparam,
|
2006-09-23 07:22:53 +07:00
|
|
|
.get_strings = spider_net_get_strings,
|
2007-10-04 08:07:32 +07:00
|
|
|
.get_sset_count = spider_net_get_sset_count,
|
2006-09-23 07:22:53 +07:00
|
|
|
.get_ethtool_stats = spider_net_get_ethtool_stats,
|
2017-03-06 05:46:00 +07:00
|
|
|
.get_link_ksettings = spider_net_ethtool_get_link_ksettings,
|
2005-09-06 05:19:29 +07:00
|
|
|
};
|
|
|
|
|