Methods for handling cache access conflicts, caching systems, and network chips.

By recording the target address and status bits of data calculation operations in the cache system, the conflict between refresh scan operations and data calculation operations is resolved, data consistency between the cache and off-chip memory is achieved, and the stability and performance of data processing are ensured.

CN123123301APending Publication Date: 2026-11-17WUXI STARS MICRO SYSTEM TECHNOLOGIES CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611282970.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-21
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

In the caching system of a network chip, when refresh scan operations and data calculation operations access the same cache address, it can easily lead to inconsistencies between the cache and off-chip memory, affecting data processing performance.

Method used

By recording the target address and its status bits of the data calculation operation in the register array inside the cache, and comparing them during the refresh scan operation, refresh scan operations with conflicting addresses are prevented, and the refresh scan operation is delayed until the data calculation operation is completed.

Benefits of technology

This effectively avoids data inconsistency issues, ensures data consistency between the cache and off-chip memory, and guarantees the stability and performance of data processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123123301A_ABST
    Figure CN123123301A_ABST
Patent Text Reader

Abstract

This application relates to a method for handling cache access conflicts, a caching system, and a network chip. The method includes: in response to a data computation operation on the cache, recording the first target address corresponding to the data computation operation in a register array inside the cache, and setting the status bit corresponding to the first target address to valid; in response to a cache refresh scan operation, obtaining the second target address corresponding to the refresh scan operation; and if a first target address matching the second target address exists in the register array, and the status bit of the first target address matching the second target address is valid, preventing the refresh scan operation from being executed. The technical solution provided by this application effectively handles cache access conflicts and ensures data consistency between the cache and off-chip memory.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing technology, and in particular to a method for handling cache access conflicts, a caching system, and a network chip. Background Technology

[0002] With the rapid development of network technology, high-speed network interface cards (NICs) need to handle increasingly larger data throughputs. In network chip switches, various data calculation operations need to be performed on the data traffic. Due to limited on-chip storage resources, a large amount of calculated statistical data needs to be stored in off-chip memory. However, off-chip memory has high access latency, which cannot meet the performance requirements of high-speed statistical counting. Therefore, an on-chip cache is needed to cache the statistical data, and the data calculation operations must be completed within the cache.

[0003] To ensure that the software can access the latest statistical data, dirty data in the cache needs to be flushed to off-chip memory periodically. This process is called a flush scan operation. The flush scan operation must be performed simultaneously with normal data read / write and data calculation operations, without affecting normal business functions and processing performance.

[0004] However, data computation operations typically require multiple clock cycles to complete. If the refresh scan operation happens to access the same cache address as the data computation operation within this time window, it can easily cause inconsistencies between the cache and off-chip memory. Summary of the Invention

[0005] Therefore, it is necessary to provide a method for handling cache access conflicts, a cache system, and a network chip to address the above-mentioned technical problems, so as to solve the problem of data inconsistency between the cache and off-chip memory caused by operation conflicts when refresh scan operations and statistical counting operations access the same cache address.

[0006] Firstly, this application provides a method for handling cache access conflicts, including:

[0007] In response to a data calculation operation on the cache, the first target address corresponding to the data calculation operation is recorded in the register array inside the cache, and the status bit corresponding to the first target address is set to valid;

[0008] In response to a refresh scan operation on the cache, obtain the second target address corresponding to the refresh scan operation;

[0009] If a first target address that matches the second target address exists in the register array, and the status bit of the first target address that matches the second target address is valid, the refresh scan operation is prevented from being executed.

[0010] In one embodiment, the refresh scan operation is performed if there is no first target address in the register array that matches the second target address.

[0011] In one embodiment, the refresh scan operation is performed when the status bit corresponding to the first target address that is consistent with the second target address is invalid; wherein, when the data calculation operation corresponding to the first target address is completed, the status bit corresponding to the first target address is set to invalid.

[0012] In one embodiment, the execution time of the data calculation operation is a preset number of cycles, and the register array includes a plurality of first registers, the number of which is not less than the preset number of cycles; wherein, one first register is used to store one first target address.

[0013] In one embodiment, preventing the execution of the refresh scan operation includes:

[0014] The refresh scan instruction corresponding to the blocked refresh scan operation is temporarily stored in the second register inside the cache;

[0015] A backpressure signal is sent to the preceding command queue of the cache; wherein the backpressure signal is used to suspend reading instructions from the preceding command queue.

[0016] Secondly, this application also provides a caching system, including:

[0017] A cache controller, connected to the register array, the cache controller comprising:

[0018] The recording module is used to record the first target address corresponding to the data calculation operation in the register array in response to the data calculation operation in the cache, and set the status bit corresponding to the first target address to be valid;

[0019] The acquisition module is used to acquire the second target address corresponding to the refresh scan operation in response to the refresh scan operation of the cache;

[0020] The first control module is configured to prevent the refresh scan operation from being performed if a first target address that matches the second target address exists in the register array and the status bit of the first target address that matches the second target address is valid.

[0021] In one embodiment, the cache controller further includes:

[0022] The second control module is used to perform the refresh scan operation when there is no first target address in the register array that matches the second target address.

