2 * Network device driver for Cell Processor-Based Blade
4 * (C) Copyright IBM Corp. 2005
6 * Authors : Utz Bacher <utz.bacher@de.ibm.com>
7 * Jens Osterkamp <Jens.Osterkamp@de.ibm.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2, or (at your option)
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include <linux/netdevice.h>
25 #include <linux/ethtool.h>
26 #include <linux/pci.h>
28 #include "spider_net.h"
32 const char str
[ETH_GSTRING_LEN
];
33 } ethtool_stats_keys
[] = {
41 { "rx_descriptor_error" },
43 { "alloc_rx_skb_error" },
44 { "rx_iommu_map_error" },
45 { "tx_iommu_map_error" },
46 { "rx_desc_unk_state" },
50 spider_net_ethtool_get_settings(struct net_device
*netdev
,
51 struct ethtool_cmd
*cmd
)
53 struct spider_net_card
*card
;
54 card
= netdev_priv(netdev
);
56 cmd
->supported
= (SUPPORTED_1000baseT_Full
|
58 cmd
->advertising
= (ADVERTISED_1000baseT_Full
|
60 cmd
->port
= PORT_FIBRE
;
61 ethtool_cmd_speed_set(cmd
, card
->phy
.speed
);
62 cmd
->duplex
= DUPLEX_FULL
;
68 spider_net_ethtool_get_drvinfo(struct net_device
*netdev
,
69 struct ethtool_drvinfo
*drvinfo
)
71 struct spider_net_card
*card
;
72 card
= netdev_priv(netdev
);
74 /* clear and fill out info */
75 strlcpy(drvinfo
->driver
, spider_net_driver_name
,
76 sizeof(drvinfo
->driver
));
77 strlcpy(drvinfo
->version
, VERSION
, sizeof(drvinfo
->version
));
78 strlcpy(drvinfo
->fw_version
, "no information",
79 sizeof(drvinfo
->fw_version
));
80 strlcpy(drvinfo
->bus_info
, pci_name(card
->pdev
),
81 sizeof(drvinfo
->bus_info
));
85 spider_net_ethtool_get_wol(struct net_device
*netdev
,
86 struct ethtool_wolinfo
*wolinfo
)
88 /* no support for wol */
89 wolinfo
->supported
= 0;
94 spider_net_ethtool_get_msglevel(struct net_device
*netdev
)
96 struct spider_net_card
*card
;
97 card
= netdev_priv(netdev
);
98 return card
->msg_enable
;
102 spider_net_ethtool_set_msglevel(struct net_device
*netdev
,
105 struct spider_net_card
*card
;
106 card
= netdev_priv(netdev
);
107 card
->msg_enable
= level
;
111 spider_net_ethtool_nway_reset(struct net_device
*netdev
)
113 if (netif_running(netdev
)) {
114 spider_net_stop(netdev
);
115 spider_net_open(netdev
);
121 spider_net_ethtool_get_ringparam(struct net_device
*netdev
,
122 struct ethtool_ringparam
*ering
)
124 struct spider_net_card
*card
= netdev_priv(netdev
);
126 ering
->tx_max_pending
= SPIDER_NET_TX_DESCRIPTORS_MAX
;
127 ering
->tx_pending
= card
->tx_chain
.num_desc
;
128 ering
->rx_max_pending
= SPIDER_NET_RX_DESCRIPTORS_MAX
;
129 ering
->rx_pending
= card
->rx_chain
.num_desc
;
132 static int spider_net_get_sset_count(struct net_device
*netdev
, int sset
)
136 return ARRAY_SIZE(ethtool_stats_keys
);
142 static void spider_net_get_ethtool_stats(struct net_device
*netdev
,
143 struct ethtool_stats
*stats
, u64
*data
)
145 struct spider_net_card
*card
= netdev_priv(netdev
);
147 data
[0] = netdev
->stats
.tx_packets
;
148 data
[1] = netdev
->stats
.tx_bytes
;
149 data
[2] = netdev
->stats
.rx_packets
;
150 data
[3] = netdev
->stats
.rx_bytes
;
151 data
[4] = netdev
->stats
.tx_errors
;
152 data
[5] = netdev
->stats
.tx_dropped
;
153 data
[6] = netdev
->stats
.rx_dropped
;
154 data
[7] = card
->spider_stats
.rx_desc_error
;
155 data
[8] = card
->spider_stats
.tx_timeouts
;
156 data
[9] = card
->spider_stats
.alloc_rx_skb_error
;
157 data
[10] = card
->spider_stats
.rx_iommu_map_error
;
158 data
[11] = card
->spider_stats
.tx_iommu_map_error
;
159 data
[12] = card
->spider_stats
.rx_desc_unk_state
;
162 static void spider_net_get_strings(struct net_device
*netdev
, u32 stringset
,
165 memcpy(data
, ethtool_stats_keys
, sizeof(ethtool_stats_keys
));
168 const struct ethtool_ops spider_net_ethtool_ops
= {
169 .get_settings
= spider_net_ethtool_get_settings
,
170 .get_drvinfo
= spider_net_ethtool_get_drvinfo
,
171 .get_wol
= spider_net_ethtool_get_wol
,
172 .get_msglevel
= spider_net_ethtool_get_msglevel
,
173 .set_msglevel
= spider_net_ethtool_set_msglevel
,
174 .get_link
= ethtool_op_get_link
,
175 .nway_reset
= spider_net_ethtool_nway_reset
,
176 .get_ringparam
= spider_net_ethtool_get_ringparam
,
177 .get_strings
= spider_net_get_strings
,
178 .get_sset_count
= spider_net_get_sset_count
,
179 .get_ethtool_stats
= spider_net_get_ethtool_stats
,