1. Field of the Invention
The present invention relates to a packet processing method and device, and more particularly to a packet processing method and device for converting data into packets conforming to the communication protocol for communication between networks.
2. Description of the Related Art
The packet conversion processing of data is generally performed as follows. In other words, data transmitted to a network is divided if it exceeds the data length defined according to the restrictions of the maximum transmission units and the purpose of the network which performs communication. Each divided data is processed by the protocol stack. By this processing, a plurality of protocol headers and protocol footers are attached to each data, and packets that can be transmitted on the network are created. In these processing steps, each data is simply copied from an area of a memory allocated by the user or from an application program to another area of dedicated memory used by the processor each time a protocol header or protocol footer is attached. Since each data to be transmitted by packets is independently copied, the load to be applied on the processor is high and a large amount of bandwidth of the memory bus is used because of frequent transmission (JP-A-2002-538731).
In the above mentioned known processing method, a copy of each data is required each time a protocol header and protocol footer is attached in the protocol stack processing. So the time required for the processor to execute the processing increases and throughput drops.
To solve this problem, it is an object of the present invention to provide a packet conversion processing method and packet conversion processing device for decreasing the number of copies to memory in the packet conversion processing steps, and improving throughput.
The present invention for the packet processing method solves the above problem by using the following processing steps.
A packet processing method for converting data into packets conforming to a communication protocol for communicating data between networks comprises steps of: dividing the data into a plurality of divided data with a predetermined data length; storing the divided data; securing a first blank area corresponding to the divided data in an area before a storage area for storing each of the divided data when the divided data is stored; securing a second blank area corresponding to the divided data in an area after the storage area for storing each of the divided data; storing a protocol header to be attached in the first blank area when the packet conversion processing is executed on the divided data; storing a protocol footer to be attached in the second blank area when the packet conversion processing is executed on the divided data; and identifying the data in the storage area, including the protocol header and protocol footer attached to each divided data, as one packet.
By using these processing steps, when a protocol header and/or protocol footer are/is attached by the packet conversion processing for the data, the data, including the protocol header and/or protocol footer, need not be copied from a dedicated memory of the processor used for packet conversion processing to a user space (e.g. data storage device of an application program). Instead only the protocol header and/or protocol footer to be attached can be copied to the first blank area and second blank area secured in the user space.
The packet processing device for implementing the packet processing method according to the present invention solves the above problem by the following configuration.
A first packet processing device according to the present invention comprises: a storage device for storing data; a transfer device for dividing the data into a plurality of data with a predetermined length and arranging the divided data at intervals in the storage device while securing a first blank area for attaching a protocol header to the divided data and a second blank area for attaching a protocol footer to the divided data; a read address control device for implementing access of the data arranged at intervals in the storage device as continuous data; and a write address control device for storing the protocol header to be attached in the first blank area and protocol footer to be attached in the second blank area when the packet conversion processing is executed on the divided data.
By this, when a protocol header and/or protocol footer are/is attached by the packet conversion processing for the data, the data, including the protocol header and/or protocol footer, need not be copied from a dedicated memory of the processor used for packet conversion processing to the storage device, and only the protocol header and/or protocol footer to be attached can be copied to the first blank area and/or second blank area secured in the storage device, and the throughput of the packet conversion processing for data can be improved.
According to the first packet processing device, it is preferable to further comprise a register for arbitrarily setting the data length of the divided data, the size of the first blank area and the size of the second blank area respectively, so that the arrangement of divided data at intervals in the storage device can be controlled with more flexibility.
It is preferable that the transfer device is a DMAC having a function of continuously transferring data while adding an arbitrary value to the transfer destination address for each transfer count that is set, when the data is transferred from the transfer source side to the transfer destination side, and implementing the arrangement of the divided data at intervals in the storage device by continuously transferring the next data with adding the sum of the address count in the first blank area and the address count in the second blank area to the transfer destination address, each time data is transferred to the storage device for the amount corresponding to the data length of the divided data.
It is preferable that the read address control device and the write address control device are updated each time the protocol header and/or protocol footer are/is attached, and the packet processing device further comprises a first register to indicate the size of the divided data storage area in the storage device at an arbitrary point of time, a second register to be updated each time a protocol header is attached and to indicate the size of the blank area for storing the protocol header in the storage device at an arbitrary point of time, and a third register to be updated each time a protocol footer is attached and to indicate the size of the blank area for storing the protocol footer in the storage device at an arbitrary point of time. These are effective to implement a plurality of protocol stack processings for the data.
It is preferable that the read address control device comprises a function for calculating the size of the blank area between the divided data stored in the storage device from the sum of the value of the second register and the value of the third register, and can implement continuous access to the divided data arranged at intervals by adding the calculated value to the address of the access destination for each read count corresponding to the value of the first register when the divided data is accessed from outside of the storage device.
It is preferable that the write address control device further comprises a function to calculate an interval address value of the protocol header storage area corresponding to each divided data by multiplying the sum of the value of the first register, the value of the second register and the value of the third register by the count of attaching the protocol header, and then adding an offset value that is a result after the size of the protocol header to be attached is subtracted from the value of the second register, and to calculate the interval address value of the protocol footer storage area corresponding to each divided data by multiplying a value that is a result after the size of the protocol footer to be attached is subtracted from the sum of the value of the first register, the value of the second register and the value of the third register by the count of attaching the protocol footer. According to this, the calculated value is added to the storage destination address each time one protocol header and/or one protocol footer are/is stored in the storage device, therefore the protocol header and/or protocol footer can be attached to each of the divided data arranged at intervals in the storage device.
For the size of the protocol header and/or protocol footer, a standard Ethernet® supported TCP/IP, for example, may be preset for each protocol, such as a TCP header is 20 or 24 bytes, an IP header is 20 bytes or more and 60 bytes or less, an Ethernet® header is 14 bytes, and a CRC to be a footer is 4 bytes. Or a dedicated counter for counting each data length of the protocol header and/or protocol footer to actually be attached to the data, in the step of performing the packet conversion processing on data, may be disposed so as to calculate the size each time.
In the second packet processing device according to the present invention, the transfer device work area on the storage device, required for the packet conversion processing, can be dramatically decreased by constructing a transfer device as follows.
The second packet processing device according to the present invention comprises a storage device for storing data, a CPU for executing packet processing on data stored in the storage device as one of the tasks, and a transfer device for transferring data between the storage device and the CPU, wherein the transfer device infinitely loops the transfer destination address on the storage device within a predetermined area by initializing the transfer destination address of the data for each transfer count that can be arbitrarily set.
By this, continuous packet processing can be implemented in a less sized memory space, and when image data is transmitted over a network in real-time, that is when packet conversion processing is continuously executed on the data and is continuously transmitted over the network, for example, the work area on the storage device, required for packet conversion processing, can be dramatically decreased.
It is preferable that the second packet processing device according to the present invention further comprises a wait instruction control device for calculating the difference between the final address of the storage area storing the data for which packet processing is completed in the storage device and a transmission destination address when data is transmitted from the transfer device to the storage device, and outputting a wait control signal to the transfer device when the calculated address difference value is smaller than an address difference value that was preset. By this, an overwrite of the packet processing uncompleted data by the transfer device can be prevented.
It is also possible that the wait instruction control device further comprises a register for setting the address difference value arbitrarily, so that an overwrite of the packet processing uncompleted data by the transfer device can be prevented more flexibly.
It is suitable that the transfer device temporarily stops data transfer from the transfer device to the storage device when a wait control signal is input from the wait instruction control device. By this, an overwrite of the packet processing uncompleted data by the transfer device can be prevented.
It is also preferable that the transfer device further comprises a counter for counting the input count of a wait control signal to be input from the wait instruction control device, and a control unit for temporarily stopping data transfer from the transfer device to the storage device when the count value of this counter reaches a preset value, and by this, an overwrite of the packet processing uncompleted data by the transfer device can be prevented more flexibly.
It is also preferable that when a wait control signal is input from the wait instruction control device, the transfer device outputs an interrupt request with a high priority level to the CPU, so as to increase the priority of the packet processing for the other tasks of the CPU.
It is also preferable that when the count value by the counter reaches a preset count, the transfer device outputs an interrupt request with a high priority level to the CPU, so as to increase the priority of the packet processing for the other tasks of the CPU. By this, the case when the wait control signal from the wait instruction control device is generated frequently, that is the case when the throughput of the packet processing drops, can be effectively handled.
It is also preferable that when an interrupt request is output to the CPU, the transfer device outputs an interrupt request with a priority level corresponding to the calculated address difference value, and outputs an interrupt request with a higher priority level to increase the priority of the packet processing as the calculated address difference value becomes smaller. By this, a more flexible packet processing, including the priority of the other tasks of the CPU, can be implemented.
According to the present invention, when a protocol header and/or protocol footer are/is attached by the packet conversion processing for the data, the data including the protocol header and/or protocol footer need not be copied from a dedicated memory of the processor used for packet conversion processing to the user space (e.g. data storage device of an application program) each time, and only the protocol header and/or protocol footer to be attached can be copied to the first blank area and/or second blank area secured in the user space, and as a result, the throughput of the packet conversion processing for the data can be improved.
The first embodiment (packet processing method) of the present invention will now be described with reference to the drawings.
In
When data 1 is converted into packets conforming to a communication protocol for communicating data 1 between networks, the data 1 is first divided into a predetermined size, as shown in (a) in
Then packet conversion processing is performed for each divided data stored in the divided data storage area 200. When the packet conversion processing is performed, the protocol header or protocol footer corresponding to each divided data is attached to the divided data, which is converted into a packet. As
In
An outline of an embodiment of the packet processing method of the present invention was described above, and now details of the embodiment of the packet processing method of the present invention will be described with reference to the drawings using TCP/IP packet processing as an example.
(a) in
(b) in
(c) in
(d) in
The embodiment of the packet processing method of the present invention was described above using TCP/IP packet processing as an example. Now an embodiment of the packet processing device for implementing the packet conversion processing method of the present invention will be described with reference to the drawings.
The data bus 12 and the data bus 13, the address bus 14 and the address bus 15, the data bus 18 and the data bus 19, the data bus 26 and the data bus 27, the data bus for receiving 30 and the data bus for transmission 31 may be constructed by a bi-directional bus respectively.
The data received by the PHY 11 is temporarily stored in a data buffer in the MAC 10. To transfer this received data temporarily stored in the data buffer to the storage device 4, the CPU 3 outputs the received data transfer request signal 16 and the first address data to be the data transfer destination of the storage device 4 to the DMA 5. At this time, the address data to be output by the CPU 3 is input to the address converter 6 via the address bus 20, but nothing is processed by the address converter 6, and this address data is output to the address bus 21 and is input to the DMA 5 via the address bus 7 and the address bus 15. The conversion of the address data by the address converter 6 will be described later. When the received data transfer request signal 16 and the address data are input, the DMA 5 starts transferring the received data, which is temporarily stored in the data buffer of the MAC 10, to the storage area of the storage device 4 indicated by the address data that was input from the data buffer of the MAC 10. At this time, the DMA 5 divides the data into predetermined sizes, as shown in
Now data division and the arrangement of the divided data at intervals by the DMA 5 will be described with reference to the drawings.
In the initial divided data length register 500, the initial divided data length information X, to indicate the size of each divided data for arranging the divided data in the storage device 4 shown in
When the received data transfer request signal 16 and the address data are input from the CPU 3 to the DMA 5 in
The counter 503 counts the transfer count of the data to be input from the data bus for receiving 30. The transfer count information 514 counted by the counter 503 is input to the comparator 504. If the transfer count information 514, which was input from the counter 503, is “a value indicating that the transfer count is 1”, the comparator 504 outputs the data “00” to the adder 505 as the comparison result 515. If the transfer count information 514, which was input from the counter 503, is “a value indicating that the transfer count is 2 or more”, the comparator 504 compares the values of the initial divided data length information X 511, which is read from the initial divided data length register 500, and the transfer count information 514, which is input from the counter 503, and if the transferred data volume indicated by the transfer count information 514 is smaller than the data volume indicated by the initial divided data length information X 511, the comparator 504 outputs the data “01” to the adder 505 as the comparison result 515. On the other hand, if the transferred data volume indicated by the transfer count information 514 is the same as the data volume indicated by the initial divided data length information X 511, when the transfer count information 514 which is input from the counter 503 is “a value indicating that the transfer count is 2 or more”, the comparator 504 outputs the data “10” to the adder 505 as the comparison result 515.
The adder 505 reads the address data 516 from the address buffer for storage device 506 in advance, and if the comparison result 515, which is input from the comparator 504, is the data “00”, the adder 505 adds the size information Y 512 of the initial blank area for a head, which is read from the initial blank area register for a header 501, to the address data 516, and stores the addition result in the address buffer for storage device 506 as the address data 517. If the comparison result 515, which is input from the comparator 504, is the data “01”, the adder 505 increments the address data 516, and stores the result to the address buffer for storage device 506 as the address data 517. If the comparison result 515, which is input from the comparator 504, is the data “10”, the adder 505 adds the size information Y 512 of the initial blank area for a header, which is read from the initial blank area register for a header 501 and the size information Z 513 of the initial blank area for a footer which is read from the initial blank area register for a footer 502, to the address data 516, and stores the addition result in the address buffer for storage device 506 as the address data 517.
When the address buffer for storage device 506 becomes full, the control unit 510 sequentially outputs the address data stored in this address buffer for storage device 506 to the address bus 14 and the data stored in the data buffer for receiving 508 to the data bus 12, and outputs the write request signal 24 to the storage device 4. The address data to be output to the address bus 14 is input to the storage device 4 via the address bus 7 and address bus 28, and the data to be output to the data bus 12 is input to the storage device 4 via the data bus 8 and data bus 26. In this case, data transfer from the DMA 5 to the storage device 4 is started when the address buffer for storage device 506 becomes full, but data transfer from the DMA 5 to the storage device 4 may be sequentially executed each time one address data is stored in the address buffer for storage device 506.
In this way, the DMA 5 divides the data stored in the data buffer of the MAC 10 into the size based on the initial divided data length information X which is set in the initial divided data length register 500, and arranges each divided data at intervals in the storage device 4 while securing the blank area with a size based on the size information Y of the initial blank area for a header, which is set in the initial blank area register for a header 501, and the size information Z of the initial blank area for a footer, which is set in the initial blank area register for a footer 502.
The division of the data and the arrangement of the divided data at intervals by the DMA 5 were described above, and now the packet conversion processing for each divided data arranged at intervals in the storage device 4 will be described.
In order to execute packet conversion processing for each divided data arranged at intervals in the storage device 4, the CPU 3 reads the divided data in the storage device 4. At this time, it is preferable that the CPU 3 reads only the divided data arranged at intervals in the storage device 4, and does not access the blank area for a header and the blank area for a footer which are secured before and after each divided data. In order to execute packet conversion processing for each divided data which is arranged at intervals in the storage device 4, the CPU 3 attaches the corresponding protocol header and the protocol footer to the divided data read from the storage device 4. At this time, the CPU 3 must write only the protocol header in the blank area for a header, which is secured before each divided data arranged at intervals in the storage device 4, and write only the protocol footer in the blank area for a footer, which is secured after each divided data.
Now the address converter 6, which is means for performing such address control, will be described with reference to the drawings.
In the divided data length register 606, the divided data length information X′, which indicates the size of each divided data at an arbitrary point of time by the address count in the storage device 4, is stored, and the initial value of the divided data length information X′ is the initial divided data length information X. In the blank area register for a header 607, the size information Y′ of the blank area for a header, which indicates the size of each blank area for a header at an arbitrary point of time by the address count in the storage device 4, is stored, and the initial value of the size information Y′ of the blank area for a header is the size information Y of the initial blank area for a header. In the blank area register for a footer 608, the size information Z′ of the blank area for a footer, which indicates the size of each blank area for a footer at an arbitrary point of time by the address count in the storage device 4, is stored, and the initial value of the size information Z′ of the blank area for a footer is the size information Z of the initial blank area for a footer.
In the header offset register 609, the address offset information Hoff of the attached header, which indicates the size of the protocol header to be attached by the address count in the storage device 4, is stored each time according to the protocol header to be attached, and in the footer offset register 610, the address offset information Foff of the attached footer, which indicates the size of the protocol footer to be attached by the address count in the storage device 4, is stored each time according to the protocol footer to be attached. The address offset information Hoff of the attached header and the address offset information Foff of the attached footer may be set for each protocol in advance according to the protocol to be processed, or an address count counter for counting the address count, which indicates the size of the protocol header and the protocol footer to be actually attached, may be installed separately, so that the count value of the address count counter is used as the address offset information Hoff of the attached header or the address offset information Foff of the attached footer.
Now the operation of the address converter 6 with the above configuration will be described. First the CPU 3 reads the divided data in the storage device 4 to execute the packet conversion processing for each divided data which is arranged at intervals in the storage device 4 in
When the count value, which is input from the read count counter 601, is smaller than the value indicated by the divided data length information X′ 611, the address control unit for reading 603 outputs the size information Y′ 612 of the blank area for a header to the adder 605 as the addition value information for reading 619.
When the count value, which is input from the read count counter 601, is the same value as the value indicated by the division data length information X′ 611, the address control unit for reading 603 outputs the result of adding the size information Y′ 612 of the blank area for a header to the sum of the size information Y′ 612 of the blank area for a header and the size information Z′ 613 of the blank area for a footer to the adder 605 as the addition value information for reading 619, and initializes the read count counter 601 at the same time.
If the reading from the CPU 3 to the storage device 4 is continuously executed, the addition value information for reading 619 is defined as follows.
Addition value information for reading 619=[initialized count of the read count counter 601]×{Y′+Z′}+Y′.
The adder 605 adds the addition value information for reading 619, which is input from the address control unit for reading 603, to the address data stored in the address register 600, and outputs the result to the address bus 21 as the post-conversion address data. The read destination address data, which is output to the address bus 21, is input to the storage device 4 via the address bus 7 and the address bus 28. When the read request signal 22, which is output from the CPU 3, and the address data are received, the storage device 4 outputs the data of the address corresponding to the address data to the data bus 27. The data, which is output to the data bus 27, is transferred to the CPU 3 via the data bus 8 and the data bus 18, and the packet conversion processing is executed by the CPU 3.
The operation of the address converter 6, when the CPU 3 reads the divided data arranged at intervals from the storage device 4, was described above, and now the operation when the CPU 3 writes the protocol header and protocol footer to the blank area for a header and the blank area for a footer of the storage device 4 will be described.
At this time, the CPU 3 outputs the data of the protocol header or protocol footer, to be written to the storage device 4, to the data bus 19. As the address data which indicates the beginning of the write destination of the storage device 4, the CPU 3 outputs the address data, which is the same as the address data, which was specified in the DMA 5, as the first address data to be the data transfer destination when data is transferred to the storage device 4 by the DMA 5. In this way, the address data to indicate the write destination of the storage device 4, which the CPU 3 outputs, is input to the address converter 6 via the address bus 20, and is stored in the address register 600. The write request signal 23, which the CPU 3 outputs to the storage device 4, is also input to the address converter 6. The write count counter 602 counts the write request signal 23 to be input to the address converter 6, and outputs the count value to the address control unit for writing 604. The address control unit for writing 604 reads the divided data length information X′ 614, size information Y′ 615 of the blank area for a header, size information Z′ 616 of the blank area for a footer, address offset information Hoff 617 of the attached header and address offset information Foff 618 of the attached footer respectively from the divided data length register 606, blank area register for a header 607, blank area register for a footer 608, header offset register 609 and footer offset register 610 in advance.
To write a protocol header, the address control unit for writing 604 outputs the value after the address offset information Hoff 617 of the attached header is subtracted from the size information Y′ 615 of the blank area for a header, to the adder 605 as the addition value information for writing 620 if the count value, which is input from the write count counter 602, is smaller than the value indicated by the address offset information Hoff 617 of the attached header. If the count value, which is input from the write count counter 602, is the same value as the value indicated by the address offset information Hoff 617 of the attached header, the address control unit for writing 604 adds the value after the address offset information Hoff 617 of the attached header is subtracted from the size information Y′ 615 of the blank area for a header to the sum of the divided data length information X′ 614, the size information Y′ 615 of the blank area for a header, and the size information Z′ 616 of the blank area for a footer, and outputs the result to the adder 605 as the addition value information for writing 620, and initializes the write count counter 602 at the same time.
The addition value information for writing 620, when the writing of the protocol header from the CPU 3 to the storage device 4 is continuously executed, is defined as follows. Addition value information for writing 620 for header writing=[initialized count of the write count counter 602]×{X′+Y′+Z′}+Y′−Hoff.
To write a protocol footer, the address control unit for writing 604 outputs the sum of the divided data length information X′ 614 and the size information Y′ 615 of the blank area for a header to the adder 605 as the addition value information for writing 620 if the count value, which is input from the write count counter 602, is smaller than the value indicated by the address offset information Foff 618 of the attached footer. If the count value, which is input from the write count counter 602, is the same value as the value indicated by the address offset information Foff 618 of the attached footer, the address control unit for writing 604 adds the sum of the divided data length information X′ 614 and the size information Y′ 615 of the blank area for a header to the value after the value of the address offset information Foff 617 of the attached footer is subtracted from the sum of the divided data length information X′ 614, size information Y′ 615 of the blank area for a header, and size information Z′ 616 of the blank area for a footer, and outputs the result to the adder 605 as the addition value information for writing 620, and initializes the write count counter 602 at the same time.
The addition value information for writing 620, when the writing of the protocol footer from the CPU 3 to the storage device 4 is continuously executed, is defined as follows. Addition value information for writing 620 for footer writing=[initialized count of the write count counter 602]×{X′+Y′+Z′−Foff}+X′+Y′.
The adder 605 adds the addition value information for writing 620, which is input from the address control unit for writing 604, to the address data stored in the address register 600, and outputs the result to the address bus 21 as the post-conversion address data. The write destination address data, which is output to the address bus 21, is input to the storage device 4 via the address bus 7 and address bus 28. When the write request signal 23, write data and address data, which the CPU 3 outputs, are received, the storage device 4 writes the data which is input from the data bus 26 via the data bus 19 and data bus 8 to the address corresponding to the address data.
3 denotes a CPU, 9 denotes a DMA, 4 denotes a storage device, 7 denotes a bi-directional address bus for transferring address data among the CPU 3, the storage device 4 and the DMA 9, 8 denotes a bi-directional data bus for transferring data among the CPU 3, the storage device 4 and the DMA 9, 10 denotes a MAC comprising a data buffer for controlling connection with a network, 11 denotes a PHY which is a physical interface with a network, 12 denotes a data bus for transferring data from the DMA 9 to the data bus 8, 13 denotes a data bus for transferring data from the data bus 8 to the DMA 9, 14 denotes an address bus for transferring address data from the DMA 9 to the address bus 7, 15 denotes an address bus for transferring address data from the address bus 7 to the DMA 9, 16 denotes a received data transfer request signal which is output from the CPU 3 to the DMA 9 for instructing the transfer of data received by the MAC 10 via the PHY 11 to the storage device 4, 17 denotes a transmission data transfer request signal which is output from the CPU 3 to the DMA 9 for instructing the transfer of data of the storage device 4 to the MAC 10, 18 denotes a data bus for transferring data from the data bus 8 to the CPU 3, and 19 denotes a data bus for transferring data from the CPU 3 to the data bus 8.
215 denotes an address bus for transferring address data from the CPU 3 to the address bus 7, 22 denotes a read request signal which the CPU 3 outputs to the storage device 4 for instructing the storage device 4 to read data, 23 denotes a write request signal which the CPU 3 outputs to the storage device 4 for instructing the storage device 4 to write data, 24 denotes a write request signal which the DMA 9 outputs to the storage device 4 for instructing the storage device 4 to write data, 25 denotes a read request signal which the DMA 9 outputs to the storage device 4 for instructing the storage device 4 to read data, 26 denotes a data bus for transferring data from the data bus 8 to the storage device 4, 27 denotes a data bus for transferring data from the storage device 4 to the data bus 8, 28 denotes an address bus for transferring address data from the address bus 7 to the storage device 4, 29 denotes an address bus for transferring address data from the DMA 9 to the MAC 10, 45 denotes a data bus for receiving data for the MAC 10 to transfer the received data received from the network to the DMA 9, 31 denotes a data bus for transmission for the DMA 9 to transfer the transmission data to be transmitted to the network to the MAC 10, 32 denotes a read request signal which the DMA 9 outputs to the MAC 10 for reading the received data from the data buffer of the MAC 10, and 33 denotes a write request signal which the DMA 9 outputs to the MAC 10 for storing the transmission data to the data buffer of the MAC 10.
The processed address register 34 stores the final address of the storage area in the storage device 4, where data for which packet processing has completed is stored. 35 denotes a processed address update instruction which the CPU 3 outputs to the processed address register 34. The wait control unit 37 outputs the wait instruction 41 to the DMA 9 based on the transfer destination address data 38 when data is transferred from the DMA 9 to the storage device 4, and on the processed address data 39 stored in the processed address register 34. The operation of the wait control unit 37 will be described later.
The data bus 12 and the data bus 13, the address bus 14 and the address bus 15, the data bus 18 and the data bus 19, the data bus 26 and the data bus 27, and the data bus for receiving 45 and the data bus for transmission 31 may be constructed by a bi-directional bus respectively.
In this configuration, the data received by the PHY 11 is temporarily stored in the data buffer of the MAC 10. To transfer the received data temporarily stored in the data buffer to the storage device 4, the CPU 3 outputs the received data transfer request signal 16 and the first address data to be the data transfer destination in the storage device 4 to the DMA 9. At this time, the address data that the CPU 3 outputs is input to the DMA 9 via the address bus 215, address bus 7 and address bus 15. When the received data transfer request signal 16 and the address data are input, the DMA 9 starts transferring the received data, which is temporarily stored in the data buffer of the MAC 10, to the storage area of the storage device 4 indicated by the address data which was input from the data buffer of the MAC 10. At this time, the DMA 9 infinitely loops the transfer destination address in the storage device 4 within a predetermined area.
Now the function to infinitely loop the transfer destination address within a predetermined area by the DMA 9 will be described with reference to the drawings.
The transfer count setup register 900 stores the transfer count information to indicate the number of addresses for which data is transferred from the DMA 9 to the storage device 4 continuously.
When the received data transfer request signal 16 and address data are input from the CPU 3 to the DMA 9, the received data transfer request signal 16 is input to the control unit 908, and the address data is stored in the address buffer for storage device 904 via the address bus 15. When the received data transfer request signal 16 is input to the control unit 908, the control unit 908 outputs the read request signal 32 to the MAC 10, and outputs the address data to be the read destination of the data buffer of the MAC 10 to the address bus 29. The address data which is output to the address bus 29 is the address data stored in the address buffer for the MAC 905, and the address data stored in the address buffer for MAC 905 is sequentially updated by the control unit 908. By the read request signal 32 and the address data of the address bus 29, the received data stored in the data buffer of the MAC 10 is transferred to the DMA 9 via the data bus for receiving 45, and is stored in the received data buffer 906. At this time, the control unit 908 continuously outputs the read request signal 32 to the MAC 10, and continuously outputs the address data stored in the address buffer for MAC 905 to the address bus 29, so that data can be continuously transferred from the data buffer of the MAC 10 to the DMA 9.
The counter 901 counts the transfer count of the data which is input from the data bus for receiving 45. The count value 910 of the counter 901 is input to the comparator 902. The comparator 902 compares the transfer count information 909 which is input from the transfer count setup register 900 and the count value 910 which is input from the counter 901, and outputs the comparison result 911 to the adder 903 and the control unit 908. If the comparison result 911 which was input indicates that the count value 910 is the same or less than the transfer count information 909, the adder 903 increments the address data 912 which was read from the address buffer for storage device 904, and stores this in the address buffer for storage device 904 as the address data 913. If the comparison result 911 which was input indicates that the count value 910 is the same or less than the transfer count information 909, the control unit 908 continues the data transfer control, and if the comparison result 911 which was input indicates that the count value 910 is greater than the transfer count information 909, the control unit 908 ends the data transfer control. When the address buffer for storage device 904 becomes full, the control unit 908 outputs the address data stored in the address buffer for storage device 904 to the address bus 14, and sequentially outputs the data stored in the data buffer for receiving 906 to the data bus 12, and outputs the write request signal 204 to the storage device 4 and the counter for address initialization 915. The address data which is output to the address bus 14 is input to the storage device 4 via the address bus 7 and address bus 28, and the data which is output to the data bus 12 is input to the storage device 4 via the data bus 8 and data bus 26.
In this case, the data transfer from the DMA 9 to the storage device 4 is started when the address buffer for storage device 904 becomes full, but data transfer from the DMA 9 to the storage device 400 may be sequentially executed each time one address data is stored in the address buffer for storage device 904.
Now the function to infinitely loop the transfer destination address within a predetermined area when the DMA 9 transfers the data to the storage device 4 will be described.
The address initialization information register 914 stores address initialization information in advance, which indicates how many times, that is how many address data is transferred from the DMA 9 to the storage device 4 to initialize the transfer destination address.
The address data, which is input from the CPU 3 to the DMA 9, is also stored in the initialization address register 916 via the address bus 15. The write request signal 24, to be output for transferring data from the DMA 9 to the storage device 4, is also input to the counter for address initialization 915. The counter for address initialization 915 counts the input count of the write request signal 24, that is the data transfer count from the DMA 9 to the storage device 4. The control unit for address initialization 917 sequentially reads the address initialization information 918 and the count value 919 from the address initialization information register 914 and counter for address initialization 915, compares the values. The control unit for address initialization 917 outputs the transfer instruction 920 to the initialization address register 916 and transfer the initialization address data 921 to the address buffer for storage device 904 if the count value 919 is the same or more than the address initialization information 918. As a result, the initial address data is stored in the address buffer for storage device 904, and a function to infinitely loop the transfer destination address within a predetermined area when the DMA 9 transfers data to the storage device 4 is implemented.
The function to infinitely loop the transfer destination address within a predetermined area when the DMA 9 transfers data to the storage device 4 was described above, and now a function to prevent an overwrite of the data on a packet processing uncompleted area in the storage device 4 at the infinite loop of an address will be described including the operation of the wait control unit 37.
In the processed address register 34 in
The wait control unit 37 reads the processed address data 39 from the processed address register 34, calculates the difference of addresses between the processed address data 39 and the transfer destination address data 38, and outputs the wait instruction 41 to the DMA 9 if the calculated address difference value is a predetermined value or less.
In the DMA 9 shown in
The DMA 9 may have the configuration shown in
In
When the wait instruction 41 is input to the DMA 9 shown in
Here 36 denotes a wait control register, 40 denotes an address difference information stored in the wait control register 36, and 370 denotes a wait control unit. The wait control unit 370 outputs the wait instruction 41 to the DMA 9 based on the transfer destination address data 38 for transferring data from the DMA 9 to the storage device 4, the processed address data 39 stored in the processed address register 34, and the address difference information 40 stored in the wait control register 36.
The difference between the fourth embodiment of the packet processing device of the present invention and the third embodiment shown in
The wait control register 36 in
The wait control unit 370 reads the processed address data 39 and the address difference information 40 from the processed address register 34 and the wait control register 36, and calculates the address difference between the processed address data 39 and the transfer destination address data 38. Then the calculated address difference value and the address difference information 40 are compared, and if the calculated address difference value is the same as or less than the address difference information 40, the wait control unit 370 outputs the wait instruction 41 to the DMA 9.
When the wait instruction 41 is input from the wait control unit 370, the DMA 9 allows the data transfer processing to wait for a predetermined time. By this, an overwrite of the data to the packet processing uncompleted area in the storage device 4 can be prevented.
Here 3 denotes a CPU, 91 is a DMA and 43 denotes an interrupt request signal which the DMA 91 outputs to the CPU 3.
The difference between the fifth embodiment of the packet processing device of the present invention and the packet processing device of the fourth embodiment in
Now the DMA 91 will be described with reference to the drawings.
When the wait instruction 41 is input from the wait control unit 370 to the DMA 91 in
When the wait instruction 41 is received, the control unit 908 immediately allows the data transfer processing by the DMA 91 to wait for a predetermined time. On the other hand, when the wait instruction 41 is received, the interrupt control unit 926 immediately outputs the interrupt request signal 43, of which the priority level is always constant, to the CPU 3. By this, when the wait instruction 41 is issued to the DMA 91, not only data transfer from the DMA 91 to the storage device 4 temporarily waits, but the priority of the packet processing for tasks other than the packet processing by the CPU 3 is increased. As a result, a drop in throughput can be prevented.
The DMA 91 may have the configuration shown in
In
In the interrupt control register 923, interrupt control information, to indicate the count of the input of the wait instruction 41 at which the interrupt request is issued to the CPU 3, is stored in advance.
In
Here 370 denotes a wait control unit, 92 denotes a DMA, 42 denotes an address difference information which is output from the wait control unit 370 to the DMA 92.
The difference between the packet processing device of the sixth embodiment and the packet processing device of the fifth embodiment in
The wait control unit 370 in
In the interrupt level control register 924, the interrupt level control information, for setting the priority level of the interrupt according to the address difference information 930, is stored in advance. This interrupt level control information is information to correspond the priority level of the interrupt to the address difference information, such as the priority level of the interrupt is “1” if the address difference information is “A”, the priority level of the interrupt is “2” if the address difference information is “B”, and the priority level of the interrupt is “3” if the address difference information is “C”.
In the DMA 92 in
The DMA 92 may have the configuration shown in
Number | Date | Country | Kind |
---|---|---|---|
2003-381878 | Nov 2003 | JP | national |
2004-127471 | Apr 2004 | JP | national |