A message scheduling method and network chip
By recording the queue identification and scheduling level of the message queue in the cache memory of the network chip, the problem that the low-priority queue cannot be scheduled when it is about to be empty is solved, and more efficient message scheduling is achieved.
Patent Information
- Application Number
- CN202111143002.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-28
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2041-09-28
AI Technical Summary
In the prior art, when the high-priority message queue is about to be empty, the low-priority message queue cannot be scheduled, resulting in the problem of wasting scheduling resources.
By recording the queue identification and scheduling level of the message queue in the cache memory of the network chip, we can determine whether the message is insufficient based on the queue identification, and schedule the message according to the time interval of the scheduling level when it is insufficient, or directly schedule the message according to priority.
It effectively avoids the problem that low-priority queues cannot be scheduled when they are about to be empty, improves the efficiency of packet scheduling and avoids waste of resources.
Smart Images

Figure CN114217918B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of network chips, and in particular to a message scheduling method and a network chip. Background Art
[0002] With the explosive growth of network traffic, efficient traffic management is becoming increasingly important. In router chips, congestion management and congestion avoidance determine the quality and performance of network packet processing. Queue entry and exit control and scheduling are implemented by the traffic management module, which consists of a queue control module and a scheduling module. The scheduling module selects queues to be dequeued based on scheduling policies such as priority and weight, and transmits the results to the queue control module. The queue control module then reads queue information from external storage, calculates the number of packets in the queue, and determines whether the queue is empty. If the queue is not empty, it dequeues the packet. If the queue is empty, it discards the packet and initiates a queue status update to the scheduling module. This scheduling scheme has the following problems: the entire scheduling and status update process is lengthy. To maintain traffic output performance, it is generally pipelined. As a result, queue status updates are not timely, resulting in the scheduling module initiating a large number of schedules even when the queue is empty. In addition, an absolute priority mechanism is usually adopted during scheduling implementation, that is, lower-priority queues are only allowed to be scheduled when the higher-priority queue is empty. Therefore, when there are many priorities, the impact of the longer processing flow of the entire scheduling process will make this empty scheduling even worse. It will be difficult for low-priority queues to obtain scheduling opportunities, resulting in an exponential decline in performance.
[0003] Therefore, how to solve the scheduling waste problem caused by the inability to schedule low-priority queues when high-priority queues are about to be empty is one of the technical issues worth considering. Summary of the Invention
[0004] In view of this, the present application provides a message scheduling method and a network chip to solve the scheduling waste problem caused by the inability to schedule low-priority message queues when high-priority message queues are about to be empty.
[0005] Specifically, this application is implemented through the following technical solutions:
[0006] According to a first aspect of the present application, a message scheduling method is provided, which is applied to a network chip. The method includes:
[0007] After selecting at least one message queue, determining whether a queue identifier of each message queue in the at least one message queue is in a cache memory of the network chip, wherein the queue identifier recorded in the cache memory is recorded when there are insufficient messages in the corresponding message queue;
[0008] If so, extracting the scheduling level corresponding to the message queue from the cache memory based on the queue identifier of the message queue; and scheduling the messages in the message queue according to the scheduling time interval corresponding to the scheduling level;
[0009] If it does not exist, the messages in the message queue are sent according to the priority of the message queue.
[0010] According to a second aspect of the present application, a network chip is provided, comprising: a queue control module and a scheduling module, wherein the scheduling module is connected to the queue control module; wherein:
[0011] The scheduling module is configured to, after selecting at least one message queue, determine whether a queue identifier of each message queue in the at least one message queue is in a high-speed cache memory of the network chip, wherein the queue identifier recorded in the high-speed cache memory is recorded when there are insufficient messages in the corresponding message queue;
[0012] The scheduling module is further configured to, if the result of the determination is yes, extract the scheduling level corresponding to the message queue from the cache memory based on the queue identifier of the message queue; and control the queue scheduling module to schedule the messages in the message queue according to the scheduling time interval corresponding to the scheduling level;
[0013] The scheduling module is further configured to control the queue control module to send the messages in the message queue according to the priority of the message queue if the judgment result is that the message queue does not exist.
[0014] According to the third aspect of the present application, another network chip is provided, including a processor and a machine-readable storage medium, the machine-readable storage medium storing a computer program that can be executed by the processor, and the processor is prompted by the computer program to execute the method provided in the first aspect of the embodiment of the present application.
[0015] According to the fourth aspect of the present application, a machine-readable storage medium is provided, which stores a computer program. When called and executed by a processor, the computer program prompts the processor to execute the method provided in the first aspect of the embodiment of the present application.
[0016] Beneficial effects of the embodiments of the present application:
[0017] By monitoring the messages in each message queue and recording the message queues with insufficient messages in the message queue in the cache memory, when the message queue to be sent out is selected, the cache memory can be used to check whether there are sufficient messages in the message queue. If the queue identifier of the message queue is in the cache memory, indicating that there are insufficient messages in the message queue, the messages in the message queue are sent according to the scheduling time interval corresponding to the scheduling level of the queue identifier, thereby allowing messages in other message queues to be scheduled. This avoids the problem of messages in low-priority message queues not being able to be scheduled when high-priority messages are about to be empty. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 This is a schematic diagram of the effect of the current message scheduling with air conditioning.
[0019] Figure 2 This is a flow chart of a message scheduling method provided in an embodiment of the present application;
[0020] Figure 3 This is a schematic diagram of the structure of a network chip provided in an embodiment of the present application;
[0021] Figure 4 This is a scheduling logic diagram provided by an embodiment of the present application;
[0022] Figure 5 This is a hardware structure diagram of a network chip provided in an embodiment of the present application. DETAILED DESCRIPTION
[0023] Exemplary embodiments are described in detail herein, with examples illustrated in the accompanying drawings. When the following description refers to the drawings, identical numerals in different figures represent identical or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatuses and methods consistent with certain aspects of the present application.
[0024] The terms used in this application are for the purpose of describing specific embodiments only and are not intended to limit this application. The singular forms "a," "the," and "the" used in this application are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" as used herein refers to and includes any or all possible combinations of one or more of the corresponding listed items.
[0025] It should be understood that although the terms first, second, third, etc. may be used in this application to describe various information, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from each other. For example, without departing from the scope of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0026] The inventors found that in the current scheduling scheme, the high-priority message queue has a priority scheduling opportunity, but when it is about to be empty, the messages in the low-priority message queue cannot be scheduled. Figure 1 As shown, priority 0 is greater than priority 1, which is greater than priority 2. When the priority 0 message queue is empty, after several clock cycles, the message queue's status is updated to the scheduling module, and the scheduling request is converted from priority 0 to priority 1. It is then transmitted to the queue control module via a path of several clock cycles for dequeuing. During this process, the scheduling of the priority 0 message queue is invalid, and the low-priority message queue is in a waiting state. After the priority 2 message queue waits for the priority 1 message queue to be scheduled, a small number of priority 0 messages are queued. However, due to the long path delay between status updates and dequeue responses, a large number of scheduling cycles are still occupied, preventing the priority 2 message queue from obtaining a scheduling opportunity.
[0027] In view of this, the present application provides a message scheduling method, which is applied to a network chip. After selecting at least one message queue, the network chip determines whether the queue identifier of each message queue in the at least one message queue is in the cache memory of the network chip, and the queue identifier recorded in the cache memory is recorded when there are insufficient messages in the corresponding message queue; if it exists, based on the queue identifier of the message queue, the scheduling level corresponding to the message queue is extracted from the cache memory; and the messages in the message queue are scheduled according to the scheduling time interval corresponding to the scheduling level; if it does not exist, the messages in the message queue are sent according to the priority of the message queue. The present application monitors the messages in each message queue and then records the message queues with insufficient messages in the message queues into a cache memory. In this way, when a message queue to be sent is selected, it is possible to check from the cache memory whether there are sufficient messages in the message queue. If there is a queue identifier of the message queue in the cache memory, indicating that there are insufficient messages in the message queue, the messages in the message queue are sent according to the scheduling time interval corresponding to the scheduling level of the queue identifier, thereby allowing messages in other message queues to be scheduled, thereby avoiding the problem of messages in low-priority message queues not being able to be scheduled when high-priority messages are about to be empty.
[0028] The message scheduling method provided in this application is described in detail below.
[0029] See also Figure 2 , Figure 2 This is a flow chart of a message scheduling method provided by the present application, which may include the following steps:
[0030] S201. After selecting at least one message queue, determine whether the queue identifier of each message queue in the at least one message queue is in the cache memory of the network chip; if so, execute step S202; if not, execute step S203.
[0031] The queue identifier recorded in the cache memory is recorded when there are insufficient messages in the corresponding message queue.
[0032] In this step, the network chip can use existing queue election methods to select the message queue that can be dequeued. Because each message queue has an election weight, a high-priority message queue may be assigned a higher weight than a low-priority message queue. Therefore, each message queue has the possibility of being elected, but the probability of a high-priority message queue being elected is higher than that of a low-priority message queue, which also meets practical needs. Based on the above principles, it can be explained that when at least one message queue is elected as multiple message queues, it can include both high-priority message queues and low-priority message queues.
[0033] To prevent a situation where a high-priority message queue is about to become empty while a low-priority message queue cannot be scheduled, the present application proposes recording the correspondence between the queue ID and the scheduling level of message queues experiencing insufficient message capacity in a cache. The scheduling level is determined based on the degree of message shortage, with different levels of message shortage corresponding to different scheduling levels. Similarly, after selecting at least one message queue, for each message queue, a determination can be made as to whether the queue ID of the message queue is stored in the cache. If the queue ID of the queue is stored in the cache, step S202 is executed. If not, step S203 is executed.
[0034] S202: Based on the queue identifier of the message queue, extract the scheduling level corresponding to the message queue from the cache memory; and schedule the messages in the message queue according to the scheduling time interval corresponding to the scheduling level.
[0035] Specifically, when it is confirmed that the queue identifier of the message queue is in the cache, it indicates that there are insufficient messages in the message queue, and there may be a situation where the messages in the message queue are about to be empty. In order to avoid the messages in the message queue being quickly scheduled empty, the present application proposes setting a scheduling level for the message queue with insufficient messages based on the degree of message shortage and storing it in the cache. In this way, the scheduling level of the message queue can be extracted from the cache based on the queue identifier of the message queue, and then the messages in the message queue can be scheduled according to the scheduling time interval corresponding to the scheduling level. It should be noted that the scheduling time interval corresponding to the scheduling level is greater than the scheduling time interval of the message queue with sufficient messages. In this way, the scheduling speed of the messages in the message queue can be slowed down, thereby providing scheduling opportunities for other message queues.
[0036] S203: Send the messages in the message queue according to the priority of the message queue.
[0037] In this step, if the queue ID of the message queue is not in the cache, it indicates that the message queue has sufficient messages. In this case, scheduling is performed according to the priority of the message queue. Because the message queue has sufficient messages, the message queue will not be nearly empty, and thus scheduling resources will not be wasted.
[0038] use Figure 2 The method shown, by recording the queue identifier and scheduling level of the message queue with insufficient messages in the cache, can increase the scheduling time interval of messages in the message queue with insufficient messages, that is, slow down the message scheduling speed of the message queue with insufficient messages, so that the messages in the message queue with sufficient messages can be scheduled; in actual applications, the messages in the high-priority message queue are scheduled relatively quickly, which can be understood as belonging to the message queue with insufficient messages, while the message queue with sufficient messages is the low-priority message queue. In this way, when there are insufficient messages in the high-priority message queue, the scheduling speed of the messages in the high-priority message queue is slowed down, that is, the messages in the high-priority message queue are scheduled according to the scheduling time interval corresponding to the scheduling level of the high-priority message queue, so that the messages in the low-priority message queue can be scheduled, thereby solving the problem of wasting scheduling resources caused by the low-priority message queue being unable to be scheduled when the high-priority message queue is about to be empty. Similarly, when the messages in the low-priority message queue are about to be empty, the scheduling speed of the messages in the low-priority message queue can also be slowed down, so that the messages in the high-priority message queue can also be scheduled, which can also avoid wasting the scheduling resources of the network chip.
[0039] In one possible implementation, regardless of whether one or multiple message queues are selected, for each message queue, Figure 2 The process shown, that is, when multiple message queues are selected, there is no waiting between them. Furthermore, the determination process for each message queue can be executed in parallel or serially, depending on the specific situation. Based on this, different scheduling levels correspond to different delay lists. After determining the presence of the queue identifier for each message queue in the cache, determining the scheduling level of the message queue, and before scheduling messages in the message queue according to the scheduling interval corresponding to the scheduling level, the process may further include writing the queue identifier of the message queue into the delay list corresponding to the scheduling level.
[0040] Furthermore, the messages in the message queue can be scheduled according to the scheduling time interval corresponding to the scheduling level according to the following process: the queue identifier of the message queue is read from each delay list, and the messages in the queue messages corresponding to the read queue identifier are scheduled according to the scheduling time interval corresponding to the delay list.
[0041] Specifically, after determining the scheduling level of each message queue, the queue identifier of the message queue can be written into the delay linked list corresponding to the scheduling level, and different delay linked lists correspond to different scheduling time intervals. Therefore, after writing the queue identifier of the message queue into the delay linked list, the queue identifier can be read from the delay linked list, and then the messages in the message queue corresponding to the read queue identifier can be scheduled according to the scheduling time interval corresponding to the delay linked list. By writing the queue identifier into the delay linked list, it can be ensured that the process of determining the scheduling level of the message queue and the process of scheduling the messages in the message queue are independent of each other, thereby further improving the scheduling efficiency of the messages while avoiding the waste of scheduling resources.
[0042] In another possible implementation, when at least one selected message queue includes multiple message queues, the multiple message queues can participate in the judgment simultaneously, that is, judging whether the queue identifiers of the multiple message queues are all in the cache. If they are all in the cache, it indicates that there are insufficient messages in the above-mentioned multiple message queues. At this time, the scheduling level corresponding to each message queue can be confirmed, and then, for each message queue in the multiple message queues, the messages in the message queue are scheduled according to the scheduling time interval corresponding to the scheduling level of the message queue, that is, the messages in the respective message queues are scheduled according to the scheduling time interval corresponding to the respective scheduling level. It should be noted that the scheduling levels corresponding to the multiple message queues can be the same or different, and the specific determination should be based on actual conditions.
[0043] When the queue identifiers of the above-mentioned multiple message queues do not exist in the cache, it indicates that the above-mentioned multiple message queues have sufficient messages. At this time, the messages in the multiple message queues can be scheduled in descending order according to their respective message priorities. Since there are sufficient messages in the message queues, there will be no problem of wasting scheduling resources due to the message queue being about to be full, resulting in the messages in the low-priority message queue not being able to be scheduled.
[0044] When the queue identifiers of multiple message queues partially exist in the cache memory, step S202 can be executed according to the following process: based on the queue identifier of the target message queue, extracting the scheduling level corresponding to the target message queue from the cache memory; and scheduling the messages in the target message queue according to the scheduling time interval corresponding to the scheduling level; sending the messages in the high-priority message queue according to the priority of the message queue other than the target message queue in the at least one message queue; wherein the target message queue is the message queue in the at least one message queue whose corresponding queue identifier is in the cache memory.
[0045] Specifically, when it is determined that the queue identifiers of some message queues exist in the cache, indicating that there are insufficient messages in the above-mentioned message queues, the above-mentioned message queues are used as target message queues, and then the scheduling level of each target message queue is extracted from the cache respectively. At the same time, for the message queues other than the target message queue (message queues with sufficient messages) among the above-mentioned multiple message queues, the messages in these message queues are scheduled according to the message queue priority. In this way, when a high-priority message queue is about to be empty, the scheduling speed of the messages in the message queue can be slowed down, so that the messages in the low-priority message queues can be scheduled (the message queues other than the target message queue are scheduled according to their priority), thereby avoiding the waste of scheduling resources in the network chip. Similarly, when the messages in the low-priority message queue are about to be empty, the scheduling speed of the messages in the low-priority message queue can also be slowed down, so that the messages in the high-priority message queue can also be scheduled, which can also avoid wasting the scheduling resources of the network chip.
[0046] Furthermore, different scheduling levels correspond to different delay linked lists; on this basis, before scheduling the messages in the target message queue according to the scheduling time interval corresponding to the scheduling level, the following process is also included: the queue identifiers of each target message queue are written into the delay linked list corresponding to the scheduling level of the target queue identifier.
[0047] On this basis, the messages in the target message queue can be scheduled according to the scheduling time interval corresponding to the scheduling level: the queue ID of the message queue is read from each delay linked list, and the messages in the queue message corresponding to the read queue ID are scheduled according to the scheduling time interval corresponding to the delay linked list.
[0048] Specifically, after determining the scheduling level corresponding to the target message queue, the queue identifier of each target message queue can be written into the delay list corresponding to the corresponding scheduling level. Then, when the network chip needs to schedule a message, it can read the queue identifier from each delay list and schedule the message in the message queue corresponding to the queue identifier according to the scheduling interval corresponding to the delay list. This ensures that the process of determining the scheduling level of the message queue is independent of the process of scheduling messages in the message queue, further improving message scheduling efficiency while avoiding wasting scheduling resources.
[0049] Based on any of the above embodiments, the correspondence between the queue identifier and the scheduling level can be recorded in the cache according to the following method: for each message queue, the message depth of the message queue is calculated; the threshold range to which the message depth belongs is determined; and the scheduling level corresponding to the threshold range to which the message depth belongs and the queue identifier of the message queue are written into the cache memory.
[0050] Specifically, the present application can set n decreasing thresholds, which can correspond to n+1 threshold ranges. Accordingly, the scheduling level corresponding to the threshold range is set. The larger the endpoint value of the threshold range, the higher the scheduling level, and thus the smaller the corresponding scheduling time interval; conversely, the smaller the endpoint value of the threshold range, the smaller the scheduling level, and thus the larger the corresponding scheduling time interval. In this way, after determining the message depth of each message queue, the threshold range to which the message depth belongs can be confirmed, and then based on the correspondence between the threshold range and the scheduling level, the scheduling level corresponding to the message queue can be determined. For example, the present application sets three set thresholds TH0, TH1 and TH2, and TH0>TH1>TH2. Accordingly, there can be four threshold ranges, namely (0, TH2), (TH2, TH1), (TH1, TH0), (TH0, message queue length). Therefore, for each message queue, the message depth of the message queue can be determined, and then the threshold range to which the message depth belongs can be determined. If the threshold range is (TH0, message queue length), it indicates that the message queue is very sufficient, that is, the message queue is not empty at all. In this case, the queue ID and queue level of the message queue do not need to be recorded in the cache. If the threshold range is (0, TH2), it indicates that the message queue is almost empty. In this case, the queue ID and the scheduling level corresponding to (0, TH2) can be recorded in the cache.
[0051] It should be noted that the cache maintains a delay level table, delay_level, which records the correspondence between the queue ID of the message queue and the scheduling level, as shown in Table 1:
[0052] Table 1
[0053] Queue ID Scheduling level Logo 1 Level 1 Logo 2 Level 2 Logo 3 Level 2 Logo 4 Level 3 …… ……
[0054] It should be noted that Table 1 is only an example and does not limit the correspondence between queue identifiers and scheduling levels. In practical applications, the size of the delay level table can be, but is not limited to, 256, which is sufficient to cover the scheduling delay.
[0055] Optionally, when three scheduling thresholds are set, the bit width of the scheduling level can be 2 bits, and the values can be as shown in Table 2:
[0056] Table 2
[0057]
[0058] In Table 2, wr_count refers to the packet depth. When the packet depth of a packet queue is greater than TH0, it indicates that the packet queue has sufficient packets, that is, it is not empty at all. In this case, the corresponding scheduling level is 0x0. To save cache resources, the queue ID of the packet queue with sufficient packets can be omitted from the cache. In other words, 0x0 in Table 2 is set to an invalid value, that is, the INIT VALUE value is 0. This prevents the queue ID and scheduling level of the packet queue with sufficient packets from being recorded in the cache. Of course, when cache storage resources are sufficient, the queue ID of the packet queue with sufficient packets can be recorded. In this case, the scheduling level 0x0 is not an invalid value, that is, the INIT VALUE value is empty. When the queue depth of a packet queue is greater than TH1 and less than TH0, it indicates that the packet queue is slightly empty, and its corresponding scheduling level is 0x1. Similarly, when the queue depth is greater than TH2 and less than TH1, it indicates that the packet queue is moderately empty, and its corresponding scheduling level is 0x2. When the queue depth is less than TH2, it indicates that the packet queue is almost empty, and its corresponding scheduling level is 0x3.
[0059] It should be noted that the above scheduling thresholds are described in Table 3. The scheduling threshold values can be dynamically configured in practice. For example, the scheduling threshold can be set based on the traffic rate, the queue depth of the packet queue can be compared with the scheduling threshold, and the queue status (queue ID and scheduling level) of the nearly empty packet queue can be recorded in Table 1.
[0060] Table 3
[0061] Name Bits Description VAL TH0 b[9:0] Threshold 0 0xA0 TH1 b[19:10] Threshold 1 0x40 TH2 b[29:20] Threshold 2 0x20 Reserved b[31:30] 0x0
[0062] By implementing the message scheduling method provided in any embodiment of the present application, by recording the message identifier and scheduling level of the message queue in the cache, when the message queue is selected, based on the information recorded in the cache, if it is confirmed that the queue identifier of the message queue is in the cache, the scheduling level of the selected message queue can be determined, and then the messages in the message queue are scheduled according to the scheduling time interval corresponding to the scheduling level. If the scheduling level does not exist, the messages in the message queue are scheduled according to the priority of the message queue, thereby achieving the goal of scheduling the messages in the low-priority message queue when the high-priority message queue is about to be empty, thereby avoiding the waste of scheduling resources.
[0063] Based on the same inventive concept, the present application also provides a network chip, which includes a scheduling module and a queue control module, the scheduling module is connected to the queue control module, and the network chip includes a scheduling module and a queue control module. Figure 3 As shown, where:
[0064] a scheduling module configured to, after selecting at least one message queue, determine whether a queue identifier of each message queue in the at least one message queue is in a high-speed cache memory of the network chip, wherein the queue identifier recorded in the high-speed cache memory is recorded when there are insufficient messages in the corresponding message queue;
[0065] The scheduling module is further configured to, if the result of the determination is yes, extract the scheduling level corresponding to the message queue from the cache memory based on the queue identifier of the message queue; and control the queue scheduling module to schedule the messages in the message queue according to the scheduling time interval corresponding to the scheduling level;
[0066] The scheduling module is further configured to control the queue control module to send the messages in the message queue according to the priority of the message queue if the judgment result is that the message queue does not exist.
[0067] Specifically, when the scheduling module performs queue election, it will update the queue status of each queue through the queue status to inform the hierarchical scheduling, so that the hierarchical scheduling can elect at least one non-empty message queue. Figure 2The relevant descriptions in the illustrated embodiment will not be described in detail here. In addition, when the scheduling module performs elections for each scheduling level, it will select multiple priority message queues. If it is confirmed that the queue identifier of the selected message queue is in the cache, then after extracting the scheduling level corresponding to the queue identifier from the cache, the queue identifier and the scheduling level can be carried in the first scheduling request, and the first scheduling request is sent to the queue control module, and the queue control module records the correspondence between each scheduling level and the scheduling time interval. In this way, when the queue control module receives the scheduling request, it can parse the queue identifier and the scheduling level from the scheduling request, and then the queue control module can determine the scheduling time interval corresponding to the scheduling level, and then forward the messages in the message queue corresponding to the parsed queue identifier according to the determined scheduling time interval.
[0068] When the scheduling module confirms that the queue identifier of the message queue is not in the cache, it indicates that there are sufficient messages in the message queue, and the queue identifier of the message queue can be carried in the second scheduling request and sent to the queue control module. In this way, after receiving the second scheduling request, the queue control module can parse the queue identifier from it. Since the queue control module can record the priority of each message queue, the queue control module can send the messages in the message queue according to the priority of the message queue. For example, if the queue identifier of the high-priority message queue is in the cache, it indicates that there are insufficient messages in the high-priority message queue, and the messages in the high-priority message queue are forwarded according to the corresponding scheduling time interval. Since the scheduling speed of the messages in the high-priority message queue is slowed down, the messages in the low-priority message queue can get the scheduling opportunity, thereby solving the scheduling waste problem caused by the low-priority message queue being unable to be scheduled when the high-priority message queue is about to be empty.
[0069] It should be noted that the number of items in the cache needs to take into account the time span for the queue status to be transmitted to the scheduling module, and the scheduling results to be obtained and then transmitted back to the queue control module to generate the dequeue operation. According to the design of the data flow and related control between the queue control module and the scheduling module, the cache uses 256 items, which is enough to cover the scheduling delay, that is, the size of the delay degree table in the cache can be set to 256 items.
[0070] Optionally, different scheduling levels correspond to different delay lists, and different delay lists correspond to different scheduling time intervals; then
[0071] The scheduling module is specifically configured to write the queue identifier of the message queue into a delay linked list corresponding to the scheduling level;
[0072] The queue control module is specifically configured to read the queue identifier of the message queue from the delay list, and schedule the messages in the queue message corresponding to the read queue identifier according to the scheduling time interval corresponding to the delay list.
[0073] Specifically, to ensure the independence of the message scheduling process and the process of identifying message queues eligible for scheduling, the present application proposes that the scheduling module can write the queue identifiers of message queues stored in the cache into the delay list corresponding to the corresponding scheduling level. This allows the queue control module to read the queue identifiers of eligible queues from the delay list one by one and then schedule the messages in the message queues corresponding to the queue identifiers read according to the scheduling intervals corresponding to the delay list. This further improves message scheduling efficiency while eliminating the waste of scheduling resources.
[0074] Optionally, the scheduling module is specifically configured to, when the at least one message queue includes multiple message queues, extract, from the cache memory based on the queue identifier of the target message queue, a scheduling level corresponding to the target message queue if the queue identifiers of the multiple message queues are partially present in the cache memory;
[0075] The scheduling module is further configured to control the queue control module to schedule messages in the target message queue according to the scheduling time interval corresponding to the scheduling level; and to control the queue control module to send messages in the high-priority message queue according to the priority of the message queue in at least one message queue other than the target message queue;
[0076] The target message queue is a message queue in the at least one message queue whose corresponding queue identifier is in the cache memory.
[0077] Specifically, when at least one message queue selected by the scheduling module includes multiple message queues, the scheduling module can carry the queue identifier of the target message queue and the determined scheduling level in the third scheduling request after confirming the target message queue with the queue identifier in the cache, and send it to the queue control module. The queue control module then parses the queue identifier and scheduling level of each target message queue respectively, and then schedules the messages in each target message queue according to the scheduling time intervals corresponding to their respective scheduling levels. At the same time, the scheduling module carries the queue identifier of the message queue other than the target message queue in the fourth scheduling request and sends it to the queue control module. In this way, the queue control module can parse the queue identifier from the fourth scheduling request, and then schedule the messages in the message queue according to the priority of the message queue corresponding to the queue identifier.
[0078] Furthermore, different scheduling levels correspond to different delay linked lists, and different delay linked lists correspond to different scheduling time intervals.
[0079] On this basis, the scheduling module is specifically used to write the queue identifier of each target message queue into the delay linked table corresponding to the scheduling level of the target queue identifier;
[0080] The queue control module is specifically configured to read the queue identifier of the message queue from each delay linked list, and schedule the messages in the queue message corresponding to the read queue identifier according to the scheduling time interval corresponding to the delay linked list.
[0081] Specifically, in order to ensure that the message scheduling process and the process of confirming the message queue that can schedule the message are independent of each other, the present application proposes that the scheduling module can write the queue identifier of the target message queue in the cache into the delay list corresponding to the scheduling level. Figure 4 As shown, after performing queue selection and filtering target message queues based on the cache, the scheduling module determines that each target message queue corresponds to three scheduling levels: 0x1, 0x2, and 0x3. The scheduling module then writes the queue IDs of the target message queues into the three delay lists corresponding to these three scheduling levels: Level 1, Level 2, and Level 3. This allows the queue control module to read the schedulable queue IDs from the three delay lists one by one and then schedule the messages in the message queues corresponding to the read queue IDs according to the scheduling intervals corresponding to those delay lists. This further improves message scheduling efficiency while eliminating the waste of scheduling resources.
[0082] Optionally, based on any of the above embodiments, in this embodiment, the queue control module is used to calculate the message depth of each message queue; determine the threshold range to which the message depth belongs; and write the scheduling level corresponding to the threshold range to which the message depth belongs and the queue identifier of the message queue into the cache memory.
[0083] Specifically, refer to Figure 3 As shown in the figure, each time a message is enqueued or dequeued, the queue depth of the message queue is affected. Based on this, the queue control module calculates the queue depth of the message queue after performing an enqueue or dequeue operation on each message queue. It compares the queue depth with the scheduling threshold to determine the scheduling level of the message queue. The queue state of the message queue, that is, the queue ID and scheduling level, is then written to the cache.
[0084] In addition, in this embodiment, the scheduling module is further configured to send a queue identifier of the at least one message queue to the queue control module after selecting the at least one message queue;
[0085] On this basis, the queue control module is further configured to determine, based on the queue identifier of the at least one message queue, whether the queue identifier of each message queue in the at least one message queue is in the cache memory of the network chip;
[0086] On this basis, the queue control module is further configured to, if the judgment result is yes, extract the scheduling level corresponding to the message queue from the cache memory based on the queue identifier of the message queue; and schedule the messages in the message queue according to the scheduling time interval corresponding to the scheduling level; if the judgment result is no, send the messages in the message queue according to the priority of the message queue.
[0087] In addition, after selecting a message queue, the scheduling module sends a scheduling request to the queue control module. Upon receiving the scheduling request, the queue control module determines whether the queue ID of the message queue exists in the cache. If so, the scheduling level corresponding to the message queue is retrieved from the cache memory based on the queue ID of the message queue. The messages in the message queue are then scheduled according to the scheduling interval corresponding to the scheduling level. If not, the messages in the message queue are sent according to the priority of the message queue. This solves the scheduling waste problem caused by the inability to schedule low-priority message queues when high-priority message queues are about to become empty.
[0088] By providing the above-mentioned network chip, the cache in the network chip is used to record the almost empty status of the queue. When the queue is almost empty, scheduling is randomly stopped, avoiding scheduling waste of the empty queue due to large delays in queue status updates and scheduling paths. When the high-priority message queue is almost empty, scheduling is allocated to the non-empty queue, allowing low-priority message queues to have scheduling opportunities while ensuring that the almost empty high-priority message queue can be fully sent. In addition, the newly added cache for recording the queue status (scheduling level and queue ID) only stores 2 bits of queue status, and only fewer cache items are required, resulting in less resource increase and no storage or processing pressure on the network chip.
[0089] Based on the same inventive concept, the present application provides another network chip, such as Figure 5As shown, the network chip includes a processor 501 and a machine-readable storage medium 502. The machine-readable storage medium 502 stores a computer program executable by the processor 501. The computer program prompts the processor 501 to execute the message scheduling method provided in any embodiment of the present application. In addition, the network chip also includes a communication interface 503 and a communication bus 504. The processor 501, the communication interface 503, and the machine-readable storage medium 502 communicate with each other via the communication bus 504.
[0090] The communication bus mentioned in the network chip can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, the figure shows only one thick line, but this does not mean that there is only one bus or only one type of bus.
[0091] The communication interface is used for communication between the network chip and other devices.
[0092] The memory may include random access memory (RAM), DDR SRAM (Double Data Rate Synchronous Dynamic Random Access Memory), or non-volatile memory (NVM), such as at least one disk storage. Optionally, the memory may be at least one storage device located remotely from the processor.
[0093] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components.
[0094] In addition, an embodiment of the present application provides a machine-readable storage medium, which stores a computer program. When called and executed by a processor, the computer program prompts the processor to execute the message scheduling method provided by the embodiment of the present application.
[0095] As for the electronic device and machine-readable storage medium embodiments, since the method contents involved are basically similar to the aforementioned method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0096] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply the existence of any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.
[0097] The implementation process of the functions and effects of each unit / module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, and will not be repeated here.
[0098] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to the partial description of the method embodiments. The device embodiments described above are merely schematic, wherein the units / modules described as separate components may or may not be physically separated, and the components displayed as units / modules may or may not be physical units / modules, that is, they may be located in one place, or they may be distributed over multiple network units / modules. Some or all of the units / modules may be selected according to actual needs to achieve the purpose of the present application scheme. A person of ordinary skill in the art can understand and implement it without paying any creative work.
[0099] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A message scheduling method, characterized in that: Applied to a network chip, the method includes: After selecting at least one message queue, determining whether a queue identifier of each message queue in the at least one message queue is in a high-speed cache memory of the network chip, wherein the queue identifier recorded in the high-speed cache memory is recorded when there are insufficient messages in the corresponding message queue; the queue identifier and scheduling level in the high-speed cache memory are recorded according to the following method: for each message queue, calculating the message depth of the message queue; determining a threshold range to which the message depth belongs; and writing the scheduling level corresponding to the threshold range to which the message depth belongs and the queue identifier of the message queue into the high-speed cache memory; If so, extracting the scheduling level corresponding to the message queue from the cache memory based on the queue identifier of the message queue; and scheduling the messages in the message queue according to the scheduling time interval corresponding to the scheduling level; If it does not exist, the messages in the message queue are sent according to the priority of the message queue.
2. The method according to claim 1, characterized in that When the at least one message queue includes multiple message queues, If so, extracting the scheduling level corresponding to the message queue from the cache memory based on the queue identifier of the message queue; The messages in the message queue are scheduled according to the scheduling interval corresponding to the scheduling level, including: If the queue identification portions of the plurality of message queues exist in the cache memory, extracting the scheduling level corresponding to the target message queue from the cache memory based on the queue identification of the target message queue; and scheduling messages in the target message queue according to the scheduling time interval corresponding to the scheduling level; Sending the messages in the high-priority message queue according to the priorities of the message queues in the at least one message queue except the target message queue; The target message queue is a message queue in the at least one message queue whose corresponding queue identifier is in the cache memory.
3. The method according to claim 1, characterized in that Different scheduling levels correspond to different delay linked lists. Before scheduling the messages in the message queue according to the scheduling time interval corresponding to the scheduling level, the following steps are also included: Writing the queue identifier of the message queue into the delay linked list corresponding to the scheduling level; Schedule the packets in the packet queue according to the scheduling interval corresponding to the scheduling level, including: The queue identifier of the message queue is read from the delay linked list, and the messages in the queue message corresponding to the read queue identifier are scheduled according to the scheduling time interval corresponding to the delay linked list.
4. The method according to claim 2, characterized in that Different scheduling levels correspond to different delay linked lists; before scheduling the messages in the target message queue according to the scheduling time interval corresponding to the scheduling level, the method further includes: Write the queue ID of each target message queue into the delay linked list corresponding to the scheduling level of the target queue ID; Scheduling the messages in the target message queue according to the scheduling time interval corresponding to the scheduling level includes: The queue identifier of the message queue is read from each delay linked list, and the messages in the queue message corresponding to the read queue identifier are scheduled according to the scheduling time interval corresponding to the delay linked list.
5. A network chip, characterized in that: include: A queue control module and a scheduling module, wherein the scheduling module is connected to the queue control module; wherein: The scheduling module is configured to, after selecting at least one message queue, determine whether a queue identifier of each message queue in the at least one message queue is in a high-speed cache memory of the network chip, wherein the queue identifier recorded in the high-speed cache memory is recorded when there are insufficient messages in the corresponding message queue; The scheduling module is further configured to, if the result of the determination is yes, extract the scheduling level corresponding to the message queue from the cache memory based on the queue identifier of the message queue; and control the queue scheduling module to schedule the messages in the message queue according to the scheduling time interval corresponding to the scheduling level; The scheduling module is further configured to control the queue control module to send the messages in the message queue according to the priority of the message queue if the judgment result is that the message queue does not exist; The queue control module is configured to calculate the message depth of each message queue, determine the threshold range to which the message depth belongs, and write the scheduling level corresponding to the threshold range to which the message depth belongs and the queue identifier of the message queue into the cache memory.
6. The network chip according to claim 5, characterized in that: The scheduling module is specifically configured to, when the at least one message queue includes a plurality of message queues, extract, from the cache memory based on the queue identifier of the target message queue, a scheduling level corresponding to the target message queue if the queue identifiers of the plurality of message queues are partially present in the cache memory; The scheduling module is further configured to control the queue control module to schedule the messages in the target message queue according to the scheduling time interval corresponding to the scheduling level; and control the queue control module to send the messages in the high-priority message queue according to the priority of the message queues other than the target message queue in the at least one message queue; The target message queue is a message queue in the at least one message queue whose corresponding queue identifier is in the cache memory.
7. The network chip according to claim 5, characterized in that: Different scheduling levels correspond to different delay lists; The scheduling module is specifically configured to write the queue identifier of the message queue into the delay linked list corresponding to the scheduling level; The queue control module is specifically configured to read a queue identifier of a message queue from the delay linked list, and schedule messages in the queue message corresponding to the read queue identifier according to a scheduling time interval corresponding to the delay linked list.
8. The network chip according to claim 6, characterized in that: Different scheduling levels correspond to different delay lists; The scheduling module is specifically configured to write the queue identifiers of the target message queues into the delay linked list corresponding to the scheduling level of the target queue identifier; The queue control module is specifically configured to read a queue identifier of a message queue from each delay linked list, and schedule messages in the queue messages corresponding to the read queue identifier according to a scheduling time interval corresponding to the delay linked list.
Citation Information
Patent Citations
Method and apparatus for preventing congestion of CPU messages
CN106559354A