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

Adaptive logging in NVMe SSDs addresses incomplete log capture and resource usage by switching between protocol analyzers and software tools, ensuring comprehensive LTSSM log capture with reduced resource consumption.

CN120045537BActive Publication Date: 2025-07-15INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

In non-volatile memory solid-state drive (NVMe SSD) communication, link training state machine (LTSSM) implementation differences lead to missing log crawl content, traditional protocol analyzers are expensive and cannot be integrated in real time, software log tools cannot capture physical layer signals, high frequency records occupy a large amount of resources, affecting power-on time and resource utilization.

Method used

Set two log acquisition modes in the solid state hard disk to determine whether the log can be obtained. If possible, obtain it through the analyzer. Otherwise, restart the hard disk and enable the software tool mode to crawl and parse the state machine logs to ensure that the state logs are fully obtained.

Benefits of technology

It realizes that without occupancying a large amount of storage and computing resources, the logs of each state of the link training state machine are fully obtained, and the resource utilization of internal processors of solid-state drives is reduced, and the implementation differences of different manufacturers are adapted.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120045537B_ABST
    Figure CN120045537B_ABST
Patent Text Reader

Abstract

The present application discloses a method, apparatus, device, and storage medium for link training state machine log management, which relates to the field of computer technology. In the present application, the method for capturing logs in a 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 a link training state machine to occupy a large amount of storage and computing resources to implement log capture. When the analyzer acquisition log mode cannot be used for log capture in the solid-state drive, it is switched to the software tool acquisition log mode to implement state machine log capture, 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 internal processor resources of the solid-state drive.
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 in particular, 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. In particular, private fields or state transition logics may be introduced into the protocol in the implementation of the link training state machine (LTSSM state machine), 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 potential impacts on 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 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 logs of each state of the link training state machine.

[0004] This application provides a method for managing link training state machine logs, including:

[0005] Setting a log capture method in the solid-state drive, including an analyzer log acquisition mode and a software tool log acquisition mode;

[0006] Performing log capture on the solid-state drive using the analyzer log acquisition mode, and determining whether the solid-state drive can obtain logs;

[0007] 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;

[0008] 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 for state machine log capture, parsing the captured state machine logs, and uploading the parsed state machine log entry information to the host side.

[0009] 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:

[0010] Setting a log capture method in the solid-state drive includes an analyzer acquisition log mode and a software tool acquisition log mode;

[0011] Performing log capture on the solid-state drive using the analyzer acquisition log mode, and determining whether the solid-state drive can acquire logs;

[0012] 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;

[0013] 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.

[0014] The present application also provides a computer-readable storage medium having a computer program stored therein, wherein the computer program, when executed by a processor, implements the steps of any of the above link training state machine log management methods:

[0015] Setting a log capture method in the solid-state drive includes an analyzer acquisition log mode and a software tool acquisition log mode;

[0016] Performing log capture on the solid-state drive using the analyzer acquisition log mode, and determining whether the solid-state drive can acquire logs;

[0017] 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;

[0018] 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.

[0019] The present application also provides a computer program product including a computer program, which when executed by a processor, implements the steps of any of the above link training state machine log management methods:

[0020] Setting a log capture method in the solid-state drive includes an analyzer acquisition log mode and a software tool acquisition log mode;

[0021] Use the analyzer to obtain the log mode for the solid-state drive to capture logs, and determine whether the solid-state drive can obtain logs;

[0022] In response to the solid-state drive being able to obtain logs, parse the obtained logs and send the parsed log entry information to the host side;

[0023] In response to the solid-state drive being unable to obtain logs, set an enable flag for the solid-state drive, restart the solid-state drive, start the software tool to obtain the log mode according to the enable flag for state machine log capture, parse the captured state machine logs, and send the parsed state machine log entry information to the host side.

[0024] Through this application, by setting the log capture methods in the solid-state drive to include the analyzer acquisition log mode and the 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 solid-state drive cannot perform log capture in the analyzer acquisition log mode, switch to the software tool acquisition log mode to implement state machine log capture, 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. Description of the Drawings

[0025] To more clearly illustrate the embodiments of the present application, the following will briefly introduce the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.

[0026] 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;

[0027] Figure 2 It is an application environment diagram of the link training state machine log management method in an embodiment of the present application;

[0028] Figure 3 It is a flow schematic diagram of the link training state machine log management method in an embodiment of the present application;

[0029] Figure 4 It is a logic diagram for controlling the restart and capture of the state machine logs of the solid-state drive according to the enable flag in an embodiment of the present application;

