A table entry space allocation method and device

By dynamically adjusting the table entry storage space in high-performance switch chips and using technologies such as direct indexing and hash indexing, the problem of limited storage capacity is solved, achieving higher storage resource utilization and improving business capacity specifications.

CN118331507BActive Publication Date: 2024-09-24格创通信(浙江)有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410742649.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-11
Publication Date
2024-09-24
Estimated Expiration
2044-06-11

AI Technical Summary

Technical Problem

Due to the limited storage media capacity of high-performance switch routing and forwarding chips, it is difficult to increase service capacity specifications under limited SRAM resources.

Method used

By allocating initial storage space for different types of tables during the chip initialization phase, and dynamically expanding the storage space after the storage space exceeds the preset threshold, the mapping relationship between the table item index and the address index is determined, and types such as direct index and hash index are used to perform space analysis. Management to achieve flexible allocation of storage space.

Benefits of technology

It improves the utilization rate of storage resources in the chip without the user being aware of it, achieves an increase in business capacity specifications under the same SRAM resources, and avoids human intervention and chip restart.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118331507B
    Figure CN118331507B
Patent Text Reader

Abstract

The embodiment of the present application provides a table entry space allocation method and device, the method comprising: in the chip initialization stage, allocating initial storage space for different types of tables from the first storage resource pool; after the storage space occupied by the first type of table exceeds the preset threshold of the initial storage space, allocating the first extended storage space for the first type of table from the free storage space contained in the first storage resource pool; determining the mapping relationship between the table entry index and the address index of the table entry in the first type of table, wherein the address index represents the storage position of the table entry in the first storage resource pool. The storage space size of a specific table can be adaptively adjusted according to the actual business scenario, and the allocation process of the table entry space is automatically executed by the device, without human intervention for mode configuration or restarting the chip, thereby improving the utilization rate of the storage resources used to store table entries in the chip in a user-imperceptible manner, or improving the business capacity specifications under the same storage resources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data communication, and in particular to a table entry space allocation method and device. Background Art

[0002] For high-performance switch routing forwarding chips with strong forwarding capabilities, the table storage medium mostly uses SRAM (Static Random-Access Memory). Due to chip area and cost factors, the SRAM capacity on the chip is generally limited and will not reach a capacity of several hundred MB (Mbyte) or even GB (Gigabyte).

[0003] Therefore, how to maximize the capacity specifications of chip services under limited SRAM resources is a difficult problem that high-performance routing and forwarding chips need to face. Summary of the invention

[0004] The purpose of the embodiments of the present application is to provide a table entry space allocation method and device to achieve adaptive adjustment of the storage space size of a specific table according to the actual business scenario, thereby improving the utilization rate of storage resources used to store table entries in the chip in a user-imperceptible manner, or improving the business capacity specifications under the same storage resources. The specific technical solution is as follows:

[0005] In a first aspect of the present application, a table entry space allocation method is provided, the method comprising:

[0006] In the chip initialization phase, initial storage space is allocated for different types of tables from the first storage resource pool;

[0007] After the storage space occupied by the first type table exceeds a preset threshold of the initial storage space, allocating a first extended storage space for the first type table from the free storage space included in the first storage resource pool;

[0008] A mapping relationship between an entry index and an address index of an entry in the first type table is determined, wherein the address index represents a storage location of the entry in the first storage resource pool.

[0009] Optionally, the step of determining a mapping relationship between an entry index and an address index of an entry in the first type table includes:

[0010] Determine an index type of the first type table, where the index type includes a first direct index type, a second direct index type, and a hash index type;

[0011] Based on the index type, a mapping relationship between an entry index of an entry in the first type table and the address index is determined.

[0012] Optionally, the step of determining, based on the index type, a mapping relationship between an entry index of an entry in the first type table and the address index includes:

[0013] If it is determined that the index type is the first direct index type, it is determined that the entry index of the entry in the first type table and the address index satisfy a first mapping relationship, and the first mapping relationship is: the index value of the entry index of the entry in the first type table represents the address index.

[0014] Optionally, the step of determining, based on the index type, a mapping relationship between an entry index of an entry in the first type table and the address index includes:

[0015] If it is determined that the index type is the second direct index type, a first page table is created for each sub-table segment contained in the first type table; the sub-table segment includes an initial table segment and an extended table segment; the first page table is used to map the table entry index of the sub-table segment of the first type table to the address index of the sub-table segment in the first storage resource pool; wherein, the index values ​​of the table entry indexes of adjacent sub-table segments are continuous.

[0016] Optionally, the step of determining, based on the index type, a mapping relationship between an entry index of an entry in the first type table and the address index includes:

[0017] If it is determined that the index type is a hash index type, for each sub-table segment included in the first type table, determine a second mapping relationship between a hash index of a table entry in the sub-table segment and the address index, the sub-table segment including an initial table segment and an extended table segment;

[0018] The second mapping relationship includes:

[0019] The mapping relationship between the first bit segment of the hash index and the starting address of the sub-table segment in the first storage resource pool, and the mapping relationship between the second bit segment of the hash index and the address offset; wherein, the hash index is calculated based on the table entry index and a pre-set hash algorithm.

[0020] Optionally, the method further includes:

