A storage unit matching method and device

By introducing multiple matching algorithms and strategies into the software and hardware shared cache and dynamically switching matching algorithms, the problems of low cache utilization and management complexity in the existing technology are solved, and efficient cache management in different scenarios is achieved.

CN118133050BActive Publication Date: 2024-09-17芯来智融半导体科技(上海)股份有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410558114.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-07
Publication Date
2024-09-17
Estimated Expiration
2044-05-07

AI Technical Summary

Technical Problem

In the existing software and hardware shared cache technology, the cache storage unit matching algorithm is fixed and cannot adapt to various scenarios, resulting in low cache utilization and increased management complexity.

Method used

Provides a storage unit matching method, including static and dynamic matching strategies. Through algorithm register and strategy register configuration, dynamic switching of matching algorithms supports multiple matching principles and algorithms, such as throughput, total number of packets, full number of matches, priority selection Suitable storage unit.

Benefits of technology

It improves cache usage efficiency and system critical path efficiency, adapts to the needs of different scenarios, and avoids the problems of low cache utilization and increased management complexity caused by a single matching algorithm.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118133050B
    Figure CN118133050B
Patent Text Reader

Abstract

The present application provides a storage unit matching method, device and storage unit matching module, which relate to the technical field of management of software and hardware shared cache areas of system-on-chip, and the purpose is to solve the problem that the existing software and hardware shared cache technology cannot provide users with choices in multiple scenarios and has low cache utilization due to the fixed storage unit matching algorithm. The above method includes: reading the matching strategy; judging whether it is a dynamic strategy; if not, reading the matching algorithm corresponding to the static strategy for storage unit matching; if so, reading the matching principle corresponding to the dynamic strategy and selecting the matching algorithm for storage unit matching. The above module includes: an algorithm register; a policy register; a dynamic switch unit, suitable for dynamically switching the matching algorithm according to the configuration of the algorithm register and the policy register; and a matching unit, suitable for selecting the corresponding matching algorithm for storage unit matching according to the configuration of the algorithm register or under the control of the dynamic switch unit.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of management of a system-on-chip software and hardware shared cache area, and in particular to a storage unit matching method, device and storage unit matching module. Background Art

[0002] The shared cache area between software and hardware is an unavoidable technical field in the System on Chip (SOC) (such as WIFI SOC). Data is sent from the upper-layer software to the SOC through the interface layer. Generally, it needs to be cached in advance, and then the cached data is taken away and sent through firmware or hardware. After the sending action is completed, the subsequent data needs to use this memory again, so that the communication can continue. Commonly used software and hardware shared cache technologies include continuous loop buf method, linked list management method, and single-block memory software and hardware alternating use of sharing methods.

[0003] The continuous circular buffer (buffer, buf) architecture consists of a read and write pointer register and a continuous buf. Before the software data frame is handed over to the hardware, the read and write pointer registers are compared first. If there is an idle buf, the data frame is stored in the buf, and then the write register is updated; if there is no idle buf, it returns to the full state and waits for the next processing. When the hardware has a data frame to send, it first compares the read and write registers. If the read and write pointer register shows that there is data to be sent, the data is sent, and the hardware updates the read register after sending. This architecture determines that the storage of data frames must be stored in sequence and the frames are stored continuously. For example, if the storage order is frame0, frame1, frame2, frame3..., then the sending must also be sent and released in the order of frame0, frame1, frame2, frame3... If for some reason, such as the need to re-queue after a failed transmission, frame2 needs to be sent before other frames, then the release and reuse of this piece of memory after frame2 is sent will be difficult to operate. For example, all the following frames need to be moved forward by frame2 positions to fill this gap, thereby freeing up space for subsequent frames. This operation is not only complicated to process, but also has a large computing overhead for moving data blocks in the buffer, wasting system resources. If the order of sending frames stored in the shared buffer in the order of frame0, frame1, frame2, frame3... is processed by the underlying software and is required to be sent in the order of frame2, frame1, frame0, frame3,..., frame_n, then the management complexity of releasing and acquiring the shared area (here, releasing refers to the hardware freeing up space for the upper-level software to load the next frame of data after sending, and acquiring refers to the hardware reading the frame to be sent from it for subsequent processing) will increase exponentially and will not be possible.

[0004] The linked list management method has a complex data access process, and the single-block memory hardware and software alternating method has a relatively simple data access process, but the data access efficiency is low.

[0005] In summary, the above software and hardware shared cache technology cannot provide users with choices in various scenarios and has low cache utilization due to the fixed cache storage unit matching algorithm. Summary of the invention

[0006] In order to solve the above technical defects, the embodiments of the present application provide a storage unit matching method, device and storage unit matching module.

[0007] The first aspect of the present application provides a storage unit matching method, including: reading a matching strategy; determining whether the matching strategy is a dynamic strategy; if not, reading a matching algorithm corresponding to the static strategy to match the storage unit with data sent by the upper-layer software according to the matching algorithm; and if so, reading a matching principle corresponding to the dynamic strategy, and dynamically selecting a matching algorithm according to the matching principle to match the storage unit with data sent by the upper-layer software according to the matching algorithm.

[0008] In one possible implementation manner, the matching principle is matching based on throughput, matching based on the total number of packets, or matching based on the number of full times.

[0009] In one possible implementation manner, the dynamically selecting a matching algorithm according to the matching principle includes: switching between various matching algorithms in descending order of weight according to the matching principle.

