net: wireless: bcmdhd: Allow Improved suspend/resume processing on 2.6.39
[linux-2.6.git] / drivers / net / spider_net_ethtool.c
index a5bb0b7..9c288cd 100644 (file)
 
 #include "spider_net.h"
 
+
+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)
@@ -39,7 +58,7 @@ spider_net_ethtool_get_settings(struct net_device *netdev,
        cmd->advertising = (ADVERTISED_1000baseT_Full |
                             ADVERTISED_FIBRE);
        cmd->port = PORT_FIBRE;
-       cmd->speed = card->phy.speed;
+       ethtool_cmd_speed_set(cmd, card->phy.speed);
        cmd->duplex = DUPLEX_FULL;
 
        return 0;
@@ -55,7 +74,7 @@ spider_net_ethtool_get_drvinfo(struct net_device *netdev,
        /* clear and fill out info */
        memset(drvinfo, 0, sizeof(struct ethtool_drvinfo));
        strncpy(drvinfo->driver, spider_net_driver_name, 32);
-       strncpy(drvinfo->version, "0.1", 32);
+       strncpy(drvinfo->version, VERSION, 32);
        strcpy(drvinfo->fw_version, "no information");
        strncpy(drvinfo->bus_info, pci_name(card->pdev), 32);
 }
@@ -96,50 +115,65 @@ spider_net_ethtool_nway_reset(struct net_device *netdev)
        return 0;
 }
 
-static u32
-spider_net_ethtool_get_rx_csum(struct net_device *netdev)
+static void
+spider_net_ethtool_get_ringparam(struct net_device *netdev,
+                                struct ethtool_ringparam *ering)
 {
-       struct spider_net_card *card = netdev->priv;
+       struct spider_net_card *card = netdev_priv(netdev);
 
-       return card->options.rx_csum;
+       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_ethtool_set_rx_csum(struct net_device *netdev, u32 n)
+static int spider_net_get_sset_count(struct net_device *netdev, int sset)
 {
-       struct spider_net_card *card = netdev->priv;
-
-       card->options.rx_csum = n;
-       return 0;
+       switch (sset) {
+       case ETH_SS_STATS:
+               return ARRAY_SIZE(ethtool_stats_keys);
+       default:
+               return -EOPNOTSUPP;
+       }
 }
 
-static uint32_t
-spider_net_ethtool_get_tx_csum(struct net_device *netdev)
+static void spider_net_get_ethtool_stats(struct net_device *netdev,
+               struct ethtool_stats *stats, u64 *data)
 {
-        return (netdev->features & NETIF_F_HW_CSUM) != 0;
+       struct spider_net_card *card = netdev_priv(netdev);
+
+       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;
+       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 int
-spider_net_ethtool_set_tx_csum(struct net_device *netdev, uint32_t data)
+static void spider_net_get_strings(struct net_device *netdev, u32 stringset,
+                                  u8 *data)
 {
-        if (data)
-                netdev->features |= NETIF_F_HW_CSUM;
-        else
-                netdev->features &= ~NETIF_F_HW_CSUM;
-
-        return 0;
+       memcpy(data, ethtool_stats_keys, sizeof(ethtool_stats_keys));
 }
 
-struct ethtool_ops spider_net_ethtool_ops = {
+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            = spider_net_ethtool_get_tx_csum,
-       .set_tx_csum            = spider_net_ethtool_set_tx_csum,
+       .get_ringparam          = spider_net_ethtool_get_ringparam,
+       .get_strings            = spider_net_get_strings,
+       .get_sset_count         = spider_net_get_sset_count,
+       .get_ethtool_stats      = spider_net_get_ethtool_stats,
 };