| 1514 | } |
| 1515 | |
| 1516 | static uint64_t |
| 1517 | rack_get_bw(struct tcp_rack *rack) |
| 1518 | { |
| 1519 | if (rack->use_fixed_rate) { |
| 1520 | /* Return the fixed pacing rate */ |
| 1521 | return (rack_get_fixed_pacing_bw(rack)); |
| 1522 | } |
| 1523 | if (rack->r_ctl.gp_bw == 0) { |
| 1524 | /* |
| 1525 | * We have yet no b/w measurement, |
| 1526 | * if we have a user set initial bw |
| 1527 | * return it. If we don't have that and |
| 1528 | * we have an srtt, use the tcp IW (10) to |
| 1529 | * calculate a fictional b/w over the SRTT |
| 1530 | * which is more or less a guess. Note |
| 1531 | * we don't use our IW from rack on purpose |
| 1532 | * so if we have like IW=30, we are not |
| 1533 | * calculating a "huge" b/w. |
| 1534 | */ |
| 1535 | uint64_t bw, srtt; |
| 1536 | if (rack->r_ctl.init_rate) |
| 1537 | return (rack->r_ctl.init_rate); |
| 1538 | |
| 1539 | /* Has the user set a max peak rate? */ |
| 1540 | #ifdef NETFLIX_PEAKRATE |
| 1541 | if (rack->rc_tp->t_maxpeakrate) |
| 1542 | return (rack->rc_tp->t_maxpeakrate); |
| 1543 | #endif |
| 1544 | /* Ok lets come up with the IW guess, if we have a srtt */ |
| 1545 | if (rack->rc_tp->t_srtt == 0) { |
| 1546 | /* |
| 1547 | * Go with old pacing method |
| 1548 | * i.e. burst mitigation only. |
| 1549 | */ |
| 1550 | return (0); |
| 1551 | } |
| 1552 | /* Ok lets get the initial TCP win (not racks) */ |
| 1553 | bw = tcp_compute_initwnd(tcp_maxseg(rack->rc_tp)); |
| 1554 | srtt = ((uint64_t)TICKS_2_USEC(rack->rc_tp->t_srtt) >> TCP_RTT_SHIFT); |
| 1555 | bw *= (uint64_t)USECS_IN_SECOND; |
| 1556 | bw /= srtt; |
| 1557 | return (bw); |
| 1558 | } else { |
| 1559 | uint64_t bw; |
| 1560 | |
| 1561 | if(rack->r_ctl.num_avg >= RACK_REQ_AVG) { |
| 1562 | /* Averaging is done, we can return the value */ |
| 1563 | bw = rack->r_ctl.gp_bw; |
| 1564 | } else { |
| 1565 | /* Still doing initial average must calculate */ |
| 1566 | bw = rack->r_ctl.gp_bw / rack->r_ctl.num_avg; |
| 1567 | } |
| 1568 | #ifdef NETFLIX_PEAKRATE |
| 1569 | if ((rack->rc_tp->t_maxpeakrate) && |
| 1570 | (bw > rack->rc_tp->t_maxpeakrate)) { |
| 1571 | /* The user has set a peak rate to pace at |
| 1572 | * don't allow us to pace faster than that. |
| 1573 | */ |
no test coverage detected