[0021] The stored table entries in the first type table are traversed, and the storage locations of the stored table entries are changed according to the second mapping relationship.

[0022] Optionally, also include:

[0023] When all entries in the first extended storage space are deleted, the first extended storage space is recycled as free storage space.

[0024] In a second aspect of the present application, a table entry space allocation device is provided, the device comprising:

[0025] A first allocation module, used to allocate initial storage space for different types of tables from a first storage resource pool during a chip initialization phase;

[0026] A second allocation module, configured to allocate a first extended storage space to the first type table from the free storage space included in the first storage resource pool after the storage space occupied by the first type table exceeds a preset threshold of the initial storage space;

[0027] A determination module is used to determine a mapping relationship between an entry index and an address index of an entry in the first type table, wherein the address index represents a storage location of the entry in the first storage resource pool.

[0028] Optionally, the determining module is specifically used to:

[0029] Determine an index type of the first type table, where the index type includes a first direct index type, a second direct index type, and a hash index type;

[0030] Based on the index type, a mapping relationship between an entry index of an entry in the first type table and the address index is determined.

[0031] Optionally, the determining module is specifically used to:

[0032] If it is determined that the index type is the first direct index type, it is determined that the entry index of the entry in the first type table and the address index satisfy a first mapping relationship, and the first mapping relationship is: the index value of the entry index of the entry in the first type table represents the address index.

[0033] Optionally, the determining module is specifically used to:

[0034] If it is determined that the index type is the second direct index type, a first page table is created for each sub-table segment contained in the first type table; the sub-table segment includes an initial table segment and an extended table segment; the first page table is used to map the table entry index of the sub-table segment of the first type table to the address index of the sub-table segment in the first storage resource pool; wherein, the index values ​​of the table entry indexes of adjacent sub-table segments are continuous.

[0035] Optionally, the determining module is specifically used to:

[0036] If it is determined that the index type is a hash index type, for each sub-table segment included in the first type table, determine a second mapping relationship between a hash index of a table entry in the sub-table segment and the address index, the sub-table segment including an initial table segment and an extended table segment;

[0037] The second mapping relationship includes:

[0038] The mapping relationship between the first bit segment of the hash index and the starting address of the sub-table segment in the first storage resource pool, and the mapping relationship between the second bit segment of the hash index and the address offset; wherein, the hash index is calculated based on the table entry index and a pre-set hash algorithm.

[0039] Optionally, the device further comprises:

[0040] The position changing module is used to traverse the stored table entries in the first type table and change the storage position of the stored table entries according to the second mapping relationship.

[0041] Optionally, the device further comprises:

[0042] The recycling module is used to recycle the first extended storage space as free storage space when all entries in the first extended storage space are deleted.

[0043] In a third aspect of the present application, an electronic device is provided, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;

[0044] Memory, used to store computer programs;

[0045] The processor is used to implement any of the above-mentioned method steps when executing the program stored in the memory.

[0046] According to a fourth aspect of the present application, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, any of the method steps described above is implemented.

[0047] Beneficial effects of the embodiments of the present application:

[0048] The table entry space allocation method and device provided in the embodiments of the present application allocate initial storage space to different types of tables from a first storage resource pool during a chip initialization phase; after the storage space occupied by the first type of table exceeds a preset threshold of the initial storage space, allocate a first extended storage space to the first type of table from the free storage space contained in the first storage resource pool; determine a mapping relationship between a table entry index and an address index of a table entry in the first type of table, wherein the address index represents a storage location of the table entry in the first storage resource pool.

[0049] Therefore, the embodiment of the present application takes into account the characteristics that different types of tables in different business scenarios will not reach the maximum capacity specifications at the same time, and provides a flexible and dynamically allocated table space resource management solution, which can adaptively adjust the storage space size of a specific table according to the actual business scenario, and the table space allocation process is automatically executed by the device, without the need for human intervention to configure the mode or restart the chip. Therefore, the dynamic allocation of storage space is achieved through hardware, and the utilization rate of storage resources used to store table items in the chip is improved in a user-imperceptible manner.

[0050] Of course, it is not necessary to achieve all of the advantages described above at the same time to implement any product or method of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other embodiments can also be obtained based on these drawings.

[0052] Figure 1 A schematic diagram of allocating table entry resources in the related art;

[0053] Figure 2 A schematic diagram of a flow chart of a table entry space allocation method provided in an embodiment of the present application;

[0054] Figure 3 Another schematic diagram of a flow chart of a table entry space allocation method provided in an embodiment of the present application;

[0055] Figure 4 A schematic diagram of the mapping relationship between the table entry index and the address index provided in the embodiment of the present application;

[0056] Figure 5 Another schematic diagram of the mapping relationship between the table entry index and the address index provided in the embodiment of the present application;

[0057] Figure 6 Another schematic diagram of the mapping relationship between the table entry index and the address index provided in the embodiment of the present application;

[0058] Figure 7 A schematic diagram of the structure of a table entry space allocation device provided in an embodiment of the present application;

[0059] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0060] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field based on the present application belong to the scope of protection of the present application.

[0061] Currently, a static partitioning method is used for the partitioning of table entry resources, that is, once the chip is powered on and initialized, the maximum capacity specification of each service table entry is fixed.

