netxen: advertise wake-on-lan support
[pandora-kernel.git] / drivers / net / netxen / netxen_nic_ethtool.c
index e45ce29..0012b31 100644 (file)
@@ -136,11 +136,9 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
 
                ecmd->port = PORT_TP;
 
-               if (netif_running(dev)) {
-                       ecmd->speed = adapter->link_speed;
-                       ecmd->duplex = adapter->link_duplex;
-                       ecmd->autoneg = adapter->link_autoneg;
-               }
+               ecmd->speed = adapter->link_speed;
+               ecmd->duplex = adapter->link_duplex;
+               ecmd->autoneg = adapter->link_autoneg;
 
        } else if (adapter->ahw.board_type == NETXEN_NIC_XGBE) {
                u32 val;
@@ -171,7 +169,7 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
        } else
                return -EIO;
 
-       ecmd->phy_address = adapter->portnum;
+       ecmd->phy_address = adapter->physical_port;
        ecmd->transceiver = XCVR_EXTERNAL;
 
        switch ((netxen_brdtype_t) boardinfo->board_type) {
@@ -180,13 +178,13 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
        case NETXEN_BRDTYPE_P3_REF_QG:
        case NETXEN_BRDTYPE_P3_4_GB:
        case NETXEN_BRDTYPE_P3_4_GB_MM:
-       case NETXEN_BRDTYPE_P3_10000_BASE_T:
 
                ecmd->supported |= SUPPORTED_Autoneg;
                ecmd->advertising |= ADVERTISED_Autoneg;
        case NETXEN_BRDTYPE_P2_SB31_10G_CX4:
        case NETXEN_BRDTYPE_P3_10G_CX4:
        case NETXEN_BRDTYPE_P3_10G_CX4_LP:
+       case NETXEN_BRDTYPE_P3_10000_BASE_T:
                ecmd->supported |= SUPPORTED_TP;
                ecmd->advertising |= ADVERTISED_TP;
                ecmd->port = PORT_TP;
@@ -204,16 +202,33 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
                ecmd->port = PORT_FIBRE;
                ecmd->autoneg = AUTONEG_DISABLE;
                break;
-       case NETXEN_BRDTYPE_P2_SB31_10G:
        case NETXEN_BRDTYPE_P3_10G_SFP_PLUS:
        case NETXEN_BRDTYPE_P3_10G_SFP_CT:
        case NETXEN_BRDTYPE_P3_10G_SFP_QT:
+               ecmd->advertising |= ADVERTISED_TP;
+               ecmd->supported |= SUPPORTED_TP;
+       case NETXEN_BRDTYPE_P2_SB31_10G:
        case NETXEN_BRDTYPE_P3_10G_XFP:
                ecmd->supported |= SUPPORTED_FIBRE;
                ecmd->advertising |= ADVERTISED_FIBRE;
                ecmd->port = PORT_FIBRE;
                ecmd->autoneg = AUTONEG_DISABLE;
                break;
+       case NETXEN_BRDTYPE_P3_10G_TP:
+               if (adapter->ahw.board_type == NETXEN_NIC_XGBE) {
+                       ecmd->autoneg = AUTONEG_DISABLE;
+                       ecmd->supported |= (SUPPORTED_FIBRE | SUPPORTED_TP);
+                       ecmd->advertising |=
+                               (ADVERTISED_FIBRE | ADVERTISED_TP);
+                       ecmd->port = PORT_FIBRE;
+               } else {
+                       ecmd->autoneg = AUTONEG_ENABLE;
+                       ecmd->supported |= (SUPPORTED_TP |SUPPORTED_Autoneg);
+                       ecmd->advertising |=
+                               (ADVERTISED_TP | ADVERTISED_Autoneg);
+                       ecmd->port = PORT_TP;
+               }
+               break;
        default:
                printk(KERN_ERR "netxen-nic: Unsupported board model %d\n",
                       (netxen_brdtype_t) boardinfo->board_type);
@@ -546,7 +561,10 @@ netxen_nic_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
        }
        ring->tx_pending = adapter->max_tx_desc_count;
 
-       ring->rx_max_pending = MAX_RCV_DESCRIPTORS;
+       if (adapter->ahw.board_type == NETXEN_NIC_GBE)
+               ring->rx_max_pending = MAX_RCV_DESCRIPTORS_1G;
+       else
+               ring->rx_max_pending = MAX_RCV_DESCRIPTORS_10G;
        ring->tx_max_pending = MAX_CMD_DESCRIPTORS_HOST;
        ring->rx_jumbo_max_pending = MAX_JUMBO_RCV_DESCRIPTORS;
        ring->rx_mini_max_pending = 0;
@@ -792,6 +810,53 @@ static int netxen_nic_set_tso(struct net_device *dev, u32 data)
        return 0;
 }
 
+static void
+netxen_nic_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
+{
+       struct netxen_adapter *adapter = netdev_priv(dev);
+       u32 wol_cfg = 0;
+
+       wol->supported = 0;
+       wol->wolopts = 0;
+
+       if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
+               return;
+
+       wol_cfg = netxen_nic_reg_read(adapter, NETXEN_WOL_CONFIG_NV);
+       if (wol_cfg & (1UL << adapter->portnum))
+               wol->supported |= WAKE_MAGIC;
+
+       wol_cfg = netxen_nic_reg_read(adapter, NETXEN_WOL_CONFIG);
+       if (wol_cfg & (1UL << adapter->portnum))
+               wol->wolopts |= WAKE_MAGIC;
+}
+
+static int
+netxen_nic_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
+{
+       struct netxen_adapter *adapter = netdev_priv(dev);
+       u32 wol_cfg = 0;
+
+       if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
+               return -EOPNOTSUPP;
+
+       if (wol->wolopts & ~WAKE_MAGIC)
+               return -EOPNOTSUPP;
+
+       wol_cfg = netxen_nic_reg_read(adapter, NETXEN_WOL_CONFIG_NV);
+       if (!(wol_cfg & (1 << adapter->portnum)))
+               return -EOPNOTSUPP;
+
+       wol_cfg = netxen_nic_reg_read(adapter, NETXEN_WOL_CONFIG);
+       if (wol->wolopts & WAKE_MAGIC)
+               wol_cfg |= 1UL << adapter->portnum;
+       else
+               wol_cfg &= ~(1UL << adapter->portnum);
+       netxen_nic_reg_write(adapter, NETXEN_WOL_CONFIG, wol_cfg);
+
+       return 0;
+}
+
 /*
  * Set the coalescing parameters. Currently only normal is supported.
  * If rx_coalesce_usecs == 0 or rx_max_coalesced_frames == 0 then set the
@@ -898,6 +963,8 @@ struct ethtool_ops netxen_nic_ethtool_ops = {
        .set_sg = ethtool_op_set_sg,
        .get_tso = netxen_nic_get_tso,
        .set_tso = netxen_nic_set_tso,
+       .get_wol = netxen_nic_get_wol,
+       .set_wol = netxen_nic_set_wol,
        .self_test = netxen_nic_diag_test,
        .get_strings = netxen_nic_get_strings,
        .get_ethtool_stats = netxen_nic_get_ethtool_stats,