diff options
author | David S. Miller <davem@davemloft.net> | 2021-08-23 12:15:05 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2021-08-23 12:15:05 +0200 |
commit | cd3d5d68819d224e588162404fcd70ab535b93ea (patch) | |
tree | 477295dad82d4f55a919285e6d15635b32b9b5b9 /drivers/net/ethernet/chelsio | |
parent | Revert "bnx2x: Read VPD with pci_vpd_alloc()" (diff) | |
download | linux-cd3d5d68819d224e588162404fcd70ab535b93ea.tar.xz linux-cd3d5d68819d224e588162404fcd70ab535b93ea.zip |
Revert "cxgb4: Validate VPD checksum with pci_vpd_check_csum()"
This reverts commit 96ce96f151261e33a170cecb8a4fa664b45743ab.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/chelsio')
-rw-r--r-- | drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 52 |
1 files changed, 20 insertions, 32 deletions
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c index 5e8ac42ac6ab..70bb057320e4 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c @@ -2743,9 +2743,9 @@ int t4_seeprom_wp(struct adapter *adapter, bool enable) */ int t4_get_raw_vpd_params(struct adapter *adapter, struct vpd_params *p) { - unsigned int id_len, pn_len, sn_len, na_len; - int sn, pn, na, addr, ret = 0; - u8 *vpd, base_val = 0; + int i, ret = 0, addr; + u8 *vpd, csum, base_val = 0; + unsigned int vpdr_len, kw_offset, id_len; vpd = vmalloc(VPD_LEN); if (!vpd) @@ -2772,38 +2772,26 @@ int t4_get_raw_vpd_params(struct adapter *adapter, struct vpd_params *p) id_len = pci_vpd_lrdt_size(vpd); - ret = pci_vpd_check_csum(vpd, VPD_LEN); - if (ret) { - dev_err(adapter->pdev_dev, "VPD checksum incorrect or missing\n"); - ret = -EINVAL; - goto out; - } - - ret = pci_vpd_find_ro_info_keyword(vpd, VPD_LEN, - PCI_VPD_RO_KEYWORD_SERIALNO, &sn_len); - if (ret < 0) - goto out; - sn = ret; +#define FIND_VPD_KW(var, name) do { \ + var = pci_vpd_find_info_keyword(vpd, kw_offset, vpdr_len, name); \ + if (var < 0) { \ + dev_err(adapter->pdev_dev, "missing VPD keyword " name "\n"); \ + ret = -EINVAL; \ + goto out; \ + } \ + var += PCI_VPD_INFO_FLD_HDR_SIZE; \ +} while (0) - ret = pci_vpd_find_ro_info_keyword(vpd, VPD_LEN, - PCI_VPD_RO_KEYWORD_PARTNO, &pn_len); - if (ret < 0) - goto out; - pn = ret; + FIND_VPD_KW(i, "RV"); + for (csum = 0; i >= 0; i--) + csum += vpd[i]; - ret = pci_vpd_find_ro_info_keyword(vpd, VPD_LEN, "NA", &na_len); - if (ret < 0) + if (csum) { + dev_err(adapter->pdev_dev, + "corrupted VPD EEPROM, actual csum %u\n", csum); + ret = -EINVAL; goto out; - na = ret; - - memcpy(p->id, vpd + PCI_VPD_LRDT_TAG_SIZE, min_t(int, id_len, ID_LEN)); - strim(p->id); - memcpy(p->sn, vpd + sn, min_t(int, sn_len, SERNUM_LEN)); - strim(p->sn); - memcpy(p->pn, vpd + pn, min_t(int, pn_len, PN_LEN)); - strim(p->pn); - memcpy(p->na, vpd + na, min_t(int, na_len, MACADDR_LEN)); - strim((char *)p->na); + } out: vfree(vpd); |