[0062] See also Figure 1 , which is a schematic diagram of allocating table entry resources in the related technology. Assuming that the chip has 10MB of SRAM space, the fixed resource sizes allocated to the FIB (Forwarding information Base) table, MAC (Media Access Control) table and MPLS (Multi-Protocol Label Switching) table are 4 megabytes, 3 megabytes and 2 megabytes respectively.

[0063] However, in different scenarios, the usage rates of different types of tables vary greatly. For example, in a scenario where Layer 3 forwarding is the main focus, the MAC table is mostly idle, and the FIB table cannot use the storage resources allocated for the MAC table. As a result, although SRAM resources are scarce, the actual SRAM space utilization rate is not high.

[0064] At present, some chip scenarios provide different table space allocation modes to cope with different business scenarios. For example, one mode is set to cope with the scenario dominated by Layer 2 forwarding, in which the MAC table capacity is large and the corresponding FIB capacity is small; another mode is set to cope with the scenario dominated by Layer 3 forwarding, in which the FIB table capacity is large and the MAC table capacity is small. When switching from one mode to another, manual access is required for control and the chip is restarted. This limitation does not meet the requirements of some test scenarios.

[0065] In view of this, this application proposes a flexible and dynamically allocated table entry space resource management solution, which can adaptively increase or reduce the size of a specific table according to the actual business scenario, without the need for human intervention to configure a new mode and restart the chip. The chip SRAM resource utilization rate is improved in a user-imperceptible way, or the business capacity specification is improved with the same SRAM resources.

[0066] The following is a detailed introduction to the table entry space allocation method provided in the embodiment of the present application.

[0067] See also Figure 2, is a flow chart of a table entry space allocation method provided in an embodiment of the present application, comprising the following steps:

[0068] S201: In the chip initialization phase, initial storage space is allocated to tables of different types from a first storage resource pool.

[0069] The first storage resource pool may be a storage medium in the forwarding chip for storing table entries, and may specifically be a storage medium in the form of SRAM.

[0070] Those skilled in the art can understand that in order to realize the network forwarding function, common network devices, such as switches and routers, each maintains some table entries to complete routing addressing and fast forwarding functions. Among them, the more important table entries include: routing table, forwarding table, MAC table, ARP (Address Resolution Protocol) table, etc.

[0071] In the embodiment of the present application, the different types of tables involved in step S201 include tables for implementing network forwarding functions required to be used in different data forwarding scenarios, including, as an example, a FIB table, a MAC table, and an MPLS table.

[0072] The initial allocated space can be understood as a table entry storage space set based on the minimum guarantee requirement, and thus can be a smaller storage space. In addition, the initial storage spaces allocated to different tables can be the same or different.

[0073] As an example, if the chip has 10MB of SRAM space, the fixed resource sizes allocated to the FIB table, MAC table, and MPLS table are 2MB, 2MB, and 1MB respectively, and the remaining 5MB is used as a free resource pool.

[0074] S202: After the storage space occupied by the first type table exceeds a preset threshold of the initial storage space, a first extended storage space is allocated to the first type table from the free storage space included in the first storage resource pool.

[0075] In the embodiment of the present application, new entries are continuously added to the corresponding table during the operation of the network device. For example, during the operation of the switch, new MAC entries are gradually generated, and the MAC entries need to be added to the storage space allocated for the MAC table.

[0076] In the embodiment of the present application, when the storage space of a certain type of table is continuously occupied and exceeds a certain threshold of the initial storage space, new storage space is allocated for this type of table. The threshold may be preset, for example, 80% or 90%.

[0077] As an example, the table entry space allocation method provided in an embodiment of the present application can be applied to a table entry space allocation module in a network device, which is pre-entered with code for implementing table entry space allocation. It can allocate initial storage space for different types of tables in the initial stage of the chip, and receive table expansion requests for different types of tables during chip operation, and allocate extended storage space.

[0078] In addition, each type of table corresponds to its own monitoring module, which is used to monitor the size of the storage space occupied by this type of table.

[0079] As an example, when the monitoring module detects that the storage space occupied by the first type of table exceeds the preset threshold of the initial storage space, it sends a table expansion request to the table entry space allocation module. After receiving the table expansion request, the table entry space allocation module allocates a first extended storage space for the first type of table from the free storage space contained in the first storage resource pool.

[0080] S203: Determine a mapping relationship between an entry index and an address index of an entry in the first type table, wherein the address index represents a storage location of the entry in the first storage resource pool.

[0081] Those skilled in the art will understand that after a table entry is added to the table, the table entry is actually written to a storage location in the SRAM. During operation of the network device, if it is necessary to find the specific content of a table entry, it is necessary to map the table entry index of the table entry to an address index. The address index represents the actual storage location of the table entry, and the specific content of the table entry can be found based on the address index.

[0082] It can be seen that a mapping relationship between the entry index and the address index of the entry needs to be established to facilitate subsequent entry writing and entry search.

[0083] In the embodiment of the present application, after the first extended storage space is allocated to the first type table, a mapping relationship between the table entry index and the address index of the table entry in the first type table can be established.

