linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / net / dccp / ccids / lib / loss_interval.c
index 906c81a..4c01a54 100644 (file)
@@ -2,7 +2,7 @@
  *  net/dccp/ccids/lib/loss_interval.c
  *
  *  Copyright (c) 2005 The University of Waikato, Hamilton, New Zealand.
- *  Copyright (c) 2005-6 Ian McDonald <ian.mcdonald@jandi.co.nz>
+ *  Copyright (c) 2005 Ian McDonald <iam4@cs.waikato.ac.nz>
  *  Copyright (c) 2005 Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -11,8 +11,8 @@
  *  (at your option) any later version.
  */
 
+#include <linux/config.h>
 #include <linux/module.h>
-#include <net/sock.h>
 
 #include "loss_interval.h"
 
@@ -91,13 +91,13 @@ u32 dccp_li_hist_calc_i_mean(struct list_head *list)
        u32 w_tot  = 0;
 
        list_for_each_entry_safe(li_entry, li_next, list, dccplih_node) {
-               if (li_entry->dccplih_interval != ~0) {
+               if (i < DCCP_LI_HIST_IVAL_F_LENGTH) {
                        i_tot0 += li_entry->dccplih_interval * dccp_li_hist_w[i];
                        w_tot  += dccp_li_hist_w[i];
-                       if (i != 0)
-                               i_tot1 += li_entry->dccplih_interval * dccp_li_hist_w[i - 1];
                }
 
+               if (i != 0)
+                       i_tot1 += li_entry->dccplih_interval * dccp_li_hist_w[i - 1];
 
                if (++i > DCCP_LI_HIST_IVAL_F_LENGTH)
                        break;
@@ -108,36 +108,37 @@ u32 dccp_li_hist_calc_i_mean(struct list_head *list)
 
        i_tot = max(i_tot0, i_tot1);
 
-       if (!w_tot) {
-               LIMIT_NETDEBUG(KERN_WARNING "%s: w_tot = 0\n", __FUNCTION__);
-               return 1;
-       }
+       /* FIXME: Why do we do this? -Ian McDonald */
+       if (i_tot * 4 < w_tot)
+               i_tot = w_tot * 4;
 
-       return i_tot / w_tot;
+       return i_tot * 4 / w_tot;
 }
 
 EXPORT_SYMBOL_GPL(dccp_li_hist_calc_i_mean);
 
-int dccp_li_hist_interval_new(struct dccp_li_hist *hist,
-   struct list_head *list, const u64 seq_loss, const u8 win_loss)
+struct dccp_li_hist_entry *dccp_li_hist_interval_new(struct dccp_li_hist *hist,
+                                                    struct list_head *list,
+                                                    const u64 seq_loss,
+                                                    const u8 win_loss)
 {
-       struct dccp_li_hist_entry *entry;
+       struct dccp_li_hist_entry *tail = NULL, *entry;
        int i;
 
-       for (i = 0; i < DCCP_LI_HIST_IVAL_F_LENGTH; i++) {
+       for (i = 0; i <= DCCP_LI_HIST_IVAL_F_LENGTH; ++i) {
                entry = dccp_li_hist_entry_new(hist, SLAB_ATOMIC);
                if (entry == NULL) {
                        dccp_li_hist_purge(hist, list);
-                       dump_stack();
-                       return 0;
+                       return NULL;
                }
-               entry->dccplih_interval = ~0;
+               if (tail == NULL)
+                       tail = entry;
                list_add(&entry->dccplih_node, list);
        }
 
        entry->dccplih_seqno     = seq_loss;
        entry->dccplih_win_count = win_loss;
-       return 1;
+       return tail;
 }
 
 EXPORT_SYMBOL_GPL(dccp_li_hist_interval_new);