aboutsummaryrefslogblamecommitdiffstats
path: root/drivers/net/spider_net_ethtool.c
blob: d940474e024a19b0eed798443b5f92a7feec2adc (plain) (tree)




























                                                                       




















                                        

















                                                          









                                                               
                                               
























































                                                                
 






                                                                 
                                                    
                                                              
                                                    

 






























                                                                            
                                                   
                                                                  



                                                                  
                                                      


                                                                 

                                                         
                                                                   


                                                               

  
/*
 * 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>
 *
 * 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, or (at your option)
 * any later version.
 *
 * 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.
 *
 * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <linux/netdevice.h>
#include <linux/ethtool.h>
#include <linux/pci.h>

#include "spider_net.h"


#define SPIDER_NET_NUM_STATS 13

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" },
};

static int
spider_net_ethtool_get_settings(struct net_device *netdev,
			       struct ethtool_cmd *cmd)
{
	struct spider_net_card *card;
	card = netdev_priv(netdev);

	cmd->supported   = (SUPPORTED_1000baseT_Full |
			     SUPPORTED_FIBRE);
	cmd->advertising = (ADVERTISED_1000baseT_Full |
			     ADVERTISED_FIBRE);
	cmd->port = PORT_FIBRE;
	cmd->speed = card->phy.speed;
	cmd->duplex = DUPLEX_FULL;

	return 0;
}

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 */
	memset(drvinfo, 0, sizeof(struct ethtool_drvinfo));
	strncpy(drvinfo->driver, spider_net_driver_name, 32);
	strncpy(drvinfo->version, VERSION, 32);
	strcpy(drvinfo->fw_version, "no information");
	strncpy(drvinfo->bus_info, pci_name(card->pdev), 32);
}

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;
}

static u32
spider_net_ethtool_get_rx_csum(struct net_device *netdev)
{
	struct spider_net_card *card = netdev->priv;

	return card->options.rx_csum;
}

static int
spider_net_ethtool_set_rx_csum(struct net_device *netdev, u32 n)
{
	struct spider_net_card *card = netdev->priv;

	card->options.rx_csum = n;
	return 0;
}


static void
spider_net_ethtool_get_ringparam(struct net_device *netdev,
				 struct ethtool_ringparam *ering)
{
	struct spider_net_card *card = netdev->priv;

	ering->tx_max_pending = SPIDER_NET_TX_DESCRIPTORS_MAX;
	ering->tx_pending = card->tx_chain.num_desc;
	ering->rx_max_pending = SPIDER_NET_RX_DESCRIPTORS_MAX;
	ering->rx_pending = card->rx_chain.num_desc;
}

static int spider_net_get_stats_count(struct net_device *netdev)
{
	return SPIDER_NET_NUM_STATS;
}

static void spider_net_get_ethtool_stats(struct net_device *netdev,
		struct ethtool_stats *stats, u64 *data)
{
	struct spider_net_card *card = netdev->priv;

	data[0] = card->netdev_stats.tx_packets;
	data[1] = card->netdev_stats.tx_bytes;
	data[2] = card->netdev_stats.rx_packets;
	data[3] = card->netdev_stats.rx_bytes;
	data[4] = card->netdev_stats.tx_errors;
	data[5] = card->netdev_stats.tx_dropped;
	data[6] = card->netdev_stats.rx_dropped;
	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));
}

const struct ethtool_ops spider_net_ethtool_ops = {
	.get_settings		= spider_net_ethtool_get_settings,
	.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,
	.get_link		= ethtool_op_get_link,
	.nway_reset		= spider_net_ethtool_nway_reset,
	.get_rx_csum		= spider_net_ethtool_get_rx_csum,
	.set_rx_csum		= spider_net_ethtool_set_rx_csum,
	.get_tx_csum		= ethtool_op_get_tx_csum,
	.set_tx_csum		= ethtool_op_set_tx_csum,
	.get_ringparam          = spider_net_ethtool_get_ringparam,
	.get_strings		= spider_net_get_strings,
	.get_stats_count	= spider_net_get_stats_count,
	.get_ethtool_stats	= spider_net_get_ethtool_stats,
};