[0030] Figure 5The structural block diagram for sending the link training state machine entry information in an embodiment of the present application to the host side;

[0031] Figure 6 The logic diagram for the host side in an embodiment of the present application to send commands to the solid-state drive through private software operation logs, and based on the log record entry number and the number of log entries sent after the command is issued, send the parsed link training state machine entry information to the host side;

[0032] Figure 7 The internal structure diagram of a computer device in an embodiment of the present application. Detailed implementation manners

[0033] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with 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 belong to the protection scope of the present application.

[0034] 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 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 explicitly 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.

[0035] In order 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 in conjunction with the accompanying drawings and specific implementation manners.

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

[0037] 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.

[0038] 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, if 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 log acquisition and insufficient log capture accuracy.

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

[0040] 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 are 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 device of the SSD, resulting in too long power-on time of the NVMe SSD and affecting the competitiveness of the product.

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

[0042] Adaptive setting capture log acquisition module: Using the private manufacturer characteristics setting command of the NVMe SSD, determine whether to capture the LTSSM state machine log when starting to establish a link; and trigger the acquisition and upload of LTSSM log records through the private manufacturer's log acquisition command.

[0043] LTSSM log dynamic recording and online parsing and uploading module: Set the LTSSM log entry recording content according to the hardware registers provided by the chip, comprehensively record the state transition process and exception-related information of the LTSSM; and optimize the write record timing of each LTSSM log to meet the recording and real-time performance of historical log information during multiple link establishment processes. Adopt the design of a circular buffer to record each Ltssm log entry online. At the same time, perform online parsing on the recorded entries when uploading the logs to maximize the readability of the log entries.

[0044] 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 reliability recording of each link establishment in a multi-port scenario.

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

[0046] 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.

[0047] As Figure 3 shown, an embodiment of the present application provides a link training state machine log management method, including the following steps:

[0048] Step S1, set the log capture method in the solid-state drive, including the analyzer log acquisition mode and the software tool log acquisition mode;

[0049] Step S2, perform log capture on the solid-state drive using the analyzer log acquisition mode, and determine whether the solid-state drive can acquire logs;

[0050] Step S3, in response to the solid-state drive being able to obtain the log, parse the obtained log and upload the parsed log entry information to the host side;

[0051] Step S4, in response to the solid-state drive being unable to obtain the log, set an enable flag for the solid-state drive, restart the solid-state drive, start the software tool to obtain the log mode according to the enable flag for state machine log capture, parse the captured state machine log, and upload the parsed state machine log entry information to the host side.

[0052] In this embodiment, the log capture method set in the solid-state drive includes an analyzer to obtain the log mode and a software tool to obtain the log mode. If the solid-state drive supports the analyzer to obtain the log mode, there is no need to use the link training state machine to occupy a large amount of storage and computing resources to achieve log capture. When the solid-state drive cannot perform log capture in the analyzer to obtain the log mode, switch to the software tool to obtain the log mode to achieve state machine log capture, parse the captured state machine log, and upload 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.

[0053] In this embodiment, setting the log capture method in the solid-state drive to include an analyzer to obtain the log mode and a software tool to obtain the log mode includes:

[0054] Set an adaptive setting log capture acquisition module and a state machine log dynamic recording and online upload module in the solid-state drive. The adaptive setting 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;

[0055] In response to the solid-state drive being in the analyzer to obtain the log mode, set a disable flag in the solid-state drive to control that the adaptive setting log capture acquisition module and the state machine log dynamic recording and online upload module are not started;

[0056] In response to the solid-state drive being in the software tool to obtain the log mode, set an enable flag in the solid-state drive to control that the adaptive setting log capture acquisition module and the state machine log dynamic recording and online upload module are started;

[0057] Set the analyzer to obtain the log mode as the default log capture method. When the solid-state drive is powered on for the first time, write a disable flag in the solid-state drive.

[0058] The adaptive setting for capturing log acquisition module uses vendor - specific commands with the current NVMe technology to complete the enabling setting for capturing LTSSM logs, and completes the host upload acquisition of logs through private log acquisition commands. Since the capture of LTSSM logs occurs during the link - establishment process when the device product is powered on initially and will occupy the CPU resources during power - on, affecting some performance indicators of the device, the private command setting is enabled adaptively only when relevant link - related abnormal problems are encountered, and takes effect again after physical power - off and then power - on.

[0059] 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.

[0060] Among them, when the analyzer acquires the log mode, the protocol analyzer is used to acquire the link training state machine logs. When the LTSSM logs cannot be acquired, it switches to the software tool to acquire the log mode and uses vendor - specific commands to complete the capture of LTSSM logs. Only at this time will it occupy the internal processor resources of the solid - state drive. After acquiring the corresponding status logs, the adaptive setting for capturing log acquisition module and the LTSSM log dynamic recording and online upload module are disabled again, and it switches back to the analyzer to acquire the log mode, thus overall reducing the 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.

[0061] Such as Figure 4 shown, in this embodiment, in response to the solid - state drive being unable to acquire logs, an enabling flag is set for the solid - state drive, the solid - state drive is restarted, and according to the enabling flag, the software tool is started to acquire the log mode for capturing the state machine logs, and the parsed state machine log entry information of the captured state machine logs is uploaded to the host side, including:

[0062] In response to the power - on of the solid - state drive, if the solid - state drive cannot acquire 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 enabling flag to the non - volatile medium;

[0063] Control the solid - state drive to power off, power on the solid - state drive again and restart it, and judge whether there is a log monitoring function enabling identifier in the non - volatile medium of the solid - state drive;

[0064] In response to the absence of the log monitoring function enabling identifier, disable the state machine log dynamic recording and online upload 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.

[0065] In response to the presence of a log monitoring function enabling flag, start a software tool to obtain a log mode according to the enabling flag, run a state machine log dynamic recording and online sending module, control the start of a solid-state drive, and determine whether to trigger log sending; at this time, the solid-state drive starts with a link training state machine log recording method;

[0066] In response to not triggering log sending, each state machine log entry of the state machine log is recorded online. In response to triggering log sending, the recorded state machine log entries are parsed online to obtain readable log entry information, and the parsed log entry information is sent to the host side.

[0067] As Figure 4 shown, running the LTSSM log dynamic recording module mainly depends on the enabling / disabling flag recorded in the non-volatile medium, and subsequent capturing is completed according to this flag. In this way, the requirement of online diagnosis is completed without affecting the physical topology and connection.

[0068] In this embodiment, each state machine log entry of the state machine log recorded online includes:

[0069] Monitor whether abnormal events occur in the PCIe link at the protocol layer and the physical layer;

[0070] In response to abnormal events occurring in the PCIe link at the protocol layer and the physical layer, notify the processor (CPU) through the system-level interrupt mechanism and trigger the start of the LTSSM dynamic recording module of the state machine log dynamic recording and online sending module by means of a global variable to record the state machine log entries;

[0071] In response to no abnormal events occurring in the PCIe link at the protocol layer and the physical layer, do not record the state machine log entries.

[0072] 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 PCIe link at the protocol layer, the physical layer, etc., and notify the CPU processing unit in the device through the system-level interrupt mechanism.

[0073] In this embodiment, monitoring whether abnormal events occur in the PCIe link at the protocol layer and the physical layer includes:

[0074] Obtain 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 a reset unlock level signal of the external physical layer, a port clock synchronization / loss of lock event, an initial detection state machine of the link training state machine state, a link activation event of the data link layer, a link layer link width / rate change event, and a correctable and uncorrectable error trigger event of the protocol layer;

[0075] After detecting a critical event, it is determined that abnormal events occur in the protocol layer and physical layer of the PCIe link.

[0076] Among them, by controlling the timing of log capture according to the critical event, all-round polling of the logs can be performed and the log content can be recorded, ensuring the comprehensiveness of log acquisition.

[0077] In this embodiment, recording the state machine log entries includes:

[0078] When recording the state machine log entries, each state machine log entry at least includes 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 critical 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;

[0079] 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.

[0080] 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.

[0081] In this embodiment, recording the state machine log entries further includes:

[0082] Set the trigger condition for adding a new log entry. 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 critical migration history state of the link training state machine changes, and when a link error state occurs; where 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 main state;

[0083] 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;

[0084] In response to the establishment of the link, use the query synchronization blocking method to update based on the status register or the real-time link error state, and trigger the recording of a new log entry when it is detected that the trigger condition for adding a new log entry is met.

[0085] Log entry update module: Log storage management adopts a circular buffer mode, and the maximum number of entries is set to N, which can cover at least 1s of historical data. In order to ensure accurate capture of key data and avoid storage overhead caused by the flooding of repeated records of the same log, the query synchronization blocking mode is used to update based on the LTSSM status register or the link real-time error status. When at least one condition is met, the recording of new log entries is triggered: 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 Detect / Polling / Configuration / Recovery / L0s, etc. changes; when the link error state occurs.

