Link training state machine log management method and device, equipment and storage medium

By setting up two log acquisition modes in the solid state drive, the interoperability and resource utilization problems of NVMe SSD link training state machine log acquisition are solved, and comprehensive and accurate log acquisition and parsing are achieved.

CN120045537AActive Publication Date: 2025-05-27INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510528345.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-25
Publication Date
2025-05-27
Estimated Expiration
2045-04-25

AI Technical Summary

Technical Problem

In the PCIe protocol implementation of NVMe SSD, the logical difference between private fields and state jumps of the link training state machine leads to failure of interoperability, traditional protocol analyzers cannot be integrated in real time, and software log tools cannot capture physical layer signals, resulting in missing log crawling content and high resource utilization.

Method used

Set two log acquisition modes in the solid state drive: analyzer access log mode and software tool access log mode. If the analyzer mode is supported, it is preferred; if it is not supported, it will switch to software tool mode, and log crawling and parsing is realized through private manufacturer commands and log acquisition modules, and gradually send log entry information to the host side.

Benefits of technology

It fully acquires logs of various states of the link training state machine, reduces the use of internal processor resources of the solid-state drive, adapts to the different protocol implementation differences of different manufacturers, and improves the accuracy and efficiency of log acquisition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120045537A_ABST
    Figure CN120045537A_ABST
Patent Text Reader

Abstract

The invention discloses a link training state machine log management method and device, equipment and a storage medium, and relates to the technical field of computers. According to the method, the log capturing modes are set in the solid state disk and comprise the analyzer log obtaining mode and the software tool log obtaining mode, and if the solid state disk supports the analyzer log obtaining mode, a link training state machine does not need to be adopted to occupy a large number of storage and computing resources to achieve log capturing; when the log capturing cannot be carried out by adopting an analyzer to obtain the log mode of the solid state disk, switching to a software tool to obtain the log mode to realize state machine log capturing, analyzing the captured state machine log, and uploading the analyzed state machine log entry information to a host side; logs of all states of the link training state machine can be comprehensively obtained, and occupation of processor resources in the solid state disk is reduced as much as possible.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer communication technologies, and particularly to a method, apparatus, electronic device, and storage medium for managing link training state machine logs. Background Art

[0002] In the field of non-volatile memory solid-state drive (NVMe SSD) communication technologies, there may be differences in the implementation of PCIe protocols by devices from different manufacturers. Especially in the implementation of the link training state machine (LTSSM state machine), private fields or state transition logics may be introduced into the protocol, resulting in interoperability failures with other devices. Traditional protocol analyzers (such as LeCroy / ViaVi) rely on physical layer signal capture. When using traditional protocol analyzers to obtain link training state machine logs, they cannot be integrated into the running system in real time, resulting in missing log capture content, high costs, and may also affect the initial link establishment process of the solid-state drive due to the access of the protocol analyzer, making it difficult to reproduce problems or causing unexpected problems. However, if software log tools (such as the Linux kernel lspci) are used to obtain link training state machine logs, physical layer signals cannot be captured, resulting in missing log capture content, and high-frequency log recording methods will occupy a large amount of storage and computing resources. Therefore, how to comprehensively obtain the logs of each state of the link training state machine has become an urgent technical problem to be solved. Summary of the Invention

[0003] This application provides a method, apparatus, electronic device, and storage medium for managing link training state machine logs to at least solve the problem in related technologies of how to comprehensively obtain the logs of each state of the link training state machine.

[0004] This application provides a method for managing link training state machine logs, including: Setting a log capture method in the solid-state drive, including an analyzer log acquisition mode and a software tool log acquisition mode; Performing log capture on the solid-state drive in the analyzer log acquisition mode, and determining whether the solid-state drive can obtain logs; In response to the solid-state drive being able to obtain logs, parsing the obtained logs and uploading the parsed log entry information to the host side; In response to the solid-state drive being unable to obtain logs, setting an enable flag for the solid-state drive, restarting the solid-state drive, starting the software tool log acquisition mode according to the enable flag to perform state machine log capture, parsing the captured state machine logs, and uploading the parsed state machine log entry information to the host side.

[0005] The present application also provides an electronic device, including: a memory for storing a computer program; a processor for implementing the steps of any of the above link training state machine log management methods when executing the computer program: Setting a log capture method in the solid-state drive includes an analyzer acquisition log mode and a software tool acquisition log mode; Performing log capture on the solid-state drive in the analyzer acquisition log mode, and determining whether the solid-state drive can acquire logs; In response to the solid-state drive being able to acquire logs, parsing the acquired logs and uploading the parsed log entry information to the host side; In response to the solid-state drive being unable to acquire logs, setting an enable flag for the solid-state drive, restarting the solid-state drive, starting the software tool acquisition log mode according to the enable flag for state machine log capture, parsing the captured state machine logs, and uploading the parsed state machine log entry information to the host side.