[0010] In one possible implementation, the matching algorithm includes: a random size matching algorithm, randomly selecting a storage unit of a certain size; a maximum size priority matching algorithm, preferentially selecting a storage unit of the largest size; and a minimum size priority matching algorithm, preferentially selecting a storage unit of the smallest size.

[0011] In one possible implementation, the matching algorithm includes: an economic algorithm that selects a storage unit or a combination of storage units that can accommodate the data and waste the least storage space.

[0012] In one possible implementation, the matching algorithm includes: a maximum size reservation priority matching algorithm, when the number of storage units of the maximum size is reduced to a preset number, the storage units of the maximum size are no longer matched for the data this time; and a minimum size reservation priority matching algorithm, when the number of storage units of the minimum size is reduced to a preset number, the storage units of the minimum size are no longer matched for the data this time.

[0013] In one possible implementation manner, the matching algorithm includes: a fixed-size priority matching algorithm, which preferentially selects storage units of a fixed size.

[0014] In one possible implementation, the matching algorithm includes: a roulette matching algorithm, which polls and selects storage units of various sizes in a preset order.

[0015] The second aspect embodiment of the present application also provides a storage unit matching device, including: a reading unit, suitable for reading a matching strategy; a judging unit, suitable for judging whether the matching strategy is a dynamic strategy; a static matching unit, suitable for reading a matching algorithm corresponding to the static strategy when the judgment result is no, so as to match the storage unit with the data sent by the upper-layer software according to the matching algorithm; and a dynamic matching unit, suitable for reading a matching principle corresponding to the dynamic strategy when the judgment result is yes, and dynamically selecting a matching algorithm according to the matching principle, so as to match the storage unit with the data sent by the upper-layer software according to the matching algorithm.

[0016] The third aspect embodiment of the present application also provides a storage unit matching module, including: an algorithm register, including an algorithm selection bit, an algorithm weight bit, a storage unit size bit and a dynamic algorithm switching control bit; a strategy register, including a total byte number bit for limiting the total number of bytes continuously sent by each algorithm, a work packet number bit for limiting the number of work packets continuously sent by each algorithm, a full event number bit for limiting the maximum number of full events occurring for each algorithm, and a strategy selection switch bit for limiting the matching strategy; a dynamic switch unit, suitable for dynamically switching the matching algorithm according to the configuration of the algorithm register and the strategy register; and a matching unit, suitable for selecting a corresponding matching algorithm for storage unit matching according to the configuration of the algorithm register or under the control of the dynamic switch unit.

[0017] The storage unit matching method, device and module provided in the embodiments of the present application provide a variety of cell matching algorithms, a variety of matching principles, and both dynamic and static matching strategies. They have rich application scenarios and can improve the utilization efficiency of shared cache in various scenarios, so that the efficiency of the system's critical path can be best optimized during use. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Figure 1 A schematic diagram of the architecture of a bitmap pool and a sram pool according to an embodiment of the present invention;

[0019] Figure 2 A schematic diagram of the data structure of txd according to an embodiment of the present invention;

[0020] Figure 3 A schematic diagram of the principle of software and hardware shared cache according to an embodiment of the present invention;

[0021] Figure 4 The architecture of a storage unit matching module according to an embodiment of the present invention;

[0022] Figure 5 is a flow chart of a storage unit matching method according to an embodiment of the present invention;

[0023] Figure 6 is a flow chart of another storage unit matching method according to an embodiment of the present invention;

[0024] Figure 7 FIG. 4 is a schematic diagram of the structure of a storage unit matching device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0025] In order to make the technical solutions and advantages in the embodiments of the present application more clearly understood, the exemplary embodiments of the present application are further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, rather than an exhaustive list of all the embodiments. It should be noted that the embodiments in the present application and the features in the embodiments can be combined with each other without conflict.

[0026] In view of the problem that the existing software and hardware shared cache technology cannot provide users with choices in various scenarios due to the fixed storage unit matching algorithm of the cache, and the cache utilization rate is low, a storage unit matching method, device and storage unit matching module are provided, and multiple storage unit matching algorithms are set. Flexible switching between the multiple storage unit matching algorithms can be performed according to actual conditions to meet the needs of various scenarios and greatly improve the utilization rate of the cache.

[0027] The storage unit matching method of the embodiment of the present application is implemented based on the following on-chip system software and hardware shared cache architecture, which includes a static random access storage pool sram pool, a bitmap pool bitmap pool, a direct memory access unit (DirectMemory Access, DMA) and a shared memory management unit (SHARE MEMOERY MANAGEMENT, SMM). Among them, sram refers to static random access memory Static Random-Access Memory, sram pool is a pre-initialized block address pool, sram pool is divided into multiple groups, each group includes multiple minimum storage unit cells, the cells in the same group have the same size, and the cells in different groups have different sizes. The bitmap pool is a pre-initialized bitmap pool, and the bitmappool includes multiple registers, each register corresponds to a group of cells, and each register is used to record the usage status of a group of cells corresponding to it. When the upper-level software needs to write data to the cache, one cell or a combination of multiple cells can be selected from the idle cells to store the data.

