diff options
author | Michael Chan <mchan@broadcom.com> | 2005-05-29 17:56:58 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2005-05-29 17:56:58 -0400 |
commit | 566f86adb336637d03900f53b886d879aa5f5d56 (patch) | |
tree | 05ca3fb70b781c580e5732e362c26ead80245384 /drivers | |
parent | 4cafd3f533475c976879d85773735c004f09f576 (diff) |
[TG3]: Add nvram test
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/tg3.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 088ed9f634e5..ab2fa213b301 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -7239,9 +7239,59 @@ static void tg3_get_ethtool_stats (struct net_device *dev, | |||
7239 | memcpy(tmp_stats, tg3_get_estats(tp), sizeof(tp->estats)); | 7239 | memcpy(tmp_stats, tg3_get_estats(tp), sizeof(tp->estats)); |
7240 | } | 7240 | } |
7241 | 7241 | ||
7242 | #define NVRAM_TEST_SIZE 0x100 | ||
7243 | |||
7244 | static int tg3_test_nvram(struct tg3 *tp) | ||
7245 | { | ||
7246 | u32 *buf, csum; | ||
7247 | int i, j, err = 0; | ||
7248 | |||
7249 | buf = kmalloc(NVRAM_TEST_SIZE, GFP_KERNEL); | ||
7250 | if (buf == NULL) | ||
7251 | return -ENOMEM; | ||
7252 | |||
7253 | for (i = 0, j = 0; i < NVRAM_TEST_SIZE; i += 4, j++) { | ||
7254 | u32 val; | ||
7255 | |||
7256 | if ((err = tg3_nvram_read(tp, i, &val)) != 0) | ||
7257 | break; | ||
7258 | buf[j] = cpu_to_le32(val); | ||
7259 | } | ||
7260 | if (i < NVRAM_TEST_SIZE) | ||
7261 | goto out; | ||
7262 | |||
7263 | err = -EIO; | ||
7264 | if (cpu_to_be32(buf[0]) != TG3_EEPROM_MAGIC) | ||
7265 | goto out; | ||
7266 | |||
7267 | /* Bootstrap checksum at offset 0x10 */ | ||
7268 | csum = calc_crc((unsigned char *) buf, 0x10); | ||
7269 | if(csum != cpu_to_le32(buf[0x10/4])) | ||
7270 | goto out; | ||
7271 | |||
7272 | /* Manufacturing block starts at offset 0x74, checksum at 0xfc */ | ||
7273 | csum = calc_crc((unsigned char *) &buf[0x74/4], 0x88); | ||
7274 | if (csum != cpu_to_le32(buf[0xfc/4])) | ||
7275 | goto out; | ||
7276 | |||
7277 | err = 0; | ||
7278 | |||
7279 | out: | ||
7280 | kfree(buf); | ||
7281 | return err; | ||
7282 | } | ||
7283 | |||
7242 | static void tg3_self_test(struct net_device *dev, struct ethtool_test *etest, | 7284 | static void tg3_self_test(struct net_device *dev, struct ethtool_test *etest, |
7243 | u64 *data) | 7285 | u64 *data) |
7244 | { | 7286 | { |
7287 | struct tg3 *tp = netdev_priv(dev); | ||
7288 | |||
7289 | memset(data, 0, sizeof(u64) * TG3_NUM_TEST); | ||
7290 | |||
7291 | if (tg3_test_nvram(tp) != 0) { | ||
7292 | etest->flags |= ETH_TEST_FL_FAILED; | ||
7293 | data[0] = 1; | ||
7294 | } | ||
7245 | } | 7295 | } |
7246 | 7296 | ||
7247 | static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | 7297 | static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |