Anti-locking method and network device
Patent Information
- Application Number
- CN202611289016.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-24
- Publication Date
- 2026-10-30
AI Technical Summary
但是,该方案依赖神经网络模型进行流量预测和参数调整,市面上常见的网络设备均只有简单的CPU,性能较差,无法满足神经网络
[0019]相对现有技术,本申请实施例提供的一种防死锁方法及网络设备,首先,交换芯片的入端口接收待转发报文,确定待转发报文支持ECN时为其分配预设类型标识符,同时在检测到待转发报文对应的出端口发生拥塞时,触发对待转发报文进行ECN标记时,并在确定待转发报文为已标记报文后,将待转发报文转发至接收端,同时上送处理器,处理器记录上送时间戳为待转发报文对应优先级的拥塞发生时刻,然后,网络设备在识别到接收端返回的CNP报文时,将CNP报文转发至发送端,同时上送处理器,处理器记录上送时间戳为该优先级的CNP报文到达时刻,之后,交换芯片在检测到出端口拥塞解除时,触发上报缓存事件至处理器,处理器记录上报时间戳为该优先级的发送端降速时刻,最后,处理器根据同一优先级的拥塞发生时刻、CNP报文到达时刻和发送端降速时刻,计算该优先级从触发ECN标记到发送端完成降速期间所需的缓存容量,并基于该缓存容量配置交换芯片中入端口的该优先级的PFC阈值,从而能够在不依赖高算力硬件的前提下,根据实际链路延迟动态自适应调整PFC阈值,有效避免PFC死锁。
Smart Images

