1 |
1275 |
phoenix |
/*******************************************************************************
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
Copyright(c) 1999 - 2004 Intel Corporation. All rights reserved.
|
5 |
|
|
|
6 |
|
|
This program is free software; you can redistribute it and/or modify it
|
7 |
|
|
under the terms of the GNU General Public License as published by the Free
|
8 |
|
|
Software Foundation; either version 2 of the License, or (at your option)
|
9 |
|
|
any later version.
|
10 |
|
|
|
11 |
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
12 |
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
13 |
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
14 |
|
|
more details.
|
15 |
|
|
|
16 |
|
|
You should have received a copy of the GNU General Public License along with
|
17 |
|
|
this program; if not, write to the Free Software Foundation, Inc., 59
|
18 |
|
|
Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
19 |
|
|
|
20 |
|
|
The full GNU General Public License is included in this distribution in the
|
21 |
|
|
file called LICENSE.
|
22 |
|
|
|
23 |
|
|
Contact Information:
|
24 |
|
|
Linux NICS <linux.nics@intel.com>
|
25 |
|
|
Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
|
26 |
|
|
|
27 |
|
|
*******************************************************************************/
|
28 |
|
|
|
29 |
|
|
/* ethtool support for e1000 */
|
30 |
|
|
|
31 |
|
|
#include "e1000.h"
|
32 |
|
|
|
33 |
|
|
#include <asm/uaccess.h>
|
34 |
|
|
|
35 |
|
|
extern char e1000_driver_name[];
|
36 |
|
|
extern char e1000_driver_version[];
|
37 |
|
|
|
38 |
|
|
extern int e1000_up(struct e1000_adapter *adapter);
|
39 |
|
|
extern void e1000_down(struct e1000_adapter *adapter);
|
40 |
|
|
extern void e1000_reset(struct e1000_adapter *adapter);
|
41 |
|
|
extern int e1000_set_spd_dplx(struct e1000_adapter *adapter, uint16_t spddplx);
|
42 |
|
|
extern int e1000_setup_rx_resources(struct e1000_adapter *adapter);
|
43 |
|
|
extern int e1000_setup_tx_resources(struct e1000_adapter *adapter);
|
44 |
|
|
extern void e1000_free_rx_resources(struct e1000_adapter *adapter);
|
45 |
|
|
extern void e1000_free_tx_resources(struct e1000_adapter *adapter);
|
46 |
|
|
extern void e1000_update_stats(struct e1000_adapter *adapter);
|
47 |
|
|
|
48 |
|
|
struct e1000_stats {
|
49 |
|
|
char stat_string[ETH_GSTRING_LEN];
|
50 |
|
|
int sizeof_stat;
|
51 |
|
|
int stat_offset;
|
52 |
|
|
};
|
53 |
|
|
|
54 |
|
|
#define E1000_STAT(m) sizeof(((struct e1000_adapter *)0)->m), \
|
55 |
|
|
offsetof(struct e1000_adapter, m)
|
56 |
|
|
static struct e1000_stats e1000_gstrings_stats[] = {
|
57 |
|
|
{ "rx_packets", E1000_STAT(net_stats.rx_packets) },
|
58 |
|
|
{ "tx_packets", E1000_STAT(net_stats.tx_packets) },
|
59 |
|
|
{ "rx_bytes", E1000_STAT(net_stats.rx_bytes) },
|
60 |
|
|
{ "tx_bytes", E1000_STAT(net_stats.tx_bytes) },
|
61 |
|
|
{ "rx_errors", E1000_STAT(net_stats.rx_errors) },
|
62 |
|
|
{ "tx_errors", E1000_STAT(net_stats.tx_errors) },
|
63 |
|
|
{ "rx_dropped", E1000_STAT(net_stats.rx_dropped) },
|
64 |
|
|
{ "tx_dropped", E1000_STAT(net_stats.tx_dropped) },
|
65 |
|
|
{ "multicast", E1000_STAT(net_stats.multicast) },
|
66 |
|
|
{ "collisions", E1000_STAT(net_stats.collisions) },
|
67 |
|
|
{ "rx_length_errors", E1000_STAT(net_stats.rx_length_errors) },
|
68 |
|
|
{ "rx_over_errors", E1000_STAT(net_stats.rx_over_errors) },
|
69 |
|
|
{ "rx_crc_errors", E1000_STAT(net_stats.rx_crc_errors) },
|
70 |
|
|
{ "rx_frame_errors", E1000_STAT(net_stats.rx_frame_errors) },
|
71 |
|
|
{ "rx_fifo_errors", E1000_STAT(net_stats.rx_fifo_errors) },
|
72 |
|
|
{ "rx_missed_errors", E1000_STAT(net_stats.rx_missed_errors) },
|
73 |
|
|
{ "tx_aborted_errors", E1000_STAT(net_stats.tx_aborted_errors) },
|
74 |
|
|
{ "tx_carrier_errors", E1000_STAT(net_stats.tx_carrier_errors) },
|
75 |
|
|
{ "tx_fifo_errors", E1000_STAT(net_stats.tx_fifo_errors) },
|
76 |
|
|
{ "tx_heartbeat_errors", E1000_STAT(net_stats.tx_heartbeat_errors) },
|
77 |
|
|
{ "tx_window_errors", E1000_STAT(net_stats.tx_window_errors) },
|
78 |
|
|
{ "tx_abort_late_coll", E1000_STAT(stats.latecol) },
|
79 |
|
|
{ "tx_deferred_ok", E1000_STAT(stats.dc) },
|
80 |
|
|
{ "tx_single_coll_ok", E1000_STAT(stats.scc) },
|
81 |
|
|
{ "tx_multi_coll_ok", E1000_STAT(stats.mcc) },
|
82 |
|
|
{ "rx_long_length_errors", E1000_STAT(stats.roc) },
|
83 |
|
|
{ "rx_short_length_errors", E1000_STAT(stats.ruc) },
|
84 |
|
|
{ "rx_align_errors", E1000_STAT(stats.algnerrc) },
|
85 |
|
|
{ "tx_tcp_seg_good", E1000_STAT(stats.tsctc) },
|
86 |
|
|
{ "tx_tcp_seg_failed", E1000_STAT(stats.tsctfc) },
|
87 |
|
|
{ "rx_flow_control_xon", E1000_STAT(stats.xonrxc) },
|
88 |
|
|
{ "rx_flow_control_xoff", E1000_STAT(stats.xoffrxc) },
|
89 |
|
|
{ "tx_flow_control_xon", E1000_STAT(stats.xontxc) },
|
90 |
|
|
{ "tx_flow_control_xoff", E1000_STAT(stats.xofftxc) },
|
91 |
|
|
{ "rx_csum_offload_good", E1000_STAT(hw_csum_good) },
|
92 |
|
|
{ "rx_csum_offload_errors", E1000_STAT(hw_csum_err) }
|
93 |
|
|
};
|
94 |
|
|
#define E1000_STATS_LEN \
|
95 |
|
|
sizeof(e1000_gstrings_stats) / sizeof(struct e1000_stats)
|
96 |
|
|
static char e1000_gstrings_test[][ETH_GSTRING_LEN] = {
|
97 |
|
|
"Register test (offline)", "Eeprom test (offline)",
|
98 |
|
|
"Interrupt test (offline)", "Loopback test (offline)",
|
99 |
|
|
"Link test (on/offline)"
|
100 |
|
|
};
|
101 |
|
|
#define E1000_TEST_LEN sizeof(e1000_gstrings_test) / ETH_GSTRING_LEN
|
102 |
|
|
|
103 |
|
|
static void
|
104 |
|
|
e1000_ethtool_gset(struct e1000_adapter *adapter, struct ethtool_cmd *ecmd)
|
105 |
|
|
{
|
106 |
|
|
struct e1000_hw *hw = &adapter->hw;
|
107 |
|
|
|
108 |
|
|
if(hw->media_type == e1000_media_type_copper) {
|
109 |
|
|
|
110 |
|
|
ecmd->supported = (SUPPORTED_10baseT_Half |
|
111 |
|
|
SUPPORTED_10baseT_Full |
|
112 |
|
|
SUPPORTED_100baseT_Half |
|
113 |
|
|
SUPPORTED_100baseT_Full |
|
114 |
|
|
SUPPORTED_1000baseT_Full|
|
115 |
|
|
SUPPORTED_Autoneg |
|
116 |
|
|
SUPPORTED_TP);
|
117 |
|
|
|
118 |
|
|
ecmd->advertising = ADVERTISED_TP;
|
119 |
|
|
|
120 |
|
|
if(hw->autoneg == 1) {
|
121 |
|
|
ecmd->advertising |= ADVERTISED_Autoneg;
|
122 |
|
|
|
123 |
|
|
/* the e1000 autoneg seems to match ethtool nicely */
|
124 |
|
|
|
125 |
|
|
ecmd->advertising |= hw->autoneg_advertised;
|
126 |
|
|
}
|
127 |
|
|
|
128 |
|
|
ecmd->port = PORT_TP;
|
129 |
|
|
ecmd->phy_address = hw->phy_addr;
|
130 |
|
|
|
131 |
|
|
if(hw->mac_type == e1000_82543)
|
132 |
|
|
ecmd->transceiver = XCVR_EXTERNAL;
|
133 |
|
|
else
|
134 |
|
|
ecmd->transceiver = XCVR_INTERNAL;
|
135 |
|
|
|
136 |
|
|
} else {
|
137 |
|
|
ecmd->supported = (SUPPORTED_1000baseT_Full |
|
138 |
|
|
SUPPORTED_FIBRE |
|
139 |
|
|
SUPPORTED_Autoneg);
|
140 |
|
|
|
141 |
|
|
ecmd->advertising = (SUPPORTED_1000baseT_Full |
|
142 |
|
|
SUPPORTED_FIBRE |
|
143 |
|
|
SUPPORTED_Autoneg);
|
144 |
|
|
|
145 |
|
|
ecmd->port = PORT_FIBRE;
|
146 |
|
|
|
147 |
|
|
if(hw->mac_type >= e1000_82545)
|
148 |
|
|
ecmd->transceiver = XCVR_INTERNAL;
|
149 |
|
|
else
|
150 |
|
|
ecmd->transceiver = XCVR_EXTERNAL;
|
151 |
|
|
}
|
152 |
|
|
|
153 |
|
|
if(netif_carrier_ok(adapter->netdev)) {
|
154 |
|
|
|
155 |
|
|
e1000_get_speed_and_duplex(hw, &adapter->link_speed,
|
156 |
|
|
&adapter->link_duplex);
|
157 |
|
|
ecmd->speed = adapter->link_speed;
|
158 |
|
|
|
159 |
|
|
/* unfortunatly FULL_DUPLEX != DUPLEX_FULL
|
160 |
|
|
* and HALF_DUPLEX != DUPLEX_HALF */
|
161 |
|
|
|
162 |
|
|
if(adapter->link_duplex == FULL_DUPLEX)
|
163 |
|
|
ecmd->duplex = DUPLEX_FULL;
|
164 |
|
|
else
|
165 |
|
|
ecmd->duplex = DUPLEX_HALF;
|
166 |
|
|
} else {
|
167 |
|
|
ecmd->speed = -1;
|
168 |
|
|
ecmd->duplex = -1;
|
169 |
|
|
}
|
170 |
|
|
|
171 |
|
|
ecmd->autoneg = (hw->autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE);
|
172 |
|
|
}
|
173 |
|
|
|
174 |
|
|
static int
|
175 |
|
|
e1000_ethtool_sset(struct e1000_adapter *adapter, struct ethtool_cmd *ecmd)
|
176 |
|
|
{
|
177 |
|
|
struct e1000_hw *hw = &adapter->hw;
|
178 |
|
|
|
179 |
|
|
if(ecmd->autoneg == AUTONEG_ENABLE) {
|
180 |
|
|
hw->autoneg = 1;
|
181 |
|
|
hw->autoneg_advertised = 0x002F;
|
182 |
|
|
ecmd->advertising = 0x002F;
|
183 |
|
|
} else
|
184 |
|
|
if(e1000_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex))
|
185 |
|
|
return -EINVAL;
|
186 |
|
|
|
187 |
|
|
/* reset the link */
|
188 |
|
|
|
189 |
|
|
if(netif_running(adapter->netdev)) {
|
190 |
|
|
e1000_down(adapter);
|
191 |
|
|
e1000_up(adapter);
|
192 |
|
|
} else
|
193 |
|
|
e1000_reset(adapter);
|
194 |
|
|
|
195 |
|
|
return 0;
|
196 |
|
|
}
|
197 |
|
|
|
198 |
|
|
static int
|
199 |
|
|
e1000_ethtool_gpause(struct e1000_adapter *adapter,
|
200 |
|
|
struct ethtool_pauseparam *epause)
|
201 |
|
|
{
|
202 |
|
|
struct e1000_hw *hw = &adapter->hw;
|
203 |
|
|
|
204 |
|
|
epause->autoneg =
|
205 |
|
|
(adapter->fc_autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE);
|
206 |
|
|
|
207 |
|
|
if(hw->fc == e1000_fc_rx_pause)
|
208 |
|
|
epause->rx_pause = 1;
|
209 |
|
|
else if(hw->fc == e1000_fc_tx_pause)
|
210 |
|
|
epause->tx_pause = 1;
|
211 |
|
|
else if(hw->fc == e1000_fc_full) {
|
212 |
|
|
epause->rx_pause = 1;
|
213 |
|
|
epause->tx_pause = 1;
|
214 |
|
|
}
|
215 |
|
|
|
216 |
|
|
return 0;
|
217 |
|
|
}
|
218 |
|
|
|
219 |
|
|
static int
|
220 |
|
|
e1000_ethtool_spause(struct e1000_adapter *adapter,
|
221 |
|
|
struct ethtool_pauseparam *epause)
|
222 |
|
|
{
|
223 |
|
|
struct e1000_hw *hw = &adapter->hw;
|
224 |
|
|
|
225 |
|
|
adapter->fc_autoneg = epause->autoneg;
|
226 |
|
|
|
227 |
|
|
if(epause->rx_pause && epause->tx_pause)
|
228 |
|
|
hw->fc = e1000_fc_full;
|
229 |
|
|
else if(epause->rx_pause && !epause->tx_pause)
|
230 |
|
|
hw->fc = e1000_fc_rx_pause;
|
231 |
|
|
else if(!epause->rx_pause && epause->tx_pause)
|
232 |
|
|
hw->fc = e1000_fc_tx_pause;
|
233 |
|
|
else if(!epause->rx_pause && !epause->tx_pause)
|
234 |
|
|
hw->fc = e1000_fc_none;
|
235 |
|
|
|
236 |
|
|
hw->original_fc = hw->fc;
|
237 |
|
|
|
238 |
|
|
if(adapter->fc_autoneg == AUTONEG_ENABLE) {
|
239 |
|
|
if(netif_running(adapter->netdev)) {
|
240 |
|
|
e1000_down(adapter);
|
241 |
|
|
e1000_up(adapter);
|
242 |
|
|
} else
|
243 |
|
|
e1000_reset(adapter);
|
244 |
|
|
}
|
245 |
|
|
else
|
246 |
|
|
return e1000_force_mac_fc(hw);
|
247 |
|
|
|
248 |
|
|
return 0;
|
249 |
|
|
}
|
250 |
|
|
|
251 |
|
|
static void
|
252 |
|
|
e1000_ethtool_gdrvinfo(struct e1000_adapter *adapter,
|
253 |
|
|
struct ethtool_drvinfo *drvinfo)
|
254 |
|
|
{
|
255 |
|
|
strncpy(drvinfo->driver, e1000_driver_name, 32);
|
256 |
|
|
strncpy(drvinfo->version, e1000_driver_version, 32);
|
257 |
|
|
strncpy(drvinfo->fw_version, "N/A", 32);
|
258 |
|
|
strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32);
|
259 |
|
|
drvinfo->n_stats = E1000_STATS_LEN;
|
260 |
|
|
drvinfo->testinfo_len = E1000_TEST_LEN;
|
261 |
|
|
#define E1000_REGS_LEN 32
|
262 |
|
|
drvinfo->regdump_len = E1000_REGS_LEN * sizeof(uint32_t);
|
263 |
|
|
drvinfo->eedump_len = adapter->hw.eeprom.word_size * 2;
|
264 |
|
|
}
|
265 |
|
|
|
266 |
|
|
static void
|
267 |
|
|
e1000_ethtool_gregs(struct e1000_adapter *adapter,
|
268 |
|
|
struct ethtool_regs *regs, uint32_t *regs_buff)
|
269 |
|
|
{
|
270 |
|
|
struct e1000_hw *hw = &adapter->hw;
|
271 |
|
|
uint16_t phy_data;
|
272 |
|
|
|
273 |
|
|
regs->version = (1 << 24) | (hw->revision_id << 16) | hw->device_id;
|
274 |
|
|
|
275 |
|
|
regs_buff[0] = E1000_READ_REG(hw, CTRL);
|
276 |
|
|
regs_buff[1] = E1000_READ_REG(hw, STATUS);
|
277 |
|
|
|
278 |
|
|
regs_buff[2] = E1000_READ_REG(hw, RCTL);
|
279 |
|
|
regs_buff[3] = E1000_READ_REG(hw, RDLEN);
|
280 |
|
|
regs_buff[4] = E1000_READ_REG(hw, RDH);
|
281 |
|
|
regs_buff[5] = E1000_READ_REG(hw, RDT);
|
282 |
|
|
regs_buff[6] = E1000_READ_REG(hw, RDTR);
|
283 |
|
|
|
284 |
|
|
regs_buff[7] = E1000_READ_REG(hw, TCTL);
|
285 |
|
|
regs_buff[8] = E1000_READ_REG(hw, TDLEN);
|
286 |
|
|
regs_buff[9] = E1000_READ_REG(hw, TDH);
|
287 |
|
|
regs_buff[10] = E1000_READ_REG(hw, TDT);
|
288 |
|
|
regs_buff[11] = E1000_READ_REG(hw, TIDV);
|
289 |
|
|
|
290 |
|
|
regs_buff[12] = adapter->hw.phy_type; /* PHY type (IGP=1, M88=0) */
|
291 |
|
|
if(hw->phy_type == e1000_phy_igp) {
|
292 |
|
|
e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT,
|
293 |
|
|
IGP01E1000_PHY_AGC_A);
|
294 |
|
|
e1000_read_phy_reg(hw, IGP01E1000_PHY_AGC_A &
|
295 |
|
|
IGP01E1000_PHY_PAGE_SELECT, &phy_data);
|
296 |
|
|
regs_buff[13] = (uint32_t)phy_data; /* cable length */
|
297 |
|
|
e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT,
|
298 |
|
|
IGP01E1000_PHY_AGC_B);
|
299 |
|
|
e1000_read_phy_reg(hw, IGP01E1000_PHY_AGC_B &
|
300 |
|
|
IGP01E1000_PHY_PAGE_SELECT, &phy_data);
|
301 |
|
|
regs_buff[14] = (uint32_t)phy_data; /* cable length */
|
302 |
|
|
e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT,
|
303 |
|
|
IGP01E1000_PHY_AGC_C);
|
304 |
|
|
e1000_read_phy_reg(hw, IGP01E1000_PHY_AGC_C &
|
305 |
|
|
IGP01E1000_PHY_PAGE_SELECT, &phy_data);
|
306 |
|
|
regs_buff[15] = (uint32_t)phy_data; /* cable length */
|
307 |
|
|
e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT,
|
308 |
|
|
IGP01E1000_PHY_AGC_D);
|
309 |
|
|
e1000_read_phy_reg(hw, IGP01E1000_PHY_AGC_D &
|
310 |
|
|
IGP01E1000_PHY_PAGE_SELECT, &phy_data);
|
311 |
|
|
regs_buff[16] = (uint32_t)phy_data; /* cable length */
|
312 |
|
|
regs_buff[17] = 0; /* extended 10bt distance (not needed) */
|
313 |
|
|
e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT, 0x0);
|
314 |
|
|
e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_STATUS &
|
315 |
|
|
IGP01E1000_PHY_PAGE_SELECT, &phy_data);
|
316 |
|
|
regs_buff[18] = (uint32_t)phy_data; /* cable polarity */
|
317 |
|
|
e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT,
|
318 |
|
|
IGP01E1000_PHY_PCS_INIT_REG);
|
319 |
|
|
e1000_read_phy_reg(hw, IGP01E1000_PHY_PCS_INIT_REG &
|
320 |
|
|
IGP01E1000_PHY_PAGE_SELECT, &phy_data);
|
321 |
|
|
regs_buff[19] = (uint32_t)phy_data; /* cable polarity */
|
322 |
|
|
regs_buff[20] = 0; /* polarity correction enabled (always) */
|
323 |
|
|
regs_buff[22] = 0; /* phy receive errors (unavailable) */
|
324 |
|
|
regs_buff[23] = regs_buff[18]; /* mdix mode */
|
325 |
|
|
e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT, 0x0);
|
326 |
|
|
} else {
|
327 |
|
|
e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
|
328 |
|
|
regs_buff[13] = (uint32_t)phy_data; /* cable length */
|
329 |
|
|
regs_buff[14] = 0; /* Dummy (to align w/ IGP phy reg dump) */
|
330 |
|
|
regs_buff[15] = 0; /* Dummy (to align w/ IGP phy reg dump) */
|
331 |
|
|
regs_buff[16] = 0; /* Dummy (to align w/ IGP phy reg dump) */
|
332 |
|
|
e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
|
333 |
|
|
regs_buff[17] = (uint32_t)phy_data; /* extended 10bt distance */
|
334 |
|
|
regs_buff[18] = regs_buff[13]; /* cable polarity */
|
335 |
|
|
regs_buff[19] = 0; /* Dummy (to align w/ IGP phy reg dump) */
|
336 |
|
|
regs_buff[20] = regs_buff[17]; /* polarity correction */
|
337 |
|
|
/* phy receive errors */
|
338 |
|
|
regs_buff[22] = adapter->phy_stats.receive_errors;
|
339 |
|
|
regs_buff[23] = regs_buff[13]; /* mdix mode */
|
340 |
|
|
}
|
341 |
|
|
regs_buff[21] = adapter->phy_stats.idle_errors; /* phy idle errors */
|
342 |
|
|
e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_data);
|
343 |
|
|
regs_buff[24] = (uint32_t)phy_data; /* phy local receiver status */
|
344 |
|
|
regs_buff[25] = regs_buff[24]; /* phy remote receiver status */
|
345 |
|
|
|
346 |
|
|
return;
|
347 |
|
|
}
|
348 |
|
|
|
349 |
|
|
static int
|
350 |
|
|
e1000_ethtool_geeprom(struct e1000_adapter *adapter,
|
351 |
|
|
struct ethtool_eeprom *eeprom, uint16_t *eeprom_buff)
|
352 |
|
|
{
|
353 |
|
|
struct e1000_hw *hw = &adapter->hw;
|
354 |
|
|
int first_word, last_word;
|
355 |
|
|
int ret_val = 0;
|
356 |
|
|
|
357 |
|
|
if(eeprom->len == 0) {
|
358 |
|
|
ret_val = -EINVAL;
|
359 |
|
|
goto geeprom_error;
|
360 |
|
|
}
|
361 |
|
|
|
362 |
|
|
eeprom->magic = hw->vendor_id | (hw->device_id << 16);
|
363 |
|
|
|
364 |
|
|
if(eeprom->offset > eeprom->offset + eeprom->len) {
|
365 |
|
|
ret_val = -EINVAL;
|
366 |
|
|
goto geeprom_error;
|
367 |
|
|
}
|
368 |
|
|
|
369 |
|
|
if((eeprom->offset + eeprom->len) > (hw->eeprom.word_size * 2))
|
370 |
|
|
eeprom->len = ((hw->eeprom.word_size * 2) - eeprom->offset);
|
371 |
|
|
|
372 |
|
|
first_word = eeprom->offset >> 1;
|
373 |
|
|
last_word = (eeprom->offset + eeprom->len - 1) >> 1;
|
374 |
|
|
|
375 |
|
|
if(hw->eeprom.type == e1000_eeprom_spi)
|
376 |
|
|
ret_val = e1000_read_eeprom(hw, first_word,
|
377 |
|
|
last_word - first_word + 1,
|
378 |
|
|
eeprom_buff);
|
379 |
|
|
else {
|
380 |
|
|
uint16_t i;
|
381 |
|
|
for (i = 0; i < last_word - first_word + 1; i++)
|
382 |
|
|
if((ret_val = e1000_read_eeprom(hw, first_word + i, 1,
|
383 |
|
|
&eeprom_buff[i])))
|
384 |
|
|
break;
|
385 |
|
|
}
|
386 |
|
|
geeprom_error:
|
387 |
|
|
return ret_val;
|
388 |
|
|
}
|
389 |
|
|
|
390 |
|
|
static int
|
391 |
|
|
e1000_ethtool_seeprom(struct e1000_adapter *adapter,
|
392 |
|
|
struct ethtool_eeprom *eeprom, void *user_data)
|
393 |
|
|
{
|
394 |
|
|
struct e1000_hw *hw = &adapter->hw;
|
395 |
|
|
uint16_t *eeprom_buff;
|
396 |
|
|
void *ptr;
|
397 |
|
|
int max_len, first_word, last_word, ret_val = 0;
|
398 |
|
|
|
399 |
|
|
if(eeprom->len == 0)
|
400 |
|
|
return -EOPNOTSUPP;
|
401 |
|
|
|
402 |
|
|
if(eeprom->magic != (hw->vendor_id | (hw->device_id << 16)))
|
403 |
|
|
return -EFAULT;
|
404 |
|
|
|
405 |
|
|
max_len = hw->eeprom.word_size * 2;
|
406 |
|
|
|
407 |
|
|
if((eeprom->offset + eeprom->len) > max_len)
|
408 |
|
|
eeprom->len = (max_len - eeprom->offset);
|
409 |
|
|
|
410 |
|
|
first_word = eeprom->offset >> 1;
|
411 |
|
|
last_word = (eeprom->offset + eeprom->len - 1) >> 1;
|
412 |
|
|
eeprom_buff = kmalloc(max_len, GFP_KERNEL);
|
413 |
|
|
if(!eeprom_buff)
|
414 |
|
|
return -ENOMEM;
|
415 |
|
|
|
416 |
|
|
ptr = (void *)eeprom_buff;
|
417 |
|
|
|
418 |
|
|
if(eeprom->offset & 1) {
|
419 |
|
|
/* need read/modify/write of first changed EEPROM word */
|
420 |
|
|
/* only the second byte of the word is being modified */
|
421 |
|
|
ret_val = e1000_read_eeprom(hw, first_word, 1,
|
422 |
|
|
&eeprom_buff[0]);
|
423 |
|
|
ptr++;
|
424 |
|
|
}
|
425 |
|
|
if(((eeprom->offset + eeprom->len) & 1) && (ret_val == 0)) {
|
426 |
|
|
/* need read/modify/write of last changed EEPROM word */
|
427 |
|
|
/* only the first byte of the word is being modified */
|
428 |
|
|
ret_val = e1000_read_eeprom(hw, last_word, 1,
|
429 |
|
|
&eeprom_buff[last_word - first_word]);
|
430 |
|
|
}
|
431 |
|
|
if((ret_val != 0) || copy_from_user(ptr, user_data, eeprom->len)) {
|
432 |
|
|
ret_val = -EFAULT;
|
433 |
|
|
goto seeprom_error;
|
434 |
|
|
}
|
435 |
|
|
|
436 |
|
|
ret_val = e1000_write_eeprom(hw, first_word,
|
437 |
|
|
last_word - first_word + 1, eeprom_buff);
|
438 |
|
|
|
439 |
|
|
/* Update the checksum over the first part of the EEPROM if needed */
|
440 |
|
|
if((ret_val == 0) && first_word <= EEPROM_CHECKSUM_REG)
|
441 |
|
|
e1000_update_eeprom_checksum(hw);
|
442 |
|
|
|
443 |
|
|
seeprom_error:
|
444 |
|
|
kfree(eeprom_buff);
|
445 |
|
|
return ret_val;
|
446 |
|
|
}
|
447 |
|
|
|
448 |
|
|
#define REG_PATTERN_TEST(R, M, W) \
|
449 |
|
|
{ \
|
450 |
|
|
uint32_t pat, value; \
|
451 |
|
|
uint32_t test[] = \
|
452 |
|
|
{0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF}; \
|
453 |
|
|
for(pat = 0; pat < sizeof(test)/sizeof(test[0]); pat++) { \
|
454 |
|
|
E1000_WRITE_REG(&adapter->hw, R, (test[pat] & W)); \
|
455 |
|
|
value = E1000_READ_REG(&adapter->hw, R); \
|
456 |
|
|
if(value != (test[pat] & W & M)) { \
|
457 |
|
|
*data = (adapter->hw.mac_type < e1000_82543) ? \
|
458 |
|
|
E1000_82542_##R : E1000_##R; \
|
459 |
|
|
return 1; \
|
460 |
|
|
} \
|
461 |
|
|
} \
|
462 |
|
|
}
|
463 |
|
|
|
464 |
|
|
#define REG_SET_AND_CHECK(R, M, W) \
|
465 |
|
|
{ \
|
466 |
|
|
uint32_t value; \
|
467 |
|
|
E1000_WRITE_REG(&adapter->hw, R, W & M); \
|
468 |
|
|
value = E1000_READ_REG(&adapter->hw, R); \
|
469 |
|
|
if ((W & M) != (value & M)) { \
|
470 |
|
|
*data = (adapter->hw.mac_type < e1000_82543) ? \
|
471 |
|
|
E1000_82542_##R : E1000_##R; \
|
472 |
|
|
return 1; \
|
473 |
|
|
} \
|
474 |
|
|
}
|
475 |
|
|
|
476 |
|
|
static int
|
477 |
|
|
e1000_reg_test(struct e1000_adapter *adapter, uint64_t *data)
|
478 |
|
|
{
|
479 |
|
|
uint32_t value;
|
480 |
|
|
uint32_t i;
|
481 |
|
|
|
482 |
|
|
/* The status register is Read Only, so a write should fail.
|
483 |
|
|
* Some bits that get toggled are ignored.
|
484 |
|
|
*/
|
485 |
|
|
value = (E1000_READ_REG(&adapter->hw, STATUS) & (0xFFFFF833));
|
486 |
|
|
E1000_WRITE_REG(&adapter->hw, STATUS, (0xFFFFFFFF));
|
487 |
|
|
if(value != (E1000_READ_REG(&adapter->hw, STATUS) & (0xFFFFF833))) {
|
488 |
|
|
*data = 1;
|
489 |
|
|
return 1;
|
490 |
|
|
}
|
491 |
|
|
|
492 |
|
|
REG_PATTERN_TEST(FCAL, 0xFFFFFFFF, 0xFFFFFFFF);
|
493 |
|
|
REG_PATTERN_TEST(FCAH, 0x0000FFFF, 0xFFFFFFFF);
|
494 |
|
|
REG_PATTERN_TEST(FCT, 0x0000FFFF, 0xFFFFFFFF);
|
495 |
|
|
REG_PATTERN_TEST(VET, 0x0000FFFF, 0xFFFFFFFF);
|
496 |
|
|
REG_PATTERN_TEST(RDTR, 0x0000FFFF, 0xFFFFFFFF);
|
497 |
|
|
REG_PATTERN_TEST(RDBAH, 0xFFFFFFFF, 0xFFFFFFFF);
|
498 |
|
|
REG_PATTERN_TEST(RDLEN, 0x000FFF80, 0x000FFFFF);
|
499 |
|
|
REG_PATTERN_TEST(RDH, 0x0000FFFF, 0x0000FFFF);
|
500 |
|
|
REG_PATTERN_TEST(RDT, 0x0000FFFF, 0x0000FFFF);
|
501 |
|
|
REG_PATTERN_TEST(FCRTH, 0x0000FFF8, 0x0000FFF8);
|
502 |
|
|
REG_PATTERN_TEST(FCTTV, 0x0000FFFF, 0x0000FFFF);
|
503 |
|
|
REG_PATTERN_TEST(TIPG, 0x3FFFFFFF, 0x3FFFFFFF);
|
504 |
|
|
REG_PATTERN_TEST(TDBAH, 0xFFFFFFFF, 0xFFFFFFFF);
|
505 |
|
|
REG_PATTERN_TEST(TDLEN, 0x000FFF80, 0x000FFFFF);
|
506 |
|
|
|
507 |
|
|
REG_SET_AND_CHECK(RCTL, 0xFFFFFFFF, 0x00000000);
|
508 |
|
|
REG_SET_AND_CHECK(RCTL, 0x06DFB3FE, 0x003FFFFB);
|
509 |
|
|
REG_SET_AND_CHECK(TCTL, 0xFFFFFFFF, 0x00000000);
|
510 |
|
|
|
511 |
|
|
if(adapter->hw.mac_type >= e1000_82543) {
|
512 |
|
|
|
513 |
|
|
REG_SET_AND_CHECK(RCTL, 0x06DFB3FE, 0xFFFFFFFF);
|
514 |
|
|
REG_PATTERN_TEST(RDBAL, 0xFFFFFFF0, 0xFFFFFFFF);
|
515 |
|
|
REG_PATTERN_TEST(TXCW, 0xC000FFFF, 0x0000FFFF);
|
516 |
|
|
REG_PATTERN_TEST(TDBAL, 0xFFFFFFF0, 0xFFFFFFFF);
|
517 |
|
|
REG_PATTERN_TEST(TIDV, 0x0000FFFF, 0x0000FFFF);
|
518 |
|
|
|
519 |
|
|
for(i = 0; i < E1000_RAR_ENTRIES; i++) {
|
520 |
|
|
REG_PATTERN_TEST(RA + ((i << 1) << 2), 0xFFFFFFFF,
|
521 |
|
|
0xFFFFFFFF);
|
522 |
|
|
REG_PATTERN_TEST(RA + (((i << 1) + 1) << 2), 0x8003FFFF,
|
523 |
|
|
0xFFFFFFFF);
|
524 |
|
|
}
|
525 |
|
|
|
526 |
|
|
} else {
|
527 |
|
|
|
528 |
|
|
REG_SET_AND_CHECK(RCTL, 0xFFFFFFFF, 0x01FFFFFF);
|
529 |
|
|
REG_PATTERN_TEST(RDBAL, 0xFFFFF000, 0xFFFFFFFF);
|
530 |
|
|
REG_PATTERN_TEST(TXCW, 0x0000FFFF, 0x0000FFFF);
|
531 |
|
|
REG_PATTERN_TEST(TDBAL, 0xFFFFF000, 0xFFFFFFFF);
|
532 |
|
|
|
533 |
|
|
}
|
534 |
|
|
|
535 |
|
|
for(i = 0; i < E1000_MC_TBL_SIZE; i++)
|
536 |
|
|
REG_PATTERN_TEST(MTA + (i << 2), 0xFFFFFFFF, 0xFFFFFFFF);
|
537 |
|
|
|
538 |
|
|
return 0;
|
539 |
|
|
}
|
540 |
|
|
|
541 |
|
|
static int
|
542 |
|
|
e1000_eeprom_test(struct e1000_adapter *adapter, uint64_t *data)
|
543 |
|
|
{
|
544 |
|
|
uint16_t temp;
|
545 |
|
|
uint16_t checksum = 0;
|
546 |
|
|
uint16_t i;
|
547 |
|
|
|
548 |
|
|
*data = 0;
|
549 |
|
|
/* Read and add up the contents of the EEPROM */
|
550 |
|
|
for(i = 0; i < (EEPROM_CHECKSUM_REG + 1); i++) {
|
551 |
|
|
if((e1000_read_eeprom(&adapter->hw, i, 1, &temp)) < 0) {
|
552 |
|
|
*data = 1;
|
553 |
|
|
break;
|
554 |
|
|
}
|
555 |
|
|
checksum += temp;
|
556 |
|
|
}
|
557 |
|
|
|
558 |
|
|
/* If Checksum is not Correct return error else test passed */
|
559 |
|
|
if((checksum != (uint16_t) EEPROM_SUM) && !(*data))
|
560 |
|
|
*data = 2;
|
561 |
|
|
|
562 |
|
|
return *data;
|
563 |
|
|
}
|
564 |
|
|
|
565 |
|
|
static irqreturn_t
|
566 |
|
|
e1000_test_intr(int irq,
|
567 |
|
|
void *data,
|
568 |
|
|
struct pt_regs *regs)
|
569 |
|
|
{
|
570 |
|
|
struct net_device *netdev = (struct net_device *) data;
|
571 |
|
|
struct e1000_adapter *adapter = netdev->priv;
|
572 |
|
|
|
573 |
|
|
adapter->test_icr |= E1000_READ_REG(&adapter->hw, ICR);
|
574 |
|
|
|
575 |
|
|
return IRQ_HANDLED;
|
576 |
|
|
}
|
577 |
|
|
|
578 |
|
|
static int
|
579 |
|
|
e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data)
|
580 |
|
|
{
|
581 |
|
|
struct net_device *netdev = adapter->netdev;
|
582 |
|
|
uint32_t icr, mask, i=0;
|
583 |
|
|
|
584 |
|
|
*data = 0;
|
585 |
|
|
|
586 |
|
|
/* Hook up test interrupt handler just for this test */
|
587 |
|
|
if(request_irq(adapter->pdev->irq, &e1000_test_intr, SA_SHIRQ,
|
588 |
|
|
netdev->name, netdev)) {
|
589 |
|
|
*data = 1;
|
590 |
|
|
return -1;
|
591 |
|
|
}
|
592 |
|
|
|
593 |
|
|
/* Disable all the interrupts */
|
594 |
|
|
E1000_WRITE_REG(&adapter->hw, IMC, 0xFFFFFFFF);
|
595 |
|
|
msec_delay(10);
|
596 |
|
|
|
597 |
|
|
/* Interrupts are disabled, so read interrupt cause
|
598 |
|
|
* register (icr) twice to verify that there are no interrupts
|
599 |
|
|
* pending. icr is clear on read.
|
600 |
|
|
*/
|
601 |
|
|
icr = E1000_READ_REG(&adapter->hw, ICR);
|
602 |
|
|
icr = E1000_READ_REG(&adapter->hw, ICR);
|
603 |
|
|
|
604 |
|
|
if(icr != 0) {
|
605 |
|
|
/* if icr is non-zero, there is no point
|
606 |
|
|
* running other interrupt tests.
|
607 |
|
|
*/
|
608 |
|
|
*data = 2;
|
609 |
|
|
i = 10;
|
610 |
|
|
}
|
611 |
|
|
|
612 |
|
|
/* Test each interrupt */
|
613 |
|
|
for(; i < 10; i++) {
|
614 |
|
|
|
615 |
|
|
/* Interrupt to test */
|
616 |
|
|
mask = 1 << i;
|
617 |
|
|
|
618 |
|
|
/* Disable the interrupt to be reported in
|
619 |
|
|
* the cause register and then force the same
|
620 |
|
|
* interrupt and see if one gets posted. If
|
621 |
|
|
* an interrupt was posted to the bus, the
|
622 |
|
|
* test failed.
|
623 |
|
|
*/
|
624 |
|
|
adapter->test_icr = 0;
|
625 |
|
|
E1000_WRITE_REG(&adapter->hw, IMC, mask);
|
626 |
|
|
E1000_WRITE_REG(&adapter->hw, ICS, mask);
|
627 |
|
|
msec_delay(10);
|
628 |
|
|
|
629 |
|
|
if(adapter->test_icr & mask) {
|
630 |
|
|
*data = 3;
|
631 |
|
|
break;
|
632 |
|
|
}
|
633 |
|
|
|
634 |
|
|
/* Enable the interrupt to be reported in
|
635 |
|
|
* the cause register and then force the same
|
636 |
|
|
* interrupt and see if one gets posted. If
|
637 |
|
|
* an interrupt was not posted to the bus, the
|
638 |
|
|
* test failed.
|
639 |
|
|
*/
|
640 |
|
|
adapter->test_icr = 0;
|
641 |
|
|
E1000_WRITE_REG(&adapter->hw, IMS, mask);
|
642 |
|
|
E1000_WRITE_REG(&adapter->hw, ICS, mask);
|
643 |
|
|
msec_delay(10);
|
644 |
|
|
|
645 |
|
|
if(!(adapter->test_icr & mask)) {
|
646 |
|
|
*data = 4;
|
647 |
|
|
break;
|
648 |
|
|
}
|
649 |
|
|
|
650 |
|
|
/* Disable the other interrupts to be reported in
|
651 |
|
|
* the cause register and then force the other
|
652 |
|
|
* interrupts and see if any get posted. If
|
653 |
|
|
* an interrupt was posted to the bus, the
|
654 |
|
|
* test failed.
|
655 |
|
|
*/
|
656 |
|
|
adapter->test_icr = 0;
|
657 |
|
|
E1000_WRITE_REG(&adapter->hw, IMC, ~mask);
|
658 |
|
|
E1000_WRITE_REG(&adapter->hw, ICS, ~mask);
|
659 |
|
|
msec_delay(10);
|
660 |
|
|
|
661 |
|
|
if(adapter->test_icr) {
|
662 |
|
|
*data = 5;
|
663 |
|
|
break;
|
664 |
|
|
}
|
665 |
|
|
}
|
666 |
|
|
|
667 |
|
|
/* Disable all the interrupts */
|
668 |
|
|
E1000_WRITE_REG(&adapter->hw, IMC, 0xFFFFFFFF);
|
669 |
|
|
msec_delay(10);
|
670 |
|
|
|
671 |
|
|
/* Unhook test interrupt handler */
|
672 |
|
|
free_irq(adapter->pdev->irq, netdev);
|
673 |
|
|
|
674 |
|
|
return *data;
|
675 |
|
|
}
|
676 |
|
|
|
677 |
|
|
static void
|
678 |
|
|
e1000_free_desc_rings(struct e1000_adapter *adapter)
|
679 |
|
|
{
|
680 |
|
|
struct e1000_desc_ring *txdr = &adapter->test_tx_ring;
|
681 |
|
|
struct e1000_desc_ring *rxdr = &adapter->test_rx_ring;
|
682 |
|
|
struct pci_dev *pdev = adapter->pdev;
|
683 |
|
|
int i;
|
684 |
|
|
|
685 |
|
|
if(txdr->desc && txdr->buffer_info) {
|
686 |
|
|
for(i = 0; i < txdr->count; i++) {
|
687 |
|
|
if(txdr->buffer_info[i].dma)
|
688 |
|
|
pci_unmap_single(pdev, txdr->buffer_info[i].dma,
|
689 |
|
|
txdr->buffer_info[i].length,
|
690 |
|
|
PCI_DMA_TODEVICE);
|
691 |
|
|
if(txdr->buffer_info[i].skb)
|
692 |
|
|
dev_kfree_skb(txdr->buffer_info[i].skb);
|
693 |
|
|
}
|
694 |
|
|
}
|
695 |
|
|
|
696 |
|
|
if(rxdr->desc && rxdr->buffer_info) {
|
697 |
|
|
for(i = 0; i < rxdr->count; i++) {
|
698 |
|
|
if(rxdr->buffer_info[i].dma)
|
699 |
|
|
pci_unmap_single(pdev, rxdr->buffer_info[i].dma,
|
700 |
|
|
rxdr->buffer_info[i].length,
|
701 |
|
|
PCI_DMA_FROMDEVICE);
|
702 |
|
|
if(rxdr->buffer_info[i].skb)
|
703 |
|
|
dev_kfree_skb(rxdr->buffer_info[i].skb);
|
704 |
|
|
}
|
705 |
|
|
}
|
706 |
|
|
|
707 |
|
|
if(txdr->desc)
|
708 |
|
|
pci_free_consistent(pdev, txdr->size, txdr->desc, txdr->dma);
|
709 |
|
|
if(rxdr->desc)
|
710 |
|
|
pci_free_consistent(pdev, rxdr->size, rxdr->desc, rxdr->dma);
|
711 |
|
|
|
712 |
|
|
if(txdr->buffer_info)
|
713 |
|
|
kfree(txdr->buffer_info);
|
714 |
|
|
if(rxdr->buffer_info)
|
715 |
|
|
kfree(rxdr->buffer_info);
|
716 |
|
|
|
717 |
|
|
return;
|
718 |
|
|
}
|
719 |
|
|
|
720 |
|
|
static int
|
721 |
|
|
e1000_setup_desc_rings(struct e1000_adapter *adapter)
|
722 |
|
|
{
|
723 |
|
|
struct e1000_desc_ring *txdr = &adapter->test_tx_ring;
|
724 |
|
|
struct e1000_desc_ring *rxdr = &adapter->test_rx_ring;
|
725 |
|
|
struct pci_dev *pdev = adapter->pdev;
|
726 |
|
|
uint32_t rctl;
|
727 |
|
|
int size, i, ret_val;
|
728 |
|
|
|
729 |
|
|
/* Setup Tx descriptor ring and Tx buffers */
|
730 |
|
|
|
731 |
|
|
txdr->count = 80;
|
732 |
|
|
|
733 |
|
|
size = txdr->count * sizeof(struct e1000_buffer);
|
734 |
|
|
if(!(txdr->buffer_info = kmalloc(size, GFP_KERNEL))) {
|
735 |
|
|
ret_val = 1;
|
736 |
|
|
goto err_nomem;
|
737 |
|
|
}
|
738 |
|
|
memset(txdr->buffer_info, 0, size);
|
739 |
|
|
|
740 |
|
|
txdr->size = txdr->count * sizeof(struct e1000_tx_desc);
|
741 |
|
|
E1000_ROUNDUP(txdr->size, 4096);
|
742 |
|
|
if(!(txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma))) {
|
743 |
|
|
ret_val = 2;
|
744 |
|
|
goto err_nomem;
|
745 |
|
|
}
|
746 |
|
|
memset(txdr->desc, 0, txdr->size);
|
747 |
|
|
txdr->next_to_use = txdr->next_to_clean = 0;
|
748 |
|
|
|
749 |
|
|
E1000_WRITE_REG(&adapter->hw, TDBAL,
|
750 |
|
|
((uint64_t) txdr->dma & 0x00000000FFFFFFFF));
|
751 |
|
|
E1000_WRITE_REG(&adapter->hw, TDBAH, ((uint64_t) txdr->dma >> 32));
|
752 |
|
|
E1000_WRITE_REG(&adapter->hw, TDLEN,
|
753 |
|
|
txdr->count * sizeof(struct e1000_tx_desc));
|
754 |
|
|
E1000_WRITE_REG(&adapter->hw, TDH, 0);
|
755 |
|
|
E1000_WRITE_REG(&adapter->hw, TDT, 0);
|
756 |
|
|
E1000_WRITE_REG(&adapter->hw, TCTL,
|
757 |
|
|
E1000_TCTL_PSP | E1000_TCTL_EN |
|
758 |
|
|
E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT |
|
759 |
|
|
E1000_FDX_COLLISION_DISTANCE << E1000_COLD_SHIFT);
|
760 |
|
|
|
761 |
|
|
for(i = 0; i < txdr->count; i++) {
|
762 |
|
|
struct e1000_tx_desc *tx_desc = E1000_TX_DESC(*txdr, i);
|
763 |
|
|
struct sk_buff *skb;
|
764 |
|
|
unsigned int size = 1024;
|
765 |
|
|
|
766 |
|
|
if(!(skb = alloc_skb(size, GFP_KERNEL))) {
|
767 |
|
|
ret_val = 3;
|
768 |
|
|
goto err_nomem;
|
769 |
|
|
}
|
770 |
|
|
skb_put(skb, size);
|
771 |
|
|
txdr->buffer_info[i].skb = skb;
|
772 |
|
|
txdr->buffer_info[i].length = skb->len;
|
773 |
|
|
txdr->buffer_info[i].dma =
|
774 |
|
|
pci_map_single(pdev, skb->data, skb->len,
|
775 |
|
|
PCI_DMA_TODEVICE);
|
776 |
|
|
tx_desc->buffer_addr = cpu_to_le64(txdr->buffer_info[i].dma);
|
777 |
|
|
tx_desc->lower.data = cpu_to_le32(skb->len);
|
778 |
|
|
tx_desc->lower.data |= cpu_to_le32(E1000_TXD_CMD_EOP |
|
779 |
|
|
E1000_TXD_CMD_IFCS |
|
780 |
|
|
E1000_TXD_CMD_RPS);
|
781 |
|
|
tx_desc->upper.data = 0;
|
782 |
|
|
}
|
783 |
|
|
|
784 |
|
|
/* Setup Rx descriptor ring and Rx buffers */
|
785 |
|
|
|
786 |
|
|
rxdr->count = 80;
|
787 |
|
|
|
788 |
|
|
size = rxdr->count * sizeof(struct e1000_buffer);
|
789 |
|
|
if(!(rxdr->buffer_info = kmalloc(size, GFP_KERNEL))) {
|
790 |
|
|
ret_val = 4;
|
791 |
|
|
goto err_nomem;
|
792 |
|
|
}
|
793 |
|
|
memset(rxdr->buffer_info, 0, size);
|
794 |
|
|
|
795 |
|
|
rxdr->size = rxdr->count * sizeof(struct e1000_rx_desc);
|
796 |
|
|
if(!(rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma))) {
|
797 |
|
|
ret_val = 5;
|
798 |
|
|
goto err_nomem;
|
799 |
|
|
}
|
800 |
|
|
memset(rxdr->desc, 0, rxdr->size);
|
801 |
|
|
rxdr->next_to_use = rxdr->next_to_clean = 0;
|
802 |
|
|
|
803 |
|
|
rctl = E1000_READ_REG(&adapter->hw, RCTL);
|
804 |
|
|
E1000_WRITE_REG(&adapter->hw, RCTL, rctl & ~E1000_RCTL_EN);
|
805 |
|
|
E1000_WRITE_REG(&adapter->hw, RDBAL,
|
806 |
|
|
((uint64_t) rxdr->dma & 0xFFFFFFFF));
|
807 |
|
|
E1000_WRITE_REG(&adapter->hw, RDBAH, ((uint64_t) rxdr->dma >> 32));
|
808 |
|
|
E1000_WRITE_REG(&adapter->hw, RDLEN, rxdr->size);
|
809 |
|
|
E1000_WRITE_REG(&adapter->hw, RDH, 0);
|
810 |
|
|
E1000_WRITE_REG(&adapter->hw, RDT, 0);
|
811 |
|
|
rctl = E1000_RCTL_EN | E1000_RCTL_BAM | E1000_RCTL_SZ_2048 |
|
812 |
|
|
E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF |
|
813 |
|
|
(adapter->hw.mc_filter_type << E1000_RCTL_MO_SHIFT);
|
814 |
|
|
E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
|
815 |
|
|
|
816 |
|
|
for(i = 0; i < rxdr->count; i++) {
|
817 |
|
|
struct e1000_rx_desc *rx_desc = E1000_RX_DESC(*rxdr, i);
|
818 |
|
|
struct sk_buff *skb;
|
819 |
|
|
|
820 |
|
|
if(!(skb = alloc_skb(E1000_RXBUFFER_2048 + 2, GFP_KERNEL))) {
|
821 |
|
|
ret_val = 6;
|
822 |
|
|
goto err_nomem;
|
823 |
|
|
}
|
824 |
|
|
skb_reserve(skb, 2);
|
825 |
|
|
rxdr->buffer_info[i].skb = skb;
|
826 |
|
|
rxdr->buffer_info[i].length = E1000_RXBUFFER_2048;
|
827 |
|
|
rxdr->buffer_info[i].dma =
|
828 |
|
|
pci_map_single(pdev, skb->data, E1000_RXBUFFER_2048,
|
829 |
|
|
PCI_DMA_FROMDEVICE);
|
830 |
|
|
rx_desc->buffer_addr = cpu_to_le64(rxdr->buffer_info[i].dma);
|
831 |
|
|
memset(skb->data, 0x00, skb->len);
|
832 |
|
|
}
|
833 |
|
|
|
834 |
|
|
return 0;
|
835 |
|
|
|
836 |
|
|
err_nomem:
|
837 |
|
|
e1000_free_desc_rings(adapter);
|
838 |
|
|
return ret_val;
|
839 |
|
|
}
|
840 |
|
|
|
841 |
|
|
static void
|
842 |
|
|
e1000_phy_disable_receiver(struct e1000_adapter *adapter)
|
843 |
|
|
{
|
844 |
|
|
/* Write out to PHY registers 29 and 30 to disable the Receiver. */
|
845 |
|
|
e1000_write_phy_reg(&adapter->hw, 29, 0x001F);
|
846 |
|
|
e1000_write_phy_reg(&adapter->hw, 30, 0x8FFC);
|
847 |
|
|
e1000_write_phy_reg(&adapter->hw, 29, 0x001A);
|
848 |
|
|
e1000_write_phy_reg(&adapter->hw, 30, 0x8FF0);
|
849 |
|
|
|
850 |
|
|
return;
|
851 |
|
|
}
|
852 |
|
|
|
853 |
|
|
static void
|
854 |
|
|
e1000_phy_reset_clk_and_crs(struct e1000_adapter *adapter)
|
855 |
|
|
{
|
856 |
|
|
uint16_t phy_reg;
|
857 |
|
|
|
858 |
|
|
/* Because we reset the PHY above, we need to re-force TX_CLK in the
|
859 |
|
|
* Extended PHY Specific Control Register to 25MHz clock. This
|
860 |
|
|
* value defaults back to a 2.5MHz clock when the PHY is reset.
|
861 |
|
|
*/
|
862 |
|
|
e1000_read_phy_reg(&adapter->hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_reg);
|
863 |
|
|
phy_reg |= M88E1000_EPSCR_TX_CLK_25;
|
864 |
|
|
e1000_write_phy_reg(&adapter->hw,
|
865 |
|
|
M88E1000_EXT_PHY_SPEC_CTRL, phy_reg);
|
866 |
|
|
|
867 |
|
|
/* In addition, because of the s/w reset above, we need to enable
|
868 |
|
|
* CRS on TX. This must be set for both full and half duplex
|
869 |
|
|
* operation.
|
870 |
|
|
*/
|
871 |
|
|
e1000_read_phy_reg(&adapter->hw, M88E1000_PHY_SPEC_CTRL, &phy_reg);
|
872 |
|
|
phy_reg |= M88E1000_PSCR_ASSERT_CRS_ON_TX;
|
873 |
|
|
e1000_write_phy_reg(&adapter->hw,
|
874 |
|
|
M88E1000_PHY_SPEC_CTRL, phy_reg);
|
875 |
|
|
}
|
876 |
|
|
|
877 |
|
|
static int
|
878 |
|
|
e1000_nonintegrated_phy_loopback(struct e1000_adapter *adapter)
|
879 |
|
|
{
|
880 |
|
|
uint32_t ctrl_reg;
|
881 |
|
|
uint16_t phy_reg;
|
882 |
|
|
|
883 |
|
|
/* Setup the Device Control Register for PHY loopback test. */
|
884 |
|
|
|
885 |
|
|
ctrl_reg = E1000_READ_REG(&adapter->hw, CTRL);
|
886 |
|
|
ctrl_reg |= (E1000_CTRL_ILOS | /* Invert Loss-Of-Signal */
|
887 |
|
|
E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */
|
888 |
|
|
E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */
|
889 |
|
|
E1000_CTRL_SPD_1000 | /* Force Speed to 1000 */
|
890 |
|
|
E1000_CTRL_FD); /* Force Duplex to FULL */
|
891 |
|
|
|
892 |
|
|
E1000_WRITE_REG(&adapter->hw, CTRL, ctrl_reg);
|
893 |
|
|
|
894 |
|
|
/* Read the PHY Specific Control Register (0x10) */
|
895 |
|
|
e1000_read_phy_reg(&adapter->hw, M88E1000_PHY_SPEC_CTRL, &phy_reg);
|
896 |
|
|
|
897 |
|
|
/* Clear Auto-Crossover bits in PHY Specific Control Register
|
898 |
|
|
* (bits 6:5).
|
899 |
|
|
*/
|
900 |
|
|
phy_reg &= ~M88E1000_PSCR_AUTO_X_MODE;
|
901 |
|
|
e1000_write_phy_reg(&adapter->hw, M88E1000_PHY_SPEC_CTRL, phy_reg);
|
902 |
|
|
|
903 |
|
|
/* Perform software reset on the PHY */
|
904 |
|
|
e1000_phy_reset(&adapter->hw);
|
905 |
|
|
|
906 |
|
|
/* Have to setup TX_CLK and TX_CRS after software reset */
|
907 |
|
|
e1000_phy_reset_clk_and_crs(adapter);
|
908 |
|
|
|
909 |
|
|
e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x8100);
|
910 |
|
|
|
911 |
|
|
/* Wait for reset to complete. */
|
912 |
|
|
udelay(500);
|
913 |
|
|
|
914 |
|
|
/* Have to setup TX_CLK and TX_CRS after software reset */
|
915 |
|
|
e1000_phy_reset_clk_and_crs(adapter);
|
916 |
|
|
|
917 |
|
|
/* Write out to PHY registers 29 and 30 to disable the Receiver. */
|
918 |
|
|
e1000_phy_disable_receiver(adapter);
|
919 |
|
|
|
920 |
|
|
/* Set the loopback bit in the PHY control register. */
|
921 |
|
|
e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_reg);
|
922 |
|
|
phy_reg |= MII_CR_LOOPBACK;
|
923 |
|
|
e1000_write_phy_reg(&adapter->hw, PHY_CTRL, phy_reg);
|
924 |
|
|
|
925 |
|
|
/* Setup TX_CLK and TX_CRS one more time. */
|
926 |
|
|
e1000_phy_reset_clk_and_crs(adapter);
|
927 |
|
|
|
928 |
|
|
/* Check Phy Configuration */
|
929 |
|
|
e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_reg);
|
930 |
|
|
if(phy_reg != 0x4100)
|
931 |
|
|
return 9;
|
932 |
|
|
|
933 |
|
|
e1000_read_phy_reg(&adapter->hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_reg);
|
934 |
|
|
if(phy_reg != 0x0070)
|
935 |
|
|
return 10;
|
936 |
|
|
|
937 |
|
|
e1000_read_phy_reg(&adapter->hw, 29, &phy_reg);
|
938 |
|
|
if(phy_reg != 0x001A)
|
939 |
|
|
return 11;
|
940 |
|
|
|
941 |
|
|
return 0;
|
942 |
|
|
}
|
943 |
|
|
|
944 |
|
|
static int
|
945 |
|
|
e1000_integrated_phy_loopback(struct e1000_adapter *adapter)
|
946 |
|
|
{
|
947 |
|
|
uint32_t ctrl_reg = 0;
|
948 |
|
|
uint32_t stat_reg = 0;
|
949 |
|
|
|
950 |
|
|
adapter->hw.autoneg = FALSE;
|
951 |
|
|
|
952 |
|
|
if(adapter->hw.phy_type == e1000_phy_m88) {
|
953 |
|
|
/* Auto-MDI/MDIX Off */
|
954 |
|
|
e1000_write_phy_reg(&adapter->hw,
|
955 |
|
|
M88E1000_PHY_SPEC_CTRL, 0x0808);
|
956 |
|
|
/* reset to update Auto-MDI/MDIX */
|
957 |
|
|
e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x9140);
|
958 |
|
|
/* autoneg off */
|
959 |
|
|
e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x8140);
|
960 |
|
|
}
|
961 |
|
|
/* force 1000, set loopback */
|
962 |
|
|
e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x4140);
|
963 |
|
|
|
964 |
|
|
/* Now set up the MAC to the same speed/duplex as the PHY. */
|
965 |
|
|
ctrl_reg = E1000_READ_REG(&adapter->hw, CTRL);
|
966 |
|
|
ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */
|
967 |
|
|
ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */
|
968 |
|
|
E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */
|
969 |
|
|
E1000_CTRL_SPD_1000 |/* Force Speed to 1000 */
|
970 |
|
|
E1000_CTRL_FD); /* Force Duplex to FULL */
|
971 |
|
|
|
972 |
|
|
if(adapter->hw.media_type == e1000_media_type_copper &&
|
973 |
|
|
adapter->hw.phy_type == e1000_phy_m88) {
|
974 |
|
|
ctrl_reg |= E1000_CTRL_ILOS; /* Invert Loss of Signal */
|
975 |
|
|
} else {
|
976 |
|
|
/* Set the ILOS bit on the fiber Nic is half
|
977 |
|
|
* duplex link is detected. */
|
978 |
|
|
stat_reg = E1000_READ_REG(&adapter->hw, STATUS);
|
979 |
|
|
if((stat_reg & E1000_STATUS_FD) == 0)
|
980 |
|
|
ctrl_reg |= (E1000_CTRL_ILOS | E1000_CTRL_SLU);
|
981 |
|
|
}
|
982 |
|
|
|
983 |
|
|
E1000_WRITE_REG(&adapter->hw, CTRL, ctrl_reg);
|
984 |
|
|
|
985 |
|
|
/* Disable the receiver on the PHY so when a cable is plugged in, the
|
986 |
|
|
* PHY does not begin to autoneg when a cable is reconnected to the NIC.
|
987 |
|
|
*/
|
988 |
|
|
if(adapter->hw.phy_type == e1000_phy_m88)
|
989 |
|
|
e1000_phy_disable_receiver(adapter);
|
990 |
|
|
|
991 |
|
|
udelay(500);
|
992 |
|
|
|
993 |
|
|
return 0;
|
994 |
|
|
}
|
995 |
|
|
|
996 |
|
|
static int
|
997 |
|
|
e1000_set_phy_loopback(struct e1000_adapter *adapter)
|
998 |
|
|
{
|
999 |
|
|
uint16_t phy_reg = 0;
|
1000 |
|
|
uint16_t count = 0;
|
1001 |
|
|
|
1002 |
|
|
switch (adapter->hw.mac_type) {
|
1003 |
|
|
case e1000_82543:
|
1004 |
|
|
if(adapter->hw.media_type == e1000_media_type_copper) {
|
1005 |
|
|
/* Attempt to setup Loopback mode on Non-integrated PHY.
|
1006 |
|
|
* Some PHY registers get corrupted at random, so
|
1007 |
|
|
* attempt this 10 times.
|
1008 |
|
|
*/
|
1009 |
|
|
while(e1000_nonintegrated_phy_loopback(adapter) &&
|
1010 |
|
|
count++ < 10);
|
1011 |
|
|
if(count < 11)
|
1012 |
|
|
return 0;
|
1013 |
|
|
}
|
1014 |
|
|
break;
|
1015 |
|
|
|
1016 |
|
|
case e1000_82544:
|
1017 |
|
|
case e1000_82540:
|
1018 |
|
|
case e1000_82545:
|
1019 |
|
|
case e1000_82545_rev_3:
|
1020 |
|
|
case e1000_82546:
|
1021 |
|
|
case e1000_82546_rev_3:
|
1022 |
|
|
case e1000_82541:
|
1023 |
|
|
case e1000_82541_rev_2:
|
1024 |
|
|
case e1000_82547:
|
1025 |
|
|
case e1000_82547_rev_2:
|
1026 |
|
|
return e1000_integrated_phy_loopback(adapter);
|
1027 |
|
|
break;
|
1028 |
|
|
|
1029 |
|
|
default:
|
1030 |
|
|
/* Default PHY loopback work is to read the MII
|
1031 |
|
|
* control register and assert bit 14 (loopback mode).
|
1032 |
|
|
*/
|
1033 |
|
|
e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_reg);
|
1034 |
|
|
phy_reg |= MII_CR_LOOPBACK;
|
1035 |
|
|
e1000_write_phy_reg(&adapter->hw, PHY_CTRL, phy_reg);
|
1036 |
|
|
return 0;
|
1037 |
|
|
break;
|
1038 |
|
|
}
|
1039 |
|
|
|
1040 |
|
|
return 8;
|
1041 |
|
|
}
|
1042 |
|
|
|
1043 |
|
|
static int
|
1044 |
|
|
e1000_setup_loopback_test(struct e1000_adapter *adapter)
|
1045 |
|
|
{
|
1046 |
|
|
uint32_t rctl;
|
1047 |
|
|
|
1048 |
|
|
if(adapter->hw.media_type == e1000_media_type_fiber ||
|
1049 |
|
|
adapter->hw.media_type == e1000_media_type_internal_serdes) {
|
1050 |
|
|
if(adapter->hw.mac_type == e1000_82545 ||
|
1051 |
|
|
adapter->hw.mac_type == e1000_82546 ||
|
1052 |
|
|
adapter->hw.mac_type == e1000_82545_rev_3 ||
|
1053 |
|
|
adapter->hw.mac_type == e1000_82546_rev_3)
|
1054 |
|
|
return e1000_set_phy_loopback(adapter);
|
1055 |
|
|
else {
|
1056 |
|
|
rctl = E1000_READ_REG(&adapter->hw, RCTL);
|
1057 |
|
|
rctl |= E1000_RCTL_LBM_TCVR;
|
1058 |
|
|
E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
|
1059 |
|
|
return 0;
|
1060 |
|
|
}
|
1061 |
|
|
} else if(adapter->hw.media_type == e1000_media_type_copper)
|
1062 |
|
|
return e1000_set_phy_loopback(adapter);
|
1063 |
|
|
|
1064 |
|
|
return 7;
|
1065 |
|
|
}
|
1066 |
|
|
|
1067 |
|
|
static void
|
1068 |
|
|
e1000_loopback_cleanup(struct e1000_adapter *adapter)
|
1069 |
|
|
{
|
1070 |
|
|
uint32_t rctl;
|
1071 |
|
|
uint16_t phy_reg;
|
1072 |
|
|
|
1073 |
|
|
rctl = E1000_READ_REG(&adapter->hw, RCTL);
|
1074 |
|
|
rctl &= ~(E1000_RCTL_LBM_TCVR | E1000_RCTL_LBM_MAC);
|
1075 |
|
|
E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
|
1076 |
|
|
|
1077 |
|
|
if(adapter->hw.media_type == e1000_media_type_copper ||
|
1078 |
|
|
((adapter->hw.media_type == e1000_media_type_fiber ||
|
1079 |
|
|
adapter->hw.media_type == e1000_media_type_internal_serdes) &&
|
1080 |
|
|
(adapter->hw.mac_type == e1000_82545 ||
|
1081 |
|
|
adapter->hw.mac_type == e1000_82546 ||
|
1082 |
|
|
adapter->hw.mac_type == e1000_82545_rev_3 ||
|
1083 |
|
|
adapter->hw.mac_type == e1000_82546_rev_3))) {
|
1084 |
|
|
adapter->hw.autoneg = TRUE;
|
1085 |
|
|
e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_reg);
|
1086 |
|
|
if(phy_reg & MII_CR_LOOPBACK) {
|
1087 |
|
|
phy_reg &= ~MII_CR_LOOPBACK;
|
1088 |
|
|
e1000_write_phy_reg(&adapter->hw, PHY_CTRL, phy_reg);
|
1089 |
|
|
e1000_phy_reset(&adapter->hw);
|
1090 |
|
|
}
|
1091 |
|
|
}
|
1092 |
|
|
}
|
1093 |
|
|
|
1094 |
|
|
static void
|
1095 |
|
|
e1000_create_lbtest_frame(struct sk_buff *skb, unsigned int frame_size)
|
1096 |
|
|
{
|
1097 |
|
|
memset(skb->data, 0xFF, frame_size);
|
1098 |
|
|
frame_size = (frame_size % 2) ? (frame_size - 1) : frame_size;
|
1099 |
|
|
memset(&skb->data[frame_size / 2], 0xAA, frame_size / 2 - 1);
|
1100 |
|
|
memset(&skb->data[frame_size / 2 + 10], 0xBE, 1);
|
1101 |
|
|
memset(&skb->data[frame_size / 2 + 12], 0xAF, 1);
|
1102 |
|
|
}
|
1103 |
|
|
|
1104 |
|
|
static int
|
1105 |
|
|
e1000_check_lbtest_frame(struct sk_buff *skb, unsigned int frame_size)
|
1106 |
|
|
{
|
1107 |
|
|
frame_size = (frame_size % 2) ? (frame_size - 1) : frame_size;
|
1108 |
|
|
if(*(skb->data + 3) == 0xFF) {
|
1109 |
|
|
if((*(skb->data + frame_size / 2 + 10) == 0xBE) &&
|
1110 |
|
|
(*(skb->data + frame_size / 2 + 12) == 0xAF)) {
|
1111 |
|
|
return 0;
|
1112 |
|
|
}
|
1113 |
|
|
}
|
1114 |
|
|
return 13;
|
1115 |
|
|
}
|
1116 |
|
|
|
1117 |
|
|
static int
|
1118 |
|
|
e1000_run_loopback_test(struct e1000_adapter *adapter)
|
1119 |
|
|
{
|
1120 |
|
|
struct e1000_desc_ring *txdr = &adapter->test_tx_ring;
|
1121 |
|
|
struct e1000_desc_ring *rxdr = &adapter->test_rx_ring;
|
1122 |
|
|
struct pci_dev *pdev = adapter->pdev;
|
1123 |
|
|
int i;
|
1124 |
|
|
|
1125 |
|
|
E1000_WRITE_REG(&adapter->hw, RDT, rxdr->count - 1);
|
1126 |
|
|
|
1127 |
|
|
for(i = 0; i < 64; i++) {
|
1128 |
|
|
e1000_create_lbtest_frame(txdr->buffer_info[i].skb, 1024);
|
1129 |
|
|
pci_dma_sync_single(pdev, txdr->buffer_info[i].dma,
|
1130 |
|
|
txdr->buffer_info[i].length,
|
1131 |
|
|
PCI_DMA_TODEVICE);
|
1132 |
|
|
}
|
1133 |
|
|
E1000_WRITE_REG(&adapter->hw, TDT, i);
|
1134 |
|
|
|
1135 |
|
|
msec_delay(200);
|
1136 |
|
|
|
1137 |
|
|
pci_dma_sync_single(pdev, rxdr->buffer_info[0].dma,
|
1138 |
|
|
rxdr->buffer_info[0].length, PCI_DMA_FROMDEVICE);
|
1139 |
|
|
|
1140 |
|
|
return e1000_check_lbtest_frame(rxdr->buffer_info[0].skb, 1024);
|
1141 |
|
|
}
|
1142 |
|
|
|
1143 |
|
|
static int
|
1144 |
|
|
e1000_loopback_test(struct e1000_adapter *adapter, uint64_t *data)
|
1145 |
|
|
{
|
1146 |
|
|
if((*data = e1000_setup_desc_rings(adapter))) goto err_loopback;
|
1147 |
|
|
if((*data = e1000_setup_loopback_test(adapter))) goto err_loopback;
|
1148 |
|
|
*data = e1000_run_loopback_test(adapter);
|
1149 |
|
|
e1000_loopback_cleanup(adapter);
|
1150 |
|
|
e1000_free_desc_rings(adapter);
|
1151 |
|
|
err_loopback:
|
1152 |
|
|
return *data;
|
1153 |
|
|
}
|
1154 |
|
|
|
1155 |
|
|
static int
|
1156 |
|
|
e1000_link_test(struct e1000_adapter *adapter, uint64_t *data)
|
1157 |
|
|
{
|
1158 |
|
|
*data = 0;
|
1159 |
|
|
e1000_check_for_link(&adapter->hw);
|
1160 |
|
|
|
1161 |
|
|
if(!(E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_LU)) {
|
1162 |
|
|
*data = 1;
|
1163 |
|
|
}
|
1164 |
|
|
return *data;
|
1165 |
|
|
}
|
1166 |
|
|
|
1167 |
|
|
static int
|
1168 |
|
|
e1000_ethtool_test(struct e1000_adapter *adapter,
|
1169 |
|
|
struct ethtool_test *eth_test, uint64_t *data)
|
1170 |
|
|
{
|
1171 |
|
|
boolean_t if_running = netif_running(adapter->netdev);
|
1172 |
|
|
|
1173 |
|
|
if(eth_test->flags == ETH_TEST_FL_OFFLINE) {
|
1174 |
|
|
/* Offline tests */
|
1175 |
|
|
|
1176 |
|
|
/* Link test performed before hardware reset so autoneg doesn't
|
1177 |
|
|
* interfere with test result */
|
1178 |
|
|
if(e1000_link_test(adapter, &data[4]))
|
1179 |
|
|
eth_test->flags |= ETH_TEST_FL_FAILED;
|
1180 |
|
|
|
1181 |
|
|
if(if_running)
|
1182 |
|
|
e1000_down(adapter);
|
1183 |
|
|
else
|
1184 |
|
|
e1000_reset(adapter);
|
1185 |
|
|
|
1186 |
|
|
if(e1000_reg_test(adapter, &data[0]))
|
1187 |
|
|
eth_test->flags |= ETH_TEST_FL_FAILED;
|
1188 |
|
|
|
1189 |
|
|
e1000_reset(adapter);
|
1190 |
|
|
if(e1000_eeprom_test(adapter, &data[1]))
|
1191 |
|
|
eth_test->flags |= ETH_TEST_FL_FAILED;
|
1192 |
|
|
|
1193 |
|
|
e1000_reset(adapter);
|
1194 |
|
|
if(e1000_intr_test(adapter, &data[2]))
|
1195 |
|
|
eth_test->flags |= ETH_TEST_FL_FAILED;
|
1196 |
|
|
|
1197 |
|
|
e1000_reset(adapter);
|
1198 |
|
|
if(e1000_loopback_test(adapter, &data[3]))
|
1199 |
|
|
eth_test->flags |= ETH_TEST_FL_FAILED;
|
1200 |
|
|
|
1201 |
|
|
e1000_reset(adapter);
|
1202 |
|
|
if(if_running)
|
1203 |
|
|
e1000_up(adapter);
|
1204 |
|
|
} else {
|
1205 |
|
|
/* Online tests */
|
1206 |
|
|
if(e1000_link_test(adapter, &data[4]))
|
1207 |
|
|
eth_test->flags |= ETH_TEST_FL_FAILED;
|
1208 |
|
|
|
1209 |
|
|
/* Offline tests aren't run; pass by default */
|
1210 |
|
|
data[0] = 0;
|
1211 |
|
|
data[1] = 0;
|
1212 |
|
|
data[2] = 0;
|
1213 |
|
|
data[3] = 0;
|
1214 |
|
|
}
|
1215 |
|
|
return 0;
|
1216 |
|
|
}
|
1217 |
|
|
|
1218 |
|
|
static void
|
1219 |
|
|
e1000_ethtool_gwol(struct e1000_adapter *adapter, struct ethtool_wolinfo *wol)
|
1220 |
|
|
{
|
1221 |
|
|
struct e1000_hw *hw = &adapter->hw;
|
1222 |
|
|
|
1223 |
|
|
switch(adapter->hw.device_id) {
|
1224 |
|
|
case E1000_DEV_ID_82542:
|
1225 |
|
|
case E1000_DEV_ID_82543GC_FIBER:
|
1226 |
|
|
case E1000_DEV_ID_82543GC_COPPER:
|
1227 |
|
|
case E1000_DEV_ID_82544EI_FIBER:
|
1228 |
|
|
wol->supported = 0;
|
1229 |
|
|
wol->wolopts = 0;
|
1230 |
|
|
return;
|
1231 |
|
|
|
1232 |
|
|
case E1000_DEV_ID_82546EB_FIBER:
|
1233 |
|
|
case E1000_DEV_ID_82546GB_FIBER:
|
1234 |
|
|
/* Wake events only supported on port A for dual fiber */
|
1235 |
|
|
if(E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1) {
|
1236 |
|
|
wol->supported = 0;
|
1237 |
|
|
wol->wolopts = 0;
|
1238 |
|
|
return;
|
1239 |
|
|
}
|
1240 |
|
|
/* Fall Through */
|
1241 |
|
|
|
1242 |
|
|
default:
|
1243 |
|
|
wol->supported = WAKE_UCAST | WAKE_MCAST |
|
1244 |
|
|
WAKE_BCAST | WAKE_MAGIC;
|
1245 |
|
|
|
1246 |
|
|
wol->wolopts = 0;
|
1247 |
|
|
if(adapter->wol & E1000_WUFC_EX)
|
1248 |
|
|
wol->wolopts |= WAKE_UCAST;
|
1249 |
|
|
if(adapter->wol & E1000_WUFC_MC)
|
1250 |
|
|
wol->wolopts |= WAKE_MCAST;
|
1251 |
|
|
if(adapter->wol & E1000_WUFC_BC)
|
1252 |
|
|
wol->wolopts |= WAKE_BCAST;
|
1253 |
|
|
if(adapter->wol & E1000_WUFC_MAG)
|
1254 |
|
|
wol->wolopts |= WAKE_MAGIC;
|
1255 |
|
|
return;
|
1256 |
|
|
}
|
1257 |
|
|
}
|
1258 |
|
|
|
1259 |
|
|
static int
|
1260 |
|
|
e1000_ethtool_swol(struct e1000_adapter *adapter, struct ethtool_wolinfo *wol)
|
1261 |
|
|
{
|
1262 |
|
|
struct e1000_hw *hw = &adapter->hw;
|
1263 |
|
|
|
1264 |
|
|
switch(adapter->hw.device_id) {
|
1265 |
|
|
case E1000_DEV_ID_82542:
|
1266 |
|
|
case E1000_DEV_ID_82543GC_FIBER:
|
1267 |
|
|
case E1000_DEV_ID_82543GC_COPPER:
|
1268 |
|
|
case E1000_DEV_ID_82544EI_FIBER:
|
1269 |
|
|
return wol->wolopts ? -EOPNOTSUPP : 0;
|
1270 |
|
|
|
1271 |
|
|
case E1000_DEV_ID_82546EB_FIBER:
|
1272 |
|
|
case E1000_DEV_ID_82546GB_FIBER:
|
1273 |
|
|
/* Wake events only supported on port A for dual fiber */
|
1274 |
|
|
if(E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1)
|
1275 |
|
|
return wol->wolopts ? -EOPNOTSUPP : 0;
|
1276 |
|
|
/* Fall Through */
|
1277 |
|
|
|
1278 |
|
|
default:
|
1279 |
|
|
if(wol->wolopts & (WAKE_PHY | WAKE_ARP | WAKE_MAGICSECURE))
|
1280 |
|
|
return -EOPNOTSUPP;
|
1281 |
|
|
|
1282 |
|
|
adapter->wol = 0;
|
1283 |
|
|
|
1284 |
|
|
if(wol->wolopts & WAKE_UCAST)
|
1285 |
|
|
adapter->wol |= E1000_WUFC_EX;
|
1286 |
|
|
if(wol->wolopts & WAKE_MCAST)
|
1287 |
|
|
adapter->wol |= E1000_WUFC_MC;
|
1288 |
|
|
if(wol->wolopts & WAKE_BCAST)
|
1289 |
|
|
adapter->wol |= E1000_WUFC_BC;
|
1290 |
|
|
if(wol->wolopts & WAKE_MAGIC)
|
1291 |
|
|
adapter->wol |= E1000_WUFC_MAG;
|
1292 |
|
|
}
|
1293 |
|
|
|
1294 |
|
|
return 0;
|
1295 |
|
|
}
|
1296 |
|
|
|
1297 |
|
|
|
1298 |
|
|
/* toggle LED 4 times per second = 2 "blinks" per second */
|
1299 |
|
|
#define E1000_ID_INTERVAL (HZ/4)
|
1300 |
|
|
|
1301 |
|
|
/* bit defines for adapter->led_status */
|
1302 |
|
|
#define E1000_LED_ON 0
|
1303 |
|
|
|
1304 |
|
|
static void
|
1305 |
|
|
e1000_led_blink_callback(unsigned long data)
|
1306 |
|
|
{
|
1307 |
|
|
struct e1000_adapter *adapter = (struct e1000_adapter *) data;
|
1308 |
|
|
|
1309 |
|
|
if(test_and_change_bit(E1000_LED_ON, &adapter->led_status))
|
1310 |
|
|
e1000_led_off(&adapter->hw);
|
1311 |
|
|
else
|
1312 |
|
|
e1000_led_on(&adapter->hw);
|
1313 |
|
|
|
1314 |
|
|
mod_timer(&adapter->blink_timer, jiffies + E1000_ID_INTERVAL);
|
1315 |
|
|
}
|
1316 |
|
|
|
1317 |
|
|
static int
|
1318 |
|
|
e1000_ethtool_led_blink(struct e1000_adapter *adapter, struct ethtool_value *id)
|
1319 |
|
|
{
|
1320 |
|
|
if(!adapter->blink_timer.function) {
|
1321 |
|
|
init_timer(&adapter->blink_timer);
|
1322 |
|
|
adapter->blink_timer.function = e1000_led_blink_callback;
|
1323 |
|
|
adapter->blink_timer.data = (unsigned long) adapter;
|
1324 |
|
|
}
|
1325 |
|
|
|
1326 |
|
|
e1000_setup_led(&adapter->hw);
|
1327 |
|
|
mod_timer(&adapter->blink_timer, jiffies);
|
1328 |
|
|
|
1329 |
|
|
set_current_state(TASK_INTERRUPTIBLE);
|
1330 |
|
|
if(id->data)
|
1331 |
|
|
schedule_timeout(id->data * HZ);
|
1332 |
|
|
else
|
1333 |
|
|
schedule_timeout(MAX_SCHEDULE_TIMEOUT);
|
1334 |
|
|
|
1335 |
|
|
del_timer_sync(&adapter->blink_timer);
|
1336 |
|
|
e1000_led_off(&adapter->hw);
|
1337 |
|
|
clear_bit(E1000_LED_ON, &adapter->led_status);
|
1338 |
|
|
e1000_cleanup_led(&adapter->hw);
|
1339 |
|
|
|
1340 |
|
|
return 0;
|
1341 |
|
|
}
|
1342 |
|
|
|
1343 |
|
|
int
|
1344 |
|
|
e1000_ethtool_ioctl(struct net_device *netdev, struct ifreq *ifr)
|
1345 |
|
|
{
|
1346 |
|
|
struct e1000_adapter *adapter = netdev->priv;
|
1347 |
|
|
void *addr = ifr->ifr_data;
|
1348 |
|
|
uint32_t cmd;
|
1349 |
|
|
|
1350 |
|
|
if(get_user(cmd, (uint32_t *) addr))
|
1351 |
|
|
return -EFAULT;
|
1352 |
|
|
|
1353 |
|
|
switch(cmd) {
|
1354 |
|
|
case ETHTOOL_GSET: {
|
1355 |
|
|
struct ethtool_cmd ecmd = {ETHTOOL_GSET};
|
1356 |
|
|
e1000_ethtool_gset(adapter, &ecmd);
|
1357 |
|
|
if(copy_to_user(addr, &ecmd, sizeof(ecmd)))
|
1358 |
|
|
return -EFAULT;
|
1359 |
|
|
return 0;
|
1360 |
|
|
}
|
1361 |
|
|
case ETHTOOL_SSET: {
|
1362 |
|
|
struct ethtool_cmd ecmd;
|
1363 |
|
|
if(copy_from_user(&ecmd, addr, sizeof(ecmd)))
|
1364 |
|
|
return -EFAULT;
|
1365 |
|
|
return e1000_ethtool_sset(adapter, &ecmd);
|
1366 |
|
|
}
|
1367 |
|
|
case ETHTOOL_GDRVINFO: {
|
1368 |
|
|
struct ethtool_drvinfo drvinfo = {ETHTOOL_GDRVINFO};
|
1369 |
|
|
e1000_ethtool_gdrvinfo(adapter, &drvinfo);
|
1370 |
|
|
if(copy_to_user(addr, &drvinfo, sizeof(drvinfo)))
|
1371 |
|
|
return -EFAULT;
|
1372 |
|
|
return 0;
|
1373 |
|
|
}
|
1374 |
|
|
case ETHTOOL_GSTRINGS: {
|
1375 |
|
|
struct ethtool_gstrings gstrings = { ETHTOOL_GSTRINGS };
|
1376 |
|
|
char *strings = NULL;
|
1377 |
|
|
int err = 0;
|
1378 |
|
|
|
1379 |
|
|
if(copy_from_user(&gstrings, addr, sizeof(gstrings)))
|
1380 |
|
|
return -EFAULT;
|
1381 |
|
|
switch(gstrings.string_set) {
|
1382 |
|
|
case ETH_SS_TEST:
|
1383 |
|
|
gstrings.len = E1000_TEST_LEN;
|
1384 |
|
|
strings = kmalloc(E1000_TEST_LEN * ETH_GSTRING_LEN,
|
1385 |
|
|
GFP_KERNEL);
|
1386 |
|
|
if(!strings)
|
1387 |
|
|
return -ENOMEM;
|
1388 |
|
|
memcpy(strings, e1000_gstrings_test, E1000_TEST_LEN *
|
1389 |
|
|
ETH_GSTRING_LEN);
|
1390 |
|
|
break;
|
1391 |
|
|
case ETH_SS_STATS: {
|
1392 |
|
|
int i;
|
1393 |
|
|
gstrings.len = E1000_STATS_LEN;
|
1394 |
|
|
strings = kmalloc(E1000_STATS_LEN * ETH_GSTRING_LEN,
|
1395 |
|
|
GFP_KERNEL);
|
1396 |
|
|
if(!strings)
|
1397 |
|
|
return -ENOMEM;
|
1398 |
|
|
for(i=0; i < E1000_STATS_LEN; i++) {
|
1399 |
|
|
memcpy(&strings[i * ETH_GSTRING_LEN],
|
1400 |
|
|
e1000_gstrings_stats[i].stat_string,
|
1401 |
|
|
ETH_GSTRING_LEN);
|
1402 |
|
|
}
|
1403 |
|
|
break;
|
1404 |
|
|
}
|
1405 |
|
|
default:
|
1406 |
|
|
return -EOPNOTSUPP;
|
1407 |
|
|
}
|
1408 |
|
|
if(copy_to_user(addr, &gstrings, sizeof(gstrings)))
|
1409 |
|
|
err = -EFAULT;
|
1410 |
|
|
addr += offsetof(struct ethtool_gstrings, data);
|
1411 |
|
|
if(!err && copy_to_user(addr, strings,
|
1412 |
|
|
gstrings.len * ETH_GSTRING_LEN))
|
1413 |
|
|
err = -EFAULT;
|
1414 |
|
|
|
1415 |
|
|
kfree(strings);
|
1416 |
|
|
return err;
|
1417 |
|
|
}
|
1418 |
|
|
case ETHTOOL_GREGS: {
|
1419 |
|
|
struct ethtool_regs regs = {ETHTOOL_GREGS};
|
1420 |
|
|
uint32_t regs_buff[E1000_REGS_LEN];
|
1421 |
|
|
|
1422 |
|
|
if(copy_from_user(®s, addr, sizeof(regs)))
|
1423 |
|
|
return -EFAULT;
|
1424 |
|
|
e1000_ethtool_gregs(adapter, ®s, regs_buff);
|
1425 |
|
|
if(copy_to_user(addr, ®s, sizeof(regs)))
|
1426 |
|
|
return -EFAULT;
|
1427 |
|
|
|
1428 |
|
|
addr += offsetof(struct ethtool_regs, data);
|
1429 |
|
|
if(copy_to_user(addr, regs_buff, regs.len))
|
1430 |
|
|
return -EFAULT;
|
1431 |
|
|
|
1432 |
|
|
return 0;
|
1433 |
|
|
}
|
1434 |
|
|
case ETHTOOL_NWAY_RST: {
|
1435 |
|
|
if(netif_running(netdev)) {
|
1436 |
|
|
e1000_down(adapter);
|
1437 |
|
|
e1000_up(adapter);
|
1438 |
|
|
}
|
1439 |
|
|
return 0;
|
1440 |
|
|
}
|
1441 |
|
|
case ETHTOOL_PHYS_ID: {
|
1442 |
|
|
struct ethtool_value id;
|
1443 |
|
|
if(copy_from_user(&id, addr, sizeof(id)))
|
1444 |
|
|
return -EFAULT;
|
1445 |
|
|
return e1000_ethtool_led_blink(adapter, &id);
|
1446 |
|
|
}
|
1447 |
|
|
case ETHTOOL_GLINK: {
|
1448 |
|
|
struct ethtool_value link = {ETHTOOL_GLINK};
|
1449 |
|
|
link.data = netif_carrier_ok(netdev);
|
1450 |
|
|
if(copy_to_user(addr, &link, sizeof(link)))
|
1451 |
|
|
return -EFAULT;
|
1452 |
|
|
return 0;
|
1453 |
|
|
}
|
1454 |
|
|
case ETHTOOL_GWOL: {
|
1455 |
|
|
struct ethtool_wolinfo wol = {ETHTOOL_GWOL};
|
1456 |
|
|
e1000_ethtool_gwol(adapter, &wol);
|
1457 |
|
|
if(copy_to_user(addr, &wol, sizeof(wol)) != 0)
|
1458 |
|
|
return -EFAULT;
|
1459 |
|
|
return 0;
|
1460 |
|
|
}
|
1461 |
|
|
case ETHTOOL_SWOL: {
|
1462 |
|
|
struct ethtool_wolinfo wol;
|
1463 |
|
|
if(copy_from_user(&wol, addr, sizeof(wol)) != 0)
|
1464 |
|
|
return -EFAULT;
|
1465 |
|
|
return e1000_ethtool_swol(adapter, &wol);
|
1466 |
|
|
}
|
1467 |
|
|
case ETHTOOL_GEEPROM: {
|
1468 |
|
|
struct ethtool_eeprom eeprom = {ETHTOOL_GEEPROM};
|
1469 |
|
|
struct e1000_hw *hw = &adapter->hw;
|
1470 |
|
|
uint16_t *eeprom_buff;
|
1471 |
|
|
void *ptr;
|
1472 |
|
|
int err = 0;
|
1473 |
|
|
|
1474 |
|
|
if(copy_from_user(&eeprom, addr, sizeof(eeprom)))
|
1475 |
|
|
return -EFAULT;
|
1476 |
|
|
|
1477 |
|
|
eeprom_buff = kmalloc(hw->eeprom.word_size * 2, GFP_KERNEL);
|
1478 |
|
|
|
1479 |
|
|
if(!eeprom_buff)
|
1480 |
|
|
return -ENOMEM;
|
1481 |
|
|
|
1482 |
|
|
if((err = e1000_ethtool_geeprom(adapter, &eeprom,
|
1483 |
|
|
eeprom_buff)))
|
1484 |
|
|
goto err_geeprom_ioctl;
|
1485 |
|
|
|
1486 |
|
|
if(copy_to_user(addr, &eeprom, sizeof(eeprom))) {
|
1487 |
|
|
err = -EFAULT;
|
1488 |
|
|
goto err_geeprom_ioctl;
|
1489 |
|
|
}
|
1490 |
|
|
|
1491 |
|
|
addr += offsetof(struct ethtool_eeprom, data);
|
1492 |
|
|
ptr = ((void *)eeprom_buff) + (eeprom.offset & 1);
|
1493 |
|
|
|
1494 |
|
|
if(copy_to_user(addr, ptr, eeprom.len))
|
1495 |
|
|
err = -EFAULT;
|
1496 |
|
|
|
1497 |
|
|
err_geeprom_ioctl:
|
1498 |
|
|
kfree(eeprom_buff);
|
1499 |
|
|
return err;
|
1500 |
|
|
}
|
1501 |
|
|
case ETHTOOL_SEEPROM: {
|
1502 |
|
|
struct ethtool_eeprom eeprom;
|
1503 |
|
|
|
1504 |
|
|
if(copy_from_user(&eeprom, addr, sizeof(eeprom)))
|
1505 |
|
|
return -EFAULT;
|
1506 |
|
|
|
1507 |
|
|
addr += offsetof(struct ethtool_eeprom, data);
|
1508 |
|
|
return e1000_ethtool_seeprom(adapter, &eeprom, addr);
|
1509 |
|
|
}
|
1510 |
|
|
case ETHTOOL_GPAUSEPARAM: {
|
1511 |
|
|
struct ethtool_pauseparam epause = {ETHTOOL_GPAUSEPARAM};
|
1512 |
|
|
e1000_ethtool_gpause(adapter, &epause);
|
1513 |
|
|
if(copy_to_user(addr, &epause, sizeof(epause)))
|
1514 |
|
|
return -EFAULT;
|
1515 |
|
|
return 0;
|
1516 |
|
|
}
|
1517 |
|
|
case ETHTOOL_SPAUSEPARAM: {
|
1518 |
|
|
struct ethtool_pauseparam epause;
|
1519 |
|
|
if(copy_from_user(&epause, addr, sizeof(epause)))
|
1520 |
|
|
return -EFAULT;
|
1521 |
|
|
return e1000_ethtool_spause(adapter, &epause);
|
1522 |
|
|
}
|
1523 |
|
|
case ETHTOOL_GSTATS: {
|
1524 |
|
|
struct {
|
1525 |
|
|
struct ethtool_stats eth_stats;
|
1526 |
|
|
uint64_t data[E1000_STATS_LEN];
|
1527 |
|
|
} stats = { {ETHTOOL_GSTATS, E1000_STATS_LEN} };
|
1528 |
|
|
int i;
|
1529 |
|
|
|
1530 |
|
|
e1000_update_stats(adapter);
|
1531 |
|
|
for(i = 0; i < E1000_STATS_LEN; i++)
|
1532 |
|
|
stats.data[i] = (e1000_gstrings_stats[i].sizeof_stat ==
|
1533 |
|
|
sizeof(uint64_t)) ?
|
1534 |
|
|
*(uint64_t *)((char *)adapter +
|
1535 |
|
|
e1000_gstrings_stats[i].stat_offset) :
|
1536 |
|
|
*(uint32_t *)((char *)adapter +
|
1537 |
|
|
e1000_gstrings_stats[i].stat_offset);
|
1538 |
|
|
if(copy_to_user(addr, &stats, sizeof(stats)))
|
1539 |
|
|
return -EFAULT;
|
1540 |
|
|
return 0;
|
1541 |
|
|
}
|
1542 |
|
|
case ETHTOOL_TEST: {
|
1543 |
|
|
struct {
|
1544 |
|
|
struct ethtool_test eth_test;
|
1545 |
|
|
uint64_t data[E1000_TEST_LEN];
|
1546 |
|
|
} test = { {ETHTOOL_TEST} };
|
1547 |
|
|
int err;
|
1548 |
|
|
|
1549 |
|
|
if(copy_from_user(&test.eth_test, addr, sizeof(test.eth_test)))
|
1550 |
|
|
return -EFAULT;
|
1551 |
|
|
|
1552 |
|
|
test.eth_test.len = E1000_TEST_LEN;
|
1553 |
|
|
|
1554 |
|
|
if((err = e1000_ethtool_test(adapter, &test.eth_test,
|
1555 |
|
|
test.data)))
|
1556 |
|
|
return err;
|
1557 |
|
|
|
1558 |
|
|
if(copy_to_user(addr, &test, sizeof(test)) != 0)
|
1559 |
|
|
return -EFAULT;
|
1560 |
|
|
return 0;
|
1561 |
|
|
}
|
1562 |
|
|
case ETHTOOL_GRXCSUM: {
|
1563 |
|
|
struct ethtool_value edata = { ETHTOOL_GRXCSUM };
|
1564 |
|
|
|
1565 |
|
|
edata.data = adapter->rx_csum;
|
1566 |
|
|
if (copy_to_user(addr, &edata, sizeof(edata)))
|
1567 |
|
|
return -EFAULT;
|
1568 |
|
|
return 0;
|
1569 |
|
|
}
|
1570 |
|
|
case ETHTOOL_SRXCSUM: {
|
1571 |
|
|
struct ethtool_value edata;
|
1572 |
|
|
|
1573 |
|
|
if (copy_from_user(&edata, addr, sizeof(edata)))
|
1574 |
|
|
return -EFAULT;
|
1575 |
|
|
adapter->rx_csum = edata.data;
|
1576 |
|
|
if(netif_running(netdev)) {
|
1577 |
|
|
e1000_down(adapter);
|
1578 |
|
|
e1000_up(adapter);
|
1579 |
|
|
} else
|
1580 |
|
|
e1000_reset(adapter);
|
1581 |
|
|
return 0;
|
1582 |
|
|
}
|
1583 |
|
|
case ETHTOOL_GTXCSUM: {
|
1584 |
|
|
struct ethtool_value edata = { ETHTOOL_GTXCSUM };
|
1585 |
|
|
|
1586 |
|
|
edata.data =
|
1587 |
|
|
(netdev->features & NETIF_F_HW_CSUM) != 0;
|
1588 |
|
|
if (copy_to_user(addr, &edata, sizeof(edata)))
|
1589 |
|
|
return -EFAULT;
|
1590 |
|
|
return 0;
|
1591 |
|
|
}
|
1592 |
|
|
case ETHTOOL_STXCSUM: {
|
1593 |
|
|
struct ethtool_value edata;
|
1594 |
|
|
|
1595 |
|
|
if (copy_from_user(&edata, addr, sizeof(edata)))
|
1596 |
|
|
return -EFAULT;
|
1597 |
|
|
|
1598 |
|
|
if(adapter->hw.mac_type < e1000_82543) {
|
1599 |
|
|
if (edata.data != 0)
|
1600 |
|
|
return -EINVAL;
|
1601 |
|
|
return 0;
|
1602 |
|
|
}
|
1603 |
|
|
|
1604 |
|
|
if (edata.data)
|
1605 |
|
|
netdev->features |= NETIF_F_HW_CSUM;
|
1606 |
|
|
else
|
1607 |
|
|
netdev->features &= ~NETIF_F_HW_CSUM;
|
1608 |
|
|
|
1609 |
|
|
return 0;
|
1610 |
|
|
}
|
1611 |
|
|
case ETHTOOL_GSG: {
|
1612 |
|
|
struct ethtool_value edata = { ETHTOOL_GSG };
|
1613 |
|
|
|
1614 |
|
|
edata.data =
|
1615 |
|
|
(netdev->features & NETIF_F_SG) != 0;
|
1616 |
|
|
if (copy_to_user(addr, &edata, sizeof(edata)))
|
1617 |
|
|
return -EFAULT;
|
1618 |
|
|
return 0;
|
1619 |
|
|
}
|
1620 |
|
|
case ETHTOOL_SSG: {
|
1621 |
|
|
struct ethtool_value edata;
|
1622 |
|
|
|
1623 |
|
|
if (copy_from_user(&edata, addr, sizeof(edata)))
|
1624 |
|
|
return -EFAULT;
|
1625 |
|
|
|
1626 |
|
|
if (edata.data)
|
1627 |
|
|
netdev->features |= NETIF_F_SG;
|
1628 |
|
|
else
|
1629 |
|
|
netdev->features &= ~NETIF_F_SG;
|
1630 |
|
|
|
1631 |
|
|
return 0;
|
1632 |
|
|
}
|
1633 |
|
|
#ifdef NETIF_F_TSO
|
1634 |
|
|
case ETHTOOL_GTSO: {
|
1635 |
|
|
struct ethtool_value edata = { ETHTOOL_GTSO };
|
1636 |
|
|
|
1637 |
|
|
edata.data = (netdev->features & NETIF_F_TSO) != 0;
|
1638 |
|
|
if (copy_to_user(addr, &edata, sizeof(edata)))
|
1639 |
|
|
return -EFAULT;
|
1640 |
|
|
return 0;
|
1641 |
|
|
}
|
1642 |
|
|
case ETHTOOL_STSO: {
|
1643 |
|
|
struct ethtool_value edata;
|
1644 |
|
|
|
1645 |
|
|
if (copy_from_user(&edata, addr, sizeof(edata)))
|
1646 |
|
|
return -EFAULT;
|
1647 |
|
|
|
1648 |
|
|
if ((adapter->hw.mac_type < e1000_82544) ||
|
1649 |
|
|
(adapter->hw.mac_type == e1000_82547)) {
|
1650 |
|
|
if (edata.data != 0)
|
1651 |
|
|
return -EINVAL;
|
1652 |
|
|
return 0;
|
1653 |
|
|
}
|
1654 |
|
|
|
1655 |
|
|
if (edata.data)
|
1656 |
|
|
netdev->features |= NETIF_F_TSO;
|
1657 |
|
|
else
|
1658 |
|
|
netdev->features &= ~NETIF_F_TSO;
|
1659 |
|
|
|
1660 |
|
|
return 0;
|
1661 |
|
|
}
|
1662 |
|
|
#endif
|
1663 |
|
|
default:
|
1664 |
|
|
return -EOPNOTSUPP;
|
1665 |
|
|
}
|
1666 |
|
|
}
|
1667 |
|
|
|
1668 |
|
|
|