[0006] The present application also provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above link training state machine log management methods are implemented: Setting a log capture method in the solid-state drive includes an analyzer acquisition log mode and a software tool acquisition log mode; Performing log capture on the solid-state drive in the analyzer acquisition log mode, and determining whether the solid-state drive can acquire logs; In response to the solid-state drive being able to acquire logs, parsing the acquired logs and uploading the parsed log entry information to the host side; In response to the solid-state drive being unable to acquire logs, setting an enable flag for the solid-state drive, restarting the solid-state drive, starting the software tool acquisition log mode according to the enable flag for state machine log capture, parsing the captured state machine logs, and uploading the parsed state machine log entry information to the host side.

[0007] The present application also provides a computer program product, including a computer program. When the computer program is executed by a processor, the steps of any of the above link training state machine log management methods are implemented: Setting a log capture method in the solid-state drive includes an analyzer acquisition log mode and a software tool acquisition log mode; Performing log capture on the solid-state drive in the analyzer acquisition log mode, and determining whether the solid-state drive can acquire logs; In response to the solid-state drive being able to acquire logs, parsing the acquired logs and uploading the parsed log entry information to the host side; In response to the solid-state drive being unable to obtain the log, an enable flag is set for the solid-state drive, the solid-state drive is restarted, and according to the enable flag, the software tool is started to obtain the log mode for state machine log capture. The captured state machine log is parsed and the parsed state machine log entry information is sent to the host side.

[0008] Through the present application, by setting the log capture method in the solid-state drive to include the analyzer log acquisition mode and the software tool log acquisition mode, if the solid-state drive supports the analyzer log acquisition mode, there is no need to use the link training state machine to occupy a large amount of storage and computing resources to implement log capture. When the solid-state drive cannot perform log capture in the analyzer log acquisition mode, it is switched to the software tool log acquisition mode to implement state machine log capture. The captured state machine log is parsed and the parsed state machine log entry information is sent to the host side, which can comprehensively obtain the logs of each state of the link training state machine and minimize the occupation of the internal processor resources of the solid-state drive. Brief Description of the Drawings

[0009] In order to more clearly illustrate the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0010] Figure 1 It is a basic process block diagram of the link training state machine specified in the PCIe Spec in an embodiment of the present application; Figure 2 It is an application environment diagram of the link training state machine log management method in an embodiment of the present application; Figure 3 It is a flow schematic diagram of the link training state machine log management method in an embodiment of the present application; Figure 4 It is a logic diagram of controlling the restart and capture of the state machine log of the solid-state drive according to the enable flag in an embodiment of the present application; Figure 5 It is a structural block diagram of sending the link training state machine entry information to the host side in an embodiment of the present application; Figure 6 It is a logic diagram of the step of sending the parsed link training state machine entry information to the host side based on the log record entry number and the number of log entries sent in response to the command issued by the host side through private software to the solid-state drive in an embodiment of the present application; Figure 7 It is an internal structure diagram of a computer device in an embodiment of the present application. Detailed implementation manners

[0011] The following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.

[0012] It should be noted that in the description of the present application, the terms "include", "comprise" or any other variant thereof are intended to cover a non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device. The terms "first", "second", etc. in the present application are used to distinguish similar objects, rather than to describe a specific order or sequence.

[0013] To enable those skilled in the art of the present technology to better understand the solution of the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific implementation manners.

[0014] As a PCIe device, the non-volatile memory solid-state drive (NVMe SSD) has become a key storage component in current artificial intelligence (AI) applications by virtue of its high bandwidth, low latency and high concurrency characteristics. And as the PCIe transmission speed is getting faster and faster, for a PCIe device to work properly, it must negotiate with the host controller for matching parameters such as rate, number of channels and electrical parameters. This process is called the link training state machine (LTSSM) migration process, as Figure 1 is the basic process block diagram of the link training state machine specified in the PCIe Spec. Among them, Detect (detection), Polling (polling), Configuration (configuration), Recovery (recovery), loopback (loopback), Hot Reset (hot reset), Disable (disable), etc. are the respective sub-states of the PCI-Express physical layer.

[0015] However, there may be differences in the implementation of the PCIe protocol by different manufacturers, especially in the implementation of the link training state machine. For example, some manufacturers may have different recovery mechanisms when detecting certain errors; or they may have different strategies in the processing of training sequences (TS1 / TS2), which may lead to the inability of both parties to correctly negotiate parameters. In addition, some manufacturers introduce private fields or state transition logics into the protocol to achieve specific optimizations (such as low power consumption), resulting in interoperability failures with other devices.

[0016] Traditional protocol analyzers (such as LeCroy / ViaVi) rely on physical layer signal capture, but cannot be integrated into the running system in real time and are costly. When actually encountering on-site problems, the access of the protocol analyzer may affect the initial link establishment process, making it difficult to reproduce the problem or causing unexpected problems. In addition, for some dual-port NVMe SSD products, when problems occur in both ports, a customized PCIe fixture acquisition card is required, which is extremely inconvenient and increases the difficulty and cycle of problem solving. Moreover, the protocol analyzer cannot obtain the link signals that change the original signal transmission mode and timing, resulting in missing acquisition logs and insufficient log capture accuracy.