[0023] In one embodiment, the cache controller further includes:

[0024] The third control module is used to perform the refresh scan operation when the status bit corresponding to the first target address that is consistent with the second target address is invalid; wherein, when the data calculation operation corresponding to the first target address is completed, the status bit corresponding to the first target address is set to invalid.

[0025] In one embodiment, the execution time of the data calculation operation is a preset number of cycles, and the register array includes a plurality of first registers, the number of which is not less than the preset number of cycles; wherein, one first register is used to store one first target address.

[0026] In one embodiment, the caching system further includes a second register; the caching controller further includes:

[0027] The temporary storage module is used to temporarily store the refresh scan instruction corresponding to the blocked refresh scan operation in the second register;

[0028] The sending module is used to send a backpressure signal to the buffered front-end command queue; wherein the backpressure signal is used to pause reading instructions from the front-end command queue.

[0029] Thirdly, this application also provides a network chip including the caching system described in any of the embodiments of the second aspect above.

[0030] The aforementioned cache access conflict handling method, caching system, and network chip, during the execution of a data computation operation, record the first target address corresponding to the data computation operation in the register array inside the cache and set the status bit corresponding to the first target address to valid. This establishes a real-time information record within the cache that reflects the target address accessed by the currently executing data computation operation. Based on this, when a refresh scan operation is performed, the second target address corresponding to the refresh scan operation is obtained and compared with each of the first target addresses recorded in the register array. Since each first target address in the register array has a status bit indicating whether a data computation operation is being executed, if a first target address matching the second target address exists in the register array and its corresponding status bit is valid, it indicates that the cache address accessed by the current refresh scan operation is the same as the target address accessed by a currently executing data computation operation. At this point, by preventing the refresh scan operation from being executed, the data ejection action of the refresh scan operation can be delayed until after the data calculation operation corresponding to the first target address, which is consistent with the second target address, is completed. This avoids the refresh scan operation accessing the same target address during the data calculation operation, and prevents the problem of data inconsistency between the cache and off-chip memory caused by the refresh scan operation prematurely ejecting dirty data from the cache during the data calculation operation and then the data calculation operation writing new data to the cache. This effectively realizes the handling of cache access conflicts and ensures data consistency between the cache and off-chip memory. Attached Figure Description

[0031] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0032] Figure 1 This is a flowchart illustrating a method for handling cache access conflicts in one embodiment;

[0033] Figure 2 This is a flowchart illustrating a method for handling cache access conflicts in another embodiment;

[0034] Figure 3 This is a flowchart illustrating a method for handling cache access conflicts in yet another embodiment;

[0035] Figure 4 This is a schematic diagram of the structure of a caching system in one embodiment;

[0036] Figure 5This is a schematic diagram of the caching system in another embodiment. Detailed Implementation

[0037] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0038] It should be noted that the terms "first," "second," etc., used in this application can be used to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from the second element. The terms "comprising" and "having," and any variations thereof, used in this application, are intended to cover non-exclusive inclusion. The term "multiple" used in this application refers to two or more. The term "and / or" used in this application refers to one of the embodiments, or any combination of multiple embodiments.

[0039] With the rapid development of network technology, high-speed network interface cards (NICs) need to handle increasingly larger data throughputs. In network chip switches, various data calculations are required on the data traffic, such as the number of packets sent and received, traffic volume, and error counts. Due to the limited area and high cost of on-chip storage (i.e., storage resources integrated within the chip), it cannot meet the storage capacity requirements of large-scale data calculations. Therefore, a large amount of statistical data needs to be stored in off-chip memory. However, the access latency of off-chip memory (i.e., the time required from issuing a data access command to receiving data) is much greater than that of on-chip storage. If every data calculation directly accesses off-chip memory, it will severely restrict data processing performance. To balance the advantages of large capacity of off-chip storage and the high-speed access of on-chip storage, a cache needs to be set up on-chip to cache statistical data, so that data calculation operations are mainly completed within the cache, thereby achieving high access speed while ensuring data storage capacity.

[0040] To ensure that software (such as drivers or management programs running on the host machine) can access the latest statistics, dirty data (data that has been updated but not yet synchronized to off-chip memory) in the cache needs to be flushed to off-chip memory periodically. This flushing process is typically performed using a full address scan, starting from the first address of the cache and scanning sequentially to the last address. For each cache line, its dirty bit is checked. If the dirty bit is valid, the data in that cache line is evicted to off-chip memory and the dirty bit is cleared; otherwise, the cache line is skipped. This flushing scan operation needs to be performed concurrently with normal data read / write and data computation operations, and should not block normal business processing for an extended period, otherwise it will affect overall throughput performance.

