1. Field of the Invention
The present invention relates to a network packet receiving management method and related apparatus, and more particularly, to a network packet receiving management method based on an array data structure and an apparatus thereof.
2. Description of the Prior Art
A network interface controller (NIC) provides an identifiable address for an electronic apparatus connecting to a network, and functions as a communication interface between the electronic apparatus and the network. When the electronic apparatus successively receives a network packet from the network, the network interface controller will upload the received network packet to a processing unit within the electronic apparatus, and receive a processed network packet replied by the processing unit. Generally speaking, the data structures adopted by network interface controllers in the present time are mostly linked-list data structures or array data structures. For a received network packet, the linked-list data structure indicates an address of a previous network packet, an address of a next network packet, or both addresses of the previous network packet and the next network packet; in this way, when the processing unit replies packets in an order different from an order used by the network interface controller for uploading packets, the processing unit can still easily find out a sequence of the data arrangement. However, one disadvantage of the linked-list data structure is that it requires more system resource to process and store addresses indicative of a previous and/or a next network packet. On the other hand, the array data structure utilizes a more simplified structure and requires only a little storage space and system resource. The disadvantage of the array data structure is that when the processing unit replies packets in an order different from an order used by the network interface controller for uploading packets, an out-of-order issue will occur, leading to a decrement in interface utilization efficiency.
Please refer to
One of the objectives of the present invention is to provide a network packet receiving management method based on an array data structure and a network control circuit thereof, to solve packet out-of-order problem and simplify hardware interface. In this way, the overall system performance can be improved and hardware cost can also be reduced.
According to one embodiment of the present invention, a network packet receiving management is provided. The network packet receiving management method includes following steps: providing a buffer unit, including at least a plurality of data blocks with a first packet number and a plurality of data blocks with a second packet number, wherein the data blocks with the first packet number store a plurality of first network packets according to a first array data structure, respectively, the first array data structure includes a plurality of first packet descriptors corresponding to the first packet number, the data blocks with the first packet number correspond to the first packet descriptors, respectively, and the data blocks with the second packet number do not correspond to any packet descriptor; and changing a correspondence of a first packet descriptor from a first data block within the buffer unit to a second data block within the buffer unit when the first data block successively receives a first network packet, wherein the second data block corresponds to no packet descriptor before a change of the correspondence of the first packet descriptor is made.
According to another embodiment of the present invention, a network control circuit with network packet receiving management functionality is provided. The network control circuit includes a buffer unit and a processing unit. The buffer unit includes at least a plurality of data blocks with a first packet number and a plurality of data blocks with a second packet number, wherein the data blocks with the first packet number store a plurality of first network packets according to a first array data structure, respectively, the first array data structure includes a plurality of first packet descriptors corresponding to the first packet number, the data blocks with the first packet number correspond to the first packet descriptors, respectively, and the data blocks with the second packet number do not correspond to any packet descriptor. The processing unit is coupled to the buffer unit, and implemented for changing a correspondence of a first packet descriptor from a first data block within the buffer unit to a second data block within the buffer unit when the first data block successively receives a first network packet, wherein the second data block corresponds to no packet descriptor before a change of the correspondence of the first packet descriptor is made.
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.
Please refer to
To further explain the network packet receiving management method of the present invention, please refer to
When the first array B1 is full with network packets Pb1˜Pb4 and before those network packets Pb1˜Pb4 are uploaded sequentially to a terminal unit 250, the processing unit 220 will assign packet descriptors Db1˜Db4 to indicate four free data blocks DB2_1˜DB2_4 which do not correspond to any packet descriptor. For example, before the network control circuit 200 uploads the network packet Pb1, the processing unit 220 within the network control circuit 200 will change the correspondence of the packet descriptor Db1 from the data block DB2_1 to one of the free data blocks DB2_1˜DB2_4, and after the network packet Pb1 is uploaded successively, the data block DB2_1 occupied by the network packet Pb1 and originally indicated by the packet descriptor Db1 also becomes a free data block. Please refer to
Please note that the aforementioned embodiments are for illustrative purpose only, and they are not supposed to be limitations to the present invention. For example, the number of data blocks contained within the first array B1 can vary according to different design requirements, and is therefore not limited to be four; similarly, the number of free data blocks can also vary according to different design requirements, and it is not necessary to be identical to the number of data blocks contained within the first array B1. Besides, when a number of network packets, which are successively stored and wait for being uploaded, exceeds a predetermined number, the processing unit 220 can dynamically increase the number of free data blocks; on the other hand, when the number of network packets, which are successively stored and wait for being uploaded, is less than a predetermined number, the processing unit 220 can dynamically decrease the number of free data blocks to release more storage space. In this way, the network control circuit 200 can dynamically adjust the efficiency of receiving network packets according to a load status of the terminal unit 250.
Please refer to
For example, before the network control circuit 300 uploads the network packet Pc1, the processing unit 320 will change the correspondence of the packet descriptor Dc1 to one of the free data blocks DB5_1˜DB5_4, and after the network packet Pc1 is uploaded successively, the data block DB3_1 occupied by the network packet Pc1 and originally indicated by the packet descriptor Dc1 becomes a free data block accordingly. As the related operational mechanism can be easily comprehended via the example shown in
Please note that the aforementioned embodiment is for illustrative purpose only, and it is not supposed to be limitations to the present invention. For example, the number of data blocks contained within the first array C1 and the number of data blocks contained within the second array D1 can vary according to different design requirements, and are not limited to be four; similarly, the number of free data blocks can also vary according to design requirements, and it is not necessary to be identical to the number of data blocks contained within the first array C1 or the number of data blocks contained within the second array D1. Besides, when a number of network packets, which are successively stored and wait for being uploaded, exceeds a predetermined number, the processing unit 320 can dynamically increase the number of free data blocks; on the other hand, when the number of network packets, which are successively stored and wait for being uploaded, is less than a predetermined number, the processing unit 320 can dynamically decrease the number of free data blocks to release more storage space.
In addition, when the number of the free data blocks are fixed, the packet descriptors of the first array C1 and the second array D1 share the free data blocks with the fixed number, where the principle of allocating free data blocks is that each terminal unit takes a different number of free data blocks according to respective requirements, i.e., a load balance is achieved due to that fact that each terminal unit utilizes resource of the free data blocks according to its own load status.
Please note that the description above is only a preferred implementation of the present invention; in an alternative design, the processing unit 320 can also utilize a predetermined ratio to allocate free data blocks within the buffer unit 310 to the first array C1 and the second array D1, and this variation in design also falls within the scope of the present invention.
To summarize, the present invention provides a network packet receiving management method and related apparatus. Since the present invention adopts an array data structure, only one adder is required for a practical implementation, and the amount of hardware can be reduced and a cost can be saved effectively; besides, reading an extra index of packet descriptors is not required, leading to a great decrement of the load of the interface. In addition, the introduction of the free data blocks in the present invention can effectively avoid the array out-of-order problem, thereby enhancing a packet receiving rate. Additionally, the function of dynamically varying the number of free data blocks can compensate the defect that an array data structure cannot dynamically vary its own size. Furthermore, the present invention provides a load balance scheme under a configuration of multiple arrays of packet descriptors, whereby great performance can be accomplished in the mainstream multi-core system.
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.
Number | Date | Country | Kind |
---|---|---|---|
098115820 | May 2009 | TW | national |