[0086] 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.

[0087] 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:

[0088] 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;

[0089] According to the maximum rate currently supported by the solid state drive, a rate lookup table is established;

[0090] 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.

[0091] 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.

[0092] Online parsing. For the current main state value and sub-state value of LTSSM, a two-level string look-up table method is adopted to parse them into a readable state machine of LTSSM in the PCIe field, as follows:

[0093] Create a two-level look-up table for the LTSSM state machine LTSSM_Table[MAX_MAJOR_STATE][MAX_SUB_STATE]= {

[0094] {DETECT, DETECT_INACTIVE},

[0095] {DETECT, DETECT_QUIET},

[0096] {DETECT, DETECT_ACTIVE},

[0097] {POLLING, POLLING_ACTIVE},

[0098] {POLLING, CONFIGURATION_US_LW_START},

[0099] {POLLING, CONFIGURATION_US_LW_ACCEPT},

[0100] ……………………………

[0101] {RECOVERY, RECOVERY_RCVR_LOCK},

[0102] {RECOVERY, RECOVERY_RCVR_CFG},

[0103] {RECOVERY, RECOVERY_EQ_PH0},

[0104] {RECOVERY, RECOVERY_EQ_PH1},

[0105] ……………………………

[0106] {L0, L0_L0},

[0107] {L0, L0_IDLE},

[0108] };

[0109] According to the maximum rate currently supported by the device, create a rate look-up table LTSSM_SPEED[MAX_LINK_SPEED]= {GEN1, GEN2, GEN3, GEN4, GEN5}.

[0110] As Figure 5 , Figure 6 shown, in this embodiment, the host side issues a command to the solid-state drive to send up the parsed link training state machine entry information based on the log record entry number and the number of log entries sent up for the command issued through private software operation (Log), including:

[0111] Obtain the number of log entries to be sent up TransferCount issued in the command for sending up logs through private software operation on the host side;

[0112] Obtain the internal log entry index number as the log record entry number ltssmLogIndex;

[0113] Obtain the maximum number of buffer entries maxLogEntries in the circular buffer;

[0114] Determine whether the log record entry number ltssmLogIndex is less than the maximum number of buffer entries maxLogEntries in the circular buffer;

[0115] If so, obtain the starting log entry number startIndex = ltssmLogIndex - Transfer Count to start sending up by subtracting the number of log entries to be sent up TransferCount from the log record entry number ltssmLogIndex, and copy the entries to be sent up to the data transfer memory buffer in sequence based on the starting log entry number startIndex;

[0116] If not, obtain the offset position offset = ltssmLogIndex % maxLogEntries 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, and determine whether the number of log entries to be sent up TransferCount is less than the offset position of the latest entry;

[0117] If so, obtain the starting log entry number startIndex = Offset - Transfer Count to start sending up by subtracting the number of log entries to be sent up TransferCount from the offset position offset of the latest entry, and copy the entries to be sent up to the data transfer memory buffer in sequence based on the starting log entry number startIndex;

[0118] Otherwise, obtain the earliest starting log entry number startIndex = maxLogEntries - (TransferCount - Offset) by subtracting the number of sent log entries TransferCount from the maximum number of buffer entries maxLogEntries in the circular buffer and adding the offset position offset of the latest entry. Then copy the earliest starting log entry number startIndex to the data transfer buffer, and copy the remaining latest log entry numbers to the data transfer buffer, with a total of offset number of the latest entries copied.

[0119] In this embodiment, the link training state machine log management method further includes:

[0120] Set a PCIe port for each host side;

[0121] Set real-time trigger recording conditions according to the link training state machine of each PCIe port and record the state transition data each time online.

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

[0123] In this embodiment, setting real-time trigger recording conditions according to the link training state machine of each PCIe port and recording the state transition data each time online includes:

[0124] Each port is assigned an independent single processor (CPU) to record the state machine logs into the log memory area corresponding to each port;

[0125] Each processor (CPU) uses an independent timer to add corresponding timestamps to the log entries introduced by each state transition.

[0126] In this embodiment, setting real-time trigger recording conditions according to the link training state machine of each PCIe port and recording the state transition data each time online further includes:

[0127] Detect the log content stored on each host side, and obtain the corresponding log content from the state machine logs of the corresponding port on the host side according to the log content;

