diff options
Diffstat (limited to 'net/dccp/ccids/lib/loss_interval.c')
-rw-r--r-- | net/dccp/ccids/lib/loss_interval.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/net/dccp/ccids/lib/loss_interval.c b/net/dccp/ccids/lib/loss_interval.c index 5b3ce0688c5c..b1ae8f8259e5 100644 --- a/net/dccp/ccids/lib/loss_interval.c +++ b/net/dccp/ccids/lib/loss_interval.c | |||
@@ -86,21 +86,26 @@ static void tfrc_lh_calc_i_mean(struct tfrc_loss_hist *lh) | |||
86 | 86 | ||
87 | /** | 87 | /** |
88 | * tfrc_lh_update_i_mean - Update the `open' loss interval I_0 | 88 | * tfrc_lh_update_i_mean - Update the `open' loss interval I_0 |
89 | * For recomputing p: returns `true' if p > p_prev <=> 1/p < 1/p_prev | 89 | * This updates I_mean as the sequence numbers increase. As a consequence, the |
90 | * open loss interval I_0 increases, hence p = W_tot/max(I_tot0, I_tot1) | ||
91 | * decreases, and thus there is no need to send renewed feedback. | ||
90 | */ | 92 | */ |
91 | u8 tfrc_lh_update_i_mean(struct tfrc_loss_hist *lh, struct sk_buff *skb) | 93 | void tfrc_lh_update_i_mean(struct tfrc_loss_hist *lh, struct sk_buff *skb) |
92 | { | 94 | { |
93 | struct tfrc_loss_interval *cur = tfrc_lh_peek(lh); | 95 | struct tfrc_loss_interval *cur = tfrc_lh_peek(lh); |
94 | u32 old_i_mean = lh->i_mean; | ||
95 | s64 len; | 96 | s64 len; |
96 | 97 | ||
97 | if (cur == NULL) /* not initialised */ | 98 | if (cur == NULL) /* not initialised */ |
98 | return 0; | 99 | return; |
100 | |||
101 | /* FIXME: should probably also count non-data packets (RFC 4342, 6.1) */ | ||
102 | if (!dccp_data_packet(skb)) | ||
103 | return; | ||
99 | 104 | ||
100 | len = dccp_delta_seqno(cur->li_seqno, DCCP_SKB_CB(skb)->dccpd_seq) + 1; | 105 | len = dccp_delta_seqno(cur->li_seqno, DCCP_SKB_CB(skb)->dccpd_seq) + 1; |
101 | 106 | ||
102 | if (len - (s64)cur->li_length <= 0) /* duplicate or reordered */ | 107 | if (len - (s64)cur->li_length <= 0) /* duplicate or reordered */ |
103 | return 0; | 108 | return; |
104 | 109 | ||
105 | if (SUB16(dccp_hdr(skb)->dccph_ccval, cur->li_ccval) > 4) | 110 | if (SUB16(dccp_hdr(skb)->dccph_ccval, cur->li_ccval) > 4) |
106 | /* | 111 | /* |
@@ -114,14 +119,11 @@ u8 tfrc_lh_update_i_mean(struct tfrc_loss_hist *lh, struct sk_buff *skb) | |||
114 | cur->li_is_closed = 1; | 119 | cur->li_is_closed = 1; |
115 | 120 | ||
116 | if (tfrc_lh_length(lh) == 1) /* due to RFC 3448, 6.3.1 */ | 121 | if (tfrc_lh_length(lh) == 1) /* due to RFC 3448, 6.3.1 */ |
117 | return 0; | 122 | return; |
118 | 123 | ||
119 | cur->li_length = len; | 124 | cur->li_length = len; |
120 | tfrc_lh_calc_i_mean(lh); | 125 | tfrc_lh_calc_i_mean(lh); |
121 | |||
122 | return (lh->i_mean < old_i_mean); | ||
123 | } | 126 | } |
124 | EXPORT_SYMBOL_GPL(tfrc_lh_update_i_mean); | ||
125 | 127 | ||
126 | /* Determine if `new_loss' does begin a new loss interval [RFC 4342, 10.2] */ | 128 | /* Determine if `new_loss' does begin a new loss interval [RFC 4342, 10.2] */ |
127 | static inline u8 tfrc_lh_is_new_loss(struct tfrc_loss_interval *cur, | 129 | static inline u8 tfrc_lh_is_new_loss(struct tfrc_loss_interval *cur, |
@@ -138,18 +140,18 @@ static inline u8 tfrc_lh_is_new_loss(struct tfrc_loss_interval *cur, | |||
138 | * @sk: Used by @calc_first_li in caller-specific way (subtyping) | 140 | * @sk: Used by @calc_first_li in caller-specific way (subtyping) |
139 | * Updates I_mean and returns 1 if a new interval has in fact been added to @lh. | 141 | * Updates I_mean and returns 1 if a new interval has in fact been added to @lh. |
140 | */ | 142 | */ |
141 | int tfrc_lh_interval_add(struct tfrc_loss_hist *lh, struct tfrc_rx_hist *rh, | 143 | bool tfrc_lh_interval_add(struct tfrc_loss_hist *lh, struct tfrc_rx_hist *rh, |
142 | u32 (*calc_first_li)(struct sock *), struct sock *sk) | 144 | u32 (*calc_first_li)(struct sock *), struct sock *sk) |
143 | { | 145 | { |
144 | struct tfrc_loss_interval *cur = tfrc_lh_peek(lh), *new; | 146 | struct tfrc_loss_interval *cur = tfrc_lh_peek(lh), *new; |
145 | 147 | ||
146 | if (cur != NULL && !tfrc_lh_is_new_loss(cur, tfrc_rx_hist_loss_prev(rh))) | 148 | if (cur != NULL && !tfrc_lh_is_new_loss(cur, tfrc_rx_hist_loss_prev(rh))) |
147 | return 0; | 149 | return false; |
148 | 150 | ||
149 | new = tfrc_lh_demand_next(lh); | 151 | new = tfrc_lh_demand_next(lh); |
150 | if (unlikely(new == NULL)) { | 152 | if (unlikely(new == NULL)) { |
151 | DCCP_CRIT("Cannot allocate/add loss record."); | 153 | DCCP_CRIT("Cannot allocate/add loss record."); |
152 | return 0; | 154 | return false; |
153 | } | 155 | } |
154 | 156 | ||
155 | new->li_seqno = tfrc_rx_hist_loss_prev(rh)->tfrchrx_seqno; | 157 | new->li_seqno = tfrc_rx_hist_loss_prev(rh)->tfrchrx_seqno; |
@@ -167,7 +169,7 @@ int tfrc_lh_interval_add(struct tfrc_loss_hist *lh, struct tfrc_rx_hist *rh, | |||
167 | 169 | ||
168 | tfrc_lh_calc_i_mean(lh); | 170 | tfrc_lh_calc_i_mean(lh); |
169 | } | 171 | } |
170 | return 1; | 172 | return true; |
171 | } | 173 | } |
172 | EXPORT_SYMBOL_GPL(tfrc_lh_interval_add); | 174 | EXPORT_SYMBOL_GPL(tfrc_lh_interval_add); |
173 | 175 | ||