aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/intel/igb/igb_ethtool.c
diff options
context:
space:
mode:
authorJoe Schultz <jschultz@xes-inc.com>2015-11-03 13:37:29 -0500
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2015-12-14 19:07:21 -0500
commitd602de05934c1d3022b153ff879e81f65df2a7b6 (patch)
treecf28cc8aa001d7504c8b9f5140e0bff1e0e816f9 /drivers/net/ethernet/intel/igb/igb_ethtool.c
parent3627f8f1d137f6487e51ff1199a54a087a2a6446 (diff)
igb: Explicitly label self-test result indices
Previously, the ethtool self-test gstrings/data arrays were accessed via hardcoded indices, which made the code difficult to follow. This patch replaces the hardcoded values with enum-based labels. Signed-off-by: Joe Schultz <jschultz@xes-inc.com> Signed-off-by: Aaron Sierra <asierra@xes-inc.com> Tested-by: Aaron Brown <aaron.f.brown@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel/igb/igb_ethtool.c')
-rw-r--r--drivers/net/ethernet/intel/igb/igb_ethtool.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c
index 2529bc625de4..1d329f1d047b 100644
--- a/drivers/net/ethernet/intel/igb/igb_ethtool.c
+++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c
@@ -127,10 +127,20 @@ static const struct igb_stats igb_gstrings_net_stats[] = {
127#define IGB_STATS_LEN \ 127#define IGB_STATS_LEN \
128 (IGB_GLOBAL_STATS_LEN + IGB_NETDEV_STATS_LEN + IGB_QUEUE_STATS_LEN) 128 (IGB_GLOBAL_STATS_LEN + IGB_NETDEV_STATS_LEN + IGB_QUEUE_STATS_LEN)
129 129
130enum igb_diagnostics_results {
131 TEST_REG = 0,
132 TEST_EEP,
133 TEST_IRQ,
134 TEST_LOOP,
135 TEST_LINK
136};
137
130static const char igb_gstrings_test[][ETH_GSTRING_LEN] = { 138static const char igb_gstrings_test[][ETH_GSTRING_LEN] = {
131 "Register test (offline)", "Eeprom test (offline)", 139 [TEST_REG] = "Register test (offline)",
132 "Interrupt test (offline)", "Loopback test (offline)", 140 [TEST_EEP] = "Eeprom test (offline)",
133 "Link test (on/offline)" 141 [TEST_IRQ] = "Interrupt test (offline)",
142 [TEST_LOOP] = "Loopback test (offline)",
143 [TEST_LINK] = "Link test (on/offline)"
134}; 144};
135#define IGB_TEST_LEN (sizeof(igb_gstrings_test) / ETH_GSTRING_LEN) 145#define IGB_TEST_LEN (sizeof(igb_gstrings_test) / ETH_GSTRING_LEN)
136 146
@@ -2002,7 +2012,7 @@ static void igb_diag_test(struct net_device *netdev,
2002 /* Link test performed before hardware reset so autoneg doesn't 2012 /* Link test performed before hardware reset so autoneg doesn't
2003 * interfere with test result 2013 * interfere with test result
2004 */ 2014 */
2005 if (igb_link_test(adapter, &data[4])) 2015 if (igb_link_test(adapter, &data[TEST_LINK]))
2006 eth_test->flags |= ETH_TEST_FL_FAILED; 2016 eth_test->flags |= ETH_TEST_FL_FAILED;
2007 2017
2008 if (if_running) 2018 if (if_running)
@@ -2011,21 +2021,21 @@ static void igb_diag_test(struct net_device *netdev,
2011 else 2021 else
2012 igb_reset(adapter); 2022 igb_reset(adapter);
2013 2023
2014 if (igb_reg_test(adapter, &data[0])) 2024 if (igb_reg_test(adapter, &data[TEST_REG]))
2015 eth_test->flags |= ETH_TEST_FL_FAILED; 2025 eth_test->flags |= ETH_TEST_FL_FAILED;
2016 2026
2017 igb_reset(adapter); 2027 igb_reset(adapter);
2018 if (igb_eeprom_test(adapter, &data[1])) 2028 if (igb_eeprom_test(adapter, &data[TEST_EEP]))
2019 eth_test->flags |= ETH_TEST_FL_FAILED; 2029 eth_test->flags |= ETH_TEST_FL_FAILED;
2020 2030
2021 igb_reset(adapter); 2031 igb_reset(adapter);
2022 if (igb_intr_test(adapter, &data[2])) 2032 if (igb_intr_test(adapter, &data[TEST_IRQ]))
2023 eth_test->flags |= ETH_TEST_FL_FAILED; 2033 eth_test->flags |= ETH_TEST_FL_FAILED;
2024 2034
2025 igb_reset(adapter); 2035 igb_reset(adapter);
2026 /* power up link for loopback test */ 2036 /* power up link for loopback test */
2027 igb_power_up_link(adapter); 2037 igb_power_up_link(adapter);
2028 if (igb_loopback_test(adapter, &data[3])) 2038 if (igb_loopback_test(adapter, &data[TEST_LOOP]))
2029 eth_test->flags |= ETH_TEST_FL_FAILED; 2039 eth_test->flags |= ETH_TEST_FL_FAILED;
2030 2040
2031 /* restore speed, duplex, autoneg settings */ 2041 /* restore speed, duplex, autoneg settings */
@@ -2045,16 +2055,16 @@ static void igb_diag_test(struct net_device *netdev,
2045 dev_info(&adapter->pdev->dev, "online testing starting\n"); 2055 dev_info(&adapter->pdev->dev, "online testing starting\n");
2046 2056
2047 /* PHY is powered down when interface is down */ 2057 /* PHY is powered down when interface is down */
2048 if (if_running && igb_link_test(adapter, &data[4])) 2058 if (if_running && igb_link_test(adapter, &data[TEST_LINK]))
2049 eth_test->flags |= ETH_TEST_FL_FAILED; 2059 eth_test->flags |= ETH_TEST_FL_FAILED;
2050 else 2060 else
2051 data[4] = 0; 2061 data[TEST_LINK] = 0;
2052 2062
2053 /* Online tests aren't run; pass by default */ 2063 /* Online tests aren't run; pass by default */
2054 data[0] = 0; 2064 data[TEST_REG] = 0;
2055 data[1] = 0; 2065 data[TEST_EEP] = 0;
2056 data[2] = 0; 2066 data[TEST_IRQ] = 0;
2057 data[3] = 0; 2067 data[TEST_LOOP] = 0;
2058 2068
2059 clear_bit(__IGB_TESTING, &adapter->state); 2069 clear_bit(__IGB_TESTING, &adapter->state);
2060 } 2070 }