diff options
Diffstat (limited to 'net/dccp/ccids/lib/loss_interval.c')
| -rw-r--r-- | net/dccp/ccids/lib/loss_interval.c | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/net/dccp/ccids/lib/loss_interval.c b/net/dccp/ccids/lib/loss_interval.c index 4c01a54143ad..906c81ab9d4f 100644 --- a/net/dccp/ccids/lib/loss_interval.c +++ b/net/dccp/ccids/lib/loss_interval.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | * net/dccp/ccids/lib/loss_interval.c | 2 | * net/dccp/ccids/lib/loss_interval.c |
| 3 | * | 3 | * |
| 4 | * Copyright (c) 2005 The University of Waikato, Hamilton, New Zealand. | 4 | * Copyright (c) 2005 The University of Waikato, Hamilton, New Zealand. |
| 5 | * Copyright (c) 2005 Ian McDonald <iam4@cs.waikato.ac.nz> | 5 | * Copyright (c) 2005-6 Ian McDonald <ian.mcdonald@jandi.co.nz> |
| 6 | * Copyright (c) 2005 Arnaldo Carvalho de Melo <acme@conectiva.com.br> | 6 | * Copyright (c) 2005 Arnaldo Carvalho de Melo <acme@conectiva.com.br> |
| 7 | * | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify | 8 | * This program is free software; you can redistribute it and/or modify |
| @@ -11,8 +11,8 @@ | |||
| 11 | * (at your option) any later version. | 11 | * (at your option) any later version. |
| 12 | */ | 12 | */ |
| 13 | 13 | ||
| 14 | #include <linux/config.h> | ||
| 15 | #include <linux/module.h> | 14 | #include <linux/module.h> |
| 15 | #include <net/sock.h> | ||
| 16 | 16 | ||
| 17 | #include "loss_interval.h" | 17 | #include "loss_interval.h" |
| 18 | 18 | ||
| @@ -91,13 +91,13 @@ u32 dccp_li_hist_calc_i_mean(struct list_head *list) | |||
| 91 | u32 w_tot = 0; | 91 | u32 w_tot = 0; |
| 92 | 92 | ||
| 93 | list_for_each_entry_safe(li_entry, li_next, list, dccplih_node) { | 93 | list_for_each_entry_safe(li_entry, li_next, list, dccplih_node) { |
| 94 | if (i < DCCP_LI_HIST_IVAL_F_LENGTH) { | 94 | if (li_entry->dccplih_interval != ~0) { |
| 95 | i_tot0 += li_entry->dccplih_interval * dccp_li_hist_w[i]; | 95 | i_tot0 += li_entry->dccplih_interval * dccp_li_hist_w[i]; |
| 96 | w_tot += dccp_li_hist_w[i]; | 96 | w_tot += dccp_li_hist_w[i]; |
| 97 | if (i != 0) | ||
| 98 | i_tot1 += li_entry->dccplih_interval * dccp_li_hist_w[i - 1]; | ||
| 97 | } | 99 | } |
| 98 | 100 | ||
| 99 | if (i != 0) | ||
| 100 | i_tot1 += li_entry->dccplih_interval * dccp_li_hist_w[i - 1]; | ||
| 101 | 101 | ||
| 102 | if (++i > DCCP_LI_HIST_IVAL_F_LENGTH) | 102 | if (++i > DCCP_LI_HIST_IVAL_F_LENGTH) |
| 103 | break; | 103 | break; |
| @@ -108,37 +108,36 @@ u32 dccp_li_hist_calc_i_mean(struct list_head *list) | |||
| 108 | 108 | ||
| 109 | i_tot = max(i_tot0, i_tot1); | 109 | i_tot = max(i_tot0, i_tot1); |
| 110 | 110 | ||
| 111 | /* FIXME: Why do we do this? -Ian McDonald */ | 111 | if (!w_tot) { |
| 112 | if (i_tot * 4 < w_tot) | 112 | LIMIT_NETDEBUG(KERN_WARNING "%s: w_tot = 0\n", __FUNCTION__); |
| 113 | i_tot = w_tot * 4; | 113 | return 1; |
| 114 | } | ||
| 114 | 115 | ||
| 115 | return i_tot * 4 / w_tot; | 116 | return i_tot / w_tot; |
| 116 | } | 117 | } |
| 117 | 118 | ||
| 118 | EXPORT_SYMBOL_GPL(dccp_li_hist_calc_i_mean); | 119 | EXPORT_SYMBOL_GPL(dccp_li_hist_calc_i_mean); |
| 119 | 120 | ||
| 120 | struct dccp_li_hist_entry *dccp_li_hist_interval_new(struct dccp_li_hist *hist, | 121 | int dccp_li_hist_interval_new(struct dccp_li_hist *hist, |
| 121 | struct list_head *list, | 122 | struct list_head *list, const u64 seq_loss, const u8 win_loss) |
| 122 | const u64 seq_loss, | ||
| 123 | const u8 win_loss) | ||
| 124 | { | 123 | { |
| 125 | struct dccp_li_hist_entry *tail = NULL, *entry; | 124 | struct dccp_li_hist_entry *entry; |
| 126 | int i; | 125 | int i; |
| 127 | 126 | ||
| 128 | for (i = 0; i <= DCCP_LI_HIST_IVAL_F_LENGTH; ++i) { | 127 | for (i = 0; i < DCCP_LI_HIST_IVAL_F_LENGTH; i++) { |
| 129 | entry = dccp_li_hist_entry_new(hist, SLAB_ATOMIC); | 128 | entry = dccp_li_hist_entry_new(hist, SLAB_ATOMIC); |
| 130 | if (entry == NULL) { | 129 | if (entry == NULL) { |
| 131 | dccp_li_hist_purge(hist, list); | 130 | dccp_li_hist_purge(hist, list); |
| 132 | return NULL; | 131 | dump_stack(); |
| 132 | return 0; | ||
| 133 | } | 133 | } |
| 134 | if (tail == NULL) | 134 | entry->dccplih_interval = ~0; |
| 135 | tail = entry; | ||
| 136 | list_add(&entry->dccplih_node, list); | 135 | list_add(&entry->dccplih_node, list); |
| 137 | } | 136 | } |
| 138 | 137 | ||
| 139 | entry->dccplih_seqno = seq_loss; | 138 | entry->dccplih_seqno = seq_loss; |
| 140 | entry->dccplih_win_count = win_loss; | 139 | entry->dccplih_win_count = win_loss; |
| 141 | return tail; | 140 | return 1; |
| 142 | } | 141 | } |
| 143 | 142 | ||
| 144 | EXPORT_SYMBOL_GPL(dccp_li_hist_interval_new); | 143 | EXPORT_SYMBOL_GPL(dccp_li_hist_interval_new); |