[0128] Store the log content into the corresponding log memory area through the port.

[0129] 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 logs for storage, realizing classified storage of log content corresponding to the functions of each host side.

[0130] 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 for each time further includes:

[0131] The link training state machine of the PCIe port is queried 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.

[0132] Multi-port storage management module: The internal ASIC chip of the device adopts a multi-CPU design. Real-time trigger recording conditions are set according to the LTSSM state machine of each PCIe port, and the CPU is allocated to query in real time and record the state transition situation for each time online, meeting the reliable recording for each link establishment in the multi-port scenario. The specific method is as follows:

[0133] a. Each port is allocated an independent single CPU to record the LTSSM log into the log memory area corresponding to different ports;

[0134] 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;

[0135] c. Each CPU uses an independent high-precision timer to add a corresponding timestamp to the log entry introduced by each state transition, with the precision reaching the ns level, ensuring that the timestamp is strictly synchronized with the state change event.

[0136] In the above link training state machine log management method, the method of setting the log capture in the solid-state drive includes the analyzer acquisition log mode and the 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 log, parse the captured state machine log, and send the parsed state machine log entry information to the host side, enabling comprehensive acquisition of the logs of each state of the link training state machine and minimizing the occupation of the internal processor resources of the solid-state drive.

[0137] 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 method.

[0138] An embodiment of the present application further 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 of the above-described embodiments of the link training state machine log management method.

[0139] In one embodiment, the electronic device may be a server, and its internal structural 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.

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

[0141] In an exemplary embodiment, the above computer-readable storage medium may include, but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disc, and other various media that can store a computer program.

[0142] An embodiment of the present application further provides a computer program product. The above 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 above-described embodiments of the link training state machine log management method.

[0143] An embodiment of the present application further provides 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 above-described embodiments of the link training state machine log management method.

[0144] Those skilled in the art may further realize that the units and algorithm steps of each example described in connection with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the composition 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. Those skilled in the art can use different methods for each specific application to implement the described functions, but such implementation should not be considered as exceeding the scope of this application.

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

Claims

1. A method for managing link training state machine logs, characterized in that, Including: Setting a log capturing method in a solid - state drive includes an analyzer log acquisition mode and a software tool log acquisition mode; Performing log capture on the solid - state drive using the analyzer log acquisition 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 not being able to acquire logs, setting an enable flag for the solid - state drive, restarting the solid - state drive, and starting the software tool log acquisition 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, including: in response to the solid - state drive power - on, if the solid - state drive cannot acquire logs, the solid - state drive enables the link training state machine log monitoring function using a private non - volatile memory command, and saves the log monitoring function enable flag to non - volatile media; controlling the solid - state drive to power off, powering on and restarting the solid - state drive again, and determining whether the log monitoring function enable identifier exists in the non - volatile media of the solid - state drive; in response to the non - existence of the log monitoring function enable identifier, disabling the state machine log dynamic recording and online upload module, and controlling the solid - state drive to start; in response to the existence of the log monitoring function enable identifier, starting the software tool log acquisition mode according to the enable flag, running the state machine log dynamic recording and online upload module, controlling the solid - state drive to start, and determining whether to trigger log upload; in response to not triggering log upload, online - recording each state machine log entry of the state machine logs, and in response to triggering log upload, performing online parsing on the recorded state machine log entries to obtain readable log entry information, and uploading the parsed log entry information to the host side.

2. The link training state machine log management method according to claim 1, wherein The setting of the log capturing method in the solid - state drive including the analyzer log acquisition mode and the software tool log acquisition mode includes: Setting an adaptive log capturing acquisition module and a state machine log dynamic recording and online upload module in the solid - state drive, and setting the adaptive log capturing acquisition module and the state machine log dynamic recording and online upload module to start according to the enable flag and to shut down according to the disable flag; In response to the solid - state drive being in the analyzer log acquisition mode, setting the disable flag in the solid - state drive, and controlling the adaptive log capturing acquisition module and the state machine log dynamic recording and online upload module not to start; In response to the solid - state drive being in the software tool log acquisition mode, setting the enable flag in the solid - state drive, and controlling the adaptive log capturing acquisition module and the state machine log dynamic recording and online upload module to start; Setting the analyzer log acquisition mode as the default log capturing method, and writing the disable flag into the solid - state drive when the solid - state drive is powered on for the first time.

3. The method for managing link training state machine logs according to claim 1, wherein The online - recording each state machine log entry of the state machine logs 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 through the system-level interrupt mechanism and trigger the dynamic recording of the state machine log and the start of the online upload module in the global variable manner, and 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.