[0028] In one implementation, the sram pool is divided into four groups, namely base_a, base_b, base_c and base_d, such as Figure 1As shown. Each group contains 32 cells. The cells in the same group have the same size and are spatially continuous. The cell sizes of different groups are inconsistent. Groups can be continuous or discontinuous, which is specifically specified by the software. Among them, each cell of base_a is 1024 consecutive bytes, each cell of base_b is 512 consecutive bytes, each cell of base_c is 256 consecutive bytes, and each cell of base_d is 128 consecutive bytes. Correspondingly, the bitmap is a register stack composed of four different registers, namely bitmap_reg_a, bitmap_reg_b, bitmap_reg_c and bitmap_reg_d. The four registers correspond to base_a, base_b, base_c and base_d respectively. Each register is 32 bits, and the 32 bits are used to indicate the usage status of cells numbered 0 to 31 in their respective sram pools: a bit of 0 indicates that it is in use; a bit of 1 indicates that it is in an idle state. As shown Figure 1 As shown, m[31..0] is register bitmap_reg_a, which is the bitmap A map of base_a, and its 0 to 31 bits respectively represent the usage status of 32 cells in base_a; n[31..0] is register bitmap_reg_b, which is the bitmap B map of base_b, and its 0 to 31 bits respectively represent the usage status of 32 cells in base_b; p[31..0] is register bitmap_reg_c, which is the bitmap C map of base_c, and its 0 to 31 bits respectively represent the usage status of 32 cells in base_c; q[31..0] is register bitmap_reg_d, which is the bitmap D map of base_d, and its 0 to 31 bits respectively represent the usage status of 32 cells in base_d. After SMM stores data in a cell, the bit in the register corresponding to the cell is cleared by SMM.

[0029] SMM is used to implement cache management, mainly including the cell match unit (CMU), bitmap search module, DMA by bitmap module, and generate TXD module, where TXD stands for transmit descriptor, which is a data structure format used to describe various information required by hardware when sending data.

[0030] In one implementation, the first two bytes of a cell, cell len, are used to record the actual length of the data stored in the cell. The length information of the data does not include len itself. For example, each cell of base_a contains 1024 consecutive bytes, so each cell can store a maximum of 1022 bytes of data. After DMA moves a block (a cell), it updates the first two bytes of the current cell, len, to the actual length of the data stored in the cell.

[0031] Under the control of the underlying software module SMM driver, SMM moves data from the upper-level software to the cell of srampool, and at the same time generates a valid txd, which is then moved to the hardware by DMA and the cell is released for next use (some of the above-mentioned software-hard connection processes will be implemented by the underlying software control logic).

[0032] Figure 2 FIG. 1 is a schematic diagram of the data structure of txd according to an embodiment of the present invention. Figure 2 As shown, a txd has two groups of cell_info, so a txd can carry up to 8 sub_cell_info. It is agreed that SMM fills in order and the subsequent hardware uses it in order. Since sub_cell_info consists of type and id, sub_cell_info can reflect which type of cell and which position of cell are used. When the upper layer data needs two or more different cells to carry, the type-cell_id in cell_info0 needs to be filled in the corresponding sub_cell_info to generate a complete cell_info. The filling order is sub_cell_info0 ...sub_cell_info7, for example, 001:00000 (cell No. 00000 of group 001) and 100:00000 (cell No. 00000 of group 100) are filled in. Three-bit cell_type and five-bit id data constitute a sub_cell_info, which are stored from low to high, as sub_cell_info0, ...sub_cell_info3. Four sub_cell_infos form a cell_info, which is recorded in the Cell_info register. This register is a 32-bit register and is divided into four groups. Each group represents a cell and records the type and id of the cell. Type refers to 1024, 512, 256 and 128. Type 001 indicates 1024 type, 002 indicates 512 type, 003 indicates 256 type, and 004 indicates 128 type. Type occupies 3 bits. For example, Figure 2 2:0 is type, 4:0 is id. Assuming that SMM takes the type 1024, 2:0 in the figure should be 0:0. 2:0 and 4:0 in the figure are called sub_cell_info, and one cell_info can write four sub_cell_info (as shown in the cell_info 0[(type:id) 4] and cell_info 1[(type:id) 4]). Cell_info records which cells these data are distributed in. 1025 data is divided into two blocks for storage. Len occupies two bytes (these two bytes record the length of the data recorded in this cell, which does not include len itself). Therefore, a 1024 cell can store 1024-2=1022 bytes, and another block of memory needs to store 1025-1022=3 bytes. The sum of the data lengths of these two blocks is equal to the total length of the data recorded by Total_len.

[0033] DMA is responsible for moving the data sent by the upper-layer software to the cell. While moving the data, DMA fills the cell_info of the current cell into txd. Specifically, after moving the data into a cell in the memory, SMM generates an interrupt to fwallocate (the allocation module of the underlying software). After fw allocate captures the interrupt, it allocates a blank txd to SMM. SMM converts the bit corresponding to this cell in the bitmap pool into a sequence number. Specifically, it converts bit_n into sequence number n and records the corresponding base_x address. For example, if the bit corresponding to this cell in the bitmap pool is bit_0, then it is converted into sequence number 0, which is the id number. Then the id number is written into txd, and txd records the information of this cell. Next, SMM generates a txd interrupt, the software captures the interrupt, and starts using the information recorded by txd. Specifically, for each incoming txd, the underlying software fw reads the starting address of txd from SMM and hangs the information of this txd in its own txd queue (i.e., txd_hdr queue). Txd_next represents a pointer (or link) pointing to the next txd, and subsequent hardware processing will be processed in the order of txd. When all txd information is hung in the txd_hdr queue, the hardware processing module is started and the txd_hdr queue is handed over to the hardware.

