aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/ccids/ccid3.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/dccp/ccids/ccid3.c')
-rw-r--r--net/dccp/ccids/ccid3.c38
1 files changed, 8 insertions, 30 deletions
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c
index 50dac01e48c5..8744590acb34 100644
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -590,12 +590,9 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk,
590 * would bring X down to s/t_mbi. That is why we return 590 * would bring X down to s/t_mbi. That is why we return
591 * X_recv according to rfc3448bis-06 for the moment. 591 * X_recv according to rfc3448bis-06 for the moment.
592 */ 592 */
593 u32 rtt = hcrx->rtt ? : DCCP_FALLBACK_RTT, s = hcrx->s; 593 u32 rtt = hcrx->rtt ? : DCCP_FALLBACK_RTT,
594 s = tfrc_rx_hist_packet_size(&hcrx->hist);
594 595
595 if (s == 0) {
596 DCCP_WARN("No sample for s, using fallback\n");
597 s = TCP_MIN_RCVMSS;
598 }
599 hcrx->x_recv = scaled_div32(s, 2 * rtt); 596 hcrx->x_recv = scaled_div32(s, 2 * rtt);
600 break; 597 break;
601 } 598 }
@@ -617,7 +614,7 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk,
617 if (delta <= 0) 614 if (delta <= 0)
618 DCCP_BUG("delta (%ld) <= 0", (long)delta); 615 DCCP_BUG("delta (%ld) <= 0", (long)delta);
619 else 616 else
620 hcrx->x_recv = scaled_div32(hcrx->bytes_recv, delta); 617 hcrx->x_recv = scaled_div32(hcrx->hist.bytes_recvd, delta);
621 break; 618 break;
622 default: 619 default:
623 return; 620 return;
@@ -628,7 +625,7 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk,
628 625
629 hcrx->tstamp_last_feedback = now; 626 hcrx->tstamp_last_feedback = now;
630 hcrx->last_counter = dccp_hdr(skb)->dccph_ccval; 627 hcrx->last_counter = dccp_hdr(skb)->dccph_ccval;
631 hcrx->bytes_recv = 0; 628 hcrx->hist.bytes_recvd = 0;
632 629
633 dp->dccps_hc_rx_insert_options = 1; 630 dp->dccps_hc_rx_insert_options = 1;
634 dccp_send_ack(sk); 631 dccp_send_ack(sk);
@@ -669,7 +666,8 @@ static int ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb)
669static u32 ccid3_first_li(struct sock *sk) 666static u32 ccid3_first_li(struct sock *sk)
670{ 667{
671 struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); 668 struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
672 u32 x_recv, p, delta; 669 u32 x_recv, p, delta,
670 s = tfrc_rx_hist_packet_size(&hcrx->hist);
673 u64 fval; 671 u64 fval;
674 672
675 /* 673 /*
@@ -686,7 +684,7 @@ static u32 ccid3_first_li(struct sock *sk)
686 } 684 }
687 685
688 delta = ktime_to_us(net_timedelta(hcrx->tstamp_last_feedback)); 686 delta = ktime_to_us(net_timedelta(hcrx->tstamp_last_feedback));
689 x_recv = scaled_div32(hcrx->bytes_recv, delta); 687 x_recv = scaled_div32(hcrx->hist.bytes_recvd, delta);
690 if (x_recv == 0) { /* would also trigger divide-by-zero */ 688 if (x_recv == 0) { /* would also trigger divide-by-zero */
691 DCCP_WARN("X_recv==0\n"); 689 DCCP_WARN("X_recv==0\n");
692 if (hcrx->x_recv == 0) { 690 if (hcrx->x_recv == 0) {
@@ -696,8 +694,7 @@ static u32 ccid3_first_li(struct sock *sk)
696 x_recv = hcrx->x_recv; 694 x_recv = hcrx->x_recv;
697 } 695 }
698 696
699 fval = scaled_div(hcrx->s, hcrx->rtt); 697 fval = scaled_div32(scaled_div(s, hcrx->rtt), x_recv);
700 fval = scaled_div32(fval, x_recv);
701 p = tfrc_calc_x_reverse_lookup(fval); 698 p = tfrc_calc_x_reverse_lookup(fval);
702 699
703 ccid3_pr_debug("%s(%p), receive rate=%u bytes/s, implied " 700 ccid3_pr_debug("%s(%p), receive rate=%u bytes/s, implied "
@@ -724,31 +721,12 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
724 721
725 if (unlikely(hcrx->state == TFRC_RSTATE_NO_DATA)) { 722 if (unlikely(hcrx->state == TFRC_RSTATE_NO_DATA)) {
726 if (is_data_packet) { 723 if (is_data_packet) {
727 const u32 payload = skb->len - dccp_hdr(skb)->dccph_doff * 4;
728 do_feedback = CCID3_FBACK_INITIAL; 724 do_feedback = CCID3_FBACK_INITIAL;
729 ccid3_hc_rx_set_state(sk, TFRC_RSTATE_DATA); 725 ccid3_hc_rx_set_state(sk, TFRC_RSTATE_DATA);
730 hcrx->s = payload;
731 /*
732 * Not necessary to update bytes_recv here,
733 * since X_recv = 0 for the first feedback packet (cf.
734 * RFC 3448, 6.3) -- gerrit
735 */
736 } 726 }
737 goto update_records; 727 goto update_records;
738 } 728 }
739 729
740 if (tfrc_rx_hist_duplicate(&hcrx->hist, skb))
741 return; /* done receiving */
742
743 if (is_data_packet) {
744 const u32 payload = skb->len - dccp_hdr(skb)->dccph_doff * 4;
745 /*
746 * Update moving-average of s and the sum of received payload bytes
747 */
748 hcrx->s = tfrc_ewma(hcrx->s, payload, 9);
749 hcrx->bytes_recv += payload;
750 }
751
752 if (tfrc_rx_hist_loss_pending(&hcrx->hist)) 730 if (tfrc_rx_hist_loss_pending(&hcrx->hist))
753 return; /* done receiving */ 731 return; /* done receiving */
754 732