all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH pve-qemu-server-rs v4 05/14] pci: bus: add buses for numa expander bridges and pcie switches
Date: Fri, 13 Nov 2026 15:39:21 +0100	[thread overview]
Message-ID: <20261113143939.3012964-6-d.csapak@proxmox.com> (raw)
In-Reply-To: <20261113143939.3012964-1-d.csapak@proxmox.com>

These are needed to place hostpcie devices like on the host.

`bridge_model` now also returns the models for them and for root
ports, so the code placing the devices can look them up.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 pve-qemu-server-pci/src/types/bus.rs | 37 +++++++++++++++++++++++++---
 1 file changed, 34 insertions(+), 3 deletions(-)

diff --git a/pve-qemu-server-pci/src/types/bus.rs b/pve-qemu-server-pci/src/types/bus.rs
index 052ef00..602c88a 100644
--- a/pve-qemu-server-pci/src/types/bus.rs
+++ b/pve-qemu-server-pci/src/types/bus.rs
@@ -84,17 +84,35 @@ pub enum Bus {
     Sys(u8),
     /// One of the bridges PVE adds per device kind, see [`PveBridge`].
     Pve { kind: PveBridge, index: u8 },
+    /// Root bus of the PCIe expander bridge for a guest NUMA node.
+    Numa(u8),
+    /// The bus behind the port of a replicated PCIe switch, only holds its
+    /// upstream port.
+    SwitchUplink(u8),
+    /// The bus behind the upstream port of a replicated PCIe switch, holds its
+    /// downstream ports.
+    Switch(u8),
+    /// The bus behind the downstream switch port for `hostpcie<index>`.
+    SwitchPort(u8),
 }
 
 type BusConstructor = fn(u8) -> Bus;
 
 impl Bus {
     /// The QEMU device model needed to create this bus below `parent`, or
-    /// `None` if the bus is not created by a bridge device.
+    /// `None` for root buses.
     pub fn bridge_model(self, parent: Bus) -> Option<&'static str> {
         match self {
+            Bus::Pcie(_) => None,
             #[expect(deprecated)]
-            Bus::Pcie(_) | Bus::RootPort(_) | Bus::LegacyRootPort(_) => None,
+            Bus::RootPort(_) | Bus::LegacyRootPort(_) => Some("pcie-root-port"),
+            Bus::Numa(_) => Some("pxb-pcie"),
+            Bus::SwitchUplink(_) => Some(match parent {
+                Bus::Switch(_) => "xio3130-downstream",
+                _ => "pcie-root-port",
+            }),
+            Bus::Switch(_) => Some("x3130-upstream"),
+            Bus::SwitchPort(_) => Some("xio3130-downstream"),
             Bus::Pcidmi => Some("i82801b11-bridge"),
             Bus::Sys(_) | Bus::Pci(_) | Bus::Pve { .. } => Some(match parent {
                 #[expect(deprecated)]
@@ -118,6 +136,10 @@ impl std::fmt::Display for Bus {
             Bus::Pve { kind, index } => {
                 write!(f, "pve.{kind}{index}")
             }
+            Bus::Numa(i) => write!(f, "pve.numa{i}"),
+            Bus::SwitchUplink(i) => write!(f, "pve.switch-uplink{i}"),
+            Bus::Switch(i) => write!(f, "pve.switch{i}"),
+            Bus::SwitchPort(i) => write!(f, "pve.switch-port{i}"),
         }
     }
 }
@@ -127,7 +149,8 @@ impl std::str::FromStr for Bus {
 
     fn from_str(s: &str) -> Result<Self, Self::Err> {
         // NOTE: the prefixes here must be checked before the generic 'pve.'
-        // one below, which would otherwise swallow them.
+        // one below, which would otherwise swallow them. Also 'pve.switch' has to
+        // come after the longer 'pve.switch-' prefixes.
         const PREFIXES: &[(&str, BusConstructor)] = &[
             ("pci.", Bus::Pci),
             ("pcie.", Bus::Pcie),
@@ -135,6 +158,10 @@ impl std::str::FromStr for Bus {
             #[expect(deprecated)]
             ("ich9-pcie-port-", Bus::LegacyRootPort),
             ("pve.sys", Bus::Sys),
+            ("pve.numa", Bus::Numa),
+            ("pve.switch-uplink", Bus::SwitchUplink),
+            ("pve.switch-port", Bus::SwitchPort),
+            ("pve.switch", Bus::Switch),
         ];
 
         if s == "pcidmi" {
@@ -194,5 +221,9 @@ mod test {
         #[expect(deprecated)]
         test(Bus::LegacyRootPort(99));
         test(Bus::Sys(99));
+        test(Bus::Numa(7));
+        test(Bus::SwitchUplink(99));
+        test(Bus::Switch(99));
+        test(Bus::SwitchPort(99));
     }
 }
-- 
2.47.3





  parent reply	other threads:[~2026-11-13 14:40 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 14:39 [PATCH manager/proxmox-perl-rs/qemu-server/qemu-server-rs v4 00/14] pci-handling rewrite Dominik Csapak
2026-11-13 14:39 ` [PATCH pve-qemu-server-rs v4 01/14] add pve-qemu-server-pci crate for guest PCI address generation Dominik Csapak
2026-11-13 14:39 ` [PATCH pve-qemu-server-rs v4 02/14] pci: legacy: generate pci bridges Dominik Csapak
2026-11-13 14:39 ` [PATCH pve-qemu-server-rs v4 03/14] pci: legacy: generate q35 chipset devices and hostpcie root ports Dominik Csapak
2026-11-13 14:39 ` [PATCH pve-qemu-server-rs v4 04/14] pci: layout: add grouped PCI and PCIe layouts Dominik Csapak
2026-11-13 14:39 ` Dominik Csapak [this message]
2026-11-13 14:39 ` [PATCH pve-qemu-server-rs v4 06/14] pci: topology: place hostpcie devices like on the host Dominik Csapak
2026-11-13 14:39 ` [PATCH proxmox-perl-rs v4 07/14] pve: add bindings for `pve-qemu-server-pci` crate Dominik Csapak
2026-11-13 14:39 ` [PATCH proxmox-perl-rs v4 08/14] pve: pci: add host placements for the hostpci topology Dominik Csapak
2026-11-13 14:39 ` [PATCH qemu-server v4 09/14] pci: use PVE::RS::PCI bindings for addresses and bus devices Dominik Csapak
2026-11-13 14:39 ` [PATCH qemu-server v4 10/14] tree-wide: use HardwareConfig for the machine version checks Dominik Csapak
2026-11-13 14:39 ` [PATCH qemu-server v4 11/14] cfg2cmd: q35: generate chipset devices with machine version 11.1+pve1 Dominik Csapak
2026-11-13 14:39 ` [PATCH qemu-server v4 12/14] machine: add 'pci-layout' option Dominik Csapak
2026-11-13 14:39 ` [PATCH qemu-server v4 13/14] machine: add 'pci-topology' option Dominik Csapak
2026-11-13 14:39 ` [PATCH pve-manager v4 14/14] ui: qemu machine: don't lose pci options on edit cycle Dominik Csapak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261113143939.3012964-6-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal