2 * Copyright (C) 2006-2008 PA Semi, Inc
4 * Ethtool hooks for the PA Semi PWRficient onchip 1G/10G Ethernet MACs
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #include <linux/netdevice.h>
21 #include <linux/ethtool.h>
22 #include <linux/pci.h>
24 #include <asm/pasemi_dma.h>
25 #include "pasemi_mac.h"
28 const char str
[ETH_GSTRING_LEN
];
29 } ethtool_stats_keys
[] = {
33 { "rx-broadcast-packets" },
34 { "rx-multicast-packets" },
36 { "rx-undersize-errors" },
37 { "rx-oversize-errors" },
38 { "rx-short-fragment-errors" },
39 { "rx-jabber-errors" },
40 { "rx-64-byte-packets" },
41 { "rx-65-127-byte-packets" },
42 { "rx-128-255-byte-packets" },
43 { "rx-256-511-byte-packets" },
44 { "rx-512-1023-byte-packets" },
45 { "rx-1024-1518-byte-packets" },
46 { "rx-pause-frames" },
49 { "tx-broadcast-packets" },
50 { "tx-multicast-packets" },
52 { "tx-late-collisions" },
53 { "tx-excessive-collisions" },
55 { "tx-undersize-errors" },
56 { "tx-oversize-errors" },
57 { "tx-64-byte-packets" },
58 { "tx-65-127-byte-packets" },
59 { "tx-128-255-byte-packets" },
60 { "tx-256-511-byte-packets" },
61 { "tx-512-1023-byte-packets" },
62 { "tx-1024-1518-byte-packets" },
66 pasemi_mac_ethtool_get_msglevel(struct net_device
*netdev
)
68 struct pasemi_mac
*mac
= netdev_priv(netdev
);
69 return mac
->msg_enable
;
73 pasemi_mac_ethtool_set_msglevel(struct net_device
*netdev
,
76 struct pasemi_mac
*mac
= netdev_priv(netdev
);
77 mac
->msg_enable
= level
;
82 pasemi_mac_ethtool_get_ringparam(struct net_device
*netdev
,
83 struct ethtool_ringparam
*ering
)
85 struct pasemi_mac
*mac
= netdev_priv(netdev
);
87 ering
->tx_max_pending
= TX_RING_SIZE
/2;
88 ering
->tx_pending
= RING_USED(mac
->tx
)/2;
89 ering
->rx_max_pending
= RX_RING_SIZE
/4;
90 ering
->rx_pending
= RING_USED(mac
->rx
)/4;
93 static int pasemi_mac_get_sset_count(struct net_device
*netdev
, int sset
)
97 return ARRAY_SIZE(ethtool_stats_keys
);
103 static void pasemi_mac_get_ethtool_stats(struct net_device
*netdev
,
104 struct ethtool_stats
*stats
, u64
*data
)
106 struct pasemi_mac
*mac
= netdev_priv(netdev
);
109 data
[0] = pasemi_read_dma_reg(PAS_DMA_RXINT_RCMDSTA(mac
->dma_if
))
110 >> PAS_DMA_RXINT_RCMDSTA_DROPS_S
;
111 for (i
= 0; i
< 32; i
++)
112 data
[1+i
] = pasemi_read_mac_reg(mac
->dma_if
, PAS_MAC_RMON(i
));
115 static void pasemi_mac_get_strings(struct net_device
*netdev
, u32 stringset
,
118 memcpy(data
, ethtool_stats_keys
, sizeof(ethtool_stats_keys
));
121 const struct ethtool_ops pasemi_mac_ethtool_ops
= {
122 .get_msglevel
= pasemi_mac_ethtool_get_msglevel
,
123 .set_msglevel
= pasemi_mac_ethtool_set_msglevel
,
124 .get_link
= ethtool_op_get_link
,
125 .get_ringparam
= pasemi_mac_ethtool_get_ringparam
,
126 .get_strings
= pasemi_mac_get_strings
,
127 .get_sset_count
= pasemi_mac_get_sset_count
,
128 .get_ethtool_stats
= pasemi_mac_get_ethtool_stats
,
129 .get_link_ksettings
= phy_ethtool_get_link_ksettings
,
130 .set_link_ksettings
= phy_ethtool_set_link_ksettings
,