4. The link training state machine log management method according to claim 3, wherein The monitoring of 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 width / rate change event of the link layer, and the correctable and uncorrectable error trigger event of the protocol layer; In response to sensing the key events, determine that abnormal events occur in the protocol layer and physical layer of the PCIe link.

5. The method for managing the link training state machine log according to claim 3, wherein The recording of the state machine log entries includes: Set that when recording the state machine log entries, each state machine log entry at least includes 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 standby state or active state where the transmit / receive state machine is located, the key migration history state, the link channel configuration method, the link peer detection state, and the key hardware continuous time linear equalizer / gain parameter of the link receiving end; 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.

6. The method for managing the link training state machine log according to claim 3, wherein The recording of the state machine log entries further includes: Set the trigger condition for adding a new log entry. 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 the link error state occurs; where the main state includes at least one of the states 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 power-on of the solid-state drive, set a 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 a 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 detected that the trigger condition for adding a new log entry is satisfied.

7. The method for managing the link training state machine log according to claim 5, characterized in that The online parsing of the recorded state machine log entries to obtain readable log entry information and uploading the parsed log entry information to the host side includes: Obtain the current main state and the main state value and sub-state value corresponding to the sub-state of the link training state machine, and use the two-level string look-up table method to parse it into a readable state machine; Establish a rate look-up table according to the maximum rate currently supported by the solid-state drive; The host side issues a command to the solid-state drive through the private software operation log, and based on the log record entry number and the number of uploaded log entries issued by the command, the parsed link training state machine entry information is uploaded to the host side.

8. The method for managing the link training state machine log according to claim 7, wherein, The host side issues a command to the solid-state drive through the private software operation log, and based on the log record entry number and the number of uploaded log entries issued by the command, uploading the parsed link training state machine entry information to the host side includes: Obtain the number of uploaded log entries issued in the command issued by the host side through the private software operation log; Obtain the internal log entry index number as the log record entry number; Obtain the maximum number of buffer entries in the circular buffer; Judge whether the log record entry number is less than the maximum number of buffer entries in the circular buffer; If so, obtain the starting log entry number for uploading by subtracting the number of uploaded log entries from the log record entry number, and sequentially copy the entries to be uploaded to the data transfer memory buffer based on the starting log entry number for uploading; If not, obtain the offset position of the latest entry by taking the remainder of the log record entry number divided by the maximum number of buffer entries in the circular buffer, and judge whether the number of uploaded log entries is less than the offset position of the latest entry; If so, obtain the starting log entry number for uploading by subtracting the number of uploaded log entries from the offset position of the latest entry, and sequentially copy the entries to be uploaded to the data transfer memory buffer based on the starting log entry number for uploading; 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 circular buffer and then adding the offset position of the latest entry, copy the earliest starting log entry number to the data transfer buffer, and copy the remaining latest number of log entries to the data transfer buffer, and a total of the number of entries at the offset position of the latest entry is copied.

9. The method for managing the link training state machine log according to claim 1, wherein It also 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 record the state migration data each time online.

10. The method for managing the link training state machine log according to claim 9, characterized in that, The setting of real-time trigger recording conditions according to the link training state machine of each PCIe port and online recording of the state migration data each time includes: Each port allocates 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 entries introduced by each state migration.

11. The link training state machine log management method according to claim 10, wherein The setting of real-time trigger recording conditions according to the link training state machine of each PCIe port and online recording of the state migration data each time further includes: The link training state machine of the PCIe port is queried in real time through the corresponding processor, and each processor triggers the writing and updating of the state machine log entries in a synchronous query manner. The synchronous query manner is based on a preset timeout period and the link state being in a low-power working standby state as the exit condition.

12. An electronic device, characterized in that, It includes: A memory for storing computer programs; A processor for implementing the steps of the link training state machine log management method according to any one of claims 1 to 11 when executing the computer program.

13. A computer-readable storage medium, characterized in that, A computer program is stored in the computer-readable storage medium, wherein the computer program implements the steps of the link training state machine log management method according to any one of claims 1 to 11 when executed by a processor.

14. A computer program product, comprising a computer program, characterized in that, The computer program implements the steps of the link training state machine log management method according to any one of claims 1 to 11 when executed by a processor.

Citation Information

Patent Citations

  • Solid state disk and log acquisition method

    CN116578236A

  • Link fault detection method and device

    CN117527649A