mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-12 05:48:40 +00:00
ixgbe: Make ethtool register test use accessors
Make the ethtool register test use the normal register accessor functions. Also eliminate macros used for calling register test functions to make error exits clearer. Use boolean values for boolean returns instead of 0 and 1. Signed-off-by: Mark Rustad <mark.d.rustad@intel.com> Tested-by: Phil Schmitt <phillip.j.schmitt@intel.com> Signed-off-by: Aaron Brown <aaron.f.brown@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
84227bcd9c
commit
49bde31966
1 changed files with 47 additions and 51 deletions
|
@ -1343,54 +1343,41 @@ static bool reg_pattern_test(struct ixgbe_adapter *adapter, u64 *data, int reg,
|
|||
0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF};
|
||||
|
||||
for (pat = 0; pat < ARRAY_SIZE(test_pattern); pat++) {
|
||||
before = readl(adapter->hw.hw_addr + reg);
|
||||
writel((test_pattern[pat] & write),
|
||||
(adapter->hw.hw_addr + reg));
|
||||
val = readl(adapter->hw.hw_addr + reg);
|
||||
before = ixgbe_read_reg(&adapter->hw, reg);
|
||||
ixgbe_write_reg(&adapter->hw, reg, test_pattern[pat] & write);
|
||||
val = ixgbe_read_reg(&adapter->hw, reg);
|
||||
if (val != (test_pattern[pat] & write & mask)) {
|
||||
e_err(drv, "pattern test reg %04X failed: got "
|
||||
"0x%08X expected 0x%08X\n",
|
||||
reg, val, (test_pattern[pat] & write & mask));
|
||||
*data = reg;
|
||||
writel(before, adapter->hw.hw_addr + reg);
|
||||
return 1;
|
||||
ixgbe_write_reg(&adapter->hw, reg, before);
|
||||
return true;
|
||||
}
|
||||
writel(before, adapter->hw.hw_addr + reg);
|
||||
ixgbe_write_reg(&adapter->hw, reg, before);
|
||||
}
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool reg_set_and_check(struct ixgbe_adapter *adapter, u64 *data, int reg,
|
||||
u32 mask, u32 write)
|
||||
{
|
||||
u32 val, before;
|
||||
before = readl(adapter->hw.hw_addr + reg);
|
||||
writel((write & mask), (adapter->hw.hw_addr + reg));
|
||||
val = readl(adapter->hw.hw_addr + reg);
|
||||
|
||||
before = ixgbe_read_reg(&adapter->hw, reg);
|
||||
ixgbe_write_reg(&adapter->hw, reg, write & mask);
|
||||
val = ixgbe_read_reg(&adapter->hw, reg);
|
||||
if ((write & mask) != (val & mask)) {
|
||||
e_err(drv, "set/check reg %04X test failed: got 0x%08X "
|
||||
"expected 0x%08X\n", reg, (val & mask), (write & mask));
|
||||
*data = reg;
|
||||
writel(before, (adapter->hw.hw_addr + reg));
|
||||
return 1;
|
||||
ixgbe_write_reg(&adapter->hw, reg, before);
|
||||
return true;
|
||||
}
|
||||
writel(before, (adapter->hw.hw_addr + reg));
|
||||
return 0;
|
||||
ixgbe_write_reg(&adapter->hw, reg, before);
|
||||
return false;
|
||||
}
|
||||
|
||||
#define REG_PATTERN_TEST(reg, mask, write) \
|
||||
do { \
|
||||
if (reg_pattern_test(adapter, data, reg, mask, write)) \
|
||||
return 1; \
|
||||
} while (0) \
|
||||
|
||||
|
||||
#define REG_SET_AND_CHECK(reg, mask, write) \
|
||||
do { \
|
||||
if (reg_set_and_check(adapter, data, reg, mask, write)) \
|
||||
return 1; \
|
||||
} while (0) \
|
||||
|
||||
static int ixgbe_reg_test(struct ixgbe_adapter *adapter, u64 *data)
|
||||
{
|
||||
const struct ixgbe_reg_test *test;
|
||||
|
@ -1419,10 +1406,10 @@ static int ixgbe_reg_test(struct ixgbe_adapter *adapter, u64 *data)
|
|||
* tests. Some bits are read-only, some toggle, and some
|
||||
* are writeable on newer MACs.
|
||||
*/
|
||||
before = IXGBE_READ_REG(&adapter->hw, IXGBE_STATUS);
|
||||
value = (IXGBE_READ_REG(&adapter->hw, IXGBE_STATUS) & toggle);
|
||||
IXGBE_WRITE_REG(&adapter->hw, IXGBE_STATUS, toggle);
|
||||
after = IXGBE_READ_REG(&adapter->hw, IXGBE_STATUS) & toggle;
|
||||
before = ixgbe_read_reg(&adapter->hw, IXGBE_STATUS);
|
||||
value = (ixgbe_read_reg(&adapter->hw, IXGBE_STATUS) & toggle);
|
||||
ixgbe_write_reg(&adapter->hw, IXGBE_STATUS, toggle);
|
||||
after = ixgbe_read_reg(&adapter->hw, IXGBE_STATUS) & toggle;
|
||||
if (value != after) {
|
||||
e_err(drv, "failed STATUS register test got: 0x%08X "
|
||||
"expected: 0x%08X\n", after, value);
|
||||
|
@ -1430,7 +1417,7 @@ static int ixgbe_reg_test(struct ixgbe_adapter *adapter, u64 *data)
|
|||
return 1;
|
||||
}
|
||||
/* restore previous status */
|
||||
IXGBE_WRITE_REG(&adapter->hw, IXGBE_STATUS, before);
|
||||
ixgbe_write_reg(&adapter->hw, IXGBE_STATUS, before);
|
||||
|
||||
/*
|
||||
* Perform the remainder of the register test, looping through
|
||||
|
@ -1438,38 +1425,47 @@ static int ixgbe_reg_test(struct ixgbe_adapter *adapter, u64 *data)
|
|||
*/
|
||||
while (test->reg) {
|
||||
for (i = 0; i < test->array_len; i++) {
|
||||
bool b = false;
|
||||
|
||||
switch (test->test_type) {
|
||||
case PATTERN_TEST:
|
||||
REG_PATTERN_TEST(test->reg + (i * 0x40),
|
||||
test->mask,
|
||||
test->write);
|
||||
b = reg_pattern_test(adapter, data,
|
||||
test->reg + (i * 0x40),
|
||||
test->mask,
|
||||
test->write);
|
||||
break;
|
||||
case SET_READ_TEST:
|
||||
REG_SET_AND_CHECK(test->reg + (i * 0x40),
|
||||
test->mask,
|
||||
test->write);
|
||||
b = reg_set_and_check(adapter, data,
|
||||
test->reg + (i * 0x40),
|
||||
test->mask,
|
||||
test->write);
|
||||
break;
|
||||
case WRITE_NO_TEST:
|
||||
writel(test->write,
|
||||
(adapter->hw.hw_addr + test->reg)
|
||||
+ (i * 0x40));
|
||||
ixgbe_write_reg(&adapter->hw,
|
||||
test->reg + (i * 0x40),
|
||||
test->write);
|
||||
break;
|
||||
case TABLE32_TEST:
|
||||
REG_PATTERN_TEST(test->reg + (i * 4),
|
||||
test->mask,
|
||||
test->write);
|
||||
b = reg_pattern_test(adapter, data,
|
||||
test->reg + (i * 4),
|
||||
test->mask,
|
||||
test->write);
|
||||
break;
|
||||
case TABLE64_TEST_LO:
|
||||
REG_PATTERN_TEST(test->reg + (i * 8),
|
||||
test->mask,
|
||||
test->write);
|
||||
b = reg_pattern_test(adapter, data,
|
||||
test->reg + (i * 8),
|
||||
test->mask,
|
||||
test->write);
|
||||
break;
|
||||
case TABLE64_TEST_HI:
|
||||
REG_PATTERN_TEST((test->reg + 4) + (i * 8),
|
||||
test->mask,
|
||||
test->write);
|
||||
b = reg_pattern_test(adapter, data,
|
||||
(test->reg + 4) + (i * 8),
|
||||
test->mask,
|
||||
test->write);
|
||||
break;
|
||||
}
|
||||
if (b)
|
||||
return 1;
|
||||
}
|
||||
test++;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue