Hot plugging method and apparatus, and computer device
By setting up a hot-plugging guard module in the computer device operating system, hot-plugging of physical and virtual devices in the PCIE chip is realized, which solves the problem of limited hot-plugging solutions in the existing technology, improves flexibility and Application scenarios.
Patent Information
- Application Number
- PCT/CN2024/077465
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-02-21
- Filing Date
- 2024-02-18
- Publication Date
- 2024-08-29
AI Technical Summary
Existing computer equipment can only realize hot-plugging of physical PCIE devices when the PCIE chip supports the switching function, and cannot realize hot-plugging of virtual PCIE devices, resulting in limited application scenarios and poor flexibility of the hot-plugging solution.
A hot-plugging guard module is set up in the operating system of the computer device, and the hot-plugging operation is performed on the PCIE device in the PCIE chip through the module. The PCIE chip does not need to support the PCIE switching function to realize the hot-plugging of physical and virtual PCIE devices.
It supports hot swapping of virtual and physical PCIE devices without changing virtio-net, expanding application scenarios and improving flexibility.
Smart Images

Figure CN2024077465_29082024_PF_FP_ABST
Abstract
Description
Hot plug method and device, and computer equipment
[0001] This application claims priority to Chinese patent application filed on February 21, 2023, with application number 202310148651.4 and application name “Hot-swap method and device, computer equipment”, all contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of computer technology, and in particular to a hot plugging method and device, and computer equipment. Background Art
[0003] A peripheral component interconnect express (PCIE) chip can be plugged into a computer device, and the computer device uses the PCIE chip to expand its external functions. A PCIE chip can include multiple PCIE devices, which can include physical PCIE devices and virtual PCIE devices. Virtual PCIE devices are derived from physical PCIE devices through virtualization technology. For example, a network card chip can include a physical function (PF) and a virtual function (VF), and the VF is derived from the PF.
[0004] To prevent the process of plugging and unplugging PCIE devices from affecting the normal operation of the computer device, the computer device needs to support hot plugging of PCIE devices. Hot plugging, or hot plugging, refers to inserting or unplugging a PCIE device into or from the computer device without turning off the computer device's power. For example, without turning off the computer device's power, the computer device's operating system (OS) can recognize the PCIE device. Currently, computer devices can only implement hot plugging of physical PCIE devices in PCIE chips that support PCIE switching functions. This results in limited application scenarios and poor flexibility of current hot plug solutions.
[0005] Summary of the Invention
[0006] The present application provides a hot-swap method and apparatus, and computer equipment. The technical solution of the present application is as follows.
[0007] In a first aspect, a hot-plug method is provided, which is applied to a hot-plug guard module in a computer device, wherein a processor of the computer device includes an operating system, the operating system includes the hot-plug guard module, the processor is communicatively connected to a first PCIE chip, and the first PCIE chip includes a first PCIE device. The method comprises: the hot-plug guard module receives a first hot-plug message from the first PCIE chip, the first hot-plug message carries insertion indication information and indication information of the first PCIE device; the hot-plug guard module determines the first PCIE device according to the indication information of the first PCIE device; the hot-plug guard module performs a hot-plug operation on the first PCIE device according to the insertion indication information to hot-plug the first PCIE device.
[0008] The technical solution provided by the present application sets a hot-swap guard module in the operating system of the computer device, and performs hot-swap on the PCIE device in the PCIE chip through the hot-swap guard module. The hot-swap of the PCIE device in the PCIE chip can be achieved without the PCIE chip supporting the PCIE switching function. Not only can the hot-swap of physical PCIE devices be achieved, but also the hot-swap of virtual PCIE devices can be achieved. It has a wide range of application scenarios and high flexibility.
[0009] Optionally, the hot-swap guard module performs a hot-swap operation on the first PCIE device according to the insertion indication information, including: the hot-swap guard module installs a device driver corresponding to the first PCIE device according to the insertion indication information. The hot-swap guard module enables the operating system to recognize the first PCIE device by installing the device driver corresponding to the first PCIE device, thereby realizing hot-swapping of the first PCIE device.
[0010] Optionally, before the hot-swap guard module installs the device driver corresponding to the first PCIE device according to the insertion instruction information, the method further includes: the hot-swap guard module obtaining the device driver corresponding to the first PCIE device according to the instruction information of the first PCIE device. The hot-swap guard module obtains the device driver corresponding to the first PCIE device to facilitate installation of the device driver.
[0011] Optionally, the method also includes: the hot-plug guard module receives a first hot-plug message from the first PCIE chip, the first hot-plug message carries the plug-out indication information and the indication information of the first PCIE device; the hot-plug guard module determines the first PCIE device according to the indication information of the first PCIE device; the hot-plug guard module performs a hot-plug operation on the first PCIE device according to the plug-out indication information to hot-plug the first PCIE device.
[0012] Optionally, the hot-plug guard module performs a hot-plug operation on the first PCIE device according to the plug-out indication information, including: the hot-plug guard module uninstalls a device driver corresponding to the first PCIE device according to the plug-out indication information.
[0013] Optionally, before the hot-swap guard module receives the first hot-swap message from the first PCIE chip, the method further includes: the hot-swap guard module initializing the first PCIE chip. The hot-swap guard module can obtain hot-swap configuration information of the first PCIE chip by initializing the first PCIE chip.
[0014] Optionally, before the hot-swap guard module receives the first hot-swap message from the first PCIE chip, the method further includes: the hot-swap guard module enabling the hot-swap function for the first PCIE chip. The hot-swap guard module enables the hot-swap function for the first PCIE chip, so that the first PCIE chip sends a hot-swap message (e.g., the first hot-swap message, the first hot-unplug message) to the processor, and the hot-swap guard module hot-plugs or unplugs the PCIE device in the first PCIE chip according to the hot-swap message.
[0015] Optionally, the operating system includes a kernel space (kernelspace) and a user space (userspace), and the hot-swappable guard module runs in the user space. The hot-swappable guard module is a user-mode module (such as a user-mode process) of the operating system. The hot-swappable guard module is decoupled from the kernel of the operating system and can be released without going through the certification process of the operating system manufacturer, thereby avoiding the problems caused by the operating system manufacturer affecting the hot-swappable guard module. For example, the hot-swappable guard module supports hot-plugging of VF and PF without changing virtio-net, and can quickly adapt to multiple operating systems. Among them, virtio-net is a network card driver, and the Chinese name of virtio is virtualized input output, and the quotation is virtualized input output.
[0016] Optionally, the first PCIE chip includes a hot plug control emulator, and the hot plug control emulator is used to interface with a processor of a computer device. For example, the hot plug control emulator is used to send a first hot plug message.
[0017] Optionally, the first PCIE chip includes a main processing unit (MPU), and the MPU includes the hot plug control emulator. The hot plug control emulator is the hot plug firmware in the MPU. The first PCIE chip may also include a service processing unit (SPU), which is communicatively connected to the MPU, and the hot plug control emulator in the MPU can send a hot plug message when triggered by the SPU.
[0018] Optionally, the first PCIE device is a physical PCIE device or a virtual PCIE device.
[0019] Optionally, the first PCIE chip includes any one of the following: a network card chip, a graphics processing unit (GPU) chip, and a field-programmable gate array (FPGA) chip.
[0020] Optionally, the first PCIE chip is a network card chip, and the first PCIE device is a PF or a VF.
[0021] In a second aspect, a hot-swap device is provided, which is applied to a hot-swap guard module in a computer device. The processor of the computer device includes an operating system, the operating system includes the hot-swap guard module, the processor is in communication with a first PCIE chip, and the first PCIE chip includes a first PCIE device. The hot-swap device includes various modules for executing the method provided in the first aspect or any optional embodiment of the first aspect. The modules can be implemented based on software, hardware, or a combination of software and hardware, and the modules can be arbitrarily combined or divided based on the specific implementation.
[0022] In a third aspect, an operating system is provided, including a hot-swap guard module, which includes a transceiver unit and a processing unit. The transceiver unit is used to execute the receiving step in the method provided by the first aspect or any optional method of the first aspect, and the processing unit is used to execute the steps of the method provided by the first aspect or any optional method of the first aspect except the receiving step.
[0023] In a fourth aspect, a processor is provided, comprising the hot-swap device provided in the second aspect.
[0024] In a fifth aspect, a processor is provided, comprising the operating system provided in the third aspect.
[0025] In a sixth aspect, a computer device is provided, comprising a memory and a processor; the memory is configured to store a computer program; and the processor is configured to execute the computer program stored in the memory to implement the method provided in the first aspect or any optional embodiment of the first aspect. For example, the processor includes a hot-swap daemon module, which is configured to execute the computer program stored in the memory to implement the method provided in the first aspect or any optional embodiment of the first aspect. Optionally, the processor is the processor provided in the fourth or fifth aspect.
[0026] In a seventh aspect, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed, the method provided in the first aspect or any optional manner of the first aspect is implemented.
[0027] In an eighth aspect, a computer program product is provided, which includes a program or code, and when the program or code is executed, it implements the method provided in the first aspect or any optional manner of the first aspect.
[0028] The beneficial effects of the technical solution provided by this application are:
[0029] The technical solution provided by the present application sets a hot-swap guard module in the operating system of the computer device, and performs hot-swap on the PCIE device in the PCIE chip through the hot-swap guard module. The hot-swap of the PCIE device in the PCIE chip can be achieved without the PCIE chip supporting the PCIE switching function. Not only can the hot-swap of physical PCIE devices be achieved, but also the hot-swap of virtual PCIE devices can be achieved. It has a wide range of application scenarios and high flexibility. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] FIG1 is a schematic diagram of an application scenario provided by an embodiment of the present application;
[0031] FIG2 is a schematic diagram of a hot plug message provided in an embodiment of the present application;
[0032] FIG3 is a schematic diagram of a control field provided in an embodiment of the present application;
[0033] FIG4 is a flow chart of a hot swap method provided in an embodiment of the present application;
[0034] FIG5 is a flow chart of another hot swap method provided in an embodiment of the present application;
[0035] FIG6 is a flow chart of another hot swap method provided in an embodiment of the present application;
[0036] FIG7 is an interactive diagram of a hot plug method provided in an embodiment of the present application;
[0037] FIG8 is an interaction diagram of another hot plug method provided in an embodiment of the present application;
[0038] FIG9 is a schematic diagram of a hot-swap device provided in an embodiment of the present application;
[0039] FIG10 is a schematic diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0040] The embodiments of the present application will be further described below with reference to the accompanying drawings.
[0041] A PCIE chip can be plugged into a computer device, and the computer device uses the PCIE chip to expand external functions. For example, the processor of the computer device includes a root complex (RC), an operating system, a device driver, a hot plug service, and a hot plug driver. The root complex includes a root port, and the PCIE chip is plugged into the root port of the RC. Among them, a PCIE chip can include multiple PCIE devices, and the multiple PCIE devices can include physical PCIE devices and virtual PCIE devices. The virtual PCIE devices are derived from the virtualization of physical PCIE devices using virtualization technology. For example, a network card chip can include a PF and a VF, and the VF is derived from the PF.
[0042] In order to prevent the process of plugging and unplugging PCIE devices from affecting the normal operation of the computer device, the computer device needs to support hot plugging of PCIE devices. Hot plugging, that is, hot plugging, refers to inserting or unplugging a PCIE device into or from the computer device without turning off the power of the computer device. For example, the operating system of the computer device can recognize the PCIE device without turning off the power of the computer device. Currently, computer devices can only implement hot plugging of physical PCIE devices in PCIE chips that support PCIE switching functions. For example, the computer device includes a PCIE switch, and the PCIE switch includes a hot plug controller (HPC) and a plug interface. The PCIE switch is plugged into the root port of the RC, and the PCIE chip is plugged into the plug interface of the PCIE switch. Therefore, the PCIE chip is plugged into the root port of the RC through the PCIE switch, and the hot plug controller can be used to implement hot plugging of the physical PCIE device in the PCIE chip.
[0043] However, it is currently impossible to implement hot-swapping of PCIE devices in PCIE chips that do not support the PCIE switching function, and due to the limitations of the single root input output virtualization (SRIOV) specification and the implementation of the input output memory management unit (IOMMU), it is currently impossible to implement hot-swapping of virtual PCIE devices. For example, for a network card chip that does not support the PCIE switching function, it is currently impossible to implement hot-swapping of the PF in the network card chip, and due to the limitations of the SRIOV specification and the implementation of the IOMMU, it is also impossible to implement hot-swapping of the VF in the network card chip. It can be seen that the application scenarios of the current hot-swapping solution are limited and the flexibility is poor.
[0044] The embodiment of the present application provides a hot-swap solution, which sets a hot-plug daemon (HPD) module in the operating system of a computer device. The hot-plug daemon module performs hot-plugging of PCIE devices in a PCIE chip, and hot-plugging of PCIE devices in the PCIE chip can be achieved without the PCIE chip supporting the PCIE switching function. Not only can hot-plugging of physical PCIE devices be achieved, but hot-plugging of virtual PCIE devices can also be achieved. For example, the present application can not only achieve hot-plugging of PFs in a network card chip, but also achieve hot-plugging of VFs in the network card chip, without the network card chip supporting the PCIE switching function. Therefore, the application scenarios of the present application are wide and the flexibility is high.
[0045] The existing hot-swap solution realizes the hot-swap of PCIE devices through a PCIE switch. This hot-swap solution is a hot-swap solution supported by hardware (or a hot-swap solution realized by hardware). Due to the limitation of hardware implementation, the flexibility of this hot-swap solution is poor. The present application realizes the hot-swap of PCIE devices through a hot-swap guardian module in the operating system of a computer device. The hot-swap guardian module is a software module (for example, the hot-swap guardian module is a hot-swap daemon process). The hot-swap solution provided by the present application is a hot-swap solution in software (or a hot-swap solution realized by software). Since the software has high flexibility, the hot-swap solution of the present application has high flexibility. The present application realizes the hot-swap of PCIE devices through software, and can realize the hot-swap of VF and PF without changing virtio-net.
[0046] The technical solution of this application is introduced below, and the application scenario of this application is first introduced.
[0047] Please refer to Figure 1, which shows a schematic diagram of an application scenario provided by an embodiment of the present application, which provides a computer device. The computer device includes a processor and a PCIE chip, and the PCIE chip is communicatively connected to the processor. For example, the PCIE chip is plugged into the root port of the processor (not shown in Figure 1). The processor is also referred to as the front-end host (front-end host), and the PCIE chip is also referred to as the back-end host (back-end host).
[0048] As shown in FIG1 , the processor includes an operating system, and the operating system includes a service layer, a driver layer, a physical layer, and a basic library.
[0049] Among them, the business layer includes a system daemon (systemd) process, a hot plug daemon (HPD) module, a log service (or log module), a hot plug message interaction service (or hot plug message interaction module) and a hot plug processing service (or hot plug processing module). The system daemon process is used to pull up the services in the user space of the operating system. For example, the hot plug daemon module, log service, hot plug message interaction service and hot plug processing service are all located in the user space of the operating system. The system daemon process is used to pull up the hot plug daemon module, log service, hot plug message interaction service and hot plug processing service to enable these modules and services to work. The hot plug message interaction service is used to connect to the PCIE chip to receive hot plug messages from the PCIE chip. The hot plug daemon module is used to process hot plug messages to realize hot plugging of PCIE devices in the PCIE chip. The hot plug processing service can be hpd func. The log service is used to collect logs generated after the computer device is turned on and running. For example, the log service is a rocket-fast system for log (rsyslog) service. Optionally, the hot plug daemon module includes a hot plug monitor (monitor) process. The hot plug monitor process is a resident process in the hot plug daemon module and is responsible for monitoring and processing dead loops. The hot plug monitor process is also called HPD_monitor.
[0050] The driver layer includes a virtual function input and output (VFIO) driver, a userspace input and output (UIO) driver, a socket driver, and a device driver. The VFIO driver is a driver that can expose device I / O, interrupts, direct memory access (DMA), etc. to the user space of the operating system. The VFIO driver, the UIO driver, the socket driver, and the device driver can all be used to support the operation of the hot-swap daemon module. In some embodiments, the VFIO driver is also referred to as a hot-swap VFIO driver or HPD_VFIO driver; the UIO driver is also referred to as a hot-swap UIO driver or HPD_UIO driver; the socket driver is also referred to as a hot-swap socket driver or HPD_socket driver; and the device driver is also referred to as a hot-swap device driver or HPD device (HPD_Dev) driver. In an embodiment of the present application, the operating modes of the VFIO driver include VFIO mode and VFIO no-IOMMU. VFIO mode refers to a mode in which the virtual IOMMU (vIOMMU) is enabled, and VFIO no-IOMMU mode refers to a mode in which the vIOMMU is not enabled. VFIO mode supports operating systems with versions ranging from 3.6 to 4.5, and VFIO no-IOMMU mode supports operating systems with versions greater than 4.5.
[0051] The physical layer includes a hot plug message definition module, which is used to define the format of the hot plug message exchanged between the processor and the PCIE chip and define the communication mechanism between the processor and the PCIE chip. For example, the hot plug message definition module is HPD_HW.
[0052] Among them, the basic library includes basic operations, peripheral component interconnect (PCI) operations, hot plug message queues, unified extensible firmware interface (UEFI) and logs. The basic operations are basic public operations. The PCI operations are PCI general operations. The hot plug message queue is used to cache hot plug messages. The log can be a log generated during the hot plug process, for example, a log generated during the hot plug process of the hot plug guardian module. The contents in the basic library shown in Figure 1 can all be hot plug-related content, and the basic library is used to support the work of the hot plug guardian module. In some embodiments, the basic library is also called a hot plug basic library or an HPD basic library; the basic operations are also called hot plug basic operations or HPD basic operations; the PCI operations are also called hot plug PCI operations or HPD_PCI operations; the log is also called a hot plug log or an HPD log (HPD_log). For example, the basic operation is HPD_UTIL and the hot plug message queue is HPD_RING.
[0053] As shown in Figure 1, the operating system includes an open virtual switch (OVS) hot plug driver, a hot plug message interaction service, a hot plug processing service, a VFIO driver, a UIO driver, a socket driver, a device driver, a hot plug message definition module, basic operations, PCI operations, a hot plug message queue, UEFI, and a log all located in the OVS hot plug driver. In some embodiments, the OVS hot plug driver in the operating system is also referred to as a hot plug driver library, a front-end OVS hot plug driver, etc. For example, the OVS hot plug driver is libhotplug.so.
[0054] As shown in Figure 1, the PCIE chip includes a service processing unit (SPU), a main processing unit (MPU) and multiple PCIE devices. The SPU includes an elasticity virtual switch (EVS) daemon, a hot-swap enabling process and a driver library, which includes an OVS hot-swap driver. The EVS daemon can be used to monitor and perceive hot-swap events. The OVS hot-swap driver is also called a back-end OVS hot-swap driver. The OVS hot-swap driver can be used to trigger hot-swap messages based on hot-swap events; the hot-swap enabling process is used to enable the hot-swap function of the PCIE chip based on an enable instruction from the operating system of the front-end host. The MPU includes a hot plug controller emulator, which can be a hot plug firmware. The hot plug control emulator is used to connect to the processor of the front-end host to realize the hot plug of the PCIE device in the PCIE chip. For example, the hot plug control emulator sends a hot plug message to the processor of the front-end host based on the hot plug event monitored by the EVS daemon. The multiple PCIE devices may include physical PCIE devices and virtual PCIE devices. For example, the multiple PCIE devices include PCIE device 01, PCIE device 02 and PCIE device 03, PCIE device 01 is a physical PCIE device, and PCIE device 02 and PCIE device 03 are both virtual PCIE devices. For example, the PCIE chip is a network card chip, the physical PCIE device is PF, and the virtual PCIE device is VF, which is derived from the virtualization of PF through virtualization technology.
[0055] Figure 1 shows the HPD-related content in a computer device. Figure 1 is also called the HPD software architecture of the computer device. The HPD software architecture shown in Figure 1 is only for example and is not used to limit the technical solution of the present application. The HPD software architecture may also include other content, which is not limited in the embodiments of the present application.
[0056] In an embodiment of the present application, a processor (front-end host) exchanges hot plug messages (hot plug messages or hot pull messages) with a PCIE chip (back-end host), and a hot plug guard module in the processor hot plugs a PCIE device in the PCIE chip according to the hot plug message. For example, the hot plug message interaction service in the processor interfaces with a hot plug control emulator in the PCIE chip to receive hot plug messages from the hot plug control emulator.
[0057] Please refer to Figure 2, which shows a structural diagram of a hot plug message provided in an embodiment of the present application. The hot plug message includes a bottom-level communication header, an upper-level message header, and an upper-level message body. The bottom-level communication header is used to carry data in the mailbox area (mailbox) x0. The upper-level message header is used to carry data in the mailbox area x1. The upper-level message body is used to carry data in mailbox areas x2 to x7 (i.e., mailbox area x2, mailbox area x3, mailbox area x4, mailbox area x5, mailbox area x6, and mailbox area x7). The bottom-level communication header includes a status field, a words field, and a reserved (rsvd) field; the status field is used to indicate whether there is data in the mailbox areas x0 to x7; the words field is used to indicate the length of the upper-level message header and the upper-level message body. The upper-layer message header includes a message sequence (Msg Seq) field, a message identification (Msg ID) field, and a message length (Msg Len) field. The Msg Seq field is used to carry the sequence of the hot plug message. The Msg ID field is used to carry the ID of the hot plug message. The Msg ID field can be used to indicate the operation type of the hot plug message, which includes a hot plug operation or a hot pull operation. For example, the ID carried by the Msg ID field is a first ID (or a first value, such as 1) or a second ID (or a second value, such as 0). The first value is used to indicate a hot plug operation, and the corresponding hot plug message is a hot plug message. The second value is used to indicate a hot pull operation, and the corresponding hot plug message is a hot pull message. The upper-layer message body is used to carry a message payload, and the Msg Len field is used to indicate the length of the message payload. Among them, the mailbox area is a register in the PCIE chip. After the processor establishes a communication connection with the PCIE chip, the processor can obtain the hot plug configuration information of the PCIE chip. For example, the processor obtains the location of the mailbox area used for hot plugging in the PCIE chip, and the processor can obtain the data in these mailbox areas. Among them, the mailbox areas x0 to x7 can be adjacent in sequence, for example, the mailbox areas x0 to x7 are mailbox areas 0 to 7. Figure 2 takes the data of 8 mailbox areas corresponding to the hot plug message as an example. The hot plug message can correspond to data in more or fewer mailbox areas, and the multiple mailbox areas where the data included in the hot plug message is located may also be non-adjacent. The embodiment of the present application does not limit this.
[0058] In an embodiment of the present application, the processor (front-end host) and the PCIE chip (back-end host) can also exchange control messages to perform hot-plug related control. For example, the processor sends a control message to the PCIE chip to control the PCIE chip to enable the hot-plug function; the processor sends a control message to the PCIE chip to request the hot-plug configuration (configure, Cfg) of the PCIE chip, that is, to obtain the hot-plug configuration information of the PCIE chip; the processor sends a control message to the PCIE chip to indicate whether the hot-plug message from the PCIE chip is successfully received by the processor; the processor sends a control message to the PCIE chip to indicate whether the processor has prepared a hot-plug confirmation (acknowledgement, Ack) message, so that the PCIE chip receives the hot-plug confirmation message from the processor according to the control message. Among them, after processing the hot-plug message from the PCIE chip, the processor sends a hot-plug confirmation message to the PCIE chip, and the hot-plug confirmation message is also called a hot-plug response message.
[0059] In an embodiment of the present application, the control message includes a control field, which is used to carry control information for corresponding control. Optionally, the control field includes a hot plug enable subfield, a hot plug configuration request subfield, a hot plug receive subfield, and a hot plug confirmation preparation subfield; the hot plug enable subfield is used to carry hot plug enable information to instruct the PCIE chip to enable the hot plug function; the hot plug configuration request subfield is used to carry hot plug configuration request information to request the hot plug configuration of the PCIE chip; the hot plug receive subfield is used to carry hot plug receive indication information to indicate whether the processor (e.g., the hot plug guard module in the processor) has received the hot plug message; the hot plug confirmation preparation subfield is used to carry hot plug confirmation preparation information to indicate whether the processor (e.g., the hot plug guard module in the processor) is ready for the hot plug confirmation message. Among them, the lengths of the four subfields, namely the hot plug enable subfield, the hot plug configuration request subfield, the hot plug receive subfield, and the hot plug confirmation preparation subfield, can be flexibly set according to actual needs. For example, if the lengths of these four subfields are all 1, then the hot plug enable subfield can also be called the hot plug enable flag, the hot plug configuration request subfield can also be called the hot plug configuration request flag, the hot plug receive subfield can also be called the hot plug receive flag, and the hot plug confirmation preparation subfield can also be called the hot plug confirmation preparation flag. As an example, please refer to Figure 3, which shows a schematic diagram of a control field provided in an embodiment of the present application. The total length of the control field is 32 bits (bits), and the control field includes bits 0 to 31, a total of 32 bits. Bit 31 is the hot-plug enable flag. Bit 31 is used to carry hot-plug enable information to indicate that the PCIE chip has enabled hot-plug functionality. For example, the value of bit 31 is 1 or 0. "1" indicates that the PCIE chip has enabled hot-plug functionality, while "0" indicates that the PCIE chip has disabled hot-plug functionality. Bit 30 is the hot-plug configuration request flag. Bit 30 is used to carry hot-plug configuration request information to request hot-plug configuration of the PCIE chip. For example, the value of bit 30 is 1 or 0. "1" indicates that the hot-plug configuration of the PCIE chip is requested, while "0" indicates that the hot-plug configuration of the PCIE chip is not requested. Bit 29 is the hot-plug receive flag. Bit 29 is used to carry hot-plug receive indication information to indicate whether the processor (e.g., the hot-plug daemon module within the processor) has received a hot-plug message. For example, the value of bit 29 is 1 or 0. "1" indicates that the hot-plug daemon module has received a hot-plug message, while "0" indicates that the hot-plug daemon module has not received a hot-plug message.Bit 28 is the hot-plug confirmation ready flag. Bit 28 carries hot-plug confirmation ready information to indicate whether the processor (e.g., the hot-plug daemon module within the processor) is ready for the hot-plug confirmation message. For example, the value of bit 28 is 1 or 0. A "1" indicates that the hot-plug daemon module has processed the hot-plug message and is ready for the hot-plug confirmation message; a "0" indicates that the hot-plug daemon module is not ready for the hot-plug confirmation message. Bits 0 through 27 may be reserved. For example, the hot-plug enable flag is called the HPD_enable flag, the hot-plug configuration request flag is called the HPD_Cfg_require flag, the hot-plug receive flag is called the HPD_Msg_accept flag, and the hot-plug confirmation ready flag is called the HPD_Ack_ready flag. The writer of the four flag bits, HPD_enable flag, HPD_Cfg_require flag, HPD_Msg_accept flag, and HPD_Ack_ready flag (the author who writes information to the four flag bits) can be the hot-plug guard module, and the reader of the four flag bits (the author who reads the information in the four flag bits) can be the OVS hot-plug driver in the PCIE chip.
[0060] The above is an introduction to the application scenarios of this application. The following introduces the method embodiments of this application.
[0061] Please refer to Figure 4, which shows a flow chart of a hot-swap method provided by an embodiment of the present application. The hot-swap method is applied to a hot-swap daemon module in a computer device, wherein the processor of the computer device includes an operating system, and the operating system includes the hot-swap daemon module. For example, the hot-swap daemon module runs in the user space of the operating system, and the hot-swap daemon module is a user-mode process. As shown in Figure 4, the hot-swap method includes the following steps S401 to S403.
[0062] S401. The hot-plug guard module receives a first hot-plug message from a first PCIE chip. The first hot-plug message carries insertion indication information and indication information of a first PCIE device. The first PCIE chip includes a first PCIE device.
[0063] Among them, the hot-swap guard module is a software module in the processor of the computer device. The first PCIE chip is communicatively connected to the processor (for example, the first PCIE chip is plugged into the root port of the processor), the first PCIE chip may include multiple PCIE devices, the multiple PCIE devices may include physical PCIE devices and virtual PCIE devices, the first PCIE device is any one of the multiple PCIE devices, and the first PCIE device is a virtual PCIE device or a physical PCIE device. Among them, the first PCIE chip includes any one of the following: a network card chip, a GPU chip, and an FPGA chip. For example, the first PCIE chip is a network card chip, and the first PCIE device is a PF or VF in the network card chip.
[0064] When a hot plug event (hot plug event or hot pull event) of a PCIE device occurs in a first PCIE chip, the first PCIE chip can sense the hot plug event, generate a hot plug message based on the hot plug event, and send the hot plug message to a processor, and a hot plug guard module in the processor can receive the hot plug message. For example, the first PCIE chip senses the hot plug event of the first PCIE device, generates a first hot plug message based on the hot plug event, and sends the first hot plug message to the processor, and the hot plug guard module in the processor receives the first hot plug message.
[0065] In an optional embodiment, the first PCIE chip includes a hot plug control emulator, and the processor includes a hot plug message interaction service. The hot plug control emulator is used to interface with the hot plug message interaction service to transmit messages between the first PCIE chip and the processor. The hot plug control emulator can send a hot plug message to the hot plug message interaction service, and the hot plug message interaction service transmits the hot plug message to the hot plug daemon module after receiving the hot plug message. In one example, the first PCIE chip includes an MPU and an SPU, the hot plug control emulator is located in the MPU, the SPU senses a hot plug event, and after the SPU senses a hot plug event, it triggers the hot plug control emulator to generate a hot plug message, and the hot plug control emulator sends a hot plug message to the hot plug message interaction service in the processor. In a specific example, the SPU includes an EVS daemon, and the EVS daemon senses the hot plug event of the PCIE device.
[0066] In an embodiment of the present application, after the SPU in the first PCIE chip senses a hot plug event of the first PCIE device, the SPU triggers the hot plug control emulator in the first PCIE chip to generate a first hot plug message. The hot plug control emulator sends the first hot plug message to the processor. After receiving the first hot plug message, the hot plug message interaction service in the processor transmits the first hot plug message to the hot plug guard module, so that the hot plug guard module can receive the first hot plug message from the first PCIE chip. The first hot plug message carries insertion indication information and indication information of the first PCIE device. The insertion indication information is used to indicate a hot plug operation, and the indication information of the first PCIE device is used to indicate the first PCIE device. The indication information of the first PCIE device can be an identifier of the first PCIE device. For example, the structure of the first hot plug message is shown in Figure 2. As mentioned above, the message identification field in Figure 2 can be used to indicate the operation type of the hot plug message, so the insertion indication information is located in the message identification field (for example, the value of the message identification field is the first value, and the first value is the insertion indication information), and the indication information of the first PCIE device can be located in the message payload.
[0067] Optionally, before the first PCIE chip sends the first hot plug message to the processor, the first PCIE chip determines whether the processor has processed the previous hot plug message (for example, the hot plug control emulator in the first PCIE chip determines whether the processor has processed the previous hot plug message). If the first PCIE chip determines that the processor has processed the previous hot plug message, the first PCIE chip sends the first hot plug message to the processor. For example, the first PCIE chip sends a query request to the processor to query whether the processor has processed the previous hot plug message. The previous hot plug message can be a hot plug message or a hot pull message.
[0068] S402. The hot-swap guard module determines the first PCIE device according to the indication information of the first PCIE device.
[0069] The first hot plug message carries indication information of the first PCIE device, and the indication information of the first PCIE device is used to indicate the first PCIE device. After the hot plug guard module receives the first hot plug message, the hot plug guard module determines the first PCIE device based on the indication information of the first PCIE device carried in the first hot plug message. Optionally, the hot plug guard module performs a device scan based on the indication information of the first PCIE device to determine the first PCIE device.
[0070] The hot-swap guard module can also determine the type of the first PCIE device by performing device scanning. The type of the first PCIE device can be a network card device (for example, a PCIE device in a network card chip), a GPU device (for example, a PCIE device in a GPU chip), or an FPGA device (for example, a PCIE device in an FPGA chip), etc. The embodiment of the present application does not limit this.
[0071] S403. The hot-plug guard module performs a hot-plug operation on the first PCIE device according to the insertion instruction information.
[0072] The first hot plug message carries insertion indication information, which is used to indicate a hot plug operation. The hot plug guard module determines the hot plug operation based on the insertion indication information carried by the first hot plug message. After the hot plug guard module determines the first PCIE device, it performs the hot plug operation on the first PCIE device to hot plug the first PCIE device.
[0073] In an optional embodiment, the hot-swap guard module obtains the device driver corresponding to the first PCIE device according to the indication information of the first PCIE device, and the hot-swap guard module installs the device driver corresponding to the first PCIE device according to the insertion indication information to perform a hot-plug operation on the first PCIE device, thereby hot-plugging the first PCIE device. For example, each device driver corresponds to a device indication information, and the device indication information corresponding to each device driver is used to indicate the PCIE device corresponding to each device driver. The hot-swap guard module determines the device driver corresponding to the indication information of the first PCIE device, and the hot-swap guard module determines the device driver as the device driver corresponding to the first PCIE device. The hot-swap guard module loads the device driver corresponding to the first PCIE device to obtain the device driver corresponding to the first PCIE device.
[0074] After the hot-plug guard module performs a hot-plug operation on the first PCIE device, the hot-plug guard module generates a first hot-plug confirmation message and sends the first hot-plug confirmation message to the first PCIE chip. The first hot-plug confirmation message is used to indicate that the hot-plug of the first PCIE device is successful. Optionally, the hot-plug guard module sends the first hot-plug confirmation message to the hot-plug message interaction service, and the hot-plug message interaction service sends the first hot-plug confirmation message to the first PCIE chip; after the hot-plug control emulator in the first PCIE chip receives the first hot-plug confirmation message, the hot-plug control emulator sends the first hot-plug confirmation message to the SPU in the first PCIE chip (for example, to the EVS daemon in the SPU), and the SPU determines that the hot-plug of the first PCIE device is successful based on the first hot-plug confirmation message. Optionally, the hot-plug guard module generates a first hot-plug control message and a first hot-plug confirmation message, the first hot-plug control message is used to indicate that the first hot-plug confirmation message is ready, the hot-plug guard module sends the first hot-plug control message and the first hot-plug confirmation message to the first PCIE chip, the first PCIE chip receives the first hot-plug control message, and the first PCIE chip receives the first hot-plug confirmation message according to the first hot-plug control message. For example, the first hot-plug control message includes a control field as shown in FIG3 , and the value in the hot-plug confirmation preparation flag (bit 28) in the first hot-plug control message can be "1".
[0075] To sum up, the technical solution provided by the embodiment of the present application sets a hot-swap guard module in the operating system of the computer device, and realizes the hot insertion of PCIE devices through the hot-swap guard module. It can not only realize the hot insertion of physical PCIE devices, but also realize the hot insertion of virtual PCIE devices. It has a wide range of application scenarios and high flexibility.
[0076] In an optional embodiment, please refer to Figure 5, which shows a flow chart of another hot-swap method provided by an embodiment of the present application. As shown in Figure 5, after S403, the hot-swap method further includes steps S404 to S406.
[0077] S404. The hot-plug guard module receives a first hot-plug message from the first PCIE chip. The first hot-plug message carries the plug-out instruction information and the instruction information of the first PCIE device.
[0078] When a hot plug event (hot plug event or hot pull event) of a PCIE device occurs in a first PCIE chip, the first PCIE chip can sense the hot plug event, generate a hot plug message based on the hot plug event, and send the hot plug message to a processor, and a hot plug guard module in the processor can receive the hot plug message. For example, the first PCIE chip senses the hot pull event of the first PCIE device, generates a first hot pull message based on the hot pull event, and sends the first hot pull message to the processor, and the hot plug guard module in the processor receives the first hot pull message.
[0079] In an optional embodiment, after the SPU in the first PCIE chip senses a hot-plug event of the first PCIE device, the SPU triggers the hot-plug control emulator in the first PCIE chip to generate a first hot-plug message. The hot-plug control emulator sends the first hot-plug message to the processor. After receiving the first hot-plug message, the hot-plug message interaction service in the processor transmits the first hot-plug message to the hot-plug guard module, so that the hot-plug guard module can receive the first hot-plug message from the first PCIE chip. The first hot-plug message carries unplug indication information and indication information of the first PCIE device. The unplug indication information is used to indicate a hot-plug operation, and the indication information of the first PCIE device is used to indicate the first PCIE device. The indication information of the first PCIE device can be an identifier of the first PCIE device. For example, the structure of the first hot plug message is shown in Figure 2. As mentioned above, the message identification field in Figure 2 can be used to indicate the operation type of the hot plug message, so the unplug indication information is located in the message identification field (for example, the value of the message identification field is the second value, and the second value is the unplug indication information), and the indication information of the first PCIE device can be located in the message payload.
[0080] Optionally, before the first PCIE chip sends the first hot plug message to the processor, the first PCIE chip determines whether the processor has processed a previous hot plug message. If the first PCIE chip determines that the processor has processed the previous hot plug message, the first PCIE chip sends the first hot plug message to the processor. The previous hot plug message may be a hot plug message or a hot pull message.
[0081] S405. The hot-swap guard module determines the first PCIE device according to the indication information of the first PCIE device.
[0082] The first hot-plug message carries indication information of the first PCIE device, and the indication information of the first PCIE device is used to indicate the first PCIE device. After the hot-plug guard module receives the first hot-plug message, the hot-plug guard module determines the first PCIE device according to the indication information of the first PCIE device carried in the first hot-plug message.
[0083] S406. The hot-plug guard module performs a hot-plug operation on the first PCIE device according to the plug-out instruction information.
[0084] The first hot unplug message carries unplug instruction information, which is used to indicate a hot unplug operation. The hot unplug guard module determines the hot unplug operation based on the unplug instruction information carried in the first hot unplug message. After determining the first PCIE device, the hot unplug guard module performs the hot unplug operation on the first PCIE device to hot unplug the first PCIE device. Optionally, the hot unplug guard module uninstalls the device driver corresponding to the first PCIE device to perform the hot unplug operation on the first PCIE device.
[0085] After the hot-plug guard module performs a hot-plug operation on the first PCIE device, the hot-plug guard module generates a first hot-plug confirmation message and sends the first hot-plug confirmation message to the first PCIE chip. The first hot-plug confirmation message is used to indicate that the hot-plug of the first PCIE device is successful. Optionally, the hot-plug guard module sends the first hot-plug confirmation message to a hot-plug message interaction service, and the hot-plug message interaction service sends the first hot-plug confirmation message to the first PCIE chip. After the hot-plug control emulator in the first PCIE chip receives the first hot-plug confirmation message, the hot-plug control emulator sends the first hot-plug confirmation message to an SPU in the first PCIE chip (for example, to an EVS daemon in the SPU). The SPU determines that the hot-plug of the first PCIE device is successful based on the first hot-plug confirmation message. Optionally, the hot-plug guard module generates a first hot-plug control message and a first hot-plug confirmation message, and the hot-plug guard module sends the first hot-plug control message and the first hot-plug confirmation message to the first PCIE chip. The first hot-plug control message is used to indicate that the first hot-plug confirmation message is ready. The first PCIE chip receives the first hot-plug control message, and the first PCIE chip receives the first hot-plug confirmation message according to the first hot-plug control message. For example, the first hot-plug control message includes a control field as shown in FIG3 , and the value in the hot-plug confirmation ready flag (bit 28) in the first hot-plug control message can be "1".
[0086] In summary, the technical solution provided by the embodiments of the present application provides a hot-swap daemon module within the operating system of a computer device. This hot-swap daemon module enables hot-swapping of PCIE devices, enabling hot-swapping of not only physical PCIE devices but also virtual PCIE devices, thus offering a wide range of applications and high flexibility. Furthermore, the hot-swap daemon module runs in the user space of the operating system. As a software module within this user space, it is decoupled from the kernel of the operating system and can be released without verification by the kernel.
[0087] In an optional embodiment, please refer to Figure 6, which shows a flow chart of another hot-swap method provided by an embodiment of the present application. As shown in Figure 6, after S401, the hot-swap method further includes step S407.
[0088] S407. The hot-swap guard module initializes the first PCIE chip.
[0089] After the first PCIE chip establishes a communication connection with the processor, the hot-swap guard module in the processor initializes the first PCIE chip to obtain the hot-swap configuration of the first PCIE chip.
[0090] Optionally, the hot-swap guard module generates a control message and sends the control message to a hot-swap message interaction service in the processor, and the hot-swap message interaction service sends the control message to the first PCIE chip. For example, the control message includes a control field as shown in FIG3 , and in the control field of the control message, the value of the hot-swap configuration request flag (bit 30) can be “1” to request hot-swap configuration of the first PCIE chip.
[0091] In an optional embodiment, please continue to refer to FIG. 6 , after S407 , the hot-swap method further includes step S408 .
[0092] S408. The hot-swap guard module enables the hot-swap function for the first PCIE chip.
[0093] Optionally, the hot-plug guard module generates a hot-plug enable message, and the hot-plug guard module sends the hot-plug enable message to the hot-plug message interaction service in the processor. The hot-plug message interaction service sends the hot-plug enable message to the first PCIE chip, and the hot-plug enable process in the first PCIE chip enables the hot-plug function for the first PCIE chip according to the hot-plug enable message. For example, the hot-plug enable message includes a control field as shown in FIG3 . In the control field in the hot-plug enable message, the value in the hot-plug enable flag (bit 31) can be "1" to indicate that the first PCIE chip enables the hot-plug function. After the first PCIE chip enables the hot-plug function, the first PCIE chip can generate a hot-plug message based on the hot-plug event and send the hot-plug message to the processor.
[0094] In an embodiment of the present application, the hot-swap daemon module runs in the user space of the operating system. Before executing the technical solution of the aforementioned embodiment of the present application, the system daemon process (systemd process) in the operating system can pull up the hot-swap daemon module so that the hot-swap daemon module can work, thereby executing the above-mentioned hot-swap method embodiment.
[0095] Please refer to Figure 7, which shows an interaction diagram of a hot-swap method provided in an embodiment of the present application. Figure 7 uses the interaction between a processor and a first PCIE chip as an example. The processor includes a system daemon and a hot-swap daemon module (for example, the processor includes an operating system, and the operating system includes the hot-swap daemon module), and the first PCIE chip includes an SPU and an MPU. As shown in Figure 7, the hot-swap method includes the following steps S701 to S718.
[0096] S701. The system daemon process starts the hot-swappable daemon module.
[0097] S702: The hot-swap protection module discovers the first PCIE chip.
[0098] For example, the hot-swap guard module performs a device discovery operation to discover the first PCIE chip.
[0099] S703. The hot-swap guard module initializes the first PCIE chip.
[0100] S704. The hot-swap guard module enables the hot-swap function of the first PCIE chip.
[0101] For example, the hot-swap guard module sends a hot-swap enable message to the first PCIE chip, and the first PCIE chip enables the hot-swap function of the first PCIE chip according to the hot-swap enable message. For example, the SPU in the first PCIE chip includes a hot-swap enable process, and the hot-swap enable process enables the hot-swap function of the first PCIE chip according to the hot-swap enable message. After the hot-swap guard module enables the hot-swap function of the first PCIE chip, the hot-swap guard module waits for a hot-swap message from the first PCIE chip.
[0102] S705. The SPU sends a hot plug event A of the first PCIE device to the MPU.
[0103] After the SPU senses the hot plug event A of the first PCIE device, it sends the hot plug event A to the MPU. For example, the SPU includes an EVS daemon process, and the MPU includes a hot plug control emulator. The EVS daemon process senses the hot plug event A and sends the hot plug event A to the hot plug control emulator.
[0104] S706. The MPU queries the hot-swap guard module whether the previous hot-swap message has been processed.
[0105] For example, the MPU sends a query request to the hot plug guard module to query whether the last hot plug message has been processed. The last hot plug message has been processed means that the hot plug guard module has completed the hot plug of the corresponding PCIE device according to the last hot plug message.
[0106] S707. The hot-swap guard module notifies the MPU that the previous hot-swap message has been processed.
[0107] For example, the hot-plug daemon module sends a query response to the MPU to inform the MPU that the previous hot-plug message has been processed.
[0108] S706 to S707 are explained using the example of the hot-swap guard module processing the previous hot-swap message. Optionally, if the hot-swap guard module has not yet processed the previous hot-swap message, the hot-swap guard module notifies the MPU that the previous hot-swap message has not been processed. Thereafter, the MPU may periodically query the hot-swap guard module to determine whether the previous hot-swap message has been processed. Until the hot-swap guard module notifies the MPU that the previous hot-swap message has been processed, the MPU executes step S708.
[0109] S708. The MPU sends a first hot plug message to the hot plug guard module according to the hot plug event A. The first hot plug message is used to instruct to perform a hot plug operation on the first PCIE device.
[0110] For example, the first hot plug message includes insertion indication information and indication information of the first PCIE device, the insertion indication information is used to indicate a hot plug operation, and the indication information of the first PCIE device is used to indicate the first PCIE device, so that the first hot plug message is used to indicate a hot plug operation for the first PCIE device.
[0111] S709. The hot plug guard module performs a hot plug operation on the first PCIE device according to the first hot plug message.
[0112] S710. The hot-plug guard module sends a first hot-plug confirmation message to the MPU.
[0113] After the hot-plug guard module performs a hot-plug operation on the first PCIE device, the hot-plug guard module generates a first hot-plug confirmation message and sends the first hot-plug confirmation message to the first PCIE chip. Optionally, the hot-plug guard module also generates a first hot-plug control message and sends the first hot-plug control message to the first PCIE chip. The first hot-plug control message is used to indicate that the first hot-plug confirmation message is ready.
[0114] S711. The MPU sends a first hot plug confirmation message to the SPU.
[0115] After receiving the first hot plug confirmation message, the MPU sends the first hot plug confirmation message to the SPU. After receiving the first hot plug confirmation message, the SPU determines that the first PCIE device is successfully hot plugged based on the first hot plug confirmation message. Optionally, the MPU further sends a first hot plug control message to the SPU. The SPU receives the first hot plug confirmation message based on the first hot plug control message and determines that the first PCIE device is successfully hot plugged based on the first hot plug confirmation message.
[0116] S712. The SPU sends a hot-plug event B of the first PCIE device to the MPU.
[0117] After the SPU senses the hot plug event B of the first PCIE device, it sends the hot plug event B to the MPU. For example, the SPU includes an EVS daemon process, and the MPU includes a hot plug control emulator. The EVS daemon process senses the hot plug event B and sends the hot plug event B to the hot plug control emulator.
[0118] S713. The MPU queries the hot-swap guard module whether the previous hot-swap message has been processed.
[0119] S714. The hot-swap guard module notifies the MPU that the previous hot-swap message has been processed.
[0120] S715. The MPU sends a first hot-plug message to the hot-plug guard module according to the hot-plug event B. The first hot-plug message is used to instruct to perform a hot-plug operation on the first PCIE device.
[0121] For example, the first hot unplug message includes unplug indication information and indication information of the first PCIE device, the unplug indication information is used to indicate the hot unplug operation, and the indication information of the first PCIE device is used to indicate the first PCIE device, so that the first hot unplug message is used to indicate the hot unplug operation for the first PCIE device.
[0122] S716. The hot plug guard module performs a hot plug operation on the first PCIE device according to the first hot plug message.
[0123] S717. The hot-swap guard module sends a first hot-swap confirmation message to the MPU.
[0124] After the hot-plug guard module performs a hot-plug operation on the first PCIE device, the hot-plug guard module generates a first hot-plug confirmation message and sends the first hot-plug confirmation message to the first PCIE chip. Optionally, the hot-plug guard module also generates a first plug control message and sends the first plug control message to the first PCIE chip, where the first plug control message is used to indicate that the first plug confirmation message is ready.
[0125] S718. The MPU sends a first hot-plug confirmation message to the SPU.
[0126] After receiving the first hot unplug confirmation message, the MPU sends the first hot unplug confirmation message to the SPU. After receiving the first hot unplug confirmation message, the SPU determines that the first PCIE device has been successfully hot unplugged based on the first hot unplug confirmation message. Optionally, the MPU further sends a first hot unplug control message to the SPU. The SPU receives the first hot unplug confirmation message based on the first hot unplug control message and determines that the first PCIE device has been successfully hot unplugged based on the first hot unplug confirmation message.
[0127] Please refer to Figure 8, which shows an interaction diagram of another hot-swap method provided in an embodiment of the present application. Figure 8 takes the interaction between a processor and a first PCIE chip as an example. The processor includes UEFI and a hot-swap guard module (for example, the processor includes an operating system, and the operating system includes the UEFI and the hot-swap guard module). The first PCIE chip includes an SPU and an MPU. The SPU includes an EVS daemon, an OVS hot-swap driver, and a hot-swap enabling process. As shown in Figure 8, the hot-swap method includes the following steps S801 to S821.
[0128] S801. The EVS daemon sends a hot plug event A1 of the first PCIE device to the OVS hot plug driver.
[0129] The EVS daemon process can sense a hot plug event A1 of a first PCIE device, and after sensing the hot plug event A1, the EVS daemon process sends the hot plug event A1 to an OVS hot plug driver, wherein the first PCIE device is in a first PCIE chip.
[0130] S802. The OVS hot-swap driver queries the hot-swap enabling process based on the hot-swap event A1 whether the front-end host enables the hot-swap function of the first PCIE chip.
[0131] For example, the OVS hot-swap driver sends a query request to the hot-swap enabling process to query whether the front-end host enables the hot-swap function of the first PCIE chip.
[0132] S803. The hot-swap enabling process notifies the OVS hot-swap driver that the front-end host does not enable the hot-swap function of the first PCIE chip.
[0133] For example, the hot-plug enabling process sends a query response to the OVS hot-plug driver to inform the OVS hot-plug driver that the front-end host does not enable the hot-plug function of the first PCIE chip.
[0134] S804. The OVS hot-swap driver hot-plugs the first PCIE device at the back end.
[0135] S805. The OVS hot-plug driver sends a hot-plug response A1 of the first PCIE device to the EVS daemon process.
[0136] The hot plug response A1 may be used to indicate that the first PCIE device is hot plugged successfully. For example, the hot plug response A1 is used to indicate that the first PCIE device is hot plugged successfully at the back end.
[0137] The above steps S801 to S805 occur during the startup of the front-end host. During the startup of the front-end host, the hot-swap guard module has not yet been pulled up and is in an offline state. However, the front-end host will perform relevant initializations. Through these initializations, the operating system of the front-end host can recognize the first PCIE device, thereby realizing hot plugging of the first PCIE device.
[0138] S806. UEFI loading. For example, the front-end host loads UEFI.
[0139] S807. UEFI sends a hot plug enable message to the hot plug enable process based on the participation of the OS of the front-end host to enable the hot plug function of the first PCIE chip.
[0140] S808. The EVS daemon sends a hot plug event A2 of the second PCIE device to the OVS hot plug driver.
[0141] The EVS daemon process can sense the hot plug event A2 of the second PCIE device, and after sensing the hot plug event A2, the EVS daemon process sends the hot plug event A2 to the OVS hot plug driver.
[0142] S809. The OVS hot-swap driver queries the hot-swap enabling process based on the hot-swap event A2 whether the front-end host enables the hot-swap function of the first PCIE chip.
[0143] S810. The hot-swap enabling process notifies the OVS hot-swap driver that the front-end host has enabled the hot-swap function of the first PCIE chip.
[0144] The S811.OVS hot-swap driver hot-plugs the second PCIE device at the back end.
[0145] S812.OVS hot-swap driver requests the hot-swap guard module to hot-plug the second PCIE device at the front end.
[0146] For example, the OVS hot-plug driver triggers the MPU to send a hot-plug message to the hot-plug guardian module to request the hot-plug guardian module to hot-plug the second PCIE device at the front end.
[0147] S813. The hot-swap guard module hot-plugs the second PCIE device at the front end.
[0148] S814. The hot-swap guard module sends a hot-swap confirmation message to the OVS hot-swap driver.
[0149] For example, the hot-plug guard module sends a hot-plug confirmation message to the MPU, and the MPU sends a hot-plug confirmation message to the OVS hot-plug driver, where the hot-plug confirmation message is used to indicate that the second PCIE device is successfully hot-plugged at the front end.
[0150] S815. The OVS hot-plug driver sends a hot-plug response A2 of the second PCIE device to the EVS daemon based on the hot-plug confirmation message. The hot-plug response A2 is used to indicate that the hot-plug of the second PCIE device is successful.
[0151] The above steps S806 to S815 occur during the operation of the front-end host (i.e., the front-end host is fully started and all initializations are completed). During the operation of the front-end host, the system daemon process in the front-end host can start the hot-swap daemon module, which is in an online state. The hot-swap daemon module participates in implementing the hot plugging of the first PCIE device.
[0152] S816. UEFI sends a disabling message to the hot plug enabling process based on the front-end host restart to disable the hot plug function of the first PCIE chip.
[0153] S817. The EVS daemon sends a hot plug event A3 of the first PCIE device to the OVS hot plug driver.
[0154] S818. The OVS hot-swap driver queries the hot-swap enabling process based on the hot-swap event A3 whether the front-end host enables the hot-swap function of the first PCIE chip.
[0155] S819. The hot-swap enabling process notifies the OVS hot-swap driver that the front-end host does not enable the hot-swap function of the first PCIE chip.
[0156] The S820.OVS hot-swap driver hot-plugs the first PCIE device at the back end.
[0157] S821. The OVS hot-plug driver sends a hot-plug response A3 of the first PCIE device to the EVS daemon process.
[0158] The hot plug response A3 may be used to indicate that the first PCIE device is hot plugged successfully. For example, the hot plug response A3 is used to indicate that the first PCIE device is hot plugged successfully at the back end.
[0159] The above steps S817 to S821 occur during the restart of the front-end host. During the restart of the front-end host, the hot-swap guard module has not yet been pulled up and is in an offline state. However, the front-end host will perform relevant initializations. Through these initializations, the operating system of the front-end host can recognize the first PCIE device, thereby realizing hot plugging of the first PCIE device.
[0160] The above is an introduction to the method embodiments of the present application. The following describes the device embodiments of the present application. The device of the present application can be used to perform the method of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments.
[0161] Please refer to Figure 9, which shows a schematic diagram of a hot-swap device 900 provided in an embodiment of the present application. The hot-swap device 900 is applied to a hot-swap guard module in a computer device, and the processor of the computer device includes an operating system, and the operating system includes the hot-swap guard module. For example, the hot-swap device 900 is the hot-swap guard module or a functional unit in the hot-swap guard module. The processor of the computer device is communicatively connected to the first PCIE chip, and the first PCIE chip includes a first PCIE device. Referring to Figure 9, the hot-swap device 900 includes a receiving unit 910, a determining unit 920, and an executing unit 930.
[0162] The receiving unit 910 is configured to receive a first hot plug message from the first PCIE chip, the first hot plug message carrying insertion indication information and indication information of the first PCIE device. The functional implementation of the receiving unit 910 may refer to the description in S401.
[0163] The determining unit 920 is configured to determine the first PCIE device according to the indication information of the first PCIE device. The functional implementation of the determining unit 920 may refer to the description in S402.
[0164] The execution unit 930 is configured to perform a hot plug operation on the first PCIE device according to the insertion instruction information. The implementation of the function of the execution unit 930 may refer to the description in S403.
[0165] Optionally, the execution unit 930 is configured to install a device driver corresponding to the first PCIE device according to the insertion instruction information.
[0166] Optionally, please continue to refer to FIG. 9 , the hot plug device 900 further includes: an acquiring unit 940 , configured to acquire a device driver corresponding to the first PCIE device according to the instruction information of the first PCIE device.
[0167] Optionally, the receiving unit 910 is further configured to receive a first hot unplug message from the first PCIE chip, the first hot unplug message carrying unplug instruction information and instruction information of the first PCIE device. The implementation of the function of the receiving unit 910 may also refer to the description in S404.
[0168] The determining unit 920 is further configured to determine the first PCIE device according to the indication information of the first PCIE device. The functional implementation of the receiving unit 910 may refer to the description in S405.
[0169] The execution unit 930 is further configured to perform a hot-plug operation on the first PCIE device according to the plug-out instruction information. The implementation of the function of the execution unit 930 may refer to the description in S406.
[0170] Optionally, the execution unit 930 is configured to uninstall a device driver corresponding to the first PCIE device according to the removal instruction information.
[0171] Optionally, please continue to refer to FIG. 9 , the hot plug device 900 further includes: an initialization unit 950 , configured to initialize the first PCIE chip before the receiving unit 910 receives the first hot plug message from the first PCIE chip.
[0172] Optionally, please continue to refer to FIG. 9 , the hot plug device 900 further includes: an enabling unit 960 , configured to enable the hot plug function for the first PCIE chip before the receiving unit 910 receives the first hot plug message from the first PCIE chip.
[0173] Optionally, the hot-swap daemon module runs in the user space of the operating system.
[0174] Optionally, the first PCIE chip includes a hot plug control emulator, and the hot plug control emulator is used to send the first hot plug message.
[0175] Optionally, the first PCIE chip includes an MPU, and the MPU includes the hot-swap control emulator.
[0176] Optionally, the first PCIE device is a physical PCIE device or a virtual PCIE device.
[0177] Optionally, the first PCIE chip includes any one of the following: a network card chip, a GPU chip, or an FPGA chip.
[0178] Optionally, the first PCIE chip is a network card chip, and the first PCIE device is a PF or a VF.
[0179] To sum up, the technical solution provided by the embodiment of the present application is to set a hot-swap guard module in the operating system of the computer device, and perform hot-swap on the PCIE device in the PCIE chip through the hot-swap guard module. The hot-swap of the PCIE device in the PCIE chip can be realized without the PCIE chip supporting the PCIE switching function. Not only can the hot-swap of physical PCIE devices be realized, but also the hot-swap of virtual PCIE devices can be realized. The application scenarios of the present application are wide and the flexibility is high.
[0180] An embodiment of the present application provides an operating system, including a hot-swap guard module, the hot-swap guard module including a receiving unit and a processing unit, the transceiver unit being used to execute the receiving step in the above-mentioned method embodiment, and the processing unit being used to execute the steps other than the receiving step in the above-mentioned method embodiment. Optionally, the hot-swap guard module includes a hot-swap device 900 as shown in FIG9 , the receiving unit being the above-mentioned receiving unit 910, and the processing unit including at least one of the above-mentioned determining unit 920, executing unit 930, acquiring unit 940, initializing unit 950, and enabling unit 960.
[0181] An embodiment of the present application provides a processor including the operating system.
[0182] An embodiment of the present application provides a processor, including a hot-swap device 900 shown in FIG. 9 .
[0183] An embodiment of the present application provides a computer device comprising a memory and a processor; the memory is configured to store a computer program; and the processor is configured to execute the computer program stored in the memory to implement all or part of the steps of the method provided in the above method embodiment. For example, the processor includes a hot-swap daemon module configured to execute the computer program stored in the memory to implement all or part of the steps of the method provided in the above method embodiment. The computer device may be a server or other device with computing capabilities.
[0184] For example, please refer to Figure 10, which shows a schematic diagram of a computer device 1000 provided in an embodiment of the present application. The computer device 1000 includes a processor 1002, a memory 1004, a PCIE chip 1006, a communication interface 1008, and a bus 1010. The processor 1002, the memory 1004, the PCIE chip 1006, and the communication interface 1008 are communicatively connected to each other via the bus 1010. The connection method between the processor 1002, the memory 1004, the PCIE chip 1006, and the communication interface 1008 shown in Figure 10 is merely exemplary. During implementation, the processor 1002, the memory 1004, the PCIE chip 1006, and the communication interface 1008 may also be communicatively connected to each other using other connection methods besides the bus 1010.
[0185] The memory 1004 can be used to store a computer program 10042, which may include instructions and data. The memory 1004 is a storage medium of various types, such as random access memory (RAM), read-only memory (ROM), non-volatile RAM (NVRAM), programmable ROM (PROM), erasable PROM (EPROM), electrically erasable PROM (EEPROM), flash memory, optical storage, and registers.
[0186] The processor 1002 may be a general-purpose processor. The general-purpose processor may perform specific steps and / or operations by reading and executing a computer program (e.g., computer program 10042) stored in a memory (e.g., memory 1004). The general-purpose processor may use data stored in the memory during the execution of the steps and / or operations. A general-purpose processor is, for example, but not limited to, a central processing unit (CPU). The processor 1002 may also be a combination of multiple processors, such as a multi-core processor. For example, as shown in FIG10 , the processor 1002 includes a hot-swap guard module 10022. The hot-swap guard module 10022 performs the method provided in the above-mentioned method embodiment by reading and executing a computer program stored in the memory.
[0187] PCIE chip 1006 can be any of a variety of PCIE chips, such as, but not limited to, a network interface card (NIC) chip, a GPU chip, or an FPGA chip. PCIE chip 1006 includes multiple PCIE devices, which can include physical PCIE devices and virtual PCIE devices. For example, the multiple PCIE devices include PCIE device 10062 and PCIE device 10064, where PCIE device 10062 is a physical PCIE device and PCIE device 10064 is a virtual PCIE device. For example, PCIE chip 1006 is a NIC chip, PCIE device 10062 is a physical device, and PCIE device 10064 is a virtual device.
[0188] The communication interface 1008 may include input / output (I / O) interfaces, physical interfaces, and logical interfaces, etc., for interconnecting components within the computer device 1000, as well as interfaces for interconnecting the computer device 1000 with other devices. The physical interface may be a gigabit Ethernet (GE) interface, which may be used to interconnect the computer device 1000 with other devices. The logical interface is an interface within the computer device 1000, which may be used to interconnect components within the computer device 1000. The communication interface 1008 may be used for the computer device 1000 to communicate with other devices. For example, the communication interface 1008 may be used to send and receive messages between the computer device 1000 and other devices.
[0189] The bus 1010 may be any type of communication bus, such as a system bus, for interconnecting the processor 1002, the memory 1004, the PCIE chip 1006, and the communication interface 1008. The bus 1010 may include a data bus, an address bus, and the like.
[0190] The computer device 1000 shown in FIG10 is merely exemplary. During implementation, the computer device 1000 may further include other components, which are not listed here one by one.
[0191] An embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed (for example, by a processor, a hot-swap guard module, the above-mentioned hot-swap device 900, etc.), all or part of the steps of the method provided in the above-mentioned method embodiment are implemented.
[0192] An embodiment of the present application provides a computer program product, which includes a program or code. When the program or code is executed (for example, by a processor, a hot-swap guard module, the above-mentioned hot-swap device 900, etc.), it implements all or part of the steps of the method provided in the above-mentioned method embodiment.
[0193] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When software is used for implementation, it can be implemented in whole or in part in the form of a computer program product, which includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, computer, server or data center to another website, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrations. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium, or a semiconductor medium (e.g., a solid-state hard disk).
[0194] It should be understood that the term "at least one" in this application refers to one or more, and "a plurality of" refers to two or more. The term "and / or" in this application is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, for the sake of clarity of description, in this application, words such as "first", "second", and "third" are used to distinguish between identical or similar items with substantially the same functions and effects. Those skilled in the art will understand that words such as "first", "second", and "third" do not limit the quantity and execution order.
[0195] The different types of embodiments, such as the method embodiments and device embodiments provided in the embodiments of this application, can refer to each other, and the embodiments of this application are not limited thereto. The order of the operations of the method embodiments provided in the embodiments of this application can be appropriately adjusted, and the operations can be increased or decreased in response to the circumstances. Any person skilled in the art who can easily think of a method of variation within the technical scope disclosed in this application should be included in the scope of protection of this application, and therefore will not be described in detail.
[0196] In the corresponding embodiments provided in this application, it should be understood that the disclosed devices, etc. can be implemented through other configurations. For example, the device embodiments described above are merely illustrative. For example, the module division is merely a logical function division. In actual implementation, other division methods may be used, such as combining or integrating multiple modules or components into another system, or ignoring or not implementing certain features.
[0197] Modules described as separate components may or may not be physically separate, and components described as modules may or may not be physical modules. They may be located in one place or distributed across multiple devices. Some or all of these modules may be selected to achieve the purpose of this embodiment based on actual needs.
[0198] The above description is merely an exemplary embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or replacements within the technical scope disclosed in this application, and these modifications or replacements should be included within the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.
Claims
1. A hot-swap method, characterized in that: A hot-swap guard module is applied to a computer device, wherein a processor of the computer device includes an operating system, the operating system includes the hot-swap guard module, the processor is communicatively connected with a first peripheral component interconnect standard PCIE chip, the first PCIE chip includes a first PCIE device, and the method includes: The hot-plug guard module receives a first hot-plug message from the first PCIE chip, where the first hot-plug message carries insertion indication information and indication information of the first PCIE device; The hot-swap guard module determines the first PCIE device according to the indication information of the first PCIE device; The hot-plug guard module performs a hot-plug operation on the first PCIE device according to the insertion indication information.
2. The method according to claim 1, characterized in that The hot-plug guard module performs a hot-plug operation on the first PCIE device according to the insertion indication information, including: The hot-swap guard module installs a device driver corresponding to the first PCIE device according to the insertion indication information.
3. The method according to claim 2, characterized in that The method further comprises: The hot-swap guard module obtains a device driver corresponding to the first PCIE device according to the indication information of the first PCIE device.
4. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: The hot-plug guard module receives a first hot-plug message from the first PCIE chip, where the first hot-plug message carries the plug-out indication information and the indication information of the first PCIE device; The hot-swap guard module determines the first PCIE device according to the indication information of the first PCIE device; The hot plug guard module performs a hot plug operation on the first PCIE device according to the pull-out indication information.
5. The method according to claim 4, characterized in that The hot-plug guard module performs a hot-plug operation on the first PCIE device according to the unplug instruction information, including: The hot-plug guard module uninstalls the device driver corresponding to the first PCIE device according to the unplug indication information.
6. The method according to any one of claims 1 to 5, characterized in that: Before the hot-plug guard module receives the first hot-plug message from the first PCIE chip, the method further includes: The hot-swap guard module initializes the first PCIE chip.
7. The method according to any one of claims 1 to 6, characterized in that: Before the hot-plug guard module receives the first hot-plug message from the first PCIE chip, the method further includes: The hot-swap guard module enables the hot-swap function for the first PCIE chip.
8. The method according to any one of claims 1 to 7, characterized in that: The hot-swap daemon module runs in the user space of the operating system.
9. The method according to any one of claims 1 to 8, characterized in that: The first PCIE chip includes a hot-plug control emulator, and the hot-plug control emulator is used to send the first hot-plug message.
10. The method according to claim 9, characterized in that The first PCIE chip includes a main control processing unit MPU, and the MPU includes the hot-swap control emulator.
11. The method according to any one of claims 1 to 10, characterized in that: The first PCIE device is a physical PCIE device or a virtual PCIE device.
12. The method according to any one of claims 1 to 11, characterized in that: The first PCIE chip includes any one of the following: a network card chip, a graphics processing unit GPU chip, and a field programmable gate array FPGA chip.
13. A hot-swap device, characterized in that: A hot-swap guard module applied to a computer device, wherein a processor of the computer device includes an operating system, the operating system includes the hot-swap guard module, the processor is communicatively connected with a first peripheral component interconnection standard PCIE chip, the first PCIE chip includes a first PCIE device, and the hot-swap device includes: A receiving unit, configured to receive a first hot plug message from the first PCIE chip, where the first hot plug message carries insertion indication information and indication information of the first PCIE device; A determining unit, configured to determine the first PCIE device according to the indication information of the first PCIE device; An execution unit is used to perform a hot plug operation on the first PCIE device according to the insertion indication information.
14. The hot-swap device according to claim 13, characterized in that: The execution unit is used to install a device driver corresponding to the first PCIE device according to the insertion indication information.
15. The hot-swap device according to claim 13, characterized in that: The hot plug device further includes: an acquisition unit, configured to acquire a device driver corresponding to the first PCIE device according to the indication information of the first PCIE device.
16. The hot-swap device according to any one of claims 13 to 15, characterized in that: The receiving unit is further configured to receive a first hot pull message from the first PCIE chip, wherein the first hot pull message carries pull-out indication information and indication information of the first PCIE device; The determining unit is further configured to determine the first PCIE device according to the indication information of the first PCIE device; The execution unit is further configured to perform a hot pull operation on the first PCIE device according to the pull-out indication information.
17. The hot-swap device according to claim 16, characterized in that: The execution unit is used to uninstall the device driver corresponding to the first PCIE device according to the removal instruction information.
18. The hot-swap device according to any one of claims 13 to 17, characterized in that: The hot plug device further includes: an initialization unit, configured to initialize the first PCIE chip before the receiving unit receives the first hot plug message from the first PCIE chip.
19. The hot-swap device according to any one of claims 13 to 18, characterized in that: The hot plug device further includes: an enabling unit, which is used to, before the receiving unit receives the first hot plug message from the first PCIE chip, A hot-swap function is enabled for the first PCIE chip.
20. The hot-swap device according to any one of claims 13 to 19, characterized in that: The hot-swap daemon module runs in the user space of the operating system.
21. The hot-swap device according to any one of claims 13 to 20, characterized in that: The first PCIE chip includes a hot-plug control emulator, and the hot-plug control emulator is used to send the first hot-plug message.
22. The hot-swap device according to claim 21, characterized in that: The first PCIE chip includes a main control processing unit MPU, and the MPU includes the hot-swap control emulator.
23. The hot-swap device according to any one of claims 13 to 22, characterized in that: The first PCIE device is a physical PCIE device or a virtual PCIE device.
24. The hot-swap device according to any one of claims 13 to 23, characterized in that: The first PCIE chip includes any one of the following: a network card chip, a graphics processing unit GPU chip, and a field programmable gate array FPGA chip.
25. An operating system, characterized in that: It includes a hot-swap guard module, which includes: a transceiver unit and a processing unit, the transceiver unit is used to execute the receiving step in the method described in any one of claims 1 to 12, and the processing unit is used to execute the steps in any one of claims 1 to 12 except the receiving step.
26. A processor, characterized in that: Comprising the hot-swap device as described in any one of claims 13 to 24.
27. A processor, characterized in that: Comprising an operating system as claimed in claim 25.
28. A computer device, characterized in that: including memory and processor; The memory is used to store computer programs; The processor is configured to execute the computer program stored in the memory so that the computer device performs the method according to any one of claims 1 to 12.
29. The computer device according to claim 28, characterized in that The processor is a processor as claimed in claim 26 or 27.
30. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed, the method according to any one of claims 1 to 12 is implemented.
31. A computer program product, characterized in that The computer program product comprises a program or a code, and when the program or the code is executed, the method according to any one of claims 1 to 12 is implemented.
Citation Information
Patent Citations
Hot plug method, hot plug control device and hot plug card system
CN101930419A
Hot plug method, host controller, host and PCIe bridge equipment
CN105701051A
Hot plug method, device and system of PCIE equipment
CN110955624A
Virtual hot plug system and method for PCIe devices
US11256648B1
Communication module and terminal for implementing hot plug
US20150205337A1