[0017] Moreover, the implementation differences of devices from different manufacturers in the LTSSM training stage (Detect → Polling → Configuration) (such as TS sequence format, Lane mapping rules) will also lead to log parsing failures and cannot effectively obtain comprehensive logs for each state based on migration conditions, interaction processes, and acquisition timing.

[0018] If a software log tool (such as the Linux kernel lspci) is used to obtain the link training state machine logs, the physical layer signals cannot be captured, and high-frequency log records will occupy a large amount of storage and computing resources. Especially during the power-on and disk recognition processes of the server, there will be multiple link establishment processes, and if the link training state machine logs are captured each time during these processes, it will occupy a large amount of processor (CPU) resources of the internal devices of the SSD, resulting in an overly long power-on time for the NVMe SSD and affecting the competitiveness of the product.

[0019] The link training state machine log management method provided by this application can be applied to an application environment such as Figure 2 shown. Figure 2 A link training state machine log management device is provided, including: an adaptive setting acquisition log acquisition module, an LTSSM log dynamic recording and online parsing and uploading module, and a multi-port storage management module.

[0020] Adaptive setting acquisition log acquisition module: uses the private manufacturer characteristics setting command of the NVMe SSD to set whether to capture the LTSSM state machine logs during startup link establishment; and triggers the acquisition and uploading of LTSSM log records through the private manufacturer's log acquisition command.

[0021] LTSSM Log Dynamic Recording and Online Parsing and Uploading Module: By setting the content of LTSSM log entries through the hardware registers provided by the chip, it comprehensively records the state transition process of LTSSM and the information related to exceptions; and optimizes the writing record timing of each LTSSM log to meet the recording and real-time performance of historical log information during multiple link establishment processes. It adopts the design of a circular buffer to record each Ltssm log entry online. At the same time, when uploading the log, it online parses the recorded entries to maximize the readability of the log entries.

[0022] The multi-port storage management module sets real-time trigger recording conditions according to the LTSSM state machine of each PCIe and allocates the CPU to record the status transition situation online in real time, meeting the reliable recording of each link establishment in the multi-port scenario.

[0023] The link training state machine log management device completes the capture, management, and uploading of LTSSM logs for PCIe link establishment. Through the adaptive real-time online diagnosis of the log module, it accurately captures the state transition process and reasonably sets the internal CPU resources, effectively solving the compatibility problem of multi-vendor devices and being applicable to the PCIe link health management in scenarios such as data centers and communication devices.

[0024] The LTSSM Log Dynamic Recording and Online Parsing and Uploading Module includes a trigger log dynamic recording module, a log entry content design module, a log entry update module, and a log online parsing and uploading module.

[0025] As Figure 3 shown, the embodiments of the present application provide a link training state machine log management method, including the following steps: Step S1, set the log capture method in the solid-state drive, including the analyzer acquisition log mode and the software tool acquisition log mode; Step S2, capture the log of the solid-state drive in the analyzer acquisition log mode, and determine whether the solid-state drive can acquire the log; Step S3, in response to the solid-state drive being able to acquire the log, parse the acquired log and upload the parsed log entry information to the host side; Step S4, in response to the solid-state drive being unable to acquire the log, set an enable flag for the solid-state drive, restart the solid-state drive, start the software tool acquisition log mode according to the enable flag to capture the state machine log, parse the captured state machine log, and upload the parsed state machine log entry information to the host side.

[0026] In this embodiment, the method for setting the log capture in the solid-state drive includes the analyzer log acquisition mode and the software tool log acquisition mode. If the solid-state drive supports the analyzer log acquisition mode, there is no need to use the link training state machine to occupy a large amount of storage and computing resources to implement log capture. When the analyzer log acquisition mode cannot be used for log capture in the solid-state drive, it switches to the software tool log acquisition mode to implement the state machine log capture, parses the captured state machine log, and uploads the parsed state machine log entry information to the host side, which can comprehensively obtain the logs of all states of the link training state machine and minimize the occupation of the internal processor resources of the solid-state drive.

[0027] In this embodiment, the method for setting the log capture in the solid-state drive includes the analyzer log acquisition mode and the software tool log acquisition mode, which includes: An adaptive log capture acquisition module and a state machine log dynamic recording and online upload module are set in the solid-state drive. The adaptive log capture acquisition module and the state machine log dynamic recording and online upload module are started according to the enable flag and closed according to the disable flag. In response to the analyzer log acquisition mode of the solid-state drive, a disable flag is set in the solid-state drive to control the adaptive log capture acquisition module and the state machine log dynamic recording and online upload module not to start. In response to the software tool log acquisition mode of the solid-state drive, an enable flag is set in the solid-state drive to control the adaptive log capture acquisition module and the state machine log dynamic recording and online upload module to start. The analyzer log acquisition mode is set as the default log capture method. When the solid-state drive is powered on for the first time, a disable flag is written in the solid-state drive.

