A method and apparatus for implementing a two-layer forwarding pipeline

By implementing pipelined methods and hashing modules for reuse, and merging the learning table and lookup table into a single MAC entry, the problems of high latency and high storage resource consumption in existing Layer 2 forwarding technologies are solved, achieving high-speed data forwarding and efficient storage.

CN116800701BActive Publication Date: 2026-06-26XIDIAN UNIV

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
XIDIAN UNIV
Filing Date
2023-06-16
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

In existing Layer 2 forwarding technologies, the state machine design results in significant latency, making it difficult to apply to high-speed designs. Furthermore, improper design of the table entry synchronization structure leads to excessive consumption of storage resources and synchronization logic.

Method used

A pipelined approach is adopted, which hashes the destination MAC address and the source MAC address to generate hash addresses and hash address identifiers, respectively. The hashes are processed in clock order, and table lookup and learning operations are performed separately. The hash module reuses the hashes and merges the learning table and the lookup table into a single MAC entry, which is stored in dual-port RAM.

Benefits of technology

It reduces the absolute latency of the Layer 2 forwarding module, increases throughput, saves storage resources, meets the needs of high-speed data transmission, and achieves efficient data forwarding and learning.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116800701B_ABST
    Figure CN116800701B_ABST
Patent Text Reader

Abstract

The application relates to a pipeline implementation method and device for two-layer forwarding, which comprises the following steps: obtaining a source MAC address and a destination MAC address in a data packet according to the received data packet, and generating a destination MAC address identifier and a source MAC address identifier; performing hash mapping on the destination MAC address and the destination MAC address identifier to generate a first hash address and a destination hash address identifier, and performing hash mapping on the source MAC address and the source MAC address identifier to generate a second hash address and a source hash address identifier after delaying for one clock; sequentially processing the first hash address and the second hash address in a clock sequence, wherein, in response to identifying the destination hash address identifier, a MAC table item is looked up according to the first hash address, and packet forwarding is performed according to a lookup result; and in response to identifying the source hash address identifier, a MAC table item is looked up according to the second hash address, and MAC table item learning is performed according to a lookup result. The method reduces the absolute delay of a two-layer forwarding module and saves storage resources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of Ethernet communication technology, specifically relating to a pipelined implementation method and apparatus for Layer 2 forwarding. Background Technology

[0002] With the development of communication technology and the rapid increase in business volume, the throughput requirements for switches are also gradually increasing. Forwarding services is an essential function of switches.

[0003] Currently, the functional requirements for Layer 2 forwarding are quite specific, such as table self-learning, lookup, and aging-up functions. However, publicly available related content is relatively limited. For example, the Ethernet Layer 2 forwarding table learning method and system disclosed in November 2021 mainly introduced the implementation of the learning function in Layer 2 forwarding; the method for accurate aging-up of Ethernet forwarding tables disclosed in September 2021 mainly introduced the implementation of the aging-up function in Layer 2 forwarding; and the Layer 2 forwarding implementation method disclosed in May 2021 mainly introduced some logic in forwarding. Current Layer 2 forwarding technologies lack content related to the overall architecture of Layer 2 forwarding.

[0004] A common approach for Layer 2 forwarding is to perform learning and forwarding simultaneously, implemented using a state machine. Storage is divided into a learning table and a forwarding table. The learning table is used for lookups during learning operations, while the forwarding table is used for lookups during forwarding. The forwarding table needs to be synchronized with the learning table and the learning tables of other modules (including aging synchronization). This approach has two problems: 1. Using a state machine results in significant relative and absolute latency, making it difficult to apply in high-speed designs; 2. The structure needs optimization when using table entries for synchronization. An inappropriate forwarding table structure design can lead to significant storage resource consumption and synchronization logic overhead. Summary of the Invention

[0005] To address the aforementioned problems in the prior art, this invention provides a method and apparatus for implementing a two-layer forwarding pipeline. The technical problem to be solved by this invention is achieved through the following technical solution:

[0006] This invention provides a pipelined implementation method for Layer 2 forwarding, comprising:

[0007] Based on the received data packet, obtain the source MAC address and destination MAC address in the data packet, and generate the destination MAC address identifier and source MAC address identifier;

[0008] The destination MAC address and the destination MAC address identifier are hashed to generate a first hash address and a destination hash address identifier. After a clock delay, the source MAC address and the source MAC address identifier are hashed to generate a second hash address and a source hash address identifier.

[0009] The first hash address and the second hash address are processed sequentially according to clock order, wherein...

[0010] In response to identifying the destination hash address identifier, the MAC table entry is looked up based on the first hash address, and the packet is forwarded based on the lookup result;