Figure CN123020469A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data communication technology, and more specifically, to a deadlock prevention method and network device. Background Technology
[0002] In traditional RoCE (RDMA over Converged Ethernet) lossless Ethernet network scenarios, there is a transmitter, a receiver, and at least one network device (such as a switch). The network device connects the transmitter and receiver, and packets sent by the transmitter are transmitted to the receiver through the network device. To achieve high-throughput, low-latency transmission with RDMA, it is essential to ensure that no packet loss occurs during network congestion. Therefore, it is necessary to deploy both end-to-end congestion control mechanisms and hop-by-hop flow control mechanisms. ECN (Explicit Congestion Notification) and PFC (Priority Flow Control) are two core collaborative control methods in traditional RoCE lossless networks. ECN operates at the end-to-end level: When the hardware queue buffer usage reaches the configured ECN threshold, congestion is considered to have occurred. The network device marks packets exceeding the ECN threshold with ECN. Upon receiving the marked packets, the receiving end generates a CNP (Congestion Notification Packet) and sends it back to the sending end. After receiving the CNP packet, the sending end reduces the bandwidth of its transmitted traffic, thus slowing down the transmission. PFC operates at the hop-by-hop level: When the queue buffer usage reaches the PFC threshold, the network device directly sends a backpressure frame to the upstream device for that priority, suspending the transmission of traffic of that priority until the buffer usage is relieved.
[0003] In real-world networks, network link latency and traffic patterns are constantly changing. The response time from triggering the ECN flag to the actual rate reduction at the sending end varies across different application scenarios. If the threshold interval between ECN and PFC cannot be dynamically adjusted according to link conditions, the chip buffer may not be fully utilized, leading to repeated PFC triggering and even PFC deadlock.
[0004] To address the above problems, existing technologies typically employ the following solutions: Existing technical solution 1: In traditional lossless Ethernet network scenarios, ECN and PFC are configured with independent static thresholds. For example... Figure 1As shown, the common practice is to first configure a static ECN threshold (e.g., 20% of the queue buffer) for the sending queue, and then configure a static PFC threshold (e.g., 60% of the queue buffer). After traffic enters the network device, the queue buffer begins to grow, and the sender continuously sends packets. When the queue buffer reaches the ECN threshold, it triggers ECN marking on packets to be forwarded. The receiver, upon receiving the marked packet, generates a CNP packet and sends it back to the sender. Ideally, the sender should immediately begin slowing down upon receiving the CNP packet, allowing the queue buffer to empty and congestion to be relieved. However, due to time lag (the delay between triggering ECN marking and the sender receiving the CNP packet and slowing down), the sender continues to send packets before the slowdown takes effect, causing the queue buffer occupied by the network device to continue to grow. When the queue buffer reaches the PFC threshold, PFC backpressure is triggered. Under normal circumstances, PFC backpressure takes effect, the sender stops sending, congestion is relieved, and the queue is emptied. However, in multi-link scenarios, multiple links triggering PFC backpressure simultaneously can lead to deadlock, resulting in decreased network throughput or even service interruption.
[0005] In other words, this static configuration method ignores the time lag in the ECN response link. From the time the network device triggers the ECN tag, to the time the receiver receives the tagged packet and sends back the CNP packet, and then to the time the sender reduces its speed, the sender is continuously sending packets, and traffic is continuously being sent to the receiver. If the PFC threshold is not configured properly, it may cause frequent PFC triggers. If multiple links trigger PFC, it can easily lead to a typical PFC deadlock, resulting in a sharp drop in network throughput or even service interruption.
[0006] Existing technical solution two: This involves using machine learning methods such as convolutional neural networks to simulate and model actual traffic, thereby dynamically modifying the configuration values of ECN and PFC to reduce PFC triggering and lower the risk of deadlock. However, this solution relies on neural network models for traffic prediction and parameter adjustment. Common network devices on the market typically only have simple CPUs with poor performance, making them unsuitable for neural networks. Meeting these requirements necessitates additional hardware support such as high-performance GPUs or dedicated AI acceleration chips, resulting in poor practicality, low cost-effectiveness, and limited deployment on ordinary network devices.
[0007] In typical RoCE lossless networks, static threshold configuration between ECN and PFC can easily lead to PFC deadlock due to neglecting time lag. Meanwhile, machine learning-based dynamic adjustment schemes are impractical and cost-effective due to excessively high hardware requirements. Therefore, how to dynamically and adaptively adjust the PFC threshold based on actual link latency without relying on high-performance hardware, thereby effectively avoiding PFC deadlock, is a problem that needs to be solved in this field. Summary of the Invention
[0008] The purpose of this application is to provide a deadlock prevention method and network device to improve the above-mentioned problems.
[0009] To achieve the above objectives, the technical solutions adopted in the embodiments of this application are as follows: In a first aspect, embodiments of this application provide an anti-deadlock method applied to a network device, the network device including a processor and a switching chip, the method comprising: The ingress port of the switching chip receives the packet to be forwarded, determines that the packet to be forwarded supports Explicit Congestion Notification (ECN), and assigns a preset type identifier to the packet to be forwarded. When the switching chip detects congestion at the output port corresponding to the packet to be forwarded, it triggers ECN marking on the packet to be forwarded. After determining that the packet to be forwarded is a marked packet, it forwards the packet to the receiving end and simultaneously sends it to the processor. The processor records and sends up a timestamp that corresponds to the time when congestion occurred for the priority of the message to be forwarded; The switching chip identifies the corresponding Congestion Notification Message (CNP) returned by the receiving end, forwards the CNP message to the sending end, and simultaneously sends it to the processor; The processor records the timestamp of the CNP message of the specified priority as the arrival time. When the switching chip detects that the congestion at the output port has been cleared, it triggers a report cache event to the processor. The processor records the reporting timestamp as the moment when the sending end of the priority drops off; The processor calculates the buffer capacity required for the priority from the triggering of the ECN flag to the completion of the rate reduction by the sender based on the congestion occurrence time, the arrival time of the CNP message, and the rate reduction time of the sender, and configures the priority-based flow control (PFC) threshold of the priority of the ingress port in the switching chip based on the buffer capacity.
[0010] Optionally, determining that the message to be forwarded is a tagged message includes: The switching chip identifies the packet to be forwarded as a marked packet by recognizing that the packet to be forwarded includes a congestion flag and carries the preset type identifier at the output port.
[0011] Optionally, the switching chip identifies the Congestion Notification Message (CNP) returned by the receiving end, including: The switching chip parses the payload of the message returned by the receiving end at the output port by using the offset position of the user-defined field. If the value of the opcode field in the basic transport header of the payload is a set value, then the returned message is identified as the CNP message.
[0012] Optionally, after the processor records the time of congestion occurrence corresponding to the priority of the packet to be forwarded, the method further includes: The processor generates a unique index based on the source IP address, destination IP address, ingress port identifier, egress port identifier, and priority of the packet to be forwarded, and stores the unique index in association with the time when the congestion occurred.
[0013] Optionally, after the processor records the arrival time of the CNP message with the timestamp of the priority, the method further includes: The processor parses the source IP address, destination IP address, ingress port identifier, egress port identifier, and priority of the CNP packet; The processor matches the pre-stored unique index based on the source IP address, destination IP address, ingress port identifier, egress port identifier, and priority of the CNP packet, and associates the arrival time of the CNP packet with the unique index.
[0014] Optionally, the processor calculates the buffer capacity required for the priority from the triggering of the ECN flag to the completion of the sender's rate reduction based on the congestion occurrence time, the CNP message arrival time, and the sender's rate reduction time, including: Calculate the difference between the arrival time of the CNP message and the time of congestion occurrence to obtain the congestion notification delay from triggering the ECN flag to receiving the CNP message; Calculate the difference between the time when the sending end slows down and the time when the CNP message arrives to obtain the congestion convergence delay from the time the priority is received to the time when the sending end completes the slowdown. Calculate the sum of the congestion notification delay and the congestion convergence delay to obtain the total delay from the triggering of the ECN flag to the completion of the rate reduction by the sending end; The buffer capacity is obtained by multiplying the total latency by the pre-acquired rate of the ingress port.
[0015] Optionally, the CNP message arrival time can be multiple; The step of calculating the difference between the arrival time of the CNP message and the time of congestion occurrence to obtain the congestion notification delay from triggering the ECN flag to receiving the CNP message includes: Calculate the difference between the arrival time of the CNP message and the time of each congestion occurrence, and take the maximum value among all the differences as the congestion notification delay; The step of calculating the difference between the time when the sender slows down and the time when the CNP message arrives, to obtain the congestion convergence delay from receiving the CNP message to the time when the sender completes the slowdown, includes: Calculate the difference between the time when the sending end slows down and the arrival time of each CNP message, and take the maximum value among all the differences as the congestion convergence delay.
[0016] Optionally, the PFC threshold includes a PFC recovery threshold and a PFC pause threshold; The processor configures the priority-based flow control (PFC) threshold for the ingress port based on the cache capacity, including: The processor configures the cache capacity to the PFC pause threshold value of the priority of the ingress port; The processor configures the difference between the PFC pause threshold and the preset hysteresis as the PFC recovery threshold for the priority of the ingress port.
[0017] Secondly, embodiments of this application provide a network device, which includes a processor and a switching chip; The switching chip is used to assign a preset type identifier to the packet to be forwarded when it receives the packet to be forwarded at the ingress port and determines that the packet to be forwarded supports explicit congestion notification (ECN). The switching chip is also used to trigger ECN marking of the packet to be forwarded when congestion is detected at the output port corresponding to the packet to be forwarded; after determining that the packet to be forwarded is a marked packet, the chip forwards the packet to be forwarded to the receiving end and sends it to the processor at the same time. The processor is used to record the time when congestion occurs with the timestamp corresponding to the priority of the packet to be forwarded. The switching chip is also used to identify the corresponding Congestion Notification Message (CNP) returned by the receiving end, forward the CNP message to the sending end, and simultaneously send it to the processor; The processor is also configured to record the arrival time of CNP messages with the uploaded timestamp of the priority. The switching chip is also used to trigger a reporting cache event to the processor when the congestion at the output port is detected to be cleared; The processor is also used to record the time when the sending end with the reporting timestamp of the priority reduces its speed; The processor is further configured to calculate the buffer capacity required for the priority from the triggering of the ECN flag to the completion of the rate reduction by the sender, based on the congestion occurrence time, the arrival time of the CNP message, and the rate reduction time of the sender, and configure the priority-based flow control (PFC) threshold of the priority of the ingress port in the switching chip based on the buffer capacity.
[0018] Optionally, the processor is specifically configured to: calculate the difference between the arrival time of the CNP message and the congestion occurrence time to obtain the congestion notification delay from the triggering of the ECN mark to the receipt of the CNP message for the priority; calculate the difference between the deceleration time of the sending end and the arrival time of the CNP message to obtain the congestion convergence delay from the receipt of the CNP message to the completion of deceleration by the sending end for the priority; calculate the sum of the congestion notification delay and the congestion convergence delay to obtain the total delay from the triggering of the ECN mark to the completion of deceleration by the sending end for the priority; and calculate the product of the total delay and the pre-acquired rate of the ingress port to obtain the buffer capacity.
[0019] Compared to existing technologies, the deadlock prevention method and network device provided in this application embodiment firstly, the ingress port of the switching chip receives a packet to be forwarded. If the packet supports ECN, a preset type identifier is assigned to it. Simultaneously, when congestion is detected at the egress port corresponding to the packet, ECN marking of the packet is triggered. After confirming that the packet is marked, it is forwarded to the receiving end and simultaneously sent to the processor. The processor records the timestamp of the sent packet as the time of congestion occurrence corresponding to the priority of the packet. Then, when the network device recognizes a CNP packet returned by the receiving end, it forwards the CNP packet to the sending end and simultaneously sends it to the processor. The processor records... The timestamp is recorded as the arrival time of the CNP packet of this priority. Then, when the switching chip detects that the congestion at the outgoing port has been cleared, it triggers a reporting buffer event to the processor. The processor records the reporting timestamp as the time when the sender slows down for this priority. Finally, the processor calculates the buffer capacity required for this priority from the triggering of the ECN flag to the completion of the sender's slowdown based on the congestion occurrence time, the arrival time of the CNP packet, and the time when the sender slows down for the same priority. Based on this buffer capacity, the processor configures the PFC threshold for this priority at the incoming port of the switching chip. This allows the PFC threshold to be dynamically and adaptively adjusted according to the actual link delay without relying on high-performance hardware, effectively avoiding PFC deadlock. Attached Figure Description
[0020] Figure 1 A flowchart illustrating the static configuration method provided by existing technology is shown.
[0021] Figure 2 A schematic diagram of an application scenario provided by an embodiment of this application is shown.
[0022] Figure 3 This paper illustrates a flowchart of an anti-deadlock method provided in an embodiment of this application. Figure 1 .
[0023] Figure 4 This paper illustrates a flowchart of an anti-deadlock method provided in an embodiment of this application. Figure 2 .
[0024] Figure 5 This paper illustrates a flowchart of an anti-deadlock method provided in an embodiment of this application. Figure 3 .
[0025] Figure 6 A block diagram of a network device provided in an embodiment of this application is shown.
[0026] Icons: 10-Network device; 11-Processor; 12-Memory; 13-Switching chip; 14-Communication module. Detailed Implementation
[0027] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings.
[0028] The deadlock prevention method provided in this application is applied to RoCE (RDMA over Converged Ethernet) lossless Ethernet environments, such as... Figure 2 As shown, it includes a transmitter, a receiver, and at least one network device.
[0029] The sender and receiver can be a single server or a server cluster. Both the sender and receiver are configured with network interface cards (NICs) that support the RoCE protocol. The receiver can identify packets marked with ECN and generate CNP packets, while the sender can dynamically adjust the transmission rate based on the CNP packets.
[0030] Network equipment can be a switch product that supports RoCE lossless characteristics or other network communication products with the same function, and its hardware includes a switching chip and a processor.
[0031] The switching chip is configured to: receive packets to be forwarded at the ingress port, and assign a preset CID (Category Identifier) to the packets to be forwarded when it is determined that the packets to be forwarded support ECN; when congestion is detected at the egress port corresponding to the packets to be forwarded (e.g., the queue buffer occupancy corresponding to a certain priority reaches a preset ECN threshold), trigger the ECN marking of the packets to be forwarded, and after confirming that the packets to be forwarded are marked packets by matching ACL (Access Control List), forward the packets to the receiver and send them to the processor; parse the BTH (Base Transport Header) opcode field (value 0x81) of the packets by the offset position of UDF (User Defined Field), identify the CNP packets returned by the receiver by ACL, and forward the CNP packets to the sender and send them to the processor; configure a buffer event monitoring unit, and when the queue buffer occupancy corresponding to the priority decreases to a preset low watermark threshold, determine that the congestion at the egress port is relieved, and trigger the reporting of the buffer event to the processor.
[0032] The processor is configured to: record the congestion occurrence time when a message to be forwarded is received, record the arrival time of a CNP message when a CNP message is received, and record the sender's deceleration time when a buffer event is received. At the same time, based on the congestion occurrence time, CNP message arrival time, and sender deceleration time of the same priority, calculate the buffer capacity required for that priority from the triggering of the ECN flag to the sender completing the deceleration, and then configure the PFC threshold of that priority on the ingress port of the switching chip based on the buffer capacity.
[0033] For example, when a switching chip receives a packet to be forwarded (such as RoCE service traffic of a certain priority) at its ingress port, it assigns a preset CID to the packet when it determines that the packet supports ECN. When congestion is detected at the egress port corresponding to the packet (e.g., queue buffer usage reaches a preset ECN threshold), it triggers ECN marking of the packet. After confirming the packet is marked via ACL matching, it forwards the packet to the receiver and simultaneously sends it to the processor. The processor records the timestamp of this sending as the time when congestion occurred for the corresponding priority of the packet. Upon receiving the packet, the receiver generates a CNP packet and sends it back. The switching chip recognizes the CNP packet, forwards it to the sender, and simultaneously sends it to the processor. The processor records the timestamp of this sending as the arrival time of the CNP packet for that priority. Meanwhile, the switching chip continuously monitors the queue buffer status for that priority. When it detects that the egress port congestion has been cleared, it triggers a buffer event report to the processor, which records the timestamp of this report as the time when the sender slows down for that priority. Finally, the processor calculates the buffer capacity required for a given priority from the triggering of the ECN flag to the completion of the sender's rate reduction, based on the congestion occurrence time, CNP packet arrival time, and sender-side rate reduction time. It then configures the PFC threshold for that priority on the ingress port of the switching chip based on the buffer capacity. This allows for dynamic adaptive adjustment of the PFC threshold according to actual link latency without relying on high-performance hardware, effectively preventing PFC deadlock.
[0034] The following section provides a detailed introduction to the deadlock prevention methods implemented by network devices.
[0035] Please refer to Figure 3 , Figure 3 A flowchart illustrating an anti-deadlock method provided in an embodiment of this application is shown. This anti-deadlock method is applied to… Figure 2 The network device in the middle may include the following steps: S101, the ingress port of the switching chip receives the message to be forwarded, determines that the message to be forwarded supports Explicit Congestion Notification (ECN), and assigns a preset type identifier to the message to be forwarded. S102, when the switching chip detects that the output port corresponding to the packet to be forwarded is congested, it triggers the ECN marking of the packet to be forwarded. After confirming that the packet to be forwarded is a marked packet, it forwards the packet to the receiving end and sends it to the processor at the same time. S103, the processor records and sends the timestamp as the time when congestion occurred for the priority of the packet to be forwarded; S104, the switching chip identifies the corresponding Congestion Notification Message (CNP) returned by the receiving end, forwards the CNP message to the sending end, and simultaneously sends it to the processor; S105, the processor records the arrival time of CNP messages with the priority of uploading timestamp; S106, when the switching chip detects that the congestion at the output port has been cleared, it triggers a report cache event to the processor; S107, the processor records the time when the sending end slows down with the reporting timestamp as the priority; S108, the processor calculates the buffer capacity required from the triggering of the ECN flag to the completion of the sender's rate reduction based on the congestion occurrence time, the arrival time of the CNP message, and the rate reduction time of the sender, and configures the priority-based flow control (PFC) threshold for the ingress port in the switching chip based on the buffer capacity.
[0036] In this embodiment, the processor pre-configures an ECN threshold and an initial PFC threshold for the switching chip. For example, the ECN threshold is configured as 20% of the queue buffer capacity, and the initial PFC threshold can be configured based on the ECN threshold, such as 60% of the queue buffer capacity, or it can be set empirically, such as 50% to 70% of the queue buffer capacity. By configuring the initial PFC threshold, sufficient margin is ensured between ECN and PFC to avoid triggering PFC backpressure at the initial congestion stage.
[0037] It should be noted that the initial PFC threshold is a temporary threshold. Once the switching chip completes the first congestion detection and triggers ECN marking, it will update the PFC threshold by executing the steps S101~S108 described above. Subsequently, whenever the network traffic model or link latency changes—for example, if a path experiences increased round-trip latency due to route switching, or if the receiver response slows down—a new congestion event will be triggered, initiating a new round of PFC threshold updates. This allows for dynamic adaptive adjustment of the PFC threshold based on actual link latency without relying on high-performance hardware, effectively preventing PFC deadlock.
[0038] In practical applications, when the ingress port of the switching chip receives a packet to be forwarded, it first determines whether the packet supports ECN. If it does, a preset type identifier is assigned to it. Optionally, on the ingress direction, ACL matching is used to identify whether the value of the lowest two bits of the ECN in the DSCP (Differentiated Services Code Point) field of the packet to be forwarded is 01 or 10 (i.e., the sender supports ECN). If so, it is determined that the packet to be forwarded supports ECN, and a preset CID is assigned to the packet to identify that the ECN field is in an unmarked state when the packet enters the network device.
[0039] When the switching chip detects congestion at the outgoing port corresponding to a packet to be forwarded (e.g., queue buffer usage reaches a preset ECN threshold), it triggers ECN marking of the packet. After confirming that the packet is marked, it forwards the packet to the receiving end and simultaneously sends it to the processor. Upon receiving the packet, the processor records the upload timestamp and uses it as the time of congestion occurrence for the packet's corresponding priority. This priority refers to the internal priority of the switching chip, mapped from the PRI field in the packet's VLAN tag or the first 6 bits of the packet's DSCP value. Based on this priority, the packet can be placed into the corresponding priority queue at the ingoing port.
[0040] Optionally, the switching chip can identify packets to be forwarded that have been marked with ECN through ACL matching. Specifically, firstly, in the inbound direction, packets with an ECN field value of 01 or 10 (i.e., the sender supports ECN) are identified through ACL matching. Then, in the outbound direction, packets to be forwarded whose ECN field value has changed to 11 are identified through ACL matching, and these packets carry a preset CID (which is carried in a register and does not change the original packet structure). This confirms that the packet to be forwarded belongs to a marked packet that was marked due to congestion within the network device.
[0041] Subsequently, the switching chip further identifies the CNP message returned by the receiving end, forwards the CNP message to the sending end, and simultaneously sends it to the processor. The processor records the sending timestamp as the arrival time of the CNP message of this priority. Optionally, the switching chip identifies the CNP message by parsing the offset position of the UDF. Specifically, in the outgoing port direction, for the payload part of the returned message, the opcode field in the BTH is located by the UDF. When the value of this field is 0x81, it is determined to be a CNP message.
[0042] Subsequently, the switching chip continuously monitors the congestion status and, upon detecting that the outgoing port congestion has been cleared, proactively triggers a buffer event report to the processor. The processor records the reporting timestamp as the sender's rate reduction moment for that priority. Optionally, the switching chip can determine whether port congestion has been cleared by detecting whether the outgoing port queue's buffer occupancy rate has dropped to a preset low-water threshold. A value below the preset low-water threshold indicates that the queue buffer has begun to empty. The preset low-water threshold is lower than the ECN threshold, for example, configured as 1% to 5% of the queue buffer capacity. These values are merely examples and can be flexibly configured according to specific circumstances. The sender's rate reduction moment is not estimated based on experience but is based on the start of queue buffer emptying, indicating that the sender has responded to the CNP message and reduced its packet transmission rate.
[0043] Next, the processor calculates the required buffer capacity for the corresponding priority from the triggering of the ECN marker to the completion of the sender's rate reduction, based on the congestion occurrence time, CNP message arrival time, and sender's rate reduction time for the same priority. Based on this buffer capacity, the processor configures the PFC threshold for that priority on the ingress port of the switching chip. Optionally, the difference between the CNP message arrival time and the congestion occurrence time is first calculated to obtain the congestion notification delay from the triggering of the ECN marker to the return of the CNP message. Then, the difference between the sender's rate reduction time and the CNP message arrival time is calculated to obtain the congestion convergence delay from the return of the CNP message to the completion of the sender's rate reduction. Adding these two delays yields the total delay from the triggering of the ECN marker to the completion of the sender's rate reduction. Based on this, the total delay is multiplied by the current rate of the corresponding ingress port to obtain the required buffer capacity for the corresponding priority of the ingress port under this link condition.
[0044] Finally, the processor configures the cache capacity to the PFC pause threshold XOFF for the corresponding priority of the ingress port, and further derives the PFC recovery threshold XON by combining the hysteresis, thereby completing the PFC threshold configuration for the corresponding priority of the ingress port in the switching chip.
[0045] Through the above process, the PFC threshold is no longer a static constant detached from actual link characteristics, but a dynamic parameter that adaptively adjusts with each congestion event. Specifically, when network link latency increases, the total latency increases, and XOFF also increases accordingly, leaving more buffer space for ECN responses and avoiding premature PFC backpressure triggering. Conversely, when network link latency decreases, XOFF decreases, reducing invalid buffer reservations and improving queue resource utilization efficiency. The entire process does not require neural network modeling, does not rely on GPUs or AI acceleration chips, and only calls upon the existing ACLs, UDFs, and buffer events of the switching chip, combined with the processor's timestamp recording and arithmetic operations, to run stably on general-purpose RoCE network devices.
[0046] In one possible implementation, the process of the switching chip determining that the packet to be forwarded is a marked packet in step S102 may include: S1011, the switching chip identifies the packet to be forwarded as a marked packet when it recognizes that the packet to be forwarded contains a congestion mark and carries a preset type identifier.
[0047] In this embodiment, as can be seen from the foregoing, when the ingress port of the switching chip receives a packet to be forwarded, the switching chip uses ACL to match packets whose ECN field is enabled but not marked when entering the device. Specifically, it identifies packets whose ECN field value is 01 or 10 in the IP header or transport layer header and adds a preset CID to the packet. This operation does not change the packet content, but only marks the packet in the internal data path of the switching chip to identify packets that support ECN and are not congested when entering the network device.
[0048] In this way, on the outgoing port side, the switching chip can identify packets to be forwarded that carry the aforementioned preset CID and include a congestion flag (i.e., the ECN field value changes from 01 or 10 to 11) by calling the ACL function again, thus determining that the packet to be forwarded is a flagged packet. Since the ECN field changing from 01 or 10 to 11 can only occur after the switching chip detects queue congestion and performs ECN marking, a packet that simultaneously meets the two conditions of carrying the preset CID and having an ECN field value of 11 can be identified as a packet that has been ECN-marked due to congestion within the network device.
[0049] After determining that the packet to be forwarded is a tagged packet, the network device not only forwards the packet to the receiving end, but also sends the packet to the processor. The processor records the sending timestamp as the time when the congestion occurred for the priority of the packet to be forwarded.
[0050] In practical applications, within RoCE networks, traffic of the same priority may be forwarded simultaneously to different receivers via multiple outgoing ports. The link delay, round-trip time, and congestion response characteristics of each path may differ. If all packets to be forwarded corresponding to a given priority are recorded with a single congestion occurrence time, subsequent CNP packets will not be able to accurately match the corresponding congestion occurrence time. For example, a CNP packet triggered by a packet to be forwarded from outgoing port A may arrive at an alternating time with a CNP packet triggered by a packet to be forwarded from outgoing port B. Without a clear attribution identifier, the processor will be unable to determine which congestion occurrence time corresponds to which CNP packet arrival time.
[0051] Therefore, in Figure 3 Based on this, please refer to Figure 4 After the processor records the time of congestion occurrence corresponding to the priority of the message to be forwarded in step S102, the deadlock prevention method provided in this application embodiment further includes step S10A.
[0052] S10A: The processor generates a unique index based on the source IP address, destination IP address, ingress port identifier, egress port identifier, and priority of the packet to be forwarded, and stores the unique index in association with the time when congestion occurs.
[0053] In this embodiment, after the processor records the upload timestamp of the packet to be forwarded as the time of congestion, it synchronously extracts the source IP address, destination IP address, ingress port identifier, egress port identifier and priority of the packet to be forwarded, and combines these five pieces of information to generate a unique index.
[0054] Subsequently, the processor associates the unique index with the time of congestion and stores it in a soft table. This soft table uses five conditions as indexes: source IP address, destination IP address, ingress port identifier, egress port identifier, and priority. When faced with a scenario where traffic with the same ingress port and the same priority is forwarded to different receivers via multiple egress ports, the processor can accurately distinguish the egress port of the returned CNP packet and thus find the corresponding time of congestion.
[0055] It should be noted that the ingress port identifier and egress port identifier are numbers used internally by the switching chip to distinguish physical or logical exits, not port numbers carried by the packet itself. The priority corresponds to eight priorities from 0 to 7 as defined in the IEEE 802.1Qbb standard, and is mapped from the PRI field in the VLAN tag of the packet to be forwarded or the DSCP field of the packet to be forwarded.
[0056] Furthermore, if multiple egress ports simultaneously forward traffic with the same ingress port and priority, the software table will store multiple data records, with one data record corresponding to one egress port. For example, if a sender sends traffic with the same ingress port priority 3 to two different receivers, which are forwarded via egress port 1 and egress port 5 respectively, the software table will store two data records, each corresponding to a different IP address pair and egress port combination, without affecting each other. In this way, the congestion response latency of each link can be calculated independently, avoiding the problem of inaccurate PFC threshold calculation.
[0057] In one possible implementation, the process of the switching chip identifying the CNP message returned by the receiving end in step S104 may include: S1041, the switching chip parses the payload of the message returned by the receiving end at the output port by the offset position of the user-defined field. If the value of the opcode field in the basic transmission header of the payload is a set value, then the returned message is identified as a CNP message.
[0058] In this embodiment, the process of the switching chip identifying the CNP packet returned by the receiving end relies on the UDF parsing capability supported by the switching chip itself. Specifically, the switching chip identifies the CNP packet through ACL in the outgoing port direction. At this time, it does not rely on the network layer or transport layer header of the packet, but parses the payload part of the packet. It locates the opcode field in BTH through the UDF function. The opcode field is located inside the UDP payload specified by the RoCEv2 protocol and is a fixed part of the BTH structure. When the value of this field is hexadecimal 0x81, it strictly corresponds to the CNP packet type. Therefore, for the packet returned by the receiving end, once the switching chip detects that the value of the Opcode field in the BTH header of the packet's payload is 0x81, it determines that the packet is a CNP packet. The switching chip forwards it to the sending end and simultaneously sends it to the processor. The processor records the arrival time of the CNP packet with the priority of the sending timestamp.
[0059] In practical applications, in RoCE networks, CNP packets themselves do not carry the complete context information of their original triggering packets, but only implicitly contain clues about the reverse path. If the processor only matches the source IP address and destination IP address of the CNP packet itself, it is easy to confuse congestion events of different service flows, different outgoing ports, or even different priorities. For example, when a server sends priority 3 traffic to two receivers at the same time, after entering the network device from the same outgoing port, it is forwarded through outgoing port 2 and outgoing port 7 respectively. The two congestion triggering CNP packets may arrive at approximately the same time. If only IP address pairs are matched, it is impossible to distinguish which CNP packet corresponds to which path's ECN tag event, resulting in incorrect calculated congestion notification delay.
[0060] Therefore, please refer to again Figure 4 After the arrival time of the CNP message with the priority of uploading timestamp is recorded in the processor in step S105, the deadlock prevention method provided in this application embodiment further includes steps S10B to S10C.
[0061] S10B, the processor parses the source IP address, destination IP address, ingress port identifier, egress port identifier, and priority of the CNP packet; In the S10C, the processor matches a pre-stored unique index based on the source IP address, destination IP address, ingress port identifier, egress port identifier, and priority of the CNP packet, and associates the arrival time of the CNP packet with the unique index.
[0062] In this embodiment, after recording the upload timestamp of the CNP packet as the arrival time of the CNP packet, the processor synchronously parses the source IP address, destination IP address, ingress port identifier, egress port identifier, and priority carried in the CNP packet. These five parameters together constitute a query condition, which is compared item by item with the unique index pre-stored in the aforementioned software table. Only when the source IP address, destination IP address, ingress port identifier, egress port identifier, and priority fields of the CNP packet are completely consistent with the corresponding fields of a record in the software table is it considered a successful match. Once a match is successful, the processor establishes a binding relationship between the arrival time of the currently recorded CNP packet and the congestion occurrence time associated with this record.
[0063] In this way, each CNP message is bound to the corresponding congestion occurrence time, ensuring that the congestion notification delay calculated subsequently can truly reflect the end-to-end transmission delay on a specific path from triggering the ECN mark to receiving the CNP message.
[0064] In one possible implementation, the process of the switching chip triggering a report of a cached event to the processor when it detects that the congestion at the output port has been cleared in step S106 may include: S1061 When the switching chip detects that the buffer occupancy rate of the outgoing port queue has dropped to a preset low waterline threshold, it determines that the outgoing port congestion has been relieved and triggers a report of the buffer event to the processor.
[0065] In this embodiment, after receiving the CNP message returned by the receiving end and forwarding the CNP message to the sending end, the switching chip detects in real time whether the port congestion has been relieved. Once the congestion is detected to be relieved, it triggers the reporting of the cached event to the processor.
[0066] Optionally, the switching chip can detect whether port congestion has been relieved in real time by calling its own supported buffer events. In practical applications, the processor pre-configures a preset low watermark threshold for each outgoing port queue to determine whether congestion has been relieved. The preset low watermark threshold is lower than the aforementioned ECN threshold, but higher than the normal idle state of the queue. For example, it is set to 1% to 5% of the total buffer capacity of the queue. Once the switching chip detects that the buffer occupancy rate of the outgoing port queue has continued to drop to the preset low watermark threshold, it determines that the current sending end has started to slow down, the outgoing port congestion has been relieved, and triggers the reporting of buffer events to the processor.
[0067] It should be noted that the switching chip triggers the reporting of buffer events not when the buffer occupancy rate of the outgoing port queue reaches the preset low watermark threshold, but when the buffer occupancy rate of the outgoing port queue shows a continuous downward trend until it reaches the preset low watermark threshold, thereby ensuring that the detected congestion has been accurately and reliably resolved.
[0068] In one possible implementation, step S108, where the processor calculates the required buffer capacity from the triggering of the ECN flag to the completion of the sender's deceleration based on the congestion occurrence time, the CNP packet arrival time, and the sender's deceleration time, may include: S1081, calculate the difference between the arrival time of the CNP message and the time of congestion to obtain the congestion notification delay from the triggering of the ECN flag to the receipt of the CNP message; S1082, calculate the difference between the time when the sender slows down and the time when the CNP message arrives, and obtain the congestion convergence delay from the receipt of the CNP message to the time when the sender completes the slowdown. S1083, calculate the sum of congestion notification delay and congestion convergence delay to obtain the total delay from triggering ECN marking to the sending end completing the deceleration; S1084 calculates the product of the total latency and the rate of the pre-acquired ingress port to obtain the buffer capacity.
[0069] In this embodiment, after the message to be forwarded is sent, it needs to be transmitted to the receiving end via the network, the receiving end generates a CNP message, the CNP message is returned to the network device, and finally forwarded to the sending end via the network device. The sending end completes internal scheduling and reduces the packet sending rate. During this period, the sending end is still continuously sending traffic. If the PFC threshold is set too low, this part of the delayed traffic will quickly fill the switching chip queue, causing PFC to be falsely triggered, or even causing deadlock in multi-path scenarios.
[0070] Based on this, this embodiment calculates the buffer capacity required for a given priority from the triggering of the ECN flag to the completion of the sender's rate reduction, according to the congestion occurrence time, CNP message arrival time, and sender's rate reduction time for the same priority. Based on this buffer capacity, the PFC threshold of the ingress port of the switching chip for that priority is configured, thereby dynamically and adaptively adjusting the PFC threshold according to the actual link delay. This prevents PFC deadlock due to insufficient reservation and avoids waste of buffer resources due to excessive reservation.
[0071] Assuming congestion occurs at time T1, the CNP message arrives at time T2, and the sender slows down at time T4, during the processor's calculation of the required buffer capacity based on the congestion occurrence time, CNP message arrival time, and sender slowdown time for the same priority, firstly, the difference between the CNP message arrival time T2 and the congestion occurrence time T1 is calculated to obtain the congestion notification delay T3 = T2 - T1 from triggering the ECN flag to receiving the CNP message for that priority. This delay reflects the time consumed by the message's round-trip transmission in the network and the receiver's response. Then, the difference between the sender slowdown time T4 and the CNP message arrival time T2 is calculated to obtain the congestion convergence delay T5 = T4 - T2 from receiving the CNP message to the sender completing the slowdown for that priority. This delay reflects the processing time required for the CNP message to take effect within the sender. Finally, by adding the congestion notification delay T3 and the congestion convergence delay T5, we can obtain the total delay T = T3 + T5 from the triggering of the ECN flag to the completion of the rate reduction at the sending end for this priority.
[0072] After calculating the total delay T from triggering the ECN tag to the sender completing the rate reduction, the processor multiplies the total delay T by the pre-acquired ingress port rate to obtain the buffer capacity required for the corresponding priority during the period from triggering the ECN tag to the sender completing the rate reduction. Here, the ingress port rate refers to the actual physical port bandwidth of the network device for the corresponding priority, such as 100Gbps, 200Gbps, etc., which can be obtained from port negotiation status or configuration information. The buffer capacity refers to the total amount of traffic continuously transmitted at the current ingress port rate that has not been processed within the entire time window from triggering the ECN tag to the sender actually reducing the rate. In other words, it is the minimum safe buffer space that the switching chip queue must reserve for the corresponding priority. This space is not used to carry normal forwarding traffic but is dedicated to processing traffic entering during the ECN response period to prevent premature PFC intervention.
[0073] In practical applications, in RoCE networks, traffic with the same ingress port and the same priority may be distributed to multiple egress ports and forwarded to different receivers. The physical distance, number of intermediate nodes, and link load status of each path may be different. For example, the arrival time T2 of an ECN tag message with priority 3 on the same ingress port may be different if it is sent from egress port 3 and egress port 8 of the network device. If only one of the CNP message arrival times is taken and the congestion occurrence time is subtracted, the resulting congestion notification delay T3 will only represent the characteristics of a single path and cannot cover the maximum response requirements of all possible paths under the corresponding priority.
[0074] Therefore, when there are multiple CNP message arrival times, the process of calculating the difference between the CNP message arrival time and the congestion occurrence time in sub-step S1081 to obtain the congestion notification delay from triggering the ECN mark to receiving the CNP message may include: calculating the difference between the CNP message arrival time and each congestion occurrence time, and taking the maximum value among all differences as the congestion notification delay.
[0075] Accordingly, the process of calculating the difference between the sending end's deceleration time and the arrival time of the CNP message in sub-step S1082 to obtain the congestion convergence delay from receiving the CNP message to the sending end completing the deceleration can include: calculating the difference between the sending end's deceleration time and the arrival time of each CNP message, and taking the maximum value among all differences as the congestion convergence delay.
[0076] In this embodiment, when there are multiple CNP message arrival times, the processor iterates through all recorded congestion occurrence times T1 belonging to the same ingress port and priority in the software table for each CNP message arrival time T2, calculates the difference T2-T1 for each, and selects the maximum value among all differences as the final congestion notification delay T3. Similarly, when calculating the congestion convergence delay, for each CNP message arrival time T2, the processor calculates the difference T4-T2 between it and the sender's deceleration time T4, and takes the maximum value among all differences as the final congestion convergence delay. This ensures that the final calculated total delay T=T3+T5 can cover the slowest path among all concurrent paths, avoiding PFC false triggering due to a path not being covered.
[0077] In one possible implementation, the PFC threshold includes a PFC recovery threshold and a PFC pause threshold. Step S108, where the processor configures the priority of the ingress port in the switching chip based on cache capacity, for priority-based flow control of the PFC threshold, may include: S1085, the processor configures the cache capacity to the PFC pause threshold value of the ingress port priority; S1086, the processor configures the difference between the PFC pause threshold and the preset hysteresis as the PFC recovery threshold for the ingress port priority.
[0078] In this embodiment, the PFC pause threshold (XOFF) is used to send a backpressure frame to the upstream device when the queue buffer reaches this value, forcibly pausing the injection of traffic of the corresponding priority; the PFC recovery threshold (XON) is used to withdraw the backpressure and resume traffic forwarding when the buffer is emptied to below this value. If the two are configured improperly, for example, if XON and XOFF are too close, it will cause the queue to oscillate repeatedly in the critical range, frequently triggering PFC start and stop; if XON is set too high, a large amount of buffer may remain after the backpressure is withdrawn, resulting in idle resources.
[0079] Optionally, the PFC pause threshold (XOFF) is configured as the buffer capacity calculated above. The buffer capacity represents the maximum number of bytes that traffic of the corresponding priority will be continuously injected and must be accommodated by the switching chip queue from the time the ECN flag is triggered until the sender completes the rate reduction. The PFC pause threshold (XOFF) is higher than the ECN threshold and can accommodate all the lagging traffic, ensuring that the queue will not be forced to start PFC due to overflow before the sender completes the rate reduction.
[0080] Based on this, the PFC pause threshold (XOFF) is subtracted from the preset hysteresis to obtain the PFC recovery threshold (XON). The preset hysteresis can be a manually configured fixed offset, such as 5% of the total queue capacity. Its purpose is to prevent the PFC state from fluctuating between XON and XOFF. That is, when the queue buffer drops below XOFF due to the sender's speed reduction, the backpressure is not immediately released. Instead, it continues to wait for the buffer to be further emptied below XON before issuing a recovery signal, preventing frequent starts and stops due to small buffer fluctuations.
[0081] like Figure 5 As shown, in a practical application scenario, assuming the RoCE network includes a sender, switch 1, switch 2, and a receiver, firstly, when congestion occurs in a queue corresponding to a certain priority, switch 1 triggers an ECN marking. After determining that the packet to be forwarded is a marked packet through ACL matching, it records the congestion occurrence time T1 and simultaneously sends the packet to be forwarded to switch 2. Then, switch 2 continues to send the packet to be forwarded to the receiver. After receiving the packet, the receiver generates a CNP packet and returns it to switch 2. Switch 2 then returns the CNP packet to switch 1. Subsequently, after receiving the CNP packet, switch 1 records the arrival time T2 of the CNP packet and sends the CNP packet to the sender. The sender begins to reduce its speed after receiving the CNP packet. Switch 1 detects link congestion and triggers a buffer. The event indicates that the sender has started to slow down, and the time of slowdown is recorded as T4. Then, based on the congestion occurrence time T1, the CNP packet arrival time T2, and the sender slowdown time T4, switch 1 calculates the buffer capacity required from the triggering of the ECN flag to the completion of the slowdown by the sender, and then configures the PFC threshold of the corresponding priority of the ingress port based on the buffer capacity.
[0082] It should be noted that each priority level can be configured with a PFC threshold according to the above process. Furthermore, as the traffic model and link latency in the network environment change in real time, each change will trigger a new round of PFC threshold configuration, thereby enabling the PFC threshold to continuously and adaptively adjust with the network environment.
[0083] Compared with the prior art, the deadlock prevention method provided in this application has the following advantages: First, by using time-series decoupling, the total latency from triggering the ECN flag to the sending end completing the speed reduction is accurately measured. The total latency and the current rate of the corresponding ingress port are then converted into buffer space to dynamically determine the PFC threshold. This reduces the use of PFC before the network card speeds up, thus avoiding the PFC deadlock problem caused by time lag at its source.
[0084] Secondly, in real network environments, due to different traffic models, link latency is constantly changing. When the latency in the link increases, network devices will automatically lengthen the buffer between ECN and PFC to prevent PFC from being frequently triggered due to slow feedback from the sending end. When the latency decreases, the buffer between ECN and PFC will also be reduced. It can even be linked with queue cache configuration to reduce the size of the queue cache and release the cache to other queues that need it, thereby making fuller use of the cache and improving throughput.
[0085] Third, most current network devices, without AI and high-performance GPUs, achieve their goals through existing chip functions (ACL matching, buffer events, etc.) and simple CPU intervention (creating soft tables, time calculations, etc.), without the need to deploy complex computing models such as neural networks, making them highly practical and feasible.
[0086] Fourth, it can be used in most RoCE environments, especially in stable lossless environments. Since the traffic congestion status is different in different environments and at different times, users only need to configure the ECN threshold, and the configuration of the PFC threshold is determined by the traffic model in the environment, thereby ensuring that deadlocks are reduced and the number of packet losses is reduced.
[0087] Please refer to Figure 6 , Figure 6 This diagram illustrates a block illustration of a network device 10 provided in an embodiment of this application. The node device 10 includes a processor 11, a memory 12, a switching chip 13, and a communication module 14. These components are electrically connected directly or indirectly to each other to achieve data transmission or interaction. For example, these components can be electrically connected to each other via one or more communication buses or signal lines. The processor 11 is responsible for control and management, the switching chip 13 is responsible for high-speed data exchange, the memory 12 is responsible for storing instructions and data, and the communication module 14 is responsible for sending and receiving network packets.
[0088] The memory 12 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.
[0089] Processor 11 may be an integrated circuit chip with signal processing capabilities. The aforementioned processor 11 may be a general-purpose processor, including a central processing unit (CPU), a microcontroller unit (MCU), a complex programmable logic device (CPLD), a field programmable gate array (FPGA), an embedded ARM chip, etc.
[0090] Switching chip 13 is an integrated circuit chip with high-speed data packet switching and processing capabilities. The aforementioned switching chip 13 can be a dedicated switching chip, including Ethernet switch chips, router switch chips, programmable switch chips, network processor units (NPUs) with integrated switching functions, and system-on-a-chip (SoCs), etc.
[0091] The switching chip 13 is used to assign a preset type identifier to the packet to be forwarded when it receives the packet to be forwarded at the ingress port and determines that the packet to be forwarded supports explicit congestion notification (ECN). The switching chip 13 is also used to trigger ECN marking of the packet to be forwarded when congestion is detected at the output port corresponding to the packet to be forwarded. After determining that the packet to be forwarded is a marked packet, the packet to be forwarded is forwarded to the receiving end and sent to the processor at the same time. Processor 11 is used to record the time of congestion occurrence when the timestamp of the uploaded message corresponds to the priority of the message to be forwarded; The switching chip 13 is also used to identify the corresponding Congestion Notification Message (CNP) returned by the receiving end, forward the CNP message to the sending end, and send it to the processor at the same time. Processor 11 is also used to record the arrival time of CNP messages with upload timestamp as the priority; The switching chip 13 is also used to trigger a reported cache event to the processor when the congestion at the output port is detected to be cleared; Processor 11 is also used to record the time when the sending end slows down when the reporting timestamp is prioritized; The processor 11 is also used to calculate the buffer capacity required from the triggering of the ECN tag to the completion of the sender's deceleration based on the congestion occurrence time, the arrival time of the CNP message and the deceleration time of the sender, and to configure the priority-based flow control (PFC) threshold of the ingress port in the switching chip based on the buffer capacity.
[0092] Optionally, the processor is specifically configured to: calculate the difference between the arrival time of the CNP message and the time of congestion occurrence to obtain the congestion notification delay from the triggering of the ECN tag to the receipt of the CNP message; calculate the difference between the time of the sender's deceleration and the arrival time of the CNP message to obtain the congestion convergence delay from the receipt of the CNP message to the sender's completion of deceleration; calculate the sum of the congestion notification delay and the congestion convergence delay to obtain the total delay from the triggering of the ECN tag to the sender's completion of deceleration; and calculate the product of the total delay and the pre-acquired ingress port rate to obtain the buffer capacity.
[0093] In summary, the deadlock prevention method and network device provided in this application firstly involve the switching chip's ingress port receiving a packet to be forwarded. If the packet supports ECN, a preset type identifier is assigned to it. Simultaneously, when congestion is detected at the egress port corresponding to the packet, ECN marking of the packet is triggered. After confirming the packet is marked, it is forwarded to the receiving end and simultaneously sent to the processor. The processor records the timestamp of the sent packet as the time of congestion occurrence corresponding to the priority of the packet. Then, when the network device recognizes a CNP packet returned by the receiving end, it forwards the CNP packet to the sending end and simultaneously sends it to the processor. The processor records... The timestamp sent is the arrival time of the CNP packet of this priority. Afterwards, when the switching chip detects that the congestion at the outgoing port has been cleared, it triggers a reporting buffer event to the processor. The processor records the reporting timestamp as the time when the sender slows down for this priority. Finally, the processor calculates the buffer capacity required for this priority from the triggering of the ECN flag to the completion of the sender's slowdown based on the congestion occurrence time, the arrival time of the CNP packet, and the time when the sender slows down for the same priority. Based on this buffer capacity, the processor configures the PFC threshold for this priority at the incoming port of the switching chip. This allows the PFC threshold to be dynamically and adaptively adjusted according to the actual link delay without relying on high-performance hardware, effectively avoiding PFC deadlock.
[0094] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A method for preventing deadlock, characterized in that, Applied to a network device, the network device including a processor and a switching chip, the method includes: The ingress port of the switching chip receives the packet to be forwarded, determines that the packet to be forwarded supports Explicit Congestion Notification (ECN), and assigns a preset type identifier to the packet to be forwarded. When the switching chip detects congestion at the output port corresponding to the packet to be forwarded, it triggers ECN marking on the packet to be forwarded. After determining that the packet to be forwarded is a marked packet, it forwards the packet to the receiving end and simultaneously sends it to the processor. The processor records and sends up a timestamp that corresponds to the time when congestion occurred for the priority of the message to be forwarded; The switching chip identifies the corresponding Congestion Notification Message (CNP) returned by the receiving end, forwards the CNP message to the sending end, and simultaneously sends it to the processor; The processor records the timestamp of the CNP message of the specified priority as the arrival time. When the switching chip detects that the congestion at the output port has been cleared, it triggers a report cache event to the processor. The processor records the reporting timestamp as the moment when the sending end of the priority is slowed down; The processor calculates the buffer capacity required for the priority from the triggering of the ECN flag to the completion of the rate reduction by the sender based on the congestion occurrence time, the arrival time of the CNP message, and the rate reduction time of the sender, and configures the priority-based flow control (PFC) threshold of the priority of the ingress port in the switching chip based on the buffer capacity.
2. The anti-deadlock method as described in claim 1, characterized in that, The step of determining that the message to be forwarded is a marked message includes: The switching chip identifies the packet to be forwarded as a marked packet by recognizing that the packet to be forwarded includes a congestion flag and carries the preset type identifier at the output port.
3. The anti-deadlock method as described in claim 1, characterized in that, The switching chip identifies the Congestion Notification Message (CNP) returned by the receiving end, including: The switching chip parses the payload of the message returned by the receiving end at the output port by using the offset position of the user-defined field. If the value of the opcode field in the basic transport header of the payload is a set value, then the returned message is identified as the CNP message.
4. The anti-deadlock method as described in claim 1, characterized in that, After the processor records the time of congestion occurrence corresponding to the priority of the packet to be forwarded, with the timestamp sent, the method further includes: The processor generates a unique index based on the source IP address, destination IP address, ingress port identifier, egress port identifier, and priority of the packet to be forwarded, and stores the unique index in association with the time when the congestion occurred.
5. The anti-deadlock method as described in claim 4, characterized in that, After the processor records the arrival time of the CNP message with the timestamp of the specified priority, the method further includes: The processor parses the source IP address, destination IP address, ingress port identifier, egress port identifier, and priority of the CNP packet; The processor matches the pre-stored unique index based on the source IP address, destination IP address, ingress port identifier, egress port identifier, and priority of the CNP packet, and associates the arrival time of the CNP packet with the unique index.
6. The anti-deadlock method as described in claim 1, characterized in that, The processor calculates the buffer capacity required for the priority from the triggering of the ECN flag to the completion of the sender's rate reduction based on the congestion occurrence time, the CNP packet arrival time, and the sender's rate reduction time, including: Calculate the difference between the arrival time of the CNP message and the time of congestion occurrence to obtain the congestion notification delay from the triggering of the ECN flag to the receipt of the CNP message; Calculate the difference between the time when the sending end slows down and the time when the CNP message arrives to obtain the congestion convergence delay from the time the priority is received to the time when the sending end completes the slowdown. Calculate the sum of the congestion notification delay and the congestion convergence delay to obtain the total delay from the triggering of the ECN flag to the completion of the rate reduction by the sending end; The buffer capacity is obtained by multiplying the total latency by the pre-acquired rate of the ingress port.
7. The anti-deadlock method as described in claim 6, characterized in that, The CNP message arrival times are multiple; The step of calculating the difference between the arrival time of the CNP message and the time of congestion occurrence to obtain the congestion notification delay from triggering the ECN flag to receiving the CNP message includes: Calculate the difference between the arrival time of the CNP message and the time of each congestion occurrence, and take the maximum value among all the differences as the congestion notification delay; The step of calculating the difference between the time when the sender slows down and the time when the CNP message arrives, to obtain the congestion convergence delay from receiving the CNP message to the time when the sender completes the slowdown, includes: Calculate the difference between the time when the sending end slows down and the arrival time of each CNP message, and take the maximum value among all the differences as the congestion convergence delay.
8. The anti-deadlock method as described in claim 1, characterized in that, The PFC threshold includes the PFC recovery threshold and the PFC pause threshold; The processor configures the priority-based flow control (PFC) threshold for the ingress port based on the cache capacity, including: The processor configures the cache capacity to the PFC pause threshold value of the priority of the ingress port; The processor configures the difference between the PFC pause threshold and the preset hysteresis as the PFC recovery threshold for the priority of the ingress port.
9. A network device, characterized in that, The network device includes a processor and a switching chip; The switching chip is used to assign a preset type identifier to the packet to be forwarded when it receives the packet to be forwarded at the ingress port and determines that the packet to be forwarded supports explicit congestion notification (ECN). The switching chip is further configured to trigger ECN marking of the packet to be forwarded when congestion is detected at the output port corresponding to the packet to be forwarded; after determining that the packet to be forwarded is a marked packet, forward the packet to be forwarded to the receiving end and simultaneously send it to the processor; the processor is configured to record the time when the congestion occurs with the timestamp corresponding to the priority of the packet to be forwarded. The switching chip is also used to identify the corresponding Congestion Notification Message (CNP) returned by the receiving end, forward the CNP message to the sending end, and simultaneously send it to the processor; the processor is also used to record the arrival time of the CNP message with the priority as the sending timestamp. The switching chip is further configured to trigger a reporting cache event to the processor when the congestion at the output port is detected to be resolved; the processor is further configured to record the time when the sending end with the reporting timestamp of the priority is slowed down. The processor is further configured to calculate the buffer capacity required for the priority from the triggering of the ECN flag to the completion of the rate reduction by the sender, based on the congestion occurrence time, the arrival time of the CNP message, and the rate reduction time of the sender, and configure the priority-based flow control (PFC) threshold of the priority of the ingress port in the switching chip based on the buffer capacity.
10. The network device as described in claim 9, characterized in that, The processor is specifically used to: calculate the difference between the arrival time of the CNP message and the time of congestion occurrence, and obtain the congestion notification delay from the triggering of the ECN flag to the receipt of the CNP message; Calculate the difference between the time when the sending end slows down and the time when the CNP message arrives to obtain the congestion convergence delay from the time the priority is received to the time when the sending end completes the slowdown. Calculate the sum of the congestion notification delay and the congestion convergence delay to obtain the total delay from the triggering of the ECN flag to the completion of the rate reduction by the sending end; The buffer capacity is obtained by multiplying the total latency by the pre-acquired rate of the ingress port.