[0028] The adaptive log capture acquisition module uses the vendor private command of the current NVMe technology to complete the capture enable setting of the LTSSM log, and completes the host upload acquisition of the log through the private log acquisition command. Since the capture of the LTSSM log is in the link establishment process when the device product is powered on for the first time and will occupy the CPU resources during power-on and affect some performance indicators of the device, the private command setting and enabling are only adaptively performed when encountering relevant link abnormal problems, and the power is physically turned off and then powered on again to take effect.

[0029] The LTSSM log dynamic recording and online upload module is the core module for LTSSM log management, including a trigger log dynamic recording module, a log entry content design module, and a log entry update module.

[0030] When the analyzer obtains the log mode, a protocol analyzer is used to obtain the link training state machine log. When the LTSSM log cannot be obtained, it switches to the software tool to obtain the log mode and uses the vendor - private command to complete the capture of the LTSSM log. Only at this time will it occupy the internal processor resources of the solid - state drive. After obtaining the corresponding status log, the adaptive setting capture log acquisition module and the LTSSM log dynamic recording and online uploading module are disabled again, and it switches to the analyzer to obtain the log mode, thus reducing the overall occupation of the internal processor resources of the solid - state drive and being able to adapt to the differences of different vendors in implementing the PCIe protocol, achieving the accurate acquisition of comprehensive logs for each state.

[0031] As Figure 4 shown, in this embodiment, in response to the solid - state drive being unable to obtain logs, an enable flag is set for the solid - state drive, the solid - state drive is restarted, and according to the enable flag, the software tool is started to obtain the log mode for state machine log capture. The captured state machine log is parsed and the parsed state machine log entry information is uploaded to the host side, including: In response to the power - on of the solid - state drive, if the solid - state drive cannot obtain logs, the solid - state drive uses a private non - volatile memory command to enable the link training state machine log monitoring function and saves the log monitoring function enable flag to the non - volatile medium. Control the solid - state drive to power off, power on and restart the solid - state drive again, and determine whether there is a log monitoring function enable identifier in the non - volatile medium of the solid - state drive. In response to the absence of the log monitoring function enable identifier, disable the state machine log dynamic recording and online uploading module and control the solid - state drive to start; at this time, the solid - state drive starts without the link training state machine log recording method. In response to the presence of the log monitoring function enable identifier, start the software tool to obtain the log mode according to the enable flag, run the state machine log dynamic recording and online uploading module, control the solid - state drive to start, and determine whether to trigger log uploading; at this time, the solid - state drive starts with the link training state machine log recording method. In response to not triggering log uploading, each state machine log entry of the state machine log is recorded online. In response to triggering log uploading, the recorded state machine log entries are parsed online to obtain readable log entry information, and the parsed log entry information is uploaded to the host side.

[0032] As Figure 4 shown, running the LTSSM log dynamic recording module mainly depends on the enable / disable flag recorded in the non - volatile medium, and subsequent capture or not is completed according to this flag. In this way, the need for online diagnosis is completed without affecting the physical topology and connection.

[0033] In this embodiment, each state machine log entry for online recording of the state machine log includes: Monitor whether abnormal events occur in the protocol layer and physical layer of the PCIe link; In response to abnormal events occurring in the protocol layer and physical layer of the PCIe link, notify the processor (CPU) through the system-level interrupt mechanism and trigger the dynamic recording of the state machine log in the form of a global variable and start the LTSSM dynamic recording module in the online upload module to record the state machine log entries; In response to no abnormal events occurring in the protocol layer and physical layer of the PCIe link, do not record the state machine log entries.

[0034] Trigger the log dynamic recording module: In order to capture LTSSM logs in real time, it is necessary to closely monitor abnormal events in the protocol layer, physical layer, etc. of the PCIe link and notify the CPU processing unit in the device through the system-level interrupt mechanism.

[0035] In this embodiment, monitoring whether abnormal events occur in the protocol layer and physical layer of the PCIe link includes: Obtain the key events captured at the initial moment when the solid-state drive and the host side establish a link in the link training state machine. The key events include at least one of the reset unlock level signal of the external physical layer, the port clock synchronization / loss of lock event, the initial detection state machine of the link training state machine state, the link activation event of the data link layer, the link layer link width / rate change event, and the correctable and uncorrectable error trigger event of the protocol layer; In response to sensing a key event, determine that an abnormal event has occurred in the protocol layer and physical layer of the PCIe link.

[0036] Among them, by controlling the timing of capturing logs according to key events, it is possible to poll all logs and record the log content to ensure the comprehensiveness of log acquisition.

[0037] In this embodiment, recording the state machine log entries includes: Set that when recording the state machine log entries, each state machine log entry contains at least a timestamp, the current main state and sub-state of the link training state machine, the link width, the link rate, the low-power working (L0s) standby state or active state where the transmit / receive state machine is located, the key migration history state, the link channel (lane) configuration method, the link peer detection state, and the link receiver key hardware continuous time linear equalizer (CTLE) / gain (Gain) parameters; The storage management of the state machine log entries adopts a circular buffer method, and the maximum number of buffer entries in the circular buffer is set according to the requirement of covering historical data for a preset duration.

