Configure PCI passthrough
You can use PCI passthrough to attach a physical PCI device, such as a graphics card or a network device, to an instance. If you use PCI passthrough for a device, the instance reserves exclusive access to the device for performing tasks, and the device is not available to the host.
The Compute service (nova) does not support single networks that span multiple provider networks. When a network contains multiple physical networks, the Compute service only uses the first physical network. Therefore, if you are using routed provider networks you must use the same physical_network name across all the Compute nodes.
If you use routed provider networks with VLAN or flat networks, you must use the same physical_network name for all segments.
You then create multiple segments for the network and map the segments to the appropriate subnets.
To enable your cloud users to create instances with PCI devices attached, you must complete the following tasks:
- Designate Compute nodes to use for PCI passthrough.
- Configure the Compute nodes for PCI passthrough that have the required PCI devices.
- Deploy the data plane.
- Create a flavor for launching instances with PCI devices attached.
Prerequisites Copy linkLink copied!
- The Compute nodes have the required PCI devices.
- The
occommand line tool is installed on your workstation. - You are logged in to Red Hat OpenStack Services on OpenShift (RHOSO) as a user with
cluster-adminprivileges.
PCI passthrough device type field Copy linkLink copied!
The Compute service (nova) categorizes PCI devices into one of three types, depending on the capabilities the devices report.
You can set the PCI device device_type field to one of the following values:
- type-PF
- The device supports SR-IOV and is the parent or root device. Specify this device type to passthrough a device that supports SR-IOV in its entirety.
- type-VF
- The device is a child device of a device that supports SR-IOV.
- type-PCI
- The device does not support SR-IOV. This is the default device type if the
device_typefield is not set.
device_spec configuration on the Compute nodes and the alias configuration of the Compute services on the control plane must use the same device_type when referring to the same device.Nova PCI passthrough configuration guidelines Copy linkLink copied!
PCI passthrough enables instances to directly use physical PCI devices, bypassing virtualization for maximum performance. Choose the right device identification parameters, address formats, and NUMA affinity policies for consistent device assignment and optimal performance.
- Do not use the
devnameparameter when configuring PCI passthrough, as the device name of a NIC can change. Instead, usevendor_idandproduct_idbecause they are more stable, or use the PCI device address of the NIC. - Use the
addressparameter orproduct_idto pass through a specific Physical Function (PF). If you have multiple PFs of the sameproduct_id, then the Compute service uses any of those devices when an alias with the sameproduct_idis requested in the flavor. Theaddressparameter is always unique. - To pass through all the Virtual Functions (VFs), specify only the
product_idandvendor_idof the VFs that you want to use for PCI passthrough. You must also specify the address of the VF if you are using SRIOV for NIC partitioning and you are running OVS on a VF. - To pass through only the VFs for a PF but not the PF itself, you can use the address parameter to specify the PCI address of the PF and
product_idto specify the product ID of the VF.- Configuring the PCI device address parameter
- The
addressparameter specifies the PCI address of the device. You can set the value of theaddressparameter by using either a string or adictmapping. - String format
-
If you specify the address by using a string, you can include wildcards (*) as shown in the following example:
alias = {"name": "a1", "address": "*:0a:00.*", "physical_network": "physnet1"} - Dictionary format
-
If you specify the address by using the dictionary format, you can include regular expression syntax, as shown in the following example:
[pci] device_spec = {"address":{"domain": ".*", "bus": "02", "slot": "01", "function": "[0-2]"}, physical_network: "net1"}The Compute service restricts the configuration of address fields to the following maximum values:
Address field
Maximum value
domain
0xFFFF
bus
0xFF
slot
0x1F
function
0x7
The Compute service supports PCI devices with a 16-bit address domain. The Compute service ignores PCI devices with a 32-bit address domain.
You can optionally specify a default NUMA affinity policy for PCI passthrough devices by adding numa_policy to the configuration. For example:
alias = {"name":"a1", "product_id":"1572", "vendor_id": "8086", "device_type": "type-PF", "numa_policy": "preferred"}
You can choose one of four values for the numa_policy.
| Value | Description |
|---|---|
|
|
The Compute service creates an instance that requests a PCI device only when at least one of the NUMA nodes of the instance has affinity with the PCI device. This option provides the best performance. |
|
|
The Compute service attempts a best effort selection of PCI devices based on NUMA affinity. If this is not possible, then the Compute service schedules the instance on a NUMA node that has no affinity with the PCI device. |
|
|
(Default) The Compute service creates instances that request a PCI device in one of the following cases:
|
|
|
The Compute service creates an instance that requests a PCI device only when at least one of the instance NUMA nodes has affinity with a NUMA node in the same host socket as the PCI device. For example, the following host architecture has two sockets, each socket has two NUMA nodes, and a PCI device is connected to one of the nodes in one of the sockets. + image::../_images/NUMA_node_socket.png[NUMA node affinity with NUMA node in the same host socket as the PCI device] The Compute service can pin an instance with two NUMA nodes and the
The only combination of host nodes that the instance cannot be pinned to is node 2 and node 3, as neither of those nodes are on the same socket as the PCI device. If the other nodes are consumed by other instances and only nodes 2 and 3 are available, the instance does not boot. |
Update the control plane for PCI passthrough Copy linkLink copied!
To enable your cloud users to create instances with PCI devices attached, start by configuring the control plane. Configure the alias field with the correct product ID, vendor ID, and device type to pass through.
Before you begin Copy linkLink copied!
- You have selected the
OpenStackDataPlaneNodeSetCR that defines the nodes that you can configure PCI passthrough on. For more information about creating anOpenStackDataPlaneNodeSetCR, see Create a pre-provisioned node set for dynamic routing in Deploy a dynamic routing environment. - The
PCIPassthroughFilterandNUMATopologyFilterfilters are enabled. These filters are enabled by default. You can verify if they have been changed by checking theOpenStackControlPlaneCR:oc exec nova-scheduler-0 -- grep "enabled_filters" /etc/nova/nova.conf.d/ -R
Procedure Copy linkLink copied!
Create a node set for PCI passthrough Copy linkLink copied!
To enable your cloud users to create instances with PCI devices attached, you must create an OpenStackDataPlaneNodeSet custom resource (CR) that groups and configures the Compute nodes that have the PCI devices to use for PCI passthrough.
Before you begin Copy linkLink copied!
- You have selected the
OpenStackDataPlaneNodeSetCR that defines the nodes that you can configure vGPU on. For more information about creating anOpenStackDataPlaneNodeSetCR, see Create an OpenStackDataPlaneNodeSet CR with pre-provisioned nodes.
About this task Copy linkLink copied!
You cannot reconfigure a subset of the nodes within a node set. If you need to do this, you must scale the node set down, and create a new node set from the previously removed nodes.
Procedure Copy linkLink copied!
Results Copy linkLink copied!
To verify that PCI passthrough is working, you must instruct an OpenStack user to create an instance with an attached PCI device, and then log directly into the instance to see that the PCI device is accessible. You can provide the following instructions:
- Create an instance with a PCI passthrough device:
$ openstack server create --flavor device_passthrough \ --image <image> --wait test-pci - Log in to the instance as a cloud user. For more information, see Connect to an instance.
- To verify that the PCI device is accessible from the instance, enter the following command from the instance:
$ lspci -nn | grep <device_name>
Configure One Time Use devices Copy linkLink copied!
The Compute service (nova) supports the marking of devices as One Time Use (OTU) to reserve them for a single use of a single instance.
Before you begin Copy linkLink copied!
- You have the
occommand line tool installed on your workstation. - You are logged on to a workstation that has access to the RHOSO control plane as a user with
cluster-adminprivileges. - You have selected the
OpenStackDataPlaneNodeSetCR that defines which nodes you want to configure as One Time Use PCI devices. For more information about creating anOpenStackDataPlaneNodeSetCR, see Create an OpenStackDataPlaneNodeSet CR with pre-provisioned nodes in the Deploying Red Hat OpenStack Services on OpenShift guide. - You have configured PCI device tracking in the Placement service. For more information, see Enabling PCI device tracking in the Placement service.
Procedure Copy linkLink copied!
Remove One Time Use device reservation Copy linkLink copied!
Devices in a One Time Use (OTU) reserved state cannot be allocated to another instance until the reserved state is cleared. Devices reserved as OTU devices have the HW_PCI_ONE_TIME_USE trait. You can use this trait to find and clear the reserved state.
Before you begin Copy linkLink copied!
- You have the
occommand line tool installed on your workstation. - You are logged on to a workstation that has access to the RHOSO control plane as a user with
cluster-adminprivileges.