Lines Matching refs:h
110 void tfrc_rx_hist_add_packet(struct tfrc_rx_hist *h, in tfrc_rx_hist_add_packet() argument
114 struct tfrc_rx_hist_entry *entry = tfrc_rx_hist_last_rcv(h); in tfrc_rx_hist_add_packet()
120 int tfrc_rx_hist_duplicate(struct tfrc_rx_hist *h, struct sk_buff *skb) in tfrc_rx_hist_duplicate() argument
125 if (dccp_delta_seqno(tfrc_rx_hist_loss_prev(h)->tfrchrx_seqno, seq) <= 0) in tfrc_rx_hist_duplicate()
128 for (i = 1; i <= h->loss_count; i++) in tfrc_rx_hist_duplicate()
129 if (tfrc_rx_hist_entry(h, i)->tfrchrx_seqno == seq) in tfrc_rx_hist_duplicate()
135 static void tfrc_rx_hist_swap(struct tfrc_rx_hist *h, const u8 a, const u8 b) in tfrc_rx_hist_swap() argument
137 const u8 idx_a = tfrc_rx_hist_index(h, a), in tfrc_rx_hist_swap()
138 idx_b = tfrc_rx_hist_index(h, b); in tfrc_rx_hist_swap()
140 swap(h->ring[idx_a], h->ring[idx_b]); in tfrc_rx_hist_swap()
152 static void __do_track_loss(struct tfrc_rx_hist *h, struct sk_buff *skb, u64 n1) in __do_track_loss() argument
154 u64 s0 = tfrc_rx_hist_loss_prev(h)->tfrchrx_seqno, in __do_track_loss()
158 h->loss_count = 1; in __do_track_loss()
159 tfrc_rx_hist_entry_from_skb(tfrc_rx_hist_entry(h, 1), skb, n1); in __do_track_loss()
163 static void __one_after_loss(struct tfrc_rx_hist *h, struct sk_buff *skb, u32 n2) in __one_after_loss() argument
165 u64 s0 = tfrc_rx_hist_loss_prev(h)->tfrchrx_seqno, in __one_after_loss()
166 s1 = tfrc_rx_hist_entry(h, 1)->tfrchrx_seqno, in __one_after_loss()
170 h->loss_count = 2; in __one_after_loss()
171 tfrc_rx_hist_entry_from_skb(tfrc_rx_hist_entry(h, 2), skb, n2); in __one_after_loss()
178 u64 n1 = tfrc_rx_hist_entry(h, 1)->tfrchrx_ndp; in __one_after_loss()
182 h->loss_count = 0; in __one_after_loss()
183 h->loss_start = tfrc_rx_hist_index(h, 1); in __one_after_loss()
186 tfrc_rx_hist_entry_from_skb(tfrc_rx_hist_loss_prev(h), skb, n2); in __one_after_loss()
192 tfrc_rx_hist_swap(h, 0, 3); in __one_after_loss()
193 h->loss_start = tfrc_rx_hist_index(h, 3); in __one_after_loss()
194 tfrc_rx_hist_entry_from_skb(tfrc_rx_hist_entry(h, 1), skb, n2); in __one_after_loss()
195 h->loss_count = 2; in __one_after_loss()
200 static int __two_after_loss(struct tfrc_rx_hist *h, struct sk_buff *skb, u32 n3) in __two_after_loss() argument
202 u64 s0 = tfrc_rx_hist_loss_prev(h)->tfrchrx_seqno, in __two_after_loss()
203 s1 = tfrc_rx_hist_entry(h, 1)->tfrchrx_seqno, in __two_after_loss()
204 s2 = tfrc_rx_hist_entry(h, 2)->tfrchrx_seqno, in __two_after_loss()
208 h->loss_count = 3; in __two_after_loss()
209 tfrc_rx_hist_entry_from_skb(tfrc_rx_hist_entry(h, 3), skb, n3); in __two_after_loss()
219 tfrc_rx_hist_swap(h, 2, 3); in __two_after_loss()
220 tfrc_rx_hist_entry_from_skb(tfrc_rx_hist_entry(h, 2), skb, n3); in __two_after_loss()
221 h->loss_count = 3; in __two_after_loss()
228 u64 n1 = tfrc_rx_hist_entry(h, 1)->tfrchrx_ndp; in __two_after_loss()
232 u64 n2 = tfrc_rx_hist_entry(h, 2)->tfrchrx_ndp; in __two_after_loss()
236 h->loss_start = tfrc_rx_hist_index(h, 2); in __two_after_loss()
237 h->loss_count = 0; in __two_after_loss()
240 h->loss_start = tfrc_rx_hist_index(h, 1); in __two_after_loss()
241 h->loss_count = 1; in __two_after_loss()
245 tfrc_rx_hist_entry_from_skb(tfrc_rx_hist_loss_prev(h), skb, n3); in __two_after_loss()
254 tfrc_rx_hist_swap(h, 0, 3); in __two_after_loss()
255 h->loss_start = tfrc_rx_hist_index(h, 3); in __two_after_loss()
256 tfrc_rx_hist_entry_from_skb(tfrc_rx_hist_entry(h, 1), skb, n3); in __two_after_loss()
257 h->loss_count = 3; in __two_after_loss()
263 static void __three_after_loss(struct tfrc_rx_hist *h) in __three_after_loss() argument
271 u64 s1 = tfrc_rx_hist_entry(h, 1)->tfrchrx_seqno, in __three_after_loss()
272 s2 = tfrc_rx_hist_entry(h, 2)->tfrchrx_seqno, in __three_after_loss()
273 s3 = tfrc_rx_hist_entry(h, 3)->tfrchrx_seqno; in __three_after_loss()
274 u64 n2 = tfrc_rx_hist_entry(h, 2)->tfrchrx_ndp, in __three_after_loss()
275 n3 = tfrc_rx_hist_entry(h, 3)->tfrchrx_ndp; in __three_after_loss()
281 h->loss_start = tfrc_rx_hist_index(h, 3); in __three_after_loss()
282 h->loss_count = 0; in __three_after_loss()
285 h->loss_start = tfrc_rx_hist_index(h, 2); in __three_after_loss()
286 h->loss_count = 1; in __three_after_loss()
290 h->loss_start = tfrc_rx_hist_index(h, 1); in __three_after_loss()
291 h->loss_count = 2; in __three_after_loss()
311 int tfrc_rx_handle_loss(struct tfrc_rx_hist *h, in tfrc_rx_handle_loss() argument
318 if (h->loss_count == 0) { in tfrc_rx_handle_loss()
319 __do_track_loss(h, skb, ndp); in tfrc_rx_handle_loss()
320 } else if (h->loss_count == 1) { in tfrc_rx_handle_loss()
321 __one_after_loss(h, skb, ndp); in tfrc_rx_handle_loss()
322 } else if (h->loss_count != 2) { in tfrc_rx_handle_loss()
323 DCCP_BUG("invalid loss_count %d", h->loss_count); in tfrc_rx_handle_loss()
324 } else if (__two_after_loss(h, skb, ndp)) { in tfrc_rx_handle_loss()
328 is_new_loss = tfrc_lh_interval_add(lh, h, calc_first_li, sk); in tfrc_rx_handle_loss()
329 __three_after_loss(h); in tfrc_rx_handle_loss()
334 int tfrc_rx_hist_alloc(struct tfrc_rx_hist *h) in tfrc_rx_hist_alloc() argument
339 h->ring[i] = kmem_cache_alloc(tfrc_rx_hist_slab, GFP_ATOMIC); in tfrc_rx_hist_alloc()
340 if (h->ring[i] == NULL) in tfrc_rx_hist_alloc()
344 h->loss_count = h->loss_start = 0; in tfrc_rx_hist_alloc()
349 kmem_cache_free(tfrc_rx_hist_slab, h->ring[i]); in tfrc_rx_hist_alloc()
350 h->ring[i] = NULL; in tfrc_rx_hist_alloc()
355 void tfrc_rx_hist_purge(struct tfrc_rx_hist *h) in tfrc_rx_hist_purge() argument
360 if (h->ring[i] != NULL) { in tfrc_rx_hist_purge()
361 kmem_cache_free(tfrc_rx_hist_slab, h->ring[i]); in tfrc_rx_hist_purge()
362 h->ring[i] = NULL; in tfrc_rx_hist_purge()
371 tfrc_rx_hist_rtt_last_s(const struct tfrc_rx_hist *h) in tfrc_rx_hist_rtt_last_s() argument
373 return h->ring[0]; in tfrc_rx_hist_rtt_last_s()
381 tfrc_rx_hist_rtt_prev_s(const struct tfrc_rx_hist *h) in tfrc_rx_hist_rtt_prev_s() argument
383 return h->ring[h->rtt_sample_prev]; in tfrc_rx_hist_rtt_prev_s()
394 u32 tfrc_rx_hist_sample_rtt(struct tfrc_rx_hist *h, const struct sk_buff *skb) in tfrc_rx_hist_sample_rtt() argument
398 tfrc_rx_hist_rtt_last_s(h)->tfrchrx_ccval); in tfrc_rx_hist_sample_rtt()
401 if (h->rtt_sample_prev == 2) { /* previous candidate stored */ in tfrc_rx_hist_sample_rtt()
402 sample = SUB16(tfrc_rx_hist_rtt_prev_s(h)->tfrchrx_ccval, in tfrc_rx_hist_sample_rtt()
403 tfrc_rx_hist_rtt_last_s(h)->tfrchrx_ccval); in tfrc_rx_hist_sample_rtt()
406 ktime_us_delta(tfrc_rx_hist_rtt_prev_s(h)->tfrchrx_tstamp, in tfrc_rx_hist_sample_rtt()
407 tfrc_rx_hist_rtt_last_s(h)->tfrchrx_tstamp); in tfrc_rx_hist_sample_rtt()
416 tfrc_rx_hist_rtt_prev_s(h)->tfrchrx_ccval, in tfrc_rx_hist_sample_rtt()
417 tfrc_rx_hist_rtt_last_s(h)->tfrchrx_ccval); in tfrc_rx_hist_sample_rtt()
419 h->rtt_sample_prev = 1; in tfrc_rx_hist_sample_rtt()
424 sample = ktime_to_us(net_timedelta(tfrc_rx_hist_rtt_last_s(h)->tfrchrx_tstamp)); in tfrc_rx_hist_sample_rtt()
426 h->rtt_sample_prev = 2; in tfrc_rx_hist_sample_rtt()
435 h->rtt_sample_prev = 0; /* use current entry as next reference */ in tfrc_rx_hist_sample_rtt()