Method, device and equipment for hot plugging of PF equipment, medium and program product
By configuring hot-swapable PF devices that support multiple device types for the data processing unit and dynamically configure identification information and visibility, the problem of fixed PF slot types is solved, and flexible device configuration and resource pool sharing is realized.
Patent Information
- Application Number
- CN202510570860.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-30
- Publication Date
- 2025-08-19
AI Technical Summary
In the existing PCIe hot-swap solution, the PF slot can only fix the device type, which is difficult to meet the needs of different users for the number of different device types.
Configure hot-swapable PF devices for the data processing unit, support multiple device types, and dynamically configure device identification information and visibility through hot-swap instructions, and send interrupt requests to notify the host device to scan.
It realizes the flexible configuration of different equipment types on fixed PF slots, adaptively adjusts the number and proportion of equipment, and meets various needs of users.
Smart Images

Figure CN120508518A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method, apparatus, device, medium and program product for hot-plugging PF devices. Background Art
[0002] PCIe (Peripheral Component Interconnect Express, a high-speed serial computer expansion bus standard) hot-swapping allows for the dynamic addition and removal of devices or functions while the system is running, without requiring a reboot. For example, in bare metal scenarios, service providers can hot-swap or hot-remove physical function (PF) devices based on tenant needs to meet their business requirements.
[0003] Although there are various existing PCIe hot-swap solutions, since the corresponding PF slots can only have fixed device types, it is difficult to meet the needs of different users for changing numbers of different device types. Summary of the Invention
[0004] In view of this, the present invention provides a method, apparatus, device, medium and program product for hot-swapping PF devices, so as to implement hot-swapping of different types of PF devices in fixed slots.
[0005] In a first aspect, the present invention provides a method for hot-swapping a PF device, which is applied to a device simulator configured for a data processing unit, the method comprising:
[0006] At least one hot-swappable PF device is configured for the data processing unit; the PF device supports multiple device types and is initially invisible to the host;
[0007] In response to a first hot plug instruction to hot plug a first device type, determining a first PF device that is currently invisible to the host;
[0008] configuring the identification information of the first PF device to be first identification information corresponding to the first device type, and updating the status of the first PF device to be visible to the host;
[0009] A first interrupt request is sent to the host; the first interrupt request is used to notify the host to perform device scanning.
[0010] In some optional implementations, configuring at least one hot-swappable PF device for the data processing unit includes:
[0011] Generate the host-side topology structure containing each PF device based on the configurable topology file;
[0012] Initialize the configuration space of the PF device; the configuration space includes identification information of the PF device.
[0013] In some optional implementations, after sending the first interrupt request to the host, the method further includes:
[0014] In response to a first configuration read request initiated by the host, sending the first identification information in the configuration space of the first PF device to the host;
[0015] In response to a first configuration write request initiated by the host, resource information in the configuration space of the first PF device is updated.
[0016] In some optional embodiments, the method further comprises:
[0017] In response to a hot-plug instruction for a second PF device, restoring identification information of the second PF device to default information, and updating a state of the second PF device to be invisible to the host;
[0018] Send a second interrupt request to the host; the second interrupt request is used to notify the host that the second PF device is hot-plugged.
[0019] In some optional embodiments, the method further comprises:
[0020] In response to a second hot plug instruction for hot plugging a second device type, if the first PF device is currently not visible to the host, configuring identification information of the first PF device to second identification information corresponding to the second device type, and updating the state of the first PF device to be visible to the host;
[0021] Send a third interrupt request to the host; the third interrupt request is used to notify the host to perform device scanning.
[0022] In some optional implementations, after sending the third interrupt request to the host, the method further includes:
[0023] In response to a second configuration read request initiated by the host, sending the second identification information in the configuration space of the first PF device to the host;
[0024] In response to a second configuration write request initiated by the host, resource information in the configuration space of the first PF device is updated.
[0025] In a second aspect, the present invention provides a device for hot-plugging a PF device, which is applied to a device simulator configured for a data processing unit, and the device comprises:
[0026] A configuration module, configured to configure at least one hot-swappable PF device for the data processing unit; the PF device supports multiple device types and is initially invisible to the host;
[0027] a processing module, configured to, in response to a first hot plug instruction for hot plugging a first device type, determine a first PF device that is currently invisible to the host; configure identification information of the first PF device to first identification information corresponding to the first device type, and update a state of the first PF device to be visible to the host;
[0028] The interrupt module is used to send a first interrupt request to the host; the first interrupt request is used to notify the host to perform device scanning.
[0029] In a third aspect, the present invention provides a computer device comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the method for hot-plugging a PF device according to the first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0030] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the method for hot-plugging a PF device according to the first aspect or any corresponding embodiment thereof.
[0031] In a fifth aspect, the present invention provides a computer program product, comprising computer instructions for causing a computer to execute the method for hot-swapping a PF device according to the first aspect or any corresponding embodiment thereof.
[0032] The present invention pre-configures the PF device corresponding to the fixed PF slot to support multiple device types and sets the status of whether it is visible to the host, so that the PF device corresponding to a certain PE slot can be configured as the required device type according to the user's hot-plug instruction. The PF device supports multiple device types, so that the fixed PF slot can hot-plug PF devices of different device types, so that the PF device of the specified device type can be hot-plugged in the corresponding PF slot according to the user's hot-plug instruction and presented to the host for use. It can realize flexible configuration of different device types, flexibly share the resource pool of hot-plug PF devices, and adaptively adjust the number and proportion of different device types to meet the various needs of users. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in related technologies, the following briefly introduces the drawings required for use in the specific embodiments or related technical descriptions. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0034] Figure 1 is a schematic diagram of an architecture of a data processing unit according to an embodiment of the present invention;
[0035] Figure 2 is a flow chart of a method for hot-swapping a PF device according to an embodiment of the present invention;
[0036] Figure 3 is a flow chart of another method for hot-swapping a PF device according to an embodiment of the present invention;
[0037] Figure 4 1 is a flow chart of another method for hot-swapping a PF device according to an embodiment of the present invention;
[0038] Figure 5 is a structural block diagram of an apparatus for hot-swapping a PF device according to an embodiment of the present invention;
[0039] Figure 6 Schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0040] To make the purpose, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making creative efforts shall fall within the scope of protection of the present invention.
[0041] For the convenience of description, some terms involved in this embodiment are first explained. These explanations are intended to make the embodiments of this application easier to understand and should not be regarded as limiting the scope of protection claimed in this application.
[0042] (1) SNIC (Smart NIC): A programmable network interface card (NIC) that integrates an FPGA (Field Programmable Gate Array) to assist the CPU (Central Processing Unit) in processing network loads, thus making network functions intelligent. It can also be called a Data Processing Unit (DPU).
[0043] (2) PF (Physical Function): This is the primary entity on the PCIe bus and one of the core components of the Single Root I / O Virtualization (SR-IOV) solution. Every PCIe device has at least one PF. Each PF has its own independent configuration space and can be recognized as an independent device by the operating system.
[0044] (3) VF (Virtual Function): A lightweight PCIe function created by a PF. A PF can manage and create multiple VFs (Virtual Functions). Each VF shares the physical resources of the PF but can be used independently in different virtual machines (VMs).
[0045] (4)Virtio (Virtual IO): It is a semi-virtualized IO technology and a set of standards for virtualization of general IO devices. It provides a communication framework and programming interface between upper-layer applications and virtualized devices, reducing compatibility issues caused by cross-platform operations. It is widely used in cloud computing.
[0046] According to an embodiment of the present invention, a method embodiment for hot-plugging a PF device is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0047] In this embodiment, a method for hot-plugging a PF device is provided, which is applied to a device simulator configured for a data processing unit to provide a PF device supporting multiple hot-pluggable device types for a host.
[0048] Figure 1 A schematic diagram of the architecture of the data processing unit is shown in FIG. Figure 1 As shown, the data processing unit (DPU) includes an FPGA, which interacts with the host through the PCIe protocol to implement logic control; and a device simulator is set for the data processing unit to implement configuration of various PF devices.
[0049] Specifically, the PCIe core is a hardware core provided by a hardware manufacturer, which encapsulates necessary intellectual property (IP) cores, such as a PCIe IP core.
[0050] The message transparent transmission channel is used to transparently transmit messages, such as TLP (Transaction Layer Packet) messages. The FPGA can send related TLP messages to the device simulator through this message transparent transmission channel, and the device simulator's response message can also be uploaded to the host through this message transparent transmission channel.
[0051] The DMA controller is used to move data based on DMA (Direct Memory Access).
[0052] like Figure 1 As shown in the figure, the device simulator mainly includes: message transceiver module, programmable topology processing engine, multi-stage switch (Switch), multiplexing, device simulation module and hot-swappable module, etc. After receiving the TLP message, it responds according to the topology and device status, thereby providing the required PCIe services to the host.
[0053] The message transceiver module is a TLP message transceiver interface, and is not limited to a register mode or a FIFO (first in first out) queue mode.
[0054] A programmable topology processing engine is a topology configuration tool that can perform topology parsing and topology generation to present the expected and required topology structure to the host.
[0055] A multi-stage switch (such as a multi-stage PCIeSwitch) cooperates with the topology configuration to generate the topology structure expected by the host and completes the distribution of TLP messages based on the topology structure.
[0056] Multiplexing, specifically SR-IOV (Single Root I / O Virtualization), is mainly used to present multiple VFs in the device simulator and respond to TLP messages of the corresponding VFs.
[0057] The device simulation module is used to simulate and manage various PF devices, including managing various PF devices, queues, interrupt resources (such as MSIX interrupts), and other information.
[0058] The hot-plug module is used to process hot-plug messages sent by the management component, such as hot-plug instructions and hot-removal instructions.
[0059] The management component is an upper-layer control and management component of the DPU, and is used to respond to the hot-swap operation performed on the device by the upper-layer console. It can be implemented based on an SDK (Software Development Kit), for example.
[0060] In this embodiment, the device simulator can specifically be a PCIe simulator. The PCIe device simulator is primarily used on DPU smart network card devices at the IaaS (Infrastructure as a Service) layer in cloud computing scenarios. By simulating the hardware processing of TLP transmission and reception via software, it can replicate PCIe device communication, data transmission, and protocol interaction processes in a virtual environment. In this embodiment, the device simulator enables a flexible topology on the DPU and allows configuration of PF devices of various device types.
[0061] Figure 2 FIG. 1 is a flow chart of a method for hot-swapping a PF device according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps.
[0062] Step S201: configure at least one hot-swappable PF device for the data processing unit; the PF device supports multiple device types and is initially invisible to the host.
[0063] In this embodiment, a corresponding PF device can be configured for the data processing unit based on the hardware capabilities of the data processing unit and user needs. The number of PF devices is generally multiple, and the PF device is hot-swappable, meaning it can be hot-plugged or hot-unplugged during system operation. Because hot-plugging a PF device is generally a logical hot-plug, unlike traditional hot-plugging of physical devices, it does not require the user to actually perform the "plug" or "unplug" action; the user only needs to trigger the corresponding hot-plug command.
[0064] Furthermore, unlike traditional static configurations of PF devices, this embodiment sets a status for FP devices indicating whether they are visible to the host and configures the PF device to support multiple device types. Specifically, these device types can include network card types and disk types. This means that the FP device can function as a network card or disk, providing services required by the host.
[0065] The PF device is initially invisible to the host. For example, when the data processing unit is just started, before receiving the relevant hot plug command, each PF device is invisible to the host. In other words, the host will not find the PF device after scanning.
[0066] Step S202 : In response to a first hot plug instruction for hot plugging a first device type, determining a first PF device that is currently invisible to the host.
[0067] In this embodiment, when the user needs to hot plug a certain device, he can initiate a corresponding hot plug instruction and indicate the type of the required device; for ease of description, the hot plug instruction is referred to as a first hot plug instruction, and the device type therein is referred to as a first device type.
[0068] For example, if a hot-plug network card is required, a first hot-plug instruction of the network card type (ie, the first device type is the network card type) can be initiated to the data processing unit through the console; Figure 1 As shown, after receiving the first hot plug instruction, the management component sends it to the device simulator, which is received and responded to by the hot plug module of the device simulator.
[0069] After obtaining the first hot plug instruction, it is possible to determine which PF devices exist whose status is invisible to the host at the current moment when the first hot plug instruction is received, and select the PF device that needs to perform the hot plug operation. For the sake of convenience, this device is called the first PF device.
[0070] The first PF device supports the first device type. Generally, each PF device supports multiple identical device types, so it is only necessary to select one of the PF devices currently invisible to the host as the first PF device.
[0071] Step S203: Configure the identification information of the first PF device to be first identification information corresponding to the first device type, and update the status of the first PF device to be visible to the host.
[0072] In this embodiment, after the first PF device is determined, the identification information of the first PF device is configured according to the first device type. Each PF device corresponds to a configuration space, which includes the identification information, resource information, etc. of the PF device.
[0073] Specifically, the identification information is used to represent the relevant identification of the PF device, such as Vendor ID, Device ID, etc.; the resource information is used to represent the resources allocated to the PF device, such as Base Address Registers (BAR), interrupt configuration, etc.
[0074] Since the first PF device is currently invisible to the host, its identification information can be empty (none), default identification information, or identification information configured when the first PF device was last hot-plugged. This embodiment does not limit this. After the first PF device is selected, identification information corresponding to the first device type, i.e., first identification information, is determined, and the identification information of the first PF device is configured as the first identification information.
[0075] For example, the identification information corresponding to different device types is generally fixed, so the correspondence between the device type and the identification information can be set in advance. Based on this correspondence, the first identification information corresponding to the first device type can be determined. For example, the specific identification information such as VendorID and Device ID corresponding to the network card type can be determined.
[0076] In addition, the state of the first PF device is updated from invisible to the host to visible to the host, so that the host can subsequently scan the first PF device.
[0077] For example, a corresponding flag bit or status bit can be set for each PF device, 1 indicates visible to the host, and 0 indicates invisible to the host. By adjusting the flag bit or status bit of the first PF device, state switching can be achieved.
[0078] Step S204: Send a first interrupt request to the host; the first interrupt request is used to notify the host to perform device scanning.
[0079] In this embodiment, after completing the configuration of the first PF device, the device simulator can send a corresponding interrupt to the host, that is, a first interrupt request, such as a MSIX interrupt, to notify the host that there is a hot-plugged device, so that the host performs a device scan to scan the first PF device visible to the host; and the device type of the first PF device is the first device type, so that the required device services can be provided to the user.
[0080] The method for hot-plugging PF devices provided in this embodiment pre-configures the PF device corresponding to the fixed PF slot to support multiple device types and sets the status of whether it is visible to the host, so that the PF device corresponding to a certain PE slot can be configured as the required device type according to the user's hot-plug instruction. The PF device supports multiple device types, so that the fixed PF slot can hot-plug PF devices of different device types, so that the PF device of the specified device type can be hot-plugged in the corresponding PF slot according to the user's hot-plug instruction and presented to the host for use. Flexible configuration of different device types can be achieved, and the resource pool of hot-pluggable PF devices can be flexibly shared. The number and proportion of different device types can be adaptively adjusted to meet the various needs of users.
[0081] In this embodiment, another method for hot-plugging a PF device is provided, which can be applied to a device simulator configured for a data processing unit. Figure 3 FIG. 1 is a flow chart of a method for hot-swapping a PF device according to an embodiment of the present invention. Figure 3 As shown, the process includes the following steps.
[0082] Step S301: configure at least one hot-swappable PF device for the data processing unit; the PF device supports multiple device types and is initially invisible to the host.
[0083] For details, please see Figure 2 Step S201 of the illustrated embodiment will not be described in detail here.
[0084] In some optional implementations, the above step S301 “configuring at least one hot-swappable PF device for the data processing unit” may specifically include steps A1 to A2.
[0085] Step A1: Generate a topology structure including various PF devices on the host side according to a configurable topology file.
[0086] Step A2: Initialize the configuration space of the PF device; the configuration space includes identification information of the PF device.
[0087] In this embodiment, a corresponding topology file can be configured according to usage scenarios and user needs, that is, the topology file is configurable according to needs.
[0088] The topology file specifically includes topology information related to the topology structure and device information related to PF devices. The topology information represents the various bus paths in the topology structure and the mounted switches, bridges, or PF devices. Device information includes whether the PF device is hot-swappable and the device types supported by the PF device.
[0089] After the device simulator is started, the programmable topology processing engine parses the topology file to determine the locations of the corresponding bridges and PF devices on the host side, thereby generating the host-side topology structure. This topology structure can indicate the location of the PF device, such as the BDF (Bus-Device-Function) address of the PF device.
[0090] In this embodiment, based on the configurable topology file, not only can the host-side topology be flexibly configured, but also the topology structure and the device simulator code can be decoupled. When the topology structure needs to change, only the topology file needs to be updated, which greatly improves the software version manageability and the configuration flexibility of the DPU, and simplifies software version management.
[0091] Step S302 : In response to a first hot plug instruction for hot plugging a first device type, determining a first PF device that is currently invisible to the host.
[0092] For details, please see Figure 2 Step S202 of the illustrated embodiment will not be described in detail here.
[0093] Step S303: Configure the identification information of the first PF device to be first identification information corresponding to the first device type, and update the status of the first PF device to be visible to the host.
[0094] For details, please see Figure 2 Step S203 of the illustrated embodiment will not be described in detail here.
[0095] Step S304: Send a first interrupt request to the host; the first interrupt request is used to notify the host to perform device scanning.
[0096] For details, please see Figure 2 Step S204 of the illustrated embodiment will not be described in detail here.
[0097] In some optional implementations, after the above step S304 of "sending a first interrupt request to the host", the method further includes steps B1 to B2.
[0098] Step B1: In response to a first configuration read request initiated by a host, first identification information in a configuration space of a first PF device is sent to the host.
[0099] Step B2: In response to the first configuration write request initiated by the host, update the resource information in the configuration space of the first PF device.
[0100] In this embodiment, as described above, the configuration space of each PF device includes identification information and resource information. After the configuration space of the first PF device is updated (primarily updating the identification information therein), an interrupt is used to notify the host of the presence of a hot-plugged device. The host can then perform a device scan to detect the first PF device and obtain the identification information of the first PF device, i.e., the first identification information in the configuration space, through a first configuration read request to verify the identity of the first PF device and confirm its existence.
[0101] In addition, the host can also allocate corresponding resources to the first PF device according to the current actual status, specifically by updating the resource information in the configuration space of the first PF device through a first configuration write request to allocate corresponding base address registers and interrupt resources to the first PF device.
[0102] Among them, the first configuration read request and the first configuration write request can both be a TLP message, which is transmitted to the device simulator through the FPGA's message transparent transmission channel to complete the update of the configuration space and ensure that the required services can be stably provided to the host in the future.
[0103] Step S305 : In response to the hot-plug instruction for the second PF device, the identification information of the second PF device is restored to default information, and the status of the second PF device is updated to be invisible to the host.
[0104] In this embodiment, similar to the hot-plug process, when a user needs to hot-plug an unused device, they can also initiate a hot-plug command through the console. The user can directly specify the PF device to be hot-plugged, i.e., the second PF device. Alternatively, the user can simply notify the management component of the current hot-plug requirement (e.g., hot-plugging a 1TB disk). The management component will then determine the second PF device that meets the user's hot-plug requirement and send the corresponding hot-plug command to the device simulator.
[0105] It can be understood that the second PF device is the PF device currently visible to the host, that is, the hot plug instruction has been executed before; if step S305 is executed after step S304, the first PF device is in a state visible to the host at this time, so the first PF device may act as the second PF device to respond to the hot pull instruction. In other words, the second PF device and the first PF device can be the same PF device.
[0106] After receiving the instruction to hot-plug the second PF device, the device simulator updates the status of the second PF device to be invisible to the host, so that the host no longer scans the second PF device; and, the identification information of the second PF device can also be restored to the default information (for example, empty) to facilitate the configuration of its identification information when the second PF device is hot-plugged subsequently.
[0107] Step S306: Send a second interrupt request to the host; the second interrupt request is used to notify the host that the second PF device is hot-plugged.
[0108] In this embodiment, after hot-unplugging the second PF device, the device emulator again sends a corresponding interrupt, namely a second interrupt request, such as a MSIX interrupt, to the host. Upon receiving the second interrupt request, the host determines that the second PF device has been hot-unplugged and can delete information related to the second PF device, such as releasing allocated resources and uninstalling the driver for the second PF device. After hot-unplugging the second PF device, the host releases the allocated resources so that they can be provided to other PF devices, thereby improving resource utilization.
[0109] In some optional implementations, as described above, the same PF device supports multiple device types, so the same PF device can be configured as different device types in different time periods. Specifically, the method further includes the following steps C1 to C2.
[0110] Step C1, in response to a second hot plug instruction for hot plugging a second device type, when the first PF device is currently invisible to the host, configure the identification information of the first PF device to second identification information corresponding to the second device type, and update the status of the first PF device to be visible to the host.
[0111] Step C2: Send a third interrupt request to the host; the third interrupt request is used to notify the host to perform device scanning.
[0112] In this embodiment, after hot-plugging the first PF device based on steps S301 to S304, if hot-plugging it again based on step S305 (i.e., the second PF device in step S305 is the same device as the first PF device), the first PF device is restored to a state invisible to the host. If a second hot-plug instruction is subsequently received for hot-plugging another second device type, i.e., the second device type is different from the first device type, and, at the current moment (the moment the second hot-plug instruction is received), the first PF device is in a state invisible to the host and also supports the second device type, then the first PF device can also be selected as the device to be hot-plugged and hot-plugged again.
[0113] Specifically, similar to the process from step S303 to step S304 above, after determining to hot-plug the first PF device again, the identification information of the first PF device is configured according to the second device type.
[0114] For example, the first device type is a network card type, and the second device type is a disk type. For the first PF device, after it is used as a network card and hot-plugged, its identification information can be configured as a disk type identifier, thereby providing storage services to the host as a disk device.
[0115] Furthermore, the state of the first PF device is updated again from invisible to the host to visible to the host, so that the host can subsequently scan the first PF device.
[0116] In this embodiment, after completing the configuration of the first PF device again, the device simulator can send a corresponding interrupt to the host, that is, a third interrupt request, such as a MSIX interrupt, to notify the host that there is currently a hot-plugged device, so that the host performs a device scan to scan the first PF device visible to the host again; and the device type of the first PF device is the second device type, so that the required device services can be provided to the user.
[0117] Optionally, in the above step C2 “after sending the third interrupt request to the host”, the method further includes steps C3 to C4.
[0118] Step C3: In response to the second configuration read request initiated by the host, the second identification information in the configuration space of the first PF device is sent to the host.
[0119] Step C4: In response to the second configuration write request initiated by the host, update the resource information in the configuration space of the first PF device.
[0120] In this embodiment, similar to the principles of steps B1 and B2 above, after updating the configuration space of the first PF device, the device simulator again uses an interrupt to notify the host of the presence of a hot-plugged device. The host can then perform a device scan to detect the first PF device and obtain the identification information of the first PF device, i.e., the second identification information in the configuration space, through a second configuration read request. It will be understood that this second identification information is different from the first identification information.
[0121] Furthermore, the host can reallocate corresponding resources to the first PF device based on the current actual state. Specifically, the host updates the resource information in the configuration space of the first PF device through a second configuration write request to reallocate corresponding base address registers and interrupt resources to the first PF device. The resource information can be the same or different, depending on the actual situation.
[0122] Among them, the second configuration read request and the second configuration write request can also be a TLP message, which is transmitted to the device simulator through the FPGA message transmission channel to complete the update of the configuration space and ensure that the required services can be stably provided to the host in the future.
[0123] Figure 4 Another flow chart of the method for hot-swapping a PF device is shown, as shown in FIG. Figure 4 As shown, the method includes the following steps.
[0124] Step S401: configure the topology.
[0125] Specifically, the topology file is configured based on the usage scenario and user needs. It also includes hot-swappable PF resources and corresponding attributes, such as the number of PF slots (each PF slot corresponds to a PF device), which PF devices are hot-swappable, and the supported device types.
[0126] Step S402: parse the topology and initialize the configuration space.
[0127] Specifically, taking the PCIe simulator as an example, after the PCIe simulator software is started, it parses the topology file to determine the presence of bridges, PF devices, and other devices. Based on the topology and device attributes, it generates the device capabilities of each PF device, such as the maximum bandwidth of the network card and disk capacity. Furthermore, it initializes the configuration space of each PF device and the relevant management structures, such as queues.
[0128] Step S403: host scanning is completed.
[0129] Specifically, the PCIe emulator waits for the host to initiate a scan (typically performed through enumeration). It then responds to the host's scan request based on the topology, presenting the expected topology to the host. Hot-swappable PF devices are invisible to the host after the scan is complete, meaning the host is unaware of the PF devices' existence. The PCIe emulator waits for the management component to initiate a hot-swap operation.
[0130] Step S404: receiving a first hot plug instruction.
[0131] After initialization, the PCIe simulator performs hot plug state management and waits for the management component to initiate a hot plug operation. The management component can send a corresponding first hot plug instruction based on the information from the console to initiate the hot plug operation. After receiving the instruction, the hot plug module starts to perform the first hot plug.
[0132] Step S405: modify the identification information and notify the host of the first interruption.
[0133] Specifically, the PCIe emulator configures the PF device's VendorID, DeviceID, and other device attributes based on the first hot-plug command sent by the management component. It then sends a MSIX interrupt to notify the host of the hot-plugging of the PF device in the corresponding slot, allowing the host to scan for the PF device. The host then begins configuring the device's presence, power, and other status, completes the hot-plug setup, and loads the corresponding driver, presenting the PF device of the corresponding network type, such as a network or disk device, to the host.
[0134] Step S406: receiving a hot-plug instruction.
[0135] Specifically, the management component determines, based on the console message, that the PF device in the slot needs to be hot-plugged, and then initiates a hot-plug instruction.
[0136] Step S407: Restore to the default identification information and interrupt the host for the second time.
[0137] Specifically, the PCIe emulator restores the identification information of the PF device to the default value according to the hot-plug instruction sent by the management component, and sends an MSIX interrupt to notify the host to hot-plug the PF device in the corresponding slot. The host uninstalls the driver and unplugs the PF device, after which the network or disk disappears.
[0138] Step S408: receiving a second hot plug instruction.
[0139] After the hot plug, the PCIe simulator performs hot plug state management again, waiting for the management component to initiate a hot plug or hot pull operation. The management component can send a corresponding second hot plug instruction based on the information from the console to initiate a hot plug operation. After receiving the instruction, the hot plug module starts to perform the second hot plug.
[0140] Step S409: modify the identification information and interrupt the host for the third time.
[0141] Specifically, the PCIe simulator reconfigures the device attributes such as the Vendor ID and Device ID of the PF device according to the second hot plug instruction sent by the management component, and sends an MSIX interrupt to notify the host to hot plug the PF device in the corresponding slot again, so that the host can scan the PF device again.
[0142] The method for hot-plugging PF devices provided in this embodiment configures the configuration file as a hybrid device, and the software records the device type. By default, it is invisible to the host. Therefore, the PF device corresponding to a certain PE slot can be configured as the required device type according to the user's hot-plug instruction. Moreover, after hot-plugging the corresponding slot, a different device type can be hot-plugged again according to the user's instruction and presented to the host side. This cycle meets the user's needs for flexible hot-plugging and flexible configuration of different device quantities, providing the system with the ability to adapt to different scenarios and different user needs. Based on the configurable topology file, the host-side topology can be flexibly configured to achieve decoupling of topology and code, decoupling of cloud hosts and bare metal scenarios, and providing hot-pluggable PF hybrid device type attribute configuration.
[0143] This embodiment also provides a device for hot-swapping a PF device. This device is used to implement the above-mentioned embodiments and preferred embodiments. Details already described will not be repeated here. As used below, the term "module" may refer to a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation using hardware, or a combination of software and hardware, is also possible and contemplated.
[0144] This embodiment provides a device for hot-plugging a PF device, which is applied to a device simulator configured for a data processing unit, such as Figure 5 As shown, including:
[0145] Configuration module 501, configured to configure at least one hot-swappable PF device for the data processing unit; the PF device supports multiple device types and is initially invisible to the host;
[0146] Processing module 502 is configured to, in response to a first hot plug instruction for hot plugging a first device type, determine a first PF device that is currently invisible to the host; configure identification information of the first PF device to first identification information corresponding to the first device type, and update a state of the first PF device to be visible to the host;
[0147] The interrupt module 503 is configured to send a first interrupt request to the host; the first interrupt request is used to notify the host to perform device scanning.
[0148] In some optional implementations, the configuration module 501 configures at least one hot-swappable PF device for the data processing unit, including:
[0149] Generate the host-side topology structure containing each PF device based on the configurable topology file;
[0150] Initialize the configuration space of the PF device; the configuration space includes identification information of the PF device.
[0151] In some optional implementations, after sending the first interrupt request to the host, the processing module 502 is further configured to:
[0152] In response to a first configuration read request initiated by the host, sending the first identification information in the configuration space of the first PF device to the host;
[0153] The method updates resource information in the configuration space of the first PF device in response to the first configuration write request initiated by the host.
[0154] In some optional implementations, the processing module 502 is further configured to:
[0155] In response to a hot-plug instruction for a second PF device, restoring identification information of the second PF device to default information, and updating a state of the second PF device to be invisible to the host;
[0156] The interrupt module 503 is further configured to send a second interrupt request to the host; the second interrupt request is used to notify the host that the second PF device is hot-plugged.
[0157] In some optional implementations, the processing module 502 is further configured to:
[0158] In response to a second hot plug instruction for hot plugging a second device type, if the first PF device is currently not visible to the host, configuring identification information of the first PF device to second identification information corresponding to the second device type, and updating the state of the first PF device to be visible to the host;
[0159] The interrupt module 503 is further configured to send a third interrupt request to the host; the third interrupt request is configured to notify the host to perform device scanning.
[0160] In some optional implementations, after sending the third interrupt request to the host, the processing module 502 is further configured to:
[0161] In response to a second configuration read request initiated by the host, sending the second identification information in the configuration space of the first PF device to the host;
[0162] In response to a second configuration write request initiated by the host, resource information in the configuration space of the first PF device is updated.
[0163] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0164] The apparatus of the hot-swappable PF device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, including a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0165] The embodiment of the present invention also provides a computer device having the above Figure 5 The apparatus for hot-swapping PF devices is shown.
[0166] See also Figure 6 , Figure 6 is a structural diagram of a computer device provided by an optional embodiment of the present invention, such as Figure 6 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components utilize different buses to communicate with each other and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of a GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories. Equally, multiple computer devices can be connected, and each device provides part of the necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 6 A processor 10 is taken as an example.
[0167] The processor 10 may be a central processing unit, a network processor, or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit, a programmable logic device, or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic, or any combination thereof.
[0168] The memory 20 stores instructions that can be executed by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.
[0169] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and application programs required for at least one function; the data storage area may store data created based on the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely located relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0170] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid-state drive; the memory 20 may also include a combination of the above types of memory.
[0171] The computer device further includes a communication interface 30 for the computer device to communicate with other devices or a communication network.
[0172] The embodiment of the present invention also provides a computer-readable storage medium. The above-mentioned method according to the embodiment of the present invention can be implemented in hardware, firmware, or implemented as a computer code that can be recorded in a storage medium, or implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and downloaded through a network and will be stored in a local storage medium, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state drive, etc.; further, the storage medium can also include a combination of the above-mentioned types of memory. It can be understood that a computer, a processor, a microprocessor controller or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor or hardware, the method shown in the above embodiment is implemented.
[0173] A portion of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the form in which the computer program instruction exists in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc. Accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium that can be accessed by the computer.
[0174] Although the embodiments of the present invention have been described with reference to the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations should all be included in the scope of protection of the present invention.
Claims
1. A method for hot-swapping a PF device, characterized in that: Applied to a device simulator configured for a data processing unit, the method comprises: At least one hot-swappable PF device is configured for the data processing unit; the PF device supports multiple device types and is initially invisible to the host; In response to a first hot plug instruction to hot plug a first device type, determining a first PF device that is currently invisible to the host; configuring the identification information of the first PF device to be first identification information corresponding to the first device type, and updating the status of the first PF device to be visible to the host; A first interrupt request is sent to the host; the first interrupt request is used to notify the host to perform device scanning.
2. The method according to claim 1, characterized in that The configuring at least one hot-pluggable PF device for the data processing unit includes: Generate the host-side topology structure containing each PF device based on the configurable topology file; Initialize the configuration space of the PF device; the configuration space includes identification information of the PF device.
3. The method according to claim 1, characterized in that After sending the first interrupt request to the host, the method further includes: In response to a first configuration read request initiated by the host, sending the first identification information in the configuration space of the first PF device to the host; In response to a first configuration write request initiated by the host, resource information in the configuration space of the first PF device is updated.
4. The method according to claim 1, wherein The method further comprises: In response to a hot-plug instruction for a second PF device, restoring identification information of the second PF device to default information, and updating a state of the second PF device to be invisible to the host; Send a second interrupt request to the host; the second interrupt request is used to notify the host that the second PF device is hot-plugged.
5. The method according to any one of claims 1 to 4, characterized in that The method further comprises: In response to a second hot plug instruction for hot plugging a second device type, if the first PF device is currently not visible to the host, configuring identification information of the first PF device to second identification information corresponding to the second device type, and updating the state of the first PF device to be visible to the host; Send a third interrupt request to the host; the third interrupt request is used to notify the host to perform device scanning.
6. The method according to claim 5, characterized in that After sending the third interrupt request to the host, the method further includes: In response to a second configuration read request initiated by the host, sending the second identification information in the configuration space of the first PF device to the host; In response to a second configuration write request initiated by the host, resource information in the configuration space of the first PF device is updated.
7. A device for hot-swappable PF equipment, characterized in that: A device simulator configured for a data processing unit, the device comprising: A configuration module, configured to configure at least one hot-swappable PF device for the data processing unit; the PF device supports multiple device types and is initially invisible to the host; a processing module, configured to, in response to a first hot plug instruction for hot plugging a first device type, determine a first PF device that is currently invisible to the host; configure identification information of the first PF device to first identification information corresponding to the first device type, and update a state of the first PF device to be visible to the host; The interrupt module is used to send a first interrupt request to the host; the first interrupt request is used to notify the host to perform device scanning.
8. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the method for hot-swappable PF devices according to any one of claims 1 to 6 by executing the computer instructions.
9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the method for hot-swapping a PF device according to any one of claims 1 to 6.
10. A computer program product, characterized in that The method comprises computer instructions for causing a computer to execute the method for hot-swapping a PF device according to any one of claims 1 to 6.
Citation Information
Cited By
PCIe equipment virtualization method and device, equipment and medium
CN121210110A
A PCIe device virtualization method, device, apparatus and medium
CN121210110B