26 #include <linux/types.h>
28 #include <linux/pci.h>
30 #include <linux/netdevice.h>
31 #include <linux/ethtool.h>
42 #define NETXEN_NIC_STAT(m) sizeof(((struct netxen_adapter *)0)->m), \
43 offsetof(struct netxen_adapter, m)
45 #define NETXEN_NIC_PORT_WINDOW 0x10000
46 #define NETXEN_NIC_INVALID_DATA 0xDEADBEEF
60 #define NETXEN_NIC_STATS_LEN ARRAY_SIZE(netxen_nic_gstrings_stats)
63 "Register_Test_on_offline",
64 "Link_Test_on_offline"
67 #define NETXEN_NIC_TEST_LEN ARRAY_SIZE(netxen_nic_gstrings_test)
69 #define NETXEN_NIC_REGS_COUNT 30
70 #define NETXEN_NIC_REGS_LEN (NETXEN_NIC_REGS_COUNT * sizeof(__le32))
71 #define NETXEN_MAX_EEPROM_LEN 1024
94 "%d.%d.%d", fw_major, fw_minor, fw_build);
99 drvinfo->
eedump_len = netxen_nic_get_eeprom_len(dev);
106 int check_sfp_module = 0;
124 ethtool_cmd_speed_set(ecmd, adapter->
link_speed);
141 ethtool_cmd_speed_set(ecmd, adapter->
link_speed);
150 u16 pcifn = adapter->
ahw.pci_func;
167 switch (adapter->
ahw.board_type) {
202 check_sfp_module = netif_running(dev) &&
218 check_sfp_module = netif_running(dev) &&
229 adapter->
ahw.board_type);
233 if (check_sfp_module) {
251 if (!netif_running(dev) || !adapter->
ahw.linkup) {
263 u32 speed = ethtool_cmd_speed(ecmd);
283 if (!netif_running(dev))
290 static int netxen_nic_get_regs_len(
struct net_device *dev)
307 regs->
version = (1 << 24) | (adapter->
ahw.revision_id << 16) |
339 regs_buff[i++] =
NXRD32(adapter,
341 regs_buff[i++] =
NXRD32(adapter,
345 regs_buff[i++] =
NXRDIO(adapter,
346 adapter->
tx_ring->crb_cmd_consumer);
349 regs_buff[i++] =
NXRDIO(adapter, adapter->
tx_ring->crb_cmd_producer);
351 regs_buff[i++] =
NXRDIO(adapter,
352 recv_ctx->
rds_rings[0].crb_rcv_producer);
353 regs_buff[i++] =
NXRDIO(adapter,
354 recv_ctx->
rds_rings[1].crb_rcv_producer);
360 regs_buff[i++] =
NXRDIO(adapter,
377 val = (val >> port*8) & 0xff;
390 if (eeprom->
len == 0)
394 ((adapter->
pdev)->device << 16);
406 netxen_nic_get_ringparam(
struct net_device *dev,
431 num_desc =
max(val, min);
432 num_desc =
min(num_desc, max);
435 if (val != num_desc) {
444 netxen_nic_set_ringparam(
struct net_device *dev,
463 num_rxd = netxen_validate_ringparam(ring->
rx_pending,
469 num_txd = netxen_validate_ringparam(ring->
tx_pending,
484 netxen_nic_get_pauseparam(
struct net_device *dev,
529 netxen_nic_set_pauseparam(
struct net_device *dev,
598 adapter->
ahw.port_type);
603 static int netxen_nic_reg_test(
struct net_device *dev)
606 u32 data_read, data_written;
609 if ((data_read & 0xffff) != adapter->
pdev->vendor)
615 data_written = (
u32)0xa5a5a5a5;
619 if (data_written != data_read)
625 static int netxen_get_sset_count(
struct net_device *dev,
int sset)
642 if ((data[0] = netxen_nic_reg_test(dev)))
645 if ((data[1] = (
u64) netxen_nic_test_link(dev)))
650 netxen_nic_get_strings(
struct net_device *dev,
u32 stringset,
u8 * data)
656 memcpy(data, *netxen_nic_gstrings_test,
662 netxen_nic_gstrings_stats[index].stat_string,
670 netxen_nic_get_ethtool_stats(
struct net_device *dev,
679 netxen_nic_gstrings_stats[index].stat_offset;
720 if (!(wol_cfg & (1 << adapter->
portnum)))
799 static int netxen_get_intr_coalesce(
struct net_device *netdev,
849 netdev_info(netdev,
"FW dump not enabled\n");
853 netdev_info(netdev,
"Previous dump not cleared, not forcing dump\n");
856 netdev_info(netdev,
"Forcing a fw dump\n");
861 netdev_info(netdev,
"Disabling FW Dump\n");
867 netdev_info(netdev,
"Enabling FW dump\n");
872 netdev_info(netdev,
"Forcing FW reset\n");
877 for (i = 0; i <
ARRAY_SIZE(FW_DUMP_LEVELS); i++) {
878 if (val->
flag == FW_DUMP_LEVELS[i]) {
881 "Driver mask changed to: 0x%x\n",
887 "Invalid dump level: 0x%x\n", val->
flag);
905 netdev_info(netdev,
"Dump not available\n");
912 for (i = 0; i < copy_sz/
sizeof(
u32); i++)
926 netdev_info(netdev,
"extracted the fw dump Successfully\n");
931 .get_settings = netxen_nic_get_settings,
932 .set_settings = netxen_nic_set_settings,
933 .get_drvinfo = netxen_nic_get_drvinfo,
934 .get_regs_len = netxen_nic_get_regs_len,
935 .get_regs = netxen_nic_get_regs,
937 .get_eeprom_len = netxen_nic_get_eeprom_len,
938 .get_eeprom = netxen_nic_get_eeprom,
939 .get_ringparam = netxen_nic_get_ringparam,
940 .set_ringparam = netxen_nic_set_ringparam,
941 .get_pauseparam = netxen_nic_get_pauseparam,
942 .set_pauseparam = netxen_nic_set_pauseparam,
943 .get_wol = netxen_nic_get_wol,
944 .set_wol = netxen_nic_set_wol,
945 .self_test = netxen_nic_diag_test,
946 .get_strings = netxen_nic_get_strings,
947 .get_ethtool_stats = netxen_nic_get_ethtool_stats,
948 .get_sset_count = netxen_get_sset_count,
949 .get_coalesce = netxen_get_intr_coalesce,
950 .set_coalesce = netxen_set_intr_coalesce,
951 .get_dump_flag = netxen_get_dump_flag,
952 .get_dump_data = netxen_get_dump_data,
953 .set_dump = netxen_set_dump,