[0041] Because data computation is a complex operation requiring multiple clock cycles to complete, there is a potential access conflict risk between data computation and refresh / scan operations. Take a typical four-cycle statistical counting operation as an example: In the first cycle, the statistical counting begins, reading old data from the cache at the target address; in the second and third cycles, the statistical counting performs addition. During this period, if the refresh / scan operation reaches the target address, since the data in the cache has not yet been updated, the refresh / scan operation will eject the old dirty data to off-chip memory and clear the dirty bit of that cache line; in the fourth cycle, the statistical counting writes the new data obtained from the addition operation back to the cache. However, since the dirty bit of this cache line has already been cleared during the refresh / scan operation, the cache controller will consider the data in the cache to be consistent with the data in the off-chip memory. Thus, the cache line stores new data, while the off-chip memory stores old data, resulting in data inconsistency. More seriously, because the dirty bit of this cache line is invalid, when the cache line is subsequently replaced by new data, the cache controller will assume that the data in the cache line has already been synchronized with the off-chip memory, and therefore will not write the data in the cache line back to the off-chip memory, causing the new data to be permanently discarded. Ultimately, the software still reads the old statistics from the off-chip memory, and the new statistics are lost.

[0042] To address the aforementioned technical problems, some embodiments of this application provide a method for handling cache access conflicts. This method can be applied to network chips, and is particularly suitable for network chips in network devices such as switches, high-speed network cards, and routers. In some embodiments, this method can be implemented on the cache controller inside the network chip.

[0043] See Figure 1 The cache access conflict handling method provided in some embodiments of this application includes the following steps S100 to S300.

[0044] S100: In response to a data calculation operation on the cache, the first target address corresponding to the data calculation operation is recorded in the register array inside the cache, and the status bit corresponding to the first target address is set to valid.

[0045] The cache controller responds to data computation operations from the service side by obtaining the first target address corresponding to the data computation operation. The service side refers to the functional unit that generates the data computation operation, such as the packet processing pipeline or statistical counting unit in a network chip.

[0046] Data computation operations are data update operations that need to be completed within the cache and require multiple clock cycles to complete. As an example, a data computation operation could be a statistical counting operation, which involves reading the current count value at a first target address from the cache, adding the current count value to data input from the service side (such as the length of a data packet transmitted by the service side or a fixed increment value), and then writing the result back to the first target address in the cache. Optionally, data computation operations could also be data accumulation operations, atomic addition operations, or read-modify-write operations; no limitation is made here.

[0047] The first target address is the target address where the current count value needs to be updated in the data calculation operation. As an example, the first target address can be the cache line address corresponding to the current count value, the index information corresponding to the cache line address corresponding to the current count value, or any form of address information that can uniquely identify the specific storage location of the current count value in the cache.

[0048] After obtaining the first target address, the cache controller records the first target address in the register array inside the cache.

[0049] The register array is located inside or connected to the cache controller and is used to temporarily store the first target address corresponding to the data computation operation being performed. In some embodiments, the register array includes multiple first registers, each used to store the first target address of a data computation operation. Optionally, the register array can also be implemented as other storage structures with multiple storage entries, as long as it can record multiple first target addresses simultaneously.

[0050] After the cache controller records the first target address in the register array, it sets the status bit of the first target address to valid.

[0051] In some implementations, each first register in the register array is assigned a status bit (e.g., a Valid bit). This status bit indicates whether a data computation operation corresponding to the first target address stored in the first register is in progress. When the status bit is valid, it indicates that a data computation operation is currently being performed at the first target address; when the status bit is invalid, it indicates that the data computation operation corresponding to the first target address has been completed.

[0052] Optionally, the valid state of the status bit can be represented by a logic high level "1", and the invalid state by a logic low level "0". In other implementations, the opposite polarity definition can also be used, that is, the valid state of the status bit can be represented by a logic low level "0", and the invalid state by a logic high level "1".

[0053] Optionally, the status bit can also be implemented as a multi-bit code, with different code values ​​representing different execution stages, as long as it can at least distinguish between the two states of "currently executing" and "not currently executing".

[0054] S200: In response to a refresh scan operation on the cache, obtain the second target address corresponding to the refresh scan operation.

[0055] The cache controller responds to a refresh scan operation from the system side by obtaining the second target address corresponding to the refresh scan operation. The system side refers to the functional unit that generates the refresh scan operation, such as a software driver, firmware, or hardware maintenance engine running on the host. The cache controller communicates with the host.

[0056] A refresh scan is a maintenance operation used to synchronize dirty data in the cache to off-chip memory. In some implementations, the refresh scan can be triggered periodically by the system-side software driver or firmware, for example, by initiating a full refresh scan at preset time intervals (such as every 1 millisecond or 10 milliseconds) to ensure that the software can access the latest statistics in a timely manner. In other implementations, the refresh scan can also be triggered automatically by hardware, for example, when the number of dirty data entries in the cache exceeds a preset threshold, or when the cache utilization reaches a certain level.

[0057] A refresh scan operation is typically performed as a full address scan, meaning it scans sequentially from one address in the cache to the last address, covering all storage locations in the cache, granularly according to cache lines. In some implementations, the refresh scan operation starts from address 0 in the cache and scans incrementally to the maximum address. In some implementations, for set-associative cache structures, the refresh scan operation scans each channel (way) of each set sequentially, granularly according to cache lines; that is, for each set, all channels within that set are scanned sequentially. Each address scanned in the refresh scan operation constitutes one scan step.

[0058] In each scanning step, the cache controller obtains the second target address corresponding to the current scanning step.

