1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Network device driver for Cell Processor-Based Blade
5 * (C) Copyright IBM Corp. 2005
7 * Authors : Utz Bacher <utz.bacher@de.ibm.com>
8 * Jens Osterkamp <Jens.Osterkamp@de.ibm.com>
11 #include <linux/netdevice.h>
12 #include <linux/ethtool.h>
13 #include <linux/pci.h>
15 #include "spider_net.h"
19 const char str
[ETH_GSTRING_LEN
];
20 } ethtool_stats_keys
[] = {
28 { "rx_descriptor_error" },
30 { "alloc_rx_skb_error" },
31 { "rx_iommu_map_error" },
32 { "tx_iommu_map_error" },
33 { "rx_desc_unk_state" },
37 spider_net_ethtool_get_link_ksettings(struct net_device
*netdev
,
38 struct ethtool_link_ksettings
*cmd
)
40 struct spider_net_card
*card
;
41 card
= netdev_priv(netdev
);
43 ethtool_link_ksettings_zero_link_mode(cmd
, supported
);
44 ethtool_link_ksettings_add_link_mode(cmd
, supported
, 1000baseT_Full
);
45 ethtool_link_ksettings_add_link_mode(cmd
, supported
, FIBRE
);
47 ethtool_link_ksettings_zero_link_mode(cmd
, advertising
);
48 ethtool_link_ksettings_add_link_mode(cmd
, advertising
, 1000baseT_Full
);
49 ethtool_link_ksettings_add_link_mode(cmd
, advertising
, FIBRE
);
51 cmd
->base
.port
= PORT_FIBRE
;
52 cmd
->base
.speed
= card
->phy
.speed
;
53 cmd
->base
.duplex
= DUPLEX_FULL
;
59 spider_net_ethtool_get_drvinfo(struct net_device
*netdev
,
60 struct ethtool_drvinfo
*drvinfo
)
62 struct spider_net_card
*card
;
63 card
= netdev_priv(netdev
);
65 /* clear and fill out info */
66 strlcpy(drvinfo
->driver
, spider_net_driver_name
,
67 sizeof(drvinfo
->driver
));
68 strlcpy(drvinfo
->version
, VERSION
, sizeof(drvinfo
->version
));
69 strlcpy(drvinfo
->fw_version
, "no information",
70 sizeof(drvinfo
->fw_version
));
71 strlcpy(drvinfo
->bus_info
, pci_name(card
->pdev
),
72 sizeof(drvinfo
->bus_info
));
76 spider_net_ethtool_get_wol(struct net_device
*netdev
,
77 struct ethtool_wolinfo
*wolinfo
)
79 /* no support for wol */
80 wolinfo
->supported
= 0;
85 spider_net_ethtool_get_msglevel(struct net_device
*netdev
)
87 struct spider_net_card
*card
;
88 card
= netdev_priv(netdev
);
89 return card
->msg_enable
;
93 spider_net_ethtool_set_msglevel(struct net_device
*netdev
,
96 struct spider_net_card
*card
;
97 card
= netdev_priv(netdev
);
98 card
->msg_enable
= level
;
102 spider_net_ethtool_nway_reset(struct net_device
*netdev
)
104 if (netif_running(netdev
)) {
105 spider_net_stop(netdev
);
106 spider_net_open(netdev
);
112 spider_net_ethtool_get_ringparam(struct net_device
*netdev
,
113 struct ethtool_ringparam
*ering
)
115 struct spider_net_card
*card
= netdev_priv(netdev
);
117 ering
->tx_max_pending
= SPIDER_NET_TX_DESCRIPTORS_MAX
;
118 ering
->tx_pending
= card
->tx_chain
.num_desc
;
119 ering
->rx_max_pending
= SPIDER_NET_RX_DESCRIPTORS_MAX
;
120 ering
->rx_pending
= card
->rx_chain
.num_desc
;
123 static int spider_net_get_sset_count(struct net_device
*netdev
, int sset
)
127 return ARRAY_SIZE(ethtool_stats_keys
);
133 static void spider_net_get_ethtool_stats(struct net_device
*netdev
,
134 struct ethtool_stats
*stats
, u64
*data
)
136 struct spider_net_card
*card
= netdev_priv(netdev
);
138 data
[0] = netdev
->stats
.tx_packets
;
139 data
[1] = netdev
->stats
.tx_bytes
;
140 data
[2] = netdev
->stats
.rx_packets
;
141 data
[3] = netdev
->stats
.rx_bytes
;
142 data
[4] = netdev
->stats
.tx_errors
;
143 data
[5] = netdev
->stats
.tx_dropped
;
144 data
[6] = netdev
->stats
.rx_dropped
;
145 data
[7] = card
->spider_stats
.rx_desc_error
;
146 data
[8] = card
->spider_stats
.tx_timeouts
;
147 data
[9] = card
->spider_stats
.alloc_rx_skb_error
;
148 data
[10] = card
->spider_stats
.rx_iommu_map_error
;
149 data
[11] = card
->spider_stats
.tx_iommu_map_error
;
150 data
[12] = card
->spider_stats
.rx_desc_unk_state
;
153 static void spider_net_get_strings(struct net_device
*netdev
, u32 stringset
,
156 memcpy(data
, ethtool_stats_keys
, sizeof(ethtool_stats_keys
));
159 const struct ethtool_ops spider_net_ethtool_ops
= {
160 .get_drvinfo
= spider_net_ethtool_get_drvinfo
,
161 .get_wol
= spider_net_ethtool_get_wol
,
162 .get_msglevel
= spider_net_ethtool_get_msglevel
,
163 .set_msglevel
= spider_net_ethtool_set_msglevel
,
164 .get_link
= ethtool_op_get_link
,
165 .nway_reset
= spider_net_ethtool_nway_reset
,
166 .get_ringparam
= spider_net_ethtool_get_ringparam
,
167 .get_strings
= spider_net_get_strings
,
168 .get_sset_count
= spider_net_get_sset_count
,
169 .get_ethtool_stats
= spider_net_get_ethtool_stats
,
170 .get_link_ksettings
= spider_net_ethtool_get_link_ksettings
,