aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/ccids/lib/packet_history.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/dccp/ccids/lib/packet_history.c')
-rw-r--r--net/dccp/ccids/lib/packet_history.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/net/dccp/ccids/lib/packet_history.c b/net/dccp/ccids/lib/packet_history.c
index 5c4ded1cf42..547ad098ea6 100644
--- a/net/dccp/ccids/lib/packet_history.c
+++ b/net/dccp/ccids/lib/packet_history.c
@@ -385,6 +385,36 @@ int tfrc_rx_handle_loss(struct tfrc_rx_hist *h,
385} 385}
386EXPORT_SYMBOL_GPL(tfrc_rx_handle_loss); 386EXPORT_SYMBOL_GPL(tfrc_rx_handle_loss);
387 387
388/* Compute the sending rate X_recv measured between feedback intervals */
389u32 tfrc_rx_hist_x_recv(struct tfrc_rx_hist *h, const u32 last_x_recv)
390{
391 u64 bytes = h->bytes_recvd, last_rtt = h->rtt_estimate;
392 s64 delta = ktime_to_us(net_timedelta(h->bytes_start));
393
394 WARN_ON(delta <= 0);
395 /*
396 * Ensure that the sampling interval for X_recv is at least one RTT,
397 * by extending the sampling interval backwards in time, over the last
398 * R_(m-1) seconds, as per rfc3448bis-06, 6.2.
399 * To reduce noise (e.g. when the RTT changes often), this is only
400 * done when delta is smaller than RTT/2.
401 */
402 if (last_x_recv > 0 && delta < last_rtt/2) {
403 tfrc_pr_debug("delta < RTT ==> %ld us < %u us\n",
404 (long)delta, (unsigned)last_rtt);
405
406 delta = (bytes ? delta : 0) + last_rtt;
407 bytes += div_u64((u64)last_x_recv * last_rtt, USEC_PER_SEC);
408 }
409
410 if (unlikely(bytes == 0)) {
411 DCCP_WARN("X_recv == 0, using old value of %u\n", last_x_recv);
412 return last_x_recv;
413 }
414 return scaled_div32(bytes, delta);
415}
416EXPORT_SYMBOL_GPL(tfrc_rx_hist_x_recv);
417
388void tfrc_rx_hist_purge(struct tfrc_rx_hist *h) 418void tfrc_rx_hist_purge(struct tfrc_rx_hist *h)
389{ 419{
390 int i; 420 int i;