[0011] In response to identifying the source hash address identifier, the MAC table entry is looked up based on the second hash address, and the MAC table entry is learned based on the lookup result.

[0012] In one embodiment of the present invention, a table lookup is performed on the MAC entry based on the first hash address, and packet forwarding is performed based on the lookup result, including:

[0013] Pull the lookup enable flag high, and look up the MAC table entry based on the first hash address to obtain the lookup result;

[0014] If a MAC entry exists in the MAC table that matches the first hash address, and the MAC address of the MAC entry matches the destination MAC address corresponding to the first hash address, then the packet is output from the port corresponding to the MAC address of the MAC entry; otherwise, the packet is broadcast.

[0015] In one embodiment of the present invention, a table lookup is performed on the MAC entry based on the second hash address, and the MAC entry is learned based on the lookup result, including:

[0016] Raise the learning enable flag and look up the MAC entry based on the second hash address to obtain the lookup result;

[0017] If there is no MAC entry in the MAC table that matches the second hash address, then the source MAC address corresponding to the second hash address is learned and the MAC entry is updated.

[0018] If there is a MAC entry in the MAC table that matches the second hash address, then it is determined whether the address information of the MAC address in the MAC entry data is consistent with the address information of the source MAC address corresponding to the second hash address, and MAC entry learning is performed based on the determination result.

[0019] In one embodiment of the present invention, determining whether the address information of the MAC address of the MAC entry data is consistent with the address information of the source MAC address corresponding to the second hash address, and learning the MAC entry based on the determination result, includes:

[0020] Step a: Determine whether the MAC address of the MAC entry data is consistent with the source MAC address corresponding to the second hash address. If they are consistent, proceed to step b; otherwise, learn the source MAC address corresponding to the second hash address and update the MAC entry.

[0021] Step b: Determine whether the port of the MAC address of the MAC entry data is consistent with the port of the source MAC address corresponding to the second hash address. If they are consistent, proceed to step c; otherwise, learn the source MAC address corresponding to the second hash address and update the MAC entry.

[0022] Step c: Determine whether the update time of the MAC address of the MAC entry data is consistent with the time of the source MAC address corresponding to the second hash address. If they are consistent, do not learn the MAC entry; otherwise, learn the source MAC address corresponding to the second hash address and update the MAC entry.

[0023] In one embodiment of the present invention, the pipelined implementation method for Layer 2 forwarding further includes: aging up the MAC entries after the learning of the MAC entries is completed.

[0024] In one embodiment of the present invention, the table lookup operation of the MAC entry based on the hash address adopts different control logic from the learning and aging of the MAC entry.

[0025] In one embodiment of the present invention, if a read operation to look up a MAC entry based on a hash address conflicts with a write operation to learn and age the MAC entry, the read operation is performed first, and the write operation data is stored in a cache register, while the MAC entry update operation is paused for one clock cycle.

[0026] In one embodiment of the present invention, after the learning of MAC entries is completed, the MAC entries are aged out, including:

[0027] Step ①: Determine if the cache register is valid. If valid, update the MAC entry in the next clock cycle based on the write operation data in the cache register; otherwise, proceed to step ②.

[0028] Step ②: Determine whether the learning address of the stored MAC table entry is valid. If it is valid, update the MAC table entry according to the stored learning address in the next clock cycle; otherwise, proceed to step ③.

[0029] Step 3: Determine whether the aging data of the stored MAC table entry is valid. If valid, update the MAC table entry according to the stored aging data in the next clock cycle; otherwise, perform an aging lookup operation on the MAC table entry.

[0030] This invention provides a pipelined implementation apparatus for two-layer forwarding, comprising:

[0031] The forwarding control module obtains the source MAC address and destination MAC address from the data packet, generates a destination MAC address identifier and a source MAC address identifier, caches the source MAC address, sends the destination MAC address and the destination MAC address identifier to the hash mapping module at the current clock, and sends the source MAC address and the source MAC address identifier to the hash mapping module after a one-clock delay.

[0032] The hash mapping module performs hash mapping on the received destination MAC address and destination MAC address identifier to generate a first hash address and a destination hash address identifier, and performs hash mapping on the received source MAC address and source MAC address identifier to generate a second hash address and a source hash address identifier;

[0033] The destination MAC lookup module, in response to recognizing the destination hash address identifier, sends the first hash address as the lookup address for the lookup operation to the table entry control module, simultaneously raises the lookup enable flag, and forwards the packet according to the lookup result;

[0034] The source MAC learning module, in response to recognizing the source hash address identifier, sends the second hash address as the lookup address for the learning operation to the table entry control module, simultaneously raises the learning enable flag, and learns the MAC table entry based on the lookup result;

