]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - drivers/net/ixgbe/ixgbe_ethtool.c
ixgbe: add WOL support for backplane adapters
[net-next-2.6.git] / drivers / net / ixgbe / ixgbe_ethtool.c
index c19594a4e8f8c6054fba141d3c4d70529d197beb..0a4b322fab6a7e85f3d78547e872b8be8e2551c6 100644 (file)
@@ -185,6 +185,16 @@ static int ixgbe_get_settings(struct net_device *netdev,
                                             ADVERTISED_FIBRE);
                        ecmd->port = PORT_FIBRE;
                        ecmd->autoneg = AUTONEG_DISABLE;
+               } else if ((hw->device_id == IXGBE_DEV_ID_82599_COMBO_BACKPLANE) ||
+                          (hw->device_id == IXGBE_DEV_ID_82599_KX4_MEZZ)) {
+                       ecmd->supported |= (SUPPORTED_1000baseT_Full |
+                                           SUPPORTED_Autoneg |
+                                           SUPPORTED_FIBRE);
+                       ecmd->advertising = (ADVERTISED_10000baseT_Full |
+                                            ADVERTISED_1000baseT_Full |
+                                            ADVERTISED_Autoneg |
+                                            ADVERTISED_FIBRE);
+                       ecmd->port = PORT_FIBRE;
                } else {
                        ecmd->supported |= (SUPPORTED_1000baseT_Full |
                                            SUPPORTED_FIBRE);
@@ -425,13 +435,12 @@ static int ixgbe_set_tx_csum(struct net_device *netdev, u32 data)
        struct ixgbe_adapter *adapter = netdev_priv(netdev);
 
        if (data) {
-               netdev->features |= (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM);
+               netdev->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
                if (adapter->hw.mac.type == ixgbe_mac_82599EB)
                        netdev->features |= NETIF_F_SCTP_CSUM;
        } else {
-               netdev->features &= ~(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM);
-               if (adapter->hw.mac.type == ixgbe_mac_82599EB)
-                       netdev->features &= ~NETIF_F_SCTP_CSUM;
+               netdev->features &= ~(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
+                                     NETIF_F_SCTP_CSUM);
        }
 
        return 0;
@@ -525,10 +534,20 @@ static void ixgbe_get_regs(struct net_device *netdev,
        regs_buff[32] = IXGBE_READ_REG(hw, IXGBE_FCTTV(1));
        regs_buff[33] = IXGBE_READ_REG(hw, IXGBE_FCTTV(2));
        regs_buff[34] = IXGBE_READ_REG(hw, IXGBE_FCTTV(3));
-       for (i = 0; i < 8; i++)
-               regs_buff[35 + i] = IXGBE_READ_REG(hw, IXGBE_FCRTL(i));
-       for (i = 0; i < 8; i++)
-               regs_buff[43 + i] = IXGBE_READ_REG(hw, IXGBE_FCRTH(i));
+       for (i = 0; i < 8; i++) {
+               switch (hw->mac.type) {
+               case ixgbe_mac_82598EB:
+                       regs_buff[35 + i] = IXGBE_READ_REG(hw, IXGBE_FCRTL(i));
+                       regs_buff[43 + i] = IXGBE_READ_REG(hw, IXGBE_FCRTH(i));
+                       break;
+               case ixgbe_mac_82599EB:
+                       regs_buff[35 + i] = IXGBE_READ_REG(hw, IXGBE_FCRTL_82599(i));
+                       regs_buff[43 + i] = IXGBE_READ_REG(hw, IXGBE_FCRTH_82599(i));
+                       break;
+               default:
+                       break;
+               }
+       }
        regs_buff[51] = IXGBE_READ_REG(hw, IXGBE_FCRTV);
        regs_buff[52] = IXGBE_READ_REG(hw, IXGBE_TFCS);
 
@@ -1226,12 +1245,19 @@ static int ixgbe_reg_test(struct ixgbe_adapter *adapter, u64 *data)
        u32 value, before, after;
        u32 i, toggle;
 
-       if (adapter->hw.mac.type == ixgbe_mac_82599EB) {
-               toggle = 0x7FFFF30F;
-               test = reg_test_82599;
-       } else {
+       switch (adapter->hw.mac.type) {
+       case ixgbe_mac_82598EB:
                toggle = 0x7FFFF3FF;
                test = reg_test_82598;
+               break;
+       case ixgbe_mac_82599EB:
+               toggle = 0x7FFFF30F;
+               test = reg_test_82599;
+               break;
+       default:
+               *data = 1;
+               return 1;
+               break;
        }
 
        /*
@@ -1449,10 +1475,14 @@ static void ixgbe_free_desc_rings(struct ixgbe_adapter *adapter)
        reg_ctl &= ~IXGBE_TXDCTL_ENABLE;
        IXGBE_WRITE_REG(hw, IXGBE_TXDCTL(tx_ring->reg_idx), reg_ctl);
 
-       if (hw->mac.type == ixgbe_mac_82599EB) {
+       switch (hw->mac.type) {
+       case ixgbe_mac_82599EB:
                reg_ctl = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
                reg_ctl &= ~IXGBE_DMATXCTL_TE;
                IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg_ctl);
+               break;
+       default:
+               break;
        }
 
        ixgbe_reset(adapter);
@@ -1481,10 +1511,14 @@ static int ixgbe_setup_desc_rings(struct ixgbe_adapter *adapter)
        if (err)
                return 1;
 
-       if (adapter->hw.mac.type == ixgbe_mac_82599EB) {
+       switch (adapter->hw.mac.type) {
+       case ixgbe_mac_82599EB:
                reg_data = IXGBE_READ_REG(&adapter->hw, IXGBE_DMATXCTL);
                reg_data |= IXGBE_DMATXCTL_TE;
                IXGBE_WRITE_REG(&adapter->hw, IXGBE_DMATXCTL, reg_data);
+               break;
+       default:
+               break;
        }
 
        ixgbe_configure_tx_ring(adapter, tx_ring);
@@ -1838,6 +1872,13 @@ static int ixgbe_wol_exclusion(struct ixgbe_adapter *adapter,
        int retval = 1;
 
        switch(hw->device_id) {
+       case IXGBE_DEV_ID_82599_COMBO_BACKPLANE:
+               /* All except this subdevice support WOL */
+               if (hw->subsystem_device_id ==
+                   IXGBE_SUBDEV_ID_82599_KX4_KR_MEZZ) {
+                       wol->supported = 0;
+                       break;
+               }
        case IXGBE_DEV_ID_82599_KX4:
                retval = 0;
                break;
@@ -1975,6 +2016,41 @@ static int ixgbe_get_coalesce(struct net_device *netdev,
        return 0;
 }
 
+/*
+ * this function must be called before setting the new value of
+ * rx_itr_setting
+ */
+static bool ixgbe_update_rsc(struct ixgbe_adapter *adapter,
+                            struct ethtool_coalesce *ec)
+{
+       struct net_device *netdev = adapter->netdev;
+
+       if (!(adapter->flags2 & IXGBE_FLAG2_RSC_CAPABLE))
+               return false;
+
+       /* if interrupt rate is too high then disable RSC */
+       if (ec->rx_coalesce_usecs != 1 &&
+           ec->rx_coalesce_usecs <= 1000000/IXGBE_MAX_RSC_INT_RATE) {
+               if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) {
+                       e_info(probe, "rx-usecs set too low, "
+                                     "disabling RSC\n");
+                       adapter->flags2 &= ~IXGBE_FLAG2_RSC_ENABLED;
+                       return true;
+               }
+       } else {
+               /* check the feature flag value and enable RSC if necessary */
+               if ((netdev->features & NETIF_F_LRO) &&
+                   !(adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED)) {
+                       e_info(probe, "rx-usecs set to %d, "
+                                     "re-enabling RSC\n",
+                              ec->rx_coalesce_usecs);
+                       adapter->flags2 |= IXGBE_FLAG2_RSC_ENABLED;
+                       return true;
+               }
+       }
+       return false;
+}
+
 static int ixgbe_set_coalesce(struct net_device *netdev,
                               struct ethtool_coalesce *ec)
 {
@@ -1992,17 +2068,14 @@ static int ixgbe_set_coalesce(struct net_device *netdev,
                adapter->tx_ring[0]->work_limit = ec->tx_max_coalesced_frames_irq;
 
        if (ec->rx_coalesce_usecs > 1) {
-               u32 max_int;
-               if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED)
-                       max_int = IXGBE_MAX_RSC_INT_RATE;
-               else
-                       max_int = IXGBE_MAX_INT_RATE;
-
                /* check the limits */
-               if ((1000000/ec->rx_coalesce_usecs > max_int) ||
+               if ((1000000/ec->rx_coalesce_usecs > IXGBE_MAX_INT_RATE) ||
                    (1000000/ec->rx_coalesce_usecs < IXGBE_MIN_INT_RATE))
                        return -EINVAL;
 
+               /* check the old value and enable RSC if necessary */
+               need_reset = ixgbe_update_rsc(adapter, ec);
+
                /* store the value in ints/second */
                adapter->rx_eitr_param = 1000000/ec->rx_coalesce_usecs;
 
@@ -2011,32 +2084,21 @@ static int ixgbe_set_coalesce(struct net_device *netdev,
                /* clear the lower bit as its used for dynamic state */
                adapter->rx_itr_setting &= ~1;
        } else if (ec->rx_coalesce_usecs == 1) {
+               /* check the old value and enable RSC if necessary */
+               need_reset = ixgbe_update_rsc(adapter, ec);
+
                /* 1 means dynamic mode */
                adapter->rx_eitr_param = 20000;
                adapter->rx_itr_setting = 1;
        } else {
+               /* check the old value and enable RSC if necessary */
+               need_reset = ixgbe_update_rsc(adapter, ec);
                /*
                 * any other value means disable eitr, which is best
                 * served by setting the interrupt rate very high
                 */
                adapter->rx_eitr_param = IXGBE_MAX_INT_RATE;
                adapter->rx_itr_setting = 0;
-
-               /*
-                * if hardware RSC is enabled, disable it when
-                * setting low latency mode, to avoid errata, assuming
-                * that when the user set low latency mode they want
-                * it at the cost of anything else
-                */
-               if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) {
-                       adapter->flags2 &= ~IXGBE_FLAG2_RSC_ENABLED;
-                       if (netdev->features & NETIF_F_LRO) {
-                               netdev->features &= ~NETIF_F_LRO;
-                               e_info(probe, "rx-usecs set to 0, "
-                                      "disabling RSC\n");
-                       }
-                       need_reset = true;
-               }
        }
 
        if (ec->tx_coalesce_usecs > 1) {
@@ -2123,15 +2185,15 @@ static int ixgbe_set_flags(struct net_device *netdev, u32 data)
                return rc;
 
        /* if state changes we need to update adapter->flags and reset */
-       if (adapter->flags2 & IXGBE_FLAG2_RSC_CAPABLE) {
-               /*
-                * cast both to bool and verify if they are set the same
-                * but only enable RSC if itr is non-zero, as
-                * itr=0 and RSC are mutually exclusive
-                */
-               if (((!!(data & ETH_FLAG_LRO)) !=
-                    (!!(adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED))) &&
-                   adapter->rx_itr_setting) {
+       if ((adapter->flags2 & IXGBE_FLAG2_RSC_CAPABLE) &&
+           (!!(data & ETH_FLAG_LRO) !=
+            !!(adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED))) {
+               if ((data & ETH_FLAG_LRO) &&
+                   (!adapter->rx_itr_setting ||
+                    (adapter->rx_itr_setting > IXGBE_MAX_RSC_INT_RATE))) {
+                       e_info(probe, "rx-usecs set too low, "
+                                     "not enabling RSC.\n");
+               } else {
                        adapter->flags2 ^= IXGBE_FLAG2_RSC_ENABLED;
                        switch (adapter->hw.mac.type) {
                        case ixgbe_mac_82599EB:
@@ -2140,11 +2202,6 @@ static int ixgbe_set_flags(struct net_device *netdev, u32 data)
                        default:
                                break;
                        }
-               } else if (!adapter->rx_itr_setting) {
-                       netdev->features &= ~NETIF_F_LRO;
-                       if (data & ETH_FLAG_LRO)
-                               e_info(probe, "rx-usecs set to 0, "
-                                      "LRO/RSC cannot be enabled.\n");
                }
        }