ixgbevf: Make the 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.

Signed-off-by: Mark Rustad <mark.d.rustad@intel.com>
Tested-by: Phil Schmitt <phillip.j.schmitt@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
This commit is contained in:
Mark Rustad 2014-03-04 03:02:29 +00:00 committed by Jeff Kirsher
parent 06380db6fc
commit 388b2e4c0f
1 changed files with 67 additions and 52 deletions

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Intel 82599 Virtual Function driver Intel 82599 Virtual Function driver
Copyright(c) 1999 - 2012 Intel Corporation. Copyright(c) 1999 - 2014 Intel Corporation.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License, under the terms and conditions of the GNU General Public License,
@ -530,41 +530,47 @@ static const u32 register_test_patterns[] = {
0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF 0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF
}; };
#define REG_PATTERN_TEST(R, M, W) \ static bool reg_pattern_test(struct ixgbevf_adapter *adapter, u64 *data,
{ \ int reg, u32 mask, u32 write)
u32 pat, val, before; \ {
for (pat = 0; pat < ARRAY_SIZE(register_test_patterns); pat++) { \ u32 pat, val, before;
before = readl(adapter->hw.hw_addr + R); \
writel((register_test_patterns[pat] & W), \ for (pat = 0; pat < ARRAY_SIZE(register_test_patterns); pat++) {
(adapter->hw.hw_addr + R)); \ before = ixgbe_read_reg(&adapter->hw, reg);
val = readl(adapter->hw.hw_addr + R); \ ixgbe_write_reg(&adapter->hw, reg,
if (val != (register_test_patterns[pat] & W & M)) { \ register_test_patterns[pat] & write);
hw_dbg(&adapter->hw, \ val = ixgbe_read_reg(&adapter->hw, reg);
"pattern test reg %04X failed: got " \ if (val != (register_test_patterns[pat] & write & mask)) {
"0x%08X expected 0x%08X\n", \ hw_dbg(&adapter->hw,
R, val, (register_test_patterns[pat] & W & M)); \ "pattern test reg %04X failed: got 0x%08X expected 0x%08X\n",
*data = R; \ reg, val,
writel(before, adapter->hw.hw_addr + R); \ register_test_patterns[pat] & write & mask);
return 1; \ *data = reg;
} \ ixgbe_write_reg(&adapter->hw, reg, before);
writel(before, adapter->hw.hw_addr + R); \ return true;
} \ }
ixgbe_write_reg(&adapter->hw, reg, before);
}
return false;
} }
#define REG_SET_AND_CHECK(R, M, W) \ static bool reg_set_and_check(struct ixgbevf_adapter *adapter, u64 *data,
{ \ int reg, u32 mask, u32 write)
u32 val, before; \ {
before = readl(adapter->hw.hw_addr + R); \ u32 val, before;
writel((W & M), (adapter->hw.hw_addr + R)); \
val = readl(adapter->hw.hw_addr + R); \ before = ixgbe_read_reg(&adapter->hw, reg);
if ((W & M) != (val & M)) { \ ixgbe_write_reg(&adapter->hw, reg, write & mask);
pr_err("set/check reg %04X test failed: got 0x%08X expected " \ val = ixgbe_read_reg(&adapter->hw, reg);
"0x%08X\n", R, (val & M), (W & M)); \ if ((write & mask) != (val & mask)) {
*data = R; \ pr_err("set/check reg %04X test failed: got 0x%08X expected 0x%08X\n",
writel(before, (adapter->hw.hw_addr + R)); \ reg, (val & mask), write & mask);
return 1; \ *data = reg;
} \ ixgbe_write_reg(&adapter->hw, reg, before);
writel(before, (adapter->hw.hw_addr + R)); \ return true;
}
ixgbe_write_reg(&adapter->hw, reg, before);
return false;
} }
static int ixgbevf_reg_test(struct ixgbevf_adapter *adapter, u64 *data) static int ixgbevf_reg_test(struct ixgbevf_adapter *adapter, u64 *data)
@ -580,38 +586,47 @@ static int ixgbevf_reg_test(struct ixgbevf_adapter *adapter, u64 *data)
*/ */
while (test->reg) { while (test->reg) {
for (i = 0; i < test->array_len; i++) { for (i = 0; i < test->array_len; i++) {
bool b = false;
switch (test->test_type) { switch (test->test_type) {
case PATTERN_TEST: case PATTERN_TEST:
REG_PATTERN_TEST(test->reg + (i * 0x40), b = reg_pattern_test(adapter, data,
test->mask, test->reg + (i * 0x40),
test->write); test->mask,
test->write);
break; break;
case SET_READ_TEST: case SET_READ_TEST:
REG_SET_AND_CHECK(test->reg + (i * 0x40), b = reg_set_and_check(adapter, data,
test->mask, test->reg + (i * 0x40),
test->write); test->mask,
test->write);
break; break;
case WRITE_NO_TEST: case WRITE_NO_TEST:
writel(test->write, ixgbe_write_reg(&adapter->hw,
(adapter->hw.hw_addr + test->reg) test->reg + (i * 0x40),
+ (i * 0x40)); test->write);
break; break;
case TABLE32_TEST: case TABLE32_TEST:
REG_PATTERN_TEST(test->reg + (i * 4), b = reg_pattern_test(adapter, data,
test->mask, test->reg + (i * 4),
test->write); test->mask,
test->write);
break; break;
case TABLE64_TEST_LO: case TABLE64_TEST_LO:
REG_PATTERN_TEST(test->reg + (i * 8), b = reg_pattern_test(adapter, data,
test->mask, test->reg + (i * 8),
test->write); test->mask,
test->write);
break; break;
case TABLE64_TEST_HI: case TABLE64_TEST_HI:
REG_PATTERN_TEST((test->reg + 4) + (i * 8), b = reg_pattern_test(adapter, data,
test->mask, test->reg + 4 + (i * 8),
test->write); test->mask,
test->write);
break; break;
} }
if (b)
return 1;
} }
test++; test++;
} }