aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/pci.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/pci.h')
-rw-r--r--include/linux/pci.h99
1 files changed, 99 insertions, 0 deletions
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 25813738c71a..ec95ebe629f1 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -662,6 +662,9 @@ extern void pci_remove_bus_device(struct pci_dev *dev);
662extern void pci_stop_bus_device(struct pci_dev *dev); 662extern void pci_stop_bus_device(struct pci_dev *dev);
663void pci_setup_cardbus(struct pci_bus *bus); 663void pci_setup_cardbus(struct pci_bus *bus);
664extern void pci_sort_breadthfirst(void); 664extern void pci_sort_breadthfirst(void);
665#define dev_is_pci(d) ((d)->bus == &pci_bus_type)
666#define dev_is_pf(d) ((dev_is_pci(d) ? to_pci_dev(d)->is_physfn : false))
667#define dev_num_vf(d) ((dev_is_pci(d) ? pci_num_vf(to_pci_dev(d)) : 0))
665 668
666/* Generic PCI functions exported to card drivers */ 669/* Generic PCI functions exported to card drivers */
667 670
@@ -1195,6 +1198,9 @@ static inline struct pci_dev *pci_get_bus_and_slot(unsigned int bus,
1195 unsigned int devfn) 1198 unsigned int devfn)
1196{ return NULL; } 1199{ return NULL; }
1197 1200
1201#define dev_is_pci(d) (false)
1202#define dev_is_pf(d) (false)
1203#define dev_num_vf(d) (0)
1198#endif /* CONFIG_PCI */ 1204#endif /* CONFIG_PCI */
1199 1205
1200/* Include architecture-dependent settings and functions */ 1206/* Include architecture-dependent settings and functions */
@@ -1356,6 +1362,7 @@ void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar);
1356extern int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn); 1362extern int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn);
1357extern void pci_disable_sriov(struct pci_dev *dev); 1363extern void pci_disable_sriov(struct pci_dev *dev);
1358extern irqreturn_t pci_sriov_migration(struct pci_dev *dev); 1364extern irqreturn_t pci_sriov_migration(struct pci_dev *dev);
1365extern int pci_num_vf(struct pci_dev *dev);
1359#else 1366#else
1360static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn) 1367static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn)
1361{ 1368{
@@ -1368,6 +1375,10 @@ static inline irqreturn_t pci_sriov_migration(struct pci_dev *dev)
1368{ 1375{
1369 return IRQ_NONE; 1376 return IRQ_NONE;
1370} 1377}
1378static inline int pci_num_vf(struct pci_dev *dev)
1379{
1380 return 0;
1381}
1371#endif 1382#endif
1372 1383
1373#if defined(CONFIG_HOTPLUG_PCI) || defined(CONFIG_HOTPLUG_PCI_MODULE) 1384#if defined(CONFIG_HOTPLUG_PCI) || defined(CONFIG_HOTPLUG_PCI_MODULE)
@@ -1404,5 +1415,93 @@ static inline bool pci_is_pcie(struct pci_dev *dev)
1404 1415
1405void pci_request_acs(void); 1416void pci_request_acs(void);
1406 1417
1418
1419#define PCI_VPD_LRDT 0x80 /* Large Resource Data Type */
1420#define PCI_VPD_LRDT_ID(x) (x | PCI_VPD_LRDT)
1421
1422/* Large Resource Data Type Tag Item Names */
1423#define PCI_VPD_LTIN_ID_STRING 0x02 /* Identifier String */
1424#define PCI_VPD_LTIN_RO_DATA 0x10 /* Read-Only Data */
1425#define PCI_VPD_LTIN_RW_DATA 0x11 /* Read-Write Data */
1426
1427#define PCI_VPD_LRDT_ID_STRING PCI_VPD_LRDT_ID(PCI_VPD_LTIN_ID_STRING)
1428#define PCI_VPD_LRDT_RO_DATA PCI_VPD_LRDT_ID(PCI_VPD_LTIN_RO_DATA)
1429#define PCI_VPD_LRDT_RW_DATA PCI_VPD_LRDT_ID(PCI_VPD_LTIN_RW_DATA)
1430
1431/* Small Resource Data Type Tag Item Names */
1432#define PCI_VPD_STIN_END 0x78 /* End */
1433
1434#define PCI_VPD_SRDT_END PCI_VPD_STIN_END
1435
1436#define PCI_VPD_SRDT_TIN_MASK 0x78
1437#define PCI_VPD_SRDT_LEN_MASK 0x07
1438
1439#define PCI_VPD_LRDT_TAG_SIZE 3
1440#define PCI_VPD_SRDT_TAG_SIZE 1
1441
1442#define PCI_VPD_INFO_FLD_HDR_SIZE 3
1443
1444#define PCI_VPD_RO_KEYWORD_PARTNO "PN"
1445#define PCI_VPD_RO_KEYWORD_MFR_ID "MN"
1446#define PCI_VPD_RO_KEYWORD_VENDOR0 "V0"
1447
1448/**
1449 * pci_vpd_lrdt_size - Extracts the Large Resource Data Type length
1450 * @lrdt: Pointer to the beginning of the Large Resource Data Type tag
1451 *
1452 * Returns the extracted Large Resource Data Type length.
1453 */
1454static inline u16 pci_vpd_lrdt_size(const u8 *lrdt)
1455{
1456 return (u16)lrdt[1] + ((u16)lrdt[2] << 8);
1457}
1458
1459/**
1460 * pci_vpd_srdt_size - Extracts the Small Resource Data Type length
1461 * @lrdt: Pointer to the beginning of the Small Resource Data Type tag
1462 *
1463 * Returns the extracted Small Resource Data Type length.
1464 */
1465static inline u8 pci_vpd_srdt_size(const u8 *srdt)
1466{
1467 return (*srdt) & PCI_VPD_SRDT_LEN_MASK;
1468}
1469
1470/**
1471 * pci_vpd_info_field_size - Extracts the information field length
1472 * @lrdt: Pointer to the beginning of an information field header
1473 *
1474 * Returns the extracted information field length.
1475 */
1476static inline u8 pci_vpd_info_field_size(const u8 *info_field)
1477{
1478 return info_field[2];
1479}
1480
1481/**
1482 * pci_vpd_find_tag - Locates the Resource Data Type tag provided
1483 * @buf: Pointer to buffered vpd data
1484 * @off: The offset into the buffer at which to begin the search
1485 * @len: The length of the vpd buffer
1486 * @rdt: The Resource Data Type to search for
1487 *
1488 * Returns the index where the Resource Data Type was found or
1489 * -ENOENT otherwise.
1490 */
1491int pci_vpd_find_tag(const u8 *buf, unsigned int off, unsigned int len, u8 rdt);
1492
1493/**
1494 * pci_vpd_find_info_keyword - Locates an information field keyword in the VPD
1495 * @buf: Pointer to buffered vpd data
1496 * @off: The offset into the buffer at which to begin the search
1497 * @len: The length of the buffer area, relative to off, in which to search
1498 * @kw: The keyword to search for
1499 *
1500 * Returns the index where the information field keyword was found or
1501 * -ENOENT otherwise.
1502 */
1503int pci_vpd_find_info_keyword(const u8 *buf, unsigned int off,
1504 unsigned int len, const char *kw);
1505
1407#endif /* __KERNEL__ */ 1506#endif /* __KERNEL__ */
1408#endif /* LINUX_PCI_H */ 1507#endif /* LINUX_PCI_H */