Background technology
Data communication class chip will unavoidably be related to traffic management, and the core of traffic management is queue scheduling technology.
WFQ dispatching techniques are RR, are the best one kind of performance and a kind of comparatively ideal scheduling in the various dispatching algorithms such as WRR, DWRR
Algorithm, but implementation complexity is high, and the performance that reach higher is relatively difficult.
While the bandwidth of data communication class chip gradually steps up, scheduling mode is gradually to based on representing fixed word joint number
The development of mandate dispatch direction, the scheduling mode of mandate is basic similar with the scheduling mode of fixed length bag.It is mentioned herein also main
It is the WFQ dispatching algorithms based on fixed length bag or mandate.
A kind of WFQ dispatching algorithms are mentioned in the patent for being WO03084283A2 in international publication number, the following is the patent
Realization method:
Because the bandwidth allocation of the scheduling of fixed length bag or mandate is actually the distribution of dispatcher meeting, it is therefore desirable to be used tricks
Device is counted to calculate and control the distribution of dispatcher meeting.If the assignment accuracy minimum of bandwidth can reach 1/16, correspondingly need
Want the distribution for the counter controls dispatcher meeting that a count range is 0-15.In order to ensure that dispatcher can equably carry out
Distribution, can provide the corresponding dispatcher of each weighting levels, enable the flow of respective weights between equably
Every obtaining dispatcher meeting, it is specified that as follows:
For 1:The WFQ schedulers of 4K, the minimal weight that can be set be 1/4096, it is necessary to bit number be 12 bits,
Each corresponds to 1/2,1/4,1/8 respectively ... 1/4096, and being that each weight ratio is special sets 1 scheduling chained list, and scheduling chained list is by treating
The flow compositions of dispatcher meeting are provided, totally 12 scheduling chained lists;One 12 digit counter, 12 scheduling chained lists and counter are set
Correspondence it is as shown in table 1:
Table 1
Counter cnt |
Dispatch chained list |
Respective weights |
000000000000 |
It is not used |
|
xxxxxxxxxxx1 |
Q(0) |
1/2 |
xxxxxxxxxx10 |
Q(1) |
1/4 |
xxxxxxxxx100 |
Q(2) |
1/8 |
xxxxxxxx1000 |
Q(3) |
1/16 |
xxxxxxx10000 |
Q(4) |
1/32 |
xxxxxx100000 |
Q(5) |
1/64 |
xxxxx1000000 |
Q(6) |
1/128 |
xxxx10000000 |
Q(7) |
1/256 |
xxx100000000 |
Q(8) |
1/512 |
xx1000000000 |
Q(9) |
1/1024 |
x10000000000 |
Q(10) |
1/2048 |
100000000000 |
Q(11) |
1/4096 |
Chained list Q is dispatched as can be seen from Table 1(0)The counter moment of half is occupied, represents 1/2 weight, Q(1)
It occupies for 1/4 counter moment, represents 1/4 weight, and so on.For ease of citing, with 1:The WFQ schedulers of 16 precision
Exemplified by, counter count range mutually should be 0-15, scheduling chained list Q(0)Dispatcher can correspond to count the moment be xxx1, Q(1)It is right
That answer is xx10, Q(2)Corresponding is x100, Q(3)Corresponding is 1000.Such as Fig. 1, if the weight of a flow only there are one
Weight position, then the flow can only be present in the weight position it is corresponding one scheduling chained list in, the weight of a flow is if there is more
A weight position, then the flow should be moved at the different counter moment it is each scheduling chained list in, it is each scheduling chained list in
The dispatcher meeting of respective weights can be obtained, its weight can will be met by obtaining total dispatcher.
As shown in Figure 1, the horizontal line in Fig. 1 represents dispatcher meeting, by above correspondence, each scheduling chained list all obtains
The dispatcher meeting of corresponding proportion was obtained, the flow in scheduling chained list also just obtains the dispatcher meeting of corresponding proportion.It is multiple
Flow may have identical weight bit simultaneously, and if WFQ schedulers have 2 flow, the weight of flow_0 is 1/2+1/
16 can be expressed as " 1001 ", and the weight of flow_1 can be expressed as " 1010 " for 1/2+1/8(It should be noted that for not
The characteristics of dispatcher meeting can be wasted, the weight of WFQ is opposite weight, and nisi weight, dispatcher can be in all connections
It is allocated between the flow of the scheduler, the ratio of distribution is the weight relative value of each flow, so the power of each flow
The sum of weight may be greater than 1)Then flow_0 and flow_1 has 1/2 weight, is required for being lined up in Q0, then exists
The same counting moment will have 2 flow to wait dispatcher meeting, i.e., to provide 2 dispatcher meetings, counter at the counting moment
It could add up.As shown in Fig. 2, solid line represents flow_0 scheduling instances in Fig. 2, dotted line represents flow_1 scheduling instances, due to
Weights of the flow_0 and flow_1 without 1/4 so Q1 is sky, only has flow_1 in Q2, there was only flow_0 in Q3, and
Existing flow_0 has flow_1 again in Q0, therefore 2 dispatcher meetings of granting are needed at the counter moment of Q0, it is therefore desirable to
Flow_0 and flow_1 are lined up in Q0, and if there is n flow has 1/2 weight, then Q0 is made of n flow, because
This needs to be managed this n flow in scheduling chained list by way of chained list.
One scheduling chained list can correspond to multiple counter moment, and the flow in a scheduling chained list is divided into two parts,
A part be should be issued at the current count moment dispatcher can flow, another part is etc. to stay in next counting moment quilt
Provide dispatcher can flow, therefore scheduling chained list is divided into movable chained list and inactive chained list, in movable chained list be exactly ought
The preceding moment should be issued dispatcher can flow, in inactive chained list is exactly to be issued dispatcher meeting at next counting moment
Flow.Chained list is in series by the Token for representing flow.One and only one Token of each flow, Token, which are included, to be directed toward
The pointer of next Token, when taking turns to some scheduling chained list service, the inactive chained list of the scheduling chained list becomes activity chain
Table, the owner pointer of scheduling chained list from movable chained list obtain No. flow that first Token is represented, dispatcher can be issued to this
Then flow calculates the counter that the flow should be serviced next time according to the weighted value of present counter value and the flow
Moment, and determine which scheduling chained list the Token of the flow should be moved to according to the counter moment, then should
Token is moved to this inactive chained list afterbody of new scheduling chained list, while updates the inactive chained list protocercal tail portion of the scheduling chained list
The pointer of Token, as shown in Figure 3.
The Token of a flow is represented to move between each scheduling chained list, and counter moment can will be corresponding to it
Scheduling chained list activity chained list in all Token all service one time, counted after the business of the movable chained list bedding and clothing of the scheduling chained list
The value of number device just adds up(1 may be added, it is also possible to add 2 etc.), therefore counted at one in Xun Huan, high weight dispatches chained list
Due to correspondence more counter moment, chained list can be dispatched than low weight and more serviced, Token, which often enters, once dispatches chain
Table can finally be issued a dispatcher meeting, and the corresponding flow weights of Token are higher, will be more moved to Gao Quan
Queue again so as to obtain more dispatcher meetings, realizes the distribution of bandwidth ratio.
Scheduling chained list is linked by Token, but the actual only needs of scheduling chained list stored in the scheduler preserve head and the tail
Pointer, and each Token is put on each flow, as shown in figure 4, therefore no matter scheduling chained list have how long, be stored in
Scheduling chained list on scheduler all only has head and the tail pointer.Also mean that scheduling chained list can be with endless, scheduler actually can be with
Connect unlimited port.The movement of Token only needs the tail pointer of the purpose that will be moved to scheduling chained list to be directed toward the Token,
As shown in Figure 4.
In WFQ schedulers, the scheduling chained list only currently serviced has movable chained list and inactive chained list simultaneously,
He only has inactive chained list by not serviced scheduling chained list, the flow bedding and clothing in the movable chained list of the scheduling chained list currently serviced
After being engaged in, counter adds up, and next scheduling chained list serviced, selected scheduling chained list are picked out according to the value of counter
Inactive chained list is switched into movable chained list, the empty chain table originally put in activity chain epitope becomes inactive chained list, new afterwards to turn
The Token for moving on to the scheduling chained list will be placed in the afterbody of inactive chained list, as shown in Figure 5.
Token moving algorithms:
The Token for representing a flow is moved between each scheduling chained list, so as to obtain the dispatcher meeting of corresponding proportion, when
Token is serviced then, and the flow corresponding to it will be issued a dispatcher meeting, and then scheduler is according to the WFQ of the flow
Weight calculation goes out the counter moment that should be in by service flow next times, and finds corresponding tune according to the counter moment
Chained list is spent, which is put into the inactive chained list afterbody of the scheduling chained list.
, it is necessary to 4 digit counters, all count values and scheduling chained list by taking minimum precision is 1/16 WFQ schedulers as an example
Correspondence it is as shown in table 2.
Table 2
Count value |
Dispatch chained list |
0000 |
It is not used |
0001 |
Q(0) |
0010 |
Q(1) |
0011 |
Q(0) |
0100 |
Q(2) |
0101 |
Q(0) |
0110 |
Q(1) |
0111 |
Q(0) |
1000 |
Q(3) |
1001 |
Q(0) |
1010 |
Q(1) |
1011 |
Q(0) |
1100 |
Q(2) |
1101 |
Q(0) |
1110 |
Q(1) |
1111 |
Q(0) |
From Table 2, it can be seen that the Q (0) of weight 1/2 in count value at intervals of 2, the Q (1) of weight 1/4 is being counted
In value at intervals of 4, and so on, and the counter moment occupied by the scheduling chained list of low level-one weight be always located in it is high by one
The centre position at the contiguous counter moment occupied by grade weight scheduling chained list, according to this feature, can obtain following algorithm
To calculate the next counter positions of Token:
1:Find out the WFQ weight weight limits position of the corresponding flow of the Token:
j=N-1-max{k,for all K’s where Wk=1};
Weight as flow includes is expressed as " 0101 " for 1/4+1/16, then j=1, as the weight of flow is expressed as 1/2
" 1000 ", then j=0.
2:The step value that counter adds up is obtained according to weight limit position:
I=0001<< j,
When i.e. weight limit is 1/2, step value 1, when weight limit is 1/4, step value 2, weight limit 1/8
When, step value 4, and so on.
3:Nonce counter is worth to new Counter Value plus stepping:
D=(Scurrent+I) mod (2N),
Scurrent is current count value, and I is step value, and N is counter bits number, if counter occurs to overflow after adding up
Go out then remainder.
4:Find out the minimum non-zero position of D:
P=min (t, for all T ' s where Dt=1),
I.e. if D=xxx1, p=0, if D=xx10, p=1, and so on.If the weighted value of the flow corresponding to p
Wp is 1, then Token is put into Q (p), if the weighted value Wp of the flow corresponding to p is 0, Token is put into Q (j)
In.
This algorithm is simply understood that:Since the counter moment residing for all low weight scheduling chained lists is inevitable
In highest weighting(The effective weight of highest of one flow)The centre position at chained list corresponding counter moment is dispatched, so only
It needs to add up according to the step value of highest weighting, if the corresponding scheduling chained list of the count value after cumulative meets the flow's
Weight, then show the counter moment need provide dispatcher meeting, otherwise the counter moment need not provide dispatcher meeting, that
The counter moment nearest from this counter moment is exactly the counter moment corresponding to highest weighting scheduling chained list.
By taking weight 0101 as an example, as shown in table 3 at the time of which should be issued dispatcher meeting
Table 3
Count value |
Whether dispatcher meeting should be provided |
Corresponding scheduling chained list |
0000 |
|
|
0001 |
|
|
0010 |
It is |
Q(1) |
0011 |
|
|
0100 |
|
|
0101 |
|
|
0110 |
It is |
Q(1) |
0111 |
|
|
1000 |
It is |
Q(3) |
1001 |
|
|
1010 |
It is |
Q(1) |
1011 |
|
|
1100 |
|
|
1101 |
|
|
1110 |
It is |
Q(1) |
1111 |
|
|
Flow is serviced when counter is 0010, it is now desired to, can from table 3 at the time of determining that it is serviced next time
To find out being at 0110 moment.J=1 is obtained when being expressed as " 0101 " according to weight, obtains step value I=0001<<1 is 2,
So it is 0 that the least significant non-zero position p of new count value D=0100, D, which is weight Wp1/8 corresponding to 2, p, so can only should
Token is put into the corresponding scheduling chained list Q (1) of highest weighting 1/4, and Q (1) will provide the flow when counter is equal to 0110
Dispatcher meeting.
Flow is issued dispatcher meeting when counter counts are to 0110, is then similarly calculated, due to highest weighting
It is always 1/4, so step value is also 2 always, obtains the least significant non-zero position p of new count value D=1000, D corresponding to 3, p
Weight Wp1/16 for 1, therefore 1000 this moment should be serviced, and 1000 to count moment corresponding scheduling chained list be Q
(3), therefore by the Token it is put into Q (3), which will be serviced when counter reaches 1000.The class according to this of calculating below
It pushes away.
Token adds in scheduler algorithms:
It, it is necessary to will when queue becomes the token bucket of non-empty or the reshaper corresponding to it from space-variant into non-empty from dummy status
Its corresponding Token is put into scheduling chained list, the algorithm of addition Token to scheduling chained list and the complete phase of algorithm of mobile Token
Together, be all to be calculated according to the value of nonce counter and the weighted value of queue, determine it should scheduling chained list.
Counter accumulation algorithm:
After the activity queue of current scheduling chained list is serviced and is finished, counter added up to obtain one it is new
Count value, next scheduling chained list is serviced according to this new count value.
1:One weight limit scheduling chained list of selection in all non-emptys dispatch chained list and current scheduling chained list;
2:Step value according to the weight limit scheduling chained list selected carries out the cumulative of count value and (is calculated with reference to Token movements
The step 2) of method.
3:If the count value after cumulative can be dispatched with non-empty, chained list is corresponding, and the count value after adding up is New count
Value.It is corresponding that if the count value after cumulative could not dispatch chained list with non-empty, the corresponding scheduling chained list of count value after cumulative
Weight limit scheduling chained list is selected between non-empty queue, repeats step 1 and 2, until finding a new count value and non-
Empty queue corresponds to, shown in Fig. 6.
Fig. 6 current count values are 1, and Q0 is sky after Q0 has been serviced, and other non-empty queues only have Q11, and
The corresponding count values of Q11 should be 2048, and in this example, first time iteration count value jumps to Q1, but Q1 is sky, and using Q1 as base
Plinth, second of iteration jump to Q2, have so jumped to Q11 by 11 iteration.
A count value can finally be found certainly using this iterative manner and correspond to non-empty queue, but the iteration time needed
Number is uncertain, at most needs 11 iteration, can cause the overlong time of scheduling.
The content of the invention
The technical problem to be solved in the present invention is to provide a kind of fixed length bag Weighted Fair Queuing dispatching method and devices, overcome
The problem of counter accumulation algorithm iterations is excessive.
In order to solve the above technical problem, the present invention provides a kind of fixed length bag Weighted Fair Queuing dispatching method, including:
After the task scheduling for completing scheduling chained list is inscribed in the current count of counter, calculate be more than in each non-empty scheduling chained list respectively
The to be dispatched count value nearest apart from current count value, the count value to be dispatched that will be calculated on current count moment direction
A middle conduct next count value nearest apart from the current count value.
Further, the above method can also have the characteristics that:
It calculates to be more than on current count moment direction in each non-empty scheduling chained list and treat apart from current count value is nearest
The method of scheduling count value specifically includes:
It determines that X low order of the corresponding standard count value of the non-empty scheduling chained list is known as BV, determines current count
X low order of value is known as CV;
When BV is more than CV, using X low order forms in the Y of current count value high invalid bits and the BV value as
Be more than in this non-empty scheduling chained list the current count moment described in distance on the current count value direction it is nearest treat that scheduling counts
Value;When BV is less than or equal to CV, lowest order in the Y of current count value high invalid bits is added into the Y after 1 high invalid bits and described
In BV the value of X low order composition dispatched as this non-empty be more than in chained list on the current count value direction described in distance when
It is preceding to count the count value to be dispatched of moment recently.
Further, the above method can also have the characteristics that:
The X with it is described Y's and for standard count value total bit.
Further, the above method can also have the characteristics that:
When BV is less than or equal to CV, after lowest order adds 1 in the Y of current count value high invalid bits, current count value
Digit adds 1, wherein high invalid bit number is Y+1.
Further, the above method can also have the characteristics that:
The low order number for the corresponding standard count value of scheduling chained list that weight is 1/2 is 1, except this 1 low order
Outside position be high invalid bit;
The low order number for the corresponding standard count value of scheduling chained list that weight is 1/4 is 2, except this 2 low orders
Outside position be high invalid bit;
And so on;
The low order number for the corresponding standard count value of scheduling chained list that weight is 1/2048 is 11, low is had except this 11
It is high invalid bit to imitate the position outside position.
In order to solve the above-mentioned technical problem, the present invention also provides a kind of fixed length bag Weighted Fair Queuing dispatching device, institutes
Stating device includes:Count value management module, computing module;
The computing module is worked as calculating in each non-empty scheduling chained list more than distance on current count moment direction
The nearest count value to be dispatched of preceding count value;
The count value management module, for inscribing the task scheduling for completing scheduling chained list in the current count of counter
Afterwards, the computing module is triggered, current count value described in distance is most in the count value to be dispatched that the computing module is calculated
A near next count value of conduct.
Further, above device can also have the characteristics that:
The computing module, X specifically for determining the corresponding standard count value of the non-empty scheduling chained list are low effective
Position is known as BV, determines that X low order of current count value is known as CV;It, will be Y of current count value high invalid when BV is more than CV
In position and the BV value of X low order composition as this non-empty dispatch in chained list more than on the current count value direction away from
The to be dispatched count value nearest from the current count moment;It, will be Y of current count value high invalid when BV is less than or equal to CV
Lowest order adds the value of X low order composition in the Y after 1 high invalid bits and the BV to be dispatched as this non-empty in chained list in position
The to be dispatched count value nearest more than the current count moment described in distance on the current count value direction.
Further, above device can also have the characteristics that:
The X with it is described Y's and for standard count value total bit.
Further, above device can also have the characteristics that:
The computing module is additionally operable to when BV is less than or equal to CV, will be minimum in the Y of current count value high invalid bits
Behind position plus 1, the digit of current count value is added 1, wherein high invalid bit number is Y+1.
Further, above device can also have the characteristics that:
The low order number for the corresponding standard count value of scheduling chained list that weight is 1/2 is 1, except this 1 low order
Outside position be high invalid bit;
The low order number for the corresponding standard count value of scheduling chained list that weight is 1/4 is 2, except this 2 low orders
Outside position be high invalid bit;
And so on;
The low order number for the corresponding standard count value of scheduling chained list that weight is 1/2048 is 11, low is had except this 11
It is high invalid bit to imitate the position outside position.
This programme employs a kind of lowest difference away from the counter accumulation algorithm in the former patent of algorithm replacement, for patent
The defects of WO03084283A2 Counter accumulation algorithms, overcomes the problems, such as that counter accumulation algorithm iterations is excessive, makes meter
Number device accumulation algorithm adapts to the scheduling requirement of high speed.
Specific embodiment
As shown in fig. 7, fixed length bag Weighted Fair Queuing dispatching method includes in this programme:In the current count of counter
After inscribing the task scheduling for completing scheduling chained list, calculate be more than in each non-empty scheduling chained list on the current count value direction respectively
The to be dispatched count value nearest apart from the current count moment, will currently count described in distance in the count value to be dispatched calculated
A nearest next count value of conduct of numerical value.
Wherein, calculate in each non-empty scheduling chained list and be more than the current count moment described in distance on the current count value direction
The method of nearest count value to be dispatched specifically includes:Determine that the X of the corresponding standard count value of the non-empty scheduling chained list is a low
Significance bit is known as BV, determines that X low order of current count value is known as CV;It is high by Y of current count value when BV is more than CV
The value of X low order composition is dispatched as this non-empty in invalid bit and the BV is more than the current count value direction in chained list
On apart from the current count moment nearest count value to be dispatched;It is high by Y of current count value when BV is less than or equal to CV
Lowest order adds the value of X low order composition in the Y after 1 high invalid bits and the BV to dispatch chain as this non-empty in invalid bit
It is more than the count value to be dispatched of current count moment described in distance recently on the current count value direction in table.
The X with it is described Y's and for standard count value total bit.
Wherein, when BV is less than or equal to CV, after lowest order adds 1 in the Y of current count value high invalid bits, current count
The digit of value adds 1, wherein high invalid bit number is Y+1.
As shown in table 1, the low order number for the corresponding standard count value of scheduling chained list that weight is 1/2 is 1, except this 1
Position is high invalid bit outside a low order;The low order number for the corresponding standard count value of scheduling chained list that weight is 1/4
For 2, the position in addition to this 2 low orders is high invalid bit;And so on;Weight is the 1/2048 corresponding mark of scheduling chained list
The low order number of quasi- count value is 11, and the position in addition to this 11 low orders is high invalid bit.
By taking Fig. 8 as an example, current count value 5, Q2 and Q3 dispatch chained list for non-empty.
Calculate count value to be dispatched nearest apart from current count value on more than current count moment direction in Q2:It determines
The corresponding standard count values of Q2(XXXXXXXXX100)3 low order BV for 100, present counter value 5=
000000000101,3 low order CV is 101, and the invalid bit CE 9 high of present counter value 5 is 000000000, BV
Less than CV, therefore the corresponding S of Q2nextFor { CE+1, BV }={ 000000001100 }, i.e., 12.
Calculate count value to be dispatched nearest apart from current count value on more than current count moment direction in Q3:It determines
The corresponding standard count values of Q3(XXXXXXXX1000)4 low order BV for 1000, present counter value 5=
000000000101,4 low order CV is 0101, and the invalid bit CE 8 high of present counter value 5 is 000000000, BV
More than CV, therefore the corresponding S of Q3nextFor { CE, BV }={ 000000001000 }, i.e., 8.
So new count value should select 8 as new count value.
This algorithm needs to carry out plus and minus calculation and what comparison operation, and combinational logic scale may be larger, but during calculating
Between it is fixed, it should can be completed within 2,3 clock cycle.Therefore lowest difference away from algorithm be really can be practical algorithm,
It is the key improvements point of the present invention.
It should be noted that it is that lowest difference can also be applied to away from algorithm on Token moving algorithms, if implementation complexity is small
In Token moving algorithms noted earlier, then can be substituted.
Fixed length bag Weighted Fair Queuing dispatching device in this case includes:Count value management module, computing module.
The computing module is worked as calculating in each non-empty scheduling chained list more than distance on current count moment direction
The nearest count value to be dispatched of preceding count value;
The count value management module, for inscribing the task scheduling for completing scheduling chained list in the current count of counter
Afterwards, the computing module is triggered, current count value described in distance is most in the count value to be dispatched that the computing module is calculated
A near next count value of conduct.
The computing module, X specifically for determining the corresponding standard count value of the non-empty scheduling chained list are low effective
Position is known as BV, determines that X low order of current count value is known as CV;It, will be Y of current count value high invalid when BV is more than CV
In position and the BV value of X low order composition as this non-empty dispatch in chained list more than on the current count value direction away from
The to be dispatched count value nearest from the current count moment;It, will be Y of current count value high invalid when BV is less than or equal to CV
Lowest order adds the value of X low order composition in the Y after 1 high invalid bits and the BV to be dispatched as this non-empty in chained list in position
The to be dispatched count value nearest more than the current count moment described in distance on the current count value direction.
The X with it is described Y's and for standard count value total bit.
The computing module is additionally operable to when BV is less than or equal to CV, will be minimum in the Y of current count value high invalid bits
Behind position plus 1, the digit of current count value is added 1, wherein high invalid bit number is Y+1.
It should be noted that in the case where there is no conflict, the feature in embodiment and embodiment in the application can phase
Mutually any combination.
Certainly, the present invention can also have other various embodiments, without deviating from the spirit and substance of the present invention, ripe
Various corresponding changes and deformation, but these corresponding changes and deformation can be made according to the present invention by knowing those skilled in the art
The protection domain of appended claims of the invention should all be belonged to.
One of ordinary skill in the art will appreciate that all or part of step in the above method can be instructed by program
Related hardware is completed, and described program can be stored in computer readable storage medium, such as read-only memory, disk or CD
Deng.Optionally, all or part of step of above-described embodiment can also be realized using one or more integrated circuits.Accordingly
Ground, the form that hardware may be employed in each module/unit in above-described embodiment are realized, can also use the shape of software function module
Formula is realized.The present invention is not limited to the combinations of the hardware and software of any particular form.