[0059] The second target address is the target address indicated by the current scan step in the refresh scan operation. As an example, the second target address can be the cache line address indicated by the current scan step, or it can be the index information corresponding to the cache line address indicated by the current scan step.

[0060] S300: If a first target address that matches the second target address exists in the register array, and the status bit of the first target address that matches the second target address is valid, prevent the refresh scan operation from being performed.

[0061] The cache controller refreshes the second target address corresponding to the scan operation and compares it with each first target address recorded in the register array.

[0062] In some implementations, the cache controller compares the second target address with each of the first target addresses stored in the register array using a comparator. Optionally, the cache controller can use a parallel comparison method, that is, use multiple sets of comparators to compare the second target address with all the first target addresses in the register array simultaneously, thereby completing all comparison operations within one clock cycle and reducing comparison latency.

[0063] After completing the comparison, the cache controller makes a judgment based on the comparison result and the information in the status bit.

[0064] If a first target address that matches the second target address exists in the register array, and the status bit corresponding to the first target address is valid, it indicates that the target address accessed by the current refresh scan operation is the same as the target address accessed by a data calculation operation that is currently being executed, that is, an access conflict has occurred between the refresh scan operation and the data calculation operation.

[0065] At this point, the cache controller prevents the refresh scan operation from being performed.

[0066] The cache controller suspends the access to the second target address by the current refresh scan operation's scan step, thus delaying the processing flow of the refresh scan operation on the second target address and ensuring that the refresh scan operation does not access the second target address before the data computation operation's write action is completed.

[0067] It should be noted that "preventing execution" in this implementation means temporarily suspending the execution of the refresh scan operation on the current target address, so that the refresh scan operation will not perform any substantive operations such as checking dirty data or kicking out data on the second target address.

[0068] In this embodiment, when a data computation operation is executed, the first target address corresponding to the data computation operation is recorded in the register array inside the cache, and the status bit corresponding to the first target address is set to valid. This establishes a real-time information record within the cache that reflects the target address accessed by the currently executing data computation operation. Based on this, when a refresh scan operation is executed, the second target address corresponding to the refresh scan operation is obtained and compared with each of the first target addresses recorded in the register array. Since each first target address in the register array has a status bit indicating whether a data computation operation is being executed, if a first target address matching the second target address exists in the register array and the status bit corresponding to that first target address is valid, it indicates that the cache address accessed by the current refresh scan operation is the same as the target address accessed by a currently executing data computation operation. At this point, by preventing the refresh scan operation from being executed, the data ejection action of the refresh scan operation can be delayed until after the data calculation operation corresponding to the first target address, which is consistent with the second target address, is completed. This avoids the refresh scan operation accessing the same target address during the data calculation operation, and prevents the problem of data inconsistency between the cache and off-chip memory caused by the refresh scan operation prematurely ejecting dirty data from the cache during the data calculation operation and then the data calculation operation writing new data to the cache. This effectively realizes the handling of cache access conflicts and ensures data consistency between the cache and off-chip memory.

[0069] Reference Figure 2 In some implementations, a method for handling cache access conflicts further includes the following S400.

[0070] S400: If a first target address that matches the second target address does not exist in the register array, perform a refresh scan operation.

[0071] If the cache controller determines that there is no first target address in the register array that matches the second target address (i.e., no first target address in the register array is the same as the second target address accessed by the current refresh scan operation), it indicates that there is no data computation operation being performed at the cache address accessed by the current refresh scan operation. In this case, the cache controller allows the refresh scan operation to continue.

[0072] In some implementations, after the data computation operation is completed, the cache controller clears the first target address corresponding to the data computation operation from the register array, for example, by zeroing or overwriting the first target address corresponding to the data computation operation stored in the register array. After the first target address in the register array is cleared, the cache controller detects that there is no longer a first target address in the register array that matches the second target address, and then releases the previously blocked refresh scan operation, allowing the refresh scan operation to continue accessing the second target address.

[0073] In this embodiment, refresh scan operations that were previously blocked due to conflicts can be resumed promptly after the access conflict is resolved, preventing the refresh scan operations from being suspended indefinitely and ensuring the overall progress of the refresh scan operations.

[0074] Reference Figure 3 In some implementations, a method for handling cache access conflicts further includes the following S500.

[0075] S500: If the status bit corresponding to the first target address that is the same as the second target address is invalid, perform a refresh scan operation.

[0076] When the data calculation operation corresponding to the first target address is completed, the status bit corresponding to the first target address is set to invalid.

[0077] The cache controller determines that a first target address matching the second target address exists in the register array, but the status bit corresponding to the first target address matching the second target address is invalid. An invalid status bit indicates that the data computation operation corresponding to the first target address has been completed. At this point, it indicates that the data computation operation that was originally being performed on the cache address accessed by the current refresh scan operation has ended. The cache controller allows the refresh scan operation to continue.

[0078] In some implementations, after detecting that the status bit of a first target address in the register array is invalid, the cache controller can remove the first target address with the invalid status bit from the register array at the same time as or before the refresh scan operation is allowed to be executed. For example, the first target address with the invalid status bit stored in the register array can be cleared or overwritten so that it can be reused by other data calculation operations that arrive later.

