1 /*******************************************************************************
3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007 Intel Corporation.
6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License,
8 version 2, as published by the Free Software Foundation.
10 This program is distributed in the hope it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26 *******************************************************************************/
28 /* ethtool support for igb */
30 #include <linux/vmalloc.h>
31 #include <linux/netdevice.h>
32 #include <linux/pci.h>
33 #include <linux/delay.h>
34 #include <linux/interrupt.h>
35 #include <linux/if_ether.h>
36 #include <linux/ethtool.h>
41 char stat_string
[ETH_GSTRING_LEN
];
46 <<<<<<< HEAD
:drivers
/net
/igb
/igb_ethtool
.c
47 #define IGB_STAT(m) sizeof(((struct igb_adapter *)0)->m), \
49 #define IGB_STAT(m) FIELD_SIZEOF(struct igb_adapter, m), \
50 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/net/igb/igb_ethtool.c
51 offsetof(struct igb_adapter
, m
)
52 static const struct igb_stats igb_gstrings_stats
[] = {
53 { "rx_packets", IGB_STAT(stats
.gprc
) },
54 { "tx_packets", IGB_STAT(stats
.gptc
) },
55 { "rx_bytes", IGB_STAT(stats
.gorc
) },
56 { "tx_bytes", IGB_STAT(stats
.gotc
) },
57 { "rx_broadcast", IGB_STAT(stats
.bprc
) },
58 { "tx_broadcast", IGB_STAT(stats
.bptc
) },
59 { "rx_multicast", IGB_STAT(stats
.mprc
) },
60 { "tx_multicast", IGB_STAT(stats
.mptc
) },
61 { "rx_errors", IGB_STAT(net_stats
.rx_errors
) },
62 { "tx_errors", IGB_STAT(net_stats
.tx_errors
) },
63 { "tx_dropped", IGB_STAT(net_stats
.tx_dropped
) },
64 { "multicast", IGB_STAT(stats
.mprc
) },
65 { "collisions", IGB_STAT(stats
.colc
) },
66 { "rx_length_errors", IGB_STAT(net_stats
.rx_length_errors
) },
67 { "rx_over_errors", IGB_STAT(net_stats
.rx_over_errors
) },
68 { "rx_crc_errors", IGB_STAT(stats
.crcerrs
) },
69 { "rx_frame_errors", IGB_STAT(net_stats
.rx_frame_errors
) },
70 { "rx_no_buffer_count", IGB_STAT(stats
.rnbc
) },
71 { "rx_missed_errors", IGB_STAT(stats
.mpc
) },
72 { "tx_aborted_errors", IGB_STAT(stats
.ecol
) },
73 { "tx_carrier_errors", IGB_STAT(stats
.tncrs
) },
74 { "tx_fifo_errors", IGB_STAT(net_stats
.tx_fifo_errors
) },
75 { "tx_heartbeat_errors", IGB_STAT(net_stats
.tx_heartbeat_errors
) },
76 { "tx_window_errors", IGB_STAT(stats
.latecol
) },
77 { "tx_abort_late_coll", IGB_STAT(stats
.latecol
) },
78 { "tx_deferred_ok", IGB_STAT(stats
.dc
) },
79 { "tx_single_coll_ok", IGB_STAT(stats
.scc
) },
80 { "tx_multi_coll_ok", IGB_STAT(stats
.mcc
) },
81 { "tx_timeout_count", IGB_STAT(tx_timeout_count
) },
82 { "tx_restart_queue", IGB_STAT(restart_queue
) },
83 { "rx_long_length_errors", IGB_STAT(stats
.roc
) },
84 { "rx_short_length_errors", IGB_STAT(stats
.ruc
) },
85 { "rx_align_errors", IGB_STAT(stats
.algnerrc
) },
86 { "tx_tcp_seg_good", IGB_STAT(stats
.tsctc
) },
87 { "tx_tcp_seg_failed", IGB_STAT(stats
.tsctfc
) },
88 { "rx_flow_control_xon", IGB_STAT(stats
.xonrxc
) },
89 { "rx_flow_control_xoff", IGB_STAT(stats
.xoffrxc
) },
90 { "tx_flow_control_xon", IGB_STAT(stats
.xontxc
) },
91 { "tx_flow_control_xoff", IGB_STAT(stats
.xofftxc
) },
92 { "rx_long_byte_count", IGB_STAT(stats
.gorc
) },
93 { "rx_csum_offload_good", IGB_STAT(hw_csum_good
) },
94 { "rx_csum_offload_errors", IGB_STAT(hw_csum_err
) },
95 { "rx_header_split", IGB_STAT(rx_hdr_split
) },
96 { "alloc_rx_buff_failed", IGB_STAT(alloc_rx_buff_failed
) },
97 { "tx_smbus", IGB_STAT(stats
.mgptc
) },
98 { "rx_smbus", IGB_STAT(stats
.mgprc
) },
99 { "dropped_smbus", IGB_STAT(stats
.mgpdc
) },
102 #define IGB_QUEUE_STATS_LEN \
103 ((((((struct igb_adapter *)netdev->priv)->num_rx_queues > 1) ? \
104 ((struct igb_adapter *)netdev->priv)->num_rx_queues : 0) + \
105 (((((struct igb_adapter *)netdev->priv)->num_tx_queues > 1) ? \
106 ((struct igb_adapter *)netdev->priv)->num_tx_queues : 0))) * \
107 (sizeof(struct igb_queue_stats) / sizeof(u64)))
108 #define IGB_GLOBAL_STATS_LEN \
109 sizeof(igb_gstrings_stats) / sizeof(struct igb_stats)
110 #define IGB_STATS_LEN (IGB_GLOBAL_STATS_LEN + IGB_QUEUE_STATS_LEN)
111 static const char igb_gstrings_test
[][ETH_GSTRING_LEN
] = {
112 "Register test (offline)", "Eeprom test (offline)",
113 "Interrupt test (offline)", "Loopback test (offline)",
114 "Link test (on/offline)"
116 #define IGB_TEST_LEN sizeof(igb_gstrings_test) / ETH_GSTRING_LEN
118 static int igb_get_settings(struct net_device
*netdev
, struct ethtool_cmd
*ecmd
)
120 struct igb_adapter
*adapter
= netdev_priv(netdev
);
121 struct e1000_hw
*hw
= &adapter
->hw
;
123 if (hw
->phy
.media_type
== e1000_media_type_copper
) {
125 ecmd
->supported
= (SUPPORTED_10baseT_Half
|
126 SUPPORTED_10baseT_Full
|
127 SUPPORTED_100baseT_Half
|
128 SUPPORTED_100baseT_Full
|
129 SUPPORTED_1000baseT_Full
|
132 ecmd
->advertising
= ADVERTISED_TP
;
134 if (hw
->mac
.autoneg
== 1) {
135 ecmd
->advertising
|= ADVERTISED_Autoneg
;
136 /* the e1000 autoneg seems to match ethtool nicely */
137 ecmd
->advertising
|= hw
->phy
.autoneg_advertised
;
140 ecmd
->port
= PORT_TP
;
141 ecmd
->phy_address
= hw
->phy
.addr
;
143 ecmd
->supported
= (SUPPORTED_1000baseT_Full
|
147 ecmd
->advertising
= (ADVERTISED_1000baseT_Full
|
151 ecmd
->port
= PORT_FIBRE
;
154 ecmd
->transceiver
= XCVR_INTERNAL
;
156 if (rd32(E1000_STATUS
) & E1000_STATUS_LU
) {
158 adapter
->hw
.mac
.ops
.get_speed_and_duplex(hw
,
159 &adapter
->link_speed
,
160 &adapter
->link_duplex
);
161 ecmd
->speed
= adapter
->link_speed
;
163 /* unfortunately FULL_DUPLEX != DUPLEX_FULL
164 * and HALF_DUPLEX != DUPLEX_HALF */
166 if (adapter
->link_duplex
== FULL_DUPLEX
)
167 ecmd
->duplex
= DUPLEX_FULL
;
169 ecmd
->duplex
= DUPLEX_HALF
;
175 ecmd
->autoneg
= ((hw
->phy
.media_type
== e1000_media_type_fiber
) ||
176 hw
->mac
.autoneg
) ? AUTONEG_ENABLE
: AUTONEG_DISABLE
;
180 static int igb_set_settings(struct net_device
*netdev
, struct ethtool_cmd
*ecmd
)
182 struct igb_adapter
*adapter
= netdev_priv(netdev
);
183 struct e1000_hw
*hw
= &adapter
->hw
;
185 /* When SoL/IDER sessions are active, autoneg/speed/duplex
186 * cannot be changed */
187 if (igb_check_reset_block(hw
)) {
188 dev_err(&adapter
->pdev
->dev
, "Cannot change link "
189 "characteristics when SoL/IDER is active.\n");
193 while (test_and_set_bit(__IGB_RESETTING
, &adapter
->state
))
196 if (ecmd
->autoneg
== AUTONEG_ENABLE
) {
198 if (hw
->phy
.media_type
== e1000_media_type_fiber
)
199 hw
->phy
.autoneg_advertised
= ADVERTISED_1000baseT_Full
|
203 hw
->phy
.autoneg_advertised
= ecmd
->advertising
|
206 ecmd
->advertising
= hw
->phy
.autoneg_advertised
;
208 if (igb_set_spd_dplx(adapter
, ecmd
->speed
+ ecmd
->duplex
)) {
209 clear_bit(__IGB_RESETTING
, &adapter
->state
);
215 if (netif_running(adapter
->netdev
)) {
221 clear_bit(__IGB_RESETTING
, &adapter
->state
);
225 static void igb_get_pauseparam(struct net_device
*netdev
,
226 struct ethtool_pauseparam
*pause
)
228 struct igb_adapter
*adapter
= netdev_priv(netdev
);
229 struct e1000_hw
*hw
= &adapter
->hw
;
232 (adapter
->fc_autoneg
? AUTONEG_ENABLE
: AUTONEG_DISABLE
);
234 if (hw
->fc
.type
== e1000_fc_rx_pause
)
236 else if (hw
->fc
.type
== e1000_fc_tx_pause
)
238 else if (hw
->fc
.type
== e1000_fc_full
) {
244 static int igb_set_pauseparam(struct net_device
*netdev
,
245 struct ethtool_pauseparam
*pause
)
247 struct igb_adapter
*adapter
= netdev_priv(netdev
);
248 struct e1000_hw
*hw
= &adapter
->hw
;
251 adapter
->fc_autoneg
= pause
->autoneg
;
253 while (test_and_set_bit(__IGB_RESETTING
, &adapter
->state
))
256 if (pause
->rx_pause
&& pause
->tx_pause
)
257 hw
->fc
.type
= e1000_fc_full
;
258 else if (pause
->rx_pause
&& !pause
->tx_pause
)
259 hw
->fc
.type
= e1000_fc_rx_pause
;
260 else if (!pause
->rx_pause
&& pause
->tx_pause
)
261 hw
->fc
.type
= e1000_fc_tx_pause
;
262 else if (!pause
->rx_pause
&& !pause
->tx_pause
)
263 hw
->fc
.type
= e1000_fc_none
;
265 hw
->fc
.original_type
= hw
->fc
.type
;
267 if (adapter
->fc_autoneg
== AUTONEG_ENABLE
) {
268 if (netif_running(adapter
->netdev
)) {
274 retval
= ((hw
->phy
.media_type
== e1000_media_type_fiber
) ?
275 igb_setup_link(hw
) : igb_force_mac_fc(hw
));
277 clear_bit(__IGB_RESETTING
, &adapter
->state
);
281 static u32
igb_get_rx_csum(struct net_device
*netdev
)
283 struct igb_adapter
*adapter
= netdev_priv(netdev
);
284 return adapter
->rx_csum
;
287 static int igb_set_rx_csum(struct net_device
*netdev
, u32 data
)
289 struct igb_adapter
*adapter
= netdev_priv(netdev
);
290 adapter
->rx_csum
= data
;
295 static u32
igb_get_tx_csum(struct net_device
*netdev
)
297 return (netdev
->features
& NETIF_F_HW_CSUM
) != 0;
300 static int igb_set_tx_csum(struct net_device
*netdev
, u32 data
)
303 netdev
->features
|= NETIF_F_HW_CSUM
;
305 netdev
->features
&= ~NETIF_F_HW_CSUM
;
310 static int igb_set_tso(struct net_device
*netdev
, u32 data
)
312 struct igb_adapter
*adapter
= netdev_priv(netdev
);
315 netdev
->features
|= NETIF_F_TSO
;
317 netdev
->features
&= ~NETIF_F_TSO
;
320 netdev
->features
|= NETIF_F_TSO6
;
322 netdev
->features
&= ~NETIF_F_TSO6
;
324 dev_info(&adapter
->pdev
->dev
, "TSO is %s\n",
325 data
? "Enabled" : "Disabled");
329 static u32
igb_get_msglevel(struct net_device
*netdev
)
331 struct igb_adapter
*adapter
= netdev_priv(netdev
);
332 return adapter
->msg_enable
;
335 static void igb_set_msglevel(struct net_device
*netdev
, u32 data
)
337 struct igb_adapter
*adapter
= netdev_priv(netdev
);
338 adapter
->msg_enable
= data
;
341 static int igb_get_regs_len(struct net_device
*netdev
)
343 #define IGB_REGS_LEN 551
344 return IGB_REGS_LEN
* sizeof(u32
);
347 static void igb_get_regs(struct net_device
*netdev
,
348 struct ethtool_regs
*regs
, void *p
)
350 struct igb_adapter
*adapter
= netdev_priv(netdev
);
351 struct e1000_hw
*hw
= &adapter
->hw
;
355 memset(p
, 0, IGB_REGS_LEN
* sizeof(u32
));
357 regs
->version
= (1 << 24) | (hw
->revision_id
<< 16) | hw
->device_id
;
359 /* General Registers */
360 regs_buff
[0] = rd32(E1000_CTRL
);
361 regs_buff
[1] = rd32(E1000_STATUS
);
362 regs_buff
[2] = rd32(E1000_CTRL_EXT
);
363 regs_buff
[3] = rd32(E1000_MDIC
);
364 regs_buff
[4] = rd32(E1000_SCTL
);
365 regs_buff
[5] = rd32(E1000_CONNSW
);
366 regs_buff
[6] = rd32(E1000_VET
);
367 regs_buff
[7] = rd32(E1000_LEDCTL
);
368 regs_buff
[8] = rd32(E1000_PBA
);
369 regs_buff
[9] = rd32(E1000_PBS
);
370 regs_buff
[10] = rd32(E1000_FRTIMER
);
371 regs_buff
[11] = rd32(E1000_TCPTIMER
);
374 regs_buff
[12] = rd32(E1000_EECD
);
377 regs_buff
[13] = rd32(E1000_EICR
);
378 regs_buff
[14] = rd32(E1000_EICS
);
379 regs_buff
[15] = rd32(E1000_EIMS
);
380 regs_buff
[16] = rd32(E1000_EIMC
);
381 regs_buff
[17] = rd32(E1000_EIAC
);
382 regs_buff
[18] = rd32(E1000_EIAM
);
383 regs_buff
[19] = rd32(E1000_ICR
);
384 regs_buff
[20] = rd32(E1000_ICS
);
385 regs_buff
[21] = rd32(E1000_IMS
);
386 regs_buff
[22] = rd32(E1000_IMC
);
387 regs_buff
[23] = rd32(E1000_IAC
);
388 regs_buff
[24] = rd32(E1000_IAM
);
389 regs_buff
[25] = rd32(E1000_IMIRVP
);
392 regs_buff
[26] = rd32(E1000_FCAL
);
393 regs_buff
[27] = rd32(E1000_FCAH
);
394 regs_buff
[28] = rd32(E1000_FCTTV
);
395 regs_buff
[29] = rd32(E1000_FCRTL
);
396 regs_buff
[30] = rd32(E1000_FCRTH
);
397 regs_buff
[31] = rd32(E1000_FCRTV
);
400 regs_buff
[32] = rd32(E1000_RCTL
);
401 regs_buff
[33] = rd32(E1000_RXCSUM
);
402 regs_buff
[34] = rd32(E1000_RLPML
);
403 regs_buff
[35] = rd32(E1000_RFCTL
);
404 regs_buff
[36] = rd32(E1000_MRQC
);
405 regs_buff
[37] = rd32(E1000_VMD_CTL
);
408 regs_buff
[38] = rd32(E1000_TCTL
);
409 regs_buff
[39] = rd32(E1000_TCTL_EXT
);
410 regs_buff
[40] = rd32(E1000_TIPG
);
411 regs_buff
[41] = rd32(E1000_DTXCTL
);
414 regs_buff
[42] = rd32(E1000_WUC
);
415 regs_buff
[43] = rd32(E1000_WUFC
);
416 regs_buff
[44] = rd32(E1000_WUS
);
417 regs_buff
[45] = rd32(E1000_IPAV
);
418 regs_buff
[46] = rd32(E1000_WUPL
);
421 regs_buff
[47] = rd32(E1000_PCS_CFG0
);
422 regs_buff
[48] = rd32(E1000_PCS_LCTL
);
423 regs_buff
[49] = rd32(E1000_PCS_LSTAT
);
424 regs_buff
[50] = rd32(E1000_PCS_ANADV
);
425 regs_buff
[51] = rd32(E1000_PCS_LPAB
);
426 regs_buff
[52] = rd32(E1000_PCS_NPTX
);
427 regs_buff
[53] = rd32(E1000_PCS_LPABNP
);
430 regs_buff
[54] = adapter
->stats
.crcerrs
;
431 regs_buff
[55] = adapter
->stats
.algnerrc
;
432 regs_buff
[56] = adapter
->stats
.symerrs
;
433 regs_buff
[57] = adapter
->stats
.rxerrc
;
434 regs_buff
[58] = adapter
->stats
.mpc
;
435 regs_buff
[59] = adapter
->stats
.scc
;
436 regs_buff
[60] = adapter
->stats
.ecol
;
437 regs_buff
[61] = adapter
->stats
.mcc
;
438 regs_buff
[62] = adapter
->stats
.latecol
;
439 regs_buff
[63] = adapter
->stats
.colc
;
440 regs_buff
[64] = adapter
->stats
.dc
;
441 regs_buff
[65] = adapter
->stats
.tncrs
;
442 regs_buff
[66] = adapter
->stats
.sec
;
443 regs_buff
[67] = adapter
->stats
.htdpmc
;
444 regs_buff
[68] = adapter
->stats
.rlec
;
445 regs_buff
[69] = adapter
->stats
.xonrxc
;
446 regs_buff
[70] = adapter
->stats
.xontxc
;
447 regs_buff
[71] = adapter
->stats
.xoffrxc
;
448 regs_buff
[72] = adapter
->stats
.xofftxc
;
449 regs_buff
[73] = adapter
->stats
.fcruc
;
450 regs_buff
[74] = adapter
->stats
.prc64
;
451 regs_buff
[75] = adapter
->stats
.prc127
;
452 regs_buff
[76] = adapter
->stats
.prc255
;
453 regs_buff
[77] = adapter
->stats
.prc511
;
454 regs_buff
[78] = adapter
->stats
.prc1023
;
455 regs_buff
[79] = adapter
->stats
.prc1522
;
456 regs_buff
[80] = adapter
->stats
.gprc
;
457 regs_buff
[81] = adapter
->stats
.bprc
;
458 regs_buff
[82] = adapter
->stats
.mprc
;
459 regs_buff
[83] = adapter
->stats
.gptc
;
460 regs_buff
[84] = adapter
->stats
.gorc
;
461 regs_buff
[86] = adapter
->stats
.gotc
;
462 regs_buff
[88] = adapter
->stats
.rnbc
;
463 regs_buff
[89] = adapter
->stats
.ruc
;
464 regs_buff
[90] = adapter
->stats
.rfc
;
465 regs_buff
[91] = adapter
->stats
.roc
;
466 regs_buff
[92] = adapter
->stats
.rjc
;
467 regs_buff
[93] = adapter
->stats
.mgprc
;
468 regs_buff
[94] = adapter
->stats
.mgpdc
;
469 regs_buff
[95] = adapter
->stats
.mgptc
;
470 regs_buff
[96] = adapter
->stats
.tor
;
471 regs_buff
[98] = adapter
->stats
.tot
;
472 regs_buff
[100] = adapter
->stats
.tpr
;
473 regs_buff
[101] = adapter
->stats
.tpt
;
474 regs_buff
[102] = adapter
->stats
.ptc64
;
475 regs_buff
[103] = adapter
->stats
.ptc127
;
476 regs_buff
[104] = adapter
->stats
.ptc255
;
477 regs_buff
[105] = adapter
->stats
.ptc511
;
478 regs_buff
[106] = adapter
->stats
.ptc1023
;
479 regs_buff
[107] = adapter
->stats
.ptc1522
;
480 regs_buff
[108] = adapter
->stats
.mptc
;
481 regs_buff
[109] = adapter
->stats
.bptc
;
482 regs_buff
[110] = adapter
->stats
.tsctc
;
483 regs_buff
[111] = adapter
->stats
.iac
;
484 regs_buff
[112] = adapter
->stats
.rpthc
;
485 regs_buff
[113] = adapter
->stats
.hgptc
;
486 regs_buff
[114] = adapter
->stats
.hgorc
;
487 regs_buff
[116] = adapter
->stats
.hgotc
;
488 regs_buff
[118] = adapter
->stats
.lenerrs
;
489 regs_buff
[119] = adapter
->stats
.scvpc
;
490 regs_buff
[120] = adapter
->stats
.hrmpc
;
492 /* These should probably be added to e1000_regs.h instead */
493 #define E1000_PSRTYPE_REG(_i) (0x05480 + ((_i) * 4))
494 #define E1000_RAL(_i) (0x05400 + ((_i) * 8))
495 #define E1000_RAH(_i) (0x05404 + ((_i) * 8))
496 #define E1000_IP4AT_REG(_i) (0x05840 + ((_i) * 8))
497 #define E1000_IP6AT_REG(_i) (0x05880 + ((_i) * 4))
498 #define E1000_WUPM_REG(_i) (0x05A00 + ((_i) * 4))
499 #define E1000_FFMT_REG(_i) (0x09000 + ((_i) * 8))
500 #define E1000_FFVT_REG(_i) (0x09800 + ((_i) * 8))
501 #define E1000_FFLT_REG(_i) (0x05F00 + ((_i) * 8))
503 for (i
= 0; i
< 4; i
++)
504 regs_buff
[121 + i
] = rd32(E1000_SRRCTL(i
));
505 for (i
= 0; i
< 4; i
++)
506 regs_buff
[125 + i
] = rd32(E1000_PSRTYPE_REG(i
));
507 for (i
= 0; i
< 4; i
++)
508 regs_buff
[129 + i
] = rd32(E1000_RDBAL(i
));
509 for (i
= 0; i
< 4; i
++)
510 regs_buff
[133 + i
] = rd32(E1000_RDBAH(i
));
511 for (i
= 0; i
< 4; i
++)
512 regs_buff
[137 + i
] = rd32(E1000_RDLEN(i
));
513 for (i
= 0; i
< 4; i
++)
514 regs_buff
[141 + i
] = rd32(E1000_RDH(i
));
515 for (i
= 0; i
< 4; i
++)
516 regs_buff
[145 + i
] = rd32(E1000_RDT(i
));
517 for (i
= 0; i
< 4; i
++)
518 regs_buff
[149 + i
] = rd32(E1000_RXDCTL(i
));
520 for (i
= 0; i
< 10; i
++)
521 regs_buff
[153 + i
] = rd32(E1000_EITR(i
));
522 for (i
= 0; i
< 8; i
++)
523 regs_buff
[163 + i
] = rd32(E1000_IMIR(i
));
524 for (i
= 0; i
< 8; i
++)
525 regs_buff
[171 + i
] = rd32(E1000_IMIREXT(i
));
526 for (i
= 0; i
< 16; i
++)
527 regs_buff
[179 + i
] = rd32(E1000_RAL(i
));
528 for (i
= 0; i
< 16; i
++)
529 regs_buff
[195 + i
] = rd32(E1000_RAH(i
));
531 for (i
= 0; i
< 4; i
++)
532 regs_buff
[211 + i
] = rd32(E1000_TDBAL(i
));
533 for (i
= 0; i
< 4; i
++)
534 regs_buff
[215 + i
] = rd32(E1000_TDBAH(i
));
535 for (i
= 0; i
< 4; i
++)
536 regs_buff
[219 + i
] = rd32(E1000_TDLEN(i
));
537 for (i
= 0; i
< 4; i
++)
538 regs_buff
[223 + i
] = rd32(E1000_TDH(i
));
539 for (i
= 0; i
< 4; i
++)
540 regs_buff
[227 + i
] = rd32(E1000_TDT(i
));
541 for (i
= 0; i
< 4; i
++)
542 regs_buff
[231 + i
] = rd32(E1000_TXDCTL(i
));
543 for (i
= 0; i
< 4; i
++)
544 regs_buff
[235 + i
] = rd32(E1000_TDWBAL(i
));
545 for (i
= 0; i
< 4; i
++)
546 regs_buff
[239 + i
] = rd32(E1000_TDWBAH(i
));
547 for (i
= 0; i
< 4; i
++)
548 regs_buff
[243 + i
] = rd32(E1000_DCA_TXCTRL(i
));
550 for (i
= 0; i
< 4; i
++)
551 regs_buff
[247 + i
] = rd32(E1000_IP4AT_REG(i
));
552 for (i
= 0; i
< 4; i
++)
553 regs_buff
[251 + i
] = rd32(E1000_IP6AT_REG(i
));
554 for (i
= 0; i
< 32; i
++)
555 regs_buff
[255 + i
] = rd32(E1000_WUPM_REG(i
));
556 for (i
= 0; i
< 128; i
++)
557 regs_buff
[287 + i
] = rd32(E1000_FFMT_REG(i
));
558 for (i
= 0; i
< 128; i
++)
559 regs_buff
[415 + i
] = rd32(E1000_FFVT_REG(i
));
560 for (i
= 0; i
< 4; i
++)
561 regs_buff
[543 + i
] = rd32(E1000_FFLT_REG(i
));
563 regs_buff
[547] = rd32(E1000_TDFH
);
564 regs_buff
[548] = rd32(E1000_TDFT
);
565 regs_buff
[549] = rd32(E1000_TDFHS
);
566 regs_buff
[550] = rd32(E1000_TDFPC
);
570 static int igb_get_eeprom_len(struct net_device
*netdev
)
572 struct igb_adapter
*adapter
= netdev_priv(netdev
);
573 return adapter
->hw
.nvm
.word_size
* 2;
576 static int igb_get_eeprom(struct net_device
*netdev
,
577 struct ethtool_eeprom
*eeprom
, u8
*bytes
)
579 struct igb_adapter
*adapter
= netdev_priv(netdev
);
580 struct e1000_hw
*hw
= &adapter
->hw
;
582 int first_word
, last_word
;
586 if (eeprom
->len
== 0)
589 eeprom
->magic
= hw
->vendor_id
| (hw
->device_id
<< 16);
591 first_word
= eeprom
->offset
>> 1;
592 last_word
= (eeprom
->offset
+ eeprom
->len
- 1) >> 1;
594 eeprom_buff
= kmalloc(sizeof(u16
) *
595 (last_word
- first_word
+ 1), GFP_KERNEL
);
599 if (hw
->nvm
.type
== e1000_nvm_eeprom_spi
)
600 ret_val
= hw
->nvm
.ops
.read_nvm(hw
, first_word
,
601 last_word
- first_word
+ 1,
604 for (i
= 0; i
< last_word
- first_word
+ 1; i
++) {
605 ret_val
= hw
->nvm
.ops
.read_nvm(hw
, first_word
+ i
, 1,
612 /* Device's eeprom is always little-endian, word addressable */
613 for (i
= 0; i
< last_word
- first_word
+ 1; i
++)
614 le16_to_cpus(&eeprom_buff
[i
]);
616 memcpy(bytes
, (u8
*)eeprom_buff
+ (eeprom
->offset
& 1),
623 static int igb_set_eeprom(struct net_device
*netdev
,
624 struct ethtool_eeprom
*eeprom
, u8
*bytes
)
626 struct igb_adapter
*adapter
= netdev_priv(netdev
);
627 struct e1000_hw
*hw
= &adapter
->hw
;
630 int max_len
, first_word
, last_word
, ret_val
= 0;
633 if (eeprom
->len
== 0)
636 if (eeprom
->magic
!= (hw
->vendor_id
| (hw
->device_id
<< 16)))
639 max_len
= hw
->nvm
.word_size
* 2;
641 first_word
= eeprom
->offset
>> 1;
642 last_word
= (eeprom
->offset
+ eeprom
->len
- 1) >> 1;
643 eeprom_buff
= kmalloc(max_len
, GFP_KERNEL
);
647 ptr
= (void *)eeprom_buff
;
649 if (eeprom
->offset
& 1) {
650 /* need read/modify/write of first changed EEPROM word */
651 /* only the second byte of the word is being modified */
652 ret_val
= hw
->nvm
.ops
.read_nvm(hw
, first_word
, 1,
656 if (((eeprom
->offset
+ eeprom
->len
) & 1) && (ret_val
== 0)) {
657 /* need read/modify/write of last changed EEPROM word */
658 /* only the first byte of the word is being modified */
659 ret_val
= hw
->nvm
.ops
.read_nvm(hw
, last_word
, 1,
660 &eeprom_buff
[last_word
- first_word
]);
663 /* Device's eeprom is always little-endian, word addressable */
664 for (i
= 0; i
< last_word
- first_word
+ 1; i
++)
665 le16_to_cpus(&eeprom_buff
[i
]);
667 memcpy(ptr
, bytes
, eeprom
->len
);
669 for (i
= 0; i
< last_word
- first_word
+ 1; i
++)
670 eeprom_buff
[i
] = cpu_to_le16(eeprom_buff
[i
]);
672 ret_val
= hw
->nvm
.ops
.write_nvm(hw
, first_word
,
673 last_word
- first_word
+ 1, eeprom_buff
);
675 /* Update the checksum over the first part of the EEPROM if needed
676 * and flush shadow RAM for 82573 controllers */
677 if ((ret_val
== 0) && ((first_word
<= NVM_CHECKSUM_REG
)))
678 igb_update_nvm_checksum(hw
);
684 static void igb_get_drvinfo(struct net_device
*netdev
,
685 struct ethtool_drvinfo
*drvinfo
)
687 struct igb_adapter
*adapter
= netdev_priv(netdev
);
688 char firmware_version
[32];
691 strncpy(drvinfo
->driver
, igb_driver_name
, 32);
692 strncpy(drvinfo
->version
, igb_driver_version
, 32);
694 /* EEPROM image version # is reported as firmware version # for
695 * 82575 controllers */
696 adapter
->hw
.nvm
.ops
.read_nvm(&adapter
->hw
, 5, 1, &eeprom_data
);
697 sprintf(firmware_version
, "%d.%d-%d",
698 (eeprom_data
& 0xF000) >> 12,
699 (eeprom_data
& 0x0FF0) >> 4,
700 eeprom_data
& 0x000F);
702 strncpy(drvinfo
->fw_version
, firmware_version
, 32);
703 strncpy(drvinfo
->bus_info
, pci_name(adapter
->pdev
), 32);
704 drvinfo
->n_stats
= IGB_STATS_LEN
;
705 drvinfo
->testinfo_len
= IGB_TEST_LEN
;
706 drvinfo
->regdump_len
= igb_get_regs_len(netdev
);
707 drvinfo
->eedump_len
= igb_get_eeprom_len(netdev
);
710 static void igb_get_ringparam(struct net_device
*netdev
,
711 struct ethtool_ringparam
*ring
)
713 struct igb_adapter
*adapter
= netdev_priv(netdev
);
714 struct igb_ring
*tx_ring
= adapter
->tx_ring
;
715 struct igb_ring
*rx_ring
= adapter
->rx_ring
;
717 ring
->rx_max_pending
= IGB_MAX_RXD
;
718 ring
->tx_max_pending
= IGB_MAX_TXD
;
719 ring
->rx_mini_max_pending
= 0;
720 ring
->rx_jumbo_max_pending
= 0;
721 ring
->rx_pending
= rx_ring
->count
;
722 ring
->tx_pending
= tx_ring
->count
;
723 ring
->rx_mini_pending
= 0;
724 ring
->rx_jumbo_pending
= 0;
727 static int igb_set_ringparam(struct net_device
*netdev
,
728 struct ethtool_ringparam
*ring
)
730 struct igb_adapter
*adapter
= netdev_priv(netdev
);
731 struct igb_buffer
*old_buf
;
732 struct igb_buffer
*old_rx_buf
;
735 u32 new_rx_count
, new_tx_count
, old_size
;
738 if ((ring
->rx_mini_pending
) || (ring
->rx_jumbo_pending
))
741 new_rx_count
= max(ring
->rx_pending
, (u32
)IGB_MIN_RXD
);
742 new_rx_count
= min(new_rx_count
, (u32
)IGB_MAX_RXD
);
743 new_rx_count
= ALIGN(new_rx_count
, REQ_RX_DESCRIPTOR_MULTIPLE
);
745 new_tx_count
= max(ring
->tx_pending
, (u32
)IGB_MIN_TXD
);
746 new_tx_count
= min(new_tx_count
, (u32
)IGB_MAX_TXD
);
747 new_tx_count
= ALIGN(new_tx_count
, REQ_TX_DESCRIPTOR_MULTIPLE
);
749 if ((new_tx_count
== adapter
->tx_ring
->count
) &&
750 (new_rx_count
== adapter
->rx_ring
->count
)) {
755 while (test_and_set_bit(__IGB_RESETTING
, &adapter
->state
))
758 if (netif_running(adapter
->netdev
))
762 * We can't just free everything and then setup again,
763 * because the ISRs in MSI-X mode get passed pointers
764 * to the tx and rx ring structs.
766 if (new_tx_count
!= adapter
->tx_ring
->count
) {
767 for (i
= 0; i
< adapter
->num_tx_queues
; i
++) {
768 /* Save existing descriptor ring */
769 old_buf
= adapter
->tx_ring
[i
].buffer_info
;
770 old_desc
= adapter
->tx_ring
[i
].desc
;
771 old_size
= adapter
->tx_ring
[i
].size
;
772 old_dma
= adapter
->tx_ring
[i
].dma
;
773 /* Try to allocate a new one */
774 adapter
->tx_ring
[i
].buffer_info
= NULL
;
775 adapter
->tx_ring
[i
].desc
= NULL
;
776 adapter
->tx_ring
[i
].count
= new_tx_count
;
777 err
= igb_setup_tx_resources(adapter
,
778 &adapter
->tx_ring
[i
]);
780 /* Restore the old one so at least
781 the adapter still works, even if
782 we failed the request */
783 adapter
->tx_ring
[i
].buffer_info
= old_buf
;
784 adapter
->tx_ring
[i
].desc
= old_desc
;
785 adapter
->tx_ring
[i
].size
= old_size
;
786 adapter
->tx_ring
[i
].dma
= old_dma
;
789 /* Free the old buffer manually */
791 pci_free_consistent(adapter
->pdev
, old_size
,
796 if (new_rx_count
!= adapter
->rx_ring
->count
) {
797 for (i
= 0; i
< adapter
->num_rx_queues
; i
++) {
799 old_rx_buf
= adapter
->rx_ring
[i
].buffer_info
;
800 old_desc
= adapter
->rx_ring
[i
].desc
;
801 old_size
= adapter
->rx_ring
[i
].size
;
802 old_dma
= adapter
->rx_ring
[i
].dma
;
804 adapter
->rx_ring
[i
].buffer_info
= NULL
;
805 adapter
->rx_ring
[i
].desc
= NULL
;
806 adapter
->rx_ring
[i
].dma
= 0;
807 adapter
->rx_ring
[i
].count
= new_rx_count
;
808 err
= igb_setup_rx_resources(adapter
,
809 &adapter
->rx_ring
[i
]);
811 adapter
->rx_ring
[i
].buffer_info
= old_rx_buf
;
812 adapter
->rx_ring
[i
].desc
= old_desc
;
813 adapter
->rx_ring
[i
].size
= old_size
;
814 adapter
->rx_ring
[i
].dma
= old_dma
;
819 pci_free_consistent(adapter
->pdev
, old_size
, old_desc
,
826 if (netif_running(adapter
->netdev
))
829 clear_bit(__IGB_RESETTING
, &adapter
->state
);
833 /* ethtool register test data */
834 struct igb_reg_test
{
842 /* In the hardware, registers are laid out either singly, in arrays
843 * spaced 0x100 bytes apart, or in contiguous tables. We assume
844 * most tests take place on arrays or single registers (handled
845 * as a single-element array) and special-case the tables.
846 * Table tests are always pattern tests.
848 * We also make provision for some required setup steps by specifying
849 * registers to be written without any read-back testing.
852 #define PATTERN_TEST 1
853 #define SET_READ_TEST 2
854 #define WRITE_NO_TEST 3
855 #define TABLE32_TEST 4
856 #define TABLE64_TEST_LO 5
857 #define TABLE64_TEST_HI 6
859 /* default register test */
860 static struct igb_reg_test reg_test_82575
[] = {
861 { E1000_FCAL
, 1, PATTERN_TEST
, 0xFFFFFFFF, 0xFFFFFFFF },
862 { E1000_FCAH
, 1, PATTERN_TEST
, 0x0000FFFF, 0xFFFFFFFF },
863 { E1000_FCT
, 1, PATTERN_TEST
, 0x0000FFFF, 0xFFFFFFFF },
864 { E1000_VET
, 1, PATTERN_TEST
, 0xFFFFFFFF, 0xFFFFFFFF },
865 { E1000_RDBAL(0), 4, PATTERN_TEST
, 0xFFFFFF80, 0xFFFFFFFF },
866 { E1000_RDBAH(0), 4, PATTERN_TEST
, 0xFFFFFFFF, 0xFFFFFFFF },
867 { E1000_RDLEN(0), 4, PATTERN_TEST
, 0x000FFF80, 0x000FFFFF },
868 /* Enable all four RX queues before testing. */
869 { E1000_RXDCTL(0), 4, WRITE_NO_TEST
, 0, E1000_RXDCTL_QUEUE_ENABLE
},
870 /* RDH is read-only for 82575, only test RDT. */
871 { E1000_RDT(0), 4, PATTERN_TEST
, 0x0000FFFF, 0x0000FFFF },
872 { E1000_RXDCTL(0), 4, WRITE_NO_TEST
, 0, 0 },
873 { E1000_FCRTH
, 1, PATTERN_TEST
, 0x0000FFF0, 0x0000FFF0 },
874 { E1000_FCTTV
, 1, PATTERN_TEST
, 0x0000FFFF, 0x0000FFFF },
875 { E1000_TIPG
, 1, PATTERN_TEST
, 0x3FFFFFFF, 0x3FFFFFFF },
876 { E1000_TDBAL(0), 4, PATTERN_TEST
, 0xFFFFFF80, 0xFFFFFFFF },
877 { E1000_TDBAH(0), 4, PATTERN_TEST
, 0xFFFFFFFF, 0xFFFFFFFF },
878 { E1000_TDLEN(0), 4, PATTERN_TEST
, 0x000FFF80, 0x000FFFFF },
879 { E1000_RCTL
, 1, SET_READ_TEST
, 0xFFFFFFFF, 0x00000000 },
880 { E1000_RCTL
, 1, SET_READ_TEST
, 0x04CFB3FE, 0x003FFFFB },
881 { E1000_RCTL
, 1, SET_READ_TEST
, 0x04CFB3FE, 0xFFFFFFFF },
882 { E1000_TCTL
, 1, SET_READ_TEST
, 0xFFFFFFFF, 0x00000000 },
883 { E1000_TXCW
, 1, PATTERN_TEST
, 0xC000FFFF, 0x0000FFFF },
884 { E1000_RA
, 16, TABLE64_TEST_LO
, 0xFFFFFFFF, 0xFFFFFFFF },
885 { E1000_RA
, 16, TABLE64_TEST_HI
, 0x800FFFFF, 0xFFFFFFFF },
886 { E1000_MTA
, 128, TABLE32_TEST
, 0xFFFFFFFF, 0xFFFFFFFF },
890 static bool reg_pattern_test(struct igb_adapter
*adapter
, u64
*data
,
891 int reg
, u32 mask
, u32 write
)
895 {0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF};
896 for (pat
= 0; pat
< ARRAY_SIZE(_test
); pat
++) {
897 writel((_test
[pat
] & write
), (adapter
->hw
.hw_addr
+ reg
));
898 val
= readl(adapter
->hw
.hw_addr
+ reg
);
899 if (val
!= (_test
[pat
] & write
& mask
)) {
900 dev_err(&adapter
->pdev
->dev
, "pattern test reg %04X "
901 "failed: got 0x%08X expected 0x%08X\n",
902 reg
, val
, (_test
[pat
] & write
& mask
));
910 static bool reg_set_and_check(struct igb_adapter
*adapter
, u64
*data
,
911 int reg
, u32 mask
, u32 write
)
914 writel((write
& mask
), (adapter
->hw
.hw_addr
+ reg
));
915 val
= readl(adapter
->hw
.hw_addr
+ reg
);
916 if ((write
& mask
) != (val
& mask
)) {
917 dev_err(&adapter
->pdev
->dev
, "set/check reg %04X test failed:"
918 " got 0x%08X expected 0x%08X\n", reg
,
919 (val
& mask
), (write
& mask
));
926 #define REG_PATTERN_TEST(reg, mask, write) \
928 if (reg_pattern_test(adapter, data, reg, mask, write)) \
932 #define REG_SET_AND_CHECK(reg, mask, write) \
934 if (reg_set_and_check(adapter, data, reg, mask, write)) \
938 static int igb_reg_test(struct igb_adapter
*adapter
, u64
*data
)
940 struct e1000_hw
*hw
= &adapter
->hw
;
941 struct igb_reg_test
*test
;
942 u32 value
, before
, after
;
946 test
= reg_test_82575
;
948 /* Because the status register is such a special case,
949 * we handle it separately from the rest of the register
950 * tests. Some bits are read-only, some toggle, and some
951 * are writable on newer MACs.
953 before
= rd32(E1000_STATUS
);
954 value
= (rd32(E1000_STATUS
) & toggle
);
955 wr32(E1000_STATUS
, toggle
);
956 after
= rd32(E1000_STATUS
) & toggle
;
957 if (value
!= after
) {
958 dev_err(&adapter
->pdev
->dev
, "failed STATUS register test "
959 "got: 0x%08X expected: 0x%08X\n", after
, value
);
963 /* restore previous status */
964 wr32(E1000_STATUS
, before
);
966 /* Perform the remainder of the register test, looping through
967 * the test table until we either fail or reach the null entry.
970 for (i
= 0; i
< test
->array_len
; i
++) {
971 switch (test
->test_type
) {
973 REG_PATTERN_TEST(test
->reg
+ (i
* 0x100),
978 REG_SET_AND_CHECK(test
->reg
+ (i
* 0x100),
984 (adapter
->hw
.hw_addr
+ test
->reg
)
988 REG_PATTERN_TEST(test
->reg
+ (i
* 4),
992 case TABLE64_TEST_LO
:
993 REG_PATTERN_TEST(test
->reg
+ (i
* 8),
997 case TABLE64_TEST_HI
:
998 REG_PATTERN_TEST((test
->reg
+ 4) + (i
* 8),
1011 static int igb_eeprom_test(struct igb_adapter
*adapter
, u64
*data
)
1018 /* Read and add up the contents of the EEPROM */
1019 for (i
= 0; i
< (NVM_CHECKSUM_REG
+ 1); i
++) {
1020 if ((adapter
->hw
.nvm
.ops
.read_nvm(&adapter
->hw
, i
, 1, &temp
))
1028 /* If Checksum is not Correct return error else test passed */
1029 if ((checksum
!= (u16
) NVM_SUM
) && !(*data
))
1035 static irqreturn_t
igb_test_intr(int irq
, void *data
)
1037 struct net_device
*netdev
= (struct net_device
*) data
;
1038 struct igb_adapter
*adapter
= netdev_priv(netdev
);
1039 struct e1000_hw
*hw
= &adapter
->hw
;
1041 adapter
->test_icr
|= rd32(E1000_ICR
);
1046 static int igb_intr_test(struct igb_adapter
*adapter
, u64
*data
)
1048 struct e1000_hw
*hw
= &adapter
->hw
;
1049 struct net_device
*netdev
= adapter
->netdev
;
1050 u32 mask
, i
= 0, shared_int
= true;
1051 u32 irq
= adapter
->pdev
->irq
;
1055 /* Hook up test interrupt handler just for this test */
1056 if (adapter
->msix_entries
) {
1057 /* NOTE: we don't test MSI-X interrupts here, yet */
1059 } else if (adapter
->msi_enabled
) {
1061 if (request_irq(irq
, &igb_test_intr
, 0, netdev
->name
, netdev
)) {
1065 } else if (!request_irq(irq
, &igb_test_intr
, IRQF_PROBE_SHARED
,
1066 netdev
->name
, netdev
)) {
1068 } else if (request_irq(irq
, &igb_test_intr
, IRQF_SHARED
,
1069 netdev
->name
, netdev
)) {
1073 dev_info(&adapter
->pdev
->dev
, "testing %s interrupt\n",
1074 (shared_int
? "shared" : "unshared"));
1076 /* Disable all the interrupts */
1077 wr32(E1000_IMC
, 0xFFFFFFFF);
1080 /* Test each interrupt */
1081 for (; i
< 10; i
++) {
1082 /* Interrupt to test */
1086 /* Disable the interrupt to be reported in
1087 * the cause register and then force the same
1088 * interrupt and see if one gets posted. If
1089 * an interrupt was posted to the bus, the
1092 adapter
->test_icr
= 0;
1093 wr32(E1000_IMC
, ~mask
& 0x00007FFF);
1094 wr32(E1000_ICS
, ~mask
& 0x00007FFF);
1097 if (adapter
->test_icr
& mask
) {
1103 /* Enable the interrupt to be reported in
1104 * the cause register and then force the same
1105 * interrupt and see if one gets posted. If
1106 * an interrupt was not posted to the bus, the
1109 adapter
->test_icr
= 0;
1110 wr32(E1000_IMS
, mask
);
1111 wr32(E1000_ICS
, mask
);
1114 if (!(adapter
->test_icr
& mask
)) {
1120 /* Disable the other interrupts to be reported in
1121 * the cause register and then force the other
1122 * interrupts and see if any get posted. If
1123 * an interrupt was posted to the bus, the
1126 adapter
->test_icr
= 0;
1127 wr32(E1000_IMC
, ~mask
& 0x00007FFF);
1128 wr32(E1000_ICS
, ~mask
& 0x00007FFF);
1131 if (adapter
->test_icr
) {
1138 /* Disable all the interrupts */
1139 wr32(E1000_IMC
, 0xFFFFFFFF);
1142 /* Unhook test interrupt handler */
1143 free_irq(irq
, netdev
);
1148 static void igb_free_desc_rings(struct igb_adapter
*adapter
)
1150 struct igb_ring
*tx_ring
= &adapter
->test_tx_ring
;
1151 struct igb_ring
*rx_ring
= &adapter
->test_rx_ring
;
1152 struct pci_dev
*pdev
= adapter
->pdev
;
1155 if (tx_ring
->desc
&& tx_ring
->buffer_info
) {
1156 for (i
= 0; i
< tx_ring
->count
; i
++) {
1157 struct igb_buffer
*buf
= &(tx_ring
->buffer_info
[i
]);
1159 pci_unmap_single(pdev
, buf
->dma
, buf
->length
,
1162 dev_kfree_skb(buf
->skb
);
1166 if (rx_ring
->desc
&& rx_ring
->buffer_info
) {
1167 for (i
= 0; i
< rx_ring
->count
; i
++) {
1168 struct igb_buffer
*buf
= &(rx_ring
->buffer_info
[i
]);
1170 pci_unmap_single(pdev
, buf
->dma
,
1172 PCI_DMA_FROMDEVICE
);
1174 dev_kfree_skb(buf
->skb
);
1178 if (tx_ring
->desc
) {
1179 pci_free_consistent(pdev
, tx_ring
->size
, tx_ring
->desc
,
1181 tx_ring
->desc
= NULL
;
1183 if (rx_ring
->desc
) {
1184 pci_free_consistent(pdev
, rx_ring
->size
, rx_ring
->desc
,
1186 rx_ring
->desc
= NULL
;
1189 kfree(tx_ring
->buffer_info
);
1190 tx_ring
->buffer_info
= NULL
;
1191 kfree(rx_ring
->buffer_info
);
1192 rx_ring
->buffer_info
= NULL
;
1197 static int igb_setup_desc_rings(struct igb_adapter
*adapter
)
1199 struct e1000_hw
*hw
= &adapter
->hw
;
1200 struct igb_ring
*tx_ring
= &adapter
->test_tx_ring
;
1201 struct igb_ring
*rx_ring
= &adapter
->test_rx_ring
;
1202 struct pci_dev
*pdev
= adapter
->pdev
;
1206 /* Setup Tx descriptor ring and Tx buffers */
1208 if (!tx_ring
->count
)
1209 tx_ring
->count
= IGB_DEFAULT_TXD
;
1211 tx_ring
->buffer_info
= kcalloc(tx_ring
->count
,
1212 sizeof(struct igb_buffer
),
1214 if (!tx_ring
->buffer_info
) {
1219 tx_ring
->size
= tx_ring
->count
* sizeof(struct e1000_tx_desc
);
1220 tx_ring
->size
= ALIGN(tx_ring
->size
, 4096);
1221 tx_ring
->desc
= pci_alloc_consistent(pdev
, tx_ring
->size
,
1223 if (!tx_ring
->desc
) {
1227 tx_ring
->next_to_use
= tx_ring
->next_to_clean
= 0;
1229 wr32(E1000_TDBAL(0),
1230 ((u64
) tx_ring
->dma
& 0x00000000FFFFFFFF));
1231 wr32(E1000_TDBAH(0), ((u64
) tx_ring
->dma
>> 32));
1232 wr32(E1000_TDLEN(0),
1233 tx_ring
->count
* sizeof(struct e1000_tx_desc
));
1234 wr32(E1000_TDH(0), 0);
1235 wr32(E1000_TDT(0), 0);
1237 E1000_TCTL_PSP
| E1000_TCTL_EN
|
1238 E1000_COLLISION_THRESHOLD
<< E1000_CT_SHIFT
|
1239 E1000_COLLISION_DISTANCE
<< E1000_COLD_SHIFT
);
1241 for (i
= 0; i
< tx_ring
->count
; i
++) {
1242 struct e1000_tx_desc
*tx_desc
= E1000_TX_DESC(*tx_ring
, i
);
1243 struct sk_buff
*skb
;
1244 unsigned int size
= 1024;
1246 skb
= alloc_skb(size
, GFP_KERNEL
);
1252 tx_ring
->buffer_info
[i
].skb
= skb
;
1253 tx_ring
->buffer_info
[i
].length
= skb
->len
;
1254 tx_ring
->buffer_info
[i
].dma
=
1255 pci_map_single(pdev
, skb
->data
, skb
->len
,
1257 tx_desc
->buffer_addr
= cpu_to_le64(tx_ring
->buffer_info
[i
].dma
);
1258 tx_desc
->lower
.data
= cpu_to_le32(skb
->len
);
1259 tx_desc
->lower
.data
|= cpu_to_le32(E1000_TXD_CMD_EOP
|
1260 E1000_TXD_CMD_IFCS
|
1262 tx_desc
->upper
.data
= 0;
1265 /* Setup Rx descriptor ring and Rx buffers */
1267 if (!rx_ring
->count
)
1268 rx_ring
->count
= IGB_DEFAULT_RXD
;
1270 rx_ring
->buffer_info
= kcalloc(rx_ring
->count
,
1271 sizeof(struct igb_buffer
),
1273 if (!rx_ring
->buffer_info
) {
1278 rx_ring
->size
= rx_ring
->count
* sizeof(struct e1000_rx_desc
);
1279 rx_ring
->desc
= pci_alloc_consistent(pdev
, rx_ring
->size
,
1281 if (!rx_ring
->desc
) {
1285 rx_ring
->next_to_use
= rx_ring
->next_to_clean
= 0;
1287 rctl
= rd32(E1000_RCTL
);
1288 wr32(E1000_RCTL
, rctl
& ~E1000_RCTL_EN
);
1289 wr32(E1000_RDBAL(0),
1290 ((u64
) rx_ring
->dma
& 0xFFFFFFFF));
1291 wr32(E1000_RDBAH(0),
1292 ((u64
) rx_ring
->dma
>> 32));
1293 wr32(E1000_RDLEN(0), rx_ring
->size
);
1294 wr32(E1000_RDH(0), 0);
1295 wr32(E1000_RDT(0), 0);
1296 rctl
= E1000_RCTL_EN
| E1000_RCTL_BAM
| E1000_RCTL_SZ_2048
|
1297 E1000_RCTL_LBM_NO
| E1000_RCTL_RDMTS_HALF
|
1298 (adapter
->hw
.mac
.mc_filter_type
<< E1000_RCTL_MO_SHIFT
);
1299 wr32(E1000_RCTL
, rctl
);
1300 wr32(E1000_SRRCTL(0), 0);
1302 for (i
= 0; i
< rx_ring
->count
; i
++) {
1303 struct e1000_rx_desc
*rx_desc
= E1000_RX_DESC(*rx_ring
, i
);
1304 struct sk_buff
*skb
;
1306 skb
= alloc_skb(IGB_RXBUFFER_2048
+ NET_IP_ALIGN
,
1312 skb_reserve(skb
, NET_IP_ALIGN
);
1313 rx_ring
->buffer_info
[i
].skb
= skb
;
1314 rx_ring
->buffer_info
[i
].dma
=
1315 pci_map_single(pdev
, skb
->data
, IGB_RXBUFFER_2048
,
1316 PCI_DMA_FROMDEVICE
);
1317 rx_desc
->buffer_addr
= cpu_to_le64(rx_ring
->buffer_info
[i
].dma
);
1318 memset(skb
->data
, 0x00, skb
->len
);
1324 igb_free_desc_rings(adapter
);
1328 static void igb_phy_disable_receiver(struct igb_adapter
*adapter
)
1330 struct e1000_hw
*hw
= &adapter
->hw
;
1332 /* Write out to PHY registers 29 and 30 to disable the Receiver. */
1333 hw
->phy
.ops
.write_phy_reg(hw
, 29, 0x001F);
1334 hw
->phy
.ops
.write_phy_reg(hw
, 30, 0x8FFC);
1335 hw
->phy
.ops
.write_phy_reg(hw
, 29, 0x001A);
1336 hw
->phy
.ops
.write_phy_reg(hw
, 30, 0x8FF0);
1339 static int igb_integrated_phy_loopback(struct igb_adapter
*adapter
)
1341 struct e1000_hw
*hw
= &adapter
->hw
;
1345 hw
->mac
.autoneg
= false;
1347 if (hw
->phy
.type
== e1000_phy_m88
) {
1348 /* Auto-MDI/MDIX Off */
1349 hw
->phy
.ops
.write_phy_reg(hw
, M88E1000_PHY_SPEC_CTRL
, 0x0808);
1350 /* reset to update Auto-MDI/MDIX */
1351 hw
->phy
.ops
.write_phy_reg(hw
, PHY_CONTROL
, 0x9140);
1353 hw
->phy
.ops
.write_phy_reg(hw
, PHY_CONTROL
, 0x8140);
1356 ctrl_reg
= rd32(E1000_CTRL
);
1358 /* force 1000, set loopback */
1359 hw
->phy
.ops
.write_phy_reg(hw
, PHY_CONTROL
, 0x4140);
1361 /* Now set up the MAC to the same speed/duplex as the PHY. */
1362 ctrl_reg
= rd32(E1000_CTRL
);
1363 ctrl_reg
&= ~E1000_CTRL_SPD_SEL
; /* Clear the speed sel bits */
1364 ctrl_reg
|= (E1000_CTRL_FRCSPD
| /* Set the Force Speed Bit */
1365 E1000_CTRL_FRCDPX
| /* Set the Force Duplex Bit */
1366 E1000_CTRL_SPD_1000
|/* Force Speed to 1000 */
1367 E1000_CTRL_FD
); /* Force Duplex to FULL */
1369 if (hw
->phy
.media_type
== e1000_media_type_copper
&&
1370 hw
->phy
.type
== e1000_phy_m88
)
1371 ctrl_reg
|= E1000_CTRL_ILOS
; /* Invert Loss of Signal */
1373 /* Set the ILOS bit on the fiber Nic if half duplex link is
1375 stat_reg
= rd32(E1000_STATUS
);
1376 if ((stat_reg
& E1000_STATUS_FD
) == 0)
1377 ctrl_reg
|= (E1000_CTRL_ILOS
| E1000_CTRL_SLU
);
1380 wr32(E1000_CTRL
, ctrl_reg
);
1382 /* Disable the receiver on the PHY so when a cable is plugged in, the
1383 * PHY does not begin to autoneg when a cable is reconnected to the NIC.
1385 if (hw
->phy
.type
== e1000_phy_m88
)
1386 igb_phy_disable_receiver(adapter
);
1393 static int igb_set_phy_loopback(struct igb_adapter
*adapter
)
1395 return igb_integrated_phy_loopback(adapter
);
1398 static int igb_setup_loopback_test(struct igb_adapter
*adapter
)
1400 struct e1000_hw
*hw
= &adapter
->hw
;
1403 if (hw
->phy
.media_type
== e1000_media_type_fiber
||
1404 hw
->phy
.media_type
== e1000_media_type_internal_serdes
) {
1405 rctl
= rd32(E1000_RCTL
);
1406 rctl
|= E1000_RCTL_LBM_TCVR
;
1407 wr32(E1000_RCTL
, rctl
);
1409 } else if (hw
->phy
.media_type
== e1000_media_type_copper
) {
1410 return igb_set_phy_loopback(adapter
);
1416 static void igb_loopback_cleanup(struct igb_adapter
*adapter
)
1418 struct e1000_hw
*hw
= &adapter
->hw
;
1422 rctl
= rd32(E1000_RCTL
);
1423 rctl
&= ~(E1000_RCTL_LBM_TCVR
| E1000_RCTL_LBM_MAC
);
1424 wr32(E1000_RCTL
, rctl
);
1426 hw
->mac
.autoneg
= true;
1427 hw
->phy
.ops
.read_phy_reg(hw
, PHY_CONTROL
, &phy_reg
);
1428 if (phy_reg
& MII_CR_LOOPBACK
) {
1429 phy_reg
&= ~MII_CR_LOOPBACK
;
1430 hw
->phy
.ops
.write_phy_reg(hw
, PHY_CONTROL
, phy_reg
);
1431 igb_phy_sw_reset(hw
);
1435 static void igb_create_lbtest_frame(struct sk_buff
*skb
,
1436 unsigned int frame_size
)
1438 memset(skb
->data
, 0xFF, frame_size
);
1440 memset(&skb
->data
[frame_size
/ 2], 0xAA, frame_size
/ 2 - 1);
1441 memset(&skb
->data
[frame_size
/ 2 + 10], 0xBE, 1);
1442 memset(&skb
->data
[frame_size
/ 2 + 12], 0xAF, 1);
1445 static int igb_check_lbtest_frame(struct sk_buff
*skb
, unsigned int frame_size
)
1448 if (*(skb
->data
+ 3) == 0xFF)
1449 if ((*(skb
->data
+ frame_size
/ 2 + 10) == 0xBE) &&
1450 (*(skb
->data
+ frame_size
/ 2 + 12) == 0xAF))
1455 static int igb_run_loopback_test(struct igb_adapter
*adapter
)
1457 struct e1000_hw
*hw
= &adapter
->hw
;
1458 struct igb_ring
*tx_ring
= &adapter
->test_tx_ring
;
1459 struct igb_ring
*rx_ring
= &adapter
->test_rx_ring
;
1460 struct pci_dev
*pdev
= adapter
->pdev
;
1461 int i
, j
, k
, l
, lc
, good_cnt
;
1465 wr32(E1000_RDT(0), rx_ring
->count
- 1);
1467 /* Calculate the loop count based on the largest descriptor ring
1468 * The idea is to wrap the largest ring a number of times using 64
1469 * send/receive pairs during each loop
1472 if (rx_ring
->count
<= tx_ring
->count
)
1473 lc
= ((tx_ring
->count
/ 64) * 2) + 1;
1475 lc
= ((rx_ring
->count
/ 64) * 2) + 1;
1478 for (j
= 0; j
<= lc
; j
++) { /* loop count loop */
1479 for (i
= 0; i
< 64; i
++) { /* send the packets */
1480 igb_create_lbtest_frame(tx_ring
->buffer_info
[k
].skb
,
1482 pci_dma_sync_single_for_device(pdev
,
1483 tx_ring
->buffer_info
[k
].dma
,
1484 tx_ring
->buffer_info
[k
].length
,
1487 if (k
== tx_ring
->count
)
1490 wr32(E1000_TDT(0), k
);
1492 time
= jiffies
; /* set the start time for the receive */
1494 do { /* receive the sent packets */
1495 pci_dma_sync_single_for_cpu(pdev
,
1496 rx_ring
->buffer_info
[l
].dma
,
1498 PCI_DMA_FROMDEVICE
);
1500 ret_val
= igb_check_lbtest_frame(
1501 rx_ring
->buffer_info
[l
].skb
, 1024);
1505 if (l
== rx_ring
->count
)
1507 /* time + 20 msecs (200 msecs on 2.4) is more than
1508 * enough time to complete the receives, if it's
1509 * exceeded, break and error off
1511 } while (good_cnt
< 64 && jiffies
< (time
+ 20));
1512 if (good_cnt
!= 64) {
1513 ret_val
= 13; /* ret_val is the same as mis-compare */
1516 if (jiffies
>= (time
+ 20)) {
1517 ret_val
= 14; /* error code for time out error */
1520 } /* end loop count loop */
1524 static int igb_loopback_test(struct igb_adapter
*adapter
, u64
*data
)
1526 /* PHY loopback cannot be performed if SoL/IDER
1527 * sessions are active */
1528 if (igb_check_reset_block(&adapter
->hw
)) {
1529 dev_err(&adapter
->pdev
->dev
,
1530 "Cannot do PHY loopback test "
1531 "when SoL/IDER is active.\n");
1535 *data
= igb_setup_desc_rings(adapter
);
1538 *data
= igb_setup_loopback_test(adapter
);
1541 *data
= igb_run_loopback_test(adapter
);
1542 igb_loopback_cleanup(adapter
);
1545 igb_free_desc_rings(adapter
);
1550 static int igb_link_test(struct igb_adapter
*adapter
, u64
*data
)
1552 struct e1000_hw
*hw
= &adapter
->hw
;
1554 if (hw
->phy
.media_type
== e1000_media_type_internal_serdes
) {
1556 hw
->mac
.serdes_has_link
= false;
1558 /* On some blade server designs, link establishment
1559 * could take as long as 2-3 minutes */
1561 hw
->mac
.ops
.check_for_link(&adapter
->hw
);
1562 if (hw
->mac
.serdes_has_link
)
1565 } while (i
++ < 3750);
1569 hw
->mac
.ops
.check_for_link(&adapter
->hw
);
1570 if (hw
->mac
.autoneg
)
1573 if (!(rd32(E1000_STATUS
) &
1580 static void igb_diag_test(struct net_device
*netdev
,
1581 struct ethtool_test
*eth_test
, u64
*data
)
1583 struct igb_adapter
*adapter
= netdev_priv(netdev
);
1584 u16 autoneg_advertised
;
1585 u8 forced_speed_duplex
, autoneg
;
1586 bool if_running
= netif_running(netdev
);
1588 set_bit(__IGB_TESTING
, &adapter
->state
);
1589 if (eth_test
->flags
== ETH_TEST_FL_OFFLINE
) {
1592 /* save speed, duplex, autoneg settings */
1593 autoneg_advertised
= adapter
->hw
.phy
.autoneg_advertised
;
1594 forced_speed_duplex
= adapter
->hw
.mac
.forced_speed_duplex
;
1595 autoneg
= adapter
->hw
.mac
.autoneg
;
1597 dev_info(&adapter
->pdev
->dev
, "offline testing starting\n");
1599 /* Link test performed before hardware reset so autoneg doesn't
1600 * interfere with test result */
1601 if (igb_link_test(adapter
, &data
[4]))
1602 eth_test
->flags
|= ETH_TEST_FL_FAILED
;
1605 /* indicate we're in test mode */
1610 if (igb_reg_test(adapter
, &data
[0]))
1611 eth_test
->flags
|= ETH_TEST_FL_FAILED
;
1614 if (igb_eeprom_test(adapter
, &data
[1]))
1615 eth_test
->flags
|= ETH_TEST_FL_FAILED
;
1618 if (igb_intr_test(adapter
, &data
[2]))
1619 eth_test
->flags
|= ETH_TEST_FL_FAILED
;
1622 if (igb_loopback_test(adapter
, &data
[3]))
1623 eth_test
->flags
|= ETH_TEST_FL_FAILED
;
1625 /* restore speed, duplex, autoneg settings */
1626 adapter
->hw
.phy
.autoneg_advertised
= autoneg_advertised
;
1627 adapter
->hw
.mac
.forced_speed_duplex
= forced_speed_duplex
;
1628 adapter
->hw
.mac
.autoneg
= autoneg
;
1630 /* force this routine to wait until autoneg complete/timeout */
1631 adapter
->hw
.phy
.autoneg_wait_to_complete
= true;
1633 adapter
->hw
.phy
.autoneg_wait_to_complete
= false;
1635 clear_bit(__IGB_TESTING
, &adapter
->state
);
1639 dev_info(&adapter
->pdev
->dev
, "online testing starting\n");
1641 if (igb_link_test(adapter
, &data
[4]))
1642 eth_test
->flags
|= ETH_TEST_FL_FAILED
;
1644 /* Online tests aren't run; pass by default */
1650 clear_bit(__IGB_TESTING
, &adapter
->state
);
1652 msleep_interruptible(4 * 1000);
1655 static int igb_wol_exclusion(struct igb_adapter
*adapter
,
1656 struct ethtool_wolinfo
*wol
)
1658 struct e1000_hw
*hw
= &adapter
->hw
;
1659 int retval
= 1; /* fail by default */
1661 switch (hw
->device_id
) {
1662 case E1000_DEV_ID_82575GB_QUAD_COPPER
:
1663 /* WoL not supported */
1666 case E1000_DEV_ID_82575EB_FIBER_SERDES
:
1667 /* Wake events not supported on port B */
1668 if (rd32(E1000_STATUS
) & E1000_STATUS_FUNC_1
) {
1672 /* return success for non excluded adapter ports */
1676 /* dual port cards only support WoL on port A from now on
1677 * unless it was enabled in the eeprom for port B
1678 * so exclude FUNC_1 ports from having WoL enabled */
1679 if (rd32(E1000_STATUS
) & E1000_STATUS_FUNC_1
&&
1680 !adapter
->eeprom_wol
) {
1691 static void igb_get_wol(struct net_device
*netdev
, struct ethtool_wolinfo
*wol
)
1693 struct igb_adapter
*adapter
= netdev_priv(netdev
);
1695 wol
->supported
= WAKE_UCAST
| WAKE_MCAST
|
1696 WAKE_BCAST
| WAKE_MAGIC
;
1699 /* this function will set ->supported = 0 and return 1 if wol is not
1700 * supported by this hardware */
1701 if (igb_wol_exclusion(adapter
, wol
))
1704 /* apply any specific unsupported masks here */
1705 switch (adapter
->hw
.device_id
) {
1710 if (adapter
->wol
& E1000_WUFC_EX
)
1711 wol
->wolopts
|= WAKE_UCAST
;
1712 if (adapter
->wol
& E1000_WUFC_MC
)
1713 wol
->wolopts
|= WAKE_MCAST
;
1714 if (adapter
->wol
& E1000_WUFC_BC
)
1715 wol
->wolopts
|= WAKE_BCAST
;
1716 if (adapter
->wol
& E1000_WUFC_MAG
)
1717 wol
->wolopts
|= WAKE_MAGIC
;
1722 static int igb_set_wol(struct net_device
*netdev
, struct ethtool_wolinfo
*wol
)
1724 struct igb_adapter
*adapter
= netdev_priv(netdev
);
1725 struct e1000_hw
*hw
= &adapter
->hw
;
1727 if (wol
->wolopts
& (WAKE_PHY
| WAKE_ARP
| WAKE_MAGICSECURE
))
1730 if (igb_wol_exclusion(adapter
, wol
))
1731 return wol
->wolopts
? -EOPNOTSUPP
: 0;
1733 switch (hw
->device_id
) {
1738 /* these settings will always override what we currently have */
1741 if (wol
->wolopts
& WAKE_UCAST
)
1742 adapter
->wol
|= E1000_WUFC_EX
;
1743 if (wol
->wolopts
& WAKE_MCAST
)
1744 adapter
->wol
|= E1000_WUFC_MC
;
1745 if (wol
->wolopts
& WAKE_BCAST
)
1746 adapter
->wol
|= E1000_WUFC_BC
;
1747 if (wol
->wolopts
& WAKE_MAGIC
)
1748 adapter
->wol
|= E1000_WUFC_MAG
;
1753 /* toggle LED 4 times per second = 2 "blinks" per second */
1754 #define IGB_ID_INTERVAL (HZ/4)
1756 /* bit defines for adapter->led_status */
1757 #define IGB_LED_ON 0
1759 static int igb_phys_id(struct net_device
*netdev
, u32 data
)
1761 struct igb_adapter
*adapter
= netdev_priv(netdev
);
1762 struct e1000_hw
*hw
= &adapter
->hw
;
1764 if (!data
|| data
> (u32
)(MAX_SCHEDULE_TIMEOUT
/ HZ
))
1765 data
= (u32
)(MAX_SCHEDULE_TIMEOUT
/ HZ
);
1768 msleep_interruptible(data
* 1000);
1771 clear_bit(IGB_LED_ON
, &adapter
->led_status
);
1772 igb_cleanup_led(hw
);
1777 static int igb_set_coalesce(struct net_device
*netdev
,
1778 struct ethtool_coalesce
*ec
)
1780 struct igb_adapter
*adapter
= netdev_priv(netdev
);
1782 if ((ec
->rx_coalesce_usecs
> IGB_MAX_ITR_USECS
) ||
1783 ((ec
->rx_coalesce_usecs
> 3) &&
1784 (ec
->rx_coalesce_usecs
< IGB_MIN_ITR_USECS
)) ||
1785 (ec
->rx_coalesce_usecs
== 2))
1788 /* convert to rate of irq's per second */
1789 if (ec
->rx_coalesce_usecs
<= 3)
1790 adapter
->itr_setting
= ec
->rx_coalesce_usecs
;
1792 adapter
->itr_setting
= (1000000 / ec
->rx_coalesce_usecs
);
1794 if (netif_running(netdev
))
1795 igb_reinit_locked(adapter
);
1800 static int igb_get_coalesce(struct net_device
*netdev
,
1801 struct ethtool_coalesce
*ec
)
1803 struct igb_adapter
*adapter
= netdev_priv(netdev
);
1805 if (adapter
->itr_setting
<= 3)
1806 ec
->rx_coalesce_usecs
= adapter
->itr_setting
;
1808 ec
->rx_coalesce_usecs
= 1000000 / adapter
->itr_setting
;
1814 static int igb_nway_reset(struct net_device
*netdev
)
1816 struct igb_adapter
*adapter
= netdev_priv(netdev
);
1817 if (netif_running(netdev
))
1818 igb_reinit_locked(adapter
);
1822 static int igb_get_sset_count(struct net_device
*netdev
, int sset
)
1826 return IGB_STATS_LEN
;
1828 return IGB_TEST_LEN
;
1834 static void igb_get_ethtool_stats(struct net_device
*netdev
,
1835 struct ethtool_stats
*stats
, u64
*data
)
1837 struct igb_adapter
*adapter
= netdev_priv(netdev
);
1839 int stat_count
= sizeof(struct igb_queue_stats
) / sizeof(u64
);
1843 igb_update_stats(adapter
);
1844 for (i
= 0; i
< IGB_GLOBAL_STATS_LEN
; i
++) {
1845 char *p
= (char *)adapter
+igb_gstrings_stats
[i
].stat_offset
;
1846 data
[i
] = (igb_gstrings_stats
[i
].sizeof_stat
==
1847 sizeof(u64
)) ? *(u64
*)p
: *(u32
*)p
;
1849 for (j
= 0; j
< adapter
->num_rx_queues
; j
++) {
1851 queue_stat
= (u64
*)&adapter
->rx_ring
[j
].rx_stats
;
1852 for (k
= 0; k
< stat_count
; k
++)
1853 data
[i
+ k
] = queue_stat
[k
];
1858 static void igb_get_strings(struct net_device
*netdev
, u32 stringset
, u8
*data
)
1860 struct igb_adapter
*adapter
= netdev_priv(netdev
);
1864 switch (stringset
) {
1866 memcpy(data
, *igb_gstrings_test
,
1867 IGB_TEST_LEN
*ETH_GSTRING_LEN
);
1870 for (i
= 0; i
< IGB_GLOBAL_STATS_LEN
; i
++) {
1871 memcpy(p
, igb_gstrings_stats
[i
].stat_string
,
1873 p
+= ETH_GSTRING_LEN
;
1875 for (i
= 0; i
< adapter
->num_tx_queues
; i
++) {
1876 sprintf(p
, "tx_queue_%u_packets", i
);
1877 p
+= ETH_GSTRING_LEN
;
1878 sprintf(p
, "tx_queue_%u_bytes", i
);
1879 p
+= ETH_GSTRING_LEN
;
1881 for (i
= 0; i
< adapter
->num_rx_queues
; i
++) {
1882 sprintf(p
, "rx_queue_%u_packets", i
);
1883 p
+= ETH_GSTRING_LEN
;
1884 sprintf(p
, "rx_queue_%u_bytes", i
);
1885 p
+= ETH_GSTRING_LEN
;
1887 /* BUG_ON(p - data != IGB_STATS_LEN * ETH_GSTRING_LEN); */
1892 static struct ethtool_ops igb_ethtool_ops
= {
1893 .get_settings
= igb_get_settings
,
1894 .set_settings
= igb_set_settings
,
1895 .get_drvinfo
= igb_get_drvinfo
,
1896 .get_regs_len
= igb_get_regs_len
,
1897 .get_regs
= igb_get_regs
,
1898 .get_wol
= igb_get_wol
,
1899 .set_wol
= igb_set_wol
,
1900 .get_msglevel
= igb_get_msglevel
,
1901 .set_msglevel
= igb_set_msglevel
,
1902 .nway_reset
= igb_nway_reset
,
1903 .get_link
= ethtool_op_get_link
,
1904 .get_eeprom_len
= igb_get_eeprom_len
,
1905 .get_eeprom
= igb_get_eeprom
,
1906 .set_eeprom
= igb_set_eeprom
,
1907 .get_ringparam
= igb_get_ringparam
,
1908 .set_ringparam
= igb_set_ringparam
,
1909 .get_pauseparam
= igb_get_pauseparam
,
1910 .set_pauseparam
= igb_set_pauseparam
,
1911 .get_rx_csum
= igb_get_rx_csum
,
1912 .set_rx_csum
= igb_set_rx_csum
,
1913 .get_tx_csum
= igb_get_tx_csum
,
1914 .set_tx_csum
= igb_set_tx_csum
,
1915 .get_sg
= ethtool_op_get_sg
,
1916 .set_sg
= ethtool_op_set_sg
,
1917 .get_tso
= ethtool_op_get_tso
,
1918 .set_tso
= igb_set_tso
,
1919 .self_test
= igb_diag_test
,
1920 .get_strings
= igb_get_strings
,
1921 .phys_id
= igb_phys_id
,
1922 .get_sset_count
= igb_get_sset_count
,
1923 .get_ethtool_stats
= igb_get_ethtool_stats
,
1924 .get_coalesce
= igb_get_coalesce
,
1925 .set_coalesce
= igb_set_coalesce
,
1928 void igb_set_ethtool_ops(struct net_device
*netdev
)
1930 SET_ETHTOOL_OPS(netdev
, &igb_ethtool_ops
);