[0035] The table entry control module performs a table lookup on the MAC table entry based on the received table lookup address and lookup enable flag, and sends the lookup result to the destination MAC lookup module. It also performs a table lookup on the MAC table entry based on the received table lookup address and learning enable flag, and sends the lookup result to the source MAC learning module. Finally, it performs a table lookup on the MAC table entry based on the received table lookup address of the aging module, and sends the lookup result to the aging module.

[0036] The MAC entry module is used to store MAC entries. It uses a dual-port RAM. The first port implements the lookup and result transmission of the destination MAC lookup module and the lookup and result transmission of the source MAC learning module according to the entry control module. The second port implements the learning and aging of MAC entries according to the entry control module.

[0037] The aging module is used to age up MAC entries based on the lookup results.

[0038] In one embodiment of the present invention, the pipelined implementation apparatus for Layer 2 forwarding further includes a learning FIFO and a deletion FIFO, wherein the learning FIFO is used to store the learning address of the MAC table entry, and the deletion FIFO is used to store the aging data of the MAC table entry.

[0039] Compared with the prior art, the beneficial effects of the present invention are as follows:

[0040] 1. The pipelined implementation method for Layer 2 forwarding of the present invention, compared with the existing Layer 2 forwarding method using state machines, reduces the absolute latency of the Layer 2 forwarding module to 4 cycles from data input to obtaining the lookup result. At the maximum operating rate, one lookup operation is performed every two clock cycles, which can meet the forwarding requirements of the shortest frame (64B) with a 256b data bus. Using a 512MHz clock and the forwarding module as the module with the highest relative latency, the maximum throughput is 130G. Using a two-channel synchronization method, a throughput of 260G can be achieved at a 512MHz clock.

[0041] 2. The pipeline implementation device for two-layer forwarding of the present invention merges the learning table and the lookup table into a single MAC entry. Synchronization can also be implemented using a low-capacity FIFO, saving a large amount of redundant storage resources. Secondly, when using a single MAC entry to synchronize data in other channels, only the learning results need to be synchronized, and aging can be completed autonomously by the device, reducing the control logic during synchronization.

[0042] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described in detail below with reference to the accompanying drawings. Attached Figure Description

[0043] Figure 1 This is a schematic diagram of a pipelined implementation method for Layer 2 forwarding provided in an embodiment of the present invention;

[0044] Figure 2 This is a schematic diagram of a search and learning pipeline provided in an embodiment of the present invention;

[0045] Figure 3 This is a structural block diagram of a two-layer forwarding pipeline implementation device provided in an embodiment of the present invention;

[0046] Figure 4 This is a schematic diagram of a learning table processing logic provided in an embodiment of the present invention;

[0047] Figure 5 This is a schematic diagram of an aging state machine provided in an embodiment of the present invention;

[0048] Figure 6 This is a schematic diagram of the control logic of the second port of a MAC entry provided in an embodiment of the present invention;

[0049] Figure 7This is a simulation result diagram of learning and table lookup provided in an embodiment of the present invention;

[0050] Figure 8 This is a simulation result diagram of the second port control logic of a MAC entry provided in an embodiment of the present invention. Detailed Implementation

[0051] To further illustrate the technical means and effects adopted by the present invention to achieve the intended purpose, the following describes in detail a two-layer forwarding pipeline implementation method and apparatus proposed according to the present invention, in conjunction with the accompanying drawings and specific embodiments.

[0052] The foregoing and other technical contents, features, and effects of the present invention will be clearly presented in the following detailed description of specific embodiments in conjunction with the accompanying drawings. Through the description of the specific embodiments, a more in-depth and concrete understanding can be gained of the technical means and effects adopted by the present invention to achieve its intended purpose. However, the accompanying drawings are for reference and illustration only and are not intended to limit the technical solutions of the present invention.

[0053] Firstly, this embodiment provides a pipelined implementation method for Layer 2 forwarding; please refer to [link to relevant documentation]. Figure 1 , Figure 1 This is a schematic diagram of a pipelined implementation method for Layer 2 forwarding provided by an embodiment of the present invention. As shown in the figure, the pipelined implementation method for Layer 2 forwarding in this embodiment includes:

[0054] Based on the received data packets, obtain the source MAC address and destination MAC address from the data packets, and generate the destination MAC address identifier and source MAC address identifier;

[0055] The destination MAC address and the destination MAC address identifier are hashed to generate the first hash address and the destination hash address identifier. After a clock delay, the source MAC address and the source MAC address identifier are hashed to generate the second hash address and the source hash address identifier.

[0056] The first hash address and the second hash address are processed sequentially according to clock order, wherein...

