The present invention is related to a circuitry within a device for delivering network packets to a processor, and an associated operating method.
In a network communications device (e.g. a network device) positioned in a switch or a router, a network device may have multiple ports for receiving or outputting packets. When the network device receives a packet, the network device may perform inquiry via an internal hardware circuit and a look-up table to determine from which port to send out the packet. If the hardware circuit determines that this process requires software to be involved, the hardware circuit may deliver the packet to a central processor, for using software processing to determine whether to correct the packet or determine a destination of the packet.
Forwarding the packet via the hardware circuit is faster, but software will be required if there is no related information of the received packet in the look-up table or the hardware cannot identify a format of the packet, meaning the hardware circuit cannot process the packet. Although software transmission can deal with all packet formats, in practice, the hardware circuit may first move the whole packet to a memory that is accessible for a processor when the processing fails, and the central processor may further read packet contents from the memory later for performing software analysis to properly handle the packet.
This conventional method may need more memory spaces and may occupy greater bus bandwidth, which degrades system performance, particularly when the frame is a Jumbo frame which will impact the performance even more severely.
Thus, an objective of the present invention is to provide a technique applied in a network device, which can effectively reduce the impact upon the system performance when the central processor processes a packet by software, to solve the problem of the related art.
In an embodiment of the present invention, a circuitry applied in a network device is disclosed. The circuitry comprises at least one port, a processor port, a packet buffer, a control circuit and a parser, where the processor port is coupled to a memory and a processor via a bus. In operations of the circuitry, the packet buffer stores a packet received from one of the at least one port. The parser analyzes the packet to determine a processing manner of the packet. When the parser is not able to determine the processing manner regarding the packet or determine that the packet need to be processed by software, the control circuit may segmentally deliver a partial content of the packet or deliver all contents at once to the memory via the processor port by a software setting, for being analyzed by the processor.
In another embodiment of the present invention, an operating method of a network device is disclosed. The operating method comprises the following steps: receiving a packet; storing the packet into a packet buffer; analyzing the packet to determine a processing manner of the packet; and when the processing manner is not able to be determined or when determining that the packet needs to be processed by software, segmentally delivering a partial content of the packet or delivering all contents at once to the memory by software setting, for being analyzed by a processor.
These and other objectives of the present invention will no doubt become obvious to those of ordinary skill in the art after reading the following detailed description of the preferred embodiment that is illustrated in the various figures and drawings.
It should be noted that, in the embodiment shown in
In Step 208, regarding details of the transmission basic unit length L of DMA, refer to
The flow then enters Step 210 to determine whether the transmission packet length variable M is less than the DMA transmission basic unit length L. If M is less than or equal to L, the flow enters Step 212 to deliver the remaining contents of the packet to the DRAM 106; otherwise, the flow enters Step 214. In Step 214, the packet is delivered to the DRAM according to L bytes of contents following the last DMA transmission. If it is the first time the DMA controller 160 delivers data of the packet to the DRAM 106, the DMA controller 160 delivers L bytes of contents starting from the header of the packet.
After the control circuit 130 and the DMA contro11er160 deliver partial contents of the packet to the DRAM 106, the control circuit 130 may inform the processor 102 via the processor port 112, and notify that partial contents of the packet 300 have been delivered to the DRAM 106. The DRAM 106 may be replaced with any other type of memory in another embodiment.
The flow then enters Step 216. The software reads packet contents that have been delivered to the DRAM 106, and performs analysis to determine whether it is required to keep reading the packet contents remaining in the packet buffer. If yes, the flow enters Step 218 to update the transmission packet length variable M (the original value M minus L bytes that were previously delivered to the DRAM 106 by DMA), and enters Step 210 again. Related descriptions of Step 210 may be known by referring to the relevant description above, and are omitted here for brevity. In another embodiment, this DMA transmission basic unit length L may be set as different values in every DMA by software setting.
When the flow determines that it is not required to keep reading the packet contents remaining in the packet buffer in Step 216, the flow enters Step 220. Similarly, Step 212 is also followed by Step 220, which means a procedure of delivering the packet contents from the DMA controller 160 to the DRAM 106 has finished.
Refer to
In Step 228, the software sends an command to make the packet buffer release the memory space occupied by the packet. The flow then enters a general conventional software operation following Step 230, which is omitted here for brevity.
In Step 224, the software sends an command to make a partial content that has been corrected in the DRAM 106 be written back to the packet buffer through the DMA controller 160, and replaces a partial content of the original packet to finish the update. The packet is then sent out via a target port in Step 226.
It should be noted that parts of the above description relating to software analysis are well-known by those skilled in this art; the main focus of this embodiment is segmentally forwarding the packet 300 for the processor 102 to perform software analysis. Details relating to software analysis are therefore omitted here for brevity.
Briefly summarized, in the circuitry applied in a network device of the present invention, when a hardware circuit is unable to determine whether to transfer information regarding a packet, or to which processor port the packet should be transferred to, the circuitry can deliver a partial content of the packet to the DRAM for the processor to perform software analysis. In one embodiment, the partial content comprises most information (e.g. a header) that is required for packet searching. Thus, under most conditions, the processor may merely read the partial content of the packet to determine subsequent processing manners of the packet without completely analyzing the whole packet contents. Utilized bandwidth of the DRAM can be effectively reduced, and execution efficiency of related circuits may be increased while power consumption can be reduced.
Those skilled in the art will readily observe that numerous modifications and alterations of the device and method may be made while retaining the teachings of the invention. Accordingly, the above disclosure should be construed as limited only by the metes and bounds of the appended claims.
Number | Date | Country | Kind |
---|---|---|---|
109109765 | Mar 2020 | TW | national |