[0084] The table entry space allocation method provided in the embodiment of the present application allocates initial storage space to different types of tables from a first storage resource pool during the chip initialization phase; after the storage space occupied by the first type of table exceeds a preset threshold of the initial storage space, allocates a first extended storage space to the first type of table from the free storage space contained in the first storage resource pool; determines the mapping relationship between the table entry index and the address index of the table entry in the first type of table, wherein the address index represents the storage position of the table entry in the first storage resource pool.

[0085] Therefore, the embodiment of the present application takes into account the characteristics that different types of tables in different business scenarios will not reach the maximum capacity specifications at the same time, and provides a flexible and dynamically allocated table space resource management solution, which can adaptively adjust the storage space size of a specific table according to the actual business scenario, and the table space allocation process is automatically executed by the device, without the need for human intervention to configure the mode or restart the chip. Therefore, the dynamic allocation of storage space is achieved through hardware, and the utilization rate of storage resources used to store table items in the chip is improved in a user-imperceptible manner.

[0086] From another perspective, it is possible to use fewer SRAM resources to support the same business capacity specification requirements. For example, if the maximum specification of the FIB table requires 8MB, the maximum specification of the MAC table requires 8MB, and the maximum specification of the MPLS table requires 4MB, if the storage space is allocated in advance based on the solution in the related art, 20MB of storage space is required. Based on the table entry space allocation method provided in the embodiment of the present application, in the initialization stage, 4MB can be allocated to the FIB table, 4MB to the MAC table, and 2MB to the MPLS table, and 4MB can be reserved as a free pool to meet the maximum specifications of the three tables. At this time, a total of 14MB is required, which is less than 20MB; or in another way, in the initialization stage, 2MB is allocated to the FIB table, 2MB to the MAC table, and 1MB to the MPLS table, and 6MB can be reserved as a free pool to meet the maximum specifications of the three tables. At this time, a total of 11MB is required.

[0087] It can be seen that the application of the table entry space allocation method provided in the embodiment of the present application can support the same service capacity specifications at a lower cost.

[0088] See also Figure 3 , is another flow chart of the table entry space allocation method provided in the embodiment of the present application, such as Figure 3 As shown, it includes S301-S304, among which S301-S302 are the same as S201-S202 and will not be repeated.

[0089] S303: Determine an index type of the first type table, where the index types include a first direct index type, a second direct index type, and a hash index type.

[0090] S304: Determine a mapping relationship between an entry index and an address index of an entry in a table of the first type based on the index type.

[0091] To facilitate understanding, the index types of tables are introduced. Based on the indexing method, they can be divided into direct index type and hash index type. Among them, the table of direct index type can be understood as an array in a logical sense. The key (key value) to be searched is the table item index (index), which itself represents the unique storage address of the result.

[0092] As an example, for a table of direct index type with a bit width of 10B, if the key value is 0, the corresponding storage address is the first 10B, and if the key value is 1, the corresponding storage address is the second 10B. It can be seen that the index value of the table entry index represents the storage location of the table entry, that is, the table entry index and the address index are the same.

[0093] In the embodiment of the present application, the direct index type is further divided into a first direct index type and a second direct index type. Among them, the index value range of the table items in the table of the first direct index type is larger and does not require continuity. The index value range of the table items in the table of the second direct index type is smaller and must be continuous. Among them, if the index value range is greater than the preset value, it can be considered that the index value range is larger; otherwise, it is considered that the index value range is smaller.

[0094] The hash index type uses the key as the input of the hash algorithm to obtain the hash index, and then establishes a mapping relationship between the hash index and the address index.

[0095] For the first direct index type, the second direct index type and the hash index type, different methods need to be used to establish a mapping relationship between the table entry index and the address index.

[0096] It can be seen that in the embodiment of the present application, when establishing the mapping relationship between the table entry index and the address index, the index type of the specific table is fully considered, and different methods are used to create the mapping relationship according to the different index types, so as to take into account various forms of forwarding tables.

[0097] In one embodiment of the present application, before establishing a mapping relationship between a table entry index and an address index, the index type of the first type table is first determined.

[0098] In the embodiment of the present application, the first type of table is a general concept, covering various tables that need to be established in the normal operation of the network device, such as routing tables, forwarding tables, etc. For a specific network device, the index type of each table can be predetermined. Therefore, after the table space allocation module in the network device receives the table expansion request for the first type of table, it can directly determine the index type of the first type of table according to the predetermined index type of each table.

[0099] In one embodiment of the present application, if the index type is determined to be the first direct index type, it is determined that the entry index of the entry in the first type table and the address index satisfy the first mapping relationship, and the first mapping relationship is: the index value of the entry index of the entry in the first type table represents the address index.

[0100] Specifically, for the first direct index type, the value of the table entry index itself represents the storage address of the table entry content, and the index value range of the table entry is relatively large and does not require continuity, so the index value of the table entry index can be directly used as the address index.

[0101] As an example, see Figure 4 , is a schematic diagram of the mapping relationship between the table entry index and the address index provided in the embodiment of the present application, such as Figure 4 As shown, table A is of the first direct index type, and the initial storage space allocated to table A occupies the address interval [0,1023] of the first storage resource pool, which is used to store the specific content of the table entry with the table entry index [0,1023]. The address interval [1023,4096] belongs to the already allocated storage space of other tables. When it is determined that the storage space for table A needs to be expanded, the expanded storage space allocated to table A occupies the address interval [4096,5119] of the first resource pool. Since the index type has a large value range and does not require continuity, for the table entries stored in the address interval [4096,5119], [4096,5119] can be directly used as the table entry index, that is, there are two table entry indexes [0,1023] and [4096,5119] in the same table.

[0102] Those skilled in the art understand that the machine language of a computer only recognizes binary, and the above-mentioned index range and address range are expressed in decimal. In actual applications, both the table entry index and the address index are in binary form. For example, for the first direct index type, the table entry index is 0000 0000 0110, then the binary value is also used as the address index, corresponding to the 7th storage location in the storage resource pool, and the size of each storage location is the bit width.

[0103] It can be seen that in the embodiment of the present application, if the index type is determined to be the first direct index type, the table item index and the address index are actually the same, and a mapping relationship between the table item index and the address index can be established accordingly. After the mapping relationship is established, when a new table item needs to be generated and inserted, the address index is determined according to the table item index of the table item, and the table item is written to the storage location represented by the address index. When searching for a table item later, the address index is determined by the table item index, and the table item content is read from the storage location represented by the address index.

[0104] In one embodiment of the present application, if the index type is determined to be the second direct index type, a first page table is created for each sub-table segment contained in the first type table; the sub-table segment includes an initial table segment and an extended table segment; the first page table is used to map the table entry index of the sub-table segment of the first type table to the address index of the sub-table segment in the first storage resource pool; wherein, the index values ​​of the table entry indexes of adjacent sub-table segments are continuous.

[0105] For ease of understanding, the concept of a sub-table segment is introduced in the embodiment of the present application. The initial storage space allocated for the first type table corresponds to a sub-table segment, and each extended storage space allocated for the first type table corresponds to a sub-table segment.

[0106] For the second direct index type, the index value range of the table entry is smaller and must be continuous, that is, the index values ​​of the table entry indexes of adjacent sub-table segments are continuous, but because the newly allocated extended storage space is not adjacent to the initially allocated initial storage space, it is necessary to map the continuous table entry indexes and map them into discontinuous address indexes.

[0107] In the embodiment of the present application, the mapping may be performed in the form of page tables, which may be implemented by hardware. As an example, the entry index of the sub-table segment is mapped to the address index of the sub-table segment in the first storage resource pool through the hardware page table.

[0108] As an example, see Figure 5 , is another schematic diagram of the mapping relationship between the table entry index and the address index provided in the embodiment of the present application, such as Figure 5 As shown, table B is the second direct index type. The initial storage space allocated to table B occupies the address interval [0,1023] of the first storage resource pool, and the address interval [1023,4096] belongs to the already allocated storage space of other tables. The extended storage space allocated to table B occupies the address interval [4096,5119] of the first storage resource pool. However, since the table entry indexes of the table entries in table B are required to be continuous, two page tables are created. The table entry index [0,1023] is mapped to the address index [0,1023] through page table 1, and the table entry index [1024,2047] is mapped to the address index [4096,5119] through page table 2. It can be seen that the table entry indexes of table B include [0,2047] and are continuous.

[0109] It can be seen that in the embodiment of the present application, if the index type is determined to be the second direct index type, the page table is implemented through the chip hardware, and for each sub-table segment, the table item index of the table item in the sub-table segment is mapped to the address index, so that the table item indexes of adjacent sub-table segments are continuous, and the mapping relationship between the table item index and the address index is accurately established. After the mapping relationship is established, when a new table item needs to be generated and inserted, the address index is determined according to the table item index of the table item, and the table item is written to the storage location represented by the address index. When searching for a table item later, the address index is determined by the table item index, and the table item content is read from the storage location represented by the address index.

[0110] In one embodiment of the present application, if the index type is determined to be a hash index type, then for each sub-table segment contained in the first type table, a second mapping relationship between the hash index of the table item in the sub-table segment and the address index is determined, and the sub-table segment includes an initial table segment and an extended table segment; the second mapping relationship includes: a mapping relationship between a first bit segment of the hash index and a starting address of the sub-table segment in the first storage resource pool, and a mapping relationship between a second bit segment of the hash index and an address offset; wherein the hash index is calculated based on the table item index and a pre-set hash algorithm.

[0111] Specifically, for the hash index type, a mapping relationship between the hash index and the address index needs to be established, wherein the hash index refers to a calculation result obtained by performing a hash algorithm based on the table entry index.

[0112] As an example, when forwarding data, the switch queries the MAC address table according to the destination MAC address and VLAN (Virtual Local Area Network) number in the Ethernet frame. The destination MAC address and VLAN number are the table entry index. Since their bytes are long, they need to be converted into a hash index through a hash algorithm. The storage location of the table entry is found through the hash index, and the specific content of the table entry is read from it. The specific content can be the output interface of the device, so that the switch can quickly determine the output interface of the data.

[0113] In the embodiment of the present application, the concept of sub-table segment is introduced, the initial storage space allocated for the first type table corresponds to a sub-table segment, and each extended storage space allocated for the first type table corresponds to a sub-table segment. Based on the bits at specific positions in the hash index, a mapping relationship between the hash index and the address index is established.

[0114] Specifically, a mapping relationship between the first bit segment of the hash index and the starting position of the sub-table segment in the first storage resource pool is established, and a mapping relationship between the second bit segment of the hash index and the address offset is established. Thus, the starting storage position of the corresponding sub-table segment in the first storage resource pool is determined through the first bit segment, and the address offset of the table item based on the starting storage position is determined through the second bit segment, and then the address index of the table item is determined by combining the first bit segment and the second bit segment in the hash index, that is, a mapping relationship between the hash index and the address index is established.

[0115] As an example, see Figure 6 , which is another schematic diagram of the mapping relationship between the table entry index and the address index provided in the embodiment of the present application, such as Figure 6As shown, bit0-bit11 in the hash index is used as the second bit segment, bit12-bit13 in the hash index is used as the first bit segment, and its values ​​include "00", "01", "10" and "11". The first bit segment is used to select page table 0-page table 3, where each page corresponds to a sub-table segment, and the size of each page table is 4096, that is, each page table corresponds to 4K (ie 4096) table entries, and each page table corresponds to the starting storage position of the sub-table segment in the first storage resource pool. Figure 6 As shown, page table 0 corresponds to the initial storage space of table C, and the corresponding starting address is 0x1000, which is used to map the hash index to the address index [0x1000, 0x1FFF]; page table 1 corresponds to the extended storage space 1 of table C, and the corresponding starting address is 0x3000, which is used to map the hash index to the address index [0x3000, 0x3FFF]; page table 2 corresponds to the extended storage space 2 of table C, and the corresponding starting address is 0x4000, which is used to map the hash index to the address index [0x4000, 0x4FFF]; page table 3 corresponds to the extended storage space 3 of table C, and the corresponding starting address is 0x6000, which is used to map the hash index to the address index [0x6000, 0x6FFF]. Figure 6 As shown in the figure, [0x2000, 0x2FFF] and [0x5000, 0x5FFF] belong to the storage space allocated to other tables. "0x" represents the prefix of the hexadecimal number.

[0116] As an example, the first bit segment of a hash index is 10, corresponding to page table 2, and the starting address corresponding to page table 2 is 0x4000. The second bit segment of the hash index is 0000 0000 0010. The address offset can be determined by the second bit segment. By adding the address offset to 0x4000, the address index corresponding to the hash index can be obtained.

[0117] It can be seen that in the embodiment of the present application, when the first type table is of hash index type, a mapping relationship between the first bit segment in the hash index and the starting storage position of the sub-table segment is established, and a mapping relationship between the second bit segment in the hash index and the address offset is established to obtain a mapping relationship between the hash index and the address index. Thus, after allocating extended storage space for the first type table, the table entry to be inserted can be inserted into the corresponding position in the extended storage space based on the mapping relationship.

[0118] In one embodiment of the present application, for a hash index type table, when the storage space of the table is expanded or contracted, the movement of table entries is also involved.

[0119] Specifically, in the embodiment of the present application, the number of first bit segments matches the number of extended storage spaces. When the number of extended storage spaces increases, the number of first bit segments increases accordingly. Then, the table entries originally belonging to the first sub-table segment may be changed to another sub-table segment, so the table entries need to be moved.

[0120] Combination Figure 6 Take an example to illustrate. After allocating 3 extended storage spaces for table C, it is necessary to traverse the stored table entries in table C, move the ones with bit [12, 13] of 01 to the extended storage space corresponding to page table 1, move the ones with bit [12, 13] of 10 to the extended storage space corresponding to page table 2, and move the ones with bit [12, 13] of 11 to the extended storage space corresponding to page table 3.

[0121] For example, if the address of a table entry before the table expansion is 0x2ab8, then after expanding from 1 sub-table segment to 4 sub-table segments, it needs to be moved from the 0xab8 position of page table 0 to the 0xab8 position of page table 2.

[0122] It can be seen that in an embodiment of the present application, for the first type table of the hash index, after allocating the extended storage space and establishing the mapping relationship between the hash index and the address index, the stored table entries in the first type table are traversed, and according to the mapping relationship between the hash index and the address index, the positions of the stored table entries are changed to make them conform to the established mapping relationship.

[0123] In one embodiment of the present application, the method further includes: when all entries in the first extended storage space are deleted, reclaiming the first extended storage space as free storage space.

[0124] Specifically, the extended storage space allocated for the first type of table is for writing more table entries, and some table entries will be dynamically deleted during the operation of the network device. If all the table entries in the extended storage space are deleted, then continuing to retain the extended storage space will cause a waste of storage resources. Therefore, the extended storage space is recycled as free storage space, and the free storage space can be used as free resources to respond to new allocation requests, which can further improve the utilization rate of storage resources used to store table entries in the chip.

[0125] See also Figure 7 , is a structural diagram of a table entry space allocation device provided in an embodiment of the present application, the device includes the following modules:

[0126] A first allocation module 701 is used to allocate initial storage space for different types of tables from a first storage resource pool during the chip initialization phase;

[0127] A second allocation module 702, configured to allocate a first extended storage space to the first type table from the free storage space included in the first storage resource pool after the storage space occupied by the first type table exceeds a preset threshold of the initial storage space;