[0057] In response to identifying the destination hash address, the MAC table entry is looked up based on the first hash address, and the packet is forwarded based on the lookup result;

[0058] In response to identifying the source hash address, the MAC entry is looked up based on the second hash address, and the MAC entry is learned based on the lookup result.

[0059] In this embodiment of the Layer 2 forwarding pipelined implementation method, to improve the absolute latency of destination MAC address lookup, the source MAC address learning and destination MAC address lookup operations are pipelined. The key functions of the source MAC address learning and destination MAC address lookup operations can be abstracted into the following steps: hashing -> table lookup -> caching -> processing -> output. Then, following the idea of ​​lookup before learning, the implementation result of the Layer 2 forwarding pipelined implementation method in this embodiment is as follows: Figure 2 As shown in the image. The first row represents the search operation, and the second row represents the learning operation.

[0060] Furthermore, the operations of destination MAC address lookup and source MAC address learning are explained in detail.

[0061] Optionally, a lookup is performed on the MAC address based on the first hash address, and the packet is forwarded based on the lookup result, including:

[0062] Raise the lookup enable flag and look up the MAC entry based on the first hash address to obtain the lookup result;

[0063] If a MAC entry exists in the MAC table that matches the first hash address, and the MAC address of the MAC entry matches the destination MAC address corresponding to the first hash address, then the packet will be output from the port corresponding to the MAC address of the MAC entry; otherwise, the packet will be broadcast.

[0064] Optionally, the MAC entry is looked up based on the second hash address, and the MAC entry is learned based on the lookup result, including:

[0065] Raise the learning enable flag and look up the MAC entry based on the second hash address to get the lookup result;

[0066] If there is no MAC entry in the MAC table that matches the second hash address, then the source MAC address corresponding to the second hash address is learned and the MAC entry is updated.

[0067] If a MAC entry exists that matches the second hash address, then it is determined whether the address information of the MAC address in the MAC entry is consistent with the address information of the source MAC address corresponding to the second hash address. Based on the determination result, the MAC entry is learned.

[0068] like Figure 4 The schematic diagram of the learning table processing logic shown in this embodiment determines whether the address information of the MAC address of the MAC table entry data is consistent with the address information of the source MAC address corresponding to the second hash address, and performs MAC table entry learning based on the determination result, including:

[0069] Step a: Determine whether the MAC address of the MAC table entry is consistent with the source MAC address corresponding to the second hash address. If they are consistent, proceed to step b. Otherwise, learn the source MAC address corresponding to the second hash address and update the MAC table entry.

[0070] Step b: Determine whether the port of the MAC address in the MAC table entry is consistent with the port of the source MAC address corresponding to the second hash address. If they are consistent, proceed to step c; otherwise, learn the source MAC address corresponding to the second hash address and update the MAC table entry.

[0071] Step c: Determine whether the update time of the MAC address in the MAC table entry is consistent with the time of the source MAC address corresponding to the second hash address. If they are consistent, do not learn the MAC table entry; otherwise, learn the source MAC address corresponding to the second hash address and update the MAC table entry.

[0072] It should be noted that, in order to improve the design frequency, in this embodiment, after the lookup result read from the lookup table is slapped, the packet forwarding or MAC entry learning is performed based on the lookup result, and the MAC entry learning is performed in the next clock cycle after the packet forwarding.

[0073] Furthermore, the pipelined implementation method for Layer 2 forwarding in this embodiment also includes: after the MAC entries are learned, aging processing is performed on the MAC entries.

[0074] In this embodiment, the lookup operation of MAC entries based on hash addresses and the learning and aging of MAC entries employ different control logic. Optionally, different control logic can be applied to the stored MAC entries by setting up two ports.

[0075] If a read operation to look up a MAC entry based on its hash address conflicts with a write operation to learn or age out a MAC entry, the read operation takes precedence, and the write operation data is stored in the cache register. The MAC entry update operation is then paused for one clock cycle.

[0076] It should be noted that when performing a lookup operation on a MAC entry based on a hash address, the lookup enable flag and learning enable flag are set to ensure that lookups for the first hash address and the second hash address do not occur simultaneously.

[0077] In this embodiment, the learning of MAC entries includes not only the learning address update of this channel but also the learning address update of other channels. Accordingly, the learning and aging of MAC entries includes three update operations: learning address update of this channel, learning address update of other channels, and aging update.

[0078] In this embodiment, priorities are set for the three update operations: learning address updates are performed first, followed by aging-in updates. Accordingly, after the MAC table entries are learned, they are aged out, specifically including the following steps:

[0079] Step ①: Determine if the cache register is valid. If valid, update the MAC table entry in the next clock cycle based on the write operation data in the cache register; otherwise, proceed to step ②.

