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_hw.h"
44 #include "netxen_nic.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_port *)0)->m), \
54 offsetof(struct netxen_port, 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 {"uphappy", NETXEN_NIC_STAT(stats.uphappy)},
68 {"updropped", NETXEN_NIC_STAT(stats.updropped)},
69 {"uplcong", NETXEN_NIC_STAT(stats.uplcong)},
70 {"uphcong", NETXEN_NIC_STAT(stats.uphcong)},
71 {"upmcong", NETXEN_NIC_STAT(stats.upmcong)},
72 {"updunno", NETXEN_NIC_STAT(stats.updunno)},
73 {"skb_freed", NETXEN_NIC_STAT(stats.skbfreed)},
74 {"tx_dropped", NETXEN_NIC_STAT(stats.txdropped)},
75 {"tx_null_skb", NETXEN_NIC_STAT(stats.txnullskb)},
76 {"csummed", NETXEN_NIC_STAT(stats.csummed)},
77 {"no_rcv", NETXEN_NIC_STAT(stats.no_rcv)},
78 {"rx_bytes", NETXEN_NIC_STAT(stats.rxbytes)},
79 {"tx_bytes", NETXEN_NIC_STAT(stats.txbytes)},
82 #define NETXEN_NIC_STATS_LEN ARRAY_SIZE(netxen_nic_gstrings_stats)
84 static const char netxen_nic_gstrings_test[][ETH_GSTRING_LEN] = {
85 "Register_Test_offline", "EEPROM_Test_offline",
86 "Interrupt_Test_offline", "Loopback_Test_offline",
87 "Link_Test_on_offline"
90 #define NETXEN_NIC_TEST_LEN sizeof(netxen_nic_gstrings_test) / ETH_GSTRING_LEN
92 #define NETXEN_NIC_REGS_COUNT 42
93 #define NETXEN_NIC_REGS_LEN (NETXEN_NIC_REGS_COUNT * sizeof(__le32))
94 #define NETXEN_MAX_EEPROM_LEN 1024
96 static int netxen_nic_get_eeprom_len(struct net_device *dev)
98 return FLASH_TOTAL_SIZE;
102 netxen_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo)
104 struct netxen_port *port = netdev_priv(dev);
105 struct netxen_adapter *adapter = port->adapter;
110 strncpy(drvinfo->driver, netxen_nic_driver_name, 32);
111 strncpy(drvinfo->version, NETXEN_NIC_LINUX_VERSIONID, 32);
112 fw_major = readl(NETXEN_CRB_NORMALIZE(adapter,
113 NETXEN_FW_VERSION_MAJOR));
114 fw_minor = readl(NETXEN_CRB_NORMALIZE(adapter,
115 NETXEN_FW_VERSION_MINOR));
116 fw_build = readl(NETXEN_CRB_NORMALIZE(adapter, NETXEN_FW_VERSION_SUB));
117 sprintf(drvinfo->fw_version, "%d.%d.%d", fw_major, fw_minor, fw_build);
119 strncpy(drvinfo->bus_info, pci_name(port->pdev), 32);
120 drvinfo->n_stats = NETXEN_NIC_STATS_LEN;
121 drvinfo->testinfo_len = NETXEN_NIC_TEST_LEN;
122 drvinfo->regdump_len = NETXEN_NIC_REGS_LEN;
123 drvinfo->eedump_len = netxen_nic_get_eeprom_len(dev);
127 netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
129 struct netxen_port *port = netdev_priv(dev);
130 struct netxen_adapter *adapter = port->adapter;
131 struct netxen_board_info *boardinfo = &adapter->ahw.boardcfg;
133 /* read which mode */
134 if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
135 ecmd->supported = (SUPPORTED_10baseT_Half |
136 SUPPORTED_10baseT_Full |
137 SUPPORTED_100baseT_Half |
138 SUPPORTED_100baseT_Full |
139 SUPPORTED_1000baseT_Half |
140 SUPPORTED_1000baseT_Full);
142 ecmd->advertising = (ADVERTISED_100baseT_Half |
143 ADVERTISED_100baseT_Full |
144 ADVERTISED_1000baseT_Half |
145 ADVERTISED_1000baseT_Full);
147 ecmd->port = PORT_TP;
149 if (netif_running(dev)) {
150 ecmd->speed = port->link_speed;
151 ecmd->duplex = port->link_duplex;
153 return -EIO; /* link absent */
154 } else if (adapter->ahw.board_type == NETXEN_NIC_XGBE) {
155 ecmd->supported = (SUPPORTED_TP |
156 SUPPORTED_1000baseT_Full |
157 SUPPORTED_10000baseT_Full);
158 ecmd->advertising = (ADVERTISED_TP |
159 ADVERTISED_1000baseT_Full |
160 ADVERTISED_10000baseT_Full);
161 ecmd->port = PORT_TP;
163 ecmd->speed = SPEED_10000;
164 ecmd->duplex = DUPLEX_FULL;
165 ecmd->autoneg = AUTONEG_DISABLE;
169 ecmd->phy_address = port->portnum;
170 ecmd->transceiver = XCVR_EXTERNAL;
172 switch ((netxen_brdtype_t) boardinfo->board_type) {
173 case NETXEN_BRDTYPE_P2_SB35_4G:
174 case NETXEN_BRDTYPE_P2_SB31_2G:
175 ecmd->supported |= SUPPORTED_Autoneg;
176 ecmd->advertising |= ADVERTISED_Autoneg;
177 case NETXEN_BRDTYPE_P2_SB31_10G_CX4:
178 ecmd->supported |= SUPPORTED_TP;
179 ecmd->advertising |= ADVERTISED_TP;
180 ecmd->port = PORT_TP;
181 ecmd->autoneg = (boardinfo->board_type ==
182 NETXEN_BRDTYPE_P2_SB31_10G_CX4) ?
183 (AUTONEG_DISABLE) : (port->link_autoneg);
185 case NETXEN_BRDTYPE_P2_SB31_10G_HMEZ:
186 case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ:
187 ecmd->supported |= SUPPORTED_MII;
188 ecmd->advertising |= ADVERTISED_MII;
189 ecmd->port = PORT_FIBRE;
190 ecmd->autoneg = AUTONEG_DISABLE;
192 case NETXEN_BRDTYPE_P2_SB31_10G:
193 ecmd->supported |= SUPPORTED_FIBRE;
194 ecmd->advertising |= ADVERTISED_FIBRE;
195 ecmd->port = PORT_FIBRE;
196 ecmd->autoneg = AUTONEG_DISABLE;
199 printk(KERN_ERR "netxen-nic: Unsupported board model %d\n",
200 (netxen_brdtype_t) boardinfo->board_type);
208 netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
210 struct netxen_port *port = netdev_priv(dev);
211 struct netxen_adapter *adapter = port->adapter;
214 /* read which mode */
215 if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
216 /* autonegotiation */
217 if (adapter->phy_write
218 && adapter->phy_write(adapter, port->portnum,
219 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG,
223 port->link_autoneg = ecmd->autoneg;
225 if (adapter->phy_read
226 && adapter->phy_read(adapter, port->portnum,
227 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
232 switch (ecmd->speed) {
234 netxen_set_phy_speed(status, 0);
237 netxen_set_phy_speed(status, 1);
240 netxen_set_phy_speed(status, 2);
243 /* set duplex mode */
244 if (ecmd->duplex == DUPLEX_HALF)
245 netxen_clear_phy_duplex(status);
246 if (ecmd->duplex == DUPLEX_FULL)
247 netxen_set_phy_duplex(status);
248 if (adapter->phy_write
249 && adapter->phy_write(adapter, port->portnum,
250 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
251 *((int *)&status)) != 0)
254 port->link_speed = ecmd->speed;
255 port->link_duplex = ecmd->duplex;
260 if (netif_running(dev)) {
267 static int netxen_nic_get_regs_len(struct net_device *dev)
269 return NETXEN_NIC_REGS_LEN;
272 struct netxen_niu_regs {
273 __u32 reg[NETXEN_NIC_REGS_COUNT];
276 static struct netxen_niu_regs niu_registers[] = {
280 NETXEN_NIU_GB_SERDES_RESET,
281 NETXEN_NIU_GB0_MII_MODE,
282 NETXEN_NIU_GB1_MII_MODE,
283 NETXEN_NIU_GB2_MII_MODE,
284 NETXEN_NIU_GB3_MII_MODE,
285 NETXEN_NIU_GB0_GMII_MODE,
286 NETXEN_NIU_GB1_GMII_MODE,
287 NETXEN_NIU_GB2_GMII_MODE,
288 NETXEN_NIU_GB3_GMII_MODE,
289 NETXEN_NIU_REMOTE_LOOPBACK,
290 NETXEN_NIU_GB0_HALF_DUPLEX,
291 NETXEN_NIU_GB1_HALF_DUPLEX,
292 NETXEN_NIU_RESET_SYS_FIFOS,
293 NETXEN_NIU_GB_CRC_DROP,
294 NETXEN_NIU_GB_DROP_WRONGADDR,
295 NETXEN_NIU_TEST_MUX_CTL,
297 NETXEN_NIU_GB_MAC_CONFIG_0(0),
298 NETXEN_NIU_GB_MAC_CONFIG_1(0),
299 NETXEN_NIU_GB_HALF_DUPLEX_CTRL(0),
300 NETXEN_NIU_GB_MAX_FRAME_SIZE(0),
301 NETXEN_NIU_GB_TEST_REG(0),
302 NETXEN_NIU_GB_MII_MGMT_CONFIG(0),
303 NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
304 NETXEN_NIU_GB_MII_MGMT_ADDR(0),
305 NETXEN_NIU_GB_MII_MGMT_CTRL(0),
306 NETXEN_NIU_GB_MII_MGMT_STATUS(0),
307 NETXEN_NIU_GB_MII_MGMT_INDICATE(0),
308 NETXEN_NIU_GB_INTERFACE_CTRL(0),
309 NETXEN_NIU_GB_INTERFACE_STATUS(0),
310 NETXEN_NIU_GB_STATION_ADDR_0(0),
311 NETXEN_NIU_GB_STATION_ADDR_1(0),
318 NETXEN_NIU_XG_SINGLE_TERM,
319 NETXEN_NIU_XG_DRIVE_HI,
320 NETXEN_NIU_XG_DRIVE_LO,
323 NETXEN_NIU_XG_WORD_ALIGN,
325 NETXEN_NIU_XG_POWER_DOWN,
326 NETXEN_NIU_XG_RESET_PLL,
327 NETXEN_NIU_XG_SERDES_LOOPBACK,
328 NETXEN_NIU_XG_DO_BYTE_ALIGN,
329 NETXEN_NIU_XG_TX_ENABLE,
330 NETXEN_NIU_XG_RX_ENABLE,
331 NETXEN_NIU_XG_STATUS,
332 NETXEN_NIU_XG_PAUSE_THRESHOLD,
333 NETXEN_NIU_XGE_CONFIG_0,
334 NETXEN_NIU_XGE_CONFIG_1,
336 NETXEN_NIU_XGE_STATION_ADDR_0_HI,
337 NETXEN_NIU_XGE_STATION_ADDR_0_1,
338 NETXEN_NIU_XGE_STATION_ADDR_1_LO,
339 NETXEN_NIU_XGE_STATUS,
340 NETXEN_NIU_XGE_MAX_FRAME_SIZE,
341 NETXEN_NIU_XGE_PAUSE_FRAME_VALUE,
342 NETXEN_NIU_XGE_TX_BYTE_CNT,
343 NETXEN_NIU_XGE_TX_FRAME_CNT,
344 NETXEN_NIU_XGE_RX_BYTE_CNT,
345 NETXEN_NIU_XGE_RX_FRAME_CNT,
346 NETXEN_NIU_XGE_AGGR_ERROR_CNT,
347 NETXEN_NIU_XGE_MULTICAST_FRAME_CNT,
348 NETXEN_NIU_XGE_UNICAST_FRAME_CNT,
349 NETXEN_NIU_XGE_CRC_ERROR_CNT,
350 NETXEN_NIU_XGE_OVERSIZE_FRAME_ERR,
351 NETXEN_NIU_XGE_UNDERSIZE_FRAME_ERR,
352 NETXEN_NIU_XGE_LOCAL_ERROR_CNT,
353 NETXEN_NIU_XGE_REMOTE_ERROR_CNT,
354 NETXEN_NIU_XGE_CONTROL_CHAR_CNT,
355 NETXEN_NIU_XGE_PAUSE_FRAME_CNT,
362 netxen_nic_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p)
364 struct netxen_port *port = netdev_priv(dev);
365 struct netxen_adapter *adapter = port->adapter;
366 __u32 mode, *regs_buff = p;
370 memset(p, 0, NETXEN_NIC_REGS_LEN);
371 regs->version = (1 << 24) | (adapter->ahw.revision_id << 16) |
372 (port->pdev)->device;
374 NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_MODE, ®s_buff[0]);
377 /* Common registers to all the modes */
378 NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_STRAP_VALUE_SAVE_HIGHER,
381 mode = (mode / 2) - 1;
384 for (i = 3; niu_registers[mode].reg[i - 3] != -1; i++) {
385 /* GB: port specific registers */
386 if (mode == 0 && i >= 19)
387 window = port->portnum * NETXEN_NIC_PORT_WINDOW;
389 NETXEN_NIC_LOCKED_READ_REG(niu_registers[mode].
398 netxen_nic_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
400 wol->supported = WAKE_UCAST | WAKE_MCAST | WAKE_BCAST | WAKE_MAGIC;
401 /* options can be added depending upon the mode */
405 static u32 netxen_nic_get_link(struct net_device *dev)
407 struct netxen_port *port = netdev_priv(dev);
408 struct netxen_adapter *adapter = port->adapter;
411 /* read which mode */
412 if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
413 if (adapter->phy_read
414 && adapter->phy_read(adapter, port->portnum,
415 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
419 return (netxen_get_phy_link(status));
420 } else if (adapter->ahw.board_type == NETXEN_NIC_XGBE) {
421 int val = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_XG_STATE));
422 return val == XG_LINK_UP;
428 netxen_nic_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
431 struct netxen_port *port = netdev_priv(dev);
432 struct netxen_adapter *adapter = port->adapter;
436 if (eeprom->len == 0)
439 eeprom->magic = (port->pdev)->vendor | ((port->pdev)->device << 16);
440 offset = eeprom->offset;
442 ret = netxen_rom_fast_read_words(adapter, offset, bytes,
451 netxen_nic_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
454 struct netxen_port *port = netdev_priv(dev);
455 struct netxen_adapter *adapter = port->adapter;
456 int offset = eeprom->offset;
457 static int flash_start;
458 static int ready_to_flash;
461 if (flash_start == 0) {
462 ret = netxen_flash_unlock(adapter);
464 printk(KERN_ERR "%s: Flash unlock failed.\n",
465 netxen_nic_driver_name);
468 printk(KERN_INFO "%s: flash unlocked. \n",
469 netxen_nic_driver_name);
470 ret = netxen_flash_erase_secondary(adapter);
471 if (ret != FLASH_SUCCESS) {
472 printk(KERN_ERR "%s: Flash erase failed.\n",
473 netxen_nic_driver_name);
476 printk(KERN_INFO "%s: secondary flash erased successfully.\n",
477 netxen_nic_driver_name);
482 if (offset == BOOTLD_START) {
483 ret = netxen_flash_erase_primary(adapter);
484 if (ret != FLASH_SUCCESS) {
485 printk(KERN_ERR "%s: Flash erase failed.\n",
486 netxen_nic_driver_name);
490 ret = netxen_rom_se(adapter, USER_START);
491 if (ret != FLASH_SUCCESS)
493 ret = netxen_rom_se(adapter, FIXED_START);
494 if (ret != FLASH_SUCCESS)
497 printk(KERN_INFO "%s: primary flash erased successfully\n",
498 netxen_nic_driver_name);
500 ret = netxen_backup_crbinit(adapter);
501 if (ret != FLASH_SUCCESS) {
502 printk(KERN_ERR "%s: CRBinit backup failed.\n",
503 netxen_nic_driver_name);
506 printk(KERN_INFO "%s: CRBinit backup done.\n",
507 netxen_nic_driver_name);
511 if (!ready_to_flash) {
512 printk(KERN_ERR "%s: Invalid write sequence, returning...\n",
513 netxen_nic_driver_name);
517 return netxen_rom_fast_write_words(adapter, offset, bytes, eeprom->len);
521 netxen_nic_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
523 struct netxen_port *port = netdev_priv(dev);
524 struct netxen_adapter *adapter = port->adapter;
527 ring->rx_pending = 0;
528 ring->rx_jumbo_pending = 0;
529 for (i = 0; i < MAX_RCV_CTX; ++i) {
530 ring->rx_pending += adapter->recv_ctx[i].
531 rcv_desc[RCV_DESC_NORMAL_CTXID].rcv_pending;
532 ring->rx_jumbo_pending += adapter->recv_ctx[i].
533 rcv_desc[RCV_DESC_JUMBO_CTXID].rcv_pending;
536 ring->rx_max_pending = adapter->max_rx_desc_count;
537 ring->tx_max_pending = adapter->max_tx_desc_count;
538 ring->rx_jumbo_max_pending = adapter->max_jumbo_rx_desc_count;
539 ring->rx_mini_max_pending = 0;
540 ring->rx_mini_pending = 0;
541 ring->rx_jumbo_pending = 0;
545 netxen_nic_get_pauseparam(struct net_device *dev,
546 struct ethtool_pauseparam *pause)
548 struct netxen_port *port = netdev_priv(dev);
549 struct netxen_adapter *adapter = port->adapter;
552 if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
553 /* get flow control settings */
554 netxen_nic_read_w0(adapter,
555 NETXEN_NIU_GB_MAC_CONFIG_0(port->portnum),
557 pause->rx_pause = netxen_gb_get_rx_flowctl(val);
558 pause->tx_pause = netxen_gb_get_tx_flowctl(val);
559 /* get autoneg settings */
560 pause->autoneg = port->link_autoneg;
565 netxen_nic_set_pauseparam(struct net_device *dev,
566 struct ethtool_pauseparam *pause)
568 struct netxen_port *port = netdev_priv(dev);
569 struct netxen_adapter *adapter = port->adapter;
571 unsigned int autoneg;
574 if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
575 /* set flow control */
576 netxen_nic_read_w0(adapter,
577 NETXEN_NIU_GB_MAC_CONFIG_0(port->portnum),
580 netxen_gb_tx_flowctl(val);
582 netxen_gb_unset_tx_flowctl(val);
584 netxen_gb_rx_flowctl(val);
586 netxen_gb_unset_rx_flowctl(val);
588 netxen_nic_write_w0(adapter,
589 NETXEN_NIU_GB_MAC_CONFIG_0(port->portnum),
592 autoneg = pause->autoneg;
593 if (adapter->phy_write
594 && adapter->phy_write(adapter, port->portnum,
595 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG,
599 port->link_autoneg = pause->autoneg;
606 static int netxen_nic_reg_test(struct net_device *dev)
608 struct netxen_port *port = netdev_priv(dev);
609 struct netxen_adapter *adapter = port->adapter;
610 u32 data_read, data_written, save;
614 * first test the "Read Only" registers by writing which mode
616 netxen_nic_read_w0(adapter, NETXEN_NIU_MODE, &mode);
617 if (netxen_get_niu_enable_ge(mode)) { /* GB Mode */
618 netxen_nic_read_w0(adapter,
619 NETXEN_NIU_GB_MII_MGMT_STATUS(port->portnum),
624 data_written = data_read & NETXEN_NIC_INVALID_DATA;
626 data_written = NETXEN_NIC_INVALID_DATA;
627 netxen_nic_write_w0(adapter,
628 NETXEN_NIU_GB_MII_MGMT_STATUS(port->
631 netxen_nic_read_w0(adapter,
632 NETXEN_NIU_GB_MII_MGMT_STATUS(port->portnum),
635 if (data_written == data_read) {
636 netxen_nic_write_w0(adapter,
637 NETXEN_NIU_GB_MII_MGMT_STATUS(port->
644 /* netxen_niu_gb_mii_mgmt_indicators is read only */
645 netxen_nic_read_w0(adapter,
646 NETXEN_NIU_GB_MII_MGMT_INDICATE(port->
652 data_written = data_read & NETXEN_NIC_INVALID_DATA;
654 data_written = NETXEN_NIC_INVALID_DATA;
655 netxen_nic_write_w0(adapter,
656 NETXEN_NIU_GB_MII_MGMT_INDICATE(port->
660 netxen_nic_read_w0(adapter,
661 NETXEN_NIU_GB_MII_MGMT_INDICATE(port->
665 if (data_written == data_read) {
666 netxen_nic_write_w0(adapter,
667 NETXEN_NIU_GB_MII_MGMT_INDICATE
668 (port->portnum), save);
672 /* netxen_niu_gb_interface_status is read only */
673 netxen_nic_read_w0(adapter,
674 NETXEN_NIU_GB_INTERFACE_STATUS(port->
680 data_written = data_read & NETXEN_NIC_INVALID_DATA;
682 data_written = NETXEN_NIC_INVALID_DATA;
683 netxen_nic_write_w0(adapter,
684 NETXEN_NIU_GB_INTERFACE_STATUS(port->
688 netxen_nic_read_w0(adapter,
689 NETXEN_NIU_GB_INTERFACE_STATUS(port->
693 if (data_written == data_read) {
694 netxen_nic_write_w0(adapter,
695 NETXEN_NIU_GB_INTERFACE_STATUS
696 (port->portnum), save);
704 static int netxen_nic_diag_test_count(struct net_device *dev)
706 return NETXEN_NIC_TEST_LEN;
710 netxen_nic_diag_test(struct net_device *dev, struct ethtool_test *eth_test,
713 if (eth_test->flags == ETH_TEST_FL_OFFLINE) { /* offline tests */
715 if (!(data[4] = (u64) netxen_nic_get_link(dev)))
716 eth_test->flags |= ETH_TEST_FL_FAILED;
718 if (netif_running(dev))
722 if (!(data[0] = netxen_nic_reg_test(dev)))
723 eth_test->flags |= ETH_TEST_FL_FAILED;
724 /* other tests pass as of now */
725 data[1] = data[2] = data[3] = 1;
726 if (netif_running(dev))
728 } else { /* online tests */
730 if (!(data[4] = (u64) netxen_nic_get_link(dev)))
731 eth_test->flags |= ETH_TEST_FL_FAILED;
733 /* other tests pass by default */
734 data[0] = data[1] = data[2] = data[3] = 1;
739 netxen_nic_get_strings(struct net_device *dev, u32 stringset, u8 * data)
745 memcpy(data, *netxen_nic_gstrings_test,
746 NETXEN_NIC_TEST_LEN * ETH_GSTRING_LEN);
749 for (index = 0; index < NETXEN_NIC_STATS_LEN; index++) {
750 memcpy(data + index * ETH_GSTRING_LEN,
751 netxen_nic_gstrings_stats[index].stat_string,
758 static int netxen_nic_get_stats_count(struct net_device *dev)
760 return NETXEN_NIC_STATS_LEN;
764 netxen_nic_get_ethtool_stats(struct net_device *dev,
765 struct ethtool_stats *stats, u64 * data)
767 struct netxen_port *port = netdev_priv(dev);
770 for (index = 0; index < NETXEN_NIC_STATS_LEN; index++) {
772 (char *)port + netxen_nic_gstrings_stats[index].stat_offset;
774 (netxen_nic_gstrings_stats[index].sizeof_stat ==
775 sizeof(u64)) ? *(u64 *) p : *(u32 *) p;
779 struct ethtool_ops netxen_nic_ethtool_ops = {
780 .get_settings = netxen_nic_get_settings,
781 .set_settings = netxen_nic_set_settings,
782 .get_drvinfo = netxen_nic_get_drvinfo,
783 .get_regs_len = netxen_nic_get_regs_len,
784 .get_regs = netxen_nic_get_regs,
785 .get_wol = netxen_nic_get_wol,
786 .get_link = netxen_nic_get_link,
787 .get_eeprom_len = netxen_nic_get_eeprom_len,
788 .get_eeprom = netxen_nic_get_eeprom,
789 .set_eeprom = netxen_nic_set_eeprom,
790 .get_ringparam = netxen_nic_get_ringparam,
791 .get_pauseparam = netxen_nic_get_pauseparam,
792 .set_pauseparam = netxen_nic_set_pauseparam,
793 .get_tx_csum = ethtool_op_get_tx_csum,
794 .set_tx_csum = ethtool_op_set_tx_csum,
795 .get_sg = ethtool_op_get_sg,
796 .set_sg = ethtool_op_set_sg,
797 .get_tso = ethtool_op_get_tso,
798 .set_tso = ethtool_op_set_tso,
799 .self_test_count = netxen_nic_diag_test_count,
800 .self_test = netxen_nic_diag_test,
801 .get_strings = netxen_nic_get_strings,
802 .get_stats_count = netxen_nic_get_stats_count,
803 .get_ethtool_stats = netxen_nic_get_ethtool_stats,
804 .get_perm_addr = ethtool_op_get_perm_addr,