[0079] In other implementations, the cache controller may choose not to clear the first target address whose status bit is invalid, but instead retain the address information but keep the status bit invalid, and then overwrite the first target address whose status bit is invalid when there are new data calculation operations that need to be recorded.

[0080] In some implementations, when the data computation operation is completed, the cache controller modifies the status bit of the first target address corresponding to the data computation operation recorded in the register array from valid to invalid. The timing of the end of the data computation operation can be determined in various ways, such as by marking the completion of writing the computation result back to the cache, or by marking the cache controller receiving a completion signal for the data computation operation, or by marking the end time of a pre-set number of execution cycles of the data computation operation. These settings can be configured by those skilled in the art according to the actual application scenario.

[0081] In this embodiment, even if a first target address exists in the register array that matches the second target address, but the status bit of the first target address is invalid, the refresh scan operation is still allowed because the data computation operation corresponding to the first target address has already been completed. Therefore, even if the refresh scan operation accesses the first target address, no access conflict will occur. This ensures that the refresh scan operation is not unnecessarily interfered with by completed data computation operations.

[0082] In some implementations, the execution time of the data computation operation is a preset number of cycles, and the register array includes multiple first registers, the number of which is not less than the preset number of cycles.

[0083] One of the registers is used to store a first target address.

[0084] The execution time of a data computation operation is a preset number of clock cycles. For example, the execution time of a statistical counting operation is four clock cycles. It is understood that in other scenarios, the execution time of a data computation operation may be three, five, or more clock cycles, depending on the complexity of the data computation operation and the pipeline depth. This application does not limit this.

[0085] The register array includes multiple first registers, each first register storing a corresponding first target address, and the number of first registers in the register array is no less than a preset number of clock cycles. For example, when the execution time of the data computation operation is four clock cycles, the number of first registers in the register array is at least four. When the execution time of the data computation operation is five clock cycles, the number of first registers in the register array is at least five, and so on.

[0086] Understandably, since data computation operations need to maintain the first target address corresponding to the data computation operation in the register array during execution (i.e., within the preset number of clock cycles), if the number of first registers in the register array is less than the preset number of clock cycles, insufficient storage space may occur. For example, if a second data computation operation arrives before the first data computation operation has finished executing, and there are no free first registers available in the register array, the new data computation operation will not be able to record its first target address, thus losing protection for the new data computation operation and failing to effectively perform subsequent conflict detection.

[0087] In some implementations, to avoid wasting hardware resources, the number of the first registers in the register array is set to be equal to the preset number of cycles for data computation operations.

[0088] In this embodiment, by setting the number of first registers in the register array to be no less than a preset number of clock cycles, it can be ensured that at any given moment, the first target address of all data calculation operations in progress has a corresponding first register available for storage within the maximum execution time of the data calculation operation. This prevents the data from being overwritten or discarded prematurely due to insufficient storage space, thereby ensuring the accuracy and reliability of subsequent conflict detection.

[0089] In some implementations, the step of preventing the refresh scan operation in S300 includes:

[0090] The refresh scan instruction corresponding to the blocked refresh scan operation is temporarily stored in the second register inside the cache; a backpressure signal is sent to the preceding command queue of the cache.

[0091] The reverse pressure signal is used to pause reading instructions from the preceding command queue.

[0092] When the cache controller determines that the second target address corresponding to the current refresh scan operation is consistent with a valid first target address in the register array, the cache controller temporarily stores the blocked refresh scan instruction in the second register set inside the cache.

[0093] The second register differs from the register array (including multiple first registers) used to store the first target address for data computation operations. The second register is specifically used to temporarily store blocked refresh scan instructions. In some implementations, the second register can be implemented as a separate register for temporarily storing a single blocked refresh scan instruction. In other implementations, the second register can be implemented as a temporary buffer queue containing multiple register entries to support the simultaneous temporary storage of multiple refresh scan instructions. Optionally, the second register can be connected to the pipeline control logic of the cache controller, allowing temporarily stored refresh scan instructions to be re-injected into the pipeline for continued execution after the conflict is resolved.

[0094] While the cache controller temporarily stores the blocked refresh scan instruction in a second register within the cache, it sends a backpressure signal to the cache's preceding command queue. The preceding command queue caches pending operation commands, including data calculation commands from the business side and refresh scan commands from the system side. The cache controller reads commands from the preceding command queue and processes them sequentially. When the cache controller detects an access violation and temporarily stores the current refresh scan instruction in the second register, it notifies the preceding command queue to pause reading new instructions via the backpressure signal.

[0095] The backpressure signal is a flow control signal used to prevent the preceding command queue from continuing to send new operation commands to the cache controller, thereby avoiding command backlog or processing chaos caused by the influx of new commands when the cache controller is unable to handle the current conflict.

[0096] In some implementations, the reverse pressure signal can be implemented using a handshake mechanism. When the buffer controller pulls the reverse pressure signal high, the popping operation of the preceding command queue is paused, while the read pointer remains unchanged. When the buffer controller pulls the reverse pressure signal low, the preceding command queue resumes normal reading. Optionally, the reverse pressure signal can also be a continuously active level signal or a pulse signal, as long as it can achieve the function of pausing the read command.