[0034] Figure 3 FIG. 1 is a schematic diagram showing the principle of software and hardware shared cache according to an embodiment of the present invention. Figure 3As shown, the system is powered on and registers are configured. The registers here refer to the algorithm registers and the policy registers. When the data from the upper layer software (upper layer sw_tx_buf) is sent to the SMM through the upper layer software send interface SMMI, as shown in (1), the CMU of the SMM reads the configuration of the algorithm registers and the policy registers, matches one or more cells for the upper layer sw_tx_buf, and then generates an interrupt, as shown in Figure 2 As shown; Next, the underlying software fw allocate captures the interrupt and generates txd, as shown in (3); Next, the software determines whether the txd is a blank txd. If it is a blank txd, it will hand over the txd to SMM, as shown in (4); Next, the SMM bitmap search module searches for cells from the bitmap pool, as shown in (5); Next, the dma by bitmap module calculates the destination address of the DMA based on the found cell, so that the DMA moves the data from the cell to the hardware according to the address, as shown in (6); Next, the generate txd module generates cell information, including the cell type and id, as shown in (7); Next, the SMM generates an interrupt, the underlying software captures the interrupt, and reads the starting address of the cell from the SMM, and hangs it in the blank transmit descriptor queue (txd_hdr queue), as shown in (8); When the information of all cells participating in this cache is hung on txd_hdr After the hardware processes the txd_hdr queue, the hardware starts to process the txd, as shown in (9). The method of hardware processing the txd_hdr queue and obtaining data is consistent with the method of SMM putting data. First, each sub_cell_info in the txd_hdr queue is obtained in turn, and the real data address is obtained after address conversion and then processed; after the hardware processes the txd_hdr queue, an interrupt is generated, as shown in (10); after the software captures the hardware processing interrupt, for the cell whose data has been successfully transferred to the hardware, the release module fw release releases the bit corresponding to the cell in the register stack, as shown in (11); and for the data that the hardware has not moved away or the data that has failed to be moved, it will be moved again, as shown in (12).

[0035] Figure 4 FIG. 4 is an architecture of a storage unit matching module according to an embodiment of the present invention. Figure 4 As shown, the CMU mainly includes an algorithm register, a strategy register, a dynamic switch unit and a matching unit.

[0036] As shown in Table 1, the algorithm register specifies the specific algorithm used by the CMU and whether to use a dynamic strategy. The bit field of the algorithm register includes the algorithm selection bit, the algorithm weight bit, the storage cell size bit, and the dynamic algorithm switching control bit. Taking the eight matching algorithms as an example, bits 24 to 31 are the algorithm selection bits, each bit corresponds to an algorithm, and setting 1 is valid, indicating that the corresponding algorithm is used, and setting 0 is invalid; bits 8 to 23 are the algorithm weight bits, where each two bits correspond to an algorithm, which are used to record the weight of the algorithm during dynamic switching. The algorithm bit value is 0 to 3; bits 6 and 7 represent the cell size when the fixed size allocation algorithm is used, 0, 1, 2 and 3 correspond to bitmap_a_reg, bitmap_b_reg, bitmap_c_reg and bitmap_d_reg respectively; bits 1 to 5 are reserved; bit 0 is the dynamic algorithm switching control bit, bit[0] is 0, indicating that the static strategy is used, and bit[0] is 1, indicating that the dynamic strategy is used.

[0037] Table 1 Meaning and value of each field of the algorithm register

[0038]

[0039] As shown in Table 2, the strategy register specifies the algorithm switching principle used and the enable bit of each algorithm when dynamically switching algorithms. The strategy register includes the total byte digits used to limit the total number of bytes continuously sent by each matching algorithm, the work packet digits used to limit the number of work packets continuously sent by each matching algorithm, the full event number digits used to limit the maximum number of full events that occur for each matching algorithm, and the strategy selection switch bits used to limit the matching strategy. Among them, the 20th to 31st bits are the total byte digits, corresponding to the throughput matching principle, the total byte digits represent the maximum number of bytes that can be continuously sent by each matching algorithm, in units of M, for example, the maximum number of bytes that can be continuously sent by each matching algorithm can be limited to 4096Mbytes; the 10th to 19th bits represent the maximum number of packets that can be continuously worked by each matching algorithm, corresponding to the total packet number matching principle, the maximum number of packets is in units of 100 packets, for example, the maximum number of packets that can be continuously worked by each matching algorithm can be limited to 102400, then when the number of packets that a certain matching algorithm continuously works reaches 102400 packets, it will switch to the next algorithm; the 3rd to 9th bits are used to limit the sram under each matching algorithm The maximum number of full times that the pool occurs corresponds to the full number matching principle. For example, if the maximum full times is limited to 127, then when a certain matching algorithm has 127 full events, it will switch to the next matching algorithm; bits 0 to 2 are matching principle selection switches, corresponding to the above three matching principles respectively. The three matching principles are mutually exclusive. Setting 1 is valid, indicating that the corresponding matching principle is used, and setting 0 is invalid. Setting all bits 0 to 2 to 0 means using the static algorithm. This configuration scheme is guaranteed by software.

[0040] Table 2 Meaning and value of each field of the policy register

[0041]

[0042] When using a static strategy, the system uses a fixed matching algorithm to match the bits in the bitmap.

[0043] When using dynamic strategy, the system starts to start internal statistical calculation values. There are three statistical modules inside SMM, namely the current total traffic statistical module (corresponding to the throughput matching principle), the total packet number statistical module (corresponding to the total packet number matching principle) and the number of SRAM full events (corresponding to the full number matching principle). The current matching algorithm cannot find a suitable cell combination to carry the upper layer tx_buf as a full count. The three statistical modules are controlled by bit[2:0] of cmu_policy_reg respectively. After the matching principle is selected, the relevant statistical modules start to work. When the count value reaches the set maximum threshold, the switching of the matching algorithm is triggered, and the statistical module is cleared at the same time. After clearing, statistics continue for the next switching. These three internal statistical modules are invalid in the static algorithm.

[0044] This embodiment provides 8 matching algorithms to adapt to different scenarios. Among the 8 algorithms, the ids of the four sizes of cells, bitmap_a_reg, bitmap_b_reg, bitmap_c_reg and bitmap_d_reg, are 0, 1, 2 and 3 respectively, wherein the cell size of bitmap_a_reg is 1024 bytes, the cell size of bitmap_b_reg is 512 bytes, the cell size of bitmap_c_reg is 256 bytes, and the cell size of bitmap_d_reg is 128 bytes, as shown in Table 3.

[0045] Table 3 Cell type and id

[0046]

[0047] Table 4 gives the cell matching methods of 8 matching algorithms. As shown in Table 4:

[0048] The id of the random size matching algorithm (RAND SIZE, RDMS) is 0. The random number generator module inside the CMU randomly selects a number from 0 to 3, and then selects an idle cell from the selected cell type. For example, when the SMM receives a data packet from the upper-layer software, the number randomly selected by the random number generator module is 2, then an idle cell will be selected from bitmap_c_rge to store data.

[0049] The id of the maximum size priority matching algorithm (MAX SIZE, MAXS) is 1. This algorithm prioritizes the cell type with the largest size from multiple cell types, that is, it prioritizes bitmap_a_reg. If the cells corresponding to bitmap_a_reg are all in use, then randomly select a number from 1 to 3, that is, randomly select a cell type from bitmap_b_reg ~ bitmap_d_reg, and then select the idle cell of this type. This algorithm is suitable for situations with large traffic and long data.

[0050] The id of the minimum size priority matching algorithm (MIN SIZE, MINS) is 2. This algorithm gives priority to selecting the cell type with the smallest size from multiple cell types, that is, bitmap_d_reg is given priority. If the cells corresponding to bitmap_d_reg are all in use, a number is randomly selected from 0 to 2, that is, a cell type is randomly selected from bitmap_a_reg ~ bitmap_c_reg, and then an idle cell of this type is selected. This algorithm is suitable for small traffic and short data such as control information or short messages;

[0051] The id of the economic algorithm (ECOS) is 3. This algorithm selects the type of cell according to the length of the data from the upper-layer software, so that the selected cell will waste the least storage space after storing the data. Specifically, when the length of the data to be stored is in the range of 1 to 126, bitmap_d_reg is selected; when the length of the data to be stored is in the range of 127 to 254, bitmap_c_reg is selected; when the length of the data to be stored is in the range of 255 to 510, bitmap_b_reg is selected; when the length of the data to be stored is in the range of 511 to 1023, bitmap_a_reg is selected;

[0052] The id of the maximum size reserved priority matching algorithm (MAX RESERVED SIZE, MAXRSV) is 4. The algorithm pre-sets the number of reserved maximum size cells. For example, the maximum size cell is bitmap_a_reg, and the reserved number is set to 4. Then, when there are 4 pieces of memory left in bitmap_a_reg, the cell of bitmap_a_reg will not be allocated this time. At the same time, the reserved mark is set to 1, so that at least four pieces of 1024-byte cells are available for the next use. When the reserved 4 pieces of 1024-byte memory are needed next time, the software needs to clear the reserved mark in advance. The specific strategy is determined by the software according to the actual scenario;

[0053] The id of this minimum reserved size priority matching algorithm (MIN RESERVED SIZE, MINRSV) is 5. This algorithm pre-sets the number of reserved minimum size cells. For example, the minimum size cell is bitmap_d_reg, and the reserved number is set to 4. Then, when there are 4 pieces of memory left in bitmap_d_reg, the cell of bitmap_d_reg will not be allocated this time. At the same time, the reserved mark is set to 1, so that at least 4 pieces of 128-byte cells are available for the next use. When the reserved 4 pieces of 128-byte memory are needed next time, the software needs to clear the reserved mark in advance. The specific strategy is determined by the software according to the actual scenario;

[0054] The id of the fixed size priority matching algorithm (FIXED SIZE, FIXS) is 6. Each time the algorithm allocates a cell, it gives priority to selecting a cell according to the fixed configuration length, that is, it gives priority to selecting a cell of a certain fixed size. When no free cell can be obtained from the current fixed size cell, it selects cells of other sizes. For example, if the fixed size of the cell is set to 512 bytes, then each time a cell is allocated, it will give priority to selecting a free cell from bitmap_c_reg. If no free cell can be selected from bitmap_c_reg, it will select a free cell from bitmap_a_reg, bitmap_b_reg and bitmap_d_reg.

[0055] The id of the roulette matching algorithm (RAND ROBIN, RR) is 7. Each time the algorithm allocates a cell, it sequentially polls and selects free cells from memories of various sizes. If the memory of a certain size has been fully retrieved when the memory of that size is retrieved in this round, the memory of that size is ignored and the next size is directly skipped. For example, the algorithm is set to sequentially poll and select free cells from bitmap_a_reg, bitmap_b_reg, bitmap_c_reg and bitmap_d_rge each time it allocates memory. When bitmap_c_reg is selected in this round, it is found that all the cells in bitmap_c_reg are in use, then bitmap_c_reg is skipped and free cells are selected from bitmap_d_rge.

[0056] Table 4 Matching methods of eight matching algorithms

[0057]

[0058] The dynamic switch unit of the CMU is used to dynamically switch the matching algorithm according to the configuration of the algorithm register and the policy register. The matching unit is used to select the corresponding matching algorithm for storage unit matching according to the configuration of the algorithm register or under the control of the dynamic switch unit.

[0059] like Figure 4 As shown, first, the algorithm register and the strategy register are configured, as shown in (1) and (2); next, the corresponding matching algorithm is selected for cell matching according to the configuration of the two registers. If it is a static strategy, the matching unit directly uses the corresponding matching algorithm to match the data from the upper-level software. If it is a dynamic strategy, the dynamic switch unit is turned on, and the dynamic switch unit controls the matching unit to use the corresponding matching algorithm to match the data from the upper-level software. During the matching process, a suitable cell is selected from the bitmap pool, as shown in (3); the position of the selected cell in the bitmap pool is determined, as shown in (4); next, the destination address of the DMA is determined based on this position combined with the starting address of the cell, as shown in (5); finally, the DMA is triggered, as shown in (6), so that the DMA moves the data stored in the cell to the hardware.

[0060] The storage unit matching method of the embodiment of the present application includes: reading a matching strategy; if the matching strategy is a static strategy, reading a matching algorithm corresponding to the static strategy to match the storage unit with the data sent by the upper-layer software according to the matching algorithm; and if the matching strategy is a dynamic strategy, reading a matching principle corresponding to the dynamic strategy, and dynamically selecting a matching algorithm according to the matching principle to match the storage unit with the data sent by the upper-layer software according to the matching algorithm.

[0061] Figure 5 FIG. 5 is a flow chart of a storage unit matching method 500 according to an embodiment of the present invention. Figure 5 As shown, the memory cell matching method 500 begins at step S510 .

[0062] In step S510, the matching strategy is read.

[0063] The matching strategy is read from the strategy register.

[0064] Next, in step S520, it is determined whether the matching strategy is a dynamic strategy, and when the determination result is no, step S530 is executed, and when the determination result is yes, step S540 is executed.

[0065] The result of the judgment is no, indicating that the configured matching strategy is a static strategy. In step S530, the matching algorithm corresponding to the static strategy is read to match the storage unit for the data sent by the upper-level software according to the matching algorithm. For example, for data with more small packets, the minimum size priority matching algorithm or the economic algorithm can be adopted by configuring the algorithm register, so that the small packet data will not occupy a large-size memory. When a large packet data arrives, the large packet will not be unable to be cached due to too many small packets, thereby avoiding the problem of decreased throughput caused by this; similarly, for data with more large packets, the maximum size priority matching algorithm or the economic algorithm can be adopted by configuring the algorithm register, so that the large packet data will not occupy a large-size memory. When a large packet data arrives, the large packet will not be unable to be cached due to too many small packets, thereby avoiding the problem of long delay of key information caused by this.

[0066] The ID of the matching algorithm corresponding to the static strategy is read from the algorithm register, and according to the read algorithm ID, the corresponding matching algorithm is called to match the storage unit with the data sent by the upper-layer software.

[0067] In step S540, the matching principle corresponding to the dynamic policy is read, and a matching algorithm is dynamically selected according to the matching principle to match the storage unit for the data sent by the upper-layer software according to the matching algorithm.

[0068] Read the configured matching principle from the policy register. The algorithm register configures the weight of each matching algorithm under the dynamic policy. According to the matching principle and the weight of each matching algorithm, the matching algorithm is switched. Each matching principle can specify a priority, which is represented by 0~3. The larger the value, the higher the priority. When the switching condition is met, the matching algorithm with the highest priority is selected for cell matching first. Several algorithms with the same priority are a set. The algorithm switches in the set are switched in order from small to large according to the id, and then jump to the next priority set. For example, the algorithm ids of priority 3 are 2, 4, and 6, the algorithm ids of priority 2 are 0 and 1, the algorithm id of priority 1 is 3, and the algorithm ids of priority 0 are 5 and 7. Then according to the switching condition, the switching order executed is to execute 2->4->6 first, then execute 0>1, then execute 3, then execute 5->7, and execute from the highest priority to the lowest priority, and repeat.

[0069] Assume that the matching principle corresponding to bit[0] of the policy register is matching based on the full number of times, the matching principle corresponding to bit[1] is matching based on the total number of packets, and the matching principle corresponding to bit[2] is matching based on the throughput. Bit[0] and bit[1] are set to 0, and bit[2] is set to 1. Then the configured matching principle is matching based on throughput. The algorithm register configures the weight values ​​of the algorithms with IDs from 0 to 7 as 0, 1, 1, 3, 1, 1, 1, 2, respectively. Then, the IDs of the eight matching algorithms are sorted in descending order of priority, which should be: 3, 7, 1, 2, 4, 5, 6, 0. When performing cell matching, the algorithm with ID 3 (economic algorithm) will be selected first. This algorithm is used to match the data sent by the upper-layer software. When the total number of bytes of the matched data reaches 4096Mbytes, it is switched to the algorithm with ID 7 (roulette matching algorithm).