[0038] Log Entry Content Design Module: To comprehensively record the interaction process of the entire LTSSM state machine and the corresponding abnormal states, the structure of each state machine log entry is set. To ensure the accuracy of each LTSSM log entry, at least microsecond-level time accuracy is adopted for the timestamp.

[0039] In this embodiment, recording the state machine log entry further includes: Setting the trigger condition for adding a new log entry. The trigger condition for adding a new log entry includes at least one of the following: when the current main state and sub-state of the link training state machine change, when the key migration history state of the link training state machine changes, and when the link error state occurs; where the main state includes at least one of the states of detection, polling, configuration, recovery, loopback, hard reset, and disable, and the sub-state is the internal state of any main state. In response to the power-on of the solid-state drive, set the state machine disable control flag in the firmware, keep the link training state machine in the detection main state, and after preparing the log resources for the power-on process, update the state machine disable control flag and then exit the detection main state to establish the link. In response to the establishment of the link, update based on the status register or the real-time link error state in a query synchronization blocking manner, and trigger the recording of a new log entry when it is queried that the trigger condition for adding a new log entry is satisfied.

[0040] Log Entry Update Module: The log storage management adopts a circular buffer method, and the maximum number of entries is set to N, which can cover at least 1 s of historical data. To ensure accurate capture of key data and avoid storage overhead caused by the flooding of repeated recording of the same log, update based on the LTSSM status register or the real-time link error state in a query synchronization blocking manner, and trigger the recording of a new log entry when at least one condition is queried to be satisfied: when the current main state and sub-state of the link training state machine change; when the key migration history states of the link training state machine such as Detect / Polling / Configuration / Recovery / L0s change; when the link error state occurs.

[0041] When the log acquisition module is adaptively enabled / disabled, the firmware indicates whether to use the firmware to control the hardware module of the PCIe LTSSM state machine according to the flag of the LTSSM log enabling module, which is called the LTSSM state machine disabling control flag. This behavior can delay the establishment of the link to complete the control of the entire hardware logic control link, complete the preparation of the log resources during the power-on process, and improve the flexibility of the link initialization state control. The specific behavior is as follows: when the LTSSM state machine disabling control flag is 1, the LTSSM state machine is kept in the Detect main state; after the preparation of the log module resources is completed, this flag is updated to 0 to allow the LTSSM state machine to exit the Detect main state and continue to establish the link. Among them, the state machine disabling control flag can effectively control the start timing of link establishment to accurately obtain comprehensive logs for each state.

[0042] In this embodiment, online parsing of recorded state machine log entries to obtain readable log entry information and sending the parsed log entry information to the host side includes: Obtain the main state value and sub-state value corresponding to the current main state and sub-state of the link training state machine, and use the secondary string table lookup method to parse it into a readable state machine; According to the maximum rate currently supported by the solid state drive, a rate lookup table is established; The host side sends commands to the solid-state drive through the private software running log. Based on the log entry number and the number of log entries sent by the command, the parsed link training state machine entry information is sent to the host side.

[0043] Log online parsing and uploading module: Logs are saved in the device's memory space. When obtaining them online, the saved content needs to be parsed online based on each log entry to achieve readability.

[0044] Online parsing, for the current main state value and sub-state value of LTSSM, uses a secondary string lookup table method to parse into the LTSSM readability state machine in the PCIe field, as follows: Create LTSSM state machine secondary lookup LTSSM_Table[MAX_MAJOR_STATE][MAX_SUB_STATE]= { {DETECT, DETECT_INACTIVE}, {DETECT, DETECT_QUIET}, {DETECT, DETECT_ACTIVE}, {POLLING, POLLING_ACTIVE}, {POLLING, CONFIGURATION_US_LW_START}, {POLLING, CONFIGURATION_US_LW_ACCEPT}, …………………………… {RECOVERY, RECOVERY_RCVR_LOCK}, {RECOVERY, RECOVERY_RCVR_CFG}, {RECOVERY, RECOVERY_EQ_PH0}, {RECOVERY, RECOVERY_EQ_PH1}, …………………………… {L0, L0_L0}, {L0, L0_IDLE}, }; Based on the maximum rate currently supported by the device, establish a rate lookup table LTSSM_SPEED[MAX_LINK_SPEED]= {GEN1, GEN2, GEN3, GEN4, GEN5}.