[0097] In some implementations, the backpressure signal can pause only commands related to refresh and scan operations, while allowing commands related to data computation operations to continue being read, in order to avoid blocking normal business processing. Optionally, the backpressure signal can also pause all types of commands uniformly to simplify control logic.

[0098] In some implementations, while sending backpressure signals, the cache controller can maintain the read progress of the refresh scan operation in the preceding command queue at the currently blocked instruction. This allows the cache controller to continue reading and advancing subsequent refresh scan instructions from the blocked instruction once the conflict is resolved, thereby ensuring that the overall order of the refresh scan operation is not disrupted.

[0099] Once the data computation operation is complete, the cache controller releases the refresh scan instruction that conflicted with the data computation operation, which was temporarily stored in the second register. This refresh scan instruction is then re-entered into the cache controller's processing pipeline for continued execution. Simultaneously, the cache controller releases the backpressure signal, notifying the preceding command queue to resume reading new instructions. Afterward, the cache controller can continue processing subsequent commands waiting in the preceding command queue, including the remaining scan steps of the refresh scan operation and other operation commands.

[0100] In this embodiment, by temporarily storing the blocked refresh scan instruction in the second register, the status information of the blocked refresh scan operation can be preserved. This allows the blocked refresh scan operation to continue execution from the blocked point after the conflict is resolved, without needing to restart the full address scan from address 0. This avoids the loss of progress in the refresh scan operation due to execution blocking, thus ensuring the overall progress efficiency of the refresh scan operation. Simultaneously, by sending a backpressure signal to the cache's preceding command queue, the reading of new commands can be paused during a conflict, preventing a continuous influx of new operation commands that would overwhelm the cache controller and prevent command backlog and pipeline congestion.

[0101] In some implementations, the status bits of the first target address stored in the register array are uniformly set using a bitmap.

[0102] The register array is configured with a bitmap register. Each bit of the bitmap register corresponds to a first register in the register array, which is used to mark whether the first register currently stores the first target address of the data calculation operation being performed.

[0103] For example, when a bit in the bitmap register is the first value (such as logic "1"), it indicates that the status bit of the first target address currently stored in the first register corresponding to that bit is valid, meaning that the data calculation operation corresponding to that first target address is in progress. When the bit is the second value (such as logic "0"), it indicates that the status bit of the first target address currently stored in the first register corresponding to that bit is invalid, meaning that the data calculation operation corresponding to that first target address has ended.

[0104] In this embodiment, by using a bitmap to manage the valid status of each first register, the cache controller can quickly obtain the status information of any first register by reading the value of the corresponding bit in the bitmap register, thereby enabling rapid setting and querying of the status bit of the first target address recorded in the register array.

[0105] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps. It is understood that the steps in different embodiments can be freely combined as needed, and all non-contradictory solutions formed by such combinations are within the scope of protection of this application.

[0106] Reference Figure 4 In some embodiments, this application also provides a caching system, including a register array 410 and a cache controller 420. The register array 410 is used to record the first target address corresponding to data calculation operations. The cache controller 420 is connected to the register array 410 and is used to control various access operations of the cache.

[0107] The cache controller 420 includes a recording module 421, an acquisition module 422, and a first control module 423.

[0108] The recording module 421 is used to record the first target address corresponding to the data calculation operation in the register array 410 in response to the data calculation operation on the cache, and set the status bit corresponding to the first target address to be valid; the acquisition module 422 is used to acquire the second target address corresponding to the refresh scan operation in response to the refresh scan operation on the cache; the first control module 423 is used to prevent the refresh scan operation from being executed when there is a first target address in the register array 410 that is consistent with the second target address, and the status bit of the first target address that is consistent with the second target address is valid.

[0109] The register array 410 in the cache system is a dedicated hardware storage structure used to record the first target address of the data computation operation being performed. In some embodiments, the register array 410 can be located inside the cache controller 420 as a component of the cache controller 420; in other embodiments, the register array 410 can also be located outside the cache controller 420 but connected to the cache controller 420, as long as the cache controller 420 can access the register array 410 by reading and writing.

[0110] In some implementations, the recording module 421 in the cache controller 420 can be implemented by the write control logic in the cache controller 420. The write control logic is connected to the write port of the register array 410 and is used to write the corresponding first target address into the free position of the register array 410 when the data calculation operation starts, and set the status bit corresponding to the first target address to be valid.

[0111] In some implementations, the acquisition module 422 in the cache controller 420 can be implemented through the address reading logic or the scan address generation logic in the cache controller 420, and is used to acquire the second target address of the current scan step in each scan step of the refresh scan operation.

[0112] In some implementations, the first control module 423 in the cache controller 420 can be implemented by comparison logic and pipeline control logic in the cache controller 420. The comparison logic is used to compare the second target address obtained by the acquisition module 422 with each first target address stored in the register array 410. The pipeline control logic is used to determine whether to prevent the execution of the refresh scan operation based on the output result of the comparison logic.

