]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/dccp/ccids/ccid3.c
This reverts "Merge branch 'dccp' of git://eden-feed.erg.abdn.ac.uk/dccp_exp"
[linux-2.6-omap-h63xx.git] / net / dccp / ccids / ccid3.c
index cd61dea2eea16bd1511f9c42e5648fc069ea4184..3b8bd7ca6761f2bded8aaae9bf21efa4cc8b2fac 100644 (file)
@@ -159,8 +159,8 @@ static void ccid3_hc_tx_update_x(struct sock *sk, ktime_t *stamp)
        } else if (ktime_us_delta(now, hctx->ccid3hctx_t_ld)
                                - (s64)hctx->ccid3hctx_rtt >= 0) {
 
-               hctx->ccid3hctx_x =
-                       max(min(2 * hctx->ccid3hctx_x, min_rate),
+               hctx->ccid3hctx_x = min(2 * hctx->ccid3hctx_x, min_rate);
+               hctx->ccid3hctx_x = max(hctx->ccid3hctx_x,
                            scaled_div(((__u64)hctx->ccid3hctx_s) << 6,
                                       hctx->ccid3hctx_rtt));
                hctx->ccid3hctx_t_ld = now;
@@ -193,22 +193,17 @@ static inline void ccid3_hc_tx_update_s(struct ccid3_hc_tx_sock *hctx, int len)
 
 /*
  *     Update Window Counter using the algorithm from [RFC 4342, 8.1].
- *     The algorithm is not applicable if RTT < 4 microseconds.
+ *     As elsewhere, RTT > 0 is assumed by using dccp_sample_rtt().
  */
 static inline void ccid3_hc_tx_update_win_count(struct ccid3_hc_tx_sock *hctx,
                                                ktime_t now)
 {
-       u32 quarter_rtts;
-
-       if (unlikely(hctx->ccid3hctx_rtt < 4))  /* avoid divide-by-zero */
-               return;
-
-       quarter_rtts = ktime_us_delta(now, hctx->ccid3hctx_t_last_win_count);
-       quarter_rtts /= hctx->ccid3hctx_rtt / 4;
+       u32 delta = ktime_us_delta(now, hctx->ccid3hctx_t_last_win_count),
+           quarter_rtts = (4 * delta) / hctx->ccid3hctx_rtt;
 
        if (quarter_rtts > 0) {
                hctx->ccid3hctx_t_last_win_count = now;
-               hctx->ccid3hctx_last_win_count  += min_t(u32, quarter_rtts, 5);
+               hctx->ccid3hctx_last_win_count  += min(quarter_rtts, 5U);
                hctx->ccid3hctx_last_win_count  &= 0xF;         /* mod 16 */
        }
 }
@@ -334,8 +329,14 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb)
                        hctx->ccid3hctx_x    = rfc3390_initial_rate(sk);
                        hctx->ccid3hctx_t_ld = now;
                } else {
-                       /* Sender does not have RTT sample: X_pps = 1 pkt/sec */
-                       hctx->ccid3hctx_x = hctx->ccid3hctx_s;
+                       /*
+                        * Sender does not have RTT sample:
+                        * - set fallback RTT (RFC 4340, 3.4) since a RTT value
+                        *   is needed in several parts (e.g.  window counter);
+                        * - set sending rate X_pps = 1pps as per RFC 3448, 4.2.
+                        */
+                       hctx->ccid3hctx_rtt = DCCP_FALLBACK_RTT;
+                       hctx->ccid3hctx_x   = hctx->ccid3hctx_s;
                        hctx->ccid3hctx_x <<= 6;
                }
                ccid3_update_send_interval(hctx);
@@ -793,7 +794,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
 {
        struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
        enum ccid3_fback_type do_feedback = CCID3_FBACK_NONE;
-       const u32 ndp = dccp_sk(sk)->dccps_options_received.dccpor_ndp;
+       const u64 ndp = dccp_sk(sk)->dccps_options_received.dccpor_ndp;
        const bool is_data_packet = dccp_data_packet(skb);
 
        if (unlikely(hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA)) {
@@ -824,18 +825,16 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
        }
 
        /*
-        * Handle pending losses and otherwise check for new loss
+        * Perform loss detection and handle pending losses
         */
-       if (tfrc_rx_hist_loss_pending(&hcrx->ccid3hcrx_hist) &&
-           tfrc_rx_handle_loss(&hcrx->ccid3hcrx_hist,
-                               &hcrx->ccid3hcrx_li_hist,
-                               skb, ndp, ccid3_first_li, sk) ) {
+       if (tfrc_rx_handle_loss(&hcrx->ccid3hcrx_hist, &hcrx->ccid3hcrx_li_hist,
+                               skb, ndp, ccid3_first_li, sk)) {
                do_feedback = CCID3_FBACK_PARAM_CHANGE;
                goto done_receiving;
        }
 
-       if (tfrc_rx_hist_new_loss_indicated(&hcrx->ccid3hcrx_hist, skb, ndp))
-               goto update_records;
+       if (tfrc_rx_hist_loss_pending(&hcrx->ccid3hcrx_hist))
+               return; /* done receiving */
 
        /*
         * Handle data packets: RTT sampling and monitoring p
@@ -964,7 +963,7 @@ static struct ccid_operations ccid3 = {
 };
 
 #ifdef CONFIG_IP_DCCP_CCID3_DEBUG
-module_param(ccid3_debug, bool, 0444);
+module_param(ccid3_debug, bool, 0644);
 MODULE_PARM_DESC(ccid3_debug, "Enable debug messages");
 #endif