aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/tg3.c
diff options
context:
space:
mode:
authorMatt Carlson <mcarlson@broadcom.com>2011-03-09 11:58:21 -0500
committerDavid S. Miller <davem@davemloft.net>2011-03-10 04:56:12 -0500
commitd4894f3ea7375dd9492b5d3d2ecb0b6e4bdb604e (patch)
treea538179ac50d080a4240f7f9da77655d4b40160c /drivers/net/tg3.c
parent01c3a3920f9f78866420b2004602944fca45083a (diff)
tg3: Add code to verify RODATA checksum of VPD
This patch adds code to verify the checksum stored in the "RV" info keyword of the RODATA VPD section. Signed-off-by: Matt Carlson <mcarlson@broadcom.com> Reviewed-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.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 8f7160812e06..ffb09795101e 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -10499,6 +10499,41 @@ static int tg3_test_nvram(struct tg3 *tp)
10499 if (csum != le32_to_cpu(buf[0xfc/4])) 10499 if (csum != le32_to_cpu(buf[0xfc/4]))
10500 goto out; 10500 goto out;
10501 10501
10502 for (i = 0; i < TG3_NVM_VPD_LEN; i += 4) {
10503 /* The data is in little-endian format in NVRAM.
10504 * Use the big-endian read routines to preserve
10505 * the byte order as it exists in NVRAM.
10506 */
10507 if (tg3_nvram_read_be32(tp, TG3_NVM_VPD_OFF + i, &buf[i/4]))
10508 goto out;
10509 }
10510
10511 i = pci_vpd_find_tag((u8 *)buf, 0, TG3_NVM_VPD_LEN,
10512 PCI_VPD_LRDT_RO_DATA);
10513 if (i > 0) {
10514 j = pci_vpd_lrdt_size(&((u8 *)buf)[i]);
10515 if (j < 0)
10516 goto out;
10517
10518 if (i + PCI_VPD_LRDT_TAG_SIZE + j > TG3_NVM_VPD_LEN)
10519 goto out;
10520
10521 i += PCI_VPD_LRDT_TAG_SIZE;
10522 j = pci_vpd_find_info_keyword((u8 *)buf, i, j,
10523 PCI_VPD_RO_KEYWORD_CHKSUM);
10524 if (j > 0) {
10525 u8 csum8 = 0;
10526
10527 j += PCI_VPD_INFO_FLD_HDR_SIZE;
10528
10529 for (i = 0; i <= j; i++)
10530 csum8 += ((u8 *)buf)[i];
10531
10532 if (csum8)
10533 goto out;
10534 }
10535 }
10536
10502 err = 0; 10537 err = 0;
10503 10538
10504out: 10539out: