CN-115982162-B - Message forwarding table query method and electronic equipment
Abstract
The application provides a message forwarding table query method and electronic equipment, wherein an ASIC chip calculates a corresponding hash value for a message to be forwarded, and models the stored value of a forwarding table to obtain an index value corresponding to the message to be forwarded, and then the ASIC chip sequentially stores all the messages to be forwarded in a message cache queue based on the size of the index value, and as a CPU determines the corresponding forwarding behavior in the forwarding table according to the index value, and stores the forwarding behavior corresponding to at least one index value after the index value in a cache. Because the data read next time is likely to be the data connected with the forwarding behavior, the probability of the data read next time to hit the cache is greatly improved, the situation that the CPU repeatedly reads the memory forwarding table due to random arrangement of the data in the message cache queue is avoided, and the forwarding efficiency is improved.
Inventors
- MA JIABIAO
- Yang Bashuang
- DAI WEIDA
- WAN HUAN
Assignees
- 苏州盛科通信股份有限公司
Dates
- Publication Date
- 20260508
- Application Date
- 20221227
Claims (8)
- 1. The message forwarding table query method is characterized in that the method is applied to electronic equipment, the electronic equipment comprises a CPU and an ASIC chip, and the method comprises the following steps: the ASIC chip receives a message to be forwarded; The ASIC chip calculates a corresponding hash value for the message to be forwarded, and models the hash value to a stored value of a forwarding table to obtain an index value corresponding to the message to be forwarded; The ASIC chip stores all the messages to be forwarded in a message buffer queue in sequence according to the index value corresponding to each message to be forwarded; The CPU reads the message to be forwarded and the index value from the message cache queue; the CPU confirms whether the cache caches forwarding behaviors corresponding to the index values according to the index values; if yes, the CPU reads the forwarding behavior, and stores the forwarding behavior corresponding to at least one index value after the index value into the cache; If not, executing the CPU to determine the corresponding forwarding behavior in the forwarding table according to the index value, and storing the forwarding behavior corresponding to at least one index value after the index value into the cache.
- 2. The method of claim 1, wherein the step of storing all the messages to be forwarded in the message buffer queue in sequence by the ASIC chip according to the index value size corresponding to each message to be forwarded comprises: And the ASIC chip stores each message to be forwarded and the corresponding index value into a storage position corresponding to a writing index one by one according to the size of the index value corresponding to each message to be forwarded, wherein the writing index points to a blank storage position in the message cache queue, and the writing index is configured to point to the next blank storage position when writing is completed once.
- 3. The method of claim 1, wherein the step of the CPU reading the message to be forwarded and the index value from the message buffer queue comprises: The CPU reads the message to be forwarded and the index value at the storage position pointed by the reading index, wherein the reading index points to the storage position of the stored content in the message cache queue, and the writing index is configured to point to the storage position of the next stored content when the reading is completed once; and when the CPU finishes reading, the ASIC chip clears the data of the corresponding storage position.
- 4.A method as claimed in any one of claims 1 to 3, further comprising: the CPU edits the corresponding message to be forwarded according to the forwarding behavior; The CPU sends the edited message to be forwarded and the target physical port to the ASIC chip; and the ASIC chip sends the edited message to be forwarded to the target physical port.
- 5. An electronic device is characterized by comprising a CPU and an ASIC chip; The ASIC chip is used for receiving a message to be forwarded, calculating a corresponding hash value aiming at the message to be forwarded, and taking a module of the hash value to a storage value of a forwarding table to obtain an index value corresponding to the message to be forwarded; The CPU is used for reading the message to be forwarded and the index value from the message cache queue, confirming whether a cache caches forwarding behaviors corresponding to the index value according to the index value, reading the forwarding behaviors if yes, storing the forwarding behaviors corresponding to at least one index value after the index value into the cache, and if not, confirming the forwarding behaviors corresponding to the forwarding table according to the index value and storing the forwarding behaviors corresponding to at least one index value after the index value into the cache.
- 6. The electronic device of claim 5, The ASIC chip is specifically configured to store each message to be forwarded and the corresponding index value to a storage position corresponding to a writing index one by one according to the size of the index value corresponding to each message to be forwarded, wherein the writing index points to a blank storage position in the message cache queue, and the writing index is configured to point to the next blank storage position when writing is completed once.
- 7. The electronic device of claim 5, The CPU is specifically used for reading the message to be forwarded and the index value on a storage position pointed by a reading index, wherein the reading index points to a storage position of stored contents in the message cache queue, and each time reading is completed, a writing index is configured to point to a storage position of the next stored contents; and the ASIC chip is also used for clearing the data of the corresponding storage position when the CPU finishes reading.
- 8. The electronic device of any one of claim 5 to 7, The CPU is also used for editing the corresponding message to be forwarded according to the forwarding behavior, and sending the edited message to be forwarded and a target physical port to the ASIC chip; the ASIC chip is further configured to send the edited message to be forwarded to the target physical port.
Description
Message forwarding table query method and electronic equipment Technical Field The present application relates to the field of communications technologies, and in particular, to a method for querying a message forwarding table and an electronic device. Background In the prior art, in order to forward a message, a CPU needs to maintain a software forwarding table, the table is stored in a memory, and the CPU performs an index of the forwarding table each time, which is actually a process that the CPU reads the memory. And memory access efficiency tends to be low. To solve this problem, a cache (cache) is generally used to cache the common data content to improve the read-write performance. However, for the packet forwarding scenario, due to randomness of the data in the cache (cache), the CPU still needs to query the forwarding table contents in the memory to implement the packet sending, so that the efficiency of sending the entire packet is reduced. Disclosure of Invention The application aims to provide a message forwarding table query method and electronic equipment, which are used for improving the query efficiency of a forwarding table and further improving the forwarding efficiency of a message. In order to achieve the above object, the technical scheme adopted by the embodiment of the application is as follows: in a first aspect, an embodiment of the present application provides a method for querying a packet forwarding table, where the method is applied to an electronic device, where the electronic device includes a CPU and an ASIC chip, and the method includes: the ASIC chip receives a message to be forwarded; The ASIC chip calculates a corresponding hash value for the message to be forwarded, and models the hash value to a stored value of a forwarding table to obtain an index value corresponding to the message to be forwarded; The ASIC chip stores all the messages to be forwarded in a message buffer queue in sequence according to the index value corresponding to each message to be forwarded; The CPU reads the message to be forwarded and the index value from the message cache queue; and the CPU determines the corresponding forwarding behavior in the forwarding table according to the index value, and stores the forwarding behavior corresponding to at least one index value after the index value into a cache. With reference to the first aspect, in a first possible implementation manner, after the step of reading, by the CPU, the to-be-forwarded packet and the index value from the packet buffer queue, the method further includes: The CPU confirms whether the cache caches forwarding behaviors corresponding to the index values according to the index values; If yes, the CPU reads the forwarding behavior, and stores the forwarding behavior corresponding to at least one index value after the index value into a cache; if not, executing the step of determining the corresponding forwarding behavior in the forwarding table by the CPU according to the index value. With reference to the first aspect, in a second possible implementation manner, the step of storing, by the ASIC chip, all the messages to be forwarded in a message buffer queue according to an index value corresponding to each of the messages to be forwarded in sequence includes: And the ASIC chip stores each message to be forwarded and the corresponding index value into a storage position corresponding to a writing index one by one according to the size of the index value corresponding to each message to be forwarded, wherein the writing index points to a blank storage position in the message cache queue, and the writing index is configured to point to the next blank storage position when writing is completed once. With reference to the first aspect, in a third possible implementation manner, the step of reading, by the CPU, the to-be-forwarded packet and the index value from the packet buffer queue includes: The CPU reads the message to be forwarded and the index value at a storage position pointed by a read index, wherein the read index points to a storage position of stored contents in the message cache queue, and the write index is configured to point to a storage position of the next stored contents when reading is completed once; and when the CPU finishes reading, the ASIC chip clears the data of the corresponding storage position. With reference to the first aspect or any one of the foregoing possible implementation manners of the first aspect, in a fourth possible implementation manner, the method further includes: the CPU edits the corresponding message to be forwarded according to the forwarding behavior; The CPU sends the edited message to be forwarded and the target physical port to the ASIC chip; and the ASIC chip sends the edited message to be forwarded to the target physical port. In a second aspect, an embodiment of the present application provides an electronic device, including a CPU and an ASIC chip; The ASIC chip is used for recei