A package descriptor splicing method, a network processor and an electronic device
By introducing a packet management module into the network processor, the problem of rate mismatch between DMA and TM was solved. Through FD splicing and storage optimization, FD congestion was reduced and TM processing efficiency was improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NEW H3C SEMICON TECH CO LTD
- Filing Date
- 2023-04-19
- Publication Date
- 2026-07-21
AI Technical Summary
In network processors, the packet descriptor rate of DMA output is greater than the TM receive rate, leading to FD congestion and reduced processing efficiency.
A packet concatenation management (FCM) module is introduced into the network processor to determine whether there are FDs in the same forwarding queue, and to concatenate or store them if necessary, and to determine the processing method based on conditions such as packet data volume and priority.
By reducing the number of FD transfers between DMA and TM, the probability of FD congestion is reduced, thereby improving the efficiency of TM in processing messages.
Smart Images

Figure CN116405434B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of network technology, and in particular to a packet descriptor splicing method, a network processor, and an electronic device. Background Technology
[0002] Currently, after receiving a packet, the DMA (Direct Memory Access) in the network processor of a network device stores the packet in IMEM (Internal Memory) or EMEM (External Memory) and outputs the FD (Frame Description) corresponding to the packet. The DMA sends the FD to the TM (Traffic Manager). The TM processes the packet according to the forwarding queue based on the received FD and forwards it to the next level.
[0003] However, in related technologies, the maximum output rate of DMA-generated FDs is often greater than the maximum receiving rate of TM-generated FDs. This results in a mismatch between the DMA output FD rate and the TM receiving FD rate, making it difficult for the TM to receive FDs sent by the DMA. A large number of FDs suffer from congestion delays and cannot reach the TM in time, thus affecting the TM's processing of corresponding messages based on FDs and reducing the efficiency of TM message processing. Summary of the Invention
[0004] The purpose of this invention is to provide a packet descriptor concatenation method, a network processor, and an electronic device to improve the efficiency of TM packet processing. The specific technical solution is as follows:
[0005] In a first aspect of the present invention, a packet descriptor concatenation method is provided. The method is applied to a network processor, which includes a direct memory access (DMA), a packet concatenation management (FCM), and a traffic management (TM) system. The FCM is connected to both the DMA and the TM. The method includes:
[0006] The FCM receives the first packet descriptor (FD) of the message output by the DMA.
[0007] The FCM determines whether a second FD is stored in the current FCM, wherein the second FD and the first FD belong to the same forwarding queue;
[0008] If the second FD is stored in the current FCM, the FCM concatenates the first FD and the second FD to obtain a concatenated FD, and sends the concatenated FD to the TM so that the TM can manage the message based on the concatenated FD;
[0009] If the second FD is not stored, the FCM determines whether the data volume of the message is less than the preset data volume;
[0010] If the data size of the message is less than the preset data size, then the FCM stores the first FD;
[0011] If the data volume of the message is not less than the preset data volume, the FCM directly sends the first FD to the TM, so that the TM manages the message based on the first FD.
[0012] In one possible embodiment, before the FCM splices the first FD and the second FD to obtain a spliced FD, the method further includes:
[0013] The FCM determines whether the forwarding priority and source port number corresponding to the first FD and the second FD are the same;
[0014] If the forwarding priority is the same as the source port number, then the FCM performs the step of concatenating the first FD and the second FD to obtain a concatenated FD;
[0015] If the forwarding priority or the source port number is different, the FCM sends the first FD and the second FD to the TM respectively.
[0016] In one possible embodiment, before the FCM determines whether a second FD is stored in the current FCM, the method further includes:
[0017] The FCM determines whether the message is an erroneous message containing bit errors;
[0018] If it is not an error message, the FCM performs the step of determining whether the second FD is stored in the current FCM; if it is an error message, the FCM directly sends the first FD to the TM.
[0019] In one possible embodiment, before the FCM determines whether a second FD is stored in the current FCM, the method further includes:
[0020] The FCM determines whether the message is a short-delay message with a delay lower than the preset delay.
[0021] If it is not a short-delay message, the FCM performs the step of determining whether the second FD is stored in the current FCM; if it is a short-delay message, the FCM directly sends the first FD to the TM.
[0022] In one possible embodiment, the method further includes:
[0023] If the number of stored FDs exceeds a first preset number, the FCM stops receiving FDs output by the DMA;
[0024] The FCM sends the stored FDs to the TM based on the storage duration of the stored FDs until the number of FDs sent reaches a second preset number, and then continues to receive FDs output by the DMA.
[0025] In one possible embodiment, the method further includes:
[0026] The FCM sends the FD with a storage duration longer than the preset duration to the TM.
[0027] In a second aspect of the invention, a network processor is also provided, the network processor including direct memory access (DMA), packet management (FCM), and traffic management (TM), the FCM being connected to the DMA and the TM respectively, the FCM including:
[0028] The FD receiving module is used to receive the first packet descriptor (FD) of the message output by the DMA.
[0029] The first judgment module is used to determine whether the current FCM stores a second FD, wherein the second FD and the first FD belong to the same forwarding queue;
[0030] The FD splicing module is used to splice the first FD and the second FD together if the second FD is stored in the current FCM, to obtain a spliced FD, and send the spliced FD to the TM so that the TM can manage the message based on the spliced FD;
[0031] The second judgment module is used to determine whether the data volume of the message is less than a preset data volume if the second FD is not stored.
[0032] An FD storage module is used to store the first FD if the data volume of the message is less than the preset data volume;
[0033] The first FD sending module is configured to directly send the first FD to the TM if the data volume of the message is not less than the preset data volume, so that the TM can manage the message based on the first FD.
[0034] In one possible embodiment, the FCM further includes:
[0035] The third judgment module is used to determine whether the forwarding priority and source port number corresponding to the first FD and the second FD are the same. If the forwarding priority and the source port number are the same, the FD splicing module is triggered.
[0036] The second FD sending module is used to send the first FD and the second FD to the TM respectively if the third judgment module determines that the forwarding priority or source port number corresponding to the first FD and the second FD are different.
[0037] In one possible embodiment, the FCM further includes:
[0038] The fourth judgment module is used to determine whether the message is an erroneous message containing bit errors. If it is not an erroneous message, the first judgment module is triggered to execute.
[0039] The third FD sending module is used to directly send the first FD to the TM if the fourth judgment module determines that the message is an erroneous message.
[0040] In one possible embodiment, the FCM further includes:
[0041] The fifth judgment module is used to determine whether the message is a short-delay message with a delay lower than the preset delay. If it is not a short-delay message, the first judgment module is triggered.
[0042] The fourth FD sending module is used to directly send the first FD to the TM if the fifth judgment module determines that the message is a short-delay message.
[0043] In one possible embodiment, the FCM further includes:
[0044] The FD stop receiving module is used to stop receiving the FDs output by the DMA when the number of stored FDs exceeds a first preset number.
[0045] The fifth FD sending module is used to send the stored FDs to the TM based on the storage duration of the stored FDs, until the number of FDs sent reaches a second preset number, and then continue to receive FDs output by the DMA.
[0046] In one possible embodiment, the FCM further includes:
[0047] The sixth FD sending module is used to send FDs with a storage duration longer than a preset duration to the TM.
[0048] In a third aspect of the present invention, an electronic device is also provided, wherein the electronic device is configured with a network processor, the network processor being any of the network processors described in the second aspect above.
[0049] Beneficial effects of the embodiments of the present invention:
[0050] The packet descriptor concatenation method provided in this embodiment of the invention involves the network processor's FCM (Front-Channel Controller) receiving the first FD (Descriptor File System) of a packet output from the DMA (Distributed Memory Management System). The FCM determines whether it stores a second FD belonging to the same forwarding queue as the first FD. If the FCM stores a second FD belonging to the same forwarding queue as the first FD, the FCM concatenates the first FD and the second FD to obtain a concatenated FD. If the FCM does not store a second FD, it indicates that the FCM does not have a second FD to concatenate with the first FD. The FCM then determines whether the packet's data size is less than a preset data size.
[0051] When the amount of data transmitted by the network processor per unit time is constant, the smaller the data size of each packet transmitted by the network processor, the larger the number of packets transmitted per unit time. Each packet corresponds to a File Controller (FD). Therefore, the smaller the data size of the packet, the higher the rate at which the DMA outputs the FD, and the greater the impact on the TM. Thus, if the data size of a packet is less than a preset data size, it indicates that the data size is small and has a significant impact on the TM. In this case, the FCM stores the first FD and temporarily does not send it to the TM, waiting for a new first FD belonging to the same forwarding queue to be concatenated. If the data size of a packet is not less than the preset data size, it indicates that the data size is large and has a smaller impact on the TM. In this case, the first FD can be sent directly to the TM, allowing the TM to process the first FD promptly. By applying the solution provided in this embodiment of the invention, since the FCM concatenates two FDs belonging to the same forwarding queue, it reduces the number of FDs transmitted between the DMA and the TM, thereby reducing the rate at which FDs arrive at the TM, reducing the probability of FD congestion, and thus improving the efficiency of the TM in processing packets.
[0052] Of course, implementing any product or method of the present invention does not necessarily require achieving all of the advantages described above at the same time. Attached Figure Description
[0053] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other embodiments can be obtained based on these drawings.
[0054] Figure 1 This is a flowchart illustrating the first packet descriptor splicing method provided in an embodiment of the present invention;
[0055] Figure 2 This is a flowchart illustrating a packet descriptor processing method in related technologies;
[0056] Figure 3A flowchart illustrating a packet descriptor processing method provided in an embodiment of the present invention;
[0057] Figure 4 This is a flowchart illustrating the second packet descriptor splicing method provided in an embodiment of the present invention;
[0058] Figure 5 This is a schematic diagram of packet management in a network processor provided in an embodiment of the present invention. Detailed Implementation
[0059] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art based on the present invention are within the scope of protection of the present invention.
[0060] This invention provides a packet descriptor concatenation method. The method is applied to a network processor, which includes Direct Memory Access (DMA), Packet Management Function (FCM), and Traffic Management Module (TM). The FCM is connected to both the DMA and the TM. (See also...) Figure 1 The above is a flowchart illustrating the first packet descriptor concatenation method provided in an embodiment of the present invention, including:
[0061] S101, FCM receives the first FD of the DMA output message.
[0062] In S101, the DMA outputs the first FD of a message as follows: The DMA receives a message from the previous stage and stores it in IMEM or EMEM, where the choice between IMEM and EMEM is pre-set. Once the message is completely stored in IMEM or EMEM, the DMA outputs the first FD of that message to the FCM. Various DMA models are available; this embodiment can select any model, such as RxDMA (The Network DMAs on Receive path). The first FD includes information such as the queue identifier of the forwarding queue to which the message belongs, the message's storage address, the source port number, and the forwarding priority.
[0063] In one embodiment of the present invention, the forwarding queues participating in FD splicing can be pre-configured. If the forwarding queue corresponding to the queue identifier recorded in the first FD is a forwarding queue participating in FD splicing, then it is determined that the first FD participates in FD splicing and the subsequent steps are executed. Otherwise, the process ends.
[0064] S102, FCM determines whether the current FCM stores a second FD.
[0065] The second FD and the first FD belong to the same forwarding queue.
[0066] If the FCM currently stores a second FD, it means that the FCM has already stored a second FD belonging to the same forwarding queue as the first FD, and this second FD has been stored for a period of time but has not yet been sent to the TM. In this case, step S103 can be executed. If the FCM currently does not store a second FD, it means that the FCM has not yet stored an FD belonging to the same forwarding queue as the first FD. It can be determined whether to store the first FD, and step S104 can be executed.
[0067] In S102, different forwarding queues correspond to different service types. If two FDs belong to the same forwarding queue, the packets corresponding to the two FDs correspond to the same service type and can be forwarded together. If the two FDs are concatenated and sent to the TM together, the TM can forward the two packets based on the concatenated FDs. Since the two packets correspond to the same service type, joint forwarding will not affect the service.
[0068] S103, FCM concatenates the first FD and the second FD to obtain a concatenated FD, and sends the concatenated FD to TM so that TM can manage the message based on the concatenated FD.
[0069] In S103, the format for concatenating FDs is small packet FD + first FD. Small packet FD refers to a message whose data size is less than a preset data size. The small packet FD is the second FD. For details, please refer to steps S104-S106 below. This embodiment of the invention does not limit the data size of the message corresponding to the first FD. The data size of the message corresponding to the first FD can be less than or greater than the preset data size. That is, regardless of the data size of the message corresponding to the first FD, in this embodiment of the invention, the second FD and the first FD can be concatenated.
[0070] S104, FCM determines whether the data volume of the message is less than the preset data volume.
[0071] If the data volume of the message is less than the preset data volume, then proceed to step S105; if the data volume of the message is not less than the preset data volume, that is, if the data volume of the message is greater than or equal to the preset data volume, then proceed to step S106.
[0072] S105, FCM storage first FD.
[0073] S106, FCM directly sends the first FD to TM so that TM can manage the message based on the first FD.
[0074] When the amount of data transmitted by the network processor per unit time is constant, the smaller the amount of data in each packet transmitted by the network processor, the larger the number of packets transmitted by the network processor per unit time. Each packet corresponds to a FD. Therefore, the smaller the amount of data in the packet, the higher the rate at which the DMA outputs FDs. The more difficult it is for the TM to fully receive the FDs sent by the DMA, the more likely it is to cause FD congestion, and the more likely it is to affect the TM.
[0075] Therefore, if the data volume of the message is less than the preset data volume, it means that the data volume of the message is small and has a greater impact on the TM. Then, step S105 is executed, the FCM stores the first FD, does not send the first FD to the TM temporarily, and waits for a new first FD belonging to the same forwarding queue as the first FD to be concatenated.
[0076] Conversely, if the data volume of the message is not less than the preset data volume, it means that the data volume of the message is large and has little impact on the TM. Then, step S106 is executed, and the first FD is sent directly to the TM without storing the first FD, so that the TM can forward the message based on the first FD as soon as possible, and also reduce the occupation of FCM storage space.
[0077] In addition, in steps S103 and S106, after the TM receives the FD, it manages the message based on the FD. For example, based on the FD, the TM performs a series of actions such as coloring, rate limiting, and shaping on the message according to the rules set by the user. Finally, the message arranged in a certain order is cached in the TM's cache queue for subsequent processing.
[0078] See Figure 2 This is a flowchart illustrating a packet descriptor processing method in related technologies. When the DMA receives a packet, it stores the packet in IMEM / EMEM. When the packet is completely stored in IMEM / EMEM, the DMA outputs the FD about the packet to the TM. The TM then processes the packet based on the FD.
[0079] See Figure 3 This is a flowchart illustrating a packet descriptor processing method provided in an embodiment of the present invention. When the DMA receives a packet, it stores the packet in IMEM / EMEM. When the packet is completely stored in IMEM / EMEM, the DMA outputs the FD of the packet to the FCM. The FCM concatenates the FD with the stored FD to obtain the concatenated FD, which is 2×FD. The TM processes the packet based on the concatenated FD, wherein the FD and the stored FD belong to the same forwarding queue.
[0080] In this embodiment, when the FCM in the network processor receives the first FD of a packet output by the DMA, it determines whether the current FCM stores a second FD belonging to the same forwarding queue as the first FD. If the current FCM stores a second FD belonging to the same forwarding queue as the first FD, the FCM concatenates the first FD and the second FD to obtain a concatenated FD. If the current FCM does not store a second FD, it means that the FCM does not have a second FD to concatenate with the first FD, and the FCM then determines whether the data size of the packet is less than a preset data size.
[0081] When the amount of data transmitted by the network processor per unit time is constant, the smaller the data size of each packet transmitted by the network processor, the larger the number of packets transmitted per unit time. Each packet corresponds to a File Controller (FD). Therefore, the smaller the data size of the packet, the higher the rate at which the DMA outputs the FD, and the greater the impact on the TM. Thus, if the data size of a packet is less than a preset data size, it indicates that the data size is small and has a significant impact on the TM. In this case, the FCM stores the first FD and temporarily does not send it to the TM, waiting for a new first FD belonging to the same forwarding queue to be concatenated. If the data size of a packet is not less than the preset data size, it indicates that the data size is large and has a smaller impact on the TM. In this case, the first FD can be sent directly to the TM, allowing the TM to process the first FD promptly. By applying the solution provided in this embodiment of the invention, since the FCM concatenates two FDs belonging to the same forwarding queue, it reduces the number of FDs transmitted between the DMA and the TM, thereby reducing the rate at which FDs arrive at the TM, reducing the probability of FD congestion, and thus improving the efficiency of the TM in processing packets.
[0082] In one possible embodiment, if the TM does not perform a mask operation, that is, the TM considers the source port number and priority of the packet during the control of packet forwarding, then the service switch is turned on. Before the FCM concatenates the first FD and the second FD to obtain the concatenated FD, the above method also includes steps A1-A3.
[0083] Step A1: FCM determines whether the forwarding priority and source port number corresponding to the first FD and the second FD are the same.
[0084] In step A1, the forwarding priority indicates the priority of packet forwarding, and the first FD and second FD carry the forwarding priority of the corresponding packet. The source port number indicates which device port the packet originated from. Different source port numbers have different forwarding priorities.
[0085] If the source port number and forwarding priority of the first FD are the same as those of the second FD, then the TM can forward the packets corresponding to the two FDs in the same way. That is, the first FD and the second FD are concatenated to obtain a concatenated FD and then sent to the TM. The TM can process the two packets together based on the concatenated FD. The concatenated FD will not affect the TM's packet processing, so step A2 can be executed.
[0086] Conversely, if the source port number or forwarding priority of the first FD and the second FD are different, the TM cannot forward the packets corresponding to the two FDs in the same way. If the first FD and the second FD are concatenated, the TM will find it difficult to forward the packets normally after obtaining the concatenated FD, and then proceed to step A3.
[0087] Step A2: If the forwarding priority and the source port number are the same, then FCM performs the step of concatenating the first FD and the second FD to obtain the concatenated FD.
[0088] In step A2, the first FD and the second FD are spliced together to obtain the spliced FD. The steps are the same as those in S103 above, and will not be repeated here.
[0089] In step A3, if the forwarding priority or source port number is different, the FCM sends the first FD and the second FD to the TM respectively.
[0090] Using the above embodiment, when the forwarding priorities and source port numbers corresponding to the first FD and the second FD are the same, the TM can forward the packets corresponding to the first FD and the second FD in the same way. Therefore, the first FD and the second FD can be concatenated to obtain a concatenated FD. Subsequent processing by the TM based on the concatenated FD will not affect the normal forwarding of packets. Furthermore, after receiving the concatenated FD, the TM does not need to determine which packet to process first based on the forwarding priority and source port number, saving the TM's packet processing time and thus improving the TM's packet processing efficiency. Conversely, if the forwarding priorities or source port numbers corresponding to the first FD and the second FD are different, the TM cannot forward the packets corresponding to the first FD and the second FD in the same way. In this case, the first FD and the second FD are not concatenated; instead, they are sent to the TM separately to prevent concatenating the first FD and the second FD to obtain a concatenated FD from affecting the normal operation of the TM.
[0091] In addition, if the service switch is turned off, i.e. steps A1-A3 are not executed, then TM needs to perform a mask operation. When forwarding packets, it does not distinguish between the source port number and forwarding priority of the packets. Correspondingly, FCM does not need to distinguish between the source port number and forwarding priority when performing FD splicing.
[0092] In one possible embodiment, before the FCM determines whether a second FD is stored in the current FCM, the above method further includes steps B1-B2.
[0093] Step B1: FCM determines whether the message is an erroneous message containing bit errors.
[0094] In step B1, an error message refers to a message containing errors. For example, the sender sends the number 0001, but the receiver receives 0010. Comparing 0001 and 0010, it is found that the last two digits have changed from 01 to 10, indicating that the message is an error message.
[0095] Specifically, other devices in the DMA front-end of the network processor can complete the process of determining whether a message is an erroneous message. The first FD carries information indicating whether the message corresponding to the first FD is an erroneous message. Based on this information, the FCM can determine whether the message is an erroneous message.
[0096] If the above message is not an error message, then proceed to step S102 to determine whether a second FD is stored in the current FCM. If the above message is an error message, then proceed to step B2.
[0097] In step B1, if the above message is not an erroneous message, that is, the message does not have any errors, then the message can be forwarded normally and the solution provided by the embodiments of the present invention can be executed normally.
[0098] In step B2, the FCM directly sends the first FD to the TM.
[0099] If the above message is an erroneous message, it cannot be forwarded in the same way as a normal message. In this case, the solution provided in the embodiment of the present invention will not be executed, and the first FD will be sent directly to the TM. The TM will then perform subsequent processing of the erroneous message. The specific processing method is not limited in the embodiment of the present invention.
[0100] If the above embodiment contains errors, it means that the message is an erroneous message. In this case, the message cannot be forwarded in the normal way, and the FD splicing scheme provided by the embodiment of the present invention will not be executed. The first FD does not participate in splicing, and the FCM directly sends the first FD to the TM, so that the first FD can be sent to the TM in a short time, and the TM can process the erroneous message in a timely manner based on the first FD.
[0101] In one possible embodiment, before the FCM determines whether a second FD is stored in the current FCM, the above method further includes steps C1-C2.
[0102] Step C1: FCM determines whether the message is a short-delay message with a delay lower than the preset delay.
[0103] In step C1, a short-delay message refers to a message whose expected delay is less than the preset delay. In other words, a short-delay message needs to be forwarded within a short period of time.
[0104] The first FD corresponding to the message records information indicating whether the message is a short-delay message. The FCM can read the information in the first FD to determine whether the message is a short-delay message.
[0105] Therefore, if the message is a short-latency message, storing the first FD corresponding to the message in the FCM and waiting to concatenate it with the FDs of other messages will prolong the message forwarding time, which does not meet the low-latency requirement of the message. Therefore, step C2 is executed.
[0106] Conversely, if the message is not a short-delay message, there is no limit to the forwarding time of the message. The first FD corresponding to the message can be temporarily stored in the FCM. That is, the FD can be spliced using the scheme provided in the embodiment of the present invention. Then, step S102 is executed.
[0107] In step C2, the FCM directly sends the first FD to the TM.
[0108] In step C2, if the message is a short-delay message, it means that the message needs to be sent to the TM in a short time. In order to make the message be processed as soon as possible, the FCM directly sends the first FD to the TM.
[0109] Using the above embodiments, if the expected delay of the message is lower than the preset delay, it indicates that the message is a short-delay message. The message needs to be sent to the TM in a shorter time. Therefore, the FCM can directly send the first FD to the TM, which can save the time required for FD splicing, so that the first FD is sent to the TM in the expected time. The TM can process the message based on the first FD in the expected time, thereby improving the efficiency of the TM in processing messages.
[0110] In one possible embodiment, the above method further includes:
[0111] Step D1: If the number of stored FDs is greater than the first preset number, the FCM stops receiving FDs output by the DMA.
[0112] In step D1, the FCM has limited storage space, and the number of FDs it can store is also limited. Therefore, if the number of FDs stored in the FCM exceeds a first preset number, a near-fullness mechanism is triggered to prevent the FCM's storage space from being filled, and the FCM will no longer accept new FDs. The first preset number is set by the user. For example, if the FCM can store 10,000 FDs, the first preset number can be 8,000, 9,000, etc.
[0113] In one possible embodiment, if the number of stored forwarding queues exceeds a first preset number, receiving FDs output by the DMA is stopped. Since if two FDs belonging to the same forwarding queue exist, the FCM can concatenate the two FDs and send them to the TM, no longer storing them in the FCM. Therefore, FDs that can be retained in the FCM must belong to different forwarding queues, with only one FD in each forwarding queue. That is, the number of forwarding queues corresponding to the FDs stored in the FCM is the same as the number of FDs stored in the FCM. Therefore, the number of forwarding queues corresponding to an FD can be used to measure the number of FDs stored in the FCM.
[0114] In step D2, the FCM sends the stored FDs to the TM based on the storage duration of the stored FDs until the number of FDs sent reaches the second preset number, and then continues to receive FDs output by the DMA.
[0115] In step D2, in order to store new FDs to FCM, FCM can send FDs with longer storage times to TM. Specifically, FDs can be sent in descending order of storage time until the number of FDs sent by FCM to TM reaches the second preset number, at which point FCM will continue to receive FDs output by DMA.
[0116] The second preset number is set by the user and is less than the first preset number. For example, if the number of FDs that can be stored in the FCM is 10,000 and the number of FDs already stored is 9,000, then the FCM will continue to receive FDs output by the DMA when the number of FDs sent to the TM reaches 5,000.
[0117] Using the above embodiment, if the number of FDs stored in the FCM is greater than the first preset number, it indicates that the FCM's storage space is insufficient and it is difficult to receive new FDs. In this case, the FCM stops receiving FDs output by the DMA and sends the stored FDs to the TM based on the storage duration of the stored FDs. When the number of FDs sent reaches the second preset number, it continues to receive FDs output by the DMA. This can prevent the number of FDs stored in the FCM from being too large, so that the FCM has enough storage space to receive new FDs.
[0118] In one possible embodiment, the above method further includes:
[0119] Step E: FCM sends FDs with a storage duration longer than the preset duration to TM.
[0120] The preset duration is set by the user in advance, and the unit of the preset duration can be hours, minutes, or seconds. For example, if the preset duration is set to 10 hours, and the FD is stored in the FCM for more than 10 hours, then the FCM will not wait for a new FD that can be concatenated with the FD, and will directly send the FD to the TM so that the TM can process the message based on the FD.
[0121] Using the above embodiment, if the storage duration of the FD is longer than the preset duration, it means that the FD has been stored in the FCM for too long. The FCM sends the FD with a storage duration longer than the preset duration to the TM, which can prevent the FD from being stored in the FCM indefinitely, so that the FD can reach the TM in time and the TM can process the message within a certain period of time.
[0122] In one possible embodiment, see Figure 4 This is a flowchart illustrating the second packet descriptor splicing method provided in an embodiment of the present invention, which includes steps S401-S409.
[0123] S401, FCM receives the first FD of the DMA output message.
[0124] S402, FCM determines the forwarding queue to which the first FD belongs and whether the first FD supports FD concatenation.
[0125] If the forwarding queue to which the first FD belongs and the first FD support FD concatenation, then proceed to step S404. If the forwarding queue to which the first FD belongs and the first FD do not support FD concatenation, then proceed to step S403.
[0126] Whether the forwarding queue supports file descriptor (FD) concatenation depends on the software configuration.
[0127] Whether the first FD supports FD concatenation depends on whether the message is an error message or a short-delay message. If the message is an error message or a short-delay message, the first FD does not support FD concatenation; otherwise, the first FD supports FD concatenation.
[0128] S403, FCM directly sends the first FD to TM so that TM can manage the message based on the first FD.
[0129] S404, FCM determines whether the current FCM stores a second FD.
[0130] If not, proceed to step S405; if yes, proceed to step S407.
[0131] S405, FCM determines whether the data volume of the message is less than the preset data volume.
[0132] If the data size of the message is less than the preset data size, proceed to step S406. If the data size of the message is not less than the preset data size, that is, if the data size of the message is greater than or equal to the preset data size, proceed to step S403.
[0133] S406, FCM storage first FD.
[0134] S407, FCM determines whether the forwarding priority and source port number corresponding to the first FD and the second FD are the same.
[0135] If the forwarding priority and source port number corresponding to the first FD and the second FD are the same, then proceed to step S409. If the forwarding priority and source port number corresponding to the first FD and the second FD are different, then proceed to step S408.
[0136] S408, FCM sends the first FD and the second FD to TM respectively.
[0137] S409, FCM concatenates the first FD and the second FD to obtain a concatenated FD, and sends the concatenated FD to TM so that TM can manage the message based on the concatenated FD.
[0138] As mentioned above Figure 1 Corresponding to the first packet descriptor concatenation method provided in the illustrated embodiment of the present invention, this embodiment also provides a network processor, which includes DMA, FCM, and TM, wherein the FCM is connected to both DMA and TM. See [link to relevant documentation]. Figure 5 This is a schematic diagram of a packet management structure in a network processor according to an embodiment of the present invention. The aforementioned FCM includes:
[0139] FD receiving module 501 is used to receive the first FD of the message output by DMA;
[0140] The first judgment module 502 is used to determine whether the current FCM stores a second FD, wherein the second FD and the first FD belong to the same forwarding queue;
[0141] The FD splicing module 503 is used to splice the first FD and the second FD together if the current FCM stores a second FD to obtain a spliced FD, and send the spliced FD to the TM so that the TM can manage the message based on the spliced FD.
[0142] The second judgment module 504 is used to determine whether the data volume of the message is less than the preset data volume if the second FD is not stored.
[0143] The FD storage module 505 is used to store the first FD if the data volume of the message is less than the preset data volume;
[0144] The first FD sending module 506 is used to directly send the first FD to the TM if the data volume of the message is not less than the preset data volume, so that the TM can manage the message based on the first FD.
[0145] In this embodiment, when the FCM in the network processor receives the first FD of a packet output by the DMA, it determines whether the current FCM stores a second FD belonging to the same forwarding queue as the first FD. If the current FCM stores a second FD belonging to the same forwarding queue as the first FD, the FCM concatenates the first FD and the second FD to obtain a concatenated FD. If the current FCM does not store a second FD, it means that the FCM does not have a second FD to concatenate with the first FD, and the FCM then determines whether the data size of the packet is less than a preset data size.
[0146] When the amount of data transmitted by the network processor per unit time is constant, the smaller the data size of each packet transmitted by the network processor, the larger the number of packets transmitted per unit time. Each packet corresponds to a File Controller (FD). Therefore, the smaller the data size of the packet, the higher the rate at which the DMA outputs the FD, and the greater the impact on the TM. Thus, if the data size of a packet is less than a preset data size, it indicates that the data size is small and has a significant impact on the TM. In this case, the FCM stores the first FD and temporarily does not send it to the TM, waiting for a new first FD belonging to the same forwarding queue to be concatenated. If the data size of a packet is not less than the preset data size, it indicates that the data size is large and has a smaller impact on the TM. In this case, the first FD can be sent directly to the TM, allowing the TM to process the first FD promptly. By applying the solution provided in this embodiment of the invention, since the FCM concatenates two FDs belonging to the same forwarding queue, it reduces the number of FDs transmitted between the DMA and the TM, thereby reducing the rate at which FDs arrive at the TM, reducing the probability of FD congestion, and thus improving the efficiency of the TM in processing packets.
[0147] In one possible embodiment, the above-described FCM further includes:
[0148] The third judgment module is used to determine whether the forwarding priority and source port number corresponding to the first FD and the second FD are the same. If the forwarding priority and source port number are the same, the FD splicing module 503 is triggered.
[0149] The second FD sending module is used to send the first FD and the second FD to TM respectively if the third judgment module determines that the forwarding priority or source port number corresponding to the first FD and the second FD are different.
[0150] Using the above embodiment, when the forwarding priorities and source port numbers corresponding to the first FD and the second FD are the same, the TM can forward the packets corresponding to the first FD and the second FD in the same way. Therefore, the first FD and the second FD can be concatenated to obtain a concatenated FD. Subsequent processing by the TM based on the concatenated FD will not affect the normal forwarding of packets. Furthermore, after receiving the concatenated FD, the TM does not need to determine which packet to process first based on the forwarding priority and source port number, saving the TM's packet processing time and thus improving the TM's packet processing efficiency. Conversely, if the forwarding priorities or source port numbers corresponding to the first FD and the second FD are different, the TM cannot forward the packets corresponding to the first FD and the second FD in the same way. In this case, the first FD and the second FD are not concatenated; instead, they are sent to the TM separately to prevent concatenating the first FD and the second FD to obtain a concatenated FD from affecting the normal operation of the TM.
[0151] In one possible embodiment, the above-described FCM further includes:
[0152] The fourth judgment module is used to determine whether the message is an erroneous message containing bit errors. If it is not an erroneous message, the execution of the first judgment module 502 is triggered.
[0153] The third FD sending module is used to directly send the first FD to the TM if the fourth judgment module determines that the message is an erroneous message.
[0154] If the above embodiment contains errors, it means that the message is an erroneous message. In this case, the message cannot be forwarded in the normal way, and the FD splicing scheme provided by the embodiment of the present invention will not be executed. The first FD does not participate in splicing, and the FCM directly sends the first FD to the TM, so that the first FD can be sent to the TM in a short time, and the TM can process the erroneous message in a timely manner based on the first FD.
[0155] In one possible embodiment, the above-described FCM further includes:
[0156] The fifth judgment module is used to determine whether the message is a short-delay message with a delay lower than the preset delay. If it is not a short-delay message, the first judgment module 502 is triggered.
[0157] The fourth FD sending module is used to directly send the first FD to the TM if the fifth judgment module determines that the message is a short-delay time message.
[0158] Using the above embodiments, if the expected delay of the message is lower than the preset delay, it indicates that the message is a short-delay message. The message needs to be sent to the TM in a shorter time. Therefore, the FCM can directly send the first FD to the TM, which can save the time required for FD splicing, so that the first FD is sent to the TM in the expected time. The TM can process the message based on the first FD in the expected time, thereby improving the efficiency of the TM in processing messages.
[0159] In one possible embodiment, the above-described FCM further includes:
[0160] The FD stop receiving module is used to stop receiving FDs output by DMA when the number of stored FDs exceeds a first preset number.
[0161] The fifth FD sending module is used to send the stored FDs to the TM based on the storage duration of the stored FDs, until the number of FDs sent reaches the second preset number, and then continue to receive FDs output by the DMA.
[0162] Using the above embodiment, if the number of FDs stored in the FCM is greater than the first preset number, it indicates that the FCM's storage space is insufficient and it is difficult to receive new FDs. In this case, the FCM stops receiving FDs output by the DMA and sends the stored FDs to the TM based on the storage duration of the stored FDs. When the number of FDs sent reaches the second preset number, it continues to receive FDs output by the DMA. This can prevent the number of FDs stored in the FCM from being too large, so that the FCM has enough storage space to receive new FDs.
[0163] In one possible embodiment, the above-described FCM further includes:
[0164] The sixth FD sending module is used to send FDs with a storage duration longer than the preset duration to TM.
[0165] Using the above embodiment, if the storage duration of the FD is longer than the preset duration, it means that the FD has been stored in the FCM for too long. The FCM sends the FD with a storage duration longer than the preset duration to the TM, which can prevent the FD from being stored in the FCM indefinitely, so that the FD can reach the TM in time and the TM can process the message within a certain period of time.
[0166] This invention also provides an electronic device, which is equipped with a network processor, and the network processor is any of the network processors described above.
[0167] In this embodiment, when the FCM in the network processor receives the first FD of a packet output by the DMA, it determines whether the current FCM stores a second FD belonging to the same forwarding queue as the first FD. If the current FCM stores a second FD belonging to the same forwarding queue as the first FD, the FCM concatenates the first FD and the second FD to obtain a concatenated FD. If the current FCM does not store a second FD, it means that the FCM does not have a second FD to concatenate with the first FD, and the FCM then determines whether the data size of the packet is less than a preset data size.
[0168] When the amount of data transmitted by the network processor per unit time is constant, the smaller the data size of each packet transmitted by the network processor, the larger the number of packets transmitted per unit time. Each packet corresponds to a File Controller (FD). Therefore, the smaller the data size of the packet, the higher the rate at which the DMA outputs the FD, and the greater the impact on the TM. Thus, if the data size of a packet is less than a preset data size, it indicates that the data size is small and has a significant impact on the TM. In this case, the FCM stores the first FD and temporarily does not send it to the TM, waiting for a new first FD belonging to the same forwarding queue to be concatenated. If the data size of a packet is not less than the preset data size, it indicates that the data size is large and has a smaller impact on the TM. In this case, the first FD can be sent directly to the TM, allowing the TM to process the first FD promptly. By applying the solution provided in this embodiment of the invention, since the FCM concatenates two FDs belonging to the same forwarding queue, it reduces the number of FDs transmitted between the DMA and the TM, thereby reducing the rate at which FDs arrive at the TM, reducing the probability of FD congestion, and thus improving the efficiency of the TM in processing packets.
[0169] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0170] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the network processor and electronic device embodiments are basically similar to the method embodiments, so the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0171] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.
Claims
1. A method for concatenating packet descriptors, characterized in that, The method is applied to a network processor, which includes Direct Memory Access (DMA), Packet Management Function (FCM), and Traffic Management Module (TM). The FCM is connected to both the DMA and the TM. The method includes: The FCM receives the first packet descriptor (FD) of the message output by the DMA. The FCM determines whether a second FD is stored in the current FCM, wherein the second FD and the first FD belong to the same forwarding queue; If the second FD is stored in the current FCM, the FCM concatenates the first FD and the second FD to obtain a concatenated FD, and sends the concatenated FD to the TM so that the TM can manage the message based on the concatenated FD; If the second FD is not stored, the FCM determines whether the data volume of the message is less than the preset data volume; If the data size of the message is less than the preset data size, then the FCM stores the first FD; If the data volume of the message is not less than the preset data volume, the FCM directly sends the first FD to the TM, so that the TM manages the message based on the first FD.
2. The method according to claim 1, characterized in that, Before the FCM splices the first FD and the second FD to obtain the spliced FD, the method further includes: The FCM determines whether the forwarding priority and source port number corresponding to the first FD and the second FD are the same; If the forwarding priority is the same as the source port number, then the FCM performs the step of concatenating the first FD and the second FD to obtain a concatenated FD; If the forwarding priority or the source port number is different, the FCM sends the first FD and the second FD to the TM respectively.
3. The method according to claim 1, characterized in that, Before the FCM determines whether a second FD is stored in the current FCM, the method further includes: The FCM determines whether the message is an erroneous message containing bit errors; If it is not an error message, the FCM performs the step of determining whether a second FD is stored in the current FCM; If it is an error message, the FCM directly sends the first FD to the TM.
4. The method according to claim 1, characterized in that, Before the FCM determines whether a second FD is stored in the current FCM, the method further includes: The FCM determines whether the message is a short-delay message with a delay lower than the preset delay. If it is not a short delay message, the FCM performs the step of determining whether the second FD is stored in the current FCM; If it is a short-delay message, the FCM directly sends the first FD to the TM.
5. The method according to any one of claims 1-4, characterized in that, The method further includes: If the number of stored FDs exceeds a first preset number, the FCM stops receiving FDs output by the DMA; The FCM sends the stored FDs to the TM based on the storage duration of the stored FDs until the number of FDs sent reaches a second preset number, and then continues to receive FDs output by the DMA.
6. The method according to any one of claims 1-4, characterized in that, The method further includes: The FCM sends the FD with a storage duration longer than the preset duration to the TM.
7. A network processor, characterized in that, The network processor includes Direct Memory Access (DMA), Packet Management Function (FCM), and Traffic Management Module (TM). The FCM is connected to both the DMA and the TM. The FCM includes: The FD receiving module is used to receive the first packet descriptor (FD) of the message output by the DMA. The first judgment module is used to determine whether the current FCM stores a second FD, wherein the second FD and the first FD belong to the same forwarding queue; The FD splicing module is used to splice the first FD and the second FD together if the second FD is stored in the current FCM, to obtain a spliced FD, and send the spliced FD to the TM so that the TM can manage the message based on the spliced FD; The second judgment module is used to determine whether the data volume of the message is less than a preset data volume if the second FD is not stored. An FD storage module is used to store the first FD if the data volume of the message is less than the preset data volume; The first FD sending module is configured to directly send the first FD to the TM if the data volume of the message is not less than the preset data volume, so that the TM can manage the message based on the first FD.
8. The network processor according to claim 7, characterized in that, The FCM also includes: The third judgment module is used to determine whether the forwarding priority and source port number corresponding to the first FD and the second FD are the same. If the forwarding priority and the source port number are the same, the FD splicing module is triggered. The second FD sending module is used to send the first FD and the second FD to the TM respectively if the third judgment module determines that the forwarding priority or source port number corresponding to the first FD and the second FD are different.
9. The network processor according to claim 7, characterized in that, The FCM also includes: The fourth judgment module is used to determine whether the message is an erroneous message containing bit errors. If it is not an erroneous message, the first judgment module is triggered to execute. The third FD sending module is used to directly send the first FD to the TM if the fourth judgment module determines that the message is an erroneous message.
10. An electronic device, characterized in that, The electronic device is equipped with a network processor, which is the network processor according to any one of claims 7-9.