2 * linux/drivers/net/ehea/ehea_ethtool.c
4 * eHEA ethernet device driver for IBM eServer System p
6 * (C) Copyright IBM Corp. 2006
9 * Christoph Raisch <raisch@de.ibm.com>
10 * Jan-Bernd Themann <themann@de.ibm.com>
11 * Thomas Klein <tklein@de.ibm.com>
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2, or (at your option)
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
32 #include "ehea_phyp.h"
34 static int ehea_get_settings(struct net_device
*dev
, struct ethtool_cmd
*cmd
)
36 struct ehea_port
*port
= netdev_priv(dev
);
39 ret
= ehea_sense_port_attr(port
);
44 if (netif_carrier_ok(dev
)) {
45 switch (port
->port_speed
) {
46 case EHEA_SPEED_10M
: cmd
->speed
= SPEED_10
; break;
47 case EHEA_SPEED_100M
: cmd
->speed
= SPEED_100
; break;
48 case EHEA_SPEED_1G
: cmd
->speed
= SPEED_1000
; break;
49 case EHEA_SPEED_10G
: cmd
->speed
= SPEED_10000
; break;
51 cmd
->duplex
= port
->full_duplex
== 1 ?
52 DUPLEX_FULL
: DUPLEX_HALF
;
58 cmd
->supported
= (SUPPORTED_10000baseT_Full
| SUPPORTED_1000baseT_Full
59 | SUPPORTED_100baseT_Full
| SUPPORTED_100baseT_Half
60 | SUPPORTED_10baseT_Full
| SUPPORTED_10baseT_Half
61 | SUPPORTED_Autoneg
| SUPPORTED_FIBRE
);
63 cmd
->advertising
= (ADVERTISED_10000baseT_Full
| ADVERTISED_Autoneg
66 cmd
->port
= PORT_FIBRE
;
67 cmd
->autoneg
= port
->autoneg
== 1 ? AUTONEG_ENABLE
: AUTONEG_DISABLE
;
72 static int ehea_set_settings(struct net_device
*dev
, struct ethtool_cmd
*cmd
)
74 struct ehea_port
*port
= netdev_priv(dev
);
78 if (cmd
->autoneg
== AUTONEG_ENABLE
) {
79 sp
= EHEA_SPEED_AUTONEG
;
85 if (cmd
->duplex
== DUPLEX_FULL
)
92 if (cmd
->duplex
== DUPLEX_FULL
)
99 if (cmd
->duplex
== DUPLEX_FULL
)
106 if (cmd
->duplex
== DUPLEX_FULL
)
120 ret
= ehea_set_portspeed(port
, sp
);
124 "Port speed successfully set: %dMbps %s Duplex\n",
126 port
->full_duplex
== 1 ? "Full" : "Half");
131 static int ehea_nway_reset(struct net_device
*dev
)
133 struct ehea_port
*port
= netdev_priv(dev
);
136 ret
= ehea_set_portspeed(port
, EHEA_SPEED_AUTONEG
);
139 netdev_info(port
->netdev
,
140 "Port speed successfully set: %dMbps %s Duplex\n",
142 port
->full_duplex
== 1 ? "Full" : "Half");
146 static void ehea_get_drvinfo(struct net_device
*dev
,
147 struct ethtool_drvinfo
*info
)
149 strlcpy(info
->driver
, DRV_NAME
, sizeof(info
->driver
));
150 strlcpy(info
->version
, DRV_VERSION
, sizeof(info
->version
));
153 static u32
ehea_get_msglevel(struct net_device
*dev
)
155 struct ehea_port
*port
= netdev_priv(dev
);
156 return port
->msg_enable
;
159 static void ehea_set_msglevel(struct net_device
*dev
, u32 value
)
161 struct ehea_port
*port
= netdev_priv(dev
);
162 port
->msg_enable
= value
;
165 static u32
ehea_get_rx_csum(struct net_device
*dev
)
170 static char ehea_ethtool_stats_keys
[][ETH_GSTRING_LEN
] = {
175 {"TCP cksum errors"},
177 {"Frame cksum errors"},
193 static void ehea_get_strings(struct net_device
*dev
, u32 stringset
, u8
*data
)
195 if (stringset
== ETH_SS_STATS
) {
196 memcpy(data
, &ehea_ethtool_stats_keys
,
197 sizeof(ehea_ethtool_stats_keys
));
201 static int ehea_get_sset_count(struct net_device
*dev
, int sset
)
205 return ARRAY_SIZE(ehea_ethtool_stats_keys
);
211 static void ehea_get_ethtool_stats(struct net_device
*dev
,
212 struct ethtool_stats
*stats
, u64
*data
)
215 struct ehea_port
*port
= netdev_priv(dev
);
217 for (i
= 0; i
< ehea_get_sset_count(dev
, ETH_SS_STATS
); i
++)
221 data
[i
++] = port
->sig_comp_iv
;
222 data
[i
++] = port
->port_res
[0].swqe_refill_th
;
223 data
[i
++] = port
->resets
;
225 for (k
= 0, tmp
= 0; k
< EHEA_MAX_PORT_RES
; k
++)
226 tmp
+= port
->port_res
[k
].p_stats
.poll_receive_errors
;
229 for (k
= 0, tmp
= 0; k
< EHEA_MAX_PORT_RES
; k
++)
230 tmp
+= port
->port_res
[k
].p_stats
.err_tcp_cksum
;
233 for (k
= 0, tmp
= 0; k
< EHEA_MAX_PORT_RES
; k
++)
234 tmp
+= port
->port_res
[k
].p_stats
.err_ip_cksum
;
237 for (k
= 0, tmp
= 0; k
< EHEA_MAX_PORT_RES
; k
++)
238 tmp
+= port
->port_res
[k
].p_stats
.err_frame_crc
;
241 for (k
= 0, tmp
= 0; k
< EHEA_MAX_PORT_RES
; k
++)
242 tmp
+= port
->port_res
[k
].p_stats
.queue_stopped
;
245 for (k
= 0, tmp
= 0; k
< EHEA_MAX_PORT_RES
; k
++)
246 tmp
|= port
->port_res
[k
].queue_stopped
;
249 for (k
= 0; k
< 8; k
++)
250 data
[i
++] = atomic_read(&port
->port_res
[k
].swqe_avail
);
252 for (k
= 0, tmp
= 0; k
< EHEA_MAX_PORT_RES
; k
++)
253 tmp
|= port
->port_res
[k
].lro_mgr
.stats
.aggregated
;
256 for (k
= 0, tmp
= 0; k
< EHEA_MAX_PORT_RES
; k
++)
257 tmp
|= port
->port_res
[k
].lro_mgr
.stats
.flushed
;
260 for (k
= 0, tmp
= 0; k
< EHEA_MAX_PORT_RES
; k
++)
261 tmp
|= port
->port_res
[k
].lro_mgr
.stats
.no_desc
;
266 static int ehea_set_flags(struct net_device
*dev
, u32 data
)
268 /* Avoid changing the VLAN flags */
269 if ((data
& (ETH_FLAG_RXVLAN
| ETH_FLAG_TXVLAN
)) !=
270 (ethtool_op_get_flags(dev
) & (ETH_FLAG_RXVLAN
|
275 return ethtool_op_set_flags(dev
, data
, ETH_FLAG_LRO
280 const struct ethtool_ops ehea_ethtool_ops
= {
281 .get_settings
= ehea_get_settings
,
282 .get_drvinfo
= ehea_get_drvinfo
,
283 .get_msglevel
= ehea_get_msglevel
,
284 .set_msglevel
= ehea_set_msglevel
,
285 .get_link
= ethtool_op_get_link
,
286 .set_tso
= ethtool_op_set_tso
,
287 .get_strings
= ehea_get_strings
,
288 .get_sset_count
= ehea_get_sset_count
,
289 .get_ethtool_stats
= ehea_get_ethtool_stats
,
290 .get_rx_csum
= ehea_get_rx_csum
,
291 .set_settings
= ehea_set_settings
,
292 .get_flags
= ethtool_op_get_flags
,
293 .set_flags
= ehea_set_flags
,
294 .nway_reset
= ehea_nway_reset
, /* Restart autonegotiation */
297 void ehea_set_ethtool_ops(struct net_device
*netdev
)
299 SET_ETHTOOL_OPS(netdev
, &ehea_ethtool_ops
);