Message storage device and method
By using the same first-in first-out cache unit to store message data and metadata in the network chip, and managing address through the message storage control unit, the problem of synchronous reading of message data and metadata is solved, and processing efficiency and cache utilization are improved.
Patent Information
- Application Number
- CN202510205682.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-24
- Publication Date
- 2025-05-23
- Estimated Expiration
- 2045-02-24
AI Technical Summary
In a network chip, synchronous reading of message data and corresponding metadata is prone to errors, and packet loss processing is inefficient.
The same first-in first-out cache unit is used to store the message data and metadata, and the message storage control unit uses the message storage control unit to latch and restore the address when the message start and end identifiers are received to ensure the synchronous writing and reading of metadata and message data.
It solves the problem of mismatch between metadata and message data when read by the message processing engine, saves chip area, improves cache utilization, and reduces delay during packet loss processing.
Smart Images

Figure CN120034512A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of network chips, and in particular, relates to a message storage device and method. Background Art
[0002] In a network chip, when storing network messages, a large amount of accompanying information (also called metadata) is often required to be stored, such as the physical or logical port of the inlet or outlet, the message type, the priority TC, whether it is dirty data, and other information. Summary of the invention
[0003] The purpose of the present application is to provide a message storage device and method, aiming to solve the problem in the related art that synchronous reading of message data and corresponding metadata is prone to errors and the efficiency of packet loss processing is low.
[0004] According to a first aspect of the present application, a message storage device is provided, comprising:
[0005] A first-in-first-out cache unit, used to store received message data and metadata corresponding to the message data; wherein the bit width of the first-in-first-out cache unit is twice the bit width of the message data;
[0006] A message storage control unit is used to latch the current write address of the first-in-first-out cache unit as the start write address in the first time slot when message data carrying a message start identifier is received, and to write the received message data into the first-in-first-out cache unit starting from the next address of the start write address from the second time slot until the first time slot when message data carrying a message end identifier is received, write the message data carrying the message end identifier into the first-in-first-out cache unit, and write metadata corresponding to the message data after restoring the current write address of the first-in-first-out cache unit to the start write address in the second time slot.
[0007] The device is easy to implement and is compatible with traditional FIFO functions. It uses the same first-in-first-out cache unit FIFO to cache metadata and message data, thereby solving the problem of mismatch between metadata and message data when a message processing engine reads the FIFO. At the same time, since two FIFOs in the related technology are merged into one FIFO, the FIFO depth is less than the sum of the depths of the two FIFOs in the related technology, thereby saving chip area and improving cache utilization.
[0008] In an optional embodiment, the message storage control unit also latches the current write address of the first-in-first-out cache unit as the message end address when receiving the message data carrying the message end identifier in the first time slot, and restores the current write address to the message end address after writing the metadata in the second time slot.
[0009] In an optional embodiment, the message storage control unit is further used to restore the current write address of the first-in-first-out cache unit to the start write address when packet loss processing is required.
[0010] In this embodiment, when the message end identifier of the message data indicates that an error occurs in the message data or other situations requiring packet loss are detected, the message data can be discarded only within one time slot, rather than slowly reading the entire message data from the fifo and then notifying the message processing engine to discard the packet as in the related art.
[0011] In an optional embodiment, the message storage control unit is also used to add 1 to the actual storage capacity of the first-in-first-out cache unit after the first-in-first-out cache unit completes the write operation, subtract 1 from the actual storage capacity of the first-in-first-out cache unit after the first-in-first-out cache unit completes the read operation, and subtract the packet loss storage capacity from the actual storage capacity of the first-in-first-out cache unit after the first-in-first-out cache unit completes the packet loss processing, and the packet loss storage capacity is determined based on the difference between the current write address of the first-in-first-out cache unit and the start write address.
[0012] In an optional embodiment, the message storage device further includes:
[0013] A message processing engine is used to read the metadata from the first-in-first-out cache unit, determine a forwarding decision for the message data corresponding to the metadata based on the metadata, and forward the message data subsequently read from the first-in-first-out cache unit based on the forwarding decision.
[0014] According to a second aspect of the present application, a message storage method is provided, comprising:
[0015] If message data carrying a message start identifier is received, then in the first time slot of receiving the message data carrying the message start identifier, the current write address of the first-in-first-out cache unit is latched as the start write address; wherein the bit width of the first-in-first-out cache unit is twice the bit width of the message data;
[0016] Starting from the second time slot when the message data carrying the message start identifier is received, writing the received message data into the first-in-first-out cache unit from the next address of the start write address until the message data carrying the message end identifier is received;
[0017] In a first time slot when receiving message data carrying a message end identifier, writing the message data carrying the message end identifier into the first-in-first-out cache unit;
[0018] After receiving the second time slot of the message data carrying the message end identifier, the current write address of the first-in-first-out cache unit is restored to the start write address, and metadata corresponding to the message data is written.
[0019] In an optional embodiment, the method further comprises:
[0020] In the first time slot when the message data carrying the message end mark is received, the current write address of the first-in-first-out cache unit is latched as the message end address;
[0021] After the metadata is written in the second time slot after receiving the message data carrying the message end identifier, the current write address is restored to the message end address.
[0022] In an optional embodiment, the method further comprises:
[0023] When packet loss processing is required, the current write address of the first-in-first-out cache unit is restored to the start write address.
[0024] In an optional embodiment, the method further comprises:
[0025] After the first-in-first-out cache unit completes the write operation, the actual storage capacity of the first-in-first-out cache unit is increased by 1;
[0026] After the first-in-first-out cache unit completes the read operation, the actual storage capacity of the first-in-first-out cache unit is reduced by 1;
[0027] After the FIFO cache unit completes packet loss processing, the packet loss storage capacity is subtracted from the actual storage capacity of the FIFO cache unit, where the packet loss storage capacity is determined based on the difference between the current write address of the FIFO cache unit and the start write address.
[0028] In an optional embodiment, the method further comprises:
[0029] Reading the metadata from the first-in-first-out cache unit;
[0030] Determine, based on the metadata, a forwarding decision for the message data corresponding to the metadata;
[0031] The message data subsequently read from the first-in-first-out cache unit is forwarded based on the forwarding decision.
[0032] The features and advantages of the present application will be described in the following description, and part of them will become apparent from the description, or will be understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained through the structures and processes indicated in the description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. It is obvious that the drawings described below are certain embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0034] Figure 1 It is a structural schematic diagram of a message storage device according to the related technology.
[0035] Figure 2 It is a structural diagram of a message storage device according to an exemplary embodiment of the present application.
[0036] Figure 3 It is a schematic diagram of the structure of storing message data and metadata in the same FIFO according to an exemplary embodiment of the present application.
[0037] Figure 4 It is a storage logic diagram of message data and metadata according to an exemplary embodiment of the present application.
[0038] Figure 5 It is a flowchart of a message storage method according to an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0039] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0040] In the related art, network messages and metadata are cached in a first-in-first-out cache unit (FIFO) and then sent to the message processing engine PPE. PPE uses the metadata to perform corresponding forwarding processing on the network message. Its processing logic is as follows: Figure 1 As shown in the figure, pfifo caches the packet data of the network packet, and the sop (start of packet) and eop (end of packet) carried by the packet data are written into pfifo; mfifo is used to cache metadata data.
[0041] However, the above processing logic in the related art has the following defects:
[0042] 1) When PPE processes network messages, it needs to keep strict synchronization in the reading of PFIFO and MFIFO to ensure that the message data P matches the metadata M. Once a mismatch occurs due to logic errors, ECC errors, or FIFO overflows, the circuit will be abnormal and cannot be recovered.
[0043] 2) When packet error information (such as FCS error, packet checksum error, sop and eop exceptions, etc.) is detected at the eop position of the data, packet loss processing is often required. However, since the above-mentioned related technologies adopt a fifo structure, packet loss processing needs to be implemented by caching the packet loss flag. Therefore, p and m (where m contains the packet loss flag) can only be read out slowly before informing the message processing engine ppe to drop the packet, which may pollute ppe.
[0044] Based on the above analysis, the present application proposes a message storage device and method, which caches metadata and message data in the same first-in-first-out cache unit fifo, solving the problem of mismatch between metadata and message data when the message processing engine reads the fifo; at the same time, two fifos are used in the related art to store metadata and message data respectively, and the worst case is taken as the standard in the logic implementation, so the depth of the two fifos is designed based on the number of bytes of the message data, and the present application merges the two fifos in the related art into one fifo. Since the number of bytes of metadata is much smaller than the number of bytes of message data, the depth of the merged fifo is less than the sum of the depths of the two fifos in the related art, saving chip area and improving cache utilization; and when the message end identifier of the message data indicates that an error occurs in the message data or other situations in which packet loss is detected, the message data can be discarded only in one time slot, instead of slowly reading the entire message data from the fifo and then notifying the message processing engine to drop the packet as in the related art. "Time slot" in the present application refers to an operation window within a clock cycle.
[0045] See also Figure 2 As shown, the present application exemplarily provides a message storage device, including:
[0046] A first-in-first-out buffer unit 201, used to store received message data and metadata corresponding to the message data; wherein the bit width of the first-in-first-out buffer unit is twice the bit width of the message data;
[0047] The message storage control unit 202 is used to latch the current write address of the first-in-first-out cache unit as the start write address in the first time slot when the message data carrying the message start identifier is received, and to write the received message data into the first-in-first-out cache unit starting from the next address of the start write address from the second time slot until the first time slot when the message data carrying the message end identifier is received, write the message data carrying the message end identifier into the first-in-first-out cache unit, and write metadata corresponding to the message data after restoring the current write address of the first-in-first-out cache unit to the start write address in the second time slot.
[0048] Exemplarily, the present application uses the same first-in-first-out cache unit to store received message data and corresponding metadata. It should be noted that message data is the network message received by the network chip through the physical port and / or logical port, and metadata is some attribute data corresponding to the network message, such as the physical port or logical port of the inlet or outlet, message type, priority TC, whether it is dirty data, etc., where the message type needs to be determined by parsing the message header of the message data. See Figure 3 As shown, for example, if a traditional FIFO cache unit is used to directly store received message data (Ethernet Packet), in the case of online fast writing, since each time slot is writing message data p to the FIFO cache unit, there is no time slot for writing metadata m before the message data of the entire network message is written. In addition, the message processing engine ppe needs to extract the metadata corresponding to a network message at the start time of a network message, that is, when the message start identifier of the network message is obtained, so as to determine the forwarding decision of the network message. If according to Figure 3 In the manner shown, the corresponding metadata can be read only after the message end mark eop of the network message is read.
[0049] To this end, the present application exemplarily expands the data bit width of the first-in-first-out cache unit to twice the bit width of the message data, so that the message data p can be written every 2 time slots, and the metadata m can be written in the remaining time slot.
[0050] For example, see Figure 4As shown, since the bit width of the first-in-first-out cache unit is twice the bit width of the message data, one beat of writing the first-in-first-out cache unit can be divided into two time slots, one time slot is sufficient for writing the message data to the first-in-first-out cache unit, and the other time slot can be used to write metadata. Therefore, after receiving the message data carrying the message start identifier, the message storage control unit latches the current write address of the first-in-first-out cache unit in the current time slot, which can also be referred to as the first time slot in which the message data carrying the message start identifier is received. For the convenience of description, the latched address can be referred to as the message start address sa. In the next time slot, the message data carrying the message start identifier can be written into the first-in-first-out cache unit at the next address sa+1 of sa, and then the message data is written once every two time slots until the message data carrying the message end identifier is written into the first-in-first-out cache unit. It can be understood that the message data carrying the message start identifier and the message end identifier and all the message data received in the middle belong to the same network message. In the first time slot when the message data carrying the message end identifier is received, the message storage control unit writes it into the first-in-first-out cache unit, and in the second time slot, the write address of the first-in-first-out cache unit is restored to the previously latched start write address sa, and the metadata corresponding to the message data is written at the start write address sa. This is because the metadata is identified and extracted only after all the message data of the entire network message are received. However, through the method of the present application, although the metadata is identified and extracted at the end position of the network message, the metadata is still written before the start position of the network message. When the message processing engine reads the network message from the first-in-first-out cache unit, it will also read the metadata first, and then read the message data of the network message.
[0051] In some optional embodiments, the message storage control unit also latches the current write address of the first-in-first-out cache unit as the message end address when receiving the message data carrying the message end identifier in the first time slot, and restores the current write address to the message end address after writing the metadata in the second time slot.
[0052] In this optional implementation, in order to continue receiving and writing the message data of the next network message to the first-in-first-out cache unit after writing the metadata, it is necessary to restore the current write address of the first-in-first-out cache unit to the original address. Therefore, after receiving the first time slot of the message data carrying the message end identifier, the message data carrying the message end identifier is written into the first-in-first-out cache unit, and the current write address of the first-in-first-out cache unit is latched. For the convenience of description, it is subsequently referred to as the message end address ea. After the metadata is written, the current write address of the first-in-first-out cache unit is restored to the message end address ea.
[0053] In some optional embodiments, the message storage control unit is further configured to restore the current write address of the first-in-first-out cache unit to the start write address when packet loss processing is required.
[0054] For example, if any error is detected in the network message, such as FCS error, packet checksum error, sop and eop exception, etc., and packet loss processing is required, the current write address of the first-in-first-out cache unit is restored to the previously latched start write address sa, so that the subsequent received message data can be written from sa, and the message data that has been written after the start write address is discarded. It can be seen that the packet loss processing in this embodiment can be completed within a time slot where the error is detected and the packet loss processing is required.
[0055] In some optional embodiments, the message storage control unit is also used to add 1 to the actual storage capacity of the first-in-first-out cache unit after the first-in-first-out cache unit completes the write operation, subtract 1 from the actual storage capacity of the first-in-first-out cache unit after the first-in-first-out cache unit completes the read operation, and subtract the packet loss storage capacity from the actual storage capacity of the first-in-first-out cache unit after the first-in-first-out cache unit completes the packet loss processing, and the packet loss storage capacity is determined based on the difference between the current write address and the start write address of the first-in-first-out cache unit.
[0056] Exemplarily, since the current write address of the first-in-first-out cache unit in the present application jumps, the empty and full flags of the first-in-first-out cache unit cannot be simply judged based on the read and write addresses. Therefore, the empty and full status of the first-in-first-out cache unit can be dynamically judged based on the actual storage capacity (cnt) of the first-in-first-out cache unit. The calculation logic of the actual storage capacity cnt is as follows: when the first-in-first-out cache unit performs a write operation, cnt increases by 1, and when the first-in-first-out cache unit performs a read operation, cnt decreases by 1. When the first-in-first-out cache unit needs to process packet loss, cnt is subtracted from the number of addresses of the first-in-first-out cache unit that needs to be discarded. The number of discarded addresses can be derived based on the difference between the current write address of the first-in-first-out cache unit when the packet is lost and the previously latched start write address sa.
[0057] In some optional embodiments, the message storage device further includes:
[0058] The message processing engine is used to read metadata from the first-in-first-out cache unit, determine the forwarding decision of the message data corresponding to the metadata based on the metadata, and forward the message data continued to be read from the first-in-first-out cache unit based on the forwarding decision.
[0059] Exemplarily, the message processing engine can read the message data cached in the first-in-first-out cache unit, and determine the forwarding decision of the message data based on the metadata corresponding to the message data. In the present application, the metadata can be read out from the first-in-first-out cache unit first, and then the corresponding message data can be read out. Therefore, after reading the metadata, the forwarding decision of the message data can be determined, so that the subsequently read message data can be forwarded according to the forwarding decision.
[0060] In the above solution of the present application, the logic change of the first-in-first-out cache unit is relatively small. Compared with the traditional first-in-first-out cache unit, only the control signals of the message start, message end and packet loss processing are newly added.
[0061] Accordingly, see Figure 5 As shown, the present application also exemplarily provides a message storage method, including:
[0062] Step 501: If message data carrying a message start identifier is received, then in the first time slot of receiving the message data carrying the message start identifier, the current write address of the first-in-first-out cache unit is latched as the start write address; wherein the bit width of the first-in-first-out cache unit is twice the bit width of the message data;
[0063] Step 502: starting from the second time slot when the message data carrying the message start identifier is received, writing the received message data into the first-in-first-out buffer unit from the next address of the start write address until the message data carrying the message end identifier is received;
[0064] Step 503: When receiving the first time slot of the message data carrying the message end identifier, write the message data carrying the message end identifier into the first-in-first-out buffer unit;
[0065] Step 504: after receiving the second time slot of the message data carrying the message end identifier, restore the current write address of the FIFO cache unit to the start write address, and then write the metadata corresponding to the message data.
[0066] In some optional embodiments, the method further includes:
[0067] In the first time slot when receiving the message data carrying the message end mark, latching the current write address of the first-in-first-out cache unit as the message end address;
[0068] After the metadata is written in the second time slot after receiving the message data carrying the message end identifier, the current write address is restored to the message end address.
[0069] In some optional embodiments, the method further includes:
[0070] When packet loss processing is required, the current write address of the first-in-first-out cache unit is restored to the start write address.
[0071] In some optional embodiments, the method further includes:
[0072] After the first-in-first-out cache unit completes the write operation, the actual storage capacity of the first-in-first-out cache unit is increased by 1;
[0073] After the first-in-first-out cache unit completes the read operation, the actual storage capacity of the first-in-first-out cache unit is reduced by 1;
[0074] After the FIFO cache unit completes packet loss processing, the packet loss storage amount is subtracted from the actual storage amount of the FIFO cache unit, and the packet loss storage amount is determined based on the difference between the current write address and the start write address of the FIFO cache unit.
[0075] In some optional embodiments, the method further includes:
[0076] Read metadata from a first-in-first-out cache unit;
[0077] Determine a forwarding decision of the message data corresponding to the metadata based on the metadata;
[0078] The message data subsequently read from the FIFO cache unit is forwarded based on the forwarding decision.
[0079] The above method can be implemented by the message storage device provided in the above embodiment. The specific implementation method can refer to the description of the message storage device in the above embodiment, which will not be repeated here.
[0080] It is understood that the circuit structures, names and parameters described in the above embodiments are only examples. Those skilled in the art can also easily combine and adjust the structural features of the above embodiments according to the use requirements, and should not limit the concept of the present application to the specific details of the above examples.
[0081] Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that he or she may still modify the technical solutions described in the aforementioned embodiments, or make equivalent substitutions for some of the technical features therein; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A message storage device, characterized in that: include: A first-in-first-out cache unit, used to store received message data and metadata corresponding to the message data; wherein the bit width of the first-in-first-out cache unit is twice the bit width of the message data; A message storage control unit is used to latch the current write address of the first-in-first-out cache unit as the start write address in the first time slot when message data carrying a message start identifier is received, and to write the received message data into the first-in-first-out cache unit starting from the next address of the start write address from the second time slot until the first time slot when message data carrying a message end identifier is received, write the message data carrying the message end identifier into the first-in-first-out cache unit, and write metadata corresponding to the message data after restoring the current write address of the first-in-first-out cache unit to the start write address in the second time slot.
2. The message storage device according to claim 1, characterized in that: The message storage control unit also latches the current write address of the first-in-first-out cache unit as the message end address when receiving the message data carrying the message end identifier in the first time slot, and restores the current write address to the message end address after writing the metadata in the second time slot.
3. The message storage device according to claim 1, characterized in that: The message storage control unit is further used to restore the current write address of the first-in-first-out cache unit to the start write address when packet loss processing is required.
4. The message storage device according to claim 1, characterized in that: The message storage control unit is also used to add 1 to the actual storage capacity of the first-in-first-out cache unit after the first-in-first-out cache unit completes the write operation, subtract 1 from the actual storage capacity of the first-in-first-out cache unit after the first-in-first-out cache unit completes the read operation, and subtract the packet loss storage capacity from the actual storage capacity of the first-in-first-out cache unit after the first-in-first-out cache unit completes the packet loss processing, and the packet loss storage capacity is determined based on the difference between the current write address of the first-in-first-out cache unit and the start write address.
5. The message storage device according to any one of claims 1 to 4, characterized in that: The message storage device also includes: A message processing engine is used to read the metadata from the first-in-first-out cache unit, determine a forwarding decision for the message data corresponding to the metadata based on the metadata, and forward the message data subsequently read from the first-in-first-out cache unit based on the forwarding decision.
6. A message storage method, characterized in that: include: If message data carrying a message start identifier is received, then in the first time slot of receiving the message data carrying the message start identifier, the current write address of the first-in-first-out cache unit is latched as the start write address; wherein the bit width of the first-in-first-out cache unit is twice the bit width of the message data; Starting from the second time slot when the message data carrying the message start identifier is received, writing the received message data into the first-in-first-out cache unit from the next address of the start write address until the message data carrying the message end identifier is received; In a first time slot when receiving message data carrying a message end identifier, writing the message data carrying the message end identifier into the first-in-first-out cache unit; After receiving the second time slot of the message data carrying the message end identifier, the current write address of the first-in-first-out cache unit is restored to the start write address, and metadata corresponding to the message data is written.
7. The message storage method according to claim 6, characterized in that: The method further comprises: In the first time slot when the message data carrying the message end mark is received, the current write address of the first-in-first-out cache unit is latched as the message end address; After the metadata is written in the second time slot after receiving the message data carrying the message end identifier, the current write address is restored to the message end address.
8. The message storage method according to claim 6, characterized in that: The method further comprises: When packet loss processing is required, the current write address of the first-in-first-out cache unit is restored to the start write address.
9. The message storage method according to claim 6, characterized in that: The method further comprises: After the first-in-first-out cache unit completes the write operation, the actual storage capacity of the first-in-first-out cache unit is increased by 1; After the first-in-first-out cache unit completes the read operation, the actual storage capacity of the first-in-first-out cache unit is reduced by 1; After the FIFO cache unit completes packet loss processing, the packet loss storage capacity is subtracted from the actual storage capacity of the FIFO cache unit, where the packet loss storage capacity is determined based on the difference between the current write address of the FIFO cache unit and the start write address.
10. The message storage method according to claim 9, characterized in that: The method further comprises: Reading the metadata from the first-in-first-out cache unit; Determine, based on the metadata, a forwarding decision for the message data corresponding to the metadata; The message data subsequently read from the first-in-first-out cache unit is forwarded based on the forwarding decision.
Citation Information
Patent Citations
Method, device and equipment for caching cell data
CN104850515A
Data access / storage method and device for cloud storage service system
CN106021381A
Method, device and system for updating metadata
CN106528866A
Metadata access method and device and computer readable storage medium
CN112000623A
Metadata storage method, device, equipment and product
CN112463037A