Skip to content

Commit 9eb45d5

Browse files
hreineckebjorn-helgaas
authored andcommitted
PCI: Update VPD definitions
The 'end' tag is actually 0x0f; it's the representation as a small resource data type tag that's 0x78 (i.e., shifted by 3). Correct PCI_VPD_STIN_END and PCI_VPD_SRDT_END accordingly. Also, add helper functions to extract the resource data type tags for both large and small resource data types. [bhelgaas: changelog] Tested-by: Shane Seymour <shane.seymour@hpe.com> Tested-by: Babu Moger <babu.moger@oracle.com> Signed-off-by: Hannes Reinecke <hare@suse.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Cc: Alexander Duyck <alexander.duyck@gmail.com>
1 parent 92e963f commit 9eb45d5

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

include/linux/pci.h

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,12 +1834,13 @@ bool pci_acs_path_enabled(struct pci_dev *start,
18341834
#define PCI_VPD_LRDT_RW_DATA PCI_VPD_LRDT_ID(PCI_VPD_LTIN_RW_DATA)
18351835

18361836
/* Small Resource Data Type Tag Item Names */
1837-
#define PCI_VPD_STIN_END 0x78 /* End */
1837+
#define PCI_VPD_STIN_END 0x0f /* End */
18381838

1839-
#define PCI_VPD_SRDT_END PCI_VPD_STIN_END
1839+
#define PCI_VPD_SRDT_END (PCI_VPD_STIN_END << 3)
18401840

18411841
#define PCI_VPD_SRDT_TIN_MASK 0x78
18421842
#define PCI_VPD_SRDT_LEN_MASK 0x07
1843+
#define PCI_VPD_LRDT_TIN_MASK 0x7f
18431844

18441845
#define PCI_VPD_LRDT_TAG_SIZE 3
18451846
#define PCI_VPD_SRDT_TAG_SIZE 1
@@ -1862,6 +1863,17 @@ static inline u16 pci_vpd_lrdt_size(const u8 *lrdt)
18621863
return (u16)lrdt[1] + ((u16)lrdt[2] << 8);
18631864
}
18641865

1866+
/**
1867+
* pci_vpd_lrdt_tag - Extracts the Large Resource Data Type Tag Item
1868+
* @lrdt: Pointer to the beginning of the Large Resource Data Type tag
1869+
*
1870+
* Returns the extracted Large Resource Data Type Tag item.
1871+
*/
1872+
static inline u16 pci_vpd_lrdt_tag(const u8 *lrdt)
1873+
{
1874+
return (u16)(lrdt[0] & PCI_VPD_LRDT_TIN_MASK);
1875+
}
1876+
18651877
/**
18661878
* pci_vpd_srdt_size - Extracts the Small Resource Data Type length
18671879
* @lrdt: Pointer to the beginning of the Small Resource Data Type tag
@@ -1873,6 +1885,17 @@ static inline u8 pci_vpd_srdt_size(const u8 *srdt)
18731885
return (*srdt) & PCI_VPD_SRDT_LEN_MASK;
18741886
}
18751887

1888+
/**
1889+
* pci_vpd_srdt_tag - Extracts the Small Resource Data Type Tag Item
1890+
* @lrdt: Pointer to the beginning of the Small Resource Data Type tag
1891+
*
1892+
* Returns the extracted Small Resource Data Type Tag Item.
1893+
*/
1894+
static inline u8 pci_vpd_srdt_tag(const u8 *srdt)
1895+
{
1896+
return ((*srdt) & PCI_VPD_SRDT_TIN_MASK) >> 3;
1897+
}
1898+
18761899
/**
18771900
* pci_vpd_info_field_size - Extracts the information field length
18781901
* @lrdt: Pointer to the beginning of an information field header

0 commit comments

Comments
 (0)