[0080] Step 2: Determine whether the learning address of the stored MAC table entry is valid. If it is valid, update the MAC table entry according to the stored learning address in the next clock cycle; otherwise, proceed to step 3.

[0081] In this embodiment, the learning address includes the learning address of this channel and the learning addresses of other channels. First, it is determined whether the learning address of the current channel is valid. If it is valid, the MAC table entry is updated according to the learning address of the current channel in the next clock cycle. Otherwise, it is determined whether the learning addresses of other channels are valid. If they are valid, the MAC table entry is updated according to the learning addresses of other channels in the next clock cycle. This process continues until all learning addresses have been updated, at which point step ③ is executed.

[0082] Step 3: Determine whether the aging data of the stored MAC table entry is valid. If it is valid, update the MAC table entry according to the stored aging data in the next clock cycle; otherwise, perform an aging lookup operation on the MAC table entry.

[0083] The pipelined implementation method for Layer 2 forwarding in this embodiment of the invention, compared with the existing Layer 2 forwarding implementation using state machines, reduces the absolute latency of the Layer 2 forwarding module to 4 cycles from data input to obtaining the lookup result. At the maximum operating rate, one lookup operation is performed every two clock cycles, which can satisfy the forwarding of the shortest frame (64B) with a 256b data bus. Using a 512MHz clock and the forwarding module as the module with the highest relative latency, the maximum throughput is 130G. Using a two-channel synchronization method, a throughput of 260G can be achieved at a 512MHz clock.

[0084] Secondly, this embodiment of the invention also provides a pipeline implementation device for Layer 2 forwarding. In order to solve the problem of excessive resource consumption, this embodiment reduces the large consumption of storage resources and simplifies the storage logic by merging the learning table and the lookup table. At the same time, in order to adapt to the use of a single MAC table entry for learning and forwarding, learning and forwarding are merged into a single pipeline, reusing the hash module.

[0085] Please see Figure 3 The diagram shown is a structural block diagram of a two-layer forwarding pipeline implementation device provided in this embodiment of the invention. As shown in the figure, the two-layer forwarding pipeline implementation device of this embodiment includes:

[0086] The forwarding control module obtains the source MAC address and destination MAC address from the data packet, generates the destination MAC address identifier and the source MAC address identifier, caches the source MAC address, sends the destination MAC address and destination MAC address identifier to the hash mapping module at the current clock, and sends the source MAC address and source MAC address identifier to the hash mapping module after a one-clock delay.

[0087] In this embodiment, after the forwarding control module obtains the source MAC address and destination MAC address from parsing the data packet, if the source MAC address and destination MAC address are valid, it generates a destination MAC address identifier and a source MAC address identifier at the current clock and sends them to the hash module for hash calculation. The source MAC address is cached, and a cache validity flag is raised. If the cache flag is valid at the next clock, the source MAC address and source MAC address identifier are sent to the hash module for hash calculation.

[0088] The hash mapping module performs hash mapping on the received destination MAC address and destination MAC address identifier to generate a first hash address and a destination hash address identifier, and performs hash mapping on the received source MAC address and source MAC address identifier to generate a second hash address and a source hash address identifier;

[0089] In this embodiment, since the pipeline processes learning and searching simultaneously, and due to the design limitation of reusing MAC entries, learning and searching cannot be performed concurrently. Therefore, the hash module is also reused. Optionally, the hash module is implemented using the CRC algorithm.

[0090] The destination MAC lookup module, in response to recognizing the destination hash address identifier, sends the first hash address as the lookup address to the table entry control module, simultaneously raises the lookup enable flag, and forwards the packet according to the lookup result;

[0091] The source MAC learning module, in response to the identification of the source hash address, sends the second hash address as the lookup address for the learning operation to the table entry control module, while simultaneously raising the learning enable flag and learning the MAC table entry based on the lookup result;

[0092] The table entry control module performs a table lookup on the MAC table entry based on the received table lookup address and lookup enable flag, and sends the lookup result to the destination MAC lookup module. It also performs a table lookup on the MAC table entry based on the received table lookup address and learning enable flag, and sends the lookup result to the source MAC learning module. Finally, it performs a table lookup on the MAC table entry based on the received table lookup address of the aging module, and sends the lookup result to the aging module.

[0093] The MAC entry module is used to store MAC entries. It uses a dual-port RAM. The first port implements the lookup and result transmission of the destination MAC lookup module and the lookup and result transmission of the source MAC learning module according to the entry control module. The second port implements the learning and aging of MAC entries according to the entry control module.

[0094] In this embodiment, the destination MAC address lookup is achieved jointly by the destination MAC lookup module, the table entry control module, and the MAC table entry module.

