1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2015 Intel Corporation.
3 * Copyright 2013-2014 6WIND S.A.
21 #include <sys/queue.h>
23 #include <sys/types.h>
25 /** Formatting string for PCI device identifier: Ex: 0000:00:01.0 */
26 #define PCI_PRI_FMT "%.4" PRIx32 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
27 #define PCI_PRI_STR_SIZE sizeof("XXXXXXXX:XX:XX.X")
29 /** Short formatting string, without domain, for PCI device: Ex: 00:01.0 */
30 #define PCI_SHORT_PRI_FMT "%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
32 /** Nb. of values in PCI device identifier format string. */
33 #define PCI_FMT_NVAL 4
35 /** Nb. of values in PCI resource format. */
36 #define PCI_RESOURCE_FMT_NVAL 3
38 /** Maximum number of PCI resources. */
39 #define PCI_MAX_RESOURCE 6
42 * A structure describing an ID for a PCI driver. Each driver provides a
43 * table of these IDs for each device that it supports.
46 uint32_t class_id; /**< Class ID or RTE_CLASS_ANY_ID. */
47 uint16_t vendor_id; /**< Vendor ID or PCI_ANY_ID. */
48 uint16_t device_id; /**< Device ID or PCI_ANY_ID. */
49 uint16_t subsystem_vendor_id; /**< Subsystem vendor ID or PCI_ANY_ID. */
50 uint16_t subsystem_device_id; /**< Subsystem device ID or PCI_ANY_ID. */
54 * A structure describing the location of a PCI device.
57 uint32_t domain; /**< Device domain */
58 uint8_t bus; /**< Device bus */
59 uint8_t devid; /**< Device ID */
60 uint8_t function; /**< Device function. */
63 /** Any PCI device identifier (vendor, device, ...) */
64 #define PCI_ANY_ID (0xffff)
65 #define RTE_CLASS_ANY_ID (0xffffff)
68 * Utility function to write a pci device name, this device name can later be
69 * used to retrieve the corresponding rte_pci_addr using eal_parse_pci_*
73 * The PCI Bus-Device-Function address
75 * The output buffer string
77 * The output buffer size
79 void rte_pci_device_name(const struct rte_pci_addr *addr,
80 char *output, size_t size);
83 * Utility function to compare two PCI device addresses.
86 * The PCI Bus-Device-Function address to compare
88 * The PCI Bus-Device-Function address to compare
90 * 0 on equal PCI address.
91 * Positive on addr is greater than addr2.
92 * Negative on addr is less than addr2, or error.
94 int rte_pci_addr_cmp(const struct rte_pci_addr *addr,
95 const struct rte_pci_addr *addr2);
99 * Utility function to parse a string into a PCI location.
102 * The string to parse
104 * The reference to the structure where the location
110 int rte_pci_addr_parse(const char *str, struct rte_pci_addr *addr);
116 #endif /* _RTE_PCI_H_ */