[0113] In this embodiment, by configuring the above hardware architecture, the conflict between data calculation operations and refresh scan operations can be effectively detected and handled by adding a small number of dedicated hardware modules on the basis of the existing cache controller 420 hardware. The hardware modification is small, the implementation cost is low, and it does not affect the original data processing flow and performance of the cache system.

[0114] Reference Figure 5 In some embodiments, the caching system further includes a tag storage array 430, a data storage bank 440, and an arithmetic unit 450. The tag storage array 430 is connected to the register array 410, the data storage bank 440 is connected to the tag storage array 430, and the arithmetic unit 450 is connected to the data storage bank 440. The tag storage array 430, the data storage bank 440, and the arithmetic unit 450 are all connected to the cache controller 420.

[0115] The tag storage array 430 stores tag information and status flags corresponding to each cache line in the cache. The status flags include valid and dirty bits. The data storage unit 440 stores cache line data. The arithmetic unit 450 performs calculations on the current cache line data read from the data storage unit 440 and external input data, and returns the calculation result to the data storage unit 440.

[0116] Based on the above architecture, the specific workflow of the caching system is explained using a single data computation operation.

[0117] When a data computation operation is initiated by the business side, the operation carries a corresponding first target address and the data to be computed. The cache controller 420 obtains the first target address corresponding to the data computation operation, records it in the register array 410, and sets the status bit corresponding to the first target address to valid. Subsequently, the cache controller 420 searches for the corresponding tag information in the tag storage array 430 based on the index information in the first target address, and compares the tag in the first target address with the tag information found in the tag storage array 430. If the comparison matches and the valid bit of the cache line for the tag information found in the tag storage array 430 is valid, it indicates that the first target address of the current data computation operation has been hit in the tag storage array 430.

[0118] In this scenario, the cache controller 420 reads the current data corresponding to the first target address from the data storage bank 440. Taking a statistical counting scenario as an example, what is read from the data storage bank 440 is the current count value corresponding to the first target address. The cache controller 420 sends the read current data to the operation bank 450, which performs a calculation on the current data and the data to be calculated carried by the data calculation operation. For example, it performs an addition operation, adding the current count value to the data to be calculated to obtain the updated count value.

[0119] After the operation is completed, the operation body 450 returns the operation result to the data storage body 440, and the data storage body 440 writes the operation result back to the location corresponding to the first target address, thus completing one data calculation operation.

[0120] During the entire execution of the data computation operation, the register array 410 maintains a record of the first target address, and the status bit corresponding to the first target address remains valid, so that subsequent refresh scan operations are blocked from execution until the data computation operation is completed and the status bit is switched to invalid, at which point the refresh scan operation can continue to be executed.

[0121] If no tag matching the first target address is found in the tag storage array 430, or if the valid bits of the found tag are invalid, it indicates that the first target address has not been cached. In this case, the cache controller 420 sends a data calculation operation request to the next-level processing unit, such as the off-chip memory controller connected to the cache system. The off-chip memory controller reads the data corresponding to the first target address from the off-chip memory, performs the corresponding calculation, and writes the result back to the off-chip memory.

[0122] In some implementations, the cache controller 420 further includes:

[0123] The second control module is used to perform a refresh scan operation when there is no first target address in the register array 410 that matches the second target address.

[0124] In some implementations, the cache controller 420 further includes:

[0125] The third control module is used to perform a refresh scan operation when the status bit corresponding to the first target address, which is the same as the second target address, is invalid; wherein, when the data calculation operation corresponding to the first target address is completed, the status bit corresponding to the first target address is set to invalid.

[0126] In some implementations, the execution time of the data calculation operation is a preset number of cycles, and the register array 410 includes a plurality of first registers, the number of which is not less than the preset number of cycles; wherein, one first register is used to store a first target address.

[0127] In some implementations, the cache system further includes a second register; the cache controller 420 also includes:

[0128] The temporary storage module is used to temporarily store the refresh scan instructions corresponding to the blocked refresh scan operation in the second register;

[0129] The sending module is used to send a backpressure signal to the buffered front-end command queue; the backpressure signal is used to pause the reading of instructions from the front-end command queue.

[0130] Each module in the aforementioned caching system can be implemented entirely or partially through hardware circuits, firmware, or a combination of hardware and firmware. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or they can be stored in the memory of the computer device as firmware, so that the processor can call and execute the operations corresponding to each module.

[0131] When implemented using hardware circuits, the aforementioned functional modules can be implemented using hardware logic devices such as Application-Specific Integrated Circuits (ASICs) and Field-Programmable Gate Arrays (FPGAs) to perform processing logic such as address recording, status bit setting, address comparison, conflict detection, and pipeline control. Register array 410 can be implemented using a register group composed of flip-flops or latches to stably store target address and status bit information during data computation operations. Tag storage array 430 and data storage bank 440 can be implemented using Static Random Access Memory (SRAM) to provide high-speed cached data access capabilities. Arithmetic unit 450 can be implemented using an Arithmetic Logic Unit (ALU) or a dedicated adder to perform addition operations in statistical counting.