[0095] During the lookup operation, the destination MAC lookup module collects the output of the hash module. After identifying the destination hash address identifier, it sends the collected hash address (i.e., the first hash address) to the table lookup control module as the lookup address for the lookup operation, and simultaneously raises the lookup enable flag. Upon receiving the lookup enable, the table lookup module performs the lookup and raises the lookup enable flag twice as a flag for distributing the lookup result. If the lookup flag is valid, the lookup result is sent to the destination MAC lookup module. The destination MAC lookup module then forwards the packet based on the lookup result. The specific packet forwarding process is as described in the pipelined implementation method of Layer 2 forwarding above, and will not be elaborated here.

[0096] In this embodiment, the learning of source MAC addresses is achieved jointly by the source MAC learning module, the entry control module, and the MAC entry module.

[0097] During the learning operation, the source MAC learning module collects the output of the hash module. After identifying the source hash address identifier, it sends the collected hash address (i.e., the second hash address) as the lookup address for the learning operation to the entry control module, and simultaneously raises the learning enable flag. Upon receiving the learning enable, the entry control module performs a table lookup, and after two clock cycles, uses the learning enable flag as a flag for distributing the lookup result. If the learning flag is valid, the lookup result is sent to the source MAC learning module. The source MAC learning module then learns the MAC entries based on the lookup result. The specific MAC entry learning process is as described in the pipelined implementation method of Layer 2 forwarding above, and will not be elaborated here.

[0098] It should be noted that the MAC entry module uses dual-port RAM. Accordingly, the entry control includes the first port control logic and the second port control logic of the RAM. The first port control logic implements the table lookup and result transmission for the destination MAC lookup module, as well as the table lookup and result transmission for the source MAC learning module. The second port control logic is described in [link to relevant documentation]. Figure 6The diagram illustrates the control logic of the second port of a MAC address table entry, implementing operations including updating the learning address of this channel, updating the learning addresses of other channels, aging-up updates, and aging-up lookup. Specifically, a priority system is set: first, it determines whether updating the cached content (cache content is used to resolve read / write conflicts between the two ports); if there is no cached address, the learning result of this channel is updated; if this channel also does not need updating, the learning results of other channels are updated; finally, it determines whether aging-up updates are needed, and if there is no content to update, an aging-up lookup operation is performed.

[0099] The aging module is used to age up MAC entries based on the lookup results.

[0100] In this embodiment, the aging module includes a seconds counter and an aging state machine. The seconds counter is used for both aging and learning functions. During learning, the current time is stored in a MAC address table. During aging, this table field is used to determine whether an entry has reached a preset lifespan; if so, it is deleted (e.g., all zeros are written to that address); otherwise, no operation is performed. The state machine polls the addresses of the MAC addresses, traversing all addresses and processing them according to the entry's validity flag and learning time. The state machine can also be blocked.

[0101] Alternatively, the second counter can be kept constant by controlling an externally configurable register, thus eliminating the need for aging deletion.

[0102] Please see Figure 5 The diagram shows an aging state machine with a simple structure, containing only three states: Idle, Lookup, and Processing. In the IDLE state, the rising edge of the address counter (which continuously increments by 1 throughout the RAM address space) is captured and sent to the table entry control module, while the address counter is also incremented. In the DATA state, the aging module performs no operation, but the table entry control module captures the aging channel read signal. In the DELETE state, the lookup result is processed: if the lookup result is valid and the time in the lookup result matches the current system time, it indicates that the aging time has expired, and the machine is deleted (by writing all 0s to this address).

[0103] The pipelined implementation device for Layer 2 forwarding in this embodiment further includes a learning FIFO and a deletion FIFO, wherein the learning FIFO is used to store the learning address of the MAC table entry, and the deletion FIFO is used to store the aging data of the MAC table entry.

[0104] The pipeline implementation device for Layer 2 forwarding in this embodiment of the invention merges the learning table and the lookup table into a single MAC entry. Synchronization can also be implemented using a low-capacity FIFO, saving a large amount of redundant storage resources. Secondly, when using a single MAC entry to synchronize data on other channels, only the learning results need to be synchronized, and aging can be completed autonomously by this device, reducing the control logic during synchronization.

[0105] Furthermore, the pipeline implementation method and apparatus for the two-layer forwarding in this embodiment were experimentally verified through circuit simulation experiments.

[0106] After the circuit was implemented, a verification environment was built using SystemVerilog, and simulation was performed using Vivado in conjunction with Modelsim. This verified whether the circuit had any errors. Additionally, to confirm that the circuit was feasible, a simple synthesis was performed using Design Compiler.

