Shared cache distribution system
By uniformly managing the shared cache's free list and dynamic allocation mechanism, the problems of decentralized management logic and complex resource coordination in traditional shared cache architectures are resolved, achieving more efficient memory utilization and management and adapting to the performance requirements of high-speed switching chips.
Patent Information
- Application Number
- CN202510842187.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-20
- Publication Date
- 2025-09-16
AI Technical Summary
When processing multi-port parallel access, the traditional shared cache architecture has problems such as decentralized management logic, complex resource coordination, and high logical resource consumption, resulting in low memory utilization.
A shared cache management module is used to manage the free cache units of all ports through a unified free linked list. The cache management unit dynamically allocates cache resources on demand and links the cache units using linked list pointers to achieve fragment-free allocation across memories.
It significantly reduces logic resource consumption, improves shared cache utilization and management efficiency, and meets the performance, efficiency, and cost requirements of high-speed switching chips.
Smart Images

Figure CN120658765A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to data shared cache technology, and in particular to a shared cache allocation system. Background Art
[0002] Switches that support store-and-forward mode need to temporarily store packets to be forwarded within the switch. Traditional solutions, which allocate a fixed buffer area to each switch port, suffer from low memory utilization. This paper proposes a solution that supports multi-port concurrent access to a shared cache. Traditional shared cache architectures consist of multiple static random-access memories (SRAMs), which can be accessed simultaneously, improving utilization. Due to its high resource utilization and flexible resource allocation, traditional shared cache architectures have become a mainstream solution for high-speed switching chips.
[0003] However, in this solution, each SRAM needs to process the access request of the input port separately and maintain the free cache unit separately. The processing process is complicated, consumes more logic resources, and reduces the management efficiency of the shared cache. Summary of the Invention
[0004] The present application provides a shared cache allocation system with low resource consumption and high management efficiency.
[0005] A shared cache allocation system, comprising: A shared cache management module includes a cache management unit, a data linked list, and a free linked list, wherein the data linked list includes at least one data cache unit and a data information unit corresponding to the data cache unit in a one-to-one manner, and the free linked list includes multiple free cache units and free information units corresponding to each free cache unit in a one-to-one manner; wherein the information unit of each cache unit includes a linked list pointer with an address of the next cache unit in the same linked list written therein, so as to link the cache units in the same linked list; a port receiving module connected to the shared cache management module, configured to, in each round of data receiving process, when writing a data packet into a target data cache unit in the data linked list, issue a first cache request if the target data cache unit is full; The cache management unit is configured to obtain a head-end free cache unit of the free linked list according to the first cache request, obtain a first allocated cache unit, and update the next free cache unit linked to the first allocated cache unit to the head-end free cache unit; The port receiving module is also used for: Writing the address of the first allocation cache unit into the linked list pointer of the target data information unit to link the first allocation cache unit to the target data cache unit to obtain the new data linked list; wherein the target data information unit is a data information unit corresponding to the target data cache unit; The first allocated cache unit is updated to the target data cache unit, and the data packet is written into the updated target data cache unit.
[0006] In one embodiment, the port receiving module is further configured to issue a pre-cache request when the shared cache management module is initialized; The cache management unit is further configured to use the head-end free cache unit as the target data cache unit in a first round of data receiving process according to the pre-cache request.
[0007] In one embodiment, the port receiving module is further configured to issue a second cache request if the data packet is received completely and it is determined that the data packet does not need to be discarded; The cache management unit is configured to obtain the head-end free cache unit according to the second cache request, obtain a second allocated cache unit, and update the next free cache unit linked to the second allocated cache unit as the head-end free cache unit; The port receiving module is further used for: The second allocated cache unit is updated to the target data cache unit.
[0008] In one embodiment, the shared cache management module further includes a plurality of cache pools, each of which corresponds to a corresponding number of free cache units in the free linked list; wherein the types of the cache pools include a global cache pool and a dedicated cache pool, and the capacity of the global cache pool is greater than that of the dedicated cache pool; The cache management unit is further configured to determine a usage of a target cache pool according to a target cache request, and based on the usage of the target cache pool: Determine whether to use the free cache unit corresponding to the global cache pool or the free cache unit corresponding to the dedicated cache pool for the port receiving module to use for data reception, and update the usage of the cache pool after the use; wherein the target cache pool includes at least one of the global cache pool and the dedicated cache pool; Obtain the head-end free cache unit to obtain the target allocated cache unit; wherein the target cache request is the first cache request and the target allocated cache unit is the first allocated cache unit, or the target cache request is the second cache request and the target allocated cache unit is the second allocated cache unit.
[0009] In one embodiment, the target cache pool is the global cache pool; the cache management unit is further configured to, upon receiving the target cache request, determine to use the free cache units in the global cache pool if the free cache units in the global cache pool are not exhausted, and update the usage of the global cache pool after the use.
[0010] In one embodiment, the first cache request includes a processing priority of the data packet; the cache management unit is further configured to, upon receiving the target cache request, determine to use the free cache unit in the dedicated cache pool if the free cache units in the global cache pool have been exhausted, the processing priority indicates selecting the free cache unit corresponding to the dedicated cache pool, and the free cache units corresponding to the dedicated cache pool have not been exhausted, and update the usage of the dedicated cache pool after being used.
[0011] In one embodiment, the cache management unit is further configured to, upon receiving the target cache request, output a request failure message if the free cache units corresponding to the global cache pool have been exhausted, the processing priority indicates selecting the free cache units in the dedicated cache pool, but the free cache units in the dedicated cache pool have been exhausted; The port receiving module is further configured to determine, based on the application failure information, whether to discard the written data packet.
[0012] In one embodiment, the cache management unit is further configured to, upon receiving the target cache request, output an application failure message if the free cache units corresponding to the global cache pool have been exhausted and the processing priority does not indicate selection of the free cache units corresponding to the dedicated cache pool; The port receiving module is further configured to determine, based on the application failure information, whether to discard the written data packet.
[0013] In one embodiment, the port receiving module is further configured to determine whether to discard the written data packet if the data packet reception is completed.
[0014] In one embodiment, the port receiving module is further configured to use the first target data cache unit that has stored the data packet as the target data cache unit in the next round of data receiving process after determining to discard the data packet.
[0015] In one embodiment, the shared cache management module further includes a free chain head pointer storing the address of the head-end free cache unit; The cache management unit is further configured to: The free cache unit pointed to by the free chain head pointer is obtained according to the target cache request to obtain the head-end free cache unit.
[0016] In one embodiment, the cache management unit is further configured to: The address in the free chain head pointer is updated to the address of the next free cache unit linked to the target allocated cache unit in the free chain list, so as to update the next free cache unit linked to the target allocated cache unit to the head-end free cache unit.
[0017] The above-mentioned method sets up information units to uniformly incorporate all free cache units into a global free linked list through the linked list pointer in the information unit. All ports share the same free linked list, and the cache management unit is responsible for allocation and cache management. Free cache units of any size are allocated on demand, dynamically and without fragmentation according to requests. Compared with the traditional solution in which each memory needs to maintain its own free unit pool and cross-memory allocation requires complex coordination, this application directly solves the key defects of the traditional shared cache architecture in which management logic is dispersed, resource coordination is complex, and logical resource consumption is large, achieving the technical effect of significantly reducing logical resource consumption, greatly improving shared cache utilization and allocation management efficiency, making it more adaptable to the performance, efficiency and cost requirements of high-speed switching chips. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 This is a structural block diagram of a shared cache allocation system according to an embodiment of the present application; Figure 2 A schematic diagram of the structure of a free linked list and a data linked list according to an embodiment of the present application; Figure 3 A schematic diagram of the structure of a free linked list and a data linked list according to another embodiment of the present application; Figure 4 A schematic diagram of the structure of a free linked list and a data linked list according to another embodiment of the present application; Figure 5 This is a schematic diagram of the workflow of the port receiving module for this application; Figure 6 This is a workflow diagram of the cache management unit for this application. DETAILED DESCRIPTION
[0019] It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application.
[0020] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0021] It should be noted that all directional indications in the embodiments of the present application (such as up, down, left, right, front, back, etc.) are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly. The connection can be a direct connection or an indirect connection.
[0022] In addition, the descriptions of "first", "second", etc. in this application are for descriptive purposes only and should not be understood as indicating or implying their relative importance or implicitly indicating the number of the technical features indicated. Therefore, the features defined as "first" or "second" may explicitly or implicitly include at least one of such features. In addition, the technical solutions between the various embodiments can be combined with each other, but this must be based on the fact that they can be implemented by ordinary technicians in this field. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.
[0023] Figure 1 FIG. 1 is a structural block diagram of a shared cache allocation system according to an embodiment of the present invention. Figure 1As shown, the shared cache allocation system includes a shared cache management module 110 and a port receiving module 120, the shared cache management module 110 includes a cache management unit 111, a data linked list 112 and a free linked list 113, wherein the data linked list 112 includes at least one data cache unit and a data information unit corresponding to the data cache unit, and the free linked list 113 includes multiple free cache units and free information units corresponding to each free cache unit; wherein the information unit of each cache unit includes a linked list pointer with the address of the next cache unit in the same linked list written therein, so as to link the cache units under the same linked list; the port receiving module 120 is connected to the shared cache management module 110, and is used to write a data packet into the destination list in the data linked list 112 in each round of data receiving process. When the target data cache unit is filled, a first cache request is issued; the cache management unit 111 is used to obtain the head-end free cache unit of the free list 113 according to the first cache request, obtain the first allocated cache unit, and update the next free cache unit linked to the first allocated cache unit to the head-end free cache unit; the port receiving module 120 is also used to: write the address of the first allocated cache unit into the linked list pointer of the target data information unit to link the first allocated cache unit to the target data cache unit to obtain a new data linked list 112; wherein the target data information unit is a data information unit corresponding to the target data cache unit; update the first allocated cache unit to the target data cache unit, and write the data packet into the updated target data cache unit.
[0024] It can be understood that the free list 113 is formed by linking the currently unused free cache units, and the data list 112 is formed by linking the data cache units that currently store data packets. When the data packet is cached, the free cache unit is selected from the free list 113 as the data cache unit, and then the data is written. When the data packet is large and a single free cache unit cannot be completely written, a chain structure is used to take out multiple free cache units in turn, and the data packet is written together through fragmented storage to form a data linked list 112 composed of multiple data cache units. Due to the linking effect of the linked list pointer, the arrangement order of each data fragment in each data cache unit is consistent with the data packet, ensuring the continuity of the data packet.
[0025] Each cache unit in the free list 113 and the data list 112 corresponds to an information unit, and the information unit has the same address as the corresponding cache unit. Figure 2 As shown in the figure, for any linked list, the cache unit with address 1 corresponds to the information unit with address 1, and the cache unit with address n corresponds to the information unit with address n. The corresponding information cache unit is provided with a linked list pointer, which has the address of the next cache unit, thereby connecting the cache units under the same linked list in series. For example, Figure 3 As shown, for the free linked list 113, by using the linked list pointer to write the address of the next free cache unit in the free information unit, the free cache unit with address 0 (the linked list pointer points to address 1), the free cache unit with address 1 (the linked list pointer points to address 4), the free cache unit with address 4 (the linked list pointer points to address 5), the free cache unit with address 5 (the linked list pointer points to address 8) ... can be sequentially connected; similarly, for the data linked list 112, by using the linked list pointer to write the address of the next data cache unit in the data information unit, the data cache unit with address 2 (the linked list pointer points to address 6), the data cache unit with address 6 (the linked list pointer points to address 10), the data cache unit with address 10 (the linked list pointer points to address 14), the data cache unit with address 14 ... can be sequentially connected; wherein, according to the number of data packets, the data linked list 112 may include multiple, with Figure 3 For example, there may also be a data linked list 112 consisting of a data cache unit with an address of 17, a data cache unit with an address of 16, a data cache unit with an address of 12, and so on.
[0026] The port receiving module 120 is responsible for receiving and caching data packets. One round of data receiving process represents the receiving and caching of one data packet. In each round of data reception, the cache management unit 111 initially retrieves a free cache unit from the free linked list 113 as the starting target data cache unit for the data packet and allocates it to the port receiving module 120, allowing the port receiving module 120 to begin writing data to this target data cache unit. During the writing process, the port receiving module 120 checks whether the current target data cache unit is full. If so, the port receiving module 120 issues a first cache request to the cache management unit 111, requesting allocation of a new cache unit to continue storing the remaining portion of the data packet. After receiving the first cache request, the cache management unit 111 retrieves the first free cache unit from the head of the free linked list 113, i.e., the head free cache unit, and uses it as the first allocated cache unit. The cache management unit 111 then updates the head of the free linked list, setting the next free cache unit originally linked after the head free cache unit (found through the linked list pointer in its corresponding free information unit) as the new head free cache unit. The port receiving module 120 writes the address of the first allocated cache unit into the linked list pointer of the current target data information unit. In this way, the original target data cache unit (already full) points to the new first allocated cache unit through its linked list pointer. These two units and all the units of the data packet that have been written before are now logically connected in series on the same data linked list 112, representing the same data packet. Figure 3As shown, the data cache unit at address 14 may be the last data cache unit of one of the data linked lists 112. The schematic diagram of the linked free list 113 and the data linked list 112 can be referred to. Figure 4 shown.
[0027] Furthermore, the port receiving module 120 sets the first allocated buffer unit as the new target data buffer unit for further data packet writing. If the new target data buffer unit is full again, the above process continues until the entire data packet is written. Ultimately, a data packet may occupy multiple data buffer units, which are connected together to form a data linked list 112 through the linked list pointers in their respective information units. In some embodiments, the port receiving module 120 may include multiple receiving ports to enable the parallel reception of multiple data packets.
[0028] In this way, compared with the traditional solution in which each memory needs to maintain its own free unit pool and cross-memory allocation requires complex coordination, the present application sets an information unit to unify all free cache units into a global free linked list 113 through the linked list pointer in the information unit. All ports share the same free linked list 113, and the cache management unit 111 is responsible for allocation and cache management. Free cache units of any size are allocated on demand, dynamically and without fragmentation according to requests. This directly solves the key defects of the traditional shared cache architecture in which management logic is dispersed, resource coordination is complex, and logical resource consumption is large. It achieves the technical effect of significantly reducing logical resource consumption, greatly improving shared cache utilization and allocation management efficiency, making it more adaptable to the performance, efficiency and cost requirements of high-speed switching chips.
[0029] In one embodiment, the port receiving module 120 is further configured to issue a pre-cache request when the shared cache management module 110 is initialized; the cache management unit 111 is further configured to use the head-end free cache unit as the target data cache unit in the first round of data receiving process according to the pre-cache request.
[0030] It can be understood that by applying for the head-end free cache unit as the target data cache unit in the first round of data receiving process when the shared cache management module 110 is initialized, when the first actual data packet arrives at the port, the port receiving module 120 does not need to wait for the allocation cache first, but can immediately start writing the data into the pre-allocated target data cache unit, skipping the waiting time for the first allocation, eliminating the first packet allocation delay, and improving the overall throughput performance of the system when processing the initial data stream.
[0031] In one embodiment, the port receiving module 120 is further used to issue a second cache request if the data packet reception is completed and it is determined that the data packet does not need to be discarded; the cache management unit 111 is used to obtain the head-end free cache unit according to the second cache request, obtain the second allocated cache unit, and update the next free cache unit linked to the second allocated cache unit to the head-end free cache unit; the port receiving module 120 is also used to update the second allocated cache unit to the target data cache unit.
[0032] It can be understood that if the data packet is received and it is determined that it does not need to be discarded, a target data cache unit can be requested in time to prepare for the reception of the next data packet. In this way, by pre-allocating at the same time as the reception is completed, the first allocation delay of the next data packet can be eliminated.
[0033] In one embodiment, the shared cache management module 110 further includes a plurality of cache pools, each of which corresponds to a corresponding number of free cache units in the free linked list 113; wherein the types of cache pools include global cache pools and dedicated cache pools; the cache management unit 111 is further configured to determine the usage of the target cache pool according to the target cache request, and based on the usage of the target cache pool: determine whether to use the free cache units corresponding to the global cache pool, or select to use the free cache units corresponding to the dedicated cache pool, and update the usage of the used cache pool; wherein the target cache pool includes at least one of the global cache pool and the dedicated cache pool; obtain the head-end free cache units to obtain the target allocated cache units; wherein the target cache request is a first cache request, and the target allocated cache unit is the first allocated cache unit, or the target cache request is a second cache request, and the target allocated cache unit is the second allocated cache unit.
[0034] It can be understood that the system includes multiple cache pools, each of which is associated with a specific number of free cache units in the free list 113. The types of cache pools include global cache pools and dedicated cache pools. The global cache pool serves as a system-level shared resource pool, which can achieve efficient sharing of a larger cache area, while the dedicated cache pool can be bound to a specific port or priority to provide exclusive resource guarantees and provide minimum cache resource guarantees for specific traffic categories. Each pool independently maintains its free unit list segment and usage counter to achieve resource isolation statistics.
[0035] During the data packet reception phase, the cache management unit 111 acquires the first allocated cache unit as follows: First, the cache management unit 111 determines the target cache pool usage based on the first cache request. Then, based on the target cache pool usage, it selects a free cache unit corresponding to the global cache pool or dedicated cache pool and updates the usage of the free cache units in the selected global cache pool or dedicated cache pool accordingly. Similarly, during the data packet reception completion phase, the cache management unit 111 acquires the second allocated cache unit in the same manner. This multi-level cache pool dynamic management mechanism allows for flexible configuration of the size and access restrictions of each cache pool. Ordinary traffic shares a global cache pool, while critical traffic uses a reserved dedicated cache pool, providing increased reliability for critical traffic.
[0036] In one embodiment, the target cache pool is the global cache pool; the cache management unit 111 is further configured to, upon receiving a target cache request, access free cache units in the global cache pool if the free cache units in the global cache pool are not exhausted, and update the usage of the accessed global cache pool.
[0037] It can be understood that whether the free cache units in the global cache pool are exhausted can be determined based on the usage of the global cache pool. The system can give priority to using the free cache units in the global cache pool and reduce the usage of the global cache pool accordingly after the use. The dedicated cache pool is only used as a final guarantee and remains idle most of the time to avoid the erosion of the dedicated cache pool by burst traffic, while improving the utilization rate of the global cache pool, which can significantly accelerate the processing of burst traffic.
[0038] In one embodiment, the target cache request includes a processing priority of the data packet; the cache management unit 111 is further configured to, upon receiving the target cache request, determine to use the free cache units in the dedicated cache pool if the free cache units in the global cache pool have been exhausted, the processing priority indicates selecting the free cache units corresponding to the dedicated cache pool, and the free cache units corresponding to the dedicated cache pool have not been exhausted, and update the usage of the dedicated cache pool after the use.
[0039] It is understood that when the global pool is exhausted, the decision to activate the dedicated buffer pool can be made based on the processing priority. If it is determined that the dedicated buffer pool is to be activated and the dedicated buffer pool is not exhausted, the dedicated buffer pool will be used, thereby correspondingly reducing the usage of the dedicated buffer pool after it is used. This ensures that the dedicated buffer pool is a high-priority exclusive pool and that the high-priority dedicated pool is not contaminated by low-priority services. The processing priority of the data packet can be obtained by the port receiving module 120 through its internal priority parser or reception feature matcher after parsing the data packet. The processing priority is then transmitted when sending the first cache request and the second cache request.
[0040] In one embodiment, the cache management unit 111 is further configured to, upon receiving a target cache request, output an application failure message if the free cache units corresponding to the global cache pool have been exhausted and the processing priority indicates selecting the free cache units in the dedicated cache pool, but the free cache units in the dedicated cache pool have been exhausted; the port receiving module 120 is further configured to determine whether to discard the written data packet based on the application failure information.
[0041] It can be understood that since the global pool is exhausted, the cache management unit 111 attempts to select a free cache unit in the dedicated cache pool according to the processing priority indication. If the free units in the dedicated cache pool are also exhausted, it indicates that the cache management unit 111 cannot allocate any cache resources at this time. At this time, the application failure information is output to the port receiving module 120 to instruct the port receiving module 120 to abandon the currently received data packet, thereby releasing cache resources, preventing the system from falling into a stagnant state, and reducing the impact on the reception of the next data packet.
[0042] In one embodiment, the cache management unit 111 is further configured to output an application failure message upon receiving a target cache request if the free cache units corresponding to the global cache pool have been exhausted and the processing priority does not indicate the selection of the free cache units corresponding to the dedicated cache pool; the port receiving module 120 is further configured to determine whether to discard the written data packets based on the application failure information.
[0043] It can be understood that when the free cache units corresponding to the global cache pool have been exhausted and the processing priority does not indicate the selection of the free cache units corresponding to the dedicated cache pool, even if there are still free cache units in the dedicated cache pool, they will not be taken from the dedicated cache pool. In this way, the dedicated pool can be isolated from low-priority traffic through the priority threshold to ensure that the dedicated resources of high-priority services are not occupied by low-priority requests.
[0044] In one embodiment, the port receiving module 120 is further configured to determine whether to discard the written data packet if the data packet reception is completed.
[0045] It can be understood that the port receiving module 120 has a filtering function and can detect whether the received data packet meets the cache requirements. If it meets the requirements, it is determined that the data packet does not need to be discarded. If it does not meet the requirements, it is determined that the data packet needs to be discarded, thereby releasing cache resources.
[0046] In one embodiment, the port receiving module 120 is further configured to use the first target data cache unit that has stored the data packet as the target data cache unit in the next round of data receiving process after determining to discard the data packet.
[0047] It can be understood that after determining that a data packet needs to be discarded, in order to ensure that the port receiving module 120 does not need to temporarily apply for a new target data cache unit when the next data packet arrives, the first target data cache unit storing the data packet to be discarded can be directly allocated to the next data packet for caching, and the remaining other data cache units are obtained through application and can enter the subsequent recovery process.
[0048] In this way, by pre-allocating the first target data cache unit for each data packet, the waiting time for the first allocation is skipped and the first allocation delay is eliminated.
[0049] In one embodiment, the shared cache management module 110 further includes a free chain head pointer storing the address of the head-end free cache unit; the cache management unit 111 is further configured to obtain the head-end free cache unit pointed to by the free chain head pointer according to the target cache request.
[0050] It can be understood that the head free cache unit in the free list 113 is not linked to other free cache units. Compared with traversing each free cache unit to see whether it is linked to other free cache units to determine whether it is the head free cache unit, this embodiment marks the head free cache unit of the free list 113 with the free chain head pointer, and can quickly determine the address of the head free cache unit without scanning the entire free list 113. It is simple and efficient.
[0051] In one embodiment, the cache management unit 111 is also used to: update the address in the free chain head pointer to the address of the next free cache unit linked to the target allocation cache unit in the free list 113, so as to update the next free cache unit linked to the target allocation cache unit to the head-end free cache unit; wherein the target cache request is a first cache request, the target allocation cache unit is a first allocation cache unit, or the target cache request is a second cache request, the target allocation cache unit is a second allocation cache unit.
[0052] It can be understood that after obtaining the first-end free cache unit as the allocated cache unit, since the allocated cache unit is to be used as the target data cache unit for data caching, it can no longer be reallocated as a free cache unit in the free list 113. At this time, the address in the free chain head pointer can be updated, and the next free cache unit linked to the original first-end free cache unit can be used as the new first-end free cache unit for allocation when the data packet is received.
[0053] In this way, the head free cache unit of the free list 113 is marked by the free chain head pointer. After the head free cache unit is allocated during the data receiving process, the address of the next free cache unit linked to it is written into the free chain head pointer to overwrite the address of the original head free cache unit, thereby becoming the new head free cache unit. The method of using the chain head pointer for jumping is simple and easy to manage.
[0054] An embodiment of the present invention further provides a shared cache allocation system, comprising a shared cache management module 110 and a port receiving module 120, wherein the shared cache management module 110 comprises a cache management unit 111, a data linked list 112, and a free linked list 113, wherein the data linked list 112 comprises at least one data cache unit and a data information unit corresponding one-to-one to each data cache unit, and the free linked list 113 comprises a plurality of free cache units and a free information unit corresponding one-to-one to each free cache unit; wherein the information unit of each cache unit comprises a linked list pointer having the address of the next cache unit in the same linked list written therein, so as to link the cache units under the same linked list. The working steps of each module unit in the allocation phase may include steps (a1) to (a22).
[0055] In step (a1), the port receiving module 120 issues a pre-cache request when the shared cache management module 110 is initialized. The cache management unit 111 uses the head-end free cache unit as the target data cache unit in the first round of data receiving process according to the pre-cache request.
[0056] Step (a2): in each round of data receiving process, when the port receiving module 120 writes a data packet into the target data cache unit in the data linked list 112 , if the target data cache unit is full, the port receiving module 120 issues a first cache request.
[0057] In step (a3), the shared cache management module 110 further includes a plurality of cache pools, each of which corresponds to a corresponding number of free cache units in the free linked list 113; wherein the types of cache pools include a global cache pool and a dedicated cache pool; the cache management unit 111 is further configured to, upon receiving the first cache request, determine to use the free cache units in the global cache pool if the free cache units in the global cache pool are not exhausted, and update the usage of the global cache pool after the use.
[0058] In step (a4), the first cache request includes a processing priority of the data packet; the cache management unit 111 is further configured to, upon receiving the first cache request, determine to use a free cache unit in the dedicated cache pool if the free cache units in the global cache pool have been exhausted, the processing priority indicates selecting a free cache unit corresponding to the dedicated cache pool, and the free cache units corresponding to the dedicated cache pool have not been exhausted, and update the usage of the dedicated cache pool after the free cache units are used.
[0059] In step (a5), the cache management unit 111 is further configured to obtain the free cache unit pointed to by the free chain head pointer according to the first cache request, obtain the head-end free cache unit, and use the head-end free cache unit as the first allocated cache unit.
[0060] Step (a6) updates the address in the free chain head pointer to the address of the next free cache unit linked to the first allocated cache unit in the free chain list 113, so as to update the next free cache unit linked to the first allocated cache unit to the head end free cache unit.
[0061] Step (a7): updating the first allocated cache unit to the target data cache unit, and writing the data packet into the updated target data cache unit.
[0062] In step (a8), the cache management unit 111 is further configured to, upon receiving the first cache request, output an application failure message if the free cache units corresponding to the global cache pool have been exhausted, the processing priority indicates selecting the free cache units in the dedicated cache pool, but the free cache units in the dedicated cache pool have been exhausted.
[0063] In step (a9), the cache management unit 111 is further configured to output an application failure message when receiving the first cache request if the free cache units corresponding to the global cache pool are exhausted and the processing priority does not indicate selecting the free cache units corresponding to the dedicated cache pool.
[0064] In step (a10), the port receiving module 120 is further configured to determine whether to discard the written data packet according to the application failure information.
[0065] In step (a11), the port receiving module 120 is further configured to determine whether to discard the written data packet if the data packet reception is completed.
[0066] In step (a12), the port receiving module 120 is further configured to use the first target data cache unit that has stored the data packet as the target data cache unit in the next round of data receiving process after determining to discard the data packet.
[0067] In step (a13), the port receiving module 120 is further configured to issue a second buffer request if the data packet is received completely and it is determined that the data packet does not need to be discarded.
[0068] In step (a14), the cache management unit 111 is further configured to, upon receiving the second cache request, determine to use a free cache unit in the global cache pool if the free cache units in the global cache pool are not exhausted, and update the usage of the used global cache pool.
[0069] In step (a15), the second cache request includes a processing priority of the data packet; the cache management unit 111 is further configured to, upon receiving the second cache request, determine to use a free cache unit in the dedicated cache pool if the free cache units in the global cache pool have been exhausted, the processing priority indicates selecting a free cache unit corresponding to the dedicated cache pool, and the free cache units corresponding to the dedicated cache pool have not been exhausted, and update the usage of the dedicated cache pool after the free cache units are used.
[0070] In step (a16), the cache management unit 111 is further configured to obtain the free cache unit pointed to by the free chain head pointer according to the second cache request, obtain the head-end free cache unit, and use the head-end free cache unit as the second allocated cache unit.
[0071] Step (a17) updates the address in the free chain head pointer to the address of the next free cache unit linked to the second allocated cache unit in the free chain list 113, so as to update the next free cache unit linked to the second allocated cache unit to the head end free cache unit.
[0072] Step (a18): updating the second allocated cache unit to a target data cache unit for caching the next round of data packets.
[0073] In step (a19), the cache management unit 111 is further configured to, upon receiving the second cache request, output an application failure message if the free cache units corresponding to the global cache pool have been exhausted, the processing priority indicates selecting the free cache units in the dedicated cache pool, but the free cache units in the dedicated cache pool have been exhausted.
[0074] In step (a20), the cache management unit 111 is further configured to output an application failure message when receiving the second cache request if the free cache units corresponding to the global cache pool are exhausted and the processing priority does not indicate selecting the free cache units corresponding to the dedicated cache pool.
[0075] In step (a21), the port receiving module 120 is further configured to determine whether to discard the written data packet according to the application failure information.
[0076] In step (a22), the port receiving module 120 is further configured to use the first target data cache unit that has stored the data packet as the target data cache unit in the next round of data receiving process after determining to discard the data packet.
[0077] It should be understood that although the various steps in steps (a1) to (a22) are shown in sequence according to the numbering, these steps are not necessarily performed in the order indicated by the arrows or numbers. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be performed in other orders. Moreover, at least a portion of the above steps may include multiple steps or multiple stages, and these steps or stages are not necessarily performed at the same time, but can be performed at different times. The order of execution of these steps or stages is not necessarily sequential, but can be performed in rotation or alternation with other steps or at least a portion of the steps or stages in other steps.
[0078] The specific working process of the port receiving module 120 in the shared cache allocation system according to the embodiment of the present invention can be referred to Figure 5 shown.
[0079] First, the port receiving module 120 determines whether the shared cache management module 110 has been initialized. If so, a pre-cache request is issued to pre-apply for a free cache unit from the head end of the free list 113 as the current cache unit. Otherwise, the module continues to determine whether the initialization is complete. Then, when a new data packet is received, the data packet is written into the current cache unit. If the current cache unit is full, a cache request is issued to the cache management unit 111 to apply for a new free cache unit. Otherwise, the data packet fragments are written into the current cache unit in sequence until the entire data packet is received or the current cache unit is full.
[0080] If the current cache unit is full and the port receiving module 120 successfully applies for a new free cache unit, the address of the newly applied free cache unit is written into the information unit corresponding to the previously full free cache unit, so that the newly applied free cache unit is linked to the full current cache unit to form a data linked list 112, and the newly applied free cache unit is used as the new current cache unit to continue caching the data packet; if the current cache unit is full, but the port receiving module 120 does not successfully apply for a new free cache unit, the port receiving module 120 determines to discard the currently received data packet and determines whether there is a successfully applied cache unit in the current data packet process. If the judgment result is yes, it indicates that in addition to the free cache unit pre-applied and allocated at the beginning, other free cache units are applied for in this round of data receiving process. At this time, the other applied free cache units are recycled, and the free cache unit pre-applied and allocated at the beginning is used as the current cache unit for the next round of data caching.
[0081] If the data packet reception is completed, the port receiving module 120 determines whether the data packet needs to be discarded. If it needs to be discarded, it is similar to the above-mentioned discarding step to further determine whether there is a cache unit that has been successfully applied for in the current data packet process; if it does not need to be discarded, it continues to apply for a new free cache unit. If the application is unsuccessful, it is similar to the above-mentioned discarding step to further determine whether there is a cache unit that has been successfully applied for in the current data packet process; if the application is successful, in order to realize subsequent data recovery, the end of the linked list flag and the valid data length of the data packet are written into the current cache unit to update the information unit corresponding to the current cache unit, and then the newly applied cache unit is used as the new current cache unit as a pre-application for the free cache unit in the next round of receiving process; finally, the address of the head-end data cache unit in the data linked list 112 is written into the to-be-sent queue of the port sending module to further realize the sending of subsequent data packets.
[0082] The specific working process of the cache management unit 111 in the shared cache allocation system according to the embodiment of the present invention can be referred to Figure 6 shown.
[0083] First, upon receiving a cache request from the port receiving module 120, the cache management unit 111 determines whether it is an initialization pre-application. If not, it determines the processing priority of the packet based on the cache request and then determines the cache pool mapped to that priority. It then determines whether the global cache pool is exhausted. If not, it accesses the corresponding free cache unit in the global cache pool, increments the global cache pool usage by one, and notifies the port receiving module 120 that the cache request is successful. It then allocates the free cache unit pointed to by the free chain head pointer to the port receiving unit and moves the free chain head pointer to the node pointed to by the previous free chain head pointer. If the global cache pool is exhausted, it is determined whether the processing priority is mapped to the dedicated cache pool. If not, a message indicating a cache application failure is sent to the port receiving module 120. If yes, it is further determined whether the corresponding dedicated cache pool is exhausted. If not, the usage of the corresponding dedicated cache pool is increased by one, and a message indicating a cache application success is sent to the port receiving module 120. The free cache unit pointed to by the free chain head pointer is allocated to the port receiving unit, and the free chain head pointer is moved to the node pointed to by the original free chain head pointer. If exhausted, a message indicating a cache application failure is sent to the port receiving module 120.
[0084] The above description is only a preferred embodiment of the present application and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A shared cache allocation system, characterized in that: include: A shared cache management module includes a cache management unit, a data linked list, and a free linked list, wherein the data linked list includes at least one data cache unit and a data information unit corresponding to the data cache unit in a one-to-one manner, and the free linked list includes multiple free cache units and free information units corresponding to each free cache unit in a one-to-one manner; wherein the information unit of each cache unit includes a linked list pointer with an address of the next cache unit in the same linked list written therein, so as to link the cache units in the same linked list; a port receiving module connected to the shared cache management module, configured to, in each round of data receiving process, when writing a data packet into a target data cache unit in the data linked list, issue a first cache request if the target data cache unit is full; The cache management unit is configured to obtain a head-end free cache unit of the free linked list according to the first cache request, obtain a first allocated cache unit, and update the next free cache unit linked to the first allocated cache unit to the head-end free cache unit; The port receiving module is also used for: Writing the address of the first allocation cache unit into the linked list pointer of the target data information unit to link the first allocation cache unit to the target data cache unit to obtain the new data linked list; wherein the target data information unit is a data information unit corresponding to the target data cache unit; The first allocated cache unit is updated to the target data cache unit, and the data packet is written into the updated target data cache unit.
2. The shared cache allocation system according to claim 1, wherein: The port receiving module is further configured to issue a pre-cache request when the shared cache management module is initialized; The cache management unit is further configured to use the head-end free cache unit as the target data cache unit in a first round of data receiving process according to the pre-cache request.
3. The shared cache allocation system according to claim 1, wherein: The port receiving module is further configured to issue a second cache request if the data packet is received completely and it is determined that the data packet does not need to be discarded; The cache management unit is configured to obtain the head-end free cache unit according to the second cache request, obtain a second allocated cache unit, and update the next free cache unit linked to the second allocated cache unit as the head-end free cache unit; The port receiving module is further used for: The second allocated cache unit is updated to the target data cache unit.
4. The shared cache allocation system according to claim 3, wherein: The shared cache management module further includes a plurality of cache pools, each of which corresponds to a corresponding number of free cache units in the free linked list; wherein the types of the cache pools include a global cache pool and a dedicated cache pool; The cache management unit is further configured to determine a usage of a target cache pool according to a target cache request, and based on the usage of the target cache pool: Determine whether to use the free cache unit corresponding to the global cache pool or the free cache unit corresponding to the dedicated cache pool for the port receiving module to use for data reception, and update the usage of the cache pool after the use; wherein the target cache pool includes at least one of the global cache pool and the dedicated cache pool; Obtain the head-end free cache unit to obtain the target allocated cache unit; wherein the target cache request is the first cache request and the target allocated cache unit is the first allocated cache unit, or the target cache request is the second cache request and the target allocated cache unit is the second allocated cache unit.
5. The shared cache allocation system according to claim 4, wherein: The target cache pool is the global cache pool; the cache management unit is further used to, upon receiving the target cache request, determine to use the free cache units in the global cache pool if the free cache units in the global cache pool are not exhausted, and update the usage of the global cache pool after the use.
6. The shared cache allocation system according to claim 5, characterized in that: The target cache request includes a processing priority of the data packet; the cache management unit is further configured to, upon receiving the target cache request, determine to use the free cache unit in the dedicated cache pool if the free cache units in the global cache pool have been exhausted, the processing priority indicates selecting the free cache unit corresponding to the dedicated cache pool, and the free cache units corresponding to the dedicated cache pool have not been exhausted, and update the usage of the dedicated cache pool after being used.
7. The shared cache allocation system according to claim 6, wherein: The cache management unit is further configured to, upon receiving the target cache request, output an application failure message if the free cache units corresponding to the global cache pool have been exhausted, the processing priority indicates selecting the free cache units in the dedicated cache pool, but the free cache units in the dedicated cache pool have been exhausted; The port receiving module is further configured to determine, based on the application failure information, whether to discard the written data packet.
8. The shared cache allocation system according to claim 6, wherein: The cache management unit is further configured to, upon receiving the target cache request, output an application failure message if the free cache units corresponding to the global cache pool have been exhausted and the processing priority does not indicate selection of the free cache units corresponding to the dedicated cache pool; The port receiving module is further configured to determine, based on the application failure information, whether to discard the written data packet.
9. The shared cache allocation system according to claim 2, wherein: The port receiving module is further configured to determine whether to discard the written data packet if the data packet reception is completed.
10. The shared cache allocation system according to any one of claims 7 to 9, characterized in that: The port receiving module is further configured to, after determining to discard the data packet, use the first target data cache unit that has stored the data packet as the target data cache unit in the next round of data receiving process.
11. The shared cache allocation system according to claim 4, wherein: The shared cache management module further includes an idle chain head pointer storing the address of the head-end idle cache unit; The cache management unit is further configured to obtain the free cache unit pointed to by the free chain head pointer according to the target cache request, to obtain the head-end free cache unit.
12. The shared cache allocation system according to claim 11, wherein: The cache management unit is further configured to: The address in the free chain head pointer is updated to the address of the next free cache unit linked to the target allocated cache unit in the free chain list, so as to update the next free cache unit linked to the target allocated cache unit to the head-end free cache unit.
Citation Information
Cited By
Buffer method and device based on dynamic linked list structure, computer equipment and medium
CN122332334A