[0045] As Figure 5 、 Figure 6 shown, in this embodiment, the host side issues commands to the solid-state drive through the operation (Log) log of private software. Based on the log record entry number and the number of log entries sent after the command is issued, the parsed link training state machine entry information is sent to the host side, including: Obtain the number of log entries TransferCount sent in the command issued by the host side through the operation log of private software; Obtain the internal log entry index number as the log record entry number ltssmLogIndex; Obtain the maximum number of buffer entries maxLogEntries in the circular buffer; Determine whether the log record entry number ltssmLogIndex is less than the maximum number of buffer entries maxLogEntries in the circular buffer; If so, obtain the starting log entry number startIndex = ltssmLogIndex - TransferCount to be sent by subtracting the number of log entries TransferCount from the log record entry number ltssmLogIndex, and copy the entries to be sent to the data transfer memory buffer in sequence based on the starting log entry number startIndex; If not, obtain the offset position of the latest entry by taking the remainder of the log record entry number ltssmLogIndex divided by the maximum number of buffer entries maxLogEntries in the circular buffer, i.e., offset = ltssmLogIndex % maxLogEntries, and determine whether the number of log entries to be sent, TransferCount, is less than the offset position of the latest entry; If so, obtain the starting log entry number to be sent, startIndex = Offset - Transfer Count, by subtracting the number of log entries to be sent, TransferCount, from the offset position of the latest entry, offset, and sequentially copy the entries to be sent to the data transfer memory buffer based on the starting log entry number startIndex; If not, obtain the earliest starting log entry number, startIndex = maxLogEntries - (TransferCount - Offset), by subtracting the number of log entries to be sent, TransferCount, from the maximum number of buffer entries maxLogEntries in the circular buffer and then adding the offset position of the latest entry, offset, copy the earliest starting log entry number startIndex to the data transfer buffer, and copy the remaining latest number of log entries to the data transfer buffer, with a total of offset number of the latest entries copied.

[0046] In this embodiment, the link training state machine log management method further includes: Set a PCIe port for each host side; Set real-time trigger recording conditions according to the link training state machine of each PCIe port and online record the state transition data each time.

[0047] Among them, each port is assigned an independent single processor to enable synchronous parallel processing of logs.

[0048] In this embodiment, setting real-time trigger recording conditions according to the link training state machine of each PCIe port and online recording the state transition data each time includes: Each port is assigned an independent single processor (CPU) to record the state machine logs into the log memory area corresponding to each port; Each processor (CPU) uses an independent timer to add corresponding timestamps to the log entries introduced by each state transition.

[0049] In this embodiment, setting real-time trigger recording conditions according to the link training state machine of each PCIe port and online recording the state transition data each time further includes: Detect the log content stored on each host side, and obtain the corresponding log content from the state machine log according to the log content from the corresponding port on the host side; Store the log content into the corresponding log memory area through the port.

[0050] Among them, based on the log content requirements stored on each host side, the corresponding log content can be obtained from each port in the state machine log for storage, realizing the classified storage of log content for the corresponding host side functions.

[0051] In this embodiment, setting real-time trigger recording conditions according to the link training state machine of each PCIe port and online recording the state migration data each time further includes: Query the link training state machine of the PCIe port in real time through the corresponding processor (CPU). Each processor (CPU) triggers the brush update of the state machine log entry in a synchronous query manner. The synchronous query manner is based on a preset timeout time and the link state being in the low-power operation (L0s) standby state as the exit condition.

[0052] Multi-port storage management module: The internal ASIC chip of the device adopts a multi-CPU design. Set real-time trigger recording conditions according to the LTSSM state machine of each PCIe port, allocate CPUs to query in real time and online record the state migration situation each time, meeting the reliable recording of each link establishment in the multi-port scenario. The specific method is as follows: a. Allocate an independent single CPU for each port to record the LTSSM log into the log memory area corresponding to different ports; b. Each CPU triggers the brush update of the LTSSM log entry in a synchronous query manner. The synchronous query manner is based on a maximum timeout time of 1 s and the link state being in the low-power operation (L0s) standby state as the exit condition, ensuring to avoid the CPU dead loop problem caused by state deadlock; c. Each CPU uses an independent high-precision timer to add a corresponding timestamp to the log entry introduced by each state migration, with an accuracy reaching the ns level, ensuring that the timestamp is strictly synchronized with the state change event.

[0053] In the above-mentioned link training state machine log management method, the method of capturing logs in the solid-state drive includes an analyzer acquisition log mode and a software tool acquisition log mode. If the solid-state drive supports the analyzer acquisition log mode, there is no need to use the link training state machine to occupy a large amount of storage and computing resources to implement log capture. When the analyzer acquisition log mode of the solid-state drive cannot perform log capture, it is switched to the software tool acquisition log mode to implement the capture of the state machine logs, parse the captured state machine logs, and send the parsed state machine log entry information to the host side, which can comprehensively obtain the logs of each state of the link training state machine and minimize the occupation of the internal processor resources of the solid-state drive.

[0054] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by means of software plus a necessary general hardware platform. Of course, it can also be implemented by hardware, but in many cases, the former is a better implementation.

[0055] The embodiment of the present application also provides an electronic device, including a memory and a processor. A computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above-mentioned link training state machine log management method embodiments.

[0056] In one embodiment, the electronic device may be a server, and its internal structure diagram may be as Figure 7 shown. The electronic device includes a processor, a memory, a network interface, and a database connected through a system bus. Among them, the processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the electronic device is used to store link training state machine log management data. The network interface of the electronic device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, it implements a link training state machine log management method.

