2013-10-14 19:01:11 +04:00
|
|
|
/*
|
|
|
|
* QEMU<->ACPI BIOS PCI hotplug interface
|
|
|
|
*
|
|
|
|
* QEMU supports PCI hotplug via ACPI. This module
|
|
|
|
* implements the interface between QEMU and the ACPI BIOS.
|
|
|
|
* Interface specification - see docs/specs/acpi_pci_hotplug.txt
|
|
|
|
*
|
|
|
|
* Copyright (c) 2013, Red Hat Inc, Michael S. Tsirkin (mst@redhat.com)
|
|
|
|
* Copyright (c) 2006 Fabrice Bellard
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
2020-10-23 15:44:24 +03:00
|
|
|
* License version 2.1 as published by the Free Software Foundation.
|
2013-10-14 19:01:11 +04:00
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, see <http://www.gnu.org/licenses/>
|
|
|
|
*
|
|
|
|
* Contributions after 2012-01-13 are licensed under the terms of the
|
|
|
|
* GNU GPL, version 2 or (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef HW_ACPI_PCIHP_H
|
|
|
|
#define HW_ACPI_PCIHP_H
|
|
|
|
|
2014-02-05 19:36:49 +04:00
|
|
|
#include "hw/acpi/acpi.h"
|
2016-05-31 13:01:17 +03:00
|
|
|
#include "hw/hotplug.h"
|
2013-10-14 19:01:11 +04:00
|
|
|
|
2015-02-18 22:14:49 +03:00
|
|
|
#define ACPI_PCIHP_IO_BASE_PROP "acpi-pcihp-io-base"
|
|
|
|
#define ACPI_PCIHP_IO_LEN_PROP "acpi-pcihp-io-len"
|
|
|
|
|
2013-10-14 19:01:11 +04:00
|
|
|
typedef struct AcpiPciHpPciStatus {
|
2014-01-26 14:31:27 +04:00
|
|
|
uint32_t up;
|
2013-10-14 19:01:11 +04:00
|
|
|
uint32_t down;
|
|
|
|
uint32_t hotplug_enable;
|
|
|
|
} AcpiPciHpPciStatus;
|
|
|
|
|
|
|
|
#define ACPI_PCIHP_PROP_BSEL "acpi-pcihp-bsel"
|
|
|
|
#define ACPI_PCIHP_MAX_HOTPLUG_BUS 256
|
2014-02-03 14:45:01 +04:00
|
|
|
#define ACPI_PCIHP_BSEL_DEFAULT 0x0
|
2013-10-14 19:01:11 +04:00
|
|
|
|
|
|
|
typedef struct AcpiPciHpState {
|
|
|
|
AcpiPciHpPciStatus acpi_pcihp_pci_status[ACPI_PCIHP_MAX_HOTPLUG_BUS];
|
|
|
|
uint32_t hotplug_select;
|
pci: introduce acpi-index property for PCI device
In x86/ACPI world, linux distros are using predictable
network interface naming since systemd v197. Which on
QEMU based VMs results into path based naming scheme,
that names network interfaces based on PCI topology.
With itm on has to plug NIC in exactly the same bus/slot,
which was used when disk image was first provisioned/configured
or one risks to loose network configuration due to NIC being
renamed to actually used topology.
That also restricts freedom to reshape PCI configuration of
VM without need to reconfigure used guest image.
systemd also offers "onboard" naming scheme which is
preferred over PCI slot/topology one, provided that
firmware implements:
"
PCI Firmware Specification 3.1
4.6.7. DSM for Naming a PCI or PCI Express Device Under
Operating Systems
"
that allows to assign user defined index to PCI device,
which systemd will use to name NIC. For example, using
-device e1000,acpi-index=100
guest will rename NIC to 'eno100', where 'eno' is default
prefix for "onboard" naming scheme. This doesn't require
any advance configuration on guest side to com in effect
at 'onboard' scheme takes priority over path based naming.
Hope is that 'acpi-index' it will be easier to consume by
management layer, compared to forcing specific PCI topology
and/or having several disk image templates for different
topologies and will help to simplify process of spawning
VM from the same template without need to reconfigure
guest NIC.
This patch adds, 'acpi-index'* property and wires up
a 32bit register on top of pci hotplug register block
to pass index value to AML code at runtime.
Following patch will add corresponding _DSM code and
wire it up to PCI devices described in ACPI.
*) name comes from linux kernel terminology
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Message-Id: <20210315180102.3008391-3-imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2021-03-15 21:00:58 +03:00
|
|
|
uint32_t acpi_index;
|
2013-10-14 19:01:11 +04:00
|
|
|
PCIBus *root;
|
|
|
|
MemoryRegion io;
|
2014-02-03 14:44:59 +04:00
|
|
|
bool legacy_piix;
|
2015-02-18 22:14:49 +03:00
|
|
|
uint16_t io_base;
|
|
|
|
uint16_t io_len;
|
2013-10-14 19:01:11 +04:00
|
|
|
} AcpiPciHpState;
|
|
|
|
|
2015-02-18 22:14:49 +03:00
|
|
|
void acpi_pcihp_init(Object *owner, AcpiPciHpState *, PCIBus *root,
|
2021-07-13 03:42:00 +03:00
|
|
|
MemoryRegion *address_space_io, bool bridges_enabled,
|
|
|
|
uint16_t io_base);
|
2013-10-14 19:01:11 +04:00
|
|
|
|
2018-12-12 12:16:17 +03:00
|
|
|
void acpi_pcihp_device_pre_plug_cb(HotplugHandler *hotplug_dev,
|
|
|
|
DeviceState *dev, Error **errp);
|
2016-05-31 13:01:17 +03:00
|
|
|
void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s,
|
2014-02-05 19:36:49 +04:00
|
|
|
DeviceState *dev, Error **errp);
|
2016-05-31 13:01:17 +03:00
|
|
|
void acpi_pcihp_device_unplug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s,
|
2014-02-05 19:36:49 +04:00
|
|
|
DeviceState *dev, Error **errp);
|
2018-12-12 12:16:19 +03:00
|
|
|
void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev,
|
|
|
|
AcpiPciHpState *s, DeviceState *dev,
|
|
|
|
Error **errp);
|
2013-10-14 19:01:11 +04:00
|
|
|
|
|
|
|
/* Called on reset */
|
2020-08-21 19:54:03 +03:00
|
|
|
void acpi_pcihp_reset(AcpiPciHpState *s, bool acpihp_root_off);
|
2013-10-14 19:01:11 +04:00
|
|
|
|
|
|
|
extern const VMStateDescription vmstate_acpi_pcihp_pci_status;
|
|
|
|
|
pci: introduce acpi-index property for PCI device
In x86/ACPI world, linux distros are using predictable
network interface naming since systemd v197. Which on
QEMU based VMs results into path based naming scheme,
that names network interfaces based on PCI topology.
With itm on has to plug NIC in exactly the same bus/slot,
which was used when disk image was first provisioned/configured
or one risks to loose network configuration due to NIC being
renamed to actually used topology.
That also restricts freedom to reshape PCI configuration of
VM without need to reconfigure used guest image.
systemd also offers "onboard" naming scheme which is
preferred over PCI slot/topology one, provided that
firmware implements:
"
PCI Firmware Specification 3.1
4.6.7. DSM for Naming a PCI or PCI Express Device Under
Operating Systems
"
that allows to assign user defined index to PCI device,
which systemd will use to name NIC. For example, using
-device e1000,acpi-index=100
guest will rename NIC to 'eno100', where 'eno' is default
prefix for "onboard" naming scheme. This doesn't require
any advance configuration on guest side to com in effect
at 'onboard' scheme takes priority over path based naming.
Hope is that 'acpi-index' it will be easier to consume by
management layer, compared to forcing specific PCI topology
and/or having several disk image templates for different
topologies and will help to simplify process of spawning
VM from the same template without need to reconfigure
guest NIC.
This patch adds, 'acpi-index'* property and wires up
a 32bit register on top of pci hotplug register block
to pass index value to AML code at runtime.
Following patch will add corresponding _DSM code and
wire it up to PCI devices described in ACPI.
*) name comes from linux kernel terminology
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Message-Id: <20210315180102.3008391-3-imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2021-03-15 21:00:58 +03:00
|
|
|
#define VMSTATE_PCI_HOTPLUG(pcihp, state, test_pcihp, test_acpi_index) \
|
2013-10-14 19:01:11 +04:00
|
|
|
VMSTATE_UINT32_TEST(pcihp.hotplug_select, state, \
|
|
|
|
test_pcihp), \
|
|
|
|
VMSTATE_STRUCT_ARRAY_TEST(pcihp.acpi_pcihp_pci_status, state, \
|
|
|
|
ACPI_PCIHP_MAX_HOTPLUG_BUS, \
|
|
|
|
test_pcihp, 1, \
|
|
|
|
vmstate_acpi_pcihp_pci_status, \
|
pci: introduce acpi-index property for PCI device
In x86/ACPI world, linux distros are using predictable
network interface naming since systemd v197. Which on
QEMU based VMs results into path based naming scheme,
that names network interfaces based on PCI topology.
With itm on has to plug NIC in exactly the same bus/slot,
which was used when disk image was first provisioned/configured
or one risks to loose network configuration due to NIC being
renamed to actually used topology.
That also restricts freedom to reshape PCI configuration of
VM without need to reconfigure used guest image.
systemd also offers "onboard" naming scheme which is
preferred over PCI slot/topology one, provided that
firmware implements:
"
PCI Firmware Specification 3.1
4.6.7. DSM for Naming a PCI or PCI Express Device Under
Operating Systems
"
that allows to assign user defined index to PCI device,
which systemd will use to name NIC. For example, using
-device e1000,acpi-index=100
guest will rename NIC to 'eno100', where 'eno' is default
prefix for "onboard" naming scheme. This doesn't require
any advance configuration on guest side to com in effect
at 'onboard' scheme takes priority over path based naming.
Hope is that 'acpi-index' it will be easier to consume by
management layer, compared to forcing specific PCI topology
and/or having several disk image templates for different
topologies and will help to simplify process of spawning
VM from the same template without need to reconfigure
guest NIC.
This patch adds, 'acpi-index'* property and wires up
a 32bit register on top of pci hotplug register block
to pass index value to AML code at runtime.
Following patch will add corresponding _DSM code and
wire it up to PCI devices described in ACPI.
*) name comes from linux kernel terminology
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Message-Id: <20210315180102.3008391-3-imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2021-03-15 21:00:58 +03:00
|
|
|
AcpiPciHpPciStatus), \
|
|
|
|
VMSTATE_UINT32_TEST(pcihp.acpi_index, state, \
|
|
|
|
test_acpi_index)
|
2013-10-14 19:01:11 +04:00
|
|
|
|
|
|
|
#endif
|