[0107] a) Simulation content

[0108] The input stimulus is provided at the fastest processing rate (processing one data point every 2 clock cycles). Simultaneous learning and table lookup operations are performed. Simulation results are as follows: Figure 7 and Figure 8 As shown.

[0109] from Figure 7 As can be seen, when inputting at the fastest speed, the first few times are broadcasts. This is because the destination MAC address is the source MAC address learned last time, and the synchronization of the learning table is completed 4 cycles after the learning result is given. The update is completed when the same address is queried for the second time. The verification results meet the design expectations.

[0110] from Figure 8 As can be seen from the priority of the second port control set in the embodiment of the present invention, and also from the design of the aging module, aging works during the interval of table update.

[0111] b) Overall Results

[0112] Synthesis was performed using Design Compiler and a 28nm process library. Due to a lack of corresponding RAM and FIFO IPs, synthesis was only performed on modules. The synthesis results revealed that the bottleneck in the circuit lies in the modulo-512M counter in the aging module, which can reach a maximum frequency of 1GHz.

[0113] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations are intended to cover non-exclusive inclusion, such that an article or apparatus comprising a list of elements includes not only those elements but also other elements not expressly listed. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the article or apparatus that includes said element. Terms such as "connected" or "linked" are not limited to physical or mechanical connections but can include electrical connections, whether direct or indirect.

[0114] The above description, in conjunction with specific preferred embodiments, provides a further detailed explanation of the present invention. It should not be construed that the specific implementation of the present invention is limited to these descriptions. For those skilled in the art, various simple deductions or substitutions can be made without departing from the concept of the present invention, and all such modifications and substitutions should be considered within the scope of protection of the present invention.

Claims

1. A pipelined implementation method for Layer 2 forwarding, applied to a pipelined implementation apparatus for Layer 2 forwarding, the apparatus comprising a forwarding control module, a hash mapping module, a destination MAC lookup module, a source MAC learning module, an entry control module, a MAC entry module, and an aging module, characterized in that, The pipeline implementation method for the second-layer forwarding includes: The forwarding control module obtains the source MAC address and destination MAC address from the data packet, generates a destination MAC address identifier and a source MAC address identifier, caches the source MAC address, sends the destination MAC address and the destination MAC address identifier to the hash mapping module at the current clock, and sends the source MAC address and the source MAC address identifier to the hash mapping module after a one-clock delay. The hash mapping module performs hash mapping on the received destination MAC address and destination MAC address identifier to generate a first hash address and a destination hash address identifier, and performs hash mapping on the received source MAC address and source MAC address identifier to generate a second hash address and a source hash address identifier; The destination MAC lookup module, in response to recognizing the destination hash address identifier, sends the first hash address as the lookup address for the lookup operation to the table entry control module, simultaneously raises the lookup enable flag, and forwards the packet according to the lookup result; The source MAC learning module, in response to recognizing the source hash address identifier, sends the second hash address as the lookup address for the learning operation to the table entry control module, simultaneously raises the learning enable flag, and learns the MAC table entry based on the lookup result; The table entry control module performs a table lookup on the MAC table entry based on the received table lookup address and lookup enable flag, and sends the lookup result to the destination MAC lookup module. It also performs a table lookup on the MAC table entry based on the received table lookup address and learning enable flag, and sends the lookup result to the source MAC learning module. Finally, it performs a table lookup on the MAC table entry based on the received table lookup address of the aging module, and sends the lookup result to the aging module. The MAC entry module is used to store MAC entries. It uses a dual-port RAM. The first port implements the lookup and result transmission of the destination MAC lookup module and the lookup and result transmission of the source MAC learning module according to the entry control module. The second port implements the learning and aging of MAC entries according to the entry control module. The aging module is used to age up MAC entries based on the lookup results.

2. The pipelined implementation method for two-layer forwarding according to claim 1, characterized in that, The MAC address is used to look up the entry in the MAC table, and the packet is forwarded based on the lookup result, including: Pull the lookup enable flag high, and look up the MAC table entry based on the first hash address to obtain the lookup result; If a MAC entry exists in the MAC table that matches the first hash address, and the MAC address of the MAC entry matches the destination MAC address corresponding to the first hash address, then the packet is output from the port corresponding to the MAC address of the MAC entry; otherwise, the packet is broadcast.

3. The pipelined implementation method for two-layer forwarding according to claim 1, characterized in that, The MAC table entry is looked up based on the second hash address, and the MAC table entry is learned based on the lookup result, including: Raise the learning enable flag and look up the MAC entry based on the second hash address to obtain the lookup result; If there is no MAC entry in the MAC table that matches the second hash address, then the source MAC address corresponding to the second hash address is learned and the MAC entry is updated. If there is a MAC entry in the MAC table that matches the second hash address, then it is determined whether the address information of the MAC address in the MAC entry data is consistent with the address information of the source MAC address corresponding to the second hash address, and MAC entry learning is performed based on the determination result.