[0128] The determination module 703 is used to determine a mapping relationship between an entry index and an address index of an entry in the first type table, wherein the address index represents a storage location of the entry in the first storage resource pool.

[0129] Using the table entry space allocation device provided in the embodiment of the present application, in the chip initialization stage, initial storage space is allocated to different types of tables from the first storage resource pool; after the storage space occupied by the first type of table exceeds the preset threshold of the initial storage space, a first extended storage space is allocated to the first type of table from the free storage space contained in the first storage resource pool; and the mapping relationship between the table entry index and the address index of the table entry in the first type of table is determined, wherein the address index represents the storage position of the table entry in the first storage resource pool.

[0130] Therefore, the embodiment of the present application takes into account the characteristics that different types of tables in different business scenarios will not reach the maximum capacity specifications at the same time, and provides a flexible and dynamically allocated table space resource management solution, which can adaptively adjust the storage space size of a specific table according to the actual business scenario, and the table space allocation process is automatically executed by the device, without the need for human intervention to configure the mode or restart the chip. Therefore, the dynamic allocation of storage space is achieved through hardware, and the utilization rate of storage resources used to store table items in the chip is improved in a user-imperceptible manner.

[0131] In one embodiment of the present application, the determining module is specifically used to:

[0132] Determine an index type of the first type table, where the index type includes a first direct index type, a second direct index type, and a hash index type;

[0133] Based on the index type, a mapping relationship between an entry index of an entry in the first type table and the address index is determined.

[0134] It can be seen that in the embodiment of the present application, when establishing the mapping relationship between the table entry index and the address index, the index type of the specific table is fully considered, and different methods are used to create the mapping relationship according to the different index types, so as to take into account various forms of forwarding tables.

[0135] It can be seen that in the embodiment of the present application, if the index type is determined to be the first direct index type, the table item index and the address index are actually the same, and a mapping relationship between the table item index and the address index can be established accordingly. After the mapping relationship is established, when a new table item needs to be generated and inserted, the address index is determined according to the table item index of the table item, and the table item is written to the storage location represented by the address index. When searching for a table item later, the address index is determined by the table item index, and the table item content is read from the storage location represented by the address index.

[0136] In one embodiment of the present application, the determining module is specifically used to:

[0137] If it is determined that the index type is the first direct index type, it is determined that the entry index of the entry in the first type table and the address index satisfy a first mapping relationship, and the first mapping relationship is: the index value of the entry index of the entry in the first type table represents the address index.

[0138] In one embodiment of the present application, the determining module is specifically used to:

[0139] If it is determined that the index type is the second direct index type, a first page table is created for each sub-table segment contained in the first type table; the sub-table segment includes an initial table segment and an extended table segment; the first page table is used to map the table entry index of the sub-table segment of the first type table to the address index of the sub-table segment in the first storage resource pool; wherein, the index values ​​of the table entry indexes of adjacent sub-table segments are continuous.

[0140] It can be seen that in the embodiment of the present application, if the index type is determined to be the second direct index type, the page table is implemented through the chip hardware, and for each sub-table segment, the table item index of the table item in the sub-table segment is mapped to the address index, so that the table item indexes of adjacent sub-table segments are continuous, and the mapping relationship between the table item index and the address index is accurately established. After the mapping relationship is established, when a new table item needs to be generated and inserted, the address index is determined according to the table item index of the table item, and the table item is written to the storage location represented by the address index. When searching for a table item later, the address index is determined by the table item index, and the table item content is read from the storage location represented by the address index.

[0141] In one embodiment of the present application, the determining module is specifically used to:

[0142] If it is determined that the index type is a hash index type, for each sub-table segment included in the first type table, determine a second mapping relationship between a hash index of a table entry in the sub-table segment and the address index, the sub-table segment including an initial table segment and an extended table segment;

[0143] The second mapping relationship includes:

[0144] The mapping relationship between the first bit segment of the hash index and the starting address of the sub-table segment in the first storage resource pool, and the mapping relationship between the second bit segment of the hash index and the address offset; wherein, the hash index is calculated based on the table entry index and a pre-set hash algorithm.

[0145] It can be seen that in the embodiment of the present application, when the first type table is of hash index type, a mapping relationship between the first bit segment in the hash index and the starting storage position of the sub-table segment is established, and a mapping relationship between the second bit segment in the hash index and the address offset is established to obtain a mapping relationship between the hash index and the address index. Thus, after allocating extended storage space for the first type table, the table entry to be inserted can be inserted into the corresponding position in the extended storage space based on the mapping relationship.

[0146] In one embodiment of the present application, the device may further include:

[0147] The position changing module is used to traverse the stored table entries in the first type table and change the storage position of the stored table entries according to the second mapping relationship.

[0148] It can be seen that in an embodiment of the present application, for the first type table of the hash index, after allocating the extended storage space and establishing the mapping relationship between the hash index and the address index, the stored table entries in the first type table are traversed, and according to the mapping relationship between the hash index and the address index, the positions of the stored table entries are changed to make them conform to the established mapping relationship.

[0149] In one embodiment of the present application, the device may further include:

[0150] The recycling module is used to recycle the first extended storage space as free storage space when all entries in the first extended storage space are deleted.

