Merge branch 'pci/vpd'
- Check Resource Item Names against those defined for type (Bjorn Helgaas) - Treat initial 0xff as missing EEPROM (Heiner Kallweit) - Reject resource tags with invalid size (Bjorn Helgaas) - Don't check Large Resource Item Names for validity (Bjorn Helgaas) - Allow access to valid parts of VPD if some is invalid (Bjorn Helgaas) - Remove pci_vpd_size() old_size argument (Heiner Kallweit) - Make pci_vpd_wait() uninterruptible (Heiner Kallweit) - Remove struct pci_vpd.flag (Heiner Kallweit) - Remove struct pci_vpd_ops (Heiner Kallweit) - Remove struct pci_vpd.valid member (Heiner Kallweit) - Embed struct pci_vpd in struct pci_dev (Heiner Kallweit) - Determine VPD size in pci_vpd_init() (Heiner Kallweit) - Treat invalid VPD like missing VPD capability (Heiner Kallweit) - Add pci_vpd_alloc() to allocate buffer and read VPD into it (Heiner Kallweit) - Add pci_vpd_find_ro_info_keyword() (Heiner Kallweit) - Add pci_vpd_check_csum() (Heiner Kallweit) - Add pci_vpd_find_id_string() (Heiner Kallweit) - Read VPD with pci_vpd_alloc() (bnx2x, bnxt, sfc, sfc falcon, tg3 drivers) (Heiner Kallweit) - Search VPD with pci_vpd_find_ro_info_keyword() (bnx2, bnx2x, bnxt, cxgb4, cxlflash SCSI, sfc, sfc falcon, tg3 drivers) (Heiner Kallweit) - Search VPD with pci_vpd_find_id_string() (cxgb4 driver) (Heiner Kallweit) - Validate VPD checksum with pci_vpd_check_csum() (cxgb4, tg3 drivers) (Heiner Kallweit) - Replace open-coded byte swapping with swab32s() in bnx2 (Heiner Kallweit) - Remove unused vpd_param member ec (Heiner Kallweit) - Stop exporting pci_vpd_find_tag(), pci_vpd_find_info_keyword() (Heiner Kallweit) - Move several VPD defines and inlines to internal PCI core (Heiner Kallweit) * pci/vpd: PCI/VPD: Use unaligned access helpers PCI/VPD: Clean up public VPD defines and inline functions cxgb4: Use pci_vpd_find_id_string() to find VPD ID string PCI/VPD: Add pci_vpd_find_id_string() PCI/VPD: Include post-processing in pci_vpd_find_tag() PCI/VPD: Stop exporting pci_vpd_find_info_keyword() PCI/VPD: Stop exporting pci_vpd_find_tag() scsi: cxlflash: Search VPD with pci_vpd_find_ro_info_keyword() cxgb4: Search VPD with pci_vpd_find_ro_info_keyword() cxgb4: Remove unused vpd_param member ec cxgb4: Validate VPD checksum with pci_vpd_check_csum() bnxt: Search VPD with pci_vpd_find_ro_info_keyword() bnxt: Read VPD with pci_vpd_alloc() bnx2x: Search VPD with pci_vpd_find_ro_info_keyword() bnx2x: Read VPD with pci_vpd_alloc() bnx2: Replace open-coded byte swapping with swab32s() bnx2: Search VPD with pci_vpd_find_ro_info_keyword() sfc: falcon: Search VPD with pci_vpd_find_ro_info_keyword() sfc: falcon: Read VPD with pci_vpd_alloc() tg3: Search VPD with pci_vpd_find_ro_info_keyword() tg3: Validate VPD checksum with pci_vpd_check_csum() tg3: Read VPD with pci_vpd_alloc() sfc: Search VPD with pci_vpd_find_ro_info_keyword() sfc: Read VPD with pci_vpd_alloc() PCI/VPD: Add pci_vpd_check_csum() PCI/VPD: Add pci_vpd_find_ro_info_keyword() PCI/VPD: Add pci_vpd_alloc() PCI/VPD: Treat invalid VPD like missing VPD capability PCI/VPD: Determine VPD size in pci_vpd_init() PCI/VPD: Embed struct pci_vpd in struct pci_dev PCI/VPD: Remove struct pci_vpd.valid member PCI/VPD: Remove struct pci_vpd_ops PCI/VPD: Reorder pci_read_vpd(), pci_write_vpd() PCI/VPD: Remove struct pci_vpd.flag PCI/VPD: Make pci_vpd_wait() uninterruptible PCI/VPD: Remove pci_vpd_size() old_size argument PCI/VPD: Allow access to valid parts of VPD if some is invalid PCI/VPD: Don't check Large Resource Item Names for validity PCI/VPD: Reject resource tags with invalid size PCI/VPD: Treat initial 0xff as missing EEPROM PCI/VPD: Check Resource Item Names against those valid for type PCI/VPD: Correct diagnostic for VPD read failure
This commit is contained in:
@@ -8033,62 +8033,40 @@ bnx2_get_pci_speed(struct bnx2 *bp)
|
|||||||
static void
|
static void
|
||||||
bnx2_read_vpd_fw_ver(struct bnx2 *bp)
|
bnx2_read_vpd_fw_ver(struct bnx2 *bp)
|
||||||
{
|
{
|
||||||
|
unsigned int len;
|
||||||
int rc, i, j;
|
int rc, i, j;
|
||||||
u8 *data;
|
u8 *data;
|
||||||
unsigned int block_end, rosize, len;
|
|
||||||
|
|
||||||
#define BNX2_VPD_NVRAM_OFFSET 0x300
|
#define BNX2_VPD_NVRAM_OFFSET 0x300
|
||||||
#define BNX2_VPD_LEN 128
|
#define BNX2_VPD_LEN 128
|
||||||
#define BNX2_MAX_VER_SLEN 30
|
#define BNX2_MAX_VER_SLEN 30
|
||||||
|
|
||||||
data = kmalloc(256, GFP_KERNEL);
|
data = kmalloc(BNX2_VPD_LEN, GFP_KERNEL);
|
||||||
if (!data)
|
if (!data)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rc = bnx2_nvram_read(bp, BNX2_VPD_NVRAM_OFFSET, data + BNX2_VPD_LEN,
|
rc = bnx2_nvram_read(bp, BNX2_VPD_NVRAM_OFFSET, data, BNX2_VPD_LEN);
|
||||||
BNX2_VPD_LEN);
|
|
||||||
if (rc)
|
if (rc)
|
||||||
goto vpd_done;
|
goto vpd_done;
|
||||||
|
|
||||||
for (i = 0; i < BNX2_VPD_LEN; i += 4) {
|
for (i = 0; i < BNX2_VPD_LEN; i += 4)
|
||||||
data[i] = data[i + BNX2_VPD_LEN + 3];
|
swab32s((u32 *)&data[i]);
|
||||||
data[i + 1] = data[i + BNX2_VPD_LEN + 2];
|
|
||||||
data[i + 2] = data[i + BNX2_VPD_LEN + 1];
|
|
||||||
data[i + 3] = data[i + BNX2_VPD_LEN];
|
|
||||||
}
|
|
||||||
|
|
||||||
i = pci_vpd_find_tag(data, BNX2_VPD_LEN, PCI_VPD_LRDT_RO_DATA);
|
j = pci_vpd_find_ro_info_keyword(data, BNX2_VPD_LEN,
|
||||||
if (i < 0)
|
PCI_VPD_RO_KEYWORD_MFR_ID, &len);
|
||||||
goto vpd_done;
|
|
||||||
|
|
||||||
rosize = pci_vpd_lrdt_size(&data[i]);
|
|
||||||
i += PCI_VPD_LRDT_TAG_SIZE;
|
|
||||||
block_end = i + rosize;
|
|
||||||
|
|
||||||
if (block_end > BNX2_VPD_LEN)
|
|
||||||
goto vpd_done;
|
|
||||||
|
|
||||||
j = pci_vpd_find_info_keyword(data, i, rosize,
|
|
||||||
PCI_VPD_RO_KEYWORD_MFR_ID);
|
|
||||||
if (j < 0)
|
if (j < 0)
|
||||||
goto vpd_done;
|
goto vpd_done;
|
||||||
|
|
||||||
len = pci_vpd_info_field_size(&data[j]);
|
if (len != 4 || memcmp(&data[j], "1028", 4))
|
||||||
|
|
||||||
j += PCI_VPD_INFO_FLD_HDR_SIZE;
|
|
||||||
if (j + len > block_end || len != 4 ||
|
|
||||||
memcmp(&data[j], "1028", 4))
|
|
||||||
goto vpd_done;
|
goto vpd_done;
|
||||||
|
|
||||||
j = pci_vpd_find_info_keyword(data, i, rosize,
|
j = pci_vpd_find_ro_info_keyword(data, BNX2_VPD_LEN,
|
||||||
PCI_VPD_RO_KEYWORD_VENDOR0);
|
PCI_VPD_RO_KEYWORD_VENDOR0,
|
||||||
|
&len);
|
||||||
if (j < 0)
|
if (j < 0)
|
||||||
goto vpd_done;
|
goto vpd_done;
|
||||||
|
|
||||||
len = pci_vpd_info_field_size(&data[j]);
|
if (len > BNX2_MAX_VER_SLEN)
|
||||||
|
|
||||||
j += PCI_VPD_INFO_FLD_HDR_SIZE;
|
|
||||||
if (j + len > block_end || len > BNX2_MAX_VER_SLEN)
|
|
||||||
goto vpd_done;
|
goto vpd_done;
|
||||||
|
|
||||||
memcpy(bp->fw_version, &data[j], len);
|
memcpy(bp->fw_version, &data[j], len);
|
||||||
|
|||||||
@@ -2407,7 +2407,6 @@ void bnx2x_igu_clear_sb_gen(struct bnx2x *bp, u8 func, u8 idu_sb_id,
|
|||||||
#define ETH_MAX_RX_CLIENTS_E2 ETH_MAX_RX_CLIENTS_E1H
|
#define ETH_MAX_RX_CLIENTS_E2 ETH_MAX_RX_CLIENTS_E1H
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define BNX2X_VPD_LEN 128
|
|
||||||
#define VENDOR_ID_LEN 4
|
#define VENDOR_ID_LEN 4
|
||||||
|
|
||||||
#define VF_ACQUIRE_THRESH 3
|
#define VF_ACQUIRE_THRESH 3
|
||||||
|
|||||||
@@ -12189,86 +12189,35 @@ static int bnx2x_get_hwinfo(struct bnx2x *bp)
|
|||||||
|
|
||||||
static void bnx2x_read_fwinfo(struct bnx2x *bp)
|
static void bnx2x_read_fwinfo(struct bnx2x *bp)
|
||||||
{
|
{
|
||||||
int cnt, i, block_end, rodi;
|
char str_id[VENDOR_ID_LEN + 1];
|
||||||
char vpd_start[BNX2X_VPD_LEN+1];
|
unsigned int vpd_len, kw_len;
|
||||||
char str_id_reg[VENDOR_ID_LEN+1];
|
u8 *vpd_data;
|
||||||
char str_id_cap[VENDOR_ID_LEN+1];
|
int rodi;
|
||||||
char *vpd_data;
|
|
||||||
char *vpd_extended_data = NULL;
|
|
||||||
u8 len;
|
|
||||||
|
|
||||||
cnt = pci_read_vpd(bp->pdev, 0, BNX2X_VPD_LEN, vpd_start);
|
|
||||||
memset(bp->fw_ver, 0, sizeof(bp->fw_ver));
|
memset(bp->fw_ver, 0, sizeof(bp->fw_ver));
|
||||||
|
|
||||||
if (cnt < BNX2X_VPD_LEN)
|
vpd_data = pci_vpd_alloc(bp->pdev, &vpd_len);
|
||||||
|
if (IS_ERR(vpd_data))
|
||||||
|
return;
|
||||||
|
|
||||||
|
rodi = pci_vpd_find_ro_info_keyword(vpd_data, vpd_len,
|
||||||
|
PCI_VPD_RO_KEYWORD_MFR_ID, &kw_len);
|
||||||
|
if (rodi < 0 || kw_len != VENDOR_ID_LEN)
|
||||||
goto out_not_found;
|
goto out_not_found;
|
||||||
|
|
||||||
/* VPD RO tag should be first tag after identifier string, hence
|
|
||||||
* we should be able to find it in first BNX2X_VPD_LEN chars
|
|
||||||
*/
|
|
||||||
i = pci_vpd_find_tag(vpd_start, BNX2X_VPD_LEN, PCI_VPD_LRDT_RO_DATA);
|
|
||||||
if (i < 0)
|
|
||||||
goto out_not_found;
|
|
||||||
|
|
||||||
block_end = i + PCI_VPD_LRDT_TAG_SIZE +
|
|
||||||
pci_vpd_lrdt_size(&vpd_start[i]);
|
|
||||||
|
|
||||||
i += PCI_VPD_LRDT_TAG_SIZE;
|
|
||||||
|
|
||||||
if (block_end > BNX2X_VPD_LEN) {
|
|
||||||
vpd_extended_data = kmalloc(block_end, GFP_KERNEL);
|
|
||||||
if (vpd_extended_data == NULL)
|
|
||||||
goto out_not_found;
|
|
||||||
|
|
||||||
/* read rest of vpd image into vpd_extended_data */
|
|
||||||
memcpy(vpd_extended_data, vpd_start, BNX2X_VPD_LEN);
|
|
||||||
cnt = pci_read_vpd(bp->pdev, BNX2X_VPD_LEN,
|
|
||||||
block_end - BNX2X_VPD_LEN,
|
|
||||||
vpd_extended_data + BNX2X_VPD_LEN);
|
|
||||||
if (cnt < (block_end - BNX2X_VPD_LEN))
|
|
||||||
goto out_not_found;
|
|
||||||
vpd_data = vpd_extended_data;
|
|
||||||
} else
|
|
||||||
vpd_data = vpd_start;
|
|
||||||
|
|
||||||
/* now vpd_data holds full vpd content in both cases */
|
|
||||||
|
|
||||||
rodi = pci_vpd_find_info_keyword(vpd_data, i, block_end,
|
|
||||||
PCI_VPD_RO_KEYWORD_MFR_ID);
|
|
||||||
if (rodi < 0)
|
|
||||||
goto out_not_found;
|
|
||||||
|
|
||||||
len = pci_vpd_info_field_size(&vpd_data[rodi]);
|
|
||||||
|
|
||||||
if (len != VENDOR_ID_LEN)
|
|
||||||
goto out_not_found;
|
|
||||||
|
|
||||||
rodi += PCI_VPD_INFO_FLD_HDR_SIZE;
|
|
||||||
|
|
||||||
/* vendor specific info */
|
/* vendor specific info */
|
||||||
snprintf(str_id_reg, VENDOR_ID_LEN + 1, "%04x", PCI_VENDOR_ID_DELL);
|
snprintf(str_id, VENDOR_ID_LEN + 1, "%04x", PCI_VENDOR_ID_DELL);
|
||||||
snprintf(str_id_cap, VENDOR_ID_LEN + 1, "%04X", PCI_VENDOR_ID_DELL);
|
if (!strncasecmp(str_id, &vpd_data[rodi], VENDOR_ID_LEN)) {
|
||||||
if (!strncmp(str_id_reg, &vpd_data[rodi], VENDOR_ID_LEN) ||
|
rodi = pci_vpd_find_ro_info_keyword(vpd_data, vpd_len,
|
||||||
!strncmp(str_id_cap, &vpd_data[rodi], VENDOR_ID_LEN)) {
|
PCI_VPD_RO_KEYWORD_VENDOR0,
|
||||||
|
&kw_len);
|
||||||
rodi = pci_vpd_find_info_keyword(vpd_data, i, block_end,
|
if (rodi >= 0 && kw_len < sizeof(bp->fw_ver)) {
|
||||||
PCI_VPD_RO_KEYWORD_VENDOR0);
|
memcpy(bp->fw_ver, &vpd_data[rodi], kw_len);
|
||||||
if (rodi >= 0) {
|
bp->fw_ver[kw_len] = ' ';
|
||||||
len = pci_vpd_info_field_size(&vpd_data[rodi]);
|
|
||||||
|
|
||||||
rodi += PCI_VPD_INFO_FLD_HDR_SIZE;
|
|
||||||
|
|
||||||
if (len < 32 && (len + rodi) <= BNX2X_VPD_LEN) {
|
|
||||||
memcpy(bp->fw_ver, &vpd_data[rodi], len);
|
|
||||||
bp->fw_ver[len] = ' ';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
kfree(vpd_extended_data);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
out_not_found:
|
out_not_found:
|
||||||
kfree(vpd_extended_data);
|
kfree(vpd_data);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bnx2x_set_modes_bitmap(struct bnx2x *bp)
|
static void bnx2x_set_modes_bitmap(struct bnx2x *bp)
|
||||||
|
|||||||
@@ -12977,60 +12977,35 @@ static int bnxt_init_mac_addr(struct bnxt *bp)
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BNXT_VPD_LEN 512
|
|
||||||
static void bnxt_vpd_read_info(struct bnxt *bp)
|
static void bnxt_vpd_read_info(struct bnxt *bp)
|
||||||
{
|
{
|
||||||
struct pci_dev *pdev = bp->pdev;
|
struct pci_dev *pdev = bp->pdev;
|
||||||
int i, len, pos, ro_size, size;
|
unsigned int vpd_size, kw_len;
|
||||||
ssize_t vpd_size;
|
int pos, size;
|
||||||
u8 *vpd_data;
|
u8 *vpd_data;
|
||||||
|
|
||||||
vpd_data = kmalloc(BNXT_VPD_LEN, GFP_KERNEL);
|
vpd_data = pci_vpd_alloc(pdev, &vpd_size);
|
||||||
if (!vpd_data)
|
if (IS_ERR(vpd_data)) {
|
||||||
|
pci_warn(pdev, "Unable to read VPD\n");
|
||||||
return;
|
return;
|
||||||
|
|
||||||
vpd_size = pci_read_vpd(pdev, 0, BNXT_VPD_LEN, vpd_data);
|
|
||||||
if (vpd_size <= 0) {
|
|
||||||
netdev_err(bp->dev, "Unable to read VPD\n");
|
|
||||||
goto exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
i = pci_vpd_find_tag(vpd_data, vpd_size, PCI_VPD_LRDT_RO_DATA);
|
pos = pci_vpd_find_ro_info_keyword(vpd_data, vpd_size,
|
||||||
if (i < 0) {
|
PCI_VPD_RO_KEYWORD_PARTNO, &kw_len);
|
||||||
netdev_err(bp->dev, "VPD READ-Only not found\n");
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
ro_size = pci_vpd_lrdt_size(&vpd_data[i]);
|
|
||||||
i += PCI_VPD_LRDT_TAG_SIZE;
|
|
||||||
if (i + ro_size > vpd_size)
|
|
||||||
goto exit;
|
|
||||||
|
|
||||||
pos = pci_vpd_find_info_keyword(vpd_data, i, ro_size,
|
|
||||||
PCI_VPD_RO_KEYWORD_PARTNO);
|
|
||||||
if (pos < 0)
|
if (pos < 0)
|
||||||
goto read_sn;
|
goto read_sn;
|
||||||
|
|
||||||
len = pci_vpd_info_field_size(&vpd_data[pos]);
|
size = min_t(int, kw_len, BNXT_VPD_FLD_LEN - 1);
|
||||||
pos += PCI_VPD_INFO_FLD_HDR_SIZE;
|
|
||||||
if (len + pos > vpd_size)
|
|
||||||
goto read_sn;
|
|
||||||
|
|
||||||
size = min(len, BNXT_VPD_FLD_LEN - 1);
|
|
||||||
memcpy(bp->board_partno, &vpd_data[pos], size);
|
memcpy(bp->board_partno, &vpd_data[pos], size);
|
||||||
|
|
||||||
read_sn:
|
read_sn:
|
||||||
pos = pci_vpd_find_info_keyword(vpd_data, i, ro_size,
|
pos = pci_vpd_find_ro_info_keyword(vpd_data, vpd_size,
|
||||||
PCI_VPD_RO_KEYWORD_SERIALNO);
|
PCI_VPD_RO_KEYWORD_SERIALNO,
|
||||||
|
&kw_len);
|
||||||
if (pos < 0)
|
if (pos < 0)
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
len = pci_vpd_info_field_size(&vpd_data[pos]);
|
size = min_t(int, kw_len, BNXT_VPD_FLD_LEN - 1);
|
||||||
pos += PCI_VPD_INFO_FLD_HDR_SIZE;
|
|
||||||
if (len + pos > vpd_size)
|
|
||||||
goto exit;
|
|
||||||
|
|
||||||
size = min(len, BNXT_VPD_FLD_LEN - 1);
|
|
||||||
memcpy(bp->board_serialno, &vpd_data[pos], size);
|
memcpy(bp->board_serialno, &vpd_data[pos], size);
|
||||||
exit:
|
exit:
|
||||||
kfree(vpd_data);
|
kfree(vpd_data);
|
||||||
|
|||||||
@@ -12791,7 +12791,7 @@ static void tg3_get_ethtool_stats(struct net_device *dev,
|
|||||||
memset(tmp_stats, 0, sizeof(struct tg3_ethtool_stats));
|
memset(tmp_stats, 0, sizeof(struct tg3_ethtool_stats));
|
||||||
}
|
}
|
||||||
|
|
||||||
static __be32 *tg3_vpd_readblock(struct tg3 *tp, u32 *vpdlen)
|
static __be32 *tg3_vpd_readblock(struct tg3 *tp, unsigned int *vpdlen)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
__be32 *buf;
|
__be32 *buf;
|
||||||
@@ -12825,15 +12825,11 @@ static __be32 *tg3_vpd_readblock(struct tg3 *tp, u32 *vpdlen)
|
|||||||
offset = TG3_NVM_VPD_OFF;
|
offset = TG3_NVM_VPD_OFF;
|
||||||
len = TG3_NVM_VPD_LEN;
|
len = TG3_NVM_VPD_LEN;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
len = TG3_NVM_PCI_VPD_MAX_LEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
buf = kmalloc(len, GFP_KERNEL);
|
buf = kmalloc(len, GFP_KERNEL);
|
||||||
if (buf == NULL)
|
if (!buf)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (magic == TG3_EEPROM_MAGIC) {
|
|
||||||
for (i = 0; i < len; i += 4) {
|
for (i = 0; i < len; i += 4) {
|
||||||
/* The data is in little-endian format in NVRAM.
|
/* The data is in little-endian format in NVRAM.
|
||||||
* Use the big-endian read routines to preserve
|
* Use the big-endian read routines to preserve
|
||||||
@@ -12844,12 +12840,9 @@ static __be32 *tg3_vpd_readblock(struct tg3 *tp, u32 *vpdlen)
|
|||||||
}
|
}
|
||||||
*vpdlen = len;
|
*vpdlen = len;
|
||||||
} else {
|
} else {
|
||||||
ssize_t cnt;
|
buf = pci_vpd_alloc(tp->pdev, vpdlen);
|
||||||
|
if (IS_ERR(buf))
|
||||||
cnt = pci_read_vpd(tp->pdev, 0, len, (u8 *)buf);
|
return NULL;
|
||||||
if (cnt < 0)
|
|
||||||
goto error;
|
|
||||||
*vpdlen = cnt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
@@ -12871,9 +12864,10 @@ error:
|
|||||||
|
|
||||||
static int tg3_test_nvram(struct tg3 *tp)
|
static int tg3_test_nvram(struct tg3 *tp)
|
||||||
{
|
{
|
||||||
u32 csum, magic, len;
|
u32 csum, magic;
|
||||||
__be32 *buf;
|
__be32 *buf;
|
||||||
int i, j, k, err = 0, size;
|
int i, j, k, err = 0, size;
|
||||||
|
unsigned int len;
|
||||||
|
|
||||||
if (tg3_flag(tp, NO_NVRAM))
|
if (tg3_flag(tp, NO_NVRAM))
|
||||||
return 0;
|
return 0;
|
||||||
@@ -13016,33 +13010,10 @@ static int tg3_test_nvram(struct tg3 *tp)
|
|||||||
if (!buf)
|
if (!buf)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
i = pci_vpd_find_tag((u8 *)buf, len, PCI_VPD_LRDT_RO_DATA);
|
err = pci_vpd_check_csum(buf, len);
|
||||||
if (i > 0) {
|
/* go on if no checksum found */
|
||||||
j = pci_vpd_lrdt_size(&((u8 *)buf)[i]);
|
if (err == 1)
|
||||||
if (j < 0)
|
err = 0;
|
||||||
goto out;
|
|
||||||
|
|
||||||
if (i + PCI_VPD_LRDT_TAG_SIZE + j > len)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
i += PCI_VPD_LRDT_TAG_SIZE;
|
|
||||||
j = pci_vpd_find_info_keyword((u8 *)buf, i, j,
|
|
||||||
PCI_VPD_RO_KEYWORD_CHKSUM);
|
|
||||||
if (j > 0) {
|
|
||||||
u8 csum8 = 0;
|
|
||||||
|
|
||||||
j += PCI_VPD_INFO_FLD_HDR_SIZE;
|
|
||||||
|
|
||||||
for (i = 0; i <= j; i++)
|
|
||||||
csum8 += ((u8 *)buf)[i];
|
|
||||||
|
|
||||||
if (csum8)
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
err = 0;
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
kfree(buf);
|
kfree(buf);
|
||||||
return err;
|
return err;
|
||||||
@@ -15621,64 +15592,36 @@ skip_phy_reset:
|
|||||||
static void tg3_read_vpd(struct tg3 *tp)
|
static void tg3_read_vpd(struct tg3 *tp)
|
||||||
{
|
{
|
||||||
u8 *vpd_data;
|
u8 *vpd_data;
|
||||||
unsigned int block_end, rosize, len;
|
unsigned int len, vpdlen;
|
||||||
u32 vpdlen;
|
int i;
|
||||||
int j, i = 0;
|
|
||||||
|
|
||||||
vpd_data = (u8 *)tg3_vpd_readblock(tp, &vpdlen);
|
vpd_data = (u8 *)tg3_vpd_readblock(tp, &vpdlen);
|
||||||
if (!vpd_data)
|
if (!vpd_data)
|
||||||
goto out_no_vpd;
|
goto out_no_vpd;
|
||||||
|
|
||||||
i = pci_vpd_find_tag(vpd_data, vpdlen, PCI_VPD_LRDT_RO_DATA);
|
i = pci_vpd_find_ro_info_keyword(vpd_data, vpdlen,
|
||||||
|
PCI_VPD_RO_KEYWORD_MFR_ID, &len);
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
goto out_not_found;
|
goto partno;
|
||||||
|
|
||||||
rosize = pci_vpd_lrdt_size(&vpd_data[i]);
|
if (len != 4 || memcmp(vpd_data + i, "1028", 4))
|
||||||
block_end = i + PCI_VPD_LRDT_TAG_SIZE + rosize;
|
goto partno;
|
||||||
i += PCI_VPD_LRDT_TAG_SIZE;
|
|
||||||
|
|
||||||
if (block_end > vpdlen)
|
i = pci_vpd_find_ro_info_keyword(vpd_data, vpdlen,
|
||||||
goto out_not_found;
|
PCI_VPD_RO_KEYWORD_VENDOR0, &len);
|
||||||
|
if (i < 0)
|
||||||
|
goto partno;
|
||||||
|
|
||||||
j = pci_vpd_find_info_keyword(vpd_data, i, rosize,
|
memset(tp->fw_ver, 0, sizeof(tp->fw_ver));
|
||||||
PCI_VPD_RO_KEYWORD_MFR_ID);
|
snprintf(tp->fw_ver, sizeof(tp->fw_ver), "%.*s bc ", len, vpd_data + i);
|
||||||
if (j > 0) {
|
|
||||||
len = pci_vpd_info_field_size(&vpd_data[j]);
|
|
||||||
|
|
||||||
j += PCI_VPD_INFO_FLD_HDR_SIZE;
|
|
||||||
if (j + len > block_end || len != 4 ||
|
|
||||||
memcmp(&vpd_data[j], "1028", 4))
|
|
||||||
goto partno;
|
|
||||||
|
|
||||||
j = pci_vpd_find_info_keyword(vpd_data, i, rosize,
|
|
||||||
PCI_VPD_RO_KEYWORD_VENDOR0);
|
|
||||||
if (j < 0)
|
|
||||||
goto partno;
|
|
||||||
|
|
||||||
len = pci_vpd_info_field_size(&vpd_data[j]);
|
|
||||||
|
|
||||||
j += PCI_VPD_INFO_FLD_HDR_SIZE;
|
|
||||||
if (j + len > block_end)
|
|
||||||
goto partno;
|
|
||||||
|
|
||||||
if (len >= sizeof(tp->fw_ver))
|
|
||||||
len = sizeof(tp->fw_ver) - 1;
|
|
||||||
memset(tp->fw_ver, 0, sizeof(tp->fw_ver));
|
|
||||||
snprintf(tp->fw_ver, sizeof(tp->fw_ver), "%.*s bc ", len,
|
|
||||||
&vpd_data[j]);
|
|
||||||
}
|
|
||||||
|
|
||||||
partno:
|
partno:
|
||||||
i = pci_vpd_find_info_keyword(vpd_data, i, rosize,
|
i = pci_vpd_find_ro_info_keyword(vpd_data, vpdlen,
|
||||||
PCI_VPD_RO_KEYWORD_PARTNO);
|
PCI_VPD_RO_KEYWORD_PARTNO, &len);
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
goto out_not_found;
|
goto out_not_found;
|
||||||
|
|
||||||
len = pci_vpd_info_field_size(&vpd_data[i]);
|
if (len > TG3_BPN_SIZE)
|
||||||
|
|
||||||
i += PCI_VPD_INFO_FLD_HDR_SIZE;
|
|
||||||
if (len > TG3_BPN_SIZE ||
|
|
||||||
(len + i) > vpdlen)
|
|
||||||
goto out_not_found;
|
goto out_not_found;
|
||||||
|
|
||||||
memcpy(tp->board_part_number, &vpd_data[i], len);
|
memcpy(tp->board_part_number, &vpd_data[i], len);
|
||||||
|
|||||||
@@ -2101,7 +2101,6 @@
|
|||||||
/* Hardware Legacy NVRAM layout */
|
/* Hardware Legacy NVRAM layout */
|
||||||
#define TG3_NVM_VPD_OFF 0x100
|
#define TG3_NVM_VPD_OFF 0x100
|
||||||
#define TG3_NVM_VPD_LEN 256
|
#define TG3_NVM_VPD_LEN 256
|
||||||
#define TG3_NVM_PCI_VPD_MAX_LEN 512
|
|
||||||
|
|
||||||
/* Hardware Selfboot NVRAM layout */
|
/* Hardware Selfboot NVRAM layout */
|
||||||
#define TG3_NVM_HWSB_CFG1 0x00000004
|
#define TG3_NVM_HWSB_CFG1 0x00000004
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ extern struct mutex uld_mutex;
|
|||||||
enum {
|
enum {
|
||||||
MAX_NPORTS = 4, /* max # of ports */
|
MAX_NPORTS = 4, /* max # of ports */
|
||||||
SERNUM_LEN = 24, /* Serial # length */
|
SERNUM_LEN = 24, /* Serial # length */
|
||||||
EC_LEN = 16, /* E/C length */
|
|
||||||
ID_LEN = 16, /* ID length */
|
ID_LEN = 16, /* ID length */
|
||||||
PN_LEN = 16, /* Part Number length */
|
PN_LEN = 16, /* Part Number length */
|
||||||
MACADDR_LEN = 12, /* MAC Address length */
|
MACADDR_LEN = 12, /* MAC Address length */
|
||||||
@@ -391,7 +390,6 @@ struct tp_params {
|
|||||||
|
|
||||||
struct vpd_params {
|
struct vpd_params {
|
||||||
unsigned int cclk;
|
unsigned int cclk;
|
||||||
u8 ec[EC_LEN + 1];
|
|
||||||
u8 sn[SERNUM_LEN + 1];
|
u8 sn[SERNUM_LEN + 1];
|
||||||
u8 id[ID_LEN + 1];
|
u8 id[ID_LEN + 1];
|
||||||
u8 pn[PN_LEN + 1];
|
u8 pn[PN_LEN + 1];
|
||||||
|
|||||||
@@ -2743,10 +2743,9 @@ int t4_seeprom_wp(struct adapter *adapter, bool enable)
|
|||||||
*/
|
*/
|
||||||
int t4_get_raw_vpd_params(struct adapter *adapter, struct vpd_params *p)
|
int t4_get_raw_vpd_params(struct adapter *adapter, struct vpd_params *p)
|
||||||
{
|
{
|
||||||
int i, ret = 0, addr;
|
unsigned int id_len, pn_len, sn_len, na_len;
|
||||||
int ec, sn, pn, na;
|
int id, sn, pn, na, addr, ret = 0;
|
||||||
u8 *vpd, csum, base_val = 0;
|
u8 *vpd, base_val = 0;
|
||||||
unsigned int vpdr_len, kw_offset, id_len;
|
|
||||||
|
|
||||||
vpd = vmalloc(VPD_LEN);
|
vpd = vmalloc(VPD_LEN);
|
||||||
if (!vpd)
|
if (!vpd)
|
||||||
@@ -2765,74 +2764,52 @@ int t4_get_raw_vpd_params(struct adapter *adapter, struct vpd_params *p)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (vpd[0] != PCI_VPD_LRDT_ID_STRING) {
|
ret = pci_vpd_find_id_string(vpd, VPD_LEN, &id_len);
|
||||||
dev_err(adapter->pdev_dev, "missing VPD ID string\n");
|
if (ret < 0)
|
||||||
|
goto out;
|
||||||
|
id = ret;
|
||||||
|
|
||||||
|
ret = pci_vpd_check_csum(vpd, VPD_LEN);
|
||||||
|
if (ret) {
|
||||||
|
dev_err(adapter->pdev_dev, "VPD checksum incorrect or missing\n");
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
id_len = pci_vpd_lrdt_size(vpd);
|
ret = pci_vpd_find_ro_info_keyword(vpd, VPD_LEN,
|
||||||
if (id_len > ID_LEN)
|
PCI_VPD_RO_KEYWORD_SERIALNO, &sn_len);
|
||||||
id_len = ID_LEN;
|
if (ret < 0)
|
||||||
|
|
||||||
i = pci_vpd_find_tag(vpd, VPD_LEN, PCI_VPD_LRDT_RO_DATA);
|
|
||||||
if (i < 0) {
|
|
||||||
dev_err(adapter->pdev_dev, "missing VPD-R section\n");
|
|
||||||
ret = -EINVAL;
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
sn = ret;
|
||||||
|
|
||||||
vpdr_len = pci_vpd_lrdt_size(&vpd[i]);
|
ret = pci_vpd_find_ro_info_keyword(vpd, VPD_LEN,
|
||||||
kw_offset = i + PCI_VPD_LRDT_TAG_SIZE;
|
PCI_VPD_RO_KEYWORD_PARTNO, &pn_len);
|
||||||
if (vpdr_len + kw_offset > VPD_LEN) {
|
if (ret < 0)
|
||||||
dev_err(adapter->pdev_dev, "bad VPD-R length %u\n", vpdr_len);
|
|
||||||
ret = -EINVAL;
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
pn = ret;
|
||||||
|
|
||||||
#define FIND_VPD_KW(var, name) do { \
|
ret = pci_vpd_find_ro_info_keyword(vpd, VPD_LEN, "NA", &na_len);
|
||||||
var = pci_vpd_find_info_keyword(vpd, kw_offset, vpdr_len, name); \
|
if (ret < 0)
|
||||||
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)
|
|
||||||
|
|
||||||
FIND_VPD_KW(i, "RV");
|
|
||||||
for (csum = 0; i >= 0; i--)
|
|
||||||
csum += vpd[i];
|
|
||||||
|
|
||||||
if (csum) {
|
|
||||||
dev_err(adapter->pdev_dev,
|
|
||||||
"corrupted VPD EEPROM, actual csum %u\n", csum);
|
|
||||||
ret = -EINVAL;
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
na = ret;
|
||||||
|
|
||||||
FIND_VPD_KW(ec, "EC");
|
memcpy(p->id, vpd + id, min_t(int, id_len, ID_LEN));
|
||||||
FIND_VPD_KW(sn, "SN");
|
|
||||||
FIND_VPD_KW(pn, "PN");
|
|
||||||
FIND_VPD_KW(na, "NA");
|
|
||||||
#undef FIND_VPD_KW
|
|
||||||
|
|
||||||
memcpy(p->id, vpd + PCI_VPD_LRDT_TAG_SIZE, id_len);
|
|
||||||
strim(p->id);
|
strim(p->id);
|
||||||
memcpy(p->ec, vpd + ec, EC_LEN);
|
memcpy(p->sn, vpd + sn, min_t(int, sn_len, SERNUM_LEN));
|
||||||
strim(p->ec);
|
|
||||||
i = pci_vpd_info_field_size(vpd + sn - PCI_VPD_INFO_FLD_HDR_SIZE);
|
|
||||||
memcpy(p->sn, vpd + sn, min(i, SERNUM_LEN));
|
|
||||||
strim(p->sn);
|
strim(p->sn);
|
||||||
i = pci_vpd_info_field_size(vpd + pn - PCI_VPD_INFO_FLD_HDR_SIZE);
|
memcpy(p->pn, vpd + pn, min_t(int, pn_len, PN_LEN));
|
||||||
memcpy(p->pn, vpd + pn, min(i, PN_LEN));
|
|
||||||
strim(p->pn);
|
strim(p->pn);
|
||||||
memcpy(p->na, vpd + na, min(i, MACADDR_LEN));
|
memcpy(p->na, vpd + na, min_t(int, na_len, MACADDR_LEN));
|
||||||
strim((char *)p->na);
|
strim((char *)p->na);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
vfree(vpd);
|
vfree(vpd);
|
||||||
return ret < 0 ? ret : 0;
|
if (ret < 0) {
|
||||||
|
dev_err(adapter->pdev_dev, "error reading VPD\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -900,74 +900,36 @@ static void efx_pci_remove(struct pci_dev *pci_dev)
|
|||||||
|
|
||||||
/* NIC VPD information
|
/* NIC VPD information
|
||||||
* Called during probe to display the part number of the
|
* Called during probe to display the part number of the
|
||||||
* installed NIC. VPD is potentially very large but this should
|
* installed NIC.
|
||||||
* always appear within the first 512 bytes.
|
|
||||||
*/
|
*/
|
||||||
#define SFC_VPD_LEN 512
|
|
||||||
static void efx_probe_vpd_strings(struct efx_nic *efx)
|
static void efx_probe_vpd_strings(struct efx_nic *efx)
|
||||||
{
|
{
|
||||||
struct pci_dev *dev = efx->pci_dev;
|
struct pci_dev *dev = efx->pci_dev;
|
||||||
char vpd_data[SFC_VPD_LEN];
|
unsigned int vpd_size, kw_len;
|
||||||
ssize_t vpd_size;
|
u8 *vpd_data;
|
||||||
int ro_start, ro_size, i, j;
|
int start;
|
||||||
|
|
||||||
/* Get the vpd data from the device */
|
vpd_data = pci_vpd_alloc(dev, &vpd_size);
|
||||||
vpd_size = pci_read_vpd(dev, 0, sizeof(vpd_data), vpd_data);
|
if (IS_ERR(vpd_data)) {
|
||||||
if (vpd_size <= 0) {
|
pci_warn(dev, "Unable to read VPD\n");
|
||||||
netif_err(efx, drv, efx->net_dev, "Unable to read VPD\n");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the Read only section */
|
start = pci_vpd_find_ro_info_keyword(vpd_data, vpd_size,
|
||||||
ro_start = pci_vpd_find_tag(vpd_data, vpd_size, PCI_VPD_LRDT_RO_DATA);
|
PCI_VPD_RO_KEYWORD_PARTNO, &kw_len);
|
||||||
if (ro_start < 0) {
|
if (start < 0)
|
||||||
netif_err(efx, drv, efx->net_dev, "VPD Read-only not found\n");
|
pci_err(dev, "Part number not found or incomplete\n");
|
||||||
return;
|
else
|
||||||
}
|
pci_info(dev, "Part Number : %.*s\n", kw_len, vpd_data + start);
|
||||||
|
|
||||||
ro_size = pci_vpd_lrdt_size(&vpd_data[ro_start]);
|
start = pci_vpd_find_ro_info_keyword(vpd_data, vpd_size,
|
||||||
j = ro_size;
|
PCI_VPD_RO_KEYWORD_SERIALNO, &kw_len);
|
||||||
i = ro_start + PCI_VPD_LRDT_TAG_SIZE;
|
if (start < 0)
|
||||||
if (i + j > vpd_size)
|
pci_err(dev, "Serial number not found or incomplete\n");
|
||||||
j = vpd_size - i;
|
else
|
||||||
|
efx->vpd_sn = kmemdup_nul(vpd_data + start, kw_len, GFP_KERNEL);
|
||||||
|
|
||||||
/* Get the Part number */
|
kfree(vpd_data);
|
||||||
i = pci_vpd_find_info_keyword(vpd_data, i, j, "PN");
|
|
||||||
if (i < 0) {
|
|
||||||
netif_err(efx, drv, efx->net_dev, "Part number not found\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
j = pci_vpd_info_field_size(&vpd_data[i]);
|
|
||||||
i += PCI_VPD_INFO_FLD_HDR_SIZE;
|
|
||||||
if (i + j > vpd_size) {
|
|
||||||
netif_err(efx, drv, efx->net_dev, "Incomplete part number\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
netif_info(efx, drv, efx->net_dev,
|
|
||||||
"Part Number : %.*s\n", j, &vpd_data[i]);
|
|
||||||
|
|
||||||
i = ro_start + PCI_VPD_LRDT_TAG_SIZE;
|
|
||||||
j = ro_size;
|
|
||||||
i = pci_vpd_find_info_keyword(vpd_data, i, j, "SN");
|
|
||||||
if (i < 0) {
|
|
||||||
netif_err(efx, drv, efx->net_dev, "Serial number not found\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
j = pci_vpd_info_field_size(&vpd_data[i]);
|
|
||||||
i += PCI_VPD_INFO_FLD_HDR_SIZE;
|
|
||||||
if (i + j > vpd_size) {
|
|
||||||
netif_err(efx, drv, efx->net_dev, "Incomplete serial number\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
efx->vpd_sn = kmalloc(j + 1, GFP_KERNEL);
|
|
||||||
if (!efx->vpd_sn)
|
|
||||||
return;
|
|
||||||
|
|
||||||
snprintf(efx->vpd_sn, j + 1, "%s", &vpd_data[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2780,75 +2780,36 @@ static void ef4_pci_remove(struct pci_dev *pci_dev)
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* NIC VPD information
|
/* NIC VPD information
|
||||||
* Called during probe to display the part number of the
|
* Called during probe to display the part number of the installed NIC.
|
||||||
* installed NIC. VPD is potentially very large but this should
|
|
||||||
* always appear within the first 512 bytes.
|
|
||||||
*/
|
*/
|
||||||
#define SFC_VPD_LEN 512
|
|
||||||
static void ef4_probe_vpd_strings(struct ef4_nic *efx)
|
static void ef4_probe_vpd_strings(struct ef4_nic *efx)
|
||||||
{
|
{
|
||||||
struct pci_dev *dev = efx->pci_dev;
|
struct pci_dev *dev = efx->pci_dev;
|
||||||
char vpd_data[SFC_VPD_LEN];
|
unsigned int vpd_size, kw_len;
|
||||||
ssize_t vpd_size;
|
u8 *vpd_data;
|
||||||
int ro_start, ro_size, i, j;
|
int start;
|
||||||
|
|
||||||
/* Get the vpd data from the device */
|
vpd_data = pci_vpd_alloc(dev, &vpd_size);
|
||||||
vpd_size = pci_read_vpd(dev, 0, sizeof(vpd_data), vpd_data);
|
if (IS_ERR(vpd_data)) {
|
||||||
if (vpd_size <= 0) {
|
pci_warn(dev, "Unable to read VPD\n");
|
||||||
netif_err(efx, drv, efx->net_dev, "Unable to read VPD\n");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the Read only section */
|
start = pci_vpd_find_ro_info_keyword(vpd_data, vpd_size,
|
||||||
ro_start = pci_vpd_find_tag(vpd_data, vpd_size, PCI_VPD_LRDT_RO_DATA);
|
PCI_VPD_RO_KEYWORD_PARTNO, &kw_len);
|
||||||
if (ro_start < 0) {
|
if (start < 0)
|
||||||
netif_err(efx, drv, efx->net_dev, "VPD Read-only not found\n");
|
pci_warn(dev, "Part number not found or incomplete\n");
|
||||||
return;
|
else
|
||||||
}
|
pci_info(dev, "Part Number : %.*s\n", kw_len, vpd_data + start);
|
||||||
|
|
||||||
ro_size = pci_vpd_lrdt_size(&vpd_data[ro_start]);
|
start = pci_vpd_find_ro_info_keyword(vpd_data, vpd_size,
|
||||||
j = ro_size;
|
PCI_VPD_RO_KEYWORD_SERIALNO, &kw_len);
|
||||||
i = ro_start + PCI_VPD_LRDT_TAG_SIZE;
|
if (start < 0)
|
||||||
if (i + j > vpd_size)
|
pci_warn(dev, "Serial number not found or incomplete\n");
|
||||||
j = vpd_size - i;
|
else
|
||||||
|
efx->vpd_sn = kmemdup_nul(vpd_data + start, kw_len, GFP_KERNEL);
|
||||||
|
|
||||||
/* Get the Part number */
|
kfree(vpd_data);
|
||||||
i = pci_vpd_find_info_keyword(vpd_data, i, j, "PN");
|
|
||||||
if (i < 0) {
|
|
||||||
netif_err(efx, drv, efx->net_dev, "Part number not found\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
j = pci_vpd_info_field_size(&vpd_data[i]);
|
|
||||||
i += PCI_VPD_INFO_FLD_HDR_SIZE;
|
|
||||||
if (i + j > vpd_size) {
|
|
||||||
netif_err(efx, drv, efx->net_dev, "Incomplete part number\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
netif_info(efx, drv, efx->net_dev,
|
|
||||||
"Part Number : %.*s\n", j, &vpd_data[i]);
|
|
||||||
|
|
||||||
i = ro_start + PCI_VPD_LRDT_TAG_SIZE;
|
|
||||||
j = ro_size;
|
|
||||||
i = pci_vpd_find_info_keyword(vpd_data, i, j, "SN");
|
|
||||||
if (i < 0) {
|
|
||||||
netif_err(efx, drv, efx->net_dev, "Serial number not found\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
j = pci_vpd_info_field_size(&vpd_data[i]);
|
|
||||||
i += PCI_VPD_INFO_FLD_HDR_SIZE;
|
|
||||||
if (i + j > vpd_size) {
|
|
||||||
netif_err(efx, drv, efx->net_dev, "Incomplete serial number\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
efx->vpd_sn = kmalloc(j + 1, GFP_KERNEL);
|
|
||||||
if (!efx->vpd_sn)
|
|
||||||
return;
|
|
||||||
|
|
||||||
snprintf(efx->vpd_sn, j + 1, "%s", &vpd_data[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2230,7 +2230,6 @@ static void pci_release_capabilities(struct pci_dev *dev)
|
|||||||
{
|
{
|
||||||
pci_aer_exit(dev);
|
pci_aer_exit(dev);
|
||||||
pci_rcec_exit(dev);
|
pci_rcec_exit(dev);
|
||||||
pci_vpd_release(dev);
|
|
||||||
pci_iov_release(dev);
|
pci_iov_release(dev);
|
||||||
pci_free_cap_save_buffers(dev);
|
pci_free_cap_save_buffers(dev);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,116 +9,94 @@
|
|||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#include <linux/export.h>
|
#include <linux/export.h>
|
||||||
#include <linux/sched/signal.h>
|
#include <linux/sched/signal.h>
|
||||||
|
#include <asm/unaligned.h>
|
||||||
#include "pci.h"
|
#include "pci.h"
|
||||||
|
|
||||||
|
#define PCI_VPD_LRDT_TAG_SIZE 3
|
||||||
|
#define PCI_VPD_SRDT_LEN_MASK 0x07
|
||||||
|
#define PCI_VPD_SRDT_TAG_SIZE 1
|
||||||
|
#define PCI_VPD_STIN_END 0x0f
|
||||||
|
#define PCI_VPD_INFO_FLD_HDR_SIZE 3
|
||||||
|
|
||||||
|
static u16 pci_vpd_lrdt_size(const u8 *lrdt)
|
||||||
|
{
|
||||||
|
return get_unaligned_le16(lrdt + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static u8 pci_vpd_srdt_tag(const u8 *srdt)
|
||||||
|
{
|
||||||
|
return *srdt >> 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
static u8 pci_vpd_srdt_size(const u8 *srdt)
|
||||||
|
{
|
||||||
|
return *srdt & PCI_VPD_SRDT_LEN_MASK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static u8 pci_vpd_info_field_size(const u8 *info_field)
|
||||||
|
{
|
||||||
|
return info_field[2];
|
||||||
|
}
|
||||||
|
|
||||||
/* VPD access through PCI 2.2+ VPD capability */
|
/* VPD access through PCI 2.2+ VPD capability */
|
||||||
|
|
||||||
struct pci_vpd_ops {
|
|
||||||
ssize_t (*read)(struct pci_dev *dev, loff_t pos, size_t count, void *buf);
|
|
||||||
ssize_t (*write)(struct pci_dev *dev, loff_t pos, size_t count, const void *buf);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct pci_vpd {
|
|
||||||
const struct pci_vpd_ops *ops;
|
|
||||||
struct mutex lock;
|
|
||||||
unsigned int len;
|
|
||||||
u16 flag;
|
|
||||||
u8 cap;
|
|
||||||
unsigned int busy:1;
|
|
||||||
unsigned int valid:1;
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct pci_dev *pci_get_func0_dev(struct pci_dev *dev)
|
static struct pci_dev *pci_get_func0_dev(struct pci_dev *dev)
|
||||||
{
|
{
|
||||||
return pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
|
return pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#define PCI_VPD_MAX_SIZE (PCI_VPD_ADDR_MASK + 1)
|
||||||
* pci_read_vpd - Read one entry from Vital Product Data
|
#define PCI_VPD_SZ_INVALID UINT_MAX
|
||||||
* @dev: pci device struct
|
|
||||||
* @pos: offset in vpd space
|
|
||||||
* @count: number of bytes to read
|
|
||||||
* @buf: pointer to where to store result
|
|
||||||
*/
|
|
||||||
ssize_t pci_read_vpd(struct pci_dev *dev, loff_t pos, size_t count, void *buf)
|
|
||||||
{
|
|
||||||
if (!dev->vpd || !dev->vpd->ops)
|
|
||||||
return -ENODEV;
|
|
||||||
return dev->vpd->ops->read(dev, pos, count, buf);
|
|
||||||
}
|
|
||||||
EXPORT_SYMBOL(pci_read_vpd);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* pci_write_vpd - Write entry to Vital Product Data
|
|
||||||
* @dev: pci device struct
|
|
||||||
* @pos: offset in vpd space
|
|
||||||
* @count: number of bytes to write
|
|
||||||
* @buf: buffer containing write data
|
|
||||||
*/
|
|
||||||
ssize_t pci_write_vpd(struct pci_dev *dev, loff_t pos, size_t count, const void *buf)
|
|
||||||
{
|
|
||||||
if (!dev->vpd || !dev->vpd->ops)
|
|
||||||
return -ENODEV;
|
|
||||||
return dev->vpd->ops->write(dev, pos, count, buf);
|
|
||||||
}
|
|
||||||
EXPORT_SYMBOL(pci_write_vpd);
|
|
||||||
|
|
||||||
#define PCI_VPD_MAX_SIZE (PCI_VPD_ADDR_MASK + 1)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pci_vpd_size - determine actual size of Vital Product Data
|
* pci_vpd_size - determine actual size of Vital Product Data
|
||||||
* @dev: pci device struct
|
* @dev: pci device struct
|
||||||
* @old_size: current assumed size, also maximum allowed size
|
|
||||||
*/
|
*/
|
||||||
static size_t pci_vpd_size(struct pci_dev *dev, size_t old_size)
|
static size_t pci_vpd_size(struct pci_dev *dev)
|
||||||
{
|
{
|
||||||
size_t off = 0;
|
size_t off = 0, size;
|
||||||
unsigned char header[1+2]; /* 1 byte tag, 2 bytes length */
|
unsigned char tag, header[1+2]; /* 1 byte tag, 2 bytes length */
|
||||||
|
|
||||||
while (off < old_size && pci_read_vpd(dev, off, 1, header) == 1) {
|
/* Otherwise the following reads would fail. */
|
||||||
unsigned char tag;
|
dev->vpd.len = PCI_VPD_MAX_SIZE;
|
||||||
|
|
||||||
if (!header[0] && !off) {
|
while (pci_read_vpd(dev, off, 1, header) == 1) {
|
||||||
pci_info(dev, "Invalid VPD tag 00, assume missing optional VPD EPROM\n");
|
size = 0;
|
||||||
return 0;
|
|
||||||
}
|
if (off == 0 && (header[0] == 0x00 || header[0] == 0xff))
|
||||||
|
goto error;
|
||||||
|
|
||||||
if (header[0] & PCI_VPD_LRDT) {
|
if (header[0] & PCI_VPD_LRDT) {
|
||||||
/* Large Resource Data Type Tag */
|
/* Large Resource Data Type Tag */
|
||||||
tag = pci_vpd_lrdt_tag(header);
|
if (pci_read_vpd(dev, off + 1, 2, &header[1]) != 2) {
|
||||||
/* Only read length from known tag items */
|
pci_warn(dev, "failed VPD read at offset %zu\n",
|
||||||
if ((tag == PCI_VPD_LTIN_ID_STRING) ||
|
off + 1);
|
||||||
(tag == PCI_VPD_LTIN_RO_DATA) ||
|
return off ?: PCI_VPD_SZ_INVALID;
|
||||||
(tag == PCI_VPD_LTIN_RW_DATA)) {
|
|
||||||
if (pci_read_vpd(dev, off+1, 2,
|
|
||||||
&header[1]) != 2) {
|
|
||||||
pci_warn(dev, "invalid large VPD tag %02x size at offset %zu",
|
|
||||||
tag, off + 1);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
off += PCI_VPD_LRDT_TAG_SIZE +
|
|
||||||
pci_vpd_lrdt_size(header);
|
|
||||||
}
|
}
|
||||||
|
size = pci_vpd_lrdt_size(header);
|
||||||
|
if (off + size > PCI_VPD_MAX_SIZE)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
off += PCI_VPD_LRDT_TAG_SIZE + size;
|
||||||
} else {
|
} else {
|
||||||
/* Short Resource Data Type Tag */
|
/* Short Resource Data Type Tag */
|
||||||
off += PCI_VPD_SRDT_TAG_SIZE +
|
|
||||||
pci_vpd_srdt_size(header);
|
|
||||||
tag = pci_vpd_srdt_tag(header);
|
tag = pci_vpd_srdt_tag(header);
|
||||||
}
|
size = pci_vpd_srdt_size(header);
|
||||||
|
if (off + size > PCI_VPD_MAX_SIZE)
|
||||||
|
goto error;
|
||||||
|
|
||||||
if (tag == PCI_VPD_STIN_END) /* End tag descriptor */
|
off += PCI_VPD_SRDT_TAG_SIZE + size;
|
||||||
return off;
|
if (tag == PCI_VPD_STIN_END) /* End tag descriptor */
|
||||||
|
return off;
|
||||||
if ((tag != PCI_VPD_LTIN_ID_STRING) &&
|
|
||||||
(tag != PCI_VPD_LTIN_RO_DATA) &&
|
|
||||||
(tag != PCI_VPD_LTIN_RW_DATA)) {
|
|
||||||
pci_warn(dev, "invalid %s VPD tag %02x at offset %zu",
|
|
||||||
(header[0] & PCI_VPD_LRDT) ? "large" : "short",
|
|
||||||
tag, off);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return off;
|
||||||
|
|
||||||
|
error:
|
||||||
|
pci_info(dev, "invalid VPD tag %#04x (size %zu) at offset %zu%s\n",
|
||||||
|
header[0], size, off, off == 0 ?
|
||||||
|
"; assume missing optional EEPROM" : "");
|
||||||
|
return off ?: PCI_VPD_SZ_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -126,33 +104,26 @@ static size_t pci_vpd_size(struct pci_dev *dev, size_t old_size)
|
|||||||
* This code has to spin since there is no other notification from the PCI
|
* This code has to spin since there is no other notification from the PCI
|
||||||
* hardware. Since the VPD is often implemented by serial attachment to an
|
* hardware. Since the VPD is often implemented by serial attachment to an
|
||||||
* EEPROM, it may take many milliseconds to complete.
|
* EEPROM, it may take many milliseconds to complete.
|
||||||
|
* @set: if true wait for flag to be set, else wait for it to be cleared
|
||||||
*
|
*
|
||||||
* Returns 0 on success, negative values indicate error.
|
* Returns 0 on success, negative values indicate error.
|
||||||
*/
|
*/
|
||||||
static int pci_vpd_wait(struct pci_dev *dev)
|
static int pci_vpd_wait(struct pci_dev *dev, bool set)
|
||||||
{
|
{
|
||||||
struct pci_vpd *vpd = dev->vpd;
|
struct pci_vpd *vpd = &dev->vpd;
|
||||||
unsigned long timeout = jiffies + msecs_to_jiffies(125);
|
unsigned long timeout = jiffies + msecs_to_jiffies(125);
|
||||||
unsigned long max_sleep = 16;
|
unsigned long max_sleep = 16;
|
||||||
u16 status;
|
u16 status;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!vpd->busy)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
ret = pci_user_read_config_word(dev, vpd->cap + PCI_VPD_ADDR,
|
ret = pci_user_read_config_word(dev, vpd->cap + PCI_VPD_ADDR,
|
||||||
&status);
|
&status);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if ((status & PCI_VPD_ADDR_F) == vpd->flag) {
|
if (!!(status & PCI_VPD_ADDR_F) == set)
|
||||||
vpd->busy = 0;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
if (fatal_signal_pending(current))
|
|
||||||
return -EINTR;
|
|
||||||
|
|
||||||
if (time_after(jiffies, timeout))
|
if (time_after(jiffies, timeout))
|
||||||
break;
|
break;
|
||||||
@@ -169,22 +140,17 @@ static int pci_vpd_wait(struct pci_dev *dev)
|
|||||||
static ssize_t pci_vpd_read(struct pci_dev *dev, loff_t pos, size_t count,
|
static ssize_t pci_vpd_read(struct pci_dev *dev, loff_t pos, size_t count,
|
||||||
void *arg)
|
void *arg)
|
||||||
{
|
{
|
||||||
struct pci_vpd *vpd = dev->vpd;
|
struct pci_vpd *vpd = &dev->vpd;
|
||||||
int ret;
|
int ret = 0;
|
||||||
loff_t end = pos + count;
|
loff_t end = pos + count;
|
||||||
u8 *buf = arg;
|
u8 *buf = arg;
|
||||||
|
|
||||||
|
if (!vpd->cap)
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
if (pos < 0)
|
if (pos < 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (!vpd->valid) {
|
|
||||||
vpd->valid = 1;
|
|
||||||
vpd->len = pci_vpd_size(dev, vpd->len);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vpd->len == 0)
|
|
||||||
return -EIO;
|
|
||||||
|
|
||||||
if (pos > vpd->len)
|
if (pos > vpd->len)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -196,21 +162,20 @@ static ssize_t pci_vpd_read(struct pci_dev *dev, loff_t pos, size_t count,
|
|||||||
if (mutex_lock_killable(&vpd->lock))
|
if (mutex_lock_killable(&vpd->lock))
|
||||||
return -EINTR;
|
return -EINTR;
|
||||||
|
|
||||||
ret = pci_vpd_wait(dev);
|
|
||||||
if (ret < 0)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
while (pos < end) {
|
while (pos < end) {
|
||||||
u32 val;
|
u32 val;
|
||||||
unsigned int i, skip;
|
unsigned int i, skip;
|
||||||
|
|
||||||
|
if (fatal_signal_pending(current)) {
|
||||||
|
ret = -EINTR;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
ret = pci_user_write_config_word(dev, vpd->cap + PCI_VPD_ADDR,
|
ret = pci_user_write_config_word(dev, vpd->cap + PCI_VPD_ADDR,
|
||||||
pos & ~3);
|
pos & ~3);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
break;
|
break;
|
||||||
vpd->busy = 1;
|
ret = pci_vpd_wait(dev, true);
|
||||||
vpd->flag = PCI_VPD_ADDR_F;
|
|
||||||
ret = pci_vpd_wait(dev);
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -228,7 +193,7 @@ static ssize_t pci_vpd_read(struct pci_dev *dev, loff_t pos, size_t count,
|
|||||||
val >>= 8;
|
val >>= 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out:
|
|
||||||
mutex_unlock(&vpd->lock);
|
mutex_unlock(&vpd->lock);
|
||||||
return ret ? ret : count;
|
return ret ? ret : count;
|
||||||
}
|
}
|
||||||
@@ -236,41 +201,26 @@ out:
|
|||||||
static ssize_t pci_vpd_write(struct pci_dev *dev, loff_t pos, size_t count,
|
static ssize_t pci_vpd_write(struct pci_dev *dev, loff_t pos, size_t count,
|
||||||
const void *arg)
|
const void *arg)
|
||||||
{
|
{
|
||||||
struct pci_vpd *vpd = dev->vpd;
|
struct pci_vpd *vpd = &dev->vpd;
|
||||||
const u8 *buf = arg;
|
const u8 *buf = arg;
|
||||||
loff_t end = pos + count;
|
loff_t end = pos + count;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
if (!vpd->cap)
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
if (pos < 0 || (pos & 3) || (count & 3))
|
if (pos < 0 || (pos & 3) || (count & 3))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (!vpd->valid) {
|
|
||||||
vpd->valid = 1;
|
|
||||||
vpd->len = pci_vpd_size(dev, vpd->len);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vpd->len == 0)
|
|
||||||
return -EIO;
|
|
||||||
|
|
||||||
if (end > vpd->len)
|
if (end > vpd->len)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (mutex_lock_killable(&vpd->lock))
|
if (mutex_lock_killable(&vpd->lock))
|
||||||
return -EINTR;
|
return -EINTR;
|
||||||
|
|
||||||
ret = pci_vpd_wait(dev);
|
|
||||||
if (ret < 0)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
while (pos < end) {
|
while (pos < end) {
|
||||||
u32 val;
|
ret = pci_user_write_config_dword(dev, vpd->cap + PCI_VPD_DATA,
|
||||||
|
get_unaligned_le32(buf));
|
||||||
val = *buf++;
|
|
||||||
val |= *buf++ << 8;
|
|
||||||
val |= *buf++ << 16;
|
|
||||||
val |= *buf++ << 24;
|
|
||||||
|
|
||||||
ret = pci_user_write_config_dword(dev, vpd->cap + PCI_VPD_DATA, val);
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
break;
|
break;
|
||||||
ret = pci_user_write_config_word(dev, vpd->cap + PCI_VPD_ADDR,
|
ret = pci_user_write_config_word(dev, vpd->cap + PCI_VPD_ADDR,
|
||||||
@@ -278,85 +228,28 @@ static ssize_t pci_vpd_write(struct pci_dev *dev, loff_t pos, size_t count,
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
vpd->busy = 1;
|
ret = pci_vpd_wait(dev, false);
|
||||||
vpd->flag = 0;
|
|
||||||
ret = pci_vpd_wait(dev);
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
buf += sizeof(u32);
|
||||||
pos += sizeof(u32);
|
pos += sizeof(u32);
|
||||||
}
|
}
|
||||||
out:
|
|
||||||
mutex_unlock(&vpd->lock);
|
mutex_unlock(&vpd->lock);
|
||||||
return ret ? ret : count;
|
return ret ? ret : count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct pci_vpd_ops pci_vpd_ops = {
|
|
||||||
.read = pci_vpd_read,
|
|
||||||
.write = pci_vpd_write,
|
|
||||||
};
|
|
||||||
|
|
||||||
static ssize_t pci_vpd_f0_read(struct pci_dev *dev, loff_t pos, size_t count,
|
|
||||||
void *arg)
|
|
||||||
{
|
|
||||||
struct pci_dev *tdev = pci_get_func0_dev(dev);
|
|
||||||
ssize_t ret;
|
|
||||||
|
|
||||||
if (!tdev)
|
|
||||||
return -ENODEV;
|
|
||||||
|
|
||||||
ret = pci_read_vpd(tdev, pos, count, arg);
|
|
||||||
pci_dev_put(tdev);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ssize_t pci_vpd_f0_write(struct pci_dev *dev, loff_t pos, size_t count,
|
|
||||||
const void *arg)
|
|
||||||
{
|
|
||||||
struct pci_dev *tdev = pci_get_func0_dev(dev);
|
|
||||||
ssize_t ret;
|
|
||||||
|
|
||||||
if (!tdev)
|
|
||||||
return -ENODEV;
|
|
||||||
|
|
||||||
ret = pci_write_vpd(tdev, pos, count, arg);
|
|
||||||
pci_dev_put(tdev);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct pci_vpd_ops pci_vpd_f0_ops = {
|
|
||||||
.read = pci_vpd_f0_read,
|
|
||||||
.write = pci_vpd_f0_write,
|
|
||||||
};
|
|
||||||
|
|
||||||
void pci_vpd_init(struct pci_dev *dev)
|
void pci_vpd_init(struct pci_dev *dev)
|
||||||
{
|
{
|
||||||
struct pci_vpd *vpd;
|
dev->vpd.cap = pci_find_capability(dev, PCI_CAP_ID_VPD);
|
||||||
u8 cap;
|
mutex_init(&dev->vpd.lock);
|
||||||
|
|
||||||
cap = pci_find_capability(dev, PCI_CAP_ID_VPD);
|
if (!dev->vpd.len)
|
||||||
if (!cap)
|
dev->vpd.len = pci_vpd_size(dev);
|
||||||
return;
|
|
||||||
|
|
||||||
vpd = kzalloc(sizeof(*vpd), GFP_ATOMIC);
|
if (dev->vpd.len == PCI_VPD_SZ_INVALID)
|
||||||
if (!vpd)
|
dev->vpd.cap = 0;
|
||||||
return;
|
|
||||||
|
|
||||||
vpd->len = PCI_VPD_MAX_SIZE;
|
|
||||||
if (dev->dev_flags & PCI_DEV_FLAGS_VPD_REF_F0)
|
|
||||||
vpd->ops = &pci_vpd_f0_ops;
|
|
||||||
else
|
|
||||||
vpd->ops = &pci_vpd_ops;
|
|
||||||
mutex_init(&vpd->lock);
|
|
||||||
vpd->cap = cap;
|
|
||||||
vpd->busy = 0;
|
|
||||||
vpd->valid = 0;
|
|
||||||
dev->vpd = vpd;
|
|
||||||
}
|
|
||||||
|
|
||||||
void pci_vpd_release(struct pci_dev *dev)
|
|
||||||
{
|
|
||||||
kfree(dev->vpd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t vpd_read(struct file *filp, struct kobject *kobj,
|
static ssize_t vpd_read(struct file *filp, struct kobject *kobj,
|
||||||
@@ -388,7 +281,7 @@ static umode_t vpd_attr_is_visible(struct kobject *kobj,
|
|||||||
{
|
{
|
||||||
struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
|
struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
|
||||||
|
|
||||||
if (!pdev->vpd)
|
if (!pdev->vpd.cap)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return a->attr.mode;
|
return a->attr.mode;
|
||||||
@@ -399,23 +292,63 @@ const struct attribute_group pci_dev_vpd_attr_group = {
|
|||||||
.is_bin_visible = vpd_attr_is_visible,
|
.is_bin_visible = vpd_attr_is_visible,
|
||||||
};
|
};
|
||||||
|
|
||||||
int pci_vpd_find_tag(const u8 *buf, unsigned int len, u8 rdt)
|
void *pci_vpd_alloc(struct pci_dev *dev, unsigned int *size)
|
||||||
|
{
|
||||||
|
unsigned int len = dev->vpd.len;
|
||||||
|
void *buf;
|
||||||
|
int cnt;
|
||||||
|
|
||||||
|
if (!dev->vpd.cap)
|
||||||
|
return ERR_PTR(-ENODEV);
|
||||||
|
|
||||||
|
buf = kmalloc(len, GFP_KERNEL);
|
||||||
|
if (!buf)
|
||||||
|
return ERR_PTR(-ENOMEM);
|
||||||
|
|
||||||
|
cnt = pci_read_vpd(dev, 0, len, buf);
|
||||||
|
if (cnt != len) {
|
||||||
|
kfree(buf);
|
||||||
|
return ERR_PTR(-EIO);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (size)
|
||||||
|
*size = len;
|
||||||
|
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(pci_vpd_alloc);
|
||||||
|
|
||||||
|
static int pci_vpd_find_tag(const u8 *buf, unsigned int len, u8 rdt, unsigned int *size)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
/* look for LRDT tags only, end tag is the only SRDT tag */
|
/* look for LRDT tags only, end tag is the only SRDT tag */
|
||||||
while (i + PCI_VPD_LRDT_TAG_SIZE <= len && buf[i] & PCI_VPD_LRDT) {
|
while (i + PCI_VPD_LRDT_TAG_SIZE <= len && buf[i] & PCI_VPD_LRDT) {
|
||||||
if (buf[i] == rdt)
|
unsigned int lrdt_len = pci_vpd_lrdt_size(buf + i);
|
||||||
return i;
|
u8 tag = buf[i];
|
||||||
|
|
||||||
i += PCI_VPD_LRDT_TAG_SIZE + pci_vpd_lrdt_size(buf + i);
|
i += PCI_VPD_LRDT_TAG_SIZE;
|
||||||
|
if (tag == rdt) {
|
||||||
|
if (i + lrdt_len > len)
|
||||||
|
lrdt_len = len - i;
|
||||||
|
if (size)
|
||||||
|
*size = lrdt_len;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
i += lrdt_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(pci_vpd_find_tag);
|
|
||||||
|
|
||||||
int pci_vpd_find_info_keyword(const u8 *buf, unsigned int off,
|
int pci_vpd_find_id_string(const u8 *buf, unsigned int len, unsigned int *size)
|
||||||
|
{
|
||||||
|
return pci_vpd_find_tag(buf, len, PCI_VPD_LRDT_ID_STRING, size);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(pci_vpd_find_id_string);
|
||||||
|
|
||||||
|
static int pci_vpd_find_info_keyword(const u8 *buf, unsigned int off,
|
||||||
unsigned int len, const char *kw)
|
unsigned int len, const char *kw)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -431,7 +364,106 @@ int pci_vpd_find_info_keyword(const u8 *buf, unsigned int off,
|
|||||||
|
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(pci_vpd_find_info_keyword);
|
|
||||||
|
/**
|
||||||
|
* pci_read_vpd - Read one entry from Vital Product Data
|
||||||
|
* @dev: PCI device struct
|
||||||
|
* @pos: offset in VPD space
|
||||||
|
* @count: number of bytes to read
|
||||||
|
* @buf: pointer to where to store result
|
||||||
|
*/
|
||||||
|
ssize_t pci_read_vpd(struct pci_dev *dev, loff_t pos, size_t count, void *buf)
|
||||||
|
{
|
||||||
|
ssize_t ret;
|
||||||
|
|
||||||
|
if (dev->dev_flags & PCI_DEV_FLAGS_VPD_REF_F0) {
|
||||||
|
dev = pci_get_func0_dev(dev);
|
||||||
|
if (!dev)
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
|
ret = pci_vpd_read(dev, pos, count, buf);
|
||||||
|
pci_dev_put(dev);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pci_vpd_read(dev, pos, count, buf);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(pci_read_vpd);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pci_write_vpd - Write entry to Vital Product Data
|
||||||
|
* @dev: PCI device struct
|
||||||
|
* @pos: offset in VPD space
|
||||||
|
* @count: number of bytes to write
|
||||||
|
* @buf: buffer containing write data
|
||||||
|
*/
|
||||||
|
ssize_t pci_write_vpd(struct pci_dev *dev, loff_t pos, size_t count, const void *buf)
|
||||||
|
{
|
||||||
|
ssize_t ret;
|
||||||
|
|
||||||
|
if (dev->dev_flags & PCI_DEV_FLAGS_VPD_REF_F0) {
|
||||||
|
dev = pci_get_func0_dev(dev);
|
||||||
|
if (!dev)
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
|
ret = pci_vpd_write(dev, pos, count, buf);
|
||||||
|
pci_dev_put(dev);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pci_vpd_write(dev, pos, count, buf);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(pci_write_vpd);
|
||||||
|
|
||||||
|
int pci_vpd_find_ro_info_keyword(const void *buf, unsigned int len,
|
||||||
|
const char *kw, unsigned int *size)
|
||||||
|
{
|
||||||
|
int ro_start, infokw_start;
|
||||||
|
unsigned int ro_len, infokw_size;
|
||||||
|
|
||||||
|
ro_start = pci_vpd_find_tag(buf, len, PCI_VPD_LRDT_RO_DATA, &ro_len);
|
||||||
|
if (ro_start < 0)
|
||||||
|
return ro_start;
|
||||||
|
|
||||||
|
infokw_start = pci_vpd_find_info_keyword(buf, ro_start, ro_len, kw);
|
||||||
|
if (infokw_start < 0)
|
||||||
|
return infokw_start;
|
||||||
|
|
||||||
|
infokw_size = pci_vpd_info_field_size(buf + infokw_start);
|
||||||
|
infokw_start += PCI_VPD_INFO_FLD_HDR_SIZE;
|
||||||
|
|
||||||
|
if (infokw_start + infokw_size > len)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (size)
|
||||||
|
*size = infokw_size;
|
||||||
|
|
||||||
|
return infokw_start;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(pci_vpd_find_ro_info_keyword);
|
||||||
|
|
||||||
|
int pci_vpd_check_csum(const void *buf, unsigned int len)
|
||||||
|
{
|
||||||
|
const u8 *vpd = buf;
|
||||||
|
unsigned int size;
|
||||||
|
u8 csum = 0;
|
||||||
|
int rv_start;
|
||||||
|
|
||||||
|
rv_start = pci_vpd_find_ro_info_keyword(buf, len, PCI_VPD_RO_KEYWORD_CHKSUM, &size);
|
||||||
|
if (rv_start == -ENOENT) /* no checksum in VPD */
|
||||||
|
return 1;
|
||||||
|
else if (rv_start < 0)
|
||||||
|
return rv_start;
|
||||||
|
|
||||||
|
if (!size)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
while (rv_start >= 0)
|
||||||
|
csum += vpd[rv_start--];
|
||||||
|
|
||||||
|
return csum ? -EILSEQ : 0;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(pci_vpd_check_csum);
|
||||||
|
|
||||||
#ifdef CONFIG_PCI_QUIRKS
|
#ifdef CONFIG_PCI_QUIRKS
|
||||||
/*
|
/*
|
||||||
@@ -450,7 +482,7 @@ static void quirk_f0_vpd_link(struct pci_dev *dev)
|
|||||||
if (!f0)
|
if (!f0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (f0->vpd && dev->class == f0->class &&
|
if (f0->vpd.cap && dev->class == f0->class &&
|
||||||
dev->vendor == f0->vendor && dev->device == f0->device)
|
dev->vendor == f0->vendor && dev->device == f0->device)
|
||||||
dev->dev_flags |= PCI_DEV_FLAGS_VPD_REF_F0;
|
dev->dev_flags |= PCI_DEV_FLAGS_VPD_REF_F0;
|
||||||
|
|
||||||
@@ -468,41 +500,27 @@ DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, PCI_ANY_ID,
|
|||||||
*/
|
*/
|
||||||
static void quirk_blacklist_vpd(struct pci_dev *dev)
|
static void quirk_blacklist_vpd(struct pci_dev *dev)
|
||||||
{
|
{
|
||||||
if (dev->vpd) {
|
dev->vpd.len = PCI_VPD_SZ_INVALID;
|
||||||
dev->vpd->len = 0;
|
pci_warn(dev, FW_BUG "disabling VPD access (can't determine size of non-standard VPD format)\n");
|
||||||
pci_warn(dev, FW_BUG "disabling VPD access (can't determine size of non-standard VPD format)\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x0060, quirk_blacklist_vpd);
|
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_LSI_LOGIC, 0x0060, quirk_blacklist_vpd);
|
||||||
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x007c, quirk_blacklist_vpd);
|
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_LSI_LOGIC, 0x007c, quirk_blacklist_vpd);
|
||||||
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x0413, quirk_blacklist_vpd);
|
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_LSI_LOGIC, 0x0413, quirk_blacklist_vpd);
|
||||||
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x0078, quirk_blacklist_vpd);
|
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_LSI_LOGIC, 0x0078, quirk_blacklist_vpd);
|
||||||
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x0079, quirk_blacklist_vpd);
|
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_LSI_LOGIC, 0x0079, quirk_blacklist_vpd);
|
||||||
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x0073, quirk_blacklist_vpd);
|
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_LSI_LOGIC, 0x0073, quirk_blacklist_vpd);
|
||||||
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x0071, quirk_blacklist_vpd);
|
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_LSI_LOGIC, 0x0071, quirk_blacklist_vpd);
|
||||||
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x005b, quirk_blacklist_vpd);
|
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_LSI_LOGIC, 0x005b, quirk_blacklist_vpd);
|
||||||
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x002f, quirk_blacklist_vpd);
|
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_LSI_LOGIC, 0x002f, quirk_blacklist_vpd);
|
||||||
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x005d, quirk_blacklist_vpd);
|
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_LSI_LOGIC, 0x005d, quirk_blacklist_vpd);
|
||||||
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x005f, quirk_blacklist_vpd);
|
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_LSI_LOGIC, 0x005f, quirk_blacklist_vpd);
|
||||||
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATTANSIC, PCI_ANY_ID,
|
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATTANSIC, PCI_ANY_ID, quirk_blacklist_vpd);
|
||||||
quirk_blacklist_vpd);
|
|
||||||
/*
|
/*
|
||||||
* The Amazon Annapurna Labs 0x0031 device id is reused for other non Root Port
|
* The Amazon Annapurna Labs 0x0031 device id is reused for other non Root Port
|
||||||
* device types, so the quirk is registered for the PCI_CLASS_BRIDGE_PCI class.
|
* device types, so the quirk is registered for the PCI_CLASS_BRIDGE_PCI class.
|
||||||
*/
|
*/
|
||||||
DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_AMAZON_ANNAPURNA_LABS, 0x0031,
|
DECLARE_PCI_FIXUP_CLASS_HEADER(PCI_VENDOR_ID_AMAZON_ANNAPURNA_LABS, 0x0031,
|
||||||
PCI_CLASS_BRIDGE_PCI, 8, quirk_blacklist_vpd);
|
PCI_CLASS_BRIDGE_PCI, 8, quirk_blacklist_vpd);
|
||||||
|
|
||||||
static void pci_vpd_set_size(struct pci_dev *dev, size_t len)
|
|
||||||
{
|
|
||||||
struct pci_vpd *vpd = dev->vpd;
|
|
||||||
|
|
||||||
if (!vpd || len == 0 || len > PCI_VPD_MAX_SIZE)
|
|
||||||
return;
|
|
||||||
|
|
||||||
vpd->valid = 1;
|
|
||||||
vpd->len = len;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void quirk_chelsio_extend_vpd(struct pci_dev *dev)
|
static void quirk_chelsio_extend_vpd(struct pci_dev *dev)
|
||||||
{
|
{
|
||||||
@@ -522,12 +540,12 @@ static void quirk_chelsio_extend_vpd(struct pci_dev *dev)
|
|||||||
* limits.
|
* limits.
|
||||||
*/
|
*/
|
||||||
if (chip == 0x0 && prod >= 0x20)
|
if (chip == 0x0 && prod >= 0x20)
|
||||||
pci_vpd_set_size(dev, 8192);
|
dev->vpd.len = 8192;
|
||||||
else if (chip >= 0x4 && func < 0x8)
|
else if (chip >= 0x4 && func < 0x8)
|
||||||
pci_vpd_set_size(dev, 2048);
|
dev->vpd.len = 2048;
|
||||||
}
|
}
|
||||||
|
|
||||||
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, PCI_ANY_ID,
|
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_CHELSIO, PCI_ANY_ID,
|
||||||
quirk_chelsio_extend_vpd);
|
quirk_chelsio_extend_vpd);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1629,8 +1629,8 @@ static int read_vpd(struct cxlflash_cfg *cfg, u64 wwpn[])
|
|||||||
{
|
{
|
||||||
struct device *dev = &cfg->dev->dev;
|
struct device *dev = &cfg->dev->dev;
|
||||||
struct pci_dev *pdev = cfg->dev;
|
struct pci_dev *pdev = cfg->dev;
|
||||||
int rc = 0;
|
int i, k, rc = 0;
|
||||||
int ro_start, ro_size, i, j, k;
|
unsigned int kw_size;
|
||||||
ssize_t vpd_size;
|
ssize_t vpd_size;
|
||||||
char vpd_data[CXLFLASH_VPD_LEN];
|
char vpd_data[CXLFLASH_VPD_LEN];
|
||||||
char tmp_buf[WWPN_BUF_LEN] = { 0 };
|
char tmp_buf[WWPN_BUF_LEN] = { 0 };
|
||||||
@@ -1648,24 +1648,6 @@ static int read_vpd(struct cxlflash_cfg *cfg, u64 wwpn[])
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the read only section offset */
|
|
||||||
ro_start = pci_vpd_find_tag(vpd_data, vpd_size, PCI_VPD_LRDT_RO_DATA);
|
|
||||||
if (unlikely(ro_start < 0)) {
|
|
||||||
dev_err(dev, "%s: VPD Read-only data not found\n", __func__);
|
|
||||||
rc = -ENODEV;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get the read only section size, cap when extends beyond read VPD */
|
|
||||||
ro_size = pci_vpd_lrdt_size(&vpd_data[ro_start]);
|
|
||||||
j = ro_size;
|
|
||||||
i = ro_start + PCI_VPD_LRDT_TAG_SIZE;
|
|
||||||
if (unlikely((i + j) > vpd_size)) {
|
|
||||||
dev_dbg(dev, "%s: Might need to read more VPD (%d > %ld)\n",
|
|
||||||
__func__, (i + j), vpd_size);
|
|
||||||
ro_size = vpd_size - i;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find the offset of the WWPN tag within the read only
|
* Find the offset of the WWPN tag within the read only
|
||||||
* VPD data and validate the found field (partials are
|
* VPD data and validate the found field (partials are
|
||||||
@@ -1681,11 +1663,9 @@ static int read_vpd(struct cxlflash_cfg *cfg, u64 wwpn[])
|
|||||||
* ports programmed and operate in an undefined state.
|
* ports programmed and operate in an undefined state.
|
||||||
*/
|
*/
|
||||||
for (k = 0; k < cfg->num_fc_ports; k++) {
|
for (k = 0; k < cfg->num_fc_ports; k++) {
|
||||||
j = ro_size;
|
i = pci_vpd_find_ro_info_keyword(vpd_data, vpd_size,
|
||||||
i = ro_start + PCI_VPD_LRDT_TAG_SIZE;
|
wwpn_vpd_tags[k], &kw_size);
|
||||||
|
if (i == -ENOENT) {
|
||||||
i = pci_vpd_find_info_keyword(vpd_data, i, j, wwpn_vpd_tags[k]);
|
|
||||||
if (i < 0) {
|
|
||||||
if (wwpn_vpd_required)
|
if (wwpn_vpd_required)
|
||||||
dev_err(dev, "%s: Port %d WWPN not found\n",
|
dev_err(dev, "%s: Port %d WWPN not found\n",
|
||||||
__func__, k);
|
__func__, k);
|
||||||
@@ -1693,9 +1673,7 @@ static int read_vpd(struct cxlflash_cfg *cfg, u64 wwpn[])
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
j = pci_vpd_info_field_size(&vpd_data[i]);
|
if (i < 0 || kw_size != WWPN_LEN) {
|
||||||
i += PCI_VPD_INFO_FLD_HDR_SIZE;
|
|
||||||
if (unlikely((i + j > vpd_size) || (j != WWPN_LEN))) {
|
|
||||||
dev_err(dev, "%s: Port %d WWPN incomplete or bad VPD\n",
|
dev_err(dev, "%s: Port %d WWPN incomplete or bad VPD\n",
|
||||||
__func__, k);
|
__func__, k);
|
||||||
rc = -ENODEV;
|
rc = -ENODEV;
|
||||||
|
|||||||
@@ -306,9 +306,14 @@ struct pci_cap_saved_state {
|
|||||||
struct pci_cap_saved_data cap;
|
struct pci_cap_saved_data cap;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct pci_vpd {
|
||||||
|
struct mutex lock;
|
||||||
|
unsigned int len;
|
||||||
|
u8 cap;
|
||||||
|
};
|
||||||
|
|
||||||
struct irq_affinity;
|
struct irq_affinity;
|
||||||
struct pcie_link_state;
|
struct pcie_link_state;
|
||||||
struct pci_vpd;
|
|
||||||
struct pci_sriov;
|
struct pci_sriov;
|
||||||
struct pci_p2pdma;
|
struct pci_p2pdma;
|
||||||
struct rcec_ea;
|
struct rcec_ea;
|
||||||
@@ -480,7 +485,7 @@ struct pci_dev {
|
|||||||
#ifdef CONFIG_PCI_MSI
|
#ifdef CONFIG_PCI_MSI
|
||||||
const struct attribute_group **msi_irq_groups;
|
const struct attribute_group **msi_irq_groups;
|
||||||
#endif
|
#endif
|
||||||
struct pci_vpd *vpd;
|
struct pci_vpd vpd;
|
||||||
#ifdef CONFIG_PCIE_DPC
|
#ifdef CONFIG_PCIE_DPC
|
||||||
u16 dpc_cap;
|
u16 dpc_cap;
|
||||||
unsigned int dpc_rp_extensions:1;
|
unsigned int dpc_rp_extensions:1;
|
||||||
@@ -2258,20 +2263,6 @@ int pci_enable_atomic_ops_to_root(struct pci_dev *dev, u32 cap_mask);
|
|||||||
#define PCI_VPD_LRDT_RO_DATA PCI_VPD_LRDT_ID(PCI_VPD_LTIN_RO_DATA)
|
#define PCI_VPD_LRDT_RO_DATA PCI_VPD_LRDT_ID(PCI_VPD_LTIN_RO_DATA)
|
||||||
#define PCI_VPD_LRDT_RW_DATA PCI_VPD_LRDT_ID(PCI_VPD_LTIN_RW_DATA)
|
#define PCI_VPD_LRDT_RW_DATA PCI_VPD_LRDT_ID(PCI_VPD_LTIN_RW_DATA)
|
||||||
|
|
||||||
/* Small Resource Data Type Tag Item Names */
|
|
||||||
#define PCI_VPD_STIN_END 0x0f /* End */
|
|
||||||
|
|
||||||
#define PCI_VPD_SRDT_END (PCI_VPD_STIN_END << 3)
|
|
||||||
|
|
||||||
#define PCI_VPD_SRDT_TIN_MASK 0x78
|
|
||||||
#define PCI_VPD_SRDT_LEN_MASK 0x07
|
|
||||||
#define PCI_VPD_LRDT_TIN_MASK 0x7f
|
|
||||||
|
|
||||||
#define PCI_VPD_LRDT_TAG_SIZE 3
|
|
||||||
#define PCI_VPD_SRDT_TAG_SIZE 1
|
|
||||||
|
|
||||||
#define PCI_VPD_INFO_FLD_HDR_SIZE 3
|
|
||||||
|
|
||||||
#define PCI_VPD_RO_KEYWORD_PARTNO "PN"
|
#define PCI_VPD_RO_KEYWORD_PARTNO "PN"
|
||||||
#define PCI_VPD_RO_KEYWORD_SERIALNO "SN"
|
#define PCI_VPD_RO_KEYWORD_SERIALNO "SN"
|
||||||
#define PCI_VPD_RO_KEYWORD_MFR_ID "MN"
|
#define PCI_VPD_RO_KEYWORD_MFR_ID "MN"
|
||||||
@@ -2279,83 +2270,45 @@ int pci_enable_atomic_ops_to_root(struct pci_dev *dev, u32 cap_mask);
|
|||||||
#define PCI_VPD_RO_KEYWORD_CHKSUM "RV"
|
#define PCI_VPD_RO_KEYWORD_CHKSUM "RV"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pci_vpd_lrdt_size - Extracts the Large Resource Data Type length
|
* pci_vpd_alloc - Allocate buffer and read VPD into it
|
||||||
* @lrdt: Pointer to the beginning of the Large Resource Data Type tag
|
* @dev: PCI device
|
||||||
|
* @size: pointer to field where VPD length is returned
|
||||||
*
|
*
|
||||||
* Returns the extracted Large Resource Data Type length.
|
* Returns pointer to allocated buffer or an ERR_PTR in case of failure
|
||||||
*/
|
*/
|
||||||
static inline u16 pci_vpd_lrdt_size(const u8 *lrdt)
|
void *pci_vpd_alloc(struct pci_dev *dev, unsigned int *size);
|
||||||
{
|
|
||||||
return (u16)lrdt[1] + ((u16)lrdt[2] << 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pci_vpd_lrdt_tag - Extracts the Large Resource Data Type Tag Item
|
* pci_vpd_find_id_string - Locate id string in VPD
|
||||||
* @lrdt: Pointer to the beginning of the Large Resource Data Type tag
|
* @buf: Pointer to buffered VPD data
|
||||||
|
* @len: The length of the buffer area in which to search
|
||||||
|
* @size: Pointer to field where length of id string is returned
|
||||||
*
|
*
|
||||||
* Returns the extracted Large Resource Data Type Tag item.
|
* Returns the index of the id string or -ENOENT if not found.
|
||||||
*/
|
*/
|
||||||
static inline u16 pci_vpd_lrdt_tag(const u8 *lrdt)
|
int pci_vpd_find_id_string(const u8 *buf, unsigned int len, unsigned int *size);
|
||||||
{
|
|
||||||
return (u16)(lrdt[0] & PCI_VPD_LRDT_TIN_MASK);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pci_vpd_srdt_size - Extracts the Small Resource Data Type length
|
* pci_vpd_find_ro_info_keyword - Locate info field keyword in VPD RO section
|
||||||
* @srdt: Pointer to the beginning of the Small Resource Data Type tag
|
* @buf: Pointer to buffered VPD data
|
||||||
*
|
* @len: The length of the buffer area in which to search
|
||||||
* Returns the extracted Small Resource Data Type length.
|
|
||||||
*/
|
|
||||||
static inline u8 pci_vpd_srdt_size(const u8 *srdt)
|
|
||||||
{
|
|
||||||
return (*srdt) & PCI_VPD_SRDT_LEN_MASK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* pci_vpd_srdt_tag - Extracts the Small Resource Data Type Tag Item
|
|
||||||
* @srdt: Pointer to the beginning of the Small Resource Data Type tag
|
|
||||||
*
|
|
||||||
* Returns the extracted Small Resource Data Type Tag Item.
|
|
||||||
*/
|
|
||||||
static inline u8 pci_vpd_srdt_tag(const u8 *srdt)
|
|
||||||
{
|
|
||||||
return ((*srdt) & PCI_VPD_SRDT_TIN_MASK) >> 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* pci_vpd_info_field_size - Extracts the information field length
|
|
||||||
* @info_field: Pointer to the beginning of an information field header
|
|
||||||
*
|
|
||||||
* Returns the extracted information field length.
|
|
||||||
*/
|
|
||||||
static inline u8 pci_vpd_info_field_size(const u8 *info_field)
|
|
||||||
{
|
|
||||||
return info_field[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* pci_vpd_find_tag - Locates the Resource Data Type tag provided
|
|
||||||
* @buf: Pointer to buffered vpd data
|
|
||||||
* @len: The length of the vpd buffer
|
|
||||||
* @rdt: The Resource Data Type to search for
|
|
||||||
*
|
|
||||||
* Returns the index where the Resource Data Type was found or
|
|
||||||
* -ENOENT otherwise.
|
|
||||||
*/
|
|
||||||
int pci_vpd_find_tag(const u8 *buf, unsigned int len, u8 rdt);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* pci_vpd_find_info_keyword - Locates an information field keyword in the VPD
|
|
||||||
* @buf: Pointer to buffered vpd data
|
|
||||||
* @off: The offset into the buffer at which to begin the search
|
|
||||||
* @len: The length of the buffer area, relative to off, in which to search
|
|
||||||
* @kw: The keyword to search for
|
* @kw: The keyword to search for
|
||||||
|
* @size: Pointer to field where length of found keyword data is returned
|
||||||
*
|
*
|
||||||
* Returns the index where the information field keyword was found or
|
* Returns the index of the information field keyword data or -ENOENT if
|
||||||
* -ENOENT otherwise.
|
* not found.
|
||||||
*/
|
*/
|
||||||
int pci_vpd_find_info_keyword(const u8 *buf, unsigned int off,
|
int pci_vpd_find_ro_info_keyword(const void *buf, unsigned int len,
|
||||||
unsigned int len, const char *kw);
|
const char *kw, unsigned int *size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pci_vpd_check_csum - Check VPD checksum
|
||||||
|
* @buf: Pointer to buffered VPD data
|
||||||
|
* @len: VPD size
|
||||||
|
*
|
||||||
|
* Returns 1 if VPD has no checksum, otherwise 0 or an errno
|
||||||
|
*/
|
||||||
|
int pci_vpd_check_csum(const void *buf, unsigned int len);
|
||||||
|
|
||||||
/* PCI <-> OF binding helpers */
|
/* PCI <-> OF binding helpers */
|
||||||
#ifdef CONFIG_OF
|
#ifdef CONFIG_OF
|
||||||
|
|||||||
Reference in New Issue
Block a user