4. The pipelined implementation method for layer 2 forwarding according to claim 3, characterized in that, Determine whether the address information of the MAC address in the MAC entry data is consistent with the address information of the source MAC address corresponding to the second hash address, and learn the MAC entry based on the determination result, including: Step a: Determine whether the MAC address of the MAC entry data is consistent with the source MAC address corresponding to the second hash address. If they are consistent, proceed to step b; otherwise, learn the source MAC address corresponding to the second hash address and update the MAC entry. Step b: Determine whether the port of the MAC address of the MAC entry data is consistent with the port of the source MAC address corresponding to the second hash address. If they are consistent, proceed to step c; otherwise, learn the source MAC address corresponding to the second hash address and update the MAC entry. Step c: Determine whether the update time of the MAC address of the MAC entry data is consistent with the time of the source MAC address corresponding to the second hash address. If they are consistent, do not learn the MAC entry; otherwise, learn the source MAC address corresponding to the second hash address and update the MAC entry.

5. The pipelined implementation method for layer 2 forwarding according to claim 1, characterized in that, Also includes: After the MAC entries have been learned, they are aged out.

6. The pipelined implementation method for layer 2 forwarding according to claim 5, characterized in that, The table lookup operation based on the hash address of the MAC entry uses different control logic than the learning and aging of the MAC entry.

7. The pipelined implementation method for layer 2 forwarding according to claim 6, characterized in that, If a read operation to look up a MAC entry based on its hash address conflicts with a write operation to learn or age out a MAC entry, the read operation takes precedence, and the write operation data is stored in the cache register. The MAC entry update operation is then paused for one clock cycle.

8. The pipelined implementation method for layer 2 forwarding according to claim 7, characterized in that, After the MAC entries have been learned, they undergo an aging process, including: Step ①: Determine if the cache register is valid. If valid, update the MAC entry in the next clock cycle based on the write operation data in the cache register; otherwise, proceed to step ②. Step ②: Determine whether the learning address of the stored MAC table entry is valid. If it is valid, update the MAC table entry according to the stored learning address in the next clock cycle; otherwise, proceed to step ③. Step 3: Determine whether the aging data of the stored MAC table entry is valid. If valid, update the MAC table entry according to the stored aging data in the next clock cycle; otherwise, perform an aging lookup operation on the MAC table entry.

9. A pipeline implementation apparatus for two-layer forwarding, characterized in that, include: The forwarding control module obtains the source MAC address and destination MAC address from the data packet, generates a destination MAC address identifier and a source MAC address identifier, caches the source MAC address, sends the destination MAC address and the destination MAC address identifier to the hash mapping module at the current clock, and sends the source MAC address and the source MAC address identifier to the hash mapping module after a one-clock delay. The hash mapping module performs hash mapping on the received destination MAC address and destination MAC address identifier to generate a first hash address and a destination hash address identifier, and performs hash mapping on the received source MAC address and source MAC address identifier to generate a second hash address and a source hash address identifier; The destination MAC lookup module, in response to recognizing the destination hash address identifier, sends the first hash address as the lookup address for the lookup operation to the table entry control module, simultaneously raises the lookup enable flag, and forwards the packet according to the lookup result; The source MAC learning module, in response to recognizing the source hash address identifier, sends the second hash address as the lookup address for the learning operation to the table entry control module, simultaneously raises the learning enable flag, and learns the MAC table entry based on the lookup result; The table entry control module performs a table lookup on the MAC table entry based on the received table lookup address and lookup enable flag, and sends the lookup result to the destination MAC lookup module. It also performs a table lookup on the MAC table entry based on the received table lookup address and learning enable flag, and sends the lookup result to the source MAC learning module. Finally, it performs a table lookup on the MAC table entry based on the received table lookup address of the aging module, and sends the lookup result to the aging module. The MAC entry module is used to store MAC entries. It uses a dual-port RAM. The first port implements the lookup and result transmission of the destination MAC lookup module and the lookup and result transmission of the source MAC learning module according to the entry control module. The second port implements the learning and aging of MAC entries according to the entry control module. The aging module is used to age up MAC entries based on the lookup results.

10. The pipeline implementation apparatus for two-layer forwarding according to claim 9, characterized in that, It also includes a learning FIFO and a deletion FIFO, where the learning FIFO is used to store the learning address of the MAC table entry, and the deletion FIFO is used to store the aging data of the MAC table entry.