Link detection method and device, computer equipment and storage medium
By obtaining the bus and memory resources of the PCIe device, it determines and isolates abnormal links, solving the problem of repeated BIOS restarts caused by abnormal links, and improving startup speed and reliability.
Patent Information
- Application Number
- CN202410772803.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-14
- Publication Date
- 2024-10-01
AI Technical Summary
When the BIOS allocates resources to PCIe devices, the BIOS repeatedly restarts due to abnormal links, resulting in increased startup time or failure to boot.
By obtaining the PCIe port and topology, the number of buses and memory resources required by the PCIe devices connected to the target link are determined. If the preset values are exceeded, the link is determined to be abnormal and isolated to avoid resource shortage or restart problems.
It effectively avoids the problem of repeated BIOS restarts caused by abnormal links, improves startup speed and reliability, and ensures stable allocation of PCIe device resources.
Smart Images

Figure CN118740683A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of storage technology, and in particular to a link detection method, device, computer equipment and storage medium. Background Art
[0002] In the field of cloud computing data centers, with the development of Internet technology, network data has increased dramatically, and the requirements for network storage have become increasingly higher. Storage servers need to expand more storage devices. At present, storage servers usually use high-speed serial computer expansion (Peripheral Component Interconnect express, PCIe) bus technology to expand connected storage devices (for example, expandable PCIe devices) to enrich the functions of the server.
[0003] Among them, expandable PCIe devices require BIOS (Basic Input Output System) or OS (Operating System) to enumerate and allocate available PCIe resources based on the preset PCIe resource table. However, when BIOS enumerates PCIe devices on at least one link, if a PCIe device on a certain link is abnormal, the abnormal link will cause BIOS to readjust the preset PCIe resource table to complete the enumeration of the abnormal device, which will cause the remaining devices to have insufficient resources due to the readjusted preset PCIe resource table, or cause multiple restarts when BIOS starts, increasing the startup time, and even causing the BIOS to restart repeatedly and fail to start. Summary of the invention
[0004] In view of this, the present invention provides a link detection method, apparatus, computer equipment and storage medium to solve the problem of repeated restart of BIOS due to abnormal links when BIOS allocates PCIe resources to PCIe devices.
[0005] In a first aspect, the present invention provides a link detection method, the method comprising: obtaining a first PCIe port and a topology structure, the topology structure comprising a correspondence between at least one PCIe port and at least one link; determining at least one link corresponding to the first PCIe port according to the first PCIe port and the topology structure, and selecting any one link among the at least one link as a target link, wherein at least one PCIe device is connected to the target link through a PCIe bus; obtaining the number of buses required by at least one PCIe device connected to the target link, and obtaining memory resources required by at least one PCIe device; if the number of buses is greater than a preset number of buses, or the memory resources are greater than a preset memory resources, determining that the target link is abnormal.
[0006] Based on the method provided in the first aspect above, a first PCIe port and a topological structure can be obtained, and based on the first PCIe port and the topological structure, at least one link corresponding to the first PCIe port can be determined, and any one link in the at least one link can be selected as a target link, and the number of buses required by at least one PCIe device connected to the target link can be obtained, as well as the memory resources required by at least one PCIe device; if the number of buses is greater than the preset number of buses, or the memory resources are greater than the preset memory resources, the target link is determined to be abnormal.
[0007] Since the preset number of buses is the number of buses required for the target link under normal conditions, and the number of buses required by at least one PCIe device connected to the target link is greater than the preset number of buses, it indicates that the number of PCIe devices currently connected to the target link is greater than the PCIe devices preset to be connected when the target link is normal, that is, there are redundant abnormal PCIe devices on the target link, and the target link is determined to be abnormal. Similarly, the preset memory resources are the memory resources required for the target link under normal conditions, and the memory resources required by at least one PCIe device connected to the target link are greater than the preset memory resources, indicating that the number of PCIe devices currently connected to the target link is greater than the PCIe devices preset to be connected when the target link is normal, or the memory resources required by the PCIe devices currently connected to the target link are abnormal, and the target link is determined to be abnormal. Furthermore, when the BIOS allocates PCIe resources to the PCIe device, the target link can be isolated, and PCIe resources are not allocated to the PCIe devices on the target link, so as to avoid the problem of repeated restarts of the BIOS due to an abnormal link.
[0008] In an optional embodiment, obtaining the number of buses required by at least one PCIe device connected to the target link includes: based on the topology structure, scanning at least one PCIe device through a register corresponding to at least one PCIe device according to a depth-first algorithm to obtain the number of buses required by at least one PCIe device.
[0009] Based on the above method, each PCIe device on the target link can be scanned to obtain the number of buses required by at least one PCIe device, so as to determine whether the target link is abnormal through the number of buses.
[0010] In an optional implementation, obtaining memory resources required by at least one PCIe device includes: reading data in a BAR register of a host bridge configuration space corresponding to a first PCIe port to determine the memory resources required by at least one PCIe device.
[0011] Based on the above method, the memory resources required by at least one PCIe device can be determined, so as to facilitate the subsequent determination of whether the target link is abnormal through the bus quantity.
[0012] In an optional embodiment, if at least one PCIe device is a first type device, the memory resources required by the at least one PCIe device are first bit width memory resources; if at least one PCIe device is a second type device, the memory resources required by the at least one PCIe device are second bit width memory resources.
[0013] Based on the above method, the type of memory resources required by at least one PCIe device can be determined based on the device type of at least one PCIe device.
[0014] In an optional implementation, the method further includes: when it is determined that the target link is abnormal, performing N detection operations to obtain N detection results; when the current detection result among the N detection results is that the target link is normal, stopping the detection operation;
[0015] In the case that N detection results are all abnormal in the target link, the reset register is set to the first signal, and the abnormal information of the target link is stored in the log database, the first signal is used to indicate a global reset of at least one PCIe link corresponding to at least one PCIe port; the abnormal information includes: the abnormal cause of the target link, the BDF information of the target link, the memory resources and the number of buses corresponding to the target link; the BDF information includes the bus number on the target link, the device number of at least one PCIe device and the function number of each PCIe device;
[0016] After a preset time period, the number of buses required by at least one PCIe device connected to the target link is obtained, as well as the memory resources required by at least one PCIe device; if the number of buses is greater than the preset number of buses, or the memory resources are greater than the preset memory resources, the target link is determined to be abnormal.
[0017] Based on the above method, when it is determined that the target link is abnormal, the target link can be detected multiple times to determine whether the target link is abnormal, thereby improving the accuracy of the detection. When N detection results are all abnormal for the target link, at least one PCIe link corresponding to at least one PCIe port is globally reset to try to recover the abnormal situation of the target link, and when it is determined that the target link cannot be recovered, the abnormal information of the target link is stored in the log database, so that the target link is identified in the log database, which is convenient for isolating the target link when the BIOS allocates PCIe resources to the PCIe device.
[0018] In an optional embodiment, the first detection operation among N detection operations is performed to obtain a first detection result, including: disconnecting the first PCIe port from at least one PCIe device through a function register in a configuration space in a main bridge; after a first time period, connecting the first PCIe port to at least one PCIe device through a function register; after a second time period, obtaining the number of buses required by at least one PCIe device connected to a target link, and obtaining memory resources required by at least one PCIe device; obtaining a first detection result based on the number of buses and the memory resources, the first detection result being used to indicate whether the target link is abnormal.
[0019] Based on the above method, when it is determined that the target link is abnormal, the target link can be restored by disconnecting and then restoring the connection between the first PCIe port and at least one PCIe device to try to restore the target link so that the target link returns to normal.
[0020] In an optional implementation, if the number of buses is greater than the preset number of buses, or the memory resources are greater than the preset memory resources, the target link is determined to be abnormal, including: if the number of buses is greater than the preset number of buses, the abnormality of the target link is determined to be a bus abnormality; if the memory resources are greater than the preset memory resources, the abnormality of the target link is determined to be a memory resource abnormality; if the number of buses is greater than the preset number of buses, and the memory resources are greater than the preset memory resources, the abnormality of the target link is determined to be a bus abnormality and a resource abnormality.
[0021] Based on the above method, the abnormal situation of the target link can be determined based on the bus number and the preset bus number, the memory resources and the preset memory resources, so as to facilitate the subsequent recovery of the target link based on the abnormal situation.
[0022] In a second aspect, the present invention provides a link detection device, which includes: an acquisition module, used to acquire a first PCIe port and a topology structure, the topology structure including a correspondence between at least one PCIe port and at least one link; a processing module, used to determine at least one link corresponding to the first PCIe port based on the first PCIe port and the topology structure, and select any one link from the at least one link as a target link, and at least one PCIe device is connected to the target link through a PCIe bus; the acquisition module is also used to acquire the number of buses required by at least one PCIe device connected to the target link, and to acquire the memory resources required by at least one PCIe device; the processing module is also used to determine that the target link is abnormal if the number of buses is greater than a preset number of buses, or the memory resources are greater than a preset memory resources.
[0023] In a third aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor are communicatively connected to each other, computer instructions are stored in the memory, and the processor executes the link detection method of the first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0024] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the link detection method of the first aspect or any corresponding embodiment thereof.
[0025] In a fifth aspect, the present invention provides a computer program product, comprising computer instructions, wherein the computer instructions are used to enable a computer to execute the link detection method of the first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0027] Figure 1 is a schematic flow chart of a link detection method according to an embodiment of the present invention;
[0028] Figure 2 is a schematic diagram of a topological structure according to an embodiment of the present invention;
[0029] Figure 3 is a schematic diagram of a PCIe resource table according to an embodiment of the present invention;
[0030] Figure 4 is a structural block diagram of a link detection device according to an embodiment of the present invention;
[0031] Figure 5 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0032] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0033] As described in the background technology, when the BIOS enumerates and allocates PCIe resources to PCIe devices on at least one link, if an abnormality occurs in the PCIe device of a certain link, the abnormal link will cause the BIOS to readjust the preset PCIe resource table to complete the enumeration of the abnormal device, thereby causing the remaining devices to have insufficient resources due to the readjusted preset PCIe resource table, or causing multiple restarts when the BIOS starts, thereby increasing the startup time, and even causing the BIOS to restart repeatedly and fail to start the computer.
[0034] In order to solve the above problems, an embodiment of the present invention provides a link detection method, which includes: obtaining a first PCIe port and a topology structure, the topology structure including a correspondence between at least one PCIe port and at least one link; determining at least one link corresponding to the first PCIe port according to the first PCIe port and the topology structure, and selecting any one link from the at least one link as a target link, wherein at least one PCIe device is connected to the target link through a PCIe bus; obtaining the number of buses required by at least one PCIe device connected to the target link, and obtaining the memory resources required by at least one PCIe device; if the number of buses is greater than a preset number of buses, or the memory resources are greater than a preset memory resources, determining that the target link is abnormal.
[0035] It is understandable that the above method can be performed by any device with computing capabilities. For example, it can be performed by a BIOS system of a server, a computer or a computing device (hereinafter referred to as a link detection device), or it can be performed by a module in the link detection device, such as a chip, a circuit, a chip system, a logical node or a logical module.
[0036] According to an embodiment of the present invention, a link detection method embodiment is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0037] In this embodiment, a link detection method is provided, which can be used in the above-mentioned BIOS system or link detection device. Figure 1 is a flow chart of a link detection method according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps:
[0038] S101: Acquire a first PCIe port and a topology structure.
[0039] The topology structure includes a corresponding relationship between at least one PCIe port and at least one link.
[0040] In the embodiment of the present invention, the first PCIe port is any one PCIe port among the at least one PCIe port.
[0041] Exemplarily, after the BIOS system allocates at least one PCIe port according to the server hardware configuration, it obtains the first PCIe port and the topology structure. Figure 2 As shown, Figure 2 1 is a schematic diagram of a topology structure according to an embodiment of the present invention. The schematic diagram of the topology structure includes a corresponding relationship between a first PCIe port and at least one link.
[0042] S102: Determine at least one link corresponding to the first PCIe port according to the first PCIe port and the topology structure, and select any one link from the at least one link as a target link.
[0043] Wherein, at least one PCIe device is connected to the target link via a PCIe bus.
[0044] For example, Figure 2 For example, the BIOS system determines, based on the first PCIe port and the topology structure, that at least one link corresponding to the first PCIe port includes link 1 and link 2, and selects any one of link 1 and link 2 as the target link, for example, the target link is link 1.
[0045] S103: Acquire the number of buses required by at least one PCIe device connected to the target link, and acquire memory resources required by at least one PCIe device.
[0046] Among them, PCIe devices can be graphics cards, network cards, hard disks, etc.
[0047] In the embodiment of the present invention, the number of buses is the number of PCIe buses connected between at least one PCIe device in the topology structure.
[0048] In an embodiment of the present invention, the memory resource is a memory-mapped I / O (MMIO) resource. The memory resource includes a first bit width memory resource and a second bit width memory resource. The first bit width resource may be a bit width resource corresponding to 32 bits. The second bit width resource may be a 64 bit bit width resource.
[0049] In one example, if at least one PCIe device is a first type device, the memory resources required by the at least one PCIe device are first bit width memory resources; if at least one PCIe device is a second type device, the memory resources required by the at least one PCIe device are second bit width memory resources.
[0050] The first type of device is a PCIe device with a 32-bit system, and the second type of device is a PCIe device with a 64-bit system.
[0051] In some optional implementations, the BIOS system scans at least one PCIe device based on the topology structure and in accordance with a depth-first algorithm through registers corresponding to at least one PCIe device to obtain the number of buses required by the at least one PCIe device.
[0052] In one example, the BIOS system, based on the topology structure and according to the depth-first algorithm, scans at least one PCIe device through the Primary BusNum, Secondary BusNum and SubordinateBusNum registers in the configuration space of the PCIe bridge corresponding to at least one PCIe device to obtain the number of buses required by at least one PCIe device.
[0053] For example, Figure 2 For example, taking link 1 as the target link, the BIOS system, based on the topology of link 1, follows a depth-first algorithm to scan each PCIe device through the Primary BusNum, Secondary BusNum, and Subordinate BusNum registers in the configuration space of the PCIe bridge corresponding to the PCIe device in link 1, and obtains that the number of buses required by the PCIe device in link 1 is 5.
[0054] In some optional implementations, the BIOS system reads data in a BAR register of a host bridge configuration space corresponding to the first PCIe port to determine memory resources required by at least one PCIe device.
[0055] In one example, the BIOS system reads data from BAR0-BAR5 in the BAR register of the host bridge configuration space corresponding to the first PCIe port; determines the first bit-width memory resources required by at least one PCIe device based on the data in BAR0 and BAR1; and determines the second bit-width memory resources required by at least one PCIe device based on the data in BAR2-BAR5.
[0056] S104: If the number of buses is greater than the preset number of buses, or the memory resources are greater than the preset memory resources, it is determined that the target link is abnormal.
[0057] The preset bus quantity and the preset memory resources are determined based on a PCIe resource table (PCIe Resource Table).
[0058] Optionally, the preset memory resources include preset first bit width memory resources and preset second bit width memory resources.
[0059] In one example, the BIOS system obtains a PCIe resource table from a flash memory BIOS Flash; based on the PCIe resource table, determines a preset bus number, a preset first-width memory resource, and a preset second-width memory resource; if the bus number is greater than the preset bus number, or the first-width memory resource is greater than the preset first-width memory resource, or the second-width memory resource is greater than the preset second-width memory resource, then determines that the target link is abnormal.
[0060] For example, Figure 3 As shown, Figure 3 is a schematic diagram of a PCIe resource table according to an embodiment of the present invention. Figure 3 In the PCIe resource table, there are 6 links from RP0 to RP6. Taking the target link as RP0 link, the BIOS system determines the preset bus number as 10 (BUS num in the PCIe resource table) according to the PCIe resource table; and determines the preset first-bit width memory resource as 32 (MMIOL in the PCIe resource table), and the preset second-bit width memory resource as 100 (MMIOH in the PCIe resource table).
[0061] In one example, if the number of buses is greater than the preset number of buses, or the memory resources are greater than the preset memory resources, the BIOS system determines that the target link is abnormal, including: if the number of buses is greater than the preset number of buses, determining that the abnormality of the target link is a bus abnormality (PCIe BUS OOR); if the memory resources are greater than the preset memory resources, determining that the abnormality of the target link is a memory resource abnormality (PCIe MMIO OOR); if the number of buses is greater than the preset number of buses, and the memory resources are greater than the preset memory resources, determining that the abnormality of the target link is a bus abnormality and a resource abnormality.
[0062] Furthermore, when it is determined that the target link is abnormal, in order to reduce the occurrence of abnormal links when the BIOS system enumerates and allocates PCIe resources to the PCIe device, the BIOS system may also:
[0063] In some optional embodiments, when the BIOS system determines that the target link is abnormal, it performs N detection operations and obtains N detection results; when the current detection result among the N detection results is that the target link is normal, the detection operation is stopped; when the N detection results are all that the target link is abnormal, the reset register is set to the first signal, and the abnormal information of the target link is stored in the log database, and after a preset time period, the number of buses required by at least one PCIe device connected to the target link and the memory resources required by at least one PCIe device are obtained; if the number of buses is greater than the preset number of buses, or the memory resources are greater than the preset memory resources, the target link is determined to be abnormal.
[0064] The first signal is used to instruct to globally reset at least one PCIe link corresponding to at least one PCIe port.
[0065] In the embodiment of the present invention, the abnormal information includes: the abnormal reason of the target link, the BDF information of the target link, the memory resources and the number of buses corresponding to the target link. The BDF information includes the bus number on the target link, the device number of at least one PCIe device, and the function number of each PCIe device.
[0066] In the embodiment of the present invention, the preset time period can be set according to actual needs without limitation. For example, the preset time period can be 2 seconds.
[0067] In the embodiment of the present invention, N may be determined according to actual detection results, and N is less than or equal to 3.
[0068] In one example, when N detection results all indicate that the target link is abnormal, the BIOS system sets the reset register to a first signal, performs a global reset on at least one PCIe link corresponding to at least one PCIe port, and records the number of global resets in a PeRST counter.
[0069] Optionally, when N detection results all indicate that the target link is abnormal, the BIOS system sets the reset register to a first signal, performs M global resets on at least one link corresponding to at least one PCIe port, and then sets the reset register to a second signal.
[0070] The second information is used to indicate that the reset register can no longer globally reset at least one PCIe link corresponding to at least one PCIe port.
[0071] In a possible design, M can be set according to actual needs without limitation. For example, M is equal to 3.
[0072] It is understandable that if the number of global resets is too large, the BIOS system will continuously re-detect at least one link corresponding to at least one PCIe port, which will increase the number of BIOS system restarts and even affect the subsequent BIOS system enumeration and allocation of PCIe resources for PCIe devices.
[0073] Optionally, if the BIOS system sets the reset register to the first signal when N detection results all show that the target link is abnormal, and globally resets at least one PCIe link corresponding to at least one PCIe port, and then detects that the target link has returned to normal, the abnormal information of the target link recorded in the log database (PCIe OOR LOG) is deleted, and the information that the target link has returned to normal is printed to the serial port log.
[0074] In some optional embodiments, the BIOS system performs the first detection operation among N detection operations to obtain a first detection result, including: disconnecting the first PCIe port from at least one PCIe device through a function register in a configuration space in a host bridge; after a first time period, connecting the first PCIe port to at least one PCIe device through a function register; after a second time period, obtaining the number of buses required by at least one PCIe device connected to a target link, and obtaining memory resources required by at least one PCIe device; obtaining the first detection result based on the number of buses and the memory resources.
[0075] The first detection result is used to indicate whether the target link is abnormal.
[0076] In the embodiment of the present invention, the first time period and the second time period can be set according to actual needs without limitation. For example, the first time period is 100 ms; the second time period is 300 ms.
[0077] Exemplarily, the BIOS system sets the LinkControl function register in the PCIe Express Capability in the configuration space of the main bridge to Link Disable, disconnects the first PCIe port from at least one PCIe device; delays and waits for 100ms, sets the function register to Link Enable, and connects the first PCIe port to at least one PCIe device; delays and waits for 300ms, then re-detects the target link to obtain the number of buses required by at least one PCIe device connected to the target link, and obtains the memory resources required by at least one PCIe device; obtains a first detection result based on the number of buses and the memory resources.
[0078] In one example, after determining that the target link is abnormal, the BIOS system sets the target link to Link Disable through the Link Control function register in the PCIe ExpressCapability, isolates the devices under the target link, and makes at least one PCIe device under the target link invisible.
[0079] It is understandable that when the BIOS system enumerates and allocates PCIe resources for PCIe devices, it pre-allocates PCIe resources for each PCIe port according to the PCIe ResourceTable (PCIe resources include bus resources and memory resources), but no longer enumerates the target link set to Link Disable. When the BIOS runs to the DXE stage, it checks whether there is any abnormal information record in the PCIe OOR LOG database. If so, it reports the abnormal information to the Baseboard Management Controller (BMC) through the Intelligent Platform Management Interface (IPMI) interface. The BMC records or issues an alarm.
[0080] Based on the above-mentioned S101-S104 method, the BIOS system can obtain the first PCIe port and the topology structure, and determine at least one link corresponding to the first PCIe port according to the first PCIe port and the topology structure, and select any one link among the at least one link as the target link, obtain the number of buses required by at least one PCIe device connected to the target link, and obtain the memory resources required by at least one PCIe device; if the number of buses is greater than the preset number of buses, or the memory resources are greater than the preset memory resources, the target link is determined to be abnormal.
[0081] Since the preset number of buses is the number of buses required for the target link under normal conditions, and the number of buses required by at least one PCIe device connected to the target link is greater than the preset number of buses, it indicates that the number of PCIe devices currently connected to the target link is greater than the PCIe devices preset to be connected when the target link is normal, that is, there are redundant abnormal PCIe devices on the target link, and the target link is determined to be abnormal. Similarly, the preset memory resources are the memory resources required for the target link under normal conditions, and the memory resources required by at least one PCIe device connected to the target link are greater than the preset memory resources, indicating that the number of PCIe devices currently connected to the target link is greater than the PCIe devices preset to be connected when the target link is normal, or the memory resources required by the PCIe devices currently connected to the target link are abnormal, and the target link is determined to be abnormal. Furthermore, when the BIOS allocates PCIe resources to the PCIe device, the target link can be isolated, and PCIe resources are not allocated to the PCIe devices on the target link, so as to avoid the problem of repeated restarts of the BIOS due to an abnormal link.
[0082] In addition, the BIOS system also repairs the link in the event of target link abnormality, and isolates the link if it cannot be repaired to prevent the fault from spreading and avoid adjusting the PCIe Resource Table.
[0083] In this embodiment, a link detection device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0084] This embodiment provides a link detection device, such as Figure 4 As shown, including:
[0085] The acquisition module 401 is used to acquire a first PCIe port and a topology structure, where the topology structure includes a correspondence between at least one PCIe port and at least one link.
[0086] The processing module 402 is used to determine at least one link corresponding to the first PCIe port according to the first PCIe port and the topology structure, and select any one link from the at least one link as a target link, and the target link is connected to at least one PCIe device through a PCIe bus.
[0087] The acquisition module 401 is further configured to acquire the number of buses required by at least one PCIe device connected to the target link, and acquire memory resources required by at least one PCIe device.
[0088] The processing module 402 is further configured to determine that the target link is abnormal if the number of buses is greater than a preset number of buses, or the memory resources are greater than a preset memory resources.
[0089] In some optional implementations, the acquisition module 401 is specifically used to scan at least one PCIe device based on the topology structure and in accordance with a depth-first algorithm through a register corresponding to at least one PCIe device to obtain the number of buses required by at least one PCIe device.
[0090] In some optional implementations, the acquisition module 401 is further specifically configured to read data in a BAR register of a host bridge configuration space corresponding to the first PCIe port to determine memory resources required by at least one PCIe device.
[0091] In some optional embodiments, if at least one PCIe device is a first type device, the memory resources required by the at least one PCIe device are first bit width memory resources; if at least one PCIe device is a second type device, the memory resources required by the at least one PCIe device are second bit width memory resources.
[0092] In some optional implementations, the processing module 402 is further configured to, when it is determined that the target link is abnormal, perform N detection operations to obtain N detection results;
[0093] The processing module 402 is further configured to stop performing the detection operation when the current detection result among the N detection results is that the target link is normal;
[0094] The processing module 402 is further used to set the reset register to a first signal and store the abnormal information of the target link in a log database when all N detection results indicate that the target link is abnormal, wherein the first signal is used to indicate that a global reset is performed on at least one PCIe link corresponding to at least one PCIe port; the abnormal information includes: the abnormal cause of the target link, the BDF information of the target link, the memory resources and the number of buses corresponding to the target link; the BDF information includes the bus number on the target link, the device number of at least one PCIe device, and the function number of each PCIe device;
[0095] The acquisition module 401 is further used to acquire the number of buses required by at least one PCIe device connected to the target link and acquire the memory resources required by at least one PCIe device after a preset time period;
[0096] The processing module 402 is further configured to determine that the target link is abnormal if the number of buses is greater than a preset number of buses, or the memory resources are greater than a preset memory resources.
[0097] In some optional embodiments, the processing module 402 is further specifically used to disconnect the first PCIe port from at least one PCIe device through a function register in a configuration space in the main bridge; the processing module 402 is further specifically used to connect the first PCIe port to at least one PCIe device through a function register after a first time period; the processing module 402 is further specifically used to obtain the number of buses required by at least one PCIe device connected to the target link and the memory resources required by at least one PCIe device after a second time period; the processing module 402 is further specifically used to obtain a first detection result based on the number of buses and the memory resources, and the first detection result is used to indicate whether the target link is abnormal.
[0098] In some optional embodiments, the processing module 402 is further specifically used to determine that the abnormality of the target link is a bus abnormality if the number of buses is greater than the preset number of buses; the processing module 402 is further specifically used to determine that the abnormality of the target link is a memory resource abnormality if the memory resources are greater than the preset memory resources; the processing module 402 is further specifically used to determine that the abnormality of the target link is a bus abnormality and a resource abnormality if the number of buses is greater than the preset number of buses and the memory resources are greater than the preset memory resources.
[0099] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0100] The link detection device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0101] The embodiment of the present invention also provides a computer device having the above Figure 4 The link detection device shown.
[0102] See also Figure 5 , Figure 5 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 5 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 5 A processor 10 is taken as an example.
[0103] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0104] The memory 20 stores instructions executable by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.
[0105] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0106] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0107] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.
[0108] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0109] Part of the present application may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present application through the operation of the computer. Those skilled in the art should understand that the existence of computer program instructions in computer-readable media includes but is not limited to source files, executable files, installation package files, etc., and accordingly, the way in which computer program instructions are executed by a computer includes but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to the computer.
[0110] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A link detection method, It is characterized in that The method comprises: Acquire a first PCIe port and a topology structure, where the topology structure includes a correspondence between at least one PCIe port and at least one link; Determine at least one link corresponding to the first PCIe port according to the first PCIe port and the topology structure, and select any one of the at least one link as a target link, where at least one PCIe device is connected to the target link through a PCIe bus; Acquire the number of buses required by the at least one PCIe device connected to the target link, and acquire the memory resources required by the at least one PCIe device; If the number of buses is greater than the preset number of buses, or the memory resources are greater than the preset memory resources, it is determined that the target link is abnormal.
2. The method according to claim 1, It is characterized in that The obtaining the number of buses required by the at least one PCIe device connected to the target link includes: Based on the topology structure and in accordance with a depth-first algorithm, the at least one PCIe device is scanned through a register corresponding to the at least one PCIe device to obtain the number of buses required by the at least one PCIe device.
3. The method according to claim 1, It is characterized in that The acquiring of memory resources required by the at least one PCIe device includes: Read data in a BAR register of a host bridge configuration space corresponding to the first PCIe port to determine the memory resources required by the at least one PCIe device.
4. The method according to claim 1, It is characterized in that If the at least one PCIe device is a first type device, the memory resource required by the at least one PCIe device is a first bit width memory resource; If the at least one PCIe device is a second type device, the memory resources required by the at least one PCIe device are second bit width memory resources.
5. The method according to claim 1, It is characterized in that The method further comprises: If it is determined that the target link is abnormal, N detection operations are performed to obtain N detection results; If the current detection result among the N detection results is that the target link is normal, then stop executing the detection operation; In the case that the N detection results are all abnormalities of the target link, a reset register is set to a first signal, and abnormal information of the target link is stored in a log database, wherein the first signal is used to indicate a global reset of at least one PCIe link corresponding to the at least one PCIe port; the abnormal information includes: the abnormal cause of the target link, the BDF information of the target link, the memory resources and the number of buses corresponding to the target link; the BDF information includes the bus number on the target link, the device number of the at least one PCIe device, and the function number of each PCIe device; After a preset time period, obtaining the number of buses required by the at least one PCIe device connected to the target link, and obtaining memory resources required by the at least one PCIe device; If the number of buses is greater than the preset number of buses, or the memory resources are greater than the preset memory resources, it is determined that the target link is abnormal.
6. The method according to claim 5, It is characterized in that The performing of the first detection operation of the N detection operations to obtain a first detection result includes: Disconnecting the first PCIe port from the at least one PCIe device through a function register of a configuration space in the host bridge; After a first time period, connecting the first PCIe port to the at least one PCIe device through the function register; After the second time period, obtaining the number of buses required by the at least one PCIe device connected to the target link, and obtaining memory resources required by the at least one PCIe device; The first detection result is obtained according to the bus quantity and the memory resource, and the first detection result is used to indicate whether the target link is abnormal.
7. The method according to claim 5, It is characterized in that If the number of buses is greater than a preset number of buses, or the memory resources are greater than a preset memory resources, determining that the target link is abnormal includes: If the number of buses is greater than the preset number of buses, determining that the abnormality of the target link is a bus abnormality; If the memory resource is greater than the preset memory resource, determining that the abnormality of the target link is a memory resource abnormality; If the number of buses is greater than the preset number of buses, and the memory resources are greater than the preset memory resources, it is determined that the abnormality of the target link is the bus abnormality and the resource abnormality.
8. A link detection device, It is characterized in that The device comprises: An acquisition module, configured to acquire a first PCIe port and a topology structure, wherein the topology structure includes a correspondence between at least one PCIe port and at least one link; a processing module, configured to determine at least one link corresponding to the first PCIe port according to the first PCIe port and the topology structure, and select any one of the at least one link as a target link, wherein at least one PCIe device is connected to the target link through a PCIe bus; The acquisition module is further used to acquire the number of buses required by the at least one PCIe device connected to the target link, and to acquire the memory resources required by the at least one PCIe device; The processing module is further configured to determine that the target link is abnormal if the number of buses is greater than a preset number of buses, or the memory resources are greater than a preset memory resources.
9. A computer device, It is characterized in that include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the link detection method according to any one of claims 1 to 7 by executing the computer instructions.
10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the link detection method according to any one of claims 1 to 7.