[0057] The embodiment of the present application also provides a computer-readable storage medium, in which a computer program is stored. The computer program is configured to execute the steps in any one of the above-mentioned link training state machine log management method embodiments when running.

[0058] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to: various media that can store computer programs such as USB flash drives, read-only memory (ROM for short), random access memory (RAM for short), mobile hard disks, magnetic disks, or optical discs.

[0059] The embodiments of the present application also provide a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, it implements the steps in any of the embodiments of the above-mentioned link training state machine log management method.

[0060] The embodiments of the present application also provide another computer program product, including a non-volatile computer-readable storage medium. The non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements the steps in any of the embodiments of the above-mentioned link training state machine log management method.

[0061] Those skilled in the art can further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the components and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Skilled professionals can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.

[0062] The above has introduced in detail a link training state machine log management method, device, electronic device, and storage medium provided by the present application. Specific examples are used herein to elaborate on the principles and implementation manners of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application. It should be noted that for those of ordinary skill in the art in the technical field, without departing from the principle of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the protection scope of the claims of the present application.

Claims

1. A link training state machine log management method, characterized in that: include: The log capture mode set in the solid state drive includes the analyzer acquisition log mode and the software tool acquisition log mode; Capturing logs from the solid state drive using the analyzer in a log acquisition mode to determine whether the solid state drive can acquire logs; In response to the solid state drive being able to obtain the log, parsing the obtained log and sending the parsed log entry information to the host side; In response to the SSD being unable to obtain logs, an enable flag is set for the SSD, the SSD is restarted, the software tool is started according to the enable flag to obtain log mode to capture state machine logs, the captured state machine logs are parsed and the parsed state machine log entry information is sent to the host side.

2. The link training state machine log management method according to claim 1, characterized in that: The log capture mode set in the solid state drive includes an analyzer obtaining log mode and a software tool obtaining log mode including: An adaptive setting capture log acquisition module and a state machine log dynamic recording and online sending module are set in the solid state drive, and the adaptive setting capture log acquisition module and the state machine log dynamic recording and online sending module are set to start according to an enable flag and shut down according to a disable flag; In response to the solid state drive acquiring the log mode for the analyzer, the disable flag is set in the solid state drive to control the adaptive setting capture log acquisition module and the state machine log dynamic recording and online sending module to not start; In response to the solid state drive acquiring a log mode for the software tool, setting the enable flag in the solid state drive to control the adaptive setting capture log acquisition module and the state machine log dynamic recording and online uploading module to start; The log acquisition mode of the analyzer is set to the default log capture mode, and when the solid state drive is powered on for the first time, the disable flag is written in the solid state drive.

3. The link training state machine log management method according to claim 2, characterized in that: In response to the SSD being unable to obtain the log, setting an enable flag for the SSD, restarting the SSD, starting the software tool to obtain the log mode according to the enable flag to capture the state machine log, parsing the captured state machine log and sending the parsed state machine log entry information to the host side, including: In response to the SSD being powered on, if the SSD cannot obtain the log, the SSD uses a private non-volatile memory command to enable the link training state machine log monitoring function, and saves a log monitoring function enabling flag to a non-volatile medium; Controlling the solid state drive to power off, powering on the solid state drive again to restart, and determining whether the log monitoring function enabling flag exists in the non-volatile medium of the solid state drive; In response to the absence of the log monitoring function enabling flag, disabling the state machine log dynamic recording and online sending module, and controlling the solid state hard disk to start; In response to the presence of the log monitoring function activation mark, the software tool is started according to the activation mark to obtain the log mode, the state machine log dynamic recording and online uploading module is run, the solid state drive is controlled to start, and it is determined whether to trigger the log uploading; In response to not triggering the log upload, each state machine log entry of the state machine log is recorded online. In response to triggering the log upload, the recorded state machine log entry is parsed online to obtain readable log entry information, and the parsed log entry information is sent to the host side.

4. The link training state machine log management method according to claim 3, characterized in that: Each state machine log entry of the online recording of the state machine log includes: Monitor the PCIe link for abnormal events at the protocol layer and physical layer; In response to an abnormal event occurring in the protocol layer and the physical layer of the PCIe link, the processor is notified through a system-level interrupt mechanism and the state machine log dynamic recording and online uploading module is triggered to start through a global variable, and the state machine log entry is recorded; In response to no abnormal event occurring at the protocol layer and the physical layer of the PCIe link, the state machine log entry is not recorded.

5. The link training state machine log management method according to claim 4, characterized in that: The monitoring of whether abnormal events occur in the protocol layer and the physical layer of the PCIe link includes: Acquire key events captured by the solid-state drive and the host side at the initial moment of link establishment by the link training state machine, wherein the key events include at least one of a reset unlock level signal of an external physical layer, a port clock synchronization / unlock event, an initial detection state machine of a link training state machine state, a link activation event of a data link layer, a link width / rate change event of a link layer, and a correctable and uncorrectable error trigger event of a protocol layer; In response to sensing the critical event, it is determined that an abnormal event occurs at the protocol layer and the physical layer of the PCIe link.

