diff options
author | Michael Chan <mchan@broadcom.com> | 2005-05-29 17:58:36 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2005-05-29 17:58:36 -0400 |
commit | 7942e1dbd7252b480ed238096dca617189d293df (patch) | |
tree | cb152b70c3276bbe4cbb11600c3da2e98ec638b5 /drivers/net/tg3.c | |
parent | a71116d1f3b85a69fe3a3acec9223fefb4b1fc66 (diff) |
[TG3]: Add memory test
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/tg3.c')
-rw-r--r-- | drivers/net/tg3.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 4589f8f90119..49cb7b3e2835 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -7520,6 +7520,62 @@ out: | |||
7520 | return -EIO; | 7520 | return -EIO; |
7521 | } | 7521 | } |
7522 | 7522 | ||
7523 | static int tg3_do_mem_test(struct tg3 *tp, u32 offset, u32 len) | ||
7524 | { | ||
7525 | static u32 test_pattern[] = { 0x00000000, 0xffffffff, 0xaa55a55a }; | ||
7526 | int i; | ||
7527 | u32 j; | ||
7528 | |||
7529 | for (i = 0; i < sizeof(test_pattern)/sizeof(u32); i++) { | ||
7530 | for (j = 0; j < len; j += 4) { | ||
7531 | u32 val; | ||
7532 | |||
7533 | tg3_write_mem(tp, offset + j, test_pattern[i]); | ||
7534 | tg3_read_mem(tp, offset + j, &val); | ||
7535 | if (val != test_pattern[i]) | ||
7536 | return -EIO; | ||
7537 | } | ||
7538 | } | ||
7539 | return 0; | ||
7540 | } | ||
7541 | |||
7542 | static int tg3_test_memory(struct tg3 *tp) | ||
7543 | { | ||
7544 | static struct mem_entry { | ||
7545 | u32 offset; | ||
7546 | u32 len; | ||
7547 | } mem_tbl_570x[] = { | ||
7548 | { 0x00000000, 0x01000}, | ||
7549 | { 0x00002000, 0x1c000}, | ||
7550 | { 0xffffffff, 0x00000} | ||
7551 | }, mem_tbl_5705[] = { | ||
7552 | { 0x00000100, 0x0000c}, | ||
7553 | { 0x00000200, 0x00008}, | ||
7554 | { 0x00000b50, 0x00400}, | ||
7555 | { 0x00004000, 0x00800}, | ||
7556 | { 0x00006000, 0x01000}, | ||
7557 | { 0x00008000, 0x02000}, | ||
7558 | { 0x00010000, 0x0e000}, | ||
7559 | { 0xffffffff, 0x00000} | ||
7560 | }; | ||
7561 | struct mem_entry *mem_tbl; | ||
7562 | int err = 0; | ||
7563 | int i; | ||
7564 | |||
7565 | if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) | ||
7566 | mem_tbl = mem_tbl_5705; | ||
7567 | else | ||
7568 | mem_tbl = mem_tbl_570x; | ||
7569 | |||
7570 | for (i = 0; mem_tbl[i].offset != 0xffffffff; i++) { | ||
7571 | if ((err = tg3_do_mem_test(tp, mem_tbl[i].offset, | ||
7572 | mem_tbl[i].len)) != 0) | ||
7573 | break; | ||
7574 | } | ||
7575 | |||
7576 | return err; | ||
7577 | } | ||
7578 | |||
7523 | static void tg3_self_test(struct net_device *dev, struct ethtool_test *etest, | 7579 | static void tg3_self_test(struct net_device *dev, struct ethtool_test *etest, |
7524 | u64 *data) | 7580 | u64 *data) |
7525 | { | 7581 | { |
@@ -7553,6 +7609,10 @@ static void tg3_self_test(struct net_device *dev, struct ethtool_test *etest, | |||
7553 | etest->flags |= ETH_TEST_FL_FAILED; | 7609 | etest->flags |= ETH_TEST_FL_FAILED; |
7554 | data[2] = 1; | 7610 | data[2] = 1; |
7555 | } | 7611 | } |
7612 | if (tg3_test_memory(tp) != 0) { | ||
7613 | etest->flags |= ETH_TEST_FL_FAILED; | ||
7614 | data[3] = 1; | ||
7615 | } | ||
7556 | 7616 | ||
7557 | tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); | 7617 | tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); |
7558 | if (netif_running(dev)) { | 7618 | if (netif_running(dev)) { |