[0070] Figure 6 yes Figure 5 The detailed flow chart of the storage unit matching method is shown in FIG. Figure 6As shown in the figure, after the system is powered on, the algorithm register and policy register are first configured. Next, the static policy or dynamic policy is determined based on the configuration of the policy register. If bit[0] of the algorithm register is set to 0, it means that the static policy is used. Combined with bit[31:24] of the algorithm register, check the matching algorithm adopted by the static policy; next, use the above matching algorithm to allocate cells for the data packets sent by the upper-layer software. If bit[0] of the algorithm register is set to 1, it means that the dynamic policy is used. Next, turn on the dynamic switch, read bit [2:0] of the policy register, and determine the matching principle of dynamic switching. Specifically, first determine whether the throughput matching principle is adopted. If so, select the corresponding matching algorithm based on the throughput matching principle and bit [23:8] of the algorithm register, and then use the selected matching algorithm to allocate cells for the data packets sent by the upper-layer software. During the cell allocation process, switch the matching algorithm based on the matching principle. If the throughput matching principle is not adopted, continue to determine whether the total packet number matching principle is adopted. If so, select the corresponding matching algorithm based on the total packet number matching principle and bit [23:8] of the algorithm register, and then use the selected matching algorithm to allocate cells for the data packets sent by the upper-layer software. During the cell allocation process, switch the matching algorithm based on the matching principle. If the total packet number matching principle is not adopted, it means that the full number matching principle is adopted. According to the full number matching principle and bit [23:8] of the algorithm register, select the corresponding matching algorithm, and then use the selected matching algorithm to allocate cells for the data packets sent by the upper-layer software. During the cell allocation process, switch the matching algorithm based on the matching principle. When the system works for a certain period of time, it can be checked again whether the currently used policy is a dynamic policy or a static policy, and then return to the step of determining whether to adopt a static policy or a dynamic policy according to the configuration of the policy register.

[0071] The present application also provides a storage unit matching device, such as Figure 7 As shown, the storage unit matching device 700 includes a reading unit 710 , a judging unit 720 , a static matching unit 730 and a dynamic matching unit 740 .

[0072] The reading unit 710 is adapted to read the matching strategy.

[0073] The determination unit 720 is adapted to determine whether the matching strategy is a dynamic strategy.

[0074] The static matching unit 730 is adapted to read the matching algorithm corresponding to the static policy when the judgment result is negative, so as to match the storage unit with the data sent by the upper-layer software according to the matching algorithm.

[0075] The dynamic matching unit 740 is adapted to read the matching principle corresponding to the dynamic strategy when the judgment result is yes, and dynamically select a matching algorithm according to the matching principle to match the storage unit with the data sent by the upper-layer software according to the matching algorithm.

[0076] As a preferred embodiment of the present application, the matching principle is matching based on throughput, matching based on the total number of packets, or matching based on the full number of times.

[0077] As a preferred embodiment of the present application, the dynamically selecting a matching algorithm according to the matching principle includes: switching between various matching algorithms in descending order of weight according to the matching principle.

[0078] As a preferred embodiment of the present application, the matching algorithm includes:

[0079] Random size matching algorithm, randomly selects a storage unit of a certain size;

[0080] The largest size first matching algorithm gives priority to the storage unit with the largest size; and

[0081] The minimum size first matching algorithm gives priority to selecting the storage unit with the smallest size.

[0082] As a preferred embodiment of the present application, the matching algorithm includes:

[0083] An economic algorithm selects a storage unit or a combination of storage units that can accommodate the data and waste the least storage space.

[0084] As a preferred embodiment of the present application, the matching algorithm includes:

[0085] The maximum size reservation priority matching algorithm is used this time. When the number of storage units of the maximum size is reduced to a preset number, the storage unit of the maximum size is no longer matched for the data this time; and

[0086] In this minimum size reservation priority matching algorithm, when the number of storage units of the minimum size is reduced to a preset number, the storage unit of the minimum size is no longer matched for the data.

[0087] As a preferred embodiment of the present application, the matching algorithm includes:

[0088] Fixed-size priority matching algorithm gives priority to storage units of fixed size.

[0089] As a preferred embodiment of the present application, the matching algorithm includes:

[0090] The roulette matching algorithm polls and selects storage units of various sizes in a preset order.

[0091] The storage unit matching device 700 can implement the processing of each step of the method 500, and has the same principle and technical effect as the method 500, which will not be described in detail here.

[0092] The storage unit matching method, device and module of the embodiment of the present application are provided with a plurality of matching algorithms, a plurality of matching principles, and two matching strategies, static and dynamic. The algorithm register and the strategy register can be configured according to the characteristics of the upper-layer software data. The system adopts a static strategy or a dynamic strategy according to the configuration of the algorithm register and the strategy register. When the dynamic strategy is adopted, it switches between a plurality of matching algorithms. The embodiment of the present application is applicable to scenarios of various packet lengths, improves the efficiency of shared cache usage in various scenarios, and avoids the problem of low cache utilization of a single matching algorithm. The storage unit matching method, device and module of the embodiment of the present application are used for cache management. For scenarios with too many small packets, the problem of decreased throughput caused by the inability of large packets to be allocated to the cache can be avoided. For scenarios with too many large packets, the problem of long delay of key information caused by the inability of small packets to be allocated to the cache can be avoided.

