DPDK 22.11.4
rte_pci.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2015 Intel Corporation.
3 * Copyright 2013-2014 6WIND S.A.
4 */
5
6#ifndef _RTE_PCI_H_
7#define _RTE_PCI_H_
8
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19#include <stdio.h>
20#include <inttypes.h>
21#include <sys/types.h>
22
23/*
24 * Conventional PCI and PCI-X Mode 1 devices have 256 bytes of
25 * configuration space. PCI-X Mode 2 and PCIe devices have 4096 bytes of
26 * configuration space.
27 */
28#define RTE_PCI_CFG_SPACE_SIZE 256
29#define RTE_PCI_CFG_SPACE_EXP_SIZE 4096
30
31#define RTE_PCI_VENDOR_ID 0x00 /* 16 bits */
32#define RTE_PCI_DEVICE_ID 0x02 /* 16 bits */
33#define RTE_PCI_COMMAND 0x04 /* 16 bits */
34
35/* PCI Command Register */
36#define RTE_PCI_COMMAND_MASTER 0x4 /* Bus Master Enable */
37
38/* PCI Express capability registers */
39#define RTE_PCI_EXP_DEVCTL 8 /* Device Control */
40
41/* Extended Capabilities (PCI-X 2.0 and Express) */
42#define RTE_PCI_EXT_CAP_ID(header) (header & 0x0000ffff)
43#define RTE_PCI_EXT_CAP_NEXT(header) ((header >> 20) & 0xffc)
44
45#define RTE_PCI_EXT_CAP_ID_ERR 0x01 /* Advanced Error Reporting */
46#define RTE_PCI_EXT_CAP_ID_DSN 0x03 /* Device Serial Number */
47#define RTE_PCI_EXT_CAP_ID_SRIOV 0x10 /* SR-IOV*/
48#define RTE_PCI_EXT_CAP_ID_PASID 0x1B /* Process Address Space ID */
49
50/* Single Root I/O Virtualization */
51#define RTE_PCI_SRIOV_CAP 0x04 /* SR-IOV Capabilities */
52#define RTE_PCI_SRIOV_CTRL 0x08 /* SR-IOV Control */
53#define RTE_PCI_SRIOV_INITIAL_VF 0x0c /* Initial VFs */
54#define RTE_PCI_SRIOV_TOTAL_VF 0x0e /* Total VFs */
55#define RTE_PCI_SRIOV_NUM_VF 0x10 /* Number of VFs */
56#define RTE_PCI_SRIOV_FUNC_LINK 0x12 /* Function Dependency Link */
57#define RTE_PCI_SRIOV_VF_OFFSET 0x14 /* First VF Offset */
58#define RTE_PCI_SRIOV_VF_STRIDE 0x16 /* Following VF Stride */
59#define RTE_PCI_SRIOV_VF_DID 0x1a /* VF Device ID */
60#define RTE_PCI_SRIOV_SUP_PGSIZE 0x1c /* Supported Page Sizes */
61
62
63/* Process Address Space ID (RTE_PCI_EXT_CAP_ID_PASID) */
64#define RTE_PCI_PASID_CTRL 0x06 /* PASID control register */
66#define PCI_PRI_FMT "%.4" PRIx32 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
67#define PCI_PRI_STR_SIZE sizeof("XXXXXXXX:XX:XX.X")
68
70#define PCI_SHORT_PRI_FMT "%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
71
73#define PCI_FMT_NVAL 4
74
76#define PCI_RESOURCE_FMT_NVAL 3
77
79#define PCI_MAX_RESOURCE 6
80
85struct rte_pci_id {
86 uint32_t class_id;
87 uint16_t vendor_id;
88 uint16_t device_id;
91};
92
97 uint32_t domain;
98 uint8_t bus;
99 uint8_t devid;
100 uint8_t function;
101};
102
104#define RTE_PCI_ANY_ID (0xffff)
106#define PCI_ANY_ID RTE_DEPRECATED(PCI_ANY_ID) RTE_PCI_ANY_ID
107#define RTE_CLASS_ANY_ID (0xffffff)
108
120void rte_pci_device_name(const struct rte_pci_addr *addr,
121 char *output, size_t size);
122
135int rte_pci_addr_cmp(const struct rte_pci_addr *addr,
136 const struct rte_pci_addr *addr2);
137
138
151int rte_pci_addr_parse(const char *str, struct rte_pci_addr *addr);
152
153#ifdef __cplusplus
154}
155#endif
156
157#endif /* _RTE_PCI_H_ */
void rte_pci_device_name(const struct rte_pci_addr *addr, char *output, size_t size)
int rte_pci_addr_cmp(const struct rte_pci_addr *addr, const struct rte_pci_addr *addr2)
int rte_pci_addr_parse(const char *str, struct rte_pci_addr *addr)
uint8_t bus
Definition: rte_pci.h:98
uint32_t domain
Definition: rte_pci.h:97
uint8_t function
Definition: rte_pci.h:100
uint8_t devid
Definition: rte_pci.h:99
uint16_t subsystem_vendor_id
Definition: rte_pci.h:89
uint16_t subsystem_device_id
Definition: rte_pci.h:90
uint16_t vendor_id
Definition: rte_pci.h:87
uint16_t device_id
Definition: rte_pci.h:88
uint32_t class_id
Definition: rte_pci.h:86