Skip to content

Commit d602de0

Browse files
Joe SchultzJeff Kirsher
authored andcommitted
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 <[email protected]> Signed-off-by: Aaron Sierra <[email protected]> Tested-by: Aaron Brown <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 3627f8f commit d602de0

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

drivers/net/ethernet/intel/igb/igb_ethtool.c

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,20 @@ static const struct igb_stats igb_gstrings_net_stats[] = {
127127
#define IGB_STATS_LEN \
128128
(IGB_GLOBAL_STATS_LEN + IGB_NETDEV_STATS_LEN + IGB_QUEUE_STATS_LEN)
129129

130+
enum igb_diagnostics_results {
131+
TEST_REG = 0,
132+
TEST_EEP,
133+
TEST_IRQ,
134+
TEST_LOOP,
135+
TEST_LINK
136+
};
137+
130138
static const char igb_gstrings_test[][ETH_GSTRING_LEN] = {
131-
"Register test (offline)", "Eeprom test (offline)",
132-
"Interrupt test (offline)", "Loopback test (offline)",
133-
"Link test (on/offline)"
139+
[TEST_REG] = "Register test (offline)",
140+
[TEST_EEP] = "Eeprom test (offline)",
141+
[TEST_IRQ] = "Interrupt test (offline)",
142+
[TEST_LOOP] = "Loopback test (offline)",
143+
[TEST_LINK] = "Link test (on/offline)"
134144
};
135145
#define IGB_TEST_LEN (sizeof(igb_gstrings_test) / ETH_GSTRING_LEN)
136146

@@ -2002,7 +2012,7 @@ static void igb_diag_test(struct net_device *netdev,
20022012
/* Link test performed before hardware reset so autoneg doesn't
20032013
* interfere with test result
20042014
*/
2005-
if (igb_link_test(adapter, &data[4]))
2015+
if (igb_link_test(adapter, &data[TEST_LINK]))
20062016
eth_test->flags |= ETH_TEST_FL_FAILED;
20072017

20082018
if (if_running)
@@ -2011,21 +2021,21 @@ static void igb_diag_test(struct net_device *netdev,
20112021
else
20122022
igb_reset(adapter);
20132023

2014-
if (igb_reg_test(adapter, &data[0]))
2024+
if (igb_reg_test(adapter, &data[TEST_REG]))
20152025
eth_test->flags |= ETH_TEST_FL_FAILED;
20162026

20172027
igb_reset(adapter);
2018-
if (igb_eeprom_test(adapter, &data[1]))
2028+
if (igb_eeprom_test(adapter, &data[TEST_EEP]))
20192029
eth_test->flags |= ETH_TEST_FL_FAILED;
20202030

20212031
igb_reset(adapter);
2022-
if (igb_intr_test(adapter, &data[2]))
2032+
if (igb_intr_test(adapter, &data[TEST_IRQ]))
20232033
eth_test->flags |= ETH_TEST_FL_FAILED;
20242034

20252035
igb_reset(adapter);
20262036
/* power up link for loopback test */
20272037
igb_power_up_link(adapter);
2028-
if (igb_loopback_test(adapter, &data[3]))
2038+
if (igb_loopback_test(adapter, &data[TEST_LOOP]))
20292039
eth_test->flags |= ETH_TEST_FL_FAILED;
20302040

20312041
/* restore speed, duplex, autoneg settings */
@@ -2045,16 +2055,16 @@ static void igb_diag_test(struct net_device *netdev,
20452055
dev_info(&adapter->pdev->dev, "online testing starting\n");
20462056

20472057
/* 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]))
20492059
eth_test->flags |= ETH_TEST_FL_FAILED;
20502060
else
2051-
data[4] = 0;
2061+
data[TEST_LINK] = 0;
20522062

20532063
/* Online tests aren't run; pass by default */
2054-
data[0] = 0;
2055-
data[1] = 0;
2056-
data[2] = 0;
2057-
data[3] = 0;
2064+
data[TEST_REG] = 0;
2065+
data[TEST_EEP] = 0;
2066+
data[TEST_IRQ] = 0;
2067+
data[TEST_LOOP] = 0;
20582068

20592069
clear_bit(__IGB_TESTING, &adapter->state);
20602070
}

0 commit comments

Comments
 (0)