Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 42061
b: refs/heads/master
c: 2bbf29a
h: refs/heads/master
i:
  42059: 1085d3a
v: v3
  • Loading branch information
Gerrit Renker authored and Arnaldo Carvalho de Melo committed Dec 3, 2006
1 parent 8b0dc77 commit fba94b3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 44158306d756c88272c8faf243ca68897498e219
refs/heads/master: 2bbf29acd8f7adcf161de7e5d891b4095687a59f
38 changes: 24 additions & 14 deletions trunk/net/dccp/ccids/lib/tfrc_equation.c
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,21 @@ static const u32 tfrc_calc_x_lookup[TFRC_CALC_X_ARRSIZE][2] = {
{ 243315981, 271305 }
};

/* return largest index i such that fval <= lookup[i][small] */
static inline u32 tfrc_binsearch(u32 fval, u8 small)
{
u32 try, low = 0, high = TFRC_CALC_X_ARRSIZE - 1;

while (low < high) {
try = (low + high) / 2;
if (fval <= tfrc_calc_x_lookup[try][small])
high = try;
else
low = try + 1;
}
return high;
}

/**
* tfrc_calc_x - Calculate the send rate as per section 3.1 of RFC3448
*
Expand Down Expand Up @@ -656,8 +671,7 @@ EXPORT_SYMBOL_GPL(tfrc_calc_x);
*/
u32 tfrc_calc_x_reverse_lookup(u32 fvalue)
{
int ctr = 0;
int small;
int index;

if (fvalue == 0) /* f(p) = 0 whenever p = 0 */
return 0;
Expand All @@ -672,18 +686,14 @@ u32 tfrc_calc_x_reverse_lookup(u32 fvalue)
return 1000000;
}

if (fvalue <= tfrc_calc_x_lookup[TFRC_CALC_X_ARRSIZE - 1][1])
small = 1;
else
small = 0;

while (fvalue > tfrc_calc_x_lookup[ctr][small])
ctr++;

if (small)
return (ctr + 1) * TFRC_CALC_X_SPLIT / TFRC_CALC_X_ARRSIZE;
else
return (ctr + 1) * 1000000 / TFRC_CALC_X_ARRSIZE;
if (fvalue <= tfrc_calc_x_lookup[TFRC_CALC_X_ARRSIZE - 1][1]) {
index = tfrc_binsearch(fvalue, 1);
return (index + 1) * TFRC_CALC_X_SPLIT / TFRC_CALC_X_ARRSIZE;
}

/* else ... it must be in the coarse-grained column */
index = tfrc_binsearch(fvalue, 0);
return (index + 1) * 1000000 / TFRC_CALC_X_ARRSIZE;
}

EXPORT_SYMBOL_GPL(tfrc_calc_x_reverse_lookup);

0 comments on commit fba94b3

Please sign in to comment.