i40e: Fix ethtool offline test
authorGreg Rose <gregory.v.rose@intel.com>
Thu, 26 Feb 2015 16:14:35 +0000 (16:14 +0000)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Thu, 5 Mar 2015 13:43:52 +0000 (05:43 -0800)
If the system administrator is requesting an offline diagnostic test using
'ethtool -t' then we should, you know, actually take the device offline
before doing the testing.

Change-ID: I6afa1cbfcc821c9ab6e6f47ed4d8dc2d8dd20e82
Signed-off-by: Greg Rose <gregory.v.rose@intel.com>
Tested-by: Jim Young <james.m.young@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/i40e/i40e_ethtool.c

index 7413b0e429c82b500c5a0dd2464c6e464949efbc..415aebceed9ab2abd322dabc7b45b3a513286a3d 100644 (file)
@@ -1530,6 +1530,7 @@ static void i40e_diag_test(struct net_device *netdev,
                           struct ethtool_test *eth_test, u64 *data)
 {
        struct i40e_netdev_priv *np = netdev_priv(netdev);
+       bool if_running = netif_running(netdev);
        struct i40e_pf *pf = np->vsi->back;
 
        if (eth_test->flags == ETH_TEST_FL_OFFLINE) {
@@ -1537,6 +1538,12 @@ static void i40e_diag_test(struct net_device *netdev,
                netif_info(pf, drv, netdev, "offline testing starting\n");
 
                set_bit(__I40E_TESTING, &pf->state);
+               /* If the device is online then take it offline */
+               if (if_running)
+                       /* indicate we're in test mode */
+                       dev_close(netdev);
+               else
+                       i40e_do_reset(pf, (1 << __I40E_PF_RESET_REQUESTED));
 
                /* Link test performed before hardware reset
                 * so autoneg doesn't interfere with test result
@@ -1559,6 +1566,9 @@ static void i40e_diag_test(struct net_device *netdev,
 
                clear_bit(__I40E_TESTING, &pf->state);
                i40e_do_reset(pf, (1 << __I40E_PF_RESET_REQUESTED));
+
+               if (if_running)
+                       dev_open(netdev);
        } else {
                /* Online tests */
                netif_info(pf, drv, netdev, "online testing starting\n");