diff options
author | Bjorn Helgaas <bhelgaas@google.com> | 2021-09-02 21:56:44 +0200 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2021-09-02 21:56:44 +0200 |
commit | 74797618e2022dfcd923f1ea8903ba4959f746a4 (patch) | |
tree | 1c2bf638d50d5bf9a68d73f4abf164097a788c0d /include | |
parent | Merge branch 'pci/virtualization' (diff) | |
parent | PCI/VPD: Use unaligned access helpers (diff) | |
download | linux-74797618e2022dfcd923f1ea8903ba4959f746a4.tar.xz linux-74797618e2022dfcd923f1ea8903ba4959f746a4.zip |
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
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/pci.h | 111 |
1 files changed, 32 insertions, 79 deletions
diff --git a/include/linux/pci.h b/include/linux/pci.h index 85801c6375f2..bd310ea53f3b 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -306,9 +306,14 @@ struct pci_cap_saved_state { struct pci_cap_saved_data cap; }; +struct pci_vpd { + struct mutex lock; + unsigned int len; + u8 cap; +}; + struct irq_affinity; struct pcie_link_state; -struct pci_vpd; struct pci_sriov; struct pci_p2pdma; struct rcec_ea; @@ -480,7 +485,7 @@ struct pci_dev { #ifdef CONFIG_PCI_MSI const struct attribute_group **msi_irq_groups; #endif - struct pci_vpd *vpd; + struct pci_vpd vpd; #ifdef CONFIG_PCIE_DPC u16 dpc_cap; 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_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_SERIALNO "SN" #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" /** - * pci_vpd_lrdt_size - Extracts the Large Resource Data Type length - * @lrdt: Pointer to the beginning of the Large Resource Data Type tag - * - * Returns the extracted Large Resource Data Type length. - */ -static inline u16 pci_vpd_lrdt_size(const u8 *lrdt) -{ - return (u16)lrdt[1] + ((u16)lrdt[2] << 8); -} - -/** - * pci_vpd_lrdt_tag - Extracts the Large Resource Data Type Tag Item - * @lrdt: Pointer to the beginning of the Large Resource Data Type tag - * - * Returns the extracted Large Resource Data Type Tag item. - */ -static inline u16 pci_vpd_lrdt_tag(const u8 *lrdt) -{ - return (u16)(lrdt[0] & PCI_VPD_LRDT_TIN_MASK); -} - -/** - * pci_vpd_srdt_size - Extracts the Small Resource Data Type length - * @srdt: Pointer to the beginning of the Small Resource Data Type tag - * - * 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 + * pci_vpd_alloc - Allocate buffer and read VPD into it + * @dev: PCI device + * @size: pointer to field where VPD length is returned * - * Returns the extracted Small Resource Data Type Tag Item. + * Returns pointer to allocated buffer or an ERR_PTR in case of failure */ -static inline u8 pci_vpd_srdt_tag(const u8 *srdt) -{ - return ((*srdt) & PCI_VPD_SRDT_TIN_MASK) >> 3; -} +void *pci_vpd_alloc(struct pci_dev *dev, unsigned int *size); /** - * pci_vpd_info_field_size - Extracts the information field length - * @info_field: Pointer to the beginning of an information field header + * pci_vpd_find_id_string - Locate id string in VPD + * @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 information field length. + * Returns the index of the id string or -ENOENT if not found. */ -static inline u8 pci_vpd_info_field_size(const u8 *info_field) -{ - return info_field[2]; -} +int pci_vpd_find_id_string(const u8 *buf, unsigned int len, unsigned int *size); /** - * 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 + * pci_vpd_find_ro_info_keyword - Locate info field keyword in VPD RO section + * @buf: Pointer to buffered VPD data + * @len: The length of the buffer area in which to search + * @kw: The keyword to search for + * @size: Pointer to field where length of found keyword data is returned * - * Returns the index where the Resource Data Type was found or - * -ENOENT otherwise. + * Returns the index of the information field keyword data or -ENOENT if + * not found. */ -int pci_vpd_find_tag(const u8 *buf, unsigned int len, u8 rdt); +int pci_vpd_find_ro_info_keyword(const void *buf, unsigned int len, + const char *kw, unsigned int *size); /** - * 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 + * pci_vpd_check_csum - Check VPD checksum + * @buf: Pointer to buffered VPD data + * @len: VPD size * - * Returns the index where the information field keyword was found or - * -ENOENT otherwise. + * Returns 1 if VPD has no checksum, otherwise 0 or an errno */ -int pci_vpd_find_info_keyword(const u8 *buf, unsigned int off, - unsigned int len, const char *kw); +int pci_vpd_check_csum(const void *buf, unsigned int len); /* PCI <-> OF binding helpers */ #ifdef CONFIG_OF |