2 * Copyright (C) 2003 - 2006 NetXen, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE.
23 * Contact Information:
26 * 3965 Freedom Circle, Fourth floor,
27 * Santa Clara, CA 95054
30 * ethtool support for netxen nic
34 #include <linux/types.h>
35 #include <asm/uaccess.h>
36 #include <linux/pci.h>
38 #include <linux/netdevice.h>
39 #include <linux/ethtool.h>
40 #include <linux/version.h>
42 #include "netxen_nic_hw.h"
43 #include "netxen_nic.h"
44 #include "netxen_nic_phan_reg.h"
46 struct netxen_nic_stats
{
47 char stat_string
[ETH_GSTRING_LEN
];
52 #define NETXEN_NIC_STAT(m) sizeof(((struct netxen_port *)0)->m), \
53 offsetof(struct netxen_port, m)
55 #define NETXEN_NIC_PORT_WINDOW 0x10000
56 #define NETXEN_NIC_INVALID_DATA 0xDEADBEEF
58 static const struct netxen_nic_stats netxen_nic_gstrings_stats
[] = {
59 {"rcvd_bad_skb", NETXEN_NIC_STAT(stats
.rcvdbadskb
)},
60 {"xmit_called", NETXEN_NIC_STAT(stats
.xmitcalled
)},
61 {"xmited_frames", NETXEN_NIC_STAT(stats
.xmitedframes
)},
62 {"xmit_finished", NETXEN_NIC_STAT(stats
.xmitfinished
)},
63 {"bad_skb_len", NETXEN_NIC_STAT(stats
.badskblen
)},
64 {"no_cmd_desc", NETXEN_NIC_STAT(stats
.nocmddescriptor
)},
65 {"polled", NETXEN_NIC_STAT(stats
.polled
)},
66 {"uphappy", NETXEN_NIC_STAT(stats
.uphappy
)},
67 {"updropped", NETXEN_NIC_STAT(stats
.updropped
)},
68 {"uplcong", NETXEN_NIC_STAT(stats
.uplcong
)},
69 {"uphcong", NETXEN_NIC_STAT(stats
.uphcong
)},
70 {"upmcong", NETXEN_NIC_STAT(stats
.upmcong
)},
71 {"updunno", NETXEN_NIC_STAT(stats
.updunno
)},
72 {"skb_freed", NETXEN_NIC_STAT(stats
.skbfreed
)},
73 {"tx_dropped", NETXEN_NIC_STAT(stats
.txdropped
)},
74 {"tx_null_skb", NETXEN_NIC_STAT(stats
.txnullskb
)},
75 {"csummed", NETXEN_NIC_STAT(stats
.csummed
)},
76 {"no_rcv", NETXEN_NIC_STAT(stats
.no_rcv
)},
77 {"rx_bytes", NETXEN_NIC_STAT(stats
.rxbytes
)},
78 {"tx_bytes", NETXEN_NIC_STAT(stats
.txbytes
)},
81 #define NETXEN_NIC_STATS_LEN ARRAY_SIZE(netxen_nic_gstrings_stats)
83 static const char netxen_nic_gstrings_test
[][ETH_GSTRING_LEN
] = {
84 "Register_Test_offline", "EEPROM_Test_offline",
85 "Interrupt_Test_offline", "Loopback_Test_offline",
86 "Link_Test_on_offline"
89 #define NETXEN_NIC_TEST_LEN sizeof(netxen_nic_gstrings_test) / ETH_GSTRING_LEN
91 #define NETXEN_NIC_REGS_COUNT 42
92 #define NETXEN_NIC_REGS_LEN (NETXEN_NIC_REGS_COUNT * sizeof(__le32))
93 #define NETXEN_MAX_EEPROM_LEN 1024
95 static int netxen_nic_get_eeprom_len(struct net_device
*dev
)
97 struct netxen_port
*port
= netdev_priv(dev
);
98 struct netxen_adapter
*adapter
= port
->adapter
;
101 if ((netxen_rom_fast_read(adapter
, 0, &n
) == 0)
102 && (n
& NETXEN_ROM_ROUNDUP
)) {
103 n
&= ~NETXEN_ROM_ROUNDUP
;
104 if (n
< NETXEN_MAX_EEPROM_LEN
)
111 netxen_nic_get_drvinfo(struct net_device
*dev
, struct ethtool_drvinfo
*drvinfo
)
113 struct netxen_port
*port
= netdev_priv(dev
);
114 struct netxen_adapter
*adapter
= port
->adapter
;
119 strncpy(drvinfo
->driver
, netxen_nic_driver_name
, 32);
120 strncpy(drvinfo
->version
, NETXEN_NIC_LINUX_VERSIONID
, 32);
121 fw_major
= readl(NETXEN_CRB_NORMALIZE(adapter
,
122 NETXEN_FW_VERSION_MAJOR
));
123 fw_minor
= readl(NETXEN_CRB_NORMALIZE(adapter
,
124 NETXEN_FW_VERSION_MINOR
));
125 fw_build
= readl(NETXEN_CRB_NORMALIZE(adapter
, NETXEN_FW_VERSION_SUB
));
126 sprintf(drvinfo
->fw_version
, "%d.%d.%d", fw_major
, fw_minor
, fw_build
);
128 strncpy(drvinfo
->bus_info
, pci_name(port
->pdev
), 32);
129 drvinfo
->n_stats
= NETXEN_NIC_STATS_LEN
;
130 drvinfo
->testinfo_len
= NETXEN_NIC_TEST_LEN
;
131 drvinfo
->regdump_len
= NETXEN_NIC_REGS_LEN
;
132 drvinfo
->eedump_len
= netxen_nic_get_eeprom_len(dev
);
136 netxen_nic_get_settings(struct net_device
*dev
, struct ethtool_cmd
*ecmd
)
138 struct netxen_port
*port
= netdev_priv(dev
);
139 struct netxen_adapter
*adapter
= port
->adapter
;
140 struct netxen_board_info
*boardinfo
= &adapter
->ahw
.boardcfg
;
142 /* read which mode */
143 if (adapter
->ahw
.board_type
== NETXEN_NIC_GBE
) {
144 ecmd
->supported
= (SUPPORTED_10baseT_Half
|
145 SUPPORTED_10baseT_Full
|
146 SUPPORTED_100baseT_Half
|
147 SUPPORTED_100baseT_Full
|
148 SUPPORTED_1000baseT_Half
|
149 SUPPORTED_1000baseT_Full
);
151 ecmd
->advertising
= (ADVERTISED_100baseT_Half
|
152 ADVERTISED_100baseT_Full
|
153 ADVERTISED_1000baseT_Half
|
154 ADVERTISED_1000baseT_Full
);
156 ecmd
->port
= PORT_TP
;
158 if (netif_running(dev
)) {
159 ecmd
->speed
= port
->link_speed
;
160 ecmd
->duplex
= port
->link_duplex
;
162 return -EIO
; /* link absent */
163 } else if (adapter
->ahw
.board_type
== NETXEN_NIC_XGBE
) {
164 ecmd
->supported
= (SUPPORTED_TP
|
165 SUPPORTED_1000baseT_Full
|
166 SUPPORTED_10000baseT_Full
);
167 ecmd
->advertising
= (ADVERTISED_TP
|
168 ADVERTISED_1000baseT_Full
|
169 ADVERTISED_10000baseT_Full
);
170 ecmd
->port
= PORT_TP
;
172 ecmd
->speed
= SPEED_10000
;
173 ecmd
->duplex
= DUPLEX_FULL
;
174 ecmd
->autoneg
= AUTONEG_DISABLE
;
178 ecmd
->phy_address
= port
->portnum
;
179 ecmd
->transceiver
= XCVR_EXTERNAL
;
181 switch ((netxen_brdtype_t
) boardinfo
->board_type
) {
182 case NETXEN_BRDTYPE_P2_SB35_4G
:
183 case NETXEN_BRDTYPE_P2_SB31_2G
:
184 ecmd
->supported
|= SUPPORTED_Autoneg
;
185 ecmd
->advertising
|= ADVERTISED_Autoneg
;
186 case NETXEN_BRDTYPE_P2_SB31_10G_CX4
:
187 ecmd
->supported
|= SUPPORTED_TP
;
188 ecmd
->advertising
|= ADVERTISED_TP
;
189 ecmd
->port
= PORT_TP
;
190 ecmd
->autoneg
= (boardinfo
->board_type
==
191 NETXEN_BRDTYPE_P2_SB31_10G_CX4
) ?
192 (AUTONEG_DISABLE
) : (port
->link_autoneg
);
194 case NETXEN_BRDTYPE_P2_SB31_10G_HMEZ
:
195 case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ
:
196 ecmd
->supported
|= SUPPORTED_MII
;
197 ecmd
->advertising
|= ADVERTISED_MII
;
198 ecmd
->port
= PORT_FIBRE
;
199 ecmd
->autoneg
= AUTONEG_DISABLE
;
201 case NETXEN_BRDTYPE_P2_SB31_10G
:
202 ecmd
->supported
|= SUPPORTED_FIBRE
;
203 ecmd
->advertising
|= ADVERTISED_FIBRE
;
204 ecmd
->port
= PORT_FIBRE
;
205 ecmd
->autoneg
= AUTONEG_DISABLE
;
208 printk(KERN_ERR
"netxen-nic: Unsupported board model %d\n",
209 (netxen_brdtype_t
) boardinfo
->board_type
);
217 netxen_nic_set_settings(struct net_device
*dev
, struct ethtool_cmd
*ecmd
)
219 struct netxen_port
*port
= netdev_priv(dev
);
220 struct netxen_adapter
*adapter
= port
->adapter
;
223 /* read which mode */
224 if (adapter
->ahw
.board_type
== NETXEN_NIC_GBE
) {
225 /* autonegotiation */
226 if (adapter
->phy_write
227 && adapter
->phy_write(adapter
, port
->portnum
,
228 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG
,
232 port
->link_autoneg
= ecmd
->autoneg
;
234 if (adapter
->phy_read
235 && adapter
->phy_read(adapter
, port
->portnum
,
236 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS
,
241 switch (ecmd
->speed
) {
243 netxen_set_phy_speed(status
, 0);
246 netxen_set_phy_speed(status
, 1);
249 netxen_set_phy_speed(status
, 2);
252 /* set duplex mode */
253 if (ecmd
->duplex
== DUPLEX_HALF
)
254 netxen_clear_phy_duplex(status
);
255 if (ecmd
->duplex
== DUPLEX_FULL
)
256 netxen_set_phy_duplex(status
);
257 if (adapter
->phy_write
258 && adapter
->phy_write(adapter
, port
->portnum
,
259 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS
,
260 *((int *)&status
)) != 0)
263 port
->link_speed
= ecmd
->speed
;
264 port
->link_duplex
= ecmd
->duplex
;
269 if (netif_running(dev
)) {
276 static int netxen_nic_get_regs_len(struct net_device
*dev
)
278 return NETXEN_NIC_REGS_LEN
;
281 struct netxen_niu_regs
{
282 __u32 reg
[NETXEN_NIC_REGS_COUNT
];
285 static struct netxen_niu_regs niu_registers
[] = {
289 NETXEN_NIU_GB_SERDES_RESET
,
290 NETXEN_NIU_GB0_MII_MODE
,
291 NETXEN_NIU_GB1_MII_MODE
,
292 NETXEN_NIU_GB2_MII_MODE
,
293 NETXEN_NIU_GB3_MII_MODE
,
294 NETXEN_NIU_GB0_GMII_MODE
,
295 NETXEN_NIU_GB1_GMII_MODE
,
296 NETXEN_NIU_GB2_GMII_MODE
,
297 NETXEN_NIU_GB3_GMII_MODE
,
298 NETXEN_NIU_REMOTE_LOOPBACK
,
299 NETXEN_NIU_GB0_HALF_DUPLEX
,
300 NETXEN_NIU_GB1_HALF_DUPLEX
,
301 NETXEN_NIU_RESET_SYS_FIFOS
,
302 NETXEN_NIU_GB_CRC_DROP
,
303 NETXEN_NIU_GB_DROP_WRONGADDR
,
304 NETXEN_NIU_TEST_MUX_CTL
,
306 NETXEN_NIU_GB_MAC_CONFIG_0(0),
307 NETXEN_NIU_GB_MAC_CONFIG_1(0),
308 NETXEN_NIU_GB_HALF_DUPLEX_CTRL(0),
309 NETXEN_NIU_GB_MAX_FRAME_SIZE(0),
310 NETXEN_NIU_GB_TEST_REG(0),
311 NETXEN_NIU_GB_MII_MGMT_CONFIG(0),
312 NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
313 NETXEN_NIU_GB_MII_MGMT_ADDR(0),
314 NETXEN_NIU_GB_MII_MGMT_CTRL(0),
315 NETXEN_NIU_GB_MII_MGMT_STATUS(0),
316 NETXEN_NIU_GB_MII_MGMT_INDICATE(0),
317 NETXEN_NIU_GB_INTERFACE_CTRL(0),
318 NETXEN_NIU_GB_INTERFACE_STATUS(0),
319 NETXEN_NIU_GB_STATION_ADDR_0(0),
320 NETXEN_NIU_GB_STATION_ADDR_1(0),
327 NETXEN_NIU_XG_SINGLE_TERM
,
328 NETXEN_NIU_XG_DRIVE_HI
,
329 NETXEN_NIU_XG_DRIVE_LO
,
332 NETXEN_NIU_XG_WORD_ALIGN
,
334 NETXEN_NIU_XG_POWER_DOWN
,
335 NETXEN_NIU_XG_RESET_PLL
,
336 NETXEN_NIU_XG_SERDES_LOOPBACK
,
337 NETXEN_NIU_XG_DO_BYTE_ALIGN
,
338 NETXEN_NIU_XG_TX_ENABLE
,
339 NETXEN_NIU_XG_RX_ENABLE
,
340 NETXEN_NIU_XG_STATUS
,
341 NETXEN_NIU_XG_PAUSE_THRESHOLD
,
342 NETXEN_NIU_XGE_CONFIG_0
,
343 NETXEN_NIU_XGE_CONFIG_1
,
345 NETXEN_NIU_XGE_STATION_ADDR_0_HI
,
346 NETXEN_NIU_XGE_STATION_ADDR_0_1
,
347 NETXEN_NIU_XGE_STATION_ADDR_1_LO
,
348 NETXEN_NIU_XGE_STATUS
,
349 NETXEN_NIU_XGE_MAX_FRAME_SIZE
,
350 NETXEN_NIU_XGE_PAUSE_FRAME_VALUE
,
351 NETXEN_NIU_XGE_TX_BYTE_CNT
,
352 NETXEN_NIU_XGE_TX_FRAME_CNT
,
353 NETXEN_NIU_XGE_RX_BYTE_CNT
,
354 NETXEN_NIU_XGE_RX_FRAME_CNT
,
355 NETXEN_NIU_XGE_AGGR_ERROR_CNT
,
356 NETXEN_NIU_XGE_MULTICAST_FRAME_CNT
,
357 NETXEN_NIU_XGE_UNICAST_FRAME_CNT
,
358 NETXEN_NIU_XGE_CRC_ERROR_CNT
,
359 NETXEN_NIU_XGE_OVERSIZE_FRAME_ERR
,
360 NETXEN_NIU_XGE_UNDERSIZE_FRAME_ERR
,
361 NETXEN_NIU_XGE_LOCAL_ERROR_CNT
,
362 NETXEN_NIU_XGE_REMOTE_ERROR_CNT
,
363 NETXEN_NIU_XGE_CONTROL_CHAR_CNT
,
364 NETXEN_NIU_XGE_PAUSE_FRAME_CNT
,
371 netxen_nic_get_regs(struct net_device
*dev
, struct ethtool_regs
*regs
, void *p
)
373 struct netxen_port
*port
= netdev_priv(dev
);
374 struct netxen_adapter
*adapter
= port
->adapter
;
375 __u32 mode
, *regs_buff
= p
;
379 memset(p
, 0, NETXEN_NIC_REGS_LEN
);
380 regs
->version
= (1 << 24) | (adapter
->ahw
.revision_id
<< 16) |
381 (port
->pdev
)->device
;
383 NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_MODE
, ®s_buff
[0]);
386 /* Common registers to all the modes */
387 NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_STRAP_VALUE_SAVE_HIGHER
,
390 mode
= (mode
/ 2) - 1;
393 for (i
= 3; niu_registers
[mode
].reg
[i
- 3] != -1; i
++) {
394 /* GB: port specific registers */
395 if (mode
== 0 && i
>= 19)
396 window
= port
->portnum
* NETXEN_NIC_PORT_WINDOW
;
398 NETXEN_NIC_LOCKED_READ_REG(niu_registers
[mode
].
407 netxen_nic_get_wol(struct net_device
*dev
, struct ethtool_wolinfo
*wol
)
409 wol
->supported
= WAKE_UCAST
| WAKE_MCAST
| WAKE_BCAST
| WAKE_MAGIC
;
410 /* options can be added depending upon the mode */
414 static u32
netxen_nic_get_link(struct net_device
*dev
)
416 struct netxen_port
*port
= netdev_priv(dev
);
417 struct netxen_adapter
*adapter
= port
->adapter
;
420 /* read which mode */
421 if (adapter
->ahw
.board_type
== NETXEN_NIC_GBE
) {
422 if (adapter
->phy_read
423 && adapter
->phy_read(adapter
, port
->portnum
,
424 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS
,
428 return (netxen_get_phy_link(status
));
429 } else if (adapter
->ahw
.board_type
== NETXEN_NIC_XGBE
) {
430 int val
= readl(NETXEN_CRB_NORMALIZE(adapter
, CRB_XG_STATE
));
431 return val
== XG_LINK_UP
;
437 netxen_nic_get_eeprom(struct net_device
*dev
, struct ethtool_eeprom
*eeprom
,
440 struct netxen_port
*port
= netdev_priv(dev
);
441 struct netxen_adapter
*adapter
= port
->adapter
;
444 if (eeprom
->len
== 0)
447 eeprom
->magic
= (port
->pdev
)->vendor
| ((port
->pdev
)->device
<< 16);
448 for (offset
= 0; offset
< eeprom
->len
; offset
++)
449 if (netxen_rom_fast_read
450 (adapter
, (8 * offset
) + 8, (int *)eeprom
->data
) == -1)
456 netxen_nic_get_ringparam(struct net_device
*dev
, struct ethtool_ringparam
*ring
)
458 struct netxen_port
*port
= netdev_priv(dev
);
459 struct netxen_adapter
*adapter
= port
->adapter
;
462 ring
->rx_pending
= 0;
463 ring
->rx_jumbo_pending
= 0;
464 for (i
= 0; i
< MAX_RCV_CTX
; ++i
) {
465 ring
->rx_pending
+= adapter
->recv_ctx
[i
].
466 rcv_desc
[RCV_DESC_NORMAL_CTXID
].rcv_pending
;
467 ring
->rx_jumbo_pending
+= adapter
->recv_ctx
[i
].
468 rcv_desc
[RCV_DESC_JUMBO_CTXID
].rcv_pending
;
471 ring
->rx_max_pending
= adapter
->max_rx_desc_count
;
472 ring
->tx_max_pending
= adapter
->max_tx_desc_count
;
473 ring
->rx_jumbo_max_pending
= adapter
->max_jumbo_rx_desc_count
;
474 ring
->rx_mini_max_pending
= 0;
475 ring
->rx_mini_pending
= 0;
476 ring
->rx_jumbo_pending
= 0;
480 netxen_nic_get_pauseparam(struct net_device
*dev
,
481 struct ethtool_pauseparam
*pause
)
483 struct netxen_port
*port
= netdev_priv(dev
);
484 struct netxen_adapter
*adapter
= port
->adapter
;
487 if (adapter
->ahw
.board_type
== NETXEN_NIC_GBE
) {
488 /* get flow control settings */
489 netxen_nic_read_w0(adapter
,
490 NETXEN_NIU_GB_MAC_CONFIG_0(port
->portnum
),
492 pause
->rx_pause
= netxen_gb_get_rx_flowctl(val
);
493 pause
->tx_pause
= netxen_gb_get_tx_flowctl(val
);
494 /* get autoneg settings */
495 pause
->autoneg
= port
->link_autoneg
;
500 netxen_nic_set_pauseparam(struct net_device
*dev
,
501 struct ethtool_pauseparam
*pause
)
503 struct netxen_port
*port
= netdev_priv(dev
);
504 struct netxen_adapter
*adapter
= port
->adapter
;
506 unsigned int autoneg
;
509 if (adapter
->ahw
.board_type
== NETXEN_NIC_GBE
) {
510 /* set flow control */
511 netxen_nic_read_w0(adapter
,
512 NETXEN_NIU_GB_MAC_CONFIG_0(port
->portnum
),
515 netxen_gb_tx_flowctl(val
);
517 netxen_gb_unset_tx_flowctl(val
);
519 netxen_gb_rx_flowctl(val
);
521 netxen_gb_unset_rx_flowctl(val
);
523 netxen_nic_write_w0(adapter
,
524 NETXEN_NIU_GB_MAC_CONFIG_0(port
->portnum
),
527 autoneg
= pause
->autoneg
;
528 if (adapter
->phy_write
529 && adapter
->phy_write(adapter
, port
->portnum
,
530 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG
,
534 port
->link_autoneg
= pause
->autoneg
;
541 static int netxen_nic_reg_test(struct net_device
*dev
)
543 struct netxen_port
*port
= netdev_priv(dev
);
544 struct netxen_adapter
*adapter
= port
->adapter
;
545 u32 data_read
, data_written
, save
;
549 * first test the "Read Only" registers by writing which mode
551 netxen_nic_read_w0(adapter
, NETXEN_NIU_MODE
, &mode
);
552 if (netxen_get_niu_enable_ge(mode
)) { /* GB Mode */
553 netxen_nic_read_w0(adapter
,
554 NETXEN_NIU_GB_MII_MGMT_STATUS(port
->portnum
),
559 data_written
= data_read
& NETXEN_NIC_INVALID_DATA
;
561 data_written
= NETXEN_NIC_INVALID_DATA
;
562 netxen_nic_write_w0(adapter
,
563 NETXEN_NIU_GB_MII_MGMT_STATUS(port
->
566 netxen_nic_read_w0(adapter
,
567 NETXEN_NIU_GB_MII_MGMT_STATUS(port
->portnum
),
570 if (data_written
== data_read
) {
571 netxen_nic_write_w0(adapter
,
572 NETXEN_NIU_GB_MII_MGMT_STATUS(port
->
579 /* netxen_niu_gb_mii_mgmt_indicators is read only */
580 netxen_nic_read_w0(adapter
,
581 NETXEN_NIU_GB_MII_MGMT_INDICATE(port
->
587 data_written
= data_read
& NETXEN_NIC_INVALID_DATA
;
589 data_written
= NETXEN_NIC_INVALID_DATA
;
590 netxen_nic_write_w0(adapter
,
591 NETXEN_NIU_GB_MII_MGMT_INDICATE(port
->
595 netxen_nic_read_w0(adapter
,
596 NETXEN_NIU_GB_MII_MGMT_INDICATE(port
->
600 if (data_written
== data_read
) {
601 netxen_nic_write_w0(adapter
,
602 NETXEN_NIU_GB_MII_MGMT_INDICATE
603 (port
->portnum
), save
);
607 /* netxen_niu_gb_interface_status is read only */
608 netxen_nic_read_w0(adapter
,
609 NETXEN_NIU_GB_INTERFACE_STATUS(port
->
615 data_written
= data_read
& NETXEN_NIC_INVALID_DATA
;
617 data_written
= NETXEN_NIC_INVALID_DATA
;
618 netxen_nic_write_w0(adapter
,
619 NETXEN_NIU_GB_INTERFACE_STATUS(port
->
623 netxen_nic_read_w0(adapter
,
624 NETXEN_NIU_GB_INTERFACE_STATUS(port
->
628 if (data_written
== data_read
) {
629 netxen_nic_write_w0(adapter
,
630 NETXEN_NIU_GB_INTERFACE_STATUS
631 (port
->portnum
), save
);
639 static int netxen_nic_diag_test_count(struct net_device
*dev
)
641 return NETXEN_NIC_TEST_LEN
;
645 netxen_nic_diag_test(struct net_device
*dev
, struct ethtool_test
*eth_test
,
648 if (eth_test
->flags
== ETH_TEST_FL_OFFLINE
) { /* offline tests */
650 if (!(data
[4] = (u64
) netxen_nic_get_link(dev
)))
651 eth_test
->flags
|= ETH_TEST_FL_FAILED
;
653 if (netif_running(dev
))
657 if (!(data
[0] = netxen_nic_reg_test(dev
)))
658 eth_test
->flags
|= ETH_TEST_FL_FAILED
;
659 /* other tests pass as of now */
660 data
[1] = data
[2] = data
[3] = 1;
661 if (netif_running(dev
))
663 } else { /* online tests */
665 if (!(data
[4] = (u64
) netxen_nic_get_link(dev
)))
666 eth_test
->flags
|= ETH_TEST_FL_FAILED
;
668 /* other tests pass by default */
669 data
[0] = data
[1] = data
[2] = data
[3] = 1;
674 netxen_nic_get_strings(struct net_device
*dev
, u32 stringset
, u8
* data
)
680 memcpy(data
, *netxen_nic_gstrings_test
,
681 NETXEN_NIC_TEST_LEN
* ETH_GSTRING_LEN
);
684 for (index
= 0; index
< NETXEN_NIC_STATS_LEN
; index
++) {
685 memcpy(data
+ index
* ETH_GSTRING_LEN
,
686 netxen_nic_gstrings_stats
[index
].stat_string
,
693 static int netxen_nic_get_stats_count(struct net_device
*dev
)
695 return NETXEN_NIC_STATS_LEN
;
699 netxen_nic_get_ethtool_stats(struct net_device
*dev
,
700 struct ethtool_stats
*stats
, u64
* data
)
702 struct netxen_port
*port
= netdev_priv(dev
);
705 for (index
= 0; index
< NETXEN_NIC_STATS_LEN
; index
++) {
707 (char *)port
+ netxen_nic_gstrings_stats
[index
].stat_offset
;
709 (netxen_nic_gstrings_stats
[index
].sizeof_stat
==
710 sizeof(u64
)) ? *(u64
*) p
: *(u32
*) p
;
714 struct ethtool_ops netxen_nic_ethtool_ops
= {
715 .get_settings
= netxen_nic_get_settings
,
716 .set_settings
= netxen_nic_set_settings
,
717 .get_drvinfo
= netxen_nic_get_drvinfo
,
718 .get_regs_len
= netxen_nic_get_regs_len
,
719 .get_regs
= netxen_nic_get_regs
,
720 .get_wol
= netxen_nic_get_wol
,
721 .get_link
= netxen_nic_get_link
,
722 .get_eeprom_len
= netxen_nic_get_eeprom_len
,
723 .get_eeprom
= netxen_nic_get_eeprom
,
724 .get_ringparam
= netxen_nic_get_ringparam
,
725 .get_pauseparam
= netxen_nic_get_pauseparam
,
726 .set_pauseparam
= netxen_nic_set_pauseparam
,
727 .get_tx_csum
= ethtool_op_get_tx_csum
,
728 .set_tx_csum
= ethtool_op_set_tx_csum
,
729 .get_sg
= ethtool_op_get_sg
,
730 .set_sg
= ethtool_op_set_sg
,
731 .get_tso
= ethtool_op_get_tso
,
732 .set_tso
= ethtool_op_set_tso
,
733 .self_test_count
= netxen_nic_diag_test_count
,
734 .self_test
= netxen_nic_diag_test
,
735 .get_strings
= netxen_nic_get_strings
,
736 .get_stats_count
= netxen_nic_get_stats_count
,
737 .get_ethtool_stats
= netxen_nic_get_ethtool_stats
,
738 .get_perm_addr
= ethtool_op_get_perm_addr
,