span class="hl num">0x82000015, 0x00000800, 0x15200011, 0x00000000, 0x00000010, 0x00000000, 0x00000010, 0x00000000, 0x00000010, 0x00000000, 0x00000010, 0x00000000, 0x00000010, 0x00000000, 0x80000015, 0x0000eea4, 0x81000015, 0x0000005f, 0x00000060, 0x00000000, 0x00004120, 0x00000000, 0x00004a00, 0x00004000, 0x00924460, 0x00000190, 0x5601401a, 0x00005956, 0x14000011, 0x00000000, 0x00934050, 0x00000018, 0x00930050, 0x00000018, 0x3601403a, 0x0000002d, 0x000643a9, 0x00000000, 0x0000c420, 0x00000140, 0x5601401a, 0x00005956, 0x14000011, 0x00000000, 0x00000010, 0x00000000, 0x00000010, 0x00000000, 0x000642a9, 0x00000000, 0x00024420, 0x00000183, 0x5601401a, 0x00005956, 0x82000015, 0x00002000, 0x15200011, 0x00000000, 0x82000015, 0x00000010, 0x15200011, 0x00000000, 0x82000015, 0x00000010, 0x15200011, 0x00000000, }; /* 104 Tx instructions */ #define FIRMWARE_TX_SIZE 104 #if 0 static const u32 firmware_wol[] = { 0x010003dc, 0x00000000, 0x19000421, 0x00000087, 0x80000015, 0x00001a1a, 0x81000015, 0x00001a1a, 0x1a0040ab, 0x00000b06, 0x15200011, 0x00000000, 0x15204022, 0x0000aaaa, 0x15204022, 0x00000300, 0x15204022, 0x00000000, 0x1a0040ab, 0x00000b15, 0x15200011, 0x00000000, 0x83000015, 0x00000002, 0x04000021, 0x00000000, 0x00000010, 0x00000000, 0x04000421, 0x00000087, 0x00000010, 0x00000000, 0x00000010, 0x00000000, 0x00008015, 0x00000000, 0x0000003e, 0x00000000, 0x00000010, 0x00000000, 0x00000010, 0x00000000, 0x82000015, 0x00004000, 0x82000015, 0x00008000, 0x0000000c, 0x00000000, 0x00000010, 0x00000000, 0x00004080, 0x00000100, 0x1f20c011, 0x00001122, 0x2720f011, 0x00003011, 0x19200071, 0x00000000, 0x1a200051, 0x00000000, 0x00000010, 0x00000000, 0x00000010, 0x00000000, 0x1d2040a4, 0x00003344, 0x1d2040a2, 0x00005566, 0x000040a0, 0x00000100, 0x00108050, 0x00000001, 0x1a208012, 0x00000006, 0x82000015, 0x00008080, 0x010003dc, 0x00000000, 0x1d2040a4, 0x00002233, 0x1d2040a4, 0x00004455, 0x2d208011, 0x00000005, 0x1d2040a4, 0x00006611, 0x00108050, 0x00000001, 0x27200011, 0x00000000, 0x1d2050a4, 0x00006600, 0x82000015, 0x00008080, 0x010003dc, 0x00000000, 0x00000050, 0x00000000, 0x1b200031, 0x00000000, 0x0000001e, 0x00000000, 0x0000001e, 0x00000000, 0x0000001e, 0x00000000, 0x0000001e, 0x00000000, 0x00924460, 0x00000086, 0x00004080, 0x00000000, 0x0092c070, 0x00000000, 0x00924060, 0x00000100, 0x0000c890, 0x00005000, 0x00a6c110, 0x00000000, 0x00b0c090, 0x00000012, 0x021c0015, 0x00000000, 0x3200001f, 0x00000034, 0x00924460, 0x00000510, 0x44210011, 0x00000000, 0x42000011, 0x00000000, 0x83000015, 0x00000040, 0x00924460, 0x00000508, 0x476a0012, 0x00000100, 0x83000015, 0x00000008, 0x16200011, 0x00000000, 0x001e8050, 0x00000000, 0x001e8050, 0x00000000, 0x00808050, 0x00000000, 0x03008015, 0x00000000, 0x62208012, 0x00000000, 0x82000015, 0x00000800, 0x16200011, 0x00000000, 0x80000015, 0x0000eea4, 0x81000015, 0x0000005f, 0x00000020, 0x00000000, 0x00004120, 0x00000000, 0x00004a00, 0x00004000, 0x00924460, 0x00000190, 0x5c01401a, 0x0000595c, 0x15000011, 0x00000000, 0x00934050, 0x00000018, 0x00930050, 0x00000018, 0x3601403a, 0x0000002d, 0x00064029, 0x00000000, 0x0000c420, 0x00000140, 0x5c01401a, 0x0000595c, 0x15000011, 0x00000000, 0x00000010, 0x00000000, 0x00000010, 0x00000000, 0x00064029, 0x00000000, 0x00024420, 0x00000183, 0x5c01401a, 0x0000595c, 0x82000015, 0x00002000, 0x16200011, 0x00000000, 0x82000015, 0x00000010, 0x16200011, 0x00000000, 0x82000015, 0x00000010, 0x16200011, 0x00000000, }; /* 104 WoL instructions */ #define FIRMWARE_WOL_SIZE 104 #endif