[0093] The storage unit matching method, device and module of the embodiments of the present application can be applied in the field of software and hardware shared cache management in SOC systems. The SOC here is not limited to WIFI SOC and other communication SOCs, and can be applied to any scenario involving software and hardware sharing data through a certain interface.

[0094] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.

[0095] Similarly, it should be understood that in order to simplify the present disclosure and help understand one or more of the various inventive aspects, in the above description of the exemplary embodiments of the present invention, the various features of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, the disclosed method should not be interpreted as reflecting the following intention: the claimed invention requires more features than the features clearly recorded in each claim. Those skilled in the art should understand that the modules or units or components of the devices in the examples disclosed herein can be arranged in the devices described in the embodiment, or alternatively can be located in one or more devices different from the devices in the example. The modules in the aforementioned examples can be combined into one module or can be divided into multiple submodules in addition.

[0096] In addition, it will be appreciated by those skilled in the art that, although some embodiments described herein include certain features included in other embodiments rather than other features, the combination of features of different embodiments is meant to be within the scope of the present invention and to form different embodiments. In addition, some of the embodiments described herein are described as a combination of methods or method elements that can be implemented by a processor of a computer system or by other devices that perform the functions. Therefore, a processor with necessary instructions for implementing the method or method elements forms a device for implementing the method or method elements. In addition, the elements described herein of the device embodiment are examples of devices that are used to implement the functions performed by the elements for the purpose of implementing the invention.

[0097] As used herein, unless otherwise specified, the use of ordinal numbers "first," "second," "third," etc. to describe common objects merely indicates that different instances of similar objects are involved, and is not intended to imply that the objects so described must have a given order in time, space, order, or in any other manner.

[0098] Although the present invention has been described according to a limited number of embodiments, it will be apparent to those skilled in the art, with the benefit of the above description, that other embodiments may be envisioned within the scope of the invention thus described. In addition, it should be noted that the language used in this specification is primarily selected for readability and instructional purposes, rather than for explaining or limiting the subject matter of the present invention.

[0099] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A storage unit matching method, characterized in that: include: Read matching strategy; Determining whether the matching strategy is a dynamic strategy; If not, then read the matching algorithm corresponding to the static policy to match the storage unit for the data sent by the upper software according to the matching algorithm; as well as If so, read the matching principle corresponding to the dynamic strategy, and dynamically select a matching algorithm according to the matching principle, so as to match the storage unit for the data sent by the upper-layer software according to the matching algorithm; wherein: the matching principle is matching according to throughput, matching according to the total number of packets, or matching according to the full number of times, and dynamically select a matching algorithm according to the matching principle, including: reading the configured matching principle from the policy register, the algorithm register is configured with the weight of each matching algorithm under the dynamic strategy; according to the matching principle, when the switching condition corresponding to the matching principle is reached, switch between the matching algorithms in the order of the weight of each matching algorithm from high to low.

2. The method according to claim 1, characterized in that The matching algorithm includes: Random size matching algorithm, randomly selects a storage unit of a certain size; The largest size first matching algorithm gives priority to the storage unit with the largest size; and The minimum size first matching algorithm gives priority to selecting the storage unit with the smallest size.

3. The method according to claim 1, characterized in that The matching algorithm includes: An economic algorithm selects a storage unit or a combination of storage units that can accommodate the data and waste the least storage space.

4. The method according to claim 1, characterized in that The matching algorithm includes: The maximum size reservation priority matching algorithm is used this time. When the number of storage units of the maximum size is reduced to a preset number, the storage unit of the maximum size is no longer matched for the data this time; and In this minimum size reservation priority matching algorithm, when the number of storage units of the minimum size is reduced to a preset number, the storage unit of the minimum size is no longer matched for the data.

5. The method according to claim 1, characterized in that The matching algorithm includes: Fixed-size priority matching algorithm gives priority to storage units of fixed size.

6. The method according to claim 1, characterized in that The matching algorithm includes: The roulette matching algorithm selects storage units of various sizes in a preset order.

7. A storage unit matching device, characterized in that: include: A reading unit, adapted to read a matching strategy; A judging unit, adapted to judge whether the matching strategy is a dynamic strategy; A static matching unit adapted to read a matching algorithm corresponding to the static policy when the judgment result is negative, so as to match the storage unit with the data sent by the upper layer software according to the matching algorithm; as well as A dynamic matching unit is adapted to read the matching principle corresponding to the dynamic strategy when the judgment result is yes, and dynamically select a matching algorithm according to the matching principle, so as to match the storage unit with the data sent by the upper-layer software according to the matching algorithm; wherein: the matching principle is matching according to throughput, matching according to the total number of packets, or matching according to the full number of times, and dynamically selecting a matching algorithm according to the matching principle includes: reading the configured matching principle from the policy register, the algorithm register is configured with the weight of each matching algorithm under the dynamic strategy; according to the matching principle, when the switching condition corresponding to the matching principle is reached, switching between the matching algorithms is performed in descending order of the weight of each matching algorithm.