Invention content
An embodiment of the present invention provides a kind of method and device for testing memory, help effectively to find storage
Failure in device.
In a first aspect, a kind of method tested memory is provided, the method includes:
The first forwarding table that first memory space of memory stores is copied to the second memory space of the memory
To obtain the second forwarding table;
Network processing unit tests first memory space;
The forwarding table that second memory space stores is copied into first memory space to obtain third forwarding table;
The network processing unit accesses the third forwarding table.
In above-mentioned technical proposal, the network processing unit tests first memory space.Relative to existing skill
In art, the test to first memory space is realized by searching for first forwarding table in first memory space,
Technical solution provided in an embodiment of the present invention helps to find the failure of memory.
In the first possible realization method of first aspect, first memory space by memory store the
One forwarding table copies to the second memory space of the memory to obtain after the second forwarding table and described by described second
The forwarding table of memory space storage copies to first memory space so that before obtaining third forwarding table, the method is also wrapped
It includes:
The network processing unit accesses second forwarding table.
According to the possible realization method of the first of first aspect or first aspect, second in first aspect may
Realization method in, the network processing unit to first memory space carry out test includes:
Determine that the network processing unit receives the rate of message less than first threshold;
The network processing unit starts to test first memory space.
According to any possible realization side in the possible realization method of the above two of first aspect or first aspect
Formula, in the third possible realization method of first aspect, first turn of the first memory space storage by memory
Deliver the second memory space for copying to the memory includes to obtain the second forwarding table:
During first forwarding table is copied to second memory space, if first forwarding table is by more
Newly, then updated first forwarding table is copied in second memory space;And/or
The forwarding table by second memory space storage copies to first memory space and is turned with obtaining third
Deliver including:
It, will if the forwarding table is updated during the forwarding table is copied to first memory space
Updated forwarding table copies in first memory space.
According to any possible realization side in above-mentioned three kinds of possible realization methods of first aspect or first aspect
Formula, in the 4th kind of possible realization method of first aspect, the network processing unit surveys first memory space
Examination includes:
Determine that the network processing unit receives the rate of message more than second threshold;
First memory space is tested in the network processing unit stopping.
Second aspect, provides a kind of device tested memory, and described device includes:First copied cells,
Test cell, the second copied cells and the first access unit;
First copied cells, it is described for copying to the first forwarding table of the first memory space storage of memory
Second memory space of memory is to obtain the second forwarding table;
The test cell, for testing first memory space;
Second copied cells, the forwarding table for storing second memory space copy to first storage
Space is to obtain third forwarding table;
First access unit, for accessing the third forwarding table.
In the first possible realization method of second aspect, described device further includes:Second access unit is used for
The first forwarding table that first memory space of memory stores is copied to the memory by first copied cells
After second memory space is to obtain the second forwarding table, and in second copied cells second memory space is stored
Forwarding table copy to first memory space with before obtaining third forwarding table, access second forwarding table.
According to the possible realization method of the first of second aspect or second aspect, second in second aspect may
Realization method in, the test cell includes:
First determination unit, for determining that the network processing unit receives the rate of message less than first threshold;
First subelement tests first memory space for starting.
According to any possible realization side in the possible realization method of the above two of second aspect or second aspect
Formula, in the third possible realization method of second aspect,
First copied cells are specifically used for:First forwarding table is copied to the process of second memory space
In, if first forwarding table is updated, updated first forwarding table is copied in second memory space;
And/or
Second copied cells are specifically used for:During the forwarding table is copied to first memory space,
If the forwarding table is updated, updated forwarding table is copied in first memory space.
According to any possible realization side in above-mentioned three kinds of possible realization methods of second aspect or second aspect
Formula, in the 4th kind of possible realization method of second aspect, the test cell includes:
Second determination unit, for determining that the network processing unit receives the rate of message more than second threshold;
Second subelement tests first memory space for stopping.
The method and device provided in an embodiment of the present invention that memory is tested, by the first memory space of memory
First forwarding table of storage copies to the second memory space of the memory to obtain the second forwarding table;Network processing unit is to institute
The first memory space is stated to be tested;By second memory space store forwarding table copy to first memory space with
Obtain third forwarding table;The network processing unit accesses the third forwarding table, to help effectively to find in memory
Failure.
Specific implementation mode
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention is clearly retouched
It states, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.Based on the present invention
In embodiment, the every other implementation that those of ordinary skill in the art are obtained without creative efforts
Example, shall fall within the protection scope of the present invention.
Fig. 1 is a kind of schematic diagram by CPU on-line testing memories provided in an embodiment of the present invention.In Fig. 1, CPU prisons
The size that forwarding module in NP receives message rate is controlled, enables and closes the detection module inside NP, and execute forwarding table
The replication actions of list item, record test result etc..Include forwarding module and detection module inside NP, forwarding module is responsible for datagram
The forward process of text, forwarding module can be always enabled.That is, the forwarding module can be constantly in operation shape
State.Detection module is then enabled and is closed under the control of cpu;NP further includes memory, which is divided into polylith storage
Space is used for storing the list item of different forwarding tables, to cope with different business.The list item of each forwarding table is in addition to normally storing
Further include a corresponding backup space, which is also to mark off to come from memory, wherein normally other than space
Memory space be known as the first memory space, backup space is known as the second memory space.Under normal circumstances, the list item of forwarding table is
It is stored in the first memory space, without being stored in the second memory space.
In Fig. 1, in normal forwarding, i.e., when not starting memory on-line testing function, the detection module inside NP
It does not run, only forwarding module is run.CPU is to operate the first of forwarding table to deposit to issuing and refreshing for the list item of each forwarding table
Space is stored up, rather than operates the second memory space of forwarding table;Simultaneously when forwarding module forwarding service message, and pass through access
Forwarding table in first memory space carrys out the forwarding of finishing service message.
Fig. 2 is the flow chart for the method tested memory that the embodiment of the present invention one provides.The method is held
Row main body can be NP.As shown in Fig. 2, the method specifically includes:
The first forwarding table that first memory space of memory stores is copied to the second storage of the memory by S201
Space is to obtain the second forwarding table.
For example, the memory can be double data speed synchronous dynamic RAM (double
Data rate synchronous dynamic random access memory, DDR SDRAM).Second forwarding table
Content it is identical as the content of the first forwarding table.
For example, the executive agent of S201 can be CPU.For example, the CPU can be read in first memory space
The first forwarding table.Then, first forwarding table is write second memory space of the memory by the CPU.Institute
Stating CPU can be by peripheral parts interconnected (peripheral component interconnect, PCI) bus and the NP
Connection.The memory can be connect by Double Data Rate (double data rate, DDR) interface with the NP.
For example, the executive agent of S201 can be the memory.For example, the CPU can indicate the storage
Device is in the mode of direct memory access (direct memory access, DMA) by described the of first memory space
One forwarding table copies to second memory space.Specifically, the CPU can send to the memory and order.It is described
The start address of the start address and second memory space of first memory space is carried in order.The memory is received
To after the order, by direct memory access controller (direct memory access controller, DMAC) to
The CPU sends the request of take over bus control right.After the memory obtains the bus control unit, described first is deposited
The first forwarding table in storage space writes second memory space of the memory.
One of the schematic diagram for the CPU on-line testing memories that the embodiment of the present invention one shown in Figure 3 provides, with online
It tests for the first memory space of forwarding table A, the forwarding table A for being recorded in the first memory space is denoted as the first forwarding table.It lifts
For example, which can be action schedule (action table).The action schedule can be linear list (linear
table).The linear list can be port table (port table).Above-mentioned action schedule may include action, and the action can be with
It is to forward, abandon, being sent to CPU, modifying to message or counted to message.Before starting detection module,
CPU is the first memory space for operating forwarding table A to the action that the list item of forwarding table A executes, and cpu cycle property first monitors
The size of the rate of the reception message of forwarding module in NP, when receiving the size of rate of message less than first threshold, wherein
First threshold generally can be set as the 30% of interface physical bandwidth, and user is configured by corresponding order line on the router
When the state of memory on-line testing function is enabled, CPU thinks that the preparation before test can be started;Then CPU starts
Monitoring issued to forwarding table A in the first memory space, start to forwarding table A issue monitoring after, by the list item of forwarding table A
The second memory space is copied to from the first memory space, is stored as the second forwarding table, wherein the content of the second forwarding table and first
The content of forwarding table is identical.During above-mentioned duplication, if cpu monitor is updated to the first forwarding table, i.e., cpu monitor arrives
When the list item of first forwarding table is updated accordingly, then stop above-mentioned reproduction process, it again will more after delay a period of time
The first forwarding table after new copies in the second memory space.It is exemplified as, if the first forwarding table has 10 list items, first replicates 6
After a list item to the second memory space, cpu monitor has list item to be updated to the first forwarding table, then stops the process replicating, prolong
It slow 10 seconds and then attempts 10 list items of updated first forwarding table all copying to the second memory space again
In.
S202, network processing unit test first memory space.
For example, the executive agent of S202 can be the NP.
For example, the CPU can indicate that the NP tests first memory space.The network processes
Device can be tested first memory space by testing results program.The test program can pass through microcode reality
It is existing.For example, the NP may include multiple processors.At least one of the multiple processor processor can pass through operation
Microcode tests first forwarding table in first memory space.For example, the test program can correspond to one
Kind testing algorithm or a variety of testing algorithms.
In Fig. 3 provided in an embodiment of the present invention, NP can be realized by FPGA, can also be realized by ASIC.The NP and
Memory can be located in the same chip, can also be located in two chips.If the NP and the memory point
Wei Yu not be in two chips, the NP can be direct-connected with the memory.For example, the NP can by ddr interface with
The memory is direct-connected.Specifically, CPU periodically monitors the size of the rate of the reception message of forwarding module in NP, works as determination
When the rate of the reception message of forwarding module is less than first threshold in NP, the detection module in NP start to the first memory space into
Row test.The two of the schematic diagram for the CPU on-line testing memories that the embodiment of the present invention one shown in Figure 4 provides, are starting
After detection module, detection module executes many algorithms and is tested comprehensively the first memory space of forwarding table A, is exemplified as,
Detection module can execute March C, March LR, March SS, Prbs_DataAlign or Qiot scheduling algorithms to forwarding table A
The first memory space tested comprehensively.Since detection module is the hardware module inside NP, performance is very high, so detection mould
The readwrite bandwidth of block can reach the maximum value of band width in physical, when solving in the prior art with CPU on-line testing memories, by
It is that internal storage access is initiated by software in CPU, to cause the bandwidth pressure that CPU accesses NP memories big, can not achieve effectively
The problem of test.It should be noted that during above-mentioned test, the action that CPU executes the list item of forwarding table A is all behaviour
Make the second forwarding table in the second memory space, while the forwarding module in NP is by accessing the list item in the second forwarding table, from
And realize the forwarding of service message, specifically, at least one of multiple processors processor can be micro- by running in NP
Code, to access the second forwarding table.
It should be noted that when startup the first memory space of detection module pair is tested, the processing energy of NP can be influenced
Power illustrates that forwarding module receives the quantity of message so when forwarding module receives the rate of message more than second threshold in NP
Increasing, in order to not influence the processing capacity of NP, is needing to stop detection module.Specifically, it is forwarded when cpu cycle property monitors in NP
The size of the rate of the reception message of module, when determining that the rate of the reception message of forwarding module in NP is more than second threshold,
The first memory space is tested in detection module stopping in NP, wherein second threshold generally can be set as interface physical
The 50% of bandwidth;After stopping test process, the detection module in NP completes the test to the first memory space, and surveys
Test result is in the case that failure is not present in the first memory space, and the detection module in the NP sends first message to CPU, should
First message is used to indicate the first memory space and failure is not present;When test result be the first memory space there are failures the case where
Under, the detection module in the NP sends second message to CPU, which is used to indicate the first memory space, and there are failures;
When in the case that detection module in NP is without completing the test to the first memory space, detection module in the NP is to CPU
Third message is sent, which is used to indicate the test that do not complete to first memory space.It is exemplified as, is stopping
After test process, if not completing the test to the first memory space, i.e., only test is completed in the first memory space
The test of the part list item of first forwarding table, then CPU record the first forwarding table in the first memory space and do not test the letter of completion
Breath, does not record other any information, when restarting detection module the first memory space of test again, retests the first forwarding
The list item of table.
The forwarding table that second memory space stores is copied to first memory space and is turned with obtaining third by S203
It delivers.
For example, the executive agent of S203 can be the CPU.For example, the CPU can read the second storage sky
Between in the forwarding table.Then, the forwarding table is write first memory space of the memory by the CPU.Institute
The content for stating forwarding table is identical as the content of third forwarding table.
For example, the executive agent of S203 can be the memory.For example, the CPU can indicate the storage
The forwarding table of second memory space is copied to first memory space by device in a manner of DMA.Specifically, institute
Order can be sent to the memory by stating CPU.The start address of second memory space and described is carried in the order
The start address of first memory space.After the memory receives the order, take over bus is sent to the CPU by DMAC
The request of control.After the memory obtains the bus control unit, by the forwarding table in second memory space
Write first memory space of the memory.
Detection module in NP completes the test to the first memory space, and test result be the first memory space not
It deposits in the case of a fault, the detection module in the NP sends first message to CPU, which is used to indicate the first storage
Failure is not present in space.The schematic diagram for the CPU on-line testing memories that the embodiment of the present invention one shown in Figure 5 provides it
Three, CPU startup issue monitoring to the second forwarding table in the second memory space, and the forwarding table that the second memory space stores is answered
It makes to the first memory space to obtain third forwarding table.It should be noted that by the storage of the first memory space of memory
After first forwarding table copies to the second memory space of memory to obtain the second forwarding table, and by the second memory space
The forwarding table of storage copies to first memory space with before obtaining third forwarding table, if the second forwarding table is updated to
4th forwarding table, then above-mentioned forwarding table is the 4th forwarding table;If the second forwarding table is not updated, above-mentioned forwarding table is the
Two forwarding tables.The content of the forwarding table is identical as the content of third forwarding table.During above-mentioned duplication, if cpu monitor
It is updated to forwarding table, is i.e. when the list item that CPU monitors forwarding table is updated accordingly, then stops above-mentioned reproduction process,
Delay again copies to updated forwarding table in the first memory space after a period of time.It is exemplified as, if forwarding table has 10
A list item, after first replicating 6 list items to the first memory space, cpu monitor has list item to issue to forwarding table, then stops duplication
Process postpones 10 seconds and then attempts all to copy to 10 list items of updated forwarding table into the first storage sky again
Between in.
S204, the network processing unit access the third forwarding table.
For example, the executive agent of S204 can be the network processing unit.For example, the network processing unit receives
After message to be forwarded, the third forwarding table can be searched, to forward the message to be forwarded.Specifically, described
Network processing unit can search the third forwarding table according to the incoming interface for receiving the message to be forwarded.The network
Processor can also search the third forwarding table according to the heading of the message to be forwarded.
In Fig. 5 provided in an embodiment of the present invention, the first storage sky is copied in the forwarding table for storing the second memory space
Between to obtain third forwarding table after, forwarding module in NP is by accessing the list item in third forwarding table, to realize business
The forwarding of message can also be to realize the forwarding of service message by searching for third forwarding table.
It should be noted that completing the survey to the first memory space according to detection module of the method in S202 in NP
Examination, and test result is that the first memory space is deposited in the case of a fault, and the detection module in the NP sends second to CPU and disappears
Breath, which is used to indicate the first memory space, and there are failures.What the embodiment of the present invention one shown in Figure 6 provided
The four of the schematic diagram of CPU on-line testing memories, the detection module in NP completes the test to the first memory space, and surveys
Test result is that the first memory space is deposited in the case of a fault, and CPU does not copy back into the list item of forwarding table from the second memory space
First memory space, because the first memory space of forwarding table A has existed mistake and cannot be used continuously, CPU is to forwarding table A's
The action that list item executes all is the second forwarding table operated in the second memory space, while the forwarding module in NP passes through access the
List item in two forwarding tables, to realize the forwarding of service message, specifically, at least one of multiple processors are handled in NP
Device can be by running microcode, to access the second forwarding table.
Optionally, in method shown in Fig. 2,
The first forwarding table that first memory space by memory stores copies to the second storage of the memory
Space is to obtain after the second forwarding table and the forwarding table for storing second memory space copies to described first
With before obtaining third forwarding table, the method further includes memory space:
The network processing unit accesses second forwarding table.
For example, executive agent can be the network processing unit.For example, the network processing unit receive it is to be forwarded
Message after, second forwarding table can be searched, to forward the message to be forwarded.Specifically, at the network
Reason device can search second forwarding table according to the incoming interface for receiving the message to be forwarded.The network processing unit
Second forwarding table can also be searched according to the heading of the message to be forwarded.
Optionally, in above-mentioned technical proposal, the network processing unit carries out test to first memory space and includes:
Determine that the network processing unit receives the rate of message less than first threshold;
The network processing unit starts to test first memory space.
Optionally, in above-mentioned technical proposal,
The first forwarding table that first memory space by memory stores copies to the second storage of the memory
Space includes to obtain the second forwarding table:During first forwarding table is copied to second memory space, if
First forwarding table is updated, then is copied to updated first forwarding table in second memory space;And/or
The forwarding table by second memory space storage copies to first memory space and is turned with obtaining third
Deliver including:It, will if the forwarding table is updated during the forwarding table is copied to first memory space
Updated forwarding table copies in first memory space.
Optionally, in above-mentioned technical proposal, the network processing unit carries out test to first memory space and includes:
Determine that the network processing unit receives the rate of message more than second threshold;
First memory space is tested in the network processing unit stopping.
For example, the second threshold is more than the first threshold.
To sum up, the method provided in an embodiment of the present invention tested memory helps effectively to find in memory
Failure, and the detection module inside NP can test memory with the access pressure of big bandwidth, so as to improving business
Reliability.
Fig. 7 is the schematic device provided by Embodiment 2 of the present invention tested memory.Described device can be used
In execution method shown in Fig. 2.For example, described device can be NP.As shown in fig. 7, the test device packet of the present embodiment
It includes:First copied cells 701, test cell 702, the second copied cells 703 and the first access unit 704.
First copied cells 701, it is described for copying to the first forwarding table of the first memory space storage of memory
Second memory space of memory is to obtain the second forwarding table.
For example, the memory can be SDRAM.The content of second forwarding table and first forwarding table
Content is identical.
For example, the first copied cells 701 can be CPU.For example, the CPU can read first memory space
In the first forwarding table.Then, first forwarding table is write second memory space of the memory by the CPU.
The CPU can be connect by pci bus with the NP.The memory can be connect by ddr interface with the NP.
For example, the first copied cells 701 can be the memory.For example, the CPU can indicate the storage
First forwarding table of first memory space is copied to second memory space by device in a manner of DMA.It is specific next
It says, the CPU can send to the memory and order.Carried in the order first memory space start address and
The start address of second memory space.After the memory receives the order, taken over to CPU transmissions by DMAC
The request of bus control right.After the memory obtains the bus control unit, by first turn in first memory space
Deliver second memory space for writing the memory.
In normal forwarding, the state of memory on-line testing function is not start.Cpu cycle property monitors NP transfers
The size for sending out the rate of the reception message of module, when user is surveyed online by corresponding order line configuration memory on the router
When the state for trying function is enabled, CPU starts or stops detection module to memory according to the variation for the rate for receiving message
Test.
Test cell 702, for testing first memory space.
For example, test cell 702 can be the NP.
For example, the CPU can indicate that the NP tests first memory space.The network processes
Device can be tested first memory space by testing results program.The test program can pass through microcode reality
It is existing.For example, the NP may include multiple processors.At least one of the multiple processor processor can pass through operation
Microcode tests first forwarding table in first memory space.For example, the test program can correspond to one
Kind testing algorithm or a variety of testing algorithms.
Second copied cells 703, the forwarding table for storing second memory space copy to first storage
Space is to obtain third forwarding table.
For example, the second copied cells 703 can be the CPU.For example, the CPU can read second storage
The forwarding table in space.Then, the forwarding table is write first memory space of the memory by the CPU.
The content of the forwarding table is identical as the content of third forwarding table.
For example, the second copied cells 703 can be the memory.For example, the CPU can indicate the storage
The forwarding table of second memory space is copied to first memory space by device in a manner of DMA.Specifically, institute
Order can be sent to the memory by stating CPU.The start address of second memory space and described is carried in the order
The start address of first memory space.After the memory receives the order, take over bus is sent to the CPU by DMAC
The request of control.After the memory obtains the bus control unit, by the forwarding table in second memory space
Write first memory space of the memory.
First access unit 704, for accessing the third forwarding table.
For example, the first access unit 704 can be the network processing unit.For example, the network processing unit receives
To after message to be forwarded, the third forwarding table can be searched, to forward the message to be forwarded.Specifically, institute
The third forwarding table can be searched according to the incoming interface for receiving the message to be forwarded by stating network processing unit.The net
Network processor can also search the third forwarding table according to the heading of the message to be forwarded.
In an implementation mode, the first copied cells 701 are specifically used for:First forwarding table is copied to described
During two memory spaces, if first forwarding table is updated, updated first forwarding table is copied to described
In second memory space;And/or
Second copied cells 703 are specifically used for:During the forwarding table is copied to first memory space, such as
Forwarding table described in fruit is updated, then is copied to updated forwarding table in first memory space.
Under another realization method, test cell 702 includes:First determination unit 705 and the first subelement 706.
First determination unit 705, for determining that the network processing unit receives the rate of message less than first threshold.
First subelement 706 tests first memory space for starting.
Under other realization methods, test cell 702 includes:Second determination unit 707 and the second subelement 708.
Second determination unit 707, for determining that the network processing unit receives the rate of message more than second threshold;
Second subelement 708 tests first memory space for stopping.
For example, the second threshold is more than the first threshold.
Optionally, which further includes the second access unit 709, in first copied cells by memory
The first memory space storage the first forwarding table copy to the second memory space of the memory to obtain the second forwarding table
Later, and in second copied cells forwarding table that second memory space stores is copied into the first storage sky
Between with before obtaining third forwarding table, access second forwarding table.
The method that device provided in an embodiment of the present invention implants the offer of the embodiment of the present invention one, therefore, the present invention provide
Device specific work process, do not repeat again herein.
In the embodiment of the present invention two, the first copied cells 701 forward first that the first memory space of memory stores
Table copies to the second memory space of the memory to obtain the second forwarding table;Test cell 702 is empty to first storage
Between tested;The forwarding table that second memory space stores is copied to the first storage sky by the second copied cells 703
Between to obtain third forwarding table;First access unit 704 accesses the third forwarding table.It thereby assists in and effectively finds memory
In failure, and the detection module inside NP can test memory with the access pressure of big bandwidth, so as to improving industry
The reliability of business.
As it can be seen that the method and device provided in an embodiment of the present invention tested memory, helps effectively to find to deposit
Failure in reservoir, and the detection module inside NP can test memory with the access pressure of big bandwidth, so as to carrying
The reliability of high business.
It should be noted that being illustrated for testing NP memories in the embodiment of the present invention, but it is not limited to NP, it is right
In programmable FPGA or multi-core CPU, this programme equally may be used;It in addition, can also be for non-programmable ASIC
The function of this programme description is solidificated in ASIC.
Professional should further appreciate that, described in conjunction with the examples disclosed in the embodiments of the present disclosure
Unit and algorithm steps, can be realized with electronic hardware, computer software, or a combination of the two, hard in order to clearly demonstrate
The interchangeability of part and software generally describes each exemplary composition and step according to function in the above description.
These functions are implemented in hardware or software actually, depend on the specific application and design constraint of technical solution.
Professional technician can use different methods to achieve the described function each specific application, but this realization
It should not be considered as beyond the scope of the present invention.
The step of method described in conjunction with the examples disclosed in this document or algorithm, can use hardware, processor to execute
The combination of software module or the two is implemented.Software module can be placed in random access memory (RAM), memory, read-only storage
Device (ROM), electrically programmable ROM, electrically erasable ROM, register, hard disk, moveable magnetic disc, CD-ROM or technology neck
Any other form of non-volatile computer-readable medium (non-transitory computer well known in domain
Readable medium) in.
Above-described specific implementation mode has carried out further the purpose of the present invention, technical solution and advantageous effect
It is described in detail, it should be understood that the foregoing is merely the specific implementation mode of the present invention, is not intended to limit the present invention
Protection domain, all within the spirits and principles of the present invention, any modification, equivalent substitution, improvement and etc. done should all include
Within protection scope of the present invention.