[0132] When implemented using firmware, the firmware configures logic according to the corresponding application scenario and business requirements. This configuration logic can be stored in the on-chip memory of the cache controller 420 in the form of microcode or firmware programs, and executed by the cache controller 420 to generate all or part of the processes or functions according to the embodiments of this application. For example, the firmware can configure the address recording logic, status bit management logic, conflict detection logic, and refresh scan operation scheduling logic of the cache controller 420 to effectively handle conflicts between data calculation operations and refresh scan operations.

[0133] In one exemplary embodiment, this application also provides a network chip that includes the caching system described in any of the above-described caching system embodiments. This network chip can be integrated into a network device (e.g., a switch, router, or high-speed network card) as a core component for data processing.

[0134] In some implementations, the network chip also includes a packet processing pipeline for parsing, classifying, and forwarding received packets, and generating data computation operation requests and refresh scan operation requests during the processing. A caching system is connected to the packet processing pipeline, capable of receiving data computation operation requests from the pipeline, recording the first target address of the data computation operation corresponding to the data computation operation request in a register array, and setting the corresponding status bit to valid; in response to a received refresh scan operation request, it obtains the second target address of the refresh scan operation corresponding to the refresh scan operation request; if a first target address matching the second target address exists in the register array, and the status bit of the first target address matching the second target address is valid, the refresh scan operation is prevented from being executed.

[0135] In some implementations, the network chip also includes a front-end command queue for caching pending operation commands. The caching system is connected to the front-end command queue, and upon detecting an access conflict, the caching system sends a backpressure signal to the front-end command queue to suspend reading new commands from it, thereby preventing new operation commands from entering the caching system during conflict resolution.

[0136] It is understandable that this network chip can be integrated into network devices as a standalone chip product, or it can be used as part of a system-on-a-chip to work with other functional modules to achieve network data processing functions. The specific implementation method can be flexibly configured according to the actual application scenario and design requirements.

[0137] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0138] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A method for handling cache access conflicts, characterized in that, include: In response to a data calculation operation on the cache, the first target address corresponding to the data calculation operation is recorded in the register array inside the cache, and the status bit corresponding to the first target address is set to valid; In response to a refresh scan operation on the cache, obtain the second target address corresponding to the refresh scan operation; If a first target address that matches the second target address exists in the register array, and the status bit of the first target address that matches the second target address is valid, the refresh scan operation is prevented from being executed.

2. The processing method according to claim 1, characterized in that, Also includes: If no first target address matching the second target address exists in the register array, the refresh scan operation is performed.

3. The processing method according to claim 1 or 2, characterized in that, Also includes: If the status bit corresponding to the first target address that is consistent with the second target address is invalid, the refresh scan operation is performed; wherein, when the data calculation operation corresponding to the first target address is completed, the status bit corresponding to the first target address is set to invalid.

4. The processing method according to claim 1 or 2, characterized in that, The execution time of the data calculation operation is a preset number of cycles, and the register array includes multiple first registers, the number of which is not less than the preset number of cycles; wherein, one first register is used to store one first target address.

5. The processing method according to claim 1, characterized in that, The prevention of the refresh scan operation includes: The refresh scan instruction corresponding to the blocked refresh scan operation is temporarily stored in the second register inside the cache; A backpressure signal is sent to the preceding command queue of the cache; wherein the backpressure signal is used to suspend reading instructions from the preceding command queue.

6. A caching system, characterized in that, include: A register array is used to record the first target address corresponding to a data computation operation; A cache controller, connected to the register array, the cache controller comprising: The recording module is used to record the first target address corresponding to the data calculation operation in the register array in response to the data calculation operation in the cache, and set the status bit corresponding to the first target address to be valid; The acquisition module is used to acquire the second target address corresponding to the refresh scan operation in response to the refresh scan operation of the cache; The first control module is configured to prevent the refresh scan operation from being performed if a first target address that matches the second target address exists in the register array and the status bit of the first target address that matches the second target address is valid.

7. The caching system according to claim 6, characterized in that, The cache controller also includes: The second control module is used to perform the refresh scan operation when there is no first target address in the register array that matches the second target address.

8. The caching system according to claim 6 or 7, characterized in that, The cache controller also includes: The third control module is used to perform the refresh scan operation when the status bit corresponding to the first target address that is consistent with the second target address is invalid; wherein, when the data calculation operation corresponding to the first target address is completed, the status bit corresponding to the first target address is set to invalid.

9. The caching system according to claim 6, characterized in that, The execution time of the data calculation operation is a preset number of cycles, and the register array includes multiple first registers, the number of which is not less than the preset number of cycles; wherein, one first register is used to store one first target address.

10. The caching system according to claim 6, characterized in that, The cache system further includes a second register; the cache controller further includes: The temporary storage module is used to temporarily store the refresh scan instruction corresponding to the blocked refresh scan operation in the second register; The sending module is used to send a backpressure signal to the buffered front-end command queue; wherein the backpressure signal is used to pause reading instructions from the front-end command queue.

11. A network chip, characterized in that, Includes the caching system as described in any one of claims 6 to 10.