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 <linux/delay.h>
36 #include <asm/uaccess.h>
37 #include <linux/pci.h>
39 #include <linux/netdevice.h>
40 #include <linux/ethtool.h>
41 #include <linux/version.h>
43 #include "netxen_nic.h"
44 #include "netxen_nic_hw.h"
45 #include "netxen_nic_phan_reg.h"
47 struct netxen_nic_stats
{
48 char stat_string
[ETH_GSTRING_LEN
];
53 #define NETXEN_NIC_STAT(m) sizeof(((struct netxen_adapter *)0)->m), \
54 offsetof(struct netxen_adapter, m)
56 #define NETXEN_NIC_PORT_WINDOW 0x10000
57 #define NETXEN_NIC_INVALID_DATA 0xDEADBEEF
59 static const struct netxen_nic_stats netxen_nic_gstrings_stats
[] = {
60 {"rcvd_bad_skb", NETXEN_NIC_STAT(stats
.rcvdbadskb
)},
61 {"xmit_called", NETXEN_NIC_STAT(stats
.xmitcalled
)},
62 {"xmited_frames", NETXEN_NIC_STAT(stats
.xmitedframes
)},
63 {"xmit_finished", NETXEN_NIC_STAT(stats
.xmitfinished
)},
64 {"bad_skb_len", NETXEN_NIC_STAT(stats
.badskblen
)},
65 {"no_cmd_desc", NETXEN_NIC_STAT(stats
.nocmddescriptor
)},
66 {"polled", NETXEN_NIC_STAT(stats
.polled
)},
67 {"tx_dropped", NETXEN_NIC_STAT(stats
.txdropped
)},
68 {"csummed", NETXEN_NIC_STAT(stats
.csummed
)},
69 {"no_rcv", NETXEN_NIC_STAT(stats
.no_rcv
)},
70 {"rx_bytes", NETXEN_NIC_STAT(stats
.rxbytes
)},
71 {"tx_bytes", NETXEN_NIC_STAT(stats
.txbytes
)},
74 #define NETXEN_NIC_STATS_LEN ARRAY_SIZE(netxen_nic_gstrings_stats)
76 static const char netxen_nic_gstrings_test
[][ETH_GSTRING_LEN
] = {
77 "Register_Test_on_offline",
78 "Link_Test_on_offline"
81 #define NETXEN_NIC_TEST_LEN ARRAY_SIZE(netxen_nic_gstrings_test)
83 #define NETXEN_NIC_REGS_COUNT 42
84 #define NETXEN_NIC_REGS_LEN (NETXEN_NIC_REGS_COUNT * sizeof(__le32))
85 #define NETXEN_MAX_EEPROM_LEN 1024
87 static int netxen_nic_get_eeprom_len(struct net_device
*dev
)
89 return NETXEN_FLASH_TOTAL_SIZE
;
93 netxen_nic_get_drvinfo(struct net_device
*dev
, struct ethtool_drvinfo
*drvinfo
)
95 struct netxen_adapter
*adapter
= netdev_priv(dev
);
100 strncpy(drvinfo
->driver
, netxen_nic_driver_name
, 32);
101 strncpy(drvinfo
->version
, NETXEN_NIC_LINUX_VERSIONID
, 32);
102 fw_major
= readl(NETXEN_CRB_NORMALIZE(adapter
,
103 NETXEN_FW_VERSION_MAJOR
));
104 fw_minor
= readl(NETXEN_CRB_NORMALIZE(adapter
,
105 NETXEN_FW_VERSION_MINOR
));
106 fw_build
= readl(NETXEN_CRB_NORMALIZE(adapter
, NETXEN_FW_VERSION_SUB
));
107 sprintf(drvinfo
->fw_version
, "%d.%d.%d", fw_major
, fw_minor
, fw_build
);
109 strncpy(drvinfo
->bus_info
, pci_name(adapter
->pdev
), 32);
110 drvinfo
->regdump_len
= NETXEN_NIC_REGS_LEN
;
111 drvinfo
->eedump_len
= netxen_nic_get_eeprom_len(dev
);
115 netxen_nic_get_settings(struct net_device
*dev
, struct ethtool_cmd
*ecmd
)
117 struct netxen_adapter
*adapter
= netdev_priv(dev
);
118 struct netxen_board_info
*boardinfo
= &adapter
->ahw
.boardcfg
;
120 /* read which mode */
121 if (adapter
->ahw
.board_type
== NETXEN_NIC_GBE
) {
122 ecmd
->supported
= (SUPPORTED_10baseT_Half
|
123 SUPPORTED_10baseT_Full
|
124 SUPPORTED_100baseT_Half
|
125 SUPPORTED_100baseT_Full
|
126 SUPPORTED_1000baseT_Half
|
127 SUPPORTED_1000baseT_Full
);
129 ecmd
->advertising
= (ADVERTISED_100baseT_Half
|
130 ADVERTISED_100baseT_Full
|
131 ADVERTISED_1000baseT_Half
|
132 ADVERTISED_1000baseT_Full
);
134 ecmd
->port
= PORT_TP
;
136 if (netif_running(dev
)) {
137 ecmd
->speed
= adapter
->link_speed
;
138 ecmd
->duplex
= adapter
->link_duplex
;
140 return -EIO
; /* link absent */
141 } else if (adapter
->ahw
.board_type
== NETXEN_NIC_XGBE
) {
142 ecmd
->supported
= (SUPPORTED_TP
|
143 SUPPORTED_1000baseT_Full
|
144 SUPPORTED_10000baseT_Full
);
145 ecmd
->advertising
= (ADVERTISED_TP
|
146 ADVERTISED_1000baseT_Full
|
147 ADVERTISED_10000baseT_Full
);
148 ecmd
->port
= PORT_TP
;
150 ecmd
->speed
= SPEED_10000
;
151 ecmd
->duplex
= DUPLEX_FULL
;
152 ecmd
->autoneg
= AUTONEG_DISABLE
;
156 ecmd
->phy_address
= adapter
->portnum
;
157 ecmd
->transceiver
= XCVR_EXTERNAL
;
159 switch ((netxen_brdtype_t
) boardinfo
->board_type
) {
160 case NETXEN_BRDTYPE_P2_SB35_4G
:
161 case NETXEN_BRDTYPE_P2_SB31_2G
:
162 ecmd
->supported
|= SUPPORTED_Autoneg
;
163 ecmd
->advertising
|= ADVERTISED_Autoneg
;
164 case NETXEN_BRDTYPE_P2_SB31_10G_CX4
:
165 ecmd
->supported
|= SUPPORTED_TP
;
166 ecmd
->advertising
|= ADVERTISED_TP
;
167 ecmd
->port
= PORT_TP
;
168 ecmd
->autoneg
= (boardinfo
->board_type
==
169 NETXEN_BRDTYPE_P2_SB31_10G_CX4
) ?
170 (AUTONEG_DISABLE
) : (adapter
->link_autoneg
);
172 case NETXEN_BRDTYPE_P2_SB31_10G_HMEZ
:
173 case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ
:
174 ecmd
->supported
|= SUPPORTED_MII
;
175 ecmd
->advertising
|= ADVERTISED_MII
;
176 ecmd
->port
= PORT_FIBRE
;
177 ecmd
->autoneg
= AUTONEG_DISABLE
;
179 case NETXEN_BRDTYPE_P2_SB31_10G
:
180 ecmd
->supported
|= SUPPORTED_FIBRE
;
181 ecmd
->advertising
|= ADVERTISED_FIBRE
;
182 ecmd
->port
= PORT_FIBRE
;
183 ecmd
->autoneg
= AUTONEG_DISABLE
;
186 printk(KERN_ERR
"netxen-nic: Unsupported board model %d\n",
187 (netxen_brdtype_t
) boardinfo
->board_type
);
195 netxen_nic_set_settings(struct net_device
*dev
, struct ethtool_cmd
*ecmd
)
197 struct netxen_adapter
*adapter
= netdev_priv(dev
);
200 /* read which mode */
201 if (adapter
->ahw
.board_type
== NETXEN_NIC_GBE
) {
202 /* autonegotiation */
203 if (adapter
->phy_write
204 && adapter
->phy_write(adapter
,
205 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG
,
209 adapter
->link_autoneg
= ecmd
->autoneg
;
211 if (adapter
->phy_read
212 && adapter
->phy_read(adapter
,
213 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS
,
218 switch (ecmd
->speed
) {
220 netxen_set_phy_speed(status
, 0);
223 netxen_set_phy_speed(status
, 1);
226 netxen_set_phy_speed(status
, 2);
229 /* set duplex mode */
230 if (ecmd
->duplex
== DUPLEX_HALF
)
231 netxen_clear_phy_duplex(status
);
232 if (ecmd
->duplex
== DUPLEX_FULL
)
233 netxen_set_phy_duplex(status
);
234 if (adapter
->phy_write
235 && adapter
->phy_write(adapter
,
236 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS
,
237 *((int *)&status
)) != 0)
240 adapter
->link_speed
= ecmd
->speed
;
241 adapter
->link_duplex
= ecmd
->duplex
;
246 if (netif_running(dev
)) {
253 static int netxen_nic_get_regs_len(struct net_device
*dev
)
255 return NETXEN_NIC_REGS_LEN
;
258 struct netxen_niu_regs
{
259 __u32 reg
[NETXEN_NIC_REGS_COUNT
];
262 static struct netxen_niu_regs niu_registers
[] = {
266 NETXEN_NIU_GB_SERDES_RESET
,
267 NETXEN_NIU_GB0_MII_MODE
,
268 NETXEN_NIU_GB1_MII_MODE
,
269 NETXEN_NIU_GB2_MII_MODE
,
270 NETXEN_NIU_GB3_MII_MODE
,
271 NETXEN_NIU_GB0_GMII_MODE
,
272 NETXEN_NIU_GB1_GMII_MODE
,
273 NETXEN_NIU_GB2_GMII_MODE
,
274 NETXEN_NIU_GB3_GMII_MODE
,
275 NETXEN_NIU_REMOTE_LOOPBACK
,
276 NETXEN_NIU_GB0_HALF_DUPLEX
,
277 NETXEN_NIU_GB1_HALF_DUPLEX
,
278 NETXEN_NIU_RESET_SYS_FIFOS
,
279 NETXEN_NIU_GB_CRC_DROP
,
280 NETXEN_NIU_GB_DROP_WRONGADDR
,
281 NETXEN_NIU_TEST_MUX_CTL
,
283 NETXEN_NIU_GB_MAC_CONFIG_0(0),
284 NETXEN_NIU_GB_MAC_CONFIG_1(0),
285 NETXEN_NIU_GB_HALF_DUPLEX_CTRL(0),
286 NETXEN_NIU_GB_MAX_FRAME_SIZE(0),
287 NETXEN_NIU_GB_TEST_REG(0),
288 NETXEN_NIU_GB_MII_MGMT_CONFIG(0),
289 NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
290 NETXEN_NIU_GB_MII_MGMT_ADDR(0),
291 NETXEN_NIU_GB_MII_MGMT_CTRL(0),
292 NETXEN_NIU_GB_MII_MGMT_STATUS(0),
293 NETXEN_NIU_GB_MII_MGMT_INDICATE(0),
294 NETXEN_NIU_GB_INTERFACE_CTRL(0),
295 NETXEN_NIU_GB_INTERFACE_STATUS(0),
296 NETXEN_NIU_GB_STATION_ADDR_0(0),
297 NETXEN_NIU_GB_STATION_ADDR_1(0),
304 NETXEN_NIU_XG_SINGLE_TERM
,
305 NETXEN_NIU_XG_DRIVE_HI
,
306 NETXEN_NIU_XG_DRIVE_LO
,
309 NETXEN_NIU_XG_WORD_ALIGN
,
311 NETXEN_NIU_XG_POWER_DOWN
,
312 NETXEN_NIU_XG_RESET_PLL
,
313 NETXEN_NIU_XG_SERDES_LOOPBACK
,
314 NETXEN_NIU_XG_DO_BYTE_ALIGN
,
315 NETXEN_NIU_XG_TX_ENABLE
,
316 NETXEN_NIU_XG_RX_ENABLE
,
317 NETXEN_NIU_XG_STATUS
,
318 NETXEN_NIU_XG_PAUSE_THRESHOLD
,
319 NETXEN_NIU_XGE_CONFIG_0
,
320 NETXEN_NIU_XGE_CONFIG_1
,
322 NETXEN_NIU_XGE_STATION_ADDR_0_HI
,
323 NETXEN_NIU_XGE_STATION_ADDR_0_1
,
324 NETXEN_NIU_XGE_STATION_ADDR_1_LO
,
325 NETXEN_NIU_XGE_STATUS
,
326 NETXEN_NIU_XGE_MAX_FRAME_SIZE
,
327 NETXEN_NIU_XGE_PAUSE_FRAME_VALUE
,
328 NETXEN_NIU_XGE_TX_BYTE_CNT
,
329 NETXEN_NIU_XGE_TX_FRAME_CNT
,
330 NETXEN_NIU_XGE_RX_BYTE_CNT
,
331 NETXEN_NIU_XGE_RX_FRAME_CNT
,
332 NETXEN_NIU_XGE_AGGR_ERROR_CNT
,
333 NETXEN_NIU_XGE_MULTICAST_FRAME_CNT
,
334 NETXEN_NIU_XGE_UNICAST_FRAME_CNT
,
335 NETXEN_NIU_XGE_CRC_ERROR_CNT
,
336 NETXEN_NIU_XGE_OVERSIZE_FRAME_ERR
,
337 NETXEN_NIU_XGE_UNDERSIZE_FRAME_ERR
,
338 NETXEN_NIU_XGE_LOCAL_ERROR_CNT
,
339 NETXEN_NIU_XGE_REMOTE_ERROR_CNT
,
340 NETXEN_NIU_XGE_CONTROL_CHAR_CNT
,
341 NETXEN_NIU_XGE_PAUSE_FRAME_CNT
,
348 netxen_nic_get_regs(struct net_device
*dev
, struct ethtool_regs
*regs
, void *p
)
350 struct netxen_adapter
*adapter
= netdev_priv(dev
);
351 __u32 mode
, *regs_buff
= p
;
355 memset(p
, 0, NETXEN_NIC_REGS_LEN
);
356 regs
->version
= (1 << 24) | (adapter
->ahw
.revision_id
<< 16) |
357 (adapter
->pdev
)->device
;
359 NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_MODE
, ®s_buff
[0]);
362 /* Common registers to all the modes */
363 NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_STRAP_VALUE_SAVE_HIGHER
,
366 mode
= (mode
/ 2) - 1;
369 for (i
= 3; niu_registers
[mode
].reg
[i
- 3] != -1; i
++) {
370 /* GB: port specific registers */
371 if (mode
== 0 && i
>= 19)
372 window
= adapter
->physical_port
*
373 NETXEN_NIC_PORT_WINDOW
;
375 NETXEN_NIC_LOCKED_READ_REG(niu_registers
[mode
].
383 static u32
netxen_nic_test_link(struct net_device
*dev
)
385 struct netxen_adapter
*adapter
= netdev_priv(dev
);
389 /* read which mode */
390 if (adapter
->ahw
.board_type
== NETXEN_NIC_GBE
) {
391 if (adapter
->phy_read
392 && adapter
->phy_read(adapter
,
393 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS
,
397 val
= netxen_get_phy_link(status
);
400 } else if (adapter
->ahw
.board_type
== NETXEN_NIC_XGBE
) {
401 val
= readl(NETXEN_CRB_NORMALIZE(adapter
, CRB_XG_STATE
));
402 return (val
== XG_LINK_UP
) ? 0 : 1;
408 netxen_nic_get_eeprom(struct net_device
*dev
, struct ethtool_eeprom
*eeprom
,
411 struct netxen_adapter
*adapter
= netdev_priv(dev
);
415 if (eeprom
->len
== 0)
418 eeprom
->magic
= (adapter
->pdev
)->vendor
|
419 ((adapter
->pdev
)->device
<< 16);
420 offset
= eeprom
->offset
;
422 ret
= netxen_rom_fast_read_words(adapter
, offset
, bytes
,
431 netxen_nic_set_eeprom(struct net_device
*dev
, struct ethtool_eeprom
*eeprom
,
434 struct netxen_adapter
*adapter
= netdev_priv(dev
);
435 int offset
= eeprom
->offset
;
436 static int flash_start
;
437 static int ready_to_flash
;
440 if (flash_start
== 0) {
441 netxen_halt_pegs(adapter
);
442 ret
= netxen_flash_unlock(adapter
);
444 printk(KERN_ERR
"%s: Flash unlock failed.\n",
445 netxen_nic_driver_name
);
448 printk(KERN_INFO
"%s: flash unlocked. \n",
449 netxen_nic_driver_name
);
450 last_schedule_time
= jiffies
;
451 ret
= netxen_flash_erase_secondary(adapter
);
452 if (ret
!= FLASH_SUCCESS
) {
453 printk(KERN_ERR
"%s: Flash erase failed.\n",
454 netxen_nic_driver_name
);
457 printk(KERN_INFO
"%s: secondary flash erased successfully.\n",
458 netxen_nic_driver_name
);
463 if (offset
== NETXEN_BOOTLD_START
) {
464 ret
= netxen_flash_erase_primary(adapter
);
465 if (ret
!= FLASH_SUCCESS
) {
466 printk(KERN_ERR
"%s: Flash erase failed.\n",
467 netxen_nic_driver_name
);
471 ret
= netxen_rom_se(adapter
, NETXEN_USER_START
);
472 if (ret
!= FLASH_SUCCESS
)
474 ret
= netxen_rom_se(adapter
, NETXEN_FIXED_START
);
475 if (ret
!= FLASH_SUCCESS
)
478 printk(KERN_INFO
"%s: primary flash erased successfully\n",
479 netxen_nic_driver_name
);
481 ret
= netxen_backup_crbinit(adapter
);
482 if (ret
!= FLASH_SUCCESS
) {
483 printk(KERN_ERR
"%s: CRBinit backup failed.\n",
484 netxen_nic_driver_name
);
487 printk(KERN_INFO
"%s: CRBinit backup done.\n",
488 netxen_nic_driver_name
);
492 if (!ready_to_flash
) {
493 printk(KERN_ERR
"%s: Invalid write sequence, returning...\n",
494 netxen_nic_driver_name
);
498 return netxen_rom_fast_write_words(adapter
, offset
, bytes
, eeprom
->len
);
502 netxen_nic_get_ringparam(struct net_device
*dev
, struct ethtool_ringparam
*ring
)
504 struct netxen_adapter
*adapter
= netdev_priv(dev
);
507 ring
->rx_pending
= 0;
508 ring
->rx_jumbo_pending
= 0;
509 for (i
= 0; i
< MAX_RCV_CTX
; ++i
) {
510 ring
->rx_pending
+= adapter
->recv_ctx
[i
].
511 rcv_desc
[RCV_DESC_NORMAL_CTXID
].max_rx_desc_count
;
512 ring
->rx_jumbo_pending
+= adapter
->recv_ctx
[i
].
513 rcv_desc
[RCV_DESC_JUMBO_CTXID
].max_rx_desc_count
;
515 ring
->tx_pending
= adapter
->max_tx_desc_count
;
517 ring
->rx_max_pending
= MAX_RCV_DESCRIPTORS
;
518 ring
->tx_max_pending
= MAX_CMD_DESCRIPTORS_HOST
;
519 ring
->rx_jumbo_max_pending
= MAX_JUMBO_RCV_DESCRIPTORS
;
520 ring
->rx_mini_max_pending
= 0;
521 ring
->rx_mini_pending
= 0;
525 netxen_nic_get_pauseparam(struct net_device
*dev
,
526 struct ethtool_pauseparam
*pause
)
528 struct netxen_adapter
*adapter
= netdev_priv(dev
);
530 int port
= adapter
->physical_port
;
532 if (adapter
->ahw
.board_type
== NETXEN_NIC_GBE
) {
533 if ((port
< 0) || (port
> NETXEN_NIU_MAX_GBE_PORTS
))
535 /* get flow control settings */
536 netxen_nic_read_w0(adapter
,NETXEN_NIU_GB_MAC_CONFIG_0(port
),
538 pause
->rx_pause
= netxen_gb_get_rx_flowctl(val
);
539 netxen_nic_read_w0(adapter
, NETXEN_NIU_GB_PAUSE_CTL
, &val
);
542 pause
->tx_pause
= !(netxen_gb_get_gb0_mask(val
));
545 pause
->tx_pause
= !(netxen_gb_get_gb1_mask(val
));
548 pause
->tx_pause
= !(netxen_gb_get_gb2_mask(val
));
552 pause
->tx_pause
= !(netxen_gb_get_gb3_mask(val
));
555 } else if (adapter
->ahw
.board_type
== NETXEN_NIC_XGBE
) {
556 if ((port
< 0) || (port
> NETXEN_NIU_MAX_XG_PORTS
))
559 netxen_nic_read_w0(adapter
, NETXEN_NIU_XG_PAUSE_CTL
, &val
);
561 pause
->tx_pause
= !(netxen_xg_get_xg0_mask(val
));
563 pause
->tx_pause
= !(netxen_xg_get_xg1_mask(val
));
565 printk(KERN_ERR
"%s: Unknown board type: %x\n",
566 netxen_nic_driver_name
, adapter
->ahw
.board_type
);
571 netxen_nic_set_pauseparam(struct net_device
*dev
,
572 struct ethtool_pauseparam
*pause
)
574 struct netxen_adapter
*adapter
= netdev_priv(dev
);
576 int port
= adapter
->physical_port
;
578 if (adapter
->ahw
.board_type
== NETXEN_NIC_GBE
) {
579 if ((port
< 0) || (port
> NETXEN_NIU_MAX_GBE_PORTS
))
581 /* set flow control */
582 netxen_nic_read_w0(adapter
,
583 NETXEN_NIU_GB_MAC_CONFIG_0(port
), &val
);
586 netxen_gb_rx_flowctl(val
);
588 netxen_gb_unset_rx_flowctl(val
);
590 netxen_nic_write_w0(adapter
, NETXEN_NIU_GB_MAC_CONFIG_0(port
),
593 netxen_nic_read_w0(adapter
, NETXEN_NIU_GB_PAUSE_CTL
, &val
);
597 netxen_gb_unset_gb0_mask(val
);
599 netxen_gb_set_gb0_mask(val
);
603 netxen_gb_unset_gb1_mask(val
);
605 netxen_gb_set_gb1_mask(val
);
609 netxen_gb_unset_gb2_mask(val
);
611 netxen_gb_set_gb2_mask(val
);
616 netxen_gb_unset_gb3_mask(val
);
618 netxen_gb_set_gb3_mask(val
);
621 netxen_nic_write_w0(adapter
, NETXEN_NIU_GB_PAUSE_CTL
, val
);
622 } else if (adapter
->ahw
.board_type
== NETXEN_NIC_XGBE
) {
623 if ((port
< 0) || (port
> NETXEN_NIU_MAX_XG_PORTS
))
625 netxen_nic_read_w0(adapter
, NETXEN_NIU_XG_PAUSE_CTL
, &val
);
628 netxen_xg_unset_xg0_mask(val
);
630 netxen_xg_set_xg0_mask(val
);
633 netxen_xg_unset_xg1_mask(val
);
635 netxen_xg_set_xg1_mask(val
);
637 netxen_nic_write_w0(adapter
, NETXEN_NIU_XG_PAUSE_CTL
, val
);
639 printk(KERN_ERR
"%s: Unknown board type: %x\n",
640 netxen_nic_driver_name
,
641 adapter
->ahw
.board_type
);
646 static int netxen_nic_reg_test(struct net_device
*dev
)
648 struct netxen_adapter
*adapter
= netdev_priv(dev
);
649 u32 data_read
, data_written
;
651 netxen_nic_read_w0(adapter
, NETXEN_PCIX_PH_REG(0), &data_read
);
652 if ((data_read
& 0xffff) != PHAN_VENDOR_ID
)
655 data_written
= (u32
)0xa5a5a5a5;
657 netxen_nic_reg_write(adapter
, CRB_SCRATCHPAD_TEST
, data_written
);
658 data_read
= readl(NETXEN_CRB_NORMALIZE(adapter
, CRB_SCRATCHPAD_TEST
));
659 if (data_written
!= data_read
)
665 static int netxen_get_sset_count(struct net_device
*dev
, int sset
)
669 return NETXEN_NIC_TEST_LEN
;
671 return NETXEN_NIC_STATS_LEN
;
678 netxen_nic_diag_test(struct net_device
*dev
, struct ethtool_test
*eth_test
,
681 memset(data
, 0, sizeof(uint64_t) * NETXEN_NIC_TEST_LEN
);
682 if ((data
[0] = netxen_nic_reg_test(dev
)))
683 eth_test
->flags
|= ETH_TEST_FL_FAILED
;
685 if ((data
[1] = (u64
) netxen_nic_test_link(dev
)))
686 eth_test
->flags
|= ETH_TEST_FL_FAILED
;
690 netxen_nic_get_strings(struct net_device
*dev
, u32 stringset
, u8
* data
)
696 memcpy(data
, *netxen_nic_gstrings_test
,
697 NETXEN_NIC_TEST_LEN
* ETH_GSTRING_LEN
);
700 for (index
= 0; index
< NETXEN_NIC_STATS_LEN
; index
++) {
701 memcpy(data
+ index
* ETH_GSTRING_LEN
,
702 netxen_nic_gstrings_stats
[index
].stat_string
,
710 netxen_nic_get_ethtool_stats(struct net_device
*dev
,
711 struct ethtool_stats
*stats
, u64
* data
)
713 struct netxen_adapter
*adapter
= netdev_priv(dev
);
716 for (index
= 0; index
< NETXEN_NIC_STATS_LEN
; index
++) {
719 netxen_nic_gstrings_stats
[index
].stat_offset
;
721 (netxen_nic_gstrings_stats
[index
].sizeof_stat
==
722 sizeof(u64
)) ? *(u64
*) p
: *(u32
*) p
;
726 static u32
netxen_nic_get_rx_csum(struct net_device
*dev
)
728 struct netxen_adapter
*adapter
= netdev_priv(dev
);
729 return adapter
->rx_csum
;
732 static int netxen_nic_set_rx_csum(struct net_device
*dev
, u32 data
)
734 struct netxen_adapter
*adapter
= netdev_priv(dev
);
735 adapter
->rx_csum
= !!data
;
739 struct ethtool_ops netxen_nic_ethtool_ops
= {
740 .get_settings
= netxen_nic_get_settings
,
741 .set_settings
= netxen_nic_set_settings
,
742 .get_drvinfo
= netxen_nic_get_drvinfo
,
743 .get_regs_len
= netxen_nic_get_regs_len
,
744 .get_regs
= netxen_nic_get_regs
,
745 .get_link
= ethtool_op_get_link
,
746 .get_eeprom_len
= netxen_nic_get_eeprom_len
,
747 .get_eeprom
= netxen_nic_get_eeprom
,
748 .set_eeprom
= netxen_nic_set_eeprom
,
749 .get_ringparam
= netxen_nic_get_ringparam
,
750 .get_pauseparam
= netxen_nic_get_pauseparam
,
751 .set_pauseparam
= netxen_nic_set_pauseparam
,
752 .set_tx_csum
= ethtool_op_set_tx_csum
,
753 .set_sg
= ethtool_op_set_sg
,
754 .set_tso
= ethtool_op_set_tso
,
755 .self_test
= netxen_nic_diag_test
,
756 .get_strings
= netxen_nic_get_strings
,
757 .get_ethtool_stats
= netxen_nic_get_ethtool_stats
,
758 .get_sset_count
= netxen_get_sset_count
,
759 .get_rx_csum
= netxen_nic_get_rx_csum
,
760 .set_rx_csum
= netxen_nic_set_rx_csum
,