6. The link training state machine log management method according to claim 4, characterized in that: The recording of the state machine log entry includes: It is set that when recording the state machine log entry, each state machine log entry at least includes a timestamp, a current main state and sub-state of a link training state machine, a link width, a link rate, a low-power working standby state or an active state of a sending / receiving state machine, a key migration history state, a link channel configuration mode, a link peer detection state, and a key hardware continuous time linear equalizer / gain parameter of a link receiving end; The storage management of the state machine log entries adopts a ring buffer mode, and the maximum number of buffer entries in the ring buffer is set according to the requirement of covering historical data of a preset time length.

7. The link training state machine log management method according to claim 4, characterized in that: The recording of the state machine log entry further includes: Setting a trigger condition for adding a new log entry, wherein the trigger condition for adding a new log entry includes at least one of when the current main state and sub-state of the link training state machine change, when the key migration history state of the link training state machine changes, and when a link error state occurs; wherein the main state includes at least one of detection, polling, configuration, recovery, loopback, hot reset, and disable, and the sub-state is an internal state of any one of the main states; In response to the SSD being powered on, a state machine disabling control flag is set in the firmware, the link training state machine is kept in a detection main state, and after the preparation of the power-on process log resource is completed, the state machine disabling control flag is updated and then the detection main state is exited to establish a link; In response to the link being established, the status register or the real-time error status of the link is updated in a query synchronization blocking manner, and the recording of the new log entry is triggered when it is found that the triggering condition of the new log entry is met.

8. The link training state machine log management method according to claim 6, characterized in that: The online parsing of the recorded state machine log entries to obtain readable log entry information and sending the parsed log entry information to the host side includes: Obtain the main state value and sub-state value corresponding to the current main state and sub-state of the link training state machine, and parse them into a readable state machine using a secondary string lookup table method; Establishing a rate lookup table according to the maximum rate currently supported by the solid state drive; The host side sends commands to the solid state drive through the private software running log, and sends the parsed link training state machine entry information to the host side based on the log record entry number and the number of log entries sent by the command.

9. The link training state machine log management method according to claim 8, characterized in that: The host side sends a command to the solid state drive through a private software running log, and sends the parsed link training state machine entry information to the host side based on the log record entry number and the number of log entries sent by the command: Obtain the number of log entries sent by the host side through the private software running log sending command; Get the internal log entry index number as the log record entry number; Obtaining the maximum number of buffer entries in the ring buffer; Determining whether the log record entry number is less than the maximum number of buffer entries in the ring buffer; If yes, then obtaining the starting number of log entries to be sent by subtracting the number of log entries to be sent from the log record entry number, and sequentially copying the entries to be sent to the data transmission memory buffer based on the starting number of log entries to be sent; If not, the offset position of the latest entry is obtained by taking the remainder of dividing the log record entry number by the maximum number of buffered entries in the ring buffer, and judging whether the number of sent log entries is less than the offset position of the latest entry; If yes, the starting number of log entries to be uploaded is obtained by subtracting the number of uploaded log entries from the offset position of the latest entry, and the entries to be uploaded are copied to the data transmission memory buffer in sequence based on the starting number of uploaded log entries; If not, obtain the earliest starting log entry by subtracting the number of uploaded log entries from the maximum number of buffer entries in the ring buffer plus the offset position of the latest entry, and copy the earliest starting log entry number to the data transmission buffer, copy the remaining latest log entries to the data transmission buffer, and copy a total of the offset position number of the latest entries.

10. The link training state machine log management method according to claim 1, characterized in that: Also includes: A PCIe port is set corresponding to each host side; Set real-time trigger recording conditions according to the link training state machine of each PCIe port and record each state transition data online.

11. The link training state machine log management method according to claim 10, characterized in that: The method of setting a real-time trigger recording condition according to the link training state machine of each PCIe port and recording each state transition data online includes: Each port is assigned an independent single processor to record the state machine log into the log memory area corresponding to each port; Each of the processors uses an independent timer to add a corresponding timestamp to the log entry introduced by each state migration.

12. The link training state machine log management method according to claim 11, characterized in that: The method of setting a real-time trigger recording condition according to the link training state machine of each PCIe port and recording each state transition data online also includes: The link training state machine of the PCIe port is queried in real time through the corresponding processor, and each processor uses a synchronous query method to trigger the flush update of the state machine log entry. The synchronous query method uses a preset timeout time and the link state being in a low-power working standby state as an exit condition.

13. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the link training state machine log management method as claimed in any one of claims 1 to 12 when executing the computer program.

14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of the link training state machine log management method according to any one of claims 1 to 12.

15. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the link training state machine log management method according to any one of claims 1 to 12 are implemented.

Citation Information

Patent Citations

  • PCIe link training method and device and medium

    CN114510366A

  • Solid state disk and log acquisition method

    CN116578236A

  • Link fault detection method and device

    CN117527649A

  • Peripheral component interconnect express interface device and operating method thereof

    US20220382706A1