[0151] The embodiment of the present invention further provides an electronic device, such as Figure 8 As shown, it includes a processor 801 , a communication interface 802 , a memory 803 and a communication bus 804 , wherein the processor 801 , the communication interface 802 , and the memory 803 communicate with each other via the communication bus 804 .

[0152] Memory 803, used for storing computer programs;

[0153] The processor 801 is used to execute the program stored in the memory 803, and implements the following steps:

[0154] In the chip initialization phase, initial storage space is allocated for different types of tables from the first storage resource pool;

[0155] After the storage space occupied by the first type table exceeds a preset threshold of the initial storage space, allocating a first extended storage space for the first type table from the free storage space included in the first storage resource pool;

[0156] A mapping relationship between an entry index and an address index of an entry in the first type table is determined, wherein the address index represents a storage location of the entry in the first storage resource pool.

[0157] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0158] The communication interface is used for communication between the above electronic device and other devices.

[0159] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0160] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0161] In another embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned table entry space allocation methods are implemented.

[0162] In another embodiment of the present invention, a computer program product including instructions is provided. When the computer program product is run on a computer, the computer executes any one of the table entry space allocation methods in the above embodiments.

[0163] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive Solid State Disk (SSD)), etc.

[0164] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0165] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, electronic device and storage medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.

[0166] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims

1. A table entry space allocation method, It is characterized in that The method comprises: In the chip initialization phase, initial storage space is allocated for different types of tables from the first storage resource pool; After the storage space occupied by the first type table exceeds a preset threshold of the initial storage space, allocating a first extended storage space for the first type table from the free storage space included in the first storage resource pool; Determine a mapping relationship between an entry index and an address index of an entry in the first type table, wherein the address index represents a storage location of the entry in the first storage resource pool; The step of determining a mapping relationship between an entry index and an address index of an entry in the first type table includes: Determine an index type of the first type table, where the index type includes a first direct index type, a second direct index type, and a hash index type; Based on the index type, determining a mapping relationship between an entry index of an entry in the first type table and the address index; The step of determining, based on the index type, a mapping relationship between an entry index of an entry in the first type table and the address index comprises: If it is determined that the index type is a hash index type, for each sub-table segment included in the first type table, determine a second mapping relationship between a hash index of a table entry in the sub-table segment and the address index, the sub-table segment including an initial table segment and an extended table segment; The second mapping relationship includes: The mapping relationship between the first bit segment of the hash index and the starting address of the sub-table segment in the first storage resource pool, and the mapping relationship between the second bit segment of the hash index and the address offset; wherein, the hash index is calculated based on the table entry index and a pre-set hash algorithm.

2. The method according to claim 1, It is characterized in that The step of determining, based on the index type, a mapping relationship between an entry index of an entry in the first type table and the address index comprises: If it is determined that the index type is the first direct index type, it is determined that the entry index of the entry in the first type table and the address index satisfy a first mapping relationship, and the first mapping relationship is: the index value of the entry index of the entry in the first type table represents the address index.

3. The method according to claim 1, It is characterized in that The step of determining, based on the index type, a mapping relationship between an entry index of an entry in the first type table and the address index comprises: If it is determined that the index type is the second direct index type, a first page table is created for each sub-table segment contained in the first type table; the sub-table segment includes an initial table segment and an extended table segment; the first page table is used to map the table entry index of the sub-table segment of the first type table to the address index of the sub-table segment in the first storage resource pool; wherein, the index values ​​of the table entry indexes of adjacent sub-table segments are continuous.

4. The method according to claim 1, It is characterized in that The method further comprises: The stored table entries in the first type table are traversed, and the storage locations of the stored table entries are changed according to the second mapping relationship.

5. The method according to claim 1, It is characterized in that Also includes: When all entries in the first extended storage space are deleted, the first extended storage space is recycled as free storage space.

6. A table entry space allocation device, It is characterized in that The device comprises: A first allocation module, used to allocate initial storage space for different types of tables from a first storage resource pool during a chip initialization phase; A second allocation module, configured to allocate a first extended storage space to the first type table from the free storage space included in the first storage resource pool after the storage space occupied by the first type table exceeds a preset threshold of the initial storage space; a determination module, configured to determine a mapping relationship between an entry index and an address index of an entry in the first type table, wherein the address index represents a storage location of the entry in the first storage resource pool; The determining module is specifically used for: Determine an index type of the first type table, where the index type includes a first direct index type, a second direct index type, and a hash index type; Based on the index type, determining a mapping relationship between an entry index of an entry in the first type table and the address index; The determining module is specifically used for: If it is determined that the index type is a hash index type, for each sub-table segment included in the first type table, determine a second mapping relationship between a hash index of a table entry in the sub-table segment and the address index, the sub-table segment including an initial table segment and an extended table segment; The second mapping relationship includes: The mapping relationship between the first bit segment of the hash index and the starting address of the sub-table segment in the first storage resource pool, and the mapping relationship between the second bit segment of the hash index and the address offset; wherein, the hash index is calculated based on the table entry index and a pre-set hash algorithm.

7. An electronic device, It is characterized in that It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 5 when executing a program stored in a memory.

8. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 to 5 are implemented.